Skip to content

Commit 6c05179

Browse files
committed
less indent on auto-xs.inc, prepare for multi-bind
1 parent 9bfaa22 commit 6c05179

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

utils/common.pl

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ sub save_file {
3333
}
3434

3535
sub bind_names {
36+
die "list context only" if !wantarray;
3637
my ($name, $s) = @_;
37-
$s->{has_ptr_arg} ? $name . '_c' : $name;
38+
return $name if !$s->{has_ptr_arg};
39+
map "$name$_", qw(_c);
3840
}
3941

4042
1;

utils/generate-XS.pl

+22-21
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,33 @@ sub generate_glew_xs {
4141
print "Skipping $name, already implemented in Modern.xs\n";
4242
next;
4343
}
44-
my $argdata = $item->{argdata};
45-
my @argdata = @{$argdata || []};
46-
my $type = $item->{restype};
44+
my @argdata = @{$item->{argdata} || []};
4745
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;
52-
$type
53-
$binding_name($args);
54-
XS
55-
$decl .= $xs_args;
5646
my $error_check = $name eq "glGetError" ? "" : "OGLM_CHECK_ERR($name)";
57-
my $res = $decl . <<XS;
47+
my $avail_check = ($item->{glewtype} eq 'fun' && $glewImpl)
48+
? " OGLM_AVAIL_CHECK($glewImpl, $name)\n"
49+
: "";
50+
my $callarg_list = $item->{glewtype} eq 'var' ? "" : "(@{[ join ', ', map $_->[0], @argdata ]})";
51+
for my $binding_name (bind_names($name, $item)) {
52+
my @thisargdata = @argdata;
53+
my $thistype = $item->{restype};
54+
my ($retcap, $retout) = $thistype eq 'void' ? ('','') : ('RETVAL = ', "\nOUTPUT:\n RETVAL");
55+
my $args = join ', ', map $_->[0], @thisargdata;
56+
my $decl = <<XS;
57+
$thistype
58+
$binding_name($args)
59+
XS
60+
$decl .= join '', map " $_->[1]$_->[0];\n", @thisargdata;
61+
my $res = $decl . <<XS;
5862
CODE:
59-
OGLM_GLEWINIT@{[$error_check && "\n $error_check"]}
63+
OGLM_GLEWINIT@{[$error_check && "\n $error_check"]}
6064
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
65+
$res .= $avail_check;
66+
$res .= <<XS;
67+
$retcap$name$callarg_list;@{[$error_check && "\n $error_check"]}$retout
6868
XS
69-
$content .= "$res\n";
69+
$content .= "$res\n";
70+
}
7071
}
7172
return $content;
7273
}

0 commit comments

Comments
 (0)