This patch allows php extension authors to declare constants on internal
objects. This pretty much just duplicates the zend_declare_property_*
functions but for constants. Currently there is no way for C level class
authors to declare constants on their objects since the engine has to
allocate space for them.
Bob Silva
We were discussing adding a per class (zend_class_entry *) callback for
constants. It might make sense to allow that and if the callback is NULL
then try the constant's hash in zend_class_entry.
That should solve all cases, right?
Andi
At 11:54 PM 10/11/2004 -0700, Robert Silva wrote:
This patch allows php extension authors to declare constants on internal
objects. This pretty much just duplicates the zend_declare_property_*
functions but for constants. Currently there is no way for C level class
authors to declare constants on their objects since the engine has to
allocate space for them.Bob Silva
Hello Andi,
Tuesday, October 12, 2004, 11:43:11 PM, you wrote:
We were discussing adding a per class (zend_class_entry *) callback for
constants. It might make sense to allow that and if the callback isNULL
then try the constant's hash in zend_class_entry.
That should solve all cases, right?
Andi still the patch is a good extension to the engine API and i think
we should add it. Why should every programmer that wants constants add
constant handlers just to add some basic constants? I see the handlers
only to allow soem special cases, maybe to have array consts or whatever.
marcus
Hi Robert,
If I remember correctly, we came to the conclusion a while ago, that unless
we make some big changes (which I'm not quite sure yet how far reaching
they would be), then we could not malloc() constants. You would really need
to emalloc()/efree() them on each request because the engine could connect
to these malloced()'ed variables and all hell would break loose. Also we do
a zval_update_constant() today in order to initialize constants with
constants just before they are being used the first time.
What this basically means that you'd initialize and free these constants in
RINIT()/RSHUTDOWN(). Not too sexy but looking at how much this is needed
it's not too bad.
Andi
At 11:54 PM 10/11/2004 -0700, Robert Silva wrote:
This patch allows php extension authors to declare constants on internal
objects. This pretty much just duplicates the zend_declare_property_*
functions but for constants. Currently there is no way for C level class
authors to declare constants on their objects since the engine has to
allocate space for them.Bob Silva