Advertisement

Linking angelscript into C. Problem when building AS_C_INTERFACE

Started by May 17, 2008 05:35 AM
5 comments, last by MichaelT 16 years, 6 months ago
Hi, I'm new to angelscript. I've been trying several scripting libraries for the last few days and when I saw angelscript's quick reference I thought I had found my little holy grial. But now that I'm trying to link it into a C based program I'm encountering problems. I understood from the manual it was possible to link it into C, after some searching I understood the way of doing it was compiling it with: AS_C_INTERFACE;AS_NO_CLASS_METHODS (and ANGELSCRIPT_EXPORT for the lib linking). Well... angelscript doesn't build when using these. The library headers try to use class methods in the building path with class methods disabled. Could anyone help me here? Does anyone have it linked into a C program? [Edited by - jal_ on May 17, 2008 6:25:27 AM]
I actually started on the same thing, never quite finished (for other reasons) but I made it compile. You only need to patch angelscript.h:
--- /home/ice/downloads/as/2.12/sdk/angelscript/include/angelscript.h	2008-03-23 12:03:10.000000000 -0400+++ angelscript.h	2008-04-15 23:45:10.000000000 -0400@@ -60,6 +60,11 @@ #define ANGELSCRIPT_VERSION_STRING "2.12.0"  // Data types++#ifndef __cplusplus+	#define class struct+	typedef enum {false, true} bool;+#endif  class asIScriptEngine; class asIScriptContext;@@ -69,14 +74,213 @@ class asIObjectType; class asIScriptFunction; class asIBinaryStream;++#ifndef __cplusplus+	typedef struct asIScriptEngine asIScriptEngine;+	typedef struct asIScriptContext asIScriptContext;+	typedef struct asIScriptGeneric asIScriptGeneric;+	typedef struct asIScriptStruct asIScriptStruct;+	typedef struct asIScriptArray asIScriptArray;+	typedef struct asIObjectType asIObjectType;+	typedef struct asIScriptFunction asIScriptFunction;+	typedef struct asIBinaryStream asIBinaryStream;+#endif -enum asEMsgType;+/*enum asEMsgType; enum asEContextState; enum asEExecStrFlags; enum asEEngineProp; enum asECallConvTypes; enum asETypeIdFlags;-enum asEBehaviours;+enum asEBehaviours;*/++// Enumerations and constants++// Engine properties+typedef enum+{+	asEP_ALLOW_UNSAFE_REFERENCES = 1,+	asEP_OPTIMIZE_BYTECODE       = 2,+	asEP_COPY_SCRIPT_SECTIONS    = 3,+} asEEngineProp;++// Calling conventions+typedef enum+{+	asCALL_CDECL            = 0,+	asCALL_STDCALL          = 1,+	asCALL_THISCALL         = 2,+	asCALL_CDECL_OBJLAST    = 3,+	asCALL_CDECL_OBJFIRST   = 4,+	asCALL_GENERIC          = 5,+} asECallConvTypes;++// Object type flags+typedef enum+{+	asOBJ_REF                   = 0x01,+	asOBJ_VALUE                 = 0x02,+	asOBJ_GC                    = 0x04,+	asOBJ_POD                   = 0x08,+	asOBJ_NOHANDLE              = 0x10,+	asOBJ_SCOPED                = 0x20,+	asOBJ_APP_CLASS             = 0x100,+	asOBJ_APP_CLASS_CONSTRUCTOR = 0x200,+	asOBJ_APP_CLASS_DESTRUCTOR  = 0x400,+	asOBJ_APP_CLASS_ASSIGNMENT  = 0x800,+	asOBJ_APP_CLASS_C           = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR),+	asOBJ_APP_CLASS_CD          = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR),+	asOBJ_APP_CLASS_CA          = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),+	asOBJ_APP_CLASS_CDA         = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),+	asOBJ_APP_CLASS_D           = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR),+	asOBJ_APP_CLASS_A           = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_ASSIGNMENT),+	asOBJ_APP_CLASS_DA          = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),+	asOBJ_APP_PRIMITIVE         = 0x1000,+	asOBJ_APP_FLOAT             = 0x2000,+	asOBJ_MASK_VALID_FLAGS      = 0x3F3F,+} asEObjTypeFlags;++// Behaviours+typedef enum+{+	// Value object memory management+	asBEHAVE_CONSTRUCT,+	asBEHAVE_DESTRUCT,++	// Reference object memory management+	asBEHAVE_FACTORY,+	asBEHAVE_ADDREF,+	asBEHAVE_RELEASE,++	// Object operators+	asBEHAVE_VALUE_CAST,+	asBEHAVE_INDEX,+	asBEHAVE_NEGATE,++	// Assignment operators+	asBEHAVE_FIRST_ASSIGN,+	 asBEHAVE_ASSIGNMENT = asBEHAVE_FIRST_ASSIGN,+	 asBEHAVE_ADD_ASSIGN,+	 asBEHAVE_SUB_ASSIGN,+	 asBEHAVE_MUL_ASSIGN,+	 asBEHAVE_DIV_ASSIGN,+	 asBEHAVE_MOD_ASSIGN,+	 asBEHAVE_OR_ASSIGN,+	 asBEHAVE_AND_ASSIGN,+	 asBEHAVE_XOR_ASSIGN,+	 asBEHAVE_SLL_ASSIGN,+	 asBEHAVE_SRL_ASSIGN,+	 asBEHAVE_SRA_ASSIGN,+	asBEHAVE_LAST_ASSIGN = asBEHAVE_SRA_ASSIGN,++	// Global operators+	asBEHAVE_FIRST_DUAL,+	 asBEHAVE_ADD = asBEHAVE_FIRST_DUAL,+	 asBEHAVE_SUBTRACT,+	 asBEHAVE_MULTIPLY,+	 asBEHAVE_DIVIDE,+	 asBEHAVE_MODULO,+	 asBEHAVE_EQUAL,+	 asBEHAVE_NOTEQUAL,+	 asBEHAVE_LESSTHAN,+	 asBEHAVE_GREATERTHAN,+	 asBEHAVE_LEQUAL,+	 asBEHAVE_GEQUAL,+	 asBEHAVE_LOGIC_OR,+	 asBEHAVE_LOGIC_AND,+	 asBEHAVE_BIT_OR,+	 asBEHAVE_BIT_AND,+	 asBEHAVE_BIT_XOR,+	 asBEHAVE_BIT_SLL,+	 asBEHAVE_BIT_SRL,+	 asBEHAVE_BIT_SRA,+	asBEHAVE_LAST_DUAL = asBEHAVE_BIT_SRA,++	// Garbage collection behaviours+	asBEHAVE_FIRST_GC,+	 asBEHAVE_GETREFCOUNT = asBEHAVE_FIRST_GC,+	 asBEHAVE_SETGCFLAG,+	 asBEHAVE_GETGCFLAG,+	 asBEHAVE_ENUMREFS,+	 asBEHAVE_RELEASEREFS,+	asBEHAVE_LAST_GC = asBEHAVE_RELEASEREFS,+} asEBehaviours;++// Return codes+typedef enum+{+	asSUCCESS                              =  0,+	asERROR                                = -1,+	asCONTEXT_ACTIVE                       = -2,+	asCONTEXT_NOT_FINISHED                 = -3,+	asCONTEXT_NOT_PREPARED                 = -4,+	asINVALID_ARG                          = -5,+	asNO_FUNCTION                          = -6,+	asNOT_SUPPORTED                        = -7,+	asINVALID_NAME                         = -8,+	asNAME_TAKEN                           = -9,+	asINVALID_DECLARATION                  = -10,+	asINVALID_OBJECT                       = -11,+	asINVALID_TYPE                         = -12,+	asALREADY_REGISTERED                   = -13,+	asMULTIPLE_FUNCTIONS                   = -14,+	asNO_MODULE                            = -15,+	asNO_GLOBAL_VAR                        = -16,+	asINVALID_CONFIGURATION                = -17,+	asINVALID_INTERFACE                    = -18,+	asCANT_BIND_ALL_FUNCTIONS              = -19,+	asLOWER_ARRAY_DIMENSION_NOT_REGISTERED = -20,+	asWRONG_CONFIG_GROUP                   = -21,+	asCONFIG_GROUP_IS_IN_USE               = -22,+	asILLEGAL_BEHAVIOUR_FOR_TYPE           = -23,+	asWRONG_CALLING_CONV                   = -24,+} asERetCodes;++// Context states+typedef enum+{+    asEXECUTION_FINISHED      = 0,+    asEXECUTION_SUSPENDED     = 1,+    asEXECUTION_ABORTED       = 2,+    asEXECUTION_EXCEPTION     = 3,+    asEXECUTION_PREPARED      = 4,+    asEXECUTION_UNINITIALIZED = 5,+    asEXECUTION_ACTIVE        = 6,+    asEXECUTION_ERROR         = 7,+} asEContextState;++// ExecuteString flags+typedef enum+{+	asEXECSTRING_ONLY_PREPARE	= 1,+	asEXECSTRING_USE_MY_CONTEXT = 2,+} asEExecStrFlags;++// Message types+typedef enum+{+    asMSGTYPE_ERROR       = 0,+    asMSGTYPE_WARNING     = 1,+    asMSGTYPE_INFORMATION = 2,+} asEMsgType;++// Prepare flags+static const int asPREPARE_PREVIOUS = -1;++// Config groups+static const char * const asALL_MODULES = (const char * const)-1;++// Type id flags+typedef enum+{+	asTYPEID_OBJHANDLE      = 0x40000000,+	asTYPEID_HANDLETOCONST  = 0x20000000,+	asTYPEID_MASK_OBJECT    = 0x1C000000,+	asTYPEID_APPOBJECT      = 0x04000000,+	asTYPEID_SCRIPTSTRUCT   = 0x0C000000,+	asTYPEID_SCRIPTARRAY    = 0x10000000,+	asTYPEID_MASK_SEQNBR    = 0x03FFFFFF,+} asETypeIdFlags;  // // asBYTE  =  8 bits@@ -108,14 +312,29 @@ typedef void (*asGENFUNC_t)(asIScriptGeneric *); typedef void *(*asALLOCFUNC_t)(size_t); typedef void (*asFREEFUNC_t)(void *);--#define asFUNCTION(f) asFunctionPtr(f)-#define asFUNCTIONPR(f,p,r) asFunctionPtr((void (*)())((r (*)p)(f)))++#ifdef AS_C_INTERFACE+	#ifdef __cplusplus+		#define asFUNCTION(f) asFunctionPtr(f)+		#define asFUNCTIONPR(f,p,r) asFunctionPtr((void (*)())((r (*)p)(f)))+	#else+		#define asFUNCTION(f) (asFUNCTION_t)(f)+		#define asFUNCTIONPR(f, p, r) asFUNCTION(f)+	#endif+#else+	#define asFUNCTION(f) asFunctionPtr(f)+	#define asFUNCTIONPR(f,p,r) asFunctionPtr((void (*)())((r (*)p)(f)))+#endif  #ifndef AS_NO_CLASS_METHODS -class asCUnknownClass;-typedef void (asCUnknownClass::*asMETHOD_t)();+class asCUnknownClass;++#ifdef __cplusplus+	typedef void (asCUnknownClass::*asMETHOD_t)();+#else+	typedef void *asMETHOD_t;+#endif  struct asSFuncPtr {@@ -142,6 +361,9 @@ 	} ptr; 	asBYTE flag; // 1 = generic, 2 = global func };++#define asMETHOD(c,m) asSMethodPtr<sizeof(void (c::*)())>::Convert((void (c::*)())(&c::m))+#define asMETHODPR(c,m,p,r) asSMethodPtr<sizeof(void (c::*)())>::Convert((r (c::*)p)(&c::m))  #endif @@ -179,9 +401,11 @@   #define AS_API #endif -#ifndef ANGELSCRIPT_DLL_MANUAL_IMPORT+#ifndef ANGELSCRIPT_DLL_MANUAL_IMPORT+#ifdef __cplusplus extern "C"-{+{+#endif 	// Engine 	AS_API asIScriptEngine * asCreateScriptEngine(asDWORD version); 	AS_API const char * asGetLibraryVersion();@@ -221,17 +445,17 @@ 	AS_API int               asEngine_EndConfigGroup(asIScriptEngine *e); 	AS_API int               asEngine_RemoveConfigGroup(asIScriptEngine *e, const char *groupName); 	AS_API int               asEngine_SetConfigGroupModuleAccess(asIScriptEngine *e, const char *groupName, const char *module, bool hasAccess);-	AS_API int               asEngine_AddScriptSection(asIScriptEngine *e, const char *module, const char *name, const char *code, int codeLength, int lineOffset = 0);+	AS_API int               asEngine_AddScriptSection(asIScriptEngine *e, const char *module, const char *name, const char *code, int codeLength, int lineOffset);	/* lineOffset = 0 */ 	AS_API int               asEngine_Build(asIScriptEngine *e, const char *module); 	AS_API int               asEngine_Discard(asIScriptEngine *e, const char *module); 	AS_API int               asEngine_GetFunctionCount(asIScriptEngine *e, const char *module); 	AS_API int               asEngine_GetFunctionIDByIndex(asIScriptEngine *e, const char *module, int index); 	AS_API int               asEngine_GetFunctionIDByName(asIScriptEngine *e, const char *module, const char *name); 	AS_API int               asEngine_GetFunctionIDByDecl(asIScriptEngine *e, const char *module, const char *decl);-	AS_API const char *      asEngine_GetFunctionDeclaration(asIScriptEngine *e, int funcID, int *length = 0);-	AS_API const char *      asEngine_GetFunctionName(asIScriptEngine *e, int funcID, int *length = 0);-	AS_API const char *      asEngine_GetFunctionModule(asIScriptEngine *e, int funcID, int *length = 0);-	AS_API const char *      asEngine_GetFunctionSection(asIScriptEngine *e, int funcID, int *length = 0);+	AS_API const char *      asEngine_GetFunctionDeclaration(asIScriptEngine *e, int funcID, int *length);	/* length = 0 */+	AS_API const char *      asEngine_GetFunctionName(asIScriptEngine *e, int funcID, int *length);	/* length = 0 */+	AS_API const char *      asEngine_GetFunctionModule(asIScriptEngine *e, int funcID, int *length);	/* length = 0 */+	AS_API const char *      asEngine_GetFunctionSection(asIScriptEngine *e, int funcID, int *length);	/* length = 0 */ 	AS_API const asIScriptFunction *asEngine_GetFunctionDescriptorByIndex(asIScriptEngine *e, const char *module, int index); 	AS_API int               asEngine_GetMethodCount(asIScriptEngine *e, int typeId); 	AS_API int               asEngine_GetMethodIDByIndex(asIScriptEngine *e, int typeId, int index);@@ -242,19 +466,19 @@ 	AS_API int               asEngine_GetGlobalVarIDByIndex(asIScriptEngine *e, const char *module, int index); 	AS_API int               asEngine_GetGlobalVarIDByName(asIScriptEngine *e, const char *module, const char *name); 	AS_API int               asEngine_GetGlobalVarIDByDecl(asIScriptEngine *e, const char *module, const char *decl);-	AS_API const char *      asEngine_GetGlobalVarDeclaration(asIScriptEngine *e, int gvarID, int *length = 0);-	AS_API const char *      asEngine_GetGlobalVarName(asIScriptEngine *e, int gvarID, int *length = 0);+	AS_API const char *      asEngine_GetGlobalVarDeclaration(asIScriptEngine *e, int gvarID, int *length);	/* length = 0 */+	AS_API const char *      asEngine_GetGlobalVarName(asIScriptEngine *e, int gvarID, int *length);	/* length = 0 */ 	AS_API void *            asEngine_GetGlobalVarPointer(asIScriptEngine *e, int gvarID); 	AS_API int               asEngine_GetImportedFunctionCount(asIScriptEngine *e, const char *module); 	AS_API int               asEngine_GetImportedFunctionIndexByDecl(asIScriptEngine *e, const char *module, const char *decl);-	AS_API const char *      asEngine_GetImportedFunctionDeclaration(asIScriptEngine *e, const char *module, int importIndex, int *length = 0);-	AS_API const char *      asEngine_GetImportedFunctionSourceModule(asIScriptEngine *e, const char *module, int importIndex, int *length = 0);+	AS_API const char *      asEngine_GetImportedFunctionDeclaration(asIScriptEngine *e, const char *module, int importIndex, int *length);	/* length = 0 */+	AS_API const char *      asEngine_GetImportedFunctionSourceModule(asIScriptEngine *e, const char *module, int importIndex, int *length);	/* length = 0 */ 	AS_API int               asEngine_BindImportedFunction(asIScriptEngine *e, const char *module, int importIndex, int funcID); 	AS_API int               asEngine_UnbindImportedFunction(asIScriptEngine *e, const char *module, int importIndex); 	AS_API int               asEngine_BindAllImportedFunctions(asIScriptEngine *e, const char *module); 	AS_API int               asEngine_UnbindAllImportedFunctions(asIScriptEngine *e, const char *module); 	AS_API int               asEngine_GetTypeIdByDecl(asIScriptEngine *e, const char *module, const char *decl);-	AS_API const char *      asEngine_GetTypeDeclaration(asIScriptEngine *e, int typeId, int *length = 0);+	AS_API const char *      asEngine_GetTypeDeclaration(asIScriptEngine *e, int typeId, int *length);	/* length = 0 */ 	AS_API int               asEngine_GetSizeOfPrimitiveType(asIScriptEngine *e, int typeId); 	AS_API asIObjectType *   asEngine_GetObjectTypeById(asIScriptEngine *e, int typeId); 	AS_API asIObjectType *   asEngine_GetObjectTypeByIndex(asIScriptEngine *e, asUINT index);@@ -267,9 +491,9 @@ 	AS_API void              asEngine_ReleaseScriptObject(asIScriptEngine *e, void *obj, int typeId); 	AS_API void              asEngine_AddRefScriptObject(asIScriptEngine *e, void *obj, int typeId); 	AS_API bool              asEngine_IsHandleCompatibleWithObject(asIScriptEngine *e, void *obj, int objTypeId, int handleTypeId);-	AS_API int               asEngine_CompareScriptObjects(asIScriptEngine *e, bool &result, int behaviour, void *leftObj, void *rightObj, int typeId);+	AS_API int               asEngine_CompareScriptObjects(asIScriptEngine *e, bool *result, int behaviour, void *leftObj, void *rightObj, int typeId);	/* bool &result */ 	AS_API int               asEngine_ExecuteString(asIScriptEngine *e, const char *module, const char *script, asIScriptContext **ctx, asDWORD flags);-	AS_API int               asEngine_GarbageCollect(asIScriptEngine *e, bool doFullCycle = true);+	AS_API int               asEngine_GarbageCollect(asIScriptEngine *e, bool doFullCycle);	/* doFullCycle = true */ 	AS_API int               asEngine_GetObjectsInGarbageCollectorCount(asIScriptEngine *e); 	AS_API void              asEngine_NotifyGarbageCollectorOfNewObject(asIScriptEngine *e, void *obj, int typeId); 	AS_API void              asEngine_GCEnumCallback(asIScriptEngine *e, void *obj);@@ -303,26 +527,26 @@ 	AS_API int              asContext_Execute(asIScriptContext *c); 	AS_API int              asContext_Abort(asIScriptContext *c); 	AS_API int              asContext_Suspend(asIScriptContext *c);-	AS_API int              asContext_GetCurrentLineNumber(asIScriptContext *c, int *column = 0);+	AS_API int              asContext_GetCurrentLineNumber(asIScriptContext *c, int *column);	/* column = 0 */ 	AS_API int              asContext_GetCurrentFunction(asIScriptContext *c); 	AS_API int              asContext_SetException(asIScriptContext *c, const char *string);-	AS_API int              asContext_GetExceptionLineNumber(asIScriptContext *c, int *column = 0);+	AS_API int              asContext_GetExceptionLineNumber(asIScriptContext *c, int *column);	/* column = 0 */ 	AS_API int              asContext_GetExceptionFunction(asIScriptContext *c);-	AS_API const char *     asContext_GetExceptionString(asIScriptContext *c, int *length = 0);-	AS_API int              asContext_SetLineCallback(asIScriptContext *c, asSFuncPtr callback, void *obj, int callConv);+	AS_API const char *     asContext_GetExceptionString(asIScriptContext *c, int *length);	/* length = 0 */+	AS_API int              asContext_SetLineCallback(asIScriptContext *c, struct asSFuncPtr callback, void *obj, int callConv); 	AS_API void             asContext_ClearLineCallback(asIScriptContext *c);-	AS_API int              asContext_SetExceptionCallback(asIScriptContext *c, asSFuncPtr callback, void *obj, int callConv);+	AS_API int              asContext_SetExceptionCallback(asIScriptContext *c, struct asSFuncPtr callback, void *obj, int callConv); 	AS_API void             asContext_ClearExceptionCallback(asIScriptContext *c); 	AS_API int              asContext_GetCallstackSize(asIScriptContext *c); 	AS_API int              asContext_GetCallstackFunction(asIScriptContext *c, int index);-	AS_API int              asContext_GetCallstackLineNumber(asIScriptContext *c, int index, int *column = 0);-	AS_API int              asContext_GetVarCount(asIScriptContext *c, int stackLevel = 0);-	AS_API const char *     asContext_GetVarName(asIScriptContext *c, int varIndex, int *length = 0, int stackLevel = 0);-	AS_API const char *     asContext_GetVarDeclaration(asIScriptContext *c, int varIndex, int *length = 0, int stackLevel = 0);-	AS_API int              asContext_GetVarTypeId(asIScriptContext *c, int varIndex, int stackLevel = -1);-	AS_API void *           asContext_GetVarPointer(asIScriptContext *c, int varIndex, int stackLevel = 0);-	AS_API int              asContext_GetThisTypeId(asIScriptContext *c, int stackLevel = -1);-	AS_API void *           asContext_GetThisPointer(asIScriptContext *c, int stackLevel = -1);+	AS_API int              asContext_GetCallstackLineNumber(asIScriptContext *c, int index, int *column);	/* column = 0 */+	AS_API int              asContext_GetVarCount(asIScriptContext *c, int stackLevel);	/* stackLevel = 0 */+	AS_API const char *     asContext_GetVarName(asIScriptContext *c, int varIndex, int *length, int stackLevel);	/* length = 0, stackLevel = 0 */+	AS_API const char *     asContext_GetVarDeclaration(asIScriptContext *c, int varIndex, int *length, int stackLevel);	/* length = 0, stackLevel = 0 */+	AS_API int              asContext_GetVarTypeId(asIScriptContext *c, int varIndex, int stackLevel);	/* stackLevel = -1 */+	AS_API void *           asContext_GetVarPointer(asIScriptContext *c, int varIndex, int stackLevel);	/* stackLevel = 0 */+	AS_API int              asContext_GetThisTypeId(asIScriptContext *c, int stackLevel);	/* stackLevel = -1 */+	AS_API void *           asContext_GetThisPointer(asIScriptContext *c, int stackLevel);	/* stackLevel = -1 */ 	AS_API void *           asContext_SetUserData(asIScriptContext *c, void *data); 	AS_API void *           asContext_GetUserData(asIScriptContext *c); @@ -385,12 +609,14 @@ 	AS_API bool                 asScriptFunction_IsClassMethod(const asIScriptFunction *f); 	AS_API bool                 asScriptFunction_IsInterfaceMethod(const asIScriptFunction *f); -#endif // AS_C_INTERFACE-}+#endif // AS_C_INTERFACE+#ifdef __cplusplus+}+#endif #endif // ANGELSCRIPT_DLL_MANUAL_IMPORT  // Interface declarations-+#ifdef __cplusplus class asIScriptEngine { public:@@ -700,200 +926,13 @@ public: 	virtual ~asIBinaryStream() {} };--// Enumerations and constants--// Engine properties-enum asEEngineProp-{-	asEP_ALLOW_UNSAFE_REFERENCES = 1,-	asEP_OPTIMIZE_BYTECODE       = 2,-	asEP_COPY_SCRIPT_SECTIONS    = 3,-};--// Calling conventions-enum asECallConvTypes-{-	asCALL_CDECL            = 0,-	asCALL_STDCALL          = 1,-	asCALL_THISCALL         = 2,-	asCALL_CDECL_OBJLAST    = 3,-	asCALL_CDECL_OBJFIRST   = 4,-	asCALL_GENERIC          = 5,-};--// Object type flags-enum asEObjTypeFlags-{-	asOBJ_REF                   = 0x01,-	asOBJ_VALUE                 = 0x02,-	asOBJ_GC                    = 0x04,-	asOBJ_POD                   = 0x08,-	asOBJ_NOHANDLE              = 0x10,-	asOBJ_SCOPED                = 0x20,-	asOBJ_APP_CLASS             = 0x100,-	asOBJ_APP_CLASS_CONSTRUCTOR = 0x200,-	asOBJ_APP_CLASS_DESTRUCTOR  = 0x400,-	asOBJ_APP_CLASS_ASSIGNMENT  = 0x800,-	asOBJ_APP_CLASS_C           = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR),-	asOBJ_APP_CLASS_CD          = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR),-	asOBJ_APP_CLASS_CA          = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),-	asOBJ_APP_CLASS_CDA         = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),-	asOBJ_APP_CLASS_D           = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR),-	asOBJ_APP_CLASS_A           = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_ASSIGNMENT),-	asOBJ_APP_CLASS_DA          = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),-	asOBJ_APP_PRIMITIVE         = 0x1000,-	asOBJ_APP_FLOAT             = 0x2000,-	asOBJ_MASK_VALID_FLAGS      = 0x3F3F,-};--// Behaviours-enum asEBehaviours-{-	// Value object memory management-	asBEHAVE_CONSTRUCT,-	asBEHAVE_DESTRUCT,--	// Reference object memory management-	asBEHAVE_FACTORY,-	asBEHAVE_ADDREF,-	asBEHAVE_RELEASE,--	// Object operators-	asBEHAVE_VALUE_CAST,-	asBEHAVE_INDEX,-	asBEHAVE_NEGATE,--	// Assignment operators-	asBEHAVE_FIRST_ASSIGN,-	 asBEHAVE_ASSIGNMENT = asBEHAVE_FIRST_ASSIGN,-	 asBEHAVE_ADD_ASSIGN,-	 asBEHAVE_SUB_ASSIGN,-	 asBEHAVE_MUL_ASSIGN,-	 asBEHAVE_DIV_ASSIGN,-	 asBEHAVE_MOD_ASSIGN,-	 asBEHAVE_OR_ASSIGN,-	 asBEHAVE_AND_ASSIGN,-	 asBEHAVE_XOR_ASSIGN,-	 asBEHAVE_SLL_ASSIGN,-	 asBEHAVE_SRL_ASSIGN,-	 asBEHAVE_SRA_ASSIGN,-	asBEHAVE_LAST_ASSIGN = asBEHAVE_SRA_ASSIGN,--	// Global operators-	asBEHAVE_FIRST_DUAL,-	 asBEHAVE_ADD = asBEHAVE_FIRST_DUAL,-	 asBEHAVE_SUBTRACT,-	 asBEHAVE_MULTIPLY,-	 asBEHAVE_DIVIDE,-	 asBEHAVE_MODULO,-	 asBEHAVE_EQUAL,-	 asBEHAVE_NOTEQUAL,-	 asBEHAVE_LESSTHAN,-	 asBEHAVE_GREATERTHAN,-	 asBEHAVE_LEQUAL,-	 asBEHAVE_GEQUAL,-	 asBEHAVE_LOGIC_OR,-	 asBEHAVE_LOGIC_AND,-	 asBEHAVE_BIT_OR,-	 asBEHAVE_BIT_AND,-	 asBEHAVE_BIT_XOR,-	 asBEHAVE_BIT_SLL,-	 asBEHAVE_BIT_SRL,-	 asBEHAVE_BIT_SRA,-	asBEHAVE_LAST_DUAL = asBEHAVE_BIT_SRA,--	// Garbage collection behaviours-	asBEHAVE_FIRST_GC,-	 asBEHAVE_GETREFCOUNT = asBEHAVE_FIRST_GC,-	 asBEHAVE_SETGCFLAG,-	 asBEHAVE_GETGCFLAG,-	 asBEHAVE_ENUMREFS,-	 asBEHAVE_RELEASEREFS,-	asBEHAVE_LAST_GC = asBEHAVE_RELEASEREFS,-};--// Return codes-enum asERetCodes-{-	asSUCCESS                              =  0,-	asERROR                                = -1,-	asCONTEXT_ACTIVE                       = -2,-	asCONTEXT_NOT_FINISHED                 = -3,-	asCONTEXT_NOT_PREPARED                 = -4,-	asINVALID_ARG                          = -5,-	asNO_FUNCTION                          = -6,-	asNOT_SUPPORTED                        = -7,-	asINVALID_NAME                         = -8,-	asNAME_TAKEN                           = -9,-	asINVALID_DECLARATION                  = -10,-	asINVALID_OBJECT                       = -11,-	asINVALID_TYPE                         = -12,-	asALREADY_REGISTERED                   = -13,-	asMULTIPLE_FUNCTIONS                   = -14,-	asNO_MODULE                            = -15,-	asNO_GLOBAL_VAR                        = -16,-	asINVALID_CONFIGURATION                = -17,-	asINVALID_INTERFACE                    = -18,-	asCANT_BIND_ALL_FUNCTIONS              = -19,-	asLOWER_ARRAY_DIMENSION_NOT_REGISTERED = -20,-	asWRONG_CONFIG_GROUP                   = -21,-	asCONFIG_GROUP_IS_IN_USE               = -22,-	asILLEGAL_BEHAVIOUR_FOR_TYPE           = -23,-	asWRONG_CALLING_CONV                   = -24,-};--// Context states-enum asEContextState-{-    asEXECUTION_FINISHED      = 0,-    asEXECUTION_SUSPENDED     = 1,-    asEXECUTION_ABORTED       = 2,-    asEXECUTION_EXCEPTION     = 3,-    asEXECUTION_PREPARED      = 4,-    asEXECUTION_UNINITIALIZED = 5,-    asEXECUTION_ACTIVE        = 6,-    asEXECUTION_ERROR         = 7,-};--// ExecuteString flags-enum asEExecStrFlags-{-	asEXECSTRING_ONLY_PREPARE	= 1,-	asEXECSTRING_USE_MY_CONTEXT = 2,-};--// Message types-enum asEMsgType-{-    asMSGTYPE_ERROR       = 0,-    asMSGTYPE_WARNING     = 1,-    asMSGTYPE_INFORMATION = 2,-};--// Prepare flags-const int asPREPARE_PREVIOUS = -1;--// Config groups-const char * const asALL_MODULES = (const char * const)-1;--// Type id flags-enum asETypeIdFlags-{-	asTYPEID_OBJHANDLE      = 0x40000000,-	asTYPEID_HANDLETOCONST  = 0x20000000,-	asTYPEID_MASK_OBJECT    = 0x1C000000,-	asTYPEID_APPOBJECT      = 0x04000000,-	asTYPEID_SCRIPTSTRUCT   = 0x0C000000,-	asTYPEID_SCRIPTARRAY    = 0x10000000,-	asTYPEID_MASK_SEQNBR    = 0x03FFFFFF,-};+#endif  //----------------------------------------------------------------- // Function pointers  // Use our own memset() and memcpy() implementations for better portability-inline void asMemClear(void *_p, int size)+static inline void asMemClear(void *_p, int size) { 	char *p = (char *)_p; 	const char *e = p + size;@@ -901,7 +940,7 @@ 		*p = 0; } -inline void asMemCopy(void *_d, const void *_s, int size)+static inline void asMemCopy(void *_d, const void *_s, int size) { 	char *d = (char *)_d; 	const char *s = (const char *)_s;@@ -911,7 +950,8 @@ }  // Template function to capture all global functions,-// except the ones using the generic calling convention+// except the ones using the generic calling convention+#ifdef __cplusplus template <class T> inline asSFuncPtr asFunctionPtr(T func) {@@ -938,9 +978,10 @@  	return p; }+#endif  #ifndef AS_NO_CLASS_METHODS-+#ifdef __cplusplus // Method pointers  // Declare a dummy class so that we can determine the size of a simple method pointer@@ -1050,6 +1091,7 @@ };  #endif+#endif	// __cplusplus  #endif // AS_NO_CLASS_METHODS


While we're on the subject: how would you deal with strings when interfacing with C? AngelScript offers no built-in string type (unless I'm completely oblivious) and the add_ons/scriptstring.(cpp|h) is just a wrapper for std::string.
Advertisement
Thanks!

I don't know about the strings, I guess with C callbacks. I'm still in my first steps here. I didn't know of the angelscript add_ons code yesterday when I posted this.

I now think I will create a module in C++ to manage angelscript which will only offer handles to the C program, so the module can use that addons code. Not sure yet, I'm still scratching the surface.
I'll take this feedback and improve the C interface. I'll probably write a separate C header file rather than keeping everything in the principal header file.

As for the string type; You ought to be able to use the asBSTR type that I developed in the early days of AngelScript and that is still supported. You'll find the source code for this in the tests/test_feature/source folder.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

For some inexplicable reason I just can't reach your site (Angelcode) for nearly two weeks running. I'm wondering if it is possible to have Angelscript mirrored anywhere else?
No no no no! :)
It's unexplicable to me too. :( I've alerted the GameDev.net staff that hosts my site, but so far they haven't been able to determine the cause. It seems to be their IIS server that's having some trouble.

Here's a direct link to download the latest SDK version:

http://www.angelcode.com/angelscript/sdk/files/angelscript_2.12.0.zip

You can also access the sourceforge SVN at:

http://www.sf.net/projects/angelscript

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Thanks a bunch for the links. I hope the problem will be resolved soon :)
No no no no! :)

This topic is closed to new replies.

Advertisement