typedef short shortOPQ; /* T_OPAQUE */
typedef int intOpq; /* T_OPAQUEPTR */
typedef unsigned intUnsigned; /* T_U_INT */
-typedef PerlIO inputfh; /* T_IN */
-typedef PerlIO outputfh; /* T_OUT */
+typedef PerlIO * inputfh; /* T_IN */
+typedef PerlIO * outputfh; /* T_OUT */
/* A structure to test T_OPAQUEPTR and T_PACKED */
struct t_opaqueptr {
}
/* test T_PACKED */
-#define XS_pack_anotherstructPtr(out, in) \
- STMT_START { \
- HV *hash = newHV(); \
- hv_stores(hash, "a", newSViv((in)->a)); \
- hv_stores(hash, "b", newSViv((in)->b)); \
- hv_stores(hash, "c", newSVnv((in)->c)); \
- sv_setsv((out), sv_2mortal(newRV_noinc((SV*)hash))); \
- } STMT_END
+STATIC void
+XS_pack_anotherstructPtr(SV *out, anotherstruct *in)
+{
+ dTHX;
+ HV *hash = newHV();
+ if (NULL == hv_stores(hash, "a", newSViv(in->a)))
+ croak("Failed to store data in hash");
+ if (NULL == hv_stores(hash, "b", newSViv(in->b)))
+ croak("Failed to store data in hash");
+ if (NULL == hv_stores(hash, "c", newSVnv(in->c)))
+ croak("Failed to store data in hash");
+ sv_setsv(out, sv_2mortal(newRV_noinc((SV*)hash)));
+}
STATIC anotherstruct *
XS_unpack_anotherstructPtr(SV *in)
}
/* test T_PACKEDARRAY */
-#define XS_pack_anotherstructPtrPtr(out, in, cnt) \
- STMT_START { \
- UV i; \
- AV *ary = newAV(); \
- for (i = 0; i < cnt; ++i) { \
- HV *hash = newHV(); \
- hv_stores(hash, "a", newSViv((in)[i]->a)); \
- hv_stores(hash, "b", newSViv((in)[i]->b)); \
- hv_stores(hash, "c", newSVnv((in)[i]->c)); \
- av_push(ary, newRV_noinc((SV*)hash)); \
- } \
- sv_setsv((out), sv_2mortal(newRV_noinc((SV*)ary))); \
- } STMT_END
+STATIC void
+XS_pack_anotherstructPtrPtr(SV *out, anotherstruct **in, UV cnt)
+{
+ dTHX;
+ UV i;
+ AV *ary = newAV();
+ for (i = 0; i < cnt; ++i) {
+ HV *hash = newHV();
+ if (NULL == hv_stores(hash, "a", newSViv(in[i]->a)))
+ croak("Failed to store data in hash");
+ if (NULL == hv_stores(hash, "b", newSViv(in[i]->b)))
+ croak("Failed to store data in hash");
+ if (NULL == hv_stores(hash, "c", newSVnv(in[i]->c)))
+ croak("Failed to store data in hash");
+ av_push(ary, newRV_noinc((SV*)hash));
+ }
+ sv_setsv(out, sv_2mortal(newRV_noinc((SV*)ary)));
+}
STATIC anotherstruct **
XS_unpack_anotherstructPtrPtr(SV *in)
else
Perl_croak(aTHX_ "Argument is not an ARRAY reference");
- nitems = av_len(inary) + 1;
+ nitems = av_tindex(inary) + 1;
/* FIXME dunno if supposed to use perl mallocs here */
/* N+1 elements so we know the last one is NULL */
if (SvROK(tmp) && SvTYPE(SvRV(tmp)) == SVt_PVHV)
inhash = (HV*)SvRV(tmp);
else
- Perl_croak(aTHX_ "Array element %u is not a HASH reference", i);
+ Perl_croak(aTHX_ "Array element %"UVuf" is not a HASH reference", i);
elem = hv_fetchs(inhash, "a", 0);
if (elem == NULL)
OUTPUT:
RETVAL
+bool
+T_BOOL_2( in )
+ bool in
+ CODE:
+ PERL_UNUSED_VAR(RETVAL);
+ OUTPUT:
+ in
+
+void
+T_BOOL_OUT( out, in )
+ bool out
+ bool in
+ CODE:
+ out = in;
+ OUTPUT:
+ out
## T_U_INT
OUTPUT:
RETVAL
+char *
+T_PV_null()
+ CODE:
+ RETVAL = NULL;
+ OUTPUT:
+ RETVAL
+
## T_PTR