1 module as.def; 2 3 enum ANGELSCRIPT_VERSION = 23400; 4 5 extern(C) { 6 struct asIScriptEngine; 7 struct asIScriptModule; 8 struct asIScriptContext; 9 struct asIScriptGeneric; 10 struct asIScriptObject; 11 struct asITypeInfo; 12 struct asIScriptFunction; 13 struct asIBinaryStream; 14 struct asIJITCompiler; 15 struct asIThreadManager; 16 struct asILockableSharedBool; 17 } 18 19 enum asERetCodes { 20 asSUCCESS = 0, 21 asERROR = -1, 22 asCONTEXT_ACTIVE = -2, 23 asCONTEXT_NOT_FINISHED = -3, 24 asCONTEXT_NOT_PREPARED = -4, 25 asINVALID_ARG = -5, 26 asNO_FUNCTION = -6, 27 asNOT_SUPPORTED = -7, 28 asINVALID_NAME = -8, 29 asNAME_TAKEN = -9, 30 asINVALID_DECLARATION = -10, 31 asINVALID_OBJECT = -11, 32 asINVALID_TYPE = -12, 33 asALREADY_REGISTERED = -13, 34 asMULTIPLE_FUNCTIONS = -14, 35 asNO_MODULE = -15, 36 asNO_GLOBAL_VAR = -16, 37 asINVALID_CONFIGURATION = -17, 38 asINVALID_INTERFACE = -18, 39 asCANT_BIND_ALL_FUNCTIONS = -19, 40 asLOWER_ARRAY_DIMENSION_NOT_REGISTERED = -20, 41 asWRONG_CONFIG_GROUP = -21, 42 asCONFIG_GROUP_IS_IN_USE = -22, 43 asILLEGAL_BEHAVIOUR_FOR_TYPE = -23, 44 asWRONG_CALLING_CONV = -24, 45 asBUILD_IN_PROGRESS = -25, 46 asINIT_GLOBAL_VARS_FAILED = -26, 47 asOUT_OF_MEMORY = -27, 48 asMODULE_IS_IN_USE = -28 49 } 50 51 enum asEEngineProp 52 { 53 asEP_ALLOW_UNSAFE_REFERENCES = 1, 54 asEP_OPTIMIZE_BYTECODE = 2, 55 asEP_COPY_SCRIPT_SECTIONS = 3, 56 asEP_MAX_STACK_SIZE = 4, 57 asEP_USE_CHARACTER_LITERALS = 5, 58 asEP_ALLOW_MULTILINE_STRINGS = 6, 59 asEP_ALLOW_IMPLICIT_HANDLE_TYPES = 7, 60 asEP_BUILD_WITHOUT_LINE_CUES = 8, 61 asEP_INIT_GLOBAL_VARS_AFTER_BUILD = 9, 62 asEP_REQUIRE_ENUM_SCOPE = 10, 63 asEP_SCRIPT_SCANNER = 11, 64 asEP_INCLUDE_JIT_INSTRUCTIONS = 12, 65 asEP_STRING_ENCODING = 13, 66 asEP_PROPERTY_ACCESSOR_MODE = 14, 67 asEP_EXPAND_DEF_ARRAY_TO_TMPL = 15, 68 asEP_AUTO_GARBAGE_COLLECT = 16, 69 asEP_DISALLOW_GLOBAL_VARS = 17, 70 asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT = 18, 71 asEP_COMPILER_WARNINGS = 19, 72 asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE = 20, 73 asEP_ALTER_SYNTAX_NAMED_ARGS = 21, 74 asEP_DISABLE_INTEGER_DIVISION = 22, 75 asEP_DISALLOW_EMPTY_LIST_ELEMENTS = 23, 76 asEP_PRIVATE_PROP_AS_PROTECTED = 24, 77 asEP_ALLOW_UNICODE_IDENTIFIERS = 25, 78 asEP_HEREDOC_TRIM_MODE = 26, 79 80 asEP_LAST_PROPERTY 81 } 82 83 84 enum asECallConvTypes 85 { 86 asCALL_CDECL = 0, 87 asCALL_STDCALL = 1, 88 asCALL_THISCALL_ASGLOBAL = 2, 89 asCALL_THISCALL = 3, 90 asCALL_CDECL_OBJLAST = 4, 91 asCALL_CDECL_OBJFIRST = 5, 92 asCALL_GENERIC = 6, 93 asCALL_THISCALL_OBJLAST = 7, 94 asCALL_THISCALL_OBJFIRST = 8, 95 asCALL_DDECL = 9, 96 asCALL_DDECL_OBJLAST = 10, 97 asCALL_DDECL_OBJFIRST = 11, 98 } 99 100 enum asEObjTypeFlags 101 { 102 asOBJ_REF = (1<<0), 103 asOBJ_VALUE = (1<<1), 104 asOBJ_GC = (1<<2), 105 asOBJ_POD = (1<<3), 106 asOBJ_NOHANDLE = (1<<4), 107 asOBJ_SCOPED = (1<<5), 108 asOBJ_TEMPLATE = (1<<6), 109 asOBJ_ASHANDLE = (1<<7), 110 asOBJ_APP_CLASS = (1<<8), 111 asOBJ_APP_CLASS_CONSTRUCTOR = (1<<9), 112 asOBJ_APP_CLASS_DESTRUCTOR = (1<<10), 113 asOBJ_APP_CLASS_ASSIGNMENT = (1<<11), 114 asOBJ_APP_CLASS_COPY_CONSTRUCTOR = (1<<12), 115 asOBJ_APP_CLASS_C = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR), 116 asOBJ_APP_CLASS_CD = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR), 117 asOBJ_APP_CLASS_CA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT), 118 asOBJ_APP_CLASS_CK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_COPY_CONSTRUCTOR), 119 asOBJ_APP_CLASS_CDA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT), 120 asOBJ_APP_CLASS_CDK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_COPY_CONSTRUCTOR), 121 asOBJ_APP_CLASS_CAK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT + asOBJ_APP_CLASS_COPY_CONSTRUCTOR), 122 asOBJ_APP_CLASS_CDAK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT + asOBJ_APP_CLASS_COPY_CONSTRUCTOR), 123 asOBJ_APP_CLASS_D = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR), 124 asOBJ_APP_CLASS_DA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT), 125 asOBJ_APP_CLASS_DK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_COPY_CONSTRUCTOR), 126 asOBJ_APP_CLASS_DAK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT + asOBJ_APP_CLASS_COPY_CONSTRUCTOR), 127 asOBJ_APP_CLASS_A = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_ASSIGNMENT), 128 asOBJ_APP_CLASS_AK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_ASSIGNMENT + asOBJ_APP_CLASS_COPY_CONSTRUCTOR), 129 asOBJ_APP_CLASS_K = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_COPY_CONSTRUCTOR), 130 asOBJ_APP_PRIMITIVE = (1<<13), 131 asOBJ_APP_FLOAT = (1<<14), 132 asOBJ_APP_ARRAY = (1<<15), 133 asOBJ_APP_CLASS_ALLINTS = (1<<16), 134 asOBJ_APP_CLASS_ALLFLOATS = (1<<17), 135 asOBJ_NOCOUNT = (1<<18), 136 asOBJ_APP_CLASS_ALIGN8 = (1<<19), 137 asOBJ_IMPLICIT_HANDLE = (1<<20), 138 asOBJ_MASK_VALID_FLAGS = 0x1FFFFF, 139 // Internal flags 140 asOBJ_SCRIPT_OBJECT = (1<<21), 141 asOBJ_SHARED = (1<<22), 142 asOBJ_NOINHERIT = (1<<23), 143 asOBJ_FUNCDEF = (1<<24), 144 asOBJ_LIST_PATTERN = (1<<25), 145 asOBJ_ENUM = (1<<26), 146 asOBJ_TEMPLATE_SUBTYPE = (1<<27), 147 asOBJ_TYPEDEF = (1<<28), 148 asOBJ_ABSTRACT = (1<<29), 149 asOBJ_APP_ALIGN16 = (1<<30) 150 } 151 152 enum asEBehaviours 153 { 154 // Value object memory management 155 asBEHAVE_CONSTRUCT, 156 asBEHAVE_LIST_CONSTRUCT, 157 asBEHAVE_DESTRUCT, 158 159 // Reference object memory management 160 asBEHAVE_FACTORY, 161 asBEHAVE_LIST_FACTORY, 162 asBEHAVE_ADDREF, 163 asBEHAVE_RELEASE, 164 asBEHAVE_GET_WEAKREF_FLAG, 165 166 // Object operators 167 asBEHAVE_TEMPLATE_CALLBACK, 168 169 // Garbage collection behaviours 170 asBEHAVE_FIRST_GC, 171 asBEHAVE_GETREFCOUNT = asBEHAVE_FIRST_GC, 172 asBEHAVE_SETGCFLAG, 173 asBEHAVE_GETGCFLAG, 174 asBEHAVE_ENUMREFS, 175 asBEHAVE_RELEASEREFS, 176 asBEHAVE_LAST_GC = asBEHAVE_RELEASEREFS, 177 178 asBEHAVE_MAX 179 } 180 181 enum asEContextState 182 { 183 asEXECUTION_FINISHED = 0, 184 asEXECUTION_SUSPENDED = 1, 185 asEXECUTION_ABORTED = 2, 186 asEXECUTION_EXCEPTION = 3, 187 asEXECUTION_PREPARED = 4, 188 asEXECUTION_UNINITIALIZED = 5, 189 asEXECUTION_ACTIVE = 6, 190 asEXECUTION_ERROR = 7 191 } 192 193 enum asEMsgType 194 { 195 asMSGTYPE_ERROR = 0, 196 asMSGTYPE_WARNING = 1, 197 asMSGTYPE_INFORMATION = 2 198 } 199 200 enum asEGCFlags 201 { 202 asGC_FULL_CYCLE = 1, 203 asGC_ONE_STEP = 2, 204 asGC_DESTROY_GARBAGE = 4, 205 asGC_DETECT_GARBAGE = 8 206 } 207 208 enum asETokenClass 209 { 210 asTC_UNKNOWN = 0, 211 asTC_KEYWORD = 1, 212 asTC_VALUE = 2, 213 asTC_IDENTIFIER = 3, 214 asTC_COMMENT = 4, 215 asTC_WHITESPACE = 5 216 } 217 218 enum asETypeIdFlags 219 { 220 asTYPEID_VOID = 0, 221 asTYPEID_BOOL = 1, 222 asTYPEID_INT8 = 2, 223 asTYPEID_INT16 = 3, 224 asTYPEID_INT32 = 4, 225 asTYPEID_INT64 = 5, 226 asTYPEID_UINT8 = 6, 227 asTYPEID_UINT16 = 7, 228 asTYPEID_UINT32 = 8, 229 asTYPEID_UINT64 = 9, 230 asTYPEID_FLOAT = 10, 231 asTYPEID_DOUBLE = 11, 232 asTYPEID_OBJHANDLE = 0x40000000, 233 asTYPEID_HANDLETOCONST = 0x20000000, 234 asTYPEID_MASK_OBJECT = 0x1C000000, 235 asTYPEID_APPOBJECT = 0x04000000, 236 asTYPEID_SCRIPTOBJECT = 0x08000000, 237 asTYPEID_TEMPLATE = 0x10000000, 238 asTYPEID_MASK_SEQNBR = 0x03FFFFFF 239 } 240 241 enum asETypeModifiers 242 { 243 asTM_NONE = 0, 244 asTM_INREF = 1, 245 asTM_OUTREF = 2, 246 asTM_INOUTREF = 3, 247 asTM_CONST = 4 248 } 249 250 enum asEGMFlags 251 { 252 asGM_ONLY_IF_EXISTS = 0, 253 asGM_CREATE_IF_NOT_EXISTS = 1, 254 asGM_ALWAYS_CREATE = 2 255 } 256 257 enum 258 { 259 asCOMP_ADD_TO_MODULE = 1 260 } 261 262 enum asEFuncType 263 { 264 asFUNC_DUMMY =-1, 265 asFUNC_SYSTEM = 0, 266 asFUNC_SCRIPT = 1, 267 asFUNC_INTERFACE = 2, 268 asFUNC_VIRTUAL = 3, 269 asFUNC_FUNCDEF = 4, 270 asFUNC_IMPORTED = 5, 271 asFUNC_DELEGATE = 6 272 } 273 274 alias asBYTE = ubyte; 275 alias asWORD = ushort; 276 alias asDWORD = uint; 277 alias asQWORD = ulong; 278 alias asPWORD = size_t; 279 alias asINT64 = long; 280 alias asBOOL = bool; 281 alias asUINT = uint; 282 283 @system extern(C) { 284 alias asFUNCTION_t = void function(); 285 alias asBINARYREADFUNC_t = int function(void* ptr, asUINT size, void* param); 286 alias asBINARYWRITEFUNC_t = int function(const(void)* ptr, asUINT size, void* param); 287 alias asGENFUNC_t = void function(asIScriptGeneric*); 288 alias asALLOCFUNC_t = void* function(size_t); 289 alias asFREEFUNC_t = void function(void*); 290 alias asCLEANENGINEFUNC_t = void function(asIScriptEngine*); 291 alias asCLEANMODULEFUNC_t = void function(asIScriptModule*); 292 alias asCLEANCONTEXTFUNC_t = void function(asIScriptContext*); 293 alias asCLEANFUNCTIONFUNC_t = void function(asIScriptFunction*); 294 alias asCLEANTYPEINFOFUNC_t = void function(asITypeInfo*); 295 alias asCLEANSCRIPTOBJECTFUNC_t = void function(asIScriptObject*); 296 alias asREQUESTCONTEXTFUNC_t = asIScriptContext* function(asIScriptEngine*, void*); 297 alias asRETURNCONTEXTFUNC_t = void function(asIScriptEngine*, asIScriptContext*, void*); 298 alias asMESSAGECALLBACKFUNC_t = void function(asSMessageInfo* msg, void*); 299 300 alias asGETSTRINGCONSTFUNC_t = void* function(const(char)* data, asUINT length); 301 alias asRELEASESTRINGCONSTFUNC_t = int function(const(void)* str); 302 alias asGETRAWSTRINGDATAFUNC_t = int function(const(void)* str, char* data, asUINT* length); 303 } 304 305 struct asSMessageInfo { 306 const(char)* section; 307 int row; 308 int col; 309 asEMsgType type; 310 const(char)* message; 311 } 312 313 @trusted extern(C) { 314 // Engine 315 asIScriptEngine *asCreateScriptEngine(asDWORD version_); 316 const(char) *asGetLibraryVersion(); 317 const(char) *asGetLibraryOptions(); 318 319 // Context 320 asIScriptContext *asGetActiveContext(); 321 322 // Thread support 323 int asPrepareMultithread(asIThreadManager *externalMgr); 324 void asUnprepareMultithread(); 325 asIThreadManager* asGetThreadManager(); 326 void asAcquireExclusiveLock(); 327 void asReleaseExclusiveLock(); 328 void asAcquireSharedLock(); 329 void asReleaseSharedLock(); 330 int asAtomicInc(ref int value); 331 int asAtomicDec(ref int value); 332 int asThreadCleanup(); 333 334 // Memory management 335 int asSetGlobalMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc); 336 int asResetGlobalMemoryFunctions(); 337 void *asAllocMem(size_t size); 338 void asFreeMem(void *mem); 339 340 // Auxiliary 341 asILockableSharedBool *asCreateLockableSharedBool(); 342 343 /////////////////////////////////////////// 344 // asIBinaryStream 345 asIBinaryStream* asStream_Create(asBINARYREADFUNC_t read, asBINARYWRITEFUNC_t write, void* param); 346 347 /////////////////////////////////////////// 348 // asIScriptEngine 349 350 // Memory management 351 int asEngine_AddRef(asIScriptEngine *e); 352 int asEngine_Release(asIScriptEngine *e); 353 int asEngine_ShutDownAndRelease(asIScriptEngine *e); 354 355 // Engine properties 356 int asEngine_SetEngineProperty(asIScriptEngine *e, asEEngineProp property, asPWORD value); 357 asPWORD asEngine_GetEngineProperty(asIScriptEngine *e, asEEngineProp property); 358 359 // Compiler messages 360 int asEngine_SetMessageCallback(asIScriptEngine *e, asFUNCTION_t callback, void *obj, asDWORD callConv); 361 int asEngine_ClearMessageCallback(asIScriptEngine *e); 362 int asEngine_WriteMessage(asIScriptEngine *e, const(char) *section, int row, int col, asEMsgType type, const(char) *message); 363 364 // JIT Compiler 365 int asEngine_SetJITCompiler(asIScriptEngine *e, asIJITCompiler *compiler); 366 asIJITCompiler * asEngine_GetJITCompiler(asIScriptEngine *e); 367 368 // Global functions 369 int asEngine_RegisterGlobalFunction(asIScriptEngine *e, const(char) *declaration, asFUNCTION_t funcPointer, asDWORD callConv, void *auxiliary); 370 asUINT asEngine_GetGlobalFunctionCount(asIScriptEngine *e); 371 asIScriptFunction* asEngine_GetGlobalFunctionByIndex(asIScriptEngine *e, asUINT index); 372 asIScriptFunction* asEngine_GetGlobalFunctionByDecl(asIScriptEngine *e, const(char) *declaration); 373 374 // Global properties 375 int asEngine_RegisterGlobalProperty(asIScriptEngine *e, const(char) *declaration, void *pointer); 376 asUINT asEngine_GetGlobalPropertyCount(asIScriptEngine *e); 377 int asEngine_GetGlobalPropertyByIndex(asIScriptEngine *e, asUINT index, const(char) **name, const(char) **nameSpace, int *typeId, asBOOL *isConst, const(char) **configGroup, void **pointer, asDWORD *accessMask); 378 int asEngine_GetGlobalPropertyIndexByName(asIScriptEngine *e, const(char) *name); 379 int asEngine_GetGlobalPropertyIndexByDecl(asIScriptEngine *e, const(char) *decl); 380 381 // Object types 382 int asEngine_RegisterObjectType(asIScriptEngine *e, const(char) *name, int byteSize, asDWORD flags); 383 int asEngine_RegisterObjectProperty(asIScriptEngine *e, const(char) *obj, const(char) *declaration, int byteOffset); 384 int asEngine_RegisterObjectMethod(asIScriptEngine *e, const(char) *obj, const(char) *declaration, asFUNCTION_t funcPointer, asDWORD callConv, void *auxiliary); 385 int asEngine_RegisterObjectBehaviour(asIScriptEngine *e, const(char) *datatype, asEBehaviours behaviour, const(char) *declaration, asFUNCTION_t funcPointer, asDWORD callConv, void *auxiliary); 386 int asEngine_RegisterInterface(asIScriptEngine *e, const(char) *name); 387 int asEngine_RegisterInterfaceMethod(asIScriptEngine *e, const(char) *intf, const(char) *declaration); 388 asUINT asEngine_GetObjectTypeCount(asIScriptEngine *e); 389 asITypeInfo * asEngine_GetObjectTypeByIndex(asIScriptEngine *e, asUINT index); 390 391 // String factory 392 int asEngine_RegisterStringFactory(asIScriptEngine *e, const(char) *datatype, asGETSTRINGCONSTFUNC_t getStr, asRELEASESTRINGCONSTFUNC_t releaseStr, asGETRAWSTRINGDATAFUNC_t getRawStr); 393 int asEngine_GetStringFactoryReturnTypeId(asIScriptEngine *e, asDWORD *flags); 394 395 // Default array type 396 int asEngine_RegisterDefaultArrayType(asIScriptEngine *e, const(char) *type); 397 int asEngine_GetDefaultArrayTypeId(asIScriptEngine *e); 398 399 // Enums 400 int asEngine_RegisterEnum(asIScriptEngine *e, const(char) *type); 401 int asEngine_RegisterEnumValue(asIScriptEngine *e, const(char) *type, const(char) *name, int value); 402 asUINT asEngine_GetEnumCount(asIScriptEngine *e); 403 asITypeInfo * asEngine_GetEnumByIndex(asIScriptEngine *e, asUINT index); 404 405 // Funcdefs 406 int asEngine_RegisterFuncdef(asIScriptEngine *e, const(char) *decl); 407 asUINT asEngine_GetFuncdefCount(asIScriptEngine *e); 408 asITypeInfo * asEngine_GetFuncdefByIndex(asIScriptEngine *e, asUINT index); 409 410 // Typedefs 411 int asEngine_RegisterTypedef(asIScriptEngine *e, const(char) *type, const(char) *decl); 412 asUINT asEngine_GetTypedefCount(asIScriptEngine *e); 413 asITypeInfo * asEngine_GetTypedefByIndex(asIScriptEngine *e, asUINT index); 414 415 // Configuration groups 416 int asEngine_BeginConfigGroup(asIScriptEngine *e, const(char) *groupName); 417 int asEngine_EndConfigGroup(asIScriptEngine *e); 418 int asEngine_RemoveConfigGroup(asIScriptEngine *e, const(char) *groupName); 419 asDWORD asEngine_SetDefaultAccessMask(asIScriptEngine *e, asDWORD defaultMask); 420 int asEngine_SetDefaultNamespace(asIScriptEngine *e, const(char) *nameSpace); 421 const(char) * asEngine_GetDefaultNamespace(asIScriptEngine *e); 422 423 // Script modules 424 asIScriptModule * asEngine_GetModule(asIScriptEngine *e, const(char)* module_, asEGMFlags flag); 425 int asEngine_DiscardModule(asIScriptEngine *e, const(char)* module_); 426 asUINT asEngine_GetModuleCount(asIScriptEngine *e); 427 asIScriptModule * asEngine_GetModuleByIndex(asIScriptEngine *e, asUINT index); 428 429 // Script functions 430 asIScriptFunction *asEngine_GetFunctionById(asIScriptEngine *e, int funcId); 431 432 // Type identification 433 int asEngine_GetTypeIdByDecl(asIScriptEngine *e, const(char) *decl); 434 const(char) * asEngine_GetTypeDeclaration(asIScriptEngine *e, int typeId, asBOOL includeNamespace); 435 int asEngine_GetSizeOfPrimitiveType(asIScriptEngine *e, int typeId); 436 asITypeInfo *asEngine_GetTypeInfoById(asIScriptEngine *e, int typeId); 437 asITypeInfo *asEngine_GetTypeInfoByName(asIScriptEngine *e, const(char) *name); 438 asITypeInfo *asEngine_GetTypeInfoByDecl(asIScriptEngine *e, const(char) *decl); 439 440 // Script execution 441 asIScriptContext * asEngine_CreateContext(asIScriptEngine *e); 442 void * asEngine_CreateScriptObject(asIScriptEngine *e, asITypeInfo *type); 443 void * asEngine_CreateScriptObjectCopy(asIScriptEngine *e, void *obj, asITypeInfo *type); 444 void * asEngine_CreateUninitializedScriptObject(asIScriptEngine *e, asITypeInfo *type); 445 asIScriptFunction * asEngine_CreateDelegate(asIScriptEngine *e, asIScriptFunction *func, void *obj); 446 int asEngine_AssignScriptObject(asIScriptEngine *e, void *dstObj, void *srcObj, asITypeInfo *type); 447 void asEngine_ReleaseScriptObject(asIScriptEngine *e, void *obj, asITypeInfo *type); 448 void asEngine_AddRefScriptObject(asIScriptEngine *e, void *obj, asITypeInfo *type); 449 int asEngine_RefCastObject(asIScriptEngine *e, void *obj, asITypeInfo *fromType, asITypeInfo *toType, void **newPtr, bool useOnlyImplicitCast); 450 asILockableSharedBool *asEngine_GetWeakRefFlagOfScriptObject(asIScriptEngine *e, void *obj, asITypeInfo *type); 451 452 // Context pooling 453 asIScriptContext *asEngine_RequestContext(asIScriptEngine *e); 454 void asEngine_ReturnContext(asIScriptEngine *e, asIScriptContext *ctx); 455 int asEngine_SetContextCallbacks(asIScriptEngine *e, asREQUESTCONTEXTFUNC_t requestCtx, asRETURNCONTEXTFUNC_t returnCtx, void *param); 456 457 // String interpretation 458 asETokenClass asEngine_ParseToken(asIScriptEngine *e, const(char) *string, size_t stringLength, asUINT *tokenLength); 459 460 // Garbage collection 461 int asEngine_GarbageCollect(asIScriptEngine *e, asDWORD flags); 462 void asEngine_GetGCStatistics(asIScriptEngine *e, asUINT *currentSize, asUINT *totalDestroyed, asUINT *totalDetected, asUINT *newObjects, asUINT *totalNewDestroyed); 463 int asEngine_NotifyGarbageCollectorOfNewObject(asIScriptEngine *e, void *obj, asITypeInfo *type); 464 int asEngine_GetObjectInGC(asIScriptEngine *e, asUINT idx, asUINT *seqNbr, void **obj, asITypeInfo **type); 465 void asEngine_GCEnumCallback(asIScriptEngine *e, void *obj); 466 467 // User data 468 void * asEngine_SetUserData(asIScriptEngine *e, void *data, asPWORD type); 469 void * asEngine_GetUserData(asIScriptEngine *e, asPWORD type); 470 void asEngine_SetEngineUserDataCleanupCallback(asIScriptEngine *e, asCLEANENGINEFUNC_t callback, asPWORD type); 471 void asEngine_SetModuleUserDataCleanupCallback(asIScriptEngine *e, asCLEANMODULEFUNC_t callback); 472 void asEngine_SetContextUserDataCleanupCallback(asIScriptEngine *e, asCLEANCONTEXTFUNC_t callback); 473 void asEngine_SetFunctionUserDataCleanupCallback(asIScriptEngine *e, asCLEANFUNCTIONFUNC_t callback); 474 void asEngine_SetTypeInfoUserDataCleanupCallback(asIScriptEngine *e, asCLEANTYPEINFOFUNC_t callback, asPWORD type); 475 void asEngine_SetScriptObjectUserDataCleanupCallback(asIScriptEngine *e, asCLEANSCRIPTOBJECTFUNC_t callback, asPWORD type); 476 477 /////////////////////////////////////////// 478 // asIScriptModule 479 480 asIScriptEngine *asModule_GetEngine(asIScriptModule *m); 481 void asModule_SetName(asIScriptModule *m, const(char) *name); 482 const(char) *asModule_GetName(asIScriptModule *m); 483 void asModule_Discard(asIScriptModule *m); 484 485 // Compilation 486 int asModule_AddScriptSection(asIScriptModule *m, const(char) *name, const(char) *code, size_t codeLength, int lineOffset); 487 int asModule_Build(asIScriptModule *m); 488 int asModule_CompileFunction(asIScriptModule *m, const(char) *sectionName, const(char) *code, int lineOffset, asDWORD compileFlags, asIScriptFunction **outFunc); 489 int asModule_CompileGlobalVar(asIScriptModule *m, const(char) *sectionName, const(char) *code, int lineOffset); 490 asDWORD asModule_SetAccessMask(asIScriptModule *m, asDWORD accessMask); 491 int asModule_SetDefaultNamespace(asIScriptModule *m,const(char) *nameSpace); 492 const(char) *asModule_GetDefaultNamespace(asIScriptModule *m); 493 494 // Functions 495 asUINT asModule_GetFunctionCount(asIScriptModule *m); 496 asIScriptFunction *asModule_GetFunctionByIndex(asIScriptModule *m, asUINT index); 497 asIScriptFunction *asModule_GetFunctionByDecl(asIScriptModule *m, const(char) *decl); 498 asIScriptFunction *asModule_GetFunctionByName(asIScriptModule *m, const(char) *name); 499 int asModule_RemoveFunction(asIScriptModule *m, asIScriptFunction *func); 500 501 // Global variables 502 int asModule_ResetGlobalVars(asIScriptModule *m, asIScriptContext *ctx); 503 asUINT asModule_GetGlobalVarCount(asIScriptModule *m); 504 int asModule_GetGlobalVarIndexByName(asIScriptModule *m, const(char) *name); 505 int asModule_GetGlobalVarIndexByDecl(asIScriptModule *m, const(char) *decl); 506 const(char) *asModule_GetGlobalVarDeclaration(asIScriptModule *m, asUINT index, asBOOL includeNamespace); 507 int asModule_GetGlobalVar(asIScriptModule *m, asUINT index, const(char) **name, const(char) **nameSpace, int *typeId, asBOOL *isConst); 508 void *asModule_GetAddressOfGlobalVar(asIScriptModule *m, asUINT index); 509 int asModule_RemoveGlobalVar(asIScriptModule *m, asUINT index); 510 511 // Type identification 512 asUINT asModule_GetObjectTypeCount(asIScriptModule *m); 513 asITypeInfo *asModule_GetObjectTypeByIndex(asIScriptModule *m, asUINT index); 514 int asModule_GetTypeIdByDecl(asIScriptModule *m, const(char) *decl); 515 asITypeInfo *asModule_GetTypeInfoByName(asIScriptModule *m, const(char) *name); 516 asITypeInfo *asModule_GetTypeInfoByDecl(asIScriptModule *m, const(char) *decl); 517 518 // Enums 519 asUINT asModule_GetEnumCount(asIScriptModule *m); 520 asITypeInfo * asModule_GetEnumByIndex(asIScriptModule *m, asUINT index); 521 522 // Typedefs 523 asUINT asModule_GetTypedefCount(asIScriptModule *m); 524 asITypeInfo * asModule_GetTypedefByIndex(asIScriptModule *m, asUINT index); 525 526 // Dynamic binding between modules 527 asUINT asModule_GetImportedFunctionCount(asIScriptModule *m); 528 int asModule_GetImportedFunctionIndexByDecl(asIScriptModule *m, const(char) *decl); 529 const(char) *asModule_GetImportedFunctionDeclaration(asIScriptModule *m, asUINT importIndex); 530 const(char) *asModule_GetImportedFunctionSourceModule(asIScriptModule *m, asUINT importIndex); 531 int asModule_BindImportedFunction(asIScriptModule *m, asUINT importIndex, asIScriptFunction *func); 532 int asModule_UnbindImportedFunction(asIScriptModule *m, asUINT importIndex); 533 int asModule_BindAllImportedFunctions(asIScriptModule *m); 534 int asModule_UnbindAllImportedFunctions(asIScriptModule *m); 535 536 // Bytecode saving and loading 537 int asModule_SaveByteCode(asIScriptModule *m, asIBinaryStream* out_, asBOOL stripDebugInfo); 538 int asModule_LoadByteCode(asIScriptModule *m, asIBinaryStream* in_, asBOOL *wasDebugInfoStripped); 539 540 // User data 541 void *asModule_SetUserData(asIScriptModule *m, void *data); 542 void *asModule_GetUserData(asIScriptModule *m); 543 544 /////////////////////////////////////////// 545 // asIScriptContext 546 547 // Memory management 548 int asContext_AddRef(asIScriptContext *c); 549 int asContext_Release(asIScriptContext *c); 550 551 // Miscellaneous 552 asIScriptEngine *asContext_GetEngine(asIScriptContext *c); 553 554 // Execution 555 int asContext_Prepare(asIScriptContext *c, asIScriptFunction *func); 556 int asContext_Unprepare(asIScriptContext *c); 557 int asContext_Execute(asIScriptContext *c); 558 int asContext_Abort(asIScriptContext *c); 559 int asContext_Suspend(asIScriptContext *c); 560 asEContextState asContext_GetState(asIScriptContext *c); 561 int asContext_PushState(asIScriptContext *c); 562 int asContext_PopState(asIScriptContext *c); 563 asBOOL asContext_IsNested(asIScriptContext *c, asUINT *nestCount); 564 565 // Object pointer for calling class methods 566 int asContext_SetObject(asIScriptContext *c, void *obj); 567 568 // Arguments 569 int asContext_SetArgByte(asIScriptContext *c, asUINT arg, asBYTE value); 570 int asContext_SetArgWord(asIScriptContext *c, asUINT arg, asWORD value); 571 int asContext_SetArgDWord(asIScriptContext *c, asUINT arg, asDWORD value); 572 int asContext_SetArgQWord(asIScriptContext *c, asUINT arg, asQWORD value); 573 int asContext_SetArgFloat(asIScriptContext *c, asUINT arg, float value); 574 int asContext_SetArgDouble(asIScriptContext *c, asUINT arg, double value); 575 int asContext_SetArgAddress(asIScriptContext *c, asUINT arg, void *addr); 576 int asContext_SetArgObject(asIScriptContext *c, asUINT arg, void *obj); 577 int asContext_SetArgVarType(asIScriptContext *c, asUINT arg, void *ptr, int typeId); 578 void * asContext_GetAddressOfArg(asIScriptContext *c, asUINT arg); 579 580 // Return value 581 asBYTE asContext_GetReturnByte(asIScriptContext *c); 582 asWORD asContext_GetReturnWord(asIScriptContext *c); 583 asDWORD asContext_GetReturnDWord(asIScriptContext *c); 584 asQWORD asContext_GetReturnQWord(asIScriptContext *c); 585 float asContext_GetReturnFloat(asIScriptContext *c); 586 double asContext_GetReturnDouble(asIScriptContext *c); 587 void * asContext_GetReturnAddress(asIScriptContext *c); 588 void * asContext_GetReturnObject(asIScriptContext *c); 589 void * asContext_GetAddressOfReturnValue(asIScriptContext *c); 590 591 // Exception handling 592 int asContext_SetException(asIScriptContext *c, const(char) *string); 593 int asContext_GetExceptionLineNumber(asIScriptContext *c, int *column, const(char) **sectionName); 594 asIScriptFunction *asContext_GetExceptionFunction(asIScriptContext *c); 595 const(char) * asContext_GetExceptionString(asIScriptContext *c); 596 int asContext_SetExceptionCallback(asIScriptContext *c, asFUNCTION_t callback, void *obj, int callConv); 597 void asContext_ClearExceptionCallback(asIScriptContext *c); 598 599 // Debugging 600 int asContext_SetLineCallback(asIScriptContext *c, asFUNCTION_t callback, void *obj, int callConv); 601 void asContext_ClearLineCallback(asIScriptContext *c); 602 asUINT asContext_GetCallstackSize(asIScriptContext *c); 603 asIScriptFunction *asContext_GetFunction(asIScriptContext *c, asUINT stackLevel); 604 int asContext_GetLineNumber(asIScriptContext *c, asUINT stackLevel, int *column, const(char) **sectionName); 605 int asContext_GetVarCount(asIScriptContext *c, asUINT stackLevel); 606 const(char) * asContext_GetVarName(asIScriptContext *c, asUINT varIndex, asUINT stackLevel); 607 const(char) * asContext_GetVarDeclaration(asIScriptContext *c, asUINT varIndex, asUINT stackLevel, asBOOL includeNamespace); 608 int asContext_GetVarTypeId(asIScriptContext *c, asUINT varIndex, asUINT stackLevel); 609 void * asContext_GetAddressOfVar(asIScriptContext *c, asUINT varIndex, asUINT stackLevel); 610 asBOOL asContext_IsVarInScope(asIScriptContext *c, asUINT varIndex, asUINT stackLevel); 611 int asContext_GetThisTypeId(asIScriptContext *c, asUINT stackLevel); 612 void * asContext_GetThisPointer(asIScriptContext *c, asUINT stackLevel); 613 asIScriptFunction *asContext_GetSystemFunction(asIScriptContext *c); 614 615 // User data 616 void * asContext_SetUserData(asIScriptContext *c, void *data); 617 void * asContext_GetUserData(asIScriptContext *c); 618 619 /////////////////////////////////////////// 620 // asIScriptGeneric 621 622 // Miscellaneous 623 asIScriptEngine *asGeneric_GetEngine(asIScriptGeneric *g); 624 asIScriptFunction *asGeneric_GetFunction(asIScriptGeneric *g); 625 void *asGeneric_GetAuxiliary(asIScriptGeneric *g); 626 627 // Object 628 void * asGeneric_GetObject(asIScriptGeneric *g); 629 int asGeneric_GetObjectTypeId(asIScriptGeneric *g); 630 631 // Arguments 632 int asGeneric_GetArgCount(asIScriptGeneric *g); 633 int asGeneric_GetArgTypeId(asIScriptGeneric *g, asUINT arg, asDWORD *flags); 634 asBYTE asGeneric_GetArgByte(asIScriptGeneric *g, asUINT arg); 635 asWORD asGeneric_GetArgWord(asIScriptGeneric *g, asUINT arg); 636 asDWORD asGeneric_GetArgDWord(asIScriptGeneric *g, asUINT arg); 637 asQWORD asGeneric_GetArgQWord(asIScriptGeneric *g, asUINT arg); 638 float asGeneric_GetArgFloat(asIScriptGeneric *g, asUINT arg); 639 double asGeneric_GetArgDouble(asIScriptGeneric *g, asUINT arg); 640 void * asGeneric_GetArgAddress(asIScriptGeneric *g, asUINT arg); 641 void * asGeneric_GetArgObject(asIScriptGeneric *g, asUINT arg); 642 void * asGeneric_GetAddressOfArg(asIScriptGeneric *g, asUINT arg); 643 644 // Return value 645 int asGeneric_GetReturnTypeId(asIScriptGeneric *g, asDWORD *flags); 646 int asGeneric_SetReturnByte(asIScriptGeneric *g, asBYTE val); 647 int asGeneric_SetReturnWord(asIScriptGeneric *g, asWORD val); 648 int asGeneric_SetReturnDWord(asIScriptGeneric *g, asDWORD val); 649 int asGeneric_SetReturnQWord(asIScriptGeneric *g, asQWORD val); 650 int asGeneric_SetReturnFloat(asIScriptGeneric *g, float val); 651 int asGeneric_SetReturnDouble(asIScriptGeneric *g, double val); 652 int asGeneric_SetReturnAddress(asIScriptGeneric *g, void *addr); 653 int asGeneric_SetReturnObject(asIScriptGeneric *g, void *obj); 654 void * asGeneric_GetAddressOfReturnLocation(asIScriptGeneric *g); 655 656 /////////////////////////////////////////// 657 // asIScriptObject 658 659 // Memory management 660 int asObject_AddRef(asIScriptObject *s); 661 int asObject_Release(asIScriptObject *s); 662 asILockableSharedBool *asObject_GetWeakRefFlag(asIScriptObject *s); 663 664 // Type info 665 int asObject_GetTypeId(asIScriptObject *s); 666 asITypeInfo * asObject_GetObjectType(asIScriptObject *s); 667 668 // Class properties 669 asUINT asObject_GetPropertyCount(asIScriptObject *s); 670 int asObject_GetPropertyTypeId(asIScriptObject *s, asUINT prop); 671 const(char) * asObject_GetPropertyName(asIScriptObject *s, asUINT prop); 672 void * asObject_GetAddressOfProperty(asIScriptObject *s, asUINT prop); 673 674 // Miscellaneous 675 asIScriptEngine *asObject_GetEngine(asIScriptObject *s); 676 int asObject_CopyFrom(asIScriptObject *s, asIScriptObject *other); 677 678 // User data 679 void *asObject_SetUserData(asIScriptObject *s, void *data, asPWORD type); 680 void *asObject_GetUserData(asIScriptObject *s, asPWORD type); 681 682 /////////////////////////////////////////// 683 // asITypeInfo 684 685 // Miscellaneous 686 asIScriptEngine *asTypeInfo_GetEngine(asITypeInfo *o); 687 const(char) *asTypeInfo_GetConfigGroup(asITypeInfo *o); 688 asDWORD asTypeInfo_GetAccessMask(asITypeInfo *o); 689 asIScriptModule *asTypeInfo_GetModule(asITypeInfo *o); 690 691 // Memory management 692 int asTypeInfo_AddRef(const asITypeInfo *o); 693 int asTypeInfo_Release(const asITypeInfo *o); 694 695 // Type info 696 const(char) *asTypeInfo_GetName(const asITypeInfo *o); 697 const(char) *asTypeInfo_GetNamespace(const asITypeInfo *o); 698 asITypeInfo *asTypeInfo_GetBaseType(const asITypeInfo *o); 699 asBOOL asTypeInfo_DerivesFrom(const asITypeInfo *o, const asITypeInfo *objType); 700 asDWORD asTypeInfo_GetFlags(const asITypeInfo *o); 701 asUINT asTypeInfo_GetSize(const asITypeInfo *o); 702 int asTypeInfo_GetTypeId(const asITypeInfo *o); 703 int asTypeInfo_GetSubTypeId(const asITypeInfo *o, asUINT subTypeIndex); 704 asITypeInfo *asTypeInfo_GetSubType(const asITypeInfo *o, asUINT subTypeIndex); 705 asUINT asTypeInfo_GetSubTypeCount(const asITypeInfo *o); 706 707 // Interfaces 708 asUINT asTypeInfo_GetInterfaceCount(const asITypeInfo *o); 709 asITypeInfo *asTypeInfo_GetInterface(const asITypeInfo *o, asUINT index); 710 asBOOL asTypeInfo_Implements(const asITypeInfo *o, const asITypeInfo *objType); 711 712 // Factories 713 asUINT asTypeInfo_GetFactoryCount(const asITypeInfo *o); 714 asIScriptFunction *asTypeInfo_GetFactoryByIndex(const asITypeInfo *o, asUINT index); 715 asIScriptFunction *asTypeInfo_GetFactoryByDecl(const asITypeInfo *o, const(char) *decl); 716 717 // Methods 718 asUINT asTypeInfo_GetMethodCount(const asITypeInfo *o); 719 asIScriptFunction *asTypeInfo_GetMethodByIndex(const asITypeInfo *o, asUINT index, asBOOL getVirtual); 720 asIScriptFunction *asTypeInfo_GetMethodByName(const asITypeInfo *o, const(char) *name, asBOOL getVirtual); 721 asIScriptFunction *asTypeInfo_GetMethodByDecl(const asITypeInfo *o, const(char) *decl, asBOOL getVirtual); 722 723 // Properties 724 asUINT asTypeInfo_GetPropertyCount(const asITypeInfo *o); 725 int asTypeInfo_GetProperty(const asITypeInfo *o, asUINT index, const(char) **name, int *typeId, asBOOL *isPrivate, asBOOL *isProtected, int *offset, asBOOL *isReference, asDWORD *accessMask); 726 const(char) *asTypeInfo_GetPropertyDeclaration(const asITypeInfo *o, asUINT index); 727 728 // Behaviours 729 asUINT asTypeInfo_GetBehaviourCount(const asITypeInfo *o); 730 asIScriptFunction *asTypeInfo_GetBehaviourByIndex(const asITypeInfo *o, asUINT index, asEBehaviours *outBehaviour); 731 732 // Child types 733 asUINT asTypeInfo_GetChildFuncdefCount(asITypeInfo *o); 734 asITypeInfo *asTypeInfo_GetChildFuncdef(asITypeInfo *o, asUINT index); 735 asITypeInfo *asTypeInfo_GetParentType(asITypeInfo *o); 736 737 // Enums 738 asUINT asTypeInfo_GetEnumValueCount(asITypeInfo *o); 739 const(char) *asTypeInfo_GetEnumValueByIndex(asITypeInfo *o, asUINT index, int *outValue); 740 741 // Typedef 742 int asTypeInfo_GetTypedefTypeId(asITypeInfo *o); 743 744 // Funcdef 745 asIScriptFunction *asTypeInfo_GetFuncdefSignature(asITypeInfo *o); 746 747 // User data 748 void *asTypeInfo_SetUserData(asITypeInfo *o, void *data, asPWORD type); 749 void *asTypeInfo_GetUserData(asITypeInfo *o, asPWORD type); 750 751 752 /////////////////////////////////////////// 753 // asIScriptFunction 754 755 asIScriptEngine *asFunction_GetEngine(const asIScriptFunction *f); 756 757 // Memory management 758 int asFunction_AddRef(const asIScriptFunction *f); 759 int asFunction_Release(const asIScriptFunction *f); 760 761 // Miscellaneous 762 int asFunction_GetId(const asIScriptFunction *f); 763 asEFuncType asFunction_GetFuncType(const asIScriptFunction *f); 764 const(char) *asFunction_GetModuleName(const asIScriptFunction *f); 765 asIScriptModule *asFunction_GetModule(const asIScriptFunction *f); 766 const(char) *asFunction_GetScriptSectionName(const asIScriptFunction *f); 767 const(char) *asFunction_GetConfigGroup(const asIScriptFunction *f); 768 asDWORD asFunction_GetAccessMask(const asIScriptFunction *f); 769 void *asFunction_GetAuxiliary(const asIScriptFunction *f); 770 771 // Function signature 772 asITypeInfo *asFunction_GetObjectType(const asIScriptFunction *f); 773 const(char) *asFunction_GetObjectName(const asIScriptFunction *f); 774 const(char) *asFunction_GetName(const asIScriptFunction *f); 775 const(char) *asFunction_GetNamespace(const asIScriptFunction *f); 776 const(char) *asFunction_GetDeclaration(const asIScriptFunction *f, asBOOL includeObjectName, asBOOL includeNamespace); 777 asBOOL asFunction_IsReadOnly(const asIScriptFunction *f); 778 asBOOL asFunction_IsPrivate(const asIScriptFunction *f); 779 asBOOL asFunction_IsProtected(const asIScriptFunction *f); 780 asBOOL asFunction_IsFinal(const asIScriptFunction *f); 781 asBOOL asFunction_IsOverride(const asIScriptFunction *f); 782 asBOOL asFunction_IsShared(const asIScriptFunction *f); 783 asUINT asFunction_GetParamCount(const asIScriptFunction *f); 784 int asFunction_GetParam(const asIScriptFunction *f, asUINT index, int *typeId, asDWORD *flags, const(char) **name, const(char) **defaultArg); 785 int asFunction_GetReturnTypeId(const asIScriptFunction *f); 786 787 // Type id for function pointers 788 int asFunction_GetTypeId(const asIScriptFunction *f); 789 asBOOL asFunction_IsCompatibleWithTypeId(const asIScriptFunction *f, int typeId); 790 791 // Delegates 792 void *asFunction_GetDelegateObject(const asIScriptFunction *f); 793 asITypeInfo *asFunction_GetDelegateObjectType(const asIScriptFunction *f); 794 asIScriptFunction *asFunction_GetDelegateFunction(const asIScriptFunction *f); 795 796 // Debug information 797 asUINT asFunction_GetVarCount(const asIScriptFunction *f); 798 int asFunction_GetVar(const asIScriptFunction *f, asUINT index, const(char) **name, int *typeId); 799 const(char) * asFunction_GetVarDecl(const asIScriptFunction *f, asUINT index, asBOOL includeNamespace); 800 int asFunction_FindNextLineWithCode(const asIScriptFunction *f, int line); 801 802 // For JIT compilation 803 asDWORD *asFunction_GetByteCode(asIScriptFunction *f, asUINT *length); 804 805 // User data 806 void *asFunction_SetUserData(asIScriptFunction *f, void *userData); 807 void *asFunction_GetUserData(const asIScriptFunction *f); 808 }