pdlperl.h.PL (PDL-2.082) | : | pdlperl.h.PL (PDL-2.083) | ||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
ANYVAL_FROM_CTYPE(av,type,val); \ | ANYVAL_FROM_CTYPE(av,type,val); \ | |||
pdl *b = pdl_scalar(av); \ | pdl *b = pdl_scalar(av); \ | |||
if (!b) XSRETURN_UNDEF; \ | if (!b) XSRETURN_UNDEF; \ | |||
SV *b_SV = sv_newmortal(); \ | SV *b_SV = sv_newmortal(); \ | |||
pdl_SetSV_PDL(b_SV, b); \ | pdl_SetSV_PDL(b_SV, b); \ | |||
EXTEND(SP, 1); \ | EXTEND(SP, 1); \ | |||
ST(0) = b_SV; \ | ST(0) = b_SV; \ | |||
XSRETURN(1); | XSRETURN(1); | |||
#define PDL_MAKE_PERL_COMPLEX(output,r,i) { \ | #define PDL_MAKE_PERL_COMPLEX(output,r,i) { \ | |||
dSP; int count; double rval = r, ival = i; SV *ret; \ | dSP; int count; double rval = r, ival = i; \ | |||
ENTER; SAVETMPS; PUSHMARK(sp); \ | ENTER; SAVETMPS; PUSHMARK(sp); \ | |||
perl_require_pv("PDL/Complex/Overloads.pm"); \ | perl_require_pv("PDL/Complex/Overloads.pm"); \ | |||
mXPUSHn(rval); \ | mXPUSHn(rval); \ | |||
mXPUSHn(ival); \ | mXPUSHn(ival); \ | |||
PUTBACK; \ | PUTBACK; \ | |||
count = perl_call_pv("PDL::Complex::Overloads::cplx", G_SCALAR); \ | count = perl_call_pv("PDL::Complex::Overloads::cplx", G_SCALAR); \ | |||
SPAGAIN; \ | SPAGAIN; \ | |||
if (count != 1) croak("Failed to create PDL::Complex::Overloads object ( %.9g, %.9g)", rval, ival); \ | if (count != 1) croak("Failed to create PDL::Complex::Overloads object ( %.9g, %.9g)", rval, ival); \ | |||
ret = POPs; \ | sv_setsv(output, POPs); \ | |||
SvREFCNT_inc(ret); \ | ||||
output = ret; \ | ||||
PUTBACK; FREETMPS; LEAVE; \ | PUTBACK; FREETMPS; LEAVE; \ | |||
} | } | |||
/*************** | /*************** | |||
* So many ways to be undefined... | * So many ways to be undefined... | |||
*/ | */ | |||
#define PDL_SV_IS_UNDEF(sv) ( (!(sv) || ((sv)==&PL_sv_undef)) || !(SvNIOK(sv) | | (SvTYPE(sv)==SVt_PVMG) || SvPOK(sv) || SvROK(sv))) | #define PDL_SV_IS_UNDEF(sv) ( (!(sv) || ((sv)==&PL_sv_undef)) || !(SvNIOK(sv) | | (SvTYPE(sv)==SVt_PVMG) || SvPOK(sv) || SvROK(sv))) | |||
#define ANYVAL_FROM_SV(outany,insv,use_undefval,forced_type) do { \ | #define ANYVAL_FROM_SV(outany,insv,use_undefval,forced_type) do { \ | |||
SV *sv2 = insv; \ | SV *sv2 = insv; \ | |||
skipping to change at line 91 | skipping to change at line 89 | |||
ANYVAL_FROM_CTYPE(outany, datatype, tmp_IV); \ | ANYVAL_FROM_CTYPE(outany, datatype, tmp_IV); \ | |||
} \ | } \ | |||
} while (0) | } while (0) | |||
#define ANYVAL_TO_SV(outsv,inany) do { switch (inany.type) { \ | #define ANYVAL_TO_SV(outsv,inany) do { switch (inany.type) { \ | |||
EOF | EOF | |||
for (PDL::Types::types()) { | for (PDL::Types::types()) { | |||
print OUT "case @{[$_->sym]}: "; | print OUT "case @{[$_->sym]}: "; | |||
if ($_->real) { | if ($_->real) { | |||
my $upper = uc(my $letter = $_->integer ? 'i' : 'n'); | my $upper = uc(my $letter = $_->integer ? 'i' : 'n'); | |||
print OUT "outsv = newSV${letter}v( (${upper}V)(inany.value.".$_->ppsym.") ) "; | print OUT "sv_set${letter}v(outsv, (${upper}V)(inany.value.".$_->ppsym."))"; | |||
} else { | } else { | |||
my ($fs, $ppsym) = ($_->floatsuffix, $_->ppsym); | my ($fs, $ppsym) = ($_->floatsuffix, $_->ppsym); | |||
print OUT "PDL_MAKE_PERL_COMPLEX(outsv, creal$fs(inany.value.$ppsym), cimag$ fs(inany.value.$ppsym))" | print OUT "PDL_MAKE_PERL_COMPLEX(outsv, creal$fs(inany.value.$ppsym), cimag$ fs(inany.value.$ppsym))" | |||
} | } | |||
print OUT "; break; \\\n"; | print OUT "; break; \\\n"; | |||
} | } | |||
print OUT <<'EOF'; | print OUT <<'EOF'; | |||
default: outsv = &PL_sv_undef; \ | default: outsv = &PL_sv_undef; \ | |||
} \ | } \ | |||
} while (0) | } while (0) | |||
End of changes. 3 change blocks. | ||||
5 lines changed or deleted | 3 lines changed or added |