as_scriptengine.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. /*
  2. AngelCode Scripting Library
  3. Copyright (c) 2003-2015 Andreas Jonsson
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any
  6. damages arising from the use of this software.
  7. Permission is granted to anyone to use this software for any
  8. purpose, including commercial applications, and to alter it and
  9. redistribute it freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you
  11. must not claim that you wrote the original software. If you use
  12. this software in a product, an acknowledgment in the product
  13. documentation would be appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and
  15. must not be misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source
  17. distribution.
  18. The original version of this library can be located at:
  19. http://www.angelcode.com/angelscript/
  20. Andreas Jonsson
  21. andreas@angelcode.com
  22. */
  23. //
  24. // as_scriptengine.h
  25. //
  26. // The implementation of the script engine interface
  27. //
  28. #ifndef AS_SCRIPTENGINE_H
  29. #define AS_SCRIPTENGINE_H
  30. #include "as_config.h"
  31. #include "as_atomic.h"
  32. #include "as_scriptfunction.h"
  33. #include "as_array.h"
  34. #include "as_datatype.h"
  35. #include "as_objecttype.h"
  36. #include "as_module.h"
  37. #include "as_callfunc.h"
  38. #include "as_configgroup.h"
  39. #include "as_memory.h"
  40. #include "as_gc.h"
  41. #include "as_tokenizer.h"
  42. BEGIN_AS_NAMESPACE
  43. class asCBuilder;
  44. class asCContext;
  45. // TODO: import: Remove this when import is removed
  46. struct sBindInfo;
  47. class asCScriptEngine : public asIScriptEngine
  48. {
  49. //=============================================================
  50. // From asIScriptEngine
  51. //=============================================================
  52. public:
  53. // Memory management
  54. virtual int AddRef() const;
  55. virtual int Release() const;
  56. virtual int ShutDownAndRelease();
  57. // Engine properties
  58. virtual int SetEngineProperty(asEEngineProp property, asPWORD value);
  59. virtual asPWORD GetEngineProperty(asEEngineProp property) const;
  60. // Compiler messages
  61. virtual int SetMessageCallback(const asSFuncPtr &callback, void *obj, asDWORD callConv);
  62. virtual int ClearMessageCallback();
  63. virtual int WriteMessage(const char *section, int row, int col, asEMsgType type, const char *message);
  64. // JIT Compiler
  65. virtual int SetJITCompiler(asIJITCompiler *compiler);
  66. virtual asIJITCompiler *GetJITCompiler() const;
  67. // Global functions
  68. virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall = 0);
  69. virtual asUINT GetGlobalFunctionCount() const;
  70. virtual asIScriptFunction *GetGlobalFunctionByIndex(asUINT index) const;
  71. virtual asIScriptFunction *GetGlobalFunctionByDecl(const char *declaration) const;
  72. // Global properties
  73. virtual int RegisterGlobalProperty(const char *declaration, void *pointer);
  74. virtual asUINT GetGlobalPropertyCount() const;
  75. 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;
  76. virtual int GetGlobalPropertyIndexByName(const char *name) const;
  77. virtual int GetGlobalPropertyIndexByDecl(const char *decl) const;
  78. // Type registration
  79. virtual int RegisterObjectType(const char *obj, int byteSize, asDWORD flags);
  80. virtual int RegisterObjectProperty(const char *obj, const char *declaration, int byteOffset);
  81. virtual int RegisterObjectMethod(const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall = 0);
  82. virtual int RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall = 0);
  83. virtual int RegisterInterface(const char *name);
  84. virtual int RegisterInterfaceMethod(const char *intf, const char *declaration);
  85. virtual asUINT GetObjectTypeCount() const;
  86. virtual asIObjectType *GetObjectTypeByIndex(asUINT index) const;
  87. virtual asIObjectType *GetObjectTypeByName(const char *name) const;
  88. virtual asIObjectType *GetObjectTypeByDecl(const char *decl) const;
  89. // String factory
  90. virtual int RegisterStringFactory(const char *datatype, const asSFuncPtr &factoryFunc, asDWORD callConv, void *objForThiscall = 0);
  91. virtual int GetStringFactoryReturnTypeId(asDWORD *flags) const;
  92. // Default array type
  93. virtual int RegisterDefaultArrayType(const char *type);
  94. virtual int GetDefaultArrayTypeId() const;
  95. // Enums
  96. virtual int RegisterEnum(const char *type);
  97. virtual int RegisterEnumValue(const char *type, const char *name, int value);
  98. virtual asUINT GetEnumCount() const;
  99. virtual const char *GetEnumByIndex(asUINT index, int *enumTypeId, const char **nameSpace, const char **configGroup = 0, asDWORD *accessMask = 0) const;
  100. virtual int GetEnumValueCount(int enumTypeId) const;
  101. virtual const char *GetEnumValueByIndex(int enumTypeId, asUINT index, int *outValue) const;
  102. // Funcdefs
  103. virtual int RegisterFuncdef(const char *decl);
  104. virtual asUINT GetFuncdefCount() const;
  105. virtual asIScriptFunction *GetFuncdefByIndex(asUINT index) const;
  106. // Typedefs
  107. // TODO: interface: Should perhaps rename this to Alias, since it doesn't really create a new type
  108. virtual int RegisterTypedef(const char *type, const char *decl);
  109. virtual asUINT GetTypedefCount() const;
  110. virtual const char *GetTypedefByIndex(asUINT index, int *typeId, const char **nameSpace, const char **configGroup = 0, asDWORD *accessMask = 0) const;
  111. // Configuration groups
  112. virtual int BeginConfigGroup(const char *groupName);
  113. virtual int EndConfigGroup();
  114. virtual int RemoveConfigGroup(const char *groupName);
  115. virtual asDWORD SetDefaultAccessMask(asDWORD defaultMask);
  116. virtual int SetDefaultNamespace(const char *nameSpace);
  117. virtual const char *GetDefaultNamespace() const;
  118. // Script modules
  119. virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag);
  120. virtual int DiscardModule(const char *module);
  121. virtual asUINT GetModuleCount() const;
  122. virtual asIScriptModule *GetModuleByIndex(asUINT index) const;
  123. // Script functions
  124. virtual asIScriptFunction *GetFunctionById(int funcId) const;
  125. virtual asIScriptFunction *GetFuncDefFromTypeId(int typeId) const;
  126. // Type identification
  127. virtual asIObjectType *GetObjectTypeById(int typeId) const;
  128. virtual int GetTypeIdByDecl(const char *decl) const;
  129. virtual const char *GetTypeDeclaration(int typeId, bool includeNamespace = false) const;
  130. virtual int GetSizeOfPrimitiveType(int typeId) const;
  131. // Script execution
  132. virtual asIScriptContext *CreateContext();
  133. virtual void *CreateScriptObject(const asIObjectType *type);
  134. virtual void *CreateScriptObjectCopy(void *obj, const asIObjectType *type);
  135. virtual void *CreateUninitializedScriptObject(const asIObjectType *type);
  136. virtual asIScriptFunction *CreateDelegate(asIScriptFunction *func, void *obj);
  137. virtual int AssignScriptObject(void *dstObj, void *srcObj, const asIObjectType *type);
  138. virtual void ReleaseScriptObject(void *obj, const asIObjectType *type);
  139. virtual void AddRefScriptObject(void *obj, const asIObjectType *type);
  140. virtual int RefCastObject(void *obj, asIObjectType *fromType, asIObjectType *toType, void **newPtr, bool useOnlyImplicitCast = false);
  141. #ifdef AS_DEPRECATED
  142. // Deprecated since 2.30.0, 2014-11-04
  143. virtual bool IsHandleCompatibleWithObject(void *obj, int objTypeId, int handleTypeId) const;
  144. #endif
  145. virtual asILockableSharedBool *GetWeakRefFlagOfScriptObject(void *obj, const asIObjectType *type) const;
  146. // Context pooling
  147. virtual asIScriptContext *RequestContext();
  148. virtual void ReturnContext(asIScriptContext *ctx);
  149. virtual int SetContextCallbacks(asREQUESTCONTEXTFUNC_t requestCtx, asRETURNCONTEXTFUNC_t returnCtx, void *param = 0);
  150. // String interpretation
  151. virtual asETokenClass ParseToken(const char *string, size_t stringLength = 0, asUINT *tokenLength = 0) const;
  152. // Garbage collection
  153. virtual int GarbageCollect(asDWORD flags = asGC_FULL_CYCLE, asUINT numIterations = 1);
  154. virtual void GetGCStatistics(asUINT *currentSize, asUINT *totalDestroyed, asUINT *totalDetected, asUINT *newObjects, asUINT *totalNewDestroyed) const;
  155. virtual int NotifyGarbageCollectorOfNewObject(void *obj, asIObjectType *type);
  156. virtual int GetObjectInGC(asUINT idx, asUINT *seqNbr, void **obj = 0, asIObjectType **type = 0);
  157. virtual void GCEnumCallback(void *reference);
  158. // User data
  159. virtual void *SetUserData(void *data, asPWORD type);
  160. virtual void *GetUserData(asPWORD type) const;
  161. virtual void SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback, asPWORD type);
  162. virtual void SetModuleUserDataCleanupCallback(asCLEANMODULEFUNC_t callback, asPWORD type);
  163. virtual void SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback, asPWORD type);
  164. virtual void SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback, asPWORD type);
  165. virtual void SetObjectTypeUserDataCleanupCallback(asCLEANOBJECTTYPEFUNC_t callback, asPWORD type);
  166. virtual void SetScriptObjectUserDataCleanupCallback(asCLEANSCRIPTOBJECTFUNC_t callback, asPWORD type);
  167. //===========================================================
  168. // internal methods
  169. //===========================================================
  170. public:
  171. asCScriptEngine();
  172. virtual ~asCScriptEngine();
  173. //protected:
  174. friend class asCBuilder;
  175. friend class asCCompiler;
  176. friend class asCContext;
  177. friend class asCDataType;
  178. friend class asCModule;
  179. friend class asCRestore;
  180. friend class asCByteCode;
  181. friend int PrepareSystemFunction(asCScriptFunction *func, asSSystemFunctionInterface *internal, asCScriptEngine *engine);
  182. int RegisterMethodToObjectType(asCObjectType *objectType, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall = 0);
  183. int RegisterBehaviourToObjectType(asCObjectType *objectType, asEBehaviours behaviour, const char *decl, const asSFuncPtr &funcPointer, asDWORD callConv, void *objForThiscall);
  184. int VerifyVarTypeNotInFunction(asCScriptFunction *func);
  185. void *CallAlloc(const asCObjectType *objType) const;
  186. void CallFree(void *obj) const;
  187. void *CallGlobalFunctionRetPtr(int func) const;
  188. void *CallGlobalFunctionRetPtr(int func, void *param1) const;
  189. void *CallGlobalFunctionRetPtr(asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  190. void *CallGlobalFunctionRetPtr(asSSystemFunctionInterface *i, asCScriptFunction *s, void *param1) const;
  191. void CallObjectMethod(void *obj, int func) const;
  192. void CallObjectMethod(void *obj, void *param, int func) const;
  193. void CallObjectMethod(void *obj, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  194. void CallObjectMethod(void *obj, void *param, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  195. bool CallObjectMethodRetBool(void *obj, int func) const;
  196. int CallObjectMethodRetInt(void *obj, int func) const;
  197. void *CallObjectMethodRetPtr(void *obj, int func) const;
  198. void *CallObjectMethodRetPtr(void *obj, int param1, asCScriptFunction *func) const;
  199. void CallGlobalFunction(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  200. bool CallGlobalFunctionRetBool(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  201. void ConstructScriptObjectCopy(void *mem, void *obj, asCObjectType *type);
  202. void DeleteDiscardedModules();
  203. void RemoveTemplateInstanceType(asCObjectType *t);
  204. void RemoveTypeAndRelatedFromList(asCMap<asCObjectType*,char> &types, asCObjectType *ot);
  205. asCConfigGroup *FindConfigGroupForFunction(int funcId) const;
  206. asCConfigGroup *FindConfigGroupForGlobalVar(int gvarId) const;
  207. asCConfigGroup *FindConfigGroupForObjectType(const asCObjectType *type) const;
  208. asCConfigGroup *FindConfigGroupForFuncDef(const asCScriptFunction *funcDef) const;
  209. int RequestBuild();
  210. void BuildCompleted();
  211. void PrepareEngine();
  212. bool isPrepared;
  213. int CreateContext(asIScriptContext **context, bool isInternal);
  214. asCObjectType *GetRegisteredObjectType(const asCString &name, asSNameSpace *ns) const;
  215. asCObjectType *GetListPatternType(int listPatternFuncId);
  216. void DestroyList(asBYTE *buffer, const asCObjectType *listPatternType);
  217. void DestroySubList(asBYTE *&buffer, asSListPatternNode *&patternNode);
  218. int AddBehaviourFunction(asCScriptFunction &func, asSSystemFunctionInterface &internal);
  219. asCString GetFunctionDeclaration(int funcId);
  220. asCScriptFunction *GetScriptFunction(int funcId) const;
  221. asCModule *GetModule(const char *name, bool create);
  222. asCModule *GetModuleFromFuncId(int funcId);
  223. int GetMethodIdByDecl(const asCObjectType *ot, const char *decl, asCModule *mod);
  224. int GetFactoryIdByDecl(const asCObjectType *ot, const char *decl);
  225. int GetNextScriptFunctionId();
  226. void AddScriptFunction(asCScriptFunction *func);
  227. void RemoveScriptFunction(asCScriptFunction *func);
  228. void RemoveFuncdef(asCScriptFunction *func);
  229. int ConfigError(int err, const char *funcName, const char *arg1, const char *arg2);
  230. int GetTypeIdFromDataType(const asCDataType &dt) const;
  231. asCDataType GetDataTypeFromTypeId(int typeId) const;
  232. asCObjectType *GetObjectTypeFromTypeId(int typeId) const;
  233. void RemoveFromTypeIdMap(asCObjectType *type);
  234. bool IsTemplateType(const char *name) const;
  235. asCObjectType *GetTemplateInstanceType(asCObjectType *templateType, asCArray<asCDataType> &subTypes, asCModule *requestingModule);
  236. asCScriptFunction *GenerateTemplateFactoryStub(asCObjectType *templateType, asCObjectType *templateInstanceType, int origFactoryId);
  237. bool GenerateNewTemplateFunction(asCObjectType *templateType, asCObjectType *templateInstanceType, asCScriptFunction *templateFunc, asCScriptFunction **newFunc);
  238. asCDataType DetermineTypeForTemplate(const asCDataType &orig, asCObjectType *tmpl, asCObjectType *ot);
  239. bool RequireTypeReplacement(asCDataType &type, asCObjectType *templateType);
  240. asCModule *FindNewOwnerForSharedType(asCObjectType *type, asCModule *mod);
  241. asCModule *FindNewOwnerForSharedFunc(asCScriptFunction *func, asCModule *mod);
  242. // String constants
  243. // TODO: Must free unused string constants, thus the ref count for each must be tracked
  244. int AddConstantString(const char *str, size_t length);
  245. const asCString &GetConstantString(int id);
  246. // Global property management
  247. asCGlobalProperty *AllocateGlobalProperty();
  248. void RemoveGlobalProperty(asCGlobalProperty *prop);
  249. int GetScriptSectionNameIndex(const char *name);
  250. // Namespace management
  251. asSNameSpace *AddNameSpace(const char *name);
  252. asSNameSpace *FindNameSpace(const char *name) const;
  253. asSNameSpace *GetParentNameSpace(asSNameSpace *ns) const;
  254. //===========================================================
  255. // internal properties
  256. //===========================================================
  257. asCMemoryMgr memoryMgr;
  258. asUINT initialContextStackSize;
  259. asCObjectType *defaultArrayObjectType;
  260. asCObjectType scriptTypeBehaviours;
  261. asCObjectType functionBehaviours;
  262. // Registered interface
  263. asCArray<asCObjectType *> registeredObjTypes;
  264. asCArray<asCObjectType *> registeredTypeDefs;
  265. asCArray<asCObjectType *> registeredEnums;
  266. 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
  267. asCSymbolTable<asCScriptFunction> registeredGlobalFuncs;
  268. asCArray<asCScriptFunction *> registeredFuncDefs;
  269. asCArray<asCObjectType *> registeredTemplateTypes;
  270. asCScriptFunction *stringFactory;
  271. bool configFailed;
  272. // Stores all registered types except funcdefs
  273. asCMap<asSNameSpaceNamePair, asCObjectType*> allRegisteredTypes; // increases ref count
  274. // Dummy types used to name the subtypes in the template objects
  275. asCArray<asCObjectType *> templateSubTypes;
  276. // Store information about template types
  277. // This list will contain all instances of templates, both registered specialized
  278. // types and those automacially instantiated from scripts
  279. asCArray<asCObjectType *> templateInstanceTypes; // increases ref count
  280. // Store information about list patterns
  281. asCArray<asCObjectType *> listPatternTypes; // increases ref count
  282. // Stores all global properties, both those registered by application, and those declared by scripts.
  283. // The id of a global property is the index in this array.
  284. asCArray<asCGlobalProperty *> globalProperties; // increases ref count
  285. asCArray<int> freeGlobalPropertyIds;
  286. // This map is used to quickly find a property by its memory address
  287. // It is used principally during building, cleanup, and garbage detection for script functions
  288. asCMap<void*, asCGlobalProperty*> varAddressMap; // doesn't increase ref count
  289. // Stores all functions, i.e. registered functions, script functions, class methods, behaviours, etc.
  290. asCArray<asCScriptFunction *> scriptFunctions; // doesn't increase ref count
  291. asCArray<int> freeScriptFunctionIds;
  292. asCArray<asCScriptFunction *> signatureIds;
  293. // An array with all module imported functions
  294. asCArray<sBindInfo *> importedFunctions; // doesn't increase ref count
  295. asCArray<int> freeImportedFunctionIdxs;
  296. // Synchronized
  297. mutable asCAtomic refCount;
  298. // Synchronized with engineRWLock
  299. // This array holds all live script modules
  300. asCArray<asCModule *> scriptModules;
  301. // Synchronized with engineRWLock
  302. // This is a pointer to the last module that was requested. It is used for performance
  303. // improvement, since it is common that the same module is accessed many times in a row
  304. asCModule *lastModule;
  305. // Synchronized with engineRWLock
  306. // This flag is true if a script is currently being compiled. It is used to prevent multiple
  307. // threads from requesting builds at the same time (without blocking)
  308. bool isBuilding;
  309. // Synchronized with engineRWLock
  310. // This array holds modules that have been discard (thus are no longer visible to the application)
  311. // but cannot yet be deleted due to having external references to some of the entities in them
  312. asCArray<asCModule *> discardedModules;
  313. // This flag is set to true during compilations of scripts (or loading pre-compiled scripts)
  314. // to delay the validation of template types until the subtypes have been fully declared
  315. bool deferValidationOfTemplateTypes;
  316. // Tokenizer is instantiated once to share resources
  317. asCTokenizer tok;
  318. // Stores shared script declared types (classes, interfaces, enums)
  319. asCArray<asCObjectType *> sharedScriptTypes; // increases ref count
  320. // This array stores the template instances types that have been automatically generated from template types
  321. asCArray<asCObjectType *> generatedTemplateTypes;
  322. // Stores the funcdefs
  323. // TODO: redesign: Only shared funcdefs should be stored here
  324. // a funcdef becomes shared if all arguments and the return type are shared (or application registered)
  325. asCArray<asCScriptFunction *> funcDefs; // doesn't increase ref count
  326. // Stores the names of the script sections for debugging purposes
  327. asCArray<asCString *> scriptSectionNames;
  328. // Type identifiers
  329. mutable int typeIdSeqNbr;
  330. mutable asCMap<int, asCObjectType*> mapTypeIdToObjectType;
  331. mutable asCMap<int, asCScriptFunction*> mapTypeIdToFunction;
  332. // Garbage collector
  333. asCGarbageCollector gc;
  334. // Dynamic groups
  335. asCConfigGroup defaultGroup;
  336. asCArray<asCConfigGroup*> configGroups;
  337. asCConfigGroup *currentGroup;
  338. asDWORD defaultAccessMask;
  339. asSNameSpace *defaultNamespace;
  340. // Message callback
  341. bool msgCallback;
  342. asSSystemFunctionInterface msgCallbackFunc;
  343. void *msgCallbackObj;
  344. struct preMessage_t
  345. {
  346. preMessage_t() { isSet = false; }
  347. bool isSet;
  348. asCString message;
  349. asCString scriptname;
  350. int r;
  351. int c;
  352. } preMessage;
  353. // JIt compilation
  354. asIJITCompiler *jitCompiler;
  355. // Namespaces
  356. // These are shared between all entities and are
  357. // only deleted once the engine is destroyed
  358. asCArray<asSNameSpace*> nameSpaces;
  359. // String constants
  360. // These are shared between all scripts and are
  361. // only deleted once the engine is destroyed
  362. asCArray<asCString*> stringConstants;
  363. asCMap<asCStringPointer, int> stringToIdMap;
  364. // Callbacks for context pooling
  365. asREQUESTCONTEXTFUNC_t requestCtxFunc;
  366. asRETURNCONTEXTFUNC_t returnCtxFunc;
  367. void *ctxCallbackParam;
  368. // User data
  369. asCArray<asPWORD> userData;
  370. struct SEngineClean { asPWORD type; asCLEANENGINEFUNC_t cleanFunc; };
  371. asCArray<SEngineClean> cleanEngineFuncs;
  372. struct SModuleClean { asPWORD type; asCLEANMODULEFUNC_t cleanFunc; };
  373. asCArray<SModuleClean> cleanModuleFuncs;
  374. struct SContextClean { asPWORD type; asCLEANCONTEXTFUNC_t cleanFunc; };
  375. asCArray<SContextClean> cleanContextFuncs;
  376. struct SFunctionClean { asPWORD type; asCLEANFUNCTIONFUNC_t cleanFunc; };
  377. asCArray<SFunctionClean> cleanFunctionFuncs;
  378. struct SObjTypeClean { asPWORD type; asCLEANOBJECTTYPEFUNC_t cleanFunc; };
  379. asCArray<SObjTypeClean> cleanObjectTypeFuncs;
  380. struct SScriptObjClean { asPWORD type; asCLEANSCRIPTOBJECTFUNC_t cleanFunc; };
  381. asCArray<SScriptObjClean> cleanScriptObjectFuncs;
  382. // Synchronization for threads
  383. DECLAREREADWRITELOCK(mutable engineRWLock)
  384. // Engine properties
  385. struct
  386. {
  387. bool allowUnsafeReferences;
  388. bool optimizeByteCode;
  389. bool copyScriptSections;
  390. asUINT maximumContextStackSize;
  391. bool useCharacterLiterals;
  392. bool allowMultilineStrings;
  393. bool allowImplicitHandleTypes;
  394. bool buildWithoutLineCues;
  395. bool initGlobalVarsAfterBuild;
  396. bool requireEnumScope;
  397. int scanner;
  398. bool includeJitInstructions;
  399. int stringEncoding;
  400. int propertyAccessorMode;
  401. bool expandDefaultArrayToTemplate;
  402. bool autoGarbageCollect;
  403. bool disallowGlobalVars;
  404. bool alwaysImplDefaultConstruct;
  405. int compilerWarnings;
  406. bool disallowValueAssignForRefType;
  407. // TODO: 3.0.0: Remove the alterSyntaxNamedArgs
  408. int alterSyntaxNamedArgs;
  409. bool disableIntegerDivision;
  410. bool disallowEmptyListElements;
  411. // TODO: 3.0.0: Remove the privatePropAsProtected
  412. bool privatePropAsProtected;
  413. } ep;
  414. // This flag is to allow a quicker shutdown when releasing the engine
  415. bool shuttingDown;
  416. // This flag is set when the engine's destructor is called, this is to
  417. // avoid recursive calls if an object happens to increment/decrement
  418. // the ref counter during shutdown
  419. bool inDestructor;
  420. };
  421. END_AS_NAMESPACE
  422. #endif