2014-10-27 18:43:09 -04:00
|
|
|
/*
|
|
|
|
AngelCode Scripting Library
|
2021-11-04 16:43:10 -04:00
|
|
|
Copyright (c) 2003-2019 Andreas Jonsson
|
2014-10-27 18:43:09 -04:00
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any
|
2014-10-27 18:43:09 -04:00
|
|
|
damages arising from the use of this software.
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
purpose, including commercial applications, and to alter it and
|
2014-10-27 18:43:09 -04:00
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
1. The origin of this software must not be misrepresented; you
|
2014-10-27 18:43:09 -04:00
|
|
|
must not claim that you wrote the original software. If you use
|
2017-11-20 08:02:33 -05:00
|
|
|
this software in a product, an acknowledgment in the product
|
2014-10-27 18:43:09 -04:00
|
|
|
documentation would be appreciated but is not required.
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
2. Altered source versions must be plainly marked as such, and
|
2014-10-27 18:43:09 -04:00
|
|
|
must not be misrepresented as being the original software.
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
3. This notice may not be removed or altered from any source
|
2014-10-27 18:43:09 -04:00
|
|
|
distribution.
|
|
|
|
|
|
|
|
The original version of this library can be located at:
|
|
|
|
http://www.angelcode.com/angelscript/
|
|
|
|
|
|
|
|
Andreas Jonsson
|
|
|
|
andreas@angelcode.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// as_scriptengine.h
|
|
|
|
//
|
|
|
|
// The implementation of the script engine interface
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef AS_SCRIPTENGINE_H
|
|
|
|
#define AS_SCRIPTENGINE_H
|
|
|
|
|
|
|
|
#include "as_config.h"
|
|
|
|
#include "as_atomic.h"
|
|
|
|
#include "as_scriptfunction.h"
|
|
|
|
#include "as_array.h"
|
|
|
|
#include "as_datatype.h"
|
|
|
|
#include "as_objecttype.h"
|
|
|
|
#include "as_module.h"
|
|
|
|
#include "as_callfunc.h"
|
|
|
|
#include "as_configgroup.h"
|
|
|
|
#include "as_memory.h"
|
|
|
|
#include "as_gc.h"
|
|
|
|
#include "as_tokenizer.h"
|
|
|
|
|
|
|
|
BEGIN_AS_NAMESPACE
|
|
|
|
|
|
|
|
class asCBuilder;
|
|
|
|
class asCContext;
|
|
|
|
|
|
|
|
// TODO: import: Remove this when import is removed
|
|
|
|
struct sBindInfo;
|
|
|
|
|
|
|
|
class asCScriptEngine : public asIScriptEngine
|
|
|
|
{
|
|
|
|
//=============================================================
|
|
|
|
// From asIScriptEngine
|
|
|
|
//=============================================================
|
|
|
|
public:
|
|
|
|
// Memory management
|
|
|
|
virtual int AddRef() const;
|
|
|
|
virtual int Release() const;
|
2015-05-11 19:40:43 -04:00
|
|
|
virtual int ShutDownAndRelease();
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Engine properties
|
|
|
|
virtual int SetEngineProperty(asEEngineProp property, asPWORD value);
|
|
|
|
virtual asPWORD GetEngineProperty(asEEngineProp property) const;
|
|
|
|
|
|
|
|
// Compiler messages
|
|
|
|
virtual int SetMessageCallback(const asSFuncPtr &callback, void *obj, asDWORD callConv);
|
|
|
|
virtual int ClearMessageCallback();
|
|
|
|
virtual int WriteMessage(const char *section, int row, int col, asEMsgType type, const char *message);
|
|
|
|
|
|
|
|
// JIT Compiler
|
|
|
|
virtual int SetJITCompiler(asIJITCompiler *compiler);
|
|
|
|
virtual asIJITCompiler *GetJITCompiler() const;
|
|
|
|
|
|
|
|
// Global functions
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0);
|
2014-10-27 18:43:09 -04:00
|
|
|
virtual asUINT GetGlobalFunctionCount() const;
|
|
|
|
virtual asIScriptFunction *GetGlobalFunctionByIndex(asUINT index) const;
|
|
|
|
virtual asIScriptFunction *GetGlobalFunctionByDecl(const char *declaration) const;
|
|
|
|
|
|
|
|
// Global properties
|
|
|
|
virtual int RegisterGlobalProperty(const char *declaration, void *pointer);
|
|
|
|
virtual asUINT GetGlobalPropertyCount() const;
|
|
|
|
virtual int GetGlobalPropertyByIndex(asUINT index, const char **name, const char **nameSpace = 0, int *typeId = 0, bool *isConst = 0, const char **configGroup = 0, void **pointer = 0, asDWORD *accessMask = 0) const;
|
|
|
|
virtual int GetGlobalPropertyIndexByName(const char *name) const;
|
|
|
|
virtual int GetGlobalPropertyIndexByDecl(const char *decl) const;
|
|
|
|
|
|
|
|
// Type registration
|
|
|
|
virtual int RegisterObjectType(const char *obj, int byteSize, asDWORD flags);
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual int RegisterObjectProperty(const char *obj, const char *declaration, int byteOffset, int compositeOffset = 0, bool isCompositeIndirect = false);
|
|
|
|
virtual int RegisterObjectMethod(const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false);
|
|
|
|
virtual int RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false);
|
2014-10-27 18:43:09 -04:00
|
|
|
virtual int RegisterInterface(const char *name);
|
|
|
|
virtual int RegisterInterfaceMethod(const char *intf, const char *declaration);
|
|
|
|
virtual asUINT GetObjectTypeCount() const;
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual asITypeInfo *GetObjectTypeByIndex(asUINT index) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// String factory
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual int RegisterStringFactory(const char *datatype, asIStringFactory *factory);
|
2015-05-11 19:40:43 -04:00
|
|
|
virtual int GetStringFactoryReturnTypeId(asDWORD *flags) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Default array type
|
|
|
|
virtual int RegisterDefaultArrayType(const char *type);
|
|
|
|
virtual int GetDefaultArrayTypeId() const;
|
|
|
|
|
|
|
|
// Enums
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual int RegisterEnum(const char *type);
|
|
|
|
virtual int RegisterEnumValue(const char *type, const char *name, int value);
|
|
|
|
virtual asUINT GetEnumCount() const;
|
|
|
|
virtual asITypeInfo *GetEnumByIndex(asUINT index) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Funcdefs
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual int RegisterFuncdef(const char *decl);
|
|
|
|
virtual asUINT GetFuncdefCount() const;
|
|
|
|
virtual asITypeInfo *GetFuncdefByIndex(asUINT index) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Typedefs
|
|
|
|
// TODO: interface: Should perhaps rename this to Alias, since it doesn't really create a new type
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual int RegisterTypedef(const char *type, const char *decl);
|
|
|
|
virtual asUINT GetTypedefCount() const;
|
|
|
|
virtual asITypeInfo *GetTypedefByIndex(asUINT index) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Configuration groups
|
|
|
|
virtual int BeginConfigGroup(const char *groupName);
|
|
|
|
virtual int EndConfigGroup();
|
|
|
|
virtual int RemoveConfigGroup(const char *groupName);
|
|
|
|
virtual asDWORD SetDefaultAccessMask(asDWORD defaultMask);
|
|
|
|
virtual int SetDefaultNamespace(const char *nameSpace);
|
|
|
|
virtual const char *GetDefaultNamespace() const;
|
|
|
|
|
|
|
|
// Script modules
|
|
|
|
virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag);
|
|
|
|
virtual int DiscardModule(const char *module);
|
|
|
|
virtual asUINT GetModuleCount() const;
|
|
|
|
virtual asIScriptModule *GetModuleByIndex(asUINT index) const;
|
|
|
|
|
|
|
|
// Script functions
|
|
|
|
virtual asIScriptFunction *GetFunctionById(int funcId) const;
|
|
|
|
|
|
|
|
// Type identification
|
|
|
|
virtual int GetTypeIdByDecl(const char *decl) const;
|
|
|
|
virtual const char *GetTypeDeclaration(int typeId, bool includeNamespace = false) const;
|
|
|
|
virtual int GetSizeOfPrimitiveType(int typeId) const;
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual asITypeInfo *GetTypeInfoById(int typeId) const;
|
|
|
|
virtual asITypeInfo *GetTypeInfoByName(const char *name) const;
|
|
|
|
virtual asITypeInfo *GetTypeInfoByDecl(const char *decl) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Script execution
|
2015-05-11 19:40:43 -04:00
|
|
|
virtual asIScriptContext *CreateContext();
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual void *CreateScriptObject(const asITypeInfo *type);
|
|
|
|
virtual void *CreateScriptObjectCopy(void *obj, const asITypeInfo *type);
|
|
|
|
virtual void *CreateUninitializedScriptObject(const asITypeInfo *type);
|
2015-05-11 19:40:43 -04:00
|
|
|
virtual asIScriptFunction *CreateDelegate(asIScriptFunction *func, void *obj);
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual int AssignScriptObject(void *dstObj, void *srcObj, const asITypeInfo *type);
|
|
|
|
virtual void ReleaseScriptObject(void *obj, const asITypeInfo *type);
|
|
|
|
virtual void AddRefScriptObject(void *obj, const asITypeInfo *type);
|
|
|
|
virtual int RefCastObject(void *obj, asITypeInfo *fromType, asITypeInfo *toType, void **newPtr, bool useOnlyImplicitCast = false);
|
|
|
|
virtual asILockableSharedBool *GetWeakRefFlagOfScriptObject(void *obj, const asITypeInfo *type) const;
|
2015-05-11 19:40:43 -04:00
|
|
|
|
|
|
|
// Context pooling
|
|
|
|
virtual asIScriptContext *RequestContext();
|
|
|
|
virtual void ReturnContext(asIScriptContext *ctx);
|
|
|
|
virtual int SetContextCallbacks(asREQUESTCONTEXTFUNC_t requestCtx, asRETURNCONTEXTFUNC_t returnCtx, void *param = 0);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// String interpretation
|
2015-05-11 19:40:43 -04:00
|
|
|
virtual asETokenClass ParseToken(const char *string, size_t stringLength = 0, asUINT *tokenLength = 0) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Garbage collection
|
2015-05-11 19:40:43 -04:00
|
|
|
virtual int GarbageCollect(asDWORD flags = asGC_FULL_CYCLE, asUINT numIterations = 1);
|
2014-10-27 18:43:09 -04:00
|
|
|
virtual void GetGCStatistics(asUINT *currentSize, asUINT *totalDestroyed, asUINT *totalDetected, asUINT *newObjects, asUINT *totalNewDestroyed) const;
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual int NotifyGarbageCollectorOfNewObject(void *obj, asITypeInfo *type);
|
|
|
|
virtual int GetObjectInGC(asUINT idx, asUINT *seqNbr, void **obj = 0, asITypeInfo **type = 0);
|
2014-10-27 18:43:09 -04:00
|
|
|
virtual void GCEnumCallback(void *reference);
|
2021-11-04 16:43:10 -04:00
|
|
|
virtual void ForwardGCEnumReferences(void *ref, asITypeInfo *type);
|
|
|
|
virtual void ForwardGCReleaseReferences(void *ref, asITypeInfo *type);
|
|
|
|
virtual void SetCircularRefDetectedCallback(asCIRCULARREFFUNC_t callback, void *param = 0);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// User data
|
2015-05-11 19:40:43 -04:00
|
|
|
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);
|
2017-11-20 08:02:33 -05:00
|
|
|
virtual void SetTypeInfoUserDataCleanupCallback(asCLEANTYPEINFOFUNC_t callback, asPWORD type);
|
2015-05-11 19:40:43 -04:00
|
|
|
virtual void SetScriptObjectUserDataCleanupCallback(asCLEANSCRIPTOBJECTFUNC_t callback, asPWORD type);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
2021-11-04 16:43:10 -04:00
|
|
|
// Exception handling
|
|
|
|
virtual int SetTranslateAppExceptionCallback(asSFuncPtr callback, void *param, int callConv);
|
|
|
|
|
2014-10-27 18:43:09 -04:00
|
|
|
//===========================================================
|
|
|
|
// internal methods
|
|
|
|
//===========================================================
|
|
|
|
public:
|
|
|
|
asCScriptEngine();
|
|
|
|
virtual ~asCScriptEngine();
|
|
|
|
|
|
|
|
//protected:
|
|
|
|
friend class asCBuilder;
|
|
|
|
friend class asCCompiler;
|
|
|
|
friend class asCContext;
|
|
|
|
friend class asCDataType;
|
|
|
|
friend class asCModule;
|
|
|
|
friend class asCRestore;
|
|
|
|
friend class asCByteCode;
|
|
|
|
friend int PrepareSystemFunction(asCScriptFunction *func, asSSystemFunctionInterface *internal, asCScriptEngine *engine);
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
int RegisterMethodToObjectType(asCObjectType *objectType, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false);
|
|
|
|
int RegisterBehaviourToObjectType(asCObjectType *objectType, asEBehaviours behaviour, const char *decl, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
int VerifyVarTypeNotInFunction(asCScriptFunction *func);
|
|
|
|
|
2015-05-11 19:40:43 -04:00
|
|
|
void *CallAlloc(const asCObjectType *objType) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
void CallFree(void *obj) const;
|
|
|
|
|
|
|
|
void *CallGlobalFunctionRetPtr(int func) const;
|
|
|
|
void *CallGlobalFunctionRetPtr(int func, void *param1) const;
|
|
|
|
void *CallGlobalFunctionRetPtr(asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
|
|
|
|
void *CallGlobalFunctionRetPtr(asSSystemFunctionInterface *i, asCScriptFunction *s, void *param1) const;
|
|
|
|
void CallObjectMethod(void *obj, int func) const;
|
|
|
|
void CallObjectMethod(void *obj, void *param, int func) const;
|
|
|
|
void CallObjectMethod(void *obj, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
|
|
|
|
void CallObjectMethod(void *obj, void *param, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
|
|
|
|
bool CallObjectMethodRetBool(void *obj, int func) const;
|
|
|
|
int CallObjectMethodRetInt(void *obj, int func) const;
|
|
|
|
void *CallObjectMethodRetPtr(void *obj, int func) const;
|
2016-02-17 23:07:55 -05:00
|
|
|
void *CallObjectMethodRetPtr(void *obj, int param1, asCScriptFunction *func) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
void CallGlobalFunction(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
|
|
|
|
bool CallGlobalFunctionRetBool(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
|
2017-11-20 08:02:33 -05:00
|
|
|
int CallScriptObjectMethod(void *obj, int func);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
void ConstructScriptObjectCopy(void *mem, void *obj, asCObjectType *type);
|
|
|
|
|
2015-05-11 19:40:43 -04:00
|
|
|
void DeleteDiscardedModules();
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
void RemoveTemplateInstanceType(asCObjectType *t);
|
|
|
|
|
|
|
|
asCConfigGroup *FindConfigGroupForFunction(int funcId) const;
|
|
|
|
asCConfigGroup *FindConfigGroupForGlobalVar(int gvarId) const;
|
2017-11-20 08:02:33 -05:00
|
|
|
asCConfigGroup *FindConfigGroupForTypeInfo(const asCTypeInfo *type) const;
|
|
|
|
asCConfigGroup *FindConfigGroupForFuncDef(const asCFuncdefType *funcDef) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
int RequestBuild();
|
|
|
|
void BuildCompleted();
|
|
|
|
|
|
|
|
void PrepareEngine();
|
|
|
|
bool isPrepared;
|
|
|
|
|
|
|
|
int CreateContext(asIScriptContext **context, bool isInternal);
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
asCTypeInfo *GetRegisteredType(const asCString &name, asSNameSpace *ns) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
asCObjectType *GetListPatternType(int listPatternFuncId);
|
|
|
|
void DestroyList(asBYTE *buffer, const asCObjectType *listPatternType);
|
|
|
|
void DestroySubList(asBYTE *&buffer, asSListPatternNode *&patternNode);
|
|
|
|
|
|
|
|
int AddBehaviourFunction(asCScriptFunction &func, asSSystemFunctionInterface &internal);
|
|
|
|
|
|
|
|
asCString GetFunctionDeclaration(int funcId);
|
|
|
|
|
|
|
|
asCScriptFunction *GetScriptFunction(int funcId) const;
|
|
|
|
|
|
|
|
asCModule *GetModule(const char *name, bool create);
|
|
|
|
asCModule *GetModuleFromFuncId(int funcId);
|
|
|
|
|
|
|
|
int GetMethodIdByDecl(const asCObjectType *ot, const char *decl, asCModule *mod);
|
|
|
|
int GetFactoryIdByDecl(const asCObjectType *ot, const char *decl);
|
|
|
|
|
|
|
|
int GetNextScriptFunctionId();
|
2015-05-11 19:40:43 -04:00
|
|
|
void AddScriptFunction(asCScriptFunction *func);
|
|
|
|
void RemoveScriptFunction(asCScriptFunction *func);
|
2017-11-20 08:02:33 -05:00
|
|
|
void RemoveFuncdef(asCFuncdefType *func);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
int ConfigError(int err, const char *funcName, const char *arg1, const char *arg2);
|
|
|
|
|
|
|
|
int GetTypeIdFromDataType(const asCDataType &dt) const;
|
|
|
|
asCDataType GetDataTypeFromTypeId(int typeId) const;
|
|
|
|
asCObjectType *GetObjectTypeFromTypeId(int typeId) const;
|
2017-11-20 08:02:33 -05:00
|
|
|
void RemoveFromTypeIdMap(asCTypeInfo *type);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
bool IsTemplateType(const char *name) const;
|
2017-11-20 08:02:33 -05:00
|
|
|
int SetTemplateRestrictions(asCObjectType *templateType, asCScriptFunction *func, const char *caller, const char *decl);
|
2015-05-11 19:40:43 -04:00
|
|
|
asCObjectType *GetTemplateInstanceType(asCObjectType *templateType, asCArray<asCDataType> &subTypes, asCModule *requestingModule);
|
2014-10-27 18:43:09 -04:00
|
|
|
asCScriptFunction *GenerateTemplateFactoryStub(asCObjectType *templateType, asCObjectType *templateInstanceType, int origFactoryId);
|
|
|
|
bool GenerateNewTemplateFunction(asCObjectType *templateType, asCObjectType *templateInstanceType, asCScriptFunction *templateFunc, asCScriptFunction **newFunc);
|
2017-11-20 08:02:33 -05:00
|
|
|
asCFuncdefType *GenerateNewTemplateFuncdef(asCObjectType *templateType, asCObjectType *templateInstanceType, asCFuncdefType *templateFuncdef);
|
2014-10-27 18:43:09 -04:00
|
|
|
asCDataType DetermineTypeForTemplate(const asCDataType &orig, asCObjectType *tmpl, asCObjectType *ot);
|
2015-05-11 19:40:43 -04:00
|
|
|
bool RequireTypeReplacement(asCDataType &type, asCObjectType *templateType);
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
asCModule *FindNewOwnerForSharedType(asCTypeInfo *type, asCModule *mod);
|
2015-05-11 19:40:43 -04:00
|
|
|
asCModule *FindNewOwnerForSharedFunc(asCScriptFunction *func, asCModule *mod);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
asCFuncdefType *FindMatchingFuncdef(asCScriptFunction *func, asCModule *mod);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
2021-11-04 16:43:10 -04:00
|
|
|
int DetermineNameAndNamespace(const char *in_name, asSNameSpace *implicitNs, asCString &out_name, asSNameSpace *&out_ns) const;
|
|
|
|
|
2014-10-27 18:43:09 -04:00
|
|
|
// Global property management
|
|
|
|
asCGlobalProperty *AllocateGlobalProperty();
|
2015-05-11 19:40:43 -04:00
|
|
|
void RemoveGlobalProperty(asCGlobalProperty *prop);
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
int GetScriptSectionNameIndex(const char *name);
|
|
|
|
|
|
|
|
// Namespace management
|
|
|
|
asSNameSpace *AddNameSpace(const char *name);
|
2015-05-11 19:40:43 -04:00
|
|
|
asSNameSpace *FindNameSpace(const char *name) const;
|
|
|
|
asSNameSpace *GetParentNameSpace(asSNameSpace *ns) const;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
//===========================================================
|
|
|
|
// internal properties
|
|
|
|
//===========================================================
|
|
|
|
asCMemoryMgr memoryMgr;
|
|
|
|
|
|
|
|
asCObjectType *defaultArrayObjectType;
|
|
|
|
asCObjectType scriptTypeBehaviours;
|
|
|
|
asCObjectType functionBehaviours;
|
|
|
|
|
|
|
|
// Registered interface
|
2017-11-20 08:02:33 -05:00
|
|
|
asCArray<asCObjectType *> registeredObjTypes; // doesn't increase ref count
|
|
|
|
asCArray<asCTypedefType *> registeredTypeDefs; // doesn't increase ref count
|
|
|
|
asCArray<asCEnumType *> registeredEnums; // doesn't increase ref count
|
|
|
|
// TODO: memory savings: Since there can be only one property with the same name a simpler symbol table should be used for global props
|
|
|
|
asCSymbolTable<asCGlobalProperty> registeredGlobalProps; // increases ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
asCSymbolTable<asCScriptFunction> registeredGlobalFuncs;
|
2017-11-20 08:02:33 -05:00
|
|
|
asCArray<asCFuncdefType *> registeredFuncDefs; // doesn't increase ref count
|
|
|
|
asCArray<asCObjectType *> registeredTemplateTypes; // doesn't increase ref count
|
|
|
|
asIStringFactory *stringFactory;
|
|
|
|
asCDataType stringType;
|
2014-10-27 18:43:09 -04:00
|
|
|
bool configFailed;
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
// Stores all registered types
|
|
|
|
asCMap<asSNameSpaceNamePair, asCTypeInfo*> allRegisteredTypes; // increases ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
// Dummy types used to name the subtypes in the template objects
|
|
|
|
asCArray<asCTypeInfo *> templateSubTypes;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Store information about template types
|
2017-11-20 08:02:33 -05:00
|
|
|
// This list will contain all instances of templates, both registered specialized
|
2015-05-11 19:40:43 -04:00
|
|
|
// types and those automacially instantiated from scripts
|
|
|
|
asCArray<asCObjectType *> templateInstanceTypes; // increases ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Store information about list patterns
|
2015-05-11 19:40:43 -04:00
|
|
|
asCArray<asCObjectType *> listPatternTypes; // increases ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// 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.
|
2015-05-11 19:40:43 -04:00
|
|
|
asCArray<asCGlobalProperty *> globalProperties; // increases ref count
|
|
|
|
asCArray<int> freeGlobalPropertyIds;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// 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
|
2015-05-11 19:40:43 -04:00
|
|
|
asCMap<void*, asCGlobalProperty*> varAddressMap; // doesn't increase ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Stores all functions, i.e. registered functions, script functions, class methods, behaviours, etc.
|
2015-05-11 19:40:43 -04:00
|
|
|
asCArray<asCScriptFunction *> scriptFunctions; // doesn't increase ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
asCArray<int> freeScriptFunctionIds;
|
|
|
|
asCArray<asCScriptFunction *> signatureIds;
|
|
|
|
|
|
|
|
// An array with all module imported functions
|
2015-05-11 19:40:43 -04:00
|
|
|
asCArray<sBindInfo *> importedFunctions; // doesn't increase ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
asCArray<int> freeImportedFunctionIdxs;
|
|
|
|
|
2015-05-11 19:40:43 -04:00
|
|
|
// Synchronized
|
2014-10-27 18:43:09 -04:00
|
|
|
mutable asCAtomic refCount;
|
2015-05-11 19:40:43 -04:00
|
|
|
// Synchronized with engineRWLock
|
|
|
|
// This array holds all live script modules
|
2014-10-27 18:43:09 -04:00
|
|
|
asCArray<asCModule *> scriptModules;
|
2015-05-11 19:40:43 -04:00
|
|
|
// Synchronized with engineRWLock
|
2017-11-20 08:02:33 -05:00
|
|
|
// This is a pointer to the last module that was requested. It is used for performance
|
2015-05-11 19:40:43 -04:00
|
|
|
// improvement, since it is common that the same module is accessed many times in a row
|
2014-10-27 18:43:09 -04:00
|
|
|
asCModule *lastModule;
|
2015-05-11 19:40:43 -04:00
|
|
|
// 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)
|
2014-10-27 18:43:09 -04:00
|
|
|
bool isBuilding;
|
2015-05-11 19:40:43 -04:00
|
|
|
// 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;
|
2017-11-20 08:02:33 -05:00
|
|
|
// 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
|
2014-10-27 18:43:09 -04:00
|
|
|
bool deferValidationOfTemplateTypes;
|
|
|
|
|
2015-05-11 19:40:43 -04:00
|
|
|
// Tokenizer is instantiated once to share resources
|
2014-10-27 18:43:09 -04:00
|
|
|
asCTokenizer tok;
|
|
|
|
|
2015-05-11 19:40:43 -04:00
|
|
|
// Stores shared script declared types (classes, interfaces, enums)
|
2017-11-20 08:02:33 -05:00
|
|
|
asCArray<asCTypeInfo *> sharedScriptTypes; // increases ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
// This array stores the template instances types that have been automatically generated from template types
|
|
|
|
asCArray<asCObjectType *> generatedTemplateTypes;
|
|
|
|
// Stores the funcdefs
|
2016-02-17 23:07:55 -05:00
|
|
|
// TODO: redesign: Only shared funcdefs should be stored here
|
|
|
|
// a funcdef becomes shared if all arguments and the return type are shared (or application registered)
|
2017-11-20 08:02:33 -05:00
|
|
|
asCArray<asCFuncdefType *> funcDefs; // doesn't increases ref count
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Stores the names of the script sections for debugging purposes
|
|
|
|
asCArray<asCString *> scriptSectionNames;
|
|
|
|
|
|
|
|
// Type identifiers
|
2016-02-17 23:07:55 -05:00
|
|
|
mutable int typeIdSeqNbr;
|
2017-11-20 08:02:33 -05:00
|
|
|
mutable asCMap<int, asCTypeInfo*> mapTypeIdToTypeInfo;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Garbage collector
|
|
|
|
asCGarbageCollector gc;
|
|
|
|
|
|
|
|
// Dynamic groups
|
|
|
|
asCConfigGroup defaultGroup;
|
|
|
|
asCArray<asCConfigGroup*> configGroups;
|
|
|
|
asCConfigGroup *currentGroup;
|
|
|
|
asDWORD defaultAccessMask;
|
|
|
|
asSNameSpace *defaultNamespace;
|
|
|
|
|
|
|
|
// Message callback
|
|
|
|
bool msgCallback;
|
|
|
|
asSSystemFunctionInterface msgCallbackFunc;
|
|
|
|
void *msgCallbackObj;
|
2015-05-11 19:40:43 -04:00
|
|
|
struct preMessage_t
|
|
|
|
{
|
|
|
|
preMessage_t() { isSet = false; }
|
|
|
|
bool isSet;
|
|
|
|
asCString message;
|
|
|
|
asCString scriptname;
|
|
|
|
int r;
|
|
|
|
int c;
|
|
|
|
} preMessage;
|
|
|
|
|
|
|
|
// JIt compilation
|
2014-10-27 18:43:09 -04:00
|
|
|
asIJITCompiler *jitCompiler;
|
|
|
|
|
|
|
|
// Namespaces
|
2017-11-20 08:02:33 -05:00
|
|
|
// These are shared between all entities and are
|
2014-10-27 18:43:09 -04:00
|
|
|
// only deleted once the engine is destroyed
|
|
|
|
asCArray<asSNameSpace*> nameSpaces;
|
|
|
|
|
2015-05-11 19:40:43 -04:00
|
|
|
// Callbacks for context pooling
|
|
|
|
asREQUESTCONTEXTFUNC_t requestCtxFunc;
|
|
|
|
asRETURNCONTEXTFUNC_t returnCtxFunc;
|
|
|
|
void *ctxCallbackParam;
|
|
|
|
|
2014-10-27 18:43:09 -04:00
|
|
|
// User data
|
|
|
|
asCArray<asPWORD> userData;
|
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
struct SEngineClean { asPWORD type; asCLEANENGINEFUNC_t cleanFunc; };
|
2015-05-11 19:40:43 -04:00
|
|
|
asCArray<SEngineClean> cleanEngineFuncs;
|
2017-11-20 08:02:33 -05:00
|
|
|
struct SModuleClean { asPWORD type; asCLEANMODULEFUNC_t cleanFunc; };
|
2015-05-11 19:40:43 -04:00
|
|
|
asCArray<SModuleClean> cleanModuleFuncs;
|
2017-11-20 08:02:33 -05:00
|
|
|
struct SContextClean { asPWORD type; asCLEANCONTEXTFUNC_t cleanFunc; };
|
2015-05-11 19:40:43 -04:00
|
|
|
asCArray<SContextClean> cleanContextFuncs;
|
2017-11-20 08:02:33 -05:00
|
|
|
struct SFunctionClean { asPWORD type; asCLEANFUNCTIONFUNC_t cleanFunc; };
|
2015-05-11 19:40:43 -04:00
|
|
|
asCArray<SFunctionClean> cleanFunctionFuncs;
|
2017-11-20 08:02:33 -05:00
|
|
|
struct STypeInfoClean { asPWORD type; asCLEANTYPEINFOFUNC_t cleanFunc; };
|
|
|
|
asCArray<STypeInfoClean> cleanTypeInfoFuncs;
|
2015-05-11 19:40:43 -04:00
|
|
|
struct SScriptObjClean { asPWORD type; asCLEANSCRIPTOBJECTFUNC_t cleanFunc; };
|
|
|
|
asCArray<SScriptObjClean> cleanScriptObjectFuncs;
|
2014-10-27 18:43:09 -04:00
|
|
|
|
|
|
|
// Synchronization for threads
|
|
|
|
DECLAREREADWRITELOCK(mutable engineRWLock)
|
|
|
|
|
|
|
|
// Engine properties
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool allowUnsafeReferences;
|
|
|
|
bool optimizeByteCode;
|
|
|
|
bool copyScriptSections;
|
|
|
|
asUINT maximumContextStackSize;
|
2021-11-04 16:43:10 -04:00
|
|
|
asUINT initContextStackSize;
|
2014-10-27 18:43:09 -04:00
|
|
|
bool useCharacterLiterals;
|
|
|
|
bool allowMultilineStrings;
|
|
|
|
bool allowImplicitHandleTypes;
|
|
|
|
bool buildWithoutLineCues;
|
|
|
|
bool initGlobalVarsAfterBuild;
|
|
|
|
bool requireEnumScope;
|
|
|
|
int scanner;
|
|
|
|
bool includeJitInstructions;
|
|
|
|
int stringEncoding;
|
|
|
|
int propertyAccessorMode;
|
|
|
|
bool expandDefaultArrayToTemplate;
|
|
|
|
bool autoGarbageCollect;
|
|
|
|
bool disallowGlobalVars;
|
|
|
|
bool alwaysImplDefaultConstruct;
|
|
|
|
int compilerWarnings;
|
|
|
|
bool disallowValueAssignForRefType;
|
2015-05-11 19:40:43 -04:00
|
|
|
// TODO: 3.0.0: Remove the alterSyntaxNamedArgs
|
|
|
|
int alterSyntaxNamedArgs;
|
|
|
|
bool disableIntegerDivision;
|
|
|
|
bool disallowEmptyListElements;
|
|
|
|
// TODO: 3.0.0: Remove the privatePropAsProtected
|
|
|
|
bool privatePropAsProtected;
|
2017-11-20 08:02:33 -05:00
|
|
|
bool allowUnicodeIdentifiers;
|
|
|
|
int heredocTrimMode;
|
|
|
|
asUINT maxNestedCalls;
|
2021-11-04 16:43:10 -04:00
|
|
|
asUINT genericCallMode;
|
|
|
|
asUINT initCallStackSize;
|
|
|
|
asUINT maxCallStackSize;
|
2014-10-27 18:43:09 -04:00
|
|
|
} ep;
|
|
|
|
|
2021-11-04 16:43:10 -04:00
|
|
|
// Callbacks
|
|
|
|
#ifndef AS_NO_EXCEPTIONS
|
|
|
|
bool translateExceptionCallback;
|
|
|
|
asSSystemFunctionInterface translateExceptionCallbackFunc;
|
|
|
|
void * translateExceptionCallbackObj;
|
|
|
|
#endif
|
|
|
|
|
2014-10-27 18:43:09 -04:00
|
|
|
// This flag is to allow a quicker shutdown when releasing the engine
|
|
|
|
bool shuttingDown;
|
2015-05-11 19:40:43 -04:00
|
|
|
|
2017-11-20 08:02:33 -05:00
|
|
|
// This flag is set when the engine's destructor is called, this is to
|
2015-05-11 19:40:43 -04:00
|
|
|
// avoid recursive calls if an object happens to increment/decrement
|
|
|
|
// the ref counter during shutdown
|
|
|
|
bool inDestructor;
|
2014-10-27 18:43:09 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
END_AS_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|