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
70 kInlineFx(kStatus) kArray1_Resize(kArray1 array, kSize length)
71 {
72 return kArray1_Allocate(array, kArray1_ItemType(array), length);
73 }
74
87 kFx(kStatus) kArray1_Attach(kArray1 array, void* items, kType itemType, kSize length);
88
104 #define kArray1_AttachT(kArray1_array, TPtr_items, kType_itemType, kSize_length) \
105 xkArray1_AttachT(kArray1_array, TPtr_items, kType_itemType, kSize_length, sizeof(*TPtr_items))
106
118 kFx(kStatus) kArray1_Assign(kArray1 array, kArray1 source);
119
127 kFx(kStatus) kArray1_Zero(kArray1 array);
128
138 kFx(kStatus) kArray1_SetItem(kArray1 array, kSize index, const void* item);
139
152 #define kArray1_SetItemT(kArray1_array, kSize_index, TPtr_item) \
153 xkArray1_SetItemT(kArray1_array, kSize_index, TPtr_item, sizeof(*TPtr_item))
154
164 kFx(kStatus) kArray1_Item(kArray1 array, kSize index, void* item);
165
178 #define kArray1_ItemT(kArray1_array, kSize_index, TPtr_item) \
179 xkArray1_ItemT(kArray1_array, kSize_index, TPtr_item, sizeof(*TPtr_item))
180
194 #define kArray1_SetAsT(kArray1_array, kSize_index, T_value, T) \
195 (kPointer_WriteAs(xkArray1_AsT(kArray1_array, kSize_index, sizeof(T)), T_value, T), (void)0)
196
210 #define kArray1_AsT(kArray1_array, kSize_index, T) \
211 kPointer_ReadAs(xkArray1_AsT(kArray1_array, kSize_index, sizeof(T)), T)
212
220 kInlineFx(void*) kArray1_Data(kArray1 array)
221 {
222 kObj(kArray1, array);
223
224 return obj->items;
225 }
226
238 #define kArray1_DataT(kArray1_array, T) \
239 kCast(T*, xkArray1_DataT(kArray1_array, sizeof(T)))
240
251 kInlineFx(void*) kArray1_DataAt(kArray1 array, kSSize index)
252 {
253 kObj(kArray1, array);
254
255 return kPointer_ItemOffset(obj->items, index, obj->itemSize);
256 }
257
272 #define kArray1_DataAtT(kArray1_array, kSSize_index, T) \
273 kCast(T*, xkArray1_DataAtT(kArray1_array, kSSize_index, sizeof(T)))
274
282 kInlineFx(kSize) kArray1_DataSize(kArray1 array)
283 {
284 kObj(kArray1, array);
285
286 return obj->length * obj->itemSize;
287 }
288
300 kInlineFx(void*) kArray1_At(kArray1 array, kSize index)
301 {
302 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
303 {
304 kAssert(index < kArray1_Length(array));
305 }
306 # endif
307
308 return kArray1_DataAt(array, (kSSize)index);
309 }
310
324 #define kArray1_AtT(kArray1_array, kSize_index, T) \
325 kCast(T*, xkArray1_AtT(kArray1_array, kSize_index, sizeof(T)))
326
334 kInlineFx(kType) kArray1_ItemType(kArray1 array)
335 {
336 kObj(kArray1, array);
337
338 return obj->itemType;
339 }
340
348 kInlineFx(kSize) kArray1_ItemSize(kArray1 array)
349 {
350 kObj(kArray1, array);
351
352 return obj->itemSize;
353 }
354
362 kInlineFx(kSize) kArray1_Length(kArray1 array)
363 {
364 kObj(kArray1, array);
365
366 return obj->length;
367 }
368
379 kInlineFx(kSize) kArray1_Count(kArray1 array)
380 {
381 kObj(kArray1, array);
382
383 return obj->length;
384 }
385
386 #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:334
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:220
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:251
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:348
kArray1::kArray1_At
void * kArray1_At(kArray1 array, kSize index)
Returns a pointer to the specified item in the array.
Definition: kArray1.h:300
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:2892
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:282
kArray1::kArray1_Resize
kStatus kArray1_Resize(kArray1 array, kSize length)
Resizes the internal array item buffer.
Definition: kArray1.h:70
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:379
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:362