dynamiC
0.1
|
Dynamic data types as part of the SelectScript-VM implementation. More...
#include <stdlib.h>
#include "dynamic_types.h"
#include "dynamic_defines.h"
#include "dynamic_string.h"
#include "dynamic_encoding.h"
Go to the source code of this file.
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) |
#define | DYN_SET_LIST(dyn) dyn_set_list_len(dyn, LIST_DEFAULT) |
Initialize dyn as list with default length. | |
#define | DYN_LIST_LEN(dyn) (dyn)->data.list->length |
Return list length. | |
#define | DYN_LIST_GET_REF(dyn, i) &(dyn)->data.list->container[i] |
Return the reference to the ith element within a dynamic list. | |
#define | DYN_LIST_GET_END(dyn) &(dyn)->data.list->container[DYN_LIST_LEN(dyn)-1] |
Return the reference to the last element within a list. | |
#define | DYN_LIST_GET_REF_END(dyn, i) &(dyn)->data.list->container[DYN_LIST_LEN(dyn)-i] |
Return the reference to the ith element starting from the last. | |
#define | DYN_DICT_LEN(dyn) dyn->data.dict->value.data.list->length |
Return number of elements within a dictionary. | |
#define | DYN_DICT_GET_I_REF(dyn, i) &(dyn)->data.dict->value.data.list->container[i] |
Return a reference to the ith element stored within a dictionary. | |
#define | DYN_DICT_GET_I_KEY(dyn, i) (dyn)->data.dict->key[i] |
Return a reference to the ith key stored within a dictionary. | |
#define | DYN_DICT_SPACE(dyn) dyn->value.data.list->space |
Return the maximal usable number of elements of a dictionary. | |
#define | DYN_DICT_LENGTH(dyn) dyn->value.data.list->length |
Return the number of elements stored within a dictionary. | |
#define | DYN_FCT_C 0 |
#define | DYN_FCT_SYS 1 |
#define | DYN_FCT_PROC 2 |
#define | DYN_FCT_GET_CODE(dyn) dyn->data.fct->ptr |
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. | |
trilean | dyn_set_list_len (dyn_c *dyn, dyn_ushort len) |
Set dynamic element to list with maximal length. More... | |
dyn_c * | dyn_list_push (dyn_c *list, const dyn_c *element) |
Push new element to the end of a list. More... | |
dyn_c * | dyn_list_push_none (dyn_c *list) |
Push NONE element to the end of a list. More... | |
trilean | dyn_list_pop (dyn_c *list, dyn_c *element) |
Pop the last element from the list and move it to param element. More... | |
trilean | dyn_list_get (const dyn_c *list, dyn_c *element, const dyn_short i) |
Copy the ith element of a list to param element. More... | |
dyn_c * | dyn_list_get_ref (const dyn_c *list, const dyn_short i) |
Return a reference to the ith element within list, negative values are allowed. More... | |
trilean | dyn_list_popi (dyn_c *list, const dyn_short i) |
Pop i elements from the end of a list. More... | |
void | dyn_list_free (dyn_c *list) |
Free the allocated memory of the entire list and set it to NONE. More... | |
trilean | dyn_list_copy (const dyn_c *list, dyn_c *copy) |
Make a deep copy of the entire list. More... | |
trilean | dyn_list_remove (dyn_c *list, dyn_ushort i) |
Delete the ith element from a list. More... | |
trilean | dyn_list_insert (dyn_c *list, dyn_c *element, const dyn_ushort i) |
Insert a new element at the ith position into a list. More... | |
trilean | dyn_list_resize (dyn_c *list, const dyn_ushort size) |
Change the maximal space of a list. More... | |
dyn_ushort | dyn_list_string_len (const dyn_c *list) |
Return the length of the string representation of a list. More... | |
void | dyn_list_string_add (const dyn_c *list, dyn_str str) |
Add string representation of a list to str. More... | |
trilean | dyn_set_set_len (dyn_c *set, const dyn_ushort len) |
Initialize dynamic element as empty set with maximal length. More... | |
trilean | dyn_set_insert (dyn_c *set, dyn_c *element) |
Insert new element into set, if and only if it is not included yet. More... | |
trilean | dyn_set_dict (dyn_c *dyn, const dyn_ushort length) |
Set dyn to a dictionary with a max. length of elements. More... | |
trilean | dyn_dict_change (dyn_c *dict, const dyn_ushort i, const dyn_c *value) |
Replace the ith element in a dictionary with a new value. | |
dyn_c * | dyn_dict_insert (dyn_c *dict, dyn_const_str key, dyn_c *value) |
Insert a new key-value pair into the dictionary. More... | |
trilean | dyn_dict_remove (dyn_c *dict, dyn_const_str key) |
Remove key-value pair from dictionary. More... | |
dyn_c * | dyn_dict_get (const dyn_c *dict, dyn_const_str key) |
Get the reference to value stored at key. More... | |
trilean | dyn_dict_resize (dyn_c *dict, const dyn_ushort size) |
Set the available space for elements. More... | |
dyn_c * | dyn_dict_get_i_ref (const dyn_c *dict, const dyn_ushort i) |
Get the reference to ith value in dict. More... | |
dyn_str | dyn_dict_get_i_key (const dyn_c *dict, const dyn_ushort i) |
Get the reference to ith key in dict. More... | |
dyn_ushort | dyn_dict_has_key (const dyn_c *dict, dyn_const_str key) |
Check if dict has key and return its position - 1 (returns 0 if not found) More... | |
void | dyn_dict_empty (dyn_c *dict) |
todo More... | |
void | dyn_dict_free (dyn_c *dict) |
Free all allocated memory. More... | |
trilean | dyn_dict_copy (const dyn_c *dict, dyn_c *copy) |
Copy the entire dict. | |
dyn_ushort | dyn_dict_string_len (const dyn_c *dict) |
Calculate the required string length. | |
void | dyn_dict_string_add (const dyn_c *dict, dyn_str string) |
Add the dict-string representation to string. | |
trilean | dyn_set_fct (dyn_c *dyn, void *ptr, const dyn_ushort type, dyn_const_str info) |
void | dyn_fct_free (dyn_c *dyn) |
trilean | dyn_fct_copy (const dyn_c *dyn, dyn_c *copy) |
trilean | dyn_op_neg (dyn_c *dyn) |
Negate dynamic value in param dyn. More... | |
trilean | dyn_op_add (dyn_c *dyn1, dyn_c *dyn2) |
Add dyn2 to dyn1. More... | |
trilean | dyn_op_sub (dyn_c *dyn1, dyn_c *dyn2) |
Subtract dyn2 from dyn1. More... | |
trilean | dyn_op_mul (dyn_c *dyn1, dyn_c *dyn2) |
Multiply dyn1 with dyn2. More... | |
trilean | dyn_op_div (dyn_c *dyn1, dyn_c *dyn2) |
Divide dyn1 by dyn2. More... | |
trilean | dyn_op_mod (dyn_c *dyn1, dyn_c *dyn2) |
dyn1 Modulo dyn2 More... | |
trilean | dyn_op_pow (dyn_c *dyn1, dyn_c *dyn2) |
dyn1 to the power of dyn2 More... | |
trilean | dyn_op_and (dyn_c *dyn1, dyn_c *dyn2) |
Logical (trinary) AND operation. More... | |
trilean | dyn_op_or (dyn_c *dyn1, dyn_c *dyn2) |
Logical (trinary) OR operation. More... | |
trilean | dyn_op_xor (dyn_c *dyn1, dyn_c *dyn2) |
Logical (trinary) XOR operation. More... | |
trilean | dyn_op_not (dyn_c *dyn) |
Logical (trinary) Negation. More... | |
trilean | dyn_op_id (dyn_c *dyn1, dyn_c *dyn2) |
Type and Value Equality. More... | |
trilean | dyn_op_eq (dyn_c *dyn1, dyn_c *dyn2) |
Relational Equality. More... | |
trilean | dyn_op_ne (dyn_c *dyn1, dyn_c *dyn2) |
Relational Not Equal. More... | |
trilean | dyn_op_lt (dyn_c *dyn1, dyn_c *dyn2) |
Relational Less Than. More... | |
trilean | dyn_op_le (dyn_c *dyn1, dyn_c *dyn2) |
Relational Less Than or Equal. More... | |
trilean | dyn_op_gt (dyn_c *dyn1, dyn_c *dyn2) |
Relational Greater Than. More... | |
trilean | dyn_op_ge (dyn_c *dyn1, dyn_c *dyn2) |
Relational Greater Than or Equal. More... | |
trilean | dyn_op_in (dyn_c *element, dyn_c *container) |
Check if dyn2 is element of dyn1. More... | |
trilean | dyn_op_b_not (dyn_c *dyn) |
Binary complement. | |
trilean | dyn_op_b_and (dyn_c *dyn1, dyn_c *dyn2) |
Binary AND. | |
trilean | dyn_op_b_or (dyn_c *dyn1, dyn_c *dyn2) |
Binary OR. | |
trilean | dyn_op_b_xor (dyn_c *dyn1, dyn_c *dyn2) |
Binary XOR. | |
trilean | dyn_op_b_shift_l (dyn_c *dyn1, dyn_c *dyn2) |
Binary shift left. | |
trilean | dyn_op_b_shift_r (dyn_c *dyn1, dyn_c *dyn2) |
Binary shift right. | |
Dynamic data types as part of the SelectScript-VM implementation.
Definition in file dynamic.h.