~ubuntu-branches/ubuntu/gutsy/wireshark/gutsy-security

« back to all changes in this revision

Viewing changes to epan/wslua/make-doc.pl

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2007-04-01 08:58:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070401085840-or3qhrpv8alt1bwg
Tags: 0.99.5-1
* New upstream release.
* debian/patches/09_idl2wrs.dpatch: updated to patch idl2wrs.sh.in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#
6
6
# (c) 2006, Luis E. Garcia Onatnon <luis.ontanon@gmail.com>
7
7
#
8
 
# $Id: make-doc.pl 19676 2006-10-24 22:21:04Z gerald $
 
8
# $Id: make-doc.pl 20192 2006-12-22 05:48:57Z lego $
9
9
#
10
10
# Wireshark - Network traffic analyzer
11
11
# By Gerald Combs <gerald@wireshark.org>
57
57
        module_desc => "\t<title>%s</title>\n",
58
58
        module_footer => "</chapter>\n",
59
59
        class_header => "\t<section id='lua_class_%s'><title>%s</title>\n",
 
60
        class_desc => "\t\t<para>%s</para>\n",
60
61
        class_footer => "\t</section> <!-- class_footer: %s -->\n",
61
 
        class_desc => "\t\t<para>%s</para>\n",
62
 
        class_constructors_header => "\t\t<section id='lua_class_constructors_%s'>\n\t\t\t<title>%s Constructors</title>\n",
63
 
        class_constructors_footer => "\t\t</section> <!-- class_constructors_footer -->\n",
64
 
        class_methods_header => "\t\t<section id='lua_class_methods_%s'>\n\t\t\t<title>%s Methods</title>\n",
65
 
        class_methods_footer => "\t\t</section> <!-- class_methods_footer: %s -->\n",
66
 
        class_attributes_header => "\t\t<section id='lua_class_attribs_%s'>\n\t\t\t<title>%s Attributes</title>\n",
67
 
        class_attributes_footer => "\t\t</section> <!-- class_attributes_footer: %s -->\n",
 
62
#       class_constructors_header => "\t\t<section id='lua_class_constructors_%s'>\n\t\t\t<title>%s Constructors</title>\n",
 
63
#       class_constructors_footer => "\t\t</section> <!-- class_constructors_footer -->\n",
 
64
#       class_methods_header => "\t\t<section id='lua_class_methods_%s'>\n\t\t\t<title>%s Methods</title>\n",
 
65
#       class_methods_footer => "\t\t</section> <!-- class_methods_footer: %s -->\n",
68
66
        class_attr_header => "\t\t<section id='lua_class_attrib_%s'>\n\t\t\t<title>%s</title>\n",
69
67
        class_attr_footer => "\t\t</section> <!-- class_attr_footer: %s -->\n",
70
68
        class_attr_descr => "\t\t\t<para>%s</para>\n",
89
87
        non_method_functions_footer => "\t\t</section> <!-- Non method -->\n",
90
88
};
91
89
 
92
 
my $wiki_template = {
93
 
        class_header => "= %s =\n",
94
 
        class_desc => "%s\n",
95
 
        class_constructors_header => "== %s constructors ==\n",
96
 
        class_methods_header => "== %s methods ==\n",
97
 
        class_attributes_header => "== %s Attributes ==\n",
98
 
        class_attr_header => "=== %s ===\n",
99
 
        class_attr_descr => "%s\n",
100
 
        function_header => "=== %s ===\n",
101
 
        function_descr => "%s\n",
102
 
        function_arg_header => "==== %s ====\n",
103
 
        function_arg_descr => "%s\n",
104
 
        function_argerrors_header => "'''Errors:'''\n",
105
 
        function_argerror => "  * %s\n",
106
 
        function_returns_header => "==== returns ====\n",
107
 
        function_returns => "  * %s\n",
108
 
        function_errors_header => "==== errors ====\n",
109
 
        function_errors => "  * %s\n",
110
 
        non_method_functions_header => "= Non method functions =\n",
111
 
};
112
 
 
113
 
 
114
 
my %metamethods = %{{
115
 
        __tostring => "tostring(__)",
116
 
        __index => "__[]",
117
 
        __newindex => "__[] = ",
118
 
        __add => "__ + __",
119
 
        __sub => "__ - __",
120
 
        __mul => "__ * __",
121
 
        __div => "__ / __",
122
 
        __mod => "__ % __",
123
 
        __pow => "__ ^ __",
124
 
        __unm => "-___",
125
 
        __concat => "__ .. __",
126
 
        __len => "#__",
127
 
        __call => "__()",
128
 
        __eq => "__ == __",
129
 
        __lt => "__ < __",
130
 
        __le => "__ <= __",
131
 
}};
132
90
 
133
91
my $template_ref = $docbook_template;
134
92
my $out_extension = "xml";
150
108
        $module{descr} = $2
151
109
}],
152
110
 
153
 
 [ 'WSLUA_CLASS_DEFINE\050\s*([A-Z][a-zA-Z]+)\s*,.*?\051' . $TRAILING_COMMENT_RE,
 
111
 [ 'WSLUA_CLASS_DEFINE\050\s*([A-Z][a-zA-Z]+).*?\051;' . $TRAILING_COMMENT_RE,
154
112
sub {
155
113
        deb ">c=$1=$2=$3=$4=$5=$6=$7=\n";
156
114
        $class = {
158
116
                descr=> gorolla($4),
159
117
                constructors => [],
160
118
                methods => [],
161
 
                metamethods => [],
162
119
                attributes => []
163
120
        };
164
121
        $classes{$1} = $class;
178
135
        push @functions, $function;
179
136
} ] ,
180
137
 
181
 
[ 'WSLUA_CONSTRUCTOR\s+([A-Za-z]+)_([a-z_]+).*?\173' . $TRAILING_COMMENT_RE,
 
138
[ 'WSLUA_CONSTRUCTOR\s+([A-Za-z0-9]+)_([a-z0-9_]+).*?\173' . $TRAILING_COMMENT_RE,
182
139
sub {
183
140
        deb ">cc=$1=$2=$3=$4=$5=$6=$7=\n";
184
141
        $function = {
192
149
        push @{${$class}{constructors}}, $function;
193
150
} ] ,
194
151
 
195
 
[ 'WSLUA_METHOD\s+([A-Za-z]+)_([a-z_]+)[^\173]*\173' . $TRAILING_COMMENT_RE,
 
152
[ '_WSLUA_CONSTRUCTOR_\s+([A-Za-z0-9]+)_([a-z0-9_]+)\s*(.*?)\052\057',
 
153
        sub {
 
154
                deb ">cc=$1=$2=$3=$4=$5=$6=$7=\n";
 
155
                $function = {
 
156
                        returns => [],
 
157
                        arglist => [],
 
158
                        args => {},
 
159
                        name => "$1.$2",
 
160
                        descr => gorolla($3),
 
161
                        type => 'constructor'
 
162
                };
 
163
                push @{${$class}{constructors}}, $function;
 
164
        } ] ,
 
165
 
 
166
[ 'WSLUA_METHOD\s+([A-Za-z]+)_([a-z0-9_]+)[^\173]*\173' . $TRAILING_COMMENT_RE,
196
167
        sub {
197
168
                deb ">cm=$1=$2=$3=$4=$5=$6=$7=\n";
 
169
                my $name = "$1";
 
170
                $name =~ tr/A-Z/a-z/;
 
171
                $name .= ":$2";
198
172
                $function = {
199
173
                        returns => [],
200
174
                        arglist => [],
201
175
                        args => {},
202
 
                        name => "$1:$2",
 
176
                        name => $name,
203
177
                        descr => gorolla($5),
204
178
                        type => 'method'
205
179
                };
206
180
                push @{${$class}{methods}}, $function;
207
181
        } ] ,
208
182
 
209
 
[ 'WSLUA_METAMETHOD\s+([A-Za-z]+)(__[a-z]+)[^\173]*\173' . $TRAILING_COMMENT_RE,
 
183
[ 'WSLUA_METAMETHOD\s+([A-Za-z]+)(__[a-z0-9]+)[^\173]*\173' . $TRAILING_COMMENT_RE,
210
184
        sub {
211
185
                deb ">cm=$1=$2=$3=$4=$5=$6=$7=\n";
212
 
                my $name = $metamethods{$2};
 
186
                my $name = "$1";
 
187
                $name =~ tr/A-Z/a-z/;
 
188
                $name .= ":$2";
213
189
                my ($c,$d) = ($1,$5);
214
190
                $function = {
215
191
                        returns => [],
216
192
                        arglist => [],
217
193
                        args => {},
218
 
                        name => "$1:$2",
 
194
                        name => $name,
219
195
                        descr => gorolla($5),
220
196
                        type => 'metamethod'
221
197
                };
222
 
                push @{${$class}{metamethods}}, $function;
 
198
                push @{${$class}{methods}}, $function;
223
199
        } ] ,
224
200
 
225
 
[ '#define WSLUA_(OPT)?ARG_([a-z_]+)_([A-Z0-9]+)\s+\d+' . $TRAILING_COMMENT_RE,
 
201
[ '#define WSLUA_(OPT)?ARG_([a-z0-9_]+)_([A-Z0-9]+)\s+\d+' . $TRAILING_COMMENT_RE,
226
202
sub {
227
203
        deb ">a=$1=$2=$3=$4=$5=$6=$7=\n";
228
 
        push @{${$function}{arglist}} , $3;
229
 
        ${${$function}{args}}{$3} = {descr=>$6}
 
204
        my $name = $1 eq 'OPT' ? "[$3]" : $3;
 
205
        push @{${$function}{arglist}} , $name;
 
206
        ${${$function}{args}}{$name} = {descr=>$6,}
 
207
} ],
 
208
 
 
209
[ '\057\052\s*WSLUA_(OPT)?ARG_([A-Za-z0-9_]+)_([A-Z0-9]+)\s*(.*?)\052\057',
 
210
        sub {
 
211
                deb ">a=$1=$2=$3=$4=$5=$6=$7=\n";
 
212
                my $name = $1 eq 'OPT' ? "[$3]" : $3;
 
213
                push @{${$function}{arglist}} , $name;
 
214
                ${${$function}{args}}{$name} = {descr=>$4,}
230
215
} ],
231
216
 
232
217
[ '#define WSLUA_(OPT)?ARG_([A-Za-z]+)_([a-z_]+)_([A-Z0-9]+)\s+\d+' . $TRAILING_COMMENT_RE,
233
218
sub {
234
219
        deb ">ca=$1=$2=$3=$4=$5=$6=$7=\n";
235
 
        push @{${$function}{arglist}} , $4;
236
 
        ${${$function}{args}}{$4} = {descr=>$7}
 
220
        my $name = $1 eq 'OPT' ? "[$4]" : $4;
 
221
        push @{${$function}{arglist}} , $name;
 
222
        ${${$function}{args}}{$name} = {descr=>$7,optional => $1 eq '' ? 1 : 0 }
237
223
} ],
238
224
 
239
225
[ '/\052\s+WSLUA_ATTRIBUTE\s+([A-Za-z]+)_([a-z_]+)\s+([A-Z]*)\s*(.*?)\052/',
240
226
        sub {
241
227
                deb ">at=$1=$2=$3=$4=$5=$6=$7=\n";
242
 
                push @{${$class}{attributes}}, { name => $2, descr => gorolla($4), mode=>$3 };
 
228
                my $name = "$1";
 
229
                $name =~ tr/A-Z/a-z/;
 
230
                $name .= ".$2";
 
231
                push @{${$class}{attributes}}, { name => $name, descr => gorolla($4), mode=>$3 };
243
232
        } ],
244
233
 
245
234
[ '/\052\s+WSLUA_MOREARGS\s+([A-Za-z_]+)\s+(.*?)\052/',
255
244
        push @{${$function}{returns}} , gorolla($4) if $4 ne '';
256
245
} ],
257
246
 
 
247
[ '\057\052\s*_WSLUA_RETURNS_\s*(.*?)\052\057',
 
248
        sub { 
 
249
                deb ">fr2=$1=$2=$3=$4=$5=$6=$7=\n";
 
250
                push @{${$function}{returns}} , gorolla($1) if $1 ne '';
 
251
} ],
 
252
 
258
253
[ 'WSLUA_ERROR\s*\050\s*(([A-Z][A-Za-z]+)_)?([a-z_]+),' . $QUOTED_RE ,
259
254
        sub { 
260
255
                deb ">e=$1=$2=$3=$4=$5=$6=$7=\n";
328
323
        for my $cname (sort keys %classes) {
329
324
                my $cl = $classes{$cname};
330
325
                printf D ${$template_ref}{class_header}, $cname, $cname;
331
 
                printf D ${$template_ref}{class_desc} , ${$cl}{descr} if ${$cl}{descr};
 
326
                
 
327
                if ( ${$cl}{descr} ) {
 
328
                        printf D ${$template_ref}{class_desc} , ${$cl}{descr};
 
329
                }
332
330
                
333
331
                if ( $#{${$cl}{constructors}} >= 0) {
334
332
#                       printf D ${$template_ref}{class_constructors_header}, $cname, $cname;
346
344
                        for my $m (@{${$cl}{methods}}) {
347
345
                                function_descr($m);
348
346
                        }
349
 
                        
350
 
                        for my $m (@{${$cl}{metamethods}}) {
351
 
                                function_descr($m);
352
 
                        }
353
 
                        
 
347
                                                
354
348
#                       printf D ${$template_ref}{class_methods_footer}, $cname, $cname;
355
349
                }
356
350
                
357
351
                if ( $#{${$cl}{attributes}} >= 0) {
358
 
                        printf D ${$template_ref}{class_attributes_header}, $cname, $cname;
359
 
                        
360
352
                        for my $a (@{${$cl}{attributes}}) {
361
353
                                printf D ${$template_ref}{class_attr_header}, ${$a}{name}, ${$a}{name};
362
354
                                printf D ${$template_ref}{class_attr_descr}, ${$a}{descr}, ${$a}{descr} if ${$a}{descr};
363
355
                                printf D ${$template_ref}{class_attr_footer}, ${$a}{name}, ${$a}{name};
364
356
                                
365
357
                        }
366
 
                        
367
 
                        printf D ${$template_ref}{class_attributes_footer}, $cname, $cname;
368
358
                }
369
359
                
370
360
                if (exists ${$template_ref}{class_footer}) {
445
435
        for my $argname (@{${$f}{arglist}}) {
446
436
                my $arg = ${${$f}{args}}{$argname};
447
437
                $argname =~ tr/A-Z/a-z/;
448
 
                
 
438
                $argname =~ s/\[(.*)\]/$1 (optional)/;
 
439
 
449
440
                printf D ${$template_ref}{function_arg_header}, $argname, $argname;
450
441
                printf D ${$template_ref}{function_arg_descr}, ${$arg}{descr} , ${$arg}{descr} if ${$arg}{descr};
451
442