From: Ben Pfaff Date: Sat, 10 Apr 2010 03:41:04 +0000 (-0700) Subject: vardict: Make vardict opaque to variable code. X-Git-Tag: v0.7.5~80 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c3d75a49708f3c32a634a032efab0e1547bcd7c;p=pspp-builds.git vardict: Make vardict opaque to variable code. --- diff --git a/src/data/vardict.h b/src/data/vardict.h index 8bb8b825..63ec88cb 100644 --- a/src/data/vardict.h +++ b/src/data/vardict.h @@ -42,4 +42,22 @@ void dict_var_changed (const struct variable *v); void dict_var_resized (const struct variable *v, int old_width); void dict_var_display_width_changed (const struct variable *v); +static inline int +vardict_get_dict_index (const struct vardict_info *vardict) +{ + return vardict->dict_index; +} + +static inline int +vardict_get_case_index (const struct vardict_info *vardict) +{ + return vardict->case_index; +} + +static inline struct dictionary * +vardict_get_dictionary (const struct vardict_info *vardict) +{ + return vardict->dict; +} + #endif /* data/vardict.h */ diff --git a/src/data/variable.c b/src/data/variable.c index 056d2567..072b96b8 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -901,7 +901,7 @@ size_t var_get_dict_index (const struct variable *v) { assert (var_has_vardict (v)); - return v->vardict->dict_index; + return vardict_get_dict_index (v->vardict); } /* Returns V's index within the case represented by its @@ -912,7 +912,7 @@ size_t var_get_case_index (const struct variable *v) { assert (var_has_vardict (v)); - return v->vardict->case_index; + return vardict_get_case_index (v->vardict); } /* Returns V's auxiliary data, or a null pointer if none has been @@ -1033,7 +1033,9 @@ var_has_attributes (const struct variable *v) const char * var_get_encoding (const struct variable *var) { - return var_has_vardict (var) ? dict_get_encoding (var->vardict->dict) : NULL; + return (var_has_vardict (var) + ? dict_get_encoding (vardict_get_dictionary (var->vardict)) + : NULL); } /* Returns V's vardict structure. */ @@ -1047,9 +1049,6 @@ var_get_vardict (const struct variable *v) void var_set_vardict (struct variable *v, struct vardict_info *vardict) { - assert (vardict->dict_index >= 0); - assert (vardict->case_index >= 0); - assert (vardict->dict != NULL); v->vardict = vardict; }