Integrated the perl module into the pspp build system.
[pspp-builds.git] / perl-module / typemap
1 TYPEMAP
2  struct dictionary *   T_PTRREF
3  struct variable *     T_PTRREF
4  struct sysfile_info * T_PTRREF
5  input_format  INPUT_FMT_SPEC
6  output_format OUTPUT_FMT_SPEC
7
8
9 INPUT
10 OUTPUT_FMT_SPEC
11  {
12    HV *hv = (HV *) SvRV ($arg);
13    SV** the_format = hv_fetch (hv, \"fmt\", 3, 0);
14    SV** decimals = hv_fetch (hv, \"decimals\", 8, 0);
15    SV** width = hv_fetch (hv, \"width\", 5, 0);
16
17    $var.type = the_format ? SvIV (*the_format) : FMT_F;
18    $var.w    = width ? SvIV (*width) : 8;
19    $var.d    = decimals ? SvIV (*decimals) :
20      fmt_takes_decimals ($var.type) ?
21      MIN (2, fmt_max_output_decimals ($var.type, $var.w)) : 0;
22    if ( ! fmt_check_output (&$var))
23    {
24         char buf[FMT_STRING_LEN_MAX + 1];
25         fmt_to_string (&$var, buf);
26         croak (\"%s is an invalid output format\", buf);
27    }
28
29  }
30
31
32 INPUT_FMT_SPEC
33  {
34    HV *hv = (HV *) SvRV ($arg);
35    SV** the_format = hv_fetch (hv, \"fmt\", 3, 0);
36    SV** decimals = hv_fetch (hv, \"decimals\", 8, 0);
37    SV** width = hv_fetch (hv, \"width\", 5, 0);
38
39
40    $var.type = the_format ? SvIV (*the_format) : FMT_F;
41    $var.w    = width ? SvIV (*width) : 8;
42    $var.d    = decimals ? SvIV (*decimals) :
43      fmt_takes_decimals ($var.type) ?
44      MIN (2, fmt_max_input_decimals ($var.type, $var.w)) : 0;
45    if ( ! fmt_check_input (&$var))
46    {
47         char buf[FMT_STRING_LEN_MAX + 1];
48         fmt_to_string (&$var, buf);
49         croak (\"%s is an invalid input format\", buf);
50    }
51
52  }