cvs: pear /CodeGen_PECL/PECL Extension.php /CodeGen_PECL/PECL/Element Function.php

From: Date: Wed, 11 Oct 2006 10:16:03 +0000
Subject: cvs: pear /CodeGen_PECL/PECL Extension.php /CodeGen_PECL/PECL/Element Function.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42492@lists.php.net to get a copy of this message
hholzgra Wed Oct 11 10:16:03 2006 UTC Modified files: /pear/CodeGen_PECL/PECL Extension.php /pear/CodeGen_PECL/PECL/Element Function.php Log: simplified access to constants and resources http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Extension.php?r1=1.60&r2=1.61&diff_format=u Index: pear/CodeGen_PECL/PECL/Extension.php diff -u pear/CodeGen_PECL/PECL/Extension.php:1.60 pear/CodeGen_PECL/PECL/Extension.php:1.61 --- pear/CodeGen_PECL/PECL/Extension.php:1.60 Tue Oct 10 07:18:46 2006 +++ pear/CodeGen_PECL/PECL/Extension.php Wed Oct 11 10:16:02 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.60 2006/10/10 07:18:46 hholzgra Exp $ + * @version CVS: $Id: Extension.php,v 1.61 2006/10/11 10:16:02 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen_PECL */ @@ -376,6 +376,22 @@ } /** + * Get a specific resource by name + * + * @access public + * @param string resource name + * @return object resource object or false if not found + */ + function getResource($name) + { + if (isset($this->resources[$name])) { + return $this->resources[$name]; + } + + return false; + } + + /** * Get PHP constants * * @access public @@ -386,6 +402,22 @@ return $this->constants; } + /** + * Get a specific constant by name + * + * @access public + * @param string constant name + * @return object constant object or false if not found + */ + function getConstant($name) + { + if (isset($this->constants[$name])) { + return $this->constants[$name]; + } + + return false; + } + /** * Add a PHP class to the extension http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Function.php?r1=1.37&r2=1.38&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Function.php diff -u pear/CodeGen_PECL/PECL/Element/Function.php:1.37 pear/CodeGen_PECL/PECL/Element/Function.php:1.38 --- pear/CodeGen_PECL/PECL/Element/Function.php:1.37 Tue Oct 10 07:18:46 2006 +++ pear/CodeGen_PECL/PECL/Element/Function.php Wed Oct 11 10:16:02 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: Function.php,v 1.37 2006/10/10 07:18:46 hholzgra Exp $ + * @version CVS: $Id: Function.php,v 1.38 2006/10/11 10:16:02 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -492,8 +492,8 @@ break; default: // now see if this is a constand defined by this extension - $constants = $extension->getConstants(); - if (isset($constants[$token])) { + $constant = $extension->getConstant($token); + if ($constant) { $param["default"] = $constants[$token]->getValue(); } else { return PEAR::raiseError("invalid default value '$token' specification for parameter '$param[name]' ($type)"); @@ -941,15 +941,16 @@ $returns = explode(" ", $this->returns); // for functions returning a named resource we create payload pointer variable - $resources = $extension->getResources(); if ($returns[0] === "resource") { - if (isset($returns[1]) && isset($resources[$returns[1]])) { - $resource = $resources[$returns[1]]; - $payload = $resource->getPayload(); - if ($resource->getAlloc()) { - $code .= " $payload * return_res = ($payload *)ecalloc(1, sizeof($payload));\n"; - } else { - $code .= " $payload * return_res;\n"; + if (isset($returns[1])) { + $resource = $extension->getResource($returns[1]); + if ($resource) { + $payload = $resource->getPayload(); + if ($resource->getAlloc()) { + $code .= " $payload * return_res = ($payload *)ecalloc(1, sizeof($payload));\n"; + } else { + $code .= " $payload * return_res;\n"; + } } } else { $code .= " void * return_res;\n"; @@ -1084,6 +1085,7 @@ case "resource": $zvalType = true; + $resource = false; $argString .= "r"; if ($extension->haveVersion("1.0.0alpha")) { @@ -1099,9 +1101,11 @@ $code .= " zval * $resVar = NULL;\n"; $code .= " int $idVar = -1;\n"; - $resources = $extension->getResources(); - if (isset($param['subtype']) && isset($resources[$param['subtype']])) { - $resource = $resources[$param['subtype']]; + if (isset($param['subtype'])) { + $resource = $extension->getResource($param['subtype']); + } + + if ($resource) { if ($extension->haveVersion("1.0.0dev")) { $varname = $name; } else {

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