| 514 | } |
| 515 | |
| 516 | void Squirrel::Initialize() |
| 517 | { |
| 518 | ScriptAllocatorScope alloc_scope(this); |
| 519 | |
| 520 | this->global_pointer = nullptr; |
| 521 | this->print_func = nullptr; |
| 522 | this->crashed = false; |
| 523 | this->overdrawn_ops = 0; |
| 524 | this->vm = sq_open(1024); |
| 525 | |
| 526 | /* Handle compile-errors ourself, so we can display it nicely */ |
| 527 | sq_setcompilererrorhandler(this->vm, &Squirrel::CompileError); |
| 528 | sq_notifyallexceptions(this->vm, _debug_script_level > 5); |
| 529 | /* Set a good print-function */ |
| 530 | sq_setprintfunc(this->vm, &Squirrel::PrintFunc); |
| 531 | /* Handle runtime-errors ourself, so we can display it nicely */ |
| 532 | sq_newclosure(this->vm, &Squirrel::_RunError, 0); |
| 533 | sq_seterrorhandler(this->vm); |
| 534 | |
| 535 | /* Set the foreign pointer, so we can always find this instance from within the VM */ |
| 536 | sq_setforeignptr(this->vm, this); |
| 537 | |
| 538 | sq_pushroottable(this->vm); |
| 539 | squirrel_register_global_std(*this); |
| 540 | |
| 541 | /* Set consts table as delegate of root table, so consts/enums defined via require() are accessible */ |
| 542 | sq_pushconsttable(this->vm); |
| 543 | sq_setdelegate(this->vm, -2); |
| 544 | } |
| 545 | |
| 546 | class SQFile { |
| 547 | private: |
no test coverage detected