Re: Submission: Inline_C
| From: | Tal Peer | Date: | Thu, 26 Sep 2002 06:05:20 +0000 |
| Subject: | Re: Submission: Inline_C | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-9520@lists.php.net to get a copy of this message | ||
George Schlossnagle wrote:
Inline_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) {Just a little note, with the new parameter parsing api (which you used), you don't need the WRONG_PARAM_COUNT, only return;. Tallong 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 Looks very very useful, +1.