Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32493 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4433 invoked by uid 1010); 28 Sep 2007 14:04:24 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 4418 invoked from network); 28 Sep 2007 14:04:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Sep 2007 14:04:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 83.243.58.163 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 83.243.58.163 mail4.netbeat.de Received: from [83.243.58.163] ([83.243.58.163:34374] helo=mail4.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AB/61-24070-6E90DF64 for ; Fri, 28 Sep 2007 10:04:24 -0400 Received: (qmail 3120 invoked by uid 507); 28 Sep 2007 14:04:18 -0000 Received: from unknown (HELO ?192.168.1.102?) (postmaster%schlueters.de@82.135.5.61) by mail4.netbeat.de with ESMTPA; 28 Sep 2007 14:04:18 -0000 To: alon , Michael Wallner Cc: internals@lists.php.net In-Reply-To: References: <200709281257.34488.alon@f4w.nl> Content-Type: text/plain Date: Fri, 28 Sep 2007 16:04:14 +0200 Message-ID: <1190988254.3004.8.camel@johannes.nop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-4.fc7) Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: using zend_parse_parameters to get an object of an externally defined class From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, On Fri, 2007-09-28 at 13:21 +0200, Michael Wallner wrote: > alon wrote: > > A newbie question: > > > > How can I use zend_parse_parameters to accept object of an external class as > > parametr. > > > > I want for example to build a method that accepts 'DateTime' objects. > > > But how do I initiate the zend_class_entry to specify an object of the > > DateTime class? > > The class entry pointer or a function which returns it needs to be > exported by the datetime API. IIRC that's not the case ATM. > you can also get the ce using zend_fetch_class() API function. So the code would look something like zend_class_entry *ce = zend_fetch_class("DateTime", sizeof("DateTime")-1, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, ce) == FAILURE) { return; } When referencing an internal class it should be enough to do the fetch just once and cache the value inside your extension. > -- > Michael >