source: stubgen.pl @ e20dd769

release-1.7release-1.8release-1.9
Last change on this file since e20dd769 was e20dd769, checked in by David Benjamin <davidben@mit.edu>, 11 years ago
Actually construct the notifier and avoid invalid property names -follow is not a valid property name.
  • Property mode set to 100755
File size: 1.6 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    my $detailname = $altvarname;
15    $detailname =~ s/[^a-zA-Z0-9]/-/g;
16    $detailname =~ s/^[^a-zA-Z]+//;
17    if ($vartype =~ /^BOOL/) {
18        print <<EOT;
19void owl_global_set_${altvarname}_on(owl_global *g) {
20  g_object_set(G_OBJECT(g->gn), "$detailname", TRUE, NULL);
21}
22void owl_global_set_${altvarname}_off(owl_global *g) {
23  g_object_set(G_OBJECT(g->gn), "$detailname", FALSE, NULL);
24}
25int owl_global_is_$altvarname(const owl_global *g) {
26  return owl_variable_get_bool(&g->vars, "$varname");
27}
28EOT
29    } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) {
30        print <<EOT;
31void owl_global_set_${altvarname}(owl_global *g, const char *text) {
32  g_object_set(G_OBJECT(g->gn), "$detailname", text, NULL);
33}
34const char *owl_global_get_$altvarname(const owl_global *g) {
35  return owl_variable_get_string(&g->vars, "$varname");
36}
37EOT
38    } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) {
39        print <<EOT;
40void owl_global_set_${altvarname}(owl_global *g, int n) {
41  g_object_set(G_OBJECT(g->gn), "$detailname", n, NULL);
42}
43int owl_global_get_$altvarname(const owl_global *g) {
44  return owl_variable_get_int(&g->vars, "$varname");
45}
46EOT
47    } 
48    }
49    }
50    close(FILE);
51    print "\n";
52}
Note: See TracBrowser for help on using the repository browser.