]> git.mxchange.org Git - flightgear.git/commitdiff
add optional SGPropertyNode* argument to NasalSys::createModule. This is
authormfranz <mfranz>
Thu, 27 Apr 2006 15:56:51 +0000 (15:56 +0000)
committermfranz <mfranz>
Thu, 27 Apr 2006 15:56:51 +0000 (15:56 +0000)
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
src/Scripting/NasalSys.cxx
src/Scripting/NasalSys.hxx

index b248fc9363f926605cfc1cb488fdaa3e0059609e..a40bcd2f2bb32c459107143a3b1a3cb31c24c3a8 100644 (file)
@@ -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());
 
index c0b25c4eaf47377baa79a1279da23315840800ef..7ae4244647223dc679060b61f034747f5cff2ba6 100644 (file)
@@ -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);
index 7da34d66fe2663c637f5e7ec59c4bcc5f26ec43d..7324a23b7edf6cd45222595978a3eca632ba0d1a 100644 (file)
@@ -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);