API.pod (PDL-2.080) | : | API.pod (PDL-2.081) | ||
---|---|---|---|---|
skipping to change at line 242 | skipping to change at line 242 | |||
BOOT => &PDL_BOOT; # code for the XS boot section | BOOT => &PDL_BOOT; # code for the XS boot section | |||
The code returned by C<PDL_AUTO_INCLUDE> makes sure that F<pdlcore.h> | The code returned by C<PDL_AUTO_INCLUDE> makes sure that F<pdlcore.h> | |||
is included and declares the static variables to hold the pointer to | is included and declares the static variables to hold the pointer to | |||
the C<Core> struct. It looks something like this: | the C<Core> struct. It looks something like this: | |||
print PDL_AUTO_INCLUDE; | print PDL_AUTO_INCLUDE; | |||
#include <pdlcore.h> | #include <pdlcore.h> | |||
static Core* PDL; /* Structure holds core C functions */ | static Core* PDL; /* Structure holds core C functions */ | |||
static SV* CoreSV; /* Gets pointer to Perl var holding core structure */ | ||||
The code returned by C<PDL_BOOT> retrieves the C<$PDL::SHARE> variable | The code returned by C<PDL_BOOT> retrieves the C<$PDL::SHARE> variable | |||
and initializes the pointer to the C<Core> struct. For those who know | and initializes the pointer to the C<Core> struct. For those who know | |||
their way around the Perl API here is the code: | their way around the Perl API here is the code: | |||
perl_require_pv ("PDL/Core.pm"); /* make sure PDL::Core is loaded */ | perl_require_pv ("PDL/Core.pm"); /* make sure PDL::Core is loaded */ | |||
#ifndef aTHX_ | #ifndef aTHX_ | |||
#define aTHX_ | #define aTHX_ | |||
#endif | #endif | |||
if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV)); | if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV)); | |||
if (!(CoreSV = perl_get_sv("PDL::SHARE",FALSE))) /* SV* value */ | SV* CoreSV = perl_get_sv("PDL::SHARE",FALSE); /* var with core structure */ | |||
if (!CoreSV) | ||||
Perl_croak(aTHX_ "We require the PDL::Core module, which was not found"); | Perl_croak(aTHX_ "We require the PDL::Core module, which was not found"); | |||
if (!(PDL = INT2PTR(Core*,SvIV( CoreSV )))) /* Core* value */ | if (!(PDL = INT2PTR(Core*,SvIV( CoreSV )))) /* Core* value */ | |||
Perl_croak(aTHX_ "Got NULL pointer for PDL"); | Perl_croak(aTHX_ "Got NULL pointer for PDL"); | |||
if (PDL->Version != PDL_CORE_VERSION) | if (PDL->Version != PDL_CORE_VERSION) | |||
Perl_croak(aTHX_ "[PDL->Version: \%d PDL_CORE_VERSION: \%d XS_VERSION: \%s] The code needs to be recompiled against the newly installed PDL", PDL->Version, PDL_CORE_VERSION, XS_VERSION); | Perl_croak(aTHX_ "[PDL->Version: \%d PDL_CORE_VERSION: \%d XS_VERSION: \%s] The code needs to be recompiled against the newly installed PDL", PDL->Version, PDL_CORE_VERSION, XS_VERSION); | |||
The C<Core> struct contains version info to ensure that the structure defined | The C<Core> struct contains version info to ensure that the structure defined | |||
in F<pdlcore.h> really corresponds to the one obtained at runtime. The code | in F<pdlcore.h> really corresponds to the one obtained at runtime. The code | |||
above tests for this | above tests for this | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added |