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 enum DCallConv = asECallConvTypes.asCALL_CDECL; 84 enum DCallConvClass = asECallConvTypes.asCALL_CDECL_OBJLAST; 85 enum DCallConvClassR = asECallConvTypes.asCALL_CDECL_OBJFIRST; 86 87 enum asECallConvTypes 88 { 89 asCALL_CDECL = 0, 90 asCALL_STDCALL = 1, 91 asCALL_THISCALL_ASGLOBAL = 2, 92 asCALL_THISCALL = 3, 93 asCALL_CDECL_OBJLAST = 4, 94 asCALL_CDECL_OBJFIRST = 5, 95 asCALL_GENERIC = 6, 96 asCALL_THISCALL_OBJLAST = 7, 97 asCALL_THISCALL_OBJFIRST = 8 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 = void function(void* ptr, asUINT size, void* param); 286 alias asBINARYWRITEFUNC_t = void 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 // asIScriptEngine 345 346 // Memory management 347 int asEngine_AddRef(asIScriptEngine *e); 348 int asEngine_Release(asIScriptEngine *e); 349 int asEngine_ShutDownAndRelease(asIScriptEngine *e); 350 351 // Engine properties 352 int asEngine_SetEngineProperty(asIScriptEngine *e, asEEngineProp property, asPWORD value); 353 asPWORD asEngine_GetEngineProperty(asIScriptEngine *e, asEEngineProp property); 354 355 // Compiler messages 356 int asEngine_SetMessageCallback(asIScriptEngine *e, asFUNCTION_t callback, void *obj, asDWORD callConv); 357 int asEngine_ClearMessageCallback(asIScriptEngine *e); 358 int asEngine_WriteMessage(asIScriptEngine *e, const(char) *section, int row, int col, asEMsgType type, const(char) *message); 359 360 // JIT Compiler 361 int asEngine_SetJITCompiler(asIScriptEngine *e, asIJITCompiler *compiler); 362 asIJITCompiler * asEngine_GetJITCompiler(asIScriptEngine *e); 363 364 // Global functions 365 int asEngine_RegisterGlobalFunction(asIScriptEngine *e, const(char) *declaration, asFUNCTION_t funcPointer, asDWORD callConv, void *auxiliary); 366 asUINT asEngine_GetGlobalFunctionCount(asIScriptEngine *e); 367 asIScriptFunction* asEngine_GetGlobalFunctionByIndex(asIScriptEngine *e, asUINT index); 368 asIScriptFunction* asEngine_GetGlobalFunctionByDecl(asIScriptEngine *e, const(char) *declaration); 369 370 // Global properties 371 int asEngine_RegisterGlobalProperty(asIScriptEngine *e, const(char) *declaration, void *pointer); 372 asUINT asEngine_GetGlobalPropertyCount(asIScriptEngine *e); 373 int asEngine_GetGlobalPropertyByIndex(asIScriptEngine *e, asUINT index, const(char) **name, const(char) **nameSpace, int *typeId, asBOOL *isConst, const(char) **configGroup, void **pointer, asDWORD *accessMask); 374 int asEngine_GetGlobalPropertyIndexByName(asIScriptEngine *e, const(char) *name); 375 int asEngine_GetGlobalPropertyIndexByDecl(asIScriptEngine *e, const(char) *decl); 376 377 // Object types 378 int asEngine_RegisterObjectType(asIScriptEngine *e, const(char) *name, int byteSize, asDWORD flags); 379 int asEngine_RegisterObjectProperty(asIScriptEngine *e, const(char) *obj, const(char) *declaration, int byteOffset); 380 int asEngine_RegisterObjectMethod(asIScriptEngine *e, const(char) *obj, const(char) *declaration, asFUNCTION_t funcPointer, asDWORD callConv, void *auxiliary); 381 int asEngine_RegisterObjectBehaviour(asIScriptEngine *e, const(char) *datatype, asEBehaviours behaviour, const(char) *declaration, asFUNCTION_t funcPointer, asDWORD callConv, void *auxiliary); 382 int asEngine_RegisterInterface(asIScriptEngine *e, const(char) *name); 383 int asEngine_RegisterInterfaceMethod(asIScriptEngine *e, const(char) *intf, const(char) *declaration); 384 asUINT asEngine_GetObjectTypeCount(asIScriptEngine *e); 385 asITypeInfo * asEngine_GetObjectTypeByIndex(asIScriptEngine *e, asUINT index); 386 387 // String factory 388 int asEngine_RegisterStringFactory(asIScriptEngine *e, const(char) *datatype, asGETSTRINGCONSTFUNC_t getStr, asRELEASESTRINGCONSTFUNC_t releaseStr, asGETRAWSTRINGDATAFUNC_t getRawStr); 389 int asEngine_GetStringFactoryReturnTypeId(asIScriptEngine *e, asDWORD *flags); 390 391 // Default array type 392 int asEngine_RegisterDefaultArrayType(asIScriptEngine *e, const(char) *type); 393 int asEngine_GetDefaultArrayTypeId(asIScriptEngine *e); 394 395 // Enums 396 int asEngine_RegisterEnum(asIScriptEngine *e, const(char) *type); 397 int asEngine_RegisterEnumValue(asIScriptEngine *e, const(char) *type, const(char) *name, int value); 398 asUINT asEngine_GetEnumCount(asIScriptEngine *e); 399 asITypeInfo * asEngine_GetEnumByIndex(asIScriptEngine *e, asUINT index); 400 401 // Funcdefs 402 int asEngine_RegisterFuncdef(asIScriptEngine *e, const(char) *decl); 403 asUINT asEngine_GetFuncdefCount(asIScriptEngine *e); 404 asITypeInfo * asEngine_GetFuncdefByIndex(asIScriptEngine *e, asUINT index); 405 406 // Typedefs 407 int asEngine_RegisterTypedef(asIScriptEngine *e, const(char) *type, const(char) *decl); 408 asUINT asEngine_GetTypedefCount(asIScriptEngine *e); 409 asITypeInfo * asEngine_GetTypedefByIndex(asIScriptEngine *e, asUINT index); 410 411 // Configuration groups 412 int asEngine_BeginConfigGroup(asIScriptEngine *e, const(char) *groupName); 413 int asEngine_EndConfigGroup(asIScriptEngine *e); 414 int asEngine_RemoveConfigGroup(asIScriptEngine *e, const(char) *groupName); 415 asDWORD asEngine_SetDefaultAccessMask(asIScriptEngine *e, asDWORD defaultMask); 416 int asEngine_SetDefaultNamespace(asIScriptEngine *e, const(char) *nameSpace); 417 const(char) * asEngine_GetDefaultNamespace(asIScriptEngine *e); 418 419 // Script modules 420 asIScriptModule * asEngine_GetModule(asIScriptEngine *e, const(char)* module_, asEGMFlags flag); 421 int asEngine_DiscardModule(asIScriptEngine *e, const(char)* module_); 422 asUINT asEngine_GetModuleCount(asIScriptEngine *e); 423 asIScriptModule * asEngine_GetModuleByIndex(asIScriptEngine *e, asUINT index); 424 425 // Script functions 426 asIScriptFunction *asEngine_GetFunctionById(asIScriptEngine *e, int funcId); 427 428 // Type identification 429 int asEngine_GetTypeIdByDecl(asIScriptEngine *e, const(char) *decl); 430 const(char) * asEngine_GetTypeDeclaration(asIScriptEngine *e, int typeId, asBOOL includeNamespace); 431 int asEngine_GetSizeOfPrimitiveType(asIScriptEngine *e, int typeId); 432 asITypeInfo *asEngine_GetTypeInfoById(asIScriptEngine *e, int typeId); 433 asITypeInfo *asEngine_GetTypeInfoByName(asIScriptEngine *e, const(char) *name); 434 asITypeInfo *asEngine_GetTypeInfoByDecl(asIScriptEngine *e, const(char) *decl); 435 436 // Script execution 437 asIScriptContext * asEngine_CreateContext(asIScriptEngine *e); 438 void * asEngine_CreateScriptObject(asIScriptEngine *e, asITypeInfo *type); 439 void * asEngine_CreateScriptObjectCopy(asIScriptEngine *e, void *obj, asITypeInfo *type); 440 void * asEngine_CreateUninitializedScriptObject(asIScriptEngine *e, asITypeInfo *type); 441 asIScriptFunction * asEngine_CreateDelegate(asIScriptEngine *e, asIScriptFunction *func, void *obj); 442 int asEngine_AssignScriptObject(asIScriptEngine *e, void *dstObj, void *srcObj, asITypeInfo *type); 443 void asEngine_ReleaseScriptObject(asIScriptEngine *e, void *obj, asITypeInfo *type); 444 void asEngine_AddRefScriptObject(asIScriptEngine *e, void *obj, asITypeInfo *type); 445 int asEngine_RefCastObject(asIScriptEngine *e, void *obj, asITypeInfo *fromType, asITypeInfo *toType, void **newPtr, bool useOnlyImplicitCast); 446 asILockableSharedBool *asEngine_GetWeakRefFlagOfScriptObject(asIScriptEngine *e, void *obj, asITypeInfo *type); 447 448 // Context pooling 449 asIScriptContext *asEngine_RequestContext(asIScriptEngine *e); 450 void asEngine_ReturnContext(asIScriptEngine *e, asIScriptContext *ctx); 451 int asEngine_SetContextCallbacks(asIScriptEngine *e, asREQUESTCONTEXTFUNC_t requestCtx, asRETURNCONTEXTFUNC_t returnCtx, void *param); 452 453 // String interpretation 454 asETokenClass asEngine_ParseToken(asIScriptEngine *e, const(char) *string, size_t stringLength, asUINT *tokenLength); 455 456 // Garbage collection 457 int asEngine_GarbageCollect(asIScriptEngine *e, asDWORD flags); 458 void asEngine_GetGCStatistics(asIScriptEngine *e, asUINT *currentSize, asUINT *totalDestroyed, asUINT *totalDetected, asUINT *newObjects, asUINT *totalNewDestroyed); 459 int asEngine_NotifyGarbageCollectorOfNewObject(asIScriptEngine *e, void *obj, asITypeInfo *type); 460 int asEngine_GetObjectInGC(asIScriptEngine *e, asUINT idx, asUINT *seqNbr, void **obj, asITypeInfo **type); 461 void asEngine_GCEnumCallback(asIScriptEngine *e, void *obj); 462 463 // User data 464 void * asEngine_SetUserData(asIScriptEngine *e, void *data, asPWORD type); 465 void * asEngine_GetUserData(asIScriptEngine *e, asPWORD type); 466 void asEngine_SetEngineUserDataCleanupCallback(asIScriptEngine *e, asCLEANENGINEFUNC_t callback, asPWORD type); 467 void asEngine_SetModuleUserDataCleanupCallback(asIScriptEngine *e, asCLEANMODULEFUNC_t callback); 468 void asEngine_SetContextUserDataCleanupCallback(asIScriptEngine *e, asCLEANCONTEXTFUNC_t callback); 469 void asEngine_SetFunctionUserDataCleanupCallback(asIScriptEngine *e, asCLEANFUNCTIONFUNC_t callback); 470 void asEngine_SetTypeInfoUserDataCleanupCallback(asIScriptEngine *e, asCLEANTYPEINFOFUNC_t callback, asPWORD type); 471 void asEngine_SetScriptObjectUserDataCleanupCallback(asIScriptEngine *e, asCLEANSCRIPTOBJECTFUNC_t callback, asPWORD type); 472 473 /////////////////////////////////////////// 474 // asIScriptModule 475 476 asIScriptEngine *asModule_GetEngine(asIScriptModule *m); 477 void asModule_SetName(asIScriptModule *m, const(char) *name); 478 const(char) *asModule_GetName(asIScriptModule *m); 479 void asModule_Discard(asIScriptModule *m); 480 481 // Compilation 482 int asModule_AddScriptSection(asIScriptModule *m, const(char) *name, const(char) *code, size_t codeLength, int lineOffset); 483 int asModule_Build(asIScriptModule *m); 484 int asModule_CompileFunction(asIScriptModule *m, const(char) *sectionName, const(char) *code, int lineOffset, asDWORD compileFlags, asIScriptFunction **outFunc); 485 int asModule_CompileGlobalVar(asIScriptModule *m, const(char) *sectionName, const(char) *code, int lineOffset); 486 asDWORD asModule_SetAccessMask(asIScriptModule *m, asDWORD accessMask); 487 int asModule_SetDefaultNamespace(asIScriptModule *m,const(char) *nameSpace); 488 const(char) *asModule_GetDefaultNamespace(asIScriptModule *m); 489 490 // Functions 491 asUINT asModule_GetFunctionCount(asIScriptModule *m); 492 asIScriptFunction *asModule_GetFunctionByIndex(asIScriptModule *m, asUINT index); 493 asIScriptFunction *asModule_GetFunctionByDecl(asIScriptModule *m, const(char) *decl); 494 asIScriptFunction *asModule_GetFunctionByName(asIScriptModule *m, const(char) *name); 495 int asModule_RemoveFunction(asIScriptModule *m, asIScriptFunction *func); 496 497 // Global variables 498 int asModule_ResetGlobalVars(asIScriptModule *m, asIScriptContext *ctx); 499 asUINT asModule_GetGlobalVarCount(asIScriptModule *m); 500 int asModule_GetGlobalVarIndexByName(asIScriptModule *m, const(char) *name); 501 int asModule_GetGlobalVarIndexByDecl(asIScriptModule *m, const(char) *decl); 502 const(char) *asModule_GetGlobalVarDeclaration(asIScriptModule *m, asUINT index, asBOOL includeNamespace); 503 int asModule_GetGlobalVar(asIScriptModule *m, asUINT index, const(char) **name, const(char) **nameSpace, int *typeId, asBOOL *isConst); 504 void *asModule_GetAddressOfGlobalVar(asIScriptModule *m, asUINT index); 505 int asModule_RemoveGlobalVar(asIScriptModule *m, asUINT index); 506 507 // Type identification 508 asUINT asModule_GetObjectTypeCount(asIScriptModule *m); 509 asITypeInfo *asModule_GetObjectTypeByIndex(asIScriptModule *m, asUINT index); 510 int asModule_GetTypeIdByDecl(asIScriptModule *m, const(char) *decl); 511 asITypeInfo *asModule_GetTypeInfoByName(asIScriptModule *m, const(char) *name); 512 asITypeInfo *asModule_GetTypeInfoByDecl(asIScriptModule *m, const(char) *decl); 513 514 // Enums 515 asUINT asModule_GetEnumCount(asIScriptModule *m); 516 asITypeInfo * asModule_GetEnumByIndex(asIScriptModule *m, asUINT index); 517 518 // Typedefs 519 asUINT asModule_GetTypedefCount(asIScriptModule *m); 520 asITypeInfo * asModule_GetTypedefByIndex(asIScriptModule *m, asUINT index); 521 522 // Dynamic binding between modules 523 asUINT asModule_GetImportedFunctionCount(asIScriptModule *m); 524 int asModule_GetImportedFunctionIndexByDecl(asIScriptModule *m, const(char) *decl); 525 const(char) *asModule_GetImportedFunctionDeclaration(asIScriptModule *m, asUINT importIndex); 526 const(char) *asModule_GetImportedFunctionSourceModule(asIScriptModule *m, asUINT importIndex); 527 int asModule_BindImportedFunction(asIScriptModule *m, asUINT importIndex, asIScriptFunction *func); 528 int asModule_UnbindImportedFunction(asIScriptModule *m, asUINT importIndex); 529 int asModule_BindAllImportedFunctions(asIScriptModule *m); 530 int asModule_UnbindAllImportedFunctions(asIScriptModule *m); 531 532 // Bytecode saving and loading 533 int asModule_SaveByteCode(asIScriptModule *m, asIBinaryStream* out_, asBOOL stripDebugInfo); 534 int asModule_LoadByteCode(asIScriptModule *m, asIBinaryStream* in_, asBOOL *wasDebugInfoStripped); 535 536 // User data 537 void *asModule_SetUserData(asIScriptModule *m, void *data); 538 void *asModule_GetUserData(asIScriptModule *m); 539 540 /////////////////////////////////////////// 541 // asIScriptContext 542 543 // Memory management 544 int asContext_AddRef(asIScriptContext *c); 545 int asContext_Release(asIScriptContext *c); 546 547 // Miscellaneous 548 asIScriptEngine *asContext_GetEngine(asIScriptContext *c); 549 550 // Execution 551 int asContext_Prepare(asIScriptContext *c, asIScriptFunction *func); 552 int asContext_Unprepare(asIScriptContext *c); 553 int asContext_Execute(asIScriptContext *c); 554 int asContext_Abort(asIScriptContext *c); 555 int asContext_Suspend(asIScriptContext *c); 556 asEContextState asContext_GetState(asIScriptContext *c); 557 int asContext_PushState(asIScriptContext *c); 558 int asContext_PopState(asIScriptContext *c); 559 asBOOL asContext_IsNested(asIScriptContext *c, asUINT *nestCount); 560 561 // Object pointer for calling class methods 562 int asContext_SetObject(asIScriptContext *c, void *obj); 563 564 // Arguments 565 int asContext_SetArgByte(asIScriptContext *c, asUINT arg, asBYTE value); 566 int asContext_SetArgWord(asIScriptContext *c, asUINT arg, asWORD value); 567 int asContext_SetArgDWord(asIScriptContext *c, asUINT arg, asDWORD value); 568 int asContext_SetArgQWord(asIScriptContext *c, asUINT arg, asQWORD value); 569 int asContext_SetArgFloat(asIScriptContext *c, asUINT arg, float value); 570 int asContext_SetArgDouble(asIScriptContext *c, asUINT arg, double value); 571 int asContext_SetArgAddress(asIScriptContext *c, asUINT arg, void *addr); 572 int asContext_SetArgObject(asIScriptContext *c, asUINT arg, void *obj); 573 int asContext_SetArgVarType(asIScriptContext *c, asUINT arg, void *ptr, int typeId); 574 void * asContext_GetAddressOfArg(asIScriptContext *c, asUINT arg); 575 576 // Return value 577 asBYTE asContext_GetReturnByte(asIScriptContext *c); 578 asWORD asContext_GetReturnWord(asIScriptContext *c); 579 asDWORD asContext_GetReturnDWord(asIScriptContext *c); 580 asQWORD asContext_GetReturnQWord(asIScriptContext *c); 581 float asContext_GetReturnFloat(asIScriptContext *c); 582 double asContext_GetReturnDouble(asIScriptContext *c); 583 void * asContext_GetReturnAddress(asIScriptContext *c); 584 void * asContext_GetReturnObject(asIScriptContext *c); 585 void * asContext_GetAddressOfReturnValue(asIScriptContext *c); 586 587 // Exception handling 588 int asContext_SetException(asIScriptContext *c, const(char) *string); 589 int asContext_GetExceptionLineNumber(asIScriptContext *c, int *column, const(char) **sectionName); 590 asIScriptFunction *asContext_GetExceptionFunction(asIScriptContext *c); 591 const(char) * asContext_GetExceptionString(asIScriptContext *c); 592 int asContext_SetExceptionCallback(asIScriptContext *c, asFUNCTION_t callback, void *obj, int callConv); 593 void asContext_ClearExceptionCallback(asIScriptContext *c); 594 595 // Debugging 596 int asContext_SetLineCallback(asIScriptContext *c, asFUNCTION_t callback, void *obj, int callConv); 597 void asContext_ClearLineCallback(asIScriptContext *c); 598 asUINT asContext_GetCallstackSize(asIScriptContext *c); 599 asIScriptFunction *asContext_GetFunction(asIScriptContext *c, asUINT stackLevel); 600 int asContext_GetLineNumber(asIScriptContext *c, asUINT stackLevel, int *column, const(char) **sectionName); 601 int asContext_GetVarCount(asIScriptContext *c, asUINT stackLevel); 602 const(char) * asContext_GetVarName(asIScriptContext *c, asUINT varIndex, asUINT stackLevel); 603 const(char) * asContext_GetVarDeclaration(asIScriptContext *c, asUINT varIndex, asUINT stackLevel, asBOOL includeNamespace); 604 int asContext_GetVarTypeId(asIScriptContext *c, asUINT varIndex, asUINT stackLevel); 605 void * asContext_GetAddressOfVar(asIScriptContext *c, asUINT varIndex, asUINT stackLevel); 606 asBOOL asContext_IsVarInScope(asIScriptContext *c, asUINT varIndex, asUINT stackLevel); 607 int asContext_GetThisTypeId(asIScriptContext *c, asUINT stackLevel); 608 void * asContext_GetThisPointer(asIScriptContext *c, asUINT stackLevel); 609 asIScriptFunction *asContext_GetSystemFunction(asIScriptContext *c); 610 611 // User data 612 void * asContext_SetUserData(asIScriptContext *c, void *data); 613 void * asContext_GetUserData(asIScriptContext *c); 614 615 /////////////////////////////////////////// 616 // asIScriptGeneric 617 618 // Miscellaneous 619 asIScriptEngine *asGeneric_GetEngine(asIScriptGeneric *g); 620 asIScriptFunction *asGeneric_GetFunction(asIScriptGeneric *g); 621 void *asGeneric_GetAuxiliary(asIScriptGeneric *g); 622 623 // Object 624 void * asGeneric_GetObject(asIScriptGeneric *g); 625 int asGeneric_GetObjectTypeId(asIScriptGeneric *g); 626 627 // Arguments 628 int asGeneric_GetArgCount(asIScriptGeneric *g); 629 int asGeneric_GetArgTypeId(asIScriptGeneric *g, asUINT arg, asDWORD *flags); 630 asBYTE asGeneric_GetArgByte(asIScriptGeneric *g, asUINT arg); 631 asWORD asGeneric_GetArgWord(asIScriptGeneric *g, asUINT arg); 632 asDWORD asGeneric_GetArgDWord(asIScriptGeneric *g, asUINT arg); 633 asQWORD asGeneric_GetArgQWord(asIScriptGeneric *g, asUINT arg); 634 float asGeneric_GetArgFloat(asIScriptGeneric *g, asUINT arg); 635 double asGeneric_GetArgDouble(asIScriptGeneric *g, asUINT arg); 636 void * asGeneric_GetArgAddress(asIScriptGeneric *g, asUINT arg); 637 void * asGeneric_GetArgObject(asIScriptGeneric *g, asUINT arg); 638 void * asGeneric_GetAddressOfArg(asIScriptGeneric *g, asUINT arg); 639 640 // Return value 641 int asGeneric_GetReturnTypeId(asIScriptGeneric *g, asDWORD *flags); 642 int asGeneric_SetReturnByte(asIScriptGeneric *g, asBYTE val); 643 int asGeneric_SetReturnWord(asIScriptGeneric *g, asWORD val); 644 int asGeneric_SetReturnDWord(asIScriptGeneric *g, asDWORD val); 645 int asGeneric_SetReturnQWord(asIScriptGeneric *g, asQWORD val); 646 int asGeneric_SetReturnFloat(asIScriptGeneric *g, float val); 647 int asGeneric_SetReturnDouble(asIScriptGeneric *g, double val); 648 int asGeneric_SetReturnAddress(asIScriptGeneric *g, void *addr); 649 int asGeneric_SetReturnObject(asIScriptGeneric *g, void *obj); 650 void * asGeneric_GetAddressOfReturnLocation(asIScriptGeneric *g); 651 652 /////////////////////////////////////////// 653 // asIScriptObject 654 655 // Memory management 656 int asObject_AddRef(asIScriptObject *s); 657 int asObject_Release(asIScriptObject *s); 658 asILockableSharedBool *asObject_GetWeakRefFlag(asIScriptObject *s); 659 660 // Type info 661 int asObject_GetTypeId(asIScriptObject *s); 662 asITypeInfo * asObject_GetObjectType(asIScriptObject *s); 663 664 // Class properties 665 asUINT asObject_GetPropertyCount(asIScriptObject *s); 666 int asObject_GetPropertyTypeId(asIScriptObject *s, asUINT prop); 667 const(char) * asObject_GetPropertyName(asIScriptObject *s, asUINT prop); 668 void * asObject_GetAddressOfProperty(asIScriptObject *s, asUINT prop); 669 670 // Miscellaneous 671 asIScriptEngine *asObject_GetEngine(asIScriptObject *s); 672 int asObject_CopyFrom(asIScriptObject *s, asIScriptObject *other); 673 674 // User data 675 void *asObject_SetUserData(asIScriptObject *s, void *data, asPWORD type); 676 void *asObject_GetUserData(asIScriptObject *s, asPWORD type); 677 678 /////////////////////////////////////////// 679 // asITypeInfo 680 681 // Miscellaneous 682 asIScriptEngine *asTypeInfo_GetEngine(asITypeInfo *o); 683 const(char) *asTypeInfo_GetConfigGroup(asITypeInfo *o); 684 asDWORD asTypeInfo_GetAccessMask(asITypeInfo *o); 685 asIScriptModule *asTypeInfo_GetModule(asITypeInfo *o); 686 687 // Memory management 688 int asTypeInfo_AddRef(const asITypeInfo *o); 689 int asTypeInfo_Release(const asITypeInfo *o); 690 691 // Type info 692 const(char) *asTypeInfo_GetName(const asITypeInfo *o); 693 const(char) *asTypeInfo_GetNamespace(const asITypeInfo *o); 694 asITypeInfo *asTypeInfo_GetBaseType(const asITypeInfo *o); 695 asBOOL asTypeInfo_DerivesFrom(const asITypeInfo *o, const asITypeInfo *objType); 696 asDWORD asTypeInfo_GetFlags(const asITypeInfo *o); 697 asUINT asTypeInfo_GetSize(const asITypeInfo *o); 698 int asTypeInfo_GetTypeId(const asITypeInfo *o); 699 int asTypeInfo_GetSubTypeId(const asITypeInfo *o, asUINT subTypeIndex); 700 asITypeInfo *asTypeInfo_GetSubType(const asITypeInfo *o, asUINT subTypeIndex); 701 asUINT asTypeInfo_GetSubTypeCount(const asITypeInfo *o); 702 703 // Interfaces 704 asUINT asTypeInfo_GetInterfaceCount(const asITypeInfo *o); 705 asITypeInfo *asTypeInfo_GetInterface(const asITypeInfo *o, asUINT index); 706 asBOOL asTypeInfo_Implements(const asITypeInfo *o, const asITypeInfo *objType); 707 708 // Factories 709 asUINT asTypeInfo_GetFactoryCount(const asITypeInfo *o); 710 asIScriptFunction *asTypeInfo_GetFactoryByIndex(const asITypeInfo *o, asUINT index); 711 asIScriptFunction *asTypeInfo_GetFactoryByDecl(const asITypeInfo *o, const(char) *decl); 712 713 // Methods 714 asUINT asTypeInfo_GetMethodCount(const asITypeInfo *o); 715 asIScriptFunction *asTypeInfo_GetMethodByIndex(const asITypeInfo *o, asUINT index, asBOOL getVirtual); 716 asIScriptFunction *asTypeInfo_GetMethodByName(const asITypeInfo *o, const(char) *name, asBOOL getVirtual); 717 asIScriptFunction *asTypeInfo_GetMethodByDecl(const asITypeInfo *o, const(char) *decl, asBOOL getVirtual); 718 719 // Properties 720 asUINT asTypeInfo_GetPropertyCount(const asITypeInfo *o); 721 int asTypeInfo_GetProperty(const asITypeInfo *o, asUINT index, const(char) **name, int *typeId, asBOOL *isPrivate, asBOOL *isProtected, int *offset, asBOOL *isReference, asDWORD *accessMask); 722 const(char) *asTypeInfo_GetPropertyDeclaration(const asITypeInfo *o, asUINT index); 723 724 // Behaviours 725 asUINT asTypeInfo_GetBehaviourCount(const asITypeInfo *o); 726 asIScriptFunction *asTypeInfo_GetBehaviourByIndex(const asITypeInfo *o, asUINT index, asEBehaviours *outBehaviour); 727 728 // Child types 729 asUINT asTypeInfo_GetChildFuncdefCount(asITypeInfo *o); 730 asITypeInfo *asTypeInfo_GetChildFuncdef(asITypeInfo *o, asUINT index); 731 asITypeInfo *asTypeInfo_GetParentType(asITypeInfo *o); 732 733 // Enums 734 asUINT asTypeInfo_GetEnumValueCount(asITypeInfo *o); 735 const(char) *asTypeInfo_GetEnumValueByIndex(asITypeInfo *o, asUINT index, int *outValue); 736 737 // Typedef 738 int asTypeInfo_GetTypedefTypeId(asITypeInfo *o); 739 740 // Funcdef 741 asIScriptFunction *asTypeInfo_GetFuncdefSignature(asITypeInfo *o); 742 743 // User data 744 void *asTypeInfo_SetUserData(asITypeInfo *o, void *data, asPWORD type); 745 void *asTypeInfo_GetUserData(asITypeInfo *o, asPWORD type); 746 747 748 /////////////////////////////////////////// 749 // asIScriptFunction 750 751 asIScriptEngine *asFunction_GetEngine(const asIScriptFunction *f); 752 753 // Memory management 754 int asFunction_AddRef(const asIScriptFunction *f); 755 int asFunction_Release(const asIScriptFunction *f); 756 757 // Miscellaneous 758 int asFunction_GetId(const asIScriptFunction *f); 759 asEFuncType asFunction_GetFuncType(const asIScriptFunction *f); 760 const(char) *asFunction_GetModuleName(const asIScriptFunction *f); 761 asIScriptModule *asFunction_GetModule(const asIScriptFunction *f); 762 const(char) *asFunction_GetScriptSectionName(const asIScriptFunction *f); 763 const(char) *asFunction_GetConfigGroup(const asIScriptFunction *f); 764 asDWORD asFunction_GetAccessMask(const asIScriptFunction *f); 765 void *asFunction_GetAuxiliary(const asIScriptFunction *f); 766 767 // Function signature 768 asITypeInfo *asFunction_GetObjectType(const asIScriptFunction *f); 769 const(char) *asFunction_GetObjectName(const asIScriptFunction *f); 770 const(char) *asFunction_GetName(const asIScriptFunction *f); 771 const(char) *asFunction_GetNamespace(const asIScriptFunction *f); 772 const(char) *asFunction_GetDeclaration(const asIScriptFunction *f, asBOOL includeObjectName, asBOOL includeNamespace); 773 asBOOL asFunction_IsReadOnly(const asIScriptFunction *f); 774 asBOOL asFunction_IsPrivate(const asIScriptFunction *f); 775 asBOOL asFunction_IsProtected(const asIScriptFunction *f); 776 asBOOL asFunction_IsFinal(const asIScriptFunction *f); 777 asBOOL asFunction_IsOverride(const asIScriptFunction *f); 778 asBOOL asFunction_IsShared(const asIScriptFunction *f); 779 asUINT asFunction_GetParamCount(const asIScriptFunction *f); 780 int asFunction_GetParam(const asIScriptFunction *f, asUINT index, int *typeId, asDWORD *flags, const(char) **name, const(char) **defaultArg); 781 int asFunction_GetReturnTypeId(const asIScriptFunction *f); 782 783 // Type id for function pointers 784 int asFunction_GetTypeId(const asIScriptFunction *f); 785 asBOOL asFunction_IsCompatibleWithTypeId(const asIScriptFunction *f, int typeId); 786 787 // Delegates 788 void *asFunction_GetDelegateObject(const asIScriptFunction *f); 789 asITypeInfo *asFunction_GetDelegateObjectType(const asIScriptFunction *f); 790 asIScriptFunction *asFunction_GetDelegateFunction(const asIScriptFunction *f); 791 792 // Debug information 793 asUINT asFunction_GetVarCount(const asIScriptFunction *f); 794 int asFunction_GetVar(const asIScriptFunction *f, asUINT index, const(char) **name, int *typeId); 795 const(char) * asFunction_GetVarDecl(const asIScriptFunction *f, asUINT index, asBOOL includeNamespace); 796 int asFunction_FindNextLineWithCode(const asIScriptFunction *f, int line); 797 798 // For JIT compilation 799 asDWORD *asFunction_GetByteCode(asIScriptFunction *f, asUINT *length); 800 801 // User data 802 void *asFunction_SetUserData(asIScriptFunction *f, void *userData); 803 void *asFunction_GetUserData(const asIScriptFunction *f); 804 }