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.
This commit is contained in:
parent
b64e10fceb
commit
52306b9093
3 changed files with 6 additions and 4 deletions
|
@ -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());
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue