Add functions for basetypes and their entries in tables.
This commit is contained in:
@@ -61,5 +61,10 @@ typedef struct libab_basetype_s libab_basetype;
|
||||
*/
|
||||
void libab_basetype_init(libab_basetype* basetype, int n,
|
||||
const libab_basetype_param params[]);
|
||||
/**
|
||||
* Frees the given basetype.
|
||||
* @param basetype the type to free.
|
||||
*/
|
||||
void libab_basetype_free(libab_basetype* basetype);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -78,9 +78,17 @@ libab_result libab_register_operator_postfix(libab* ab, const char* op, const ch
|
||||
* @param name the name of the function.
|
||||
* @param type the type of this operator.
|
||||
* @param func the function that describes the functionality of the function.
|
||||
* @return the result of the initialization.
|
||||
* @return the result of the registration.
|
||||
*/
|
||||
libab_result libab_register_function(libab* ab, const char* name, const char* type, libab_function_ptr func);
|
||||
/**
|
||||
* Registers a base type with abacus.
|
||||
* @param ab the libabacus instance used to keep state.
|
||||
* @param name the name to register the basetype under.
|
||||
* @param basetype the basetype to register.
|
||||
* @return the result of the registration.
|
||||
*/
|
||||
libab_result libab_register_basetype(libab* ab, const char* name, libab_basetype* basetype);
|
||||
/**
|
||||
* Releases all the resources allocated by libabacus.
|
||||
* @param ab the libabacus instance to release.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "result.h"
|
||||
#include "custom.h"
|
||||
#include "trie.h"
|
||||
#include "basetype.h"
|
||||
|
||||
/**
|
||||
* A struct that represents a structure
|
||||
@@ -29,7 +30,7 @@ struct libab_table_s {
|
||||
*/
|
||||
enum libab_table_entry_variant_e {
|
||||
ENTRY_VALUE,
|
||||
ENTRY_TYPE,
|
||||
ENTRY_BASETYPE,
|
||||
ENTRY_OP,
|
||||
ENTRY_FUN
|
||||
};
|
||||
@@ -49,6 +50,7 @@ struct libab_table_entry_s {
|
||||
union {
|
||||
libab_operator op;
|
||||
libab_function function;
|
||||
libab_basetype* basetype;
|
||||
} data_u;
|
||||
};
|
||||
|
||||
@@ -95,6 +97,14 @@ libab_operator* libab_table_search_operator(libab_table* table, const char* stri
|
||||
* @return the found function, or NULL if it was not found.
|
||||
*/
|
||||
libab_function* libab_table_search_function(libab_table* table, const char* string);
|
||||
/**
|
||||
* Searches for the given basetype in the table, returning a value
|
||||
* only if it's a basetype.
|
||||
* @param table the table to search.
|
||||
* @param string the string to search for.
|
||||
* @return the found basetype, or NULL if it was not found.
|
||||
*/
|
||||
libab_basetype* libab_table_search_basetype(libab_table* table, const char* string);
|
||||
/**
|
||||
* Stores the given entry in the table under the given key.
|
||||
* @param table the table to store the entry into.
|
||||
|
||||
Reference in New Issue
Block a user