diff --git a/src/Canvas/FGCanvasSystemAdapter.cxx b/src/Canvas/FGCanvasSystemAdapter.cxx index 576e859b1..a587dff16 100644 --- a/src/Canvas/FGCanvasSystemAdapter.cxx +++ b/src/Canvas/FGCanvasSystemAdapter.cxx @@ -122,18 +122,6 @@ namespace canvas 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, diff --git a/src/Canvas/FGCanvasSystemAdapter.hxx b/src/Canvas/FGCanvasSystemAdapter.hxx index 4cb3a5547..7fca339f1 100644 --- a/src/Canvas/FGCanvasSystemAdapter.hxx +++ b/src/Canvas/FGCanvasSystemAdapter.hxx @@ -33,8 +33,6 @@ namespace canvas 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, diff --git a/src/Scripting/NasalCanvas.cxx b/src/Scripting/NasalCanvas.cxx index 1cdf9b57f..67d9f728a 100644 --- a/src/Scripting/NasalCanvas.cxx +++ b/src/Scripting/NasalCanvas.cxx @@ -202,7 +202,7 @@ naRef to_nasal_helper(naContext c, const sc::ElementWeakPtr& el) 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) diff --git a/src/Scripting/NasalCanvas.hxx b/src/Scripting/NasalCanvas.hxx index 394a1194b..090230132 100644 --- a/src/Scripting/NasalCanvas.hxx +++ b/src/Scripting/NasalCanvas.hxx @@ -23,7 +23,7 @@ #include -naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave); +naRef initNasalCanvas(naRef globals, naContext c); #endif // of SCRIPTING_NASAL_CANVAS_HXX diff --git a/src/Scripting/NasalCondition.cxx b/src/Scripting/NasalCondition.cxx index da796c533..f47a52a51 100644 --- a/src/Scripting/NasalCondition.cxx +++ b/src/Scripting/NasalCondition.cxx @@ -100,10 +100,10 @@ static struct { const char* name; naCFunction func; } funcs[] = { }; -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++) { diff --git a/src/Scripting/NasalCondition.hxx b/src/Scripting/NasalCondition.hxx index 51b2661b6..c16b2b5d1 100644 --- a/src/Scripting/NasalCondition.hxx +++ b/src/Scripting/NasalCondition.hxx @@ -28,7 +28,7 @@ class SGCondition; 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 diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx index fced59bec..5b5206eed 100644 --- a/src/Scripting/NasalPositioned.cxx +++ b/src/Scripting/NasalPositioned.cxx @@ -2403,10 +2403,10 @@ static struct { const char* name; naCFunction func; } funcs[] = { }; -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))); @@ -2424,7 +2424,7 @@ naRef initNasalPositioned(naRef globals, naContext c, naRef gcSave) 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))); @@ -2442,19 +2442,19 @@ naRef initNasalPositioned(naRef globals, naContext c, naRef gcSave) 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))); diff --git a/src/Scripting/NasalPositioned.hxx b/src/Scripting/NasalPositioned.hxx index 14401e9c2..f30ee6fc8 100644 --- a/src/Scripting/NasalPositioned.hxx +++ b/src/Scripting/NasalPositioned.hxx @@ -28,8 +28,8 @@ class SGGeod; 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 diff --git a/src/Scripting/NasalPositioned_cppbind.cxx b/src/Scripting/NasalPositioned_cppbind.cxx index b2e104442..8d51624a8 100644 --- a/src/Scripting/NasalPositioned_cppbind.cxx +++ b/src/Scripting/NasalPositioned_cppbind.cxx @@ -457,7 +457,7 @@ static naRef f_sortByRange(nasal::CallContext ctx) } //------------------------------------------------------------------------------ -naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c, naRef gcSave) +naRef initNasalPositioned_cppbind(naRef globalsRef, naContext c) { NasalPositioned::init("Positioned") .member("id", &FGPositioned::ident) diff --git a/src/Scripting/NasalString.cxx b/src/Scripting/NasalString.cxx index c3aaf609e..331c75ffb 100644 --- a/src/Scripting/NasalString.cxx +++ b/src/Scripting/NasalString.cxx @@ -131,7 +131,7 @@ static naRef f_find_first_not_of(naContext c, naRef me, int argc, naRef* args) } //------------------------------------------------------------------------------ -naRef initNasalString(naRef globals, naRef string, naContext c, naRef gcSave) +naRef initNasalString(naRef globals, naRef string, naContext c) { nasal::Hash string_module(string, c); diff --git a/src/Scripting/NasalString.hxx b/src/Scripting/NasalString.hxx index 80d6474d5..5baba39d8 100644 --- a/src/Scripting/NasalString.hxx +++ b/src/Scripting/NasalString.hxx @@ -21,7 +21,7 @@ #include -naRef initNasalString(naRef globals, naRef string, naContext c, naRef gcSave); +naRef initNasalString(naRef globals, naRef string, naContext c); #endif // of SCRIPTING_NASAL_STRING_HXX diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index d4c1ae0e2..278f97194 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -202,8 +202,6 @@ FGNasalSys::FGNasalSys() _context = 0; _globals = naNil(); _string = naNil(); - _gcHash = naNil(); - _nextGCKey = 0; // Any value will do _callCount = 0; _log = new simgear::BufferedLogCallback(SG_NASAL, SG_INFO); @@ -778,22 +776,16 @@ void FGNasalSys::init() // 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) @@ -1174,14 +1166,12 @@ void FGNasalSys::handleTimer(NasalTimer* t) 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() diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx index 973730e47..692cb3c77 100644 --- a/src/Scripting/NasalSys.hxx +++ b/src/Scripting/NasalSys.hxx @@ -172,8 +172,6 @@ private: SGPropertyNode_ptr _cmdArg; - int _nextGCKey; - naRef _gcHash; int _callCount; simgear::BufferedLogCallback* _log;