Update to latest angelscript
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
AngelCode Scripting Library
|
||||
Copyright (c) 2003-2014 Andreas Jonsson
|
||||
Copyright (c) 2003-2015 Andreas Jonsson
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
// Memory management
|
||||
virtual int AddRef() const;
|
||||
virtual int Release() const;
|
||||
virtual int ShutDownAndRelease();
|
||||
|
||||
// Engine properties
|
||||
virtual int SetEngineProperty(asEEngineProp property, asPWORD value);
|
||||
@@ -100,17 +101,18 @@ public:
|
||||
// Type registration
|
||||
virtual int RegisterObjectType(const char *obj, int byteSize, asDWORD flags);
|
||||
virtual int RegisterObjectProperty(const char *obj, const char *declaration, int byteOffset);
|
||||
virtual int RegisterObjectMethod(const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv);
|
||||
virtual int RegisterObjectMethod(const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall = 0);
|
||||
virtual int RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall = 0);
|
||||
virtual int RegisterInterface(const char *name);
|
||||
virtual int RegisterInterfaceMethod(const char *intf, const char *declaration);
|
||||
virtual asUINT GetObjectTypeCount() const;
|
||||
virtual asIObjectType *GetObjectTypeByIndex(asUINT index) const;
|
||||
virtual asIObjectType *GetObjectTypeByName(const char *name) const;
|
||||
virtual asIObjectType *GetObjectTypeByDecl(const char *decl) const;
|
||||
|
||||
// String factory
|
||||
virtual int RegisterStringFactory(const char *datatype, const asSFuncPtr &factoryFunc, asDWORD callConv, void *objForThiscall = 0);
|
||||
virtual int GetStringFactoryReturnTypeId() const;
|
||||
virtual int GetStringFactoryReturnTypeId(asDWORD *flags) const;
|
||||
|
||||
// Default array type
|
||||
virtual int RegisterDefaultArrayType(const char *type);
|
||||
@@ -160,48 +162,45 @@ public:
|
||||
virtual int GetSizeOfPrimitiveType(int typeId) const;
|
||||
|
||||
// Script execution
|
||||
virtual asIScriptContext *CreateContext();
|
||||
virtual asIScriptContext *CreateContext();
|
||||
virtual void *CreateScriptObject(const asIObjectType *type);
|
||||
virtual void *CreateScriptObjectCopy(void *obj, const asIObjectType *type);
|
||||
virtual void *CreateUninitializedScriptObject(const asIObjectType *type);
|
||||
virtual asIScriptFunction *CreateDelegate(asIScriptFunction *func, void *obj);
|
||||
virtual int AssignScriptObject(void *dstObj, void *srcObj, const asIObjectType *type);
|
||||
virtual void ReleaseScriptObject(void *obj, const asIObjectType *type);
|
||||
virtual void AddRefScriptObject(void *obj, const asIObjectType *type);
|
||||
virtual int RefCastObject(void *obj, asIObjectType *fromType, asIObjectType *toType, void **newPtr, bool useOnlyImplicitCast = false);
|
||||
#ifdef AS_DEPRECATED
|
||||
// Deprecated since 2.27.0, 2013-07-18
|
||||
virtual void *CreateScriptObject(int typeId);
|
||||
virtual void *CreateScriptObjectCopy(void *obj, int typeId);
|
||||
virtual void *CreateUninitializedScriptObject(int typeId);
|
||||
virtual void AssignScriptObject(void *dstObj, void *srcObj, int typeId);
|
||||
virtual void ReleaseScriptObject(void *obj, int typeId);
|
||||
virtual void AddRefScriptObject(void *obj, int typeId);
|
||||
// Deprecated since 2.30.0, 2014-11-04
|
||||
virtual bool IsHandleCompatibleWithObject(void *obj, int objTypeId, int handleTypeId) const;
|
||||
#endif
|
||||
virtual void *CreateScriptObject(const asIObjectType *type);
|
||||
virtual void *CreateScriptObjectCopy(void *obj, const asIObjectType *type);
|
||||
virtual void *CreateUninitializedScriptObject(const asIObjectType *type);
|
||||
virtual asIScriptFunction *CreateDelegate(asIScriptFunction *func, void *obj);
|
||||
virtual void AssignScriptObject(void *dstObj, void *srcObj, const asIObjectType *type);
|
||||
virtual void ReleaseScriptObject(void *obj, const asIObjectType *type);
|
||||
virtual void AddRefScriptObject(void *obj, const asIObjectType *type);
|
||||
// TODO: interface: Should have a method void *CastObject(void *obj, asIObjectType *fromType, asIObjectType *toType);
|
||||
// For script objects it should simply check if the object implements or derives from the toType
|
||||
// For application objects it should look for ref cast behaviours and call the matching one
|
||||
// Once implemented the IsHandleCompatibleWithObject should be removed from the engine
|
||||
virtual bool IsHandleCompatibleWithObject(void *obj, int objTypeId, int handleTypeId) const;
|
||||
asILockableSharedBool *GetWeakRefFlagOfScriptObject(void *obj, const asIObjectType *type) const;
|
||||
virtual asILockableSharedBool *GetWeakRefFlagOfScriptObject(void *obj, const asIObjectType *type) const;
|
||||
|
||||
// Context pooling
|
||||
virtual asIScriptContext *RequestContext();
|
||||
virtual void ReturnContext(asIScriptContext *ctx);
|
||||
virtual int SetContextCallbacks(asREQUESTCONTEXTFUNC_t requestCtx, asRETURNCONTEXTFUNC_t returnCtx, void *param = 0);
|
||||
|
||||
// String interpretation
|
||||
virtual asETokenClass ParseToken(const char *string, size_t stringLength = 0, int *tokenLength = 0) const;
|
||||
virtual asETokenClass ParseToken(const char *string, size_t stringLength = 0, asUINT *tokenLength = 0) const;
|
||||
|
||||
// Garbage collection
|
||||
virtual int GarbageCollect(asDWORD flags = asGC_FULL_CYCLE);
|
||||
virtual int GarbageCollect(asDWORD flags = asGC_FULL_CYCLE, asUINT numIterations = 1);
|
||||
virtual void GetGCStatistics(asUINT *currentSize, asUINT *totalDestroyed, asUINT *totalDetected, asUINT *newObjects, asUINT *totalNewDestroyed) const;
|
||||
virtual int NotifyGarbageCollectorOfNewObject(void *obj, asIObjectType *type);
|
||||
virtual int GetObjectInGC(asUINT idx, asUINT *seqNbr, void **obj = 0, asIObjectType **type = 0);
|
||||
virtual void GCEnumCallback(void *reference);
|
||||
|
||||
// User data
|
||||
virtual void *SetUserData(void *data, asPWORD type = 0);
|
||||
virtual void *GetUserData(asPWORD type = 0) const;
|
||||
virtual void SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback, asPWORD type = 0);
|
||||
virtual void SetModuleUserDataCleanupCallback(asCLEANMODULEFUNC_t callback);
|
||||
virtual void SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback);
|
||||
virtual void SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback);
|
||||
virtual void *SetUserData(void *data, asPWORD type);
|
||||
virtual void *GetUserData(asPWORD type) const;
|
||||
virtual void SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback, asPWORD type);
|
||||
virtual void SetModuleUserDataCleanupCallback(asCLEANMODULEFUNC_t callback, asPWORD type);
|
||||
virtual void SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback, asPWORD type);
|
||||
virtual void SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback, asPWORD type);
|
||||
virtual void SetObjectTypeUserDataCleanupCallback(asCLEANOBJECTTYPEFUNC_t callback, asPWORD type);
|
||||
virtual void SetScriptObjectUserDataCleanupCallback(asCLEANSCRIPTOBJECTFUNC_t callback, asPWORD type);
|
||||
|
||||
//===========================================================
|
||||
// internal methods
|
||||
@@ -220,12 +219,12 @@ public:
|
||||
friend class asCByteCode;
|
||||
friend int PrepareSystemFunction(asCScriptFunction *func, asSSystemFunctionInterface *internal, asCScriptEngine *engine);
|
||||
|
||||
int RegisterMethodToObjectType(asCObjectType *objectType, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv);
|
||||
int RegisterMethodToObjectType(asCObjectType *objectType, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall = 0);
|
||||
int RegisterBehaviourToObjectType(asCObjectType *objectType, asEBehaviours behaviour, const char *decl, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall);
|
||||
|
||||
int VerifyVarTypeNotInFunction(asCScriptFunction *func);
|
||||
|
||||
void *CallAlloc(asCObjectType *objType) const;
|
||||
void *CallAlloc(const asCObjectType *objType) const;
|
||||
void CallFree(void *obj) const;
|
||||
|
||||
void *CallGlobalFunctionRetPtr(int func) const;
|
||||
@@ -244,11 +243,10 @@ public:
|
||||
|
||||
void ConstructScriptObjectCopy(void *mem, void *obj, asCObjectType *type);
|
||||
|
||||
void CleanupAfterDiscardModule();
|
||||
void DeleteDiscardedModules();
|
||||
|
||||
int ClearUnusedTypes();
|
||||
void RemoveTemplateInstanceType(asCObjectType *t);
|
||||
void RemoveTypeAndRelatedFromList(asCArray<asCObjectType*> &types, asCObjectType *ot);
|
||||
void RemoveTypeAndRelatedFromList(asCMap<asCObjectType*,char> &types, asCObjectType *ot);
|
||||
|
||||
asCConfigGroup *FindConfigGroupForFunction(int funcId) const;
|
||||
asCConfigGroup *FindConfigGroupForGlobalVar(int gvarId) const;
|
||||
@@ -282,8 +280,9 @@ public:
|
||||
int GetFactoryIdByDecl(const asCObjectType *ot, const char *decl);
|
||||
|
||||
int GetNextScriptFunctionId();
|
||||
void SetScriptFunction(asCScriptFunction *func);
|
||||
void FreeScriptFunctionId(int id);
|
||||
void AddScriptFunction(asCScriptFunction *func);
|
||||
void RemoveScriptFunction(asCScriptFunction *func);
|
||||
void RemoveFuncdef(asCScriptFunction *func);
|
||||
|
||||
int ConfigError(int err, const char *funcName, const char *arg1, const char *arg2);
|
||||
|
||||
@@ -293,11 +292,14 @@ public:
|
||||
void RemoveFromTypeIdMap(asCObjectType *type);
|
||||
|
||||
bool IsTemplateType(const char *name) const;
|
||||
asCObjectType *GetTemplateInstanceType(asCObjectType *templateType, asCArray<asCDataType> &subTypes);
|
||||
asCObjectType *GetTemplateInstanceType(asCObjectType *templateType, asCArray<asCDataType> &subTypes, asCModule *requestingModule);
|
||||
asCScriptFunction *GenerateTemplateFactoryStub(asCObjectType *templateType, asCObjectType *templateInstanceType, int origFactoryId);
|
||||
bool GenerateNewTemplateFunction(asCObjectType *templateType, asCObjectType *templateInstanceType, asCScriptFunction *templateFunc, asCScriptFunction **newFunc);
|
||||
void OrphanTemplateInstances(asCObjectType *subType);
|
||||
asCDataType DetermineTypeForTemplate(const asCDataType &orig, asCObjectType *tmpl, asCObjectType *ot);
|
||||
bool RequireTypeReplacement(asCDataType &type, asCObjectType *templateType);
|
||||
|
||||
asCModule *FindNewOwnerForSharedType(asCObjectType *type, asCModule *mod);
|
||||
asCModule *FindNewOwnerForSharedFunc(asCScriptFunction *func, asCModule *mod);
|
||||
|
||||
// String constants
|
||||
// TODO: Must free unused string constants, thus the ref count for each must be tracked
|
||||
@@ -306,13 +308,14 @@ public:
|
||||
|
||||
// Global property management
|
||||
asCGlobalProperty *AllocateGlobalProperty();
|
||||
void FreeUnusedGlobalProperties();
|
||||
void RemoveGlobalProperty(asCGlobalProperty *prop);
|
||||
|
||||
int GetScriptSectionNameIndex(const char *name);
|
||||
|
||||
// Namespace management
|
||||
asSNameSpace *AddNameSpace(const char *name);
|
||||
asSNameSpace *FindNameSpace(const char *name);
|
||||
asSNameSpace *FindNameSpace(const char *name) const;
|
||||
asSNameSpace *GetParentNameSpace(asSNameSpace *ns) const;
|
||||
|
||||
//===========================================================
|
||||
// internal properties
|
||||
@@ -324,14 +327,12 @@ public:
|
||||
asCObjectType *defaultArrayObjectType;
|
||||
asCObjectType scriptTypeBehaviours;
|
||||
asCObjectType functionBehaviours;
|
||||
asCObjectType objectTypeBehaviours;
|
||||
asCObjectType globalPropertyBehaviours;
|
||||
|
||||
// Registered interface
|
||||
asCArray<asCObjectType *> registeredObjTypes;
|
||||
asCArray<asCObjectType *> registeredTypeDefs;
|
||||
asCArray<asCObjectType *> registeredEnums;
|
||||
asCSymbolTable<asCGlobalProperty> registeredGlobalProps; // TODO: memory savings: Since there can be only one property with the same name a simpler symbol table should be used
|
||||
asCSymbolTable<asCGlobalProperty> registeredGlobalProps; // increases ref count // TODO: memory savings: Since there can be only one property with the same name a simpler symbol table should be used
|
||||
asCSymbolTable<asCScriptFunction> registeredGlobalFuncs;
|
||||
asCArray<asCScriptFunction *> registeredFuncDefs;
|
||||
asCArray<asCObjectType *> registeredTemplateTypes;
|
||||
@@ -339,54 +340,69 @@ public:
|
||||
bool configFailed;
|
||||
|
||||
// Stores all registered types except funcdefs
|
||||
asCMap<asSNameSpaceNamePair, asCObjectType*> allRegisteredTypes;
|
||||
asCMap<asSNameSpaceNamePair, asCObjectType*> allRegisteredTypes; // increases ref count
|
||||
|
||||
// Dummy types used to name the subtypes in the template objects
|
||||
asCArray<asCObjectType *> templateSubTypes;
|
||||
|
||||
// Store information about template types
|
||||
// This list will contain all instances of templates, both registered specialized
|
||||
// types and those automacially instanciated from scripts
|
||||
asCArray<asCObjectType *> templateInstanceTypes;
|
||||
// types and those automacially instantiated from scripts
|
||||
asCArray<asCObjectType *> templateInstanceTypes; // increases ref count
|
||||
|
||||
// Store information about list patterns
|
||||
asCArray<asCObjectType *> listPatternTypes;
|
||||
asCArray<asCObjectType *> listPatternTypes; // increases ref count
|
||||
|
||||
// Stores all global properties, both those registered by application, and those declared by scripts.
|
||||
// The id of a global property is the index in this array.
|
||||
asCArray<asCGlobalProperty *> globalProperties;
|
||||
asCArray<asCGlobalProperty *> globalProperties; // increases ref count
|
||||
asCArray<int> freeGlobalPropertyIds;
|
||||
|
||||
// This map is used to quickly find a property by its memory address
|
||||
// It is used principally during building, cleanup, and garbage detection for script functions
|
||||
asCMap<void*, asCGlobalProperty*> varAddressMap;
|
||||
|
||||
asCArray<int> freeGlobalPropertyIds;
|
||||
asCMap<void*, asCGlobalProperty*> varAddressMap; // doesn't increase ref count
|
||||
|
||||
// Stores all functions, i.e. registered functions, script functions, class methods, behaviours, etc.
|
||||
asCArray<asCScriptFunction *> scriptFunctions;
|
||||
asCArray<asCScriptFunction *> scriptFunctions; // doesn't increase ref count
|
||||
asCArray<int> freeScriptFunctionIds;
|
||||
asCArray<asCScriptFunction *> signatureIds;
|
||||
|
||||
// An array with all module imported functions
|
||||
asCArray<sBindInfo *> importedFunctions;
|
||||
asCArray<sBindInfo *> importedFunctions; // doesn't increase ref count
|
||||
asCArray<int> freeImportedFunctionIdxs;
|
||||
|
||||
// These resources must be protected for multiple accesses
|
||||
// Synchronized
|
||||
mutable asCAtomic refCount;
|
||||
// Synchronized with engineRWLock
|
||||
// This array holds all live script modules
|
||||
asCArray<asCModule *> scriptModules;
|
||||
// Synchronized with engineRWLock
|
||||
// This is a pointer to the last module that was requested. It is used for performance
|
||||
// improvement, since it is common that the same module is accessed many times in a row
|
||||
asCModule *lastModule;
|
||||
// Synchronized with engineRWLock
|
||||
// This flag is true if a script is currently being compiled. It is used to prevent multiple
|
||||
// threads from requesting builds at the same time (without blocking)
|
||||
bool isBuilding;
|
||||
// Synchronized with engineRWLock
|
||||
// This array holds modules that have been discard (thus are no longer visible to the application)
|
||||
// but cannot yet be deleted due to having external references to some of the entities in them
|
||||
asCArray<asCModule *> discardedModules;
|
||||
// This flag is set to true during compilations of scripts (or loading pre-compiled scripts)
|
||||
// to delay the validation of template types until the subtypes have been fully declared
|
||||
bool deferValidationOfTemplateTypes;
|
||||
|
||||
// Tokenizer is instanciated once to share resources
|
||||
// Tokenizer is instantiated once to share resources
|
||||
asCTokenizer tok;
|
||||
|
||||
// Stores script declared object types
|
||||
asCArray<asCObjectType *> classTypes;
|
||||
// Stores shared script declared types (classes, interfaces, enums)
|
||||
asCArray<asCObjectType *> sharedScriptTypes; // increases ref count
|
||||
// This array stores the template instances types that have been automatically generated from template types
|
||||
asCArray<asCObjectType *> generatedTemplateTypes;
|
||||
// Stores the funcdefs
|
||||
asCArray<asCScriptFunction *> funcDefs;
|
||||
// TODO: 2.30.0: redesign: Only shared funcdefs should be stored here
|
||||
// a funcdef becomes shared if all arguments and the return type are shared (or application registered)
|
||||
asCArray<asCScriptFunction *> funcDefs; // doesn't increase ref count
|
||||
|
||||
// Stores the names of the script sections for debugging purposes
|
||||
asCArray<asCString *> scriptSectionNames;
|
||||
@@ -409,7 +425,17 @@ public:
|
||||
bool msgCallback;
|
||||
asSSystemFunctionInterface msgCallbackFunc;
|
||||
void *msgCallbackObj;
|
||||
struct preMessage_t
|
||||
{
|
||||
preMessage_t() { isSet = false; }
|
||||
bool isSet;
|
||||
asCString message;
|
||||
asCString scriptname;
|
||||
int r;
|
||||
int c;
|
||||
} preMessage;
|
||||
|
||||
// JIt compilation
|
||||
asIJITCompiler *jitCompiler;
|
||||
|
||||
// Namespaces
|
||||
@@ -423,16 +449,26 @@ public:
|
||||
asCArray<asCString*> stringConstants;
|
||||
asCMap<asCStringPointer, int> stringToIdMap;
|
||||
|
||||
// Callbacks for context pooling
|
||||
asREQUESTCONTEXTFUNC_t requestCtxFunc;
|
||||
asRETURNCONTEXTFUNC_t returnCtxFunc;
|
||||
void *ctxCallbackParam;
|
||||
|
||||
// User data
|
||||
asCArray<asPWORD> userData;
|
||||
|
||||
struct SEngineClean { asPWORD type; asCLEANENGINEFUNC_t cleanFunc; };
|
||||
asCArray<SEngineClean> cleanEngineFuncs;
|
||||
asCLEANMODULEFUNC_t cleanModuleFunc;
|
||||
asCLEANCONTEXTFUNC_t cleanContextFunc;
|
||||
asCLEANFUNCTIONFUNC_t cleanFunctionFunc;
|
||||
struct SObjTypeClean { asPWORD type; asCLEANOBJECTTYPEFUNC_t cleanFunc; };
|
||||
asCArray<SObjTypeClean> cleanObjectTypeFuncs;
|
||||
struct SEngineClean { asPWORD type; asCLEANENGINEFUNC_t cleanFunc; };
|
||||
asCArray<SEngineClean> cleanEngineFuncs;
|
||||
struct SModuleClean { asPWORD type; asCLEANMODULEFUNC_t cleanFunc; };
|
||||
asCArray<SModuleClean> cleanModuleFuncs;
|
||||
struct SContextClean { asPWORD type; asCLEANCONTEXTFUNC_t cleanFunc; };
|
||||
asCArray<SContextClean> cleanContextFuncs;
|
||||
struct SFunctionClean { asPWORD type; asCLEANFUNCTIONFUNC_t cleanFunc; };
|
||||
asCArray<SFunctionClean> cleanFunctionFuncs;
|
||||
struct SObjTypeClean { asPWORD type; asCLEANOBJECTTYPEFUNC_t cleanFunc; };
|
||||
asCArray<SObjTypeClean> cleanObjectTypeFuncs;
|
||||
struct SScriptObjClean { asPWORD type; asCLEANSCRIPTOBJECTFUNC_t cleanFunc; };
|
||||
asCArray<SScriptObjClean> cleanScriptObjectFuncs;
|
||||
|
||||
// Synchronization for threads
|
||||
DECLAREREADWRITELOCK(mutable engineRWLock)
|
||||
@@ -460,10 +496,21 @@ public:
|
||||
bool alwaysImplDefaultConstruct;
|
||||
int compilerWarnings;
|
||||
bool disallowValueAssignForRefType;
|
||||
// TODO: 3.0.0: Remove the alterSyntaxNamedArgs
|
||||
int alterSyntaxNamedArgs;
|
||||
bool disableIntegerDivision;
|
||||
bool disallowEmptyListElements;
|
||||
// TODO: 3.0.0: Remove the privatePropAsProtected
|
||||
bool privatePropAsProtected;
|
||||
} ep;
|
||||
|
||||
// This flag is to allow a quicker shutdown when releasing the engine
|
||||
bool shuttingDown;
|
||||
|
||||
// This flag is set when the engine's destructor is called, this is to
|
||||
// avoid recursive calls if an object happens to increment/decrement
|
||||
// the ref counter during shutdown
|
||||
bool inDestructor;
|
||||
};
|
||||
|
||||
END_AS_NAMESPACE
|
||||
|
||||
Reference in New Issue
Block a user