Remove unused nesting in behavior struct.
This commit is contained in:
parent
325c9b9ef7
commit
97543a3d19
|
@ -27,9 +27,10 @@ enum libab_operator_variant_e {
|
|||
enum libab_behavior_variant_e { BIMPL_INTERNAL, BIMPL_TREE };
|
||||
|
||||
/**
|
||||
* A struct that represents the implementation of a behavior.
|
||||
* The common information
|
||||
* that both operators and functions shared.
|
||||
*/
|
||||
struct libab_behavior_impl_s {
|
||||
struct libab_behavior_s {
|
||||
/**
|
||||
* The variant of this implementation.
|
||||
*/
|
||||
|
@ -46,16 +47,6 @@ struct libab_behavior_impl_s {
|
|||
} data_u;
|
||||
};
|
||||
|
||||
/**
|
||||
* The common information
|
||||
* that both operators and functions shared.
|
||||
*/
|
||||
struct libab_behavior_s {
|
||||
/**
|
||||
* The implementation of this behavior.
|
||||
*/
|
||||
struct libab_behavior_impl_s impl;
|
||||
};
|
||||
/**
|
||||
* A struct that holds informatiion
|
||||
* about an operator that has been
|
||||
|
@ -100,7 +91,6 @@ struct libab_function_s {
|
|||
|
||||
typedef enum libab_operator_variant_e libab_operator_variant;
|
||||
typedef enum libab_behavior_variant_e libab_behavior_variant;
|
||||
typedef struct libab_behavior_impl_s libab_behavior_impl;
|
||||
typedef struct libab_behavior_s libab_behavior;
|
||||
typedef struct libab_operator_s libab_operator;
|
||||
typedef struct libab_function_s libab_function;
|
||||
|
|
12
src/custom.c
12
src/custom.c
|
@ -2,19 +2,19 @@
|
|||
|
||||
void libab_behavior_init_internal(libab_behavior* behavior,
|
||||
libab_function_ptr func) {
|
||||
behavior->impl.variant = BIMPL_INTERNAL;
|
||||
behavior->impl.data_u.internal = func;
|
||||
behavior->variant = BIMPL_INTERNAL;
|
||||
behavior->data_u.internal = func;
|
||||
}
|
||||
|
||||
void libab_behavior_init_tree(libab_behavior* behavior,
|
||||
libab_tree* tree) {
|
||||
behavior->impl.variant = BIMPL_TREE;
|
||||
behavior->impl.data_u.tree = tree;
|
||||
behavior->variant = BIMPL_TREE;
|
||||
behavior->data_u.tree = tree;
|
||||
}
|
||||
|
||||
void libab_behavior_free(libab_behavior* behavior) {
|
||||
if (behavior->impl.variant == BIMPL_TREE) {
|
||||
libab_tree_free_recursive(behavior->impl.data_u.tree);
|
||||
if (behavior->variant == BIMPL_TREE) {
|
||||
libab_tree_free_recursive(behavior->data_u.tree);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,8 @@ void _sanitize(char* to, const char* from, size_t buffer_size) {
|
|||
|
||||
void _initialize_behavior(libab_behavior* behavior, libab_ref* type,
|
||||
libab_function_ptr func) {
|
||||
behavior->impl.variant = BIMPL_INTERNAL;
|
||||
behavior->impl.data_u.internal = func;
|
||||
behavior->variant = BIMPL_INTERNAL;
|
||||
behavior->data_u.internal = func;
|
||||
}
|
||||
|
||||
libab_result _register_operator(libab* ab, const char* op,
|
||||
|
|
Loading…
Reference in New Issue
Block a user