0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-08 00:25:19 +00:00

Remove conditional compilation of generator support

All supported V8 versions (>= 4.6.76) have support for JS generators,
therefore it's no longer needed.
This commit is contained in:
Stefan Siegl 2016-05-22 23:47:36 +02:00
parent fba023bd9a
commit 8287a19c8d
6 changed files with 2 additions and 41 deletions

View File

@ -66,11 +66,6 @@ extern "C" {
#define V8JS_GET_CLASS_NAME(var, obj) \
v8::String::Utf8Value var(obj->GetConstructorName());
#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
* declared as 'char *' instead of 'const char *' before PHP 5.4 */
#if ZEND_MODULE_API_NO >= 20100525

View File

@ -17,8 +17,6 @@
#include <assert.h>
#include "php_v8js_macros.h"
#ifdef V8JS_GENERATOR_EXPORT_SUPPORT
v8::Local<v8::Value> v8js_wrap_generator(v8::Isolate *isolate, v8::Local<v8::Value> wrapped_object) /* {{{ */
{
v8::Local<v8::Value> result;
@ -64,8 +62,6 @@ function(wrapped_object) { \
}
/* }}} */
#endif /* V8JS_GENERATOR_EXPORT_SUPPORT */
/*
* Local variables:
* tab-width: 4

View File

@ -13,12 +13,8 @@
#ifndef V8JS_GENERATOR_EXPORT_H
#define V8JS_GENERATOR_EXPORT_H
#ifdef V8JS_GENERATOR_EXPORT_SUPPORT
v8::Local<v8::Value> v8js_wrap_generator(v8::Isolate *isolate, v8::Local<v8::Value> wrapped_object);
#endif /* V8JS_GENERATOR_EXPORT_SUPPORT */
#endif /* V8JS_GENERATOR_EXPORT_H */
/*

View File

@ -932,11 +932,7 @@ v8::Handle<v8::Value> 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 || ce == php_ce_v8object
#ifdef V8JS_V8GENERATOR_SUPPORT
|| ce == php_ce_v8generator
#endif
) {
if (ce == php_ce_v8function || ce == php_ce_v8object || ce == php_ce_v8generator) {
v8js_v8object *c = Z_V8JS_V8OBJECT_OBJ_P(value);
if(isolate != c->ctx->isolate) {
@ -951,13 +947,11 @@ v8::Handle<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRML
if (ce) {
v8::Local<v8::Value> 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;
}

View File

@ -33,18 +33,12 @@ extern "C" {
/* {{{ Class Entries */
zend_class_entry *php_ce_v8object;
zend_class_entry *php_ce_v8function;
#ifdef V8JS_V8GENERATOR_SUPPORT
zend_class_entry *php_ce_v8generator;
#endif
/* }}} */
/* {{{ Object Handlers */
static zend_object_handlers v8js_v8object_handlers;
#ifdef V8JS_V8GENERATOR_SUPPORT
static zend_object_handlers v8js_v8generator_handlers;
#endif
/* }}} */
#define V8JS_V8_INVOKE_FUNC_NAME "V8Js::V8::Invoke"
@ -483,7 +477,6 @@ PHP_METHOD(V8Function, __wakeup)
/* }}} */
#ifdef V8JS_V8GENERATOR_SUPPORT
static void v8js_v8generator_free_storage(zend_object *object) /* {{{ */
{
v8js_v8generator *c = v8js_v8generator_fetch_object(object);
@ -662,20 +655,16 @@ PHP_METHOD(V8Generator, valid)
RETVAL_BOOL(!g->done);
}
/* }}} */
#endif /* /V8JS_V8GENERATOR_SUPPORT */
void v8js_v8object_create(zval *res, v8::Handle<v8::Value> value, int flags, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
{
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
#ifdef V8JS_V8GENERATOR_SUPPORT
if(value->IsGeneratorObject()) {
object_init_ex(res, php_ce_v8generator);
}
else
#endif /* /V8JS_V8GENERATOR_SUPPORT */
if(value->IsFunction()) {
else if(value->IsFunction()) {
object_init_ex(res, php_ce_v8function);
}
else {
@ -709,7 +698,6 @@ static const zend_function_entry v8js_v8function_methods[] = { /* {{{ */
};
/* }}} */
#ifdef V8JS_V8GENERATOR_SUPPORT
ZEND_BEGIN_ARG_INFO(arginfo_v8generator_current, 0)
ZEND_END_ARG_INFO()
@ -739,7 +727,6 @@ static const zend_function_entry v8js_v8generator_methods[] = { /* {{{ */
{NULL, NULL, NULL}
};
/* }}} */
#endif /* /V8JS_V8GENERATOR_SUPPORT */
PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
@ -758,7 +745,6 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
php_ce_v8function->ce_flags |= ZEND_ACC_FINAL;
php_ce_v8function->create_object = v8js_v8object_new;
#ifdef V8JS_V8GENERATOR_SUPPORT
/* V8Generator Class */
INIT_CLASS_ENTRY(ce, "V8Generator", v8js_v8generator_methods);
php_ce_v8generator = zend_register_internal_class(&ce TSRMLS_CC);
@ -766,7 +752,6 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
php_ce_v8generator->create_object = v8js_v8generator_new;
zend_class_implements(php_ce_v8generator, 1, zend_ce_iterator);
#endif /* /V8JS_V8GENERATOR_SUPPORT */
/* V8<Object|Function> handlers */
@ -786,13 +771,11 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
v8js_v8object_handlers.offset = XtOffsetOf(struct v8js_v8object, std);
v8js_v8object_handlers.free_obj = v8js_v8object_free_storage;
#ifdef V8JS_V8GENERATOR_SUPPORT
/* V8Generator handlers */
memcpy(&v8js_v8generator_handlers, &v8js_v8object_handlers, sizeof(zend_object_handlers));
v8js_v8generator_handlers.get_method = v8js_v8generator_get_method;
v8js_v8generator_handlers.offset = XtOffsetOf(struct v8js_v8generator, v8obj.std);
v8js_v8generator_handlers.free_obj = v8js_v8generator_free_storage;
#endif /* /V8JS_V8GENERATOR_SUPPORT */
return SUCCESS;
} /* }}} */

View File

@ -37,8 +37,6 @@ static inline v8js_v8object *v8js_v8object_fetch_object(zend_object *obj) {
#define Z_V8JS_V8OBJECT_OBJ_P(zv) v8js_v8object_fetch_object(Z_OBJ_P(zv));
#ifdef V8JS_V8GENERATOR_SUPPORT
/* {{{ Generator container */
struct v8js_v8generator {
zval value;
@ -57,7 +55,6 @@ static inline v8js_v8generator *v8js_v8generator_fetch_object(zend_object *obj)
#define Z_V8JS_V8GENERATOR_OBJ_P(zv) v8js_v8generator_fetch_object(Z_OBJ_P(zv));
#endif /* /V8JS_V8GENERATOR_SUPPORT */
PHP_MINIT_FUNCTION(v8js_v8object_class);