]> git.mxchange.org Git - simgear.git/commitdiff
cppbind: some new methods and safer type check.
authorThomas Geymayer <tomgey@gmail.com>
Thu, 29 May 2014 14:29:02 +0000 (16:29 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Thu, 29 May 2014 14:30:41 +0000 (16:30 +0200)
simgear/nasal/cppbind/NasalCallContext.hxx
simgear/nasal/cppbind/NasalHash.hxx

index 0e5be1663bcd31a99e6d3866228388dcd2679e4f..574fe59edc4a23e7e5e51a94ab9b70bbe5d5a40f 100644 (file)
@@ -38,30 +38,24 @@ namespace nasal
         args(args)
       {}
 
-      bool isNumeric(size_t index) const
-      {
-        return (index < argc && naIsNum(args[index]));
-      }
-
-      bool isString(size_t index) const
-      {
-        return (index < argc && naIsString(args[index]));
-      }
-
-      bool isHash(size_t index) const
-      {
-        return (index < argc && naIsHash(args[index]));
-      }
-
-      bool isVector(size_t index) const
-      {
-        return (index < argc && naIsVector(args[index]));
+#define SG_CTX_CHECK_ARG(name, check)\
+      bool is##name(size_t index) const\
+      {\
+        return (index < argc && naIs##check(args[index]));\
       }
 
-      bool isGhost(size_t index) const
-      {
-        return (index < argc && naIsGhost(args[index]));
-      }
+      SG_CTX_CHECK_ARG(Code,    Code)
+      SG_CTX_CHECK_ARG(CCode,   CCode)
+      SG_CTX_CHECK_ARG(Func,    Func)
+      SG_CTX_CHECK_ARG(Ghost,   Ghost)
+      SG_CTX_CHECK_ARG(Hash,    Hash)
+      SG_CTX_CHECK_ARG(Nil,     Nil)
+      SG_CTX_CHECK_ARG(Numeric, Num)
+      SG_CTX_CHECK_ARG(Scalar,  Scalar)
+      SG_CTX_CHECK_ARG(String,  String)
+      SG_CTX_CHECK_ARG(Vector,  Vector)
+
+#undef SG_CTX_CHECK_ARG
 
       void popFront(size_t num = 1)
       {
index aaf673dd2b7b219db4c3bc463398fac856a5aef3..af3b8faeb76de054e8800f24d224957b0b581194 100644 (file)
@@ -183,7 +183,7 @@ namespace nasal
             _key(key)
           {
             assert(hash);
-            assert(!naIsNil(key));
+            assert(naIsScalar(key));
           }
 
           std::string getKey() const