cvs: pecl /PECL_Gen manual.xml
| From: | Hartmut Holzgraefe | Date: | Tue, 09 Nov 2004 18:36:39 +0000 |
| Subject: | cvs: pecl /PECL_Gen manual.xml | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-2002@lists.php.net to get a copy of this message | ||
hholzgra Tue Nov 9 13:36:39 2004 EDT
Modified files:
/pecl/PECL_Gen manual.xml
Log:
lots of small doc fixes
http://cvs.php.net/diff.php/pecl/PECL_Gen/manual.xml?r1=1.2&r2=1.3&ty=u Index: pecl/PECL_Gen/manual.xml diff -u pecl/PECL_Gen/manual.xml:1.2 pecl/PECL_Gen/manual.xml:1.3 --- pecl/PECL_Gen/manual.xml:1.2 Mon Apr 26 12:49:18 2004 +++ pecl/PECL_Gen/manual.xml Tue Nov 9 13:36:38 2004 @@ -1,10 +1,12 @@ <?xml version='1.0' encoding='ISO-8859-1' ?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "../../phpdoc/dtds/dbxml-4.1.2/docbookx.dtd" [ - ]> <book> + +<!-- TODO: src=... is now available in a lot of places --> + <title><literal>PECL_Gen</literal> - the PHP extension generator</title> <chapter> <title>Introduction</title> @@ -13,20 +15,25 @@ <para> <literal>PECL_Gen</literal> is a tool that can automatically create the basic framework for a PHP extension from a rather simple XML - configuration file. + specification file. </para> <para> It also supports the simpler (but less powerful) prototype file format as used by the shell script <literal>ext_skel</literal> that - is part of the PHP source code. + is distributed togehter with the PHP source code. </para> <para> <literal>PECL_Gen</literal>, unlike the older <literal>ext_skel</literal> solution, is a 100% PHP 5 bases - solution and does not rely on any external tools like + solution and does not require any external tools like <literal>awk</literal> or <literal>sed</literal>. It only uses PHP functions that are always enabled in a default build so it should - be usable on any platform PHP itself runs on. + be usable on any platform that PHP itself runs on. + </para> + <para> + The code generated by <literal>PECL_Gen</literal> is designed to work + with both the PHP 4 and PHP 5 extension APIs, PHP 5 is only required + for the conversion of the XML spec file to C/C++ code. </para> </section> @@ -54,12 +61,12 @@ </para> <para> DocBook XML documentation templates suitable for inclusion in the - PHP or PEAR manual is generated in the hope that it will ease the + PHP or PEAR manual are generated in the hope that it will ease the task of documenting extension. </para> <para> - Test scripts for automatic regression testing are already created - but due to some missing features within the "<literal>make + Test script templates for automatic regression testing are already + created but due to some missing features within the "<literal>make test</literal>" infrastructure it is not possible to use the generated tests with standalone PECL extensions right now. </para> @@ -78,9 +85,9 @@ C code skeleton for just that function to standard output. </para> <para> - <literal>ext_skel</literal> compatibility mode is not documented - here, please refer to the original <literal>ext_skel</literal> - documentation instead. + <literal>ext_skel</literal> compatibility and immediate mode are + not documented here, please refer to the original + <literal>ext_skel</literal> documentation instead. </para> <para> Below you find a hardcopy of the <literal>pecl-gen @@ -168,9 +175,9 @@ </para> <para> The <sgmltag>maintainers</sgmltag>, <sgmltag>release</sgmltag> and - <sgmltag>changelog</sgmltag> tags specifications are taken from - the PEAR <literal>package.xml</literal> specification so please - refer to the PEAR documentation here for now. + <sgmltag>changelog</sgmltag> tags specifications are identical to + those in the PEAR <literal>package.xml</literal> specification so + please refer to the PEAR documentation here. </para> <example> <title>Release information</title> @@ -247,7 +254,7 @@ <programlisting role="xml"> <![CDATA[ ... - <logo src="sample_logo.gif" /> + <logo src="sample_logo.gif" mimetype="image/gif" /> ... ]]> </programlisting> @@ -276,6 +283,12 @@ (<literal>platform="unix"</literal>), Microsoft Windows (<literal>platform="win32"</literal>) or both (<literal>platform="all"</literal>). </para> + <para> + <sgmltag>with</sgmltag>, <sgmltag>lib</sgmltag> and + <sgmltag>header</sgmltag> tags may be used within the + <sgmltag>deps</sgmltag> section to add configure switches + and library and header file dependencies. + </para> <example> <title>Dependencies</title> <programlisting> @@ -295,7 +308,7 @@ When building an extension on Unix-like systems or within the Cygwin environment under Windows the <literal>configure</literal> script will try to figure out where external libraries and header - files needed by an extension are installed on the target system. + files needed by an extension are installed on the build 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 @@ -381,12 +394,14 @@ unless you set the <literal>prepend="yes"</literal> attribute to have it put in front of the other <literal>#include</literal>s. </para> +<!-- TODO: is this still true? <note> <para> <literal>config.m4</literal>/<literal>configure</literal> checks for header file availability has not been added yet. </para> </note> +--> <example> <title>Header file dependencies</title> <programlisting> @@ -400,6 +415,9 @@ </example> </section> +<!-- TODO: will we ever support this? + would make sense for e.g. pkgtools? + <section> <title>External programs</title> <para> @@ -413,7 +431,25 @@ Not supported yet. </para> </section> +--> + + </section> + <section> + <title>Custom code</title> + <para> + Custom code may be added to your extension source files using the + <sgmltag>code</sgmltag> tags. The <literal>role=...</literal> + and <literal>position=...</literal> tags specify the actual place + in there generated source files where your code should be + inserted. + </para> + <para> + Possible roles are '<literal>code</literal>' (default) for the generated C + or C++ code file and '<literal>header</literal>' header file. + Possible positions are '<literal>top</literal>' and '<literal>bottom</literal>' + (default) for insertion near the beginning or end of the generated file. + </para> </section> <section> @@ -471,7 +507,8 @@ <member><type>resource</type> <emphasis>[typename]</emphasis></member> <member><type>stream</type></member> </simplelist> - Argument names in prototypes ... no $? ... + Argument names in prototypes are not prepended by a <literal>$</literal> + sign by convention. </para> <para> Function documentation should be given using the @@ -489,6 +526,8 @@ return value is up to the code fragment if any is given, adding a template doesn't make sense in this case. </para> + + <!-- TODO: this is a very big TODO!!!! -> <note> <para> Maybe some stuff regarding actual coding should be added here? @@ -601,13 +640,14 @@ </variablelist> </para> <para> - <sgmltag>code</sgmltag> sections for the init and shutdown + <sgmltag>code</sgmltag> sections for the internal functions may be written as if they were C function bodies, including local variable definitions. </para> </section> +<!-- deprecated!!! <section> <title>Private functions</title> <para> @@ -619,6 +659,7 @@ course match the name attribute, but this is not checked for. </para> </section> +--> </section> @@ -632,8 +673,8 @@ The actual constant name, type and value are specified using the <literal>name=...</literal>, <literal>type=...</literal> and <literal>value=...</literal> attributes. The constant name has to - be a valid C name. PHP constant names should use only uppercase - letters by convention. Possible types are "string", "int" and + be a valid C name. PHP constant names should use uppercase letters + only by convention. Possible types are "string", "int" and "float", the possible values depend on the type. For "int" and "float" you may use either numeric strings or the names of C constants (either true ANSI C/C++ constants or values @@ -641,6 +682,11 @@ values are always used "as is", no constants may be used here. </para> <para> + It is sufficient to specify a constant <literal>name</literal> + only if a C integer constant should be available under the same + name in PHP, too. + </para> + <para> A descriptive text may be given as content of the <sgmltag>constant</sgmltag> tag. This text will be used when generation the DocBook XML documentation. @@ -657,9 +703,15 @@ <constant name="SAMPLE_FLOAT" type="float" value="3.14"> A sample floating point constant. </constant> + <constant name="SAMPLE_FLOAT" type="float" value="M_PI"> + A sample floating point constant using a #defined constant + </constant> <constant name="SAMPLE_STRING" type="string" value="Hello World!"> A sample string constant. </constant> + <constant name="MY_CONST"> + A shortcat for #defined integer constants + </constant> </constants> ... ]]> @@ -673,7 +725,8 @@ An extension may define variables that are global to either the complete extension or to a specific request. True globals that are global to the complete extensions do not need any registration so - they can be defined using C code within the <sgmltag>code</sgmltag> tag. + they can be defined using C code within the global <sgmltag>code</sgmltag> + tag. </para> <para> Module globals that are only global to a single request need to @@ -790,6 +843,37 @@ ]]> </programlisting> </example> + <para> + Access to the modul globals and ini parameters is provided in a thread safe + manner through the EXTNAME_G() macro (replace EXTNAME with the upper cased + name of your extension). + </para> + <example> + <title>Globals</title> + <programlisting role="xml"> +<![CDATA[ +<extension name="foobar"> + ... + <globals> + <global name="sample_int" type="int" value="42" /> + </globals> + ... + <function ...> + ... + <code> + ... + int foo = FOOBAR_G(sample_int); // get global value + ... + FOOBAR_G(sample_init) = 42; // set global value + ... + </code> + </function> +]]> + </programlisting> + </example> + + <!-- TODO: add an example how to write an OnUpdate handler? --> + </section> <section> @@ -799,22 +883,25 @@ <sgmltag>resources</sgmltag> environment. For each <sgmltag>resource</sgmltag> you have to specify the <literal>name=...</literal> and <literal>payload=...</literal> - attributes. The name has to be a valid C name and the payload has - to be a valid C type specifier. The payload type can only be - checked for the correctness of its form as the actual type - definitions from included header files are not known to the - extension generator when it generates the extension code. + attributes. The <literal>name</literal> has to be a valid + C name and the <literal>payload</literal> has to be a valid + C type specifier. The payload type can only be checked for + the correctness of its form as the actual type definitions + from included header files are not known to the extension + generator when it generates the extension code. </para> <para> The actual resource data structure carries a pointer to the payload type. You may specify that PHP shall allocate and free the actual payload by setting the <literal>alloc=...</literal> attribute to "<literal>yes</literal>". If the payload is allocated - by a library function you should set <literal>alloc=...</literal> - to "<literal>no</literal>" (the default value). + by a library function or by yourself you should set + <literal>alloc=...</literal> to "<literal>no</literal>" + (the default value). </para> <para> - Resources are cleaned up at request shutdown. If your resource + Resources are destructed when the last variable reference refering + to them is unset or at request shutdown. If your resource payload needs to be cleaned up as well you have to add an appropriate C code snippet that takes care of this using the <sgmltag>destruct</sgmltag> tag. Within the destructor snippet you @@ -866,33 +953,21 @@ <title>Classes</title> <para> OO support is planned for a future release but not implemented yet. + OO code generation may be limited to PHP 5 extensions as unlike the + rest of the extension API the OO implementation changed a lot between + PHP 4 and 5. </para> </section> <section> <title>Streams</title> <para> - Stream filter and wrapper support is planned but not implemented yet. + Stream filter and wrapper support is experimental and not yet added + to the released code base. </para> </section> - <section> - <title>Custom code</title> - <para> - Custom code may be added to your extension source files using the - <sgmltag>code</sgmltag> tags. The <literal>role=...</literal> - and <literal>position=...</literal> tags specify the actual place - in there generated source files where your code should be - inserted. - </para> - <para> - Possible roles are '<literal>code</literal>' for the generated C - or C++ code file and '<literal>header</literal>' header file. - Possible positions are '<literal>top</literal>' and '<literal>bottom</literal>' - for insertion near the beginning or end of the generated file. - </para> - </section> - + <section> <title>Makefile fragments</title> <para> @@ -904,7 +979,11 @@ <example> <title>Makefile fragments</title> <screen> +<[!CDATA +<makefile> $(builddir)/tokenizer.lo: Zend/zend_language_parser.h +</makefile> +]]> </screen> </example> </section>
http://cvs.php.net/diff.php/pecl/PECL_Gen/manual.xml?r1=1.2&r2=1.3&ty=u Index: pecl/PECL_Gen/manual.xml diff -u pecl/PECL_Gen/manual.xml:1.2 pecl/PECL_Gen/manual.xml:1.3 --- pecl/PECL_Gen/manual.xml:1.2 Mon Apr 26 12:49:18 2004 +++ pecl/PECL_Gen/manual.xml Tue Nov 9 13:36:38 2004 @@ -1,10 +1,12 @@ <?xml version='1.0' encoding='ISO-8859-1' ?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "../../phpdoc/dtds/dbxml-4.1.2/docbookx.dtd" [ - ]> <book> + +<!-- TODO: src=... is now available in a lot of places --> + <title><literal>PECL_Gen</literal> - the PHP extension generator</title> <chapter> <title>Introduction</title> @@ -13,20 +15,25 @@ <para> <literal>PECL_Gen</literal> is a tool that can automatically create the basic framework for a PHP extension from a rather simple XML - configuration file. + specification file. </para> <para> It also supports the simpler (but less powerful) prototype file format as used by the shell script <literal>ext_skel</literal> that - is part of the PHP source code. + is distributed togehter with the PHP source code. </para> <para> <literal>PECL_Gen</literal>, unlike the older <literal>ext_skel</literal> solution, is a 100% PHP 5 bases - solution and does not rely on any external tools like + solution and does not require any external tools like <literal>awk</literal> or <literal>sed</literal>. It only uses PHP functions that are always enabled in a default build so it should - be usable on any platform PHP itself runs on. + be usable on any platform that PHP itself runs on. + </para> + <para> + The code generated by <literal>PECL_Gen</literal> is designed to work + with both the PHP 4 and PHP 5 extension APIs, PHP 5 is only required + for the conversion of the XML spec file to C/C++ code. </para> </section> @@ -54,12 +61,12 @@ </para> <para> DocBook XML documentation templates suitable for inclusion in the - PHP or PEAR manual is generated in the hope that it will ease the + PHP or PEAR manual are generated in the hope that it will ease the task of documenting extension. </para> <para> - Test scripts for automatic regression testing are already created - but due to some missing features within the "<literal>make + Test script templates for automatic regression testing are already + created but due to some missing features within the "<literal>make test</literal>" infrastructure it is not possible to use the generated tests with standalone PECL extensions right now. </para> @@ -78,9 +85,9 @@ C code skeleton for just that function to standard output. </para> <para> - <literal>ext_skel</literal> compatibility mode is not documented - here, please refer to the original <literal>ext_skel</literal> - documentation instead. + <literal>ext_skel</literal> compatibility and immediate mode are + not documented here, please refer to the original + <literal>ext_skel</literal> documentation instead. </para> <para> Below you find a hardcopy of the <literal>pecl-gen @@ -168,9 +175,9 @@ </para> <para> The <sgmltag>maintainers</sgmltag>, <sgmltag>release</sgmltag> and - <sgmltag>changelog</sgmltag> tags specifications are taken from - the PEAR <literal>package.xml</literal> specification so please - refer to the PEAR documentation here for now. + <sgmltag>changelog</sgmltag> tags specifications are identical to + those in the PEAR <literal>package.xml</literal> specification so + please refer to the PEAR documentation here. </para> <example> <title>Release information</title> @@ -247,7 +254,7 @@ <programlisting role="xml"> <![CDATA[ ... - <logo src="sample_logo.gif" /> + <logo src="sample_logo.gif" mimetype="image/gif" /> ... ]]> </programlisting> @@ -276,6 +283,12 @@ (<literal>platform="unix"</literal>), Microsoft Windows (<literal>platform="win32"</literal>) or both (<literal>platform="all"</literal>). </para> + <para> + <sgmltag>with</sgmltag>, <sgmltag>lib</sgmltag> and + <sgmltag>header</sgmltag> tags may be used within the + <sgmltag>deps</sgmltag> section to add configure switches + and library and header file dependencies. + </para> <example> <title>Dependencies</title> <programlisting> @@ -295,7 +308,7 @@ When building an extension on Unix-like systems or within the Cygwin environment under Windows the <literal>configure</literal> script will try to figure out where external libraries and header - files needed by an extension are installed on the target system. + files needed by an extension are installed on the build 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 @@ -381,12 +394,14 @@ unless you set the <literal>prepend="yes"</literal> attribute to have it put in front of the other <literal>#include</literal>s. </para> +<!-- TODO: is this still true? <note> <para> <literal>config.m4</literal>/<literal>configure</literal> checks for header file availability has not been added yet. </para> </note> +--> <example> <title>Header file dependencies</title> <programlisting> @@ -400,6 +415,9 @@ </example> </section> +<!-- TODO: will we ever support this? + would make sense for e.g. pkgtools? + <section> <title>External programs</title> <para> @@ -413,7 +431,25 @@ Not supported yet. </para> </section> +--> + + </section> + <section> + <title>Custom code</title> + <para> + Custom code may be added to your extension source files using the + <sgmltag>code</sgmltag> tags. The <literal>role=...</literal> + and <literal>position=...</literal> tags specify the actual place + in there generated source files where your code should be + inserted. + </para> + <para> + Possible roles are '<literal>code</literal>' (default) for the generated C + or C++ code file and '<literal>header</literal>' header file. + Possible positions are '<literal>top</literal>' and '<literal>bottom</literal>' + (default) for insertion near the beginning or end of the generated file. + </para> </section> <section> @@ -471,7 +507,8 @@ <member><type>resource</type> <emphasis>[typename]</emphasis></member> <member><type>stream</type></member> </simplelist> - Argument names in prototypes ... no $? ... + Argument names in prototypes are not prepended by a <literal>$</literal> + sign by convention. </para> <para> Function documentation should be given using the @@ -489,6 +526,8 @@ return value is up to the code fragment if any is given, adding a template doesn't make sense in this case. </para> + + <!-- TODO: this is a very big TODO!!!! -> <note> <para> Maybe some stuff regarding actual coding should be added here? @@ -601,13 +640,14 @@ </variablelist> </para> <para> - <sgmltag>code</sgmltag> sections for the init and shutdown + <sgmltag>code</sgmltag> sections for the internal functions may be written as if they were C function bodies, including local variable definitions. </para> </section> +<!-- deprecated!!! <section> <title>Private functions</title> <para> @@ -619,6 +659,7 @@ course match the name attribute, but this is not checked for. </para> </section> +--> </section> @@ -632,8 +673,8 @@ The actual constant name, type and value are specified using the <literal>name=...</literal>, <literal>type=...</literal> and <literal>value=...</literal> attributes. The constant name has to - be a valid C name. PHP constant names should use only uppercase - letters by convention. Possible types are "string", "int" and + be a valid C name. PHP constant names should use uppercase letters + only by convention. Possible types are "string", "int" and "float", the possible values depend on the type. For "int" and "float" you may use either numeric strings or the names of C constants (either true ANSI C/C++ constants or values @@ -641,6 +682,11 @@ values are always used "as is", no constants may be used here. </para> <para> + It is sufficient to specify a constant <literal>name</literal> + only if a C integer constant should be available under the same + name in PHP, too. + </para> + <para> A descriptive text may be given as content of the <sgmltag>constant</sgmltag> tag. This text will be used when generation the DocBook XML documentation. @@ -657,9 +703,15 @@ <constant name="SAMPLE_FLOAT" type="float" value="3.14"> A sample floating point constant. </constant> + <constant name="SAMPLE_FLOAT" type="float" value="M_PI"> + A sample floating point constant using a #defined constant + </constant> <constant name="SAMPLE_STRING" type="string" value="Hello World!"> A sample string constant. </constant> + <constant name="MY_CONST"> + A shortcat for #defined integer constants + </constant> </constants> ... ]]> @@ -673,7 +725,8 @@ An extension may define variables that are global to either the complete extension or to a specific request. True globals that are global to the complete extensions do not need any registration so - they can be defined using C code within the <sgmltag>code</sgmltag> tag. + they can be defined using C code within the global <sgmltag>code</sgmltag> + tag. </para> <para> Module globals that are only global to a single request need to @@ -790,6 +843,37 @@ ]]> </programlisting> </example> + <para> + Access to the modul globals and ini parameters is provided in a thread safe + manner through the EXTNAME_G() macro (replace EXTNAME with the upper cased + name of your extension). + </para> + <example> + <title>Globals</title> + <programlisting role="xml"> +<![CDATA[ +<extension name="foobar"> + ... + <globals> + <global name="sample_int" type="int" value="42" /> + </globals> + ... + <function ...> + ... + <code> + ... + int foo = FOOBAR_G(sample_int); // get global value + ... + FOOBAR_G(sample_init) = 42; // set global value + ... + </code> + </function> +]]> + </programlisting> + </example> + + <!-- TODO: add an example how to write an OnUpdate handler? --> + </section> <section> @@ -799,22 +883,25 @@ <sgmltag>resources</sgmltag> environment. For each <sgmltag>resource</sgmltag> you have to specify the <literal>name=...</literal> and <literal>payload=...</literal> - attributes. The name has to be a valid C name and the payload has - to be a valid C type specifier. The payload type can only be - checked for the correctness of its form as the actual type - definitions from included header files are not known to the - extension generator when it generates the extension code. + attributes. The <literal>name</literal> has to be a valid + C name and the <literal>payload</literal> has to be a valid + C type specifier. The payload type can only be checked for + the correctness of its form as the actual type definitions + from included header files are not known to the extension + generator when it generates the extension code. </para> <para> The actual resource data structure carries a pointer to the payload type. You may specify that PHP shall allocate and free the actual payload by setting the <literal>alloc=...</literal> attribute to "<literal>yes</literal>". If the payload is allocated - by a library function you should set <literal>alloc=...</literal> - to "<literal>no</literal>" (the default value). + by a library function or by yourself you should set + <literal>alloc=...</literal> to "<literal>no</literal>" + (the default value). </para> <para> - Resources are cleaned up at request shutdown. If your resource + Resources are destructed when the last variable reference refering + to them is unset or at request shutdown. If your resource payload needs to be cleaned up as well you have to add an appropriate C code snippet that takes care of this using the <sgmltag>destruct</sgmltag> tag. Within the destructor snippet you @@ -866,33 +953,21 @@ <title>Classes</title> <para> OO support is planned for a future release but not implemented yet. + OO code generation may be limited to PHP 5 extensions as unlike the + rest of the extension API the OO implementation changed a lot between + PHP 4 and 5. </para> </section> <section> <title>Streams</title> <para> - Stream filter and wrapper support is planned but not implemented yet. + Stream filter and wrapper support is experimental and not yet added + to the released code base. </para> </section> - <section> - <title>Custom code</title> - <para> - Custom code may be added to your extension source files using the - <sgmltag>code</sgmltag> tags. The <literal>role=...</literal> - and <literal>position=...</literal> tags specify the actual place - in there generated source files where your code should be - inserted. - </para> - <para> - Possible roles are '<literal>code</literal>' for the generated C - or C++ code file and '<literal>header</literal>' header file. - Possible positions are '<literal>top</literal>' and '<literal>bottom</literal>' - for insertion near the beginning or end of the generated file. - </para> - </section> - + <section> <title>Makefile fragments</title> <para> @@ -904,7 +979,11 @@ <example> <title>Makefile fragments</title> <screen> +<[!CDATA +<makefile> $(builddir)/tokenizer.lo: Zend/zend_language_parser.h +</makefile> +]]> </screen> </example> </section>