develooper Front page | perl.perl5.porters | Postings from October 2014

XS_APIVERSION_BOOTCHECK and XS_VERSION is CPP defined but "", mowwhat?

Thread Next
From:
bulk88
Date:
October 16, 2014 08:04
Subject:
XS_APIVERSION_BOOTCHECK and XS_VERSION is CPP defined but "", mowwhat?
Message ID:
BLU436-SMTP15885980212D42AB3476319DFAB0@phx.gbl
I am refactoring how XS_APIVERSION_BOOTCHECK and XS_VERSION_BOOTCHECK 
and BOOT:/ParseXS work (see attachment for WIP). The ultimate plan is to 
merge XS_APIVERSION_BOOTCHECK and XS_VERSION_BOOTCHECK into 1 function 
call and push/move less outgoing C args to the now 1 and only function 
call. Also some of dXSARGS will be factored out into the new 1 function 
call. So far I ran into a test that tests bad behavior but breaks my 
code's assumptions.

http://perl5.git.perl.org/perl.git/commitdiff/f9cc56fa8caacd402d316a1cd95160cd70fb4c9e

"xs_version_bootcheck() must use mortals, as {new,upg}_version() can croak."

Currently if XS_VERSION is CPP undef, the version check doesn't happen. 
Currently if XS_VERSION is CPP defined but empty string litteral (""), 
the code croaks with "Invalid version format (version required)" which 
is from version::'s guts, not ****version_bootcheck()'s code.

--------XSUB.h----------------
#ifdef XS_VERSION
#  define XS_VERSION_BOOTCHECK					\
      Perl_xs_version_bootcheck(aTHX_ items, ax, STR_WITH_LEN(XS_VERSION))
#else
#  define XS_VERSION_BOOTCHECK
#endif
-------------------------------

-------------XSUB-redefined-macros.xs------------------
/* We have to be in a different .xs so that we can do this:  */

#undef XS_VERSION
#define XS_VERSION ""
#undef PERL_API_VERSION_STRING
#define PERL_API_VERSION_STRING "1.0.16"
#include "XSUB.h"

/* This can't be "MODULE = XS::APItest" as then we get duplicate 
bootstraps.  */
MODULE = XS::APItest::XSUB1	PACKAGE = XS::APItest::XSUB

PROTOTYPES: DISABLE

EXPORT_XSUB_SYMBOLS: ENABLE

void
XS_VERSION_empty(...)
     PPCODE:
         XS_VERSION_BOOTCHECK;
         XSRETURN_EMPTY;

void
XS_APIVERSION_invalid(...)
     PPCODE:
         XS_APIVERSION_BOOTCHECK;
         XSRETURN_EMPTY;
-------------------------------

My new code assumes that if XS_VERSION is CPP undef, or sizeof("" 
XS_VERSION "")-1 == 0, to not do the XS_VERSION api. Can I change the 
test and make "" for XS_VERSION stop being a fatal error/test fail?

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About