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
73 kInlineFx(kStatus) kArray3_Resize(kArray3 array, kSize length0, kSize length1, kSize length2)
74 {
75 return kArray3_Allocate(array, kArray3_ItemType(array), length0, length1, length2);
76 }
77
92 kFx(kStatus) kArray3_Attach(kArray3 array, void* items, kType itemType, kSize length0, kSize length1, kSize length2);
93
111 #define kArray3_AttachT(kArray3_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1, kSize_length2) \
112 xkArray3_AttachT(kArray3_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1, kSize_length2, sizeof(*TPtr_items))
113
125 kFx(kStatus) kArray3_Assign(kArray3 array, kArray3 source);
126
134 kFx(kStatus) kArray3_Zero(kArray3 array);
135
147 kFx(kStatus) kArray3_SetItem(kArray3 array, kSize index0, kSize index1, kSize index2, const void* item);
148
163 #define kArray3_SetItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item) \
164 xkArray3_SetItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item, sizeof(*TPtr_item))
165
177 kFx(kStatus) kArray3_Item(kArray3 array, kSize index0, kSize index1, kSize index2, void* item);
178
193 #define kArray3_ItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item) \
194 xkArray3_ItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item, sizeof(*TPtr_item))
195
196
213 #define kArray3_SetAsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T_value, T) \
214 (kPointer_WriteAs(xkArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)), T_value, T), (void)0)
215
231 #define kArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
232 kPointer_ReadAs(xkArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)), T)
233
241 kInlineFx(void*) kArray3_Data(kArray3 array)
242 {
243 kObj(kArray3, array);
244
245 return obj->items;
246 }
247
259 #define kArray3_DataT(kArray3_array, T) \
260 kCast(T*, xkArray3_DataT(kArray3_array, sizeof(T)))
261
274 kInlineFx(void*) kArray3_DataAt(kArray3 array, kSSize index0, kSSize index1, kSize index2)
275 {
276 kObj(kArray3, array);
277 kSSize index = (index0*(kSSize)obj->length[1] + index1)*(kSSize)obj->length[2] + index2;
278
279 return kPointer_ItemOffset(obj->items, index, obj->itemSize);
280 }
281
298 #define kArray3_DataAtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
299 kCast(T*, xkArray3_DataAtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)))
300
308 kInlineFx(kSize) kArray3_DataSize(kArray3 array)
309 {
310 kObj(kArray3, array);
311
312 return kArray3_Count(array) * obj->itemSize;
313 }
314
328 kInlineFx(void*) kArray3_At(kArray3 array, kSize index0, kSize index1, kSize index2)
329 {
330 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
331 {
332 kAssert(index0 < kArray3_Length(array, 0));
333 kAssert(index1 < kArray3_Length(array, 1));
334 kAssert(index2 < kArray3_Length(array, 2));
335 }
336 # endif
337
338 return kArray3_DataAt(array, index0, index1, index2);
339 }
340
356 #define kArray3_AtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
357 kCast(T*, xkArray3_AtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)))
358
366 kInlineFx(kType) kArray3_ItemType(kArray3 array)
367 {
368 kObj(kArray3, array);
369
370 return obj->itemType;
371 }
372
380 kInlineFx(kSize) kArray3_ItemSize(kArray3 array)
381 {
382 kObj(kArray3, array);
383
384 return obj->itemSize;
385 }
386
395 kInlineFx(kSize) kArray3_Length(kArray3 array, kSize dimension)
396 {
397 kObj(kArray3, array);
398
399 kAssert(dimension < 3);
400
401 return obj->length[dimension];
402 }
403
411 kInlineFx(kSize) kArray3_Count(kArray3 array)
412 {
413 kObj(kArray3, array);
414
415 return obj->length[0] * obj->length[1] * obj->length[2];
416 }
417
418 #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:328
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_ItemType
kType kArray3_ItemType(kArray3 array)
Returns the array item type.
Definition: kArray3.h:366
kArray3::kArray3_Resize
kStatus kArray3_Resize(kArray3 array, kSize length0, kSize length1, kSize length2)
Resizes the internal array item buffer.
Definition: kArray3.h:73
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_DataAt
void * kArray3_DataAt(kArray3 array, kSSize index0, kSSize index1, kSize index2)
Calculates an address relative to the start of the buffer.
Definition: kArray3.h:274
kArray3::kArray3_ItemSize
kSize kArray3_ItemSize(kArray3 array)
Returns the array item size.
Definition: kArray3.h:380
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:2858
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:241
kArray3::kArray3_Length
kSize kArray3_Length(kArray3 array, kSize dimension)
Returns the length of the specified array dimension, in elements.
Definition: kArray3.h:395
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:411
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:308
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.