diff options
| author | George Schlossnagle <gschlossnagle@php.net> | 2003-07-06 19:55:20 +0000 |
|---|---|---|
| committer | George Schlossnagle <gschlossnagle@php.net> | 2003-07-06 19:55:20 +0000 |
| commit | daf3ac65eaf1e47d915b4ae4c08f6cfa59deacc0 (patch) | |
| tree | ca715e2f328d3faf7687610763d1c4e996cf87e4 /Zend/zend_API.c | |
| parent | f4b24b82f2292310c6253ed16a1b1a721147b064 (diff) | |
| download | php-git-daf3ac65eaf1e47d915b4ae4c08f6cfa59deacc0.tar.gz | |
add convenience functions or adding class properties. Ok'd for commit by Andi.
Diffstat (limited to 'Zend/zend_API.c')
| -rw-r--r-- | Zend/zend_API.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 52e32af03d..213262fd35 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1576,6 +1576,51 @@ ZEND_API char *zend_get_module_version(char *module_name) return module->version; } +ZEND_API void zend_declare_property(zend_class_entry *ce, char *name, int namelen, zval *property, int access_type) +{ + zend_property_info property_info; + HashTable *target_symbol_table; + + if (!(access_type & ZEND_ACC_PPP_MASK)) { + access_type |= ZEND_ACC_PUBLIC; + } + if (access_type & ZEND_ACC_STATIC) { + target_symbol_table = ce->static_members; + } else { + target_symbol_table = &ce->default_properties; + } + switch (access_type & ZEND_ACC_PPP_MASK) { + case ZEND_ACC_PRIVATE: { + char *priv_name; + int priv_name_length; + + mangle_property_name(&priv_name, &priv_name_length, ce->name, ce->name_length, name, namelen); + zend_hash_update(target_symbol_table, priv_name, priv_name_length+1, &property, sizeof(zval *), NULL); + property_info.name = priv_name; + property_info.name_length = priv_name_length; + } + break; + case ZEND_ACC_PROTECTED: { + char *prot_name; + int prot_name_length; + + mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, namelen); + zend_hash_update(target_symbol_table, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL); + property_info.name = prot_name; + property_info.name_length = prot_name_length; + } + break; + case ZEND_ACC_PUBLIC: + zend_hash_update(target_symbol_table, name, namelen, &property, sizeof(zval *), NULL); + property_info.name = estrdup(name); + property_info.name_length = namelen; + break; + } + property_info.flags = access_type; + property_info.h = zend_get_hash_value(property_info.name, property_info.name_length+1); + + zend_hash_update(&ce->properties_info, name, namelen + 1, &property_info, sizeof(zend_property_info), NULL); +} /* * Local variables: * tab-width: 4 |
