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
63 kFx(kStatus) kArray3_ConstructEx(kArray3* array, kType itemType, kSize length0, kSize length1, kSize length2, kAlloc allocator, kAlloc dataAllocator);
64
76 kFx(kStatus) kArray3_Allocate(kArray3 array, kType itemType, kSize length0, kSize length1, kSize length2);
77
91 kInlineFx(kStatus) kArray3_Resize(kArray3 array, kSize length0, kSize length1, kSize length2)
92 {
93 return kArray3_Allocate(array, kArray3_ItemType(array), length0, length1, length2);
94 }
95
110 kFx(kStatus) kArray3_Attach(kArray3 array, void* items, kType itemType, kSize length0, kSize length1, kSize length2);
111
129 #define kArray3_AttachT(kArray3_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1, kSize_length2) \
130 xkArray3_AttachT(kArray3_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1, kSize_length2, sizeof(*TPtr_items))
131
143 kFx(kStatus) kArray3_Assign(kArray3 array, kArray3 source);
144
152 kFx(kStatus) kArray3_Zero(kArray3 array);
153
165 kFx(kStatus) kArray3_SetItem(kArray3 array, kSize index0, kSize index1, kSize index2, const void* item);
166
181 #define kArray3_SetItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item) \
182 xkArray3_SetItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item, sizeof(*TPtr_item))
183
195 kFx(kStatus) kArray3_Item(kArray3 array, kSize index0, kSize index1, kSize index2, void* item);
196
211 #define kArray3_ItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item) \
212 xkArray3_ItemT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, TPtr_item, sizeof(*TPtr_item))
213
214
231 #define kArray3_SetAsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T_value, T) \
232 (kPointer_WriteAs(xkArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)), T_value, T), (void)0)
233
249 #define kArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
250 kPointer_ReadAs(xkArray3_AsT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)), T)
251
259 kInlineFx(void*) kArray3_Data(kArray3 array)
260 {
261 kObj(kArray3, array);
262
263 return obj->items;
264 }
265
277 #define kArray3_DataT(kArray3_array, T) \
278 kCast(T*, xkArray3_DataT(kArray3_array, sizeof(T)))
279
292 kInlineFx(void*) kArray3_DataAt(kArray3 array, kSSize index0, kSSize index1, kSSize index2)
293 {
294 kObj(kArray3, array);
295 kSSize index = (index0*(kSSize)obj->length[1] + index1)*(kSSize)obj->length[2] + index2;
296
297 return kPointer_ItemOffset(obj->items, index, obj->itemSize);
298 }
299
316 #define kArray3_DataAtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
317 kCast(T*, xkArray3_DataAtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)))
318
326 kInlineFx(kSize) kArray3_DataSize(kArray3 array)
327 {
328 kObj(kArray3, array);
329
330 return kArray3_Count(array) * obj->itemSize;
331 }
332
346 kInlineFx(void*) kArray3_At(kArray3 array, kSize index0, kSize index1, kSize index2)
347 {
348 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
349 {
350 kAssert(index0 < kArray3_Length(array, 0));
351 kAssert(index1 < kArray3_Length(array, 1));
352 kAssert(index2 < kArray3_Length(array, 2));
353 }
354 # endif
355
356 return kArray3_DataAt(array, (kSSize)index0, (kSSize)index1, (kSSize)index2);
357 }
358
374 #define kArray3_AtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, T) \
375 kCast(T*, xkArray3_AtT(kArray3_array, kSize_index0, kSize_index1, kSize_index2, sizeof(T)))
376
384 kInlineFx(kType) kArray3_ItemType(kArray3 array)
385 {
386 kObj(kArray3, array);
387
388 return obj->itemType;
389 }
390
398 kInlineFx(kSize) kArray3_ItemSize(kArray3 array)
399 {
400 kObj(kArray3, array);
401
402 return obj->itemSize;
403 }
404
413 kInlineFx(kSize) kArray3_Length(kArray3 array, kSize dimension)
414 {
415 kObj(kArray3, array);
416
417 kAssert(dimension < 3);
418
419 return obj->length[dimension];
420 }
421
429 kInlineFx(kSize) kArray3_Count(kArray3 array)
430 {
431 kObj(kArray3, array);
432
433 return obj->length[0] * obj->length[1] * obj->length[2];
434 }
435
443 kInlineFx(kAlloc) kArray3_DataAlloc(kArray3 array)
444 {
445 kObj(kArray3, array);
446
447 return obj->dataAlloc;
448 }
449
450 #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:346
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:292
kArray3::kArray3_ItemType
kType kArray3_ItemType(kArray3 array)
Returns the array item type.
Definition: kArray3.h:384
kArray3::kArray3_Resize
kStatus kArray3_Resize(kArray3 array, kSize length0, kSize length1, kSize length2)
Resizes the internal array item buffer.
Definition: kArray3.h:91
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:294
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:398
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_DataAlloc
kAlloc kArray3_DataAlloc(kArray3 array)
Reports the data allocator that was optionally provided at construction time.
Definition: kArray3.h:443
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:2923
kArray3
Represents a 3D array.
kArray3::kArray3_ConstructEx
kStatus kArray3_ConstructEx(kArray3 *array, kType itemType, kSize length0, kSize length1, kSize length2, kAlloc allocator, kAlloc dataAllocator)
Constructs a kArray3 object using a separate allocator for data array memory.
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:259
kArray3::kArray3_Length
kSize kArray3_Length(kArray3 array, kSize dimension)
Returns the length of the specified array dimension, in elements.
Definition: kArray3.h:413
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:429
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:326
kAssert
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:751
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.