X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=perl-module%2FPSPP.xs;fp=perl-module%2FPSPP.xs;h=e0943d6e6513b052b6ff97417d7b82f09fdc9ca1;hb=8ec9e3a8a285f20c614d555185e4cffca3bea8ef;hp=c479c75b09e1e67f85a208aa03fc6aa08e27257e;hpb=a8a61c1dd90faf464a46ad11620c6e461f31bab1;p=pspp-builds.git diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index c479c75b..e0943d6e 100644 --- a/perl-module/PSPP.xs +++ b/perl-module/PSPP.xs @@ -31,7 +31,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -180,7 +182,7 @@ CODE: RETVAL = ret; OUTPUT: RETVAL - + int value_is_missing (val, var) @@ -423,6 +425,43 @@ CODE: XSRETURN_IV (1); +SV * +get_attributes (var) + struct variable *var +CODE: + HV *attrhash = (HV *) sv_2mortal ((SV *) newHV()); + + struct attrset *as = var_get_attributes (var); + + if ( as ) + { + struct attrset_iterator iter; + struct attribute *attr; + + for (attr = attrset_first (as, &iter); + attr; + attr = attrset_next (as, &iter)) + { + int i; + const char *name = attribute_get_name (attr); + + AV *values = newAV (); + + for (i = 0 ; i < attribute_get_n_values (attr); ++i ) + { + const char *value = attribute_get_value (attr, i); + av_push (values, newSVpv (value, 0)); + } + + hv_store (attrhash, name, strlen (name), + newRV_noinc ((SV*) values), 0); + } + } + + RETVAL = newRV ((SV *) attrhash); + OUTPUT: +RETVAL + const char * get_name (var)