From c79aab4ce5b9a90f8bd3ff1f6873b4023f41f600 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 2 Nov 2005 18:23:10 +0000 Subject: [PATCH] Much work on ZOOM_resultset_records(). It now has a different, Perl-friendly, signature, and works correctly in the case where it is not asked to actually return the records that it fetches. However, when asked to do so, while it does return an array of the correct number of entries, these are all undefined values. D'oh! --- ZOOM.xs | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/ZOOM.xs b/ZOOM.xs index c33cfa0..557e4ed 100644 --- a/ZOOM.xs +++ b/ZOOM.xs @@ -1,4 +1,4 @@ -/* $Id: ZOOM.xs,v 1.19 2005-11-02 17:23:50 mike Exp $ */ +/* $Id: ZOOM.xs,v 1.20 2005-11-02 18:23:10 mike Exp $ */ #include "EXTERN.h" #include "perl.h" @@ -251,12 +251,43 @@ ZOOM_resultset_size(r) ZOOM_resultset r # TESTING -void -ZOOM_resultset_records(r, recs, start, count) +SV * +ZOOM_resultset_records(r, start, count, return_values) ZOOM_resultset r - ZOOM_record* recs size_t start size_t count + int return_values + INIT: + ZOOM_record *recs; + CODE: + /*printf("*** ZOOM_resultset_records(r=0x%lx, start=%lu, count=%lx, return_values=%d)\n", (unsigned long) r, (unsigned long) start, (unsigned long) count, return_values);*/ + if (return_values) { + /*printf("*** generating space for %ld records\n", (unsigned long) count);*/ + recs = (ZOOM_record*) xmalloc(count * sizeof *recs); + } else { + /*printf("*** using null pointer for records array\n");*/ + recs = 0; + } + ZOOM_resultset_records(r, recs, start, count); + /*printf("*** returned from ZOOM_resultset_records()\n");*/ + if (return_values) { + AV *av = newAV(); + int i; + for (i = 0; i < count; i++) { + SV *tmp = sv_newmortal(); + printf("*** recs[%d] = %lu\n", i, (unsigned long) recs[i]); + /* ### Next line fails. Damn and blast Perl */ + sv_setref_pv(tmp, "ZOOM_record", (void*) recs[i]); + av_push(av, tmp); + } + RETVAL = newRV((SV*) av); + printf("*** returning array %lu\n", (unsigned long) RETVAL); + } else { + /*printf("*** returning undef\n");*/ + RETVAL = &PL_sv_undef; + } + OUTPUT: + RETVAL # TESTED ZOOM_record -- 1.7.10.4