nasal::Ghost tweaking and to_nasal_helper for SGGeod.

This commit is contained in:
Thomas Geymayer
2013-03-23 12:47:06 +01:00
parent 2d62275a08
commit b6c542b0e7
4 changed files with 23 additions and 0 deletions

View File

@@ -278,6 +278,14 @@ namespace nasal
return *getSingletonPtr();
}
/**
* Check whether ghost type has already been initialized.
*/
static bool isInit()
{
return getSingletonPtr();
}
/**
* Register a base class for this ghost. The base class needs to be
* registers on its own before it can be used as base class.

View File

@@ -165,6 +165,7 @@ int main(int argc, char* argv[])
.member("base", &DoubleDerived2::getBase)
.method("doIt", &DoubleDerived2::doSomeBaseWork);
VERIFY( Ghost<BasePtr>::isInit() );
nasal::to_nasal(c, DoubleDerived2Ptr());
BasePtr d( new Derived );

View File

@@ -20,6 +20,7 @@
#include <simgear/nasal/cppbind/NasalHash.hxx>
#include <simgear/nasal/cppbind/Ghost.hxx>
#include <simgear/math/SGMath.hxx>
#include <simgear/misc/sg_path.hxx>
#include <boost/function.hpp>
@@ -52,6 +53,16 @@ namespace nasal
return ref;
}
//------------------------------------------------------------------------------
naRef to_nasal_helper(naContext c, const SGGeod& pos)
{
nasal::Hash hash(c);
hash.set("lat", pos.getLatitudeDeg());
hash.set("lon", pos.getLongitudeDeg());
hash.set("elevation", pos.getElevationM());
return hash.get_naRef();
}
//----------------------------------------------------------------------------
naRef to_nasal_helper(naContext c, const SGPath& path)
{

View File

@@ -33,6 +33,7 @@
#include <string>
#include <vector>
class SGGeod;
class SGPath;
namespace nasal
@@ -63,6 +64,8 @@ namespace nasal
*/
naRef to_nasal_helper(naContext c, const naRef& ref);
naRef to_nasal_helper(naContext c, const SGGeod& pos);
naRef to_nasal_helper(naContext c, const SGPath& path);
/**