Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97851 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94179 invoked from network); 18 Jan 2017 08:17:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jan 2017 08:17:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=rosenberger@taoweb.at; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rosenberger@taoweb.at; sender-id=unknown Received-SPF: error (pb1.pair.com: domain taoweb.at from 213.145.225.130 cause and error) X-PHP-List-Original-Sender: rosenberger@taoweb.at X-Host-Fingerprint: 213.145.225.130 host23.ssl-gesichert.at Received: from [213.145.225.130] ([213.145.225.130:50181] helo=host23.ssl-gesichert.at) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/B4-00729-B942F785 for ; Wed, 18 Jan 2017 03:17:32 -0500 Received: (qmail 7485 invoked by uid 7799); 18 Jan 2017 08:17:29 -0000 Received: by simscan 1.4.0 ppid: 7446, pid: 7474, t: 0.0375s scanners: clamav: 0.99/m:46/d:7299 Received: from unknown (HELO ?10.0.0.13?) (rosenberger@taoweb.at@188.22.95.12) by host23.ssl-gesichert.at with SMTP; 18 Jan 2017 08:17:29 -0000 Message-ID: <1484727448.3119.8.camel@toro.home> To: internals@lists.php.net Date: Wed, 18 Jan 2017 09:17:28 +0100 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: writing extensions best practice, pass an object as parameter From: rosenberger@taoweb.at (Torsten Rosenberger) Hello List I'm new to C and writing extensions I hope this ist the right list. I want to port the PEAR HTML_Template_Sigma Class to an PHP extension. I startet with the old book 'Building custom PHP Extensions' found now newer one. At the moment i have some class functions in my extension as they are in the PHP Class. in the PHP Class are some callback functions registert $this->setCallbackFunction('e', array(&$this, '_htmlentities')); $this->setCallbackFunction('u', 'urlencode'); the easier callback's to a php function i managed with this code zval tplFunction; ZVAL_STRING(&tplFunction,"u"); zval callback; ZVAL_STRING(&callback,"urlencode"); zend_call_method_with_2_params ( obj,Template_Sigma, NULL, "setcallbackfunction", NULL, &tplFunction, &callback); but how can i pass the object from a private method of the PHP extension class to the setcallbackfunction as it is down in PHP with array(&$this, '_htmlentities') So i try doing some bench :( Testing with php7. i call the class constructor from the extension 1000 times and also the same with the PHP class. $x = new HTML_Template_Sigma("dir","dir_cache"); so the PHP Class with opcache ist equal faste as my extension. My goal was to write the class as an extension to get faster. The last question should I use call_user_function or write this function in C. for example the private methode _jsEscape uses the PHP strtr and the second parameter is an array so the internal php_strtr_array function is called. Should I instead call the php_strtr function multiple times ? Best Regards Torsten