]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/nasal-props.cxx
Fix crashes (activating the route-manager) with a default GPS.
[flightgear.git] / src / Scripting / nasal-props.cxx
index ab21f2a24397163d2b13406d7adac87be77ced25..9f309903a11b7401a2b7992a49926bd53da9ab89 100644 (file)
@@ -3,6 +3,9 @@
 #  include "config.h"
 #endif
 
+#include <cstring>
+
+#include <simgear/math/SGMath.hxx>
 #include <simgear/nasal/nasal.h>
 #include <simgear/props/props.hxx>
 
@@ -10,6 +13,8 @@
 
 #include "NasalSys.hxx"
 
+using namespace std;
+
 // Implementation of a Nasal wrapper for the SGPropertyNode class,
 // using the Nasal "ghost" (er... Garbage collection Handle for
 // OutSide Thingy) facility.
@@ -58,21 +63,22 @@ naRef FGNasalSys::propNodeGhost(SGPropertyNode* handle)
 
 static naRef f_getType(naContext c, naRef me, int argc, naRef* args)
 {
-    using namespace simgear::props;
+    using namespace simgear;
     NODEARG();
     const char* t = "unknown";
     switch((*node)->getType()) {
-    case NONE:   t = "NONE";   break;
-    case ALIAS:  t = "ALIAS";  break;
-    case BOOL:   t = "BOOL";   break;
-    case INT:    t = "INT";    break;
-    case LONG:   t = "LONG";   break;
-    case FLOAT:  t = "FLOAT";  break;
-    case DOUBLE: t = "DOUBLE"; break;
-    case STRING: t = "STRING"; break;
-    case UNSPECIFIED: t = "UNSPECIFIED"; break;
-    case VEC3D:  t = "VEC3D";  break;
-    case VEC4D:  t = "VEC4D";  break;
+    case props::NONE:   t = "NONE";   break;
+    case props::ALIAS:  t = "ALIAS";  break;
+    case props::BOOL:   t = "BOOL";   break;
+    case props::INT:    t = "INT";    break;
+    case props::LONG:   t = "LONG";   break;
+    case props::FLOAT:  t = "FLOAT";  break;
+    case props::DOUBLE: t = "DOUBLE"; break;
+    case props::STRING: t = "STRING"; break;
+    case props::UNSPECIFIED: t = "UNSPECIFIED"; break;
+    case props::VEC3D:  t = "VEC3D";  break;
+    case props::VEC4D:  t = "VEC4D";  break;
+    case props::EXTENDED: t = "EXTENDED";  break; // shouldn't happen
     }
     return NASTR(t);
 }
@@ -146,7 +152,7 @@ static naRef f_getIndex(naContext c, naRef me, int argc, naRef* args)
 template<typename T>
 naRef makeVectorFromVec(naContext c, const T& vec)
 {
-    const unsigned num_components
+    const int num_components
         = sizeof(vec.data()) / sizeof(typename T::value_type);
     naRef vector = naNewVector(c);
     naVec_setsize(vector, num_components);
@@ -157,19 +163,19 @@ naRef makeVectorFromVec(naContext c, const T& vec)
 
 static naRef f_getValue(naContext c, naRef me, int argc, naRef* args)
 {
-    using namespace simgear::props;
+    using namespace simgear;
     NODEARG();
     switch((*node)->getType()) {
-    case BOOL:   case INT:
-    case LONG:   case FLOAT:
-    case DOUBLE:
+    case props::BOOL:   case props::INT:
+    case props::LONG:   case props::FLOAT:
+    case props::DOUBLE:
         return naNum((*node)->getDoubleValue());
-    case STRING:
-    case UNSPECIFIED:
+    case props::STRING:
+    case props::UNSPECIFIED:
         return NASTR((*node)->getStringValue());
-    case VEC3D:
+    case props::VEC3D:
         return makeVectorFromVec(c, (*node)->getValue<SGVec3d>());
-    case VEC4D:
+    case props::VEC4D:
         return makeVectorFromVec(c, (*node)->getValue<SGVec4d>());
     default:
         return naNil();
@@ -180,7 +186,7 @@ template<typename T>
 T makeVecFromVector(naRef vector)
 {
     T vec;
-    const unsigned num_components
+    const int num_components
         = sizeof(vec.data()) / sizeof(typename T::value_type);
     int size = naVec_size(vector);