Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kArray2.h
Go to the documentation of this file.
1
10 #ifndef K_API_ARRAY_2_H
11 #define K_API_ARRAY_2_H
12
13 #include <kApi/kApiDef.h>
14 #include <kApi/Data/kArray2.x.h>
15
34 //typedef kObject kArray2; --forward-declared in kApiDef.x.h
35
47 kFx(kStatus) kArray2_Construct(kArray2* array, kType itemType, kSize length0, kSize length1, kAlloc allocator);
48
59 kFx(kStatus) kArray2_Allocate(kArray2 array, kType itemType, kSize length0, kSize length1);
60
73 kInlineFx(kStatus) kArray2_Resize(kArray2 array, kSize length0, kSize length1)
74 {
75 return kArray2_Allocate(array, kArray2_ItemType(array), length0, length1);
76 }
77
91 kFx(kStatus) kArray2_Attach(kArray2 array, void* items, kType itemType, kSize length0, kSize length1);
92
109 #define kArray2_AttachT(kArray2_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1) \
110 xkArray2_AttachT(kArray2_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1, sizeof(*TPtr_items))
111
123 kFx(kStatus) kArray2_Assign(kArray2 array, kArray2 source);
124
132 kFx(kStatus) kArray2_Zero(kArray2 array);
133
144 kFx(kStatus) kArray2_SetItem(kArray2 array, kSize index0, kSize index1, const void* item);
145
159 #define kArray2_SetItemT(kArray2_array, kSize_index0, kSize_index1, TPtr_item) \
160 xkArray2_SetItemT(kArray2_array, kSize_index0, kSize_index1, TPtr_item, sizeof(*TPtr_item))
161
172 kFx(kStatus) kArray2_Item(kArray2 array, kSize index0, kSize index1, void* item);
173
187 #define kArray2_ItemT(kArray2_array, kSize_index0, kSize_index1, TPtr_item) \
188 xkArray2_ItemT(kArray2_array, kSize_index0, kSize_index1, TPtr_item, sizeof(*TPtr_item))
189
204 #define kArray2_SetAsT(kArray2_array, kSize_index0, kSize_index1, T_value, T) \
205 (kPointer_WriteAs(xkArray2_AsT(kArray2_array, kSize_index0, kSize_index1, sizeof(T)), T_value, T), (void)0)
206
221 #define kArray2_AsT(kArray2_array, kSize_index0, kSize_index1, T) \
222 kPointer_ReadAs(xkArray2_AsT(kArray2_array, kSize_index0, kSize_index1, sizeof(T)), T)
223
231 kInlineFx(void*) kArray2_Data(kArray2 array)
232 {
233 kObj(kArray2, array);
234
235 return obj->items;
236 }
237
249 #define kArray2_DataT(kArray2_array, T) \
250 kCast(T*, xkArray2_DataT(kArray2_array, sizeof(T)))
251
263 kInlineFx(void*) kArray2_DataAt(kArray2 array, kSSize index0, kSSize index1)
264 {
265 kObj(kArray2, array);
266 kSSize index = index0*(kSSize)obj->length[1] + index1;
267
268 return kPointer_ItemOffset(obj->items, index, obj->itemSize);
269 }
270
286 #define kArray2_DataAtT(kArray2_array, kSSize_index0, kSSize_index1, T) \
287 kCast(T*, xkArray2_DataAtT(kArray2_array, kSSize_index0, kSSize_index1, sizeof(T)))
288
296 kInlineFx(kSize) kArray2_DataSize(kArray2 array)
297 {
298 kObj(kArray2, array);
299
300 return kArray2_Count(array) * obj->itemSize;
301 }
302
315 kInlineFx(void*) kArray2_At(kArray2 array, kSize index0, kSize index1)
316 {
317 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
318 {
319 kAssert(index0 < kArray2_Length(array, 0));
320 kAssert(index1 < kArray2_Length(array, 1));
321 }
322 # endif
323
324 return kArray2_DataAt(array, (kSSize)index0, (kSSize)index1);
325 }
326
341 #define kArray2_AtT(kArray2_array, kSize_index0, kSize_index1, T) \
342 kCast(T*, xkArray2_AtT(kArray2_array, kSize_index0, kSize_index1, sizeof(T)))
343
351 kInlineFx(kType) kArray2_ItemType(kArray2 array)
352 {
353 kObj(kArray2, array);
354
355 return obj->itemType;
356 }
357
365 kInlineFx(kSize) kArray2_ItemSize(kArray2 array)
366 {
367 kObj(kArray2, array);
368
369 return obj->itemSize;
370 }
371
380 kInlineFx(kSize) kArray2_Length(kArray2 array, kSize dimension)
381 {
382 kObj(kArray2, array);
383
384 kAssert(dimension < 2);
385
386 return obj->length[dimension];
387 }
388
396 kInlineFx(kSize) kArray2_Count(kArray2 array)
397 {
398 kObj(kArray2, array);
399
400 return obj->length[0] * obj->length[1];
401 }
402
403 #endif
kArray2::kArray2_Allocate
kStatus kArray2_Allocate(kArray2 array, kType itemType, kSize length0, kSize length1)
Reallocates the internal array item buffer.
kArray2::kArray2_DataSize
kSize kArray2_DataSize(kArray2 array)
Reports the size, in bytes, of the array item buffer.
Definition: kArray2.h:296
kArray2::kArray2_Resize
kStatus kArray2_Resize(kArray2 array, kSize length0, kSize length1)
Resizes the internal array item buffer.
Definition: kArray2.h:73
kArray2::kArray2_DataAt
void * kArray2_DataAt(kArray2 array, kSSize index0, kSSize index1)
Calculates an address relative to the start of the buffer.
Definition: kArray2.h:263
kArray2::kArray2_Construct
kStatus kArray2_Construct(kArray2 *array, kType itemType, kSize length0, kSize length1, kAlloc allocator)
Constructs a kArray2 object.
kArray2::kArray2_Count
kSize kArray2_Count(kArray2 array)
Returns the array item count, in elements.
Definition: kArray2.h:396
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
kArray2
Represents a 2D array.
kInlineFx
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
kArray2::kArray2_At
void * kArray2_At(kArray2 array, kSize index0, kSize index1)
Returns a pointer to the specified item in the array.
Definition: kArray2.h:315
kSSize
Represents a signed integer that can store a pointer address.
kArray2::kArray2_SetItem
kStatus kArray2_SetItem(kArray2 array, kSize index0, kSize index1, const void *item)
Sets the value of an item.
kArray2::kArray2_Length
kSize kArray2_Length(kArray2 array, kSize dimension)
Returns the length of the specified array dimension, in elements.
Definition: kArray2.h:380
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
kArray2::kArray2_Zero
kStatus kArray2_Zero(kArray2 array)
Sets all array element bits to zero.
kArray2::kArray2_ItemSize
kSize kArray2_ItemSize(kArray2 array)
Returns the array item size.
Definition: kArray2.h:365
kApiDef.h
Core Zen type declarations.
kType
Represents metadata about a type (class, interface, or value).
kArray2::kArray2_Data
void * kArray2_Data(kArray2 array)
Returns a pointer to the array item buffer.
Definition: kArray2.h:231
kArray2::kArray2_Assign
kStatus kArray2_Assign(kArray2 array, kArray2 source)
Performs a shallow copy of the source array.
kAssert
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:749
kStatus
Represents an error code.
kArray2::kArray2_Item
kStatus kArray2_Item(kArray2 array, kSize index0, kSize index1, void *item)
Gets the value of an item.
kArray2::kArray2_Attach
kStatus kArray2_Attach(kArray2 array, void *items, kType itemType, kSize length0, kSize length1)
Attaches the array to an external item buffer.
kArray2::kArray2_ItemType
kType kArray2_ItemType(kArray2 array)
Returns the array item type.
Definition: kArray2.h:351