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 



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to