]> granicus.if.org Git - php/commitdiff
add 'extern "C"' where needed for C++
authorHartmut Holzgraefe <hholzgra@php.net>
Tue, 6 May 2003 16:53:18 +0000 (16:53 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Tue, 6 May 2003 16:53:18 +0000 (16:53 +0000)
(TODO: shouldn't this be done in the appropriate php headers
and Zend macros themselves?)

scripts/ext_skel_ng/extension_parser.php

index ef8c5de775188ab9fcab93d509b191f152c083d2..1d22cd3097ddaf3cf87710cc3b0221f337655033 100644 (file)
          // {{{   extension entry
 
                function generate_extension_entry() {
-                       return '
-/* {{{ '.$this->name.'_module_entry
+      $name = $this->name;
+      $upname = strtoupper($this->name);
+
+                       $code = "
+/* {{{ {$name}_module_entry
  */
-zend_module_entry '.$this->name.'_module_entry = {
+zend_module_entry {$name}_module_entry = {
        STANDARD_MODULE_HEADER,
-       "'.$this->name.'",
-       '.$this->name.'_functions,
-       PHP_MINIT('.$this->name.'),     /* Replace with NULL if there is nothing to do at php startup   */ 
-       PHP_MSHUTDOWN('.$this->name.'), /* Replace with NULL if there is nothing to do at php shutdown  */
-       PHP_RINIT('.$this->name.'),               /* Replace with NULL if there is nothing to do at request start */
-       PHP_RSHUTDOWN('.$this->name.'), /* Replace with NULL if there is nothing to do at request end   */
-       PHP_MINFO('.$this->name.'),
-       "'.$this->release['version'].'", 
+       \"$name\",
+       {$name}_functions,
+       PHP_MINIT($name),     /* Replace with NULL if there is nothing to do at php startup   */ 
+       PHP_MSHUTDOWN($name), /* Replace with NULL if there is nothing to do at php shutdown  */
+       PHP_RINIT($name),                 /* Replace with NULL if there is nothing to do at request start */
+       PHP_RSHUTDOWN($name),   /* Replace with NULL if there is nothing to do at request end   */
+       PHP_MINFO($name),
+       \"".$this->release['version']."\", 
        STANDARD_MODULE_PROPERTIES
 };
 /* }}} */
 
-#ifdef COMPILE_DL_'.strtoupper($this->name).'
-ZEND_GET_MODULE('.$this->name.')
-#endif
-';
+";
+
+      $code .= "#ifdef COMPILE_DL_$upname\n";
+           if ($this->language == "cpp") $code .= "extern \"C\" {\n";
+      $code .= "ZEND_GET_MODULE($name)\n";
+           if ($this->language == "cpp") $code .= "}\n";
+           $code .= "#endif\n\n";
+
+                       return $code;
                }
 
        // }}} 
@@ -540,6 +548,10 @@ ZEND_GET_MODULE('.$this->name.')
                                }
                        }
 
+                       if ($this->language == "cpp") {
+                               fputs($fp, "extern \"C\" {\n");
+                       }
+
                        fputs($fp, '
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -552,6 +564,10 @@ ZEND_GET_MODULE('.$this->name.')
 
 ');
 
+                       if ($this->language == "cpp") {
+                               fputs($fp, "}\n");
+                       }
+
                        if (isset($this->headers)) {
                                foreach ($this->headers as $header) {
                                        if (@$header["prepend"] !== "yes") {