From: Hartmut Holzgraefe Date: Tue, 20 May 2003 13:51:29 +0000 (+0000) Subject: - experimental streams support X-Git-Tag: RELEASE_1_0_2~689 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3562b9bd985837dedc2e969ba41199ca4168410;p=php - experimental streams support - more file types: conf and doc - requirements/install/configure documentation in configure.xml - auto-generated PEAR/PECL package.xml files - auto-generated CREDITS file - auto-generated EXPERIMENTAL file if release state != stable - beginning support for test file generation --- diff --git a/scripts/ext_skel_ng/extension_parser.php b/scripts/ext_skel_ng/extension_parser.php index 1d22cd3097..09ba750365 100644 --- a/scripts/ext_skel_ng/extension_parser.php +++ b/scripts/ext_skel_ng/extension_parser.php @@ -32,6 +32,7 @@ $this->constants = array(); $this->resources = array(); + $this->streams = array(); $this->functions = array(); $this->internal_functions = array(); $this->private_functions = array(); @@ -45,7 +46,11 @@ $this->language = "c"; $this->platform = "all"; - $this->files = array("c"=>array(), "h"=>array()); + $this->files = array("c" => array(), + "h" => array(), + "conf" => array(), + "doc" => array() + ); parent::__construct($stream); } @@ -103,9 +108,14 @@ $this->license = license::factory($this->release['license']); if (is_object($this->license)) { $this->license->write_license_file(); + $this->files['doc'][] = "LICENSE"; } } + function handle_release_notes($attr) { + $this->release['notes'] = trim($this->cdata); + } + function handle_maintainers_maintainer_user($attr) { $this->user["user"] = trim($this->cdata); } @@ -160,7 +170,9 @@ } function handle_deps_with($attr) { - $this->with = $attr; + $this->with = array(); + $this->with['attr'] = $attr; + $this->with['desc'] = trim($this->cdata); } // }}} @@ -177,6 +189,29 @@ // }}} + // {{{ streams + function hamdle_steams($attr) { + } + + function hamdle_steams_stream($attr) { + $this->streams[$attr['name']] = new php_stream($attr, $this->stream_data); + unset($this->stream_data); + } + + function hamdle_steams_stream_description($attr) { + $this->stream_data['desc'] = $this->_trimdata; + } + + function hamdle_steams_stream_ops($attr) { + } + + function hamdle_steams_stream_ops_op($attr) { + } + + function hamdle_steams_stream_data($attr) { + } + // }}} + // {{{ resources function handle_resources_resource_destruct($attr) { @@ -326,26 +361,7 @@ - - -
- &reftitle.runtime; -"); - - if (empty($this->phpini)) { - fputs($fp, " &no.config;\n"); - } else { - fputs($fp, php_ini::docbook_xml_header($this->name)); - foreach ($this->phpini as $phpini) { - fputs($fp, $phpini->docbook_xml()); - } - fputs($fp, php_ini::docbook_xml_footer()); - } - - fputs($fp, -"
&reftitle.resources; @@ -387,10 +403,68 @@ "); - fputs($fp, php_element::docbook_editor_footer()); + fputs($fp, php_element::docbook_editor_settings()); fclose($fp); + // configure options and dependencies have their own file + $fp = fopen("$docdir/configure.xml","w"); + + fputs($fp,"\n
\n &reftitle.required;\n"); + if (empty($this->libs) && empty($this->headers)) { + fputs($fp, " &no.requirement;\n"); + } else { + // TODO allow custom text + if (isset($this->libs)) { + $libs = array(); + foreach ($this->libs as $lib) { + $libs[] = $lib['name']; + } + $ies = count($libs)>1 ? "ies" :"y"; + fputs($fp, "This extension requires the following librar$ies: ".join(",", $libs)."\n"); + } + if (isset($this->headers)) { + $headers = array(); + foreach ($this->headers as $header) { + $headers[] = $header['name']; + } + $s = count($headers)>1 ? "s" : ""; + fputs($fp, "This extension requires the following header$s: ".join(",", $headers)."\n"); + } + } + fputs($fp, "\n
\n\n"); + + fputs($fp,"\n
\n &reftitle.install;\n"); + if (empty($this->with)) { + fputs($fp, " &no.install;\n"); + } else { + if (isset($this->with['desc'])) { + if (strstr($this->with['desc'], "")) { + fputs($fp, $this->with['desc']); + } else { + fputs($fp, " \n".rtrim($this->with['desc'])."\n \n"); + } + } else { + // TODO default text + } + } + fputs($fp, "\n
\n\n"); + + fputs($fp,"\n
\n &reftitle.runtime;\n"); + if (empty($this->phpini)) { + fputs($fp, " &no.config;\n"); + } else { + fputs($fp, php_ini::docbook_xml_header($this->name)); + foreach ($this->phpini as $phpini) { + fputs($fp, $phpini->docbook_xml()); + } + fputs($fp, php_ini::docbook_xml_footer()); + } + fputs($fp, "\n
\n\n"); + + fputs($fp, php_element::docbook_editor_settings()); + fclose($fp); + mkdir("$docdir/functions"); foreach ($this->functions as $name => $function) { $filename = $docdir . "/functions/" . strtolower(str_replace("_", "-", $name)) . ".xml"; @@ -538,8 +612,6 @@ zend_module_entry {$name}_module_entry = { fputs($fp, "#ifndef PHP_{$upname}_H\n"); fputs($fp, "#define PHP_{$upname}_H\n\n"); - fputs($fp, "#ifndef PHP_HAVE_{$upname}\n\n"); - if (isset($this->headers)) { foreach ($this->headers as $header) { if (@$header["prepend"] === "yes") { @@ -557,6 +629,8 @@ zend_module_entry {$name}_module_entry = { #include "config.h" #endif +#ifdef HAVE_'.$upname.' + #include #include #include @@ -884,7 +958,6 @@ $code .= " // {{{ config.m4 file function write_config_m4() { - $upname = strtoupper($this->name); ob_start(); @@ -895,7 +968,7 @@ dnl $ Id: $ dnl '; - if (isset($this->with)) { + if (isset($this->with['attr'])) { echo " PHP_ARG_WITH({$this->name}, whether to enable {$this->name} functions, [ --with-{$this->name}[=DIR] With {$this->name} support], yes) @@ -903,12 +976,12 @@ PHP_ARG_WITH({$this->name}, whether to enable {$this->name} functions, echo " if test \"\$PHP_$upname\" != \"no\"; then - if test -r \"\$PHP_$upname/{$this->with['testfile']}\"; then + if test -r \"\$PHP_$upname/{$this->with['attr']['testfile']}\"; then PHP_{$upname}_DIR=\"\$PHP_$upname\" else AC_MSG_CHECKING(for {$this->name} in default path) - for i in ".str_replace(":"," ",$this->with['defaults'])."; do - if test -r \"\$i/{$this->with['testfile']}\"; then + for i in ".str_replace(":"," ",$this->with['attr']['defaults'])."; do + if test -r \"\$i/{$this->with['attr']['testfile']}\"; then PHP_{$upname}_DIR=\$i AC_MSG_RESULT(found in \$i) fi @@ -942,7 +1015,7 @@ PHP_ARG_ENABLE({$this->name} , whether to enable {$this->name} functions, $first = false; } - if (isset($this->with)) { + if (isset($this->with['attr'])) { echo "PHP_ADD_LIBRARY_WITH_PATH($lib[name], \$PHP_{$upname}_DIR/lib, {$upname}_SHARED_LIBADD)\n"; } else { echo "PHP_ADD_LIBRARY($lib[name],, {$upname}_SHARED_LIBADD)\n"; @@ -969,7 +1042,10 @@ fi "; - $fp = fopen("{$this->name}/config.m4", "w"); + $filename = "{$this->name}/config.m4"; + $this->files['conf'][] = basename($filename); + + $fp = fopen($filename, "w"); fputs($fp, ob_get_contents()); fclose($fp); ob_end_clean(); @@ -1143,9 +1219,11 @@ echo # End Project '; + $filename = "{$this->name}/{$this->name}.dsp"; + $this->files['conf'][] = basename($filename); - - $fp = fopen("{$this->name}/{$this->name}.dsp","wb"); + // write file, enforce DOS/Windows line endings on all platforms + $fp = fopen($filename,"wb"); fputs($fp, str_replace("\n","\r\n",ob_get_contents())); fclose($fp); ob_end_clean(); @@ -1153,8 +1231,131 @@ echo // }}} - // }}} - } + function write_credits() { + if (count($this->users)) { + $this->files['doc'][] = "CREDITS"; + $fp = fopen("{$this->name}/CREDITS", "w"); + fputs($fp, "{$this->name}\n"); + $names = array(); + foreach($this->users as $user) { + if (isset($user['name'])) { + $names[] = $user['name']; + } + } + fclose($fp); + } + } + + + function write_experimental() { + if (isset($this->release['state']) && $this->release['state'] !== 'stable') { + $this->files['doc'][] = "EXPERIMENTAL"; + $fp = fopen("{$this->name}/EXPERIMENTAL", "w"); + fputs($fp, +"this extension is experimental, +its functions may change their names +or move to extension all together +so do not rely to much on them +you have been warned! +"); + fclose($fp); + } + } + + function write_package_xml() { + $status = false; + + ob_start(); + + echo +" + + + {$this->name} +"; + + if (isset($this->summary)) { + echo " {$this->summary}\n"; + } + + if (isset($this->description)) { + echo " \n".rtrim($this->description)."\n \n"; + } + + if (@is_array($this->users)) { + echo "\n \n"; + foreach ($this->users as $user) { + echo " \n"; + foreach (array("user","name","email","role") as $key) { + if (isset($user[$key])) { + echo " <$key>{$user[$key]}\n"; + } + } + echo " \n"; + } + echo " \n"; + } + + if (is_array($this->release)) { + echo "\n \n"; + foreach (array("version","date","state","notes") as $key) { + if (isset($this->release[$key])) { + echo " <$key>{$this->release[$key]}\n"; + } + } + echo " \n"; + } + + echo "\n \n"; + echo " \n"; + if (@is_array($this->files['doc'])) { + foreach ($this->files['doc'] as $file) { + echo " $file\n"; + } + } + if (@is_array($this->files['conf'])) { + foreach ($this->files['conf'] as $file) { + echo " $file\n"; + } + } + if (@is_array($this->files['c'])) { + foreach ($this->files['c'] as $file) { + echo " $file\n"; + } + } + if (@is_array($this->files['h'])) { + foreach ($this->files['h'] as $file) { + echo " $file\n"; + } + } + + echo " \n"; + echo " \n"; + + + echo "\n"; + + $fp = fopen("{$this->name}/package.xml", "w"); + if (is_resource($fp)) { + fputs($fp, ob_get_contents()); + fclose($fp); + } + + ob_end_clean(); + return $status; + } + + // }}} + + function write_test_files() { + mkdir("$this->name/tests"); + + foreach ($this->functions as $function) { + $function->write_test($this); + } + } + +} ?> \ No newline at end of file