fcml
1.2.2
|
API for symbols handling. More...
Go to the source code of this file.
Classes | |
struct | fcml_st_symbol |
Represents one named symbol with associated value. More... | |
Typedefs | |
typedef fcml_ptr | fcml_st_symbol_table |
Type for symbol tables. More... | |
typedef struct fcml_st_symbol | fcml_st_symbol |
Represents one named symbol with associated value. More... | |
Functions | |
LIB_EXPORT fcml_st_symbol *LIB_CALL | fcml_fn_symbol_alloc (const fcml_string symbol, fcml_int64_t value) |
Allocates new symbol on FCML library heap. More... | |
LIB_EXPORT void LIB_CALL | fcml_fn_symbol_free (fcml_st_symbol *symbol) |
Frees symbol allocated by FCML library. More... | |
LIB_EXPORT fcml_st_symbol_table LIB_CALL | fcml_fn_symbol_table_alloc () |
Allocates new symbol table. More... | |
LIB_EXPORT fcml_ceh_error LIB_CALL | fcml_fn_symbol_add_raw (fcml_st_symbol_table symbol_table, const fcml_string symbol, fcml_int64_t value) |
Adds new symbol to the symbol table. More... | |
LIB_EXPORT fcml_ceh_error LIB_CALL | fcml_fn_symbol_add (fcml_st_symbol_table symbol_table, const fcml_st_symbol *symbol) |
Adds existing symbol to the symbol table. More... | |
LIB_EXPORT void LIB_CALL | fcml_fn_symbol_remove (fcml_st_symbol_table symbol_table, const fcml_string symbol) |
Removes the symbol from the symbol table. More... | |
LIB_EXPORT fcml_st_symbol *LIB_CALL | fcml_fn_symbol_get (fcml_st_symbol_table symbol_table, const fcml_string symbol) |
Gets the symbol with the given name from the symbol table. More... | |
LIB_EXPORT void LIB_CALL | fcml_fn_symbol_remove_all (fcml_st_symbol_table symbol_table) |
Removes all symbols from the symbol table. More... | |
LIB_EXPORT void LIB_CALL | fcml_fn_symbol_table_free (fcml_st_symbol_table symbol_table) |
Frees a symbol table. More... | |
API for symbols handling.
Currently used only by parsers.
typedef struct fcml_st_symbol fcml_st_symbol |
Represents one named symbol with associated value.
typedef fcml_ptr fcml_st_symbol_table |
Type for symbol tables.
LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_symbol_add | ( | fcml_st_symbol_table | symbol_table, |
const fcml_st_symbol * | symbol | ||
) |
Adds existing symbol to the symbol table.
Remember that only symbols allocated on FCML heap should be added there. Of course in some cases heaps are shared so it will works without any problems but even if they are you should use fcml_fn_symbol_table_alloc() function to allocate every symbol.
symbol_table | The symbol table where new symbol should be placed. |
symbol | The symbol to be added. |
LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_symbol_add_raw | ( | fcml_st_symbol_table | symbol_table, |
const fcml_string | symbol, | ||
fcml_int64_t | value | ||
) |
Adds new symbol to the symbol table.
This function is more secure than fcml_fn_symbol_add() because it always allocates new symbol instance internally, so you do not have to pay attention not to pass the symbol allocated on the different heap to the symbol table. After the symbol has been properly added you can safely free the name because this function duplicates the name to the symbol needs. Of course the symbol as well as the duplicated name are freed by fcml_fn_symbol_table_free() function. You can also free it on your own if the symbol is not managed by symbol table using fcml_fn_symbol_free() function.
symbol_table | The symbol table. |
symbol | The symbol name. |
value | The symbol value. |
LIB_EXPORT fcml_st_symbol* LIB_CALL fcml_fn_symbol_alloc | ( | const fcml_string | symbol, |
fcml_int64_t | value | ||
) |
Allocates new symbol on FCML library heap.
This function should be always used when symbols are added using fcml_fn_symbol_add() function.
LIB_EXPORT void LIB_CALL fcml_fn_symbol_free | ( | fcml_st_symbol * | symbol | ) |
Frees symbol allocated by FCML library.
symbol | The symbol to be freed. |
LIB_EXPORT fcml_st_symbol* LIB_CALL fcml_fn_symbol_get | ( | fcml_st_symbol_table | symbol_table, |
const fcml_string | symbol | ||
) |
Gets the symbol with the given name from the symbol table.
symbol_table | The symbol table. |
symbol | The name of the symbol to get from the table. |
LIB_EXPORT void LIB_CALL fcml_fn_symbol_remove | ( | fcml_st_symbol_table | symbol_table, |
const fcml_string | symbol | ||
) |
Removes the symbol from the symbol table.
The removed symbol is automatically freed.
symbol_table | The symbol table. |
symbol | The name of the symbol to remove. |
LIB_EXPORT void LIB_CALL fcml_fn_symbol_remove_all | ( | fcml_st_symbol_table | symbol_table | ) |
Removes all symbols from the symbol table.
Removes and frees all symbols from the given symbol table but does not free the symbol table itself.
symbol_table | The symbol table to be cleared. |
LIB_EXPORT fcml_st_symbol_table LIB_CALL fcml_fn_symbol_table_alloc | ( | ) |
Allocates new symbol table.
LIB_EXPORT void LIB_CALL fcml_fn_symbol_table_free | ( | fcml_st_symbol_table | symbol_table | ) |
Frees a symbol table.
Frees all symbols as well as the symbol table itself.
symbol_table | A symbol table to be freed. |