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

From: Date: Wed, 18 Oct 2006 01:25:26 +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-42616@lists.php.net to get a copy of this message
hholzgra Wed Oct 18 01:25:26 2006 UTC Modified files: /pear/CodeGen_PECL/PECL/Element Function.php /pear/CodeGen_PECL/PECL Extension.php Log: arg_info and version requirement infrastructure for "return by reference" http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Element/Function.php?r1=1.42&r2=1.43&diff_format=u Index: pear/CodeGen_PECL/PECL/Element/Function.php diff -u pear/CodeGen_PECL/PECL/Element/Function.php:1.42 pear/CodeGen_PECL/PECL/Element/Function.php:1.43 --- pear/CodeGen_PECL/PECL/Element/Function.php:1.42 Wed Oct 18 00:23:02 2006 +++ pear/CodeGen_PECL/PECL/Element/Function.php Wed Oct 18 01:25:26 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.42 2006/10/18 00:23:02 hholzgra Exp $ + * @version CVS: $Id: Function.php,v 1.43 2006/10/18 01:25:26 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -1476,7 +1476,15 @@ // generate refargs mask if needed $code.= "#if (PHP_MAJOR_VERSION >= 5)\n"; - $code.= "ZEND_BEGIN_ARG_INFO($argInfoName, 0)\n"; + $minArgs = 0; + foreach ($params as $param) { + if (isset($param["optional"])) break; + $minArgs++; + } + + $code.= sprintf("ZEND_BEGIN_ARG_INFO_EX($argInfoName, ZEND_SEND_BY_VAL, ZEND_RETURN_%s, %d)\n", + isset($this->returns["byRef"]) ? "REFERENCE" : "VALUE", + $minArgs); foreach ($params as $param) { switch ($param["type"]) { @@ -1620,6 +1628,23 @@ return $code; } + + /** + * Return minimal PHP version required to support the requested features + * + * @return string version string + */ + function minPhpVersion() + { + // return by reference only exist in 5.1 and above + if (isset($this->returns["byRef"])) { + return "5.1.0rc1"; + } + + // default: 4.0 + return "4.0.0"; // TODO test for real lower bound + } + } /* http://cvs.php.net/viewvc.cgi/pear/CodeGen_PECL/PECL/Extension.php?r1=1.63&r2=1.64&diff_format=u Index: pear/CodeGen_PECL/PECL/Extension.php diff -u pear/CodeGen_PECL/PECL/Extension.php:1.63 pear/CodeGen_PECL/PECL/Extension.php:1.64 --- pear/CodeGen_PECL/PECL/Extension.php:1.63 Wed Oct 18 00:23:02 2006 +++ pear/CodeGen_PECL/PECL/Extension.php Wed Oct 18 01:25:26 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.63 2006/10/18 00:23:02 hholzgra Exp $ + * @version CVS: $Id: Extension.php,v 1.64 2006/10/18 01:25:26 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen_PECL */ @@ -2440,23 +2440,30 @@ */ function minPhpVersion() { + // min. default: 4.0 + $version = "4.0.0"; // TODO test for real lower bound + + // we only support the 5.0 (ZE2) OO api + if (!empty($this->classes) || !empty($this->interfaces)) { + $version = $this->maxVersion($version, "5.0.0"); + } + // extension interdependencies only exist in 5.1 and above if (!empty($this->otherExtensions)) { - return "5.1.0rc1"; + $version = $this->maxVersion($version, "5.1.0rc1"); } - // return by reference only exist in 5.1 and above - if (isset($this->returns["byRef"])) { - return "5.1.0rc1"; - } + // check function requirements + foreach ($this->functions as $function) { + $version = $this->maxVersion($version, $function->minPhpVersion()); + } - // we only support the 5.0 (ZE2) OO api - if (!empty($this->classes) || !empty($this->interfaces)) { - return "5.0.0"; - } + return $version; + } - // default: 4.0 - return "4.0.0"; // TODO test for real lower bound + function maxVersion($v1, $v2) + { + return version_compare($v1, $v2) > 0 ? $v1 : $v2; } /**

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