Re: Submission: Inline_C
| From: | Lux | Date: | Thu, 26 Sep 2002 07:10:07 +0000 |
| Subject: | Re: Submission: Inline_C | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-9524@lists.php.net to get a copy of this message | ||
+1, rock 'n' roll!
lux
On Thursday, September 26, 2002, at 01:05 AM, Tal Peer wrote:
George Schlossnagle wrote:-- John Luxford Simian Systems _______________________ phone : 204.946.5955 email : lux@simian.ca web : www.simian.ca _______________________ web content management application development consulting and trainingInline_C is a class that allows you to write critical function code in C, from within userland php. Basically it provides 'glue' and a build system for taking PHP_FUNCTION definitions, and wrapping the build and dl() process. The interface is like: <? require_once("Inline_C.php"); $function1 = <<<EOF PHP_FUNCTION(times) {Looks very very useful, +1. Just a little note, with the new parameter parsing api (which you used), you don't need the WRONG_PARAM_COUNT, only return;. Tal -- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phplong i,j; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &i,&j) == FAILURE) { WRONG_PARAM_COUNT; } RETURN_LONG(i*j);} EOF; $inline = new Inline_C; $inline->add_code($function1); // To link against libfoo //$inline->library("foo","/usr/local/lib"); $inline->compile(); for($i=0;$i<10;$i++) {for($j=0; $j<10; $j++) { print "$i * $j = ".times($i,$j)."\n"; }} ?> Code is available at http://www.omniti.com/~george/Inline.tar.gz. Basic testing has been done on 4.2.3 and HEAD. // George Schlossnagle // Principal Consultant// OmniTI, Inc http://www.omniti.com// (c) 240.460.5234 (e) george@omniti.com // 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0