Zen API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kBox.h
Go to the documentation of this file.
1 
10 #ifndef K_API_BOX_H
11 #define K_API_BOX_H
12 
13 #include <kApi/kApiDef.h>
14 #include <kApi/Data/kBox.x.h>
15 
30 //typedef kObject kBox; --forward-declared in kApiDef.x.h
31 
41 kFx(kStatus) kBox_Construct(kBox* box, kType itemType, kAlloc allocator);
42 
51 kFx(kStatus) kBox_Allocate(kBox box, kType itemType);
52 
61 kFx(kStatus) kBox_Assign(kBox box, kBox source);
62 
70 kFx(kStatus) kBox_Zero(kBox box);
71 
80 kFx(kStatus) kBox_SetItem(kBox box, const void* item);
81 
93 #define kBox_SetItemT(kBox_box, TPtr_item) \
94  xkBox_SetItemT(kBox_box, TPtr_item, sizeof(*(TPtr_item)))
95 
104 kFx(kStatus) kBox_Item(kBox box, void* item);
105 
117 #define kBox_SetAsT(kBox_box, T_value, T) \
118  (kPointer_WriteAs(xkBox_AsT(kBox_box, sizeof(T)), T_value, T), (void)0)
119 
130 #define kBox_AsT(kBox_box, T) \
131  kPointer_ReadAs(xkBox_AsT(kBox_box, sizeof(T)), T)
132 
144 #define kBox_ItemT(kBox_box, TPtr_item) \
145  xkBox_ItemT(kBox_box, TPtr_item, sizeof(*(TPtr_item)))
146 
155 {
156  kObj(kBox, box);
157 
158  return obj->item;
159 }
160 
172 #define kBox_DataT(kBox_box, T) \
173  kCast(T*, xkBox_DataT(kBox_box, sizeof(T)))
174 
183 {
184  kObj(kBox, box);
185 
186  return obj->itemType;
187 }
188 
197 {
198  kObj(kBox, box);
199 
200  return obj->itemSize;
201 }
202 
203 #endif
kStatus kBox_Construct(kBox *box, kType itemType, kAlloc allocator)
Constructs a kBox object.
Represents an unsigned integer that can store a pointer address.
Abstract base class for memory allocator types.
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
kStatus kBox_Assign(kBox box, kBox source)
Copies the value contained within the source box into this box.
#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:3383
kType kBox_ItemType(kBox box)
Returns the box item type.
Definition: kBox.h:182
Core Zen type declarations.
kStatus kBox_Zero(kBox box)
Sets all box element bits to zero.
Represents an instance of a value type as an object.
void * kBox_Data(kBox box)
Returns a pointer to the box item buffer.
Definition: kBox.h:154
Represents metadata about a type (class, interface, or value).
Represents an error code.
kStatus kBox_SetItem(kBox box, const void *item)
Sets the box value.
kSize kBox_ItemSize(kBox box)
Returns the box item size.
Definition: kBox.h:196
kStatus kBox_Allocate(kBox box, kType itemType)
Reallocates the internal box item buffer.
kStatus kBox_Item(kBox box, void *item)
Gets the box value.