From 89399fa961639fda5251b22de7c9a3591f2f6bdd Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Sat, 9 Jan 2016 14:17:48 +0100 Subject: [PATCH] Disable generator export for V8 < 3.30 (not supported) --- php_v8js_macros.h | 1 + v8js_generator_export.cc | 4 ++++ v8js_generator_export.h | 4 ++++ v8js_object_export.cc | 2 ++ 4 files changed, 11 insertions(+) diff --git a/php_v8js_macros.h b/php_v8js_macros.h index 2cb3dd8..205a47f 100644 --- a/php_v8js_macros.h +++ b/php_v8js_macros.h @@ -63,6 +63,7 @@ extern "C" { #if PHP_V8_API_VERSION >= 3030000 #define V8JS_V8GENERATOR_SUPPORT 1 +#define V8JS_GENERATOR_EXPORT_SUPPORT 1 #endif /* method signatures of zend_update_property and zend_read_property were diff --git a/v8js_generator_export.cc b/v8js_generator_export.cc index 4aea008..1623fa4 100644 --- a/v8js_generator_export.cc +++ b/v8js_generator_export.cc @@ -17,6 +17,8 @@ #include #include "php_v8js_macros.h" +#ifdef V8JS_GENERATOR_EXPORT_SUPPORT + v8::Local v8js_wrap_generator(v8::Isolate *isolate, v8::Local wrapped_object) /* {{{ */ { v8::Local result; @@ -62,6 +64,8 @@ function(wrapped_object) { \ } /* }}} */ +#endif /* V8JS_GENERATOR_EXPORT_SUPPORT */ + /* * Local variables: * tab-width: 4 diff --git a/v8js_generator_export.h b/v8js_generator_export.h index f19f3a6..8c8becf 100644 --- a/v8js_generator_export.h +++ b/v8js_generator_export.h @@ -13,8 +13,12 @@ #ifndef V8JS_GENERATOR_EXPORT_H #define V8JS_GENERATOR_EXPORT_H +#ifdef V8JS_GENERATOR_EXPORT_SUPPORT + v8::Local v8js_wrap_generator(v8::Isolate *isolate, v8::Local wrapped_object); +#endif /* V8JS_GENERATOR_EXPORT_SUPPORT */ + #endif /* V8JS_GENERATOR_EXPORT_H */ /* diff --git a/v8js_object_export.cc b/v8js_object_export.cc index e9bc632..85aa33e 100644 --- a/v8js_object_export.cc +++ b/v8js_object_export.cc @@ -959,11 +959,13 @@ v8::Handle v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRML if (ce) { v8::Local wrapped_object = v8js_wrap_object(isolate, ce, value TSRMLS_CC); +#ifdef V8JS_GENERATOR_EXPORT_SUPPORT if (ce == zend_ce_generator) { /* Wrap PHP Generator object in a wrapper function that provides * ES6 style behaviour. */ wrapped_object = v8js_wrap_generator(isolate, wrapped_object); } +#endif return wrapped_object; }