From d99109c9e4babd1d6d9df1060c0fccfe8414294e Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 23 Nov 2013 20:08:55 +0000 Subject: [PATCH] Reset: do re-init Ghost bindings. --- src/GUI/FileDialog.cxx | 22 ++++++++++------------ src/Scripting/NasalCanvas.cxx | 3 --- src/Scripting/NasalHTTP.cxx | 4 ---- src/Scripting/NasalModelData.cxx | 6 +----- src/Scripting/NasalPositioned_cppbind.cxx | 3 --- src/Scripting/NasalSys.cxx | 16 +++++++--------- 6 files changed, 18 insertions(+), 36 deletions(-) diff --git a/src/GUI/FileDialog.cxx b/src/GUI/FileDialog.cxx index 3c6b48d83..200b15690 100644 --- a/src/GUI/FileDialog.cxx +++ b/src/GUI/FileDialog.cxx @@ -153,18 +153,16 @@ static naRef f_createFileDialog(naContext c, naRef me, int argc, naRef* args) void postinitNasalGUI(naRef globals, naContext c) { - if (!NasalFileDialog::isInit()) { - NasalFileDialog::init("gui._FileDialog") - .member("title", &FGFileDialog::getTitle, &FGFileDialog::setTitle) - .member("button", &FGFileDialog::getButton, &FGFileDialog::setButton) - .member("directory", &FGFileDialog::getDirectory, &FGFileDialog::setDirectory) - .member("show_hidden", &FGFileDialog::showHidden, &FGFileDialog::setShowHidden) - .member("placeholder", &FGFileDialog::getPlaceholder, &FGFileDialog::setPlaceholderName) - .member("pattern", &FGFileDialog::filterPatterns, &FGFileDialog::setFilterPatterns) - .method("open", &FGFileDialog::exec) - .method("close", &FGFileDialog::close) - .method("setCallback", &FGFileDialog::setCallbackFromNasal); - } + NasalFileDialog::init("gui._FileDialog") + .member("title", &FGFileDialog::getTitle, &FGFileDialog::setTitle) + .member("button", &FGFileDialog::getButton, &FGFileDialog::setButton) + .member("directory", &FGFileDialog::getDirectory, &FGFileDialog::setDirectory) + .member("show_hidden", &FGFileDialog::showHidden, &FGFileDialog::setShowHidden) + .member("placeholder", &FGFileDialog::getPlaceholder, &FGFileDialog::setPlaceholderName) + .member("pattern", &FGFileDialog::filterPatterns, &FGFileDialog::setFilterPatterns) + .method("open", &FGFileDialog::exec) + .method("close", &FGFileDialog::close) + .method("setCallback", &FGFileDialog::setCallbackFromNasal); nasal::Hash guiModule = nasal::Hash(globals, c).get("gui"); diff --git a/src/Scripting/NasalCanvas.cxx b/src/Scripting/NasalCanvas.cxx index 8ea979998..a8b592698 100644 --- a/src/Scripting/NasalCanvas.cxx +++ b/src/Scripting/NasalCanvas.cxx @@ -204,8 +204,6 @@ naRef to_nasal_helper(naContext c, const sc::ElementWeakPtr& el) naRef initNasalCanvas(naRef globals, naContext c) { - if (!NasalEvent::isInit()) { - NasalEvent::init("canvas.Event") .member("type", &sc::Event::getTypeString) .member("target", &sc::Event::getTarget) @@ -247,7 +245,6 @@ naRef initNasalCanvas(naRef globals, naContext c) .bases() .member("_node_ghost", &elementGetNode) .method("_getCanvasDecoration", &canvas::Window::getCanvasDecoration); - } nasal::Hash globals_module(globals, c), canvas_module = globals_module.createHash("canvas"); diff --git a/src/Scripting/NasalHTTP.cxx b/src/Scripting/NasalHTTP.cxx index fbee30a0f..ae55204ac 100644 --- a/src/Scripting/NasalHTTP.cxx +++ b/src/Scripting/NasalHTTP.cxx @@ -81,8 +81,6 @@ static naRef f_http_load(const nasal::CallContext& ctx) //------------------------------------------------------------------------------ naRef initNasalHTTP(naRef globals, naContext c) { - if (!NasalRequest::isInit()) { - using simgear::HTTP::Request; NasalRequest::init("http.Request") .member("url", &Request::url) @@ -108,8 +106,6 @@ naRef initNasalHTTP(naRef globals, naContext c) NasalMemoryRequest::init("http.MemoryRequest") .bases() .member("response", &MemoryRequest::responseBody); - - } nasal::Hash globals_module(globals, c), http = globals_module.createHash("http"); diff --git a/src/Scripting/NasalModelData.cxx b/src/Scripting/NasalModelData.cxx index 8d20d6e66..20df177ad 100644 --- a/src/Scripting/NasalModelData.cxx +++ b/src/Scripting/NasalModelData.cxx @@ -122,12 +122,8 @@ void FGNasalModelData::load() nasal::Hash module = nasalSys->getGlobals().createHash(_module); module.set("_module_id", _module_id); - if( !NasalNode::isInit() ) - { - NasalNode::init("osg.Node") + NasalNode::init("osg.Node") .method("getPose", &f_node_getPose); - } - module.set("_model", _branch); naRef arg[2]; diff --git a/src/Scripting/NasalPositioned_cppbind.cxx b/src/Scripting/NasalPositioned_cppbind.cxx index cc3568c4b..8d51624a8 100644 --- a/src/Scripting/NasalPositioned_cppbind.cxx +++ b/src/Scripting/NasalPositioned_cppbind.cxx @@ -459,8 +459,6 @@ static naRef f_sortByRange(nasal::CallContext ctx) //------------------------------------------------------------------------------ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c) { - if (!NasalPositioned::isInit()) { - NasalPositioned::init("Positioned") .member("id", &FGPositioned::ident) .member("ident", &FGPositioned::ident) // TODO to we really need id and ident? @@ -504,7 +502,6 @@ naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c) .method("getStar", &FGAirport::findSTARWithIdent) .method("getIAP", &FGAirport::findApproachWithIdent) .method("tostring", &FGAirport::toString); - } nasal::Hash globals(globalsRef, c), positioned( globals.createHash("positioned") ); diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index f0df1aacf..57967ebf6 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -777,15 +777,13 @@ void FGNasalSys::init() initNasalCondition(_globals, _context); initNasalHTTP(_globals, _context); - if (!NasalTimerObj::isInit()) { - NasalTimerObj::init("Timer") - .method("start", &TimerObj::start) - .method("stop", &TimerObj::stop) - .method("restart", &TimerObj::restart) - .member("singleShot", &TimerObj::isSingleShot, &TimerObj::setSingleShot) - .member("isRunning", &TimerObj::isRunning); - } - + NasalTimerObj::init("Timer") + .method("start", &TimerObj::start) + .method("stop", &TimerObj::stop) + .method("restart", &TimerObj::restart) + .member("singleShot", &TimerObj::isSingleShot, &TimerObj::setSingleShot) + .member("isRunning", &TimerObj::isRunning); + // Now load the various source files in the Nasal directory simgear::Dir nasalDir(SGPath(globals->get_fg_root(), "Nasal")); loadScriptDirectory(nasalDir);