Skip to content

Commit 35398cc

Browse files
committed
add zend_class_entry* to method_tmpls key, fixes #410
1 parent 5f7bf99 commit 35398cc

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

v8js_class.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static void v8js_free_storage(zend_object *object) /* {{{ */
119119
}
120120
c->call_impls.~map();
121121

122-
for (std::map<zend_function *, v8js_function_tmpl_t>::iterator it = c->method_tmpls.begin();
122+
for (std::map<std::pair<zend_class_entry *, zend_function *>, v8js_function_tmpl_t>::iterator it = c->method_tmpls.begin();
123123
it != c->method_tmpls.end(); ++it) {
124124
it->second.Reset();
125125
}
@@ -232,7 +232,7 @@ static zend_object* v8js_new(zend_class_entry *ce) /* {{{ */
232232
new(&c->weak_closures) std::map<v8js_function_tmpl_t *, v8js_persistent_obj_t>();
233233
new(&c->weak_objects) std::map<zend_object *, v8js_persistent_obj_t>();
234234
new(&c->call_impls) std::map<v8js_function_tmpl_t *, v8js_function_tmpl_t>();
235-
new(&c->method_tmpls) std::map<zend_function *, v8js_function_tmpl_t>();
235+
new(&c->method_tmpls) std::map<std::pair<zend_class_entry *, zend_function *>, v8js_function_tmpl_t>();
236236

237237
new(&c->v8js_v8objects) std::list<v8js_v8object *>();
238238
new(&c->script_objects) std::vector<v8js_script *>();
@@ -589,7 +589,7 @@ static PHP_METHOD(V8Js, __construct)
589589
ft = v8::FunctionTemplate::New(isolate, v8js_php_callback,
590590
v8::External::New((isolate), method_ptr));
591591
// @fixme add/check Signature v8::Signature::New((isolate), tmpl));
592-
v8js_function_tmpl_t *persistent_ft = &c->method_tmpls[method_ptr];
592+
v8js_function_tmpl_t *persistent_ft = &c->method_tmpls[std::make_pair(ce, method_ptr)];
593593
persistent_ft->Reset(isolate, ft);
594594

595595
php_obj->CreateDataProperty(context, method_name, ft->GetFunction(context).ToLocalChecked());

v8js_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct v8js_ctx {
6363
std::map<zend_object *, v8js_persistent_obj_t> weak_objects;
6464
std::map<v8js_function_tmpl_t *, v8js_persistent_obj_t> weak_closures;
6565
std::map<v8js_function_tmpl_t *, v8js_function_tmpl_t> call_impls;
66-
std::map<zend_function *, v8js_function_tmpl_t> method_tmpls;
66+
std::map<std::pair<zend_class_entry *, zend_function *>, v8js_function_tmpl_t> method_tmpls;
6767

6868
std::list<v8js_v8object *> v8js_v8objects;
6969

v8js_object_export.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,13 +701,13 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::Name> property_n
701701
v8::Local<v8::FunctionTemplate> ft;
702702
try {
703703
ft = v8::Local<v8::FunctionTemplate>::New
704-
(isolate, ctx->method_tmpls.at(method_ptr));
704+
(isolate, ctx->method_tmpls.at(std::make_pair(ce, method_ptr)));
705705
}
706706
catch (const std::out_of_range &) {
707707
ft = v8::FunctionTemplate::New(isolate, v8js_php_callback,
708708
v8::External::New((isolate), method_ptr),
709709
v8::Signature::New((isolate), tmpl));
710-
v8js_function_tmpl_t *persistent_ft = &ctx->method_tmpls[method_ptr];
710+
v8js_function_tmpl_t *persistent_ft = &ctx->method_tmpls[std::make_pair(ce, method_ptr)];
711711
persistent_ft->Reset(isolate, ft);
712712
}
713713
ft->GetFunction(v8_context).ToLocal(&ret_value);

0 commit comments

Comments
 (0)