From d44deb32bd985aab59848c054569aac5b19eee22 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 5 Sep 2016 12:49:21 -0400 Subject: [PATCH] UDF iterate --- c/mapping/function_manager.c | 34 +++++++++++++++++++++---- c/mapping/function_manager.h | 48 +++++++++--------------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/c/mapping/function_manager.c b/c/mapping/function_manager.c index 5d4656133..19e44645e 100644 --- a/c/mapping/function_manager.c +++ b/c/mapping/function_manager.c @@ -4,6 +4,34 @@ #include "mapping/context_flags.h" #include "mapping/rval_evaluators.h" +// ---------------------------------------------------------------- +typedef enum _func_class_t { + FUNC_CLASS_ARITHMETIC, + FUNC_CLASS_MATH, + FUNC_CLASS_BOOLEAN, + FUNC_CLASS_STRING, + FUNC_CLASS_CONVERSION, + FUNC_CLASS_TIME +} func_class_t; + +typedef enum _arity_check_t { + ARITY_CHECK_PASS, + ARITY_CHECK_FAIL, + ARITY_CHECK_NO_SUCH +} arity_check_t; + +// xxx move to fcn manager, along with move functions -> methods there +typedef struct _function_lookup_t { + func_class_t function_class; + char* function_name; + int arity; + char* usage_string; +} function_lookup_t; + +// xxx rm +extern function_lookup_t FUNCTION_LOOKUP_TABLE[]; + +// ---------------------------------------------------------------- //typedef struct _function_lookup_t { // func_class_t function_class; // char* function_name; @@ -40,6 +68,7 @@ static rval_evaluator_t* rval_evaluator_alloc_from_ternary_func_name(char* fnnm, static rval_evaluator_t* rval_evaluator_alloc_from_ternary_regex_arg2_func_name(char* fnnm, rval_evaluator_t* parg1, char* regex_string, int ignore_case, rval_evaluator_t* parg3); +// ---------------------------------------------------------------- // ---------------------------------------------------------------- fmgr_t* fmgr_alloc() { fmgr_t* pfmgr = mlr_malloc_or_die(sizeof(fmgr_t)); @@ -69,11 +98,6 @@ void fmgr_install_UDF(fmgr_t* pfmgr, char* name, rval_evaluator_t* pevaluator) { // xxx stub } -// ---------------------------------------------------------------- -rval_evaluator_t* fmgr_alloc_evaluator(fmgr_t* pfmgr, char* name) { - return NULL; // xxx stub -} - // ================================================================ // xxx make static function_lookup_t FUNCTION_LOOKUP_TABLE[] = { diff --git a/c/mapping/function_manager.h b/c/mapping/function_manager.h index 1ca51fd0e..0b3452df2 100644 --- a/c/mapping/function_manager.h +++ b/c/mapping/function_manager.h @@ -7,52 +7,28 @@ #include "mapping/type_inference.h" // ---------------------------------------------------------------- -// xxx make static in fmgr - -typedef enum _func_class_t { - FUNC_CLASS_ARITHMETIC, - FUNC_CLASS_MATH, - FUNC_CLASS_BOOLEAN, - FUNC_CLASS_STRING, - FUNC_CLASS_CONVERSION, - FUNC_CLASS_TIME -} func_class_t; - -typedef enum _arity_check_t { - ARITY_CHECK_PASS, - ARITY_CHECK_FAIL, - ARITY_CHECK_NO_SUCH -} arity_check_t; - -// xxx move to fcn manager, along with move functions -> methods there -typedef struct _function_lookup_t { - func_class_t function_class; - char* function_name; - int arity; - char* usage_string; -} function_lookup_t; - -extern function_lookup_t FUNCTION_LOOKUP_TABLE[]; // xxx rm - -// ---------------------------------------------------------------- - +struct _function_lookup_t; typedef struct _fmgr_t { - function_lookup_t * function_lookup_table; + struct _function_lookup_t * function_lookup_table; lhmsv_t* pUDF_names_to_evaluators; } fmgr_t; +// ---------------------------------------------------------------- fmgr_t* fmgr_alloc(); + void fmgr_free(fmgr_t* pfmgr); + // xxx disallow redefine ? void fmgr_install_UDF(fmgr_t* pfmgr, char* name, rval_evaluator_t* pevaluator); -rval_evaluator_t* fmgr_alloc_evaluator(fmgr_t* pfmgr, char* name); - -void fmgr_list_functions(fmgr_t* pfmgr, FILE* output_stream, char* leader); -// Pass function_name == NULL to get usage for all functions: -void fmgr_function_usage(fmgr_t* pfmgr, FILE* output_stream, char* function_name); -void fmgr_list_all_functions_raw(fmgr_t* pfmgr, FILE* output_stream); rval_evaluator_t* fmgr_alloc_from_operator_or_function(fmgr_t* pfmgr, mlr_dsl_ast_node_t* pnode, int type_inferencing, int context_flags); +void fmgr_list_functions(fmgr_t* pfmgr, FILE* output_stream, char* leader); + +// Pass function_name == NULL to get usage for all functions: +void fmgr_function_usage(fmgr_t* pfmgr, FILE* output_stream, char* function_name); + +void fmgr_list_all_functions_raw(fmgr_t* pfmgr, FILE* output_stream); + #endif // FUNCTION_MANAGER_H