1
0
Fork 0

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:
mfranz 2006-04-27 15:56:51 +00:00
parent b64e10fceb
commit 52306b9093
3 changed files with 6 additions and 4 deletions

View 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());

View 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);

View 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);