ScummVM API documentation
as_property.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 // as_property.h
34 //
35 // A class for storing object property information
36 //
37 
38 
39 
40 #ifndef AS_PROPERTY_H
41 #define AS_PROPERTY_H
42 
43 #include "as_string.h"
44 #include "as_datatype.h"
45 #include "as_atomic.h"
46 #include "as_scriptfunction.h"
47 #include "as_symboltable.h"
48 
49 BEGIN_AS_NAMESPACE
50 
51 struct asSNameSpace;
52 
54 public:
55  asCObjectProperty() : byteOffset(0), accessMask(0xFFFFFFFF), compositeOffset(0), isCompositeIndirect(false), isPrivate(false), isProtected(false), isInherited(false) {}
56  asCObjectProperty(const asCObjectProperty &o) : name(o.name), type(o.type), byteOffset(o.byteOffset), accessMask(o.accessMask), compositeOffset(o.compositeOffset), isCompositeIndirect(o.isCompositeIndirect), isPrivate(o.isPrivate), isProtected(o.isProtected), isInherited(o.isInherited) {}
57  asCString name;
58  asCDataType type;
59  int byteOffset;
60  asDWORD accessMask;
61  int compositeOffset;
62  bool isCompositeIndirect;
63  bool isPrivate;
64  bool isProtected;
65  bool isInherited;
66 };
67 
69 public:
72 
73  void AddRef();
74  void Release();
75  void DestroyInternal();
76 
77  void *GetAddressOfValue();
78  void AllocateMemory();
79  void SetRegisteredAddress(void *p);
80  void *GetRegisteredAddress() const;
81 
82  asCString name;
83  asCDataType type;
84  asUINT id;
85  asSNameSpace *nameSpace;
86 
87  void SetInitFunc(asCScriptFunction *initFunc);
88  asCScriptFunction *GetInitFunc();
89 
90 //protected:
91  // This is only stored for registered properties, and keeps the pointer given by the application
92  void *realAddress;
93 
94  bool memoryAllocated;
95  void *memory;
96  asQWORD storage;
97 
98  asCScriptFunction *initFunc;
99 
100  asDWORD accessMask;
101 
102  // The global property structure is reference counted, so that the
103  // engine can keep track of how many references to the property there are.
104  asCAtomic refCount;
105 };
106 
108 public:
109  const asCDataType &m_type;
110 
111  asCCompGlobPropType(const asCDataType &type) : m_type(type) {}
112 
113  bool operator()(const void *p) const {
114  const asCGlobalProperty *prop = reinterpret_cast<const asCGlobalProperty *>(p);
115  return prop->type == m_type;
116  }
117 
118 private:
119  // The assignment operator is required for MSVC9, otherwise it will complain that it is not possible to auto generate the operator
120  asCCompGlobPropType &operator=(const asCCompGlobPropType &) {
121  return *this;
122  }
123 };
124 
125 END_AS_NAMESPACE
126 
127 #endif
Definition: as_scriptfunction.h:146
Definition: as_property.h:53
Definition: as_property.h:107
Definition: as_namespace.h:39
Definition: as_symboltable.h:59
Definition: as_atomic.h:49
Definition: as_datatype.h:60
Definition: as_property.h:68
Definition: as_string.h:41