cvs: pear /CodeGen_PECL/PECL/Element Global.php /CodeGen_PECL/docs/examples globals.xml

From: Date: Sun, 21 Aug 2005 16:39:17 +0000
Subject: cvs: pear /CodeGen_PECL/PECL/Element Global.php /CodeGen_PECL/docs/examples globals.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-34198@lists.php.net to get a copy of this message
hholzgra Sun Aug 21 12:39:17 2005 EDT Added files: /pear/CodeGen_PECL/docs/examples globals.xml Modified files: /pear/CodeGen_PECL/PECL/Element Global.php Log: setting a default value for <global> didn't produce code (pear bug #5157) test case added http://cvs.php.net/diff.php/pear/CodeGen_PECL/PECL/Element/Global.php?r1=1.2&r2=1.3&ty=u Index: pear/CodeGen_PECL/PECL/Element/Global.php diff -u pear/CodeGen_PECL/PECL/Element/Global.php:1.2 pear/CodeGen_PECL/PECL/Element/Global.php:1.3 --- pear/CodeGen_PECL/PECL/Element/Global.php:1.2 Tue Jul 26 05:16:04 2005 +++ pear/CodeGen_PECL/PECL/Element/Global.php Sun Aug 21 12:39:17 2005 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Global.php,v 1.2 2005/07/26 09:16:04 hholzgra Exp $ + * @version CVS: $Id: Global.php,v 1.3 2005/08/21 16:39:17 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -122,7 +122,7 @@ * @access private * @var string */ - protected $value; + protected $value = null; /** * Set method for default value @@ -196,11 +196,19 @@ function cCode($name) { $code = " {$name}_globals->{$this->name} = "; - if (strstr($this->type, "*")) { - $code .= "NULL;\n"; + + if ($this->value != null) { + $code .= $this->value; } else { - $code .= "0;\n"; - } + if (strstr($this->type, "*")) { + $code .= "NULL"; + } else { + $code .= "0"; + } + } + + $code .= ";\n"; + return $code; } http://cvs.php.net/co.php/pear/CodeGen_PECL/docs/examples/globals.xml?r=1.1&p=1 Index: pear/CodeGen_PECL/docs/examples/globals.xml +++ pear/CodeGen_PECL/docs/examples/globals.xml <?xml version="1.0" ?> <extension name="globals" version="0.9.0"> <global name="foo" type="int" value="42"/> <function name="get_foo"> <proto>int get_foo()</proto> <code> RETURN_LONG(GLOBALS_G(foo)); </code> </function> <function name="set_foo"> <proto>void set_foo(int val)</proto> <code> GLOBALS_G(foo) = val; </code> </function> <test> <code> echo get_foo()."\n"; set_foo(23)."\n"; echo get_foo()."\n"; </code> <result> 42 23 </result> </test> </extension>

« previous php.pear.cvs (#34198) next »