return getNasalSys()->context();
}
- //----------------------------------------------------------------------------
- int FGCanvasSystemAdapter::gcSave(naRef r)
- {
- return getNasalSys()->gcSave(r);
- }
-
- //----------------------------------------------------------------------------
- void FGCanvasSystemAdapter::gcRelease(int key)
- {
- getNasalSys()->gcRelease(key);
- }
-
//------------------------------------------------------------------------------
naRef FGCanvasSystemAdapter::callMethod( naRef code,
naRef self,
virtual osg::Image* getImage(const std::string& path) const;
virtual naContext getNasalContext() const;
- virtual int gcSave(naRef r);
- virtual void gcRelease(int key);
virtual naRef callMethod( naRef code,
naRef self,
int argc,
return NasalElement::create(c, el.lock());
}
-naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
+naRef initNasalCanvas(naRef globals, naContext c)
{
NasalEvent::init("canvas.Event")
.member("type", &sc::Event::getTypeString)
#include <simgear/nasal/nasal.h>
-naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave);
+naRef initNasalCanvas(naRef globals, naContext c);
#endif // of SCRIPTING_NASAL_CANVAS_HXX
};
-naRef initNasalCondition(naRef globals, naContext c, naRef gcSave)
+naRef initNasalCondition(naRef globals, naContext c)
{
conditionPrototype = naNewHash(c);
- hashset(c, gcSave, "conditionProto", conditionPrototype);
+ naSave(c, conditionPrototype);
hashset(c, conditionPrototype, "test", naNewFunc(c, naNewCCode(c, f_condition_test)));
for(int i=0; funcs[i].name; i++) {
naRef ghostForCondition(naContext c, const SGCondition* cond);
-naRef initNasalCondition(naRef globals, naContext c, naRef gcSave);
+naRef initNasalCondition(naRef globals, naContext c);
#endif // of SCRIPTING_NASAL_CONDITION_HXX
};
-naRef initNasalPositioned(naRef globals, naContext c, naRef gcSave)
+naRef initNasalPositioned(naRef globals, naContext c)
{
airportPrototype = naNewHash(c);
- hashset(c, gcSave, "airportProto", airportPrototype);
+ naSave(c, airportPrototype);
hashset(c, airportPrototype, "runway", naNewFunc(c, naNewCCode(c, f_airport_runway)));
hashset(c, airportPrototype, "runwaysWithoutReciprocals", naNewFunc(c, naNewCCode(c, f_airport_runwaysWithoutReciprocals)));
hashset(c, airportPrototype, "tostring", naNewFunc(c, naNewCCode(c, f_airport_toString)));
flightplanPrototype = naNewHash(c);
- hashset(c, gcSave, "flightplanProto", flightplanPrototype);
+ naSave(c, flightplanPrototype);
hashset(c, flightplanPrototype, "getWP", naNewFunc(c, naNewCCode(c, f_flightplan_getWP)));
hashset(c, flightplanPrototype, "currentWP", naNewFunc(c, naNewCCode(c, f_flightplan_currentWP)));
hashset(c, flightplanPrototype, "finish", naNewFunc(c, naNewCCode(c, f_flightplan_finish)));
waypointPrototype = naNewHash(c);
- hashset(c, gcSave, "wayptProto", waypointPrototype);
+ naSave(c, waypointPrototype);
hashset(c, waypointPrototype, "navaid", naNewFunc(c, naNewCCode(c, f_waypoint_navaid)));
hashset(c, waypointPrototype, "runway", naNewFunc(c, naNewCCode(c, f_waypoint_runway)));
hashset(c, waypointPrototype, "airport", naNewFunc(c, naNewCCode(c, f_waypoint_airport)));
procedurePrototype = naNewHash(c);
- hashset(c, gcSave, "procedureProto", procedurePrototype);
+ naSave(c, procedurePrototype);
hashset(c, procedurePrototype, "transition", naNewFunc(c, naNewCCode(c, f_procedure_transition)));
hashset(c, procedurePrototype, "route", naNewFunc(c, naNewCCode(c, f_procedure_route)));
fpLegPrototype = naNewHash(c);
- hashset(c, gcSave, "fpLegProto", fpLegPrototype);
+ naSave(c, fpLegPrototype);
hashset(c, fpLegPrototype, "setSpeed", naNewFunc(c, naNewCCode(c, f_leg_setSpeed)));
hashset(c, fpLegPrototype, "setAltitude", naNewFunc(c, naNewCCode(c, f_leg_setAltitude)));
hashset(c, fpLegPrototype, "path", naNewFunc(c, naNewCCode(c, f_leg_path)));
bool geodFromHash(naRef ref, SGGeod& result);
-naRef initNasalPositioned(naRef globals, naContext c, naRef gcSave);
-naRef initNasalPositioned_cppbind(naRef globals, naContext c, naRef gcSave);
+naRef initNasalPositioned(naRef globals, naContext c);
+naRef initNasalPositioned_cppbind(naRef globals, naContext c);
void postinitNasalPositioned(naRef globals, naContext c);
#endif // of SCRIPTING_NASAL_POSITIONED_HXX
}
//------------------------------------------------------------------------------
-naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c, naRef gcSave)
+naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c)
{
NasalPositioned::init("Positioned")
.member("id", &FGPositioned::ident)
}
//------------------------------------------------------------------------------
-naRef initNasalString(naRef globals, naRef string, naContext c, naRef gcSave)
+naRef initNasalString(naRef globals, naRef string, naContext c)
{
nasal::Hash string_module(string, c);
#include <simgear/nasal/nasal.h>
-naRef initNasalString(naRef globals, naRef string, naContext c, naRef gcSave);
+naRef initNasalString(naRef globals, naRef string, naContext c);
#endif // of SCRIPTING_NASAL_STRING_HXX
_context = 0;
_globals = naNil();
_string = naNil();
- _gcHash = naNil();
- _nextGCKey = 0; // Any value will do
_callCount = 0;
_log = new simgear::BufferedLogCallback(SG_NASAL, SG_INFO);
// And our SGPropertyNode wrapper
hashset(_globals, "props", genPropsModule());
- // Make a "__gcsave" hash to hold the naRef objects which get
- // passed to handles outside the interpreter (to protect them from
- // begin garbage-collected).
- _gcHash = naNewHash(_context);
- hashset(_globals, "__gcsave", _gcHash);
-
// Add string methods
_string = naInit_string(_context);
naSave(_context, _string);
- initNasalString(_globals, _string, _context, _gcHash);
+ initNasalString(_globals, _string, _context);
- initNasalPositioned(_globals, _context, _gcHash);
- initNasalPositioned_cppbind(_globals, _context, _gcHash);
+ initNasalPositioned(_globals, _context);
+ initNasalPositioned_cppbind(_globals, _context);
NasalClipboard::init(this);
- initNasalCanvas(_globals, _context, _gcHash);
- initNasalCondition(_globals, _context, _gcHash);
+ initNasalCanvas(_globals, _context);
+ initNasalCondition(_globals, _context);
NasalTimerObj::init("Timer")
.method("start", &TimerObj::start)
int FGNasalSys::gcSave(naRef r)
{
- int key = _nextGCKey++;
- naHash_set(_gcHash, naNum(key), r);
- return key;
+ return naGCSave(r);
}
void FGNasalSys::gcRelease(int key)
{
- naHash_delete(_gcHash, naNum(key));
+ naGCRelease(key);
}
void FGNasalSys::NasalTimer::timerExpired()
SGPropertyNode_ptr _cmdArg;
- int _nextGCKey;
- naRef _gcHash;
int _callCount;
simgear::BufferedLogCallback* _log;