Merge branch 'master' of /home/john/Development/pspp-bare
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 7 Jan 2009 22:16:58 +0000 (07:16 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 7 Jan 2009 22:16:58 +0000 (07:16 +0900)
1  2 
perl-module/PSPP.xs

diff --combined perl-module/PSPP.xs
index 3b3dcceff82d275d55fd76986836f0044b30baac,6373bc37dea1c4fa540c19315743900f47ef80d3..7bb36ef3bc7468bd419a8ce2681ea00ba064baf9
@@@ -55,6 -55,9 +55,9 @@@ struct sysfile_inf
  
    /* A pointer to the dictionary. Owned externally */
    const struct dictionary *dict;
+   /* The scalar containing the dictionary */
+   SV *dict_sv;
  };
  
  
@@@ -273,23 -276,6 +276,23 @@@ CODE
   OUTPUT:
  RETVAL
  
 +
 +struct variable *
 +pxs_get_var_by_name (dict, name)
 + struct dictionary *dict
 + const char *name
 +INIT:
 + SV *errstr = get_sv("PSPP::errstr", TRUE);
 + sv_setpv (errstr, "");
 +CODE:
 + struct variable *var = dict_lookup_var (dict, name);
 + if ( ! var )
 +      sv_setpv (errstr, "No such variable.");
 + RETVAL = var;
 + OUTPUT:
 +RETVAL
 +
 +
  MODULE = PSPP         PACKAGE = PSPP::Var
  
  
@@@ -471,11 -457,13 +474,13 @@@ MODULE = PSPP           PACKAGE = PSPP::Sysfil
  
  
  struct sysfile_info *
- pxs_create_sysfile (name, dict, opts_hr)
+ pxs_create_sysfile (name, dict_ref, opts_hr)
   char *name
-  struct dictionary *dict
+  SV *dict_ref
   SV *opts_hr
  INIT:
+  SV *dict_sv = SvRV (dict_ref);
+  struct dictionary *dict = (void *) SvIV (dict_sv);
   struct sfm_write_options opts;
   if (!SvROK (opts_hr))
    {
@@@ -499,6 -487,8 +504,8 @@@ CODE
   sfi->writer = sfm_open_writer (fh, dict, opts);
   sfi->dict = dict;
   sfi->opened = true;
+  sfi->dict_sv = dict_sv;
+  SvREFCNT_inc (sfi->dict_sv);
   
   RETVAL = sfi;
   OUTPUT:
@@@ -517,6 -507,7 +524,7 @@@ DESTROY (sfi
   struct sysfile_info *sfi
  CODE:
   sysfile_close (sfi);
+  SvREFCNT_dec (sfi->dict_sv);
   free (sfi);
  
  int
@@@ -583,7 -574,7 +591,7 @@@ CODE
   }
   RETVAL = casewriter_write (sfi->writer, &c);
   finish:
 -// Case_destroy (&c);
 +// case_destroy (&c);
   free (vv);
  OUTPUT:
   RETVAL