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
61 kFx(kStatus) kArray2_ConstructEx(kArray2* array, kType itemType, kSize length0, kSize length1, kAlloc allocator, kAlloc dataAllocator);
62
73 kFx(kStatus) kArray2_Allocate(kArray2 array, kType itemType, kSize length0, kSize length1);
74
87 kInlineFx(kStatus) kArray2_Resize(kArray2 array, kSize length0, kSize length1)
88 {
89 return kArray2_Allocate(array, kArray2_ItemType(array), length0, length1);
90 }
91
105 kFx(kStatus) kArray2_Attach(kArray2 array, void* items, kType itemType, kSize length0, kSize length1);
106
123 #define kArray2_AttachT(kArray2_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1) \
124 xkArray2_AttachT(kArray2_array, TPtr_items, kType_itemType, kSize_length0, kSize_length1, sizeof(*TPtr_items))
125
137 kFx(kStatus) kArray2_Assign(kArray2 array, kArray2 source);
138
146 kFx(kStatus) kArray2_Zero(kArray2 array);
147
158 kFx(kStatus) kArray2_SetItem(kArray2 array, kSize index0, kSize index1, const void* item);
159
173 #define kArray2_SetItemT(kArray2_array, kSize_index0, kSize_index1, TPtr_item) \
174 xkArray2_SetItemT(kArray2_array, kSize_index0, kSize_index1, TPtr_item, sizeof(*TPtr_item))
175
186 kFx(kStatus) kArray2_Item(kArray2 array, kSize index0, kSize index1, void* item);
187
201 #define kArray2_ItemT(kArray2_array, kSize_index0, kSize_index1, TPtr_item) \
202 xkArray2_ItemT(kArray2_array, kSize_index0, kSize_index1, TPtr_item, sizeof(*TPtr_item))
203
218 #define kArray2_SetAsT(kArray2_array, kSize_index0, kSize_index1, T_value, T) \
219 (kPointer_WriteAs(xkArray2_AsT(kArray2_array, kSize_index0, kSize_index1, sizeof(T)), T_value, T), (void)0)
220
235 #define kArray2_AsT(kArray2_array, kSize_index0, kSize_index1, T) \
236 kPointer_ReadAs(xkArray2_AsT(kArray2_array, kSize_index0, kSize_index1, sizeof(T)), T)
237
245 kInlineFx(void*) kArray2_Data(kArray2 array)
246 {
247 kObj(kArray2, array);
248
249 return obj->items;
250 }
251
263 #define kArray2_DataT(kArray2_array, T) \
264 kCast(T*, xkArray2_DataT(kArray2_array, sizeof(T)))
265
277 kInlineFx(void*) kArray2_DataAt(kArray2 array, kSSize index0, kSSize index1)
278 {
279 kObj(kArray2, array);
280 kSSize index = index0*(kSSize)obj->length[1] + index1;
281
282 return kPointer_ItemOffset(obj->items, index, obj->itemSize);
283 }
284
300 #define kArray2_DataAtT(kArray2_array, kSSize_index0, kSSize_index1, T) \
301 kCast(T*, xkArray2_DataAtT(kArray2_array, kSSize_index0, kSSize_index1, sizeof(T)))
302
310 kInlineFx(kSize) kArray2_DataSize(kArray2 array)
311 {
312 kObj(kArray2, array);
313
314 return kArray2_Count(array) * obj->itemSize;
315 }
316
329 kInlineFx(void*) kArray2_At(kArray2 array, kSize index0, kSize index1)
330 {
331 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
332 {
333 kAssert(index0 < kArray2_Length(array, 0));
334 kAssert(index1 < kArray2_Length(array, 1));
335 }
336 # endif
337
338 return kArray2_DataAt(array, (kSSize)index0, (kSSize)index1);
339 }
340
355 #define kArray2_AtT(kArray2_array, kSize_index0, kSize_index1, T) \
356 kCast(T*, xkArray2_AtT(kArray2_array, kSize_index0, kSize_index1, sizeof(T)))
357
365 kInlineFx(kType) kArray2_ItemType(kArray2 array)
366 {
367 kObj(kArray2, array);
368
369 return obj->itemType;
370 }
371
379 kInlineFx(kSize) kArray2_ItemSize(kArray2 array)
380 {
381 kObj(kArray2, array);
382
383 return obj->itemSize;
384 }
385
394 kInlineFx(kSize) kArray2_Length(kArray2 array, kSize dimension)
395 {
396 kObj(kArray2, array);
397
398 kAssert(dimension < 2);
399
400 return obj->length[dimension];
401 }
402
410 kInlineFx(kSize) kArray2_Count(kArray2 array)
411 {
412 kObj(kArray2, array);
413
414 return obj->length[0] * obj->length[1];
415 }
416
424 kInlineFx(kAlloc) kArray2_DataAlloc(kArray2 array)
425 {
426 kObj(kArray2, array);
427
428 return obj->dataAlloc;
429 }
430
431 #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:310
kArray2::kArray2_Resize
kStatus kArray2_Resize(kArray2 array, kSize length0, kSize length1)
Resizes the internal array item buffer.
Definition: kArray2.h:87
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:277
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:410
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
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:329
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:394
kArray2::kArray2_ConstructEx
kStatus kArray2_ConstructEx(kArray2 *array, kType itemType, kSize length0, kSize length1, kAlloc allocator, kAlloc dataAllocator)
Constructs a kArray2 object using a separate allocator for data array memory.
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
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:379
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:245
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:751
kArray2::kArray2_DataAlloc
kAlloc kArray2_DataAlloc(kArray2 array)
Reports the data allocator that was optionally provided at construction time.
Definition: kArray2.h:424
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:365