| 246 | }; |
| 247 | |
| 248 | int 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 | |
| 277 | static const char *GetCurrentDir(char *buf, size_t size) |
| 278 | { |
no test coverage detected