Re: [PHP-DEV] AUTOLOAD in PHP

2002-03-23 Thread S.Murali Krishna


Hi 
Thanks for you to point me such coding style.

I had looked in to unserialize() callback mechanism, you know,
it is now disabled in 4.1.2 (look at ext/standard/incomplete_class.c )
In manual also there is nothing about callback function and all, anyway
the link you showed me has a seperate Note about that.

I think to pass the undef_function_name  as first argument, could
you point me any code similar to this.


 S.Murali Krishna wrote:
  Hi,
  As I told in my Previous Post that I have added a feauture in PHP
  which is similar to AUTOLOAD feauture in Perl Modules. 
  
  I had sent a unified diff output along with this.
  
  According to that if a user tried to call a undefined function,
  PHP Zend Engine would search for a function named '__autoload' in current
  scope, if it finds one, it would set the global variable 
  
  $php_undef_func_name  
  
  with name of the called function and call the __autoload()  function with
  passed arguments.
  
  Its working fine for me. If it seems to be good, we could discuss
  on this. 
 
 please have a look at the callback mechanism for unserialize()
 ( http://php.net/unserialize ) and try to follow the scheme already
 implemented for including files for undefined classes on demand



 
 
 
 -- 
 Hartmut Holzgraefe  [EMAIL PROTECTED]  http://www.six.de  +49-711-99091-77
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 

[EMAIL PROTECTED]
---
We must use time wisely and forever realize that the time is 
always ripe to do right.

-- Nelson Mandela
---


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




Re: [PHP-DEV] AUTOLOAD in PHP

2002-03-22 Thread Hartmut Holzgraefe

S.Murali Krishna wrote:
 Hi,
   As I told in my Previous Post that I have added a feauture in PHP
 which is similar to AUTOLOAD feauture in Perl Modules. 
   
   I had sent a unified diff output along with this.
 
   According to that if a user tried to call a undefined function,
 PHP Zend Engine would search for a function named '__autoload' in current
 scope, if it finds one, it would set the global variable 
 
 $php_undef_func_name  
 
 with name of the called function and call the __autoload()  function with
 passed arguments.
 
   Its working fine for me. If it seems to be good, we could discuss
 on this. 

please have a look at the callback mechanism for unserialize()
( http://php.net/unserialize ) and try to follow the scheme already
implemented for including files for undefined classes on demand



-- 
Hartmut Holzgraefe  [EMAIL PROTECTED]  http://www.six.de  +49-711-99091-77


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




[PHP-DEV] AUTOLOAD in PHP

2002-03-21 Thread S.Murali Krishna


Hi,
As I told in my Previous Post that I have added a feauture in PHP
which is similar to AUTOLOAD feauture in Perl Modules. 

I had sent a unified diff output along with this.

According to that if a user tried to call a undefined function,
PHP Zend Engine would search for a function named '__autoload' in current
scope, if it finds one, it would set the global variable 

$php_undef_func_name  

with name of the called function and call the __autoload()  function with
passed arguments.

Its working fine for me. If it seems to be good, we could discuss
on this. 

[EMAIL PROTECTED]
---
We must use time wisely and forever realize that the time is 
always ripe to do right.

-- Nelson Mandela
---


diff -bBr php-4.1.2/Zend/zend_execute.c ./php/php-4.1.2/Zend/zend_execute.c
1555a1556
 if (zend_hash_find(active_function_table, __autoload, 
sizeof(__autoload), (void **) function)==FAILURE) {
1556a1558,1566
  } else {
 zval *undef_func ;
 
 ALLOC_ZVAL(undef_func);
 convert_to_string(undef_func);
 undef_func-value.str.val = (char *) 
estrndup(function_name-value.str.val, function_name-value.str.len);
 undef_func-value.str.len = function_name-value.str.len 
;
 undef_func-type = IS_STRING;
 zend_hash_update(EG(active_symbol_table), 
php_undef_func_name, sizeof(php_undef_func_name), undef_func, sizeof(zval *), 
NULL);
1557a1568,1569
 }
   


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


Re: [PHP-DEV] AUTOLOAD in PHP

2002-03-21 Thread S.Murali Krishna


Hi Chris
I Intially thought about passing function name as first argument only,
but I don't know whether I done it correctly or not, Its not recognizing
the argument that I pushed in to argument stack. If you help me in how to
do this, it would be really helpful to me.

After some two days of trying that, I switched over to this
method of passing function name.

overload()
--
  When I searched for AUTOLOAD requierment in PHP, I came across
overload() function, but its not working for me, even the property
overloading, Its seems to be not recognizing __get or __set method.

If anything needs to be done for this, please tell me.


On Thu, 21 Mar 2002, Chris Adams wrote:

 On Thursday, March 21, 2002, at 03:41 , S.Murali Krishna wrote:
  scope, if it finds one, it would set the global variable
 
  $php_undef_func_name
 
 
 Why not pass the function name as the first parameter? Otherwise, this 
 looks like some interesting code - I'm looking forward to the overload() 
 extension to do similar things with object methods and properties.
 
 Chris
 

[EMAIL PROTECTED]
---
We must use time wisely and forever realize that the time is 
always ripe to do right.

-- Nelson Mandela
---



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