MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / run

Method run

Source/Scripting/angelscript/ascontext.cpp:145–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143std::stack<ASContext *> active_context_stack;
144
145void ASContext::run(asIScriptFunction *func, const ASArglist *args_ptr, ASArg *return_val) {
146 LOGS << "Pushing a new callstack " << this << std::endl;
147 active_context_stack.push(this);
148 ctx->PushState();
149
150 int r = ctx->Prepare(func);
151 if (r < 0) {
152 FatalError("Error", "Failed to prepare the context for function: \"%s\"", func->GetName());
153 }
154
155 // Set args
156 if (args_ptr) {
157 const ASArglist &args = *args_ptr;
158 for (unsigned i = 0; i < args.size(); i++) {
159 const ASArgType &type = args[i].type;
160 switch (type) {
161 case _as_char:
162 case _as_bool:
163 ctx->SetArgByte(i, *((asBYTE *)args[i].data));
164 break;
165 case _as_int:
166 ctx->SetArgDWord(i, *((asDWORD *)args[i].data));
167 break;
168 case _as_unsigned:
169 ctx->SetArgDWord(i, *((asDWORD *)args[i].data));
170 break;
171 case _as_float:
172 ctx->SetArgFloat(i, *((float *)args[i].data));
173 break;
174 case _as_double:
175 ctx->SetArgDouble(i, *((double *)args[i].data));
176 break;
177 case _as_address:
178 ctx->SetArgAddress(i, args[i].data);
179 break;
180 case _as_object:
181 ctx->SetArgObject(i, args[i].data);
182 break;
183 case _as_string:
184 ctx->SetArgObject(i, args[i].data);
185 // LOGE << "Unhandled _as_string case" << std::endl;
186 break;
187 case _as_json:
188 LOGE << "Unhandled _as_json case" << std::endl;
189 break;
190 }
191 }
192 }
193
194 r = ctx->Execute();
195 if (r != asEXECUTION_FINISHED) {
196 // The execution didn't finish as we had planned. Determine why.
197 if (r == asEXECUTION_ABORTED) {
198 LOGE << "The script was aborted before it could finish. Probably it timed out." << std::endl;
199 } else if (r == asEXECUTION_EXCEPTION) {
200 LOGE << "The script ended with an exception." << std::endl;
201
202 // Write some information about the script exception

Callers

nothing calls this directly

Calls 15

PushStateMethod · 0.80
SetArgByteMethod · 0.80
SetArgDWordMethod · 0.80
SetArgFloatMethod · 0.80
SetArgDoubleMethod · 0.80
SetArgAddressMethod · 0.80
SetArgObjectMethod · 0.80
GetExceptionFunctionMethod · 0.80
GetDeclarationMethod · 0.80
GetModuleNameMethod · 0.80
GetScriptSectionNameMethod · 0.80

Tested by

no test coverage detected