PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/xbmc/visualizations/Vortex/angelscript/docs/doxygen/source/angelscript.h

https://bitbucket.org/bgiorgini/xbmc
C Header | 3862 lines | 1244 code | 265 blank | 2353 comment | 5 complexity | 41f23e90b623c1f5a6974d5bb9d8929e MD5 | raw file
Possible License(s): GPL-3.0, CC-BY-SA-3.0, BSD-3-Clause, GPL-2.0, LGPL-3.0, 0BSD, LGPL-2.0, AGPL-1.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. AngelCode Scripting Library
  3. Copyright (c) 2003-2009 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. // angelscript.h
  25. //
  26. // The script engine interface
  27. //
  28. //! \file angelscript.h
  29. //! \brief The API definition for AngelScript.
  30. //!
  31. //! This header file describes the complete application programming interface for AngelScript.
  32. #ifndef ANGELSCRIPT_H
  33. #define ANGELSCRIPT_H
  34. #include <stddef.h>
  35. #ifdef AS_USE_NAMESPACE
  36. #define BEGIN_AS_NAMESPACE namespace AngelScript {
  37. #define END_AS_NAMESPACE }
  38. #else
  39. #define BEGIN_AS_NAMESPACE
  40. #define END_AS_NAMESPACE
  41. #endif
  42. BEGIN_AS_NAMESPACE
  43. // AngelScript version
  44. //! \details Version 2.18.0
  45. #define ANGELSCRIPT_VERSION 21800
  46. #define ANGELSCRIPT_VERSION_STRING "2.18.0"
  47. // Data types
  48. class asIScriptEngine;
  49. class asIScriptModule;
  50. class asIScriptContext;
  51. class asIScriptGeneric;
  52. class asIScriptObject;
  53. class asIScriptArray;
  54. class asIObjectType;
  55. class asIScriptFunction;
  56. class asIBinaryStream;
  57. class asIJITCompiler;
  58. // Enumerations and constants
  59. // Engine properties
  60. //! Engine properties
  61. enum asEEngineProp
  62. {
  63. //! Allow unsafe references. Default: false.
  64. asEP_ALLOW_UNSAFE_REFERENCES = 1,
  65. //! Optimize byte code. Default: true.
  66. asEP_OPTIMIZE_BYTECODE = 2,
  67. //! Copy script section memory. Default: true.
  68. asEP_COPY_SCRIPT_SECTIONS = 3,
  69. //! Maximum stack size for script contexts. Default: 0 (no limit).
  70. asEP_MAX_STACK_SIZE = 4,
  71. //! Interpret single quoted strings as character literals. Default: false.
  72. asEP_USE_CHARACTER_LITERALS = 5,
  73. //! Allow linebreaks in string constants. Default: false.
  74. asEP_ALLOW_MULTILINE_STRINGS = 6,
  75. //! Allow script to declare implicit handle types. Default: false.
  76. asEP_ALLOW_IMPLICIT_HANDLE_TYPES = 7,
  77. //! Remove SUSPEND instructions between each statement. Default: false.
  78. asEP_BUILD_WITHOUT_LINE_CUES = 8,
  79. //! Initialize global variables after a build. Default: true.
  80. asEP_INIT_GLOBAL_VARS_AFTER_BUILD = 9,
  81. //! When set the enum values must be prefixed with the enum type. Default: false.
  82. asEP_REQUIRE_ENUM_SCOPE = 10,
  83. //! Select scanning method: 0 - ASCII, 1 - UTF8. Default: 1 (UTF8).
  84. asEP_SCRIPT_SCANNER = 11,
  85. //! When set extra bytecode instructions needed for JIT compiled funcions will be included. Default: false.
  86. asEP_INCLUDE_JIT_INSTRUCTIONS = 12,
  87. //! Select string encoding for literals: 0 - UTF8/ASCII, 1 - UTF16. Default: 0 (UTF8)
  88. asEP_STRING_ENCODING = 13
  89. };
  90. // Calling conventions
  91. //! Calling conventions
  92. enum asECallConvTypes
  93. {
  94. //! A cdecl function.
  95. asCALL_CDECL = 0,
  96. //! A stdcall function.
  97. asCALL_STDCALL = 1,
  98. //! A thiscall class method.
  99. asCALL_THISCALL = 2,
  100. //! A cdecl function that takes the object pointer as the last parameter.
  101. asCALL_CDECL_OBJLAST = 3,
  102. //! A cdecl function that takes the object pointer as the first parameter.
  103. asCALL_CDECL_OBJFIRST = 4,
  104. //! A function using the generic calling convention.
  105. asCALL_GENERIC = 5
  106. };
  107. // Object type flags
  108. //! Object type flags
  109. enum asEObjTypeFlags
  110. {
  111. //! A reference type.
  112. asOBJ_REF = 0x01,
  113. //! A value type.
  114. asOBJ_VALUE = 0x02,
  115. //! A garbage collected type. Only valid for reference types.
  116. asOBJ_GC = 0x04,
  117. //! A plain-old-data type. Only valid for value types.
  118. asOBJ_POD = 0x08,
  119. //! This reference type doesn't allow handles to be held. Only valid for reference types.
  120. asOBJ_NOHANDLE = 0x10,
  121. //! The life time of objects of this type are controlled by the scope of the variable. Only valid for reference types.
  122. asOBJ_SCOPED = 0x20,
  123. //! A template type.
  124. asOBJ_TEMPLATE = 0x40,
  125. //! The C++ type is a class type. Only valid for value types.
  126. asOBJ_APP_CLASS = 0x100,
  127. //! The C++ class has an explicit constructor. Only valid for value types.
  128. asOBJ_APP_CLASS_CONSTRUCTOR = 0x200,
  129. //! The C++ class has an explicit destructor. Only valid for value types.
  130. asOBJ_APP_CLASS_DESTRUCTOR = 0x400,
  131. //! The C++ class has an explicit assignment operator. Only valid for value types.
  132. asOBJ_APP_CLASS_ASSIGNMENT = 0x800,
  133. //! The C++ type is a class with a constructor, but no destructor or assignment operator.
  134. asOBJ_APP_CLASS_C = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR),
  135. //! The C++ type is a class with a constructor and destructor, but no assignment operator.
  136. asOBJ_APP_CLASS_CD = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR),
  137. //! The C++ type is a class with a constructor and assignment operator, but no destructor.
  138. asOBJ_APP_CLASS_CA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),
  139. //! The C++ type is a class with a constructor, destructor, and assignment operator.
  140. asOBJ_APP_CLASS_CDA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),
  141. //! The C++ type is a class with a destructor, but no constructor or assignment operator.
  142. asOBJ_APP_CLASS_D = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR),
  143. //! The C++ type is a class with an assignment operator, but no constructor or destructor.
  144. asOBJ_APP_CLASS_A = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_ASSIGNMENT),
  145. //! The C++ type is a class with a destructor and assignment operator, but no constructor.
  146. asOBJ_APP_CLASS_DA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),
  147. //! The C++ type is a primitive type. Only valid for value types.
  148. asOBJ_APP_PRIMITIVE = 0x1000,
  149. //! The C++ type is a float or double. Only valid for value types.
  150. asOBJ_APP_FLOAT = 0x2000,
  151. asOBJ_MASK_VALID_FLAGS = 0x3F7F,
  152. //! The object is a script class or an interface.
  153. asOBJ_SCRIPT_OBJECT = 0x10000
  154. };
  155. // Behaviours
  156. //! Behaviours
  157. enum asEBehaviours
  158. {
  159. // Value object memory management
  160. //! \brief Constructor
  161. asBEHAVE_CONSTRUCT,
  162. //! \brief Destructor
  163. asBEHAVE_DESTRUCT,
  164. // Reference object memory management
  165. //! \brief Factory
  166. asBEHAVE_FACTORY,
  167. //! \brief AddRef
  168. asBEHAVE_ADDREF,
  169. //! \brief Release
  170. asBEHAVE_RELEASE,
  171. // Object operators
  172. //! \brief Explicit value cast operator
  173. asBEHAVE_VALUE_CAST,
  174. //! \brief Implicit value cast operator
  175. asBEHAVE_IMPLICIT_VALUE_CAST,
  176. //! \brief Explicit reference cast operator
  177. asBEHAVE_REF_CAST,
  178. //! \brief Implicit reference cast operator
  179. asBEHAVE_IMPLICIT_REF_CAST,
  180. //! \brief operator []
  181. asBEHAVE_INDEX,
  182. //! \brief Callback for validating template instances
  183. asBEHAVE_TEMPLATE_CALLBACK,
  184. // Garbage collection behaviours
  185. asBEHAVE_FIRST_GC,
  186. //! \brief (GC) Get reference count
  187. asBEHAVE_GETREFCOUNT = asBEHAVE_FIRST_GC,
  188. //! \brief (GC) Set GC flag
  189. asBEHAVE_SETGCFLAG,
  190. //! \brief (GC) Get GC flag
  191. asBEHAVE_GETGCFLAG,
  192. //! \brief (GC) Enumerate held references
  193. asBEHAVE_ENUMREFS,
  194. //! \brief (GC) Release all references
  195. asBEHAVE_RELEASEREFS,
  196. asBEHAVE_LAST_GC = asBEHAVE_RELEASEREFS,
  197. asBEHAVE_MAX
  198. };
  199. // Return codes
  200. //! Return codes
  201. enum asERetCodes
  202. {
  203. //! Success
  204. asSUCCESS = 0,
  205. //! Failure
  206. asERROR = -1,
  207. //! The context is active
  208. asCONTEXT_ACTIVE = -2,
  209. //! The context is not finished
  210. asCONTEXT_NOT_FINISHED = -3,
  211. //! The context is not prepared
  212. asCONTEXT_NOT_PREPARED = -4,
  213. //! Invalid argument
  214. asINVALID_ARG = -5,
  215. //! The function was not found
  216. asNO_FUNCTION = -6,
  217. //! Not supported
  218. asNOT_SUPPORTED = -7,
  219. //! Invalid name
  220. asINVALID_NAME = -8,
  221. //! The name is already taken
  222. asNAME_TAKEN = -9,
  223. //! Invalid declaration
  224. asINVALID_DECLARATION = -10,
  225. //! Invalid object
  226. asINVALID_OBJECT = -11,
  227. //! Invalid type
  228. asINVALID_TYPE = -12,
  229. //! Already registered
  230. asALREADY_REGISTERED = -13,
  231. //! Multiple matching functions
  232. asMULTIPLE_FUNCTIONS = -14,
  233. //! The module was not found
  234. asNO_MODULE = -15,
  235. //! The global variable was not found
  236. asNO_GLOBAL_VAR = -16,
  237. //! Invalid configuration
  238. asINVALID_CONFIGURATION = -17,
  239. //! Invalid interface
  240. asINVALID_INTERFACE = -18,
  241. //! All imported functions couldn't be bound
  242. asCANT_BIND_ALL_FUNCTIONS = -19,
  243. //! The array sub type has not been registered yet
  244. asLOWER_ARRAY_DIMENSION_NOT_REGISTERED = -20,
  245. //! Wrong configuration group
  246. asWRONG_CONFIG_GROUP = -21,
  247. //! The configuration group is in use
  248. asCONFIG_GROUP_IS_IN_USE = -22,
  249. //! Illegal behaviour for the type
  250. asILLEGAL_BEHAVIOUR_FOR_TYPE = -23,
  251. //! The specified calling convention doesn't match the function/method pointer
  252. asWRONG_CALLING_CONV = -24,
  253. //! A build is currently in progress
  254. asBUILD_IN_PROGRESS = -25,
  255. //! The initialization of global variables failed
  256. asINIT_GLOBAL_VARS_FAILED = -26
  257. };
  258. // Context states
  259. //! \brief Context states.
  260. enum asEContextState
  261. {
  262. //! The context has successfully completed the execution.
  263. asEXECUTION_FINISHED = 0,
  264. //! The execution is suspended and can be resumed.
  265. asEXECUTION_SUSPENDED = 1,
  266. //! The execution was aborted by the application.
  267. asEXECUTION_ABORTED = 2,
  268. //! The execution was terminated by an unhandled script exception.
  269. asEXECUTION_EXCEPTION = 3,
  270. //! The context has been prepared for a new execution.
  271. asEXECUTION_PREPARED = 4,
  272. //! The context is not initialized.
  273. asEXECUTION_UNINITIALIZED = 5,
  274. //! The context is currently executing a function call.
  275. asEXECUTION_ACTIVE = 6,
  276. //! The context has encountered an error and must be reinitialized.
  277. asEXECUTION_ERROR = 7
  278. };
  279. #ifdef AS_DEPRECATED
  280. // Deprecated since 2.18.0, 2009-12-08
  281. // ExecuteString flags
  282. //! \brief ExecuteString flags.
  283. //! \deprecated since 2.18.0
  284. enum asEExecStrFlags
  285. {
  286. //! Only prepare the context
  287. asEXECSTRING_ONLY_PREPARE = 1,
  288. //! Use the pre-allocated context
  289. asEXECSTRING_USE_MY_CONTEXT = 2
  290. };
  291. #endif
  292. // Message types
  293. //! \brief Compiler message types.
  294. enum asEMsgType
  295. {
  296. //! The message is an error.
  297. asMSGTYPE_ERROR = 0,
  298. //! The message is a warning.
  299. asMSGTYPE_WARNING = 1,
  300. //! The message is informational only.
  301. asMSGTYPE_INFORMATION = 2
  302. };
  303. // Garbage collector flags
  304. //! \brief Garbage collector flags.
  305. enum asEGCFlags
  306. {
  307. //! Execute a full cycle.
  308. asGC_FULL_CYCLE = 1,
  309. //! Execute only one step
  310. asGC_ONE_STEP = 2,
  311. //! Destroy known garbage
  312. asGC_DESTROY_GARBAGE = 4,
  313. //! Detect garbage with circular references
  314. asGC_DETECT_GARBAGE = 8
  315. };
  316. // Token classes
  317. //! \brief Token classes.
  318. enum asETokenClass
  319. {
  320. //! Unknown token.
  321. asTC_UNKNOWN = 0,
  322. //! Keyword token.
  323. asTC_KEYWORD = 1,
  324. //! Literal value token.
  325. asTC_VALUE = 2,
  326. //! Identifier token.
  327. asTC_IDENTIFIER = 3,
  328. //! Comment token.
  329. asTC_COMMENT = 4,
  330. //! White space token.
  331. asTC_WHITESPACE = 5
  332. };
  333. // Prepare flags
  334. const int asPREPARE_PREVIOUS = -1;
  335. // Config groups
  336. const char * const asALL_MODULES = (const char * const)-1;
  337. // Type id flags
  338. //! \brief Type id flags
  339. enum asETypeIdFlags
  340. {
  341. //! The type id for void
  342. asTYPEID_VOID = 0,
  343. //! The type id for bool
  344. asTYPEID_BOOL = 1,
  345. //! The type id for int8
  346. asTYPEID_INT8 = 2,
  347. //! The type id for int16
  348. asTYPEID_INT16 = 3,
  349. //! The type id for int
  350. asTYPEID_INT32 = 4,
  351. //! The type id for int64
  352. asTYPEID_INT64 = 5,
  353. //! The type id for uint8
  354. asTYPEID_UINT8 = 6,
  355. //! The type id for uint16
  356. asTYPEID_UINT16 = 7,
  357. //! The type id for uint
  358. asTYPEID_UINT32 = 8,
  359. //! The type id for uint64
  360. asTYPEID_UINT64 = 9,
  361. //! The type id for float
  362. asTYPEID_FLOAT = 10,
  363. //! The type id for double
  364. asTYPEID_DOUBLE = 11,
  365. //! The bit that shows if the type is a handle
  366. asTYPEID_OBJHANDLE = 0x40000000,
  367. //! The bit that shows if the type is a handle to a const
  368. asTYPEID_HANDLETOCONST = 0x20000000,
  369. //! If any of these bits are set, then the type is an object
  370. asTYPEID_MASK_OBJECT = 0x1C000000,
  371. //! The bit that shows if the type is an application registered type
  372. asTYPEID_APPOBJECT = 0x04000000,
  373. //! The bit that shows if the type is a script class
  374. asTYPEID_SCRIPTOBJECT = 0x08000000,
  375. //! The bit that shows if the type is a script array
  376. asTYPEID_SCRIPTARRAY = 0x10000000,
  377. //! The mask for the type id sequence number
  378. asTYPEID_MASK_SEQNBR = 0x03FFFFFF
  379. };
  380. // Type modifiers
  381. //! \brief Type modifiers
  382. enum asETypeModifiers
  383. {
  384. //! No modification
  385. asTM_NONE = 0,
  386. //! Input reference
  387. asTM_INREF = 1,
  388. //! Output reference
  389. asTM_OUTREF = 2,
  390. //! In/out reference
  391. asTM_INOUTREF = 3
  392. };
  393. // GetModule flags
  394. //! \brief Flags for GetModule.
  395. enum asEGMFlags
  396. {
  397. //! \brief Don't return any module if it is not found.
  398. asGM_ONLY_IF_EXISTS = 0,
  399. //! \brief Create the module if it doesn't exist.
  400. asGM_CREATE_IF_NOT_EXISTS = 1,
  401. //! \brief Always create a new module, discarding the existing one.
  402. asGM_ALWAYS_CREATE = 2
  403. };
  404. // Compile flags
  405. //! \brief Flags for compilation
  406. enum asECompileFlags
  407. {
  408. //! \brief The compiled function should be added to the scope of the module.
  409. asCOMP_ADD_TO_MODULE = 1
  410. };
  411. //! \typedef asBYTE
  412. //! \brief 8 bit unsigned integer
  413. //! \typedef asWORD
  414. //! \brief 16 bit unsigned integer
  415. //! \typedef asDWORD
  416. //! \brief 32 bit unsigned integer
  417. //! \typedef asQWORD
  418. //! \brief 64 bit unsigned integer
  419. //! \typedef asUINT
  420. //! \brief 32 bit unsigned integer
  421. //! \typedef asINT64
  422. //! \brief 64 bit integer
  423. //! \typedef asPWORD
  424. //! \brief Unsigned integer with the size of a pointer.
  425. //
  426. // asBYTE = 8 bits
  427. // asWORD = 16 bits
  428. // asDWORD = 32 bits
  429. // asQWORD = 64 bits
  430. // asPWORD = size of pointer
  431. //
  432. typedef unsigned char asBYTE;
  433. typedef unsigned short asWORD;
  434. typedef unsigned int asUINT;
  435. typedef size_t asPWORD;
  436. #ifdef __LP64__
  437. typedef unsigned int asDWORD;
  438. typedef unsigned long asQWORD;
  439. typedef long asINT64;
  440. #else
  441. typedef unsigned long asDWORD;
  442. #if defined(__GNUC__) || defined(__MWERKS__)
  443. typedef unsigned long long asQWORD;
  444. typedef long long asINT64;
  445. #else
  446. typedef unsigned __int64 asQWORD;
  447. typedef __int64 asINT64;
  448. #endif
  449. #endif
  450. typedef void (*asFUNCTION_t)();
  451. typedef void (*asGENFUNC_t)(asIScriptGeneric *);
  452. //! The function signature for the custom memory allocation function
  453. typedef void *(*asALLOCFUNC_t)(size_t);
  454. //! The function signature for the custom memory deallocation function
  455. typedef void (*asFREEFUNC_t)(void *);
  456. //! \ingroup funcs
  457. //! \brief Returns an asSFuncPtr representing the function specified by the name
  458. #define asFUNCTION(f) asFunctionPtr(f)
  459. //! \ingroup funcs
  460. //! \brief Returns an asSFuncPtr representing the function specified by the name, parameter list, and return type
  461. #if defined(_MSC_VER) && _MSC_VER <= 1200
  462. // MSVC 6 has a bug that prevents it from properly compiling using the correct asFUNCTIONPR with operator >
  463. // so we need to use ordinary C style cast instead of static_cast. The drawback is that the compiler can't
  464. // check that the cast is really valid.
  465. #define asFUNCTIONPR(f,p,r) asFunctionPtr((void (*)())((r (*)p)(f)))
  466. #else
  467. #define asFUNCTIONPR(f,p,r) asFunctionPtr((void (*)())(static_cast<r (*)p>(f)))
  468. #endif
  469. #ifndef AS_NO_CLASS_METHODS
  470. class asCUnknownClass;
  471. typedef void (asCUnknownClass::*asMETHOD_t)();
  472. //! \brief Represents a function or method pointer.
  473. struct asSFuncPtr
  474. {
  475. union
  476. {
  477. // The largest known method point is 20 bytes (MSVC 64bit),
  478. // but with 8byte alignment this becomes 24 bytes. So we need
  479. // to be able to store at least that much.
  480. char dummy[25];
  481. struct {asMETHOD_t mthd; char dummy[25-sizeof(asMETHOD_t)];} m;
  482. struct {asFUNCTION_t func; char dummy[25-sizeof(asFUNCTION_t)];} f;
  483. } ptr;
  484. asBYTE flag; // 1 = generic, 2 = global func, 3 = method
  485. };
  486. //! \ingroup funcs
  487. //! \brief Returns an asSFuncPtr representing the class method specified by class and method name.
  488. #define asMETHOD(c,m) asSMethodPtr<sizeof(void (c::*)())>::Convert((void (c::*)())(&c::m))
  489. //! \ingroup funcs
  490. //! \brief Returns an asSFuncPtr representing the class method specified by class, method name, parameter list, return type.
  491. #define asMETHODPR(c,m,p,r) asSMethodPtr<sizeof(void (c::*)())>::Convert(static_cast<r (c::*)p>(&c::m))
  492. #else // Class methods are disabled
  493. struct asSFuncPtr
  494. {
  495. union
  496. {
  497. char dummy[25]; // largest known class method pointer
  498. struct {asFUNCTION_t func; char dummy[25-sizeof(asFUNCTION_t)];} f;
  499. } ptr;
  500. asBYTE flag; // 1 = generic, 2 = global func
  501. };
  502. #endif
  503. //! \brief Represents a compiler message
  504. struct asSMessageInfo
  505. {
  506. //! The script section where the message is raised
  507. const char *section;
  508. //! The row number
  509. int row;
  510. //! The column
  511. int col;
  512. //! The type of message
  513. asEMsgType type;
  514. //! The message text
  515. const char *message;
  516. };
  517. // API functions
  518. // ANGELSCRIPT_EXPORT is defined when compiling the dll or lib
  519. // ANGELSCRIPT_DLL_LIBRARY_IMPORT is defined when dynamically linking to the
  520. // dll through the link lib automatically generated by MSVC++
  521. // ANGELSCRIPT_DLL_MANUAL_IMPORT is defined when manually loading the dll
  522. // Don't define anything when linking statically to the lib
  523. //! \def AS_API
  524. //! \brief A define that specifies how the function should be imported
  525. #ifdef WIN32
  526. #ifdef ANGELSCRIPT_EXPORT
  527. #define AS_API __declspec(dllexport)
  528. #elif defined ANGELSCRIPT_DLL_LIBRARY_IMPORT
  529. #define AS_API __declspec(dllimport)
  530. #else // statically linked library
  531. #define AS_API
  532. #endif
  533. #else
  534. #define AS_API
  535. #endif
  536. #ifndef ANGELSCRIPT_DLL_MANUAL_IMPORT
  537. extern "C"
  538. {
  539. // Engine
  540. //! \brief Creates the script engine.
  541. //!
  542. //! \param[in] version The library version. Should always be \ref ANGELSCRIPT_VERSION.
  543. //! \return A pointer to the script engine interface.
  544. //!
  545. //! Call this function to create a new script engine. When you're done with the
  546. //! script engine, i.e. after you've executed all your scripts, you should call
  547. //! \ref asIScriptEngine::Release "Release" on the pointer to free the engine object.
  548. AS_API asIScriptEngine * asCreateScriptEngine(asDWORD version);
  549. //! \brief Returns the version of the compiled library.
  550. //!
  551. //! \return A null terminated string with the library version.
  552. //!
  553. //! The returned string can be used for presenting the library version in a log file, or in the GUI.
  554. AS_API const char * asGetLibraryVersion();
  555. //! \brief Returns the options used to compile the library.
  556. //!
  557. //! \return A null terminated string with indicators that identify the options
  558. //! used to compile the script library.
  559. //!
  560. //! This can be used to identify at run-time different ways to configure the engine.
  561. //! For example, if the returned string contain the identifier AS_MAX_PORTABILITY then
  562. //! functions and methods must be registered with the \ref asCALL_GENERIC calling convention.
  563. AS_API const char * asGetLibraryOptions();
  564. // Context
  565. //! \brief Returns the currently active context.
  566. //!
  567. //! \return A pointer to the currently executing context, or null if no context is executing.
  568. //!
  569. //! This function is most useful for registered functions, as it will allow them to obtain
  570. //! a pointer to the context that is calling the function, and through that get the engine,
  571. //! or custom user data.
  572. //!
  573. //! If the script library is compiled with multithread support, this function will return
  574. //! the context that is currently active in the thread that is being executed. It will thus
  575. //! work even if there are multiple threads executing scripts at the same time.
  576. AS_API asIScriptContext * asGetActiveContext();
  577. // Thread support
  578. //! \brief Cleans up memory allocated for the current thread.
  579. //!
  580. //! \return A negative value on error.
  581. //! \retval asCONTEXT_ACTIVE A context is still active.
  582. //!
  583. //! Call this method before terminating a thread that has
  584. //! accessed the engine to clean up memory allocated for that thread.
  585. //!
  586. //! It's not necessary to call this if only a single thread accesses the engine.
  587. AS_API int asThreadCleanup();
  588. // Memory management
  589. //! \brief Set the memory management functions that AngelScript should use.
  590. //!
  591. //! \param[in] allocFunc The function that will be used to allocate memory.
  592. //! \param[in] freeFunc The function that will be used to free the memory.
  593. //! \return A negative value on error.
  594. //!
  595. //! Call this method to register the global memory allocation and deallocation
  596. //! functions that AngelScript should use for memory management. This function
  597. //! Should be called before \ref asCreateScriptEngine.
  598. //!
  599. //! If not called, AngelScript will use the malloc and free functions from the
  600. //! standard C library.
  601. AS_API int asSetGlobalMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc);
  602. //! \brief Remove previously registered memory management functions.
  603. //!
  604. //! \return A negative value on error.
  605. //!
  606. //! Call this method to restore the default memory management functions.
  607. AS_API int asResetGlobalMemoryFunctions();
  608. }
  609. #endif // ANGELSCRIPT_DLL_MANUAL_IMPORT
  610. // Interface declarations
  611. //! \brief The engine interface
  612. class asIScriptEngine
  613. {
  614. public:
  615. // Memory management
  616. //! \name Memory management
  617. //! \{
  618. //! \brief Increase reference counter.
  619. //!
  620. //! \return The number of references to this object.
  621. //!
  622. //! Call this method when storing an additional reference to the object.
  623. //! Remember that the first reference that is received from \ref asCreateScriptEngine
  624. //! is already accounted for.
  625. virtual int AddRef() = 0;
  626. //! \brief Decrease reference counter.
  627. //!
  628. //! \return The number of references to this object.
  629. //!
  630. //! Call this method when you will no longer use the references that you own.
  631. virtual int Release() = 0;
  632. //! \}
  633. // Engine properties
  634. //! \name Engine properties
  635. //! \{
  636. //! \brief Dynamically change some engine properties.
  637. //!
  638. //! \param[in] property One of the \ref asEEngineProp values.
  639. //! \param[in] value The new value of the property.
  640. //! \return Negative value on error.
  641. //! \retval asINVALID_ARG Invalid property.
  642. //!
  643. //! With this method you can change the way the script engine works in some regards.
  644. virtual int SetEngineProperty(asEEngineProp property, asPWORD value) = 0;
  645. //! \brief Retrieve current engine property settings.
  646. //!
  647. //! \param[in] property One of the \ref asEEngineProp values.
  648. //! \return The value of the property, or 0 if it is an invalid property.
  649. //!
  650. //! Calling this method lets you determine the current value of the engine properties.
  651. virtual asPWORD GetEngineProperty(asEEngineProp property) = 0;
  652. //! \}
  653. // Compiler messages
  654. //! \name Compiler messages
  655. //! \{
  656. //! \brief Sets a message callback that will receive compiler messages.
  657. //!
  658. //! \param[in] callback A function or class method pointer.
  659. //! \param[in] obj The object for methods, or an optional parameter for functions.
  660. //! \param[in] callConv The calling convention.
  661. //! \return A negative value for an error.
  662. //! \retval asINVALID_ARG One of the arguments is incorrect, e.g. obj is null for a class method.
  663. //! \retval asNOT_SUPPORTED The arguments are not supported, e.g. asCALL_GENERIC.
  664. //!
  665. //! This method sets the callback routine that will receive compiler messages.
  666. //! The callback routine can be either a class method, e.g:
  667. //! \code
  668. //! void MyClass::MessageCallback(const asSMessageInfo *msg);
  669. //! r = engine->SetMessageCallback(asMETHOD(MyClass,MessageCallback), &obj, asCALL_THISCALL);
  670. //! \endcode
  671. //! or a global function, e.g:
  672. //! \code
  673. //! void MessageCallback(const asSMessageInfo *msg, void *param);
  674. //! r = engine->SetMessageCallback(asFUNCTION(MessageCallback), param, asCALL_CDECL);
  675. //! \endcode
  676. //! It is recommended to register the message callback routine right after creating the engine,
  677. //! as some of the registration functions can provide useful information to better explain errors.
  678. virtual int SetMessageCallback(const asSFuncPtr &callback, void *obj, asDWORD callConv) = 0;
  679. //! \brief Clears the registered message callback routine.
  680. //!
  681. //! \return A negative value on error.
  682. //!
  683. //! Call this method to remove the message callback.
  684. virtual int ClearMessageCallback() = 0;
  685. //! \brief Writes a message to the message callback.
  686. //!
  687. //! \param[in] section The name of the script section.
  688. //! \param[in] row The row number.
  689. //! \param[in] col The column number.
  690. //! \param[in] type The message type.
  691. //! \param[in] message The message text.
  692. //! \return A negative value on error.
  693. //! \retval asINVALID_ARG The section or message is null.
  694. //!
  695. //! This method can be used by the application to write messages
  696. //! to the same message callback that the script compiler uses. This
  697. //! is useful for example if a preprocessor is used.
  698. virtual int WriteMessage(const char *section, int row, int col, asEMsgType type, const char *message) = 0;
  699. //! \}
  700. // JIT Compiler
  701. //! \name JIT compiler
  702. //! \{
  703. //! \brief Sets the JIT compiler
  704. virtual int SetJITCompiler(asIJITCompiler *compiler) = 0;
  705. //! \brief Returns the JIT compiler
  706. virtual asIJITCompiler *GetJITCompiler() = 0;
  707. //! \}
  708. // Global functions
  709. //! \name Global functions
  710. //! \{
  711. //! \brief Registers a global function.
  712. //!
  713. //! \param[in] declaration The declaration of the global function in script syntax.
  714. //! \param[in] funcPointer The function pointer.
  715. //! \param[in] callConv The calling convention for the function.
  716. //! \return A negative value on error, or the function id if successful.
  717. //! \retval asNOT_SUPPORTED The calling convention is not supported.
  718. //! \retval asWRONG_CALLING_CONV The function's calling convention doesn't match \a callConv.
  719. //! \retval asINVALID_DECLARATION The function declaration is invalid.
  720. //! \retval asNAME_TAKEN The function name is already used elsewhere.
  721. //!
  722. //! This method registers system functions that the scripts may use to communicate with the host application.
  723. //!
  724. //! \see \ref doc_register_func
  725. virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0;
  726. //! \brief Returns the number of registered functions.
  727. //! \return The number of registered functions.
  728. virtual int GetGlobalFunctionCount() = 0;
  729. //! \brief Returns the function id of the registered function.
  730. //! \param[in] index The index of the registered global function.
  731. //! \return The id of the function, or a negative value on error.
  732. //! \retval asINVALID_ARG \a index is too large.
  733. virtual int GetGlobalFunctionIdByIndex(asUINT index) = 0;
  734. //! \}
  735. // Global properties
  736. //! \name Global properties
  737. //! \{
  738. //! \brief Registers a global property.
  739. //!
  740. //! \param[in] declaration The declaration of the global property in script syntax.
  741. //! \param[in] pointer The address of the property that will be used to access the property value.
  742. //! \return A negative value on error.
  743. //! \retval asINVALID_DECLARATION The declaration has invalid syntax.
  744. //! \retval asINVALID_TYPE The declaration is a reference.
  745. //! \retval asNAME_TAKEN The name is already taken.
  746. //!
  747. //! Use this method to register a global property that the scripts will be
  748. //! able to access as global variables. The property may optionally be registered
  749. //! as const, if the scripts shouldn't be allowed to modify it.
  750. //!
  751. //! When registering the property, the application must pass the address to
  752. //! the actual value. The application must also make sure that this address
  753. //! remains valid throughout the life time of this registration, i.e. until
  754. //! the engine is released or the dynamic configuration group is removed.
  755. virtual int RegisterGlobalProperty(const char *declaration, void *pointer) = 0;
  756. //! \brief Returns the number of registered global properties.
  757. //! \return The number of registered global properties.
  758. virtual int GetGlobalPropertyCount() = 0;
  759. //! \brief Returns the detail on the registered global property.
  760. //! \param[in] index The index of the global variable.
  761. //! \param[out] name Receives the name of the property.
  762. //! \param[out] typeId Receives the typeId of the property.
  763. //! \param[out] isConst Receives the constness indicator of the property.
  764. //! \param[out] configGroup Receives the config group in which the property was registered.
  765. //! \param[out] pointer Receives the pointer of the property.
  766. //! \return A negative value on error.
  767. //! \retval asINVALID_ARG \a index is too large.
  768. virtual int GetGlobalPropertyByIndex(asUINT index, const char **name, int *typeId = 0, bool *isConst = 0, const char **configGroup = 0, void **pointer = 0) = 0;
  769. //! \}
  770. // Object types
  771. //! \name Object types
  772. //! \{
  773. //! \brief Registers a new object type.
  774. //!
  775. //! \param[in] obj The name of the type.
  776. //! \param[in] byteSize The size of the type in bytes. Only necessary for value types.
  777. //! \param[in] flags One or more of the asEObjTypeFlags.
  778. //! \return A negative value on error.
  779. //! \retval asINVALID_ARG The flags are invalid.
  780. //! \retval asINVALID_NAME The name is invalid.
  781. //! \retval asALREADY_REGISTERED Another type of the same name already exists.
  782. //! \retval asNAME_TAKEN The name conflicts with other symbol names.
  783. //! \retval asLOWER_ARRAY_DIMENSION_NOT_REGISTERED When registering an array type the array element must be a primitive or a registered type.
  784. //! \retval asINVALID_TYPE The array type was not properly formed.
  785. //! \retval asNOT_SUPPORTED The array type is not supported, or already in use preventing it from being overloaded.
  786. //!
  787. //! Use this method to register new types that should be available to the scripts.
  788. //! Reference types, which have their memory managed by the application, should be registered with \ref asOBJ_REF.
  789. //! Value types, which have their memory managed by the engine, should be registered with \ref asOBJ_VALUE.
  790. //!
  791. //! \see \ref doc_register_type
  792. virtual int RegisterObjectType(const char *obj, int byteSize, asDWORD flags) = 0;
  793. //! \brief Registers a property for the object type.
  794. //!
  795. //! \param[in] obj The name of the type.
  796. //! \param[in] declaration The property declaration in script syntax.
  797. //! \param[in] byteOffset The offset into the memory block where this property is found.
  798. //! \return A negative value on error.
  799. //! \retval asWRONG_CONFIG_GROUP The object type was registered in a different configuration group.
  800. //! \retval asINVALID_OBJECT The \a obj does not specify an object type.
  801. //! \retval asINVALID_TYPE The \a obj parameter has invalid syntax.
  802. //! \retval asINVALID_DECLARATION The \a declaration is invalid.
  803. //! \retval asNAME_TAKEN The name conflicts with other members.
  804. //!
  805. //! Use this method to register a member property of a class. The property must
  806. //! be local to the object, i.e. not a global variable or a static member. The
  807. //! easiest way to get the offset of the property is to use the offsetof macro
  808. //! from stddef.h.
  809. //!
  810. //! \code
  811. //! struct MyType {float prop;};
  812. //! r = engine->RegisterObjectProperty("MyType", "float prop", offsetof(MyType, prop)));
  813. //! \endcode
  814. virtual int RegisterObjectProperty(const char *obj, const char *declaration, int byteOffset) = 0;
  815. //! \brief Registers a method for the object type.
  816. //!
  817. //! \param[in] obj The name of the type.
  818. //! \param[in] declaration The declaration of the method in script syntax.
  819. //! \param[in] funcPointer The method or function pointer.
  820. //! \param[in] callConv The calling convention for the method or function.
  821. //! \return A negative value on error, or the function id if successful.
  822. //! \retval asWRONG_CONFIG_GROUP The object type was registered in a different configuration group.
  823. //! \retval asNOT_SUPPORTED The calling convention is not supported.
  824. //! \retval asINVALID_TYPE The \a obj parameter is not a valid object name.
  825. //! \retval asINVALID_DECLARATION The \a declaration is invalid.
  826. //! \retval asNAME_TAKEN The name conflicts with other members.
  827. //! \retval asWRONG_CALLING_CONV The function's calling convention isn't compatible with \a callConv.
  828. //!
  829. //! Use this method to register a member method for the type. The method
  830. //! that is registered may be an actual class method, or a global function
  831. //! that takes the object pointer as either the first or last parameter. Or
  832. //! it may be a global function implemented with the generic calling convention.
  833. //!
  834. //! \see \ref doc_register_func
  835. virtual int RegisterObjectMethod(const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0;
  836. //! \brief Registers a behaviour for the object type.
  837. //!
  838. //! \param[in] obj The name of the type.
  839. //! \param[in] behaviour One of the object behaviours from \ref asEBehaviours.
  840. //! \param[in] declaration The declaration of the method in script syntax.
  841. //! \param[in] funcPointer The method or function pointer.
  842. //! \param[in] callConv The calling convention for the method or function.
  843. //! \return A negative value on error, or the function id is successful.
  844. //! \retval asWRONG_CONFIG_GROUP The object type was registered in a different configuration group.
  845. //! \retval asINVALID_ARG \a obj is not set, or a global behaviour is given in \a behaviour.
  846. //! \retval asWRONG_CALLING_CONV The function's calling convention isn't compatible with \a callConv.
  847. //! \retval asNOT_SUPPORTED The calling convention or the behaviour signature is not supported.
  848. //! \retval asINVALID_TYPE The \a obj parameter is not a valid object name.
  849. //! \retval asINVALID_DECLARATION The \a declaration is invalid.
  850. //! \retval asILLEGAL_BEHAVIOUR_FOR_TYPE The \a behaviour is not allowed for this type.
  851. //! \retval asALREADY_REGISTERED The behaviour is already registered with the same signature.
  852. //!
  853. //! Use this method to register behaviour functions that will be called by
  854. //! the virtual machine to perform certain operations, such as memory management,
  855. //! math operations, comparisons, etc.
  856. //!
  857. //! \see \ref doc_register_func, \ref doc_reg_opbeh
  858. virtual int RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0;
  859. //! \brief Registers an interface.
  860. //!
  861. //! \param[in] name The name of the interface.
  862. //! \return A negative value on error.
  863. //! \retval asINVALID_NAME The \a name is null, or a reserved keyword.
  864. //! \retval asALREADY_REGISTERED An object type with this name already exists.
  865. //! \retval asERROR The \a name is not a proper identifier.
  866. //! \retval asNAME_TAKEN The \a name is already used elsewhere.
  867. //!
  868. //! This registers an interface that script classes can implement. By doing this the application
  869. //! can register functions and methods that receives an \ref asIScriptObject and still be sure that the
  870. //! class implements certain methods needed by the application.
  871. virtual int RegisterInterface(const char *name) = 0;
  872. //! \brief Registers an interface method.
  873. //!
  874. //! \param[in] intf The name of the interface.
  875. //! \param[in] declaration The method declaration.
  876. //! \return A negative value on error.
  877. //! \retval asWRONG_CONFIG_GROUP The interface was registered in another configuration group.
  878. //! \retval asINVALID_TYPE \a intf is not an interface type.
  879. //! \retval asINVALID_DECLARATION The \a declaration is invalid.
  880. //! \retval asNAME_TAKEN The method name is already taken.
  881. //!
  882. //! This registers a method that the class that implements the interface must have.
  883. virtual int RegisterInterfaceMethod(const char *intf, const char *declaration) = 0;
  884. //! \brief Returns the number of registered object types.
  885. //! \return The number of object types registered by the application.
  886. virtual int GetObjectTypeCount() = 0;
  887. //! \brief Returns the object type interface by index.
  888. //! \param[in] index The index of the type.
  889. //! \return The registered object type interface for the type, or null if not found.
  890. virtual asIObjectType *GetObjectTypeByIndex(asUINT index) = 0;
  891. //! \}
  892. // String factory
  893. //! \name String factory
  894. //! \{
  895. //! \brief Registers the string factory.
  896. //!
  897. //! \param[in] datatype The datatype that the string factory returns
  898. //! \param[in] factoryFunc The pointer to the factory function
  899. //! \param[in] callConv The calling convention of the factory function
  900. //! \return A negative value on error, or the function id if successful.
  901. //! \retval asNOT_SUPPORTED The calling convention is not supported.
  902. //! \retval asWRONG_CALLING_CONV The function's calling convention doesn't match \a callConv.
  903. //! \retval asINVALID_TYPE The \a datatype is not a valid type.
  904. //!
  905. //! Use this function to register a string factory that will be called when the
  906. //! virtual machine finds a string constant in an expression. The string factory
  907. //! function will receive two parameters, the length of the string constant in bytes and a
  908. //! pointer to the character data. The factory should return a value to a previously
  909. //! registered type that will represent the string. Example:
  910. //!
  911. //! \code
  912. //! // Our string factory implementation
  913. //! std::string StringFactory(unsigned int byteLength, const char *s)
  914. //! {
  915. //! return std::string(s, byteLength);
  916. //! }
  917. //!
  918. //! // Registering the string factory
  919. //! int r = engine->RegisterStringFactory("string", asFUNCTION(StringFactory), asCALL_CDECL); assert( r >= 0 );
  920. //! \endcode
  921. //!
  922. //! The example assumes that the std::string type has been registered as the string type, with \ref RegisterObjectType.
  923. virtual int RegisterStringFactory(const char *datatype, const asSFuncPtr &factoryFunc, asDWORD callConv) = 0;
  924. //! \brief Returns the type id of the type that the string factory returns.
  925. //! \return The type id of the type that the string type returns, or a negative value on error.
  926. //! \retval asNO_FUNCTION The string factory has not been registered.
  927. virtual int GetStringFactoryReturnTypeId() = 0;
  928. //! \}
  929. // Enums
  930. //! \name Enums
  931. //! \{
  932. //! \brief Registers an enum type.
  933. //!
  934. //! \param[in] type The name of the enum type.
  935. //! \return A negative value on error.
  936. //! \retval asINVALID_NAME \a type is null.
  937. //! \retval asALREADY_REGISTERED Another type with this name already exists.
  938. //! \retval asERROR The \a type couldn't be parsed.
  939. //! \retval asINVALID_NAME The \a type is not an identifier, or it is a reserved keyword.
  940. //! \retval asNAME_TAKEN The type name is already taken.
  941. //!
  942. //! This method registers an enum type in the engine. The enum values should then be registered
  943. //! with \ref RegisterEnumValue.
  944. virtual int RegisterEnum(const char *type) = 0;
  945. //! \brief Registers an enum value.
  946. //!
  947. //! \param[in] type The name of the enum type.
  948. //! \param[in] name The name of the enum value.
  949. //! \param[in] value The integer value of the enum value.
  950. //! \return A negative value on error.
  951. //! \retval asWRONG_CONFIG_GROUP The enum \a type was registered in a different configuration group.
  952. //! \retval asINVALID_TYPE The \a type is invalid.
  953. //! \retval asALREADY_REGISTERED The \a name is already registered for this enum.
  954. //!
  955. //! This method registers an enum value for a previously registered enum type.
  956. virtual int RegisterEnumValue(const char *type, const char *name, int value) = 0;
  957. //! \brief Returns the number of registered enum types.
  958. //! \return The number of registered enum types.
  959. virtual int GetEnumCount() = 0;
  960. //! \brief Returns the registered enum type.
  961. //! \param[in] index The index of the enum type.
  962. //! \param[out] enumTypeId Receives the type if of the enum type.
  963. //! \param[out] configGroup Receives the config group in which the enum was registered.
  964. //! \return The name of the registered enum type, or null on error.
  965. virtual const char *GetEnumByIndex(asUINT index, int *enumTypeId, const char **configGroup = 0) = 0;
  966. //! \brief Returns the number of enum values for the enum type.
  967. //! \param[in] enumTypeId The type id of the enum type.
  968. //! \return The number of enum values for the enum type.
  969. virtual int GetEnumValueCount(int enumTypeId) = 0;
  970. //! \brief Returns the name and value of the enum value for the enum type.
  971. //! \param[in] enumTypeId The type id of the enum type.
  972. //! \param[in] index The index of the enum value.
  973. //! \param[out] outValue Receives the value of the enum value.
  974. //! \return The name of the enum value.
  975. virtual const char *GetEnumValueByIndex(int enumTypeId, asUINT index, int *outValue) = 0;
  976. //! \}
  977. // Typedefs
  978. //! \name Typedefs
  979. //! \{
  980. //! \brief Registers a typedef.
  981. //!
  982. //! \param[in] type The name of the new typedef
  983. //! \param[in] decl The datatype that the typedef represents
  984. //! \return A negative value on error.
  985. //! \retval asINVALID_NAME The \a type is null.
  986. //! \retval asALREADY_REGISTERED A type with the same name already exists.
  987. //! \retval asINVALID_TYPE The \a decl is not a primitive type.
  988. //! \retval asINVALID_NAME The \a type is not an identifier, or it is a reserved keyword.
  989. //! \retval asNAME_TAKEN The name is already used elsewhere.
  990. //!
  991. //! This method registers an alias for a data type.
  992. //!
  993. //! Currently typedefs can only be registered for built-in primitive types.
  994. virtual int RegisterTypedef(const char *type, const char *decl) = 0;
  995. //! \brief Returns the number of registered typedefs.
  996. //! \return The number of registered typedefs.
  997. virtual int GetTypedefCount() = 0;
  998. //! \brief Returns a registered typedef.
  999. //! \param[in] index The index of the typedef.
  1000. //! \param[out] typeId The type that the typedef aliases.
  1001. //! \param[out] configGroup Receives the config group in which the type def was registered.
  1002. //! \return The name of the typedef.
  1003. virtual const char *GetTypedefByIndex(asUINT index, int *typeId, const char **configGroup = 0) = 0;
  1004. //! \}
  1005. // Configuration groups
  1006. //! \name Configuration groups
  1007. //! \{
  1008. //! \brief Starts a new dynamic configuration group.
  1009. //!
  1010. //! \param[in] groupName The name of the configuration group
  1011. //! \return A negative value on error
  1012. //! \retval asNAME_TAKEN Another group with the same name already exists.
  1013. //! \retval asNOT_SUPPORTED Nesting configuration groups is not supported.
  1014. //!
  1015. //! Starts a new dynamic configuration group. This group can be setup so that it is only
  1016. //! visible to specific modules, and it can also be removed when it is no longer used.
  1017. virtual int BeginConfigGroup(const char *groupName) = 0;
  1018. //! \brief Ends the configuration group.
  1019. //!
  1020. //! \return A negative value on error
  1021. //! \retval asNOT_SUPPORTED Can't end a group that hasn't been begun.
  1022. //!
  1023. //! Ends the current configuration group. Once finished a config group cannot be changed,
  1024. //! but it can be removed when it is no longer used.
  1025. virtual int EndConfigGroup() = 0;
  1026. //! \brief Removes a previously registered configuration group.
  1027. //!
  1028. //! \param[in] groupName The name of the configuration group
  1029. //! \return A negative value on error
  1030. //! \retval asCONFIG_GROUP_IS_IN_USE The group is in use and cannot be removed.
  1031. //!
  1032. //! Remove the configuration group. If something in the configuration group is currently in
  1033. //! use, the function will return with an error code. Examples of uses are compiled modules
  1034. //! that have function calls to functions in the group and global variables of types registered
  1035. //! in the group.
  1036. virtual int RemoveConfigGroup(const char *groupName) = 0;
  1037. //! \brief Tell AngelScript which modules have access to which configuration groups.
  1038. //!
  1039. //! \param[in] groupName The name of the configuration group
  1040. //! \param[in] module The module name
  1041. //! \param[in] hasAccess Whether the module has access or not to the group members
  1042. //! \return A negative value on error
  1043. //! \retval asWRONG_CONFIG_GROUP No group with the \a groupName was found.
  1044. //!
  1045. //! With this method the application can give modules access to individual configuration groups.
  1046. //! This is useful when exposing more than one script interface for various parts of the application,
  1047. //! e.g. one interface for GUI handling, another for in-game events, etc.
  1048. //!
  1049. //! The default module access is granted. The default for a group can be changed by specifying
  1050. //! the modulename asALL_MODULES.
  1051. virtual int SetConfigGroupModuleAccess(const char *groupName, const char *module, bool hasAccess) = 0;
  1052. //! \}
  1053. // Script modules
  1054. //! \name Script modules
  1055. //! \{
  1056. //! \brief Return an interface pointer to the module.
  1057. //!
  1058. //! \param[in] module The name of the module
  1059. //! \param[in] flag One of the \ref asEGMFlags flags
  1060. //! \return A pointer to the module interface
  1061. //!
  1062. //! Use this method to get access to the module interface, which will
  1063. //! let you build new scripts, and enumerate functions and types in
  1064. //! existing modules.
  1065. //!
  1066. //! If \ref asGM_ALWAYS_CREATE is informed as the flag the previous
  1067. //! module with the same name will be discarded, thus any pointers that
  1068. //! the engine holds to it will be invalid after the call.
  1069. virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag = asGM_ONLY_IF_EXISTS) = 0;
  1070. //! \brief Discard a module.
  1071. //!
  1072. //! \param[in] module The name of the module
  1073. //! \return A negative value on error
  1074. //! \retval asNO_MODULE The module was not found.
  1075. //!
  1076. //! Discards a module and frees its memory. Any pointers that the application holds
  1077. //! to this module will be invalid after this call.
  1078. virtual int DiscardModule(const char *module) = 0;
  1079. //! \}
  1080. // Script functions
  1081. //! \name Script functions
  1082. //! \{
  1083. //! \brief Returns the function descriptor for the script function
  1084. //! \param[in] funcId The id of the function or method.
  1085. //! \return A pointer to the function description interface, or null if not found.
  1086. virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) = 0;
  1087. //! \}
  1088. // Type identification
  1089. //! \name Type identification
  1090. //! \{
  1091. //! \brief Returns the object type interface for type.
  1092. //! \param[in] typeId The type id of the type.
  1093. //! \return The object type interface for the type, or null if not found.
  1094. virtual asIObjectType *GetObjectTypeById(int typeId) = 0;
  1095. //! \brief Returns a type id by declaration.
  1096. //! \param[in] decl The declaration of the type.
  1097. //! \return A negative value on error, or the type id of the type.
  1098. //! \retval asINVALID_TYPE \a decl is not a valid type.
  1099. //!
  1100. //! Translates a type declaration into a type id. The returned type id is valid for as long as
  1101. //! the type is valid, so you can safely store it for later use to avoid potential overhead by
  1102. //! calling this function each time. Just remember to update the type id, any time the type is
  1103. //! changed within the engine, e.g. when recompiling script declared classes, or changing the
  1104. //! engine configuration.
  1105. //!
  1106. //! The type id is based on a sequence number and depends on the order in which the type ids are
  1107. //! queried, thus is not guaranteed to always be the same for each execution of the application.
  1108. //! The \ref asETypeIdFlags can be used to obtain some information about the type directly from the id.
  1109. //!
  1110. //! A base type yields the same type id whether the declaration is const or not, however if the
  1111. //! const is for the subtype then the type id is different, e.g. string@ isn't the same as const
  1112. //! string@ but string is the same as const string.
  1113. //!
  1114. //! This method is only able to return the type id that are not specific for a script module, i.e.
  1115. //! built-in types and application registered types. Type ids for script declared types should
  1116. //! be obtained through the script module's \ref asIScriptModule::GetTypeIdByDecl "GetTypeIdByDecl".
  1117. virtual int GetTypeIdByDecl(const char *decl) = 0;
  1118. //! \brief Returns a type declaration.
  1119. //! \param[in] typeId The type id of the type.
  1120. //! \return A null terminated string with the type declaration, or null if not found.
  1121. virtual const char *GetTypeDeclaration(int t

Large files files are truncated, but you can click here to view the full file