From 4a87bb608d18c0cb3dd20535a488ade6d1b224eb Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 26 Dec 2021 16:24:10 -0800 Subject: [PATCH] some more type decls --- src/language/stats/ctables.c | 150 ++++++++++++++++++++++++++++++++--- 1 file changed, 138 insertions(+), 12 deletions(-) diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index 6ac8a7f83b..c5ac106e06 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -18,7 +18,9 @@ #include "language/command.h" #include "language/lexer/lexer.h" +#include "libpspp/hmap.h" #include "libpspp/message.h" +#include "output/pivot-table.h" #include "gl/xalloc.h" @@ -74,28 +76,28 @@ struct ctables_postcompute_expr enum ctables_postcompute_op { /* Terminals. */ - CTPET_CAT_NUMBER, - CTPET_CAT_STRING, - CTPET_CAT_RANGE, - CTPET_CAT_MISSING, + CTPO_CAT_NUMBER, + CTPO_CAT_STRING, + CTPO_CAT_RANGE, + CTPO_CAT_MISSING, /* XXX OTHERNM */ /* XXX SUBTOTAL and HSUBTOTAL */ /* Nonterminals. */ - CTPET_ADD, - CTPET_SUB, - CTPET_MUL, - CTPET_DIV, - CTPET_POW, + CTPO_ADD, + CTPO_SUB, + CTPO_MUL, + CTPO_DIV, + CTPO_POW, } op; union { - /* CTPET_CAT_NUMBER, CTPET_NUMBER. */ + /* CTPO_CAT_NUMBER, CTPO_NUMBER. */ double number; - /* CTPET_CAT_RANGE. + /* CTPO_CAT_RANGE. XXX what about string ranges? */ struct @@ -105,11 +107,135 @@ struct ctables_postcompute_expr } range; - /* CTPET_ADD, CTPET_SUB, CTPET_MUL, CTPET_DIV, CTPET_POW. */ + /* CTPO_ADD, CTPO_SUB, CTPO_MUL, CTPO_DIV, CTPO_POW. */ struct ctables_postcompute_expr *subs[2]; }; }; +struct ctables_table + { + struct ctables_axis *axes[PIVOT_N_AXES]; + + + }; + +struct ctables_axis + { + enum ctables_axis_op + { + /* Terminals. */ + CTAO_VAR, + CTAO_MRSET, + + /* Nonterminals. */ + CTAO_CONCAT, /* + */ + CTAO_NEST, /* > */ + } + op; + + union + { + /* Terminals. */ + struct + { + union + { + struct variable *var; + struct mrset *mrset; + }; + + bool scale; + struct ctables_summary *summaries; + size_t n_summaries; + }; + + /* Nonterminals. */ + struct ctables_axis *subs[2]; + }; + }; + +struct ctables_summary + { + enum ctables_summary_function + { + /* All variables. */ + CTSF_COUNT, + CTSF_ECOUNT, + CTSF_ROWPCT_COUNT, + CTSF_COLPCT_COUNT, + CTSF_TABLEPCT_COUNT, + CTSF_SUBTABLEPCT_COUNT, + CTSF_LAYERPCT_COUNT, + CTSF_LAYERROWPCT_COUNT, + CTSF_LAYERCOLPCT_COUNT, + CTSF_ROWPCT_VALIDN, + CTSF_COLPCT_VALIDN, + CTSF_TABLEPCT_VALIDN, + CTSF_SUBTABLEPCT_VALIDN, + CTSF_LAYERPCT_VALIDN, + CTSF_LAYERROWPCT_VALIDN, + CTSF_LAYERCOLPCT_VALIDN, + CTSF_ROWPCT_TOTALN, + CTSF_COLPCT_TOTALN, + CTSF_TABLEPCT_TOTALN, + CTSF_SUBTABLEPCT_TOTALN, + CTSF_LAYERPCT_TOTALN, + CTSF_LAYERROWPCT_TOTALN, + CTSF_LAYERCOLPCT_TOTALN, + + /* Scale variables, totals, and subtotals. */ + CTSF_MAXIMUM, + CTSF_MEAN, + CTSF_MEDIAN, + CTSF_MINIMUM, + CTSF_MISSING, + CTSF_MODE, + CTSF_PTILE, + CTSF_RANGE, + CTSF_SEMAN, + CTSF_STDDEV, + CTSF_SUM, + CSTF_TOTALN, + CTSF_ETOTALN, + CTSF_VALIDN, + CTSF_EVALIDN, + CTSF_VARIANCE, + CTSF_ROWPCT_SUM, + CTSF_COLPCT_SUM, + CTSF_TABLEPCT_SUM, + CTSF_SUBTABLEPCT_SUM, + CTSF_LAYERPCT_SUM, + CTSF_LAYERROWPCT_SUM, + CTSF_LAYERCOLPCT_SUM, + + /* Multiple response sets. */ + CTSF_ROWPCT_RESPONSES, + CTSF_COLPCT_RESPONSES, + CTSF_TABLEPCT_RESPONSES, + CTSF_SUBTABLEPCT_RESPONSES, + CTSF_LAYERPCT_RESPONSES, + CTSF_LAYERROWPCT_RESPONSES, + CTSF_LAYERCOLPCT_RESPONSES, + CTSF_ROWPCT_RESPONSES_COUNT, + CTSF_COLPCT_RESPONSES_COUNT, + CTSF_TABLEPCT_RESPONSES_COUNT, + CTSF_SUBTABLEPCT_RESPONSES_COUNT, + CTSF_LAYERPCT_RESPONSES_COUNT, + CTSF_LAYERROWPCT_RESPONSES_COUNT, + CTSF_LAYERCOLPCT_RESPONSES_COUNT, + CTSF_ROWPCT_COUNT_RESPONSES, + CTSF_COLPCT_COUNT_RESPONSES, + CTSF_TABLEPCT_COUNT_RESPONSES, + CTSF_SUBTABLEPCT_COUNT_RESPONSES, + CTSF_LAYERPCT_COUNT_RESPONSES, + CTSF_LAYERROWPCT_COUNT_RESPONSES, + CTSF_LAYERCOLPCT_COUNT_RESPONSES, + } + function; + + char *label; + struct fmt_spec format; /* XXX extra CTABLES formats */ + }; int cmd_ctables (struct lexer *lexer, struct dataset *ds) -- 2.30.2