cvs: php-gtk /src php_gtk_object.c
| From: | Andrei Zmievski | Date: | Fri, 27 Apr 2001 16:25:06 +0000 |
| Subject: | cvs: php-gtk /src php_gtk_object.c | ||
| Groups: | php.gtk | ||
| Request: | Send a blank email to php-gtk+get-1542@lists.php.net to get a copy of this message | ||
andrei Fri Apr 27 09:25:06 2001 EDT
Modified files:
/php-gtk/src php_gtk_object.c
Log:
Now the explicit property chain support is getting into shape.
Index: php-gtk/src/php_gtk_object.c
diff -u php-gtk/src/php_gtk_object.c:1.27 php-gtk/src/php_gtk_object.c:1.28
--- php-gtk/src/php_gtk_object.c:1.27 Thu Apr 26 21:42:45 2001
+++ php-gtk/src/php_gtk_object.c Fri Apr 27 09:25:05 2001
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: php_gtk_object.c,v 1.27 2001/04/27 04:42:45 andrei Exp $ */
+/* $Id: php_gtk_object.c,v 1.28 2001/04/27 16:25:05 andrei Exp $ */
#include "php_gtk.h"
@@ -723,15 +723,17 @@
found = FAILURE;
if (Z_TYPE_P(overloaded_property) == OE_IS_OBJECT) {
+ /* Trying to access a property on a non-object. */
if (Z_TYPE(object) != IS_OBJECT) {
- /* php_error(E_WARNING, "Trying to access property '%s' on a non-object",
Z_STRVAL(overloaded_property->element)); */
ZVAL_NULL(&result);
return result;
}
- for (ce = Z_OBJCE(object); ce != NULL && found != SUCCESS; ce = ce->parent) {
- if (zend_hash_index_find(&php_gtk_prop_getters, (long)ce, (void **)&getter) == SUCCESS)
{
- (*getter)(&result, &object, &element, &found);
+ if (Z_OBJCE(object)->handle_property_get) {
+ for (ce = Z_OBJCE(object); ce != NULL && found != SUCCESS; ce = ce->parent) {
+ if (zend_hash_index_find(&php_gtk_prop_getters, (long)ce, (void **)&getter) ==
SUCCESS) {
+ (*getter)(&result, &object, &element, &found);
+ }
}
}
if (found == FAILURE &&
@@ -742,6 +744,7 @@
result = **prop_result;
}
} else if (Z_TYPE_P(overloaded_property) == OE_IS_ARRAY) {
+ /* Trying to access index on a non-array. */
if (Z_TYPE(object) != IS_ARRAY) {
ZVAL_NULL(&result);
return result;
@@ -805,9 +808,11 @@
}
found = FAILURE;
- for (ce = Z_OBJCE(object); ce != NULL && found != SUCCESS; ce = ce->parent) {
- if (zend_hash_index_find(&php_gtk_prop_getters, (long)ce, (void **)&getter) == SUCCESS)
{
- (*getter)(&result, &object, &element, &found);
+ if (Z_OBJCE(object)->handle_property_get) {
+ for (ce = Z_OBJCE(object); ce != NULL && found != SUCCESS; ce = ce->parent) {
+ if (zend_hash_index_find(&php_gtk_prop_getters, (long)ce, (void **)&getter) == SUCCESS)
{
+ (*getter)(&result, &object, &element, &found);
+ }
}
}
if (found == FAILURE) {
@@ -826,26 +831,34 @@
retval = FAILURE;
overloaded_property = (zend_overloaded_element *) element->data;
- if (zend_hash_index_find(&php_gtk_prop_setters, (long)object.value.obj.ce, (void
**)&setter) == SUCCESS) {
- retval = (*setter)(&object, &element, value);
- } else {
- found = FAILURE;
- for (ce = Z_OBJCE(object); ce != NULL && found != SUCCESS; ce = ce->parent) {
- if (zend_hash_index_find(&php_gtk_prop_getters, (long)ce, (void **)&getter) == SUCCESS)
{
- (*getter)(&result, &object, &element, &found);
+ if (Z_OBJCE(object)->handle_property_set) {
+ for (ce = Z_OBJCE(object); ce != NULL && retval != SUCCESS; ce = ce->parent) {
+ if (zend_hash_index_find(&php_gtk_prop_setters, (long)ce, (void **)&setter) == SUCCESS)
{
+ retval = (*setter)(&object, &element, value);
}
}
- if (found == FAILURE) {
- if (value->refcount) {
- SEPARATE_ZVAL(&value);
- } else
- zval_add_ref(&value);
+ }
+ if (retval == FAILURE) {
+ if (Z_OBJCE(object)->handle_property_get) {
+ for (ce = Z_OBJCE(object); ce != NULL && retval != SUCCESS; ce = ce->parent) {
+ if (zend_hash_index_find(&php_gtk_prop_getters, (long)ce, (void **)&getter) == SUCCESS)
{
+ (*getter)(&result, &object, &element, &retval);
+ }
+ }
+ }
+
+ if (retval == FAILURE) {
+ zval *local_value;
+
+ MAKE_STD_ZVAL(local_value);
+ *local_value = *value;
+ zval_copy_ctor(local_value);
retval = add_property_zval_ex(&object,
Z_STRVAL(overloaded_property->element),
- Z_STRLEN(overloaded_property->element)+1, value);
+ Z_STRLEN(overloaded_property->element)+1, local_value);
} else {
- php_error(E_WARNING, "Cannot assign to overloaded property");
- retval = FAILURE;
+ php_error(E_WARNING, "Cannot assign to overloaded property '%s'",
+ Z_STRVAL(overloaded_property->element));
}
}