summaryrefslogtreecommitdiff
path: root/zend/callable.cpp
diff options
context:
space:
mode:
authorMartijn Otto <martijn.otto@copernica.com>2016-05-18 11:25:55 +0200
committerMartijn Otto <martijn.otto@copernica.com>2016-05-18 11:25:55 +0200
commitcd047b9bb786166485ec21d83d047428f561e6eb (patch)
treecdc8ccd5270b54db550023a1a82bfc846feb789e /zend/callable.cpp
parent1b2562a3af73f1b0554c73d2f9078acb00eda37b (diff)
Store all callables in a map because the hidden pointer trick no longer works
Diffstat (limited to 'zend/callable.cpp')
-rw-r--r--zend/callable.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/zend/callable.cpp b/zend/callable.cpp
index 1231b55..cf0dd64 100644
--- a/zend/callable.cpp
+++ b/zend/callable.cpp
@@ -14,6 +14,16 @@
namespace Php {
/**
+ * Map function names to their implementation
+ *
+ * This is braindead, there should be a way to get this information
+ * from the "This" zval in the execute_data, I just can't find it
+ * @todo Find a better way for this
+ * @var std::map<std::string, Callable*>
+ */
+static std::map<std::string, Callable*> callables;
+
+/**
* Function that is called by the Zend engine every time that a function gets called
* @param ht
* @param return_value
@@ -28,8 +38,8 @@ void Callable::invoke(INTERNAL_FUNCTION_PARAMETERS)
// find the function name
const char *name = get_active_function_name(TSRMLS_C);
- // uncover the hidden pointer inside the function name
- Callable *callable = HiddenPointer<Callable>(name);
+ // retrieve the callable from the map
+ auto *callable = callables.find(name)->second;
// check if sufficient parameters were passed (for some reason this check
// is not done by Zend, so we do it here ourselves)
@@ -75,8 +85,11 @@ void Callable::invoke(INTERNAL_FUNCTION_PARAMETERS)
*/
void Callable::initialize(zend_function_entry *entry, const char *classname, int flags) const
{
+ // track the callable
+ callables[_name] = const_cast<Callable*>(this);
+
// fill the members of the entity, and hide a pointer to the current object in the name
- entry->fname = (const char *)_ptr;
+ entry->fname = _name.data();
entry->handler = &Callable::invoke;
entry->arg_info = _argv.get();
entry->num_args = _argc;