|
@@ -27,34 +27,27 @@ extern "C" {
|
|
|
#include "v8js_object_export.h"
|
|
|
|
|
|
|
|
|
-static zval *v8js_array_access_dispatch(zval *object, const char *method_name, int param_count,
|
|
|
- uint32_t index, zval *zvalue_ptr TSRMLS_DC) /* {{{ */
|
|
|
+static zval v8js_array_access_dispatch(zend_object *object, const char *method_name, int param_count,
|
|
|
+ uint32_t index, zval zvalue TSRMLS_DC) /* {{{ */
|
|
|
{
|
|
|
- zend_class_entry *ce = Z_OBJCE_P(object);
|
|
|
-
|
|
|
- /* Okay, let's call offsetGet. */
|
|
|
zend_fcall_info fci;
|
|
|
- zval *php_value;
|
|
|
-
|
|
|
- zval fmember;
|
|
|
- ZVAL_STRING(&fmember, method_name);
|
|
|
-
|
|
|
- zval zindex;
|
|
|
- ZVAL_LONG(&zindex, index);
|
|
|
+ zval php_value;
|
|
|
+ ZVAL_UNDEF(&php_value);
|
|
|
|
|
|
fci.size = sizeof(fci);
|
|
|
- fci.function_table = &ce->function_table;
|
|
|
- fci.function_name = &fmember;
|
|
|
+ fci.function_table = &object->ce->function_table;
|
|
|
+ ZVAL_STRING(&fci.function_name, method_name);
|
|
|
fci.symbol_table = NULL;
|
|
|
- fci.retval_ptr_ptr = &php_value;
|
|
|
+ fci.retval = &php_value;
|
|
|
|
|
|
- zval *zindex_ptr = &zindex;
|
|
|
- zval **params[2] = { &zindex_ptr, &zvalue_ptr };
|
|
|
+ zval params[2];
|
|
|
+ ZVAL_LONG(¶ms[0], index);
|
|
|
+ params[1] = zvalue;
|
|
|
|
|
|
fci.param_count = param_count;
|
|
|
fci.params = params;
|
|
|
|
|
|
- fci.object_ptr = object;
|
|
|
+ fci.object = object;
|
|
|
fci.no_separation = 0;
|
|
|
|
|
|
zend_call_function(&fci, NULL TSRMLS_CC);
|
|
@@ -72,11 +65,14 @@ void v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo<v8:
|
|
|
V8JS_TSRMLS_FETCH();
|
|
|
|
|
|
v8::Local<v8::Value> php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY));
|
|
|
- zval *object = reinterpret_cast<zval *>(v8::External::Cast(*php_object)->Value());
|
|
|
+ zend_object *object = reinterpret_cast<zend_object *>(v8::External::Cast(*php_object)->Value());
|
|
|
+
|
|
|
+ zval zvalue;
|
|
|
+ ZVAL_UNDEF(&zvalue);
|
|
|
|
|
|
- zval *php_value = v8js_array_access_dispatch(object, "offsetGet", 1, index, NULL TSRMLS_CC);
|
|
|
+ zval php_value = v8js_array_access_dispatch(object, "offsetGet", 1, index, zvalue TSRMLS_CC);
|
|
|
v8::Local<v8::Value> ret_value = zval_to_v8js(php_value, isolate TSRMLS_CC);
|
|
|
- zval_ptr_dtor(&php_value);
|
|
|
+ zval_dtor(&php_value);
|
|
|
|
|
|
info.GetReturnValue().Set(ret_value);
|
|
|
}
|
|
@@ -91,17 +87,18 @@ void v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
|
|
|
V8JS_TSRMLS_FETCH();
|
|
|
|
|
|
v8::Local<v8::Value> php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY));
|
|
|
- zval *object = reinterpret_cast<zval *>(v8::External::Cast(*php_object)->Value());
|
|
|
+ zend_object *object = reinterpret_cast<zend_object *>(v8::External::Cast(*php_object)->Value());
|
|
|
+
|
|
|
+ zval zvalue;
|
|
|
+ ZVAL_UNDEF(&zvalue);
|
|
|
|
|
|
- zval *zvalue_ptr;
|
|
|
- MAKE_STD_ZVAL(zvalue_ptr);
|
|
|
- if (v8js_to_zval(value, zvalue_ptr, 0, isolate TSRMLS_CC) != SUCCESS) {
|
|
|
+ if (v8js_to_zval(value, &zvalue, 0, isolate TSRMLS_CC) != SUCCESS) {
|
|
|
info.GetReturnValue().Set(v8::Handle<v8::Value>());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- zval *php_value = v8js_array_access_dispatch(object, "offsetSet", 2, index, zvalue_ptr TSRMLS_CC);
|
|
|
- zval_ptr_dtor(&php_value);
|
|
|
+ zval php_value = v8js_array_access_dispatch(object, "offsetSet", 2, index, zvalue TSRMLS_CC);
|
|
|
+ zval_dtor(&php_value);
|
|
|
|
|
|
/* simply pass back the value to tell we intercepted the call
|
|
|
* as the offsetSet function returns void. */
|
|
@@ -109,40 +106,43 @@ void v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
|
|
|
|
|
|
/* if PHP wanted to hold on to this value, zend_call_function would
|
|
|
* have bumped the refcount. */
|
|
|
- zval_ptr_dtor(&zvalue_ptr);
|
|
|
+ zval_dtor(&zvalue);
|
|
|
}
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
|
-static int v8js_array_access_get_count_result(zval *object TSRMLS_DC) /* {{{ */
|
|
|
+static int v8js_array_access_get_count_result(zend_object *object TSRMLS_DC) /* {{{ */
|
|
|
{
|
|
|
- zval *php_value = v8js_array_access_dispatch(object, "count", 0, 0, NULL TSRMLS_CC);
|
|
|
+ zval zvalue;
|
|
|
+ ZVAL_UNDEF(&zvalue);
|
|
|
+
|
|
|
+ zval php_value = v8js_array_access_dispatch(object, "count", 0, 0, zvalue TSRMLS_CC);
|
|
|
|
|
|
- if(Z_TYPE_P(php_value) != IS_LONG) {
|
|
|
+ if(Z_TYPE(php_value) != IS_LONG) {
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-numeric return value from count() method");
|
|
|
+ zval_dtor(&php_value);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- int result = Z_LVAL_P(php_value);
|
|
|
- zval_ptr_dtor(&php_value);
|
|
|
-
|
|
|
+ int result = Z_LVAL(php_value);
|
|
|
return result;
|
|
|
}
|
|
|
/* }}} */
|
|
|
|
|
|
-static bool v8js_array_access_isset_p(zval *object, int index TSRMLS_DC) /* {{{ */
|
|
|
+static bool v8js_array_access_isset_p(zend_object *object, int index TSRMLS_DC) /* {{{ */
|
|
|
{
|
|
|
- zval *php_value = v8js_array_access_dispatch(object, "offsetExists", 1, index, NULL TSRMLS_CC);
|
|
|
+ zval zvalue;
|
|
|
+ ZVAL_UNDEF(&zvalue);
|
|
|
|
|
|
- if(Z_TYPE_P(php_value) != IS_BOOL) {
|
|
|
+ zval php_value = v8js_array_access_dispatch(object, "offsetExists", 1, index, zvalue TSRMLS_CC);
|
|
|
+
|
|
|
+ if(Z_TYPE(php_value) != IS_TRUE && Z_TYPE(php_value) != IS_FALSE) {
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-boolean return value from offsetExists() method");
|
|
|
+ zval_dtor(&php_value);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- bool result = Z_LVAL_P(php_value);
|
|
|
- zval_ptr_dtor(&php_value);
|
|
|
-
|
|
|
- return result;
|
|
|
+ return Z_TYPE(php_value) == IS_TRUE;
|
|
|
}
|
|
|
/* }}} */
|
|
|
|
|
@@ -155,7 +155,7 @@ static void v8js_array_access_length(v8::Local<v8::String> property, const v8::P
|
|
|
V8JS_TSRMLS_FETCH();
|
|
|
|
|
|
v8::Local<v8::Value> php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY));
|
|
|
- zval *object = reinterpret_cast<zval *>(v8::External::Cast(*php_object)->Value());
|
|
|
+ zend_object *object = reinterpret_cast<zend_object *>(v8::External::Cast(*php_object)->Value());
|
|
|
|
|
|
int length = v8js_array_access_get_count_result(object TSRMLS_CC);
|
|
|
info.GetReturnValue().Set(V8JS_INT(length));
|
|
@@ -170,9 +170,12 @@ void v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInfo<v8
|
|
|
V8JS_TSRMLS_FETCH();
|
|
|
|
|
|
v8::Local<v8::Value> php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY));
|
|
|
- zval *object = reinterpret_cast<zval *>(v8::External::Cast(*php_object)->Value());
|
|
|
+ zend_object *object = reinterpret_cast<zend_object *>(v8::External::Cast(*php_object)->Value());
|
|
|
+
|
|
|
+ zval zvalue;
|
|
|
+ ZVAL_UNDEF(&zvalue);
|
|
|
|
|
|
- zval *php_value = v8js_array_access_dispatch(object, "offsetUnset", 1, index, NULL TSRMLS_CC);
|
|
|
+ zval php_value = v8js_array_access_dispatch(object, "offsetUnset", 1, index, zvalue TSRMLS_CC);
|
|
|
zval_ptr_dtor(&php_value);
|
|
|
|
|
|
info.GetReturnValue().Set(V8JS_BOOL(true));
|
|
@@ -187,7 +190,7 @@ void v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo<v8::
|
|
|
V8JS_TSRMLS_FETCH();
|
|
|
|
|
|
v8::Local<v8::Value> php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY));
|
|
|
- zval *object = reinterpret_cast<zval *>(v8::External::Cast(*php_object)->Value());
|
|
|
+ zend_object *object = reinterpret_cast<zend_object *>(v8::External::Cast(*php_object)->Value());
|
|
|
|
|
|
/* If index is set, then return an integer encoding a v8::PropertyAttribute;
|
|
|
* otherwise we're expected to return an empty handle. */
|
|
@@ -206,7 +209,7 @@ void v8js_array_access_enumerator(const v8::PropertyCallbackInfo<v8::Array>& inf
|
|
|
V8JS_TSRMLS_FETCH();
|
|
|
|
|
|
v8::Local<v8::Value> php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY));
|
|
|
- zval *object = reinterpret_cast<zval *>(v8::External::Cast(*php_object)->Value());
|
|
|
+ zend_object *object = reinterpret_cast<zend_object *>(v8::External::Cast(*php_object)->Value());
|
|
|
|
|
|
int length = v8js_array_access_get_count_result(object TSRMLS_CC);
|
|
|
v8::Local<v8::Array> result = v8::Array::New(isolate, length);
|