Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kArray1.h
Go to the documentation of this file.
1
10 #ifndef K_API_ARRAY_1_H
11 #define K_API_ARRAY_1_H
12
13 #include <kApi/kApiDef.h>
14 #include <kApi/Data/kArray1.x.h>
15
34 //typedef kObject kArray1; --forward-declared in kApiDef.x.h
35
46 kFx(kStatus) kArray1_Construct(kArray1* array, kType itemType, kSize length, kAlloc allocator);
47
57 kFx(kStatus) kArray1_Allocate(kArray1 array, kType itemType, kSize length);
58
67 kInlineFx(kStatus) kArray1_Resize(kArray1 array, kSize length)
68 {
69 return kArray1_Allocate(array, kArray1_ItemType(array), length);
70 }
71
84 kFx(kStatus) kArray1_Attach(kArray1 array, void* items, kType itemType, kSize length);
85
101 #define kArray1_AttachT(kArray1_array, TPtr_items, kType_itemType, kSize_length) \
102 xkArray1_AttachT(kArray1_array, TPtr_items, kType_itemType, kSize_length, sizeof(*TPtr_items))
103
115 kFx(kStatus) kArray1_Assign(kArray1 array, kArray1 source);
116
124 kFx(kStatus) kArray1_Zero(kArray1 array);
125
135 kFx(kStatus) kArray1_SetItem(kArray1 array, kSize index, const void* item);
136
149 #define kArray1_SetItemT(kArray1_array, kSize_index, TPtr_item) \
150 xkArray1_SetItemT(kArray1_array, kSize_index, TPtr_item, sizeof(*TPtr_item))
151
161 kFx(kStatus) kArray1_Item(kArray1 array, kSize index, void* item);
162
175 #define kArray1_ItemT(kArray1_array, kSize_index, TPtr_item) \
176 xkArray1_ItemT(kArray1_array, kSize_index, TPtr_item, sizeof(*TPtr_item))
177
191 #define kArray1_SetAsT(kArray1_array, kSize_index, T_value, T) \
192 (kPointer_WriteAs(xkArray1_AsT(kArray1_array, kSize_index, sizeof(T)), T_value, T), (void)0)
193
207 #define kArray1_AsT(kArray1_array, kSize_index, T) \
208 kPointer_ReadAs(xkArray1_AsT(kArray1_array, kSize_index, sizeof(T)), T)
209
217 kInlineFx(void*) kArray1_Data(kArray1 array)
218 {
219 kObj(kArray1, array);
220
221 return obj->items;
222 }
223
235 #define kArray1_DataT(kArray1_array, T) \
236 kCast(T*, xkArray1_DataT(kArray1_array, sizeof(T)))
237
248 kInlineFx(void*) kArray1_DataAt(kArray1 array, kSSize index)
249 {
250 kObj(kArray1, array);
251
252 return kPointer_ItemOffset(obj->items, index, obj->itemSize);
253 }
254
269 #define kArray1_DataAtT(kArray1_array, kSSize_index, T) \
270 kCast(T*, xkArray1_DataAtT(kArray1_array, kSSize_index, sizeof(T)))
271
279 kInlineFx(kSize) kArray1_DataSize(kArray1 array)
280 {
281 kObj(kArray1, array);
282
283 return obj->length * obj->itemSize;
284 }
285
297 kInlineFx(void*) kArray1_At(kArray1 array, kSize index)
298 {
299 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
300 {
301 kAssert(index < kArray1_Length(array));
302 }
303 # endif
304
305 return kArray1_DataAt(array, index);
306 }
307
321 #define kArray1_AtT(kArray1_array, kSize_index, T) \
322 kCast(T*, xkArray1_AtT(kArray1_array, kSize_index, sizeof(T)))
323
331 kInlineFx(kType) kArray1_ItemType(kArray1 array)
332 {
333 kObj(kArray1, array);
334
335 return obj->itemType;
336 }
337
345 kInlineFx(kSize) kArray1_ItemSize(kArray1 array)
346 {
347 kObj(kArray1, array);
348
349 return obj->itemSize;
350 }
351
359 kInlineFx(kSize) kArray1_Length(kArray1 array)
360 {
361 kObj(kArray1, array);
362
363 return obj->length;
364 }
365
376 kInlineFx(kSize) kArray1_Count(kArray1 array)
377 {
378 kObj(kArray1, array);
379
380 return obj->length;
381 }
382
383 #endif
kArray1
Represents a 1D array.
kArray1::kArray1_Zero
kStatus kArray1_Zero(kArray1 array)
Sets all array element bits to zero.
kArray1::kArray1_ItemType
kType kArray1_ItemType(kArray1 array)
Returns the array item type.
Definition: kArray1.h:331
kSize
Represents an unsigned integer that can store a pointer address.
kArray1::kArray1_Allocate
kStatus kArray1_Allocate(kArray1 array, kType itemType, kSize length)
Reallocates the internal array item buffer.
kAlloc
Abstract base class for memory allocator types.
kArray1::kArray1_Data
void * kArray1_Data(kArray1 array)
Returns a pointer to the array item buffer.
Definition: kArray1.h:217
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
kArray1::kArray1_DataAt
void * kArray1_DataAt(kArray1 array, kSSize index)
Calculates an address relative to the start of the buffer.
Definition: kArray1.h:248
kSSize
Represents a signed integer that can store a pointer address.
kArray1::kArray1_ItemSize
kSize kArray1_ItemSize(kArray1 array)
Returns the array item size.
Definition: kArray1.h:345
kArray1::kArray1_At
void * kArray1_At(kArray1 array, kSize index)
Returns a pointer to the specified item in the array.
Definition: kArray1.h:297
kArray1::kArray1_Construct
kStatus kArray1_Construct(kArray1 *array, kType itemType, kSize length, kAlloc allocator)
Constructs a kArray1 object.
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
kApiDef.h
Core Zen type declarations.
kArray1::kArray1_Item
kStatus kArray1_Item(kArray1 array, kSize index, void *item)
Gets the value of an item.
kType
Represents metadata about a type (class, interface, or value).
kArray1::kArray1_DataSize
kSize kArray1_DataSize(kArray1 array)
Reports the size, in bytes, of the array item buffer.
Definition: kArray1.h:279
kArray1::kArray1_Resize
kStatus kArray1_Resize(kArray1 array, kSize length)
Resizes the internal array item buffer.
Definition: kArray1.h:67
kAssert
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:749
kArray1::kArray1_Count
kSize kArray1_Count(kArray1 array)
Returns the array item count, in elements.
Definition: kArray1.h:376
kStatus
Represents an error code.
kArray1::kArray1_SetItem
kStatus kArray1_SetItem(kArray1 array, kSize index, const void *item)
Sets the value of an item.
kArray1::kArray1_Assign
kStatus kArray1_Assign(kArray1 array, kArray1 source)
Performs a shallow copy of the source array.
kArray1::kArray1_Attach
kStatus kArray1_Attach(kArray1 array, void *items, kType itemType, kSize length)
Attaches the array to an external item buffer.
kArray1::kArray1_Length
kSize kArray1_Length(kArray1 array)
Returns the array length, in elements.
Definition: kArray1.h:359