Fiddling with x86_64 and i486 builds
[tpg/acess2.git] / Usermode / include / spiderscript.h
index 9d15d35..dc62a23 100644 (file)
@@ -13,9 +13,6 @@
  */
 typedef struct sSpiderScript   tSpiderScript;
 
-/**
- * \brief Variant type
- */
 typedef struct sSpiderVariant  tSpiderVariant;
 typedef struct sSpiderFunction tSpiderFunction;
 typedef struct sSpiderValue    tSpiderValue;
@@ -25,15 +22,43 @@ typedef struct sSpiderObject        tSpiderObject;
 
 /**
  * \brief SpiderScript Variable Datatypes
+ * \todo Expand the descriptions
  */
 enum eSpiderScript_DataTypes
 {
-       SS_DATATYPE_UNDEF,      //!< Undefined
-       SS_DATATYPE_NULL,       //!< NULL (Probably will never be used)
-       SS_DATATYPE_DYNAMIC,    //!< Dynamically typed variable (will this be used?)
-       SS_DATATYPE_OBJECT,     //!< Opaque object reference
-       SS_DATATYPE_ARRAY,      //!< Array
-       SS_DATATYPE_INTEGER,    //!< Integer (64-bits)
+       /**
+        * \brief Undefined data
+        * \note Default type of an undefined dynamic variable
+        */
+       SS_DATATYPE_UNDEF,
+       /**
+        * \brief Dynamically typed variable
+        * \note Used to dentote a non-fixed type for function parameters
+        */
+       SS_DATATYPE_DYNAMIC,
+       /**
+        * \brief Opaque Data Pointer
+        * 
+        * Opaque data types are used for resource handles or for system buffers.
+        */
+       SS_DATATYPE_OPAQUE,
+       /**
+        * \brief Object reference
+        * 
+        * A reference to a SpiderScript class instance. Can be accessed
+        * using the -> operator.
+        */
+       SS_DATATYPE_OBJECT,
+       /**
+        * \brief Array data type
+        */
+       SS_DATATYPE_ARRAY,
+       /**
+        * \brief Integer datatype
+        * 
+        * 64-bit integer
+        */
+       SS_DATATYPE_INTEGER,
        SS_DATATYPE_REAL,       //!< Real Number (double)
        SS_DATATYPE_STRING,     //!< String
        NUM_SS_DATATYPES
@@ -46,10 +71,9 @@ struct sSpiderVariant
 {
        const char      *Name;  // Just for debug
        
-        int    bDyamicTyped;
+        int    bDyamicTyped;   //!< Use static typing
        
-        int    NFunctions;     //!< Number of functions
-       tSpiderFunction *Functions;     //!< Functions
+       tSpiderFunction *Functions;     //!< Functions (Linked List)
        
         int    NConstants;     //!< Number of constants
        tSpiderValue    *Constants;     //!< Number of constants
@@ -60,7 +84,7 @@ struct sSpiderVariant
  */
 struct sSpiderValue
 {
-        int    Type;   //!< Variable type
+       enum eSpiderScript_DataTypes    Type;   //!< Variable type
         int    ReferenceCount; //!< Reference count
        
        union {
@@ -81,6 +105,17 @@ struct sSpiderValue
                        tSpiderValue    *Items[];       //!< Array elements (\a Length long)
                }       Array;
                
+               /**
+                * \brief Opaque data
+                */
+               struct {
+                       void    *Data;  //!< Data (can be anywhere)
+                       void    (*Destroy)(void *Data); //!< Called on GC
+               }       Opaque;
+               
+               /**
+                * \brief Object Instance
+                */
                tSpiderObject   *Object;
        };
 };
@@ -92,6 +127,13 @@ struct sSpiderValue
  */
 struct sSpiderObjectDef
 {
+       /**
+        */
+       struct sSpiderObjectDef *Next;  //!< Internal linked list
+       /**
+        * \brief Object type name
+        */
+       const char*     const Name;
        /**
         * \brief Construct an instance of the object
         * \param NArgs Number of arguments
@@ -139,6 +181,11 @@ struct sSpiderObject
  */
 struct sSpiderFunction
 {
+       /**
+        * \brief Next function in list
+        */
+       struct sSpiderFunction  *Next;
+       
        /**
         * \brief Function name
         */
@@ -155,7 +202,7 @@ struct sSpiderFunction
         * parameters, if the final entry is -1, the function has a variable
         * number of arguments.
         */
-        int    *ArgTypes;      // Zero (or -1) terminated array of parameter types
+        int    ArgTypes[];     // Zero (or -1) terminated array of parameter types
 };
 
 
@@ -180,7 +227,22 @@ extern tSpiderValue        *SpiderScript_ExecuteMethod(tSpiderScript *Script,
 
 /**
  * \brief Free a script
+ * \param Script       Script structure to free
  */
 extern void    SpiderScript_Free(tSpiderScript *Script);
 
+/**
+ * \name tSpiderValue Manipulation functions
+ * \{
+ */
+extern tSpiderValue    *SpiderScript_CreateInteger(uint64_t Value);
+extern tSpiderValue    *SpiderScript_CreateReal(double Value);
+extern tSpiderValue    *SpiderScript_CreateString(int Length, const char *Data);
+extern tSpiderValue    *SpiderScript_CastValueTo(int Type, tSpiderValue *Source);
+extern int     SpiderScript_IsValueTrue(tSpiderValue *Value);
+extern char    *SpiderScript_DumpValue(tSpiderValue *Value);
+/**
+ * \}
+ */
+
 #endif

UCC git Repository :: git.ucc.asn.au