From: Hartmut Holzgraefe Date: Thu, 20 Feb 2003 15:19:14 +0000 (+0000) Subject: put constants into C output X-Git-Tag: RELEASE_0_5~845 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30212544c3fd1c21facfa21b5df3df91051fd683;p=php put constants into C output do not limit int constants to numbers, C #defines are ok as strings foobar(void) needs special treatment in code generation --- diff --git a/scripts/ext_skel_ng/extension_parser.php b/scripts/ext_skel_ng/extension_parser.php index fd3c54531a..1031ec0f2b 100644 --- a/scripts/ext_skel_ng/extension_parser.php +++ b/scripts/ext_skel_ng/extension_parser.php @@ -90,9 +90,7 @@ switch($type) { case "int": case "integer": - if (!is_numeric($value)) $this->error("invalid value for integer constant: '$value'"); - if ((int)$value != $value) $this->error("invalid value for integer constant: '$value'"); - $this->constants[] = &new php_constant($name, (int)$value, "integer", trim($this->cdata)); + $this->constants[] = &new php_constant($name, $value, "integer", trim($this->cdata)); break; case "float": @@ -501,6 +499,12 @@ PHP_MINIT_FUNCTION({$this->name}) $code .= "\tREGISTER_INI_ENTRIES();\n"; } + if(count($this->constants)) { + foreach($this->constants as $constant) { + $code .= $constant->c_code(); + } + } + if(isset($this->internal_functions['MINIT'])) { if(count($this->globals) || count($this->phpini)) $code .= "\n\t{\n"; $code .= $this->internal_functions['MINIT']->code; @@ -634,8 +638,10 @@ $code .= " foreach ($func->params as $key => $param) { if (!empty($param['optional'])) $code.=" ["; if ($key) $code.=", "; - $code .= $param['type']." "; - $code .= isset($param['name']) ? $param['name'] : "par_$key"; + $code .= $param['type']; + if($param['type'] != "void") { + $code .= isset($param['name']) ? $param['name'] : "par_$key"; + } } } for ($n=$func->optional; $n>0; $n--) { @@ -647,7 +653,6 @@ $code .= " $code .= "PHP_FUNCTION({$func->name})\n"; $code .= "{\n"; - $code .= "\tint argc = ZEND_NUM_ARGS();\n\n"; if (isset($func->params)) { $arg_string=""; @@ -715,11 +720,14 @@ $code .= " break; } } + } + if(strlen($arg_string)) { + $code .= "\tint argc = ZEND_NUM_ARGS();\n\n"; $code .= "\n\tif (zend_parse_parameters(argc TSRMLS_CC, \"$arg_string\", ".join(", ",$arg_pointers).") == FAILURE) return;\n"; if($res_fetch) $code.="\n$res_fetch\n"; } else { - $code .= "\tif(argc>0) { WRONG_PARAM_COUNT; }\n"; + $code .= "\tif(ZEND_NUM_ARGS()>0) { WRONG_PARAM_COUNT; }\n"; } $code .= "\n";