Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kArray3.h
Go to the documentation of this file.
1
10 #ifndef K_API_ARRAY_3_H
11 #define K_API_ARRAY_3_H
12
13 #include <kApi/kApiDef.h>
14 #include <kApi/Data/kArray3.x.h>
15
34 //typedef kObject kArray3; --forward-declared in kApiDef.x.h
35
48 kFx(kStatus) kArray3_Construct(kArray3* array, kType itemType, kSize length0, kSize length1, kSize length2, kAlloc allocator);
49
61 kFx(kStatus) kArray3_Allocate(kArray3 array, kType itemType, kSize length0, kSize length1, kSize length2);
62
76 kInlineFx(kStatus) kArray3_Resize(kArray3 array, kSize length0, kSize length1, kSize length2)
77 {
78 return kArray3_Allocate(array, kArray3_ItemType(array), length0, length1, length2);
79 }
80
95 kFx(kStatus) kArray3_Attach(kArray3 array, void* items, kType itemType, kSize length0, kSize length1, kSize length2);
96
114 #define kArray3_AttachT(kArray3_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1, kSize_length2) \
115 xkArray3_AttachT(kArray3_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1, kSize_length2, sizeof(*TPtr_items))
116
128 kFx(kStatus) kArray3_Assign(kArray3 array, kArray3 source);
129
137 kFx(kStatus) kArray3_Zero(kArray3 array);
138
150 kFx(kStatus) kArray3_SetItem(kArray3 array, kSize index0, kSize index1, kSize index2, const void* item);
151
166 #define kArray3_SetItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item) \
167 xkArray3_SetItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item, sizeof(*TPtr_item))
168
180 kFx(kStatus) kArray3_Item(kArray3 array, kSize index0, kSize index1, kSize index2, void* item);
181
196 #define kArray3_ItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item) \
197 xkArray3_ItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item, sizeof(*TPtr_item))
198
199
216 #define kArray3_SetAsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T_value, T) \
217 (kPointer_WriteAs(xkArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)), T_value, T), (void)0)
218
234 #define kArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
235 kPointer_ReadAs(xkArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)), T)
236
244 kInlineFx(void*) kArray3_Data(kArray3 array)
245 {
246 kObj(kArray3, array);
247
248 return obj->items;
249 }
250
262 #define kArray3_DataT(kArray3_array, T) \
263 kCast(T*, xkArray3_DataT(kArray3_array, sizeof(T)))
264
277 kInlineFx(void*) kArray3_DataAt(kArray3 array, kSSize index0, kSSize index1, kSSize index2)
278 {
279 kObj(kArray3, array);
280 kSSize index = (index0*(kSSize)obj->length[1] + index1)*(kSSize)obj->length[2] + index2;
281
282 return kPointer_ItemOffset(obj->items, index, obj->itemSize);
283 }
284
301 #define kArray3_DataAtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
302 kCast(T*, xkArray3_DataAtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)))
303
311 kInlineFx(kSize) kArray3_DataSize(kArray3 array)
312 {
313 kObj(kArray3, array);
314
315 return kArray3_Count(array) * obj->itemSize;
316 }
317
331 kInlineFx(void*) kArray3_At(kArray3 array, kSize index0, kSize index1, kSize index2)
332 {
333 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
334 {
335 kAssert(index0 < kArray3_Length(array, 0));
336 kAssert(index1 < kArray3_Length(array, 1));
337 kAssert(index2 < kArray3_Length(array, 2));
338 }
339 # endif
340
341 return kArray3_DataAt(array, (kSSize)index0, (kSSize)index1, (kSSize)index2);
342 }
343
359 #define kArray3_AtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
360 kCast(T*, xkArray3_AtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)))
361
369 kInlineFx(kType) kArray3_ItemType(kArray3 array)
370 {
371 kObj(kArray3, array);
372
373 return obj->itemType;
374 }
375
383 kInlineFx(kSize) kArray3_ItemSize(kArray3 array)
384 {
385 kObj(kArray3, array);
386
387 return obj->itemSize;
388 }
389
398 kInlineFx(kSize) kArray3_Length(kArray3 array, kSize dimension)
399 {
400 kObj(kArray3, array);
401
402 kAssert(dimension < 3);
403
404 return obj->length[dimension];
405 }
406
414 kInlineFx(kSize) kArray3_Count(kArray3 array)
415 {
416 kObj(kArray3, array);
417
418 return obj->length[0] * obj->length[1] * obj->length[2];
419 }
420
421 #endif
kArray3::kArray3_At
void * kArray3_At(kArray3 array, kSize index0, kSize index1, kSize index2)
Returns a pointer to the specified item in the array.
Definition: kArray3.h:331
kArray3::kArray3_Attach
kStatus kArray3_Attach(kArray3 array, void *items, kType itemType, kSize length0, kSize length1, kSize length2)
Attaches the array to an external item buffer.
kArray3::kArray3_DataAt
void * kArray3_DataAt(kArray3 array, kSSize index0, kSSize index1, kSSize index2)
Calculates an address relative to the start of the buffer.
Definition: kArray3.h:277
kArray3::kArray3_ItemType
kType kArray3_ItemType(kArray3 array)
Returns the array item type.
Definition: kArray3.h:369
kArray3::kArray3_Resize
kStatus kArray3_Resize(kArray3 array, kSize length0, kSize length1, kSize length2)
Resizes the internal array item buffer.
Definition: kArray3.h:76
kSize
Represents an unsigned integer that can store a pointer address.
kAlloc
Abstract base class for memory allocator types.
kPointer::kPointer_ItemOffset
void * kPointer_ItemOffset(const void *pointer, kSSize itemIndex, kSize itemSize)
Gets a pointer to the Nth element of an array.
Definition: kApiDef.h:292
kInlineFx
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
kArray3::kArray3_Construct
kStatus kArray3_Construct(kArray3 *array, kType itemType, kSize length0, kSize length1, kSize length2, kAlloc allocator)
Constructs a kArray3 object.
kArray3::kArray3_ItemSize
kSize kArray3_ItemSize(kArray3 array)
Returns the array item size.
Definition: kArray3.h:383
kSSize
Represents a signed integer that can store a pointer address.
kArray3::kArray3_Item
kStatus kArray3_Item(kArray3 array, kSize index0, kSize index1, kSize index2, void *item)
Gets the value of an item.
kArray3::kArray3_Zero
kStatus kArray3_Zero(kArray3 array)
Sets all array element bits to zero.
kObj
#define kObj(TypeName_T, T_object)
Declares a local "obj" (this-pointer) variable and initializes it from a type-checked object handle...
Definition: kApiDef.h:2892
kArray3
Represents a 3D array.
kArray3::kArray3_Allocate
kStatus kArray3_Allocate(kArray3 array, kType itemType, kSize length0, kSize length1, kSize length2)
Reallocates the internal array item buffer.
kApiDef.h
Core Zen type declarations.
kArray3::kArray3_Data
void * kArray3_Data(kArray3 array)
Returns a pointer to the array item buffer.
Definition: kArray3.h:244
kArray3::kArray3_Length
kSize kArray3_Length(kArray3 array, kSize dimension)
Returns the length of the specified array dimension, in elements.
Definition: kArray3.h:398
kType
Represents metadata about a type (class, interface, or value).
kArray3::kArray3_Count
kSize kArray3_Count(kArray3 array)
Returns the array item count, in elements.
Definition: kArray3.h:414
kArray3::kArray3_Assign
kStatus kArray3_Assign(kArray3 array, kArray3 source)
Performs a shallow copy of the source array.
kArray3::kArray3_DataSize
kSize kArray3_DataSize(kArray3 array)
Reports the size, in bytes, of the array item buffer.
Definition: kArray3.h:311
kAssert
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:749
kStatus
Represents an error code.
kArray3::kArray3_SetItem
kStatus kArray3_SetItem(kArray3 array, kSize index0, kSize index1, kSize index2, const void *item)
Sets the value of an item.