hholzgra                Thu Feb 20 10:19:14 2003 EDT

  Modified files:              
    /php4/scripts/ext_skel_ng   extension_parser.php 
  Log:
  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
  
  
Index: php4/scripts/ext_skel_ng/extension_parser.php
diff -u php4/scripts/ext_skel_ng/extension_parser.php:1.3 
php4/scripts/ext_skel_ng/extension_parser.php:1.4
--- php4/scripts/ext_skel_ng/extension_parser.php:1.3   Wed Feb 19 11:02:45 2003
+++ php4/scripts/ext_skel_ng/extension_parser.php       Thu Feb 20 10:19:14 2003
@@ -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":
@@ -223,7 +221,7 @@
                        $fp = fopen("$docdir/reference.xml", "w");
                        fputs($fp,
 "<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- \$Revision: 1.3 $ -->
+<!-- \$Revision: 1.4 $ -->
  <reference id='ref.{$this->name}'>
   <title>{$this->summary}</title>
   <titleabbrev>{$this->name}</titleabbrev>
@@ -501,6 +499,12 @@
                        $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 @@
                                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 .= "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 @@
                                                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";



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to