cvs: presentations / PECL_Gen.xml /slides/PECL_Gen classes.xml constants.xml custom_code.xml dependencies.xml dependencies_2.xml documentation.xml
globals.xml makefile_fragments.xml outlook.xml php_ini.xml resources.xml returning.xml returning_2.xml returning_3.xml special_functions.xml
streams.xml tests.xml /slides/PECL_Gen/examples constants.snippet custom_code.snippet globals.snippet ini.snippet internal_functions.snippet
return.snippet return_array.snippet return_resource.snippet with.snippet

From: Date: Mon, 26 Apr 2004 16:20:43 +0000
Subject: cvs: presentations / PECL_Gen.xml /slides/PECL_Gen classes.xml constants.xml custom_code.xml dependencies.xml dependencies_2.xml documentation.xml
globals.xml makefile_fragments.xml outlook.xml php_ini.xml resources.xml returning.xml returning_2.xml returning_3.xml special_functions.xml
streams.xml tests.xml /slides/PECL_Gen/examples constants.snippet custom_code.snippet globals.snippet ini.snippet internal_functions.snippet
return.snippet return_array.snippet return_resource.snippet with.snippet
Groups: php.pres 
Request: Send a blank email to pres+get-984@lists.php.net to get a copy of this message
hholzgra Mon Apr 26 12:20:43 2004 EDT Added files: /presentations/slides/PECL_Gen classes.xml constants.xml custom_code.xml dependencies.xml dependencies_2.xml documentation.xml globals.xml makefile_fragments.xml outlook.xml php_ini.xml resources.xml returning.xml returning_2.xml returning_3.xml special_functions.xml streams.xml tests.xml /presentations/slides/PECL_Gen/examples constants.snippet custom_code.snippet globals.snippet ini.snippet internal_functions.snippet return.snippet return_array.snippet return_resource.snippet with.snippet Modified files: /presentations PECL_Gen.xml Log: more content, slides nearing completion

http://cvs.php.net/diff.php/presentations/PECL_Gen.xml?r1=1.1&r2=1.2&ty=u Index: presentations/PECL_Gen.xml diff -u presentations/PECL_Gen.xml:1.1 presentations/PECL_Gen.xml:1.2 --- presentations/PECL_Gen.xml:1.1 Thu Apr 22 12:14:32 2004 +++ presentations/PECL_Gen.xml Mon Apr 26 12:20:42 2004 @@ -26,12 +26,16 @@ <slide>slides/PECL_Gen/parameters_2.xml</slide> <slide>slides/PECL_Gen/parameters_3.xml</slide> <slide>slides/PECL_Gen/returning.xml</slide> + <slide>slides/PECL_Gen/returning_2.xml</slide> + <slide>slides/PECL_Gen/returning_3.xml</slide> <slide>slides/PECL_Gen/special_functions.xml</slide> <slide>slides/PECL_Gen/constants.xml</slide> <slide>slides/PECL_Gen/php_ini.xml</slide> + <slide>slides/PECL_Gen/globals.xml</slide> <slide>slides/PECL_Gen/resources.xml</slide> <slide>slides/PECL_Gen/custom_code.xml</slide> <slide>slides/PECL_Gen/dependencies.xml</slide> + <slide>slides/PECL_Gen/dependencies_2.xml</slide> <slide>slides/PECL_Gen/makefile_fragments.xml</slide> <slide>slides/PECL_Gen/documentation.xml</slide> <slide>slides/PECL_Gen/tests.xml</slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/classes.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/classes.xml +++ presentations/slides/PECL_Gen/classes.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Classes</title> <blurb> There is no support for the object oriented features of either PHP 4 or 5 in PECL_Gen for now. </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/constants.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/constants.xml +++ presentations/slides/PECL_Gen/constants.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Constants</title> <blurb> PHP constants are defined using %&amp;lt;constant&amp;gt;% tags. </blurb> <blurb> The actual constant name, type and value are specified using the %name%, %type% and %value% attributes. Valid types for a constant are %int%, %float% and %string%. </blurb> <blurb> For %int% and %float% you may use either numeric strings or the names of C constants (either true ANSI C/C++ constants or values &#35;defined using the C preprocessor. %string% values are always used "as is", no constants may be used here. </blurb> <blurb> If only the %name% attribute is given it is assumed that the constant is supposed of type %int% and that its value is to be that of a C constant of the same name. </blurb> <blurb> A descriptive text may be given as data content of the %&amp;lt;constant&amp;gt;% tag. This text will be used when generation the DocBook XML documentation. </blurb> <example filename="examples/constants.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/custom_code.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/custom_code.xml +++ presentations/slides/PECL_Gen/custom_code.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Custom code</title> <blurb> Custom C/C++ code may be added to the generated code and header file using %&amp;lt;code&amp;gt;% tags on the top level within %&amp;lt;extension%&amp;gt;. </blurb> <blurb> Code can be added to either the generated code or hader file by setting the %role% attribute to %code% (default) or %header%. </blurb> <blurb> The %position% attribute controls whether the code will be inserted near the %top% or %bottom% (default) of the generated file. </blurb> <blurb> Code fragments that go to the same file and position are inserted by order of appearance in the XML source. </blurb> <example filename="examples/custom_code.snippet" fontsize="1em"/> <blurb> If you have to add large ammounts of custom code you should put it into seperate files and add these in the dependencies section (described on the next slide). </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/dependencies.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/dependencies.xml +++ presentations/slides/PECL_Gen/dependencies.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Dependencies</title> <blurb> Dependencies to be checked by %configure% are declared within the %&amp;lt;deps&amp;gt;% section. </blurb> <blurb> The %&amp;lt;deps&amp;gt;% tag itself has two attributes: %lang% for the programming language you want to have code generated for and %platform% for the operating systems to be supported. </blurb> <blurb> Set %lang% to %"c"% for plain C code or %"c++"% for C++ code generation. By default C code is generated. C++ code generation should be selected for extensions making use of C++ libraries. </blurb> <blurb> Possible values for %platform% are %unix% for all Unix-like platforms supporting %configure% scripts, %win32% for Microsoft Windows with Microsoft VisualStudio as developement platform or %all% for both supported platforms. </blurb> <blurb> Within the %&amp;lt;deps&amp;gt;% section it is possible to define %configure% parameters, to specify needed header files and libraries and to add existing files to the extension. </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/dependencies_2.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/dependencies_2.xml +++ presentations/slides/PECL_Gen/dependencies_2.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>%--with%</title> <blurb> When building an extension on Unix-like systems or within the Cygwin environment under Windows the configure script will try to figure out where external libraries and header files needed by an extension are installed on the target system. Using a "with" option it is possible to specify where to actually look for libraries and headers. This way it is possible to override search paths if things are not installed in the default system paths or to specify the exact version of a package to be used if multiple versions are installed on the target system. </blurb> <blurb> The %&amp;lt;with&amp;gt;% tag takes three attributes: name=... for the actual name of the "with" option, testfile for the relative path of a file to check for while running the configure script and a list of default paths to check if no path is given as an argument to the "with" option in defaults. </blurb> <blurb> Name and defaults are set to the extension base name and "/usr:/usr/local" if no values are given. The testfile attribute is mandatory. </blurb> <blurb> Textual data enclosed by the %&amp;lt;with&amp;gt;% is used to describe the "with" option in the output of configure --help calls. </blurb> <example filename="examples/with.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/documentation.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/documentation.xml +++ presentations/slides/PECL_Gen/documentation.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Documentation</title> <blurb> to be done ... </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/globals.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/globals.xml +++ presentations/slides/PECL_Gen/globals.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Request globals</title> <blurb> Variables global to a single request need special treatment as some server APIs may run several PHP requests in different threads at the same time. </blurb> <blurb> Request global variables are declared using the %&amp;lt;global&amp;gt;% tag and its %name% and %type% attributes. </blurb> <blurb> Simple default values can be given with the %value% attribute, else you can always initialize request globals within the %RINIT% internal function. </blurb> <blurb> To access your request global variables you have to use the the %EXTNAME_G% macro (replace %EXTNAME% with the uppercased name of your extension). </blurb> <example filename="examples/globals.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/makefile_fragments.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/makefile_fragments.xml +++ presentations/slides/PECL_Gen/makefile_fragments.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Makefile fragments</title> <blurb> to be done ... </blurb> <example filename="examples/makefile_fragment.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/outlook.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/outlook.xml +++ presentations/slides/PECL_Gen/outlook.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>What's next?</title> <blurb> The next TODO (after cleanups) is definetly OO support, although this will most likely be implemented for PHP 5 extensions only. Currently extensions generated by PECL_Gen work with both PHP 4 and 5, but unlike the rest of the extension API the OO related parts of it have undergone some substantial changes. </blurb> <blurb> PECL_Gen can also be used as base for other code generators. A first example showing its capabilities in this realm is UDF_Gen, a code generator for MySQL User Defined Function libraries. </blurb> <blurb> Extensions that have been created using PECL_Gen include PECLS %html_parse% and %mdb_tools%. So although still not finished PECL_Gen is already perfectly capable of doing 'real work' :) </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/php_ini.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/php_ini.xml +++ presentations/slides/PECL_Gen/php_ini.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>%php.ini% directives</title> <blurb> %php.ini% directives are defined using the %&amp;lt;phpini&amp;gt;% tag. To define a %php.ini% directive you have to specify its %name%, %type% and default %value%. </blurb> <blurb> Valid directive %name% values are C variable names. The actual directive name is the extension name followed by a single dot '.' and the specified name. A directive may be of %type% %bool%, %int%, %float% or %string%. </blurb> <blurb> Directive default values are passed to the engine as strings, so you may not use any C constants or preprocessor macros here. The default value strings are parsed by the %OnUpdate% handler registered for that directive. The %OnUpdate% handler defaults to the appropriate internal %OnUpdate...% handler for its %type% unless you specify a different handler using the %onupdate% attribute. </blurb> <blurb> The directive value may be changed at any time unless you specify an %access% attribute. Possible values are %all% (default), %perdir% (may be changed by local %.htaccess% file but not by PHP code) and %system% (may only be set in %php.ini% or global web server configuration. </blurb> <blurb> The content data of %&amp;lt;phpini&amp;gt;% tags is used to generate documentation for the defined directive. </blurb> <example filename="examples/ini.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/resources.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/resources.xml +++ presentations/slides/PECL_Gen/resources.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Resources</title> <blurb> to be done ... </blurb> <example filename="examples/resource.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/returning.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/returning.xml +++ presentations/slides/PECL_Gen/returning.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Return values</title> <blurb> To return data from a function you may use the convenience macros provided by the Zend API or assign to the predefined %return_value% %zval% pointer. </blurb> <blurb> If you do not add a &amp;lt;code&amp;gt; section to your function the generated code skeleton will include a suggestion on how to return data. If you put your own code into the XML specification you also have to take care of returning your results yourself. </blurb> <example filename="examples/return.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/returning_2.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/returning_2.xml +++ presentations/slides/PECL_Gen/returning_2.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Returning resources</title> <blurb> For functions defined to return a known resource type a special local variable %return_res% is generated. </blurb> <blurb> This variables type is a pointer to the resources payload type and points to an allready allocated piece of memory of this type unless you specified %alloc="no"% in the %resource% tag. </blurb> <blurb> All you have to do is to take care of storing the appropriate payload data here. The actual resource registration and returning code will be generated for you. </blurb> <blurb> Resources will be covered in more detail later on. </blurb> <example filename="examples/return_resource.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/returning_3.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/returning_3.xml +++ presentations/slides/PECL_Gen/returning_3.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Returning arrays</title> <blurb> When a function is defined to return an array its %return_value% variable is already appropriately initialized. All you have to do is to add the acutal array elements to %return_value%. </blurb> <blurb> The Zend API provides a rich set of functions for adding various data types as array elements, supporting numerical, associative and automatic indexes. </blurb> <example filename="examples/return_array.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/special_functions.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/special_functions.xml +++ presentations/slides/PECL_Gen/special_functions.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Internal functions</title> <blurb> Five special C functions take care for internal matters within a PHP extension: %MINIT%, %MSHUTDOWN%, %RINIT%, %RSHUTDOWN% and %MINFO%. </blurb> <blurb> %MINIT% and %MSHUTDOWN% are called on initialization and shutdown of an extension within PHP, these are called exactly once. Any initialization and cleanup you need to do globaly should be added here. </blurb> <blurb> %RINIT% and %RSHUTDOWN% are called on the beginning and end of each request handled by PHP. Depending on the server api these may be called just once or many times. Any per request initialization and cleanup needed should be added here. </blurb> <blurb> %MINFO% is called to produce the extensions output for %phpinfo()% whenever this function is called. </blurb> <blurb> All these functions are generated for you. Only if you have to add special code you need to add %&amp;lt;function&amp;gt;% tags for them. Usually you will only add code for %MINIT% and %MSHUTDOWN%. Internal functions are specified by setting the %role% attribute to %"internal"%. </blurb> <example filename="examples/internal_functions.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/streams.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/streams.xml +++ presentations/slides/PECL_Gen/streams.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Stream wrappers and filters</title> <blurb> To be done ... </blurb> <example filename="examples/stream.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/tests.xml?r=1.1&p=1 Index: presentations/slides/PECL_Gen/tests.xml +++ presentations/slides/PECL_Gen/tests.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Regression tests</title> <blurb> to be done ... </blurb> <example filename="examples/tests.snippet" fontsize="1em"/> </slide> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/constants.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/constants.snippet +++ presentations/slides/PECL_Gen/examples/constants.snippet <constant name="ANSWER" type="int" value="42">Answer to THE question</constant> <constant name="PI" type="float" value="3.14"/> <constant name="MYNAME" type="string" value="Hartmut Holzgraefe"/> <constant name="FOOBAR" type="int" value="FOOBAR"/> <constant name="FOOBAR"/> <!-- short form of previous constant --> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/custom_code.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/custom_code.snippet +++ presentations/slides/PECL_Gen/examples/custom_code.snippet <extension> ... <code role="code" position="top"> /* this is a global variable used throughout this extension */ void *global_master_pointer = NULL; </code> ... </extension> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/globals.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/globals.snippet +++ presentations/slides/PECL_Gen/examples/globals.snippet <extension name="foobar"> <global name="foo" type="long" value="42"/> <function name="get_foo"> <proto>int get_foo(void)</proto> <code> RETURN_LONG( FOOBAR_G(foo) ); </code> </function> <function name="set_foo"> <proto>void set_foo(int newfoo)</proto> <code> FOOBAR_G(foo) = newfoo; </code> </function> </extension> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/ini.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/ini.snippet +++ presentations/slides/PECL_Gen/examples/ini.snippet <phpini name="my_int" type="int" value="42" onupdate="OnUpdateLong" access="all"> Definition for directive "sample.my_int" </phpini> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/internal_functions.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/internal_functions.snippet +++ presentations/slides/PECL_Gen/examples/internal_functions.snippet <function role="internal" name="MINIT"> <code>somelib_init();</code> </function> <function role="internal" name="MSHUTDOWN"> <code>somelib_shutdown();</code> </function> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/return.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/return.snippet +++ presentations/slides/PECL_Gen/examples/return.snippet RETURN_BOOL(1); // returning a PHP bool RETURN_TRUE; // short for RETURN_BOOL(1) RETURN_FALSE; // short for RETURN_BOOL(0) RETURN_LONG(42); // returning a PHP int RETURN_DOUBLE(3.14); // returning a PHP float RETURN_STRING(stringvar, 1); // returning copy of a C string RETURN_STRING(stringvar, 0); // returning a C string allocated with emalloc() RETURN_STRINGL(strvar, len, 1); // binary safe return of string copy RETURN_STRINGL(strvar, len, 0); // binary safe return of emalloc()ed string http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/return_array.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/return_array.snippet +++ presentations/slides/PECL_Gen/examples/return_array.snippet // adding an integer element add_assoc_long(return_value, "index", 42); // like $array["index"] = 42; add_index_long(return_value, 23, 42); // like $array[23] = 42; add_next_index_long(return_value, 42); // like $array[] = 42; // adding a string element (string is copied) add_assoc_string(return_value, "foo", "bar", 1); // like $array["foo"] = "bar" add_assoc_stringl(return_value, "foo", "bar", 3, 1); // the same binary safe including length // adding a string element previously allocated using emalloc add_assoc_string(return_value, "foo", "bar", 0); // no need to copy as memory is already managed // general form of adding a zval add_assoc_zval(return_value, "foobar", zval_ptr); http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/return_resource.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/return_resource.snippet +++ presentations/slides/PECL_Gen/examples/return_resource.snippet <resource name="my_FILE" payload="FILE" alloc="no"> <destruct> fclose(resource); </destruct> </resource> <function name="my_fopen"> <proto>resource my_FILE my_fopen(string name, string mode)</proto> <code> return_res = fopen(name, mode); if (!return_res) RETURN_FALSE; </code> </function> http://cvs.php.net/co.php/presentations/slides/PECL_Gen/examples/with.snippet?r=1.1&p=1 Index: presentations/slides/PECL_Gen/examples/with.snippet +++ presentations/slides/PECL_Gen/examples/with.snippet <with defaults='/usr:/usr/local' testfile='include/sample.h'>sample install</with>
« previous php.pres (#984) next »