source: stubgen.pl @ 7d4fbcd

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 7d4fbcd was 7d4fbcd, checked in by James M. Kretchmar <kretch@mit.edu>, 18 years ago
Initial check in
  • Property mode set to 100755
File size: 1.6 KB
Line 
1if ($#ARGV eq -1) {
2    @ARGV=`ls *.c`;
3    chop(@ARGV);
4}
5
6print qq(/* THIS FILE WAS AUTOGENERATED BY STUBGEN.PL --- DO NOT EDIT BY HAND!!! */\n\n);
7print qq(#include "owl.h");
8
9foreach $file (@ARGV) {
10    open(FILE, $file);
11
12    print "/* -------------------------------- $file -------------------------------- */\n";
13    while (<FILE>) {
14        if (m|^\s*OWLVAR_([A-Z_0-9]+)\s*\(\s*"([^"]+)"\s*/\*\s*%OwlVarStub:?([a-z0-9_]+)?\s*\*/|) {   # "
15    my $vartype = $1;
16    my $varname = $2;
17    my $altvarname = $2;
18    $altvarname = $3 if ($3);
19    if ($vartype =~ /^BOOL/) {
20        print "void owl_global_set_${altvarname}_on(owl_global *g) {\n";
21        print "  owl_variable_set_bool_on(&g->vars, \"$varname\");\n}\n";
22        print "void owl_global_set_${altvarname}_off(owl_global *g) {\n";
23        print "  owl_variable_set_bool_off(&g->vars, \"$varname\");\n}\n";
24        print "int owl_global_is_$altvarname(owl_global *g) {\n";
25        print "  return owl_variable_get_bool(&g->vars, \"$varname\");\n}\n";
26    } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) {
27        print "void owl_global_set_$altvarname(owl_global *g, char *text) {\n";
28        print "  owl_variable_set_string(&g->vars, \"$varname\", text);\n}\n";
29        print "char *owl_global_get_$altvarname(owl_global *g) {\n";
30        print "  return owl_variable_get_string(&g->vars, \"$varname\");\n}\n";
31    } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) {
32        print "void owl_global_set_$altvarname(owl_global *g, int n) {\n";
33        print "  owl_variable_set_int(&g->vars, \"$varname\", n);\n}\n";
34        print "int owl_global_get_$altvarname(owl_global *g) {\n";
35        print "  return owl_variable_get_int(&g->vars, \"$varname\");\n}\n";
36    } 
37    }
38    }
39    close(FILE);
40    print "\n";
41}
Note: See TracBrowser for help on using the repository browser.