cvs: ZendEngine2 / zend_API.c zend_API.h zend_default_classes.c
| From: | Marcus Boerger | Date: | Sun, 24 Aug 2003 00:36:53 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_API.h zend_default_classes.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1671@lists.php.net to get a copy of this message | ||
helly Sat Aug 23 20:36:53 2003 EDT
Modified files:
/ZendEngine2 zend_API.c zend_API.h zend_default_classes.c
Log:
Add property read code and use that in default exception class
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.203 ZendEngine2/zend_API.c:1.204
--- ZendEngine2/zend_API.c:1.203 Sat Aug 23 15:37:39 2003
+++ ZendEngine2/zend_API.c Sat Aug 23 20:36:53 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.203 2003/08/23 19:37:39 helly Exp $ */
+/* $Id: zend_API.c,v 1.204 2003/08/24 00:36:53 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1736,6 +1736,23 @@
tmp->refcount = 0;
ZVAL_STRING(tmp, value, 1);
zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
+}
+
+ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *name, int
name_length, zend_bool silent TSRMLS_DC)
+{
+ zval property, *value;
+ zend_class_entry *old_scope = EG(scope);
+
+ EG(scope) = scope;
+
+ if (!Z_OBJ_HT_P(object)->read_property) {
+ zend_error(E_CORE_ERROR, "Property %s of class %s cannot be read",
Z_OBJCE_P(object)->name, name);
+ }
+ ZVAL_STRINGL(&property, name, name_length, 0);
+ value = Z_OBJ_HT_P(object)->read_property(object, &property, silent TSRMLS_CC);
+
+ EG(scope) = old_scope;
+ return value;
}
/*
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.154 ZendEngine2/zend_API.h:1.155
--- ZendEngine2/zend_API.h:1.154 Sat Aug 23 15:37:39 2003
+++ ZendEngine2/zend_API.h Sat Aug 23 20:36:53 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.154 2003/08/23 19:37:39 helly Exp $ */
+/* $Id: zend_API.h,v 1.155 2003/08/24 00:36:53 helly Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -171,6 +171,8 @@
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, char *name, int
name_length TSRMLS_DC);
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, char *name, int
name_length, long value TSRMLS_DC);
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int
name_length, char *value TSRMLS_DC);
+
+ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *name, int
name_length, zend_bool silent TSRMLS_DC);
ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC);
Index: ZendEngine2/zend_default_classes.c
diff -u ZendEngine2/zend_default_classes.c:1.10 ZendEngine2/zend_default_classes.c:1.11
--- ZendEngine2/zend_default_classes.c:1.10 Sat Aug 23 15:48:52 2003
+++ ZendEngine2/zend_default_classes.c Sat Aug 23 20:36:53 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_default_classes.c,v 1.10 2003/08/23 19:48:52 helly Exp $ */
+/* $Id: zend_default_classes.c,v 1.11 2003/08/24 00:36:53 helly Exp $ */
#include "zend.h"
#include "zend_API.h"
@@ -72,13 +72,11 @@
static void _default_exception_get_entry(zval *object, char *name, int name_len, zval *return_value
TSRMLS_DC)
{
- zval **value;
+ zval *value;
- if (zend_hash_find(Z_OBJPROP_P(object), name, name_len, (void **) &value) == FAILURE) {
- RETURN_FALSE;
- }
+ value = zend_read_property(Z_OBJCE_P(object), object, name, name_len, 0 TSRMLS_CC);
- *return_value = **value;
+ *return_value = *value;
zval_copy_ctor(return_value);
}
@@ -86,28 +84,28 @@
{
DEFAULT_0_PARAMS;
- _default_exception_get_entry(getThis(), "file", sizeof("file"), return_value
TSRMLS_CC);
+ _default_exception_get_entry(getThis(), "file", sizeof("file")-1, return_value
TSRMLS_CC);
}
ZEND_FUNCTION(getline)
{
DEFAULT_0_PARAMS;
- _default_exception_get_entry(getThis(), "line", sizeof("line"), return_value
TSRMLS_CC);
+ _default_exception_get_entry(getThis(), "line", sizeof("line")-1, return_value
TSRMLS_CC);
}
ZEND_FUNCTION(getmessage)
{
DEFAULT_0_PARAMS;
- _default_exception_get_entry(getThis(), "message", sizeof("message"),
return_value TSRMLS_CC);
+ _default_exception_get_entry(getThis(), "message", sizeof("message")-1,
return_value TSRMLS_CC);
}
ZEND_FUNCTION(getcode)
{
DEFAULT_0_PARAMS;
- _default_exception_get_entry(getThis(), "code", sizeof("code"), return_value
TSRMLS_CC);
+ _default_exception_get_entry(getThis(), "code", sizeof("code")-1, return_value
TSRMLS_CC);
}
static zend_function_entry default_exception_functions[] = {