dynamiC
0.1
|
Dynamic type system for C with support for None, Boolean, Integer, Float, List, Sets, Dictionaries and others ...
https://andre-dietrich.github.io/dynamiC/
https://github.com/andre-dietrich/dynamiC
You can either generate a libdynC
with make lib
for dynamically linking or simply include this repository into your project and include it into your Makefile.
It is possible to define various basic data types as listed below:
List have to be initialized with a default buffer length, this buffer is automatically increased of decreased as the list grows or shrinks:
Any element can be coppied with the following function, previously allocated memory get cleaned up and new one gets created:
Any type of dynamically allocated memory can be freed with one function, the resulting elements are reset to type NONE:
Further structures are sets and dictionaries, as for lists, memory is automatically increased or decreased:
Operations are the commonly used +, -, *, /, <, ==,... bitshift ...
among others. All of them are defined within dynamic_op.h with the naming convention dyn_op_operator
with (operator == add, sub, le, eq, not, pow, ...)
. Their implementation mimics the common Python operators and the result of an operation is stored within the first function parameter, which gets rewritten:
Depending on the used datatypes, different behavior is exposed for some operations, the highest datatype defines the result type, to which the other parameter is casted, see the enumeration in dynamic_types.h.
Furhtermore, and unlike in Python, the order of parameters results in different results:
Boolean operations can also be used for sets:
Otherwise, and as in Python, dynamic elements are cast to boolean values:
Boolean operations perform as usual, except if a value is NONE or associated with... Then a ternary operations gets applied
This behavior is quite usefull, if for example relational operations are applied onto dynamic elements, which cannot be compared, such as:
The result element is of type NONE and can still be used in the further evaluation ...
This project is licensed under the MIT License - see the LICENSE.md file for details
Copyright (C) 2016-2017
André Dietrich dietr ich@ ivs.c s.un i-mag debu rg.de