Kouhei Sutou
null+****@clear*****
Thu Mar 16 10:11:34 JST 2017
Kouhei Sutou 2017-03-16 10:11:34 +0900 (Thu, 16 Mar 2017) New Revision: 60ae506e057629ae943bbb0a42c7ce238f05e454 https://github.com/groonga/groonga/commit/60ae506e057629ae943bbb0a42c7ce238f05e454 Message: Add grn_obj_is_expr() Modified files: include/groonga/obj.h lib/obj.c test/unit/core/test-object.c Modified: include/groonga/obj.h (+1 -0) =================================================================== --- include/groonga/obj.h 2017-03-16 10:11:11 +0900 (d0722d7) +++ include/groonga/obj.h 2017-03-16 10:11:34 +0900 (d00458e) @@ -53,6 +53,7 @@ GRN_API grn_bool grn_obj_is_normalizer_proc(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_token_filter_proc(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_scorer_proc(grn_ctx *ctx, grn_obj *obj); GRN_API grn_bool grn_obj_is_window_function_proc(grn_ctx *ctx, grn_obj *obj); +GRN_API grn_bool grn_obj_is_expr(grn_ctx *ctx, grn_obj *obj); GRN_API grn_rc grn_obj_cast(grn_ctx *ctx, grn_obj *src, Modified: lib/obj.c (+10 -0) =================================================================== --- lib/obj.c 2017-03-16 10:11:11 +0900 (be38286) +++ lib/obj.c 2017-03-16 10:11:34 +0900 (a9ca53d) @@ -367,6 +367,16 @@ grn_obj_is_window_function_proc(grn_ctx *ctx, grn_obj *obj) return proc->type == GRN_PROC_WINDOW_FUNCTION; } +grn_bool +grn_obj_is_expr(grn_ctx *ctx, grn_obj *obj) +{ + if (!obj) { + return GRN_FALSE; + } + + return obj->header.type == GRN_EXPR; +} + static void grn_db_reindex(grn_ctx *ctx, grn_obj *db) { Modified: test/unit/core/test-object.c (+12 -0) =================================================================== --- test/unit/core/test-object.c 2017-03-16 10:11:11 +0900 (c2ee7de) +++ test/unit/core/test-object.c 2017-03-16 10:11:34 +0900 (6c2ead3) @@ -67,6 +67,7 @@ void data_is_scorer_proc(void); void test_is_scorer_proc(gconstpointer data); void data_is_window_function_proc(void); void test_is_window_function_proc(gconstpointer data); +void test_is_expr(void); void data_type_to_string(void); void test_type_to_string(gconstpointer data); void data_name_is_column(void); @@ -861,6 +862,17 @@ test_is_window_function_proc(gconstpointer data) } void +test_is_expr(void) +{ + grn_obj *expr; + + cut_assert_false(grn_obj_is_expr(context, grn_ctx_get(context, "select", -1))); + expr = grn_expr_create(context, NULL, 0); + cut_assert_true(grn_obj_is_expr(context, expr)); + grn_expr_close(ctx, expr); +} + +void data_type_to_string(void) { #define ADD_DATUM(expected, type) \ -------------- next part -------------- HTML����������������������������...Download