Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21701 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78454 invoked by uid 1010); 27 Jan 2006 09:46:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 78439 invoked from network); 27 Jan 2006 09:46:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jan 2006 09:46:02 -0000 X-Host-Fingerprint: 64.233.162.197 zproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.162.197:11920] helo=zproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id BE/EC-03249-ADBE9D34 for ; Fri, 27 Jan 2006 04:46:02 -0500 Received: by zproxy.gmail.com with SMTP id 18so603300nzp for ; Fri, 27 Jan 2006 01:45:59 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=PLV0wq+H5hQR4kvmdCzhLZoMAsywsATnN7uW6av6+Qs9tsEd2XKrrdB4qaDtLFEirs95yVaePTJBPlApKAWRHSX8DKS9qh2M3cCkm3W5hnfkSCBRAg/qLLuAKeCqn/LE9Rfw32/vILkB2jeTDGeA5nMiJevDtUYdTBkSoTHEiVU= Received: by 10.64.213.20 with SMTP id l20mr120412qbg; Fri, 27 Jan 2006 01:45:59 -0800 (PST) Received: by 10.65.192.14 with HTTP; Fri, 27 Jan 2006 01:45:59 -0800 (PST) Message-ID: Date: Fri, 27 Jan 2006 10:45:59 +0100 To: Sara Golemon Cc: internals@lists.php.net In-Reply-To: <00da01c622ce$8db2f200$5c8be5a9@ohr.berkeley.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <00da01c622ce$8db2f200$5c8be5a9@ohr.berkeley.edu> Subject: Re: Need help in defining a class from C code. From: kiputnik@gmail.com (Kiput) > What functionality is it that you feel is lacking from sapi/embed? I kno= w > that C !=3D C++, but C++ can certainly link against C libraries and using > sapi/embed is pretty well dirt-simple. Or were you planning on dumbing i= t > down to the point where the C++ developer doesn't need to know what zval* > is, let alone how to interact with script code. Yes, I want to make it easy for someone who doesn't know anything about how to handle core PHP/Zend code. Here is a litte sample of what already can be done with it: #include "php-cpp.h" PHPCPP_FUNCTION( my_func ) { PHPCPP_CHECKARG( 1 ); PHPCPP_VECTORIZE( Params ); Params[ 0 ]++; PHPCPP_RETURN( Params[ 0 ] ); } int main( ) { // Initialize, called once per app. Php :: Initialize( ); Php :: AddFunctionEx( my_func ); Php :: RequestStart( ); { Php :: clZval A( 10 ); Php :: clZval B( 20 ); Php :: clZval C; C =3D A + B; Php :: SetGlobal( "foo", C ); Php :: Interpret( "echo( my_func( $foo ) );" ); } Php :: RequestEnd( ); Php :: Destroy( ); } (This code is untested, I've wrote it from memory =3DP) > That depends very largely on whether or not you want it to be PHP4 > compatable. The structure is similar enough that PHP4 classes will work = in > PHP5, but if you're willing to eschew PHP4 support, it'd be best to go wi= th > a clean PHP5 design.... I'm not aiming for PHP4. I even have this in my code: #define PHPCPP_PHPVERSION ( PHP_MAJOR_VERSION * 10 + PHP_MINOR_VERSION ) #if PHPCPP_PHPVERSION < 51 #error "Only PHP 5.1.0 and up is supported!" #endif > Wait.... are you planning on giving your PHP scripts direct access to you= r > C++ object instances? Thats.... daring... Basically, yes. =3D)