RE: [PHP-DEV] call_user_function()

2002-04-17 Thread Sam Liddicott

What happened with this in the end.

I have a case where call_user_function needs to call a class function
without me having to instantiate a dummy object first.

Sam

 -Original Message-
 From: Andi Gutmans [mailto:[EMAIL PROTECTED]]
 Sent: 26 February 2002 17:13
 To: brad lafountain; [EMAIL PROTECTED]
 Subject: Re: [PHP-DEV] call_user_function()
 
 
 Can you send  a unified diff of what call_user_function() 
 would look like 
 with your changes?
 
 Andi
 
 At 06:04 AM 2/25/2002 -0800, brad lafountain wrote:
 Ok,
   I know ive already posted this but no responded. So I'll 
 do it again.
 
 Currently call_user_function() doesn't call overloaded class methods.
 I hacked together a function to get around this. Does anyone 
 want to look 
 at it
 and see if it's gunna mess anything up as far as zend 
 execution. if not put it
 in as part as the normal call_user_function.
 
 int my_call_user_function(HashTable *function_table, zval 
 **object_pp, zval
 *function_name, zval *retval_ptr, int param_count, zval 
 *params[] TSRMLS_DC)
 {
  if(call_user_function(function_table, object_pp, 
 function_name, 
  retval_ptr,
 param_count, params TSRMLS_CC) == FAILURE)
  {
  
 if(Z_OBJCE_PP(object_pp)-handle_function_call != NULL)
  {
  zend_overloaded_element overloaded_element;
  zend_property_reference property_reference;
  zend_function_state function_state;
  zend_function_state 
 *original_function_state_ptr;
  int i;
 
  overloaded_element.element = *function_name;
  overloaded_element.type = OE_IS_METHOD;
 
  function_state.function = (zend_function *) 
  emalloc(sizeof(zend_function));
  function_state.function-type = 
  ZEND_OVERLOADED_FUNCTION;
  
 function_state.function-common.arg_types = NULL;
  
 function_state.function-overloaded_function.function_name =
 Z_STRVAL_P(function_name);
 
  property_reference.object = *object_pp;
  property_reference.type = BP_VAR_NA;
  property_reference.elements_list = 
 (zend_llist
 *)emalloc(sizeof(zend_llist));
  
 zend_llist_init(property_reference.elements_list,
 sizeof(zend_overloaded_element), NULL, 0);
  
 zend_llist_add_element(property_reference.elements_list,
 overloaded_element);
 
  //Build argument stack
  for(i = 0;i  param_count;i++)
  
 zend_ptr_stack_push(EG(argument_stack), 
  params[i]);
  
 zend_ptr_stack_n_push(EG(argument_stack), 2, 
  (void *)param_count, NULL);
 
  EG(function_state_ptr) = function_state;
  
 Z_OBJCE_PP(object_pp)-handle_function_call(param_count, retval_ptr,
 *object_pp, 1 TSRMLS_CC, property_reference);
  EG(function_state_ptr) = 
 original_function_state_ptr;
 
  
 zend_llist_destroy(property_reference.elements_list);
  efree(property_reference.elements_list);
  efree(function_state.function);
 
  zend_ptr_stack_clear_multiple(TSRMLS_C);
  return SUCCESS;
  }
  }
 }
 
 
 __
 Do You Yahoo!?
 Yahoo! Sports - Coverage of the 2002 Olympic Games
 http://sports.yahoo.com
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_user_function()

2002-02-26 Thread Andi Gutmans

Can you send  a unified diff of what call_user_function() would look like 
with your changes?

Andi

At 06:04 AM 2/25/2002 -0800, brad lafountain wrote:
Ok,
  I know ive already posted this but no responded. So I'll do it again.

Currently call_user_function() doesn't call overloaded class methods.
I hacked together a function to get around this. Does anyone want to look 
at it
and see if it's gunna mess anything up as far as zend execution. if not put it
in as part as the normal call_user_function.

int my_call_user_function(HashTable *function_table, zval **object_pp, zval
*function_name, zval *retval_ptr, int param_count, zval *params[] TSRMLS_DC)
{
 if(call_user_function(function_table, object_pp, function_name, 
 retval_ptr,
param_count, params TSRMLS_CC) == FAILURE)
 {
 if(Z_OBJCE_PP(object_pp)-handle_function_call != NULL)
 {
 zend_overloaded_element overloaded_element;
 zend_property_reference property_reference;
 zend_function_state function_state;
 zend_function_state *original_function_state_ptr;
 int i;

 overloaded_element.element = *function_name;
 overloaded_element.type = OE_IS_METHOD;

 function_state.function = (zend_function *) 
 emalloc(sizeof(zend_function));
 function_state.function-type = 
 ZEND_OVERLOADED_FUNCTION;
 function_state.function-common.arg_types = NULL;
 
function_state.function-overloaded_function.function_name =
Z_STRVAL_P(function_name);

 property_reference.object = *object_pp;
 property_reference.type = BP_VAR_NA;
 property_reference.elements_list = (zend_llist
*)emalloc(sizeof(zend_llist));
 zend_llist_init(property_reference.elements_list,
sizeof(zend_overloaded_element), NULL, 0);
 
zend_llist_add_element(property_reference.elements_list,
overloaded_element);

 //Build argument stack
 for(i = 0;i  param_count;i++)
 zend_ptr_stack_push(EG(argument_stack), 
 params[i]);
 zend_ptr_stack_n_push(EG(argument_stack), 2, 
 (void *)param_count, NULL);

 EG(function_state_ptr) = function_state;
 
Z_OBJCE_PP(object_pp)-handle_function_call(param_count, retval_ptr,
*object_pp, 1 TSRMLS_CC, property_reference);
 EG(function_state_ptr) = original_function_state_ptr;

 zend_llist_destroy(property_reference.elements_list);
 efree(property_reference.elements_list);
 efree(function_state.function);

 zend_ptr_stack_clear_multiple(TSRMLS_C);
 return SUCCESS;
 }
 }
}


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] call_user_function()

2002-02-25 Thread brad lafountain

Ok, 
 I know ive already posted this but no responded. So I'll do it again.

Currently call_user_function() doesn't call overloaded class methods.
I hacked together a function to get around this. Does anyone want to look at it
and see if it's gunna mess anything up as far as zend execution. if not put it
in as part as the normal call_user_function.

int my_call_user_function(HashTable *function_table, zval **object_pp, zval
*function_name, zval *retval_ptr, int param_count, zval *params[] TSRMLS_DC)
{
if(call_user_function(function_table, object_pp, function_name, retval_ptr,
param_count, params TSRMLS_CC) == FAILURE)
{
if(Z_OBJCE_PP(object_pp)-handle_function_call != NULL)
{
zend_overloaded_element overloaded_element;
zend_property_reference property_reference;
zend_function_state function_state;
zend_function_state *original_function_state_ptr;
int i;

overloaded_element.element = *function_name;
overloaded_element.type = OE_IS_METHOD;

function_state.function = (zend_function *) 
emalloc(sizeof(zend_function));
function_state.function-type = ZEND_OVERLOADED_FUNCTION;
function_state.function-common.arg_types = NULL;
function_state.function-overloaded_function.function_name =
Z_STRVAL_P(function_name);  

property_reference.object = *object_pp;
property_reference.type = BP_VAR_NA;
property_reference.elements_list = (zend_llist
*)emalloc(sizeof(zend_llist));
zend_llist_init(property_reference.elements_list,
sizeof(zend_overloaded_element), NULL, 0);
zend_llist_add_element(property_reference.elements_list,
overloaded_element);

//Build argument stack
for(i = 0;i  param_count;i++)
zend_ptr_stack_push(EG(argument_stack), params[i]);
zend_ptr_stack_n_push(EG(argument_stack), 2, (void 
*)param_count, NULL);

EG(function_state_ptr) = function_state;
Z_OBJCE_PP(object_pp)-handle_function_call(param_count, 
retval_ptr,
*object_pp, 1 TSRMLS_CC, property_reference);
EG(function_state_ptr) = original_function_state_ptr;

zend_llist_destroy(property_reference.elements_list);
efree(property_reference.elements_list);
efree(function_state.function);

zend_ptr_stack_clear_multiple(TSRMLS_C);
return SUCCESS;
}
}
}


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] call_user_function()

2002-02-20 Thread brad lafountain

I was wondering why call_user_function doens't handle calling methods of
objects for an incomplete_class_entry.

call_user_function(NULL, incomplete_class, function_name, return, 0, NULL);

i took a look at the code and it assumes that the function that you want to
call is in the class_entry.function_table... is this by design or did someone
just not want to implement call_user_function and call the callback handler if
there were no builtin functions...

- Brad

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_user_function()

2002-02-20 Thread brad lafountain

well... i hacked up a function to handle this...
does anyone wanna look at my code and maybe possible include it with
call_user_function

int my_call_user_function(HashTable *function_table, zval **object_pp, zval
*function_name, zval *retval_ptr, int param_count, zval *params[] TSRMLS_DC)
{
if(call_user_function(function_table, object_pp, function_name, retval_ptr,
param_count, params TSRMLS_CC) == FAILURE)
{
if(Z_OBJCE_PP(object_pp)-handle_function_call != NULL)
{
zend_overloaded_element overloaded_element;
zend_property_reference property_reference;
zend_function_state function_state;
zend_function_state *original_function_state_ptr;
int i;

overloaded_element.element = *function_name;
overloaded_element.type = OE_IS_METHOD;

property_reference.object = *object_pp;
property_reference.type = BP_VAR_NA;
property_reference.elements_list = (zend_llist *)
emalloc(sizeof(zend_llist));
zend_llist_init(property_reference.elements_list,
sizeof(zend_overloaded_element), NULL, 0);
zend_llist_add_element(property_reference.elements_list,
overloaded_element);

//Build argument stack
for(i = 0;i  param_count;i++)
zend_ptr_stack_push(EG(argument_stack), params[i]);
zend_ptr_stack_n_push(EG(argument_stack), 2, (void *) 
param_count, NULL);

EG(function_state_ptr) = function_state;
Z_OBJCE_PP(object_pp)-handle_function_call(param_count, 
retval_ptr,
*object_pp, 1 TSRMLS_CC, property_reference);
EG(function_state_ptr) = original_function_state_ptr;

zend_llist_destroy(property_reference.elements_list);
efree(property_reference.elements_list);

zend_ptr_stack_clear_multiple(TSRMLS_C);
return SUCCESS;
}
}
}

i know there's some things wrong with it but... it does work...
like function_state will be garbage.. i didn't know what/how to fill that
structure with. 

- Brad
--- brad lafountain [EMAIL PROTECTED] wrote:
 I was wondering why call_user_function doens't handle calling methods of
 objects for an incomplete_class_entry.
 
 call_user_function(NULL, incomplete_class, function_name, return, 0, NULL);
 
 i took a look at the code and it assumes that the function that you want to
 call is in the class_entry.function_table... is this by design or did someone
 just not want to implement call_user_function and call the callback handler
 if
 there were no builtin functions...
 
 - Brad
 
 __
 Do You Yahoo!?
 Yahoo! Sports - Coverage of the 2002 Olympic Games
 http://sports.yahoo.com
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php