reindex_var (struct dictionary *d, struct vardict_info *vardict)
{
struct variable *var = vardict->var;
+ struct variable *old = var_clone (var);
var_set_vardict (var, vardict);
hmap_insert_fast (&d->name_map, &vardict->name_node,
if ( d->changed ) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->var_changed )
- d->callbacks->var_changed (d, var_get_dict_index (var), d->cb_data);
+ d->callbacks->var_changed (d, var_get_dict_index (var), VAR_TRAIT_POSITION, old, d->cb_data);
+ var_destroy (old);
}
/* Sets the case_index in V's vardict to CASE_INDEX. */
dict_rename_var (struct dictionary *d, struct variable *v,
const char *new_name)
{
+ struct variable *old = var_clone (v);
assert (!utf8_strcasecmp (var_get_name (v), new_name)
|| dict_lookup_var (d, new_name) == NULL);
if ( d->changed ) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->var_changed )
- d->callbacks->var_changed (d, var_get_dict_index (v), d->cb_data);
+ d->callbacks->var_changed (d, var_get_dict_index (v), VAR_TRAIT_NAME, old, d->cb_data);
+
+ var_destroy (old);
}
/* Renames COUNT variables specified in VARS to the names given
return attrset_count (&d->attributes) > 0;
}
-/* Called from variable.c to notify the dictionary that some property of
- the variable has changed */
+/* Called from variable.c to notify the dictionary that some property (indicated
+ by WHAT) of the variable has changed. OLDVAR is a copy of V as it existed
+ prior to the change. OLDVAR is destroyed by this function.
+*/
void
-dict_var_changed (const struct variable *v, unsigned int what UNUSED)
+dict_var_changed (const struct variable *v, unsigned int what, struct variable *oldvar)
{
if ( var_has_vardict (v))
{
if (d->changed ) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->var_changed )
- d->callbacks->var_changed (d, var_get_dict_index (v), d->cb_data);
- }
-}
-
-
-/* Called from variable.c to notify the dictionary that the variable's width
- has changed */
-void
-dict_var_resized (const struct variable *v, int old_width)
-{
- if ( var_has_vardict (v))
- {
- const struct vardict_info *vardict = var_get_vardict (v);
- struct dictionary *d;
-
- d = vardict->dict;
-
- if (d->changed) d->changed (d, d->changed_data);
-
- invalidate_proto (d);
- if ( d->callbacks && d->callbacks->var_resized )
- d->callbacks->var_resized (d, var_get_dict_index (v), old_width,
- d->cb_data);
+ d->callbacks->var_changed (d, var_get_dict_index (v), what, oldvar, d->cb_data);
}
+ var_destroy (oldvar);
}
-/* Called from variable.c to notify the dictionary that the variable's display width
- has changed */
-void
-dict_var_display_width_changed (const struct variable *v)
-{
- if ( var_has_vardict (v))
- {
- const struct vardict_info *vardict = var_get_vardict (v);
- struct dictionary *d;
-
- d = vardict->dict;
- if (d->changed) d->changed (d, d->changed_data);
- if ( d->callbacks && d->callbacks->var_display_width_changed )
- d->callbacks->var_display_width_changed (d, var_get_dict_index (v), d->cb_data);
- }
-}
\f
/* Dictionary used to contain "internal variables". */
static struct dictionary *internal_dict;