Re: Namespaces

From: Date: Sat, 08 Mar 2003 22:32:31 +0000
Subject: Re: Namespaces
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-94938@lists.php.net to get a copy of this message
At 08:10 08.03.2003, l0t3k wrote:
this may be a bit premature, but how do i inject the classes, functions and constants in my extension into a namespace ? l0t3k
See below :-) marcus /* {{{ register_namespace */ /* You will have to alloc the pns before the call */ void register_namespace(zend_namespace * pns, char *namespace_name TSRMLS_DC) {
        pns->name_length = strlen(namespace_name);
        pns->name = namespace_name;
        zend_hash_add(&CG(global_namespace).class_table, pns->name, pns->name_length+1, (void **)&pns, sizeof(zend_namespace *), NULL);
        zend_init_namespace(pns TSRMLS_CC);
} /* }}} */ /* {{{ register_interface */ /* You will have to alloc the pce before the call and namespace_entry must be valid */ void register_interface(zend_class_entry *pce, zend_namespace *namespace_entry, char *class_name TSRMLS_DC) {
        pce->type = ZEND_USER_CLASS;
        pce->name_length = strlen(class_name);
        pce->name = class_name;
        pce->parent = NULL;
        pce->num_interfaces = 0;
        zend_initialize_class_data(pce, 1 TSRMLS_CC);
        /* entries changed by initialize */
        pce->ce_flags = ZEND_ACC_ABSTRACT | ZEND_ACC_INTERFACE;
        pce->ns = namespace_entry;
        zend_hash_add(&namespace_entry->class_table, class_name, pce->name_length+1, &pce, sizeof(zend_class_entry *), NULL);
} /* }}} */

« previous php.dev (#94938) next »