summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gras/callable.hpp40
-rw-r--r--include/gras/detail/callable.hpp64
-rw-r--r--include/gras/element.i4
-rw-r--r--lib/callable.cpp24
-rw-r--r--lib/top_block_query.cpp2
-rw-r--r--python/gras/GRAS_PyBlock.i26
6 files changed, 80 insertions, 80 deletions
diff --git a/include/gras/callable.hpp b/include/gras/callable.hpp
index 792be93..60d0fb0 100644
--- a/include/gras/callable.hpp
+++ b/include/gras/callable.hpp
@@ -42,71 +42,71 @@ public:
//! Destructor (virtual for subclasses)
virtual ~Callable(void);
- //! Get a list of keys for registered calls
- std::vector<std::string> get_registered_keys(void) const;
+ //! Get a list of names for registered calls
+ std::vector<std::string> get_registered_names(void) const;
protected:
/*!
* Unregister a previously registered call.
- * Throws if the key is not found in the registry.
+ * Throws if the name is not found in the registry.
*/
- void unregister_call(const std::string &key);
+ void unregister_call(const std::string &name);
/*******************************************************************
* Register API - don't look here, template magic, not helpful
******************************************************************/
protected:
template <typename ClassType, typename ReturnType>
- void register_call(const std::string &key, ReturnType(ClassType::*fcn)(void));
+ void register_call(const std::string &name, ReturnType(ClassType::*fcn)(void));
template <typename ClassType>
- void register_call(const std::string &key, void(ClassType::*fcn)(void));
+ void register_call(const std::string &name, void(ClassType::*fcn)(void));
template <typename ClassType, typename ReturnType, typename Arg0>
- void register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &));
+ void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &));
template <typename ClassType, typename Arg0>
- void register_call(const std::string &key, void(ClassType::*fcn)(const Arg0 &));
+ void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &));
template <typename ClassType, typename ReturnType, typename Arg0, typename Arg1>
- void register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &));
+ void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &));
template <typename ClassType, typename Arg0, typename Arg1>
- void register_call(const std::string &key, void(ClassType::*fcn)(const Arg0 &, const Arg1 &));
+ void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &));
template <typename ClassType, typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
- void register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &));
+ void register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &));
template <typename ClassType, typename Arg0, typename Arg1, typename Arg2>
- void register_call(const std::string &key, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &));
+ void register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &));
/*******************************************************************
* Call API - don't look here, template magic, not helpful
******************************************************************/
public:
template <typename ReturnType>
- ReturnType x(const std::string &key);
+ ReturnType x(const std::string &name);
inline
- void x(const std::string &key);
+ void x(const std::string &name);
template <typename ReturnType, typename Arg0>
- ReturnType x(const std::string &key, const Arg0 &);
+ ReturnType x(const std::string &name, const Arg0 &);
template <typename Arg0>
- void x(const std::string &key, const Arg0 &);
+ void x(const std::string &name, const Arg0 &);
template <typename ReturnType, typename Arg0, typename Arg1>
- ReturnType x(const std::string &key, const Arg0 &, const Arg1 &);
+ ReturnType x(const std::string &name, const Arg0 &, const Arg1 &);
template <typename Arg0, typename Arg1>
- void x(const std::string &key, const Arg0 &, const Arg1 &);
+ void x(const std::string &name, const Arg0 &, const Arg1 &);
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
- ReturnType x(const std::string &key, const Arg0 &, const Arg1 &, const Arg2 &);
+ ReturnType x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &);
template <typename Arg0, typename Arg1, typename Arg2>
- void x(const std::string &key, const Arg0 &, const Arg1 &, const Arg2 &);
+ void x(const std::string &name, const Arg0 &, const Arg1 &, const Arg2 &);
/*******************************************************************
* Private registration hooks
diff --git a/include/gras/detail/callable.hpp b/include/gras/detail/callable.hpp
index ddc8f55..98fa29d 100644
--- a/include/gras/detail/callable.hpp
+++ b/include/gras/detail/callable.hpp
@@ -35,11 +35,11 @@ struct CallableRegistryEntryImpl0 : CallableRegistryEntry
};
template <typename ClassType, typename ReturnType>
-void Callable::register_call(const std::string &key, ReturnType(ClassType::*fcn)(void))
+void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(void))
{
ClassType *obj = dynamic_cast<ClassType *>(this);
void *fr = new CallableRegistryEntryImpl0<ClassType, ReturnType>(obj, fcn);
- _register_call(key, fr);
+ _register_call(name, fr);
}
template <typename ClassType>
@@ -56,11 +56,11 @@ struct CallableRegistryEntryImplVoid0 : CallableRegistryEntry
};
template <typename ClassType>
-void Callable::register_call(const std::string &key, void(ClassType::*fcn)(void))
+void Callable::register_call(const std::string &name, void(ClassType::*fcn)(void))
{
ClassType *obj = dynamic_cast<ClassType *>(this);
void *fr = new CallableRegistryEntryImplVoid0<ClassType>(obj, fcn);
- _register_call(key, fr);
+ _register_call(name, fr);
}
/***********************************************************************
@@ -81,11 +81,11 @@ struct CallableRegistryEntryImpl1 : CallableRegistryEntry
};
template <typename ClassType, typename ReturnType, typename Arg0>
-void Callable::register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &))
+void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &))
{
ClassType *obj = dynamic_cast<ClassType *>(this);
void *fr = new CallableRegistryEntryImpl1<ClassType, ReturnType, Arg0>(obj, fcn);
- _register_call(key, fr);
+ _register_call(name, fr);
}
template <typename ClassType, typename Arg0>
@@ -103,11 +103,11 @@ struct CallableRegistryEntryImplVoid1 : CallableRegistryEntry
};
template <typename ClassType, typename Arg0>
-void Callable::register_call(const std::string &key, void(ClassType::*fcn)(const Arg0 &))
+void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &))
{
ClassType *obj = dynamic_cast<ClassType *>(this);
void *fr = new CallableRegistryEntryImplVoid1<ClassType, Arg0>(obj, fcn);
- _register_call(key, fr);
+ _register_call(name, fr);
}
/***********************************************************************
@@ -128,11 +128,11 @@ struct CallableRegistryEntryImpl2 : CallableRegistryEntry
};
template <typename ClassType, typename ReturnType, typename Arg0, typename Arg1>
-void Callable::register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &))
+void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &))
{
ClassType *obj = dynamic_cast<ClassType *>(this);
void *fr = new CallableRegistryEntryImpl2<ClassType, ReturnType, Arg0, Arg1>(obj, fcn);
- _register_call(key, fr);
+ _register_call(name, fr);
}
template <typename ClassType, typename Arg0, typename Arg1>
@@ -150,11 +150,11 @@ struct CallableRegistryEntryImplVoid2 : CallableRegistryEntry
};
template <typename ClassType, typename Arg0, typename Arg1>
-void Callable::register_call(const std::string &key, void(ClassType::*fcn)(const Arg0 &, const Arg1 &))
+void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &))
{
ClassType *obj = dynamic_cast<ClassType *>(this);
void *fr = new CallableRegistryEntryImplVoid2<ClassType, Arg0, Arg1>(obj, fcn);
- _register_call(key, fr);
+ _register_call(name, fr);
}
/***********************************************************************
@@ -175,11 +175,11 @@ struct CallableRegistryEntryImpl3 : CallableRegistryEntry
};
template <typename ClassType, typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
-void Callable::register_call(const std::string &key, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &))
+void Callable::register_call(const std::string &name, ReturnType(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &))
{
ClassType *obj = dynamic_cast<ClassType *>(this);
void *fr = new CallableRegistryEntryImpl3<ClassType, ReturnType, Arg0, Arg1, Arg2>(obj, fcn);
- _register_call(key, fr);
+ _register_call(name, fr);
}
template <typename ClassType, typename Arg0, typename Arg1, typename Arg2>
@@ -197,95 +197,95 @@ struct CallableRegistryEntryImplVoid3 : CallableRegistryEntry
};
template <typename ClassType, typename Arg0, typename Arg1, typename Arg2>
-void Callable::register_call(const std::string &key, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &))
+void Callable::register_call(const std::string &name, void(ClassType::*fcn)(const Arg0 &, const Arg1 &, const Arg2 &))
{
ClassType *obj = dynamic_cast<ClassType *>(this);
void *fr = new CallableRegistryEntryImplVoid3<ClassType, Arg0, Arg1, Arg2>(obj, fcn);
- _register_call(key, fr);
+ _register_call(name, fr);
}
/***********************************************************************
* Call implementations with 0 args
**********************************************************************/
template <typename ReturnType>
-ReturnType Callable::x(const std::string &key)
+ReturnType Callable::x(const std::string &name)
{
PMCList args(0);
- PMCC r = _handle_call(key, PMC_M(args));
+ PMCC r = _handle_call(name, PMC_M(args));
return r.safe_as<ReturnType>();
}
inline
-void Callable::x(const std::string &key)
+void Callable::x(const std::string &name)
{
PMCList args(0);
- _handle_call(key, PMC_M(args));
+ _handle_call(name, PMC_M(args));
}
/***********************************************************************
* Call implementations with 1 args
**********************************************************************/
template <typename ReturnType, typename Arg0>
-ReturnType Callable::x(const std::string &key, const Arg0 &a0)
+ReturnType Callable::x(const std::string &name, const Arg0 &a0)
{
PMCList args(1);
args[0] = PMC_M(a0);
- PMCC r = _handle_call(key, PMC_M(args));
+ PMCC r = _handle_call(name, PMC_M(args));
return r.safe_as<ReturnType>();
}
template <typename Arg0>
-void Callable::x(const std::string &key, const Arg0 &a0)
+void Callable::x(const std::string &name, const Arg0 &a0)
{
PMCList args(1);
args[0] = PMC_M(a0);
- _handle_call(key, PMC_M(args));
+ _handle_call(name, PMC_M(args));
}
/***********************************************************************
* Call implementations with 2 args
**********************************************************************/
template <typename ReturnType, typename Arg0, typename Arg1>
-ReturnType Callable::x(const std::string &key, const Arg0 &a0, const Arg1 &a1)
+ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1)
{
PMCList args(2);
args[0] = PMC_M(a0);
args[1] = PMC_M(a1);
- PMCC r = _handle_call(key, PMC_M(args));
+ PMCC r = _handle_call(name, PMC_M(args));
return r.safe_as<ReturnType>();
}
template <typename Arg0, typename Arg1>
-void Callable::x(const std::string &key, const Arg0 &a0, const Arg1 &a1)
+void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1)
{
PMCList args(2);
args[0] = PMC_M(a0);
args[1] = PMC_M(a1);
- _handle_call(key, PMC_M(args));
+ _handle_call(name, PMC_M(args));
}
/***********************************************************************
* Call implementations with 3 args
**********************************************************************/
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
-ReturnType Callable::x(const std::string &key, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2)
+ReturnType Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2)
{
PMCList args(3);
args[0] = PMC_M(a0);
args[1] = PMC_M(a1);
args[2] = PMC_M(a2);
- PMCC r = _handle_call(key, PMC_M(args));
+ PMCC r = _handle_call(name, PMC_M(args));
return r.safe_as<ReturnType>();
}
template <typename Arg0, typename Arg1, typename Arg2>
-void Callable::x(const std::string &key, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2)
+void Callable::x(const std::string &name, const Arg0 &a0, const Arg1 &a1, const Arg2 &a2)
{
PMCList args(3);
args[0] = PMC_M(a0);
args[1] = PMC_M(a1);
args[2] = PMC_M(a2);
- _handle_call(key, PMC_M(args));
+ _handle_call(name, PMC_M(args));
}
} //namespace gras
diff --git a/include/gras/element.i b/include/gras/element.i
index 5857548..d462370 100644
--- a/include/gras/element.i
+++ b/include/gras/element.i
@@ -40,9 +40,9 @@ from PMC import *
{
%insert("python")
%{
- def x(self, key, *args):
+ def x(self, name, *args):
pmcargs = PMC_M(list(args))
- pmcret = self._handle_call(key, pmcargs)
+ pmcret = self._handle_call(name, pmcargs)
return pmcret()
def __getattr__(self, name):
diff --git a/lib/callable.cpp b/lib/callable.cpp
index f52d604..af27399 100644
--- a/lib/callable.cpp
+++ b/lib/callable.cpp
@@ -21,35 +21,35 @@ Callable::~Callable(void)
_call_registry.reset();
}
-std::vector<std::string> Callable::get_registered_keys(void) const
+std::vector<std::string> Callable::get_registered_names(void) const
{
CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry.get());
- std::vector<std::string> keys;
+ std::vector<std::string> names;
BOOST_FOREACH(const CallableRegistryPair &p, (*cr))
{
- keys.push_back(p.first);
+ names.push_back(p.first);
}
- return keys;
+ return names;
}
-void Callable::unregister_call(const std::string &key)
+void Callable::unregister_call(const std::string &name)
{
CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry.get());
- if (cr->count(key) == 0) throw std::invalid_argument("Callable - no method registered for key: " + key);
- cr->erase(key);
+ if (cr->count(name) == 0) throw std::invalid_argument("Callable - no method registered for name: " + name);
+ cr->erase(name);
}
-void Callable::_register_call(const std::string &key, void *entry)
+void Callable::_register_call(const std::string &name, void *entry)
{
CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry.get());
- (*cr)[key].reset(reinterpret_cast<CallableRegistryEntry *>(entry));
+ (*cr)[name].reset(reinterpret_cast<CallableRegistryEntry *>(entry));
}
-PMCC Callable::_handle_call(const std::string &key, const PMCC &args)
+PMCC Callable::_handle_call(const std::string &name, const PMCC &args)
{
CallableRegistry *cr = reinterpret_cast<CallableRegistry *>(_call_registry.get());
- if (cr->count(key) == 0) throw std::invalid_argument("Callable - no method registered for key: " + key);
- return (*cr)[key]->call(args);
+ if (cr->count(name) == 0) throw std::invalid_argument("Callable - no method registered for name: " + name);
+ return (*cr)[name]->call(args);
}
CallableRegistryEntry::CallableRegistryEntry(void)
diff --git a/lib/top_block_query.cpp b/lib/top_block_query.cpp
index ee9d234..8be8419 100644
--- a/lib/top_block_query.cpp
+++ b/lib/top_block_query.cpp
@@ -36,7 +36,7 @@ static ptree query_blocks(ElementImpl *self, const ptree &)
{
BlockActor *actor = dynamic_cast<BlockActor *>(w->get_actor());
ptree prop_e;
- BOOST_FOREACH(const std::string &key, actor->data->block->get_registered_keys())
+ BOOST_FOREACH(const std::string &key, actor->data->block->get_registered_names())
{
ptree pname; pname.put_value(key);
prop_e.push_back(std::make_pair("call", pname));
diff --git a/python/gras/GRAS_PyBlock.i b/python/gras/GRAS_PyBlock.i
index 80fc2bb..d7c67f8 100644
--- a/python/gras/GRAS_PyBlock.i
+++ b/python/gras/GRAS_PyBlock.i
@@ -157,24 +157,24 @@ struct BlockPython : Block
virtual void _Py_propagate_tags(const size_t which_input, const TagIter &iter) = 0;
- PMCC _handle_call(const std::string &key, const PMCC &args)
+ PMCC _handle_call(const std::string &name, const PMCC &args)
{
PyTSPhondler phil;
- return Block::_handle_call(key, args);
+ return Block::_handle_call(name, args);
}
- PMCC _handle_call_ts(const std::string &key, const PMCC &args)
+ PMCC _handle_call_ts(const std::string &name, const PMCC &args)
{
PyGILPhondler phil;
- return this->_Py_handle_call_ts(key, args);
+ return this->_Py_handle_call_ts(name, args);
}
- virtual PMCC _Py_handle_call_ts(const std::string &key, const PMCC &args) = 0;
+ virtual PMCC _Py_handle_call_ts(const std::string &name, const PMCC &args) = 0;
- //dummy registration so the C++ knows at least the key names
- void dummy_register_call(const std::string &key)
+ //dummy registration so the C++ knows at least the name names
+ void dummy_register_call(const std::string &name)
{
- this->register_call(key, &BlockPython::__my_dummy);
+ this->register_call(name, &BlockPython::__my_dummy);
}
//dummy call that should not really be called!
@@ -286,13 +286,13 @@ class PyBlock(BlockPython):
t.offset -= self.get_consumed(i)
self.post_output_tag(o, t)
- def _Py_handle_call_ts(self, key, args):
- call = self.__call_registry[key]
+ def _Py_handle_call_ts(self, name, args):
+ call = self.__call_registry[name]
pyargs = args()
pyret = call(*pyargs)
return PMC_M(pyret)
- def register_call(self, key, call):
- self.dummy_register_call(key) #c++ knows key name
- self.__call_registry[key] = call
+ def register_call(self, name, call):
+ self.dummy_register_call(name) #c++ knows name name
+ self.__call_registry[name] = call
%}