From 52306b9093ee2c9d8483d02805dfa5fcf40fb526 Mon Sep 17 00:00:00 2001 From: mfranz Date: Thu, 27 Apr 2006 15:56:51 +0000 Subject: [PATCH] add optional SGPropertyNode* argument to NasalSys::createModule. This is used in dialog.cxx to allow XML dialogs access to their own prop tree via Nasal's cmdarg(). That way dialogs can generate dynamic content, such as list entries. --- src/GUI/dialog.cxx | 4 ++-- src/Scripting/NasalSys.cxx | 4 +++- src/Scripting/NasalSys.hxx | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index b248fc936..a40bcd2f2 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -335,7 +335,7 @@ FGDialog::FGDialog (SGPropertyNode * props) if (open) { const char *s = open->getStringValue(); FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal"); - nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s)); + nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), props); } } display(props); @@ -351,7 +351,7 @@ FGDialog::~FGDialog () FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal"); if (_nasal_close) { const char *s = _nasal_close->getStringValue(); - nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s)); + nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _props); } nas->deleteModule(_module.c_str()); diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index c0b25c4ea..7ae424464 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -483,7 +483,7 @@ void FGNasalSys::loadModule(SGPath file, const char* module) // Parse and run. Save the local variables namespace, as it will // become a sub-object of globals. void FGNasalSys::createModule(const char* moduleName, const char* fileName, - const char* src, int len) + const char* src, int len, const SGPropertyNode* arg) { naRef code = parse(fileName, src, len); if(naIsNil(code)) @@ -498,6 +498,8 @@ void FGNasalSys::createModule(const char* moduleName, const char* fileName, if(!naHash_get(_globals, modname, &locals)) locals = naNewHash(_context); + _cmdArg = (SGPropertyNode*)arg; + naCall(_context, code, 0, 0, naNil(), locals); if(naGetError(_context)) { logError(_context); diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx index 7da34d66f..7324a23b7 100644 --- a/src/Scripting/NasalSys.hxx +++ b/src/Scripting/NasalSys.hxx @@ -53,7 +53,7 @@ public: virtual bool handleCommand(const SGPropertyNode* arg); void createModule(const char* moduleName, const char* fileName, - const char* src, int len); + const char* src, int len, const SGPropertyNode* arg=0); void deleteModule(const char* moduleName);