void
add_transformation (struct dataset *ds, trns_proc_func *proc, trns_free_func *free, void *aux)
{
- trns_chain_append (ds->cur_trns_chain, NULL, proc, free, aux);
- dataset_transformations_changed__ (ds, true);
-}
-
-/* Adds a transformation that processes a case with PROC and
- frees itself with FREE to the current set of transformations.
- When parsing of the block of transformations is complete,
- FINALIZE will be called.
- The functions are passed AUX as auxiliary data. */
-void
-add_transformation_with_finalizer (struct dataset *ds,
- trns_finalize_func *finalize,
- trns_proc_func *proc,
- trns_free_func *free, void *aux)
-{
- trns_chain_append (ds->cur_trns_chain, finalize, proc, free, aux);
+ trns_chain_append (ds->cur_trns_chain, proc, free, aux);
dataset_transformations_changed__ (ds, true);
}
void add_transformation (struct dataset *ds,
trns_proc_func *, trns_free_func *, void *);
-void add_transformation_with_finalizer (struct dataset *ds,
- trns_finalize_func *,
- trns_proc_func *,
- trns_free_func *, void *);
size_t next_transformation (const struct dataset *ds);
bool proc_cancel_all_transformations (struct dataset *ds);
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2009, 2011, 2013 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009, 2011, 2013, 2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdlib.h>
#include "libpspp/str.h"
+#include "language/control/control-stack.h" /* XXX layering violation */
#include "gl/xalloc.h"
transformation index. Normally 0 but set to the starting
index of a spliced chain after splicing. */
int idx_ofs;
- trns_finalize_func *finalize; /* Finalize proc. */
trns_proc_func *execute; /* Executes the transformation. */
trns_free_func *free; /* Garbage collector proc. */
void *aux; /* Auxiliary data. */
{
while (!chain->finalized)
{
- size_t i;
-
+ ctl_stack_clear (); /* XXX layering violation */
chain->finalized = true;
- for (i = 0; i < chain->trns_cnt; i++)
- {
- struct transformation *trns = &chain->trns[i];
- trns_finalize_func *finalize = trns->finalize;
-
- trns->finalize = NULL;
- if (finalize != NULL)
- finalize (trns->aux);
- }
}
}
return chain->trns_cnt == 0;
}
-/* Adds a transformation to CHAIN with finalize function
- FINALIZE, execute function EXECUTE, free function FREE, and
- auxiliary data AUX. */
+/* Adds a transformation to CHAIN with execute function EXECUTE, free function
+ FREE, and auxiliary data AUX. */
void
-trns_chain_append (struct trns_chain *chain, trns_finalize_func *finalize,
- trns_proc_func *execute, trns_free_func *free,
- void *aux)
+trns_chain_append (struct trns_chain *chain, trns_proc_func *execute,
+ trns_free_func *free, void *aux)
{
struct transformation *trns;
trns = &chain->trns[chain->trns_cnt++];
trns->idx_ofs = 0;
- trns->finalize = finalize;
trns->execute = execute;
trns->free = free;
trns->aux = aux;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2009, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009, 2011, 2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
};
struct ccase;
-typedef void trns_finalize_func (void *);
typedef int trns_proc_func (void *, struct ccase **, casenumber);
typedef bool trns_free_func (void *);
\f
bool trns_chain_is_empty (const struct trns_chain *);
-void trns_chain_append (struct trns_chain *, trns_finalize_func *,
+void trns_chain_append (struct trns_chain *,
trns_proc_func *, trns_free_func *, void *);
size_t trns_chain_next (struct trns_chain *);
enum trns_result trns_chain_execute (const struct trns_chain *,
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static bool must_not_have_else (struct do_if_trns *);
static void close_do_if (void *do_if);
-static trns_finalize_func do_if_finalize_func;
static trns_proc_func do_if_trns_proc, break_trns_proc;
static trns_free_func do_if_trns_free;
do_if->ds = ds;
ctl_stack_push (&do_if_class, do_if);
- add_transformation_with_finalizer (ds, do_if_finalize_func,
- do_if_trns_proc, do_if_trns_free, do_if);
+ add_transformation (ds, do_if_trns_proc, do_if_trns_free, do_if);
return parse_clause (lexer, do_if, ds);
}
clause->target_index = next_transformation (do_if->ds);
}
-/* Finalizes DO IF by clearing the control stack, thus ensuring
- that all open DO IFs are closed. */
-static void
-do_if_finalize_func (void *do_if_ UNUSED)
-{
- /* This will be called multiple times if multiple DO IFs were
- executed, which is slightly unclean, but at least it's
- idempotent. */
- ctl_stack_clear ();
-}
-
/* DO IF transformation procedure.
Checks each clause and jumps to the appropriate
transformation. */
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009-2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009-2011, 2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static const struct ctl_class loop_class;
-static trns_finalize_func loop_trns_finalize;
static trns_proc_func loop_trns_proc, end_loop_trns_proc, break_trns_proc;
static trns_free_func loop_trns_free;
loop->loop_condition = loop->end_loop_condition = NULL;
loop->ds = ds;
- add_transformation_with_finalizer (ds, loop_trns_finalize,
- loop_trns_proc, loop_trns_free, loop);
+ add_transformation (ds, loop_trns_proc, loop_trns_free, loop);
loop->past_LOOP_index = next_transformation (ds);
ctl_stack_push (&loop_class, loop);
return loop;
}
-/* Finalizes LOOP by clearing the control stack, thus ensuring
- that all open LOOPs are closed. */
-static void
-loop_trns_finalize (void *do_if_ UNUSED)
-{
- /* This will be called multiple times if multiple LOOPs were
- executed, which is slightly unclean, but at least it's
- idempotent. */
- ctl_stack_clear ();
-}
-
/* Sets up LOOP for the first pass. */
static int
loop_trns_proc (void *loop_, struct ccase **c, casenumber case_num)