[PHP-DEV] Question about zend_compile

2003-03-05 Thread John Coggeshall

I'm playing around with the compiler/executor and I was wondering if
someone could answer a question.. 

Is there any reasonable way to essentially push/pop the function table?
What I'd like to do is get a function_table hash for only a single file
(pesudo code below):

PUSH_FUNCTION_TABLE(CG(function_table))
Op_array = zend_compile_file(fh, ZEND_REQUIRE);

/* retrieve information from the function_table 
about the functions in the fh handle only*/

POP_FUNCTION_TABLE(CG(function_table))

Specifically, I'd like to get the zend_function structures for the
user-defined functions declared inside of myfile.php... Basically my
problem is I have a userspace get_func_info($filename) function which
works great when retrieving information from the function table after
zend_compile_file(), but I end up having more functions than I wanted
since every user-defined function regardless of file (including the file
I'm in) is in the hash... i.e.

Myscript.php
?php
function foo() {

}
/* supposed to return an array based 
   on the function declarations in myfile.php, but it includes
foo() because it's already in the function table when zend
compiled this script. */
$info = get_func_info(myfile.php) 
?

It seems to me that this is exactly the sort of thing I would want to
use namespaces for, is there a elequent way to create a new namespace
from within my C function temporarily between when my function is called
and returns?

Suggestions? 

John



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



Re: [PHP-DEV] Question about zend_compile

2003-03-05 Thread George Schlossnagle
Look at apc.  It tracks per-file function and class tables.

http://apc.communityconnect.com/  (v2.0)
pear/PECL/apc (v1.x)
Both versions do the thing you wish for.

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