From: James Turner Date: Fri, 28 Dec 2012 14:53:31 +0000 (+0000) Subject: Add SGPath to the Nasal conversion helpers. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0ea8dbea100b24d13e57200323f9c69c2d735e3c;p=simgear.git Add SGPath to the Nasal conversion helpers. --- diff --git a/simgear/nasal/cppbind/from_nasal.cxx b/simgear/nasal/cppbind/from_nasal.cxx index 0cede8c1..0c3fba95 100644 --- a/simgear/nasal/cppbind/from_nasal.cxx +++ b/simgear/nasal/cppbind/from_nasal.cxx @@ -19,6 +19,8 @@ #include "from_nasal_detail.hxx" #include "NasalHash.hxx" +#include + namespace nasal { //---------------------------------------------------------------------------- @@ -53,6 +55,12 @@ namespace nasal return std::string(naStr_data(na_str), naStr_len(na_str)); } + SGPath from_nasal_helper(naContext c, naRef ref, SGPath*) + { + naRef na_str = naStringValue(c, ref); + return SGPath(std::string(naStr_data(na_str), naStr_len(na_str))); + } + //---------------------------------------------------------------------------- Hash from_nasal_helper(naContext c, naRef ref, Hash*) { diff --git a/simgear/nasal/cppbind/from_nasal_detail.hxx b/simgear/nasal/cppbind/from_nasal_detail.hxx index 21d354ae..aeec6e20 100644 --- a/simgear/nasal/cppbind/from_nasal_detail.hxx +++ b/simgear/nasal/cppbind/from_nasal_detail.hxx @@ -31,6 +31,8 @@ #include // std::bad_cast #include +class SGPath; + namespace nasal { class Hash; @@ -75,6 +77,11 @@ namespace nasal */ std::string from_nasal_helper(naContext c, naRef ref, std::string*); + /** + * Convert a Nasal string to an SGPath + */ + SGPath from_nasal_helper(naContext c, naRef ref, SGPath*); + /** * Convert a Nasal hash to a nasal::Hash */ diff --git a/simgear/nasal/cppbind/to_nasal.cxx b/simgear/nasal/cppbind/to_nasal.cxx index ef5b1a21..40b3cd4f 100644 --- a/simgear/nasal/cppbind/to_nasal.cxx +++ b/simgear/nasal/cppbind/to_nasal.cxx @@ -19,6 +19,8 @@ #include "to_nasal.hxx" #include "NasalHash.hxx" +#include + namespace nasal { //---------------------------------------------------------------------------- @@ -53,4 +55,9 @@ namespace nasal return ref; } + //---------------------------------------------------------------------------- + naRef to_nasal(naContext c, const SGPath& path) + { + return to_nasal(c, path.str()); + } } // namespace nasal diff --git a/simgear/nasal/cppbind/to_nasal.hxx b/simgear/nasal/cppbind/to_nasal.hxx index 45a27411..20d989c6 100644 --- a/simgear/nasal/cppbind/to_nasal.hxx +++ b/simgear/nasal/cppbind/to_nasal.hxx @@ -30,6 +30,8 @@ #include #include +class SGPath; + namespace nasal { class Hash; @@ -60,6 +62,8 @@ namespace nasal */ naRef to_nasal(naContext c, naRef ref); + naRef to_nasal(naContext c, const SGPath& path); + /** * Convert a numeric type to Nasal number */