source: stubgen.pl @ eb20731

release-1.10release-1.8release-1.9
Last change on this file since eb20731 was ca54fd6, checked in by Jason Gross <jgross@mit.edu>, 13 years ago
Pass owl_variable * around instead of owl_vardict *. This allows (forces) functions to do their own NULL- and type- checking on variables. The functions in varsubs.c get less checking, but if these auto-generated functions are failing, something more serious is probably wrong. The owl_variable_get_* functions type-check their arguments, and owl_function_error if the argument is the wrong type (it's a programmer error and we should make some noise).
  • Property mode set to 100755
File size: 1.8 KB
Line 
1print qq(/* THIS FILE WAS AUTOGENERATED BY STUBGEN.PL --- DO NOT EDIT BY HAND!!! */\n\n);
2print qq(#include "owl.h");
3
4foreach $file (@ARGV) {
5    open(FILE, $file);
6
7    print "/* -------------------------------- $file -------------------------------- */\n";
8    while (<FILE>) {
9        if (m|^\s*OWLVAR_([A-Z_0-9]+)\s*\(\s*"([^"]+)"\s*/\*\s*%OwlVarStub:?([a-z0-9_]+)?\s*\*/|) {   # "
10    my $vartype = $1;
11    my $varname = $2;
12    my $altvarname = $2;
13    $altvarname = $3 if ($3);
14    if ($vartype =~ /^BOOL/) {
15        print "void owl_global_set_${altvarname}_on(owl_global *g) {\n";
16        print "  owl_variable_set_bool_on(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
17        print "void owl_global_set_${altvarname}_off(owl_global *g) {\n";
18        print "  owl_variable_set_bool_off(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
19        print "int owl_global_is_$altvarname(const owl_global *g) {\n";
20        print "  return owl_variable_get_bool(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
21    } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) {
22        print "void owl_global_set_$altvarname(owl_global *g, const char *text) {\n";
23        print "  owl_variable_set_string(owl_variable_get_var(&g->vars, \"$varname\"), text);\n}\n";
24        print "const char *owl_global_get_$altvarname(const owl_global *g) {\n";
25        print "  return owl_variable_get_string(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
26    } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) {
27        print "void owl_global_set_$altvarname(owl_global *g, int n) {\n";
28        print "  owl_variable_set_int(owl_variable_get_var(&g->vars, \"$varname\"), n);\n}\n";
29        print "int owl_global_get_$altvarname(const owl_global *g) {\n";
30        print "  return owl_variable_get_int(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
31    } 
32    }
33    }
34    close(FILE);
35    print "\n";
36}
Note: See TracBrowser for help on using the repository browser.