From: Thomas Geymayer Date: Sat, 23 Mar 2013 11:47:06 +0000 (+0100) Subject: nasal::Ghost tweaking and to_nasal_helper for SGGeod. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b6c542b0e7803971fca223ab3eb8d76b4685f31d;p=simgear.git nasal::Ghost tweaking and to_nasal_helper for SGGeod. --- diff --git a/simgear/nasal/cppbind/Ghost.hxx b/simgear/nasal/cppbind/Ghost.hxx index 77c0f287..1ffadba7 100644 --- a/simgear/nasal/cppbind/Ghost.hxx +++ b/simgear/nasal/cppbind/Ghost.hxx @@ -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. diff --git a/simgear/nasal/cppbind/cppbind_test.cxx b/simgear/nasal/cppbind/cppbind_test.cxx index 9fa92534..ed5cb400 100644 --- a/simgear/nasal/cppbind/cppbind_test.cxx +++ b/simgear/nasal/cppbind/cppbind_test.cxx @@ -165,6 +165,7 @@ int main(int argc, char* argv[]) .member("base", &DoubleDerived2::getBase) .method("doIt", &DoubleDerived2::doSomeBaseWork); + VERIFY( Ghost::isInit() ); nasal::to_nasal(c, DoubleDerived2Ptr()); BasePtr d( new Derived ); diff --git a/simgear/nasal/cppbind/detail/to_nasal_helper.cxx b/simgear/nasal/cppbind/detail/to_nasal_helper.cxx index fd744fde..d3dd584f 100644 --- a/simgear/nasal/cppbind/detail/to_nasal_helper.cxx +++ b/simgear/nasal/cppbind/detail/to_nasal_helper.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -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) { diff --git a/simgear/nasal/cppbind/detail/to_nasal_helper.hxx b/simgear/nasal/cppbind/detail/to_nasal_helper.hxx index c74282ef..f9e4f235 100644 --- a/simgear/nasal/cppbind/detail/to_nasal_helper.hxx +++ b/simgear/nasal/cppbind/detail/to_nasal_helper.hxx @@ -33,6 +33,7 @@ #include #include +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); /**