From 19ec7a09fc332d1430bd1488861ef72cb227fca6 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 24 Aug 2003 17:32:47 +0000 Subject: - Provide appropriate way to destroy internal zval's. - Allow internal zval's of type string and disallow complex types. - Define the default string for extensions at class level instead of ctor. --- Zend/zend_API.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Zend/zend_API.c') diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 3451f0ff5a..53f7d48219 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1629,6 +1629,16 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le } else { target_symbol_table = &ce->default_properties; } + switch(Z_TYPE_P(property)) { + case IS_ARRAY: + case IS_CONSTANT_ARRAY: + case IS_OBJECT: + case IS_RESOURCE: + zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources"); + break; + default: + break; + } switch (access_type & ZEND_ACC_PPP_MASK) { case ZEND_ACC_PRIVATE: { char *priv_name; @@ -1691,6 +1701,21 @@ ZEND_API int zend_declare_property_long(zend_class_entry *ce, char *name, int na return zend_declare_property(ce, name, name_length, property, access_type); } +ZEND_API int zend_declare_property_string(zend_class_entry *ce, char *name, int name_length, char *value, int access_type) +{ + zval *property; + int len = strlen(value); + + if (ce->type & ZEND_INTERNAL_CLASS) { + property = malloc(sizeof(zval)); + } else { + ALLOC_ZVAL(property); + } + INIT_PZVAL(property); + ZVAL_STRINGL(property, zend_strndup(value, len), len, 0); + return zend_declare_property(ce, name, name_length, property, access_type); +} + ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *name, int name_length, zval *value TSRMLS_DC) { zval property; -- cgit v1.2.1