X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_requestdatashare_object.c;h=eed7d6b8ef125ecfb08c36e2a2f70c0a52b02d10;hp=8b4a51df89e0ba9468eba95606501a4464275d46;hb=refs%2Fheads%2Fv1.7.x;hpb=8e6cf53b544342e1eaf0ec4f530e32852120294a diff --git a/http_requestdatashare_object.c b/http_requestdatashare_object.c index 8b4a51d..eed7d6b 100644 --- a/http_requestdatashare_object.c +++ b/http_requestdatashare_object.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2007, Michael Wallner | + | Copyright (c) 2004-2010, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -60,9 +60,9 @@ HTTP_END_ARGS; #define http_requestdatashare_object_read_prop _http_requestdatashare_object_read_prop -static zval *_http_requestdatashare_object_read_prop(zval *object, zval *member, int type TSRMLS_DC); +static zval *_http_requestdatashare_object_read_prop(zval *object, zval *member, int type ZEND_LITERAL_KEY_DC TSRMLS_DC); #define http_requestdatashare_object_write_prop _http_requestdatashare_object_write_prop -static void _http_requestdatashare_object_write_prop(zval *object, zval *member, zval *value TSRMLS_DC); +static void _http_requestdatashare_object_write_prop(zval *object, zval *member, zval *value ZEND_LITERAL_KEY_DC TSRMLS_DC); #define http_requestdatashare_instantiate(t, g) _http_requestdatashare_instantiate((t), (g) TSRMLS_CC) static inline zval *_http_requestdatashare_instantiate(zval *this_ptr, zend_bool global TSRMLS_DC); @@ -125,9 +125,14 @@ zend_object_value _http_requestdatashare_object_new_ex(zend_class_entry *ce, htt *ptr = o; } +#ifdef ZEND_ENGINE_2_4 + zend_object_std_init(o, ce TSRMLS_CC); + object_properties_init(o, ce); +#else ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); +#endif ov.handle = putObject(http_requestdatashare_object, o); ov.handlers = &http_requestdatashare_object_handlers; @@ -145,35 +150,41 @@ void _http_requestdatashare_object_free(zend_object *object TSRMLS_DC) freeObject(o); } -static zval *_http_requestdatashare_object_read_prop(zval *object, zval *member, int type TSRMLS_DC) +static zval *_http_requestdatashare_object_read_prop(zval *object, zval *member, int type ZEND_LITERAL_KEY_DC TSRMLS_DC) { - if (type == BP_VAR_W && zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)) { + if (type == BP_VAR_W && +#ifdef ZEND_ENGINE_2_4 + zend_hash_exists(&THIS_CE->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) +#else + zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) +#endif + ) { zend_error(E_ERROR, "Cannot access HttpRequestDataShare default properties by reference or array key/index"); return NULL; } - return zend_get_std_object_handlers()->read_property(object, member, type TSRMLS_CC); + return zend_get_std_object_handlers()->read_property(object, member, type ZEND_LITERAL_KEY_CC TSRMLS_CC); } -static void _http_requestdatashare_object_write_prop(zval *object, zval *member, zval *value TSRMLS_DC) +static void _http_requestdatashare_object_write_prop(zval *object, zval *member, zval *value ZEND_LITERAL_KEY_DC TSRMLS_DC) { - if (zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)) { + if ( +#ifdef ZEND_ENGINE_2_4 + zend_hash_exists(&THIS_CE->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) +#else + zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) +#endif + ) { int status; - zval *orig = value; getObjectEx(http_requestdatashare_object, obj, object); - SEPARATE_ZVAL_IF_NOT_REF(&value); - status = http_request_datashare_set(obj->share, Z_STRVAL_P(member), Z_STRLEN_P(member), (zend_bool) zval_is_true(value)); - if (orig != value) { - zval_ptr_dtor(&value); - value = orig; - } + status = http_request_datashare_set(obj->share, Z_STRVAL_P(member), Z_STRLEN_P(member), (zend_bool) i_zend_is_true(value)); if (SUCCESS != status) { return; } } - zend_get_std_object_handlers()->write_property(object, member, value TSRMLS_CC); + zend_get_std_object_handlers()->write_property(object, member, value ZEND_LITERAL_KEY_CC TSRMLS_CC); } /* {{{ proto void HttpRequestDataShare::__destruct() @@ -253,7 +264,7 @@ PHP_METHOD(HttpRequestDataShare, factory) PHP_METHOD(HttpRequestDataShare, singleton) { zend_bool global = 0; - zval *instance = *zend_std_get_static_property(THIS_CE, ZEND_STRS("instance")-1, 0 TSRMLS_CC); + zval *instance = *zend_std_get_static_property(THIS_CE, ZEND_STRS("instance")-1, 0 ZEND_LITERAL_NIL_CC TSRMLS_CC); SET_EH_THROW_HTTP(); if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &global)) {