summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Mueller <smueller@cpan.org>2012-02-02 08:04:43 +0100
committerSteffen Mueller <smueller@cpan.org>2012-02-02 08:06:05 +0100
commit62e90759156bee3f2bcbf1ac6fd055aeab81b9e4 (patch)
tree36931338a976135b28272213fd4f5d45b9642984
parent57e770c980de065ed94a4bc87d0b1f930c5ff3d0 (diff)
downloadperl-62e90759156bee3f2bcbf1ac6fd055aeab81b9e4.tar.gz
XS::Typemap: Silence pedantic compiler warnings
No need to try to optimize the typemap tests. But it's still a rather backwards and useless typemap in general.
-rw-r--r--ext/XS-Typemap/Typemap.xs52
1 files changed, 31 insertions, 21 deletions
diff --git a/ext/XS-Typemap/Typemap.xs b/ext/XS-Typemap/Typemap.xs
index 02b2e5c847..563350b0da 100644
--- a/ext/XS-Typemap/Typemap.xs
+++ b/ext/XS-Typemap/Typemap.xs
@@ -69,14 +69,19 @@ intArray * intArrayPtr( int nelem ) {
}
/* 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)
@@ -115,19 +120,24 @@ 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)