Browse Source

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
PHP-5
Hartmut Holzgraefe 24 years ago
parent
commit
30212544c3
  1. 22
      scripts/ext_skel_ng/extension_parser.php

22
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";

Loading…
Cancel
Save