Skip to content

Commit 9bfaa22

Browse files
committed
extract bind_names
1 parent 47cb4f7 commit 9bfaa22

File tree

3 files changed

+37
-32
lines changed

3 files changed

+37
-32
lines changed

utils/common.pl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ sub save_file {
3232
}
3333
}
3434

35+
sub bind_names {
36+
my ($name, $s) = @_;
37+
$s->{has_ptr_arg} ? $name . '_c' : $name;
38+
}
39+
3540
1;

utils/generate-XS.pl

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,41 @@ sub munge_GL_args {
3434
}
3535

3636
sub generate_glew_xs {
37-
my $content;
38-
for my $name (@_ ? @_ : sort keys %signature) {
39-
my $item = $signature{$name};
40-
if ( is_manual($name) ) {
41-
print "Skipping $name, already implemented in Modern.xs\n";
42-
next;
43-
}
44-
my $argdata = $item->{argdata};
45-
my @argdata = @{$argdata || []};
46-
my $type = $item->{restype};
47-
my $glewImpl = $item->{glewImpl};
48-
my $args = join ', ', map $_->[0], @argdata;
49-
my $xs_args = join '', map " $_->[1]$_->[0];\n", @argdata;
50-
my $binding_name = $item->{has_ptr_arg} ? $name . '_c' : $name;
51-
my $decl = <<XS;
37+
my $content;
38+
for my $name (@_ ? @_ : sort keys %signature) {
39+
my $item = $signature{$name};
40+
if ( is_manual($name) ) {
41+
print "Skipping $name, already implemented in Modern.xs\n";
42+
next;
43+
}
44+
my $argdata = $item->{argdata};
45+
my @argdata = @{$argdata || []};
46+
my $type = $item->{restype};
47+
my $glewImpl = $item->{glewImpl};
48+
my $args = join ', ', map $_->[0], @argdata;
49+
my $xs_args = join '', map " $_->[1]$_->[0];\n", @argdata;
50+
my ($binding_name) = bind_names($name, $item);
51+
my $decl = <<XS;
5252
$type
5353
$binding_name($args);
5454
XS
55-
$decl .= $xs_args;
56-
my $error_check = $name eq "glGetError" ? "" : "OGLM_CHECK_ERR($name)";
57-
my $res = $decl . <<XS;
55+
$decl .= $xs_args;
56+
my $error_check = $name eq "glGetError" ? "" : "OGLM_CHECK_ERR($name)";
57+
my $res = $decl . <<XS;
5858
CODE:
59-
OGLM_GLEWINIT@{[$error_check && "\n $error_check"]}
60-
XS
61-
if ( $item->{glewtype} eq 'fun' and $glewImpl ) {
62-
$res .= " OGLM_AVAIL_CHECK($glewImpl, $name)\n";
63-
}
64-
my ($retcap, $retout) = $type eq 'void' ? ('','') : ('RETVAL = ', "\nOUTPUT:\n RETVAL");
65-
my $arg_list = $item->{glewtype} eq 'var' ? "" : "($args)";
66-
$res .= <<XS;
67-
$retcap$name$arg_list;@{[$error_check && "\n $error_check"]}$retout
59+
OGLM_GLEWINIT@{[$error_check && "\n $error_check"]}
6860
XS
69-
$content .= "$res\n";
61+
if ( $item->{glewtype} eq 'fun' and $glewImpl ) {
62+
$res .= " OGLM_AVAIL_CHECK($glewImpl, $name)\n";
7063
}
71-
return $content;
64+
my ($retcap, $retout) = $type eq 'void' ? ('','') : ('RETVAL = ', "\nOUTPUT:\n RETVAL");
65+
my $arg_list = $item->{glewtype} eq 'var' ? "" : "($args)";
66+
$res .= <<XS;
67+
$retcap$name$arg_list;@{[$error_check && "\n $error_check"]}$retout
68+
XS
69+
$content .= "$res\n";
70+
}
71+
return $content;
7272
}
7373

7474
my $xs_code = generate_glew_xs(@ARGV);

utils/generate-registry.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ sub preprocess_for_registry {
150150
my (%features, %gltags);
151151
for my $name (sort {uc$a cmp uc$b} keys %signature) {
152152
my $s = $signature{$name};
153-
my $binding_name = $s->{has_ptr_arg} ? $name . '_c' : $name;
154-
push @exported_functions, $binding_name if !is_manual($name);
153+
my @binding_names = bind_names($name, $s);
154+
push @exported_functions, @binding_names if !is_manual($name);
155155
next if !$s->{feature};
156156
for ($s->{feature}, grep defined, $feature2version{$s->{feature}}) {
157-
$gltags{$_}{$binding_name} = undef;
157+
@{ $gltags{$_} }{ @binding_names } = ();
158158
$features{$_}{$name} = undef;
159159
}
160160
}

0 commit comments

Comments
 (0)