summaryrefslogtreecommitdiff
path: root/include/gras/detail
diff options
context:
space:
mode:
authorJosh Blum2013-07-05 14:13:37 -0700
committerJosh Blum2013-07-05 14:13:37 -0700
commit086cf85eca88941819909f5877d9558aaa761b72 (patch)
tree750197523499df923b69dc2cdf0f8003e7d8a02a /include/gras/detail
parentbc8165bcc3a2703d8fd3d17925b6bcb55ddff6ef (diff)
downloadsandhi-086cf85eca88941819909f5877d9558aaa761b72.tar.gz
sandhi-086cf85eca88941819909f5877d9558aaa761b72.tar.bz2
sandhi-086cf85eca88941819909f5877d9558aaa761b72.zip
gras: revert block changes, test w/ callable now
Diffstat (limited to 'include/gras/detail')
-rw-r--r--include/gras/detail/block.hpp100
1 files changed, 0 insertions, 100 deletions
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<PMCC> &args) = 0;
-};
-
-template <typename ClassType, typename ReturnType, typename Arg0, typename Arg1>
-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<PMCC> &args)
- {
- if (_fcn0) return PMC_M((_obj->*_fcn0)());
- if (_fcn1) return PMC_M((_obj->*_fcn1)(args[0].safe_as<Arg0>()));
- if (_fcn2) return PMC_M((_obj->*_fcn2)(args[0].safe_as<Arg0>(), args[1].safe_as<Arg1>()));
- return PMCC();//should not get here
- }
-
-private:
- ClassType *_obj;
- Fcn0 _fcn0; Fcn1 _fcn1; Fcn2 _fcn2;
-};
-
-template <typename ClassType, typename ReturnType> void Block::register_call(const std::string &key, ReturnType(ClassType::*fcn)(void))
-{
- ClassType *obj = dynamic_cast<ClassType *>(this);
- void *fr = new FunctionRegistryImpl<ClassType, ReturnType, int, int>(obj, fcn);
- _register_function(key, fr);
-}
-
-template <typename ClassType, typename ReturnType, typename Arg0> void Block::register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &))
-{
- ClassType *obj = dynamic_cast<ClassType *>(this);
- void *fr = new FunctionRegistryImpl<ClassType, ReturnType, Arg0, int>(obj, NULL, fcn);
- _register_function(key, fr);
-}
-
-template <typename ClassType, typename ReturnType, typename Arg0, typename Arg1> void Block::register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &))
-{
- ClassType *obj = dynamic_cast<ClassType *>(this);
- void *fr = new FunctionRegistryImpl<ClassType, ReturnType, Arg0, Arg1>(obj, NULL, NULL, fcn);
- _register_function(key, fr);
-}
-
-template <typename ReturnType> ReturnType Block::call(const std::string &key)
-{
- std::vector<PMCC> args;
- PMCC r = _handle_function_access(key, args);
- return r.safe_as<ReturnType>();
-}
-
-template <typename ReturnType, typename Arg0> ReturnType Block::call(const std::string &key, const Arg0 &a0)
-{
- std::vector<PMCC> args;
- args.push_back(PMC_M(a0));
- PMCC r = _handle_function_access(key, args);
- return r.safe_as<ReturnType>();
-}
-
-template <typename ReturnType, typename Arg0, typename Arg1> ReturnType Block::call(const std::string &key, const Arg0 &a0, const Arg1 &a1)
-{
- std::vector<PMCC> args;
- args.push_back(PMC_M(a0));
- args.push_back(PMC_M(a1));
- PMCC r = _handle_function_access(key, args);
- return r.safe_as<ReturnType>();
-}
-
-inline void Block::call(const std::string &key)
-{
- std::vector<PMCC> args;
- _handle_function_access(key, args);
-}
-
-template <typename Arg0> void Block::call(const std::string &key, const Arg0 &a0)
-{
- std::vector<PMCC> args;
- args.push_back(PMC_M(a0));
- _handle_function_access(key, args);
-}
-
-template <typename Arg0, typename Arg1> void Block::call(const std::string &key, const Arg0 &a0, const Arg1 &a1)
-{
- std::vector<PMCC> args;
- args.push_back(PMC_M(a0));
- args.push_back(PMC_M(a1));
- _handle_function_access(key, args);
-}
-
struct GRAS_API PropertyRegistry
{
PropertyRegistry(void);