[7d4fbcd] | 1 | print qq(/* THIS FILE WAS AUTOGENERATED BY STUBGEN.PL --- DO NOT EDIT BY HAND!!! */\n\n); |
---|
| 2 | print qq(#include "owl.h"); |
---|
| 3 | |
---|
| 4 | foreach $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); |
---|
[f57a106] | 14 | my $detailname = $altvarname; |
---|
| 15 | $detailname =~ s/[^a-zA-Z0-9]/-/g; |
---|
[7d4fbcd] | 16 | if ($vartype =~ /^BOOL/) { |
---|
[f57a106] | 17 | print <<EOT; |
---|
| 18 | void owl_global_set_${altvarname}_on(owl_global *g) { |
---|
| 19 | g_object_set(G_OBJECT(g->gn), "$detailname", TRUE, NULL); |
---|
| 20 | } |
---|
| 21 | void owl_global_set_${altvarname}_off(owl_global *g) { |
---|
| 22 | g_object_set(G_OBJECT(g->gn), "$detailname", FALSE, NULL); |
---|
| 23 | } |
---|
| 24 | int owl_global_is_$altvarname(const owl_global *g) { |
---|
| 25 | return owl_variable_get_bool(&g->vars, "$varname"); |
---|
| 26 | } |
---|
| 27 | EOT |
---|
[7d4fbcd] | 28 | } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) { |
---|
[f57a106] | 29 | print <<EOT; |
---|
| 30 | void owl_global_set_${altvarname}(owl_global *g, const char *text) { |
---|
| 31 | g_object_set(G_OBJECT(g->gn), "$detailname", text, NULL); |
---|
| 32 | } |
---|
| 33 | const char *owl_global_get_$altvarname(const owl_global *g) { |
---|
| 34 | return owl_variable_get_string(&g->vars, "$varname"); |
---|
| 35 | } |
---|
| 36 | EOT |
---|
[7d4fbcd] | 37 | } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) { |
---|
[f57a106] | 38 | print <<EOT; |
---|
| 39 | void owl_global_set_${altvarname}(owl_global *g, int n) { |
---|
| 40 | g_object_set(G_OBJECT(g->gn), "$detailname", n, NULL); |
---|
| 41 | } |
---|
| 42 | int owl_global_get_$altvarname(const owl_global *g) { |
---|
| 43 | return owl_variable_get_int(&g->vars, "$varname"); |
---|
| 44 | } |
---|
| 45 | EOT |
---|
[7d4fbcd] | 46 | } |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | close(FILE); |
---|
| 50 | print "\n"; |
---|
| 51 | } |
---|