Skip to content

Commit 8287a19

Browse files
committed
Remove conditional compilation of generator support
All supported V8 versions (>= 4.6.76) have support for JS generators, therefore it's no longer needed.
1 parent fba023b commit 8287a19

6 files changed

+2
-41
lines changed

php_v8js_macros.h

-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ extern "C" {
6666
#define V8JS_GET_CLASS_NAME(var, obj) \
6767
v8::String::Utf8Value var(obj->GetConstructorName());
6868

69-
#if PHP_V8_API_VERSION >= 3030000
70-
#define V8JS_V8GENERATOR_SUPPORT 1
71-
#define V8JS_GENERATOR_EXPORT_SUPPORT 1
72-
#endif
73-
7469
/* method signatures of zend_update_property and zend_read_property were
7570
* declared as 'char *' instead of 'const char *' before PHP 5.4 */
7671
#if ZEND_MODULE_API_NO >= 20100525

v8js_generator_export.cc

-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include <assert.h>
1818
#include "php_v8js_macros.h"
1919

20-
#ifdef V8JS_GENERATOR_EXPORT_SUPPORT
21-
2220
v8::Local<v8::Value> v8js_wrap_generator(v8::Isolate *isolate, v8::Local<v8::Value> wrapped_object) /* {{{ */
2321
{
2422
v8::Local<v8::Value> result;
@@ -64,8 +62,6 @@ function(wrapped_object) { \
6462
}
6563
/* }}} */
6664

67-
#endif /* V8JS_GENERATOR_EXPORT_SUPPORT */
68-
6965
/*
7066
* Local variables:
7167
* tab-width: 4

v8js_generator_export.h

-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
#ifndef V8JS_GENERATOR_EXPORT_H
1414
#define V8JS_GENERATOR_EXPORT_H
1515

16-
#ifdef V8JS_GENERATOR_EXPORT_SUPPORT
17-
1816
v8::Local<v8::Value> v8js_wrap_generator(v8::Isolate *isolate, v8::Local<v8::Value> wrapped_object);
1917

20-
#endif /* V8JS_GENERATOR_EXPORT_SUPPORT */
21-
2218
#endif /* V8JS_GENERATOR_EXPORT_H */
2319

2420
/*

v8js_object_export.cc

+1-7
Original file line numberDiff line numberDiff line change
@@ -932,11 +932,7 @@ v8::Handle<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRML
932932
}
933933

934934
/* Special case, passing back object originating from JS to JS */
935-
if (ce == php_ce_v8function || ce == php_ce_v8object
936-
#ifdef V8JS_V8GENERATOR_SUPPORT
937-
|| ce == php_ce_v8generator
938-
#endif
939-
) {
935+
if (ce == php_ce_v8function || ce == php_ce_v8object || ce == php_ce_v8generator) {
940936
v8js_v8object *c = Z_V8JS_V8OBJECT_OBJ_P(value);
941937

942938
if(isolate != c->ctx->isolate) {
@@ -951,13 +947,11 @@ v8::Handle<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRML
951947
if (ce) {
952948
v8::Local<v8::Value> wrapped_object = v8js_wrap_object(isolate, ce, value TSRMLS_CC);
953949

954-
#ifdef V8JS_GENERATOR_EXPORT_SUPPORT
955950
if (ce == zend_ce_generator) {
956951
/* Wrap PHP Generator object in a wrapper function that provides
957952
* ES6 style behaviour. */
958953
wrapped_object = v8js_wrap_generator(isolate, wrapped_object);
959954
}
960-
#endif
961955

962956
return wrapped_object;
963957
}

v8js_v8object_class.cc

+1-18
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,12 @@ extern "C" {
3333
/* {{{ Class Entries */
3434
zend_class_entry *php_ce_v8object;
3535
zend_class_entry *php_ce_v8function;
36-
37-
#ifdef V8JS_V8GENERATOR_SUPPORT
3836
zend_class_entry *php_ce_v8generator;
39-
#endif
4037
/* }}} */
4138

4239
/* {{{ Object Handlers */
4340
static zend_object_handlers v8js_v8object_handlers;
44-
45-
#ifdef V8JS_V8GENERATOR_SUPPORT
4641
static zend_object_handlers v8js_v8generator_handlers;
47-
#endif
4842
/* }}} */
4943

5044
#define V8JS_V8_INVOKE_FUNC_NAME "V8Js::V8::Invoke"
@@ -483,7 +477,6 @@ PHP_METHOD(V8Function, __wakeup)
483477
/* }}} */
484478

485479

486-
#ifdef V8JS_V8GENERATOR_SUPPORT
487480
static void v8js_v8generator_free_storage(zend_object *object) /* {{{ */
488481
{
489482
v8js_v8generator *c = v8js_v8generator_fetch_object(object);
@@ -662,20 +655,16 @@ PHP_METHOD(V8Generator, valid)
662655
RETVAL_BOOL(!g->done);
663656
}
664657
/* }}} */
665-
#endif /* /V8JS_V8GENERATOR_SUPPORT */
666658

667659

668660
void v8js_v8object_create(zval *res, v8::Handle<v8::Value> value, int flags, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
669661
{
670662
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
671663

672-
#ifdef V8JS_V8GENERATOR_SUPPORT
673664
if(value->IsGeneratorObject()) {
674665
object_init_ex(res, php_ce_v8generator);
675666
}
676-
else
677-
#endif /* /V8JS_V8GENERATOR_SUPPORT */
678-
if(value->IsFunction()) {
667+
else if(value->IsFunction()) {
679668
object_init_ex(res, php_ce_v8function);
680669
}
681670
else {
@@ -709,7 +698,6 @@ static const zend_function_entry v8js_v8function_methods[] = { /* {{{ */
709698
};
710699
/* }}} */
711700

712-
#ifdef V8JS_V8GENERATOR_SUPPORT
713701
ZEND_BEGIN_ARG_INFO(arginfo_v8generator_current, 0)
714702
ZEND_END_ARG_INFO()
715703

@@ -739,7 +727,6 @@ static const zend_function_entry v8js_v8generator_methods[] = { /* {{{ */
739727
{NULL, NULL, NULL}
740728
};
741729
/* }}} */
742-
#endif /* /V8JS_V8GENERATOR_SUPPORT */
743730

744731

745732
PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
@@ -758,15 +745,13 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
758745
php_ce_v8function->ce_flags |= ZEND_ACC_FINAL;
759746
php_ce_v8function->create_object = v8js_v8object_new;
760747

761-
#ifdef V8JS_V8GENERATOR_SUPPORT
762748
/* V8Generator Class */
763749
INIT_CLASS_ENTRY(ce, "V8Generator", v8js_v8generator_methods);
764750
php_ce_v8generator = zend_register_internal_class(&ce TSRMLS_CC);
765751
php_ce_v8generator->ce_flags |= ZEND_ACC_FINAL;
766752
php_ce_v8generator->create_object = v8js_v8generator_new;
767753

768754
zend_class_implements(php_ce_v8generator, 1, zend_ce_iterator);
769-
#endif /* /V8JS_V8GENERATOR_SUPPORT */
770755

771756

772757
/* V8<Object|Function> handlers */
@@ -786,13 +771,11 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
786771
v8js_v8object_handlers.offset = XtOffsetOf(struct v8js_v8object, std);
787772
v8js_v8object_handlers.free_obj = v8js_v8object_free_storage;
788773

789-
#ifdef V8JS_V8GENERATOR_SUPPORT
790774
/* V8Generator handlers */
791775
memcpy(&v8js_v8generator_handlers, &v8js_v8object_handlers, sizeof(zend_object_handlers));
792776
v8js_v8generator_handlers.get_method = v8js_v8generator_get_method;
793777
v8js_v8generator_handlers.offset = XtOffsetOf(struct v8js_v8generator, v8obj.std);
794778
v8js_v8generator_handlers.free_obj = v8js_v8generator_free_storage;
795-
#endif /* /V8JS_V8GENERATOR_SUPPORT */
796779

797780
return SUCCESS;
798781
} /* }}} */

v8js_v8object_class.h

-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ static inline v8js_v8object *v8js_v8object_fetch_object(zend_object *obj) {
3737
#define Z_V8JS_V8OBJECT_OBJ_P(zv) v8js_v8object_fetch_object(Z_OBJ_P(zv));
3838

3939

40-
#ifdef V8JS_V8GENERATOR_SUPPORT
41-
4240
/* {{{ Generator container */
4341
struct v8js_v8generator {
4442
zval value;
@@ -57,7 +55,6 @@ static inline v8js_v8generator *v8js_v8generator_fetch_object(zend_object *obj)
5755

5856
#define Z_V8JS_V8GENERATOR_OBJ_P(zv) v8js_v8generator_fetch_object(Z_OBJ_P(zv));
5957

60-
#endif /* /V8JS_V8GENERATOR_SUPPORT */
6158

6259

6360
PHP_MINIT_FUNCTION(v8js_v8object_class);

0 commit comments

Comments
 (0)