summaryrefslogtreecommitdiff
path: root/src/callable.cpp
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-08-25 23:10:15 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-08-25 23:10:15 +0200
commit9ba4fb9ae4233a656bbfca1b169b0a608202b717 (patch)
tree0ccad56abc640ace7c97847552ff99702e16c577 /src/callable.cpp
parente14055694478d70e58b5fc653b08a9a514bbc455 (diff)
By hiding a pointer to the callable object in front of the function name we have managed to retrieve back the callable object, so we can pass all callbacks to one single function, which will further deliver them to the appropriate function object
Diffstat (limited to 'src/callable.cpp')
-rw-r--r--src/callable.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/callable.cpp b/src/callable.cpp
index 1ad4ed2..05545f1 100644
--- a/src/callable.cpp
+++ b/src/callable.cpp
@@ -19,8 +19,17 @@ namespace PhpCpp {
*/
void invoke_callable(INTERNAL_FUNCTION_PARAMETERS)
{
- std::cout << "invoke_callable" << std::endl;
+ // find the function name
+ const char *function = get_active_function_name(TSRMLS_C);
+ // when we registered the function name, we have hidden the pointer to the
+ // callable right in front of the function name - we retrieve it back
+ Callable *callable = *((Callable **)(function - sizeof(Callable *)));
+
+ std::cout << "callable: " << callable << std::endl;
+
+
+ return;
}
/**
@@ -30,7 +39,7 @@ void invoke_callable(INTERNAL_FUNCTION_PARAMETERS)
void Callable::fill(zend_function_entry *entry)
{
// fill the members of the entity
- entry->fname = _function.c_str();
+ entry->fname = _name;
entry->handler = invoke_callable;
entry->arg_info = _argv;
entry->num_args = _argc;
@@ -44,8 +53,8 @@ void Callable::fill(zend_function_entry *entry)
void Callable::fill(zend_internal_function_info *info)
{
// fill in all the members, not that the returning by reference is not used
- info->_name = _function.c_str();
- info->_name_len = _function.size();
+ info->_name = _name;
+ info->_name_len = _data.size() - sizeof(this);
info->_class_name = _classname.size() ? _classname.c_str() : NULL;
info->required_num_args = _required;
info->_type_hint = _type;