? expr-accessor.patch Index: src/language/expressions/parse.c =================================================================== RCS file: /cvsroot/pspp/pspp/src/language/expressions/parse.c,v retrieving revision 1.25 diff -u -p -r1.25 parse.c --- src/language/expressions/parse.c 2 Apr 2007 08:55:52 -0000 1.25 +++ src/language/expressions/parse.c 16 Apr 2007 00:38:14 -0000 @@ -1507,3 +1507,42 @@ allocate_unary_variable (struct expressi return expr_allocate_unary (e, var_is_numeric (v) ? OP_NUM_VAR : OP_STR_VAR, expr_allocate_variable (e, v)); } + +/* Export function details to other modules. */ + +/* Returns the operation structure for the function with the + given IDX. */ +const struct operation * +expr_get_function (size_t idx) +{ + assert (idx < OP_function_cnt); + return &operations[OP_function_first + idx]; +} + +/* Returns the number of expression functions. */ +size_t +expr_get_function_cnt (void) +{ + return OP_function_cnt; +} + +/* Returns the name of operation OP. */ +const char * +expr_operation_get_name (const struct operation *op) +{ + return op->name; +} + +/* Returns the human-readable prototype for operation OP. */ +const char * +expr_operation_get_prototype (const struct operation *op) +{ + return op->prototype; +} + +/* Returns the number of arguments for operation OP. */ +int +expr_operation_get_arg_cnt (const struct operation *op) +{ + return op->arg_cnt; +} Index: src/language/expressions/public.h =================================================================== RCS file: /cvsroot/pspp/pspp/src/language/expressions/public.h,v retrieving revision 1.4 diff -u -p -r1.4 public.h --- src/language/expressions/public.h 15 Dec 2006 00:16:02 -0000 1.4 +++ src/language/expressions/public.h 16 Apr 2007 00:38:14 -0000 @@ -50,4 +50,10 @@ double expr_evaluate_num (struct express void expr_evaluate_str (struct expression *, const struct ccase *, int case_idx, char *dst, size_t dst_size); +const struct operation *expr_get_function (size_t idx); +size_t expr_get_function_cnt (void); +const char *expr_operation_get_name (const struct operation *); +const char *expr_operation_get_prototype (const struct operation *); +int expr_operation_get_arg_cnt (const struct operation *); + #endif /* expr.h */ Index: src/ui/gui/compute-dialog.c =================================================================== RCS file: /cvsroot/pspp/pspp/src/ui/gui/compute-dialog.c,v retrieving revision 1.2 diff -u -p -r1.2 compute-dialog.c --- src/ui/gui/compute-dialog.c 16 Apr 2007 00:19:41 -0000 1.2 +++ src/ui/gui/compute-dialog.c 16 Apr 2007 00:38:14 -0000 @@ -29,11 +29,11 @@ #include "dialog-common.h" #include "dict-display.h" +#include #include #include "syntax-editor.h" -#include #include "c-ctype.h" static void function_list_populate (GtkTreeView *tv); @@ -291,12 +291,6 @@ enum { }; -static const struct operation fs[] = - { -#include "parse.inc" - }; - - static void function_list_populate (GtkTreeView *tv) { @@ -304,25 +298,20 @@ function_list_populate (GtkTreeView *tv) GtkTreeIter iter; gint i; - const gint n_funcs = sizeof (fs) / sizeof fs[0] ; + const gint n_funcs = expr_get_function_cnt (); liststore = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT); for (i = 0 ; i < n_funcs ; ++i) { - if ( fs[i].prototype == NULL) - continue; - - /* All the real ones seem to begin with an upper case letter */ - if ( !c_isupper(*fs[i].prototype)) - continue; - + const struct operation *op = expr_get_function (i); + gtk_list_store_append (liststore, &iter); gtk_list_store_set (liststore, &iter, - COL_NAME, fs[i].name, - COL_USAGE,fs[i].prototype, - COL_ARITY, fs[i].arg_cnt, + COL_NAME, expr_operation_get_name (op), + COL_USAGE, expr_operation_get_prototype (op), + COL_ARITY, expr_operation_get_arg_cnt (op), -1); }