forked from barnowl/barnowl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
stubgen.pl
executable file
·36 lines (34 loc) · 1.77 KB
/
stubgen.pl
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
print qq(/* THIS FILE WAS AUTOGENERATED BY STUBGEN.PL --- DO NOT EDIT BY HAND!!! */\n\n);
print qq(#include "owl.h");
foreach $file (@ARGV) {
open(FILE, $file);
print "/* -------------------------------- $file -------------------------------- */\n";
while (<FILE>) {
if (m|^\s*OWLVAR_([A-Z_0-9]+)\s*\(\s*"([^"]+)"\s*/\*\s*%OwlVarStub:?([a-z0-9_]+)?\s*\*/|) { # "
my $vartype = $1;
my $varname = $2;
my $altvarname = $2;
$altvarname = $3 if ($3);
if ($vartype =~ /^BOOL/) {
print "void owl_global_set_${altvarname}_on(owl_global *g) {\n";
print " owl_variable_set_bool_on(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
print "void owl_global_set_${altvarname}_off(owl_global *g) {\n";
print " owl_variable_set_bool_off(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
print "int owl_global_is_$altvarname(const owl_global *g) {\n";
print " return owl_variable_get_bool(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
} elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) {
print "void owl_global_set_$altvarname(owl_global *g, const char *text) {\n";
print " owl_variable_set_string(owl_variable_get_var(&g->vars, \"$varname\"), text);\n}\n";
print "const char *owl_global_get_$altvarname(const owl_global *g) {\n";
print " return owl_variable_get_string(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
} elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) {
print "void owl_global_set_$altvarname(owl_global *g, int n) {\n";
print " owl_variable_set_int(owl_variable_get_var(&g->vars, \"$varname\"), n);\n}\n";
print "int owl_global_get_$altvarname(const owl_global *g) {\n";
print " return owl_variable_get_int(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
}
}
}
close(FILE);
print "\n";
}