hholzgra Wed Feb 19 11:02:46 2003 EDT Modified files: /php4/scripts/ext_skel_ng extension.xml extension_parser.php php_function.php Log: code for the special functions MINIT, MSHUTDOWN, RINIT, RSHUTDOWN, MINFO and for private internal C helper functions may now be embedded into the XML specification Index: php4/scripts/ext_skel_ng/extension.xml diff -u php4/scripts/ext_skel_ng/extension.xml:1.2 php4/scripts/ext_skel_ng/extension.xml:1.3 --- php4/scripts/ext_skel_ng/extension.xml:1.2 Wed Feb 19 09:50:43 2003 +++ php4/scripts/ext_skel_ng/extension.xml Wed Feb 19 11:02:45 2003 @@ -106,6 +106,16 @@ </code> </function> + <function role='private' name='myfunc'> + <code> +<![CDATA[ + static int myfunc(void) { + return 23; + } +]]> + </code> + </function> + <function role='public' name='dummy_int'> <summary>dummy integer conversion</summary> Index: php4/scripts/ext_skel_ng/extension_parser.php diff -u php4/scripts/ext_skel_ng/extension_parser.php:1.2 php4/scripts/ext_skel_ng/extension_parser.php:1.3 --- php4/scripts/ext_skel_ng/extension_parser.php:1.2 Wed Feb 19 05:12:28 2003 +++ php4/scripts/ext_skel_ng/extension_parser.php Wed Feb 19 11:02:45 2003 @@ -23,6 +23,8 @@ $this->constants = array(); $this->functions = array(); + $this->internal_functions = array(); + $this->private_functions = array(); $this->globals = array(); $this->phpini = array(); $this->users = array(); @@ -128,7 +130,22 @@ } function handle_functions_function($attr) { - $this->functions[$attr['name']] = new php_function($attr['name'], $this->func_summary, $this->func_proto, @$this->func_desc, @$this->func_code); + $role = isset($attr['role']) ? $attr['role'] : "public"; + $function = new php_function($attr['name'], +$this->func_summary, $this->func_proto, @$this->func_desc, @$this->func_code, $role); + switch($role) { + case "internal": + $this->internal_functions[$attr['name']] = $function; + break; + case "private": + $this->private_functions[$attr['name']] = $function; + break; + case "public": + $this->functions[$attr['name']] = $function; + break; + default: + $this->error("function role must be either public, +private or internal"); + break; + } unset($this->func_summary); unset($this->func_proto); unset($this->func_desc); @@ -206,7 +223,7 @@ $fp = fopen("$docdir/reference.xml", "w"); fputs($fp, "<?xml version='1.0' encoding='iso-8859-1'?> -<!-- \$Revision: 1.2 $ --> +<!-- \$Revision: 1.3 $ --> <reference id='ref.{$this->name}'> <title>{$this->summary}</title> <titleabbrev>{$this->name}</titleabbrev> @@ -477,15 +494,20 @@ "; if(count($this->globals)) { - $code .= " ZEND_INIT_MODULE_GLOBALS({$this->name}, php_{$this->name}_init_globals, NULL)\n"; + $code .= "\tZEND_INIT_MODULE_GLOBALS({$this->name}, +php_{$this->name}_init_globals, NULL)\n"; } if(count($this->phpini)) { - $code .= " REGISTER_INI_ENTRIES();\n"; + $code .= "\tREGISTER_INI_ENTRIES();\n"; } - $code .="\n /* add your stuff here */\n"; - + if(isset($this->internal_functions['MINIT'])) { + if(count($this->globals) || count($this->phpini)) $code .= "\n\t{\n"; + $code .= $this->internal_functions['MINIT']->code; + if(count($this->globals) || count($this->phpini)) $code .= "\n\t}\n"; + } else { + $code .="\n\t/* add your stuff here */\n"; + } $code .= " return SUCCESS; } @@ -500,10 +522,16 @@ "; if(count($this->phpini)) { - $code .= " UNREGISTER_INI_ENTRIES();\n"; + $code .= "\tUNREGISTER_INI_ENTRIES();\n"; } - $code .="\n /* add your stuff here */\n"; + if(isset($this->internal_functions['MSHUTDOWN'])) { + if(count($this->phpini)) $code .= "\n\t{\n"; + $code .= $this->internal_functions['MSHUTDOWN']->code; + if(count($this->phpini)) $code .= "\n\t}\n"; + } else { + $code .="\n\t/* add your stuff here */\n"; + } $code .= " return SUCCESS; @@ -516,9 +544,16 @@ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION({$this->name}) { - /* add your stuff here */ +"; - return SUCCESS; + if(isset($this->internal_functions['RINIT'])) { + $code .= $this->internal_functions['RINIT']->code; + } else { + $code .= " /* add your stuff here */\n"; + } + + $code .= " +\treturn SUCCESS; } /* }}} */ @@ -528,9 +563,16 @@ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION({$this->name}) { - /* add your stuff here */ +"; - return SUCCESS; + if(isset($this->internal_functions['RSHUTDOWN'])) { + $code .= $this->internal_functions['RSHUTDOWN']->code; + } else { + $code .= " /* add your stuff here */\n"; + } + + $code .= " +\treturn SUCCESS; } /* }}} */ @@ -540,15 +582,23 @@ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION({$this->name}) { - php_info_print_table_start(); - php_info_print_table_header(2, \"{$this->name} support\", \"enabled\"); - php_info_print_table_end(); +\tphp_info_print_table_start(); +\tphp_info_print_table_header(2, \"{$this->name} support\", \"enabled\"); +\tphp_info_print_table_end(); - /* add your stuff here */ "; + if(isset($this->internal_functions['MINFO'])) { + $code .= "\n\t{\n"; + $code .= $this->internal_functions['MINFO']->code; + $code .= "\n\t}\n"; + } else { + $code .= "\t/* add your stuff here */\n"; + } + + if(count($this->phpini)) { - $code .= "\n DISPLAY_INI_ENTRIES();"; + $code .= "\n\tDISPLAY_INI_ENTRIES();"; } $code .= " } @@ -562,6 +612,16 @@ // }}} + function private_functions_c() { + $code = ""; + + foreach ($this->private_functions as $name => $func) { + $code .= "\n\t/* {{{ $name() */\n{$func->code}\n\t/* }}} */\n\n"; + } + + return $code; + } + // {{{ public functions function public_functions_c() { @@ -749,7 +809,7 @@ fputs($fp, "/* {{{ {$this->name}_functions[] */\n"); fputs($fp, "function_entry {$this->name}_functions[] = {\n"); foreach($this->functions as $name => $function) { - fputs($fp, sprintf(" PHP_FE(%-20s, NULL)\n",$name)); + fputs($fp, sprintf("\tPHP_FE(%-20s, NULL)\n",$name)); } fputs($fp, "};\n/* }}} */\n\n"); @@ -760,6 +820,8 @@ fputs($fp, "/* }}} */\n\n"); fputs($fp, $this->internal_functions_c()); + + fputs($fp, $this->private_functions_c()); fputs($fp, $this->public_functions_c()); Index: php4/scripts/ext_skel_ng/php_function.php diff -u php4/scripts/ext_skel_ng/php_function.php:1.2 php4/scripts/ext_skel_ng/php_function.php:1.3 --- php4/scripts/ext_skel_ng/php_function.php:1.2 Wed Feb 19 05:12:28 2003 +++ php4/scripts/ext_skel_ng/php_function.php Wed Feb 19 11:02:45 2003 @@ -2,12 +2,13 @@ class php_function extends php_element { // all known php types - function php_function($name, $summary, $proto, $desc="", $code="") { + function php_function($name, $summary, $proto, $desc="", $code="", +$role="") { $this->name = $name; $this->summary = $summary; - $this->parse_proto($proto); $this->desc = empty($desc) ? "&warn.undocumented.func;" : $desc; $this->code = $code; + $this->role = empty($role) ? "public" : $role; + if($this->role === "public") $this->parse_proto($proto); } function parse_proto($proto) { @@ -76,6 +77,10 @@ } function c_code() { + $code = ""; + + switch($this->role) { + case "public": $code .= "\n/* {{{ proto {$this->returns} {$this->name}("; if(isset($this->params)) { foreach($this->params as $param) { @@ -160,14 +165,25 @@ } $code .= "\tphp_error(E_WARNING, \"{$this->name}: not yet implemented\");\n"; $code .= "}\n/* }}} */\n\n"; - + break; + case "internal": + if(!empty($this->code)) { + $code .= "\t\t{\n"; + $code .= $this->code."\n"; + $code .= "\t\t}\n"; + } + break; + case "private": + $code .= $this->code."\n"; + + break; + } return $code; } function docbook_xml() { $xml = '<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="function.'.strtolower(str_replace("_","-",$this->name)).'"> <refnamediv> <refname>'.$this->name.'</refname>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php