From cf8ca0ba62e78e70b7621b0c81bf7c031eabe3ac Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 29 Jul 2013 22:14:19 -0700 Subject: gras: simplfy factory w/ macros and namespace --- include/gras/detail/factory.hpp | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'include/gras/detail') diff --git a/include/gras/detail/factory.hpp b/include/gras/detail/factory.hpp index ac4df6f..d1edf81 100644 --- a/include/gras/detail/factory.hpp +++ b/include/gras/detail/factory.hpp @@ -37,7 +37,7 @@ struct FactoryRegistryEntryImpl0 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)()) +void register_make(const std::string &name, ReturnType(*fcn)()) { void *r = new FactoryRegistryEntryImpl0(fcn); Factory::_register_make(name, r); @@ -61,7 +61,7 @@ struct FactoryRegistryEntryImpl1 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &)) { void *r = new FactoryRegistryEntryImpl1(fcn); Factory::_register_make(name, r); @@ -85,7 +85,7 @@ struct FactoryRegistryEntryImpl2 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &)) { void *r = new FactoryRegistryEntryImpl2(fcn); Factory::_register_make(name, r); @@ -109,7 +109,7 @@ struct FactoryRegistryEntryImpl3 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &)) { void *r = new FactoryRegistryEntryImpl3(fcn); Factory::_register_make(name, r); @@ -133,7 +133,7 @@ struct FactoryRegistryEntryImpl4 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &)) { void *r = new FactoryRegistryEntryImpl4(fcn); Factory::_register_make(name, r); @@ -157,7 +157,7 @@ struct FactoryRegistryEntryImpl5 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &)) { void *r = new FactoryRegistryEntryImpl5(fcn); Factory::_register_make(name, r); @@ -181,7 +181,7 @@ struct FactoryRegistryEntryImpl6 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &)) { void *r = new FactoryRegistryEntryImpl6(fcn); Factory::_register_make(name, r); @@ -205,7 +205,7 @@ struct FactoryRegistryEntryImpl7 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &)) { void *r = new FactoryRegistryEntryImpl7(fcn); Factory::_register_make(name, r); @@ -229,7 +229,7 @@ struct FactoryRegistryEntryImpl8 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &)) { void *r = new FactoryRegistryEntryImpl8(fcn); Factory::_register_make(name, r); @@ -253,7 +253,7 @@ struct FactoryRegistryEntryImpl9 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &)) { void *r = new FactoryRegistryEntryImpl9(fcn); Factory::_register_make(name, r); @@ -277,7 +277,7 @@ struct FactoryRegistryEntryImpl10 : FactoryRegistryEntry }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &)) +void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &)) { void *r = new FactoryRegistryEntryImpl10(fcn); Factory::_register_make(name, r); @@ -287,14 +287,14 @@ void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 & * Templated make implementations **********************************************************************/ inline -Element *Factory::make(const std::string &name) +Element *make(const std::string &name) { PMCList args(0); return Factory::_handle_make(name, PMC_M(args)); } template -Element *Factory::make(const std::string &name, const A0 &a0) +Element *make(const std::string &name, const A0 &a0) { PMCList args(1); args[0] = PMC_M(a0); @@ -302,7 +302,7 @@ Element *Factory::make(const std::string &name, const A0 &a0) } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1) +Element *make(const std::string &name, const A0 &a0, const A1 &a1) { PMCList args(2); args[0] = PMC_M(a0); @@ -311,7 +311,7 @@ Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1) } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2) +Element *make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2) { PMCList args(3); args[0] = PMC_M(a0); @@ -321,7 +321,7 @@ Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, cons } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3) +Element *make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3) { PMCList args(4); args[0] = PMC_M(a0); @@ -332,7 +332,7 @@ Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, cons } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) +Element *make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { PMCList args(5); args[0] = PMC_M(a0); @@ -344,7 +344,7 @@ Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, cons } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) +Element *make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { PMCList args(6); args[0] = PMC_M(a0); @@ -357,7 +357,7 @@ Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, cons } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) +Element *make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { PMCList args(7); args[0] = PMC_M(a0); @@ -371,7 +371,7 @@ Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, cons } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) +Element *make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { PMCList args(8); args[0] = PMC_M(a0); @@ -386,7 +386,7 @@ Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, cons } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) +Element *make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { PMCList args(9); args[0] = PMC_M(a0); @@ -402,7 +402,7 @@ Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, cons } template -Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) +Element *make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { PMCList args(10); args[0] = PMC_M(a0); -- cgit