char buf[256];
if(!name) {
- sprintf(buf, "FGNasalScript@%8.8x", (int)script);
+ sprintf(buf, "FGNasalScript@%p", script);
name = buf;
}
fullpath.append(dent->d_name);
SGPath file(dent->d_name);
if(file.extension() != "nas") continue;
- readScriptFile(fullpath, file.base().c_str());
+ loadModule(fullpath, file.base().c_str());
}
// Pull scripts out of the property tree, too
const char* file = fn->getStringValue();
SGPath p(globals->get_fg_root());
p.append(file);
- readScriptFile(p, module);
+ loadModule(p, module);
j++;
}
if(file) {
SGPath p(globals->get_fg_root());
p.append(file);
- readScriptFile(p, module);
+ loadModule(p, module);
}
*/
// Reads a script file, executes it, and places the resulting
// namespace into the global namespace under the specified module
// name.
-void FGNasalSys::readScriptFile(SGPath file, const char* module)
+void FGNasalSys::loadModule(SGPath file, const char* module)
{
int len = 0;
char* buf = readfile(file.c_str(), &len);
virtual void init();
virtual void update(double dt) { /* noop */ }
+ // Loads a nasal script from an external file and inserts it as a
+ // global module of the specified name.
+ void loadModule(SGPath file, const char* moduleName);
+
// Simple hook to run arbitrary source code. Returns a bool to
// indicate successful execution. Does *not* return any Nasal
// values, because handling garbage-collected objects from C space
void loadPropertyScripts();
void initModule(const char* moduleName, const char* fileName,
const char* src, int len);
- void readScriptFile(SGPath file, const char* lib);
void hashset(naRef hash, const char* key, naRef val);
void logError();
naRef parse(const char* filename, const char* buf, int len);