On Mon, 6 Aug 2001, Zeev Suraski wrote:
> It's not a big deal and we can commit it (as it's done in the
> 'put-expensive-operations-here' part of PHP, the module-init, hint hint :).
>
;)
> However, is it really necessary?
>
Well, I have the following function (there maybe bugs, I'm still
debugging it:
/* {{{ adt_status_t adt_register_type(const char *type_name, adt_type *p)
Register a new abstract data type */
ADT_DECLARE(adt_status_t) adt_register_type(adt_type *p)
{
zend_class_entry ce;
TSRMLS_FETCH();
if (zend_hash_update(ADTG(types),
p->name,
strlen(p->name) + 1,
(void *) p,
sizeof(adt_type),
NULL) == FAILURE) {
php_error(E_WARNING, "Cannot register type: %s", p->name);
return -1;
}
p->le_id = zend_register_list_destructors_ex(p->le_dtor, NULL, p->le_name,
global_module_number);
INIT_OVERLOADED_CLASS_ENTRY(ce, p->name, NULL, adt_method_call_handler,
adt_property_get_handler, adt_property_set_handler);
p->ce = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
return 0;
}
/* }}} */
That's used to register the class. If you can think of another way
to do (*don't* say macro ;-), then I'd be more than willing to hear
it, but otherwise...
-Sterling
> Zeev
>
> At 05:53 06/08/2001, Sterling Hughes wrote:
> > Hey,
> >
> > The attached patch adds support for passing a variable to
> > INIT_*CLASS_ENTRY in the name field (instead of just passing a
> > constant string). I've needed this for a function which provides
> > API functionality, registering classes with Zend based on the
> > information passed to it.
> >
> > -Sterling
> >
> > Ps: The Midguard folks needed this feature/ran up against this wall
> > awhile ago as well. Its the only reason I was able to find the
> > problem without hours of painful debugging ;-)
> >
> >--
> >PHP Development Mailing List <http://www.php.net/>
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> Zeev Suraski <[EMAIL PROTECTED]>
> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]