diff --git a/method_dispatcher.c b/method_dispatcher/method_dispatcher.c similarity index 100% rename from method_dispatcher.c rename to method_dispatcher/method_dispatcher.c diff --git a/method_dispatcher.h b/method_dispatcher/method_dispatcher.h similarity index 100% rename from method_dispatcher.h rename to method_dispatcher/method_dispatcher.h diff --git a/test/Makefile b/method_dispatcher/test/Makefile similarity index 100% rename from test/Makefile rename to method_dispatcher/test/Makefile diff --git a/method_dispatcher/test/test_method_dispatcher.c b/method_dispatcher/test/test_method_dispatcher.c new file mode 100644 index 0000000..ae1fff0 --- /dev/null +++ b/method_dispatcher/test/test_method_dispatcher.c @@ -0,0 +1,51 @@ +#include +#include "../method_dispatcher.h" + +char m1(uint8_t small_arg, void * state); +char m2(uint8_t small_arg, void * state); +char m3(uint8_t small_arg, void * state); +char m4(uint8_t small_arg, void * state); +char m5(uint8_t small_arg, void * state); + +int main(void) +{ + printf("sizeof struct dispatch_tree_node_s: %zd\n", sizeof(struct dispatch_tree_node_s)); + dispatch_tree_t tree = dispatch_tree_t_new(); + + dispatch_tree_t_insert(tree, 3 << 6, m3); + dispatch_tree_t_insert(tree, 2 << 6, m2); + dispatch_tree_t_insert(tree, 1 << 6, m1); + dispatch_tree_t_insert(tree, 4 << 6, m4); + dispatch_tree_t_insert(tree, 5 << 6, m5); + + int i; + for(i = 1; i < 6; i++) + { + dispatch_tree_t_dispatch(tree, i << 6)(i, NULL); + } + dispatch_tree_t_del(tree); + return 0; +} + + + +char m1(uint8_t small_arg, void * state) +{ + printf("m1: %d\n", small_arg); +} +char m2(uint8_t small_arg, void * state) +{ + printf("m2: %d\n", small_arg); +} +char m3(uint8_t small_arg, void * state) +{ + printf("m3: %d\n", small_arg); +} +char m4(uint8_t small_arg, void * state) +{ + printf("m4: %d\n", small_arg); +} +char m5(uint8_t small_arg, void * state) +{ + printf("m5: %d\n", small_arg); +} diff --git a/test/method_dispatcher b/test/method_dispatcher deleted file mode 100755 index 722927d..0000000 Binary files a/test/method_dispatcher and /dev/null differ diff --git a/test/test_method_dispatcher.c b/test/test_method_dispatcher.c deleted file mode 100644 index 563d888..0000000 --- a/test/test_method_dispatcher.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include "../method_dispatcher.h" - -char m1(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_reg, uint16_t * reg[10], bci_stack_t * stack); -char m2(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_reg, uint16_t * reg[10], bci_stack_t * stack); -char m3(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_reg, uint16_t * reg[10], bci_stack_t * stack); -char m4(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_reg, uint16_t * reg[10], bci_stack_t * stack); -char m5(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_reg, uint16_t * reg[10], bci_stack_t * stack); - -int main(void) -{ - printf("sizeof struct dispatch_tree_node_s: %zd\n", sizeof(struct dispatch_tree_node_s)); - dispatch_tree_t tree = dispatch_tree_t_new(); - - dispatch_tree_t_insert(tree, 3 << 6, m3); - dispatch_tree_t_insert(tree, 2 << 6, m2); - dispatch_tree_t_insert(tree, 1 << 6, m1); - dispatch_tree_t_insert(tree, 4 << 6, m4); - dispatch_tree_t_insert(tree, 5 << 6, m5); - - int i; - for(i = 1; i < 6; i++) - { - dispatch_tree_t_dispatch(tree, i << 6)(i, i << 6, NULL, NULL, NULL, NULL); - } - dispatch_tree_t_del(tree); - return 0; -} - - - -char m1(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_register, uint16_t * reg[10], bci_stack_t * stack) -{ - printf("m1: %d, %d\n", small_arg, arg); -} -char m2(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_register, uint16_t * reg[10], bci_stack_t * stack) -{ - printf("m2: %d, %d\n", small_arg, arg); -} -char m3(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_register, uint16_t * reg[10], bci_stack_t * stack) -{ - printf("m3: %d, %d\n", small_arg, arg); -} -char m4(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_register, uint16_t * reg[10], bci_stack_t * stack) -{ - printf("m4: %d, %d\n", small_arg, arg); -} -char m5(uint8_t small_arg, uint16_t arg, uint16_t * s_reg, uint16_t * shutdown_register, uint16_t * reg[10], bci_stack_t * stack) -{ - printf("m5: %d, %d\n", small_arg, arg); -}