dynamiC
0.1
|
basic functionality for scalar dynamic data types More...
Macros | |
#define | DYN_INIT(dyn) (dyn)->type=NONE |
Mandatory initialization for dynamic elements (NONE) | |
#define | DYN_TYPE(dyn) (dyn)->type |
Return type value of a dynamic element. More... | |
#define | DYN_IS_NONE(dyn) !DYN_TYPE(dyn) |
Check if dynamic element is of type NONE. | |
#define | DYN_NOT_NONE(dyn) DYN_TYPE(dyn) |
Check if dynamic element is not of type NONE. | |
#define | DYN_IS_REFERENCE(dyn) DYN_TYPE(dyn)==REFERENCE || DYN_TYPE(dyn)==REFERENCE2 |
Check if dynamic element is of type REFERENCE. | |
#define | DYN_MOVE(from, to) *to = *from; DYN_INIT(from) |
Functions | |
TYPE | dyn_type (const dyn_c *dyn) |
Return type value of a dynamic element. More... | |
void | dyn_free (dyn_c *dyn) |
free allocated memory More... | |
trilean | dyn_copy (const dyn_c *dyn, dyn_c *copy) |
Deep copy dynamic element. | |
void | dyn_move (dyn_c *from, dyn_c *to) |
Move dynamic element to new reference, from is of type NONE afterwards. | |
dyn_ushort | dyn_length (const dyn_c *dyn) |
Reterns the length of an element. More... | |
dyn_uint | dyn_size (const dyn_c *dyn) |
Return the number of allocated bytes. More... | |
void | dyn_set_none (dyn_c *dyn) |
Set dynamic element to NONE. More... | |
void | dyn_set_bool (dyn_c *dyn, const dyn_char v) |
Set dynamic element to BOOL (DYN_TRUE or DYN_FALSE) More... | |
void | dyn_set_int (dyn_c *dyn, const dyn_int v) |
Set dynamic element to INTEGER. More... | |
void | dyn_set_float (dyn_c *dyn, const dyn_float v) |
Set dynamic element to FLOAT. More... | |
void | dyn_set_extern (dyn_c *dyn, const void *v) |
Set dynamic element to point to an arbitrary value. More... | |
trilean | dyn_set_string (dyn_c *dyn, dyn_const_str v) |
Set dynamic element to STRING. More... | |
void | dyn_set_ref (dyn_c *ref, dyn_c *orig) |
Set dynamic element as reference to another dynamic element. More... | |
trilean | dyn_get_bool (const dyn_c *dyn) |
Return boolean value of an dynamic element. More... | |
trilean | dyn_get_bool_3 (const dyn_c *dyn) |
Returns the trinary truth value (DYN_TRUE|DYN_FALSE|DYN_NONE) of an element. More... | |
dyn_int | dyn_get_int (const dyn_c *dyn) |
Return integer value of a dynamic element. | |
dyn_float | dyn_get_float (const dyn_c *dyn) |
Return float value of a dynamic element. | |
dyn_str | dyn_get_string (const dyn_c *dyn) |
Return string representation value of a dynamic element. | |
const void * | dyn_get_extern (const dyn_c *dyn) |
Return pointer, stored in dyn->data.ex. | |
void | dyn_string_add (const dyn_c *dyn, dyn_str string) |
Add string representation of dynamic element to string. | |
dyn_ushort | dyn_string_len (const dyn_c *dyn) |
Calculate length of string representation of dynamic element. | |
basic functionality for scalar dynamic data types
These functions and macros cover basic scalar data types, their handling, initialization, etc. Every module includes its own functions for memory allocation and freeing, but functions such as dyn_free, dyn_get_string, as well es others provide basic interfaces, which hide the additional and type specific functionality which is required to deal with different dynamic data types.
#define DYN_TYPE | ( | dyn | ) | (dyn)->type |
Return type value of a dynamic element.
Definition at line 40 of file dynamic.h.
Referenced by dyn_free(), dyn_get_bool(), dyn_get_bool_3(), dyn_op_b_not(), dyn_op_id(), dyn_op_in(), dyn_size(), and dyn_type().
void dyn_free | ( | dyn_c * | dyn | ) |
free allocated memory
Frees any kind of dynamic type and convertes it to a NONE element. For the the freeing of different data types the different free functions in the different modules is applied.
[in,out] | dyn | element to free, result is of type NONE |
Definition at line 30 of file dynamic.c.
Referenced by dyn_dict_copy(), dyn_dict_empty(), dyn_dict_free(), dyn_dict_remove(), dyn_list_copy(), dyn_list_free(), dyn_list_get(), dyn_list_popi(), dyn_op_and(), dyn_op_b_not(), dyn_op_gt(), dyn_op_lt(), dyn_op_or(), dyn_op_xor(), dyn_set_bool(), dyn_set_dict(), dyn_set_extern(), dyn_set_float(), dyn_set_int(), dyn_set_list_len(), dyn_set_none(), dyn_set_ref(), and dyn_set_string().
Return boolean value of an dynamic element.
The conversion of dynamic values into boolean truth values is similar to the one in Python. NONE, FUNCTION, etc. elements are also converted into DYN_FALSE in contrast to dyn_get_bool_3, which return DYN_NONE as a third truth value.
dyn | dynamic element to check for boolean truth value |
Definition at line 241 of file dynamic.c.
Referenced by dyn_get_bool_3(), and dyn_set_insert().
Returns the trinary truth value (DYN_TRUE|DYN_FALSE|DYN_NONE) of an element.
Only an element of type NONE results in a return value of DYN_NONE, all other types result in a boolean value, as defined in
[in] | dyn | value to check DYN_TRUE ( 1) DYN_FALSE ( 0) DYN_NONE (-1) |
In case of a NONE value or a FUNCTION the unknown truth value DYN_NONE gets returned otherwise the boolean truth value from dyn_get_bool.
dyn | input dynamic element |
Definition at line 509 of file dynamic_op.c.
Referenced by dyn_op_and(), dyn_op_or(), and dyn_op_xor().
dyn_ushort dyn_length | ( | const dyn_c * | dyn | ) |
Reterns the length of an element.
[in] | dyn | value to check |
Referenced by dyn_dict_string_add(), and dyn_get_bool().
Set dynamic element to BOOL (DYN_TRUE or DYN_FALSE)
[in,out] | dyn | element, which is either DYN_TRUE or DYN_FALSE |
[in] | v | boolean value |
Definition at line 77 of file dynamic.c.
Referenced by dyn_op_and(), dyn_op_eq(), dyn_op_gt(), dyn_op_id(), dyn_op_in(), dyn_op_lt(), dyn_op_ne(), dyn_op_or(), and dyn_op_xor().
void dyn_set_extern | ( | dyn_c * | dyn, |
const void * | v | ||
) |
void dyn_set_none | ( | dyn_c * | dyn | ) |
Set dynamic element as reference to another dynamic element.
This function is used to store a reference to a dynamic element instead of copying it.
[in,out] | ref | element, which is used to reference the original element |
[in] | orig | original dynamic element |
Definition at line 149 of file dynamic.c.
Referenced by dyn_set_insert().
trilean dyn_set_string | ( | dyn_c * | dyn, |
dyn_const_str | v | ||
) |
Set dynamic element to STRING.
An new char array is allocated to store the entire passed string v.
[in,out] | dyn | element, which is set to STRING |
[in] | v | C-string value |
DYN_TRUE | if the memory could allocated |
DYN_FALSE | otherwise |
Definition at line 128 of file dynamic.c.
Referenced by dyn_get_bool().
Return the number of allocated bytes.
This function is intended calculate the size of an dynamic element in bytes.
[in,out] | dyn | element to check |
Definition at line 164 of file dynamic.c.
Referenced by dyn_size().
Return type value of a dynamic element.
It is more appropriate to apply the macro DYN_TYPE instead of calling this function. This function is only applied to offer an interface if a compiled library is used.
dyn | element to check |
Definition at line 56 of file dynamic.c.