}
+/* Shallow copy the callbacks from SRC to DEST */
+void
+dict_copy_callbacks (struct dictionary *dest,
+ const struct dictionary *src)
+{
+ dest->callbacks = src->callbacks;
+ dest->cb_data = src->cb_data;
+}
+
/* Creates and returns a new dictionary. */
struct dictionary *
dict_create (void)
for (i = 0; i < d->var_cnt; i++)
{
+ if (d->callbacks && d->callbacks->var_deleted )
+ d->callbacks->var_deleted (d, i, d->cb_data);
+
var_clear_vardict (d->var[i]);
var_destroy (d->var[i]);
}
set_var_dict_index (struct variable *v, int dict_index)
{
struct vardict_info vdi = *var_get_vardict (v);
+ struct dictionary *d = vdi.dict;
vdi.dict_index = dict_index;
var_set_vardict (v, &vdi);
+
+ if ( d->callbacks && d->callbacks->var_changed )
+ d->callbacks->var_changed (d, dict_index, d->cb_data);
}
/* Sets the case_index in V's vardict to DICT_INDEX. */
listed in ORDER in that order at the beginning of D. The
other variables in D, if any, retain their relative
positions. */
-void
+void
dict_reorder_vars (struct dictionary *d,
- struct variable *const *order, size_t count)
+ struct variable *const *order, size_t count)
{
struct variable **new_var;
size_t i;
-
+
assert (d != NULL);
assert (count == 0 || order != NULL);
assert (count <= d->var_cnt);
new_var = xnmalloc (d->var_cnt, sizeof *new_var);
memcpy (new_var, order, count * sizeof *new_var);
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
{
size_t index = var_get_dict_index (order[i]);
assert (d->var[index] == order[i]);
else
{
double w = case_num (c, d->weight);
- if (w < 0.0 || var_is_num_missing (d->weight, w))
+ if (w < 0.0 || var_is_num_missing (d->weight, w, MV_ANY))
w = 0.0;
if ( w == 0.0 && *warn_on_invalid ) {
*warn_on_invalid = false;