cvs: pear /CodeGen_PECL/PECL Command.php Extension.php Maintainer.php Release.php /CodeGen_PECL/PECL/Dependency Extension.php Header.php With.php
/CodeGen_PECL/PECL/Element Class.php ClassConstant.php Constant.php Global.php Ini.php Interface.php Logo.php Method.php Property.php Resource.php
Stream.php Test.php

From: Date: Mon, 09 Oct 2006 21:27:05 +0000
Subject: cvs: pear /CodeGen_PECL/PECL Command.php Extension.php Maintainer.php Release.php /CodeGen_PECL/PECL/Dependency Extension.php Header.php With.php
/CodeGen_PECL/PECL/Element Class.php ClassConstant.php Constant.php Global.php Ini.php Interface.php Logo.php Method.php Property.php Resource.php
Stream.php Test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42469@lists.php.net to get a copy of this message
hholzgra Mon Oct 9 21:27:05 2006 UTC Modified files: /pear/CodeGen_PECL/PECL Command.php Extension.php Maintainer.php Release.php /pear/CodeGen_PECL/PECL/Dependency Extension.php Header.php With.php /pear/CodeGen_PECL/PECL/Element Class.php ClassConstant.php Constant.php Global.php Ini.php Interface.php Logo.php Method.php Property.php Resource.php Stream.php Test.php Log: CS/WS fixes

http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Command.php?r1=1.5&r2=1.6&diff_format=u Index: pear/CodeGen_PECL/PECL/Command.php diff -u pear/CodeGen_PECL/PECL/Command.php:1.5 pear/CodeGen_PECL/PECL/Command.php:1.6 --- pear/CodeGen_PECL/PECL/Command.php:1.5 Mon Aug 21 14:12:41 2006 +++ pear/CodeGen_PECL/PECL/Command.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Command.php,v 1.5 2006/08/21 14:12:41 hholzgra Exp $ + * @version CVS: $Id: Command.php,v 1.6 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -74,7 +74,7 @@ "linespecs", "no-help", "proto=", - "skel=" , + "skel=", "stubs=", "xml==")); @@ -153,7 +153,7 @@ echo "\n\n/*----------------------------------------------------------------------*/\n\n"; foreach ($this->extension->functions as $name => $function) { - echo sprintf("\tPHP_FE(%-20s, NULL)\n",$name); + echo sprintf("\tPHP_FE(%-20s, NULL)\n", $name); } echo "\n\n/*----------------------------------------------------------------------*/\n\n"; @@ -211,7 +211,7 @@ fputs($fp, "\n\n/*----------------------------------------------------------------------*/\n\n"); foreach ($this->extension->functions as $name => $function) { - fputs($fp, sprintf("\tPHP_FE(%-20s, NULL)\n",$name)); + fputs($fp, sprintf("\tPHP_FE(%-20s, NULL)\n", $name)); } fputs($fp, "\n\n/*----------------------------------------------------------------------*/\n\n"); @@ -223,7 +223,7 @@ fclose($fp); echo "$stubname successfully written\n"; - } else { + } else { if (file_exists("./$extname") && !$this->options->have("f", "force")) { $command->terminate("'$extname' already exists, can't create directory (use '--force' to override)"); } http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Extension.php?r1=1.58&r2=1.59&diff_format=u Index: pear/CodeGen_PECL/PECL/Extension.php diff -u pear/CodeGen_PECL/PECL/Extension.php:1.58 pear/CodeGen_PECL/PECL/Extension.php:1.59 --- pear/CodeGen_PECL/PECL/Extension.php:1.58 Tue Sep 5 08:33:45 2006 +++ pear/CodeGen_PECL/PECL/Extension.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Extension.php,v 1.58 2006/09/05 08:33:45 hholzgra Exp $ + * @version CVS: $Id: Extension.php,v 1.59 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen_PECL */ @@ -540,7 +540,7 @@ // purge and create extension directory if ($dirpath !== ".") { - if (!$force && file_exists($dirpath)) { + if (!$force && file_exists($dirpath)) { return PEAR::raiseError("'$dirpath' already exists, can't create that directory (use '--force' to override)"); } else if (!@System::mkdir("-p $dirpath")) { return PEAR::raiseError("can't create '$dirpath'"); @@ -588,7 +588,7 @@ $this->writeHeaderFile(); $this->writeCodeFile(); - foreach($this->logos as $logo) { + foreach ($this->logos as $logo) { $fp = new CodeGen_Tools_FileReplacer("{$this->dirpath}/".$logo->getName()."_logos.h"); $fp->puts($logo->hCode()); $fp->close(); @@ -858,9 +858,10 @@ @mkdir("$docdir/$idName/functions"); foreach ($this->functions as $name => $function) { $functionId = strtolower(str_replace("_", "-", $name)); - $filepath = "$idName/functions/$functionId.xml"; + $filepath = "$idName/functions/$functionId.xml"; $entity = "reference.$idName.functions.$functionId"; + $function_entities[] = $entity; $entities->puts("<!ENTITY $entity SYSTEM './$filepath'>\n"); @@ -895,10 +896,9 @@ * @return string zend_module_entry code fragment */ function generateExtensionEntry() { - $name = $this->name; + $name = $this->name; $upname = strtoupper($this->name); - - $code = ""; + $code = ""; if (empty($this->otherExtensions)) { $moduleHeader = " STANDARD_MODULE_HEADER,"; @@ -1327,7 +1327,7 @@ "; if (count($this->globals)) { - $code .= " ZEND_INIT_MODULE_GLOBALS({$this->name}, php_{$this->name}_init_globals, php_{$this->name}_shutdown_globals)\n"; + $code .= " ZEND_INIT_MODULE_GLOBALS({$this->name}, php_{$this->name}_init_globals, php_{$this->name}_shutdown_globals)\n"; $need_block = true; } @@ -1464,8 +1464,7 @@ php_info_print_box_start(0); "; - foreach ($this->logos as $logo) - { + foreach ($this->logos as $logo) { $code.= $logo->phpinfoCode($this->name); } @@ -1517,7 +1516,8 @@ * @access private * @return string code snippet */ - function publicFunctionsC() { + function publicFunctionsC() + { $code = ""; foreach ($this->functions as $function) { @@ -1538,7 +1538,8 @@ * @access private * @param string directory to write to */ - function writeCodeFile() { + function writeCodeFile() + { $filename = "{$this->name}.{$this->language}"; // todo extension logic $upname = strtoupper($this->name); @@ -1614,7 +1615,8 @@ * @access private * @param string directory to write to */ - function writeConfigM4() { + function writeConfigM4() + { $upname = strtoupper($this->name); $this->addPackageFile("conf", "config.m4"); @@ -1652,7 +1654,7 @@ } $pathes = array(); - foreach($this->headers as $header) { + foreach ($this->headers as $header) { $pathes[$header->getPath()] = true; // TODO WTF??? } @@ -1674,7 +1676,7 @@ $this->terminate("global headers not bound to a --with option found and no --with option by the default name"); } - foreach($this->headers as $header) { + foreach ($this->headers as $header) { echo $header->configm4($this->name, $this->name); } } @@ -1707,7 +1709,7 @@ echo " PHP_ADD_MAKEFILE_FRAGMENT\n"; $frag = new CodeGen_Tools_FileReplacer($this->dirpath."/Makefile.frag"); - foreach($this->makefragments as $block) { + foreach ($this->makefragments as $block) { $frag->puts(CodeGen_Tools_IndentC::tabify("\n$block\n")); } $frag->close(); @@ -1737,7 +1739,8 @@ * @access private * @param string directory to write to */ - function writeConfigW32() { + function writeConfigW32() + { // TODO fragments $upname = strtoupper($this->name); @@ -1770,7 +1773,7 @@ echo $lib->configw32($this->name, $this->name); } - foreach($this->headers as $header) { + foreach ($this->headers as $header) { echo $header->configw32($this->name, $this->name); } @@ -1981,7 +1984,7 @@ $fp = new CodeGen_Tools_FileReplacer($this->dirpath."/CREDITS"); $fp->puts("{$this->name}\n"); $names = array(); - foreach($this->authors as $author) { + foreach ($this->authors as $author) { $names[] = $author->getName(); } $fp->puts(join(", ", $names) . "\n"); @@ -2031,7 +2034,7 @@ } } - foreach (array("conf", "code", "header") as $type) { + foreach (array("conf", "code", "header") as $type) { foreach ($this->packageFiles[$type] as $basename => $filepath) { $code.= " <file role='src' name='$basename'/>\n"; } @@ -2227,7 +2230,8 @@ * @access public * @param object a Test object */ - function addTest(CodeGen_PECL_Element_Test $test) { + function addTest(CodeGen_PECL_Element_Test $test) + { $name = $test->getName(); if (isset($this->testcases[$name])) { @@ -2243,7 +2247,8 @@ * * @access private */ - function writeTestFiles() { + function writeTestFiles() + { $testCount=0; @mkdir($this->dirpath."/tests"); @@ -2373,7 +2378,7 @@ */ function minPhpVersion() { - if (!empty($this->otherExtensions)) { + if (!empty($this->otherExtensions)) { return "5.1.0rc1"; } @@ -2405,7 +2410,7 @@ sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil -sgml-default-dtd-file:"'.str_repeat("../",$level).'manual.ced" +sgml-default-dtd-file:"'.str_repeat("../", $level).'manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Maintainer.php?r1=1.5&r2=1.6&diff_format=u Index: pear/CodeGen_PECL/PECL/Maintainer.php diff -u pear/CodeGen_PECL/PECL/Maintainer.php:1.5 pear/CodeGen_PECL/PECL/Maintainer.php:1.6 --- pear/CodeGen_PECL/PECL/Maintainer.php:1.5 Mon Aug 21 14:12:41 2006 +++ pear/CodeGen_PECL/PECL/Maintainer.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Maintainer.php,v 1.5 2006/08/21 14:12:41 hholzgra Exp $ + * @version CVS: $Id: Maintainer.php,v 1.6 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -39,79 +39,79 @@ class CodeGen_PECL_Maintainer extends CodeGen_Maintainer { - /** - * Generate a phpinfo line for this author - * - * @access public - * @return string phpinfo() line - */ - function phpinfoCode() - { - return " php_printf(\"<p>{$this->name} &lt;{$this->email}&gt; ({$this->role})</p>\\n\");\n"; - } + /** + * Generate a phpinfo line for this author + * + * @access public + * @return string phpinfo() line + */ + function phpinfoCode() + { + return " php_printf(\"<p>{$this->name} &lt;{$this->email}&gt; ({$this->role})</p>\\n\");\n"; + } - - /** - * Generate a package.xml <maintainer> entry for this author - * - * @access public - * @return string phpinfo() line - */ - function packageXml() - { - $code = " <maintainer>\n"; - $code.= " <user>{$this->user}</user>\n"; - $code.= " <name>{$this->name}</name>\n"; - $code.= " <email>{$this->email}</email>\n"; - $code.= " <role>{$this->role}</role>\n"; - $code.= " </maintainer>\n"; - - return $code; - } - - /** - * Generate a package.xml 2.0 <maintainer> entry for this author - * - * @access public - * @return string phpinfo() line - */ - function packageXml2() - { - $code = ""; - - $code.= " <{$this->role}>\n"; - $code.= " <name>{$this->name}</name>\n"; - $code.= " <user>{$this->user}</user>\n"; - $code.= " <email>{$this->email}</email>\n"; - $code.= " <active>yes</active>\n"; // TODO add something like this on the input side, too - $code.= " </{$this->role}>\n"; - - return $code; - } - - /** - * Comparison function - * - * We need to sort maintainers by role as package.xml 2.0 - * requires this. This callback can be used by usort() to - * sort an array of Maintainer objects - * - * @param object maintainer #1 - * @param object maintainer #2 - * @return int the usual -1, 0, 1 - */ - static function comp($m1, $m2) - { - $ranking = array("lead"=>1, "developer"=>2, "contributor"=>3, "helper"=>4); - - $r1 = $ranking[$m1->role]; - $r2 = $ranking[$m2->role]; - - if ($r1 < $r2) return -1; - if ($r1 > $r2) return 1; - return 0; - } + + /** + * Generate a package.xml <maintainer> entry for this author + * + * @access public + * @return string phpinfo() line + */ + function packageXml() + { + $code = " <maintainer>\n"; + $code.= " <user>{$this->user}</user>\n"; + $code.= " <name>{$this->name}</name>\n"; + $code.= " <email>{$this->email}</email>\n"; + $code.= " <role>{$this->role}</role>\n"; + $code.= " </maintainer>\n"; + + return $code; + } + + /** + * Generate a package.xml 2.0 <maintainer> entry for this author + * + * @access public + * @return string phpinfo() line + */ + function packageXml2() + { + $code = ""; + + $code.= " <{$this->role}>\n"; + $code.= " <name>{$this->name}</name>\n"; + $code.= " <user>{$this->user}</user>\n"; + $code.= " <email>{$this->email}</email>\n"; + $code.= " <active>yes</active>\n"; // TODO add something like this on the input side, too + $code.= " </{$this->role}>\n"; + + return $code; + } + + /** + * Comparison function + * + * We need to sort maintainers by role as package.xml 2.0 + * requires this. This callback can be used by usort() to + * sort an array of Maintainer objects + * + * @param object maintainer #1 + * @param object maintainer #2 + * @return int the usual -1, 0, 1 + */ + static function comp($m1, $m2) + { + $ranking = array("lead"=>1, "developer"=>2, "contributor"=>3, "helper"=>4); + + $r1 = $ranking[$m1->role]; + $r2 = $ranking[$m2->role]; + + if ($r1 < $r2) return -1; + if ($r1 > $r2) return 1; + return 0; + } } /* http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Release.php?r1=1.8&r2=1.9&diff_format=u Index: pear/CodeGen_PECL/PECL/Release.php diff -u pear/CodeGen_PECL/PECL/Release.php:1.8 pear/CodeGen_PECL/PECL/Release.php:1.9 --- pear/CodeGen_PECL/PECL/Release.php:1.8 Mon Aug 21 14:12:41 2006 +++ pear/CodeGen_PECL/PECL/Release.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Release.php,v 1.8 2006/08/21 14:12:41 hholzgra Exp $ + * @version CVS: $Id: Release.php,v 1.9 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -116,8 +116,7 @@ return sprintf(" php_printf(\"<p>Version %s%s (%s)</p>\\n\");\n", $this->version, $this->state, - date("Y-m-d", $this->date) - ); + date("Y-m-d", $this->date)); } } http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Dependency/Extension.php?r1=1.8&r2=1.9&diff_format=u Index: pear/CodeGen_PECL/PECL/Dependency/Extension.php diff -u pear/CodeGen_PECL/PECL/Dependency/Extension.php:1.8 pear/CodeGen_PECL/PECL/Dependency/Extension.php:1.9 --- pear/CodeGen_PECL/PECL/Dependency/Extension.php:1.8 Mon Aug 21 14:12:41 2006 +++ pear/CodeGen_PECL/PECL/Dependency/Extension.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Extension.php,v 1.8 2006/08/21 14:12:41 hholzgra Exp $ + * @version CVS: $Id: Extension.php,v 1.9 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -225,8 +225,7 @@ if (!empty($types)) { $types = (array)$types; - if (!in_array($this->type, $types)) - { + if (!in_array($this->type, $types)) { return ""; } } http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Dependency/Header.php?r1=1.8&r2=1.9&diff_format=u Index: pear/CodeGen_PECL/PECL/Dependency/Header.php diff -u pear/CodeGen_PECL/PECL/Dependency/Header.php:1.8 pear/CodeGen_PECL/PECL/Dependency/Header.php:1.9 --- pear/CodeGen_PECL/PECL/Dependency/Header.php:1.8 Mon Aug 21 14:12:41 2006 +++ pear/CodeGen_PECL/PECL/Dependency/Header.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Header.php,v 1.8 2006/08/21 14:12:41 hholzgra Exp $ + * @version CVS: $Id: Header.php,v 1.9 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen_PECL */ @@ -47,7 +47,7 @@ */ function configm4($extname, $withname) { - $upname = strtoupper($extname); + $upname = strtoupper($extname); $withUpname = strtoupper($withname); return " AC_CHECK_HEADER([{$this->name}], [], AC_MSG_ERROR('{$this->name}' header not found))\n"; } http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Dependency/With.php?r1=1.13&r2=1.14&diff_format=u Index: pear/CodeGen_PECL/PECL/Dependency/With.php diff -u pear/CodeGen_PECL/PECL/Dependency/With.php:1.13 pear/CodeGen_PECL/PECL/Dependency/With.php:1.14 --- pear/CodeGen_PECL/PECL/Dependency/With.php:1.13 Tue Aug 22 11:45:48 2006 +++ pear/CodeGen_PECL/PECL/Dependency/With.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: With.php,v 1.13 2006/08/22 11:45:48 hholzgra Exp $ + * @version CVS: $Id: With.php,v 1.14 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -371,7 +371,7 @@ PHP_{$withUpname}_DIR=\"\$PHP_$withUpname\" else AC_MSG_CHECKING(for ".$this->name." in default path) - for i in ".str_replace(":"," ",$this->getDefaults())."; do + for i in ".str_replace(":", " ", $this->getDefaults())."; do if test -r \"\$i/".$this->testfile."\"; then PHP_{$withUpname}_DIR=\$i AC_MSG_RESULT(found in \$i) @@ -387,7 +387,7 @@ } $pathes = array(); - foreach($this->getHeaders() as $header) { + foreach ($this->getHeaders() as $header) { $pathes[$header->getPath()] = true; } foreach (array_keys($pathes) as $path) { @@ -400,7 +400,7 @@ $code.= " export OLD_CPPFLAGS=\"\$CPPFLAGS\"\n"; $code.= " export CPPFLAGS=\"\$CPPFLAGS \$INCLUDES -DHAVE_$withUpname\"\n"; - foreach($this->headers as $header) { + foreach ($this->headers as $header) { $code.= $header->configm4($extName, $this->name); } http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Class.php?r1=1.30&r2=1.31&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Class.php diff -u pear/CodeGen_PECL/PECL/Element/Class.php:1.30 pear/CodeGen_PECL/PECL/Element/Class.php:1.31 --- pear/CodeGen_PECL/PECL/Element/Class.php:1.30 Tue Aug 22 13:20:21 2006 +++ pear/CodeGen_PECL/PECL/Element/Class.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Class.php,v 1.30 2006/08/22 13:20:21 hholzgra Exp $ + * @version CVS: $Id: Class.php,v 1.31 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -40,466 +40,467 @@ * @link http://pear.php.net/package/CodeGen */ - class CodeGen_PECL_Element_Class - extends CodeGen_PECL_Element - implements CodeGen_PECL_Element_ObjectInterface - { - /** - * The class name - * - * @var string - */ - protected $name = "unknown"; - - /** - * class name setter - * - * @param string Classname - */ - function setName($name) - { - if (!self::isName($name)) { - return PEAR::raiseError("'$name' is not a valid class name"); - } +class CodeGen_PECL_Element_Class + extends CodeGen_PECL_Element + implements CodeGen_PECL_Element_ObjectInterface +{ + /** + * The class name + * + * @var string + */ + protected $name = "unknown"; + + /** + * class name setter + * + * @param string Classname + */ + function setName($name) + { + if (!self::isName($name)) { + return PEAR::raiseError("'$name' is not a valid class name"); + } - $this->name = $name; + $this->name = $name; - return true; - } + return true; + } - /** - * class name getter - * - * @return string Classname - */ - function getName() - { - return $this->name; - } - - - - /** - * A short description - * - * @var string - */ - protected $summary = ""; - - /** - * Description summary setter - * - * @param string Description summary - */ - function setSummary($text) - { - $this->summary = $text; - return true; - } + /** + * class name getter + * + * @return string Classname + */ + function getName() + { + return $this->name; + } + /** + * A short description + * + * @var string + */ + protected $summary = ""; + + /** + * Description summary setter + * + * @param string Description summary + */ + function setSummary($text) + { + $this->summary = $text; + return true; + } - /** - * A long description - * - * @var string - */ - protected $description = ""; - - /** - * Class description setter - * - * @param string Class description - */ - function setDescription($text) - { - $this->description = $text; - return true; - } - - - - /** - * Documentation - * - * TODO: isn't this in Element base class already? - * - * @var string - */ - protected $documentation = ""; - - /** - * Class documentation setter - * - * @param string Class documentation - */ - function setDocumentation($text) { - $this->documentation = $text; - } - - - - /** - * Extents which class? - * - * @var string - */ - protected $extends = ""; - - /** - * Set parent class that this class inherits from - * - * @param string parent class name - */ - function setExtends($parent) - { - if (!self::isName($parent)) { - return PEAR::raiseError("'$parent' is not a valid parent class name"); - } - - $this->extends = $parent; - } - - - /** - * Implemented Interfaces - * - * @var array - */ - protected $implements = array(); - - /** - * Add an interface that this class implements - * - * @param string interface name - */ - function addInterface($interface) - { - if (!self::isName($interface)) { - return PEAR::raiseError("'$interface' is not a valid interface name"); - } - - if (isset($this->implements[$interface])) { - return PEAR::raiseError("interface '$interface' added twice"); - } - $this->implements[$interface] = $interface; - } - /** - * Properties - * - * @var array - */ - protected $properties = array(); - - /** - * Add a class property - * - * @param object a class property object - */ - function addProperty(CodeGen_PECL_Element_Property $property) - { - $name = $property->getName(); + /** + * A long description + * + * @var string + */ + protected $description = ""; + + /** + * Class description setter + * + * @param string Class description + */ + function setDescription($text) + { + $this->description = $text; + return true; + } - if (isset($this->properties[$name])) { - return PEAR::raiseError("property '$name' already exists"); - } - $this->properties[$name] = $property; - } + + /** + * Documentation + * + * TODO: isn't this in Element base class already? + * + * @var string + */ + protected $documentation = ""; + + /** + * Class documentation setter + * + * @param string Class documentation + */ + function setDocumentation($text) + { + $this->documentation = $text; + } + - /** - * Constants - * - * @var array - */ - protected $constants = array(); - - /** - * Add a constant to a class - * - * @param object a class constant object - */ - function addConstant(CodeGen_PECL_Element_ClassConstant $constant) - { - $name = $constant->getName(); + /** + * Extents which class? + * + * @var string + */ + protected $extends = ""; + + /** + * Set parent class that this class inherits from + * + * @param string parent class name + */ + function setExtends($parent) + { + if (!self::isName($parent)) { + return PEAR::raiseError("'$parent' is not a valid parent class name"); + } - if (isset($this->constants[$name])) { - return PEAR::raiseError("constant '$name' already exists"); - } + $this->extends = $parent; + } + - $this->constants[$name] = $constant; + /** + * Implemented Interfaces + * + * @var array + */ + protected $implements = array(); + + /** + * Add an interface that this class implements + * + * @param string interface name + */ + function addInterface($interface) + { + if (!self::isName($interface)) { + return PEAR::raiseError("'$interface' is not a valid interface name"); + } + + if (isset($this->implements[$interface])) { + return PEAR::raiseError("interface '$interface' added twice"); } - - /** - * Member Functions - * - * @var array - */ - protected $methods = array(); - - /** - * Add a method definition to the class - * - * @param object class method object - */ - function addMethod(CodeGen_PECL_Element_Method $method) - { - $name = $method->getName(); + $this->implements[$interface] = $interface; + } - if (isset($this->functions[$name])) { - return PEAR::raiseError("method '$name' already exists"); - } - $this->methods[$name] = $method; + /** + * Properties + * + * @var array + */ + protected $properties = array(); + + /** + * Add a class property + * + * @param object a class property object + */ + function addProperty(CodeGen_PECL_Element_Property $property) + { + $name = $property->getName(); - return true; + if (isset($this->properties[$name])) { + return PEAR::raiseError("property '$name' already exists"); } + $this->properties[$name] = $property; + } + + + /** + * Constants + * + * @var array + */ + protected $constants = array(); + + /** + * Add a constant to a class + * + * @param object a class constant object + */ + function addConstant(CodeGen_PECL_Element_ClassConstant $constant) + { + $name = $constant->getName(); + if (isset($this->constants[$name])) { + return PEAR::raiseError("constant '$name' already exists"); + } - /** - * Is this an abstract class? - * - * @var bool - */ - protected $isAbstract = false; + $this->constants[$name] = $constant; + } - /** - * Make class abstract - */ - function isAbstract() - { - $this->isAbstract = true; + + /** + * Member Functions + * + * @var array + */ + protected $methods = array(); + + /** + * Add a method definition to the class + * + * @param object class method object + */ + function addMethod(CodeGen_PECL_Element_Method $method) + { + $name = $method->getName(); + + if (isset($this->functions[$name])) { + return PEAR::raiseError("method '$name' already exists"); } + $this->methods[$name] = $method; + return true; + } - /** - * Is this class final? - * - * @var bool - */ - protected $isFinal = false; - /** - * Make class final - */ - function isFinal() - { - $this->isFinal = true; - } + /** + * Is this an abstract class? + * + * @var bool + */ + protected $isAbstract = false; + + /** + * Make class abstract + */ + function isAbstract() + { + $this->isAbstract = true; + } + + + + /** + * Is this class final? + * + * @var bool + */ + protected $isFinal = false; + + /** + * Make class final + */ + function isFinal() + { + $this->isFinal = true; + } - /** - * Is this an interface? - * - * @var bool - */ - protected $isInterface = false; - /** - * Make class an interface - */ - function isInterface() - { - // TODO: check for already added non-abstract stuff + /** + * Is this an interface? + * + * @var bool + */ + protected $isInterface = false; + + /** + * Make class an interface + */ + function isInterface() + { + // TODO: check for already added non-abstract stuff - $this->isInterface = true; - } + $this->isInterface = true; + } - /** - * Class payload data type - * - * @var string C type name class payload data - */ - protected $payloadType = ""; - - /** - * Payload type setter - * - * @param string - */ - function setPayloadType($type) - { - // TODO check - $this->payloadType = $type; - } - - /** - * Payload type getter - * - * @return string - */ - function getPayloadType() - { - return $this->payloadType; - } - - - /** - * Allocate storage space for payload data? - * - * @var bool - */ - protected $payloadAlloc = true; - - /** - * Payload alloc setter - * - * @param string - */ - function setPayloadAlloc($alloc) - { - $this->payloadAlloc = (bool)$alloc; - } - - /** - * Payload init code snippet - * - * @param string - */ - protected $payloadCtor = ""; - - /** - * Payload init code setter - * - * @param string code snippet - */ - function setPayloadCtor($code) - { - $this->payloadCtor = $code; - } - - /** - * Payload init code getter - * - * @return string code snippet - */ - function getPayloadCtor($extension) - { - $code = ""; + /** + * Class payload data type + * + * @var string C type name class payload data + */ + protected $payloadType = ""; + + /** + * Payload type setter + * + * @param string + */ + function setPayloadType($type) + { + // TODO check + $this->payloadType = $type; + } - if ($this->payloadAlloc) { - $code.= " payload->data = ({$this->payloadType} *)malloc(sizeof({$this->payloadType}));\n"; - } + /** + * Payload type getter + * + * @return string + */ + function getPayloadType() + { + return $this->payloadType; + } - $code .= $extension->codegen->varblock($this->payloadCtor); - return $code; + /** + * Allocate storage space for payload data? + * + * @var bool + */ + protected $payloadAlloc = true; + + /** + * Payload alloc setter + * + * @param string + */ + function setPayloadAlloc($alloc) + { + $this->payloadAlloc = (bool)$alloc; + } + + /** + * Payload init code snippet + * + * @param string + */ + protected $payloadCtor = ""; + + /** + * Payload init code setter + * + * @param string code snippet + */ + function setPayloadCtor($code) + { + $this->payloadCtor = $code; + } + + /** + * Payload init code getter + * + * @return string code snippet + */ + function getPayloadCtor($extension) + { + $code = ""; + + if ($this->payloadAlloc) { + $code.= " payload->data = ({$this->payloadType} *)malloc(sizeof({$this->payloadType}));\n"; } + $code .= $extension->codegen->varblock($this->payloadCtor); - /** - * Payload dtor code snippet - * - * @param string - */ - protected $payloadDtor = ""; - - /** - * Payload dtor code setter - * - * @param string code snippet - */ - function setPayloadDtor($code) - { - $this->payloadDtor = $code; - } - - /** - * Payload dtor code getter - * - * @return string code snippet - */ - function getPayloadDtor($extension) - { - $code = $extension->codegen->varblock($this->payloadDtor); + return $code; + } - if ($this->payloadAlloc) { - $code.= " free(payload->data);\n"; - } - return $code; + /** + * Payload dtor code snippet + * + * @param string + */ + protected $payloadDtor = ""; + + /** + * Payload dtor code setter + * + * @param string code snippet + */ + function setPayloadDtor($code) + { + $this->payloadDtor = $code; + } + + /** + * Payload dtor code getter + * + * @return string code snippet + */ + function getPayloadDtor($extension) + { + $code = $extension->codegen->varblock($this->payloadDtor); + + if ($this->payloadAlloc) { + $code.= " free(payload->data);\n"; } - /** - * Create C header entry for clas - * - * @access public - * @param class Extension extension the function is part of - * @return string C header code snippet - */ - function hCode($extension) - { - $code = ""; - - if ($this->payloadType) { - $upname = strtoupper($this->name); - echo " + + return $code; + } + /** + * Create C header entry for clas + * + * @access public + * @param class Extension extension the function is part of + * @return string C header code snippet + */ + function hCode($extension) + { + $code = ""; + + if ($this->payloadType) { + $upname = strtoupper($this->name); + echo " typedef struct _php_obj_{$this->name} { zend_object obj; {$this->payloadType} *data; } php_obj_{$this->name}; "; - } - - foreach ($this->methods as $method) { - $code.= $method->hCode($extension); - } + } - if ($code) { - $code = $this->ifConditionStart() . $code . $this->ifConditionEnd(); - } + foreach ($this->methods as $method) { + $code.= $method->hCode($extension); + } - return $code; + if ($code) { + $code = $this->ifConditionStart() . $code . $this->ifConditionEnd(); } + return $code; + } - /** - * Generate global scope code - * - * @access public - * @return string - */ - function globalCode($extension) - { - $upname = strtoupper($this->name); - ob_start(); + /** + * Generate global scope code + * + * @access public + * @return string + */ + function globalCode($extension) + { + $upname = strtoupper($this->name); + + ob_start(); - echo "/* {{{ Class {$this->name} */\n\n"; + echo "/* {{{ Class {$this->name} */\n\n"; - echo $this->ifConditionStart(); + echo $this->ifConditionStart(); - echo "static zend_class_entry * {$this->name}_ce_ptr = NULL;\n\n"; + echo "static zend_class_entry * {$this->name}_ce_ptr = NULL;\n\n"; - echo "/* {{{ Methods */\n\n"; - foreach ($this->methods as $method) { - echo $method->cCode($extension); - echo "\n"; - } + echo "/* {{{ Methods */\n\n"; + foreach ($this->methods as $method) { + echo $method->cCode($extension); + echo "\n"; + } - echo "static zend_function_entry {$this->name}_methods[] = {\n"; + echo "static zend_function_entry {$this->name}_methods[] = {\n"; - foreach ($this->methods as $method) { - echo " ".$method->methodEntry()."\n"; - } + foreach ($this->methods as $method) { + echo " ".$method->methodEntry()."\n"; + } - echo " { NULL, NULL, NULL }\n"; - echo "};\n\n"; + echo " { NULL, NULL, NULL }\n"; + echo "};\n\n"; - echo "/* }}} Methods */\n\n"; + echo "/* }}} Methods */\n\n"; - if ($this->payloadType) { - echo " + if ($this->payloadType) { + echo " static zend_object_handlers {$this->name}_obj_handlers; static void {$this->name}_obj_free(void *object TSRMLS_DC) @@ -528,142 +529,141 @@ } "; - } + } - echo "static void class_init_{$this->name}(void)\n{\n"; + echo "static void class_init_{$this->name}(void)\n{\n"; - echo " zend_class_entry ce;\n\n"; + echo " zend_class_entry ce;\n\n"; - echo " INIT_CLASS_ENTRY(ce, \"{$this->name}\", {$this->name}_methods);\n"; + echo " INIT_CLASS_ENTRY(ce, \"{$this->name}\", {$this->name}_methods);\n"; - if ($this->payloadType) { - echo " ce.create_object = {$this->name}_obj_create;\n"; - } + if ($this->payloadType) { + echo " ce.create_object = {$this->name}_obj_create;\n"; + } - if ($this->extends) { - echo " {$this->name}_ce_ptr = zend_register_internal_class_ex(&ce, NULL, \"{$this->extends}\" TSRMLS_CC);\n"; - } else { - echo " {$this->name}_ce_ptr = zend_register_internal_class(&ce);\n"; - } + if ($this->extends) { + echo " {$this->name}_ce_ptr = zend_register_internal_class_ex(&ce, NULL, \"{$this->extends}\" TSRMLS_CC);\n"; + } else { + echo " {$this->name}_ce_ptr = zend_register_internal_class(&ce);\n"; + } - if ($this->payloadType) { - echo " memcpy(&{$this->name}_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));\n"; - echo " {$this->name}_obj_handlers.clone_obj = NULL;\n"; - } + if ($this->payloadType) { + echo " memcpy(&{$this->name}_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));\n"; + echo " {$this->name}_obj_handlers.clone_obj = NULL;\n"; + } - if ($this->isFinal) { - echo " {$this->name}_ce_ptr->ce_flags |= ZEND_ACC_FINAL_CLASS;\n"; - } + if ($this->isFinal) { + echo " {$this->name}_ce_ptr->ce_flags |= ZEND_ACC_FINAL_CLASS;\n"; + } - if ($this->isAbstract) { - echo " {$this->name}_ce_ptr->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;\n"; - } + if ($this->isAbstract) { + echo " {$this->name}_ce_ptr->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;\n"; + } - if (!empty($this->properties)) { - echo "\n /* {{{ Property registration */\n\n"; - foreach ($this->properties as $property) { - echo $property->minitCode($this->name."_ce_ptr"); - } - echo " /* }}} Property registration */\n\n"; + if (!empty($this->properties)) { + echo "\n /* {{{ Property registration */\n\n"; + foreach ($this->properties as $property) { + echo $property->minitCode($this->name."_ce_ptr"); } + echo " /* }}} Property registration */\n\n"; + } - if (!empty($this->constants)) { - echo "\n"; - echo CodeGen_PECL_Element_ClassConstant::minitHeader(); - foreach ($this->constants as $constant) { - echo $constant->minitCode($this->name."_ce_ptr"); - } - echo CodeGen_PECL_Element_ClassConstant::minitFooter(); + if (!empty($this->constants)) { + echo "\n"; + echo CodeGen_PECL_Element_ClassConstant::minitHeader(); + foreach ($this->constants as $constant) { + echo $constant->minitCode($this->name."_ce_ptr"); } + echo CodeGen_PECL_Element_ClassConstant::minitFooter(); + } - if (count($this->implements)) { - ob_start(); + if (count($this->implements)) { + ob_start(); - echo "zend_class_entry **tmp;\n"; + echo "zend_class_entry **tmp;\n"; - $interfaces = array(); - foreach ($this->implements as $interface) { - echo sprintf("if (SUCCESS == zend_hash_find(CG(class_table), \"%s\", %d, (void **)&tmp)) {\n", - strtolower($interface), strlen($interface) + 1); - echo " zend_class_implements({$this->name}_ce_ptr TSRMLS_CC, 1, *tmp);\n"; - echo "} else {\n"; - echo " php_error(E_WARNING, \"Couldn't find interface '$interface' while setting up class '{$this->name}', skipped\");\n"; - echo "}\n"; - } - - echo $extension->codegen->varblock(ob_get_clean()); + $interfaces = array(); + foreach ($this->implements as $interface) { + echo sprintf("if (SUCCESS == zend_hash_find(CG(class_table), \"%s\", %d, (void **)&tmp)) {\n", + strtolower($interface), strlen($interface) + 1); + echo " zend_class_implements({$this->name}_ce_ptr TSRMLS_CC, 1, *tmp);\n"; + echo "} else {\n"; + echo " php_error(E_WARNING, \"Couldn't find interface '$interface' while setting up class '{$this->name}', skipped\");\n"; + echo "}\n"; } + + echo $extension->codegen->varblock(ob_get_clean()); + } - echo "}\n\n"; + echo "}\n\n"; - echo $this->ifConditionEnd(); + echo $this->ifConditionEnd(); - echo "/* }}} Class {$this->name} */\n\n"; + echo "/* }}} Class {$this->name} */\n\n"; - return ob_get_clean(); - } + return ob_get_clean(); + } - /** - * MINIT code fragment - * - * @access public - * @return string - */ - function minitCode($extension) - { - return $this->ifConditionStart() - . "class_init_{$this->name}();\n" - . $this->ifConditionEnd(); - } + /** + * MINIT code fragment + * + * @access public + * @return string + */ + function minitCode($extension) + { + return $this->ifConditionStart() + . "class_init_{$this->name}();\n" + . $this->ifConditionEnd(); + } - /** - * DocBook documentation fragment - * - * @access public - * @return string - */ - function docEntry($base) - { - $xml = ""; + /** + * DocBook documentation fragment + * + * @access public + * @return string + */ + function docEntry($base) + { + $xml = ""; - return $xml; - } + return $xml; + } - /** - * Write method test cases - * - * @param object Extension to write tests for - */ - function writeTests(CodeGen_PECL_Extension $extension) - { - foreach ($this->methods as $method) { - $method->writeTest($extension); - } + /** + * Write method test cases + * + * @param object Extension to write tests for + */ + function writeTests(CodeGen_PECL_Extension $extension) + { + foreach ($this->methods as $method) { + $method->writeTest($extension); } + } - /** - * Return function alias entries for all methods - * - */ - function functionAliasEntries() - { - $code = ""; - - foreach($this->methods as $method) - { - $code.= $method->functionAliasEntry(); - } + /** + * Return function alias entries for all methods + * + */ + function functionAliasEntries() + { + $code = ""; + + foreach ($this->methods as $method) { + $code.= $method->functionAliasEntry(); + } - if ($code) { - $code = $this->ifConditionStart() . $code . $this->ifConditionEnd(); - } - - return $code; + if ($code) { + $code = $this->ifConditionStart() . $code . $this->ifConditionEnd(); } - + + return $code; } + +} ?> http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/ClassConstant.php?r1=1.5&r2=1.6&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/ClassConstant.php diff -u pear/CodeGen_PECL/PECL/Element/ClassConstant.php:1.5 pear/CodeGen_PECL/PECL/Element/ClassConstant.php:1.6 --- pear/CodeGen_PECL/PECL/Element/ClassConstant.php:1.5 Tue Aug 22 13:51:54 2006 +++ pear/CodeGen_PECL/PECL/Element/ClassConstant.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: ClassConstant.php,v 1.5 2006/08/22 13:51:54 hholzgra Exp $ + * @version CVS: $Id: ClassConstant.php,v 1.6 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -36,201 +36,209 @@ * @link http://pear.php.net/package/CodeGen */ - class CodeGen_PECL_Element_ClassConstant - extends CodeGen_PECL_Element +class CodeGen_PECL_Element_ClassConstant + extends CodeGen_PECL_Element +{ + /** + * The constants name + * + * @access private + * @var string + */ + protected $name; + + /** + * The constants PHP data type + * + * @access private + * @var string + */ + protected $type = "string"; + + /** + * The constants value + * + * @access private + * @var string + */ + protected $value; + + /** + * The constants description text + * + * @access private + * @var string + */ + protected $desc; + + + /** + * Set constant name + * + * @access public + * @param string the name + * @return bool true on success + */ + function setName($name) { - /** - * The constants name - * - * @access private - * @var string - */ - protected $name; - - /** - * The constants PHP data type - * - * @access private - * @var string - */ - protected $type = "string"; - - /** - * The constants value - * - * @access private - * @var string - */ - protected $value; - - /** - * The constants description text - * - * @access private - * @var string - */ - protected $desc; - - - /** - * Set constant name - * - * @access public - * @param string the name - * @return bool true on success - */ - function setName($name) - { - if (!self::isName($name)) { - return PEAR::raiseError("'$name'is not a valid constant name"); - } - - if (self::isKeyword($name)) { - return PEAR::raiseError("'$name' is a reserved word which is not valid for constant names"); - } + if (!self::isName($name)) { + return PEAR::raiseError("'$name'is not a valid constant name"); + } + + if (self::isKeyword($name)) { + return PEAR::raiseError("'$name' is a reserved word which is not valid for constant names"); + } - $this->name = $name; + $this->name = $name; - return true; - } + return true; + } - /** - * Get constant name - * - * @access public - * @return string - */ - function getName() - { - return $this->name; - } + /** + * Get constant name + * + * @access public + * @return string + */ + function getName() + { + return $this->name; + } - /** - * Set constant type - * - * @access public - * @param string the type - * @return bool true on success - */ - function setType($type) - { - if (!in_array($type, array('int', 'float', 'string'))) { - return PEAR::raiseError("'$type' is not a valid constant type, only int, float and string"); - } + /** + * Set constant type + * + * @access public + * @param string the type + * @return bool true on success + */ + function setType($type) + { + if (!in_array($type, array('int', 'float', 'string'))) { + return PEAR::raiseError("'$type' is not a valid constant type, only int, float and string"); + } - $this->type = $type; + $this->type = $type; - return true; - } + return true; + } - /** - * Set constant value - * - * @access public - * @param string the value - * @return bool true on success - */ - function setValue($value) - { - $this->value = $value; - - if ($this->value == $this->name) { - $this->deinfe = false; - } + /** + * Set constant value + * + * @access public + * @param string the value + * @return bool true on success + */ + function setValue($value) + { + $this->value = $value; - return true; + if ($this->value == $this->name) { + $this->deinfe = false; } - /** - * Set constant descriptive text - * - * @access public - * @param string the name - * @return bool true on success - */ - function setDesc($desc) - { - $this->desc = $desc; + return true; + } - return true; - } + /** + * Set constant descriptive text + * + * @access public + * @param string the name + * @return bool true on success + */ + function setDesc($desc) + { + $this->desc = $desc; + return true; + } - /** - * MINIT code fragment - * - * @access public - * @return string - */ - function minitCode($classptr) { - switch ($this->type) { - case "string": - $value = 'ZVAL_STRING(tmp, "'.$this->value.'", 1);'; - break; - case "int": - $value = 'ZVAL_LONG(tmp, '.$this->value.');'; - break; - case "float": - $value = 'ZVAL_DOUBLE(tmp, '.$this->value.');'; - break; - default: - return ""; - } - $key = '"'.$this->name.'"'; - $key_len = strlen($this->name) + 1; + /** + * MINIT code fragment + * + * @access public + * @return string + */ + function minitCode($classptr) + { + switch ($this->type) { + case "string": + $value = 'ZVAL_STRING(tmp, "'.$this->value.'", 1);'; + break; + case "int": + $value = 'ZVAL_LONG(tmp, '.$this->value.');'; + break; + case "float": + $value = 'ZVAL_DOUBLE(tmp, '.$this->value.');'; + break; + default: + return ""; + } + $key = '"'.$this->name.'"'; + $key_len = strlen($this->name) + 1; - $code = $this->ifConditionStart(); + + $code = $this->ifConditionStart(); - $code.= " + $code.= " tmp = (zval *) malloc(sizeof(zval)); INIT_PZVAL(tmp); $value zend_symtable_update(&({$classptr}->constants_table), $key, $key_len, (void *) &tmp, sizeof(zval *), NULL); "; - $code.= $this->ifConditionEnd(); + $code.= $this->ifConditionEnd(); - return $code; - } + return $code; + } - /** - * MINIT code header - * - * @access public - * @return string - */ - static function minitHeader() - { - ob_start(); - - echo " /* {{{ Constant registration */\n\n"; - echo " do {\n"; - echo " zval *tmp, *val;\n"; + /** + * MINIT code header + * + * @access public + * @return string + */ + static function minitHeader() + { + ob_start(); - return ob_get_clean(); - } + echo " /* {{{ Constant registration */\n\n"; + echo " do {\n"; + echo " zval *tmp, *val;\n"; + return ob_get_clean(); + } - /** - * MINIT code footer - * - * @access public - * @return string - */ - static function minitFooter() - { - ob_start(); - echo " } while(0);\n\n"; - echo " /* } Constant registration */\n\n"; + /** + * MINIT code footer + * + * @access public + * @return string + */ + static function minitFooter() + { + ob_start(); - return ob_get_clean(); - } + echo " } while(0);\n\n"; + echo " /* } Constant registration */\n\n"; + return ob_get_clean(); } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode:nil + * End: + */ ?> http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Constant.php?r1=1.10&r2=1.11&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Constant.php diff -u pear/CodeGen_PECL/PECL/Element/Constant.php:1.10 pear/CodeGen_PECL/PECL/Element/Constant.php:1.11 --- pear/CodeGen_PECL/PECL/Element/Constant.php:1.10 Tue Sep 5 08:32:58 2006 +++ pear/CodeGen_PECL/PECL/Element/Constant.php Mon Oct 9 21:27:04 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Constant.php,v 1.10 2006/09/05 08:32:58 hholzgra Exp $ + * @version CVS: $Id: Constant.php,v 1.11 2006/10/09 21:27:04 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -36,270 +36,270 @@ * @link http://pear.php.net/package/CodeGen */ - class CodeGen_PECL_Element_Constant - extends CodeGen_PECL_Element +class CodeGen_PECL_Element_Constant + extends CodeGen_PECL_Element +{ + /** + * The constants name + * + * @access private + * @var string + */ + protected $name; + + /** + * The constants PHP data type + * + * @access private + * @var string + */ + protected $type = "string"; + + /** + * The constants value + * + * @access private + * @var string + */ + protected $value; + + /** + * The constants description text + * + * @access private + * @var string + */ + protected $desc; + + + /** + * Create a C #define for this constant + * + * @access private + * @var bool + */ + protected $define = false; + + /** + * Resource group + * + * @var string + */ + protected $group = "default"; + + /** + * Set constant name + * + * @access public + * @param string the name + * @return bool true on success + */ + function setName($name) { - /** - * The constants name - * - * @access private - * @var string - */ - protected $name; - - /** - * The constants PHP data type - * - * @access private - * @var string - */ - protected $type = "string"; - - /** - * The constants value - * - * @access private - * @var string - */ - protected $value; - - /** - * The constants description text - * - * @access private - * @var string - */ - protected $desc; - - - /** - * Create a C #define for this constant - * - * @access private - * @var bool - */ - protected $define = false; - - /** - * Resource group - * - * @var string - */ - protected $group = "default"; - - /** - * Set constant name - * - * @access public - * @param string the name - * @return bool true on success - */ - function setName($name) - { - if (!self::isName($name)) { - return PEAR::raiseError("'$name'is not a valid constant name"); - } - - if (self::isKeyword($name)) { - return PEAR::raiseError("'$name' is a reserved word which is not valid for constant names"); - } + if (!self::isName($name)) { + return PEAR::raiseError("'$name'is not a valid constant name"); + } + + if (self::isKeyword($name)) { + return PEAR::raiseError("'$name' is a reserved word which is not valid for constant names"); + } - $this->name = $name; + $this->name = $name; - return true; - } + return true; + } - /** - * Get constant name - * - * @access public - * @param string - */ - function getName() - { - return $this->name; - } + /** + * Get constant name + * + * @access public + * @param string + */ + function getName() + { + return $this->name; + } - /** - * Set constant type - * - * @access public - * @param string the type - * @return bool true on success - */ - function setType($type) - { - if (!in_array($type, array('int', 'float', 'string'))) { - return PEAR::raiseError("'$type' is not a valid constant type, only int, float and string"); - } + /** + * Set constant type + * + * @access public + * @param string the type + * @return bool true on success + */ + function setType($type) + { + if (!in_array($type, array('int', 'float', 'string'))) { + return PEAR::raiseError("'$type' is not a valid constant type, only int, float and string"); + } - $this->type = $type; + $this->type = $type; - return true; - } + return true; + } - /** - * Set constant value - * - * @access public - * @param string the value - * @return bool true on success - */ - function setValue($value) - { - $this->value = $value; - - if ($this->value == $this->name) { - $this->deinfe = false; - } + /** + * Set constant value + * + * @access public + * @param string the value + * @return bool true on success + */ + function setValue($value) + { + $this->value = $value; - return true; + if ($this->value == $this->name) { + $this->deinfe = false; } - /** - * Get constant value - * - * @access public - * @return string the value - */ - function getValue() - { - return $this->value; - } + return true; + } - /** - * Set constant descriptive text - * - * @access public - * @param string the name - * @return bool true on success - */ - function setDesc($desc) - { - $this->desc = $desc; + /** + * Get constant value + * + * @access public + * @return string the value + */ + function getValue() + { + return $this->value; + } - return true; - } + /** + * Set constant descriptive text + * + * @access public + * @param string the name + * @return bool true on success + */ + function setDesc($desc) + { + $this->desc = $desc; - /** - * Set group this constant belongs to - * - * @access public - * @param string group name - * @return bool true on success - */ - function setGroup($group) - { - $this->group = $group; + return true; + } - return true; - } + /** + * Set group this constant belongs to + * + * @access public + * @param string group name + * @return bool true on success + */ + function setGroup($group) + { + $this->group = $group; - /** - * Get group thsi constant belongs to - * - * @access public - * @return string group name - */ - function getGroup() - { - return $this->group; - } + return true; + } - /** - * Set define flag - * - * @access public - * @param string the value - * @return bool true on success - */ - function setDefine($value) - { - if (is_bool($value)) { - $this->define = $value; - return true; - } else if (in_array($value, array("yes", "no"), true)) { - $this->define = ($value === 'yes'); - return true; - } - - return PEAR::raiseError("'define' attribute has to be 'yes' or 'no', '$value' given"); + /** + * Get group thsi constant belongs to + * + * @access public + * @return string group name + */ + function getGroup() + { + return $this->group; + } + + /** + * Set define flag + * + * @access public + * @param string the value + * @return bool true on success + */ + function setDefine($value) + { + if (is_bool($value)) { + $this->define = $value; + return true; + } else if (in_array($value, array("yes", "no"), true)) { + $this->define = ($value === 'yes'); + return true; } + + return PEAR::raiseError("'define' attribute has to be 'yes' or 'no', '$value' given"); + } - /** - * Create C code snippet to register this constant - * - * @access public - * @param class Extension extension we are owned by - * @return sting C code snippet - */ - function cCode($extension) - { - $code = $this->ifConditionStart(); - - switch ($this->type) { - case "int": - $code.= "REGISTER_LONG_CONSTANT(\"{$this->name}\", {$this->value}, CONST_PERSISTENT | CONST_CS);\n"; - break; - - case "float": - $code.= "REGISTER_DOUBLE_CONSTANT(\"{$this->name}\", {$this->value}, CONST_PERSISTENT | CONST_CS);\n"; - break; - - case "string": - $code.= "REGISTER_STRINGL_CONSTANT(\"{$this->name}\", \"{$this->value}\", ".strlen($this->value).", CONST_PERSISTENT | CONST_CS);\n"; - break; - } + /** + * Create C code snippet to register this constant + * + * @access public + * @param class Extension extension we are owned by + * @return sting C code snippet + */ + function cCode($extension) + { + $code = $this->ifConditionStart(); + + switch ($this->type) { + case "int": + $code.= "REGISTER_LONG_CONSTANT(\"{$this->name}\", {$this->value}, CONST_PERSISTENT | CONST_CS);\n"; + break; - $code.= $this->ifConditionEnd(); + case "float": + $code.= "REGISTER_DOUBLE_CONSTANT(\"{$this->name}\", {$this->value}, CONST_PERSISTENT | CONST_CS);\n"; + break; - return $code; + case "string": + $code.= "REGISTER_STRINGL_CONSTANT(\"{$this->name}\", \"{$this->value}\", ".strlen($this->value).", CONST_PERSISTENT | CONST_CS);\n"; + break; } - /** - * Create C header snippet to register this constant - * - * @access public - * @param class Extension extension we are owned by - * @return sting C code snippet - */ - function hCode($extension) - { - if (!$this->define) { - return ""; - } + $code.= $this->ifConditionEnd(); - $code = $this->ifConditionStart(); + return $code; + } + + /** + * Create C header snippet to register this constant + * + * @access public + * @param class Extension extension we are owned by + * @return sting C code snippet + */ + function hCode($extension) + { + if (!$this->define) { + return ""; + } + + $code = $this->ifConditionStart(); - switch ($this->type) { - case "int": - case "float": - $code.= "#define {$this->name} {$this->value}\n"; - break; - case "string": - $code.= "#define {$this->name} \"$value\"\n"; - break; - } + switch ($this->type) { + case "int": + case "float": + $code.= "#define {$this->name} {$this->value}\n"; + break; + case "string": + $code.= "#define {$this->name} \"$value\"\n"; + break; + } - $this->ifConditionEnd(); + $this->ifConditionEnd(); - return $code; - } + return $code; + } - /** - * Generate DocBook XML section block header - * - * @access public - * @param string Extension name - * @return string DocBook XML snippet - */ - static function docHeader($name) - { - return -" <table> + /** + * Generate DocBook XML section block header + * + * @access public + * @param string Extension name + * @return string DocBook XML snippet + */ + static function docHeader($name) + { + return + " <table> <title>$name constants</title> <tgroup cols='3'> <thead> @@ -311,43 +311,43 @@ </thead> <tbody> "; - } + } - /** - * Generate DocBook XML entry for this constant - * - * @access public - * @param string Extension name (currently unused) - * @return string DocBook XML snippet - */ - function docEntry($base) - { - return " + /** + * Generate DocBook XML entry for this constant + * + * @access public + * @param string Extension name (currently unused) + * @return string DocBook XML snippet + */ + function docEntry($base) + { + return " <row> <entry> - <constant id='constant".strtolower(str_replace("_","-",$this->name))."'>{$this->name}</constant> + <constant id='constant".strtolower(str_replace("_", "-", $this->name))."'>{$this->name}</constant> (<link linkend='language.types.integer'>integer</link>) </entry> <entry>{$this->value}</entry> <entry>{$this->desc}</entry> </row>\n\n"; - } + } - /** - * Generate DocBook XML section block footer - * - * @access public - * @param string Extension name - * @return string DocBook XML snippet - */ - static function docFooter() - { - return -" </tbody> + /** + * Generate DocBook XML section block footer + * + * @access public + * @param string Extension name + * @return string DocBook XML snippet + */ + static function docFooter() + { + return + " </tbody> </tgroup> </table> "; - } } +} ?> http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Global.php?r1=1.7&r2=1.8&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Global.php diff -u pear/CodeGen_PECL/PECL/Element/Global.php:1.7 pear/CodeGen_PECL/PECL/Element/Global.php:1.8 --- pear/CodeGen_PECL/PECL/Element/Global.php:1.7 Tue Aug 22 13:04:37 2006 +++ pear/CodeGen_PECL/PECL/Element/Global.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Global.php,v 1.7 2006/08/22 13:04:37 hholzgra Exp $ + * @version CVS: $Id: Global.php,v 1.8 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -164,11 +164,11 @@ so we check for a sequence of valid names for now TODO: check for either simple type, struct/class or single word (typedef) */ - $array = explode(" ", str_replace('*',' ',$type)); + $array = explode(" ", str_replace('*', ' ', $type)); foreach ($array as $name) { if (empty($name)) continue; // TODO :: should only be allowed for C++, not C extensions - if (!$this->isName(str_replace("::","", $name))) return false; + if (!$this->isName(str_replace("::", "", $name))) return false; } return true; } @@ -245,7 +245,7 @@ static function hCodeHeader($name) { return "ZEND_BEGIN_MODULE_GLOBALS({$name})\n"; - } + } /** * Generate declaration for this global variable in header file http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Ini.php?r1=1.5&r2=1.6&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Ini.php diff -u pear/CodeGen_PECL/PECL/Element/Ini.php:1.5 pear/CodeGen_PECL/PECL/Element/Ini.php:1.6 --- pear/CodeGen_PECL/PECL/Element/Ini.php:1.5 Tue Aug 22 13:04:37 2006 +++ pear/CodeGen_PECL/PECL/Element/Ini.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Ini.php,v 1.5 2006/08/22 13:04:37 hholzgra Exp $ + * @version CVS: $Id: Ini.php,v 1.6 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -35,269 +35,269 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/CodeGen */ - class CodeGen_PECL_Element_Ini +class CodeGen_PECL_Element_Ini extends CodeGen_PECL_Element - { - // TODO this should be a subclass of CodeGen_PECL_Element_Global ? +{ + // TODO this should be a subclass of CodeGen_PECL_Element_Global ? - /** - * Directive name - * - * @access private - * @var string - */ - protected $name; + /** + * Directive name + * + * @access private + * @var string + */ + protected $name; - /** - * Set method for name - * - * @access public - * @var string directive name - */ - function setName($name) - { - if (!self::isName($name)) { - return PEAR::raiseError("'$name' is not a valid php.ini directive name"); - } + /** + * Set method for name + * + * @access public + * @var string directive name + */ + function setName($name) + { + if (!self::isName($name)) { + return PEAR::raiseError("'$name' is not a valid php.ini directive name"); + } - $this->name = $name; + $this->name = $name; - return true; - } + return true; + } + + /** + * Get method for name + * + * @access public + * @return string + */ + function getName() + { + return $this->name; + } + + + + + /** + * Directive data type + * + * @access private + * @var string + */ + protected $type; + + /** + * Set method for data type + * + * @access public + * @param string one of bool, int, float, string + */ + function setType($type) + { + switch ($type) { + case "bool": + $this->cType = "zend_bool"; + if (!$this->onupdate) { + $this->onupdate = "OnUpdateBool"; + } + return true; + + case "int": + $this->cType = "long"; + if (!$this->onupdate) { + $this->onupdate = "OnUpdateLong"; + } + return true; + + case "float": + $this->cType = "double"; + if (!$this->onupdate) { + $this->onupdate = "OnUpdateReal"; + } + return true; + + case "string": + $this->cType = "char *"; + if (!$this->onupdate) { + $this->onupdate = "OnUpdateString"; + } + return true; + + default: + return PEAR::raiseError("'$this->type' not supported, only bool, int, float and string"); + } + } + + + /** + * Get method for type + * + * @access public + * @return string + */ + function getType() + { + return $this->cType; + } + - /** - * Get method for name - * - * @access public - * @return string - */ - function getName() - { - return $this->name; - } - - - - - /** - * Directive data type - * - * @access private - * @var string - */ - protected $type; - - /** - * Set method for data type - * - * @access public - * @param string one of bool, int, float, string - */ - function setType($type) - { - switch ($type) { - case "bool": - $this->cType = "zend_bool"; - if (!$this->onupdate) { - $this->onupdate = "OnUpdateBool"; - } - return true; - - case "int": - $this->cType = "long"; - if (!$this->onupdate) { - $this->onupdate = "OnUpdateLong"; - } - return true; - - case "float": - $this->cType = "double"; - if (!$this->onupdate) { - $this->onupdate = "OnUpdateReal"; - } - return true; - - case "string": - $this->cType = "char *"; - if (!$this->onupdate) { - $this->onupdate = "OnUpdateString"; - } - return true; - - default: - return PEAR::raiseError("'$this->type' not supported, only bool, int, float and string"); - } - } - - - /** - * Get method for type - * - * @access public - * @return string - */ - function getType() - { - return $this->cType; - } - - - - /** - * Directive default value - * - * @access private - * @var string - */ - protected $value; + + /** + * Directive default value + * + * @access private + * @var string + */ + protected $value; - /** - * Set method for default value - * - * @access public - * @param string default value - */ - function setValue($value) - { - // TODO checks - $this->value = $value; + /** + * Set method for default value + * + * @access public + * @param string default value + */ + function setValue($value) + { + // TODO checks + $this->value = $value; - return true; - } + return true; + } - /** - * Get method for default value - * - * @access public - * @return string - */ - function getValue() - { - return $this->value; - } + /** + * Get method for default value + * + * @access public + * @return string + */ + function getValue() + { + return $this->value; + } - /** - * Directive description - * - * @access private - * @var string - */ - protected $desc; + /** + * Directive description + * + * @access private + * @var string + */ + protected $desc; - /** - * Set method for directive description - * - * @access public - * @param string description - */ - function setDesc($desc) - { - $this->desc = $desc; + /** + * Set method for directive description + * + * @access public + * @param string description + */ + function setDesc($desc) + { + $this->desc = $desc; - return true; - } + return true; + } - /** - * Get method for description - * - * @access public - * @return string - */ - function getDesc() - { - return $this->desc; - } - - - - /** - * Directive access mode - * - * @access private - * @var string - */ - protected $access = "PHP_INI_ALL"; - - /** - * Set method for access mode - * - * @access private - * @param string access mode specification (system|perdir|user|all) - */ - function setAccess($access) - { - switch ($access) { - case "system": - $this->access = "PHP_INI_SYSTEM"; - return true; - case "perdir": - $this->access = "PHP_INI_PERDIR"; - return true; - case "user": - // TODO shouldn't this be ALL instead? - $this->access = "PHP_INI_USER"; - return true; - case "all": - case "": - $this->access = "PHP_INI_ALL"; - return true; - default: - return PEAR::raiseError("'$access' is not a valid access mode (system|perdir|user|all)"); - } - } - - /** - * Get method for access - * - * @access public - * @return string - */ - function getAccess() - { - return $this->access; - } - - - - /** - * Directive OnUpdate handler - * - * @access private - * @var string - */ - protected $onupdate; + /** + * Get method for description + * + * @access public + * @return string + */ + function getDesc() + { + return $this->desc; + } + + + + /** + * Directive access mode + * + * @access private + * @var string + */ + protected $access = "PHP_INI_ALL"; + + /** + * Set method for access mode + * + * @access private + * @param string access mode specification (system|perdir|user|all) + */ + function setAccess($access) + { + switch ($access) { + case "system": + $this->access = "PHP_INI_SYSTEM"; + return true; + case "perdir": + $this->access = "PHP_INI_PERDIR"; + return true; + case "user": + // TODO shouldn't this be ALL instead? + $this->access = "PHP_INI_USER"; + return true; + case "all": + case "": + $this->access = "PHP_INI_ALL"; + return true; + default: + return PEAR::raiseError("'$access' is not a valid access mode (system|perdir|user|all)"); + } + } + + /** + * Get method for access + * + * @access public + * @return string + */ + function getAccess() + { + return $this->access; + } + + + + /** + * Directive OnUpdate handler + * + * @access private + * @var string + */ + protected $onupdate; - /** - * Set method for OnUpdate handler - * - * @access public - * @param string C function name - */ - function setOnUpdate($name) - { - if (!self::isName($name)) { - return PEAR::raiseError("'$name' is not a valid update function name"); - } + /** + * Set method for OnUpdate handler + * + * @access public + * @param string C function name + */ + function setOnUpdate($name) + { + if (!self::isName($name)) { + return PEAR::raiseError("'$name' is not a valid update function name"); + } - $this->onupdate = $name; + $this->onupdate = $name; - return true; - } + return true; + } - /** - * Get method for update handler - * - * @access public - * @return string - */ - function getOnupdate() - { - return $this->onupdate; - } + /** + * Get method for update handler + * + * @access public + * @return string + */ + function getOnupdate() + { + return $this->onupdate; + } @@ -317,7 +317,7 @@ */ function __construct() { - $this->setType("string"); + $this->setType("string"); } @@ -332,21 +332,21 @@ */ static function cCodeHeader($name) { - // this is a small incompatibility between ZE1 and ZE2 APIs - // "OnUpdateInt" was changed to "OnUpdateLong" as it actualy - // works on C type "long", not "int" - // the actual implementation didn't change so it is safe to - // just revert the name change using a cpp #define - // TODO: skip this for extensions that depend on PHP 5 anyway - $code = " + // this is a small incompatibility between ZE1 and ZE2 APIs + // "OnUpdateInt" was changed to "OnUpdateLong" as it actualy + // works on C type "long", not "int" + // the actual implementation didn't change so it is safe to + // just revert the name change using a cpp #define + // TODO: skip this for extensions that depend on PHP 5 anyway + $code = " #ifndef ZEND_ENGINE_2 #define OnUpdateLong OnUpdateInt #endif "; - $code .="PHP_INI_BEGIN()\n"; + $code .="PHP_INI_BEGIN()\n"; - return $code; + return $code; } /** @@ -391,7 +391,7 @@ static function docHeader($name) { return -" <table> + " <table> <title>$name runtime configuration</title> <tgroup cols='3'> <thead> @@ -415,7 +415,7 @@ function docEntry($base) { return -" <row> + " <row> <entry>$this->name</entry> <entry>$this->value</entry> <entry>$this->desc</entry> @@ -433,11 +433,19 @@ static function docFooter() { return -" </tbody> + " </tbody> </tgroup> </table> "; } - } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode:nil + * End: + */ ?> http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Interface.php?r1=1.5&r2=1.6&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Interface.php diff -u pear/CodeGen_PECL/PECL/Element/Interface.php:1.5 pear/CodeGen_PECL/PECL/Element/Interface.php:1.6 --- pear/CodeGen_PECL/PECL/Element/Interface.php:1.5 Tue Aug 22 13:36:01 2006 +++ pear/CodeGen_PECL/PECL/Element/Interface.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Interface.php,v 1.5 2006/08/22 13:36:01 hholzgra Exp $ + * @version CVS: $Id: Interface.php,v 1.6 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -40,266 +40,268 @@ * @link http://pear.php.net/package/CodeGen */ - class CodeGen_PECL_Element_Interface - extends CodeGen_PECL_Element - implements CodeGen_PECL_Element_ObjectInterface - { - /** - * The class name - * - * @var string - */ - protected $name = "unknown"; - - /** - * name set()er - * - * @param string - */ - function setName($name) - { - if (!self::isName($name)) { - return PEAR::raiseError("'$name' is not a valid interface name"); - } +class CodeGen_PECL_Element_Interface + extends CodeGen_PECL_Element + implements CodeGen_PECL_Element_ObjectInterface +{ + /** + * The class name + * + * @var string + */ + protected $name = "unknown"; + + /** + * name set()er + * + * @param string + */ + function setName($name) + { + if (!self::isName($name)) { + return PEAR::raiseError("'$name' is not a valid interface name"); + } - $this->name = $name; + $this->name = $name; - return true; - } + return true; + } - /** - * name get()er - * - * @return string - */ - function getName() - { - return $this->name; - } + /** + * name get()er + * + * @return string + */ + function getName() + { + return $this->name; + } - /** - * A short description - * - * @var string - */ - protected $summary = ""; - - /** - * summary set()er - * - * @param string - */ - function setSummary($text) - { - $this->summary = $text; - return true; - } + /** + * A short description + * + * @var string + */ + protected $summary = ""; + + /** + * summary set()er + * + * @param string + */ + function setSummary($text) + { + $this->summary = $text; + return true; + } - /** - * A long description - * - * @var string - */ - protected $description = ""; - - /** - * description set()er - * - * @param string - */ - function setDescription($text) - { - $this->description = $text; - return true; - } + /** + * A long description + * + * @var string + */ + protected $description = ""; + + /** + * description set()er + * + * @param string + */ + function setDescription($text) + { + $this->description = $text; + return true; + } - /** - * Documentation - * - * TODO: isn't this in Element base class already? - * - * @var string - */ - protected $documentation = ""; - - /** - * description set()er - * - * @param string - */ - function setDocumentation($text) { - $this->documentation = $text; - } + /** + * Documentation + * + * TODO: isn't this in Element base class already? + * + * @var string + */ + protected $documentation = ""; + + /** + * description set()er + * + * @param string + */ + function setDocumentation($text) + { + $this->documentation = $text; + } - /** - * Extents which interface? - * - * @var string - */ - protected $extends = ""; - - /** - * extends set()er - * - * @param string - */ - function setExtends($parent) - { - if (!self::isName($parent)) { - return PEAR::raiseError("'$parent' is not a valid parent interface name"); - } + /** + * Extents which interface? + * + * @var string + */ + protected $extends = ""; + + /** + * extends set()er + * + * @param string + */ + function setExtends($parent) + { + if (!self::isName($parent)) { + return PEAR::raiseError("'$parent' is not a valid parent interface name"); + } - $this->extends = $parent; - } + $this->extends = $parent; + } - /** - * Member Functions - * - * @var array - */ - protected $methods = array(); + /** + * Member Functions + * + * @var array + */ + protected $methods = array(); - /** - * Add a method to the interface - * - * @param object - */ - function addMethod(CodeGen_PECL_Element_Method $method) - { - $name = $method->getName(); - - if (isset($this->functions[$name])) { - return PEAR::raiseError("method '$name' already exists"); - } - -# TODO -# if (!$method->isAbstract || !$method->isInterface) { -# return PEAR::raiseError("an interface method has to be declated both abstract and interface"); -# } - - $this->methods[$name] = $method; + /** + * Add a method to the interface + * + * @param object + */ + function addMethod(CodeGen_PECL_Element_Method $method) + { + $name = $method->getName(); + + if (isset($this->functions[$name])) { + return PEAR::raiseError("method '$name' already exists"); + } - return true; + /* TODO + if (!$method->isAbstract || !$method->isInterface) { + return PEAR::raiseError("an interface method has to be declated both abstract and interface"); } + */ + + $this->methods[$name] = $method; + + return true; + } - /** - * Create C header entry for interface - * - * @access public - * @param class Extension extension the function is part of - * @return string C header code snippet - */ - function hCode($extension) - { - $code = ""; - - foreach ($this->methods as $method) { - $code.= $method->hCode($extension); - } - - if ($code) { - $code = $this->ifConditionStart() . $code . $this->ifConditionEnd(); - } + /** + * Create C header entry for interface + * + * @access public + * @param class Extension extension the function is part of + * @return string C header code snippet + */ + function hCode($extension) + { + $code = ""; - return $code; + foreach ($this->methods as $method) { + $code.= $method->hCode($extension); } + if ($code) { + $code = $this->ifConditionStart() . $code . $this->ifConditionEnd(); + } + + return $code; + } - /** - * Generate global scope code - * - * @access public - * @return string - */ - function globalCode($extension) - { - ob_start(); - - echo "/* {{{ Interface {$this->name} */\n\n"; - - echo $this->ifConditionStart(); - - echo "static zend_class_entry * {$this->name}_ce_ptr = NULL;\n\n"; - - echo "static zend_function_entry {$this->name}_methods[] = {\n"; - - foreach ($this->methods as $method) { - echo " ".$method->methodEntry()."\n"; - } - - echo " { NULL, NULL, NULL }\n"; - echo "};\n\n"; - - echo "static void interface_init_{$this->name}(void)\n{\n"; - echo " zend_class_entry ce;\n"; - if ($this->extends) { - echo " zend_class_entry **parent_ce;\n"; - } - echo "\n"; - echo " INIT_CLASS_ENTRY(ce, \"{$this->name}\", {$this->name}_methods);\n"; - echo " {$this->name}_ce_ptr = zend_register_internal_interface(&ce TSRMLS_CC);\n"; - - if ($this->extends) { - echo sprintf(" if (SUCCESS == zend_hash_find(CG(class_table), \"%s\", %d, (void **)&parent_ce)) {\n", - strtolower($this->extends), strlen($this->extends) + 1); - echo ""; - echo " if (parent_ce) {\n"; - echo " zend_do_inheritance({$this->name}_ce_ptr, *parent_ce TSRMLS_CC);\n"; - echo " }\n"; - } - echo "}\n\n"; + /** + * Generate global scope code + * + * @access public + * @return string + */ + function globalCode($extension) + { + ob_start(); - echo $this->ifConditionEnd(); + echo "/* {{{ Interface {$this->name} */\n\n"; - echo "/* }}} Class {$this->name} */\n\n"; + echo $this->ifConditionStart(); - return ob_get_clean(); + echo "static zend_class_entry * {$this->name}_ce_ptr = NULL;\n\n"; + + echo "static zend_function_entry {$this->name}_methods[] = {\n"; + + foreach ($this->methods as $method) { + echo " ".$method->methodEntry()."\n"; } + echo " { NULL, NULL, NULL }\n"; + echo "};\n\n"; - /** - * MINIT code fragment - * - * @access public - * @return string - */ - function minitCode($extension) - { - return $this->ifConditionStart() . "interface_init_{$this->name}();\n" . $this->ifConditionEnd(); + echo "static void interface_init_{$this->name}(void)\n{\n"; + echo " zend_class_entry ce;\n"; + if ($this->extends) { + echo " zend_class_entry **parent_ce;\n"; + } + echo "\n"; + echo " INIT_CLASS_ENTRY(ce, \"{$this->name}\", {$this->name}_methods);\n"; + echo " {$this->name}_ce_ptr = zend_register_internal_interface(&ce TSRMLS_CC);\n"; + + if ($this->extends) { + echo sprintf(" if (SUCCESS == zend_hash_find(CG(class_table), \"%s\", %d, (void **)&parent_ce)) {\n", + strtolower($this->extends), strlen($this->extends) + 1); + echo ""; + echo " if (parent_ce) {\n"; + echo " zend_do_inheritance({$this->name}_ce_ptr, *parent_ce TSRMLS_CC);\n"; + echo " }\n"; } + + echo "}\n\n"; + + echo $this->ifConditionEnd(); + + echo "/* }}} Class {$this->name} */\n\n"; + + return ob_get_clean(); + } + + + /** + * MINIT code fragment + * + * @access public + * @return string + */ + function minitCode($extension) + { + return $this->ifConditionStart() . "interface_init_{$this->name}();\n" . $this->ifConditionEnd(); + } - /** - * DocBook documentation fragment - * - * @access public - * @return string - */ - function docEntry($base) - { - $xml = ""; + /** + * DocBook documentation fragment + * + * @access public + * @return string + */ + function docEntry($base) + { + $xml = ""; - return $xml; - } + return $xml; + } - function getPayloadType() - { - return ""; - } + function getPayloadType() + { + return ""; } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Logo.php?r1=1.5&r2=1.6&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Logo.php diff -u pear/CodeGen_PECL/PECL/Element/Logo.php:1.5 pear/CodeGen_PECL/PECL/Element/Logo.php:1.6 --- pear/CodeGen_PECL/PECL/Element/Logo.php:1.5 Mon Aug 21 14:12:41 2006 +++ pear/CodeGen_PECL/PECL/Element/Logo.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Logo.php,v 1.5 2006/08/21 14:12:41 hholzgra Exp $ + * @version CVS: $Id: Logo.php,v 1.6 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -110,11 +110,11 @@ // perform a little magic // we only accept GIF, PNG and JPEG here, so we can test // for the 'magic' signatures ourself - if (!strncmp("GIF8", $data, 4)) { + if (!strncmp("GIF8", $data, 4)) { $this->mimetype = "image/gif"; - } else if(!strncmp(chr(0x89)."PNG\r\n", $data, 6)) { + } else if (!strncmp(chr(0x89)."PNG\r\n", $data, 6)) { $this->mimetype = "image/png"; - } else if(ord($data[0]) == 0xff && ord($data[1]) == 0xd8) { + } else if (ord($data[0]) == 0xff && ord($data[1]) == 0xd8) { $this->mimetype = "image/jpeg"; } else { return PEAR::raiseError("can't detect mimetype for logo image data, pease add 'mimetype=...' attribute"); @@ -220,7 +220,7 @@ $code = " "; $i=0; for ($n = 0; $n < $len; $n++) { - $code .= sprintf(" %3d",ord($this->data[$n])); + $code .= sprintf(" %3d", ord($this->data[$n])); if ($n == $len - 1) break; $code .= ","; if (++$i==8) { http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Method.php?r1=1.20&r2=1.21&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Method.php diff -u pear/CodeGen_PECL/PECL/Element/Method.php:1.20 pear/CodeGen_PECL/PECL/Element/Method.php:1.21 --- pear/CodeGen_PECL/PECL/Element/Method.php:1.20 Tue Aug 22 13:50:58 2006 +++ pear/CodeGen_PECL/PECL/Element/Method.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Method.php,v 1.20 2006/08/22 13:50:58 hholzgra Exp $ + * @version CVS: $Id: Method.php,v 1.21 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -37,439 +37,448 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/CodeGen */ - class CodeGen_PECL_Element_Method - extends CodeGen_PECL_Element_Function +class CodeGen_PECL_Element_Method + extends CodeGen_PECL_Element_Function +{ + function __construct(Codegen_PECL_Element_ObjectInterface $class) { - function __construct(Codegen_PECL_Element_ObjectInterface $class) - { - $this->class = $class; - $this->classname = $class->getName(); - } - - /** - * The class this method belongs to - * - * @var object - */ - protected $class; - - /** - * Name of class this method belongs to - * - * @var string - */ - protected $classname; + $this->class = $class; + $this->classname = $class->getName(); + } + + /** + * The class this method belongs to + * + * @var object + */ + protected $class; + + /** + * Name of class this method belongs to + * + * @var string + */ + protected $classname; - /** - * Name for procedural alias of this method - * - * @var string - */ - protected $proceduralName = ""; - - function getProceduralName() - { - return $this->proceduralName; - } + /** + * Name for procedural alias of this method + * + * @var string + */ + protected $proceduralName = ""; + + function getProceduralName() + { + return $this->proceduralName; + } - function setProceduralName($name) - { - if ($name == "default") { - $name = $this->classname."_".$this->name; - } else if (!$this->isName($name)) { - return PEAR::raiseError("'$name' is not a valid function alias name"); - } + function setProceduralName($name) + { + if ($name == "default") { + $name = $this->classname."_".$this->name; + } else if (!$this->isName($name)) { + return PEAR::raiseError("'$name' is not a valid function alias name"); + } - $this->proceduralName = $name; + $this->proceduralName = $name; - return true; - } + return true; + } - /** - * distinguishable name getter - * - * @return string - */ - function getFullName() - { - return $this->classname."__".$this->name; - } - - /** - * Is this an abstract method? - * - * @var bool - */ - protected $isAbstract = false; - - function isAbstract() - { - $this->isAbstract = true; + /** + * distinguishable name getter + * + * @return string + */ + function getFullName() + { + return $this->classname."__".$this->name; + } - return $this->validate(); - } + /** + * Is this an abstract method? + * + * @var bool + */ + protected $isAbstract = false; - /** - * Is this an interface method? - * - * @var bool - */ - protected $isInterface = false; - - function isInterface() - { - $this->isInterface = true; - $this->isAbstract = true; + function isAbstract() + { + $this->isAbstract = true; - return $this->validate(); - } + return $this->validate(); + } - /** - * Is this a final method? - * - * @var bool - */ - protected $isFinal = false; - - function isFinal() - { - $this->isFinal = true; + /** + * Is this an interface method? + * + * @var bool + */ + protected $isInterface = false; - return $this->validate(); - } + function isInterface() + { + $this->isInterface = true; + $this->isAbstract = true; - /** - * Is this a static method? - * - * @var bool - */ - protected $isStatic = false; - - function isStatic() - { - $this->isStatic = true; + return $this->validate(); + } - return $this->validate(); - } + /** + * Is this a final method? + * + * @var bool + */ + protected $isFinal = false; - /** - * Visibility of this property - * - * @var string - */ - protected $access = "public"; - - function setAccess($access) - { - switch ($this->access) { - case "private": - case "protected": - case "public": - $this->access = $access; - return $this->validate(); - default: - return PEAR::raiseError("'$access' is not a valid access property"); - } + function isFinal() + { + $this->isFinal = true; + + return $this->validate(); + } + + /** + * Is this a static method? + * + * @var bool + */ + protected $isStatic = false; + + function isStatic() + { + $this->isStatic = true; + + return $this->validate(); + } + + /** + * Visibility of this property + * + * @var string + */ + protected $access = "public"; + + function setAccess($access) + { + switch ($this->access) { + case "private": + case "protected": + case "public": + $this->access = $access; + return $this->validate(); + default: + return PEAR::raiseError("'$access' is not a valid access property"); } + } - /** - * Hook for parameter parsing API function - * - * @param string C expr. for number of arguments - * @param string Argument string - * @param array Argument variable pointers - */ - protected function parseParameterHook($argc, $argString, $argPointers) - { - if ($this->name == "__construct") { - $code = parent::parseParameterHook($argc, $argString, $argPointers); - $code.= "\n _this_zval = getThis();\n"; - } else { + /** + * Hook for parameter parsing API function + * + * @param string C expr. for number of arguments + * @param string Argument string + * @param array Argument variable pointers + */ + protected function parseParameterHook($argc, $argString, $argPointers) + { + if ($this->name == "__construct") { + $code = parent::parseParameterHook($argc, $argString, $argPointers); + $code.= "\n _this_zval = getThis();\n"; + } else { $code = " if (zend_parse_method_parameters($argc TSRMLS_CC, getThis(), \"$argString\", ".join(", ",$argPointers).") == FAILURE) { return; } "; - } - $code .= " _this_ce = Z_OBJCE_P(_this_zval);\n\n"; - - $payload = $this->class->getPayloadType(); - if ($payload) { - $code.= " payload = (php_obj_{$this->classname} *) zend_object_store_get_object(_this_zval TSRMLS_CC);\n"; - } + } + $code .= " _this_ce = Z_OBJCE_P(_this_zval);\n\n"; - return $code; + $payload = $this->class->getPayloadType(); + if ($payload) { + $code.= " payload = (php_obj_{$this->classname} *) zend_object_store_get_object(_this_zval TSRMLS_CC);\n"; } + return $code; + } + - /** - * Generate local variable declarations - * - * @return string C code snippet - */ - function localVariables($extension) - { - $code = parent::localVariables($extension); - $code.= " zend_class_entry * _this_ce;\n"; + /** + * Generate local variable declarations + * + * @return string C code snippet + */ + function localVariables($extension) + { + $code = parent::localVariables($extension); + $code.= " zend_class_entry * _this_ce;\n"; - if ($this->name == "__construct") { - $code.= " zval * _this_zval;\n"; - } - - $payload = $this->class->getPayloadType(); - if ($payload) { - $code.= " php_obj_{$this->classname} *payload;\n"; - } + if ($this->name == "__construct") { + $code.= " zval * _this_zval;\n"; + } - return $code; + $payload = $this->class->getPayloadType(); + if ($payload) { + $code.= " php_obj_{$this->classname} *payload;\n"; } - /** - * Set parameter and return value information from PHP style prototype - * - * @access public - * @param string PHP style prototype - * @return bool Success status - */ - function setProto($proto, $extension) { - $err = parent::setProto($proto, $extension); - if (PEAR::isError($err)) { - return $err; - } - - if ($this->name != "__construct") { - $param = array(); - $param['name'] = "_this_zval"; - $param['type'] = "object"; - $param['subtype'] = $this->classname; - $param['byRef'] = true; + return $code; + } - array_unshift($this->params, $param); - } + /** + * Set parameter and return value information from PHP style prototype + * + * @access public + * @param string PHP style prototype + * @return bool Success status + */ + function setProto($proto, $extension) + { + $err = parent::setProto($proto, $extension); + if (PEAR::isError($err)) { + return $err; } + + if ($this->name != "__construct") { + $param = array(); + $param['name'] = "_this_zval"; + $param['type'] = "object"; + $param['subtype'] = $this->classname; + $param['byRef'] = true; - /** - * Create registration line for method table - * - * @param string Name of class owning this method - * @return string C code snippet - */ - function methodEntry() - { - $code = ""; - - // TODO catch arg #2->type == void - $arginfo = (count($this->params)>1) ? ($this->getFullName()."_args") : "NULL"; - - if ($this->isAbstract || $this->isInterface) { - $code.= "ZEND_FENTRY({$this->name}, NULL, $arginfo, ZEND_ACC_ABSTRACT | "; - if ($this->isInterface) { - $code.= " ZEND_ACC_INTERFACE | "; - } - } else { - $code.= "PHP_ME({$this->classname}, {$this->name}, $arginfo, /**/"; - } + array_unshift($this->params, $param); + } + } - $code.= "ZEND_ACC_".strtoupper($this->access); + /** + * Create registration line for method table + * + * @param string Name of class owning this method + * @return string C code snippet + */ + function methodEntry() + { + $code = ""; - if ($this->isStatic) { - $code.= " | ZEND_ACC_STATIC"; - } + // TODO catch arg #2->type == void + $arginfo = (count($this->params)>1) ? ($this->getFullName()."_args") : "NULL"; - if ($this->isFinal) { - $code.= " | ZEND_ACC_FINAL"; + if ($this->isAbstract || $this->isInterface) { + $code.= "ZEND_FENTRY({$this->name}, NULL, $arginfo, ZEND_ACC_ABSTRACT | "; + if ($this->isInterface) { + $code.= " ZEND_ACC_INTERFACE | "; } - - $code.= ")"; - - return $code; + } else { + $code.= "PHP_ME({$this->classname}, {$this->name}, $arginfo, /**/"; } - /** - * Create registration line for method table - * - * @param string Name of class owning this method - * @return string C code snippet - */ - function functionAliasEntry() - { - if (!$this->proceduralName) { - return ""; - } + $code.= "ZEND_ACC_".strtoupper($this->access); - // TODO arg_info? - return " PHP_MALIAS({$this->classname}, {$this->proceduralName}, {$this->name}, NULL, ZEND_ACC_PUBLIC)\n"; + if ($this->isStatic) { + $code.= " | ZEND_ACC_STATIC"; } - /** - * Create proto line for method - * - * @param string Name of class owning this method - * @return string C code snippet - */ - function cProto() - { - if ($this->isAbstract || $this->isInterface) { - return ""; - } - - return "PHP_METHOD({$this->classname}, {$this->name})"; + + if ($this->isFinal) { + $code.= " | ZEND_ACC_FINAL"; } + $code.= ")"; + + return $code; + } - /** - * Create C code implementing the PHP userlevel function - * - * @access public - * @param class Extension extension the function is part of - * @return string C code implementing the function - */ - function cCode($extension) - { - if (!$this->isAbstract && !$this->isInterface) { - return parent::cCode($extension); - } + /** + * Create registration line for method table + * + * @param string Name of class owning this method + * @return string C code snippet + */ + function functionAliasEntry() + { + if (!$this->proceduralName) { + return ""; + } + // TODO arg_info? + return " PHP_MALIAS({$this->classname}, {$this->proceduralName}, {$this->name}, NULL, ZEND_ACC_PUBLIC)\n"; + } + /** + * Create proto line for method + * + * @param string Name of class owning this method + * @return string C code snippet + */ + function cProto() + { + if ($this->isAbstract || $this->isInterface) { return ""; } + + return "PHP_METHOD({$this->classname}, {$this->name})"; + } - /** - * Validate settings, spot conflicts - * - * @return true or exception - */ - function validate() - { - /* an abstract method can't be final or private and can't have code */ - if ($this->isAbstract && $this->isFinal) { - return PEAR::raiseError("A method can't be abstract and final at the same time"); - } - if ($this->isAbstract && $this->access == "private") { - return PEAR::raiseError("A method can't be abstract and private at the same time"); - } + /** + * Create C code implementing the PHP userlevel function + * + * @access public + * @param class Extension extension the function is part of + * @return string C code implementing the function + */ + function cCode($extension) + { + if (!$this->isAbstract && !$this->isInterface) { + return parent::cCode($extension); + } - if ($this->isAbstract && !empty($this->code)) { - return PEAR::raiseError("A method can't be abstract and implemented at the same time"); - } + return ""; + } - // TODO add "abstract may not have test" as soon as test mess is cleaned up - return true; + /** + * Validate settings, spot conflicts + * + * @return true or exception + */ + function validate() + { + /* an abstract method can't be final or private and can't have code */ + if ($this->isAbstract && $this->isFinal) { + return PEAR::raiseError("A method can't be abstract and final at the same time"); } - /** - * The role attribute doesn't apply here - * - * @param string - * @return exception - */ - function setRole($role) - { - return PEAR::raiseError("the role attribute is not defined for class member functions"); - } - - /** - * Code addition must be validated here - * - * @param string code snippet - */ - function setCode($code) - { - parent::setCode($code); + if ($this->isAbstract && $this->access == "private") { + return PEAR::raiseError("A method can't be abstract and private at the same time"); + } - return $this->validate(); + if ($this->isAbstract && !empty($this->code)) { + return PEAR::raiseError("A method can't be abstract and implemented at the same time"); } - /** - * Method name checking is less strict - * - * Method names can't clash with PHP standard functions - * so we can just check for syntax and keywords here - * - * @param string method name - */ - function setName($name) - { - if (!self::isName($name)) { - return PEAR::raiseError("'$name' is not a valid function name"); - } + // TODO add "abstract may not have test" as soon as test mess is cleaned up + return true; + } + + /** + * The role attribute doesn't apply here + * + * @param string + * @return exception + */ + function setRole($role) + { + return PEAR::raiseError("the role attribute is not defined for class member functions"); + } + + /** + * Code addition must be validated here + * + * @param string code snippet + */ + function setCode($code) + { + parent::setCode($code); + + return $this->validate(); + } + + /** + * Method name checking is less strict + * + * Method names can't clash with PHP standard functions + * so we can just check for syntax and keywords here + * + * @param string method name + */ + function setName($name) + { + if (!self::isName($name)) { + return PEAR::raiseError("'$name' is not a valid function name"); + } - if (self::isKeyword($name)) { - return PEAR::raiseError("'$name' is a reserved word which is not valid for function names"); - } + if (self::isKeyword($name)) { + return PEAR::raiseError("'$name' is a reserved word which is not valid for function names"); + } - $this->name = $name; + $this->name = $name; - return true; - } + return true; + } - /** - * Create test case for this function - * - * @access public - * @param object extension the function is part of - * @return object generated test case - */ - function createTest(CodeGen_PECL_Extension $extension) - { - if ($this->isAbstract || $this->isInterface) { - return null; - } + /** + * Create test case for this function + * + * @access public + * @param object extension the function is part of + * @return object generated test case + */ + function createTest(CodeGen_PECL_Extension $extension) + { + if ($this->isAbstract || $this->isInterface) { + return null; + } - $test = parent::createTest($extension); + $test = parent::createTest($extension); - $test->setName($this->getFullName()); - $test->setTitle($this->classname."::".$this->name."() member function"); + $test->setName($this->getFullName()); + $test->setTitle($this->classname."::".$this->name."() member function"); - return $test; - } + return $test; + } + + /** + * Code needed ahead of the method table + * + * Abstract/Interface methods need to define their argument + * list ahead of the method table + * + * @returns string + */ + function argInfoCode() + { + $code = ""; + + if (count($this->params) > 0) { + $code.= "ZEND_BEGIN_ARG_INFO(".$this->getFullName()."_args, 0)\n"; + + $params = $this->params; + array_shift($params); - /** - * Code needed ahead of the method table - * - * Abstract/Interface methods need to define their argument - * list ahead of the method table - * - * @returns string - */ - function argInfoCode() { - $code = ""; - - if (count($this->params) > 0) { - $code.= "ZEND_BEGIN_ARG_INFO(".$this->getFullName()."_args, 0)\n"; - - $params = $this->params; - array_shift($params); - - $useTypeHints = true; - - foreach($params as $param) { - if ($param['type'] != "object" || !isset($param['subtype'])) { - $useTypeHints = false; - break; - } + $useTypeHints = true; + + foreach ($params as $param) { + if ($param['type'] != "object" || !isset($param['subtype'])) { + $useTypeHints = false; + break; } + } - // TODO optional paramteres? - foreach($params as $param) { - $byRef = empty($param["byRef"]) ? 0 : 1; - if ($useTypeHints) { - $code.= " ZEND_ARG_OBJ_INFO(0, $param[name], $param[subtype], 0)\n"; - } else { - $code.= " ZEND_ARG_INFO($byRef, $param[name])\n"; - } - } + // TODO optional paramteres? + foreach ($params as $param) { + $byRef = empty($param["byRef"]) ? 0 : 1; + if ($useTypeHints) { + $code.= " ZEND_ARG_OBJ_INFO(0, $param[name], $param[subtype], 0)\n"; + } else { + $code.= " ZEND_ARG_INFO($byRef, $param[name])\n"; + } + } - $code.= "ZEND_END_ARG_INFO()\n"; - } + $code.= "ZEND_END_ARG_INFO()\n"; + } - return $code; - } + return $code; + } - } +} +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode:nil + * End: + */ ?> http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Property.php?r1=1.6&r2=1.7&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Property.php diff -u pear/CodeGen_PECL/PECL/Element/Property.php:1.6 pear/CodeGen_PECL/PECL/Element/Property.php:1.7 --- pear/CodeGen_PECL/PECL/Element/Property.php:1.6 Tue Aug 22 13:51:54 2006 +++ pear/CodeGen_PECL/PECL/Element/Property.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Property.php,v 1.6 2006/08/22 13:51:54 hholzgra Exp $ + * @version CVS: $Id: Property.php,v 1.7 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -37,195 +37,195 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/CodeGen */ - class CodeGen_PECL_Element_Property - extends CodeGen_PECL_Element +class CodeGen_PECL_Element_Property + extends CodeGen_PECL_Element +{ + /** + * Is this an abstract property? + * + * @var bool + */ + protected $isAbstract = false; + + function isAbstract() { - /** - * Is this an abstract property? - * - * @var bool - */ - protected $isAbstract = false; - - function isAbstract() - { - $this->isAbstract = true; - } - - /** - * Is this an interface property? - * - * @var bool - */ - protected $isInterface = false; - - function isInterface() - { - $this->isInterface = true; - } - - /** - * Is this a final property? - * - * @var bool - */ - protected $isFinal = false; - - function isFinal() - { - $this->isFinal = true; - } - - /** - * Is this a static property? - * - * @var bool - */ - protected $isStatic = false; - - function isStatic() - { - $this->isStatic = true; - } - - /** - * Visibility of this property - * - * @var string - */ - protected $access = "public"; - - function setAccess($access) - { - switch ($this->access) { - case "private": - case "protected": - case "public": - $this->access = $access; - return true; - default: - return PEAR::raiseError("'$access' is not a valid access property"); - } - } - - - /** - * Property type - * - * @var string - */ - protected $type = "null"; - - function setType($type) - { - switch ($type) { - case "int": - case "long": - $this->type = "long"; - break; - case "float": - case "double": - $this->type = "double"; - break; - case "string": - $this->type = "string"; - break; - case "null": - case "void": - $this->type = "null"; - break; - default: - return PEAR::raiseError("'$type' is not a valid property type"); - } + $this->isAbstract = true; + } - return true; - } + /** + * Is this an interface property? + * + * @var bool + */ + protected $isInterface = false; + function isInterface() + { + $this->isInterface = true; + } - /** - * Property name - * - * @var string - */ - protected $name = "unknown"; - - function setName($name) - { - if (!$this->isName($name)) { - return PEAR::raiseError("'$name' is not a valid property name"); - } - - $this->name = $name; + /** + * Is this a final property? + * + * @var bool + */ + protected $isFinal = false; + + function isFinal() + { + $this->isFinal = true; + } + + /** + * Is this a static property? + * + * @var bool + */ + protected $isStatic = false; + function isStatic() + { + $this->isStatic = true; + } + + /** + * Visibility of this property + * + * @var string + */ + protected $access = "public"; + + function setAccess($access) + { + switch ($this->access) { + case "private": + case "protected": + case "public": + $this->access = $access; return true; + default: + return PEAR::raiseError("'$access' is not a valid access property"); } + } - function getName() - { - return $this->name; - } - - /** - * Default value - * - * @var string - * @access private - */ - protected $value = ""; - - function setValue($value) - { - // TODO check? - $this->value = $value; - return true; + /** + * Property type + * + * @var string + */ + protected $type = "null"; + + function setType($type) + { + switch ($type) { + case "int": + case "long": + $this->type = "long"; + break; + case "float": + case "double": + $this->type = "double"; + break; + case "string": + $this->type = "string"; + break; + case "null": + case "void": + $this->type = "null"; + break; + default: + return PEAR::raiseError("'$type' is not a valid property type"); } - /** - * MINIT code fragment - * - * @access public - * @return string - */ - function minitCode($classptr) { - $code = $this->ifConditionStart(); - - $code.= " zend_declare_property_{$this->type}({$classptr}, \n"; - $code.= ' "' . $this->name . '", ' . strlen($this->name) . ", "; - - switch ($this->type) { - case "string": - $code .= '"'.$this->value.'", '; - break; - case "long": - case "double": - // TODO zend_declare_property_double only available in 5.1? add a configure check for this? - $code .= $this->value.", "; - break; - default: - break; - } + return true; + } + + + /** + * Property name + * + * @var string + */ + protected $name = "unknown"; + function setName($name) + { + if (!$this->isName($name)) { + return PEAR::raiseError("'$name' is not a valid property name"); + } - $code.= "\n ZEND_ACC_".strtoupper($this->access); - if ($this->isStatic) { - $code.= " | ZEND_ACC_STATIC"; - } - if ($this->isAbstract) { - $code.= " | ZEND_ACC_ABSTRACT"; - } - if ($this->isInterface) { - $code.= " | ZEND_ACC_INTERFACE"; - } - if ($this->isFinal) { - $code.= " | ZEND_ACC_FINAL"; - } + $this->name = $name; - $code .= " TSRMLS_DC);\n\n"; + return true; + } - $code.= $this->ifConditionEnd(); + function getName() + { + return $this->name; + } + + /** + * Default value + * + * @var string + * @access private + */ + protected $value = ""; - return $code; + function setValue($value) + { + // TODO check? + $this->value = $value; + + return true; + } + + /** + * MINIT code fragment + * + * @access public + * @return string + */ + function minitCode($classptr) { + $code = $this->ifConditionStart(); + + $code.= " zend_declare_property_{$this->type}({$classptr}, \n"; + $code.= ' "' . $this->name . '", ' . strlen($this->name) . ", "; + + switch ($this->type) { + case "string": + $code .= '"'.$this->value.'", '; + break; + case "long": + case "double": + // TODO zend_declare_property_double only available in 5.1? add a configure check for this? + $code .= $this->value.", "; + break; + default: + break; + } + + + $code.= "\n ZEND_ACC_".strtoupper($this->access); + if ($this->isStatic) { + $code.= " | ZEND_ACC_STATIC"; + } + if ($this->isAbstract) { + $code.= " | ZEND_ACC_ABSTRACT"; } + if ($this->isInterface) { + $code.= " | ZEND_ACC_INTERFACE"; + } + if ($this->isFinal) { + $code.= " | ZEND_ACC_FINAL"; + } + + $code .= " TSRMLS_DC);\n\n"; + + $code.= $this->ifConditionEnd(); + + return $code; } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Resource.php?r1=1.11&r2=1.12&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Resource.php diff -u pear/CodeGen_PECL/PECL/Element/Resource.php:1.11 pear/CodeGen_PECL/PECL/Element/Resource.php:1.12 --- pear/CodeGen_PECL/PECL/Element/Resource.php:1.11 Tue Aug 22 12:28:13 2006 +++ pear/CodeGen_PECL/PECL/Element/Resource.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Resource.php,v 1.11 2006/08/22 12:28:13 hholzgra Exp $ + * @version CVS: $Id: Resource.php,v 1.12 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -200,7 +200,8 @@ * @access public * @return string C code snippet */ - function minitCode() { + function minitCode() + { $code = $this->ifConditionStart(); $code.= " @@ -236,7 +237,7 @@ */ static function cCodeFooter($name) { - return "/* }}} *\n\n"; + return "/* }}} *\n\n"; } /** @@ -246,7 +247,8 @@ * @param object extension * @return string C code snippet */ - function cCode($extension) { + function cCode($extension) + { $code = $this->ifConditionStart(); $code.= "int le_{$this->name};\n"; @@ -285,7 +287,8 @@ * @access public * @return string C code snippet */ - function hCode() { + function hCode() + { $upname = strtoupper($this->name); $code = $this->ifConditionStart(); @@ -310,7 +313,8 @@ * @access public * @return string autoconf code snippet */ - function configm4($extension_name) { + function configm4($extension_name) + { if ($this->ifCondition) { return ""; // TODO implement more clever checking } @@ -327,7 +331,8 @@ * @param string id basename for extension * @return string DocBook XML code snippet */ - function docEntry($base) { + function docEntry($base) + { return " <section id='$base.resources.{$this->name}'> <title><literal>{$this->name}</literal></title> http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Stream.php?r1=1.3&r2=1.4&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Stream.php diff -u pear/CodeGen_PECL/PECL/Element/Stream.php:1.3 pear/CodeGen_PECL/PECL/Element/Stream.php:1.4 --- pear/CodeGen_PECL/PECL/Element/Stream.php:1.3 Mon Aug 21 14:12:41 2006 +++ pear/CodeGen_PECL/PECL/Element/Stream.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Stream.php,v 1.3 2006/08/21 14:12:41 hholzgra Exp $ + * @version CVS: $Id: Stream.php,v 1.4 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -155,7 +155,8 @@ * @access public * @return string C code snippet */ - function minitCode() { + function minitCode() + { return "/* ".$this->name." stream goes here */\n"; } @@ -167,7 +168,8 @@ * @param object extension * @return string C code snippet */ - function cCode($extension) { + function cCode($extension) + { ob_start(); echo "static php_stream_ops php_{$this->name}_stream_ops = {\n"; @@ -215,7 +217,8 @@ * @access public * @return string C code snippet */ - function hCode() { + function hCode() + { return "/* ".$this->name." stream goes here */\n"; } @@ -228,7 +231,8 @@ * @param string id basename for extension * @return string DocBook XML code snippet */ - function docEntry($base) { + function docEntry($base) + { return " "; } http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Test.php?r1=1.12&r2=1.13&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Test.php diff -u pear/CodeGen_PECL/PECL/Element/Test.php:1.12 pear/CodeGen_PECL/PECL/Element/Test.php:1.13 --- pear/CodeGen_PECL/PECL/Element/Test.php:1.12 Tue Aug 22 12:01:54 2006 +++ pear/CodeGen_PECL/PECL/Element/Test.php Mon Oct 9 21:27:05 2006 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005, 2006 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Test.php,v 1.12 2006/08/22 12:01:54 hholzgra Exp $ + * @version CVS: $Id: Test.php,v 1.13 2006/10/09 21:27:05 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -59,7 +59,8 @@ * * @access public * @return string value of - */ function setName($name) + */ + function setName($name) { if (! preg_match('|^[\w-]+$|i', $name)) { return PEAR::raiseError("'$name' is not a valid test case basename");
« previous php.pear.cvs (#42469) next »