| 1 | /* |
| 2 | Copyright (C) 2024 Sutou Kouhei <[email protected]> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #include "grn_applier.h"cxx . . $ `<file>/lib/grn_applier.h`/ |
| 20 | #include "grn_expr.h"cxx . . $ `<file>/lib/grn_expr.h`/ |
| 21 | |
| 22 | grn_objcxx . . $ grn_obj# * |
| 23 | grn_applier_data_get_appliercxx . . $ grn_applier_data_get_applier(a08f760c9bd20156).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_applier_datacxx . . $ grn_applier_data# *data) |
| 24 | { |
| 25 | return data->appliercxx . . $ _grn_applier_data#applier.; |
| 26 | } |
| 27 | |
| 28 | grn_objcxx . . $ grn_obj# * |
| 29 | grn_applier_data_get_tablecxx . . $ grn_applier_data_get_table(a08f760c9bd20156).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_applier_datacxx . . $ grn_applier_data# *data) |
| 30 | { |
| 31 | return data->tablecxx . . $ _grn_applier_data#table.; |
| 32 | } |
| 33 | |
| 34 | grn_objcxx . . $ grn_obj# * |
| 35 | grn_applier_data_get_output_columncxx . . $ grn_applier_data_get_output_column(a08f760c9bd20156).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_applier_datacxx . . $ grn_applier_data# *data) |
| 36 | { |
| 37 | return data->output_columncxx . . $ _grn_applier_data#output_column.; |
| 38 | } |
| 39 | |
| 40 | grn_objcxx . . $ grn_obj# ** |
| 41 | grn_applier_data_get_argscxx . . $ grn_applier_data_get_args(f080cb29cc6f2c0a).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_applier_datacxx . . $ grn_applier_data# *data, size_t *n_args) |
| 42 | { |
| 43 | *n_args = GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&(data->args)); |
| 44 | return (grn_objcxx . . $ grn_obj# **)GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(&(data->args)); |
| 45 | } |
| 46 | |
| 47 | void |
| 48 | grn_applier_data_initcxx . . $ grn_applier_data_init(2bb9ae61a72a957).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 49 | grn_applier_datacxx . . $ grn_applier_data# *data, |
| 50 | grn_objcxx . . $ grn_obj# *table, |
| 51 | grn_objcxx . . $ grn_obj# *output_column) |
| 52 | { |
| 53 | data->tablecxx . . $ _grn_applier_data#table. = table; |
| 54 | data->output_columncxx . . $ _grn_applier_data#output_column. = output_column; |
| 55 | data->appliercxx . . $ _grn_applier_data#applier. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 56 | GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&(data->args), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | grn_applier_data_fincxx . . $ grn_applier_data_fin(6293364e288f7816).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_applier_datacxx . . $ grn_applier_data# *data) |
| 61 | { |
| 62 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(data->args)); |
| 63 | } |
| 64 | |
| 65 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 66 | grn_applier_data_extractcxx . . $ grn_applier_data_extract(9d4b39bd6f38a60a).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_applier_datacxx . . $ grn_applier_data# *data, grn_objcxx . . $ grn_obj# *expr) |
| 67 | { |
| 68 | grn_exprcxx . . $ grn_expr# *e = (grn_exprcxx . . $ grn_expr# *)expr; |
| 69 | grn_expr_codecxx . . $ grn_expr_code# *codes = e->codescxx . . $ _grn_expr#codes.; |
| 70 | uint32_tcxx . . $ uint32_t# codes_curr = e->codes_currcxx . . $ _grn_expr#codes_curr.; |
| 71 | if (codes_curr < 3) { |
| 72 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 73 | } |
| 74 | if (e->codescxx . . $ _grn_expr#codes.[0].opcxx . . $ $anonymous_type_640a68f6a3c9e981_0#op. != GRN_OP_PUSHcxx . . $ GRN_OP_PUSH.) { |
| 75 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 76 | } |
| 77 | if (!grn_obj_is_applier_proccxx . . $ grn_obj_is_applier_proc(a5760e5c319a06ee).(ctx, e->codescxx . . $ _grn_expr#codes.[0].valuecxx . . $ $anonymous_type_640a68f6a3c9e981_0#value.)) { |
| 78 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 79 | } |
| 80 | data->appliercxx . . $ _grn_applier_data#applier. = e->codescxx . . $ _grn_expr#codes.[0].valuecxx . . $ $anonymous_type_640a68f6a3c9e981_0#value.; |
| 81 | for (uint32_tcxx . . $ uint32_t# i = 1; i < e->codes_currcxx . . $ _grn_expr#codes_curr. - 1; i++) { |
| 82 | switch (e->codescxx . . $ _grn_expr#codes.[i].opcxx . . $ $anonymous_type_640a68f6a3c9e981_0#op.) { |
| 83 | case GRN_OP_GET_VALUEcxx . . $ GRN_OP_GET_VALUE.: |
| 84 | case GRN_OP_PUSHcxx . . $ GRN_OP_PUSH.: |
| 85 | if (e->codescxx . . $ _grn_expr#codes.[i].modifycxx . . $ $anonymous_type_640a68f6a3c9e981_0#modify. == 0) { |
| 86 | GRN_PTR_PUTcxx . . $ `include/groonga/groonga.h:3218:9`!(ctx, &(data->args), e->codes[i].value); |
| 87 | } else { |
| 88 | uint32_tcxx . . $ uint32_t# call_i = i + e->codescxx . . $ _grn_expr#codes.[i].modifycxx . . $ $anonymous_type_640a68f6a3c9e981_0#modify.; |
| 89 | if (e->codescxx . . $ _grn_expr#codes.[call_i].opcxx . . $ $anonymous_type_640a68f6a3c9e981_0#op. != GRN_OP_CALLcxx . . $ GRN_OP_CALL.) { |
| 90 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 91 | } |
| 92 | if (!grn_obj_is_function_proccxx . . $ grn_obj_is_function_proc(a5760e5c319a06ee).(ctx, e->codescxx . . $ _grn_expr#codes.[i].valuecxx . . $ $anonymous_type_640a68f6a3c9e981_0#value.)) { |
| 93 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 94 | } |
| 95 | /* Literal arguments are only supported for now. Nested |
| 96 | * function call isn't supported yet. */ |
| 97 | for (uint32_tcxx . . $ uint32_t# j = i + 1; j < call_i; j++) { |
| 98 | if (e->codescxx . . $ _grn_expr#codes.[j].opcxx . . $ $anonymous_type_640a68f6a3c9e981_0#op. != GRN_OP_PUSHcxx . . $ GRN_OP_PUSH.) { |
| 99 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 100 | } |
| 101 | grn_objcxx . . $ grn_obj# *arg = e->codescxx . . $ _grn_expr#codes.[j].valuecxx . . $ $anonymous_type_640a68f6a3c9e981_0#value.; |
| 102 | if (!arg) { |
| 103 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 104 | } |
| 105 | switch (arg->headercxx . . $ _grn_obj#header..typecxx . . $ _grn_obj_header#type.) { |
| 106 | case GRN_BULKcxx . . $ `include/groonga/groonga.h:868:9`!: |
| 107 | case GRN_VECTORcxx . . $ `include/groonga/groonga.h:877:9`!: |
| 108 | case GRN_UVECTORcxx . . $ `include/groonga/groonga.h:875:9`!: |
| 109 | case GRN_PVECTORcxx . . $ `include/groonga/groonga.h:876:9`!: |
| 110 | /* supported */ |
| 111 | break; |
| 112 | default: |
| 113 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 114 | } |
| 115 | } |
| 116 | e->codescxx . . $ _grn_expr#codes. += i; |
| 117 | e->codes_currcxx . . $ _grn_expr#codes_curr. = call_i - i + 1; |
| 118 | grn_expr_executorcxx . . $ grn_expr_executor# executor; |
| 119 | grn_expr_executor_initcxx . . $ grn_expr_executor_init(16b7e5d9c819f729).(ctx, &executor, expr); |
| 120 | grn_objcxx . . $ grn_obj# *arg = grn_expr_executor_execcxx . . $ grn_expr_executor_exec(16f9569af33219a9).(ctx, &executor, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 121 | GRN_PTR_PUTcxx . . $ `include/groonga/groonga.h:3218:9`!(ctx, &(data->args), arg); |
| 122 | grn_expr_executor_fincxx . . $ grn_expr_executor_fin(55b9315442a275ec).(ctx, &executor); |
| 123 | e->codescxx . . $ _grn_expr#codes. = codes; |
| 124 | e->codes_currcxx . . $ _grn_expr#codes_curr. = codes_curr; |
| 125 | i += e->codescxx . . $ _grn_expr#codes.[i].modifycxx . . $ $anonymous_type_640a68f6a3c9e981_0#modify.; |
| 126 | } |
| 127 | break; |
| 128 | default: |
| 129 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 130 | } |
| 131 | } |
| 132 | if (e->codescxx . . $ _grn_expr#codes.[e->codes_currcxx . . $ _grn_expr#codes_curr. - 1].opcxx . . $ $anonymous_type_640a68f6a3c9e981_0#op. != GRN_OP_CALLcxx . . $ GRN_OP_CALL.) { |
| 133 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 134 | } |
| 135 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 136 | } |
| 137 | |
| 138 | grn_rccxx . . $ grn_rc# |
| 139 | grn_applier_data_runcxx . . $ grn_applier_data_run(6580e31ad1f8e719).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_applier_datacxx . . $ grn_applier_data# *data) |
| 140 | { |
| 141 | grn_proccxx . . $ grn_proc# *proc = (grn_proccxx . . $ grn_proc# *)(data->appliercxx . . $ _grn_applier_data#applier.); |
| 142 | return proc->callbackscxx . . $ _grn_proc#callbacks..functioncxx . . $ _grn_proc#$anonymous_type_5#function..appliercxx . . $ _grn_proc#$anonymous_type_5#$anonymous_type_6#applier.(ctx, data); |
| 143 | } |