Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25666 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79159 invoked by uid 1010); 13 Sep 2006 16:54:52 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 79144 invoked from network); 13 Sep 2006 16:54:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2006 16:54:52 -0000 X-Host-Fingerprint: 69.12.155.129 talos.alphaweb.net Received: from [69.12.155.129] ([69.12.155.129:19821] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/AD-00938-99738054 for ; Wed, 13 Sep 2006 12:54:20 -0400 Message-ID: To: internals@lists.php.net Date: Wed, 13 Sep 2006 09:53:09 -0700 User-Agent: Thunderbird 1.5.0.5 (Macintosh/20060719) MIME-Version: 1.0 References: <533439121@web.de> In-Reply-To: <533439121@web.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 69.12.155.129 Subject: Re: [PHP-DEV] PHP5 extensions: using existing functionnames as method names From: pollita@php.net (Sara Golemon) > zend_module_entry string_module_entry = { > #if ZEND_MODULE_API_NO >= 20010901 > STANDARD_MODULE_HEADER, > #endif > "string", > string_functions, > PHP_MINIT(string), > PHP_MSHUTDOWN(string), > PHP_RINIT(string), /* Replace with NULL if there's nothing to do at request start */ > PHP_RSHUTDOWN(string), /* Replace with NULL if there's nothing to do at request end */ > PHP_MINFO(string), > #if ZEND_MODULE_API_NO >= 20010901 > "0.1", /* Replace with version number for your extension */ > #endif > STANDARD_MODULE_PROPERTIES > }; > > PHP_MINIT_FUNCTION(string) > { > zend_class_entry ce; > > INIT_CLASS_ENTRY(ce, "String", string_functions); > string_ce = zend_register_internal_class(&ce TSRMLS_CC); > string_ce->create_object = string_object_new; > memcpy(&string_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); > string_handlers.clone_obj = string_object_clone; > > return SUCCESS; > } > Problem #1 (The one you actually wrote about) You're registering your methods twice. Once in zend_module_entry as global functions (the cause of your error), and again in INIT_CLASS_ENTRY() (The right place to be doing it). Solution: Change "string_functions" to "NULL" in zend_module_entry. Now for the rest of my complaints (all minor points): > stringclass.h > Not a major problem, but this file naming will trip up static linking. So long as this is only ever a shared module you don't have any worry of course. But you might as well name it php_stringclass.h > #define STRING_METHOD(function_name) \ > ZEND_NAMED_FUNCTION(c_stringclass_##function_name) > #define STRING_ME(name, arg_info, flags) \ > ZEND_FENTRY(name, c_stringclass_ ##name, arg_info, flags) > There's nothing special about these macros except for the specific function prefix you assign them. Any particular reason you're using them? > #ifdef ZTS > #define string_G(v) TSRMG(string_globals_id, zend_string_globals *, v) > #else > #define string_G(v) (string_globals.v) > #endif > It's common practice to use all uppercase for TSRM macros. Not really an issue, but worth a mentiCONFORM!!!!! YOU MUST CONFORM!!!! :) -Sara