summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHartmut Holzgraefe <hholzgra@php.net>2003-04-23 16:38:22 +0000
committerHartmut Holzgraefe <hholzgra@php.net>2003-04-23 16:38:22 +0000
commitda57d295263ae5a7beb024a05c30bcd22925a17e (patch)
tree9b5f7554bf9042e8e3ad0ae424f5cc15929f2c1b
parent9736a76171c007de8204f2bcd2c360babfb444f7 (diff)
downloadphp-git-da57d295263ae5a7beb024a05c30bcd22925a17e.tar.gz
reorganized code generation
- source file includes generated header only, generated header includes anything else and is able to prepend include statements to files that need to be included *before* any php delivered header files - 'private' functions are now moved up in the generated source file so we do not add extra C protos for them before use
-rw-r--r--scripts/ext_skel_ng/extension_parser.php51
1 files changed, 37 insertions, 14 deletions
diff --git a/scripts/ext_skel_ng/extension_parser.php b/scripts/ext_skel_ng/extension_parser.php
index 4750ad636e..023169a261 100644
--- a/scripts/ext_skel_ng/extension_parser.php
+++ b/scripts/ext_skel_ng/extension_parser.php
@@ -588,6 +588,40 @@ ZEND_GET_MODULE('.$this->name.')
fputs($fp, "#ifndef PHP_HAVE_{$upname}\n\n");
+ if(isset($this->headers)) {
+ foreach($this->headers as $header) {
+ if (@$header["prepend"] === "yes") {
+ fputs($fp, "#include <$header[name]>\n");
+ }
+ }
+ }
+
+ fputs($fp, '
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <php.h>
+#include <php_ini.h>
+#include <SAPI.h>
+#include <ext/standard/info.h>
+
+');
+
+ if(isset($this->headers)) {
+ foreach($this->headers as $header) {
+ if (@$header["prepend"] !== "yes") {
+ fputs($fp, "#include <$header[name]>\n");
+ }
+ }
+ }
+
+ if(isset($this->code["header"])) {
+ foreach($this->code["header"] as $code) {
+ fputs($fp, $code);
+ }
+ }
+
fputs($fp, "
extern zend_module_entry {$this->name}_module_entry;
#define phpext_{$this->name}_ptr &{$this->name}_module_entry
@@ -825,7 +859,7 @@ $code .= "
$code = "";
foreach($this->functions as $function) {
- $code .= $function->c_code();
+ $code .= $function->c_code(&$this);
}
return $code;
@@ -846,17 +880,6 @@ $code .= "
fputs($fp, $this->get_license());
- fputs($fp, '
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <php.h>
-#include <php_ini.h>
-#include <SAPI.h>
-#include <ext/standard/info.h>
-
-');
fputs($fp, "#include \"php_{$this->name}.h\"\n\n");
if (isset($this->logo)) {
@@ -867,6 +890,8 @@ $code .= "
fputs($fp, "ZEND_DECLARE_MODULE_GLOBALS({$this->name})\n\n");
}
+ fputs($fp, $this->private_functions_c());
+
if (!empty($this->resources)) {
foreach ($this->resources as $resource) {
fputs($fp, $resource->c_code());
@@ -889,8 +914,6 @@ $code .= "
fputs($fp, $this->internal_functions_c());
- fputs($fp, $this->private_functions_c());
-
fputs($fp, $this->public_functions_c());
fputs($fp, $this->editor_config_c());