ScummVM API documentation
as_objecttype.h
1 /*
2  AngelCode Scripting Library
3  Copyright (c) 2003-2017 Andreas Jonsson
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any
7  damages arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any
10  purpose, including commercial applications, and to alter it and
11  redistribute it freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you
14  must not claim that you wrote the original software. If you use
15  this software in a product, an acknowledgment in the product
16  documentation would be appreciated but is not required.
17 
18  2. Altered source versions must be plainly marked as such, and
19  must not be misrepresented as being the original software.
20 
21  3. This notice may not be removed or altered from any source
22  distribution.
23 
24  The original version of this library can be located at:
25  http://www.angelcode.com/angelscript/
26 
27  Andreas Jonsson
28  andreas@angelcode.com
29 */
30 
31 
32 
33 //
34 // as_objecttype.h
35 //
36 // A class for storing object type information
37 //
38 
39 
40 
41 #ifndef AS_OBJECTTYPE_H
42 #define AS_OBJECTTYPE_H
43 
44 #include "as_property.h"
45 #include "as_memory.h"
46 #include "as_memory.h"
47 #include "as_scriptfunction.h"
48 #include "as_typeinfo.h"
49 
50 BEGIN_AS_NAMESPACE
51 
54  factory = 0;
55  listFactory = 0;
56  copyfactory = 0;
57  construct = 0;
58  copyconstruct = 0;
59  destruct = 0;
60  copy = 0;
61  addref = 0;
62  release = 0;
63  gcGetRefCount = 0;
64  gcSetFlag = 0;
65  gcGetFlag = 0;
66  gcEnumReferences = 0;
67  gcReleaseAllReferences = 0;
68  templateCallback = 0;
69  getWeakRefFlag = 0;
70  }
71 
72  int factory;
73  int listFactory; // Used for initialization lists only
74  int copyfactory;
75  int construct;
76  int copyconstruct;
77  int destruct;
78  int copy;
79  int addref;
80  int release;
81  int templateCallback;
82 
83  // GC behaviours
84  int gcGetRefCount;
85  int gcSetFlag;
86  int gcGetFlag;
87  int gcEnumReferences;
88  int gcReleaseAllReferences;
89 
90  // Weakref behaviours
91  int getWeakRefFlag;
92 
93  asCArray<int> factories;
94  asCArray<int> constructors;
95 };
96 
97 class asCScriptEngine;
98 struct asSNameSpace;
99 
100 class asCObjectType : public asCTypeInfo {
101 public:
102  asITypeInfo *GetBaseType() const;
103  bool DerivesFrom(const asITypeInfo *objType) const;
104  int GetSubTypeId(asUINT subtypeIndex = 0) const;
105  asITypeInfo *GetSubType(asUINT subtypeIndex = 0) const;
106  asUINT GetSubTypeCount() const;
107  asUINT GetInterfaceCount() const;
108  asITypeInfo *GetInterface(asUINT index) const;
109  bool Implements(const asITypeInfo *objType) const;
110  asUINT GetFactoryCount() const;
111  asIScriptFunction *GetFactoryByIndex(asUINT index) const;
112  asIScriptFunction *GetFactoryByDecl(const char *decl) const;
113  asUINT GetMethodCount() const;
114  asIScriptFunction *GetMethodByIndex(asUINT index, bool getVirtual) const;
115  asIScriptFunction *GetMethodByName(const char *name, bool getVirtual) const;
116  asIScriptFunction *GetMethodByDecl(const char *decl, bool getVirtual) const;
117  asUINT GetPropertyCount() const;
118  int GetProperty(asUINT index, const char **name, int *typeId, bool *isPrivate, bool *isProtected, int *offset, bool *isReference, asDWORD *accessMask, int *compositeOffset, bool *isCompositeIndirect) const;
119  const char *GetPropertyDeclaration(asUINT index, bool includeNamespace = false) const;
120  asUINT GetBehaviourCount() const;
121  asIScriptFunction *GetBehaviourByIndex(asUINT index, asEBehaviours *outBehaviour) const;
122  asUINT GetChildFuncdefCount() const;
123  asITypeInfo *GetChildFuncdef(asUINT index) const;
124 
125 public:
127  ~asCObjectType();
128  void DestroyInternal();
129 
130  void ReleaseAllFunctions();
131 
132  bool IsInterface() const;
133 
134  asCObjectProperty *AddPropertyToClass(const asCString &name, const asCDataType &dt, bool isPrivate, bool isProtected, bool isInherited);
135  void ReleaseAllProperties();
136 
137 #ifdef WIP_16BYTE_ALIGN
138  int alignment;
139 #endif
141  asCArray<int> methods;
142 
143  // TODO: These are not used by template types. Should perhaps create a derived class to save memory on ordinary object types
144  asCArray<asCObjectType *> interfaces;
145  asCArray<asUINT> interfaceVFTOffsets;
146  asCObjectType *derivedFrom;
147  asCArray<asCScriptFunction *> virtualFunctionTable;
148 
149  // Used for funcdefs declared as members of class.
150  // TODO: child funcdef: Should be possible to enumerate these from application
151  asCArray<asCFuncdefType *> childFuncDefs;
152 
153  asSTypeBehaviour beh;
154 
155  // Used for template types
156  asCArray<asCDataType> templateSubTypes; // increases refCount for typeinfo held in datatype
157  bool acceptValueSubType;
158  bool acceptRefSubType;
159 
160 protected:
161  friend class asCScriptEngine;
162  friend class asCConfigGroup;
163  friend class asCModule;
164  asCObjectType();
165 };
166 
167 END_AS_NAMESPACE
168 
169 #endif
Definition: as_module.h:93
Definition: angelscript.h:1083
Definition: as_typeinfo.h:64
Definition: as_objecttype.h:100
Definition: as_property.h:53
Definition: as_namespace.h:39
Definition: as_configgroup.h:50
Definition: as_datatype.h:60
Definition: as_objecttype.h:52
Definition: as_scriptengine.h:64
Definition: angelscript.h:1011
Definition: as_string.h:41