cvs: php-gtk /src php_gtk_object.c
| From: | Andrei Zmievski | Date: | Fri, 27 Apr 2001 20:54:51 +0000 |
| Subject: | cvs: php-gtk /src php_gtk_object.c | ||
| Groups: | php.gtk | ||
| Request: | Send a blank email to php-gtk+get-1547@lists.php.net to get a copy of this message | ||
andrei Fri Apr 27 13:54:51 2001 EDT
Modified files:
/php-gtk/src php_gtk_object.c
Log:
More work.
Index: php-gtk/src/php_gtk_object.c
diff -u php-gtk/src/php_gtk_object.c:1.28 php-gtk/src/php_gtk_object.c:1.29
--- php-gtk/src/php_gtk_object.c:1.28 Fri Apr 27 09:25:05 2001
+++ php-gtk/src/php_gtk_object.c Fri Apr 27 13:54:51 2001
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: php_gtk_object.c,v 1.28 2001/04/27 16:25:05 andrei Exp $ */
+/* $Id: php_gtk_object.c,v 1.29 2001/04/27 20:54:51 andrei Exp $ */
#include "php_gtk.h"
@@ -766,8 +766,6 @@
if (found == FAILURE) {
ZVAL_NULL(&result);
- if (element == property_reference->elements_list->tail)
- return result;
}
object = result;
@@ -801,28 +799,52 @@
for (element=property_reference->elements_list->head; element &&
element!=stop_element; element=element->next) {
overloaded_property = (zend_overloaded_element *) element->data;
- if (Z_TYPE_P(overloaded_property) != OE_IS_OBJECT ||
- Z_TYPE(overloaded_property->element) != IS_STRING ||
- (Z_TYPE(object) != IS_OBJECT)) {
- return FAILURE;
- }
found = FAILURE;
- 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 (Z_TYPE_P(overloaded_property) == OE_IS_OBJECT) {
+ /* Trying to access a property on a non-object. */
+ if (Z_TYPE(object) != IS_OBJECT) {
+ return FAILURE;
+ }
+
+ 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) {
- if (zend_hash_find(Z_OBJPROP(object),
+ if (found == FAILURE &&
+ (found = zend_hash_find(Z_OBJPROP(object),
Z_STRVAL(overloaded_property->element),
Z_STRLEN(overloaded_property->element)+1,
- (void **)&prop_result) == SUCCESS)
+ (void **)&prop_result)) == SUCCESS) {
result = **prop_result;
- else
+ }
+ } else if (Z_TYPE_P(overloaded_property) == OE_IS_ARRAY) {
+ /* Trying to access index on a non-array. */
+ if (Z_TYPE(object) != IS_ARRAY) {
return FAILURE;
+ }
+
+ if (Z_TYPE(overloaded_property->element) == IS_STRING) {
+ found = zend_hash_find(Z_ARRVAL(object),
+ Z_STRVAL(overloaded_property->element),
+ Z_STRLEN(overloaded_property->element)+1,
+ (void **)&prop_result);
+ } else if (Z_TYPE(overloaded_property->element) == IS_LONG) {
+ found = zend_hash_index_find(Z_ARRVAL(object),
+ Z_LVAL(overloaded_property->element),
+ (void **)&prop_result);
+ }
+ if (found == SUCCESS)
+ result = **prop_result;
+ }
+
+ if (found == FAILURE) {
+ /* TODO if not found store a null as the property/index, then in the
+ * above checks replace init null to array or object */
+ return FAILURE;
}
object = result;
@@ -853,6 +875,7 @@
MAKE_STD_ZVAL(local_value);
*local_value = *value;
zval_copy_ctor(local_value);
+ INIT_PZVAL(local_value);
retval = add_property_zval_ex(&object,
Z_STRVAL(overloaded_property->element),
Z_STRLEN(overloaded_property->element)+1, local_value);