MCPcopy Create free account
hub / github.com/anjo76/angelscript / SaveBytecode

Function SaveBytecode

sdk/samples/asbuild/source/main.cpp:248–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246};
247
248int SaveBytecode(asIScriptEngine *engine, const char *outputFile)
249{
250 CBytecodeStream stream;
251 int r = stream.Open(outputFile);
252 if( r < 0 )
253 {
254 engine->WriteMessage(outputFile, 0, 0, asMSGTYPE_ERROR, "Failed to open output file for writing");
255 return -1;
256 }
257
258 asIScriptModule *mod = engine->GetModule("build");
259 if( mod == 0 )
260 {
261 engine->WriteMessage(outputFile, 0, 0, asMSGTYPE_ERROR, "Failed to retrieve the compiled bytecode");
262 return -1;
263 }
264
265 r = mod->SaveByteCode(&stream);
266 if( r < 0 )
267 {
268 engine->WriteMessage(outputFile, 0, 0, asMSGTYPE_ERROR, "Failed to write the bytecode");
269 return -1;
270 }
271
272 engine->WriteMessage(outputFile, 0, 0, asMSGTYPE_INFORMATION, "Bytecode successfully saved");
273
274 return 0;
275}
276
277static const char *GetCurrentDir(char *buf, size_t size)
278{

Callers 1

mainFunction · 0.85

Calls 4

WriteMessageMethod · 0.80
SaveByteCodeMethod · 0.80
OpenMethod · 0.45
GetModuleMethod · 0.45

Tested by

no test coverage detected