Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22400 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84474 invoked by uid 1010); 14 Mar 2006 08:17:29 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 84457 invoked from network); 14 Mar 2006 08:17:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Mar 2006 08:17:29 -0000 X-Host-Fingerprint: 64.233.162.206 zproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.162.206:48345] helo=zproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id F0/82-55982-91C76144 for ; Tue, 14 Mar 2006 03:17:29 -0500 Received: by zproxy.gmail.com with SMTP id z3so1426685nzf for ; Tue, 14 Mar 2006 00:17:26 -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=WnGs+/9XYDMW+0/kzYwnlfitjho40zxrwhnMWD4nrNt/x6HR3+lfy4EuP3sqwoc6wYQ+dlxjIDyh94Z6oBsPfKVVyu6JVvrHj57PQzMr+cRxgF2ExCWkxCGKfmcoPV2uhPdl9u4ZcQ9oAseXpyUbzLmPWCE862DyFLlQdDJZoO4= Received: by 10.64.181.16 with SMTP id d16mr2658494qbf; Tue, 14 Mar 2006 00:17:26 -0800 (PST) Received: by 10.65.61.3 with HTTP; Tue, 14 Mar 2006 00:17:26 -0800 (PST) Message-ID: <877e9a170603140017r50914e7aybb9ceb0948d84e40@mail.gmail.com> Date: Tue, 14 Mar 2006 09:17:26 +0100 To: "an.dromeda@btconnect.com" Cc: internals@lists.php.net In-Reply-To: <200603131658.33954.an.dromeda@btconnect.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <200603131658.33954.an.dromeda@btconnect.com> Subject: Re: [PHP-DEV] Template Linkage for a PhpClassFactory in C++ From: michael.walter@gmail.com ("Michael Walter") I could be missing the point (only skimmed your mail), but you need to include your template implementation in every source file that tries to instantiate the template, e.g. by adding the code to the header file (the alternative, that is, explicitely instantiating the template in factory.cpp, would be missing the point, as you say). Anyway, this is only due to the way templates work (no code is generated unless the template is instantiated, so there's nothing the linker can link your module.cpp to) and unrelated to PHP as such. Regards, Michael On 3/13/06, an.dromeda@btconnect.com wrote: > The saga continues, with progress towards a (hoped for) marriage > between Php and C++ that 'looks like' C++ to the extension developer. > > I'm exploring a templated version of PhpClassFactory (vs possible root > PhpClassFactoryObject) which is making progress, but a linking error > not dissimilar to separated C++ file is rearing its head. > > in File 1, 'module.cpp' we have a basic extension skeleton, with > PHP_MINIT_FUNCTION() > > in File2 (pair, .h, .cpp) 'factory.h/cpp' we have a fully functional and > independent set of php-class management routines in C++, > requiring a single register_myclass() call from the module.cpp file > to enable the full php-class object behaviour implmented in factory.cpp. > > Encapsulating them piecemeal into a template format/structure is working, > but with a proviso: > > template > class PhpClassFactory > { > public: > static void Register(TSRMLS_D); // Call from MINIT_FUNCTION > } > > with implementation: > > template > void PhpClassFactory::Register(TSRMLS_D) > { > ::register_myclass("myclass" TSRMLS_CC); > } > > works ONLY if the above is in the 'module.cpp' file from which the > PhpClassFactory::Register(TSRMLS_C); call originates. > > ... whereas: > > void PhpClassFactory::Register(TSRMLS_D) > { > ::register_myclass("myclass" TSRMLS_CC); > } > > with specified class works from the separate 'factory.cpp' > file as intended, but with the cost that the very point of the templated = class > is lost, as we have to explicitly declare the MyCppClass, rather than let= ting > the intended templated form PhpClassFactory::Register(TSRMLS_D) > do the instantiation. > > Somehow, the linker can handle the generic form as long as it's in the > same object as the caller, or the class-specific form in a separate objec= t, > but neither of these is ideal/intended. Obviously, we'd like to be able t= o > link to the generic form in the separate form, so it can be a simple incl= ude > to instantiate a php-object based on a cpp-class. > > Another extern/linker issue I'm afraid. Any thoughts? > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >