From 0ca56f0ec2e1201b9a5da98f8700aa862eb0523c Mon Sep 17 00:00:00 2001 From: Balazs Scheidler Date: Sat, 8 Jun 2024 11:30:32 +0200 Subject: [PATCH] filterx: add filterx error handling to simple functions argument validation This patch does two things: 1) adds FilterXExpr * argument to all simple functions 2) changes msg_error() style error handling to filterx style Signed-off-by: Balazs Scheidler --- lib/filterx/expr-function.c | 2 +- lib/filterx/expr-function.h | 2 +- lib/filterx/filterx-globals.c | 6 ++- lib/filterx/filterx-globals.h | 2 +- lib/filterx/func-len.c | 8 +-- lib/filterx/func-len.h | 2 +- lib/filterx/func-vars.c | 4 +- lib/filterx/func-vars.h | 2 +- lib/filterx/object-datetime.c | 14 ++--- lib/filterx/object-datetime.h | 4 +- lib/filterx/object-json-array.c | 13 +++-- lib/filterx/object-json.c | 9 ++-- lib/filterx/object-json.h | 4 +- lib/filterx/object-primitive.c | 12 ++--- lib/filterx/object-primitive.h | 6 +-- lib/filterx/object-string.c | 12 ++--- lib/filterx/object-string.h | 6 +-- lib/filterx/tests/test_builtin_functions.c | 4 +- lib/filterx/tests/test_expr_condition.c | 4 +- lib/filterx/tests/test_expr_function.c | 2 +- lib/filterx/tests/test_object_boolean.c | 10 ++-- lib/filterx/tests/test_object_bytes.c | 14 ++--- lib/filterx/tests/test_object_datetime.c | 20 +++---- lib/filterx/tests/test_object_double.c | 14 ++--- lib/filterx/tests/test_object_integer.c | 20 +++---- lib/filterx/tests/test_object_json.c | 4 +- lib/filterx/tests/test_object_protobuf.c | 12 ++--- lib/filterx/tests/test_object_string.c | 14 ++--- .../grpc/otel/filterx/object-otel-array.cpp | 2 +- .../grpc/otel/filterx/object-otel-kvlist.cpp | 2 +- .../otel/filterx/object-otel-logrecord.cpp | 2 +- .../otel/filterx/object-otel-resource.cpp | 2 +- .../grpc/otel/filterx/object-otel-scope.cpp | 2 +- modules/grpc/otel/filterx/object-otel.h | 21 ++++---- modules/grpc/otel/tests/test-otel-filterx.cpp | 54 +++++++++---------- modules/json/filterx-format-json.c | 4 +- modules/json/filterx-format-json.h | 2 +- modules/json/tests/test_filterx_format_json.c | 2 +- 38 files changed, 157 insertions(+), 162 deletions(-) diff --git a/lib/filterx/expr-function.c b/lib/filterx/expr-function.c index bcb14d029f..e5cbc65fd5 100644 --- a/lib/filterx/expr-function.c +++ b/lib/filterx/expr-function.c @@ -103,7 +103,7 @@ _simple_eval(FilterXExpr *s) FilterXSimpleFunctionProto f = self->function_proto; g_assert(f != NULL); - FilterXObject *res = f(args); + FilterXObject *res = f(s, args); if (args != NULL) g_ptr_array_free(args, TRUE); diff --git a/lib/filterx/expr-function.h b/lib/filterx/expr-function.h index b2493d5d7b..0d943228b8 100644 --- a/lib/filterx/expr-function.h +++ b/lib/filterx/expr-function.h @@ -28,7 +28,7 @@ #include "filterx/filterx-object.h" #include "plugin.h" -typedef FilterXObject *(*FilterXSimpleFunctionProto)(GPtrArray *); +typedef FilterXObject *(*FilterXSimpleFunctionProto)(FilterXExpr *s, GPtrArray *); void filterx_simple_function_argument_error(FilterXExpr *s, gchar *error_info, gboolean free_info); diff --git a/lib/filterx/filterx-globals.c b/lib/filterx/filterx-globals.c index 399ac6ede7..e69bea53e3 100644 --- a/lib/filterx/filterx-globals.c +++ b/lib/filterx/filterx-globals.c @@ -33,6 +33,7 @@ #include "filterx/func-istype.h" #include "filterx/func-len.h" #include "filterx/func-vars.h" +#include "filterx/filterx-eval.h" static GHashTable *filterx_builtin_simple_functions = NULL; static GHashTable *filterx_builtin_function_ctors = NULL; @@ -197,11 +198,12 @@ filterx_global_deinit(void) filterx_types_deinit(); } -FilterXObject *filterx_typecast_get_arg(GPtrArray *args, gchar *alt_msg) +FilterXObject * +filterx_typecast_get_arg(FilterXExpr *s, GPtrArray *args) { if (args == NULL || args->len != 1) { - msg_error(alt_msg ? alt_msg : "filterx: typecast functions must have exactly 1 argument"); + filterx_simple_function_argument_error(s, "Requires exactly one argument", FALSE); return NULL; } diff --git a/lib/filterx/filterx-globals.h b/lib/filterx/filterx-globals.h index 2162c3de01..a3249a6977 100644 --- a/lib/filterx/filterx-globals.h +++ b/lib/filterx/filterx-globals.h @@ -41,6 +41,6 @@ FilterXType *filterx_type_lookup(const gchar *type_name); gboolean filterx_type_register(const gchar *type_name, FilterXType *fxtype); // Helpers -FilterXObject *filterx_typecast_get_arg(GPtrArray *args, gchar *alt_msg); +FilterXObject *filterx_typecast_get_arg(FilterXExpr *s, GPtrArray *args); #endif diff --git a/lib/filterx/func-len.c b/lib/filterx/func-len.c index a7e49b5493..cceb82552d 100644 --- a/lib/filterx/func-len.c +++ b/lib/filterx/func-len.c @@ -23,15 +23,16 @@ #include "filterx/func-len.h" #include "filterx/object-primitive.h" +#include "filterx/filterx-eval.h" #define FILTERX_FUNC_LEN_USAGE "Usage: len(object)" FilterXObject * -filterx_simple_function_len(GPtrArray *args) +filterx_simple_function_len(FilterXExpr *s, GPtrArray *args) { if (args == NULL || args->len != 1) { - msg_error("FilterX: len: invalid number of arguments. " FILTERX_FUNC_LEN_USAGE); + filterx_simple_function_argument_error(s, "Requires exactly one argument", FALSE); return NULL; } @@ -41,8 +42,7 @@ filterx_simple_function_len(GPtrArray *args) gboolean success = filterx_object_len(object, &len); if (!success) { - msg_error("FilterX: len: object type is not supported", - evt_tag_str("type", object->type->name)); + filterx_eval_push_error("Object does not support len()", s, object); return NULL; } diff --git a/lib/filterx/func-len.h b/lib/filterx/func-len.h index 2bd93aca98..d93909f3ca 100644 --- a/lib/filterx/func-len.h +++ b/lib/filterx/func-len.h @@ -26,6 +26,6 @@ #include "filterx/expr-function.h" -FilterXObject *filterx_simple_function_len(GPtrArray *args); +FilterXObject *filterx_simple_function_len(FilterXExpr *s, GPtrArray *args); #endif diff --git a/lib/filterx/func-vars.c b/lib/filterx/func-vars.c index f4e1fe11af..f71f3681a1 100644 --- a/lib/filterx/func-vars.c +++ b/lib/filterx/func-vars.c @@ -47,11 +47,11 @@ _add_to_dict(FilterXVariable *variable, gpointer user_data) } FilterXObject * -filterx_simple_function_vars(GPtrArray *args) +filterx_simple_function_vars(FilterXExpr *s, GPtrArray *args) { if (args && args->len != 0) { - msg_error("filterx: vars() function does not take any arguments"); + filterx_simple_function_argument_error(s, "Incorrect number of arguments", FALSE); return NULL; } diff --git a/lib/filterx/func-vars.h b/lib/filterx/func-vars.h index 000a947249..cc32ce7720 100644 --- a/lib/filterx/func-vars.h +++ b/lib/filterx/func-vars.h @@ -26,6 +26,6 @@ #include "filterx/expr-function.h" -FilterXObject *filterx_simple_function_vars(GPtrArray *args); +FilterXObject *filterx_simple_function_vars(FilterXExpr *s, GPtrArray *args); #endif diff --git a/lib/filterx/object-datetime.c b/lib/filterx/object-datetime.c index fcdee03d2f..e2bf5fc483 100644 --- a/lib/filterx/object-datetime.c +++ b/lib/filterx/object-datetime.c @@ -115,11 +115,9 @@ filterx_datetime_get_value(FilterXObject *s) FilterXObject * -filterx_typecast_datetime(GPtrArray *args) +filterx_typecast_datetime(FilterXExpr *s, GPtrArray *args) { - FilterXObject *object = filterx_typecast_get_arg(args, - "FilterX: Failed to create datetime object: invalid number of arguments. " - "Usage: datetime($isodate_str), datetime($unix_int_ms) or datetime($unix_float_s)"); + FilterXObject *object = filterx_typecast_get_arg(s, args); if (!object) return NULL; @@ -144,7 +142,7 @@ filterx_typecast_datetime(GPtrArray *args) } else if (filterx_object_is_type(object, &FILTERX_TYPE_NAME(string))) { - return filterx_typecast_datetime_isodate(args); + return filterx_typecast_datetime_isodate(s, args); } msg_error("filterx: invalid typecast", evt_tag_str("from", object->type->name), @@ -153,11 +151,9 @@ filterx_typecast_datetime(GPtrArray *args) } FilterXObject * -filterx_typecast_datetime_isodate(GPtrArray *args) +filterx_typecast_datetime_isodate(FilterXExpr *s, GPtrArray *args) { - FilterXObject *object = filterx_typecast_get_arg(args, - "FilterX: Failed to create datetime object: invalid number of arguments. " - "Usage: datetime($isodate_str), datetime($unix_int_ms) or datetime($unix_float_s)"); + FilterXObject *object = filterx_typecast_get_arg(s, args); if (!object) return NULL; diff --git a/lib/filterx/object-datetime.h b/lib/filterx/object-datetime.h index 7d012258d9..aeb22a737d 100644 --- a/lib/filterx/object-datetime.h +++ b/lib/filterx/object-datetime.h @@ -32,8 +32,8 @@ FILTERX_DECLARE_TYPE(datetime); FilterXObject *filterx_datetime_new(const UnixTime *ut); UnixTime filterx_datetime_get_value(FilterXObject *s); -FilterXObject *filterx_typecast_datetime(GPtrArray *args); -FilterXObject *filterx_typecast_datetime_isodate(GPtrArray *args); +FilterXObject *filterx_typecast_datetime(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_typecast_datetime_isodate(FilterXExpr *, GPtrArray *args); FilterXFunction *filterx_function_strptime_new(const gchar *function_name, FilterXFunctionArgs *args, GError **error); gboolean datetime_repr(const UnixTime *ut, GString *repr); diff --git a/lib/filterx/object-json-array.c b/lib/filterx/object-json-array.c index f61566f16a..0ae2abbef3 100644 --- a/lib/filterx/object-json-array.c +++ b/lib/filterx/object-json-array.c @@ -27,6 +27,8 @@ #include "filterx/object-message-value.h" #include "filterx/filterx-weakrefs.h" #include "filterx/object-list-interface.h" +#include "filterx/expr-function.h" +#include "filterx/filterx-eval.h" #include "scanner/list-scanner/list-scanner.h" #include "str-repr/encode.h" @@ -304,15 +306,14 @@ filterx_json_array_new_from_syslog_ng_list(const gchar *repr, gssize repr_len) } FilterXObject * -filterx_json_array_new_from_args(GPtrArray *args) +filterx_json_array_new_from_args(FilterXExpr *s, GPtrArray *args) { if (!args || args->len == 0) return filterx_json_array_new_empty(); if (args->len != 1) { - msg_error("FilterX: Failed to create JSON array: invalid number of arguments. " - "Usage: json_array() or json_array($raw_json_string) or json_array($existing_json_array)"); + filterx_simple_function_argument_error(s, "Requires zero or one argument", FALSE); return NULL; } @@ -338,10 +339,8 @@ filterx_json_array_new_from_args(GPtrArray *args) return filterx_json_array_new_from_repr(repr, repr_len); error: - msg_error("FilterX: Failed to create JSON object: invalid argument type. " - "Usage: json_array() or json_array($raw_json_string) or json_array($syslog_ng_list) or " - "json_array($existing_json_array)", - evt_tag_str("type", arg->type->name)); + filterx_eval_push_error_info("Argument must be a json array, a string or a syslog-ng list", s, + g_strdup_printf("got \"%s\" instead", arg->type->name), TRUE); return NULL; } diff --git a/lib/filterx/object-json.c b/lib/filterx/object-json.c index 11261f894d..f60299d22f 100644 --- a/lib/filterx/object-json.c +++ b/lib/filterx/object-json.c @@ -162,15 +162,14 @@ filterx_json_new_from_repr(const gchar *repr, gssize repr_len) } FilterXObject * -filterx_json_new_from_args(GPtrArray *args) +filterx_json_new_from_args(FilterXExpr *s, GPtrArray *args) { if (!args || args->len == 0) return filterx_json_object_new_empty(); if (args->len != 1) { - msg_error("FilterX: Failed to create JSON object: invalid number of arguments. " - "Usage: json() or json($raw_json_string) or json($existing_json)"); + filterx_eval_push_error("Too many arguments", s, NULL); return NULL; } @@ -220,9 +219,7 @@ filterx_json_new_from_args(GPtrArray *args) return filterx_json_new_from_repr(repr, repr_len); error: - msg_error("FilterX: Failed to create JSON object: invalid argument type. " - "Usage: json() or json($raw_json_string) or json($syslog_ng_list) or json($existing_json)", - evt_tag_str("type", arg->type->name)); + filterx_eval_push_error_info("Argument must be a json, a string or a syslog-ng list", s, g_strdup_printf("got \"%s\" instead", arg->type->name), TRUE); return NULL; } diff --git a/lib/filterx/object-json.h b/lib/filterx/object-json.h index 023bf9b4a9..86118dc34f 100644 --- a/lib/filterx/object-json.h +++ b/lib/filterx/object-json.h @@ -41,8 +41,8 @@ FilterXObject *filterx_json_array_new_from_syslog_ng_list(const gchar *repr, gss FilterXObject *filterx_json_object_new_empty(void); FilterXObject *filterx_json_array_new_empty(void); -FilterXObject *filterx_json_new_from_args(GPtrArray *args); -FilterXObject *filterx_json_array_new_from_args(GPtrArray *args); +FilterXObject *filterx_json_new_from_args(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_json_array_new_from_args(FilterXExpr *s, GPtrArray *args); FilterXObject *filterx_json_new_from_object(struct json_object *object); diff --git a/lib/filterx/object-primitive.c b/lib/filterx/object-primitive.c index 92b9c71006..8884e0d14d 100644 --- a/lib/filterx/object-primitive.c +++ b/lib/filterx/object-primitive.c @@ -231,9 +231,9 @@ filterx_primitive_get_value(FilterXObject *s) } FilterXObject * -filterx_typecast_boolean(GPtrArray *args) +filterx_typecast_boolean(FilterXExpr *s, GPtrArray *args) { - FilterXObject *object = filterx_typecast_get_arg(args, NULL); + FilterXObject *object = filterx_typecast_get_arg(s, args); if (!object) return NULL; @@ -247,9 +247,9 @@ filterx_typecast_boolean(GPtrArray *args) } FilterXObject * -filterx_typecast_integer(GPtrArray *args) +filterx_typecast_integer(FilterXExpr *s, GPtrArray *args) { - FilterXObject *object = filterx_typecast_get_arg(args, NULL); + FilterXObject *object = filterx_typecast_get_arg(s, args); if (!object) return NULL; @@ -281,9 +281,9 @@ filterx_typecast_integer(GPtrArray *args) } FilterXObject * -filterx_typecast_double(GPtrArray *args) +filterx_typecast_double(FilterXExpr *s, GPtrArray *args) { - FilterXObject *object = filterx_typecast_get_arg(args, NULL); + FilterXObject *object = filterx_typecast_get_arg(s, args); if (!object) return NULL; diff --git a/lib/filterx/object-primitive.h b/lib/filterx/object-primitive.h index 60022f5ac2..160d2d8d57 100644 --- a/lib/filterx/object-primitive.h +++ b/lib/filterx/object-primitive.h @@ -48,9 +48,9 @@ FilterXObject *filterx_boolean_new(gboolean value); FilterXObject *filterx_enum_new(GlobalConfig *cfg, const gchar *namespace_name, const gchar *enum_name); GenericNumber filterx_primitive_get_value(FilterXObject *s); -FilterXObject *filterx_typecast_boolean(GPtrArray *args); -FilterXObject *filterx_typecast_integer(GPtrArray *args); -FilterXObject *filterx_typecast_double(GPtrArray *args); +FilterXObject *filterx_typecast_boolean(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_typecast_integer(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_typecast_double(FilterXExpr *s, GPtrArray *args); gboolean bool_repr(gboolean bool_val, GString *repr); gboolean double_repr(double val, GString *repr); diff --git a/lib/filterx/object-string.c b/lib/filterx/object-string.c index b890cac5cb..8ccdc26ee2 100644 --- a/lib/filterx/object-string.c +++ b/lib/filterx/object-string.c @@ -209,9 +209,9 @@ filterx_protobuf_new(const gchar *mem, gssize mem_len) } FilterXObject * -filterx_typecast_string(GPtrArray *args) +filterx_typecast_string(FilterXExpr *s, GPtrArray *args) { - FilterXObject *object = filterx_typecast_get_arg(args, NULL); + FilterXObject *object = filterx_typecast_get_arg(s, args); if (!object) return NULL; @@ -235,9 +235,9 @@ filterx_typecast_string(GPtrArray *args) } FilterXObject * -filterx_typecast_bytes(GPtrArray *args) +filterx_typecast_bytes(FilterXExpr *s, GPtrArray *args) { - FilterXObject *object = filterx_typecast_get_arg(args, NULL); + FilterXObject *object = filterx_typecast_get_arg(s, args); if (!object) return NULL; @@ -268,9 +268,9 @@ filterx_typecast_bytes(GPtrArray *args) } FilterXObject * -filterx_typecast_protobuf(GPtrArray *args) +filterx_typecast_protobuf(FilterXExpr *s, GPtrArray *args) { - FilterXObject *object = filterx_typecast_get_arg(args, NULL); + FilterXObject *object = filterx_typecast_get_arg(s, args); if (!object) return NULL; diff --git a/lib/filterx/object-string.h b/lib/filterx/object-string.h index b76a47df69..8839fd5547 100644 --- a/lib/filterx/object-string.h +++ b/lib/filterx/object-string.h @@ -32,9 +32,9 @@ FILTERX_DECLARE_TYPE(protobuf); const gchar *filterx_string_get_value(FilterXObject *s, gsize *length); const gchar *filterx_bytes_get_value(FilterXObject *s, gsize *length); const gchar *filterx_protobuf_get_value(FilterXObject *s, gsize *length); -FilterXObject *filterx_typecast_string(GPtrArray *args); -FilterXObject *filterx_typecast_bytes(GPtrArray *args); -FilterXObject *filterx_typecast_protobuf(GPtrArray *args); +FilterXObject *filterx_typecast_string(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_typecast_bytes(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_typecast_protobuf(FilterXExpr *s, GPtrArray *args); FilterXObject *filterx_string_new(const gchar *str, gssize str_len); FilterXObject *filterx_bytes_new(const gchar *str, gssize str_len); diff --git a/lib/filterx/tests/test_builtin_functions.c b/lib/filterx/tests/test_builtin_functions.c index 01a933d764..a59bd32d53 100644 --- a/lib/filterx/tests/test_builtin_functions.c +++ b/lib/filterx/tests/test_builtin_functions.c @@ -46,7 +46,7 @@ #define TEST_BUILTIN_FUNCTION_NAME "TEST_BUILTIN_DUMMY_KEY" FilterXObject * -test_builtin_simple_dummy_function(GPtrArray *args) +test_builtin_simple_dummy_function(FilterXExpr *s, GPtrArray *args) { return filterx_string_new("test-builtin-functions", -1); } @@ -82,7 +82,7 @@ Test(builtin_functions, test_builtin_simple_functions_lookup) cr_assert(func != NULL); // check dummy function as result - FilterXObject *res = func(NULL); + FilterXObject *res = func(NULL, NULL); cr_assert(res != NULL); cr_assert(filterx_object_is_type(res, &FILTERX_TYPE_NAME(string))); gsize len; diff --git a/lib/filterx/tests/test_expr_condition.c b/lib/filterx/tests/test_expr_condition.c index c0029bc937..29b8d2516b 100644 --- a/lib/filterx/tests/test_expr_condition.c +++ b/lib/filterx/tests/test_expr_condition.c @@ -346,7 +346,7 @@ Test(expr_condition, test_condition_do_not_allow_to_add_else_into_else, .signal= } FilterXObject * -_fail_func(GPtrArray *args) +_fail_func(FilterXExpr *s, GPtrArray *args) { return NULL; } @@ -365,7 +365,7 @@ Test(expr_condition, test_condition_return_null_on_illegal_expr) } FilterXObject * -_dummy_func(GPtrArray *args) +_dummy_func(FilterXExpr *s, GPtrArray *args) { return filterx_string_new("foobar", -1); } diff --git a/lib/filterx/tests/test_expr_function.c b/lib/filterx/tests/test_expr_function.c index 8edda5cff2..437dbde918 100644 --- a/lib/filterx/tests/test_expr_function.c +++ b/lib/filterx/tests/test_expr_function.c @@ -43,7 +43,7 @@ #include "apphook.h" #include "scratch-buffers.h" -FilterXObject *test_dummy_function(GPtrArray *args) +FilterXObject *test_dummy_function(FilterXExpr *s, GPtrArray *args) { GString *repr = scratch_buffers_alloc(); GString *out = scratch_buffers_alloc(); diff --git a/lib/filterx/tests/test_object_boolean.c b/lib/filterx/tests/test_object_boolean.c index d4c6e1634f..a45a791dd9 100644 --- a/lib/filterx/tests/test_object_boolean.c +++ b/lib/filterx/tests/test_object_boolean.c @@ -65,7 +65,7 @@ Test(filterx_boolean, test_filterx_boolean_typecast_null_args) { GPtrArray *args = NULL; - FilterXObject *obj = filterx_typecast_boolean(args); + FilterXObject *obj = filterx_typecast_boolean(NULL, args); cr_assert_null(obj); } @@ -73,7 +73,7 @@ Test(filterx_boolean, test_filterx_boolean_typecast_empty_args) { GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); - FilterXObject *obj = filterx_typecast_boolean(args); + FilterXObject *obj = filterx_typecast_boolean(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -85,7 +85,7 @@ Test(filterx_boolean, test_filterx_boolean_typecast_null_arg) g_ptr_array_add(args, NULL); - FilterXObject *obj = filterx_typecast_boolean(args); + FilterXObject *obj = filterx_typecast_boolean(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -97,7 +97,7 @@ Test(filterx_boolean, test_filterx_boolean_typecast_null_object_arg) FilterXObject *in = filterx_null_new(); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_boolean(args); + FilterXObject *obj = filterx_typecast_boolean(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(boolean))); @@ -113,7 +113,7 @@ Test(filterx_boolean, test_filterx_boolean_typecast_from_boolean) FilterXObject *in = filterx_boolean_new(TRUE); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_boolean(args); + FilterXObject *obj = filterx_typecast_boolean(NULL, args); cr_assert_eq(in, obj); g_ptr_array_free(args, TRUE); diff --git a/lib/filterx/tests/test_object_bytes.c b/lib/filterx/tests/test_object_bytes.c index 040d0484e6..c3cd591587 100644 --- a/lib/filterx/tests/test_object_bytes.c +++ b/lib/filterx/tests/test_object_bytes.c @@ -31,7 +31,7 @@ Test(filterx_bytes, test_filterx_bytes_typecast_null_args) { GPtrArray *args = NULL; - FilterXObject *obj = filterx_typecast_bytes(args); + FilterXObject *obj = filterx_typecast_bytes(NULL, args); cr_assert_null(obj); } @@ -39,7 +39,7 @@ Test(filterx_bytes, test_filterx_bytes_typecast_empty_args) { GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); - FilterXObject *obj = filterx_typecast_bytes(args); + FilterXObject *obj = filterx_typecast_bytes(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -51,7 +51,7 @@ Test(filterx_bytes, test_filterx_bytes_typecast_null_arg) g_ptr_array_add(args, NULL); - FilterXObject *obj = filterx_typecast_bytes(args); + FilterXObject *obj = filterx_typecast_bytes(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -63,7 +63,7 @@ Test(filterx_bytes, test_filterx_bytes_typecast_null_object_arg) FilterXObject *in = filterx_null_new(); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_bytes(args); + FilterXObject *obj = filterx_typecast_bytes(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -76,7 +76,7 @@ Test(filterx_bytes, test_filterx_bytes_typecast_from_bytes) FilterXObject *in = filterx_bytes_new("byte \0sequence", 14); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_bytes(args); + FilterXObject *obj = filterx_typecast_bytes(NULL, args); cr_assert_eq(in, obj); @@ -90,7 +90,7 @@ Test(filterx_bytes, test_filterx_bytes_typecast_from_string) FilterXObject *in = filterx_string_new("string whatever", -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_bytes(args); + FilterXObject *obj = filterx_typecast_bytes(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(bytes))); @@ -109,7 +109,7 @@ Test(filterx_bytes, test_filterx_bytes_typecast_from_protobuf) FilterXObject *in = filterx_protobuf_new("not a valid \0protobuf!", 22); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_bytes(args); + FilterXObject *obj = filterx_typecast_bytes(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(bytes))); diff --git a/lib/filterx/tests/test_object_datetime.c b/lib/filterx/tests/test_object_datetime.c index c5f58fb62b..1d93493033 100644 --- a/lib/filterx/tests/test_object_datetime.c +++ b/lib/filterx/tests/test_object_datetime.c @@ -57,7 +57,7 @@ Test(filterx_datetime, test_filterx_datetime_typecast_null_args) { GPtrArray *args = NULL; - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_null(obj); } @@ -65,7 +65,7 @@ Test(filterx_datetime, test_filterx_datetime_typecast_empty_args) { GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -76,7 +76,7 @@ Test(filterx_datetime, test_filterx_datetime_typecast_null_arg) GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); g_ptr_array_add(args, NULL); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -88,7 +88,7 @@ Test(filterx_datetime, test_filterx_datetime_typecast_null_object_arg) FilterXObject *in = filterx_null_new(); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -101,7 +101,7 @@ Test(filterx_datetime, test_filterx_datetime_typecast_from_int) FilterXObject *in = filterx_integer_new(1710762325395194); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(datetime))); @@ -121,7 +121,7 @@ Test(filterx_datetime, test_filterx_datetime_typecast_from_double) FilterXObject *in = filterx_double_new(1710762325.395194); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(datetime))); @@ -141,7 +141,7 @@ Test(filterx_datetime, test_filterx_datetime_typecast_from_string) FilterXObject *in = filterx_string_new("2024-03-18T12:34:00Z", -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(datetime))); @@ -162,7 +162,7 @@ Test(filterx_datetime, test_filterx_datetime_typecast_from_datetime) FilterXObject *in = filterx_datetime_new(&ut); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_eq(in, obj); @@ -176,7 +176,7 @@ Test(filterx_datetime, test_filterx_datetime_repr) FilterXObject *in = filterx_string_new("2024-03-18T12:34:13+0900", -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(datetime))); @@ -198,7 +198,7 @@ Test(filterx_datetime, test_filterx_datetime_repr_isodate_Z) FilterXObject *in = filterx_string_new(test_time_str, -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_datetime(args); + FilterXObject *obj = filterx_typecast_datetime(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(datetime))); diff --git a/lib/filterx/tests/test_object_double.c b/lib/filterx/tests/test_object_double.c index 8abdcdae37..64f9f01cec 100644 --- a/lib/filterx/tests/test_object_double.c +++ b/lib/filterx/tests/test_object_double.c @@ -61,7 +61,7 @@ Test(filterx_double, test_filterx_double_typecast_null_args) { GPtrArray *args = NULL; - FilterXObject *obj = filterx_typecast_double(args); + FilterXObject *obj = filterx_typecast_double(NULL, args); cr_assert_null(obj); } @@ -69,7 +69,7 @@ Test(filterx_double, test_filterx_double_typecast_empty_args) { GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); - FilterXObject *obj = filterx_typecast_double(args); + FilterXObject *obj = filterx_typecast_double(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -81,7 +81,7 @@ Test(filterx_double, test_filterx_double_typecast_null_arg) g_ptr_array_add(args, NULL); - FilterXObject *obj = filterx_typecast_double(args); + FilterXObject *obj = filterx_typecast_double(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -93,7 +93,7 @@ Test(filterx_double, test_filterx_double_typecast_null_object_arg) FilterXObject *in = filterx_null_new(); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_double(args); + FilterXObject *obj = filterx_typecast_double(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -106,7 +106,7 @@ Test(filterx_double, test_filterx_double_typecast_from_double) FilterXObject *in = filterx_double_new(3.14); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_double(args); + FilterXObject *obj = filterx_typecast_double(NULL, args); cr_assert_eq(in, obj); g_ptr_array_free(args, TRUE); @@ -119,7 +119,7 @@ Test(filterx_double, test_filterx_double_typecast_from_integer) FilterXObject *in = filterx_integer_new(443); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_double(args); + FilterXObject *obj = filterx_typecast_double(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(double))); @@ -137,7 +137,7 @@ Test(filterx_double, test_filterx_double_typecast_from_string) FilterXObject *in = filterx_string_new("443.117", -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_double(args); + FilterXObject *obj = filterx_typecast_double(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(double))); diff --git a/lib/filterx/tests/test_object_integer.c b/lib/filterx/tests/test_object_integer.c index 67798ef5b9..d4988640f6 100644 --- a/lib/filterx/tests/test_object_integer.c +++ b/lib/filterx/tests/test_object_integer.c @@ -63,7 +63,7 @@ Test(filterx_integer, test_filterx_integer_typecast_null_args) { GPtrArray *args = NULL; - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_null(obj); } @@ -71,7 +71,7 @@ Test(filterx_integer, test_filterx_integer_typecast_empty_args) { GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -83,7 +83,7 @@ Test(filterx_integer, test_filterx_integer_typecast_null_arg) g_ptr_array_add(args, NULL); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -96,7 +96,7 @@ Test(filterx_integer, test_filterx_integer_typecast_null_object_arg) FilterXObject *in = filterx_null_new(); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -108,7 +108,7 @@ Test(filterx_integer, test_filterx_integer_typecast_from_integer) FilterXObject *in = filterx_integer_new(443); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_eq(in, obj); g_ptr_array_free(args, TRUE); @@ -121,7 +121,7 @@ Test(filterx_integer, test_filterx_integer_typecast_from_double) FilterXObject *in = filterx_double_new(171.443); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(integer))); @@ -141,7 +141,7 @@ Test(filterx_integer, test_filterx_integer_typecast_from_double_roundup) FilterXObject *in = filterx_double_new(171.743); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(integer))); @@ -159,7 +159,7 @@ Test(filterx_integer, test_filterx_integer_typecast_from_string) FilterXObject *in = filterx_string_new("443", -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(integer))); @@ -177,7 +177,7 @@ Test(filterx_integer, test_filterx_integer_typecast_from_string_very_very_zero) FilterXObject *in = filterx_string_new("000", -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(integer))); @@ -195,7 +195,7 @@ Test(filterx_integer, test_filterx_integer_typecast_from_double_string) FilterXObject *in = filterx_string_new("443.117", -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_integer(args); + FilterXObject *obj = filterx_typecast_integer(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); diff --git a/lib/filterx/tests/test_object_json.c b/lib/filterx/tests/test_object_json.c index cbe76d7520..0e01d8a345 100644 --- a/lib/filterx/tests/test_object_json.c +++ b/lib/filterx/tests/test_object_json.c @@ -69,11 +69,11 @@ static FilterXObject * _exec_func(FilterXSimpleFunctionProto func, FilterXObject *arg) { if (!arg) - return func(NULL); + return func(NULL, NULL); GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); g_ptr_array_add(args, arg); - FilterXObject *result = func(args); + FilterXObject *result = func(NULL, args); g_ptr_array_unref(args); return result; } diff --git a/lib/filterx/tests/test_object_protobuf.c b/lib/filterx/tests/test_object_protobuf.c index 9f64e7c79b..cdda4be00c 100644 --- a/lib/filterx/tests/test_object_protobuf.c +++ b/lib/filterx/tests/test_object_protobuf.c @@ -31,7 +31,7 @@ Test(filterx_protobuf, test_filterx_protobuf_typecast_null_args) { GPtrArray *args = NULL; - FilterXObject *obj = filterx_typecast_protobuf(args); + FilterXObject *obj = filterx_typecast_protobuf(NULL, args); cr_assert_null(obj); } @@ -39,7 +39,7 @@ Test(filterx_protobuf, test_filterx_protobuf_typecast_empty_args) { GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); - FilterXObject *obj = filterx_typecast_protobuf(args); + FilterXObject *obj = filterx_typecast_protobuf(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -51,7 +51,7 @@ Test(filterx_protobuf, test_filterx_protobuf_typecast_null_arg) g_ptr_array_add(args, NULL); - FilterXObject *obj = filterx_typecast_protobuf(args); + FilterXObject *obj = filterx_typecast_protobuf(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -63,7 +63,7 @@ Test(filterx_protobuf, test_filterx_protobuf_typecast_null_object_arg) FilterXObject *in = filterx_null_new(); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_protobuf(args); + FilterXObject *obj = filterx_typecast_protobuf(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -75,7 +75,7 @@ Test(filterx_protobuf, test_filterx_protobuf_typecast_from_bytes) FilterXObject *in = filterx_bytes_new("not valid \0protobuf!", 20); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_protobuf(args); + FilterXObject *obj = filterx_typecast_protobuf(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(protobuf))); @@ -94,7 +94,7 @@ Test(filterx_protobuf, test_filterx_protobuf_typecast_from_protobuf) FilterXObject *in = filterx_protobuf_new("not valid \0protobuf!", 20); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_protobuf(args); + FilterXObject *obj = filterx_typecast_protobuf(NULL, args); cr_assert_eq(in, obj); g_ptr_array_free(args, TRUE); diff --git a/lib/filterx/tests/test_object_string.c b/lib/filterx/tests/test_object_string.c index a552e7a224..cfaef89ff8 100644 --- a/lib/filterx/tests/test_object_string.c +++ b/lib/filterx/tests/test_object_string.c @@ -47,7 +47,7 @@ Test(filterx_string, test_filterx_string_typecast_null_args) { GPtrArray *args = NULL; - FilterXObject *obj = filterx_typecast_string(args); + FilterXObject *obj = filterx_typecast_string(NULL, args); cr_assert_null(obj); } @@ -55,7 +55,7 @@ Test(filterx_string, test_filterx_string_typecast_empty_args) { GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); - FilterXObject *obj = filterx_typecast_string(args); + FilterXObject *obj = filterx_typecast_string(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -67,7 +67,7 @@ Test(filterx_string, test_filterx_string_typecast_null_arg) g_ptr_array_add(args, NULL); - FilterXObject *obj = filterx_typecast_string(args); + FilterXObject *obj = filterx_typecast_string(NULL, args); cr_assert_null(obj); g_ptr_array_free(args, TRUE); @@ -79,7 +79,7 @@ Test(filterx_string, test_filterx_string_typecast_null_object_arg) FilterXObject *in = filterx_null_new(); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_string(args); + FilterXObject *obj = filterx_typecast_string(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(string))); @@ -98,7 +98,7 @@ Test(filterx_string, test_filterx_string_typecast_from_string) FilterXObject *in = filterx_string_new("foobar", -1); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_string(args); + FilterXObject *obj = filterx_typecast_string(NULL, args); cr_assert_eq(in, obj); @@ -112,7 +112,7 @@ Test(filterx_string, test_filterx_string_typecast_from_bytes) FilterXObject *in = filterx_bytes_new("\x00\x1f byte \\sequence \x7f \xff", 21); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_string(args); + FilterXObject *obj = filterx_typecast_string(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(string))); @@ -131,7 +131,7 @@ Test(filterx_string, test_filterx_string_typecast_from_protobuf) FilterXObject *in = filterx_protobuf_new("\xffnot a valid protobuf! \xd9", 23); g_ptr_array_add(args, in); - FilterXObject *obj = filterx_typecast_string(args); + FilterXObject *obj = filterx_typecast_string(NULL, args); cr_assert_not_null(obj); cr_assert(filterx_object_is_type(obj, &FILTERX_TYPE_NAME(string))); diff --git a/modules/grpc/otel/filterx/object-otel-array.cpp b/modules/grpc/otel/filterx/object-otel-array.cpp index cdb77fa254..765c3e0615 100644 --- a/modules/grpc/otel/filterx/object-otel-array.cpp +++ b/modules/grpc/otel/filterx/object-otel-array.cpp @@ -244,7 +244,7 @@ _filterx_otel_array_clone(FilterXObject *s) } FilterXObject * -filterx_otel_array_new_from_args(GPtrArray *args) +filterx_otel_array_new_from_args(FilterXExpr *s, GPtrArray *args) { FilterXOtelArray *self = g_new0(FilterXOtelArray, 1); _init_instance(self); diff --git a/modules/grpc/otel/filterx/object-otel-kvlist.cpp b/modules/grpc/otel/filterx/object-otel-kvlist.cpp index 0349bad721..8dccbf5d34 100644 --- a/modules/grpc/otel/filterx/object-otel-kvlist.cpp +++ b/modules/grpc/otel/filterx/object-otel-kvlist.cpp @@ -343,7 +343,7 @@ _filterx_otel_kvlist_clone(FilterXObject *s) } FilterXObject * -filterx_otel_kvlist_new_from_args(GPtrArray *args) +filterx_otel_kvlist_new_from_args(FilterXExpr *s, GPtrArray *args) { FilterXOtelKVList *self = g_new0(FilterXOtelKVList, 1); _init_instance(self); diff --git a/modules/grpc/otel/filterx/object-otel-logrecord.cpp b/modules/grpc/otel/filterx/object-otel-logrecord.cpp index 0e45fd99f5..fa40e948a0 100644 --- a/modules/grpc/otel/filterx/object-otel-logrecord.cpp +++ b/modules/grpc/otel/filterx/object-otel-logrecord.cpp @@ -277,7 +277,7 @@ _filterx_otel_logrecord_clone(FilterXObject *s) } FilterXObject * -filterx_otel_logrecord_new_from_args(GPtrArray *args) +filterx_otel_logrecord_new_from_args(FilterXExpr *s, GPtrArray *args) { FilterXOtelLogRecord *self = g_new0(FilterXOtelLogRecord, 1); _init_instance(self); diff --git a/modules/grpc/otel/filterx/object-otel-resource.cpp b/modules/grpc/otel/filterx/object-otel-resource.cpp index 599587bdaf..3e410067b9 100644 --- a/modules/grpc/otel/filterx/object-otel-resource.cpp +++ b/modules/grpc/otel/filterx/object-otel-resource.cpp @@ -263,7 +263,7 @@ _filterx_otel_resource_clone(FilterXObject *s) } FilterXObject * -filterx_otel_resource_new_from_args(GPtrArray *args) +filterx_otel_resource_new_from_args(FilterXExpr *s, GPtrArray *args) { FilterXOtelResource *self = g_new0(FilterXOtelResource, 1); _init_instance(self); diff --git a/modules/grpc/otel/filterx/object-otel-scope.cpp b/modules/grpc/otel/filterx/object-otel-scope.cpp index cebf2ea7bb..c7ca42cfb8 100644 --- a/modules/grpc/otel/filterx/object-otel-scope.cpp +++ b/modules/grpc/otel/filterx/object-otel-scope.cpp @@ -263,7 +263,7 @@ _filterx_otel_scope_clone(FilterXObject *s) } FilterXObject * -filterx_otel_scope_new_from_args(GPtrArray *args) +filterx_otel_scope_new_from_args(FilterXExpr *s, GPtrArray *args) { FilterXOtelScope *self = g_new0(FilterXOtelScope, 1); _init_instance(self); diff --git a/modules/grpc/otel/filterx/object-otel.h b/modules/grpc/otel/filterx/object-otel.h index 5cdad0e509..313787410b 100644 --- a/modules/grpc/otel/filterx/object-otel.h +++ b/modules/grpc/otel/filterx/object-otel.h @@ -35,40 +35,41 @@ FILTERX_SIMPLE_FUNCTION_DECLARE(otel_scope); FILTERX_SIMPLE_FUNCTION_DECLARE(otel_kvlist); FILTERX_SIMPLE_FUNCTION_DECLARE(otel_array); -FilterXObject *filterx_otel_logrecord_new_from_args(GPtrArray *args); -FilterXObject *filterx_otel_resource_new_from_args(GPtrArray *args); -FilterXObject *filterx_otel_scope_new_from_args(GPtrArray *args); -FilterXObject *filterx_otel_kvlist_new_from_args(GPtrArray *args); -FilterXObject *filterx_otel_array_new_from_args(GPtrArray *args); + +FilterXObject *filterx_otel_logrecord_new_from_args(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_otel_resource_new_from_args(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_otel_scope_new_from_args(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_otel_kvlist_new_from_args(FilterXExpr *s, GPtrArray *args); +FilterXObject *filterx_otel_array_new_from_args(FilterXExpr *s, GPtrArray *args); static inline FilterXObject * filterx_otel_logrecord_new(void) { - return filterx_otel_logrecord_new_from_args(NULL); + return filterx_otel_logrecord_new_from_args(NULL, NULL); } static inline FilterXObject * filterx_otel_resource_new(void) { - return filterx_otel_resource_new_from_args(NULL); + return filterx_otel_resource_new_from_args(NULL, NULL); } static inline FilterXObject * filterx_otel_scope_new(void) { - return filterx_otel_scope_new_from_args(NULL); + return filterx_otel_scope_new_from_args(NULL, NULL); } static inline FilterXObject * filterx_otel_kvlist_new(void) { - return filterx_otel_kvlist_new_from_args(NULL); + return filterx_otel_kvlist_new_from_args(NULL, NULL); } static inline FilterXObject * filterx_otel_array_new(void) { - return filterx_otel_array_new_from_args(NULL); + return filterx_otel_array_new_from_args(NULL, NULL); } gpointer grpc_otel_filterx_enum_construct(Plugin *self); diff --git a/modules/grpc/otel/tests/test-otel-filterx.cpp b/modules/grpc/otel/tests/test-otel-filterx.cpp index db92199ddc..e033fba761 100644 --- a/modules/grpc/otel/tests/test-otel-filterx.cpp +++ b/modules/grpc/otel/tests/test-otel-filterx.cpp @@ -173,7 +173,7 @@ Test(otel_filterx, logrecord_from_protobuf) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_log_record.c_str(), serialized_log_record.length())); - FilterXOtelLogRecord *filterx_otel_logrecord = (FilterXOtelLogRecord *) filterx_otel_logrecord_new_from_args(args); + FilterXOtelLogRecord *filterx_otel_logrecord = (FilterXOtelLogRecord *) filterx_otel_logrecord_new_from_args(NULL, args); cr_assert(filterx_otel_logrecord); const LogRecord &log_record_from_filterx = filterx_otel_logrecord->cpp->get_value(); @@ -188,7 +188,7 @@ Test(otel_filterx, logrecord_from_protobuf_invalid_arg) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_string_new("", 0)); - FilterXOtelLogRecord *filterx_otel_logrecord = (FilterXOtelLogRecord *) filterx_otel_logrecord_new_from_args(args); + FilterXOtelLogRecord *filterx_otel_logrecord = (FilterXOtelLogRecord *) filterx_otel_logrecord_new_from_args(NULL, args); cr_assert_not(filterx_otel_logrecord); g_ptr_array_free(args, TRUE); @@ -199,7 +199,7 @@ Test(otel_filterx, logrecord_from_protobuf_malformed_data) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new("1234", 4)); - FilterXOtelLogRecord *filterx_otel_logrecord = (FilterXOtelLogRecord *) filterx_otel_logrecord_new_from_args(args); + FilterXOtelLogRecord *filterx_otel_logrecord = (FilterXOtelLogRecord *) filterx_otel_logrecord_new_from_args(NULL, args); cr_assert_not(filterx_otel_logrecord); g_ptr_array_free(args, TRUE); @@ -211,7 +211,7 @@ Test(otel_filterx, logrecord_too_many_args) g_ptr_array_insert(args, 0, filterx_string_new("foo", 3)); g_ptr_array_insert(args, 1, filterx_protobuf_new("bar", 3)); - FilterXOtelLogRecord *filterx_otel_logrecord = (FilterXOtelLogRecord *) filterx_otel_logrecord_new_from_args(args); + FilterXOtelLogRecord *filterx_otel_logrecord = (FilterXOtelLogRecord *) filterx_otel_logrecord_new_from_args(NULL, args); cr_assert_not(filterx_otel_logrecord); g_ptr_array_free(args, TRUE); @@ -322,7 +322,7 @@ Test(otel_filterx, resource_from_protobuf) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_resource.c_str(), serialized_resource.length())); - FilterXOtelResource *filterx_otel_resource = (FilterXOtelResource *) filterx_otel_resource_new_from_args(args); + FilterXOtelResource *filterx_otel_resource = (FilterXOtelResource *) filterx_otel_resource_new_from_args(NULL, args); cr_assert(filterx_otel_resource); const opentelemetry::proto::resource::v1::Resource &resource_from_filterx = filterx_otel_resource->cpp->get_value(); @@ -337,7 +337,7 @@ Test(otel_filterx, resource_from_protobuf_invalid_arg) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_string_new("", 0)); - FilterXOtelResource *filterx_otel_resource = (FilterXOtelResource *) filterx_otel_resource_new_from_args(args); + FilterXOtelResource *filterx_otel_resource = (FilterXOtelResource *) filterx_otel_resource_new_from_args(NULL, args); cr_assert_not(filterx_otel_resource); g_ptr_array_free(args, TRUE); @@ -348,7 +348,7 @@ Test(otel_filterx, resource_from_protobuf_malformed_data) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new("1234", 4)); - FilterXOtelResource *filterx_otel_resource = (FilterXOtelResource *) filterx_otel_resource_new_from_args(args); + FilterXOtelResource *filterx_otel_resource = (FilterXOtelResource *) filterx_otel_resource_new_from_args(NULL, args); cr_assert_not(filterx_otel_resource); g_ptr_array_free(args, TRUE); @@ -360,7 +360,7 @@ Test(otel_filterx, resource_too_many_args) g_ptr_array_insert(args, 0, filterx_string_new("foo", 3)); g_ptr_array_insert(args, 1, filterx_protobuf_new("bar", 3)); - FilterXOtelResource *filterx_otel_resource = (FilterXOtelResource *) filterx_otel_resource_new_from_args(args); + FilterXOtelResource *filterx_otel_resource = (FilterXOtelResource *) filterx_otel_resource_new_from_args(NULL, args); cr_assert_not(filterx_otel_resource); g_ptr_array_free(args, TRUE); @@ -378,7 +378,7 @@ Test(otel_filterx, resource_get_field) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_resource.c_str(), serialized_resource.length())); - FilterXObject *filterx_otel_resource = (FilterXObject *) filterx_otel_resource_new_from_args(args); + FilterXObject *filterx_otel_resource = (FilterXObject *) filterx_otel_resource_new_from_args(NULL, args); cr_assert(filterx_otel_resource); _assert_filterx_integer_attribute(filterx_otel_resource, "dropped_attributes_count", 42); @@ -407,7 +407,7 @@ Test(otel_filterx, resource_set_field) GPtrArray *attributes_kvlist_args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(attributes_kvlist_args, 0, filterx_protobuf_new(serialized_attributes.c_str(), serialized_attributes.length())); - FilterXObject *filterx_kvlist = filterx_otel_kvlist_new_from_args(attributes_kvlist_args); + FilterXObject *filterx_kvlist = filterx_otel_kvlist_new_from_args(NULL, attributes_kvlist_args); cr_assert(filterx_object_setattr_string(filterx_otel_resource, "attributes", &filterx_kvlist)); cr_assert_not(filterx_object_setattr_string(filterx_otel_resource, "invalid_attr", &filterx_integer)); @@ -479,7 +479,7 @@ Test(otel_filterx, resource_iter) Test(otel_filterx, scope_empty) { - FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(NULL); + FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new(); cr_assert(filterx_otel_scope); cr_assert(MessageDifferencer::Equals(opentelemetry::proto::common::v1::InstrumentationScope(), @@ -502,7 +502,7 @@ Test(otel_filterx, scope_from_protobuf) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_scope.c_str(), serialized_scope.length())); - FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(args); + FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(NULL, args); cr_assert(filterx_otel_scope); const opentelemetry::proto::common::v1::InstrumentationScope &scope_from_filterx = filterx_otel_scope->cpp->get_value(); @@ -517,7 +517,7 @@ Test(otel_filterx, scope_from_protobuf_invalid_arg) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_string_new("", 0)); - FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(args); + FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(NULL, args); cr_assert_not(filterx_otel_scope); g_ptr_array_free(args, TRUE); @@ -528,7 +528,7 @@ Test(otel_filterx, scope_from_protobuf_malformed_data) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new("1234", 4)); - FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(args); + FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(NULL, args); cr_assert_not(filterx_otel_scope); g_ptr_array_free(args, TRUE); @@ -540,7 +540,7 @@ Test(otel_filterx, scope_too_many_args) g_ptr_array_insert(args, 0, filterx_string_new("foo", 3)); g_ptr_array_insert(args, 1, filterx_protobuf_new("bar", 3)); - FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(args); + FilterXOtelScope *filterx_otel_scope = (FilterXOtelScope *) filterx_otel_scope_new_from_args(NULL, args); cr_assert_not(filterx_otel_scope); g_ptr_array_free(args, TRUE); @@ -559,7 +559,7 @@ Test(otel_filterx, scope_get_field) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_scope.c_str(), serialized_scope.length())); - FilterXObject *filterx_otel_scope = (FilterXObject *) filterx_otel_scope_new_from_args(args); + FilterXObject *filterx_otel_scope = (FilterXObject *) filterx_otel_scope_new_from_args(NULL, args); cr_assert(filterx_otel_scope); _assert_filterx_integer_attribute(filterx_otel_scope, "dropped_attributes_count", 42); @@ -592,7 +592,7 @@ Test(otel_filterx, scope_set_field) GPtrArray *attributes_kvlist_args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(attributes_kvlist_args, 0, filterx_protobuf_new(serialized_attributes.c_str(), serialized_attributes.length())); - FilterXObject *filterx_kvlist = filterx_otel_kvlist_new_from_args(attributes_kvlist_args); + FilterXObject *filterx_kvlist = filterx_otel_kvlist_new_from_args(NULL, attributes_kvlist_args); cr_assert(filterx_object_setattr_string(filterx_otel_scope, "attributes", &filterx_kvlist)); cr_assert_not(filterx_object_setattr_string(filterx_otel_scope, "invalid_attr", &filterx_integer)); @@ -643,7 +643,7 @@ Test(otel_filterx, kvlist_from_protobuf) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_kvlist.c_str(), serialized_kvlist.length())); - FilterXOtelKVList *filterx_otel_kvlist = (FilterXOtelKVList *) filterx_otel_kvlist_new_from_args(args); + FilterXOtelKVList *filterx_otel_kvlist = (FilterXOtelKVList *) filterx_otel_kvlist_new_from_args(NULL, args); cr_assert(filterx_otel_kvlist); _assert_repeated_kvs(filterx_otel_kvlist->cpp->get_value(), kvlist.values()); @@ -657,7 +657,7 @@ Test(otel_filterx, kvlist_from_protobuf_invalid_arg) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_string_new("", 0)); - FilterXOtelKVList *filterx_otel_kvlist = (FilterXOtelKVList *) filterx_otel_kvlist_new_from_args(args); + FilterXOtelKVList *filterx_otel_kvlist = (FilterXOtelKVList *) filterx_otel_kvlist_new_from_args(NULL, args); cr_assert_not(filterx_otel_kvlist); g_ptr_array_free(args, TRUE); @@ -668,7 +668,7 @@ Test(otel_filterx, kvlist_from_protobuf_malformed_data) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new("1234", 4)); - FilterXOtelKVList *filterx_otel_kvlist = (FilterXOtelKVList *) filterx_otel_kvlist_new_from_args(args); + FilterXOtelKVList *filterx_otel_kvlist = (FilterXOtelKVList *) filterx_otel_kvlist_new_from_args(NULL, args); cr_assert_not(filterx_otel_kvlist); g_ptr_array_free(args, TRUE); @@ -680,7 +680,7 @@ Test(otel_filterx, kvlist_too_many_args) g_ptr_array_insert(args, 0, filterx_string_new("foo", 3)); g_ptr_array_insert(args, 1, filterx_protobuf_new("bar", 3)); - FilterXOtelKVList *filterx_otel_kvlist = (FilterXOtelKVList *) filterx_otel_kvlist_new_from_args(args); + FilterXOtelKVList *filterx_otel_kvlist = (FilterXOtelKVList *) filterx_otel_kvlist_new_from_args(NULL, args); cr_assert_not(filterx_otel_kvlist); g_ptr_array_free(args, TRUE); @@ -711,7 +711,7 @@ Test(otel_filterx, kvlist_get_subscript) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_kvlist.c_str(), serialized_kvlist.length())); - FilterXObject *filterx_otel_kvlist = (FilterXObject *) filterx_otel_kvlist_new_from_args(args); + FilterXObject *filterx_otel_kvlist = (FilterXObject *) filterx_otel_kvlist_new_from_args(NULL, args); cr_assert(filterx_otel_kvlist); FilterXObject *element_1_key = filterx_string_new("element_1_key", -1); @@ -972,7 +972,7 @@ Test(otel_filterx, array_from_protobuf) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_array.c_str(), serialized_array.length())); - FilterXOtelArray *filterx_otel_array = (FilterXOtelArray *) filterx_otel_array_new_from_args(args); + FilterXOtelArray *filterx_otel_array = (FilterXOtelArray *) filterx_otel_array_new_from_args(NULL, args); cr_assert(filterx_otel_array); const opentelemetry::proto::common::v1::ArrayValue &array_from_filterx = filterx_otel_array->cpp->get_value(); @@ -987,7 +987,7 @@ Test(otel_filterx, array_from_protobuf_invalid_arg) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_string_new("", 0)); - FilterXOtelArray *filterx_otel_array = (FilterXOtelArray *) filterx_otel_array_new_from_args(args); + FilterXOtelArray *filterx_otel_array = (FilterXOtelArray *) filterx_otel_array_new_from_args(NULL, args); cr_assert_not(filterx_otel_array); g_ptr_array_free(args, TRUE); @@ -998,7 +998,7 @@ Test(otel_filterx, array_from_protobuf_malformed_data) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new("1234", 4)); - FilterXOtelArray *filterx_otel_array = (FilterXOtelArray *) filterx_otel_array_new_from_args(args); + FilterXOtelArray *filterx_otel_array = (FilterXOtelArray *) filterx_otel_array_new_from_args(NULL, args); cr_assert_not(filterx_otel_array); g_ptr_array_free(args, TRUE); @@ -1010,7 +1010,7 @@ Test(otel_filterx, array_too_many_args) g_ptr_array_insert(args, 0, filterx_string_new("foo", 3)); g_ptr_array_insert(args, 1, filterx_protobuf_new("bar", 3)); - FilterXOtelArray *filterx_otel_array = (FilterXOtelArray *) filterx_otel_array_new_from_args(args); + FilterXOtelArray *filterx_otel_array = (FilterXOtelArray *) filterx_otel_array_new_from_args(NULL, args); cr_assert_not(filterx_otel_array); g_ptr_array_free(args, TRUE); @@ -1037,7 +1037,7 @@ Test(otel_filterx, array_get_subscript) GPtrArray *args = g_ptr_array_new_full(1, (GDestroyNotify) filterx_object_unref); g_ptr_array_insert(args, 0, filterx_protobuf_new(serialized_array.c_str(), serialized_array.length())); - FilterXObject *filterx_otel_array = (FilterXObject *) filterx_otel_array_new_from_args(args); + FilterXObject *filterx_otel_array = (FilterXObject *) filterx_otel_array_new_from_args(NULL, args); cr_assert(filterx_otel_array); FilterXObject *element_1_index = filterx_integer_new(0); diff --git a/modules/json/filterx-format-json.c b/modules/json/filterx-format-json.c index 6e6ff0f179..b92e38e743 100644 --- a/modules/json/filterx-format-json.c +++ b/modules/json/filterx-format-json.c @@ -316,7 +316,7 @@ _format_json(FilterXObject *arg) } FilterXObject * -filterx_format_json_new(GPtrArray *args) +filterx_format_json_call(FilterXExpr *s, GPtrArray *args) { if (!args || args->len != 1) { @@ -329,4 +329,4 @@ filterx_format_json_new(GPtrArray *args) return _format_json(arg); } -FILTERX_SIMPLE_FUNCTION(format_json, filterx_format_json_new); +FILTERX_SIMPLE_FUNCTION(format_json, filterx_format_json_call); diff --git a/modules/json/filterx-format-json.h b/modules/json/filterx-format-json.h index f154e078f9..0e495b61c3 100644 --- a/modules/json/filterx-format-json.h +++ b/modules/json/filterx-format-json.h @@ -24,7 +24,7 @@ #include "filterx/filterx-object.h" #include "filterx/expr-function.h" -FilterXObject *filterx_format_json_new(GPtrArray *args); +FilterXObject *filterx_format_json_call(FilterXExpr *s, GPtrArray *args); FILTERX_SIMPLE_FUNCTION_DECLARE(format_json); diff --git a/modules/json/tests/test_filterx_format_json.c b/modules/json/tests/test_filterx_format_json.c index fe105f513b..6bcc56da3b 100644 --- a/modules/json/tests/test_filterx_format_json.c +++ b/modules/json/tests/test_filterx_format_json.c @@ -44,7 +44,7 @@ _exec_format_json_and_unref(FilterXObject *arg) GPtrArray *args = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_object_unref); g_ptr_array_add(args, arg); - FilterXObject *result = filterx_format_json_new(args); + FilterXObject *result = filterx_format_json_call(NULL, args); cr_assert(filterx_object_is_type(result, &FILTERX_TYPE_NAME(string))); g_ptr_array_unref(args);