Lines Matching +full:- +full:- +full:env
8 * http://www.apache.org/licenses/LICENSE-2.0
17 #include "actions/lua-utils.h"
75 LuaEnvironment* env) { in PushAnnotation() argument
79 lua_newtable(env->state()); in PushAnnotation()
81 env->PushFlatbuffer(entity_data_schema, in PushAnnotation()
85 lua_pushinteger(env->state(), in PushAnnotation()
87 lua_setfield(env->state(), /*idx=*/-2, kTimeUsecKey); in PushAnnotation()
88 lua_pushinteger(env->state(), in PushAnnotation()
90 lua_setfield(env->state(), /*idx=*/-2, kGranularityKey); in PushAnnotation()
91 env->PushString(classification.collection); in PushAnnotation()
92 lua_setfield(env->state(), /*idx=*/-2, kCollectionKey); in PushAnnotation()
93 lua_pushnumber(env->state(), classification.score); in PushAnnotation()
94 lua_setfield(env->state(), /*idx=*/-2, kScoreKey); in PushAnnotation()
95 env->PushString(classification.serialized_entity_data); in PushAnnotation()
96 lua_setfield(env->state(), /*idx=*/-2, kSerializedEntity); in PushAnnotation()
102 LuaEnvironment* env) { in PushAnnotation() argument
103 PushAnnotation(classification, entity_data_schema, env); in PushAnnotation()
104 env->PushString(text); in PushAnnotation()
105 lua_setfield(env->state(), /*idx=*/-2, kTextKey); in PushAnnotation()
111 LuaEnvironment* env) { in PushAnnotatedSpan() argument
112 lua_newtable(env->state()); in PushAnnotatedSpan()
114 lua_newtable(env->state()); in PushAnnotatedSpan()
115 lua_pushinteger(env->state(), annotated_span.span.first); in PushAnnotatedSpan()
116 lua_setfield(env->state(), /*idx=*/-2, kBeginKey); in PushAnnotatedSpan()
117 lua_pushinteger(env->state(), annotated_span.span.second); in PushAnnotatedSpan()
118 lua_setfield(env->state(), /*idx=*/-2, kEndKey); in PushAnnotatedSpan()
120 lua_setfield(env->state(), /*idx=*/-2, kSpanKey); in PushAnnotatedSpan()
122 &annotated_span.classification, env->state()); in PushAnnotatedSpan()
123 lua_setfield(env->state(), /*idx=*/-2, kClassificationKey); in PushAnnotatedSpan()
126 MessageTextSpan ReadSpan(LuaEnvironment* env) { in ReadSpan() argument
128 lua_pushnil(env->state()); in ReadSpan()
129 while (lua_next(env->state(), /*idx=*/-2)) { in ReadSpan()
130 const StringPiece key = env->ReadString(/*index=*/-2); in ReadSpan()
133 static_cast<int>(lua_tonumber(env->state(), /*idx=*/-1)); in ReadSpan()
136 static_cast<int>(lua_tonumber(env->state(), /*idx=*/-1)); in ReadSpan()
139 static_cast<int>(lua_tonumber(env->state(), /*idx=*/-1)); in ReadSpan()
141 span.text = env->ReadString(/*index=*/-1).ToString(); in ReadSpan()
145 lua_pop(env->state(), 1); in ReadSpan()
151 LuaEnvironment* env, in ReadAnnotations() argument
153 if (lua_type(env->state(), /*idx=*/-1) != LUA_TTABLE) { in ReadAnnotations()
155 << lua_type(env->state(), /*idx=*/-1); in ReadAnnotations()
156 lua_pop(env->state(), 1); in ReadAnnotations()
157 lua_error(env->state()); in ReadAnnotations()
162 lua_pushnil(env->state()); in ReadAnnotations()
163 while (lua_next(env->state(), /*idx=*/-2)) { in ReadAnnotations()
164 if (lua_type(env->state(), /*idx=*/-1) != LUA_TTABLE) { in ReadAnnotations()
166 << lua_type(env->state(), /*idx=*/-1); in ReadAnnotations()
167 lua_pop(env->state(), 1); in ReadAnnotations()
170 annotations->push_back(ReadAnnotation(entity_data_schema, env)); in ReadAnnotations()
171 lua_pop(env->state(), 1); in ReadAnnotations()
177 const reflection::Schema* entity_data_schema, LuaEnvironment* env) { in ReadAnnotation() argument
179 lua_pushnil(env->state()); in ReadAnnotation()
180 while (lua_next(env->state(), /*idx=*/-2)) { in ReadAnnotation()
181 const StringPiece key = env->ReadString(/*index=*/-2); in ReadAnnotation()
183 annotation.name = env->ReadString(/*index=*/-1).ToString(); in ReadAnnotation()
185 annotation.span = ReadSpan(env); in ReadAnnotation()
187 annotation.entity = ReadClassificationResult(entity_data_schema, env); in ReadAnnotation()
191 lua_pop(env->state(), 1); in ReadAnnotation()
197 const reflection::Schema* entity_data_schema, LuaEnvironment* env) { in ReadClassificationResult() argument
199 lua_pushnil(env->state()); in ReadClassificationResult()
200 while (lua_next(env->state(), /*idx=*/-2)) { in ReadClassificationResult()
201 const StringPiece key = env->ReadString(/*index=*/-2); in ReadClassificationResult()
203 classification.collection = env->ReadString(/*index=*/-1).ToString(); in ReadClassificationResult()
206 static_cast<float>(lua_tonumber(env->state(), /*idx=*/-1)); in ReadClassificationResult()
209 static_cast<int64>(lua_tonumber(env->state(), /*idx=*/-1)); in ReadClassificationResult()
213 lua_tonumber(env->state(), /*idx=*/-1)); in ReadClassificationResult()
216 env->ReadString(/*index=*/-1).ToString(); in ReadClassificationResult()
219 env->ReadFlatbuffer(buffer.get()); in ReadClassificationResult()
220 classification.serialized_entity_data = buffer->Serialize(); in ReadClassificationResult()
225 lua_pop(env->state(), 1); in ReadClassificationResult()
232 LuaEnvironment* env) { in PushAnnotation() argument
234 env); in PushAnnotation()
235 env->PushString(annotation.name); in PushAnnotation()
236 lua_setfield(env->state(), /*idx=*/-2, kNameKey); in PushAnnotation()
238 lua_newtable(env->state()); in PushAnnotation()
239 lua_pushinteger(env->state(), annotation.span.message_index); in PushAnnotation()
240 lua_setfield(env->state(), /*idx=*/-2, kMessageKey); in PushAnnotation()
241 lua_pushinteger(env->state(), annotation.span.span.first); in PushAnnotation()
242 lua_setfield(env->state(), /*idx=*/-2, kBeginKey); in PushAnnotation()
243 lua_pushinteger(env->state(), annotation.span.span.second); in PushAnnotation()
244 lua_setfield(env->state(), /*idx=*/-2, kEndKey); in PushAnnotation()
246 lua_setfield(env->state(), /*idx=*/-2, kSpanKey); in PushAnnotation()
253 LuaEnvironment* env) { in PushAction() argument
256 lua_newtable(env->state()); in PushAction()
258 env->PushFlatbuffer(entity_data_schema, in PushAction()
262 env->PushString(action.type); in PushAction()
263 lua_setfield(env->state(), /*idx=*/-2, kTypeKey); in PushAction()
264 env->PushString(action.response_text); in PushAction()
265 lua_setfield(env->state(), /*idx=*/-2, kResponseTextKey); in PushAction()
266 lua_pushnumber(env->state(), action.score); in PushAction()
267 lua_setfield(env->state(), /*idx=*/-2, kScoreKey); in PushAction()
268 lua_pushnumber(env->state(), action.priority_score); in PushAction()
269 lua_setfield(env->state(), /*idx=*/-2, kPriorityScoreKey); in PushAction()
271 env->state()); in PushAction()
272 lua_setfield(env->state(), /*idx=*/-2, kAnnotationKey); in PushAction()
278 LuaEnvironment* env) { in ReadAction() argument
280 lua_pushnil(env->state()); in ReadAction()
281 while (lua_next(env->state(), /*idx=*/-2)) { in ReadAction()
282 const StringPiece key = env->ReadString(/*index=*/-2); in ReadAction()
284 action.response_text = env->ReadString(/*index=*/-1).ToString(); in ReadAction()
286 action.type = env->ReadString(/*index=*/-1).ToString(); in ReadAction()
288 action.score = static_cast<float>(lua_tonumber(env->state(), /*idx=*/-1)); in ReadAction()
291 static_cast<float>(lua_tonumber(env->state(), /*idx=*/-1)); in ReadAction()
293 ReadAnnotations(actions_entity_data_schema, env, &action.annotations); in ReadAction()
297 env->ReadFlatbuffer(buffer.get()); in ReadAction()
298 action.serialized_entity_data = buffer->Serialize(); in ReadAction()
302 lua_pop(env->state(), 1); in ReadAction()
309 LuaEnvironment* env, std::vector<ActionSuggestion>* actions) { in ReadActions() argument
310 if (lua_type(env->state(), /*idx=*/-1) != LUA_TTABLE) { in ReadActions()
312 << lua_type(env->state(), /*idx=*/-1); in ReadActions()
313 lua_pop(env->state(), 1); in ReadActions()
314 lua_error(env->state()); in ReadActions()
319 lua_pushnil(env->state()); in ReadActions()
320 while (lua_next(env->state(), /*idx=*/-2)) { in ReadActions()
321 if (lua_type(env->state(), /*idx=*/-1) != LUA_TTABLE) { in ReadActions()
323 << lua_type(env->state(), /*idx=*/-1); in ReadActions()
324 lua_pop(env->state(), 1); in ReadActions()
327 actions->push_back(ReadAction(actions_entity_data_schema, in ReadActions()
328 annotations_entity_data_schema, env)); in ReadActions()
329 lua_pop(env->state(), /*n=1*/ 1); in ReadActions()
331 lua_pop(env->state(), /*n=*/1); in ReadActions()
341 lua_setfield(state, /*idx=*/-2, "user_id"); in Item()
342 env_->PushString(message.text); in Item()
343 lua_setfield(state, /*idx=*/-2, "text"); in Item()
345 lua_setfield(state, /*idx=*/-2, "time_ms_utc"); in Item()
346 env_->PushString(message.reference_timezone); in Item()
347 lua_setfield(state, /*idx=*/-2, "timezone"); in Item()
350 lua_setfield(state, /*idx=*/-2, "annotation"); in Item()