Skip to content

Commit 6669f50

Browse files
committed
PoC
1 parent 7946d6a commit 6669f50

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

XSUB.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,19 @@ is a lexical C<$_> in scope.
188188

189189
#define dXSI32 I32 ix = XSANY.any_i32
190190

191-
#ifdef __cplusplus
192-
# define XSINTERFACE_CVT(ret,name) ret (*name)(...)
193-
# define XSINTERFACE_CVT_ANON(ret) ret (*)(...)
191+
#if __STDC_VERSION__ >= 202311L || defined(__GNUC__)
192+
# define XSINTERFACE_CVT(ret, name, example_func_name) typeof(&example_func_name) (name)
193+
# define XSINTERFACE_CVT_ANON(ret, example_func_name) typeof(&example_func_name)
194+
#elif defined(__cplusplus)
195+
# define XSINTERFACE_CVT(ret, name, example_func_name) decltype(&example_func_name) (name)
196+
# define XSINTERFACE_CVT_ANON(ret, example_func_name) decltype(&example_func_name)
194197
#else
195-
# define XSINTERFACE_CVT(ret,name) ret (*name)()
196-
# define XSINTERFACE_CVT_ANON(ret) ret (*)()
198+
# define XSINTERFACE_CVT(ret,name, example_func_name) ret (*name)()
199+
# define XSINTERFACE_CVT_ANON(ret, example_func_name) ret (*)()
197200
#endif
198-
#define dXSFUNCTION(ret) XSINTERFACE_CVT(ret,XSFUNCTION)
199-
#define XSINTERFACE_FUNC(ret,cv,f) ((XSINTERFACE_CVT_ANON(ret))(f))
201+
202+
#define dXSFUNCTION(ret, example_func_name) XSINTERFACE_CVT(ret, XSFUNCTION, example_func_name)
203+
#define XSINTERFACE_FUNC(ret,cv,f,example_func_name) ((XSINTERFACE_CVT_ANON(ret, example_func_name))(f))
200204
#define XSINTERFACE_FUNC_SET(cv,f) \
201205
CvXSUBANY(cv).any_dxptr = (void (*) (pTHX_ void*))(f)
202206

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use Symbol;
6464

6565
our $VERSION;
6666
BEGIN {
67-
$VERSION = '3.57';
67+
$VERSION = '3.58';
6868
require ExtUtils::ParseXS::Constants; ExtUtils::ParseXS::Constants->VERSION($VERSION);
6969
require ExtUtils::ParseXS::CountLines; ExtUtils::ParseXS::CountLines->VERSION($VERSION);
7070
require ExtUtils::ParseXS::Node; ExtUtils::ParseXS::Node->VERSION($VERSION);
@@ -898,10 +898,6 @@ EOF
898898
| dXSI32;
899899
EOF
900900

901-
print Q(<<"EOF") if $self->{xsub_seen_INTERFACE};
902-
| dXSFUNCTION($self->{xsub_return_type});
903-
EOF
904-
905901

906902
{
907903
# the code to emit to determine whether the correct number of argument
@@ -2244,13 +2240,17 @@ sub INTERFACE_handler {
22442240

22452241
trim_whitespace($in);
22462242

2243+
# used for function pointer type inference
2244+
my $example_interface_function;
22472245
foreach (split /[\s,]+/, $in) {
22482246
my $iface_name = $_;
22492247
$iface_name =~ s/^$self->{PREFIX_pattern}//;
22502248
$self->{xsub_map_interface_name_short_to_original}->{$iface_name} = $_;
2249+
$example_interface_function = $_;
22512250
}
2251+
22522252
print Q(<<"EOF");
2253-
| XSFUNCTION = $self->{xsub_interface_macro}($self->{xsub_return_type},cv,XSANY.any_dptr);
2253+
| dXSFUNCTION($self->{xsub_return_type}, $example_interface_function) = $self->{xsub_interface_macro}($self->{xsub_return_type},cv,XSANY.any_dptr,$example_interface_function);
22542254
EOF
22552255
$self->{xsub_seen_INTERFACE_or_MACRO} = 1; # local
22562256
$self->{seen_INTERFACE_or_MACRO} = 1; # global

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use strict;
33
use warnings;
44
use Symbol;
55

6-
our $VERSION = '3.57';
6+
our $VERSION = '3.58';
77

88
=head1 NAME
99

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/CountLines.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ExtUtils::ParseXS::CountLines;
22
use strict;
33

4-
our $VERSION = '3.57';
4+
our $VERSION = '3.58';
55

66
our $SECTION_END_MARKER;
77

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Eval.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package ExtUtils::ParseXS::Eval;
22
use strict;
33
use warnings;
44

5-
our $VERSION = '3.57';
5+
our $VERSION = '3.58';
66

77
=head1 NAME
88

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package ExtUtils::ParseXS::Node;
22
use strict;
33
use warnings;
44

5-
our $VERSION = '3.57';
5+
our $VERSION = '3.58';
66

77
=head1 NAME
88

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use Exporter;
55
use File::Spec;
66
use ExtUtils::ParseXS::Constants ();
77

8-
our $VERSION = '3.57';
8+
our $VERSION = '3.58';
99

1010
our (@ISA, @EXPORT_OK);
1111
@ISA = qw(Exporter);

0 commit comments

Comments
 (0)