1 | |
---|
2 | # $Id$ |
---|
3 | |
---|
4 | if ($#ARGV eq -1) { |
---|
5 | @ARGV=`ls *.c`; |
---|
6 | chop(@ARGV); |
---|
7 | } |
---|
8 | |
---|
9 | print qq(/* THIS FILE WAS AUTOGENERATED BY STUBGEN.PL --- DO NOT EDIT BY HAND!!! */\n\n); |
---|
10 | print qq(#include "owl.h"); |
---|
11 | |
---|
12 | foreach $file (@ARGV) { |
---|
13 | open(FILE, $file); |
---|
14 | |
---|
15 | print "/* -------------------------------- $file -------------------------------- */\n"; |
---|
16 | while (<FILE>) { |
---|
17 | if (m|^\s*OWLVAR_([A-Z_0-9]+)\s*\(\s*"([^"]+)"\s*/\*\s*%OwlVarStub:?([a-z0-9_]+)?\s*\*/|) { # " |
---|
18 | my $vartype = $1; |
---|
19 | my $varname = $2; |
---|
20 | my $altvarname = $2; |
---|
21 | $altvarname = $3 if ($3); |
---|
22 | if ($vartype =~ /^BOOL/) { |
---|
23 | print "void owl_global_set_${altvarname}_on(owl_global *g) {\n"; |
---|
24 | print " owl_variable_set_bool_on(&g->vars, \"$varname\");\n}\n"; |
---|
25 | print "void owl_global_set_${altvarname}_off(owl_global *g) {\n"; |
---|
26 | print " owl_variable_set_bool_off(&g->vars, \"$varname\");\n}\n"; |
---|
27 | print "int owl_global_is_$altvarname(owl_global *g) {\n"; |
---|
28 | print " return owl_variable_get_bool(&g->vars, \"$varname\");\n}\n"; |
---|
29 | } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) { |
---|
30 | print "void owl_global_set_$altvarname(owl_global *g, char *text) {\n"; |
---|
31 | print " owl_variable_set_string(&g->vars, \"$varname\", text);\n}\n"; |
---|
32 | print "char *owl_global_get_$altvarname(owl_global *g) {\n"; |
---|
33 | print " return owl_variable_get_string(&g->vars, \"$varname\");\n}\n"; |
---|
34 | } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) { |
---|
35 | print "void owl_global_set_$altvarname(owl_global *g, int n) {\n"; |
---|
36 | print " owl_variable_set_int(&g->vars, \"$varname\", n);\n}\n"; |
---|
37 | print "int owl_global_get_$altvarname(owl_global *g) {\n"; |
---|
38 | print " return owl_variable_get_int(&g->vars, \"$varname\");\n}\n"; |
---|
39 | } |
---|
40 | } |
---|
41 | } |
---|
42 | close(FILE); |
---|
43 | print "\n"; |
---|
44 | } |
---|