Subject: | Compilation error with OVERLOAD: keyword |
I am working with Windows XP Home SP2,
perl is v5.9.5 compiled with MSVC++ 2005,
ExtUtils::ParseXS is 2.18.
I tried to use the OVERLOAD: keyword with following xs code:
MODULE = CLR PACKAGE = CLR::OverLoad
STRING
op_stringify(OBJECT self, ...)
OVERLOAD: \"\"
CODE:
RETVAL = self->ToString();
OUTPUT:
RETVAL
When compiling, two errors occurred.
CLR.c(1474) : error C2065: 'ax' : undeclared identifier
CLR.c(1502) : error C2664: 'Perl_sv_setsv_flags' : cannot convert
parameter 3 from 'SV' to 'SV*'
Generated C code is:
XS(XS_CLR__OverLoad_nil); /* prototype to pass -Wmissing-prototypes */
XS(XS_CLR__OverLoad_nil)
{
XSRETURN_EMPTY; <- line 1474
}
/* register the overloading (type 'A') magic */
PL_amagic_generation++;
/* The magic for overload gets a GV* via gv_fetchmeth as */
/* mentioned above, and looks in the SV* slot of it for */
/* the "fallback" status. */
sv_setsv(
get_sv( "CLR::OverLoad::()", TRUE ),
PL_sv_undef
); <- line 1502
I found the discussion about this problem.
http://groups.google.com/group/perl.xs/browse_thread/thread/9f9120aeba415bde/d7ab8b44ad510c1b?#d7ab8b44ad510c1b
I thought ParseXS generates incorrectly code, so I edited ParseXS.pm as
follows.
*** ParseXS.pm Tue Jan 30 11:56:14 2007
--- ParseXS_fixoverload.pm Fri Dec 14 21:15:58 2007
***************
*** 76,82 ****
$proto_re = "[" . quotemeta('\$%&*@;[]') . "]" ;
$Overload = 0;
$errors = 0;
! $Fallback = 'PL_sv_undef';
# Most of the 1500 lines below uses these globals. We'll have to
# clean this up sometime, probably. For now, we just pull them out
--- 76,82 ----
$proto_re = "[" . quotemeta('\$%&*@;[]') . "]" ;
$Overload = 0;
$errors = 0;
! $Fallback = '&PL_sv_undef';
# Most of the 1500 lines below uses these globals. We'll have to
# clean this up sometime, probably. For now, we just pull them out
***************
*** 896,901 ****
--- 896,902 ----
#XS(XS_${Packid}_nil); /* prototype to pass -Wmissing-prototypes */
#XS(XS_${Packid}_nil)
#{
+ # dXSARGS;
# XSRETURN_EMPTY;
#}
#
***************
*** 1318,1326 ****
TrimWhitespace($_) ;
my %map = (
! TRUE => "PL_sv_yes", 1 => "PL_sv_yes",
! FALSE => "PL_sv_no", 0 => "PL_sv_no",
! UNDEF => "PL_sv_undef",
) ;
# check for valid FALLBACK value
--- 1319,1327 ----
TrimWhitespace($_) ;
my %map = (
! TRUE => "&PL_sv_yes", 1 => "&PL_sv_yes",
! FALSE => "&PL_sv_no", 0 => "&PL_sv_no",
! UNDEF => "&PL_sv_undef",
) ;
# check for valid FALLBACK value
As a result, compilation successed and the code came to work correctly!
Is this way correct for this problem?
Subject: | ParseXS-2.18.pm.patch |
*** ParseXS.pm Tue Jan 30 11:56:14 2007
--- ParseXS_fixoverload.pm Fri Dec 14 21:15:58 2007
***************
*** 76,82 ****
$proto_re = "[" . quotemeta('\$%&*@;[]') . "]" ;
$Overload = 0;
$errors = 0;
! $Fallback = 'PL_sv_undef';
# Most of the 1500 lines below uses these globals. We'll have to
# clean this up sometime, probably. For now, we just pull them out
--- 76,82 ----
$proto_re = "[" . quotemeta('\$%&*@;[]') . "]" ;
$Overload = 0;
$errors = 0;
! $Fallback = '&PL_sv_undef';
# Most of the 1500 lines below uses these globals. We'll have to
# clean this up sometime, probably. For now, we just pull them out
***************
*** 896,901 ****
--- 896,902 ----
#XS(XS_${Packid}_nil); /* prototype to pass -Wmissing-prototypes */
#XS(XS_${Packid}_nil)
#{
+ # dXSARGS;
# XSRETURN_EMPTY;
#}
#
***************
*** 1318,1326 ****
TrimWhitespace($_) ;
my %map = (
! TRUE => "PL_sv_yes", 1 => "PL_sv_yes",
! FALSE => "PL_sv_no", 0 => "PL_sv_no",
! UNDEF => "PL_sv_undef",
) ;
# check for valid FALLBACK value
--- 1319,1327 ----
TrimWhitespace($_) ;
my %map = (
! TRUE => "&PL_sv_yes", 1 => "&PL_sv_yes",
! FALSE => "&PL_sv_no", 0 => "&PL_sv_no",
! UNDEF => "&PL_sv_undef",
) ;
# check for valid FALLBACK value