Add SGPath to the Nasal conversion helpers.

This commit is contained in:
James Turner
2012-12-28 14:53:31 +00:00
parent a131f44247
commit 0ea8dbea10
4 changed files with 26 additions and 0 deletions
+8
View File
@@ -19,6 +19,8 @@
#include "from_nasal_detail.hxx" #include "from_nasal_detail.hxx"
#include "NasalHash.hxx" #include "NasalHash.hxx"
#include <simgear/misc/sg_path.hxx>
namespace nasal namespace nasal
{ {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -53,6 +55,12 @@ namespace nasal
return std::string(naStr_data(na_str), naStr_len(na_str)); 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*) Hash from_nasal_helper(naContext c, naRef ref, Hash*)
{ {
@@ -31,6 +31,8 @@
#include <typeinfo> // std::bad_cast #include <typeinfo> // std::bad_cast
#include <vector> #include <vector>
class SGPath;
namespace nasal namespace nasal
{ {
class Hash; class Hash;
@@ -75,6 +77,11 @@ namespace nasal
*/ */
std::string from_nasal_helper(naContext c, naRef ref, std::string*); 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 * Convert a Nasal hash to a nasal::Hash
*/ */
+7
View File
@@ -19,6 +19,8 @@
#include "to_nasal.hxx" #include "to_nasal.hxx"
#include "NasalHash.hxx" #include "NasalHash.hxx"
#include <simgear/misc/sg_path.hxx>
namespace nasal namespace nasal
{ {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -53,4 +55,9 @@ namespace nasal
return ref; return ref;
} }
//----------------------------------------------------------------------------
naRef to_nasal(naContext c, const SGPath& path)
{
return to_nasal(c, path.str());
}
} // namespace nasal } // namespace nasal
+4
View File
@@ -30,6 +30,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
class SGPath;
namespace nasal namespace nasal
{ {
class Hash; class Hash;
@@ -60,6 +62,8 @@ namespace nasal
*/ */
naRef to_nasal(naContext c, naRef ref); naRef to_nasal(naContext c, naRef ref);
naRef to_nasal(naContext c, const SGPath& path);
/** /**
* Convert a numeric type to Nasal number * Convert a numeric type to Nasal number
*/ */