From d6394301b2c90ea3279a703e32beb552704ff298 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Fri, 25 Mar 2016 17:40:23 +0100 Subject: [PATCH] Pass back V8Object instances, don't re-wrap --- tests/object_passback_002.phpt | 20 ++++++++++++++++++++ v8js_object_export.cc | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/object_passback_002.phpt diff --git a/tests/object_passback_002.phpt b/tests/object_passback_002.phpt new file mode 100644 index 0000000..35b6917 --- /dev/null +++ b/tests/object_passback_002.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test V8::executeString() : Object passing JS > PHP > JS +--SKIPIF-- + +--FILE-- +theApiCall = function() use ($v8) { + return $v8->executeString('({ foo: 23 })'); +}; + +$v8->executeString('var_dump(PHP.theApiCall().constructor.name);'); + +?> +===EOF=== +--EXPECT-- +string(6) "Object" +===EOF=== diff --git a/v8js_object_export.cc b/v8js_object_export.cc index 9562178..34ab680 100644 --- a/v8js_object_export.cc +++ b/v8js_object_export.cc @@ -988,7 +988,7 @@ v8::Handle v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRML } /* Special case, passing back object originating from JS to JS */ - if (ce == php_ce_v8function) { + if (ce == php_ce_v8function || ce == php_ce_v8object) { v8js_v8object *c = (v8js_v8object *) zend_object_store_get_object(value TSRMLS_CC); if(isolate != c->ctx->isolate) {