├── .gitignore ├── LICENSE ├── README.md └── auto-gen ├── IoC ├── Makefile ├── README.md └── topdir.mk ├── Makefile ├── adapter ├── Makefile ├── adaptee.c ├── adaptee.h ├── adapter.c ├── adapter.h ├── main.c ├── target.c ├── target.h ├── test.c └── topdir.mk ├── base.mk ├── bridge ├── Makefile ├── README.md ├── shape │ ├── Makefile │ ├── color.c │ ├── color.h │ ├── color_blue.c │ ├── color_blue.h │ ├── color_red.c │ ├── color_red.h │ ├── main.c │ ├── shape.c │ ├── shape.h │ ├── shape_circle.c │ ├── shape_circle.h │ ├── shape_rectangle.c │ ├── shape_rectangle.h │ ├── test.c │ └── topdir.mk ├── stack │ ├── Makefile │ ├── bridge.c │ ├── bridge.h │ ├── main.c │ ├── node.c │ ├── node.h │ ├── stack.c │ ├── stack.h │ ├── stack_fifo.c │ ├── stack_fifo.h │ ├── stack_hanoi.c │ ├── stack_hanoi.h │ ├── stack_impl.c │ ├── stack_impl.h │ ├── stack_impl_array.c │ ├── stack_impl_array.h │ ├── stack_impl_list.c │ ├── stack_impl_list.h │ ├── test.c │ └── topdir.mk └── topdir.mk ├── builder ├── Makefile ├── animal.c ├── animal.h ├── animal_builder.c ├── animal_builder.h ├── animal_builder_kitten.c ├── animal_builder_kitten.h ├── animal_builder_monkey.c ├── animal_builder_monkey.h ├── kid.c ├── kid.h ├── kitten.c ├── kitten.h ├── main.c ├── monkey.c ├── monkey.h ├── test.c └── topdir.mk ├── chain_of_responsibility ├── Makefile ├── chain_handle.c ├── chain_handle.h ├── chain_handle1.c ├── chain_handle1.h ├── chain_handle2.c ├── chain_handle2.h ├── chain_handle3.c ├── chain_handle3.h ├── main.c ├── test.c └── topdir.mk ├── command ├── Makefile ├── command.c ├── command.h ├── flipdown.c ├── flipdown.h ├── flipup.c ├── flipup.h ├── graphic.pyns ├── light.c ├── light.h ├── main.c ├── switcher.c ├── switcher.h ├── test.c └── topdir.mk ├── composite ├── Makefile ├── column.c ├── column.h ├── component.c ├── component.h ├── composite.c ├── composite.h ├── main.c ├── primitive.c ├── primitive.h ├── row.c ├── row.h ├── test.c └── topdir.mk ├── config.mk ├── decorator ├── Makefile ├── README.md ├── encode │ ├── Makefile │ ├── core.c │ ├── core.h │ ├── decorator.c │ ├── decorator.h │ ├── graphic.pyns │ ├── interface.c │ ├── interface.h │ ├── main.c │ ├── test.c │ ├── topdir.mk │ ├── wrapper.c │ └── wrapper.h ├── pizza │ ├── Makefile │ ├── extra_cheese_topping.c │ ├── extra_cheese_topping.h │ ├── gourmet_pizza.c │ ├── gourmet_pizza.h │ ├── graphic.pyns │ ├── jalapeno_topping.c │ ├── jalapeno_topping.h │ ├── main.c │ ├── margherita_pizza.c │ ├── margherita_pizza.h │ ├── mushroom_topping.c │ ├── mushroom_topping.h │ ├── pizza.c │ ├── pizza.h │ ├── test.c │ ├── topdir.mk │ ├── toppings_decorator.c │ └── toppings_decorator.h └── topdir.mk ├── facade ├── Makefile ├── bank.c ├── bank.h ├── credit.c ├── credit.h ├── graphic.pyns ├── loan.c ├── loan.h ├── main.c ├── mortgage.c ├── mortgage.h ├── test.c └── topdir.mk ├── factory ├── Makefile ├── abstract_factory │ ├── GoF_family_object │ │ ├── Makefile │ │ ├── main.c │ │ ├── test.c │ │ ├── topdir.mk │ │ ├── widget.c │ │ ├── widget.h │ │ ├── widget_factory.c │ │ ├── widget_factory.h │ │ ├── widget_factory_motif.c │ │ ├── widget_factory_motif.h │ │ ├── widget_factory_windows.c │ │ ├── widget_factory_windows.h │ │ ├── widget_motif_button.c │ │ ├── widget_motif_button.h │ │ ├── widget_motif_menu.c │ │ ├── widget_motif_menu.h │ │ ├── widget_windows_button.c │ │ ├── widget_windows_button.h │ │ ├── widget_windows_menu.c │ │ └── widget_windows_menu.h │ ├── Makefile │ ├── README.md │ ├── three_dimension │ │ ├── Makefile │ │ ├── README.md │ │ ├── cheese_pizza_v2.c │ │ ├── cheese_pizza_v2.h │ │ ├── main.c │ │ ├── pizza_factory_standard_v2.c │ │ ├── pizza_factory_standard_v2.h │ │ ├── pizza_ingredient_factory.c │ │ ├── pizza_ingredient_factory.h │ │ ├── pizza_ingredient_factory_no_organic.c │ │ ├── pizza_ingredient_factory_no_organic.h │ │ ├── pizza_ingredient_factory_organic.c │ │ ├── pizza_ingredient_factory_organic.h │ │ ├── test.c │ │ ├── topdir.mk │ │ ├── veggie_pizza_v2.c │ │ └── veggie_pizza_v2.h │ ├── topdir.mk │ └── two_dimension │ │ ├── Makefile │ │ ├── README.md │ │ ├── greek_cheese_pizza.c │ │ ├── greek_cheese_pizza.h │ │ ├── greek_veggie_pizza.c │ │ ├── greek_veggie_pizza.h │ │ ├── main.c │ │ ├── pizza_factory.c │ │ ├── pizza_factory.h │ │ ├── pizza_factory_greek.c │ │ ├── pizza_factory_greek.h │ │ ├── pizza_factory_standard.c │ │ ├── pizza_factory_standard.h │ │ ├── pizza_store3.c │ │ ├── pizza_store3.h │ │ ├── test.c │ │ └── topdir.mk ├── cheese_pizza.c ├── cheese_pizza.h ├── factory_method │ ├── GoF_product │ │ ├── Makefile │ │ ├── concrete_product_1.c │ │ ├── concrete_product_1.h │ │ ├── concrete_product_2.c │ │ ├── concrete_product_2.h │ │ ├── factory.c │ │ ├── factory.h │ │ ├── factory_product_1.c │ │ ├── factory_product_1.h │ │ ├── factory_product_2.c │ │ ├── factory_product_2.h │ │ ├── main.c │ │ ├── product.c │ │ ├── product.h │ │ ├── test.c │ │ └── topdir.mk │ ├── Makefile │ ├── README.md │ ├── topdir.mk │ └── two_stage │ │ ├── Makefile │ │ ├── README.md │ │ ├── domain_class.c │ │ ├── domain_class.h │ │ ├── factory.c │ │ ├── factory.h │ │ ├── factory_product.c │ │ ├── factory_product.h │ │ ├── file_access_handler.c │ │ ├── file_access_handler.h │ │ ├── main.c │ │ ├── product.c │ │ ├── product.h │ │ ├── serializer.c │ │ ├── serializer.h │ │ ├── test.c │ │ └── topdir.mk ├── lib.mk ├── pizza.c ├── pizza.h ├── projs.mk ├── simple_factory │ ├── Makefile │ ├── main.c │ ├── pizza_simple_factory.c │ ├── pizza_simple_factory.h │ ├── pizza_store2.c │ ├── pizza_store2.h │ ├── test.c │ └── topdir.mk ├── static_factory │ ├── Makefile │ ├── main.c │ ├── pizza_store.c │ ├── pizza_store.h │ ├── test.c │ └── topdir.mk ├── topdir.mk ├── veggie_pizza.c └── veggie_pizza.h ├── flyweight ├── Makefile ├── character.c ├── character.h ├── character_a.c ├── character_a.h ├── character_b.c ├── character_b.h ├── character_c.c ├── character_c.h ├── character_factory.c ├── character_factory.h ├── graphic.pyns ├── main.c ├── test.c └── topdir.mk ├── handle_body ├── Makefile ├── graphic.pyns ├── main.c ├── socket.c ├── socket.h ├── socket_impl.c ├── socket_impl.h ├── test.c └── topdir.mk ├── interpreter ├── Makefile ├── caculator.c ├── caculator.h ├── context.c ├── context.h ├── expression.c ├── expression.h ├── graphic.pyns ├── main.c ├── number.c ├── number.h ├── operand.c ├── operand.h ├── test.c ├── topdir.mk ├── variable.c └── variable.h ├── iterator ├── Makefile ├── README.md ├── data_node.c ├── data_node.h ├── graphic.pyns ├── iterator.c ├── iterator.h ├── main.c ├── stack.c ├── stack.h ├── stack_array.c ├── stack_array.h ├── stack_array_iter.c ├── stack_array_iter.h ├── stack_link.c ├── stack_link.h ├── stack_link_iter.c ├── stack_link_iter.h ├── test.c └── topdir.mk ├── mediator ├── Makefile ├── graphic.pyns ├── main.c ├── mediator.c ├── mediator.h ├── participant.c ├── participant.h ├── test.c ├── topdir.mk ├── widget_one.c ├── widget_one.h ├── widget_two.c └── widget_two.h ├── mvc ├── Makefile ├── README.md ├── student │ ├── Makefile │ ├── graphic.pyns │ ├── main.c │ ├── student.c │ ├── student.h │ ├── student_controller.c │ ├── student_controller.h │ ├── student_view.c │ ├── student_view.h │ ├── test.c │ └── topdir.mk └── topdir.mk ├── observer ├── Makefile ├── database.c ├── database.h ├── graphic.pyns ├── main.c ├── observer.c ├── observer.h ├── subject.c ├── subject.h ├── test.c ├── topdir.mk ├── view.c └── view.h ├── oop ├── Makefile ├── README.md ├── inheritance │ ├── Makefile │ ├── child.c │ ├── child.h │ ├── grandgirl.c │ ├── grandgirl.h │ ├── grandson.c │ ├── grandson.h │ ├── inheritance.py │ ├── main.c │ ├── parent.c │ ├── parent.h │ ├── test.c │ └── topdir.mk ├── mult_inherit │ ├── A.c │ ├── A.h │ ├── A_B1.c │ ├── A_B1.h │ ├── A_B2.c │ ├── A_B2.h │ ├── A_B3.c │ ├── A_B3.h │ ├── M.c │ ├── M.h │ ├── M_N.c │ ├── M_N.h │ ├── Makefile │ ├── P.c │ ├── P.h │ ├── P_Q.c │ ├── P_Q.h │ ├── graphic.pyns │ ├── main.c │ ├── me.c │ ├── me.h │ ├── test.c │ └── topdir.mk └── topdir.mk ├── prototype ├── Makefile ├── book.c ├── book.h ├── disk.c ├── disk.h ├── main.c ├── product.c ├── product.h ├── product_cache.c ├── product_cache.h ├── test.c └── topdir.mk ├── proxy ├── Makefile ├── graphic.pyns ├── main.c ├── proxy.c ├── proxy.h ├── real_subject.c ├── real_subject.h ├── subject.c ├── subject.h ├── test.c └── topdir.mk ├── state ├── Makefile ├── README.md ├── fsm_state.c ├── fsm_state_table.c ├── game_door_substate.c ├── split_func.c ├── state │ ├── Makefile │ ├── graphic.pyns │ ├── machine.c │ ├── machine.h │ ├── main.c │ ├── state.c │ ├── state.h │ ├── state_off.c │ ├── state_off.h │ ├── state_on.c │ ├── state_on.h │ ├── test.c │ └── topdir.mk ├── switch_whole.c ├── tcp_state.c └── topdir.mk ├── strategy ├── Makefile ├── main.c ├── strategy.c ├── strategy.h ├── strategy_left.c ├── strategy_left.h ├── strategy_right.c ├── strategy_right.h ├── test.c ├── test_bed.c ├── test_bed.h └── topdir.mk ├── template_method ├── Makefile ├── graphic.pyns ├── main.c ├── method_a.c ├── method_a.h ├── method_b.c ├── method_b.h ├── template_method.c ├── template_method.h ├── test.c └── topdir.mk ├── tools ├── Makefile ├── README.md ├── breeder.py ├── comn.py ├── config.py ├── const.py ├── enum.py ├── ext_re.py ├── gencode.py ├── graphic.py ├── jinja.py ├── json │ ├── Makefile │ ├── adapter.json │ ├── bridge │ │ ├── Makefile │ │ ├── shape_x_color.json │ │ ├── stack_fifo_x_list.json │ │ └── topdir.mk │ ├── builder.json │ ├── command.json │ ├── composite.json │ ├── decorator │ │ ├── Makefile │ │ ├── encode.json │ │ ├── pizza.json │ │ └── topdir.mk │ ├── facade.json │ ├── factory │ │ ├── Makefile │ │ ├── factory_method.json │ │ ├── topdir.mk │ │ └── two_stage.json │ ├── flyweight.json │ ├── handle_body.json │ ├── interpreter.json │ ├── iterator.json │ ├── mediator.json │ ├── mvc │ │ ├── Makefile │ │ ├── student.json │ │ └── topdir.mk │ ├── observer.json │ ├── oop │ │ ├── Makefile │ │ ├── inheritance.json │ │ ├── mult_inherit.json │ │ └── topdir.mk │ ├── prototype.json │ ├── proxy.json │ ├── sample.json │ ├── state │ │ ├── Makefile │ │ ├── state.json │ │ └── topdir.mk │ ├── template_method.json │ ├── topdir.mk │ └── visitor.json ├── odict.py ├── tmpl │ ├── Makefile │ ├── c │ │ ├── Makefile │ │ ├── _common.jinja │ │ ├── _graphic.pyns │ │ ├── _header.jinja │ │ ├── _macro.jinja │ │ ├── _source.jinja │ │ ├── _test.c │ │ ├── c.jinja │ │ ├── h.jinja │ │ └── topdir.mk │ ├── python │ │ ├── Makefile │ │ ├── README.md │ │ ├── py.jinja │ │ └── topdir.mk │ └── topdir.mk └── topdir.mk ├── topdir.mk ├── tpl_make.mk ├── tpl_top.mk ├── util ├── Makefile ├── mycommon.h ├── myobj.h ├── mytrace.c ├── mytrace.h ├── stack.h ├── test_suite.c ├── test_suite.h ├── topdir.mk ├── ulist.h ├── util.c └── util.h └── visitor ├── Makefile ├── animal.c ├── animal.h ├── animal_do.c ├── animal_do.h ├── cat.c ├── cat.h ├── dog.c ├── dog.h ├── eat.c ├── eat.h ├── graphic.pyns ├── main.c ├── sound.c ├── sound.h ├── test.c └── topdir.mk /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Libraries 8 | *.lib 9 | *.a 10 | 11 | # Shared objects (inc. Windows DLLs) 12 | *.dll 13 | *.so 14 | *.so.* 15 | *.dylib 16 | 17 | # Executables 18 | *.exe 19 | *.out 20 | *.app 21 | *.i*86 22 | *.x86_64 23 | *.hex 24 | 25 | # Build dir 26 | Debug 27 | Release 28 | 29 | # Speical files 30 | *.pyc 31 | tools/tmpl/autogen_.jinja 32 | tools/_code 33 | *.log 34 | log* 35 | *TAGS 36 | *cscope.files 37 | -------------------------------------------------------------------------------- /auto-gen/IoC/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = #proj1 proj2 proj_n proj_m 10 | SUBDIRS = #dir1 dir2 dir_n dir_m 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/IoC/README.md: -------------------------------------------------------------------------------- 1 | IoC and DI 2 | ================= 3 | 4 | * DI - Dependency injection 5 | * IOC - Inversion of control 6 | 7 | ``` 8 | +––––––––––––––––––––––––––+ 9 | +––+ Constructor way | 10 | +–––––––+ | +––––––––––––––––––––––––––+ 11 | | IoC | | 12 | +––+––––+ | +––––––––––––––––––––––––––+ 13 | | +––+Exposing setter and getter| 14 | +––+––––+ | +––––––––––––––––––––––––––+ 15 | | DI +–––––+ 16 | +–––––––+ | +––––––––––––––––––––––––––+ 17 | +––+ Interface implementation | 18 | | +––––––––––––––––––––––––––+ 19 | | 20 | | +––––––––––––––––––––––––––+ 21 | +––+ Service locator | 22 | +––––––––––––––––––––––––––+ 23 | ``` 24 | 25 | 26 | -------------------------------------------------------------------------------- /auto-gen/IoC/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = 10 | SUBDIRS = util 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = 15 | EXTRA_LIBDIRS = 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/adapter/adaptee.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * adaptee.c 2014-04-29 05:44:08 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "adaptee.h" 20 | 21 | 22 | 23 | void adaptee_init(struct adaptee *adaptee) 24 | { 25 | memset(adaptee, sizeof(*adaptee), 0); 26 | } 27 | 28 | 29 | void adaptee_specific_request(struct adaptee *adaptee) 30 | { 31 | printf("adaptee::specific_request()\n"); 32 | } -------------------------------------------------------------------------------- /auto-gen/adapter/adaptee.h: -------------------------------------------------------------------------------- 1 | /** 2 | * adaptee.h 2014-04-29 05:44:08 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __ADAPTEE_H__ 15 | #define __ADAPTEE_H__ 16 | 17 | 18 | 19 | struct adaptee { 20 | }; 21 | 22 | void adaptee_init(struct adaptee *); 23 | 24 | void adaptee_specific_request(struct adaptee *); 25 | 26 | 27 | #endif /* __ADAPTEE_H__ */ 28 | -------------------------------------------------------------------------------- /auto-gen/adapter/adapter.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * adapter.h 2014-04-29 05:44:08 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #ifndef __ADAPTER_H__ 16 | #define __ADAPTER_H__ 17 | 18 | #include "adaptee.h" 19 | #include "target.h" 20 | 21 | 22 | struct adapter { 23 | struct target target; 24 | struct adaptee * _adaptee; 25 | }; 26 | 27 | void adapter_init(struct adapter *, struct adaptee *); 28 | 29 | 30 | 31 | #endif /* __ADAPTER_H__ */ 32 | -------------------------------------------------------------------------------- /auto-gen/adapter/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/adapter/target.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * target.c 2014-04-29 05:44:08 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "target.h" 20 | 21 | 22 | static void target_ops_request(struct target *target) 23 | { 24 | printf("target::request()\n"); 25 | } 26 | static struct target_ops target_ops = { 27 | .request = target_ops_request, 28 | }; 29 | 30 | void target_init(struct target *target) 31 | { 32 | memset(target, sizeof(*target), 0); 33 | target->ops = &target_ops; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /auto-gen/adapter/target.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * target.h 2014-04-29 05:44:08 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #ifndef __TARGET_H__ 16 | #define __TARGET_H__ 17 | 18 | 19 | struct target_ops; 20 | struct target { 21 | struct target_ops *ops; 22 | }; 23 | struct target_ops { 24 | void (*request)(struct target *); 25 | }; 26 | void target_init(struct target *); 27 | 28 | 29 | static inline void target_request(struct target *target) 30 | { 31 | target->ops->request(target); 32 | } 33 | 34 | #endif /* __TARGET_H__ */ 35 | -------------------------------------------------------------------------------- /auto-gen/adapter/test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include "adapter.h" 7 | 8 | static int test_adapter(char *output, size_t sz) 9 | { 10 | struct adapter *one_adapter; 11 | struct adaptee *one_adaptee; 12 | 13 | one_adaptee = malloc(sizeof(*one_adaptee)); 14 | if (!one_adaptee) { 15 | snprintf(output, sz, "malloc one_adaptee fail"); 16 | return 1; 17 | } 18 | adaptee_init(one_adaptee); 19 | 20 | one_adapter = malloc(sizeof(*one_adapter)); 21 | if (!one_adapter) { 22 | snprintf(output, sz, "malloc one_adapter fail"); 23 | return 1; 24 | } 25 | adapter_init(one_adapter, one_adaptee); 26 | 27 | target_request(&one_adapter->target); 28 | return 0; 29 | } 30 | 31 | void main_entry_test(void); 32 | void main_entry_test(void) 33 | { 34 | my_test_suite_add(test_adapter, "Test template_method"); 35 | } 36 | -------------------------------------------------------------------------------- /auto-gen/adapter/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/bridge/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = #proj1 proj2 proj_n proj_m 10 | SUBDIRS = 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/bridge/shape/color.c: -------------------------------------------------------------------------------- 1 | /** 2 | * color.c 2014-05-03 16:10:55 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include "color.h" 21 | 22 | static void color_ops_render(struct color *color) 23 | { 24 | printf("color::render()\n"); 25 | } 26 | static struct color_ops color_ops = { 27 | .render = color_ops_render, 28 | }; 29 | 30 | void color_init(struct color *color) 31 | { 32 | memset(color, sizeof(*color), 0); 33 | color->ops = &color_ops; 34 | } -------------------------------------------------------------------------------- /auto-gen/bridge/shape/color.h: -------------------------------------------------------------------------------- 1 | /** 2 | * color.h 2014-05-03 16:10:55 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __COLOR_H__ 15 | #define __COLOR_H__ 16 | 17 | #include 18 | 19 | struct color_ops; 20 | 21 | struct color { 22 | struct color_ops *ops; 23 | }; 24 | struct color_ops { 25 | void (*render)(struct color *); 26 | }; 27 | void color_init(struct color *); 28 | 29 | static inline void color_render(struct color *color) 30 | { 31 | color->ops->render(color); 32 | } 33 | 34 | #endif /* __COLOR_H__ */ -------------------------------------------------------------------------------- /auto-gen/bridge/shape/color_blue.h: -------------------------------------------------------------------------------- 1 | /** 2 | * color_blue.h 2014-05-03 16:10:55 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __COLOR_BLUE_H__ 15 | #define __COLOR_BLUE_H__ 16 | 17 | #include 18 | 19 | #include "color.h" 20 | 21 | struct color_blue { 22 | struct color color; 23 | }; 24 | 25 | void color_blue_init(struct color_blue *); 26 | 27 | #endif /* __COLOR_BLUE_H__ */ -------------------------------------------------------------------------------- /auto-gen/bridge/shape/color_red.h: -------------------------------------------------------------------------------- 1 | /** 2 | * color_red.h 2014-05-03 16:10:55 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __COLOR_RED_H__ 15 | #define __COLOR_RED_H__ 16 | 17 | #include 18 | 19 | #include "color.h" 20 | 21 | struct color_red { 22 | struct color color; 23 | }; 24 | 25 | void color_red_init(struct color_red *); 26 | 27 | #endif /* __COLOR_RED_H__ */ -------------------------------------------------------------------------------- /auto-gen/bridge/shape/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/bridge/shape/shape_circle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * shape_circle.h 2014-05-03 16:10:55 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __SHAPE_CIRCLE_H__ 15 | #define __SHAPE_CIRCLE_H__ 16 | 17 | #include 18 | 19 | #include "shape.h" 20 | 21 | struct shape_circle { 22 | struct shape shape; 23 | }; 24 | 25 | void shape_circle_init(struct shape_circle *, struct color *); 26 | 27 | #endif /* __SHAPE_CIRCLE_H__ */ 28 | -------------------------------------------------------------------------------- /auto-gen/bridge/shape/shape_rectangle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * shape_rectangle.h 2014-05-03 16:10:55 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __SHAPE_RECTANGLE_H__ 15 | #define __SHAPE_RECTANGLE_H__ 16 | 17 | #include 18 | 19 | #include "shape.h" 20 | 21 | struct shape_rectangle { 22 | struct shape shape; 23 | }; 24 | 25 | void shape_rectangle_init(struct shape_rectangle *, struct color *); 26 | 27 | #endif /* __SHAPE_RECTANGLE_H__ */ 28 | -------------------------------------------------------------------------------- /auto-gen/bridge/shape/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/bridge/stack/bridge.h: -------------------------------------------------------------------------------- 1 | /** 2 | * bridge.h 2014-05-02 01:32:58 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __BRIDGE_H__ 15 | #define __BRIDGE_H__ 16 | 17 | #include "stack_hanoi.h" 18 | #include "stack_fifo.h" 19 | #include "stack_impl_array.h" 20 | #include "stack_impl_list.h" 21 | 22 | struct bridge { 23 | }; 24 | 25 | void bridge_init(struct bridge *); 26 | 27 | void bridge_main_entry(void); 28 | 29 | #endif /* __BRIDGE_H__ */ 30 | -------------------------------------------------------------------------------- /auto-gen/bridge/stack/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/bridge/stack/node.c: -------------------------------------------------------------------------------- 1 | /** 2 | * node.c 2014-05-02 01:32:58 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #include 15 | #include 16 | #include 17 | 18 | #include "node.h" 19 | 20 | void node_init(struct node *node, int val) 21 | { 22 | memset(node, sizeof(*node), 0); 23 | node->val = val; 24 | node->prev = node; 25 | node->next = node; 26 | } -------------------------------------------------------------------------------- /auto-gen/bridge/stack/node.h: -------------------------------------------------------------------------------- 1 | /** 2 | * node.h 2014-05-02 01:32:58 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __NODE_H__ 15 | #define __NODE_H__ 16 | 17 | struct node { 18 | int val; 19 | struct node * prev; 20 | struct node * next; 21 | }; 22 | void node_init(struct node *, int val); 23 | 24 | 25 | #endif /* __NODE_H__ */ -------------------------------------------------------------------------------- /auto-gen/bridge/stack/stack_fifo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * stack_fifo.h 2014-05-02 01:32:58 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __STACK_FIFO_H__ 15 | #define __STACK_FIFO_H__ 16 | 17 | #include "stack.h" 18 | 19 | struct stack_fifo { 20 | struct stack stack; 21 | }; 22 | 23 | void stack_fifo_init(struct stack_fifo *, char *); 24 | 25 | 26 | #endif /* __STACK_FIFO_H__ */ -------------------------------------------------------------------------------- /auto-gen/bridge/stack/stack_hanoi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * stack_hanoi.h 2014-05-02 01:32:58 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __STACK_HANOI_H__ 15 | #define __STACK_HANOI_H__ 16 | 17 | #include "stack.h" 18 | 19 | struct stack_hanoi { 20 | struct stack stack; 21 | int rejects; 22 | }; 23 | 24 | void stack_hanoi_init(struct stack_hanoi *, char *); 25 | 26 | #endif /* __STACK_HANOI_H__ */ -------------------------------------------------------------------------------- /auto-gen/bridge/stack/stack_impl_array.h: -------------------------------------------------------------------------------- 1 | /** 2 | * stack_impl_array.h 2014-05-02 01:32:58 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __STACK_IMPL_ARRAY_H__ 15 | #define __STACK_IMPL_ARRAY_H__ 16 | 17 | #include "stack_impl.h" 18 | 19 | enum stack_array_items_size { stack_array_items_size = 32 }; 20 | struct stack_impl_array { 21 | struct stack_impl stack_impl; 22 | int items[stack_array_items_size]; 23 | int total; 24 | }; 25 | 26 | void stack_impl_array_init(struct stack_impl_array *); 27 | 28 | #endif /* __STACK_IMPL_ARRAY_H__ */ -------------------------------------------------------------------------------- /auto-gen/bridge/stack/stack_impl_list.h: -------------------------------------------------------------------------------- 1 | /** 2 | * stack_impl_list.h 2014-05-02 01:32:58 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __STACK_IMPL_LIST_H__ 15 | #define __STACK_IMPL_LIST_H__ 16 | 17 | #include "node.h" 18 | #include "stack_impl.h" 19 | 20 | struct stack_impl_list { 21 | struct stack_impl stack_impl; 22 | struct node * nodes; 23 | }; 24 | 25 | void stack_impl_list_init(struct stack_impl_list *); 26 | 27 | #endif /* __STACK_IMPL_LIST_H__ */ -------------------------------------------------------------------------------- /auto-gen/bridge/stack/test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include "bridge.h" 7 | 8 | static int test_main_entry(char *output, size_t sz) 9 | { 10 | bridge_main_entry(); 11 | return 0; 12 | } 13 | 14 | void main_entry_test(void); 15 | void main_entry_test(void) 16 | { 17 | my_test_suite_add(test_main_entry, "Bridge stack"); 18 | } 19 | -------------------------------------------------------------------------------- /auto-gen/bridge/stack/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/bridge/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/builder/animal.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * animal.c 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "animal.h" 20 | 21 | 22 | static void animal_ops_eat(struct animal *animal) 23 | { 24 | printf("animal::eat()\n"); 25 | } 26 | static struct animal_ops animal_ops = { 27 | .eat = animal_ops_eat, 28 | }; 29 | 30 | void animal_init(struct animal *animal) 31 | { 32 | memset(animal, sizeof(*animal), 0); 33 | animal->ops = &animal_ops; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /auto-gen/builder/animal.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * animal.h 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #ifndef __ANIMAL_H__ 16 | #define __ANIMAL_H__ 17 | 18 | 19 | struct animal_ops; 20 | struct animal { 21 | struct animal_ops *ops; 22 | }; 23 | struct animal_ops { 24 | void (*eat)(struct animal *); 25 | }; 26 | void animal_init(struct animal *); 27 | 28 | 29 | static inline void animal_eat(struct animal *animal) 30 | { 31 | animal->ops->eat(animal); 32 | } 33 | 34 | #endif /* __ANIMAL_H__ */ 35 | -------------------------------------------------------------------------------- /auto-gen/builder/animal_builder_kitten.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * animal_builder_kitten.h 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #ifndef __ANIMAL_BUILDER_KITTEN_H__ 16 | #define __ANIMAL_BUILDER_KITTEN_H__ 17 | #include "animal_builder.h" 18 | 19 | 20 | struct animal_builder_kitten { 21 | struct animal_builder animal_builder; 22 | }; 23 | 24 | void animal_builder_kitten_init(struct animal_builder_kitten *); 25 | 26 | 27 | 28 | #endif /* __ANIMAL_BUILDER_KITTEN_H__ */ 29 | -------------------------------------------------------------------------------- /auto-gen/builder/animal_builder_monkey.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * animal_builder_monkey.h 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #ifndef __ANIMAL_BUILDER_MONKEY_H__ 16 | #define __ANIMAL_BUILDER_MONKEY_H__ 17 | #include "animal_builder.h" 18 | 19 | 20 | struct animal_builder_monkey { 21 | struct animal_builder animal_builder; 22 | }; 23 | 24 | void animal_builder_monkey_init(struct animal_builder_monkey *); 25 | 26 | 27 | 28 | #endif /* __ANIMAL_BUILDER_MONKEY_H__ */ 29 | -------------------------------------------------------------------------------- /auto-gen/builder/kid.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * kid.c 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "kid.h" 20 | 21 | 22 | 23 | void kid_init(struct kid *kid) 24 | { 25 | memset(kid, sizeof(*kid), 0); 26 | } 27 | 28 | 29 | void kid_make_animal(struct kid *kid, struct animal_builder *builder) 30 | { 31 | printf("kid::make_animal()\n"); 32 | animal_builder_build_header(builder); 33 | animal_builder_build_body(builder); 34 | animal_builder_build_leg(builder); 35 | animal_builder_build_arm(builder); 36 | animal_builder_build_tail(builder); 37 | } 38 | -------------------------------------------------------------------------------- /auto-gen/builder/kid.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * kid.h 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #ifndef __KID_H__ 16 | #define __KID_H__ 17 | 18 | #include "animal_builder.h" 19 | 20 | 21 | struct kid { 22 | char name[32]; 23 | }; 24 | 25 | void kid_init(struct kid *); 26 | 27 | void kid_make_animal(struct kid *, struct animal_builder *builder); 28 | 29 | 30 | #endif /* __KID_H__ */ 31 | -------------------------------------------------------------------------------- /auto-gen/builder/kitten.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * kitten.c 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "kitten.h" 20 | 21 | 22 | static void kitten_ops_eat(struct animal *animal) 23 | { 24 | printf("kitten::eat()\n"); 25 | } 26 | 27 | static struct animal_ops animal_ops = { 28 | .eat = kitten_ops_eat, 29 | }; 30 | 31 | 32 | void kitten_init(struct kitten *kitten) 33 | { 34 | memset(kitten, sizeof(*kitten), 0); 35 | animal_init(&kitten->animal); 36 | CLASS_OPS_INIT(kitten->animal.ops, animal_ops); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /auto-gen/builder/kitten.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * kitten.h 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #ifndef __KITTEN_H__ 16 | #define __KITTEN_H__ 17 | #include "animal.h" 18 | 19 | 20 | struct kitten { 21 | struct animal animal; 22 | }; 23 | 24 | void kitten_init(struct kitten *); 25 | 26 | 27 | 28 | #endif /* __KITTEN_H__ */ 29 | -------------------------------------------------------------------------------- /auto-gen/builder/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/builder/monkey.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * monkey.c 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "monkey.h" 20 | 21 | 22 | static void monkey_ops_eat(struct animal *animal) 23 | { 24 | printf("monkey::eat()\n"); 25 | } 26 | 27 | static struct animal_ops animal_ops = { 28 | .eat = monkey_ops_eat, 29 | }; 30 | 31 | 32 | void monkey_init(struct monkey *monkey) 33 | { 34 | memset(monkey, sizeof(*monkey), 0); 35 | animal_init(&monkey->animal); 36 | CLASS_OPS_INIT(monkey->animal.ops, animal_ops); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /auto-gen/builder/monkey.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * monkey.h 2014-04-28 16:14:06 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate to show Design Pattern in C 14 | */ 15 | #ifndef __MONKEY_H__ 16 | #define __MONKEY_H__ 17 | #include "animal.h" 18 | 19 | 20 | struct monkey { 21 | struct animal animal; 22 | }; 23 | 24 | void monkey_init(struct monkey *); 25 | 26 | 27 | 28 | #endif /* __MONKEY_H__ */ 29 | -------------------------------------------------------------------------------- /auto-gen/builder/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/chain_handle.c: -------------------------------------------------------------------------------- 1 | #include "chain_handle.h" 2 | 3 | static void chain_base_ops_add(struct chan_handle *base, struct chan_handle *next) 4 | { 5 | if (base->next) 6 | chain_base_add(base->next, next); 7 | else 8 | base->next = next; 9 | } 10 | 11 | static void chain_base_ops_handle(struct chain_handle *base, int data) 12 | { 13 | if (base->next) 14 | chain_base_handle(base->next, data); 15 | else 16 | assert(0); /* virtual: assume override */ 17 | } 18 | 19 | static struct chain_base_ops chain_base_ops = { 20 | ._add = chain_base_ops_add, 21 | .handle = chain_base_ops_handle, 22 | }; 23 | struct chain_base_ops *chain_base_ops_get(struct chain_handle *base) 24 | { 25 | return base->ops; 26 | } 27 | 28 | void chain_base_init(struct chain_handle *base) 29 | { 30 | base->ops = &chain_base_ops; 31 | base->next = 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/chain_handle1.c: -------------------------------------------------------------------------------- 1 | #include "chain_handle1.h" 2 | 3 | static void chain_handler1_ops_handle(struct chain_handle *base, int data) 4 | { 5 | if (data % 3 == 1) { 6 | printf("H1 processed %d \n", data); 7 | } 8 | else { 9 | printf("H1 passsed %d \n", data); 10 | 11 | // 3. Delegate to the base class 12 | //chain_base_ops_get(base, i); 13 | chain_base_handle_super(base, data); 14 | } 15 | } 16 | 17 | static void chain_handler1_ops_close(struct chain_handle *base) 18 | { 19 | } 20 | 21 | static struct chain_base_ops chain_handler1_ops = { 22 | .handle = chain_handler1_ops_handle, 23 | .close = chain_handler1_ops_close, 24 | }; 25 | 26 | void chain_handle1_init(struct chain_handle1 *chain) 27 | { 28 | chain_base_init(&chain->super); 29 | CLASS_OPS_INIT_SUPER(chain->super.ops, chain_handler1_ops); 30 | #if DEBUG 31 | chain_handler1_ops.__super = chain_base_init(&chain->super); 32 | chain->ops = OPS_FILL(&chain_handler1_ops, chain->ops.__super); 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/chain_handle1.h: -------------------------------------------------------------------------------- 1 | #ifndef __CHAIN_HANDLE1_H__ 2 | #define __CHAIN_HANDLE1_H__ 3 | 4 | #include "chain_handle.h" 5 | 6 | struct chain_handle1 { 7 | union { struct chain_handle; struct chain_handle super; }; 8 | }; 9 | 10 | void chain_handle1_init(struct chain_handle1 *); 11 | 12 | #endif /* __CHAIN_HANDLE1_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/chain_handle2.c: -------------------------------------------------------------------------------- 1 | #include "chain_handle2.h" 2 | 3 | static void chain_handler2_ops_handle(struct chain_handle *base, int data) 4 | { 5 | if (data % 3 == 2) { 6 | printf("H2 processed %d \n", data); 7 | } 8 | else { 9 | // 3. Don't handle requests 3 times out of 4 10 | printf("H2 passsed %d \n", data); 11 | 12 | // 3. Delegate to the base class 13 | //chain_base_ops_get(base, i); 14 | chain_base_handle_super(base, data); 15 | } 16 | } 17 | 18 | static void chain_handler2_ops_close(struct chain_handle *base) 19 | { 20 | } 21 | 22 | static struct chain_base_ops chain_handler2_ops = { 23 | .handle = chain_handler2_ops_handle, 24 | .close = chain_handler2_ops_close, 25 | }; 26 | 27 | void chain_handle2_init(struct chain_handle2 *chain) 28 | { 29 | chain_base_init(&chain->super); 30 | CLASS_OPS_INIT_SUPER(chain->super.ops, chain_handler2_ops); 31 | } 32 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/chain_handle2.h: -------------------------------------------------------------------------------- 1 | #ifndef __CHAIN_HANDLE2_H__ 2 | #define __CHAIN_HANDLE2_H__ 3 | 4 | #include "chain_handle.h" 5 | 6 | struct chain_handle2 { 7 | struct chain_handle super; 8 | }; 9 | 10 | void chain_handle2_init(struct chain_handle2 *); 11 | 12 | #endif /* __CHAIN_HANDLE2_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/chain_handle3.c: -------------------------------------------------------------------------------- 1 | #include "chain_handle3.h" 2 | 3 | static void chain_handler3_ops_handle(struct chain_handle *base, int data) 4 | { 5 | if (data % 3 == 0) { 6 | printf("H3 processed %d \n", data); 7 | } 8 | else { 9 | // 3. Don't handle requests 3 times out of 4 10 | printf("H3 passsed %d \n", data); 11 | 12 | // 3. Delegate to the base class 13 | //chain_base_ops_get(base, i); 14 | chain_base_handle_super(base, data); 15 | } 16 | } 17 | 18 | static void chain_handler3_ops_close(struct chain_handle *base) 19 | { 20 | } 21 | 22 | static struct chain_base_ops chain_handler3_ops = { 23 | .handle = chain_handler3_ops_handle, 24 | .close = chain_handler3_ops_close, 25 | }; 26 | 27 | void chain_handle3_init(struct chain_handle3 *chain) 28 | { 29 | chain_base_init(&chain->super); 30 | CLASS_OPS_INIT_SUPER(chain->super.ops, chain_handler3_ops); 31 | } 32 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/chain_handle3.h: -------------------------------------------------------------------------------- 1 | #ifndef __CHAIN_HANDLE3_H__ 2 | #define __CHAIN_HANDLE3_H__ 3 | 4 | #include "chain_handle.h" 5 | 6 | struct chain_handle3 { 7 | struct chain_handle super; 8 | }; 9 | 10 | void chain_handle3_init(struct chain_handle3 *); 11 | 12 | #endif /* __CHAIN_HANDLE3_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "chain_handle1.h" 4 | #include "chain_handle2.h" 5 | #include "chain_handle3.h" 6 | 7 | static int chain_of_responsibility_test(char *output, size_t sz) 8 | { 9 | int i; 10 | 11 | struct chain_handle1 root; 12 | struct chain_handle2 two; 13 | struct chain_handle3 thr; 14 | 15 | chain_handle1_init(&root); 16 | chain_handle2_init(&two); 17 | chain_handle3_init(&thr); 18 | 19 | chain_base_add(&root.super, &two.super); 20 | chain_base_add(&root.super, &thr.super); 21 | thr.super.next = &root.super; 22 | 23 | for (i = 1; i < 10; i++) { 24 | chain_base_handle(&root.super, i); 25 | } 26 | return 0; 27 | } 28 | 29 | void main_entry_test(void); 30 | void main_entry_test(void) 31 | { 32 | my_test_suite_add(chain_of_responsibility_test, "Test chain of responsibility"); 33 | } 34 | -------------------------------------------------------------------------------- /auto-gen/chain_of_responsibility/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/command/light.h: -------------------------------------------------------------------------------- 1 | /** 2 | * light.h 2014-05-19 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C * 13 | * 14 | * The info will insert to every source file explaining the pattern's design details. 15 | We also can append lists like this: 16 | - list 1, give point one 17 | detail provide for point one 18 | - list 2, offer point two 19 | */ 20 | #ifndef __LIGHT_H__ 21 | #define __LIGHT_H__ 22 | 23 | #include 24 | #include 25 | 26 | struct light { 27 | }; 28 | 29 | /** constructor(). */ 30 | void light_init(struct light *light); 31 | 32 | void light_turnon(struct light *light); 33 | 34 | void light_turnoff(struct light *light); 35 | 36 | #endif /* __LIGHT_H__ */ -------------------------------------------------------------------------------- /auto-gen/command/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/command/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/composite/column.h: -------------------------------------------------------------------------------- 1 | /** 2 | * column.h 2014-05-04 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __COLUMN_H__ 15 | #define __COLUMN_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "composite.h" 21 | 22 | struct column { 23 | struct composite composite; 24 | }; 25 | 26 | void column_init(struct column *, int val); 27 | 28 | #endif /* __COLUMN_H__ */ -------------------------------------------------------------------------------- /auto-gen/composite/component.c: -------------------------------------------------------------------------------- 1 | /** 2 | * component.c 2014-05-04 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include "component.h" 21 | 22 | static void component_ops_traverse(struct component *component) 23 | { 24 | _MY_TRACE_STR("component::traverse()\n"); 25 | } 26 | static struct component_ops component_ops = { 27 | .traverse = component_ops_traverse, 28 | }; 29 | 30 | void component_init(struct component *component) 31 | { 32 | memset(component, sizeof(*component), 0); 33 | component->ops = &component_ops; 34 | } -------------------------------------------------------------------------------- /auto-gen/composite/component.h: -------------------------------------------------------------------------------- 1 | /** 2 | * component.h 2014-05-04 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __COMPONENT_H__ 15 | #define __COMPONENT_H__ 16 | 17 | #include 18 | #include 19 | 20 | struct component_ops; 21 | 22 | struct component { 23 | struct component_ops *ops; 24 | }; 25 | struct component_ops { 26 | void (*traverse)(struct component *); 27 | struct component_ops *__super; 28 | }; 29 | void component_init(struct component *); 30 | 31 | static inline void component_traverse(struct component *component) 32 | { 33 | component->ops->traverse(component); 34 | } 35 | 36 | #endif /* __COMPONENT_H__ */ -------------------------------------------------------------------------------- /auto-gen/composite/composite.h: -------------------------------------------------------------------------------- 1 | /** 2 | * composite.h 2014-05-04 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __COMPOSITE_H__ 15 | #define __COMPOSITE_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "component.h" 21 | 22 | struct composite { 23 | struct component component; 24 | int value; 25 | struct component * children[32]; 26 | int children_sz; 27 | }; 28 | 29 | void composite_init(struct composite *, int val); 30 | 31 | void composite_add(struct composite *, struct component *c); 32 | 33 | #endif /* __COMPOSITE_H__ */ -------------------------------------------------------------------------------- /auto-gen/composite/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/composite/primitive.h: -------------------------------------------------------------------------------- 1 | /** 2 | * primitive.h 2014-05-04 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __PRIMITIVE_H__ 15 | #define __PRIMITIVE_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "component.h" 21 | 22 | struct primitive { 23 | struct component component; 24 | int value; 25 | }; 26 | 27 | void primitive_init(struct primitive *, int val); 28 | 29 | #endif /* __PRIMITIVE_H__ */ -------------------------------------------------------------------------------- /auto-gen/composite/row.h: -------------------------------------------------------------------------------- 1 | /** 2 | * row.h 2014-05-04 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __ROW_H__ 15 | #define __ROW_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "composite.h" 21 | 22 | struct row { 23 | struct composite composite; 24 | }; 25 | 26 | void row_init(struct row *, int val); 27 | 28 | #endif /* __ROW_H__ */ -------------------------------------------------------------------------------- /auto-gen/composite/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/config.mk: -------------------------------------------------------------------------------- 1 | REPLACE_ME= XXXXXX 2 | OUTDIR = $(REPLACE_ME) 3 | #_______________________________________________________________________________ 4 | # PROJECTS GLOBAL CONFIG IGNORE ABOVE 5 | #VERBOSE = 1 6 | DEBUGMODE = 1 7 | 8 | G_MACROS = 9 | G_INCS = $(TOPDIR)util . 10 | G_LIBDIRS = $(TOPDIR)util 11 | G_LIBS = util 12 | G_CPPFLAGS= -Wall -Werror -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wunused-value -Wno-unused-parameter -Wformat \ 13 | -Wfloat-equal -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wredundant-decls 14 | G_LDFLAGS = 15 | G_ARFLAGS = -cr 16 | 17 | G_OUTDIR_DEBUG = out_debug 18 | G_OUTDIR_RELEASE = out_release 19 | G_OUTDIR_PROFILE = out_profile 20 | #_______________________________________________________________________________ 21 | # IGNORE BELOW 22 | include $(TOPDIR)base.mk 23 | -------------------------------------------------------------------------------- /auto-gen/decorator/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = #proj1 proj2 proj_n proj_m 10 | SUBDIRS = 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/decorator/README.md: -------------------------------------------------------------------------------- 1 | ## Decorator vs Proxy 2 | 3 | - Decorator get reference for decorated object (usually through constructor) while Proxy responsible to do that by himself. 4 | - Proxy may not instantiate wrapping object at all (like this do ORMs to prevent unnecessary access to DB if object fields/getters are not used) while Decorator always hold link to actual wrapped instance. 5 | - Proxy usually used by frameworks to add security or caching/lazing and constructed by framework (not by regular developer itself). 6 | - Decorator usually used to add new behavior to old or legacy classes by developer itself based on interface rather then actual class (so it work on wide range of interface instances, Proxy is around concrete class). 7 | -------------------------------------------------------------------------------- /auto-gen/decorator/encode/core.h: -------------------------------------------------------------------------------- 1 | /** 2 | * core.h 2014-05-08 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __CORE_H__ 15 | #define __CORE_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "interface.h" 21 | 22 | struct core { 23 | struct interface interface; 24 | }; 25 | 26 | /** constructor(). */ 27 | #define core_init(...) _Static_assert(0, "private constructor, cannot be called directly.") 28 | 29 | #endif /* __CORE_H__ */ -------------------------------------------------------------------------------- /auto-gen/decorator/encode/interface.c: -------------------------------------------------------------------------------- 1 | /** 2 | * interface.c 2014-05-08 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include "interface.h" 21 | 22 | static struct interface_ops interface_ops = {0 23 | }; 24 | 25 | /** constructor(). */ 26 | void interface_init(struct interface *interface) 27 | { 28 | memset(interface, sizeof(*interface), 0); 29 | interface->ops = &interface_ops; 30 | } -------------------------------------------------------------------------------- /auto-gen/decorator/encode/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/decorator/encode/test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * test.c 2014-05-08 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "wrapper.h" 22 | #include "core.h" 23 | 24 | static int test_main_entry(char *output, size_t sz) 25 | { 26 | TODO(Please add our **test** code here ...) 27 | return 0; 28 | } 29 | 30 | void main_entry_test(void); 31 | void main_entry_test(void) 32 | { 33 | my_test_suite_add(test_main_entry, "Test decorator encode"); 34 | } 35 | -------------------------------------------------------------------------------- /auto-gen/decorator/encode/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/decorator/encode/wrapper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * wrapper.h 2014-05-08 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __WRAPPER_H__ 15 | #define __WRAPPER_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "decorator.h" 21 | 22 | struct wrapper { 23 | struct decorator decorator; 24 | }; 25 | 26 | /** constructor(). */ 27 | void wrapper_init(struct wrapper *wrapper, struct interface *inner, char *str); 28 | 29 | #endif /* __WRAPPER_H__ */ -------------------------------------------------------------------------------- /auto-gen/decorator/pizza/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/decorator/pizza/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/decorator/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/facade/graphic.pyns: -------------------------------------------------------------------------------- 1 | {'type':'node', 'id':'bank', 'attrs':'', 'meths':'+ bank()|+ has_sufficient_savings()', 'x':1, 'y':1, 'width':1, 'height':1} 2 | {'type':'node', 'id':'credit', 'attrs':'', 'meths':'+ credit()|+ has_good_credit()', 'x':61, 'y':61, 'width':1, 'height':1} 3 | {'type':'node', 'id':'loan', 'attrs':'', 'meths':'+ loan()|+ has_bad_loan()', 'x':121, 'y':121, 'width':1, 'height':1} 4 | {'type':'node', 'id':'mortgage', 'attrs':'+ _bank|+ _credit|+ _loan', 'meths':'+ mortgage()|+ is_eligible()', 'x':181, 'y':181, 'width':1, 'height':1} 5 | {'type':'edge', 'id':'mortgage_to_bank', 'source':'mortgage', 'target':'bank', 'uml_edge_type':'composition'} 6 | {'type':'edge', 'id':'mortgage_to_credit', 'source':'mortgage', 'target':'credit', 'uml_edge_type':'composition'} 7 | {'type':'edge', 'id':'mortgage_to_loan', 'source':'mortgage', 'target':'loan', 'uml_edge_type':'composition'} -------------------------------------------------------------------------------- /auto-gen/facade/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/facade/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = lib 10 | SUBDIRS = # 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget.c: -------------------------------------------------------------------------------- 1 | 2 | #include "widget.h" 3 | 4 | static struct widget_ops ops = {0}; /* virtual */ 5 | 6 | void widget_init(struct widget *widget) 7 | { 8 | widget->ops = &ops; 9 | } 10 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIDGET_H_ 3 | #define WIDGET_H_ 4 | 5 | struct widget_ops; 6 | struct widget { 7 | struct widget_ops *ops; 8 | }; 9 | 10 | struct widget_ops { 11 | void (*draw)(struct widget *); 12 | }; 13 | 14 | void widget_init(struct widget *); 15 | 16 | static inline 17 | void widget_draw(struct widget *widget) 18 | { 19 | widget->ops->draw(widget); 20 | } 21 | 22 | #endif /* WIDGET_H_ */ 23 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_factory.c: -------------------------------------------------------------------------------- 1 | 2 | #include "widget_factory.h" 3 | 4 | static struct widget_factory_ops ops = {0}; /* virtual */ 5 | 6 | void widget_factory_init(struct widget_factory *factory) 7 | { 8 | factory->ops = &ops; 9 | } 10 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_factory.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIDGET_FACTORY_H_ 3 | #define WIDGET_FACTORY_H_ 4 | 5 | #include "widget.h" 6 | 7 | struct widget_factory_ops; 8 | struct widget_factory { 9 | struct widget_factory_ops *ops; 10 | }; 11 | 12 | struct widget_factory_ops { 13 | struct widget *(*create_button)(struct widget_factory *); 14 | struct widget *(*create_menu)(struct widget_factory *); 15 | }; 16 | 17 | void widget_factory_init(struct widget_factory *); 18 | 19 | static inline 20 | struct widget *widget_factory_create_button(struct widget_factory *factory) 21 | { 22 | return factory->ops->create_button(factory); 23 | } 24 | 25 | static inline 26 | struct widget *widget_factory_create_menu(struct widget_factory *factory) 27 | { 28 | return factory->ops->create_menu(factory); 29 | } 30 | 31 | #endif /* WIDGET_FACTORY_H_ */ 32 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_factory_motif.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIDGET_FACTORY_MOTIF_H_ 3 | #define WIDGET_FACTORY_MOTIF_H_ 4 | 5 | #include "widget_factory.h" 6 | 7 | struct widget_factory_motif { 8 | struct widget_factory factory; 9 | }; 10 | 11 | void widget_factory_motif_init(struct widget_factory_motif *); 12 | 13 | #endif /* WIDGET_FACTORY_MOTIF_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_factory_windows.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIDGET_FACTORY_WINDOWS_H_ 3 | #define WIDGET_FACTORY_WINDOWS_H_ 4 | 5 | #include "widget_factory.h" 6 | 7 | struct widget_factory_windows { 8 | struct widget_factory factory; 9 | }; 10 | 11 | void widget_factory_windows_init(struct widget_factory_windows *); 12 | 13 | #endif /* WIDGET_FACTORY_WINDOWS_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_motif_button.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "widget_motif_button.h" 5 | 6 | static void motif_button_draw(struct widget *widget) 7 | { 8 | printf("motif::button.draw()\n"); 9 | } 10 | 11 | static struct widget_ops ops = { 12 | .draw = motif_button_draw, 13 | }; 14 | 15 | void widget_motif_button_init(struct widget_motif_button *widget) 16 | { 17 | widget_init(&widget->widget); 18 | CLASS_OPS_INIT(widget->widget.ops, ops); 19 | } 20 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_motif_button.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIDGET_MOTIF_BUTTON_H_ 3 | #define WIDGET_MOTIF_BUTTON_H_ 4 | 5 | #include "widget.h" 6 | 7 | struct widget_motif_button { 8 | struct widget widget; 9 | }; 10 | 11 | void widget_motif_button_init(struct widget_motif_button *); 12 | 13 | #endif /* WIDGET_MOTIF_BUTTON_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_motif_menu.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "widget_motif_menu.h" 5 | 6 | static void motif_menu_draw(struct widget *widget) 7 | { 8 | printf("motif::menu.draw()\n"); 9 | } 10 | 11 | static struct widget_ops ops = { 12 | .draw = motif_menu_draw, 13 | }; 14 | 15 | void widget_motif_menu_init(struct widget_motif_menu *widget) 16 | { 17 | widget_init(&widget->widget); 18 | CLASS_OPS_INIT(widget->widget.ops, ops); 19 | } 20 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_motif_menu.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIDGET_MOTIF_MENU_H_ 3 | #define WIDGET_MOTIF_MENU_H_ 4 | 5 | #include "widget.h" 6 | 7 | struct widget_motif_menu { 8 | struct widget widget; 9 | }; 10 | 11 | void widget_motif_menu_init(struct widget_motif_menu *); 12 | 13 | #endif /* WIDGET_MOTIF_MENU_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_windows_button.c: -------------------------------------------------------------------------------- 1 | 2 | #include /* printf */ 3 | #include 4 | #include "widget_windows_button.h" 5 | 6 | static void windows_button_draw(struct widget *widget) 7 | { 8 | printf("windows::button.draw()\n"); 9 | } 10 | 11 | static struct widget_ops ops = { 12 | .draw = windows_button_draw, 13 | }; 14 | 15 | void widget_windows_button_init(struct widget_windows_button *widget) 16 | { 17 | widget_init(&widget->widget); 18 | CLASS_OPS_INIT(widget->widget.ops, ops); 19 | } 20 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_windows_button.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIDGET_WINDOWS_BUTTON_H_ 3 | #define WIDGET_WINDOWS_BUTTON_H_ 4 | 5 | #include "widget.h" 6 | 7 | struct widget_windows_button { 8 | struct widget widget; 9 | }; 10 | 11 | void widget_windows_button_init(struct widget_windows_button *); 12 | 13 | #endif /* WIDGET_WINDOWS_BUTTON_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_windows_menu.c: -------------------------------------------------------------------------------- 1 | 2 | #include /* printf */ 3 | #include 4 | #include "widget_windows_menu.h" 5 | 6 | static void windows_menu_draw(struct widget *widget) 7 | { 8 | printf("windows::menu.draw()\n"); 9 | } 10 | 11 | static struct widget_ops ops = { 12 | .draw = windows_menu_draw, 13 | }; 14 | 15 | void widget_windows_menu_init(struct widget_windows_menu *widget) 16 | { 17 | widget_init(&widget->widget); 18 | CLASS_OPS_INIT(widget->widget.ops, ops); 19 | } 20 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/GoF_family_object/widget_windows_menu.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIDGET_WINDOWS_MENU_H_ 3 | #define WIDGET_WINDOWS_MENU_H_ 4 | 5 | #include "widget.h" 6 | 7 | struct widget_windows_menu { 8 | struct widget widget; 9 | }; 10 | 11 | void widget_windows_menu_init(struct widget_windows_menu *); 12 | 13 | #endif /* WIDGET_WINDOWS_MENU_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/README.md: -------------------------------------------------------------------------------- 1 | Problem 2 | ======= 3 | 4 | Assume our customers require organic pizza, this's the second dimension of our product, and also an orthogonality with the existed functions. 5 | This sample base on the Factory-Method sample which providing standard-pizza(cheese,vaggie) and greek-pizza(also cheese,vaggie), 6 | So we come front the new issues: 7 | * How to offer our customers organic type of these four kinds pizza? 8 | * Also our customers can choose traditional type. 9 | * Try to implement the new feature with less and no-invasion code. 10 | 11 | Dimensions 12 | ---------- 13 | 14 | 1. Dimension-one: We have cheese, veggie pizza. 15 | 2. Dimension-two: Then we can provide Greek-style option 16 | 3. Dimension-three: Then we can provide organic option for all pizza 17 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/cheese_pizza_v2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "pizza_ingredient_factory.h" 5 | #include "cheese_pizza_v2.h" 6 | 7 | static void cheese_v2_prepare(struct pizza *pizza) 8 | { 9 | struct cheese_pizza_v2 *cheese = container_of(pizza, typeof(*cheese), pizza.pizza); 10 | 11 | CLASS_SUPER(pizza, prepare); 12 | 13 | pizza->dough = *pizza_ingredient_factory_create_dough(cheese->factory); 14 | pizza->sauce = *pizza_ingredient_factory_create_sauce(cheese->factory); 15 | printf("cheese_pizza_v2::prepare()\n"); 16 | } 17 | 18 | static struct pizza_ops cheese_v2_ops = { 19 | .prepare = cheese_v2_prepare, 20 | }; 21 | 22 | void cheese_pizza_v2_init(struct cheese_pizza_v2 *pizza, enum pizza_size_type type, 23 | struct pizza_ingredient_factory *factory) 24 | { 25 | cheese_pizza_init(&pizza->pizza, type); 26 | CLASS_OPS_INIT_SUPER(pizza->pizza.pizza.ops, cheese_v2_ops); 27 | pizza->factory = factory; 28 | } 29 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/cheese_pizza_v2.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CHEESE_PIZZA_V2_H_ 3 | #define CHEESE_PIZZA_V2_H_ 4 | 5 | #include "../../cheese_pizza.h" 6 | #include "pizza_ingredient_factory.h" 7 | 8 | struct cheese_pizza_v2 { 9 | struct cheese_pizza pizza; 10 | struct pizza_ingredient_factory *factory; 11 | }; 12 | 13 | void cheese_pizza_v2_init(struct cheese_pizza_v2 *, enum pizza_size_type type, 14 | struct pizza_ingredient_factory *); 15 | 16 | #endif /* CHEESE_PIZZA_V2_H_ */ 17 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/pizza_factory_standard_v2.h: -------------------------------------------------------------------------------- 1 | /* Normal style pizza */ 2 | #ifndef PIZZA_FACTORY_STANDARD_V2_H_ 3 | #define PIZZA_FACTORY_STANDARD_V2_H_ 4 | 5 | #include "../two_dimension/pizza_factory.h" 6 | #include "pizza_ingredient_factory.h" 7 | 8 | struct pizza_factory_standard_v2 { 9 | struct pizza_factory factory; 10 | struct pizza_ingredient_factory *ingredient_factory; 11 | }; 12 | 13 | void pizza_factory_standard_v2_init(struct pizza_factory_standard_v2 *, 14 | struct pizza_ingredient_factory *); 15 | 16 | #endif /* PIZZA_FACTORY_STANDARD_V2_H_ */ 17 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/pizza_ingredient_factory.c: -------------------------------------------------------------------------------- 1 | 2 | #include "pizza_ingredient_factory.h" 3 | 4 | static struct pizza_ingredient_factory_ops ops = {0}; /* virtual */ 5 | 6 | void pizza_ingredient_factory_init(struct pizza_ingredient_factory *factory) 7 | { 8 | factory->ops = &ops; 9 | } 10 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/pizza_ingredient_factory.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PIZZA_INGREDIENT_FACTORY_H_ 3 | #define PIZZA_INGREDIENT_FACTORY_H_ 4 | 5 | #include "../../pizza.h" 6 | 7 | struct pizza_ingredient_factory_ops; 8 | struct pizza_ingredient_factory { 9 | struct pizza_ingredient_factory_ops *ops; 10 | }; 11 | 12 | struct pizza_ingredient_factory_ops { 13 | struct pizza_dough *(*create_dough)(struct pizza_ingredient_factory *); 14 | struct pizza_sauce *(*create_sauce)(struct pizza_ingredient_factory *); 15 | }; 16 | 17 | void pizza_ingredient_factory_init(struct pizza_ingredient_factory *); 18 | 19 | static inline 20 | struct pizza_dough *pizza_ingredient_factory_create_dough(struct pizza_ingredient_factory *factory) 21 | { 22 | return factory->ops->create_dough(factory); 23 | } 24 | 25 | static inline 26 | struct pizza_sauce *pizza_ingredient_factory_create_sauce(struct pizza_ingredient_factory *factory) 27 | { 28 | return factory->ops->create_sauce(factory); 29 | } 30 | 31 | #endif /* PIZZA_INGREDIENT_FACTORY_H_ */ 32 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/pizza_ingredient_factory_no_organic.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PIZZA_INGREDIENT_FACTORY_NO_ORGANIC_H_ 3 | #define PIZZA_INGREDIENT_FACTORY_NO_ORGANIC_H_ 4 | 5 | #include "pizza_ingredient_factory.h" 6 | 7 | struct pizza_ingredient_factory_no_organic { 8 | struct pizza_ingredient_factory factory; 9 | }; 10 | 11 | void pizza_ingredient_factory_no_organic_init(struct pizza_ingredient_factory_no_organic *); 12 | 13 | #endif /* PIZZA_INGREDIENT_FACTORY_NO_ORGANIC_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/pizza_ingredient_factory_organic.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PIZZA_INGREDIENT_FACTORY_ORGANIC_H_ 3 | #define PIZZA_INGREDIENT_FACTORY_ORGANIC_H_ 4 | 5 | #include "pizza_ingredient_factory.h" 6 | 7 | struct pizza_ingredient_factory_organic { 8 | struct pizza_ingredient_factory factory; 9 | }; 10 | 11 | void pizza_ingredient_factory_organic_init(struct pizza_ingredient_factory_organic *); 12 | 13 | #endif /* PIZZA_INGREDIENT_FACTORY_ORGANIC_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/veggie_pizza_v2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "pizza_ingredient_factory.h" 5 | #include "veggie_pizza_v2.h" 6 | #include "../../veggie_pizza.h" 7 | 8 | static void veggie_v2_prepare(struct pizza *pizza) 9 | { 10 | struct veggie_pizza_v2 *veggie = container_of(pizza, typeof(*veggie), pizza.pizza); 11 | 12 | CLASS_SUPER(pizza, prepare); 13 | 14 | pizza->dough = *pizza_ingredient_factory_create_dough(veggie->factory); 15 | pizza->sauce = *pizza_ingredient_factory_create_sauce(veggie->factory); 16 | printf("veggie_pizza_v2::prepare()\n"); 17 | } 18 | 19 | static struct pizza_ops ops = { 20 | .prepare = veggie_v2_prepare, 21 | }; 22 | 23 | void veggie_pizza_v2_init(struct veggie_pizza_v2 *pizza, enum pizza_size_type type, 24 | struct pizza_ingredient_factory *factory) 25 | { 26 | veggie_pizza_init(&pizza->pizza, type); 27 | CLASS_OPS_INIT_SUPER(pizza->pizza.pizza.ops, ops); 28 | pizza->factory = factory; 29 | } 30 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/three_dimension/veggie_pizza_v2.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef VEGGIE_PIZZA_V2_H_ 3 | #define VEGGIE_PIZZA_V2_H_ 4 | 5 | #include "../../veggie_pizza.h" 6 | #include "pizza_ingredient_factory.h" 7 | 8 | struct veggie_pizza_v2 { 9 | struct veggie_pizza pizza; 10 | struct pizza_ingredient_factory *factory; 11 | }; 12 | 13 | void veggie_pizza_v2_init(struct veggie_pizza_v2 *, enum pizza_size_type type, 14 | struct pizza_ingredient_factory *); 15 | 16 | #endif /* VEGGIE_PIZZA_V2_H_ */ 17 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/README.md: -------------------------------------------------------------------------------- 1 | Problem 2 | ======= 3 | 4 | We have Cheese, Veggie pizza. Now we want add these two pizza have Greek-style option. 5 | So have Greek-style or not is another dimension which our customers can choose. 6 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/greek_cheese_pizza.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GREEK_CHEESE_PIZZA_H_ 3 | #define GREEK_CHEESE_PIZZA_H_ 4 | 5 | #include "pizza.h" 6 | 7 | struct greek_cheese_pizza { 8 | struct pizza pizza; 9 | }; 10 | 11 | void greek_cheese_pizza_init(struct greek_cheese_pizza *, enum pizza_size_type); 12 | 13 | #endif /* GREEK_CHEESE_PIZZA_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/greek_veggie_pizza.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GREEK_VEGGIE_PIZZA_H_ 3 | #define GREEK_VEGGIE_PIZZA_H_ 4 | 5 | #include "pizza.h" 6 | 7 | struct greek_veggie_pizza { 8 | struct pizza pizza; 9 | }; 10 | 11 | void greek_veggie_pizza_init(struct greek_veggie_pizza *, enum pizza_size_type); 12 | 13 | #endif /* GREEK_VEGGIE_PIZZA_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/pizza_factory.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "pizza_factory.h" 4 | 5 | static struct pizza_factory_ops ops = {0}; /* virtual */ 6 | 7 | void pizza_factory_init(struct pizza_factory *factory) 8 | { 9 | factory->ops = &ops; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/pizza_factory.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PIZZA_FACTORY_H_ 3 | #define PIZZA_FACTORY_H_ 4 | 5 | #include "../../pizza.h" 6 | 7 | struct pizza_factory_ops; 8 | struct pizza_factory { /* interface */ 9 | struct pizza_factory_ops *ops; 10 | }; 11 | 12 | struct pizza_factory_ops { 13 | /* virtual | private, implement by sub-class */ 14 | struct pizza *(*create)(struct pizza_factory *, const char *name, enum pizza_size_type size); 15 | void (*free)(struct pizza_factory *); 16 | }; 17 | 18 | static inline 19 | struct pizza *pizza_factory_create(struct pizza_factory *factory, 20 | const char *name, enum pizza_size_type size) 21 | { 22 | return factory->ops->create(factory, name, size); 23 | } 24 | 25 | static inline 26 | void pizza_factory_free(struct pizza_factory *factory) 27 | { 28 | factory->ops->free(factory); 29 | } 30 | 31 | void pizza_factory_init(struct pizza_factory *); 32 | 33 | #endif /* PIZZA_FACTORY_H_ */ 34 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/pizza_factory_greek.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PIZZA_FACTORY_GREEK_H_ 3 | #define PIZZA_FACTORY_GREEK_H_ 4 | 5 | #include "pizza_factory.h" 6 | 7 | struct pizza_factory_greek { 8 | struct pizza_factory factory; 9 | }; 10 | 11 | void pizza_factory_greek_init(struct pizza_factory_greek *); 12 | 13 | #endif /* PIZZA_FACTORY_GREEK_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/pizza_factory_standard.h: -------------------------------------------------------------------------------- 1 | /* Normal style pizza */ 2 | #ifndef PIZZA_FACTORY_STANDARD_H_ 3 | #define PIZZA_FACTORY_STANDARD_H_ 4 | 5 | #include "pizza_factory.h" 6 | 7 | struct pizza_factory_standard { 8 | struct pizza_factory factory; 9 | }; 10 | 11 | void pizza_factory_standard_init(struct pizza_factory_standard *); 12 | 13 | #endif /* PIZZA_FACTORY_STANDARD_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/pizza_store3.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "pizza_store3.h" 4 | 5 | struct pizza *pizza_store3_order_pizza(struct pizza_store3 *store, 6 | const char *name, enum pizza_size_type size) 7 | { 8 | struct pizza *pizza; 9 | 10 | pizza = pizza_factory_create(store->factory, name, size); 11 | if (!pizza) 12 | return 0; 13 | 14 | pizza_prepare(pizza); 15 | pizza_bake(pizza); 16 | pizza_cut(pizza); 17 | pizza_box(pizza); 18 | 19 | return pizza; 20 | } 21 | 22 | void pizza_store3_init(struct pizza_store3 *store) 23 | { 24 | store->factory = 0; 25 | } 26 | 27 | void pizza_store3_free(struct pizza_store3 *store) 28 | { 29 | if (store->factory) 30 | pizza_factory_free(store->factory); 31 | } 32 | 33 | void pizza_store3_set_factory(struct pizza_store3 *store, struct pizza_factory *factory) 34 | { 35 | if (store->factory) 36 | pizza_factory_free(store->factory); 37 | store->factory = factory; 38 | } 39 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/pizza_store3.h: -------------------------------------------------------------------------------- 1 | /**PizzaStore3 2 | Depend on the interface|abstract pizza_factory, 3 | the implement of how to CreatePizza delay to Sub-Class 4 | */ 5 | #ifndef PIZZA_STORE3_H_ 6 | #define PIZZA_STORE3_H_ 7 | 8 | #include "../../pizza.h" 9 | #include "../two_dimension/pizza_factory.h" 10 | 11 | struct pizza_store3 { 12 | struct pizza_factory *factory; 13 | }; 14 | 15 | void pizza_store3_init(struct pizza_store3 *); 16 | void pizza_store3_free(struct pizza_store3 *); 17 | void pizza_store3_set_factory(struct pizza_store3 *, struct pizza_factory *); 18 | 19 | /* static method */ 20 | struct pizza *pizza_store3_order_pizza(struct pizza_store3 *, 21 | const char *name, enum pizza_size_type); 22 | 23 | #endif /* PIZZA_STORE3_H_ */ 24 | -------------------------------------------------------------------------------- /auto-gen/factory/abstract_factory/two_dimension/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/cheese_pizza.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CHEESE_PIZZA_H_ 3 | #define CHEESE_PIZZA_H_ 4 | 5 | #include "pizza.h" 6 | 7 | struct cheese_pizza { 8 | struct pizza pizza; 9 | }; 10 | 11 | void cheese_pizza_init(struct cheese_pizza *, enum pizza_size_type); 12 | 13 | #endif /* CHEESE_PIZZA_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/concrete_product_1.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "concrete_product_1.h" 7 | 8 | 9 | static void concrete_product_1_ops_do_it(struct product *product, int a, int b) 10 | { 11 | printf("concrete_product_1::do_it()\n"); 12 | } 13 | 14 | static struct product_ops product_ops = { 15 | .do_it = concrete_product_1_ops_do_it, 16 | }; 17 | 18 | 19 | void concrete_product_1_init(struct concrete_product_1 *concrete_product_1) 20 | { 21 | memset(concrete_product_1, sizeof(*concrete_product_1), 0); 22 | product_init(&concrete_product_1->product); 23 | CLASS_OPS_INIT(concrete_product_1->product.ops, product_ops); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/concrete_product_1.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CONCRETE_PRODUCT_1_H__ 3 | #define __CONCRETE_PRODUCT_1_H__ 4 | #include "product.h" 5 | 6 | 7 | struct concrete_product_1 { 8 | struct product product; 9 | }; 10 | 11 | void concrete_product_1_init(struct concrete_product_1 *); 12 | 13 | 14 | 15 | #endif /* __CONCRETE_PRODUCT_1_H__ */ 16 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/concrete_product_2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "concrete_product_2.h" 7 | 8 | 9 | static void concrete_product_2_ops_do_it(struct product *product, int a, int b) 10 | { 11 | printf("concrete_product_2::do_it()\n"); 12 | } 13 | 14 | static struct product_ops product_ops = { 15 | .do_it = concrete_product_2_ops_do_it, 16 | }; 17 | 18 | 19 | void concrete_product_2_init(struct concrete_product_2 *concrete_product_2) 20 | { 21 | memset(concrete_product_2, sizeof(*concrete_product_2), 0); 22 | product_init(&concrete_product_2->product); 23 | CLASS_OPS_INIT(concrete_product_2->product.ops, product_ops); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/concrete_product_2.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CONCRETE_PRODUCT_2_H__ 3 | #define __CONCRETE_PRODUCT_2_H__ 4 | #include "product.h" 5 | 6 | 7 | struct concrete_product_2 { 8 | struct product product; 9 | }; 10 | 11 | void concrete_product_2_init(struct concrete_product_2 *); 12 | 13 | 14 | 15 | #endif /* __CONCRETE_PRODUCT_2_H__ */ 16 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/factory.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include "factory.h" 7 | 8 | 9 | static struct product * factory_ops_create(struct factory *factory) 10 | { 11 | printf("factory::create()\n"); 12 | return 0; 13 | } 14 | static struct factory_ops factory_ops = { 15 | .create = factory_ops_create, 16 | }; 17 | 18 | void factory_init(struct factory *factory) 19 | { 20 | memset(factory, sizeof(*factory), 0); 21 | factory->ops = &factory_ops; 22 | } 23 | 24 | 25 | void factory_do_it(struct factory *factory) 26 | { 27 | printf("factory::do_it()\n"); 28 | } -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/factory.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __FACTORY_H__ 3 | #define __FACTORY_H__ 4 | 5 | 6 | struct factory_ops; 7 | struct factory { 8 | struct factory_ops *ops; 9 | }; 10 | struct factory_ops { 11 | struct product * (*create)(struct factory *); 12 | }; 13 | void factory_init(struct factory *); 14 | 15 | void factory_do_it(struct factory *); 16 | 17 | static inline struct product * factory_create(struct factory *factory) 18 | { 19 | return factory->ops->create(factory); 20 | } 21 | 22 | #endif /* __FACTORY_H__ */ 23 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/factory_product_1.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "concrete_product_1.h" 7 | #include "factory_product_1.h" 8 | 9 | 10 | static struct product * factory_product_1_ops_create(struct factory *factory) 11 | { 12 | struct concrete_product_1 *p1; 13 | 14 | printf("factory_product_1::create()\n"); 15 | p1 = malloc(sizeof(*p1)); 16 | concrete_product_1_init(p1); 17 | return &p1->product; 18 | } 19 | 20 | static struct factory_ops factory_ops = { 21 | .create = factory_product_1_ops_create, 22 | }; 23 | 24 | 25 | void factory_product_1_init(struct factory_product_1 *factory_product_1) 26 | { 27 | memset(factory_product_1, sizeof(*factory_product_1), 0); 28 | factory_init(&factory_product_1->factory); 29 | CLASS_OPS_INIT(factory_product_1->factory.ops, factory_ops); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/factory_product_1.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __FACTORY_PRODUCT_1_H__ 3 | #define __FACTORY_PRODUCT_1_H__ 4 | #include "factory.h" 5 | 6 | 7 | struct factory_product_1 { 8 | struct factory factory; 9 | }; 10 | 11 | void factory_product_1_init(struct factory_product_1 *); 12 | 13 | 14 | 15 | #endif /* __FACTORY_PRODUCT_1_H__ */ 16 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/factory_product_2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "concrete_product_2.h" 7 | #include "factory_product_2.h" 8 | 9 | 10 | static struct product * factory_product_2_ops_create(struct factory *factory) 11 | { 12 | struct concrete_product_2 *p2; 13 | 14 | printf("factory_product_2::create()\n"); 15 | p2 = malloc(sizeof(*p2)); 16 | concrete_product_2_init(p2); 17 | return &p2->product; 18 | } 19 | 20 | static struct factory_ops factory_ops = { 21 | .create = factory_product_2_ops_create, 22 | }; 23 | 24 | 25 | void factory_product_2_init(struct factory_product_2 *factory_product_2) 26 | { 27 | memset(factory_product_2, sizeof(*factory_product_2), 0); 28 | factory_init(&factory_product_2->factory); 29 | CLASS_OPS_INIT(factory_product_2->factory.ops, factory_ops); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/factory_product_2.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __FACTORY_PRODUCT_2_H__ 3 | #define __FACTORY_PRODUCT_2_H__ 4 | #include "factory.h" 5 | 6 | 7 | struct factory_product_2 { 8 | struct factory factory; 9 | }; 10 | 11 | void factory_product_2_init(struct factory_product_2 *); 12 | 13 | 14 | 15 | #endif /* __FACTORY_PRODUCT_2_H__ */ 16 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/product.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include "product.h" 7 | 8 | 9 | static void product_ops_do_it(struct product *product, int a, int b) 10 | { 11 | printf("product::do_it()\n"); 12 | } 13 | static struct product_ops product_ops = { 14 | .do_it = product_ops_do_it, 15 | }; 16 | 17 | void product_init(struct product *product) 18 | { 19 | memset(product, sizeof(*product), 0); 20 | product->ops = &product_ops; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/product.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PRODUCT_H__ 3 | #define __PRODUCT_H__ 4 | 5 | 6 | struct product_ops; 7 | struct product { 8 | struct product_ops *ops; 9 | char name[32]; 10 | }; 11 | struct product_ops { 12 | void (*do_it)(struct product *, int a, int b); 13 | }; 14 | void product_init(struct product *); 15 | 16 | 17 | static inline void product_do_it(struct product *product, int a, int b) 18 | { 19 | product->ops->do_it(product, a, b); 20 | } 21 | 22 | #endif /* __PRODUCT_H__ */ 23 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/GoF_product/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = #proj1 proj2 proj_n proj_m 10 | SUBDIRS = 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/README.md: -------------------------------------------------------------------------------- 1 | Problem 2 | ======= 3 | 4 | Assume we have some class Service, that has two dependencies: an IDatabaseAccessHandler and an IFileAccessHandler which can be disiced at first. 5 | Now this class Service also has other dependencies, such as functional dependencies like an IDomain which be decised at runtime. 6 | * I'd also need to pass a IDomain object in the constructor. 7 | * How to instantiating the class Service in a elegant way? 8 | 9 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/domain_class.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * domain_class.c 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "domain_class.h" 20 | 21 | 22 | 23 | void domain_class_init(struct domain_class *domain_class) 24 | { 25 | memset(domain_class, sizeof(*domain_class), 0); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/domain_class.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * domain_class.h 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #ifndef __DOMAIN_CLASS_H__ 16 | #define __DOMAIN_CLASS_H__ 17 | 18 | 19 | 20 | struct domain_class { 21 | }; 22 | 23 | void domain_class_init(struct domain_class *); 24 | 25 | 26 | 27 | #endif /* __DOMAIN_CLASS_H__ */ 28 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/factory.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * factory.c 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "factory.h" 20 | 21 | 22 | static struct product * factory_ops_create(struct factory *factory, struct domain_class *dc) 23 | { 24 | printf("factory::create()\n"); 25 | return 0; 26 | } 27 | static struct factory_ops factory_ops = { 28 | .create = factory_ops_create, 29 | }; 30 | 31 | void factory_init(struct factory *factory) 32 | { 33 | memset(factory, sizeof(*factory), 0); 34 | factory->ops = &factory_ops; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/file_access_handler.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * file_access_handler.c 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "file_access_handler.h" 20 | 21 | 22 | 23 | void file_access_handler_init(struct file_access_handler *file_access_handler) 24 | { 25 | memset(file_access_handler, sizeof(*file_access_handler), 0); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/file_access_handler.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * file_access_handler.h 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #ifndef __FILE_ACCESS_HANDLER_H__ 16 | #define __FILE_ACCESS_HANDLER_H__ 17 | 18 | 19 | 20 | struct file_access_handler { 21 | }; 22 | 23 | void file_access_handler_init(struct file_access_handler *); 24 | 25 | 26 | 27 | #endif /* __FILE_ACCESS_HANDLER_H__ */ 28 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/product.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * product.c 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "product.h" 20 | 21 | 22 | 23 | void product_init(struct product *product) 24 | { 25 | memset(product, sizeof(*product), 0); 26 | } 27 | 28 | 29 | void product_do_something(struct product *product) 30 | { 31 | printf("product::do_something()\n"); 32 | } -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/product.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * product.h 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #ifndef __PRODUCT_H__ 16 | #define __PRODUCT_H__ 17 | 18 | 19 | 20 | struct product { 21 | char name[32]; 22 | }; 23 | 24 | void product_init(struct product *); 25 | 26 | void product_do_something(struct product *); 27 | 28 | 29 | #endif /* __PRODUCT_H__ */ 30 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/serializer.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * serializer.c 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #include 16 | #include 17 | #include 18 | 19 | #include "serializer.h" 20 | 21 | 22 | 23 | void serializer_init(struct serializer *serializer) 24 | { 25 | memset(serializer, sizeof(*serializer), 0); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/serializer.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * serializer.h 2014-04-29 17:03:57 4 | * anonymouse(anonymouse@email) 5 | * 6 | * Copyright (C) 2000-2014 All Right Reserved 7 | * 8 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 9 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 11 | * PARTICULAR PURPOSE. 12 | * 13 | * Auto generate for Design Patterns in C 14 | */ 15 | #ifndef __SERIALIZER_H__ 16 | #define __SERIALIZER_H__ 17 | 18 | 19 | 20 | struct serializer { 21 | }; 22 | 23 | void serializer_init(struct serializer *); 24 | 25 | 26 | 27 | #endif /* __SERIALIZER_H__ */ 28 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include "product.h" 7 | #include "factory_product.h" 8 | #include "domain_class.h" 9 | #include "serializer.h" 10 | #include "file_access_handler.h" 11 | 12 | static int test_two_stage(char *output, size_t sz) 13 | { 14 | struct factory_product *factory; 15 | struct serializer *serializer; 16 | struct file_access_handler *file_handler; 17 | struct domain_class *dc; 18 | 19 | serializer = malloc(sizeof(*serializer)); // sanity check 20 | file_handler = malloc(sizeof(*file_handler)); // sanity check 21 | factory = malloc(sizeof(*factory)); // sanity check 22 | factory_product_init(factory, serializer, file_handler); 23 | 24 | dc = malloc(sizeof(*dc)); // sanity check 25 | product_do_something(factory_create(&factory->factory, dc)); 26 | 27 | return 0; 28 | } 29 | 30 | void two_stage_test(void); 31 | void two_stage_test(void) 32 | { 33 | my_test_suite_add(test_two_stage, "Factory Method: two stage"); 34 | } 35 | -------------------------------------------------------------------------------- /auto-gen/factory/factory_method/two_stage/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/lib.mk: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = 8 | SOURCES = 9 | SUBPROJS = # 10 | SUBDIRS = # 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/factory/pizza.c: -------------------------------------------------------------------------------- 1 | 2 | #include /* memset */ 3 | #include /* printf */ 4 | #include 5 | #include "pizza.h" 6 | 7 | static void pizza_ops_prepare(struct pizza *pizza) 8 | { 9 | printf("pizza::prepare()\n"); 10 | pizza->dough = (struct pizza_dough){.ingredient = pizza_ingredient_no_organic}; 11 | pizza->sauce = (struct pizza_sauce){.ingredient = pizza_ingredient_no_organic}; 12 | } 13 | 14 | static struct pizza_ops pizza_ops = { /* virtual method */ 15 | .prepare = pizza_ops_prepare, 16 | }; 17 | 18 | void pizza_init(struct pizza *pizza) 19 | { 20 | pizza->ops = &pizza_ops; 21 | memset(pizza->name, 0, sizeof(pizza->name)); 22 | pizza->size = pizza_size_normal; 23 | pizza->dough = (struct pizza_dough){.ingredient = pizza_ingredient_null}; 24 | pizza->sauce = (struct pizza_sauce){.ingredient = pizza_ingredient_null}; 25 | } 26 | -------------------------------------------------------------------------------- /auto-gen/factory/projs.mk: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = # 10 | SUBDIRS = # 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/factory/simple_factory/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/factory/simple_factory/pizza_simple_factory.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "cheese_pizza.h" 5 | #include "veggie_pizza.h" 6 | #include "pizza_simple_factory.h" 7 | 8 | static struct pizza *simple_factory_create(const char *name, enum pizza_size_type size) 9 | { 10 | struct pizza *pizza = 0; 11 | struct cheese_pizza *cheese; 12 | struct veggie_pizza *veggie; 13 | 14 | if (!strcmp(name, "cheese")) { 15 | cheese = malloc(sizeof(*cheese)); 16 | if (!cheese) 17 | return 0; 18 | 19 | cheese_pizza_init(cheese, size); 20 | pizza = &cheese->pizza; 21 | } 22 | else if (!strcmp(name, "veggie")) { 23 | veggie = malloc(sizeof(*veggie)); 24 | if (!veggie) 25 | return 0; 26 | 27 | veggie_pizza_init(veggie, size); 28 | pizza = &veggie->pizza; 29 | } 30 | return pizza; 31 | } 32 | 33 | static struct pizza_simple_factory_ops ops = { 34 | .create = simple_factory_create, 35 | }; 36 | 37 | void pizza_simple_factory_init(struct pizza_simple_factory *factory) 38 | { 39 | factory->ops = &ops; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /auto-gen/factory/simple_factory/pizza_simple_factory.h: -------------------------------------------------------------------------------- 1 | /**Simple Factory 2 | Encapsulate the create method into class, 3 | let the store just depend on this factory. 4 | */ 5 | #ifndef PIZZA_SIMPLE_FACTORY_H_ 6 | #define PIZZA_SIMPLE_FACTORY_H_ 7 | 8 | #include "pizza.h" 9 | 10 | struct pizza_simple_factory_ops; 11 | struct pizza_simple_factory { 12 | struct pizza_simple_factory_ops *ops; 13 | }; 14 | 15 | struct pizza_simple_factory_ops { 16 | struct pizza *(*create)(const char *name, enum pizza_size_type size); 17 | }; 18 | 19 | static inline 20 | struct pizza *pizza_simple_factory_create(struct pizza_simple_factory *factory, 21 | const char *name, enum pizza_size_type size) 22 | { 23 | return factory->ops->create(name, size); 24 | } 25 | 26 | void pizza_simple_factory_init(struct pizza_simple_factory *); 27 | 28 | #endif /* PIZZA_SIMPLE_FACTORY_H_ */ 29 | -------------------------------------------------------------------------------- /auto-gen/factory/simple_factory/pizza_store2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "pizza_store2.h" 4 | 5 | struct pizza *pizza_store2_order_pizza(struct pizza_store2 *store, 6 | const char *name, enum pizza_size_type size) 7 | { 8 | struct pizza *pizza; 9 | 10 | pizza = pizza_simple_factory_create(store->factory, name, size); 11 | if (!pizza) 12 | return 0; 13 | 14 | pizza_prepare(pizza); 15 | pizza_bake(pizza); 16 | pizza_cut(pizza); 17 | pizza_box(pizza); 18 | 19 | return pizza; 20 | } 21 | 22 | void pizza_store2_init(struct pizza_store2 *store, struct pizza_simple_factory *factory) 23 | { 24 | store->factory = factory; 25 | } 26 | 27 | void pizza_store2_free(struct pizza_store2 *store) 28 | { 29 | free(store->factory); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /auto-gen/factory/simple_factory/pizza_store2.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PIZZA_STORE2_H_ 3 | #define PIZZA_STORE2_H_ 4 | 5 | #include "pizza.h" 6 | #include "pizza_simple_factory.h" 7 | 8 | struct pizza_store2 { 9 | struct pizza_simple_factory *factory; 10 | }; 11 | 12 | /* static method */ 13 | void pizza_store2_init(struct pizza_store2 *, struct pizza_simple_factory *); 14 | void pizza_store2_free(struct pizza_store2 *); 15 | struct pizza *pizza_store2_order_pizza(struct pizza_store2 *, 16 | const char *name, enum pizza_size_type); 17 | 18 | #endif /* PIZZA_STORE2_H_ */ 19 | -------------------------------------------------------------------------------- /auto-gen/factory/simple_factory/test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include "pizza_store2.h" 8 | #include "pizza_simple_factory.h" 9 | 10 | static int test_simple_factory(char *output, size_t sz) 11 | { 12 | struct pizza *pizza; 13 | struct pizza_store2 *store; 14 | struct pizza_simple_factory *factory; 15 | 16 | factory = malloc(sizeof(*factory)); 17 | pizza_simple_factory_init(factory); 18 | 19 | store = malloc(sizeof(*store)); 20 | pizza_store2_init(store, factory); 21 | 22 | pizza = pizza_store2_order_pizza(store, "cheese", pizza_size_large); 23 | pizza_free(pizza); 24 | 25 | pizza = pizza_store2_order_pizza(store, "veggie", pizza_size_normal); 26 | pizza_free(pizza); 27 | 28 | pizza_store2_free(store); 29 | 30 | return 0; 31 | } 32 | 33 | void factory_simple_test(void); 34 | void factory_simple_test(void) 35 | { 36 | my_test_suite_add(test_simple_factory, "Simple Factory"); 37 | } 38 | -------------------------------------------------------------------------------- /auto-gen/factory/simple_factory/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/static_factory/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/factory/static_factory/pizza_store.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PIZZA_STORE_H_ 3 | #define PIZZA_STORE_H_ 4 | 5 | #include "pizza.h" 6 | 7 | struct pizza *pizza_store_create_pizza(const char *name, enum pizza_size_type); 8 | struct pizza *pizza_store_order_pizza(const char *name, enum pizza_size_type); 9 | 10 | #endif /* PIZZA_STORE_H_ */ 11 | -------------------------------------------------------------------------------- /auto-gen/factory/static_factory/test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include "pizza_store.h" 8 | 9 | static int test_static_factory(char *output, size_t sz) 10 | { 11 | struct pizza *pizza; 12 | pizza = pizza_store_order_pizza("cheese", pizza_size_large); 13 | pizza_free(pizza); 14 | 15 | pizza = pizza_store_order_pizza("veggie", pizza_size_normal); 16 | pizza_free(pizza); 17 | 18 | return 0; 19 | } 20 | 21 | 22 | void factory_static_test(void); 23 | void factory_static_test(void) 24 | { 25 | my_test_suite_add(test_static_factory, "Static Factory"); 26 | } 27 | -------------------------------------------------------------------------------- /auto-gen/factory/static_factory/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/factory/veggie_pizza.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef VEGGIE_PIZZA_H_ 3 | #define VEGGIE_PIZZA_H_ 4 | 5 | #include "pizza.h" 6 | 7 | struct veggie_pizza { 8 | struct pizza pizza; 9 | }; 10 | 11 | void veggie_pizza_init(struct veggie_pizza *, enum pizza_size_type); 12 | 13 | #endif /* VEGGIE_PIZZA_H_ */ 14 | -------------------------------------------------------------------------------- /auto-gen/flyweight/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/flyweight/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/handle_body/graphic.pyns: -------------------------------------------------------------------------------- 1 | {'type':'node', 'id':'socket', 'attrs':'- _pimpl', 'meths':'+ socket()|+ open()|+ receive()', 'x':1, 'y':1, 'width':1, 'height':1} 2 | {'type':'node', 'id':'socket_impl', 'attrs':'- sock_id|- sockaddr|- buffer', 'meths':'+ socket_impl()|+ network_byte_order()', 'x':61, 'y':61, 'width':1, 'height':1} 3 | {'type':'edge', 'id':'socket_to_socket_impl', 'source':'socket', 'target':'socket_impl', 'uml_edge_type':'composition'} 4 | {'type':'edge', 'id':'socket_impl_to_sockaddr_un', 'source':'socket_impl', 'target':'sockaddr_un', 'uml_edge_type':'composition'} -------------------------------------------------------------------------------- /auto-gen/handle_body/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/handle_body/test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 2014-05-11 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "socket.h" 22 | 23 | static int test_main(void) 24 | { 25 | _MY_TRACE_STR("test::main()\n"); 26 | return 0; 27 | } 28 | 29 | static int test_main_entry(char *output, size_t sz) 30 | { 31 | test_main(); 32 | return 0; 33 | } 34 | 35 | void main_entry_test(void); 36 | void main_entry_test(void) 37 | { 38 | my_test_suite_add(test_main_entry, "Test handle_body"); 39 | } 40 | -------------------------------------------------------------------------------- /auto-gen/handle_body/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/interpreter/context.h: -------------------------------------------------------------------------------- 1 | /** 2 | * context.h 2014-05-17 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C * 13 | * 14 | * Uses a class hierarchy to represent the grammar given. 15 | */ 16 | #ifndef __CONTEXT_H__ 17 | #define __CONTEXT_H__ 18 | 19 | #include 20 | #include 21 | 22 | /** Hold the variable's eval value */ 23 | struct context { 24 | char _names[32][32]; 25 | int _values[32]; 26 | }; 27 | 28 | /** constructor(). */ 29 | void context_init(struct context *context); 30 | 31 | int context_get_value(struct context *context, char *name); 32 | void context_put_value(struct context *context, char *name, int val); 33 | 34 | #endif /* __CONTEXT_H__ */ 35 | -------------------------------------------------------------------------------- /auto-gen/interpreter/expression.h: -------------------------------------------------------------------------------- 1 | /** 2 | * expression.h 2014-05-17 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C * 13 | * 14 | * Uses a class hierarchy to represent the grammar given. 15 | */ 16 | #ifndef __EXPRESSION_H__ 17 | #define __EXPRESSION_H__ 18 | 19 | #include 20 | #include 21 | 22 | #include "operand.h" 23 | 24 | /** */ 25 | struct expression { 26 | struct operand operand; 27 | char _oper; 28 | struct operand * _left; 29 | struct operand * _right; 30 | }; 31 | 32 | /** constructor(). */ 33 | void expression_init(struct expression *expression, char oper); 34 | 35 | #endif /* __EXPRESSION_H__ */ 36 | -------------------------------------------------------------------------------- /auto-gen/interpreter/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/interpreter/number.h: -------------------------------------------------------------------------------- 1 | /** 2 | * number.h 2014-05-17 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C * 13 | * 14 | * Uses a class hierarchy to represent the grammar given. 15 | */ 16 | #ifndef __NUMBER_H__ 17 | #define __NUMBER_H__ 18 | 19 | #include 20 | #include 21 | 22 | #include "operand.h" 23 | 24 | /** */ 25 | struct number { 26 | struct operand operand; 27 | int _val; 28 | }; 29 | 30 | /** constructor(). */ 31 | void number_init(struct number *number, int val); 32 | 33 | #endif /* __NUMBER_H__ */ 34 | -------------------------------------------------------------------------------- /auto-gen/interpreter/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/interpreter/variable.h: -------------------------------------------------------------------------------- 1 | /** 2 | * variable.h 2014-05-17 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C * 13 | * 14 | * Uses a class hierarchy to represent the grammar given. 15 | */ 16 | #ifndef __VARIABLE_H__ 17 | #define __VARIABLE_H__ 18 | 19 | #include 20 | #include 21 | 22 | #include "operand.h" 23 | 24 | /** */ 25 | struct variable { 26 | struct operand operand; 27 | char * _name; 28 | }; 29 | 30 | /** constructor(). */ 31 | void variable_init(struct variable *variable, char *name); 32 | 33 | #endif /* __VARIABLE_H__ */ 34 | -------------------------------------------------------------------------------- /auto-gen/iterator/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/iterator/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/mediator/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/mediator/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/mvc/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = #proj1 proj2 proj_n proj_m 10 | SUBDIRS = 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/mvc/student/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/mvc/student/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/mvc/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/observer/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/observer/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/oop/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = # 8 | SOURCES = # 9 | SUBPROJS = #proj1 proj2 proj_n proj_m 10 | SUBDIRS = 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/oop/inheritance/child.h: -------------------------------------------------------------------------------- 1 | /** 2 | * child.h 2014-05-03 15:06:28 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __CHILD_H__ 15 | #define __CHILD_H__ 16 | 17 | #include 18 | 19 | #include "parent.h" 20 | 21 | struct child_ops; 22 | 23 | struct child { 24 | struct parent parent; 25 | struct child_ops *ops; 26 | int pub_data1; 27 | int pri_data2; 28 | }; 29 | struct child_ops { 30 | struct child_ops *__super; 31 | int static_pub_data3; 32 | int static_pri_data4; 33 | }; 34 | void child_init(struct child *); 35 | 36 | #endif /* __CHILD_H__ */ -------------------------------------------------------------------------------- /auto-gen/oop/inheritance/grandgirl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * grandgirl.h 2014-05-03 15:06:28 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __GRANDGIRL_H__ 15 | #define __GRANDGIRL_H__ 16 | 17 | #include 18 | 19 | #include "child.h" 20 | 21 | struct grandgirl { 22 | struct child child; 23 | }; 24 | 25 | void grandgirl_init(struct grandgirl *); 26 | 27 | #endif /* __GRANDGIRL_H__ */ -------------------------------------------------------------------------------- /auto-gen/oop/inheritance/grandson.h: -------------------------------------------------------------------------------- 1 | /** 2 | * grandson.h 2014-05-03 15:06:28 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __GRANDSON_H__ 15 | #define __GRANDSON_H__ 16 | 17 | #include 18 | 19 | #include "child.h" 20 | 21 | struct grandson { 22 | struct child child; 23 | }; 24 | 25 | void grandson_init(struct grandson *); 26 | 27 | #endif /* __GRANDSON_H__ */ -------------------------------------------------------------------------------- /auto-gen/oop/inheritance/inheritance.py: -------------------------------------------------------------------------------- 1 | class Parent: 2 | 3 | def v_override_who(self): # virtual and override 4 | pass 5 | 6 | def v_ancestor(self): # virtual but no-override 7 | pass 8 | 9 | def method_work(self): # method 10 | pass 11 | 12 | class Child(Parent): 13 | 14 | def v_override_who(self): 15 | pass 16 | 17 | def v_child_right(self): 18 | pass 19 | 20 | def method_work(self): # method 21 | pass 22 | 23 | class GrandSon(Child): 24 | 25 | def v_override_who(self): 26 | pass 27 | 28 | class GrandGirl(Child): 29 | 30 | def v_override_who(self): 31 | pass 32 | 33 | 34 | -------------------------------------------------------------------------------- /auto-gen/oop/inheritance/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/oop/inheritance/test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * test.c 2014-05-03 15:06:28 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include "grandgirl.h" 21 | #include "grandson.h" 22 | 23 | static int test_main_entry(char *output, size_t sz) 24 | { 25 | struct grandson *a_grandson; 26 | a_grandson = malloc(sizeof(*a_grandson)); 27 | grandson_init(a_grandson); 28 | parent_free(&a_grandson->child.parent); 29 | return 0; 30 | } 31 | 32 | void main_entry_test(void); 33 | void main_entry_test(void) 34 | { 35 | my_test_suite_add(test_main_entry, "Test inheritance"); 36 | } 37 | -------------------------------------------------------------------------------- /auto-gen/oop/inheritance/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/A_B1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A_B1.h 2014-05-14 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __A_B1_H__ 15 | #define __A_B1_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "A.h" 21 | 22 | /** show override */ 23 | struct A_B1 { 24 | struct A A; 25 | }; 26 | 27 | /** constructor(). */ 28 | void A_B1_init(struct A_B1 *A_B1); 29 | 30 | #endif /* __A_B1_H__ */ -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/A_B2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A_B2.h 2014-05-14 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __A_B2_H__ 15 | #define __A_B2_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "A.h" 21 | 22 | /** show override */ 23 | struct A_B2 { 24 | struct A A; 25 | }; 26 | 27 | /** constructor(). */ 28 | void A_B2_init(struct A_B2 *A_B2); 29 | 30 | #endif /* __A_B2_H__ */ -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/A_B3.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A_B3.h 2014-05-14 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __A_B3_H__ 15 | #define __A_B3_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "A.h" 21 | 22 | /** show override */ 23 | struct A_B3 { 24 | struct A A; 25 | }; 26 | 27 | /** constructor(). */ 28 | void A_B3_init(struct A_B3 *A_B3); 29 | 30 | #endif /* __A_B3_H__ */ -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/M_N.c: -------------------------------------------------------------------------------- 1 | /** 2 | * M_N.c 2014-05-14 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include "M_N.h" 21 | 22 | static struct M_ops M_ops = {0 23 | }; 24 | 25 | /** constructor(). */ 26 | void M_N_init(struct M_N *M_N) 27 | { 28 | memset(M_N, sizeof(*M_N), 0); 29 | M_init(&M_N->M); 30 | CLASS_OPS_INIT_SUPER(M_N->M.ops, M_ops); 31 | } -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/M_N.h: -------------------------------------------------------------------------------- 1 | /** 2 | * M_N.h 2014-05-14 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __M_N_H__ 15 | #define __M_N_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "M.h" 21 | 22 | /** show none-override */ 23 | struct M_N { 24 | struct M M; 25 | }; 26 | 27 | /** constructor(). */ 28 | void M_N_init(struct M_N *M_N); 29 | 30 | #endif /* __M_N_H__ */ -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/P_Q.h: -------------------------------------------------------------------------------- 1 | /** 2 | * P_Q.h 2014-05-14 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __P_Q_H__ 15 | #define __P_Q_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "P.h" 21 | 22 | /** show pure virtual */ 23 | struct P_Q { 24 | struct P P; 25 | }; 26 | 27 | /** constructor(). */ 28 | void P_Q_init(struct P_Q *P_Q); 29 | 30 | #endif /* __P_Q_H__ */ -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/me.h: -------------------------------------------------------------------------------- 1 | /** 2 | * me.h 2014-05-14 3 | * anonymouse(anonymouse@email) 4 | * 5 | * Copyright (C) 2000-2014 All Right Reserved 6 | * 7 | * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 8 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 9 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 10 | * PARTICULAR PURPOSE. 11 | * 12 | * Auto generate for Design Patterns in C 13 | */ 14 | #ifndef __ME_H__ 15 | #define __ME_H__ 16 | 17 | #include 18 | #include 19 | 20 | #include "A_B1.h" 21 | #include "A_B2.h" 22 | #include "A_B3.h" 23 | #include "M_N.h" 24 | #include "P_Q.h" 25 | 26 | struct me { 27 | struct A_B1 A_B1; 28 | struct A_B2 A_B2; 29 | struct A_B3 A_B3; 30 | struct M_N M_N; 31 | struct P_Q P_Q; 32 | }; 33 | 34 | /** constructor(). */ 35 | void me_init(struct me *me); 36 | 37 | #endif /* __ME_H__ */ 38 | -------------------------------------------------------------------------------- /auto-gen/oop/mult_inherit/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/oop/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/prototype/book.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __BOOK_H__ 3 | #define __BOOK_H__ 4 | #include "product.h" 5 | 6 | 7 | struct book { 8 | struct product product; 9 | int pages_num; 10 | }; 11 | 12 | void book_init(struct book *); 13 | 14 | void book_set_pages_num(struct book *, int pages); 15 | int book_get_pages_num(struct book *); 16 | 17 | 18 | #endif /* __BOOK_H__ */ 19 | -------------------------------------------------------------------------------- /auto-gen/prototype/disk.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __DISK_H__ 3 | #define __DISK_H__ 4 | #include "product.h" 5 | 6 | 7 | struct disk { 8 | struct product product; 9 | int duration; 10 | }; 11 | 12 | void disk_init(struct disk *); 13 | 14 | void disk_set_duration(struct disk *, int duration); 15 | int disk_get_duration(struct disk *); 16 | 17 | 18 | #endif /* __DISK_H__ */ 19 | -------------------------------------------------------------------------------- /auto-gen/prototype/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/prototype/product_cache.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PRODUCT_CACHE_H__ 3 | #define __PRODUCT_CACHE_H__ 4 | 5 | #include "book.h" 6 | #include "disk.h" 7 | 8 | struct product_cache_ops; 9 | struct product_cache { 10 | struct product_cache_ops *ops; 11 | }; 12 | struct product_cache_ops { 13 | int product_list_sz; 14 | struct product * product_list[32]; 15 | }; 16 | void product_cache_init(struct product_cache *); 17 | 18 | void product_cache_load_cache(void); 19 | struct product * product_cache_get_product(const char *); 20 | 21 | 22 | #endif /* __PRODUCT_CACHE_H__ */ 23 | -------------------------------------------------------------------------------- /auto-gen/prototype/test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include "product_cache.h" 8 | #include "book.h" 9 | #include "disk.h" 10 | 11 | static int test_prototype(char *output, size_t sz) 12 | { 13 | struct product *p1; 14 | struct book *b2; 15 | struct disk *d2; 16 | 17 | product_cache_load_cache(); 18 | 19 | p1 = product_cache_get_product("B1"); 20 | b2 = container_of(p1, struct book, product); 21 | printf("SKU = %s, %s, %d", 22 | product_get_sku(p1), 23 | product_get_description(p1), 24 | book_get_pages_num(b2)); 25 | 26 | p1 = product_cache_get_product("D1"); 27 | d2 = container_of(p1, struct disk, product); 28 | printf("SKU = %s, %s, %d", 29 | product_get_sku(p1), 30 | product_get_description(p1), 31 | disk_get_duration(d2)); 32 | 33 | return 0; 34 | } 35 | 36 | void main_entry_test(void); 37 | void main_entry_test(void) 38 | { 39 | my_test_suite_add(test_prototype, "Prototype"); 40 | } 41 | -------------------------------------------------------------------------------- /auto-gen/prototype/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/proxy/graphic.pyns: -------------------------------------------------------------------------------- 1 | {'type':'node', 'id':'subject', 'attrs':'', 'meths':'+ subject()|=0', 'x':1, 'y':1, 'width':1, 'height':1} 2 | {'type':'node', 'id':'real_subject', 'attrs':'', 'meths':'+ real_subject()|~ request(subject)', 'x':61, 'y':61, 'width':1, 'height':1} 3 | {'type':'node', 'id':'proxy', 'attrs':'+ _subject', 'meths':'+ proxy()|~ request(subject)', 'x':121, 'y':121, 'width':1, 'height':1} 4 | {'type':'edge', 'id':'real_subject_to_subject', 'source':'real_subject', 'target':'subject', 'uml_edge_type':'generalisation'} 5 | {'type':'edge', 'id':'proxy_to_real_subject', 'source':'proxy', 'target':'real_subject', 'uml_edge_type':'composition'} 6 | {'type':'edge', 'id':'proxy_to_subject', 'source':'proxy', 'target':'subject', 'uml_edge_type':'generalisation'} -------------------------------------------------------------------------------- /auto-gen/proxy/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/proxy/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/state/Makefile: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # IGNORE ABOVE 4 | # if = : auto assign value 5 | # 6 | # target: foo, foo.a, foo.so 7 | TARGET = 8 | SOURCES = 9 | SUBPROJS = #proj1 proj2 proj_n proj_m 10 | SUBDIRS = 11 | 12 | # add more to global config 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | 21 | # this proj donnot use global config 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | 30 | #_______________________________________________________________________________ 31 | # IGNORE BELOW 32 | include $(TOPDIR)config.mk 33 | -------------------------------------------------------------------------------- /auto-gen/state/README.md: -------------------------------------------------------------------------------- 1 | http://www.cprogramdevelop.com/5336903/ 2 | -------------------------------------------------------------------------------- /auto-gen/state/state/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/state/state/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/state/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/strategy/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/strategy/strategy.c: -------------------------------------------------------------------------------- 1 | #include "strategy.h" 2 | 3 | struct strategy_ops strategy_ops = {0}; /* virtual, force derive class implement */ 4 | 5 | void strategy_init(struct strategy *strategy) 6 | { 7 | strategy->ops = &strategy_ops; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /auto-gen/strategy/strategy.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGY_H_ 2 | #define STRATEGY_H_ 3 | 4 | 5 | struct strategy_ops; 6 | struct strategy { 7 | struct strategy_ops *ops; 8 | }; 9 | 10 | struct strategy_ops { 11 | void (*justify) (struct strategy *, char *line); /* virtual */ 12 | }; 13 | 14 | void strategy_init(struct strategy *); 15 | 16 | static inline 17 | void strategy_justify(struct strategy *strat, char *line) 18 | { 19 | strat->ops->justify(strat, line); 20 | } 21 | 22 | #endif /* STRATEGY_H_ */ 23 | -------------------------------------------------------------------------------- /auto-gen/strategy/strategy_left.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "myobj.h" 4 | #include "strategy_left.h" 5 | 6 | static void left_justify(struct strategy *strat, char *line) 7 | { 8 | printf("left "); 9 | } 10 | 11 | static struct strategy_ops left_ops = { 12 | .justify = left_justify, 13 | }; 14 | 15 | void strategy_left_init(struct strategy_left *strat) 16 | { 17 | strategy_init(&strat->strategy); 18 | CLASS_OPS_INIT(strat->strategy.ops, left_ops); 19 | } 20 | -------------------------------------------------------------------------------- /auto-gen/strategy/strategy_left.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGY_LEFT_H_ 2 | #define STRATEGY_LEFT_H_ 3 | 4 | #include "strategy.h" 5 | 6 | struct strategy_left { 7 | struct strategy strategy; 8 | }; 9 | 10 | void strategy_left_init(struct strategy_left *); 11 | 12 | #endif /* STRATEGY_LEFT_H_ */ 13 | -------------------------------------------------------------------------------- /auto-gen/strategy/strategy_right.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "myobj.h" 4 | #include "strategy_right.h" 5 | 6 | static void right_justify(struct strategy *strat, char *line) 7 | { 8 | printf("right "); 9 | } 10 | 11 | static struct strategy_ops right_ops = { 12 | .justify = right_justify, 13 | }; 14 | 15 | void strategy_right_init(struct strategy_right *strat) 16 | { 17 | strategy_init(&strat->strategy); 18 | CLASS_OPS_INIT(strat->strategy.ops, right_ops); 19 | } 20 | -------------------------------------------------------------------------------- /auto-gen/strategy/strategy_right.h: -------------------------------------------------------------------------------- 1 | #ifndef STRATEGY_RIGHT_H_ 2 | #define STRATEGY_RIGHT_H_ 3 | 4 | #include "strategy.h" 5 | 6 | struct strategy_right { 7 | struct strategy strategy; 8 | }; 9 | 10 | void strategy_right_init(struct strategy_right *); 11 | 12 | #endif /* STRATEGY_RIGHT_H_ */ 13 | -------------------------------------------------------------------------------- /auto-gen/strategy/test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include "test_bed.h" 8 | 9 | static int strategy_test(char *output, size_t sz) 10 | { 11 | struct test_bed test; 12 | unsigned int ii, answer[] = {1,2,1,1,2}; 13 | const char *retstr = "left,right,left,left,right"; 14 | 15 | test_bed_init(&test); 16 | printf("output should be: \n%s\n", retstr); 17 | for (ii=0; ii < sizeof(answer)/sizeof(answer[0]); ++ii) { 18 | test.ops->set_strategy(&test, answer[ii]); 19 | test.ops->do_it(&test); 20 | } 21 | printf("\n"); 22 | return 0; 23 | } 24 | 25 | void main_entry_test(void); 26 | void main_entry_test(void) 27 | { 28 | my_test_suite_add(strategy_test, "Test Strategy"); 29 | } 30 | -------------------------------------------------------------------------------- /auto-gen/strategy/test_bed.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test_bed.h" 3 | #include "strategy_left.h" 4 | #include "strategy_right.h" 5 | 6 | static void test_bed_set_strategy(struct test_bed *test, int type) 7 | { 8 | struct strategy_left *left; 9 | struct strategy_right *right; 10 | 11 | free(test->strategy_); 12 | test->strategy_ = 0; 13 | if (type == Left) { 14 | left = malloc(sizeof(*left)); 15 | strategy_left_init(left); 16 | test->strategy_ = &left->strategy; 17 | } 18 | else if (type == Right) { 19 | right = malloc(sizeof(*right)); 20 | strategy_right_init(right); 21 | test->strategy_ = &right->strategy; 22 | } 23 | } 24 | 25 | static void test_bed_do_it(struct test_bed *test) 26 | { 27 | strategy_justify(test->strategy_, 0); 28 | } 29 | 30 | static struct test_bed_ops test_ops = { 31 | .set_strategy = test_bed_set_strategy, 32 | .do_it = test_bed_do_it, 33 | }; 34 | 35 | void test_bed_init(struct test_bed *test) 36 | { 37 | test->ops = &test_ops; 38 | test->strategy_ = NULL; 39 | } 40 | -------------------------------------------------------------------------------- /auto-gen/strategy/test_bed.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTBED_H_ 2 | #define TESTBED_H_ 3 | 4 | struct test_bed_ops; 5 | struct test_bed { 6 | struct test_bed_ops *ops; 7 | struct strategy *strategy_; 8 | }; 9 | 10 | enum strategy_type { 11 | Dummy, Left, Right, 12 | }; 13 | 14 | struct test_bed_ops { 15 | void (*set_strategy) (struct test_bed *, int type); 16 | void (*do_it) (struct test_bed *); 17 | }; 18 | 19 | void test_bed_init(struct test_bed *); 20 | 21 | #endif /* TESTBED_H_ */ 22 | -------------------------------------------------------------------------------- /auto-gen/strategy/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/template_method/graphic.pyns: -------------------------------------------------------------------------------- 1 | {'type':'node', 'id':'template_method', 'attrs':'', 'meths':'+ template_method()|+ step_1()|+ step_3()|+ step_5()|+ execute()|=0|=0', 'x':1, 'y':1, 'width':1, 'height':1} 2 | {'type':'node', 'id':'method_a', 'attrs':'', 'meths':'+ method_a()|~ step_2(template_method)|~ step_4(template_method)', 'x':61, 'y':61, 'width':1, 'height':1} 3 | {'type':'node', 'id':'method_b', 'attrs':'', 'meths':'+ method_b()|~ step_2(template_method)|~ step_4(template_method)', 'x':121, 'y':121, 'width':1, 'height':1} 4 | {'type':'edge', 'id':'method_a_to_template_method', 'source':'method_a', 'target':'template_method', 'uml_edge_type':'generalisation'} 5 | {'type':'edge', 'id':'method_b_to_template_method', 'source':'method_b', 'target':'template_method', 'uml_edge_type':'generalisation'} -------------------------------------------------------------------------------- /auto-gen/template_method/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/template_method/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/comn.py: -------------------------------------------------------------------------------- 1 | 2 | def get_value_else_default(rdict, key, def_val): 3 | rval = rdict.get(key, def_val) 4 | if not rval: 5 | rval = def_val 6 | return rval 7 | 8 | 9 | def parse_parameters(params_str): 10 | params = params_str.split(',') 11 | args = [] 12 | for one_param in params: 13 | find = False 14 | for idx in range(len(one_param)-1, 0, -1): 15 | one_char = one_param[idx] 16 | if one_char >= 'a' and one_char <= 'z' or \ 17 | one_char >= 'A' and one_char <= 'Z' or \ 18 | one_char >= '0' and one_char <= '9' or \ 19 | one_char == '_': 20 | pass 21 | else: 22 | find = True 23 | args.append(one_param[(idx+1):]) 24 | break 25 | return params,args 26 | 27 | 28 | def convert_to_class(myclasses_array_dict, class_name): 29 | if myclasses_array_dict.has_key(class_name) and len(myclasses_array_dict[class_name]) > 0: 30 | return myclasses_array_dict[class_name]; 31 | else: 32 | raise Exception('class *{0}* not exist'.format(class_name)) 33 | 34 | 35 | -------------------------------------------------------------------------------- /auto-gen/tools/const.py: -------------------------------------------------------------------------------- 1 | class _const: 2 | class ConstError(TypeError): pass 3 | def __setattr__(self,name,value): 4 | if self.__dict__.has_key(name): 5 | raise self.ConstError, "Can't rebind const(%s)"%name 6 | self.__dict__[name]=value 7 | import sys 8 | sys.modules[__name__]=_const() 9 | -------------------------------------------------------------------------------- /auto-gen/tools/enum.py: -------------------------------------------------------------------------------- 1 | def enum(*sequential, **named): 2 | enums = dict(zip(sequential, range(len(sequential))), **named) 3 | reverse = dict((value, key) for key, value in enums.iteritems()) 4 | enums['reverse_mapping'] = reverse 5 | return type('Enum', (), enums) 6 | 7 | -------------------------------------------------------------------------------- /auto-gen/tools/json/adapter.json: -------------------------------------------------------------------------------- 1 | { 2 | "file_note": "True", 3 | "namespace": "adapter", 4 | "path": "adapter", 5 | 6 | "classes": { 7 | "target":{ 8 | "members": [ 9 | ["virtual", "request", "void"] 10 | ], 11 | 12 | "inheritances": { 13 | "adapter":{ 14 | "includes":["adaptee"], 15 | "members": [ 16 | ["override", ""], 17 | ["var", "_adaptee", "struct adaptee *", "", "private"], 18 | ], 19 | }, 20 | }, 21 | }, 22 | 23 | "adaptee":{ 24 | "members": [ 25 | ["method", "specific_request", "void"] 26 | ] 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /auto-gen/tools/json/bridge/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/json/decorator/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/json/factory/factory_method.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespace":"factory_method", 3 | "path":"factory_method", 4 | "classes": { 5 | "product":{ 6 | "members": [ 7 | ["virtual", "do_it","void", "int a, int b"], 8 | ["var", "name", "char", "[32]"] 9 | ], 10 | 11 | "inheritances": { 12 | "concrete_product_1":{ 13 | "members": [ ["override", ""] ] 14 | }, 15 | "concrete_product_2":{ 16 | "members": [ ["override", ""] ] 17 | } 18 | } 19 | }, 20 | 21 | "factory":{ 22 | "members": [ 23 | ["virtual", "create", "struct product *"], 24 | ["method", "do_it", "void" ] 25 | ], 26 | 27 | "inheritances": { 28 | "factory_product_1":{ 29 | "members": [ ["override", ""] ] 30 | }, 31 | "factory_product_2":{ 32 | "members": [ ["override", ""] ] 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /auto-gen/tools/json/factory/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/json/factory/two_stage.json: -------------------------------------------------------------------------------- 1 | { 2 | "file_note": "True", 3 | "namespace": "two_stage", 4 | "path": "two_stage", 5 | 6 | "classes": { 7 | "factory":{ 8 | "includes": ["product", "domain_class"], 9 | "members": [ 10 | ["virtual", "create", "struct product *", "struct domain_class *dc"] 11 | ], 12 | 13 | "inheritances": { 14 | "factory_product":{ 15 | "includes": ["product", "serializer", "file_access_handler", "domain_class"], 16 | "members": [ ["override", ""], 17 | ["var", "serializer", "struct serializer *", "", "private"], 18 | ["var", "file_access_handler", "struct file_access_handler *", "", "private"] 19 | ] 20 | } 21 | } 22 | }, 23 | 24 | "serializer":{}, 25 | "file_access_handler":{}, 26 | "domain_class":{}, 27 | 28 | "product":{ 29 | "members": [ 30 | ["method", "do_something", "void"], 31 | ["var", "name", "char", "[32]"] 32 | ] 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /auto-gen/tools/json/mvc/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/json/oop/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/json/state/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/json/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/c/_graphic.pyns: -------------------------------------------------------------------------------- 1 | {%- for node in nodes %} 2 | {'type':'node', 'id':'{{ node.id }}', 'attrs':'{{ node.attrs }}', 'meths':'{{ node.meths }}', 'x':{{ node.x }}, 'y':{{ node.y }}, 'width':{{ node.width }}, 'height':{{ node.height }}} 3 | {%- endfor -%} 4 | {%- for edge in edges %} 5 | {'type':'edge', 'id':'{{ edge.id }}', 'source':'{{ edge.source }}', 'target':'{{ edge.target }}', 'uml_edge_type':'{{ edge.uml_edge_type }}'} 6 | {%- endfor -%} 7 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/c/_header.jinja: -------------------------------------------------------------------------------- 1 | {%- include '../autogen_.jinja' ignore missing -%} 2 | {%- block file_header %}{% endblock %} 3 | #ifndef __{{ name.upper() }}_H__ 4 | #define __{{ name.upper() }}_H__ 5 | 6 | #include 7 | {% if trace %}#include {% endif %} 8 | {% block include %}{% endblock %} 9 | 10 | {% block forward_declare %}{% endblock %} 11 | {% block class_definition %}{% endblock %} 12 | {% block vtable_declare %}{% endblock %} 13 | {% block private_class_init %}{% endblock %} 14 | {% block class_init %}{% endblock %} 15 | {% block public_methods %}{% endblock %} 16 | {% block vtable_helper %}{% endblock %} 17 | {% block inline_method %}{% endblock %} 18 | 19 | #endif /* __{{ name.upper() }}_H__ */ 20 | 21 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/c/_source.jinja: -------------------------------------------------------------------------------- 1 | {% block file_header %}{% endblock %} 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | {% if supers or _have_vtable_new %}#include {% endif %} 8 | #include "{{ name }}.h" 9 | {% block private_class_init %}{% endblock %} 10 | 11 | {% block message %}{% endblock %} 12 | {% block error %}{% endblock %} 13 | 14 | {% block include_impl %}{% endblock %} 15 | {% block inline_method %}{% endblock %} 16 | {% block private_method %}{% endblock %} 17 | {%- if _have_vtable_new -%} 18 | {%- block vtable_impl %}{% endblock -%} 19 | {%- block vtable_set %}{% endblock -%} 20 | {%- endif -%} 21 | {% block supers %}{% endblock %} 22 | {% block class_init %}{% endblock %} 23 | {% block public_method %}{% endblock %} 24 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/c/_test.c: -------------------------------------------------------------------------------- 1 | {%- import '_macro.jinja' as func -%} 2 | 3 | {{ func.file_header(file_header_name,copyright,author,date,summary) }} 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | {% if trace %}#include {% endif %} 10 | #include 11 | {%- if includes -%} 12 | {%- for one_include in includes %} 13 | #include "{{ one_include }}.h" 14 | {%- endfor -%} 15 | {%- endif %} 16 | 17 | {{ func.macro_loop_functions(trace,name,methods,'methods',mode='impl-print',qualifier='static') }} 18 | 19 | static int test_main_entry(char *output, size_t sz) 20 | { 21 | TODO(Please add our **test** code here ...) 22 | return 0; 23 | } 24 | 25 | void main_entry_test(void); 26 | void main_entry_test(void) 27 | { 28 | my_test_suite_add(test_main_entry, "Test {{ namespace }}"); 29 | } 30 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/c/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/python/README.md: -------------------------------------------------------------------------------- 1 | Problem 2 | ======= 3 | 4 | When we implement oop using c, there have so many repeated code temple, 5 | Maybe the frame code can be autogen. Ok, This is the one. 6 | 7 | Solution 8 | ======== 9 | 10 | 1. Using json to describe our class 11 | 12 | QuickStart 13 | ========== 14 | Run 15 | --- 16 | 17 | ``` 18 | $ cd tools 19 | $ ./autogen_jinja2.py --file json/factory-method.json 20 | ``` 21 | 22 | Refs 23 | ==== 24 | 25 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/python/py.jinja: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | {%- macro macro_variable(func,format_str,params,args) %} 4 | {{ rtn_type }} {{ func }}{{ params }}; 5 | {%- endmacro -%} 6 | 7 | {%- macro macro_loop_functions(functions) -%} 8 | {%- for func_scope,rtn_type,func,params,args in functions -%} 9 | {%- if mode == "var" -%} 10 | {{- macro_variable(name,abstract_name,qualifier,func_scope,rtn_type,func,format_str,params,args) -}} 11 | {%- elif mode == "declare" -%} 12 | {%- endif -%} 13 | {%- endfor -%} 14 | {%- endmacro -%} 15 | 16 | 17 | class {{ name }}{% if supers %}({{ supers|join(', ') }}){% endif %}: 18 | {% if comment %}'{{ comment }}'{% endif %} 19 | instance_count = 0 20 | 21 | def __init__(self): 22 | self.name = name 23 | self.salary = salary 24 | 25 | def displayCount(self): 26 | print "Total Employee %d" % Employee.empCount 27 | 28 | def displayEmployee(self): 29 | print "Name : ", self.name, ", Salary: ", self.salary 30 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/python/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/tmpl/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/tools/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/topdir.mk: -------------------------------------------------------------------------------- 1 | REPLACE_ME= XXXXXX 2 | OUTDIR = $(REPLACE_ME) 3 | 4 | ifndef TOPDIR 5 | TOPDIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 6 | $(info make help View help info) 7 | #$(info TOPDIR $(TOPDIR)) 8 | endif 9 | export TOPDIR 10 | -------------------------------------------------------------------------------- /auto-gen/tpl_make.mk: -------------------------------------------------------------------------------- 1 | include topdir.mk 2 | #_______________________________________________________________________________ 3 | # Config IGNORE ABOVE 4 | TARGET = # 5 | SOURCES = # 6 | SOURCES_NOT = 7 | SUBPROJS = # 8 | SUBPROJS_NOT = 9 | SUBDIRS = # 10 | SUBDIRS_NOT = 11 | #_____________ 12 | # Append Flags 13 | EXTRA_MACROS = 14 | EXTRA_INCS = #$(TOPDIR)include 15 | EXTRA_LIBDIRS = #$(TOPDIR)$(OUTDIR)lib 16 | EXTRA_LIBS = 17 | EXTRA_CPPFLAGS = 18 | EXTRA_LDFLAGS = 19 | EXTRA_ARFLAGS = 20 | #______________________ 21 | # Override Global Flags 22 | #MACROS = 23 | #INCS = 24 | #LIBDIRS = 25 | #LIBS = 26 | #CPPFLAGS = 27 | #LDFLAGS = 28 | #ARFLAGS = 29 | #_______________________________________________________________________________ 30 | # IGNORE BELOW 31 | include $(TOPDIR)config.mk 32 | -------------------------------------------------------------------------------- /auto-gen/tpl_top.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | REPLACE_ME= XXXXXX 7 | OUTDIR = $(REPLACE_ME) 8 | 9 | ifndef TOPDIR 10 | empty:= 11 | space:= $(empty) $(empty) 12 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 13 | tmpdir := $(subst /,$(space),$(tmpdir)) 14 | number := $(words $(tmpdir)) 15 | 16 | topdir := $(shell \ 17 | tmpdir="." ; number=$(number) ; \ 18 | while [[ $$number -gt 1 ]] ; do \ 19 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 20 | tmpdir="$${tmpdir}/.." ; \ 21 | ((number = number - 1)) ; \ 22 | done ; \ 23 | ) 24 | TOPDIR := $(realpath $(topdir))/ 25 | include $(TOPDIR)topdir.mk 26 | endif 27 | #_______________________________________________________________________________ 28 | -------------------------------------------------------------------------------- /auto-gen/util/mycommon.h: -------------------------------------------------------------------------------- 1 | #ifndef __MY_COMMON_H__ 2 | #define __MY_COMMON_H__ 3 | 4 | #define DO_PRAGMA(x) _Pragma (#x) 5 | #define TODO(x) DO_PRAGMA(message ("TODO - " #x)) 6 | 7 | #endif /* __MY_COMMON_H__ */ 8 | -------------------------------------------------------------------------------- /auto-gen/util/stack.h: -------------------------------------------------------------------------------- 1 | #ifndef __STACK_H__ 2 | #define __STACK_H__ 3 | 4 | /* 5 | * Simple stack implementation. 6 | 7 | * STACK_IMPL(sample, type, 128); 8 | * 9 | * bool sample_is_empty() 10 | * bool sample_is_full() 11 | * void sample_push(type) 12 | * type sample_pop() 13 | */ 14 | 15 | #define STACK_IMPL(stack, type, sz) \ 16 | static int stack ## _top = 0; \ 17 | static type stack[sz]; \ 18 | \ 19 | static inline int stack ## _is_empty(void) \ 20 | { \ 21 | return (stack ## _top <= 0); \ 22 | } \ 23 | static inline int stack ## _is_full(void) \ 24 | { \ 25 | return (stack ## _top >= sz); \ 26 | } \ 27 | static inline void stack ## _push(type obj) \ 28 | { \ 29 | if (!stack ## _is_full()) \ 30 | stack[stack ## _top++] = obj; \ 31 | } \ 32 | static inline type stack ## _pop(void) \ 33 | { \ 34 | if (!stack ## _is_empty()) \ 35 | return stack[--stack ## _top]; \ 36 | return (type){0}; \ 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /auto-gen/util/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | -------------------------------------------------------------------------------- /auto-gen/util/util.c: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int is_numeric (const char * s) 8 | { 9 | if (s == NULL || *s == '\0' || isspace(*s)) 10 | return 0; 11 | char * p; 12 | strtod (s, &p); 13 | return *p == '\0'; 14 | } 15 | -------------------------------------------------------------------------------- /auto-gen/util/util.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTIL_H__ 2 | #define __UTIL_H__ 3 | 4 | int is_numeric (const char * s); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /auto-gen/visitor/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "test_suite.h" 5 | 6 | int main(void) 7 | { 8 | _MY_TRACE_INIT_; /* support trace, remove if no-trace needed */ 9 | 10 | my_test_suite_open(); 11 | my_test_suite_run_all(MY_TEST_SUITE_FLAG_VERBOSE); 12 | my_test_suite_close(); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /auto-gen/visitor/topdir.mk: -------------------------------------------------------------------------------- 1 | #include ../topdir.mk 2 | #_______________________________________________________________________________ 3 | # READONLY FILE 4 | # Using file 'config.mk' as upward search sanity file to detect $(TOPDIR) 5 | #_______________________________________________________________________________ 6 | ifndef TOPDIR 7 | empty:= 8 | space:= $(empty) $(empty) 9 | tmpdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 10 | tmpdir := $(subst /,$(space),$(tmpdir)) 11 | number := $(words $(tmpdir)) 12 | 13 | topdir := $(shell \ 14 | tmpdir="." ; number=$(number) ; \ 15 | while [[ $$number -gt 1 ]] ; do \ 16 | if [ -a "$${tmpdir}/config.mk" ]; then echo $$tmpdir; break; fi; \ 17 | tmpdir="$${tmpdir}/.." ; \ 18 | ((number = number - 1)) ; \ 19 | done ; \ 20 | ) 21 | TOPDIR := $(realpath $(topdir))/ 22 | include $(TOPDIR)topdir.mk 23 | endif 24 | #_______________________________________________________________________________ 25 | --------------------------------------------------------------------------------