]> git.mxchange.org Git - simgear.git/blobdiff - simgear/nasal/nasal.h
Update the code a bit more, add a function to retreive the last error string and...
[simgear.git] / simgear / nasal / nasal.h
index 417ca67d3438959a775e89c164b8bfe45f7eebf9..85fff9661e4a82c519ae5b2bc042109c7c00e4a1 100644 (file)
@@ -4,6 +4,39 @@
 extern "C" {
 #endif
 
+#ifndef BYTE_ORDER
+
+# if (BSD >= 199103)
+#  include <machine/endian.h>
+# elif defined(__CYGWIN__) || defined(__MINGW32__)
+#  include <sys/param.h>
+# elif defined(linux)
+#  include <endian.h>
+# else
+#  ifndef LITTLE_ENDIAN
+#   define LITTLE_ENDIAN   1234    /* LSB first: i386, vax */
+#  endif
+#  ifndef BIG_ENDIAN
+#   define BIG_ENDIAN      4321    /* MSB first: 68000, ibm, net */
+#  endif
+
+#  if defined(ultrix) || defined(__alpha__) || defined(__alpha) ||  \
+      defined(__i386__) || defined(__i486__) || defined(_X86_) ||   \
+      defined(sun386)
+#   define BYTE_ORDER LITTLE_ENDIAN
+#  else
+#   define BYTE_ORDER BIG_ENDIAN
+#  endif
+# endif /* BSD */
+#endif /* BYTE_ORDER */
+
+#if BYTE_ORDER == BIG_ENDIAN
+# include <limits.h>
+# if (LONG_MAX == 2147483647)
+#  define NASAL_BIG_ENDIAN_32_BIT 1
+# endif
+#endif
+
 // This is a nasal "reference".  They are always copied by value, and
 // contain either a pointer to a garbage-collectable nasal object
 // (string, vector, hash) or a floating point number.  Keeping the
@@ -31,6 +64,7 @@ typedef union {
             struct naFunc* func;
             struct naClosure* closure;
             struct naCCode* ccode;
+            struct naGhost* ghost;
         } ptr;
 #ifndef NASAL_BIG_ENDIAN_32_BIT
         int reftag; // Little-endian and 64 bit systems need this here!
@@ -129,6 +163,7 @@ naRef naVec_get(naRef v, int i);
 void naVec_set(naRef vec, int i, naRef o);
 int naVec_append(naRef vec, naRef o);
 naRef naVec_removelast(naRef vec);
+void naVec_setsize(naRef vec, int sz);
 
 // Hash utilities:
 int naHash_size(naRef h);
@@ -139,6 +174,15 @@ void naHash_cset(naRef hash, char* key, naRef val);
 void naHash_delete(naRef hash, naRef key);
 void naHash_keys(naRef dst, naRef hash);
 
+// Ghost utilities:
+typedef struct naGhostType {
+    void (*destroy)(void* ghost);
+} naGhostType;
+naRef        naNewGhost(naContext c, naGhostType* t, void* ghost);
+naGhostType* naGhost_type(naRef ghost);
+void*        naGhost_ptr(naRef ghost);
+int          naIsGhost(naRef r);
+
 #ifdef __cplusplus
 } // extern "C"
 #endif