From 086cf85eca88941819909f5877d9558aaa761b72 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 5 Jul 2013 14:13:37 -0700 Subject: gras: revert block changes, test w/ callable now --- include/gras/detail/block.hpp | 100 ------------------------------------------ 1 file changed, 100 deletions(-) (limited to 'include/gras/detail') diff --git a/include/gras/detail/block.hpp b/include/gras/detail/block.hpp index e098797..9dccb22 100644 --- a/include/gras/detail/block.hpp +++ b/include/gras/detail/block.hpp @@ -8,106 +8,6 @@ namespace gras { -struct GRAS_API FunctionRegistry -{ - FunctionRegistry(void); - virtual ~FunctionRegistry(void); - virtual PMCC call(const std::vector &args) = 0; -}; - -template -class FunctionRegistryImpl : public FunctionRegistry -{ -public: - - typedef ReturnType(ClassType::*Fcn0)(void); - typedef ReturnType(ClassType::*Fcn1)(const Arg0 &); - typedef ReturnType(ClassType::*Fcn2)(const Arg0 &, const Arg1 &); - - FunctionRegistryImpl(ClassType *obj, Fcn0 fcn0, Fcn1 fcn1 = NULL, Fcn2 fcn2 = NULL): - _obj(obj), _fcn0(fcn0), _fcn1(fcn1), _fcn2(fcn2) - {} - virtual ~FunctionRegistryImpl(void){} - - PMCC call(const std::vector &args) - { - if (_fcn0) return PMC_M((_obj->*_fcn0)()); - if (_fcn1) return PMC_M((_obj->*_fcn1)(args[0].safe_as())); - if (_fcn2) return PMC_M((_obj->*_fcn2)(args[0].safe_as(), args[1].safe_as())); - return PMCC();//should not get here - } - -private: - ClassType *_obj; - Fcn0 _fcn0; Fcn1 _fcn1; Fcn2 _fcn2; -}; - -template void Block::register_call(const std::string &key, ReturnType(ClassType::*fcn)(void)) -{ - ClassType *obj = dynamic_cast(this); - void *fr = new FunctionRegistryImpl(obj, fcn); - _register_function(key, fr); -} - -template void Block::register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &)) -{ - ClassType *obj = dynamic_cast(this); - void *fr = new FunctionRegistryImpl(obj, NULL, fcn); - _register_function(key, fr); -} - -template void Block::register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &)) -{ - ClassType *obj = dynamic_cast(this); - void *fr = new FunctionRegistryImpl(obj, NULL, NULL, fcn); - _register_function(key, fr); -} - -template ReturnType Block::call(const std::string &key) -{ - std::vector args; - PMCC r = _handle_function_access(key, args); - return r.safe_as(); -} - -template ReturnType Block::call(const std::string &key, const Arg0 &a0) -{ - std::vector args; - args.push_back(PMC_M(a0)); - PMCC r = _handle_function_access(key, args); - return r.safe_as(); -} - -template ReturnType Block::call(const std::string &key, const Arg0 &a0, const Arg1 &a1) -{ - std::vector args; - args.push_back(PMC_M(a0)); - args.push_back(PMC_M(a1)); - PMCC r = _handle_function_access(key, args); - return r.safe_as(); -} - -inline void Block::call(const std::string &key) -{ - std::vector args; - _handle_function_access(key, args); -} - -template void Block::call(const std::string &key, const Arg0 &a0) -{ - std::vector args; - args.push_back(PMC_M(a0)); - _handle_function_access(key, args); -} - -template void Block::call(const std::string &key, const Arg0 &a0, const Arg1 &a1) -{ - std::vector args; - args.push_back(PMC_M(a0)); - args.push_back(PMC_M(a1)); - _handle_function_access(key, args); -} - struct GRAS_API PropertyRegistry { PropertyRegistry(void); -- cgit