as_scriptengine.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /*
  2. AngelCode Scripting Library
  3. Copyright (c) 2003-2019 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 *auxiliary = 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, int compositeOffset = 0, bool isCompositeIndirect = false);
  81. virtual int RegisterObjectMethod(const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false);
  82. 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);
  83. virtual int RegisterInterface(const char *name);
  84. virtual int RegisterInterfaceMethod(const char *intf, const char *declaration);
  85. virtual asUINT GetObjectTypeCount() const;
  86. virtual asITypeInfo *GetObjectTypeByIndex(asUINT index) const;
  87. // String factory
  88. virtual int RegisterStringFactory(const char *datatype, asIStringFactory *factory);
  89. virtual int GetStringFactoryReturnTypeId(asDWORD *flags) const;
  90. // Default array type
  91. virtual int RegisterDefaultArrayType(const char *type);
  92. virtual int GetDefaultArrayTypeId() const;
  93. // Enums
  94. virtual int RegisterEnum(const char *type);
  95. virtual int RegisterEnumValue(const char *type, const char *name, int value);
  96. virtual asUINT GetEnumCount() const;
  97. virtual asITypeInfo *GetEnumByIndex(asUINT index) const;
  98. // Funcdefs
  99. virtual int RegisterFuncdef(const char *decl);
  100. virtual asUINT GetFuncdefCount() const;
  101. virtual asITypeInfo *GetFuncdefByIndex(asUINT index) const;
  102. // Typedefs
  103. // TODO: interface: Should perhaps rename this to Alias, since it doesn't really create a new type
  104. virtual int RegisterTypedef(const char *type, const char *decl);
  105. virtual asUINT GetTypedefCount() const;
  106. virtual asITypeInfo *GetTypedefByIndex(asUINT index) const;
  107. // Configuration groups
  108. virtual int BeginConfigGroup(const char *groupName);
  109. virtual int EndConfigGroup();
  110. virtual int RemoveConfigGroup(const char *groupName);
  111. virtual asDWORD SetDefaultAccessMask(asDWORD defaultMask);
  112. virtual int SetDefaultNamespace(const char *nameSpace);
  113. virtual const char *GetDefaultNamespace() const;
  114. // Script modules
  115. virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag);
  116. virtual int DiscardModule(const char *module);
  117. virtual asUINT GetModuleCount() const;
  118. virtual asIScriptModule *GetModuleByIndex(asUINT index) const;
  119. // Script functions
  120. virtual asIScriptFunction *GetFunctionById(int funcId) const;
  121. // Type identification
  122. virtual int GetTypeIdByDecl(const char *decl) const;
  123. virtual const char *GetTypeDeclaration(int typeId, bool includeNamespace = false) const;
  124. virtual int GetSizeOfPrimitiveType(int typeId) const;
  125. virtual asITypeInfo *GetTypeInfoById(int typeId) const;
  126. virtual asITypeInfo *GetTypeInfoByName(const char *name) const;
  127. virtual asITypeInfo *GetTypeInfoByDecl(const char *decl) const;
  128. // Script execution
  129. virtual asIScriptContext *CreateContext();
  130. virtual void *CreateScriptObject(const asITypeInfo *type);
  131. virtual void *CreateScriptObjectCopy(void *obj, const asITypeInfo *type);
  132. virtual void *CreateUninitializedScriptObject(const asITypeInfo *type);
  133. virtual asIScriptFunction *CreateDelegate(asIScriptFunction *func, void *obj);
  134. virtual int AssignScriptObject(void *dstObj, void *srcObj, const asITypeInfo *type);
  135. virtual void ReleaseScriptObject(void *obj, const asITypeInfo *type);
  136. virtual void AddRefScriptObject(void *obj, const asITypeInfo *type);
  137. virtual int RefCastObject(void *obj, asITypeInfo *fromType, asITypeInfo *toType, void **newPtr, bool useOnlyImplicitCast = false);
  138. virtual asILockableSharedBool *GetWeakRefFlagOfScriptObject(void *obj, const asITypeInfo *type) const;
  139. // Context pooling
  140. virtual asIScriptContext *RequestContext();
  141. virtual void ReturnContext(asIScriptContext *ctx);
  142. virtual int SetContextCallbacks(asREQUESTCONTEXTFUNC_t requestCtx, asRETURNCONTEXTFUNC_t returnCtx, void *param = 0);
  143. // String interpretation
  144. virtual asETokenClass ParseToken(const char *string, size_t stringLength = 0, asUINT *tokenLength = 0) const;
  145. // Garbage collection
  146. virtual int GarbageCollect(asDWORD flags = asGC_FULL_CYCLE, asUINT numIterations = 1);
  147. virtual void GetGCStatistics(asUINT *currentSize, asUINT *totalDestroyed, asUINT *totalDetected, asUINT *newObjects, asUINT *totalNewDestroyed) const;
  148. virtual int NotifyGarbageCollectorOfNewObject(void *obj, asITypeInfo *type);
  149. virtual int GetObjectInGC(asUINT idx, asUINT *seqNbr, void **obj = 0, asITypeInfo **type = 0);
  150. virtual void GCEnumCallback(void *reference);
  151. virtual void ForwardGCEnumReferences(void *ref, asITypeInfo *type);
  152. virtual void ForwardGCReleaseReferences(void *ref, asITypeInfo *type);
  153. virtual void SetCircularRefDetectedCallback(asCIRCULARREFFUNC_t callback, void *param = 0);
  154. // User data
  155. virtual void *SetUserData(void *data, asPWORD type);
  156. virtual void *GetUserData(asPWORD type) const;
  157. virtual void SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback, asPWORD type);
  158. virtual void SetModuleUserDataCleanupCallback(asCLEANMODULEFUNC_t callback, asPWORD type);
  159. virtual void SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback, asPWORD type);
  160. virtual void SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback, asPWORD type);
  161. virtual void SetTypeInfoUserDataCleanupCallback(asCLEANTYPEINFOFUNC_t callback, asPWORD type);
  162. virtual void SetScriptObjectUserDataCleanupCallback(asCLEANSCRIPTOBJECTFUNC_t callback, asPWORD type);
  163. // Exception handling
  164. virtual int SetTranslateAppExceptionCallback(asSFuncPtr callback, void *param, int callConv);
  165. //===========================================================
  166. // internal methods
  167. //===========================================================
  168. public:
  169. asCScriptEngine();
  170. virtual ~asCScriptEngine();
  171. //protected:
  172. friend class asCBuilder;
  173. friend class asCCompiler;
  174. friend class asCContext;
  175. friend class asCDataType;
  176. friend class asCModule;
  177. friend class asCRestore;
  178. friend class asCByteCode;
  179. friend int PrepareSystemFunction(asCScriptFunction *func, asSSystemFunctionInterface *internal, asCScriptEngine *engine);
  180. int RegisterMethodToObjectType(asCObjectType *objectType, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false);
  181. int RegisterBehaviourToObjectType(asCObjectType *objectType, asEBehaviours behaviour, const char *decl, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false);
  182. int VerifyVarTypeNotInFunction(asCScriptFunction *func);
  183. void *CallAlloc(const asCObjectType *objType) const;
  184. void CallFree(void *obj) const;
  185. void *CallGlobalFunctionRetPtr(int func) const;
  186. void *CallGlobalFunctionRetPtr(int func, void *param1) const;
  187. void *CallGlobalFunctionRetPtr(asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  188. void *CallGlobalFunctionRetPtr(asSSystemFunctionInterface *i, asCScriptFunction *s, void *param1) const;
  189. void CallObjectMethod(void *obj, int func) const;
  190. void CallObjectMethod(void *obj, void *param, int func) const;
  191. void CallObjectMethod(void *obj, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  192. void CallObjectMethod(void *obj, void *param, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  193. bool CallObjectMethodRetBool(void *obj, int func) const;
  194. int CallObjectMethodRetInt(void *obj, int func) const;
  195. void *CallObjectMethodRetPtr(void *obj, int func) const;
  196. void *CallObjectMethodRetPtr(void *obj, int param1, asCScriptFunction *func) const;
  197. void CallGlobalFunction(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  198. bool CallGlobalFunctionRetBool(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc) const;
  199. int CallScriptObjectMethod(void *obj, int func);
  200. void ConstructScriptObjectCopy(void *mem, void *obj, asCObjectType *type);
  201. void DeleteDiscardedModules();
  202. void RemoveTemplateInstanceType(asCObjectType *t);
  203. asCConfigGroup *FindConfigGroupForFunction(int funcId) const;
  204. asCConfigGroup *FindConfigGroupForGlobalVar(int gvarId) const;
  205. asCConfigGroup *FindConfigGroupForTypeInfo(const asCTypeInfo *type) const;
  206. asCConfigGroup *FindConfigGroupForFuncDef(const asCFuncdefType *funcDef) const;
  207. int RequestBuild();
  208. void BuildCompleted();
  209. void PrepareEngine();
  210. bool isPrepared;
  211. int CreateContext(asIScriptContext **context, bool isInternal);
  212. asCTypeInfo *GetRegisteredType(const asCString &name, asSNameSpace *ns) const;
  213. asCObjectType *GetListPatternType(int listPatternFuncId);
  214. void DestroyList(asBYTE *buffer, const asCObjectType *listPatternType);
  215. void DestroySubList(asBYTE *&buffer, asSListPatternNode *&patternNode);
  216. int AddBehaviourFunction(asCScriptFunction &func, asSSystemFunctionInterface &internal);
  217. asCString GetFunctionDeclaration(int funcId);
  218. asCScriptFunction *GetScriptFunction(int funcId) const;
  219. asCModule *GetModule(const char *name, bool create);
  220. asCModule *GetModuleFromFuncId(int funcId);
  221. int GetMethodIdByDecl(const asCObjectType *ot, const char *decl, asCModule *mod);
  222. int GetFactoryIdByDecl(const asCObjectType *ot, const char *decl);
  223. int GetNextScriptFunctionId();
  224. void AddScriptFunction(asCScriptFunction *func);
  225. void RemoveScriptFunction(asCScriptFunction *func);
  226. void RemoveFuncdef(asCFuncdefType *func);
  227. int ConfigError(int err, const char *funcName, const char *arg1, const char *arg2);
  228. int GetTypeIdFromDataType(const asCDataType &dt) const;
  229. asCDataType GetDataTypeFromTypeId(int typeId) const;
  230. asCObjectType *GetObjectTypeFromTypeId(int typeId) const;
  231. void RemoveFromTypeIdMap(asCTypeInfo *type);
  232. bool IsTemplateType(const char *name) const;
  233. int SetTemplateRestrictions(asCObjectType *templateType, asCScriptFunction *func, const char *caller, const char *decl);
  234. asCObjectType *GetTemplateInstanceType(asCObjectType *templateType, asCArray<asCDataType> &subTypes, asCModule *requestingModule);
  235. asCScriptFunction *GenerateTemplateFactoryStub(asCObjectType *templateType, asCObjectType *templateInstanceType, int origFactoryId);
  236. bool GenerateNewTemplateFunction(asCObjectType *templateType, asCObjectType *templateInstanceType, asCScriptFunction *templateFunc, asCScriptFunction **newFunc);
  237. asCFuncdefType *GenerateNewTemplateFuncdef(asCObjectType *templateType, asCObjectType *templateInstanceType, asCFuncdefType *templateFuncdef);
  238. asCDataType DetermineTypeForTemplate(const asCDataType &orig, asCObjectType *tmpl, asCObjectType *ot);
  239. bool RequireTypeReplacement(asCDataType &type, asCObjectType *templateType);
  240. asCModule *FindNewOwnerForSharedType(asCTypeInfo *type, asCModule *mod);
  241. asCModule *FindNewOwnerForSharedFunc(asCScriptFunction *func, asCModule *mod);
  242. asCFuncdefType *FindMatchingFuncdef(asCScriptFunction *func, asCModule *mod);
  243. int DetermineNameAndNamespace(const char *in_name, asSNameSpace *implicitNs, asCString &out_name, asSNameSpace *&out_ns) const;
  244. // Global property management
  245. asCGlobalProperty *AllocateGlobalProperty();
  246. void RemoveGlobalProperty(asCGlobalProperty *prop);
  247. int GetScriptSectionNameIndex(const char *name);
  248. // Namespace management
  249. asSNameSpace *AddNameSpace(const char *name);
  250. asSNameSpace *FindNameSpace(const char *name) const;
  251. asSNameSpace *GetParentNameSpace(asSNameSpace *ns) const;
  252. //===========================================================
  253. // internal properties
  254. //===========================================================
  255. asCMemoryMgr memoryMgr;
  256. asCObjectType *defaultArrayObjectType;
  257. asCObjectType scriptTypeBehaviours;
  258. asCObjectType functionBehaviours;
  259. // Registered interface
  260. asCArray<asCObjectType *> registeredObjTypes; // doesn't increase ref count
  261. asCArray<asCTypedefType *> registeredTypeDefs; // doesn't increase ref count
  262. asCArray<asCEnumType *> registeredEnums; // doesn't increase ref count
  263. // TODO: memory savings: Since there can be only one property with the same name a simpler symbol table should be used for global props
  264. asCSymbolTable<asCGlobalProperty> registeredGlobalProps; // increases ref count
  265. asCSymbolTable<asCScriptFunction> registeredGlobalFuncs;
  266. asCArray<asCFuncdefType *> registeredFuncDefs; // doesn't increase ref count
  267. asCArray<asCObjectType *> registeredTemplateTypes; // doesn't increase ref count
  268. asIStringFactory *stringFactory;
  269. asCDataType stringType;
  270. bool configFailed;
  271. // Stores all registered types
  272. asCMap<asSNameSpaceNamePair, asCTypeInfo*> allRegisteredTypes; // increases ref count
  273. // Dummy types used to name the subtypes in the template objects
  274. asCArray<asCTypeInfo *> templateSubTypes;
  275. // Store information about template types
  276. // This list will contain all instances of templates, both registered specialized
  277. // types and those automacially instantiated from scripts
  278. asCArray<asCObjectType *> templateInstanceTypes; // increases ref count
  279. // Store information about list patterns
  280. asCArray<asCObjectType *> listPatternTypes; // increases ref count
  281. // Stores all global properties, both those registered by application, and those declared by scripts.
  282. // The id of a global property is the index in this array.
  283. asCArray<asCGlobalProperty *> globalProperties; // increases ref count
  284. asCArray<int> freeGlobalPropertyIds;
  285. // This map is used to quickly find a property by its memory address
  286. // It is used principally during building, cleanup, and garbage detection for script functions
  287. asCMap<void*, asCGlobalProperty*> varAddressMap; // doesn't increase ref count
  288. // Stores all functions, i.e. registered functions, script functions, class methods, behaviours, etc.
  289. asCArray<asCScriptFunction *> scriptFunctions; // doesn't increase ref count
  290. asCArray<int> freeScriptFunctionIds;
  291. asCArray<asCScriptFunction *> signatureIds;
  292. // An array with all module imported functions
  293. asCArray<sBindInfo *> importedFunctions; // doesn't increase ref count
  294. asCArray<int> freeImportedFunctionIdxs;
  295. // Synchronized
  296. mutable asCAtomic refCount;
  297. // Synchronized with engineRWLock
  298. // This array holds all live script modules
  299. asCArray<asCModule *> scriptModules;
  300. // Synchronized with engineRWLock
  301. // This is a pointer to the last module that was requested. It is used for performance
  302. // improvement, since it is common that the same module is accessed many times in a row
  303. asCModule *lastModule;
  304. // Synchronized with engineRWLock
  305. // This flag is true if a script is currently being compiled. It is used to prevent multiple
  306. // threads from requesting builds at the same time (without blocking)
  307. bool isBuilding;
  308. // Synchronized with engineRWLock
  309. // This array holds modules that have been discard (thus are no longer visible to the application)
  310. // but cannot yet be deleted due to having external references to some of the entities in them
  311. asCArray<asCModule *> discardedModules;
  312. // This flag is set to true during compilations of scripts (or loading pre-compiled scripts)
  313. // to delay the validation of template types until the subtypes have been fully declared
  314. bool deferValidationOfTemplateTypes;
  315. // Tokenizer is instantiated once to share resources
  316. asCTokenizer tok;
  317. // Stores shared script declared types (classes, interfaces, enums)
  318. asCArray<asCTypeInfo *> sharedScriptTypes; // increases ref count
  319. // This array stores the template instances types that have been automatically generated from template types
  320. asCArray<asCObjectType *> generatedTemplateTypes;
  321. // Stores the funcdefs
  322. // TODO: redesign: Only shared funcdefs should be stored here
  323. // a funcdef becomes shared if all arguments and the return type are shared (or application registered)
  324. asCArray<asCFuncdefType *> funcDefs; // doesn't increases ref count
  325. // Stores the names of the script sections for debugging purposes
  326. asCArray<asCString *> scriptSectionNames;
  327. // Type identifiers
  328. mutable int typeIdSeqNbr;
  329. mutable asCMap<int, asCTypeInfo*> mapTypeIdToTypeInfo;
  330. // Garbage collector
  331. asCGarbageCollector gc;
  332. // Dynamic groups
  333. asCConfigGroup defaultGroup;
  334. asCArray<asCConfigGroup*> configGroups;
  335. asCConfigGroup *currentGroup;
  336. asDWORD defaultAccessMask;
  337. asSNameSpace *defaultNamespace;
  338. // Message callback
  339. bool msgCallback;
  340. asSSystemFunctionInterface msgCallbackFunc;
  341. void *msgCallbackObj;
  342. struct preMessage_t
  343. {
  344. preMessage_t() { isSet = false; }
  345. bool isSet;
  346. asCString message;
  347. asCString scriptname;
  348. int r;
  349. int c;
  350. } preMessage;
  351. // JIt compilation
  352. asIJITCompiler *jitCompiler;
  353. // Namespaces
  354. // These are shared between all entities and are
  355. // only deleted once the engine is destroyed
  356. asCArray<asSNameSpace*> nameSpaces;
  357. // Callbacks for context pooling
  358. asREQUESTCONTEXTFUNC_t requestCtxFunc;
  359. asRETURNCONTEXTFUNC_t returnCtxFunc;
  360. void *ctxCallbackParam;
  361. // User data
  362. asCArray<asPWORD> userData;
  363. struct SEngineClean { asPWORD type; asCLEANENGINEFUNC_t cleanFunc; };
  364. asCArray<SEngineClean> cleanEngineFuncs;
  365. struct SModuleClean { asPWORD type; asCLEANMODULEFUNC_t cleanFunc; };
  366. asCArray<SModuleClean> cleanModuleFuncs;
  367. struct SContextClean { asPWORD type; asCLEANCONTEXTFUNC_t cleanFunc; };
  368. asCArray<SContextClean> cleanContextFuncs;
  369. struct SFunctionClean { asPWORD type; asCLEANFUNCTIONFUNC_t cleanFunc; };
  370. asCArray<SFunctionClean> cleanFunctionFuncs;
  371. struct STypeInfoClean { asPWORD type; asCLEANTYPEINFOFUNC_t cleanFunc; };
  372. asCArray<STypeInfoClean> cleanTypeInfoFuncs;
  373. struct SScriptObjClean { asPWORD type; asCLEANSCRIPTOBJECTFUNC_t cleanFunc; };
  374. asCArray<SScriptObjClean> cleanScriptObjectFuncs;
  375. // Synchronization for threads
  376. DECLAREREADWRITELOCK(mutable engineRWLock)
  377. // Engine properties
  378. struct
  379. {
  380. bool allowUnsafeReferences;
  381. bool optimizeByteCode;
  382. bool copyScriptSections;
  383. asUINT maximumContextStackSize;
  384. asUINT initContextStackSize;
  385. bool useCharacterLiterals;
  386. bool allowMultilineStrings;
  387. bool allowImplicitHandleTypes;
  388. bool buildWithoutLineCues;
  389. bool initGlobalVarsAfterBuild;
  390. bool requireEnumScope;
  391. int scanner;
  392. bool includeJitInstructions;
  393. int stringEncoding;
  394. int propertyAccessorMode;
  395. bool expandDefaultArrayToTemplate;
  396. bool autoGarbageCollect;
  397. bool disallowGlobalVars;
  398. bool alwaysImplDefaultConstruct;
  399. int compilerWarnings;
  400. bool disallowValueAssignForRefType;
  401. // TODO: 3.0.0: Remove the alterSyntaxNamedArgs
  402. int alterSyntaxNamedArgs;
  403. bool disableIntegerDivision;
  404. bool disallowEmptyListElements;
  405. // TODO: 3.0.0: Remove the privatePropAsProtected
  406. bool privatePropAsProtected;
  407. bool allowUnicodeIdentifiers;
  408. int heredocTrimMode;
  409. asUINT maxNestedCalls;
  410. asUINT genericCallMode;
  411. asUINT initCallStackSize;
  412. asUINT maxCallStackSize;
  413. } ep;
  414. // Callbacks
  415. #ifndef AS_NO_EXCEPTIONS
  416. bool translateExceptionCallback;
  417. asSSystemFunctionInterface translateExceptionCallbackFunc;
  418. void * translateExceptionCallbackObj;
  419. #endif
  420. // This flag is to allow a quicker shutdown when releasing the engine
  421. bool shuttingDown;
  422. // This flag is set when the engine's destructor is called, this is to
  423. // avoid recursive calls if an object happens to increment/decrement
  424. // the ref counter during shutdown
  425. bool inDestructor;
  426. };
  427. END_AS_NAMESPACE
  428. #endif