parser injection

From: Date: Tue, 29 Jun 1999 14:08:52 +0000
Subject: parser injection
Groups: php.dev 
Request: Send a blank email to php-dev+get-7804@lists.php.net to get a copy of this message
Zeev/Andi: I looked at the COM implementation. It appears to allow "programmatic scripting" of COM objects. What would it take to "inject" COM objects into the parser symbol table? I think it would be much cool to do: <? $x = new com::MyClass(); $y = $x->MyMethod("testing"); ?> rather than: <? $x = com_load("MyClass"); $y = com_invoke($x, "MyMethod", "testing"); ?> particularly because you could build an abstraction layer around the "exteral object" support. then, to call a java class, or a corba class, or a next-generation-object class, you don't need a whole new set of PHP methods, you just need a new "instantiation operator": $x = new corba::ComeCorbaObject(); $x = new java::SomeJavaClass(); I'm assuming that in the hash table, $x would still be an "Object", but perhaps it would have a "modifier" field to indicate that it is "external", and/or a field to indicate that it's a "COM" or "JAVA", or whatever. Then, the parser would need some hooks for calling instantiation, methods, properties, and deletes on objects. I'm not a parser geek, but I would think that in the "object" code, it could examine the object and determine if it's external, and then use the appropriate external object code layer to do the work. I guess it would be a php component api. This doesn't seem to be too far removed from the "adding a constructor" discussion - so I'm not sure if the new parser is built to handle something like this. But I in theory it doesn't sound too difficult. -brian-

« previous php.dev (#7804) next »