From 92c8b4646d77d569480d7c3120a00df6a9645aba Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 13 Jul 2013 11:23:41 -0700 Subject: gras: work on generator scripts for template madness --- include/gras/callable.hpp | 88 +++++- include/gras/detail/callable.hpp | 589 ++++++++++++++++++++++++++++++++++++++- include/gras/detail/factory.hpp | 277 +++++++++++++++++- include/gras/factory.hpp | 52 +++- tmpl/callable.tmpl.hpp | 94 +++++++ tmpl/callable_detail.tmpl.hpp | 100 +++++++ tmpl/expand_template.py | 33 +++ tmpl/factory.tmpl.hpp | 63 +++++ tmpl/factory_detail.tmpl.hpp | 64 +++++ tmpl/regen_all.sh | 10 + 10 files changed, 1354 insertions(+), 16 deletions(-) create mode 100644 tmpl/callable.tmpl.hpp create mode 100644 tmpl/callable_detail.tmpl.hpp create mode 100644 tmpl/expand_template.py create mode 100644 tmpl/factory.tmpl.hpp create mode 100644 tmpl/factory_detail.tmpl.hpp create mode 100644 tmpl/regen_all.sh diff --git a/include/gras/callable.hpp b/include/gras/callable.hpp index 60d0fb0..015f965 100644 --- a/include/gras/callable.hpp +++ b/include/gras/callable.hpp @@ -57,10 +57,10 @@ protected: ******************************************************************/ protected: template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(void)); + void register_call(const std::string &name, ReturnType(ClassType::*fcn)()); template - void register_call(const std::string &name, void(ClassType::*fcn)(void)); + void register_call(const std::string &name, void(ClassType::*fcn)()); template void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &)); @@ -80,6 +80,48 @@ protected: template void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)); + + template + void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)); + + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)); + + template + void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)); + + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)); + + template + void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)); + + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)); + + template + void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)); + + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)); + + template + void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)); + + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)); + + template + void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)); + + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)); + + template + void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)); + /******************************************************************* * Call API - don't look here, template magic, not helpful ******************************************************************/ @@ -108,6 +150,48 @@ public: template void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &); + template + ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + + template + void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + + template + ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + + template + void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + + template + ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + + template + void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + + template + ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + + template + void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + + template + ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + + template + void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + + template + ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + + template + void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + + template + ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + + template + void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + /******************************************************************* * Private registration hooks ******************************************************************/ diff --git a/include/gras/detail/callable.hpp b/include/gras/detail/callable.hpp index 98fa29d..7a82a45 100644 --- a/include/gras/detail/callable.hpp +++ b/include/gras/detail/callable.hpp @@ -24,18 +24,20 @@ struct GRAS_API CallableRegistryEntry template struct CallableRegistryEntryImpl0 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(void); + typedef ReturnType(ClassType::*Fcn)(); CallableRegistryEntryImpl0(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} - PMCC call(const PMCC &) + PMCC call(const PMCC &args) { + const PMCList &a = args.as(); + if (a.size() < 0) throw a; return PMC_M((_obj->*_fcn)()); } ClassType *_obj; Fcn _fcn; }; template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(void)) +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)()) { ClassType *obj = dynamic_cast(this); void *fr = new CallableRegistryEntryImpl0(obj, fcn); @@ -45,18 +47,20 @@ void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn template struct CallableRegistryEntryImplVoid0 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(void); + typedef void(ClassType::*Fcn)(); CallableRegistryEntryImplVoid0(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} - PMCC call(const PMCC &) + PMCC call(const PMCC &args) { + const PMCList &a = args.as(); + if (a.size() < 0) throw a; (_obj->*_fcn)(); return PMCC(); } ClassType *_obj; Fcn _fcn; }; template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(void)) +void Callable::register_call(const std::string &name, void(ClassType::*fcn)()) { ClassType *obj = dynamic_cast(this); void *fr = new CallableRegistryEntryImplVoid0(obj, fcn); @@ -75,6 +79,7 @@ struct CallableRegistryEntryImpl1 : CallableRegistryEntry PMCC call(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 1) throw a; return PMC_M((_obj->*_fcn)(a[0].safe_as())); } ClassType *_obj; Fcn _fcn; @@ -97,6 +102,7 @@ struct CallableRegistryEntryImplVoid1 : CallableRegistryEntry PMCC call(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 1) throw a; (_obj->*_fcn)(a[0].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; @@ -122,6 +128,7 @@ struct CallableRegistryEntryImpl2 : CallableRegistryEntry PMCC call(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 2) throw a; return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as())); } ClassType *_obj; Fcn _fcn; @@ -144,6 +151,7 @@ struct CallableRegistryEntryImplVoid2 : CallableRegistryEntry PMCC call(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 2) throw a; (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; @@ -169,6 +177,7 @@ struct CallableRegistryEntryImpl3 : CallableRegistryEntry PMCC call(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 3) throw a; return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as())); } ClassType *_obj; Fcn _fcn; @@ -191,6 +200,7 @@ struct CallableRegistryEntryImplVoid3 : CallableRegistryEntry PMCC call(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 3) throw a; (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; @@ -204,6 +214,349 @@ void Callable::register_call(const std::string &name, void(ClassType::*fcn)(cons _register_call(name, fr); } +/*********************************************************************** + * Registration for return with 4 args + **********************************************************************/ +template +struct CallableRegistryEntryImpl4 : CallableRegistryEntry +{ + typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + CallableRegistryEntryImpl4(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 4) throw a; + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as())); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImpl4(obj, fcn); + _register_call(name, fr); +} + +template +struct CallableRegistryEntryImplVoid4 : CallableRegistryEntry +{ + typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + CallableRegistryEntryImplVoid4(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 4) throw a; + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as()); return PMCC(); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImplVoid4(obj, fcn); + _register_call(name, fr); +} + +/*********************************************************************** + * Registration for return with 5 args + **********************************************************************/ +template +struct CallableRegistryEntryImpl5 : CallableRegistryEntry +{ + typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + CallableRegistryEntryImpl5(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 5) throw a; + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as())); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImpl5(obj, fcn); + _register_call(name, fr); +} + +template +struct CallableRegistryEntryImplVoid5 : CallableRegistryEntry +{ + typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + CallableRegistryEntryImplVoid5(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 5) throw a; + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as()); return PMCC(); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImplVoid5(obj, fcn); + _register_call(name, fr); +} + +/*********************************************************************** + * Registration for return with 6 args + **********************************************************************/ +template +struct CallableRegistryEntryImpl6 : CallableRegistryEntry +{ + typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + CallableRegistryEntryImpl6(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 6) throw a; + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as())); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImpl6(obj, fcn); + _register_call(name, fr); +} + +template +struct CallableRegistryEntryImplVoid6 : CallableRegistryEntry +{ + typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + CallableRegistryEntryImplVoid6(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 6) throw a; + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as()); return PMCC(); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImplVoid6(obj, fcn); + _register_call(name, fr); +} + +/*********************************************************************** + * Registration for return with 7 args + **********************************************************************/ +template +struct CallableRegistryEntryImpl7 : CallableRegistryEntry +{ + typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + CallableRegistryEntryImpl7(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 7) throw a; + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as())); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImpl7(obj, fcn); + _register_call(name, fr); +} + +template +struct CallableRegistryEntryImplVoid7 : CallableRegistryEntry +{ + typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + CallableRegistryEntryImplVoid7(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 7) throw a; + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as()); return PMCC(); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImplVoid7(obj, fcn); + _register_call(name, fr); +} + +/*********************************************************************** + * Registration for return with 8 args + **********************************************************************/ +template +struct CallableRegistryEntryImpl8 : CallableRegistryEntry +{ + typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + CallableRegistryEntryImpl8(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 8) throw a; + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as())); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImpl8(obj, fcn); + _register_call(name, fr); +} + +template +struct CallableRegistryEntryImplVoid8 : CallableRegistryEntry +{ + typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + CallableRegistryEntryImplVoid8(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 8) throw a; + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as()); return PMCC(); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImplVoid8(obj, fcn); + _register_call(name, fr); +} + +/*********************************************************************** + * Registration for return with 9 args + **********************************************************************/ +template +struct CallableRegistryEntryImpl9 : CallableRegistryEntry +{ + typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + CallableRegistryEntryImpl9(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 9) throw a; + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as())); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImpl9(obj, fcn); + _register_call(name, fr); +} + +template +struct CallableRegistryEntryImplVoid9 : CallableRegistryEntry +{ + typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + CallableRegistryEntryImplVoid9(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 9) throw a; + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as()); return PMCC(); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImplVoid9(obj, fcn); + _register_call(name, fr); +} + +/*********************************************************************** + * Registration for return with 10 args + **********************************************************************/ +template +struct CallableRegistryEntryImpl10 : CallableRegistryEntry +{ + typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + CallableRegistryEntryImpl10(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 10) throw a; + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as())); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImpl10(obj, fcn); + _register_call(name, fr); +} + +template +struct CallableRegistryEntryImplVoid10 : CallableRegistryEntry +{ + typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + CallableRegistryEntryImplVoid10(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 10) throw a; + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as()); return PMCC(); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImplVoid10(obj, fcn); + _register_call(name, fr); +} + /*********************************************************************** * Call implementations with 0 args **********************************************************************/ @@ -288,6 +641,230 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const _handle_call(name, PMC_M(args)); } +/*********************************************************************** + * Call implementations with 4 args + **********************************************************************/ +template +ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3) +{ + PMCList args(4); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + PMCC r = _handle_call(name, PMC_M(args)); + return r.safe_as(); +} + +template +void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3) +{ + PMCList args(4); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + _handle_call(name, PMC_M(args)); +} + +/*********************************************************************** + * Call implementations with 5 args + **********************************************************************/ +template +ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4) +{ + PMCList args(5); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + PMCC r = _handle_call(name, PMC_M(args)); + return r.safe_as(); +} + +template +void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4) +{ + PMCList args(5); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + _handle_call(name, PMC_M(args)); +} + +/*********************************************************************** + * Call implementations with 6 args + **********************************************************************/ +template +ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5) +{ + PMCList args(6); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + PMCC r = _handle_call(name, PMC_M(args)); + return r.safe_as(); +} + +template +void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5) +{ + PMCList args(6); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + _handle_call(name, PMC_M(args)); +} + +/*********************************************************************** + * Call implementations with 7 args + **********************************************************************/ +template +ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6) +{ + PMCList args(7); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + PMCC r = _handle_call(name, PMC_M(args)); + return r.safe_as(); +} + +template +void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6) +{ + PMCList args(7); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + _handle_call(name, PMC_M(args)); +} + +/*********************************************************************** + * Call implementations with 8 args + **********************************************************************/ +template +ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7) +{ + PMCList args(8); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + PMCC r = _handle_call(name, PMC_M(args)); + return r.safe_as(); +} + +template +void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7) +{ + PMCList args(8); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + _handle_call(name, PMC_M(args)); +} + +/*********************************************************************** + * Call implementations with 9 args + **********************************************************************/ +template +ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8) +{ + PMCList args(9); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + args[8] = PMC_M(a8); + PMCC r = _handle_call(name, PMC_M(args)); + return r.safe_as(); +} + +template +void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8) +{ + PMCList args(9); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + args[8] = PMC_M(a8); + _handle_call(name, PMC_M(args)); +} + +/*********************************************************************** + * Call implementations with 10 args + **********************************************************************/ +template +ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9) +{ + PMCList args(10); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + args[8] = PMC_M(a8); + args[9] = PMC_M(a9); + PMCC r = _handle_call(name, PMC_M(args)); + return r.safe_as(); +} + +template +void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9) +{ + PMCList args(10); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + args[8] = PMC_M(a8); + args[9] = PMC_M(a9); + _handle_call(name, PMC_M(args)); +} + } //namespace gras #endif /*INCLUDED_GRAS_DETAIL_CALLABLE_HPP*/ diff --git a/include/gras/detail/factory.hpp b/include/gras/detail/factory.hpp index 632e09d..6570da4 100644 --- a/include/gras/detail/factory.hpp +++ b/include/gras/detail/factory.hpp @@ -24,17 +24,19 @@ struct GRAS_API FactoryRegistryEntry template struct FactoryRegistryEntryImpl0 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(void); + typedef ReturnType(*Fcn)(); FactoryRegistryEntryImpl0(Fcn fcn):_fcn(fcn){} - Element *make(const PMCC &) + Element *make(const PMCC &args) { + const PMCList &a = args.as(); + if (a.size() < 0) throw a; return _fcn(); } Fcn _fcn; }; template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(void)) +void Factory::register_make(const std::string &name, ReturnType(*fcn)()) { void *r = new FactoryRegistryEntryImpl0(fcn); Factory::_register_make(name, r); @@ -51,6 +53,7 @@ struct FactoryRegistryEntryImpl1 : FactoryRegistryEntry Element *make(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 1) throw a; return _fcn(a[0].safe_as()); } Fcn _fcn; @@ -74,6 +77,7 @@ struct FactoryRegistryEntryImpl2 : FactoryRegistryEntry Element *make(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 2) throw a; return _fcn(a[0].safe_as(), a[1].safe_as()); } Fcn _fcn; @@ -97,6 +101,7 @@ struct FactoryRegistryEntryImpl3 : FactoryRegistryEntry Element *make(const PMCC &args) { const PMCList &a = args.as(); + if (a.size() < 3) throw a; return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as()); } Fcn _fcn; @@ -109,6 +114,174 @@ void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 Factory::_register_make(name, r); } +/*********************************************************************** + * Templated registration - 4 args + **********************************************************************/ +template +struct FactoryRegistryEntryImpl4 : FactoryRegistryEntry +{ + typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + FactoryRegistryEntryImpl4(Fcn fcn):_fcn(fcn){} + Element *make(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 4) throw a; + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as()); + } + Fcn _fcn; +}; + +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)) +{ + void *r = new FactoryRegistryEntryImpl4(fcn); + Factory::_register_make(name, r); +} + +/*********************************************************************** + * Templated registration - 5 args + **********************************************************************/ +template +struct FactoryRegistryEntryImpl5 : FactoryRegistryEntry +{ + typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + FactoryRegistryEntryImpl5(Fcn fcn):_fcn(fcn){} + Element *make(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 5) throw a; + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as()); + } + Fcn _fcn; +}; + +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)) +{ + void *r = new FactoryRegistryEntryImpl5(fcn); + Factory::_register_make(name, r); +} + +/*********************************************************************** + * Templated registration - 6 args + **********************************************************************/ +template +struct FactoryRegistryEntryImpl6 : FactoryRegistryEntry +{ + typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + FactoryRegistryEntryImpl6(Fcn fcn):_fcn(fcn){} + Element *make(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 6) throw a; + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as()); + } + Fcn _fcn; +}; + +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)) +{ + void *r = new FactoryRegistryEntryImpl6(fcn); + Factory::_register_make(name, r); +} + +/*********************************************************************** + * Templated registration - 7 args + **********************************************************************/ +template +struct FactoryRegistryEntryImpl7 : FactoryRegistryEntry +{ + typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + FactoryRegistryEntryImpl7(Fcn fcn):_fcn(fcn){} + Element *make(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 7) throw a; + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as()); + } + Fcn _fcn; +}; + +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)) +{ + void *r = new FactoryRegistryEntryImpl7(fcn); + Factory::_register_make(name, r); +} + +/*********************************************************************** + * Templated registration - 8 args + **********************************************************************/ +template +struct FactoryRegistryEntryImpl8 : FactoryRegistryEntry +{ + typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + FactoryRegistryEntryImpl8(Fcn fcn):_fcn(fcn){} + Element *make(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 8) throw a; + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as()); + } + Fcn _fcn; +}; + +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)) +{ + void *r = new FactoryRegistryEntryImpl8(fcn); + Factory::_register_make(name, r); +} + +/*********************************************************************** + * Templated registration - 9 args + **********************************************************************/ +template +struct FactoryRegistryEntryImpl9 : FactoryRegistryEntry +{ + typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + FactoryRegistryEntryImpl9(Fcn fcn):_fcn(fcn){} + Element *make(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 9) throw a; + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as()); + } + Fcn _fcn; +}; + +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)) +{ + void *r = new FactoryRegistryEntryImpl9(fcn); + Factory::_register_make(name, r); +} + +/*********************************************************************** + * Templated registration - 10 args + **********************************************************************/ +template +struct FactoryRegistryEntryImpl10 : FactoryRegistryEntry +{ + typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + FactoryRegistryEntryImpl10(Fcn fcn):_fcn(fcn){} + Element *make(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < 10) throw a; + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as()); + } + Fcn _fcn; +}; + +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)) +{ + void *r = new FactoryRegistryEntryImpl10(fcn); + Factory::_register_make(name, r); +} + /*********************************************************************** * Templated make implementations **********************************************************************/ @@ -146,6 +319,104 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, return Factory::_handle_make(name, PMC_M(args)); } +template +Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3) +{ + PMCList args(4); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + return Factory::_handle_make(name, PMC_M(args)); +} + +template +Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4) +{ + PMCList args(5); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + return Factory::_handle_make(name, PMC_M(args)); +} + +template +Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5) +{ + PMCList args(6); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + return Factory::_handle_make(name, PMC_M(args)); +} + +template +Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6) +{ + PMCList args(7); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + return Factory::_handle_make(name, PMC_M(args)); +} + +template +Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7) +{ + PMCList args(8); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + return Factory::_handle_make(name, PMC_M(args)); +} + +template +Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8) +{ + PMCList args(9); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + args[8] = PMC_M(a8); + return Factory::_handle_make(name, PMC_M(args)); +} + +template +Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9) +{ + PMCList args(10); + args[0] = PMC_M(a0); + args[1] = PMC_M(a1); + args[2] = PMC_M(a2); + args[3] = PMC_M(a3); + args[4] = PMC_M(a4); + args[5] = PMC_M(a5); + args[6] = PMC_M(a6); + args[7] = PMC_M(a7); + args[8] = PMC_M(a8); + args[9] = PMC_M(a9); + return Factory::_handle_make(name, PMC_M(args)); +} + } #endif /*INCLUDED_GRAS_DETAIL_FACTORY_HPP*/ diff --git a/include/gras/factory.hpp b/include/gras/factory.hpp index 52ed881..b60b1e7 100644 --- a/include/gras/factory.hpp +++ b/include/gras/factory.hpp @@ -37,7 +37,7 @@ struct GRAS_API Factory * Register API - don't look here, template magic, not helpful ******************************************************************/ template - static void register_make(const std::string &name, ReturnType(*fcn)(void)); + static void register_make(const std::string &name, ReturnType(*fcn)()); template static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &)); @@ -48,20 +48,62 @@ struct GRAS_API Factory template static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &)); + template + static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)); + + template + static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)); + + template + static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)); + + template + static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)); + + template + static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)); + + template + static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)); + + template + static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)); + /******************************************************************* * Make API - don't look here, template magic, not helpful - ******************************************************************/ + ******************************************************************/; inline static Element *make(const std::string &name); template - static Element *make(const std::string &name, const Arg0 &a0); + static Element *make(const std::string &name, const Arg0 &); template - static Element *make(const std::string &name, const Arg0 &a0, const Arg1 &a1); + static Element *make(const std::string &name, const Arg0 &, const Arg1 &); template - static Element *make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2); + static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &); + + template + static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + + template + static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + + template + static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + + template + static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + + template + static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + + template + static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + + template + static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); /******************************************************************* * Private registration hooks diff --git a/tmpl/callable.tmpl.hpp b/tmpl/callable.tmpl.hpp new file mode 100644 index 0000000..1c73910 --- /dev/null +++ b/tmpl/callable.tmpl.hpp @@ -0,0 +1,94 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_CALLABLE_HPP +#define INCLUDED_GRAS_CALLABLE_HPP + +#include +#include +#include +#include +#include + +namespace gras +{ + +/*! + * The callable interface allows subclasses to export public methods, + * but without actually exporting traditional library symbols. + * + * Callable handles the template magic so you don't have to: + * - registering subclass methods is simple and easy on the user. + * - users call registered methods with natural code aesthetics. + * + * Register a method (in the constructor of MyClass): + * this->register_call("set_foo", &MyClass::set_foo); + * + * Call a method on a instance of MyClass: + * my_class->x("set_foo", new_foo_val); + * + * Why x for the call method? + * - The "x" is short, one character of screen width. + * - The "x" looks like "*", which is commonly used. + * - The overloaded () operator sucks with pointers. + * - The overloaded () operator has template issues. + */ +class GRAS_API Callable +{ +public: + + //! Default constructor + Callable(void); + + //! Destructor (virtual for subclasses) + virtual ~Callable(void); + + //! Get a list of names for registered calls + std::vector get_registered_names(void) const; + +protected: + /*! + * Unregister a previously registered call. + * Throws if the name is not found in the registry. + */ + void unregister_call(const std::string &name); + + /******************************************************************* + * Register API - don't look here, template magic, not helpful + ******************************************************************/ +protected: + #for $NARGS in range($MAX_ARGS) + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)($expand('const Arg%d &', $NARGS))); + + template + void register_call(const std::string &name, void(ClassType::*fcn)($expand('const Arg%d &', $NARGS))); + + #end for + /******************************************************************* + * Call API - don't look here, template magic, not helpful + ******************************************************************/ +public: + #for $NARGS in range($MAX_ARGS) + template + ReturnType x(const std::string &name, $expand('const Arg%d &', $NARGS)); + + template <$expand('typename Arg%d', $NARGS)> + void x(const std::string &name, $expand('const Arg%d &', $NARGS)); + + #end for + /******************************************************************* + * Private registration hooks + ******************************************************************/ +protected: + void _register_call(const std::string &, void *); +public: + virtual PMCC _handle_call(const std::string &, const PMCC &); +private: + boost::shared_ptr _call_registry; +}; + +} //namespace gras + +#include + +#endif /*INCLUDED_GRAS_CALLABLE_HPP*/ diff --git a/tmpl/callable_detail.tmpl.hpp b/tmpl/callable_detail.tmpl.hpp new file mode 100644 index 0000000..ee11815 --- /dev/null +++ b/tmpl/callable_detail.tmpl.hpp @@ -0,0 +1,100 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_DETAIL_CALLABLE_HPP +#define INCLUDED_GRAS_DETAIL_CALLABLE_HPP + +#include //PMCList + +namespace gras +{ + +/*********************************************************************** + * Registration entry base class + **********************************************************************/ +struct GRAS_API CallableRegistryEntry +{ + CallableRegistryEntry(void); + virtual ~CallableRegistryEntry(void); + virtual PMCC call(const PMCC &args) = 0; +}; + +#for $NARGS in range($MAX_ARGS) +/*********************************************************************** + * Registration for return with $NARGS args + **********************************************************************/ +template +struct CallableRegistryEntryImpl$(NARGS) : CallableRegistryEntry +{ + typedef ReturnType(ClassType::*Fcn)($expand('const Arg%d &', $NARGS)); + CallableRegistryEntryImpl$(NARGS)(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < $NARGS) throw a; + return PMC_M((_obj->*_fcn)($expand('a[%d].safe_as()', $NARGS))); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)($expand('const Arg%d &', $NARGS))) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImpl$(NARGS)(obj, fcn); + _register_call(name, fr); +} + +template +struct CallableRegistryEntryImplVoid$(NARGS) : CallableRegistryEntry +{ + typedef void(ClassType::*Fcn)($expand('const Arg%d &', $NARGS)); + CallableRegistryEntryImplVoid$(NARGS)(ClassType *obj, Fcn fcn): + _obj(obj), _fcn(fcn){} + PMCC call(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < $NARGS) throw a; + (_obj->*_fcn)($expand('a[%d].safe_as()', $NARGS)); return PMCC(); + } + ClassType *_obj; Fcn _fcn; +}; + +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)($expand('const Arg%d &', $NARGS))) +{ + ClassType *obj = dynamic_cast(this); + void *fr = new CallableRegistryEntryImplVoid$(NARGS)(obj, fcn); + _register_call(name, fr); +} + +#end for +#for $NARGS in range($MAX_ARGS) +/*********************************************************************** + * Call implementations with $NARGS args + **********************************************************************/ +template +ReturnType Callable::x(const std::string &name, $expand('const Arg%d &a%d', $NARGS)) +{ + PMCList args($NARGS); + #for $i in range($NARGS): + args[$i] = PMC_M(a$i); + #end for + PMCC r = _handle_call(name, PMC_M(args)); + return r.safe_as(); +} + +template <$expand('typename Arg%d', $NARGS)> +void Callable::x(const std::string &name, $expand('const Arg%d &a%d', $NARGS)) +{ + PMCList args($NARGS); + #for $i in range($NARGS): + args[$i] = PMC_M(a$i); + #end for + _handle_call(name, PMC_M(args)); +} + +#end for +} //namespace gras + +#endif /*INCLUDED_GRAS_DETAIL_CALLABLE_HPP*/ diff --git a/tmpl/expand_template.py b/tmpl/expand_template.py new file mode 100644 index 0000000..3941fb2 --- /dev/null +++ b/tmpl/expand_template.py @@ -0,0 +1,33 @@ +# Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +import os +import sys +from Cheetah.Template import Template + +MAX_ARGS = 11 + +def expand(t, n): + out = list() + for i in range(n): out.append(t.replace('%d', str(i))) + return ', '.join(out) + +def cleanup(code): + code = code.replace('template <>', 'inline') + code = code.replace(', >', '>') + code = code.replace(', )', ')') + code = code.replace('\\#', '#') + return code + +if __name__ == '__main__': + in_path = sys.argv[1] + out_path = sys.argv[2] + tmpl = open(in_path, 'r').read() + for key in ['define', 'include', 'if', 'endif', 'else', 'ifdef', 'ifndef']: + tmpl = tmpl.replace('#%s'%key, '\\#%s'%key) + code = str(Template(tmpl, dict( + MAX_ARGS=MAX_ARGS, expand=expand, + ))) + code = cleanup(code) + if not os.path.exists(out_path) or open(out_path, 'r').read() != code: + print 'write code to', out_path + open(out_path, 'w').write(code) diff --git a/tmpl/factory.tmpl.hpp b/tmpl/factory.tmpl.hpp new file mode 100644 index 0000000..66f3e3e --- /dev/null +++ b/tmpl/factory.tmpl.hpp @@ -0,0 +1,63 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_FACTORY_HPP +#define INCLUDED_GRAS_FACTORY_HPP + +#include +#include +#include +#include + +/*! + * Register a block's factory function: + * Declare this macro at the global scope in a cpp file. + * The block will register at static initialization time. + */ +#define GRAS_REGISTER_FACTORY(name, fcn) \ + GRAS_STATIC_BLOCK(fcn) \ + {gras::Factory::register_make(name, &fcn);} + +namespace gras +{ + +/*! + * Element factory: + * - Register factory functions into the global factory. + * - Call make() to create element from global factory. + * + * Example register a factory function: + * gras::Factory::register_make("make_my_block", &make_my_block); + * + * Example call into the factory: + * gras::Element *my_block = gras::Factory::make("make_my_block", arg0, arg1); + */ +struct GRAS_API Factory +{ + /******************************************************************* + * Register API - don't look here, template magic, not helpful + ******************************************************************/ + #for $NARGS in range($MAX_ARGS) + template + static void register_make(const std::string &name, ReturnType(*fcn)($expand('const Arg%d &', $NARGS))); + + #end for + /******************************************************************* + * Make API - don't look here, template magic, not helpful + ******************************************************************/; + #for $NARGS in range($MAX_ARGS) + template <$expand('typename Arg%d', $NARGS)> + static Element *make(const std::string &name, $expand('const Arg%d &', $NARGS)); + + #end for + /******************************************************************* + * Private registration hooks + ******************************************************************/ + static void _register_make(const std::string &, void *); + static Element *_handle_make(const std::string &, const PMCC &); +}; + +} + +#include + +#endif /*INCLUDED_GRAS_FACTORY_HPP*/ diff --git a/tmpl/factory_detail.tmpl.hpp b/tmpl/factory_detail.tmpl.hpp new file mode 100644 index 0000000..1238c38 --- /dev/null +++ b/tmpl/factory_detail.tmpl.hpp @@ -0,0 +1,64 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_DETAIL_FACTORY_HPP +#define INCLUDED_GRAS_DETAIL_FACTORY_HPP + +#include //PMCList + +namespace gras +{ + +/*********************************************************************** + * Factory entry base class + **********************************************************************/ +struct GRAS_API FactoryRegistryEntry +{ + FactoryRegistryEntry(void); + virtual ~FactoryRegistryEntry(void); + virtual Element *make(const PMCC &args) = 0; +}; + +#for $NARGS in range($MAX_ARGS) +/*********************************************************************** + * Templated registration - $NARGS args + **********************************************************************/ +template +struct FactoryRegistryEntryImpl$(NARGS) : FactoryRegistryEntry +{ + typedef ReturnType(*Fcn)($expand('const Arg%d &', $NARGS)); + FactoryRegistryEntryImpl$(NARGS)(Fcn fcn):_fcn(fcn){} + Element *make(const PMCC &args) + { + const PMCList &a = args.as(); + if (a.size() < $NARGS) throw a; + return _fcn($expand('a[%d].safe_as()', $NARGS)); + } + Fcn _fcn; +}; + +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)($expand('const Arg%d &', $NARGS))) +{ + void *r = new FactoryRegistryEntryImpl$(NARGS)(fcn); + Factory::_register_make(name, r); +} + +#end for +/*********************************************************************** + * Templated make implementations + **********************************************************************/ +#for $NARGS in range($MAX_ARGS) +template <$expand('typename Arg%d', $NARGS)> +Element *Factory::make(const std::string &name, $expand('const Arg%d &a%d', $NARGS)) +{ + PMCList args($NARGS); + #for $i in range($NARGS): + args[$i] = PMC_M(a$i); + #end for + return Factory::_handle_make(name, PMC_M(args)); +} + +#end for +} + +#endif /*INCLUDED_GRAS_DETAIL_FACTORY_HPP*/ diff --git a/tmpl/regen_all.sh b/tmpl/regen_all.sh new file mode 100644 index 0000000..f9f4c95 --- /dev/null +++ b/tmpl/regen_all.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT="`readlink -e $0`" +SCRIPTPATH="`dirname $SCRIPT`" +DEST=${SCRIPTPATH}/../include/gras + +python expand_template.py factory.tmpl.hpp ${DEST}/factory.hpp +python expand_template.py factory_detail.tmpl.hpp ${DEST}/detail/factory.hpp +python expand_template.py callable.tmpl.hpp ${DEST}/callable.hpp +python expand_template.py callable_detail.tmpl.hpp ${DEST}/detail/callable.hpp -- cgit From fc98eaf2a00e000841cb16d962f83c118e4824c2 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 13 Jul 2013 12:58:22 -0700 Subject: gras: added comments and renamed tmpl args --- include/gras/callable.hpp | 160 ++++++++++---------- include/gras/detail/callable.hpp | 320 +++++++++++++++++++-------------------- include/gras/detail/factory.hpp | 160 ++++++++++---------- include/gras/factory.hpp | 80 +++++----- tmpl/callable.tmpl.hpp | 16 +- tmpl/callable_detail.tmpl.hpp | 32 ++-- tmpl/factory.tmpl.hpp | 8 +- tmpl/factory_detail.tmpl.hpp | 16 +- tmpl/regen_all.sh | 9 ++ 9 files changed, 405 insertions(+), 396 deletions(-) mode change 100644 => 100755 tmpl/regen_all.sh diff --git a/include/gras/callable.hpp b/include/gras/callable.hpp index 015f965..b5003c1 100644 --- a/include/gras/callable.hpp +++ b/include/gras/callable.hpp @@ -62,65 +62,65 @@ protected: template void register_call(const std::string &name, void(ClassType::*fcn)()); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &)); - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &)); - template - void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)); + template + void register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &)); /******************************************************************* * Call API - don't look here, template magic, not helpful @@ -132,65 +132,65 @@ public: inline void x(const std::string &name); - template - ReturnType x(const std::string &name, const Arg0 &); + template + ReturnType x(const std::string &name, const A0 &); - template - void x(const std::string &name, const Arg0 &); + template + void x(const std::string &name, const A0 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &); + template + void x(const std::string &name, const A0 &, const A1 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &, const A2 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &); + template + void x(const std::string &name, const A0 &, const A1 &, const A2 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + template + void x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + template + void x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + template + void x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + template + void x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + template + void x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + template + void x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &); - template - ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + template + ReturnType x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &); - template - void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + template + void x(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &); /******************************************************************* * Private registration hooks diff --git a/include/gras/detail/callable.hpp b/include/gras/detail/callable.hpp index 7a82a45..68766fe 100644 --- a/include/gras/detail/callable.hpp +++ b/include/gras/detail/callable.hpp @@ -70,490 +70,490 @@ void Callable::register_call(const std::string &name, void(ClassType::*fcn)()) /*********************************************************************** * Registration for return with 1 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl1 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &); CallableRegistryEntryImpl1(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 1) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl1(obj, fcn); + void *fr = new CallableRegistryEntryImpl1(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid1 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &); + typedef void(ClassType::*Fcn)(const A0 &); CallableRegistryEntryImplVoid1(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 1) throw a; - (_obj->*_fcn)(a[0].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid1(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid1(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 2 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl2 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &); CallableRegistryEntryImpl2(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 2) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl2(obj, fcn); + void *fr = new CallableRegistryEntryImpl2(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid2 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &); CallableRegistryEntryImplVoid2(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 2) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid2(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid2(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 3 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl3 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &); CallableRegistryEntryImpl3(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 3) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl3(obj, fcn); + void *fr = new CallableRegistryEntryImpl3(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid3 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &); CallableRegistryEntryImplVoid3(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 3) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid3(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid3(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 4 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl4 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &); CallableRegistryEntryImpl4(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 4) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl4(obj, fcn); + void *fr = new CallableRegistryEntryImpl4(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid4 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &); CallableRegistryEntryImplVoid4(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 4) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid4(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid4(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 5 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl5 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &); CallableRegistryEntryImpl5(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 5) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl5(obj, fcn); + void *fr = new CallableRegistryEntryImpl5(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid5 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &); CallableRegistryEntryImplVoid5(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 5) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid5(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid5(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 6 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl6 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &); CallableRegistryEntryImpl6(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 6) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl6(obj, fcn); + void *fr = new CallableRegistryEntryImpl6(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid6 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &); CallableRegistryEntryImplVoid6(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 6) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid6(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid6(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 7 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl7 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &); CallableRegistryEntryImpl7(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 7) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl7(obj, fcn); + void *fr = new CallableRegistryEntryImpl7(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid7 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &); CallableRegistryEntryImplVoid7(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 7) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid7(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid7(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 8 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl8 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &); CallableRegistryEntryImpl8(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 8) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl8(obj, fcn); + void *fr = new CallableRegistryEntryImpl8(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid8 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &); CallableRegistryEntryImplVoid8(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 8) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid8(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid8(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 9 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl9 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &); CallableRegistryEntryImpl9(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 9) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl9(obj, fcn); + void *fr = new CallableRegistryEntryImpl9(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid9 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &); CallableRegistryEntryImplVoid9(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 9) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid9(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid9(obj, fcn); _register_call(name, fr); } /*********************************************************************** * Registration for return with 10 args **********************************************************************/ -template +template struct CallableRegistryEntryImpl10 : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + typedef ReturnType(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &); CallableRegistryEntryImpl10(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 10) throw a; - return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as())); + return PMC_M((_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as())); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl10(obj, fcn); + void *fr = new CallableRegistryEntryImpl10(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid10 : CallableRegistryEntry { - typedef void(ClassType::*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + typedef void(ClassType::*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &); CallableRegistryEntryImplVoid10(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 10) throw a; - (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as()); return PMCC(); + (_obj->*_fcn)(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as()); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &)) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid10(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid10(obj, fcn); _register_call(name, fr); } @@ -578,8 +578,8 @@ void Callable::x(const std::string &name) /*********************************************************************** * Call implementations with 1 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0) +template +ReturnType Callable::x(const std::string &name, const A0 &a0) { PMCList args(1); args[0] = PMC_M(a0); @@ -587,8 +587,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0) return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0) +template +void Callable::x(const std::string &name, const A0 &a0) { PMCList args(1); args[0] = PMC_M(a0); @@ -598,8 +598,8 @@ void Callable::x(const std::string &name, const Arg0 &a0) /*********************************************************************** * Call implementations with 2 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1) +template +ReturnType Callable::x(const std::string &name, const A0 &a0, const A1 &a1) { PMCList args(2); args[0] = PMC_M(a0); @@ -608,8 +608,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1) return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1) +template +void Callable::x(const std::string &name, const A0 &a0, const A1 &a1) { PMCList args(2); args[0] = PMC_M(a0); @@ -620,8 +620,8 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1) /*********************************************************************** * Call implementations with 3 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2) +template +ReturnType Callable::x(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2) { PMCList args(3); args[0] = PMC_M(a0); @@ -631,8 +631,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2) +template +void Callable::x(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2) { PMCList args(3); args[0] = PMC_M(a0); @@ -644,8 +644,8 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const /*********************************************************************** * Call implementations with 4 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3) +template +ReturnType Callable::x(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3) { PMCList args(4); args[0] = PMC_M(a0); @@ -656,8 +656,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3) +template +void Callable::x(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3) { PMCList args(4); args[0] = PMC_M(a0); @@ -670,8 +670,8 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const /*********************************************************************** * Call implementations with 5 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4) +template +ReturnType Callable::x(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); @@ -683,8 +683,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4) +template +void Callable::x(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); @@ -698,8 +698,8 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const /*********************************************************************** * Call implementations with 6 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5) +template +ReturnType Callable::x(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); @@ -712,8 +712,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5) +template +void Callable::x(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); @@ -728,8 +728,8 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const /*********************************************************************** * Call implementations with 7 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6) +template +ReturnType Callable::x(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); @@ -743,8 +743,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6) +template +void Callable::x(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); @@ -760,8 +760,8 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const /*********************************************************************** * Call implementations with 8 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7) +template +ReturnType Callable::x(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); @@ -776,8 +776,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7) +template +void Callable::x(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); @@ -794,8 +794,8 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const /*********************************************************************** * Call implementations with 9 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8) +template +ReturnType Callable::x(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); @@ -811,8 +811,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8) +template +void Callable::x(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); @@ -830,8 +830,8 @@ void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const /*********************************************************************** * Call implementations with 10 args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9) +template +ReturnType Callable::x(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); @@ -848,8 +848,8 @@ ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, return r.safe_as(); } -template -void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9) +template +void Callable::x(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); diff --git a/include/gras/detail/factory.hpp b/include/gras/detail/factory.hpp index 6570da4..a2de116 100644 --- a/include/gras/detail/factory.hpp +++ b/include/gras/detail/factory.hpp @@ -45,240 +45,240 @@ void Factory::register_make(const std::string &name, ReturnType(*fcn)()) /*********************************************************************** * Templated registration - 1 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl1 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &); + typedef ReturnType(*Fcn)(const A0 &); FactoryRegistryEntryImpl1(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 1) throw a; - return _fcn(a[0].safe_as()); + return _fcn(a[0].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &)) +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &)) { - void *r = new FactoryRegistryEntryImpl1(fcn); + void *r = new FactoryRegistryEntryImpl1(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 2 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl2 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &); FactoryRegistryEntryImpl2(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 2) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &)) +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &)) { - void *r = new FactoryRegistryEntryImpl2(fcn); + void *r = new FactoryRegistryEntryImpl2(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 3 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl3 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &, const A2 &); FactoryRegistryEntryImpl3(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 3) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &)) +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &)) { - void *r = new FactoryRegistryEntryImpl3(fcn); + void *r = new FactoryRegistryEntryImpl3(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 4 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl4 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &); FactoryRegistryEntryImpl4(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 4) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)) +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &)) { - void *r = new FactoryRegistryEntryImpl4(fcn); + void *r = new FactoryRegistryEntryImpl4(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 5 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl5 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &); FactoryRegistryEntryImpl5(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 5) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)) +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &)) { - void *r = new FactoryRegistryEntryImpl5(fcn); + void *r = new FactoryRegistryEntryImpl5(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 6 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl6 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &); FactoryRegistryEntryImpl6(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 6) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)) +template +void Factory::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); + void *r = new FactoryRegistryEntryImpl6(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 7 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl7 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &); FactoryRegistryEntryImpl7(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 7) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)) +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 *r = new FactoryRegistryEntryImpl7(fcn); + void *r = new FactoryRegistryEntryImpl7(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 8 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl8 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &); FactoryRegistryEntryImpl8(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 8) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)) +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 *r = new FactoryRegistryEntryImpl8(fcn); + void *r = new FactoryRegistryEntryImpl8(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 9 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl9 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &); FactoryRegistryEntryImpl9(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 9) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)) +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 *r = new FactoryRegistryEntryImpl9(fcn); + void *r = new FactoryRegistryEntryImpl9(fcn); Factory::_register_make(name, r); } /*********************************************************************** * Templated registration - 10 args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl10 : FactoryRegistryEntry { - typedef ReturnType(*Fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + typedef ReturnType(*Fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &); FactoryRegistryEntryImpl10(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < 10) throw a; - return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as()); + return _fcn(a[0].safe_as(), a[1].safe_as(), a[2].safe_as(), a[3].safe_as(), a[4].safe_as(), a[5].safe_as(), a[6].safe_as(), a[7].safe_as(), a[8].safe_as(), a[9].safe_as()); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)) +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 *r = new FactoryRegistryEntryImpl10(fcn); + void *r = new FactoryRegistryEntryImpl10(fcn); Factory::_register_make(name, r); } @@ -292,16 +292,16 @@ Element *Factory::make(const std::string &name) return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0) +template +Element *Factory::make(const std::string &name, const A0 &a0) { PMCList args(1); args[0] = PMC_M(a0); return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1) +template +Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1) { PMCList args(2); args[0] = PMC_M(a0); @@ -309,8 +309,8 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1) return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2) +template +Element *Factory::make(const std::string &name, const A0 &a0, const A1 &a1, const A2 &a2) { PMCList args(3); args[0] = PMC_M(a0); @@ -319,8 +319,8 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3) +template +Element *Factory::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); @@ -330,8 +330,8 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4) +template +Element *Factory::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); @@ -342,8 +342,8 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5) +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) { PMCList args(6); args[0] = PMC_M(a0); @@ -355,8 +355,8 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6) +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) { PMCList args(7); args[0] = PMC_M(a0); @@ -369,8 +369,8 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7) +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) { PMCList args(8); args[0] = PMC_M(a0); @@ -384,8 +384,8 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8) +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) { PMCList args(9); args[0] = PMC_M(a0); @@ -400,8 +400,8 @@ Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, return Factory::_handle_make(name, PMC_M(args)); } -template -Element *Factory::make(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9) +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) { PMCList args(10); args[0] = PMC_M(a0); diff --git a/include/gras/factory.hpp b/include/gras/factory.hpp index b60b1e7..cffd4b1 100644 --- a/include/gras/factory.hpp +++ b/include/gras/factory.hpp @@ -39,35 +39,35 @@ struct GRAS_API Factory template static void register_make(const std::string &name, ReturnType(*fcn)()); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &)); + template + static void register_make(const std::string &name, ReturnType(*fcn)(const A0 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &)); + template + static void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &)); + template + static void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &)); + template + static void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &)); + template + static void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &)); + template + static void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &)); + template + static void register_make(const std::string &name, ReturnType(*fcn)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &)); + template + static 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 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &)); + template + static 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 &)); - template - static void register_make(const std::string &name, ReturnType(*fcn)(const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &)); + template + static 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 &)); /******************************************************************* * Make API - don't look here, template magic, not helpful @@ -75,35 +75,35 @@ struct GRAS_API Factory inline static Element *make(const std::string &name); - template - static Element *make(const std::string &name, const Arg0 &); + template + static Element *make(const std::string &name, const A0 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &, const A2 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &); - template - static Element *make(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &, const Arg3 &, const Arg4 &, const Arg5 &, const Arg6 &, const Arg7 &, const Arg8 &, const Arg9 &); + template + static Element *make(const std::string &name, const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 &); /******************************************************************* * Private registration hooks diff --git a/tmpl/callable.tmpl.hpp b/tmpl/callable.tmpl.hpp index 1c73910..900bae4 100644 --- a/tmpl/callable.tmpl.hpp +++ b/tmpl/callable.tmpl.hpp @@ -57,11 +57,11 @@ protected: ******************************************************************/ protected: #for $NARGS in range($MAX_ARGS) - template - void register_call(const std::string &name, ReturnType(ClassType::*fcn)($expand('const Arg%d &', $NARGS))); + template + void register_call(const std::string &name, ReturnType(ClassType::*fcn)($expand('const A%d &', $NARGS))); - template - void register_call(const std::string &name, void(ClassType::*fcn)($expand('const Arg%d &', $NARGS))); + template + void register_call(const std::string &name, void(ClassType::*fcn)($expand('const A%d &', $NARGS))); #end for /******************************************************************* @@ -69,11 +69,11 @@ protected: ******************************************************************/ public: #for $NARGS in range($MAX_ARGS) - template - ReturnType x(const std::string &name, $expand('const Arg%d &', $NARGS)); + template + ReturnType x(const std::string &name, $expand('const A%d &', $NARGS)); - template <$expand('typename Arg%d', $NARGS)> - void x(const std::string &name, $expand('const Arg%d &', $NARGS)); + template <$expand('typename A%d', $NARGS)> + void x(const std::string &name, $expand('const A%d &', $NARGS)); #end for /******************************************************************* diff --git a/tmpl/callable_detail.tmpl.hpp b/tmpl/callable_detail.tmpl.hpp index ee11815..65750e7 100644 --- a/tmpl/callable_detail.tmpl.hpp +++ b/tmpl/callable_detail.tmpl.hpp @@ -22,49 +22,49 @@ struct GRAS_API CallableRegistryEntry /*********************************************************************** * Registration for return with $NARGS args **********************************************************************/ -template +template struct CallableRegistryEntryImpl$(NARGS) : CallableRegistryEntry { - typedef ReturnType(ClassType::*Fcn)($expand('const Arg%d &', $NARGS)); + typedef ReturnType(ClassType::*Fcn)($expand('const A%d &', $NARGS)); CallableRegistryEntryImpl$(NARGS)(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < $NARGS) throw a; - return PMC_M((_obj->*_fcn)($expand('a[%d].safe_as()', $NARGS))); + return PMC_M((_obj->*_fcn)($expand('a[%d].safe_as()', $NARGS))); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)($expand('const Arg%d &', $NARGS))) +template +void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)($expand('const A%d &', $NARGS))) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImpl$(NARGS)(obj, fcn); + void *fr = new CallableRegistryEntryImpl$(NARGS)(obj, fcn); _register_call(name, fr); } -template +template struct CallableRegistryEntryImplVoid$(NARGS) : CallableRegistryEntry { - typedef void(ClassType::*Fcn)($expand('const Arg%d &', $NARGS)); + typedef void(ClassType::*Fcn)($expand('const A%d &', $NARGS)); CallableRegistryEntryImplVoid$(NARGS)(ClassType *obj, Fcn fcn): _obj(obj), _fcn(fcn){} PMCC call(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < $NARGS) throw a; - (_obj->*_fcn)($expand('a[%d].safe_as()', $NARGS)); return PMCC(); + (_obj->*_fcn)($expand('a[%d].safe_as()', $NARGS)); return PMCC(); } ClassType *_obj; Fcn _fcn; }; -template -void Callable::register_call(const std::string &name, void(ClassType::*fcn)($expand('const Arg%d &', $NARGS))) +template +void Callable::register_call(const std::string &name, void(ClassType::*fcn)($expand('const A%d &', $NARGS))) { ClassType *obj = dynamic_cast(this); - void *fr = new CallableRegistryEntryImplVoid$(NARGS)(obj, fcn); + void *fr = new CallableRegistryEntryImplVoid$(NARGS)(obj, fcn); _register_call(name, fr); } @@ -73,8 +73,8 @@ void Callable::register_call(const std::string &name, void(ClassType::*fcn)($exp /*********************************************************************** * Call implementations with $NARGS args **********************************************************************/ -template -ReturnType Callable::x(const std::string &name, $expand('const Arg%d &a%d', $NARGS)) +template +ReturnType Callable::x(const std::string &name, $expand('const A%d &a%d', $NARGS)) { PMCList args($NARGS); #for $i in range($NARGS): @@ -84,8 +84,8 @@ ReturnType Callable::x(const std::string &name, $expand('const Arg%d &a%d', $NAR return r.safe_as(); } -template <$expand('typename Arg%d', $NARGS)> -void Callable::x(const std::string &name, $expand('const Arg%d &a%d', $NARGS)) +template <$expand('typename A%d', $NARGS)> +void Callable::x(const std::string &name, $expand('const A%d &a%d', $NARGS)) { PMCList args($NARGS); #for $i in range($NARGS): diff --git a/tmpl/factory.tmpl.hpp b/tmpl/factory.tmpl.hpp index 66f3e3e..a9c9820 100644 --- a/tmpl/factory.tmpl.hpp +++ b/tmpl/factory.tmpl.hpp @@ -37,16 +37,16 @@ struct GRAS_API Factory * Register API - don't look here, template magic, not helpful ******************************************************************/ #for $NARGS in range($MAX_ARGS) - template - static void register_make(const std::string &name, ReturnType(*fcn)($expand('const Arg%d &', $NARGS))); + template + static void register_make(const std::string &name, ReturnType(*fcn)($expand('const A%d &', $NARGS))); #end for /******************************************************************* * Make API - don't look here, template magic, not helpful ******************************************************************/; #for $NARGS in range($MAX_ARGS) - template <$expand('typename Arg%d', $NARGS)> - static Element *make(const std::string &name, $expand('const Arg%d &', $NARGS)); + template <$expand('typename A%d', $NARGS)> + static Element *make(const std::string &name, $expand('const A%d &', $NARGS)); #end for /******************************************************************* diff --git a/tmpl/factory_detail.tmpl.hpp b/tmpl/factory_detail.tmpl.hpp index 1238c38..87a0756 100644 --- a/tmpl/factory_detail.tmpl.hpp +++ b/tmpl/factory_detail.tmpl.hpp @@ -22,24 +22,24 @@ struct GRAS_API FactoryRegistryEntry /*********************************************************************** * Templated registration - $NARGS args **********************************************************************/ -template +template struct FactoryRegistryEntryImpl$(NARGS) : FactoryRegistryEntry { - typedef ReturnType(*Fcn)($expand('const Arg%d &', $NARGS)); + typedef ReturnType(*Fcn)($expand('const A%d &', $NARGS)); FactoryRegistryEntryImpl$(NARGS)(Fcn fcn):_fcn(fcn){} Element *make(const PMCC &args) { const PMCList &a = args.as(); if (a.size() < $NARGS) throw a; - return _fcn($expand('a[%d].safe_as()', $NARGS)); + return _fcn($expand('a[%d].safe_as()', $NARGS)); } Fcn _fcn; }; -template -void Factory::register_make(const std::string &name, ReturnType(*fcn)($expand('const Arg%d &', $NARGS))) +template +void Factory::register_make(const std::string &name, ReturnType(*fcn)($expand('const A%d &', $NARGS))) { - void *r = new FactoryRegistryEntryImpl$(NARGS)(fcn); + void *r = new FactoryRegistryEntryImpl$(NARGS)(fcn); Factory::_register_make(name, r); } @@ -48,8 +48,8 @@ void Factory::register_make(const std::string &name, ReturnType(*fcn)($expand('c * Templated make implementations **********************************************************************/ #for $NARGS in range($MAX_ARGS) -template <$expand('typename Arg%d', $NARGS)> -Element *Factory::make(const std::string &name, $expand('const Arg%d &a%d', $NARGS)) +template <$expand('typename A%d', $NARGS)> +Element *Factory::make(const std::string &name, $expand('const A%d &a%d', $NARGS)) { PMCList args($NARGS); #for $i in range($NARGS): diff --git a/tmpl/regen_all.sh b/tmpl/regen_all.sh old mode 100644 new mode 100755 index f9f4c95..53886c9 --- a/tmpl/regen_all.sh +++ b/tmpl/regen_all.sh @@ -1,5 +1,14 @@ #!/bin/bash +# This script generates the multi-argument template code +# for the callable and factory interfaces. +# This is the magic that makes the API calls +# so natural to call into as a C++ client app. +# This script is manually run when the source tmpl files are changed. +# And the generated sources are checked in. +# This way, the build system does not generate public headers. +# And the build system does not depend on Cheetah templates. + SCRIPT="`readlink -e $0`" SCRIPTPATH="`dirname $SCRIPT`" DEST=${SCRIPTPATH}/../include/gras -- cgit