Re: Register Class Constants for my Extension?
| From: | Unknown Sender | Date: | Mon, 20 Jun 2005 12:19:17 +0000 |
| Subject: | Re: Register Class Constants for my Extension? | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-2477@lists.php.net to get a copy of this message | ||
Hi,
need confirmation but this works fine for me. also two utility functions and
macro
----------------------------------------------------------------------------
------------------------------
void js_declare_constant_long(HashTable *constants_table, char *name, int
name_length, long value){
zval *constant;
MAKE_STD_ZVAL(constant);
ZVAL_LONG(constant,value);
zend_hash_add(constants_table, name, name_length, &constant, sizeof(zval
*), NULL);
}
/* }}} */
/* {{{
*/
void js_declare_constant_string(HashTable *constants_table, char *name, int
name_length, char *value){
zval *constant;
MAKE_STD_ZVAL(constant);
ZVAL_STRING(constant, value, 0);
zend_hash_add(constants_table, name, name_length, &constant, sizeof(zval
*), NULL);
}
#define PHP_JS_DECLARE_CONSTANT_LONG(ht, name, value) \
js_declare_constant_long( ht, name, sizeof(name), value)
#define PHP_JS_DECLARE_CONSTANT_STRING(ht, name, value) \
js_declare_constant_string( ht, name, sizeof(name), value)
ht = &js_JSengine_ce->constants_table;
ALLOC_HASHTABLE(ht);
zend_hash_init(&js_JSengine_ce->constants_table, 0, NULL, ZVAL_PTR_DTOR, 0);
PHP_JS_DECLARE_CONSTANT_STRING(&js_JSengine_ce->constants_table, "VERSION",
PHP_JS_VERSION);
----------------------------------------------------------------------------
------------------------------
regards
fred
----- Original Message -----
From: "Markus Duft" <markus.duft@chello.at>
To: <pecl-dev@lists.php.net>
Sent: Monday, June 20, 2005 1:30 PM
Subject: [PECL-DEV] Register Class Constants for my Extension?
Hi Everybody!
I just wanted to ask someone to help me out a little with creating class
constants within my extension code... i just can't figure out how this
works!!
Thanks in advance!
Markus