Skip to content

Commit c4bed35

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

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
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

+18-23
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,27 @@ 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;
58-
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";
47+
my $avail_check = ($item->{glewtype} eq 'fun' && $glewImpl)
48+
? " OGLM_AVAIL_CHECK($glewImpl, $name)\n"
49+
: "";
50+
my $preamble = qq{ OGLM_GLEWINIT@{[$error_check && "\n $error_check"]}\n};
51+
my $callarg_list = $item->{glewtype} eq 'var' ? "" : "(@{[ join ', ', map $_->[0], @argdata ]})";
52+
for my $binding_name (bind_names($name, $item)) {
53+
my (@thisargdata, $thistype, $retcap, $retout, $thiscode) = @argdata;
54+
my ($beforecall, $aftercall) = ('', '');
55+
$thistype = $item->{restype};
56+
($retcap, $retout) = $thistype eq 'void' ? ('','') : ('RETVAL = ', "\nOUTPUT:\n RETVAL");
57+
$thiscode = "CODE:\n";
58+
my $args = join ', ', map $_->[0], @thisargdata;
59+
my $res = "$thistype\n$binding_name($args)\n";
60+
$res .= join '', map " $_->[1]$_->[0];\n", @thisargdata;
61+
$res .= $thiscode . $preamble . $avail_check . $beforecall;
62+
$res .= qq{ $retcap$name$callarg_list;@{[$error_check && "\n $error_check"]}};
63+
$content .= "$res$aftercall$retout\n\n";
6364
}
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";
7065
}
7166
return $content;
7267
}

0 commit comments

Comments
 (0)