File: zendapi_macros.php

package info (click to toggle)
php-doc 20100521-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 59,992 kB
  • ctags: 4,085
  • sloc: xml: 796,833; php: 21,338; cpp: 500; sh: 117; makefile: 58; awk: 28
file content (163 lines) | stat: -rw-r--r-- 4,674 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
$overwrite = false;

$zend_include_dir = "../../php-src/Zend";

$zend_include_files = array(
                            "zend.h", 
                            "zend_API.h", 
                            "zend_builtin_functions.h",
                            "zend_compile.h",
                            "zend_constants.h",
                            "zend_exceptions.h",
                            "zend_execute.h",
                            "zend_hash.h", 
                            "zend_highlight.h",
                            "zend_interfaces.h",
                            "zend_ini.h",
                            "zend_list.h", 
                            "zend_modules.h",
                            "zend_objects.h",
                            "zend_object_handlers.h",
                            "zend_objects_API.h",
                            "zend_qsort.h",
                            "zend_stream.h",
                            "zend_strtod.h",
                            "zend_unicode.h",
                            "zend_variables.h",
                            "../TSRM/TSRM.h",
                            "../TSRM/tsrm_virtual_cwd.h",
                            );

$output_dirs = array("../en/internals/zendapi/macros" => array("ZEND_", "Z_", "RETURN_"), 
                     "../en/internals/tsrm/macros" => array("VCWD_"));

foreach ($zend_include_files as $infile) {
  echo "processing $zend_include_dir/$infile\n";
  
  $in = fopen("$zend_include_dir/$infile", "r");
  
  if (!$in) {
    die("can't open $zend_include_dir/$infile");
  }
  
  // loop over all lines in the file
  while (!feof($in)) {
    $line = trim(fgets($in));

    // now check for all known macro prefixes
    foreach ($output_dirs as $output_dir => $macro_prefixes) {
      foreach ($macro_prefixes as $prefix) {
        // does this line match a macro definition?
        if (preg_match("|#define\\s*($prefix\\w+)\\((.*)\\)|U", $line, $matches)) {
          // get macro name and parameter list from the matches
          $macro  = $matches[1];
          $params = preg_split('|,\s+|', $matches[2]);

          // path to output file
          $outfile = $output_dir."/".$macro.".xml";

          // do not overwrite existing files unless specified
          if ($overwrite || !file_exists($outfile)) {
            echo "writing $outfile\n";
            // now write the template file to phpdoc/en/internals/zendapi/macros
            ob_start();
          
            echo '<?xml version="1.0" encoding="iso-8859-1"?>'."\n";
          
            // take revision from existing file if any, else it is 1.1
            if (!$overwrite || !file_exists($outfile)) {
              echo "<!-- $"."Revision: 1.1 $ -->\n";
            } else {
              foreach (file($outfile) as $line) {
                if (strstr($line, 'Revision: ')) {
                  echo $line;
                  break;
                }
              }
            }
?>
<refentry id="zend-macro.<?php echo strtolower(str_replace("_", "-", $macro)); ?>">
 <refnamediv>
  <refname><?php echo $macro; ?></refname>
  <refpurpose>...</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;          
  <literallayout>#include &lt;<?php echo basename($infile); ?>&gt;</literallayout>
  <methodsynopsis>
   <type>???</type><methodname><?php echo $macro; ?></methodname>
<?php
            foreach($params as $param) {
              echo "    <methodparam><type>???</type><parameter>$param</parameter></methodparam>\n";
            }
?>
  </methodsynopsis>
  <para>
   ...
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
<?php
            foreach($params as $param) {
?>
    <varlistentry>
     <term><parameter><?php echo $param; ?></parameter></term>
     <listitem>
      <para>
       ...
      </para>
     </listitem>
    </varlistentry>
<?php
            }
?>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   ...
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
<?php
       
            file_put_contents($outfile, ob_get_clean());
          }
        }
      }
    }
  }
  
}
?>