| 245 | } |
| 246 | |
| 247 | int CompileScript(asIScriptEngine *engine) |
| 248 | { |
| 249 | int r; |
| 250 | |
| 251 | // The builder is a helper class that will load the script file, |
| 252 | // search for #include directives, and load any included files as |
| 253 | // well. |
| 254 | CScriptBuilder builder; |
| 255 | |
| 256 | // Build the script. If there are any compiler messages they will |
| 257 | // be written to the message stream that we set right after creating the |
| 258 | // script engine. If there are no errors, and no warnings, nothing will |
| 259 | // be written to the stream. |
| 260 | r = builder.StartNewModule(engine, 0); |
| 261 | if( r < 0 ) |
| 262 | { |
| 263 | cout << "Failed to start new module" << endl; |
| 264 | return r; |
| 265 | } |
| 266 | r = builder.AddSectionFromFile("script.as"); |
| 267 | if( r < 0 ) |
| 268 | { |
| 269 | cout << "Failed to add script file" << endl; |
| 270 | return r; |
| 271 | } |
| 272 | r = builder.BuildModule(); |
| 273 | if( r < 0 ) |
| 274 | { |
| 275 | cout << "Failed to build the module" << endl; |
| 276 | return r; |
| 277 | } |
| 278 | |
| 279 | // The engine doesn't keep a copy of the script sections after Build() has |
| 280 | // returned. So if the script needs to be recompiled, then all the script |
| 281 | // sections must be added again. |
| 282 | |
| 283 | // If we want to have several scripts executing at different times but |
| 284 | // that have no direct relation with each other, then we can compile them |
| 285 | // into separate script modules. Each module use their own namespace and |
| 286 | // scope, so function names, and global variables will not conflict with |
| 287 | // each other. |
| 288 | |
| 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | void LineCallback(asIScriptContext *ctx, DWORD *timeOut) |
| 293 | { |
no test coverage detected