Jump to content

ede

New Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ede's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. *must be too tired* I take one half back about earlier post..call_user_func_ex works perfectly with internal (module/extension) functions. Still would like to see if someone can get up a simple explanation about the use of argument_stack and calling the internal function directly zif_Item(...)
  2. Hello everyone! Been wrestling with a problem for couple of days, and I seem not to get over it. As I understand in PHP (4.3.4) there's no way to create a class chain where the parent class constructor is automatically called when a child class is created. Thus a "kludge" with zif_parent as show below... ..register_internal_class etc. //Parent class ZEND_FUNCTION(Item) { //do something add_property_string(...) } //child class extends Item ZEND_FUNCTION(StringItem) { //... zif_Item(INTERNAL_FUNCTION_PARAM_PASSTHRU); add_property_string(...) } So now I have everything working... in PHP script side $p=new Item(); //creates the parent, can access its methods and properties $c=new StringItem(); //creates the child, CALLS the parent ctor //can access BOTH the child and parent properties and methods.. Now if (well...when) I would like the parent constructor to have certain function arguments (some or many) (possibly) in no relation to the child's constructor what would be the step to go? Say parent constructor takes arguments caption, link and image. The first two are mandatory, the last is optional (I've gone this far... ;-) Now I would like to have the child ctor be called with one argument and it to call the parent constructor with proper arguments, how can I do that? Ehm..there are many different child class types extending the parent. Like StringItem, DateItem etc. (Let's not go into why this would have to be the case...it just is ;-) $p=new Item("caption","link","image"); //this is the parent class $c=new DateItem(..); //perhaps having more or less arguments, extends Item $c=new GaugeItem(..); //perhaps having more or less arguments, extends Item Since there's no way to easily add more function arguments to the zif_Item() call, how can I achieve this at all? (Well I could create a generic init function in C-side which Item ctor calls to setup properties likewise the child classes then, but its not the same thing ;-) I've burned my head off with the call_user_function_ex, I just can't it call other the userland functions. Perhaps one cannot call an extension(my own module) functions with it? Or then the function naming is something I didn't just try... I've tried to twiddle with the argument stack(code spied from zend_execute_API.c - the details which have overall understanding only): zend_ptr_stack_push(&EG(argument_stack),caption); zend_ptr_stack_push(&EG(argument_stack),link); zend_ptr_stack_push(&EG(argument_stack),image); long param_count=3; zend_ptr_stack_n_push(&EG(argument_stack),2,(void*)(long)param_count,NULL); zif_Item(INTERNAL_FUNCTION_PARAM_PASSTHRU); But alas, the original functions are passed, not the ones I just added. I tried to see if any other ext's might have this solved, but didn't find a proper match from those either... Apparently there's no documentation that explains this either. *sigh* Hopefully some of you know the deal, before I just have to load up the ddd and start stepping thru the extension line by line ;-)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.