| 576 | |
| 577 | |
| 578 | static ScriptedOrbit* |
| 579 | CreateScriptedOrbit(Hash* orbitData, |
| 580 | const string& path) |
| 581 | { |
| 582 | #if !defined(CELX) |
| 583 | clog << "ScriptedOrbit not usable without scripting support.\n"; |
| 584 | return NULL; |
| 585 | #else |
| 586 | |
| 587 | // Function name is required |
| 588 | string funcName; |
| 589 | if (!orbitData->getString("Function", funcName)) |
| 590 | { |
| 591 | clog << "Function name missing from script orbit definition.\n"; |
| 592 | return NULL; |
| 593 | } |
| 594 | |
| 595 | // Module name is optional |
| 596 | string moduleName; |
| 597 | orbitData->getString("Module", moduleName); |
| 598 | |
| 599 | string* pathCopy = new string(path); |
| 600 | Value* pathValue = new Value(*pathCopy); |
| 601 | orbitData->addValue("AddonPath", *pathValue); |
| 602 | |
| 603 | ScriptedOrbit* scriptedOrbit = new ScriptedOrbit(); |
| 604 | if (scriptedOrbit != NULL) |
| 605 | { |
| 606 | if (!scriptedOrbit->initialize(moduleName, funcName, orbitData)) |
| 607 | { |
| 608 | delete scriptedOrbit; |
| 609 | scriptedOrbit = NULL; |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | return scriptedOrbit; |
| 614 | #endif |
| 615 | } |
| 616 | |
| 617 | |
| 618 | Orbit* |
no test coverage detected