 |
Gorgon Game Engine
|
Go to the documentation of this file.
10 #include "../Containers/Collection.h"
11 #include "../Containers/Hashmap.h"
14 #include "../Utils/Assert.h"
143 template <
class ...Params_>
144 Parameter(
const std::string &name,
const std::string &help,
const Type *type,
146 name(name), type(type), help(help), defaultvalue(defaultvalue) {
147 ASSERT((type!=
nullptr),
"Parameter type cannot be nullptr", 1, 2);
159 template <
class ...Params_>
160 Parameter(
const std::string &name,
const std::string &help,
const Type *type,
Tag firsttag,
165 template <
class ...Params_>
166 Parameter(
const std::string &name,
const std::string &help,
const Type *type,
Data defaultvalue,
167 Tag firsttag, Params_ ...tags) :
168 Parameter(name, help, type, defaultvalue,
OptionList(), firsttag, std::forward<Params_>(tags)...) {
171 Parameter(
const std::string &name,
const std::string &help,
const Type *type,
172 Data defaultvalue,
OptionList options,
bool reference,
bool constant,
bool variable,
bool allownull) :
173 Parameter(name, help, type, defaultvalue, options)
175 this->reference = reference;
176 this->constant = constant;
177 this->variable = variable;
178 this->optional = defaultvalue.IsValid();
179 this->allownull = allownull;
188 defaultvalue= p.defaultvalue;
190 optional = p.optional ;
191 reference = p.reference ;
192 constant = p.constant ;
193 variable = p.variable ;
194 allownull = p.allownull ;
205 optional == p.optional &&
206 reference == p.reference &&
207 constant == p.constant &&
208 variable == p.variable &&
209 allownull == p.allownull ;
255 ASSERT(optional, name+
" parameter does not have default value");
266 template<
class ...Params_>
267 void UnpackTags(
Tag tag, Params_ ...tags) {
301 bool optional =
false;
302 bool reference =
false;
303 bool constant =
false;
304 bool variable =
false;
305 bool allownull =
false;
432 template <
class ...P_>
447 throw ReadOnlyException(
name);
511 template<
class ...Params_>
512 void UnpackTags(
Tag tag, Params_ ...tags) {
592 template<
class ...P_>
688 template<
class ...P_>
689 void unpacktags(
Tag tag, P_ ...rest) {
724 ASSERT(
false,
"Unknown tag", 2, 16);
733 virtual void dochecks(
bool ismethod);
770 template<
class ...P_>
773 Tag tag, P_ ...tags) :
780 for(
auto &variant : overloads) {
784 for(
auto &variant : methods) {
792 template<
class ...P_>
800 for(
auto &overload : overloads) {
808 template<
class ...P_>
814 for(
auto &overload : overloads) {
818 for(
auto &overload : methods) {
826 template<
class ...P_>
828 bool keyword,
bool isoperator,
bool staticmember) :
830 this->keyword=keyword;
831 this->isoperator=isoperator;
832 this->staticmember=staticmember;
848 virtual Data Get() const override final;
864 return parent!=
nullptr;
875 ASSERT(parent,
"This function does not have an owner.", 1, 5);
884 "Operators should have only a single parameter\n"
885 "in function "+
name, 1, 3
889 for(
const auto &v : overloads) {
898 overloads.Push(overload);
903 ASSERT(!isoperator,
"Operators cannot be methods\n in function "+
name, 1, 3);
906 for(
const auto &v : methods) {
915 methods.Push(overload);
920 ASSERT(overload,
"Empty variant\n in function "+
name);
927 ASSERT(overload,
"Empty variant\n in function "+
name);
943 template<
class ...P_>
944 void unpacktags(
Tag tag, P_ ...rest) {
952 ASSERT(!isoperator,
"A function cannot be a static operator");
957 ASSERT(!staticmember,
"A function cannot be a static operator");
958 ASSERT(parent,
"Operators should be member functions");
963 ASSERT(
false,
"Unknown tag", 2, 16);
973 const Type *parent =
nullptr;
975 bool keyword =
false;
977 bool isoperator =
false;
979 bool staticmember =
false;
981 Containers::Collection<Overload> overloads;
983 Containers::Collection<Overload> methods;
1021 throw ReadOnlyException(
name);
1096 ASSERT(member!=
nullptr,
"Member is null");
1104 virtual void AddMembers(std::initializer_list<StaticMember*> newmembers) {
1105 for(
auto member : newmembers) {
1106 ASSERT(member!=
nullptr,
"Member is null");
1107 ASSERT(!
members.
Find(member->GetName()).IsValid(),
"Symbol "+member->GetName()+
" is already added.");
1110 member->SetParent(*
this);
1116 for(
auto member : newmembers) {
1117 ASSERT(member!=
nullptr,
"Member is null");
1118 ASSERT(!
members.
Find(member->GetName()).IsValid(),
"Symbol "+member->GetName()+
" is already added.");
1121 member->SetParent(*
this);
1142 throw SymbolNotFoundException(
name, SymbolType::Identifier,
"Symbol "+
name+
" cannot be found.");
1144 return elm.Current().second.Get();
1210 return {
TypeType(),
dynamic_cast<const Type*
>(
this),
true,
true};
1228 virtual void AddMembers(std::initializer_list<StaticMember*> newmembers)
override {
1229 for(
auto member : newmembers) {
1237 virtual void AddMembers(std::vector<StaticMember*> newmembers)
override {
1238 for(
auto member : newmembers) {
1260 ASSERT(member!=
nullptr,
"Member is null");
1270 virtual void AddMembers(std::initializer_list<InstanceMember*> newmembers) {
1271 for(
auto member : newmembers) {
1272 member->typecheck(
this);
1274 ASSERT(member!=
nullptr,
"Member is null");
1275 ASSERT(!
members.
Find(member->GetName()).IsValid(),
"Symbol "+member->GetName()+
" is already added.");
1279 member->SetParent(*
this);
1284 virtual void AddMembers(std::vector<InstanceMember*> newmembers) {
1285 for(
auto member : newmembers) {
1286 member->typecheck(
this);
1288 ASSERT(member!=
nullptr,
"Member is null");
1289 ASSERT(!
members.
Find(member->GetName()).IsValid(),
"Symbol "+member->GetName()+
" is already added.");
1293 member->SetParent(*
this);
1299 for(
auto element : elements) {
1300 ASSERT((element !=
nullptr),
"Given element cannot be nullptr", 1, 2);
1301 ASSERT(element->HasReturnType() && element->GetReturnType()==
this,
1302 "Given constructor should return this ("+
name+
") type", 1, 2);
1311 "Given constructor should return this ("+
name+
") type", 1, 2);
1339 return this==&other;
1348 return this!=&other;
1365 if(ctor.Parameters.size()==1 && ctor.Parameters[0].GetType()==other &&
1366 (!implicit || ctor.IsImplicit())
1402 const std::map<const Type *, const Type *> &
Parents;
1429 virtual bool compare(
const Data &l,
const Data &r)
const {
throw std::runtime_error(
"These elements cannot be compared"); }
1551 const std::vector<ElementInitializer> &elements,
1557 ordered.push_back(elm);
1571 const std::vector<const Scripting::Constant*> &
Ordered;
1582 ordered.push_back(elm);
1587 std::vector<const Scripting::Constant*> ordered;
virtual void dochecks(bool ismethod)
This function should perform validity checks on the variant.
Definition: Reflection.cpp:295
virtual Data Parse(const std::string &) const =0
Parses a string into this data. This function is allowed to throw.
const Type & GetType() const
Returns the type of this data member.
Definition: Reflection.h:1003
Overload(const Type *returntype, ParameterList parameters, bool stretchlast, bool repeatlast, bool accessible, bool constant, bool returnsref, bool returnsconst, bool implicit)
A full constructor.
Definition: Reflection.h:603
bool IsOptional() const
Checks if the parameter is optional.
Definition: Reflection.h:228
bool HasReturnType() const
Returns whether event handlers should return a value.
Definition: Reflection.h:1510
virtual Data get() const =0
This function should return the data. It is overloaded to enforce modifiers.
EnumType(const std::string &name, const std::string &help, Any defval, TMP::RTTH *typeinterface)
Definition: Reflection.h:1575
virtual void AddOverload(Overload &overload)
Adds the given overload to this function after performing necessary checks.
Definition: Reflection.h:881
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
virtual void AddMethod(Overload *overload)
Adds the given overload as a method to this function after performing necessary checks.
Definition: Reflection.h:926
Data ValueOf(const std::string &name) const
Convenience function, returns the value of the symbol with the given name.
Definition: Reflection.h:1139
virtual Data Get() const override
Gets data from the datamember.
Definition: Reflection.h:454
virtual MemberType GetMemberType() const override
Returns the type of this member.
Definition: Reflection.h:440
virtual std::string ToString(const Data &) const =0
Converts a data of this type to string.
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
bool IsReference() const
Returns whether this member is a reference.
Definition: Reflection.h:474
EventType(const std::string &name, const std::string &help, const Any &defaultvalue, TMP::RTTH *typeinterface, const Type *ret, ParameterList parameters)
Definition: Reflection.h:1493
bool HasReturnType() const
Returns whether this variant returns a value.
Definition: Reflection.h:657
@ InputTag
Marks the object as input.
Definition: Reflection.h:64
constexpr Type Data
Data resource.
Definition: GID.h:164
const Type & GetReturnType() const
Returns the return type expected from the handlers.
Definition: Reflection.h:1515
@ ReadonlyTag
Marks a data member readonly, so that it can be manipulated, but cannot be changed.
Definition: Reflection.h:111
bool IsOperator() const
Returns if this function is an operator.
Definition: Reflection.h:868
virtual Data Get() const override final
Returns the value of this static member.
Definition: Reflection.cpp:380
const InstanceMemberList & InstanceMembers
Definition: Reflection.h:1410
Data value
Definition: Reflection.h:1480
virtual void AddMembers(std::initializer_list< StaticMember * > newmembers)
Adds a list of members to this namespace.
Definition: Reflection.h:1104
virtual void SetParent(const Member &parent)
Changes the parent of the member.
Definition: Reflection.h:350
Overload(const Type *returntype, ParameterList parameters, P_ ...tags)
Regular constructor that can take as many tags as needed.
Definition: Reflection.h:593
virtual Data Get() const override final
Returns the value of this static member.
Definition: Reflection.h:1566
@ OperatorTag
Makes a function operator.
Definition: Reflection.h:92
@ PublicTag
Makes the object public, allowing it to be accessed from all.
Definition: Reflection.h:86
Definition: Reflection.h:1187
const Scripting::Type & Constant()
void Register(const Data &data)
Registers a new object of reference counting, this will set reference count to one.
Definition: Runtime.h:24
virtual void typecheck(const Type *type) const =0
Type checks the parent.
virtual Data Call(bool ismethod, const std::vector< Data > ¶meters) const =0
Class the stub for this function.
virtual void AddMembers(std::initializer_list< StaticMember * > newmembers) override
Adds a list of static members to this type.
Definition: Reflection.h:1228
void Delete(const Data &obj) const
Deletes the object.
Definition: Reflection.h:1379
Data GetDefaultValue() const
Returns the default value for this parameter.
Definition: Reflection.h:254
TMP::RTTH & TypeInterface
Type interface used for this type.
Definition: Reflection.h:1414
virtual bool IsInstanceMember() const override final
Returns if this member is an instance member.
Definition: Reflection.h:1000
This class can hold any other information providing type erasure.
Definition: Any.h:32
virtual MemberType GetMemberType() const override
Returns the type of this member.
Definition: Reflection.h:1562
virtual void SetParent(const Member &parent) override final
Changes the parent of the member.
Definition: Reflection.cpp:365
bool IsConstant() const
Returns whether this function is a constant.
Definition: Reflection.h:635
Tag
Tags define behavior of reflection objects.
Definition: Reflection.h:54
ReferenceCounter References
This system allows objects of automatic lifetime.
Definition: VirtualMachine.h:222
ParameterList parameters
Parameters that every event handler should accept.
Definition: Reflection.h:1530
@ ReturnsConstTag
Denotes a function that returns const.
Definition: Reflection.h:98
std::ostream & operator<<(std::ostream &out, const Data &data)
This function parses the code and returns any syntax errors.
Definition: Scripting.h:73
bool reference
This instance member is a reference.
Definition: Reflection.h:503
@ UpCasting
This is an upcasting, but not a direct one.
Definition: Reflection.h:1177
const Type * returntype
Return type of this function variant. If nullptr this function does not return a value.
Definition: Reflection.h:739
@ PrivateTag
Makes the object private, allowing only access from it parent.
Definition: Reflection.h:83
StaticDataMember(const std::string &name, const std::string &help, const Type *type)
Definition: Reflection.h:429
@ DownCasting
This is a down casting.
Definition: Reflection.h:1180
Parameter(const std::string &name, const std::string &help, const Type *type, Data defaultvalue, OptionList options, Params_ ...tags)
Constructs a new parameter.
Definition: Reflection.h:144
bool implicit
If the parent function is constructor, marks this variant as an implicit type conversion.
Definition: Reflection.h:766
Data describes a piece of data.
Definition: Data.h:22
virtual void AddMembers(std::vector< InstanceMember * > newmembers)
Adds an instance member to this type.
Definition: Reflection.h:1284
const Containers::Hashmap< std::string, const Type, nullptr, std::map, String::CaseInsensitiveLess > & InheritedSymbols
Inherited symbols.
Definition: Reflection.h:1408
@ MethodTag
Marks the object as output. This may set ReferenceTag and unset InputTag.
Definition: Reflection.h:70
virtual void AddMembers(std::vector< StaticMember * > newmembers)
Adds a list of members to this namespace.
Definition: Reflection.h:1115
void init()
Definition: X11.cpp:143
std::map< const Type *, const Type * > parents
This lists all parents of this type in the entire hierarchy.
Definition: Reflection.h:1449
bool readonly
Marks this instance as read-only.
Definition: Reflection.h:506
virtual void AddMember(InstanceMember *member)
Adds a list of instance members to this type.
Definition: Reflection.h:1257
std::vector< Parameter > ParameterList
Definition: Reflection.h:308
const Scripting::Function & Constructor
Constructors of this type.
Definition: Reflection.h:1399
Parameter & operator=(const Parameter &p)
Copy assignment.
Definition: Reflection.h:184
const StaticMemberList & Members
List of static members.
Definition: Reflection.h:1148
std::string GetName() const
Returns the name of the parameter.
Definition: Reflection.h:213
Data Get(Data &source) const
Gets data from the datamember.
Definition: Reflection.h:1008
std::string name
Definition: Reflection.h:1545
std::string GetNameOf(const T_ &val)
Definition: Reflection.h:44
const Type & GetOwner() const
If this function is a member function, returns the owner object.
Definition: Reflection.h:874
bool RepeatLast() const
Returns if the last parameter of this function should be repeated.
Definition: Reflection.h:630
const Function::Overload * GetTypeCastingFrom(const Type *other, bool implicit=true) const
This function returns type casting function from a given type to this one.
Definition: Reflection.h:1363
const Scripting::Type & InstanceMember()
bool constant
This instance member is a constant.
Definition: Reflection.h:500
void Add(const K_ &key, T_ &obj, bool deleteprev=false)
Adds the given item with the related key.
Definition: Hashmap.h:264
Runtime Type Hierarchy.
Definition: TMP.h:364
StaticDataMember(const std::string &name, const std::string &help, const Type *type, bool constant, bool ref, bool readonly)
Definition: Reflection.h:423
virtual void SetParent(const Member &parent) override
Changes the parent of the member.
Definition: Reflection.h:1605
bool Compare(const Data &l, const Data &r) const
This function compares two instances of this type. Both left and right should of this type.
Definition: Reflection.cpp:95
bool IsMember() const
Returns if this function is a member function of a type.
Definition: Reflection.h:863
bool accessible
Only meaningful in class member functions.
Definition: Reflection.h:751
static VirtualMachine & Get()
Returns the current VM for this thread.
Definition: VirtualMachine.h:109
bool operator==(const Type &other) const
Compares two types.
Definition: Reflection.h:1338
MorphType
There are multiple ways to morph a type to another, this enumeration holds these types.
Definition: Reflection.h:1169
const Member * parent
Definition: Reflection.h:358
void AddInheritance(const Type &type, Inheritance::ConversionFunction from, Inheritance::ConversionFunction to)
Adds an inheritance parent.
Definition: Reflection.cpp:257
bool IsReferenceType() const
Returns whether this type is a reference type.
Definition: Reflection.h:1327
const Scripting::Type & StaticDataMember()
std::string GetHelp() const
Returns the help related with this parameter.
Definition: Reflection.h:218
EnumType(const std::string &name, const std::string &help, const std::vector< ElementInitializer > &elements, TMP::RTTH *typeinterface)
Definition: Reflection.h:1550
void AddConstructors(std::initializer_list< Function::Overload * > elements)
Adds the given constructors.
Definition: Reflection.h:1298
StaticDataMember(const std::string &name, const std::string &help, const Type *type, Tag first, P_ ...rest)
Definition: Reflection.h:433
InstanceMember * MapFunctionToInstanceMember(F_ reader, const std::string &name, const std::string &help, const Type *membertype, const Type *parenttype)
This function will map a const data returning function to a read-only, non-ref, const instance member...
Definition: Embedding.h:1147
Inheritance(const Type &target, ConversionFunction from, ConversionFunction to)
Definition: Reflection.h:1193
std::string GetHelpOf(const T_ &val)
Definition: Reflection.h:49
void ASSERT_FALSE(const std::string &message, int skip=1, int depth=4)
Definition: Assert.h:192
const Scripting::Type & Namespace()
Definition: Reflection.h:315
const Type & GetType() const
Returns the type of the data.
Definition: Data.h:173
virtual MemberType GetMemberType() const override
Returns the type of this member.
Definition: Reflection.h:1501
virtual Data get(Data &source) const =0
This function should return the value of this member.
virtual void AddMethod(Overload &overload)
Adds the given overload as a method to this function after performing necessary checks.
Definition: Reflection.h:902
const std::vector< const Scripting::Constant * > & Ordered
Ordered list of allowed values.
Definition: Reflection.h:1571
const std::map< const Type *, const Type * > & Parents
Parents of this type. This includes indirect parents as well.
Definition: Reflection.h:1402
Represents a member of a type.
Definition: Reflection.h:314
bool IsReference() const
Checks if the parameter is a reference.
Definition: Reflection.cpp:362
MemberType
Possible member types.
Definition: Reflection.h:368
virtual const std::type_info & TypeInfo() const =0
Function(const std::string &name, const std::string &help, const Type *parent, const Containers::Collection< Overload > &overloads, const Containers::Collection< Overload > &methods, Tag tag, P_ ...tags)
Regular constructor with both overloads and methods specified a long with at least a single tag.
Definition: Reflection.h:771
void Destroy()
Deletes and removes all the elements of this map, in addition to destroying data used.
Definition: Hashmap.h:366
@ Namespace
Namespace, which is also a type.
Definition: Reflection.h:379
bool AllowsNull() const
If true, a null reference can be passed to this parameter.
Definition: Reflection.h:249
virtual ~Member()
Definition: Reflection.h:322
virtual ~Function()
Definition: Reflection.h:839
void MakeConstant()
Makes this data a constant.
Definition: Data.cpp:199
bool IsConstant() const
Returns whether this member is a constant.
Definition: Reflection.h:469
This class stores information about types.
Definition: Reflection.h:1165
void AddConstructor(Function::Overload &element)
Adds the given constructor.
Definition: Reflection.h:1309
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
const Type * type
Type of the datamember.
Definition: Reflection.h:1056
This class represents a library.
Definition: Reflection.h:1596
StaticMemberList members
Definition: Reflection.h:1152
const Containers::Collection< Overload > & Methods
The list of methods this function has.
Definition: Reflection.h:936
bool IsReference() const
Returns whether this member is a reference.
Definition: Reflection.h:1032
RTTS & NormalType
Definition: TMP.h:375
Namespace contains other static members as members.
Definition: Reflection.h:1073
~Library()
Definition: Reflection.h:1602
bool referencetype
Whether this type is a reference type.
Definition: Reflection.h:1452
virtual void AddMember(InstanceMember &member)
Adds a list of instance members to this type.
Definition: Reflection.h:1246
StaticMember(const std::string &name, const std::string &help)
Definition: Reflection.h:391
virtual Data Get() const override final
Returns the value of this static member.
Definition: Reflection.h:1466
@ AlreadMatching
Already that type.
Definition: Reflection.h:1174
virtual void Assign(Data &l, const Data &r) const =0
Assigns the value of the second parameter to the first, reference types can ignore this function.
virtual MemberType GetMemberType() const override
Returns the type of this member.
Definition: Reflection.h:1079
@ RepeatTag
Marks an object as repeatable.
Definition: Reflection.h:73
virtual Data Get() const =0
Returns the value of this static member.
virtual void set(Data &newval)=0
Implementers of static data member should overload this function for assignment.
bool StretchLast() const
Returns if the last parameter of this function should be stretched.
Definition: Reflection.h:622
bool IsImplicit() const
Returns if this variant can be used as implicit conversion.
Definition: Reflection.h:669
bool operator==(const Parameter &p) const
Compares two parameters, not very reliable, it does not check defaultvalue and options.
Definition: Reflection.h:200
virtual ~Overload()
Definition: Reflection.h:613
bool IsReference() const
Returns if this data contains a reference.
Definition: Data.cpp:212
bool IsConstant() const
Returns whether this member is a constant.
Definition: Reflection.h:1027
Iterator end()
end iterator
Definition: Hashmap.h:420
This is the base class for all static members.
Definition: Reflection.h:365
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
static Data Invalid()
Constructs an invalid data object.
Definition: Data.h:27
DefineEnumStringsCM(StaticMember, MemberType, {StaticMember::RegularType, "RegularType"}, {StaticMember::EventType, "EventType"}, {StaticMember::EnumType, "EnumType"}, {StaticMember::Namespace, "Namespace"}, {StaticMember::DataMember, "DataMember"}, {StaticMember::Function, "Function"}, {StaticMember::Constant, "Constant"},)
virtual void AddMember(StaticMember &member) override
Adds a static member to this type.
Definition: Reflection.h:1214
bool IsReadonly() const
Returns whether this member is read-only.
Definition: Reflection.h:481
This class represents a static constant.
Definition: Reflection.h:1458
Collection is a container for reference typed objects.
Definition: Collection.h:21
InstanceMember(const std::string &name, const std::string &help, const Type &type, bool constant=false, bool ref=false, bool readonly=false)
Constructor.
Definition: Reflection.h:994
Function * parent
The parent function of this variant.
Definition: Reflection.h:763
virtual void AddMembers(std::vector< StaticMember * > newmembers) override
Adds a list of static members to this type.
Definition: Reflection.h:1237
std::vector< Any > OptionList
Definition: Reflection.h:114
TMP::RTTI & TypeInfo() const
Returns TypeInfo used by current data.
Definition: Any.h:87
const Scripting::Type & Library()
virtual Data Get() const override final
Returns the value of this static member.
Definition: Reflection.h:1505
void Set(Data &source, Data &value) const
Sets the data of the data member, if the source is a reference, this function should perform in place...
Definition: Reflection.h:1019
OptionList Options
Allowed values for this parameter.
Definition: Reflection.h:261
@ ReferenceTag
Marks the object as a reference.
Definition: Reflection.h:61
virtual void AddMembers(std::initializer_list< InstanceMember * > newmembers)
Adds an instance member to this type.
Definition: Reflection.h:1270
const Scripting::Type & EnumType()
@ OptionalTag
Marks the object as optional.
Definition: Reflection.h:56
@ StaticTag
Makes an object static.
Definition: Reflection.h:89
const Type & target
Definition: Reflection.h:1196
bool IsSame(const Overload &var) const
Compares two variants if they have the same signature.
Definition: Reflection.cpp:332
@ Function
Function, functions can also be represented as data members.
Definition: Reflection.h:385
virtual bool IsInstanceMember() const override final
Returns if this member is an instance member.
Definition: Reflection.h:394
virtual void AddMember(StaticMember *member) override
Adds a static member to this type.
Definition: Reflection.h:1221
const ParameterList & Parameters
The parameters of this overload.
Definition: Reflection.h:681
Data Construct(const std::vector< Data > ¶meters) const
!Unsafe. Constructs a new object from the given parameters. Requires parameters to be the exact type.
Definition: Reflection.cpp:15
@ StretchTag
Used only in functions with console dialect.
Definition: Reflection.h:77
Namespace(const std::string &name, const std::string &help)
Definition: Reflection.h:1075
@ KeywordTag
Marks object as a keyword.
Definition: Reflection.h:80
virtual void AddOverload(Overload *overload)
Adds the given overload to this function after performing necessary checks.
Definition: Reflection.h:919
Represents a function overload.
Definition: Reflection.h:588
@ DataMember
Data member.
Definition: Reflection.h:382
virtual ~Type()
Destructor.
Definition: Reflection.h:1417
bool stretchlast
If true, in console dialect, spaces in the last parameter are not treated as parameter separator as i...
Definition: Reflection.h:743
virtual MemberType GetMemberType() const =0
Returns the type of this member.
Scripting::Function constructor
Constructors of this type.
Definition: Reflection.h:1440
std::map< const Type *, Inheritance > inheritsfrom
Inheritance list.
Definition: Reflection.h:1443
bool IsReadonly() const
Returns whether this member is read-only.
Definition: Reflection.h:1039
Any GetDefaultValue() const
Returns the value of the type.
Definition: Reflection.h:1322
const Type * returntype
The return type of this event, if it is allowed to return a value.
Definition: Reflection.h:1533
bool repeatlast
If true last parameter can be specified any number of times.
Definition: Reflection.h:747
const Type & GetType() const
Returns the type of the parameter.
Definition: Reflection.h:223
@ ConstTag
Marks a parameter or a function constant.
Definition: Reflection.h:95
bool IsVariable() const
If true, this parameter is a variable and its name is given to the function as a string.
Definition: Reflection.h:244
ParameterList parameters
Modifiable parameters of this overload.
Definition: Reflection.h:736
This class allows embedded types to become scripting types that are passed around as values.
Definition: Embedding.h:1300
virtual Data Get() const override
Returns the value of this static member.
Definition: Reflection.h:1207
E_ is an enumeration with defined strings.
Definition: Embedding.h:1786
virtual MemberType GetMemberType() const override
Returns the type of this member.
Definition: Reflection.h:844
const Function & GetParent() const
Returns the function this variant belongs.
Definition: Reflection.h:650
Type * ArrayType()
Definition: Array.cpp:74
Any GetData() const
Returns the data contained in this data element.
Definition: Data.h:133
virtual Data Get() const override
Returns the value of this static member.
Definition: Reflection.h:1083
const Type & GetType(const std::string &name) const
Convenience function, returns the type with the given name.
Definition: Reflection.cpp:395
virtual bool IsInstanceMember() const =0
Returns if this member is an instance member.
bool returnsref
This function variant returns a reference.
Definition: Reflection.h:757
std::set< std::string, String::CaseInsensitiveLess > KeywordNames
Definition: Scripting.cpp:13
bool IsKeyword() const
Returns if this function is actually a keyword.
Definition: Reflection.h:853
This class represents a function parameter description.
Definition: Reflection.h:137
const Type & GetType() const
Returns the type of this static member.
Definition: Reflection.h:464
bool readonly
Marks this instance as read-only.
Definition: Reflection.h:1065
Any value
Definition: Reflection.h:1547
Function(const std::string &name, const std::string &help, const Type *parent, const Containers::Collection< Overload > &overloads, const Containers::Collection< Overload > &methods=Containers::Collection< Overload >())
Regular constructor with both overloads and methods without any tags.
Definition: Reflection.h:809
bool reference
This instance member is a reference.
Definition: Reflection.h:1062
const Scripting::Function & GetFunction(const std::string &name) const
Convenience function, returns the function with the given name.
Definition: Reflection.cpp:406
Represents an enumeration type.
Definition: Reflection.h:1540
std::function< Data(Data)> ConversionFunction
Definition: Reflection.h:1191
std::string name
The name of the datamember.
Definition: Reflection.h:353
@ TypeCasting
This is a type casting.
Definition: Reflection.h:1183
const Type & GetReturnType() const
Returns the type this variant returns.
Definition: Reflection.h:662
Type * TypeType()
Definition: Reflection.cpp:15
@ VariableTag
Makes this parameter a variable accepting parameter.
Definition: Reflection.h:102
Type
Definition: Shader.h:14
void * Pointer() const
Returns the pointer without type information.
Definition: Any.h:332
void Destroy()
Destroys the entire collection, effectively deleting the contents and the list including all the memo...
Definition: Collection.h:662
void add(const ElementInitializer &element)
Definition: Reflection.h:1580
bool IsInstanceable() const
Whether this member can be used to instantiate an object.
Definition: Reflection.h:398
const Type & GetType() const
Returns the type of the constant.
Definition: Reflection.h:1475
virtual ~InstanceMember()
Definition: Reflection.h:1043
Function(const std::string &name, const std::string &help, const Type *parent, bool keyword, bool isoperator, bool staticmember)
Full constructor.
Definition: Reflection.h:827
virtual void deleteobject(const Data &) const =0
This function should delete the given object.
std::string GetQualifiedName() const
Returns the namespace qualified name of this member.
Definition: Reflection.h:338
const Namespace & GetNamespace(const std::string &name) const
Convenience function, returns the namespace with the given name.
Definition: Reflection.cpp:384
Library Reflection
Definition: Builtin.cpp:17
std::string help
Help string of the datamember.
Definition: Reflection.h:356
virtual void AddMember(StaticMember &member)
Adds a new member to this namespace.
Definition: Reflection.h:1088
bool operator!=(const Type &other) const
Compares two types.
Definition: Reflection.h:1347
This class allows embedded types to become scripting types that are passed around as references.
Definition: Embedding.h:1406
virtual void AddMember(StaticMember *member)
Adds a new member to this namespace.
Definition: Reflection.h:1095
const Member * GetOwner() const
Definition: Reflection.h:345
void Set(Data &newval)
Changes the value of this member.
Definition: Reflection.h:445
Library Reflection("Reflection", "This library contains reflection objects")
Scripting::Function::Overload * MapFunction(F_ fn, const Type *returntype, ParameterList parameters, P_ ...tags)
Definition: Embedding.h:614
const std::map< const Type *, Inheritance > & InheritsFrom
Inheritance list.
Definition: Reflection.h:1405
const Containers::Collection< Overload > & Overloads
The list of overloads this function has.
Definition: Reflection.h:933
bool constant
This instance member is a constant.
Definition: Reflection.h:1059
virtual MemberType GetMemberType() const override final
Returns the type of this member.
Definition: Reflection.h:1470
Exceptions This file contains string related exceptions.
ElementInitializer(std::string name, std::string help, Any value)
Definition: Reflection.h:1543
Containers::Hashmap< std::string, const Type, nullptr, std::map, String::CaseInsensitiveLess > inheritedsymbols
Inherited symbols.
Definition: Reflection.h:1446
@ Constant
Static fixed constant.
Definition: Reflection.h:388
bool returnsconst
This function variant returns a constant, useful with references.
Definition: Reflection.h:760
friend class Type
Definition: Reflection.h:316
const Scripting::Type & EventType()
Function(const std::string &name, const std::string &help, const Type *parent, const Containers::Collection< Overload > &overloads, Tag tag, P_ ...tags)
Regular constructor with overloads specified a long with at least a single tag.
Definition: Reflection.h:793
RTTS & PtrType
Definition: TMP.h:375
bool constant
Makes this function constant. Only works on member functions.
Definition: Reflection.h:754
const Scripting::Type & Function()
Definition: Reflection.h:589
Array * BuildArray(const Type *type, std::vector< Data > datav)
Definition: Array.cpp:184
Represents a function.
Definition: Reflection.h:557
Iterator First()
returns the iterator to the first item
Definition: Hashmap.h:425
std::string GetHelp() const
Returns the help string. Help strings may contain markdown notation.
Definition: Reflection.h:330
Library(const std::string &name, const std::string &help)
Constructor.
Definition: Reflection.h:1599
@ EnumType
Enumeration, which is also a type.
Definition: Reflection.h:376
const Scripting::Type & Type()
Definition: Reflection.h:316
bool IsConstant() const
Checks if this parameter accepts a constant value.
Definition: Reflection.h:238
virtual bool compare(const Data &l, const Data &r) const
This function should compare two instances of the type.
Definition: Reflection.h:1429
MorphType CanMorphTo(const Type &type) const
Check if it is possible to morph this type to the other.
Definition: Reflection.cpp:214
Member(const std::string &name, const std::string &help)
Definition: Reflection.h:319
bool ReturnsRef() const
This function variant returns a reference to a value rather than the value itself.
Definition: Reflection.h:640
bool ReturnsConst() const
This function variant returns a constant.
Definition: Reflection.h:645
@ NotPossible
Morphing is not possible.
Definition: Reflection.h:1171
@ EventType
An event type, which contains additional information about an event.
Definition: Reflection.h:373
InstanceMemberList instancemembers
Instance members of this type.
Definition: Reflection.h:1432
bool IsValid() const
Returns if the data is in a valid state.
Definition: Data.h:152
Constant(const std::string &name, const std::string &help, Data value)
Definition: Reflection.h:1460
Function(const Function &)=delete
Definition: Reflection.h:1542
@ RegularType
A type.
Definition: Reflection.h:370
friend class Type
Definition: Reflection.h:558
const ParameterList & Parameters
Read only list of parameters.
Definition: Reflection.h:1526
This class represents an instance data member.
Definition: Reflection.h:989
Iterator Find(const K_ &key)
Finds the given key in the hashmap and returns iterator for it.
Definition: Hashmap.h:402
@ ImplicitTag
Makes a constructor implicit.
Definition: Reflection.h:105
const Type * type
Type of the datamember.
Definition: Reflection.h:497
virtual void Assign(Data &l, const Data &r) const override
Assigns the value of the second parameter to the first, reference types can ignore this function.
Definition: Reflection.h:1521
virtual MemberType GetMemberType() const override
Returns the type of this member.
Definition: Reflection.h:1205
Data MorphTo(const Type &type, Data source, bool allowtypecast=true) const
Morphs the given data into the target type.
Definition: Reflection.cpp:123
virtual void set(Data &source, Data &value) const =0
This function should perform set operation.
bool IsStatic() const
Returns if this function is static. Only meaningful when the function is a member function.
Definition: Reflection.h:858
Events allow an easy mechanism to program logic into actions instead of checking actions continuously...
Definition: Reflection.h:1491
@ AllowNullTag
Allows a parameter to be NULL.
Definition: Reflection.h:108
Definition: Reflection.h:421
std::string help
Definition: Reflection.h:1546
bool Exists(const K_ &key) const
Checks if an element with the given key exists.
Definition: Hashmap.h:396
void InitReflection()
Definition: Reflection.cpp:30
Any defaultvalue
Default value of this type.
Definition: Reflection.h:1436
std::string GetName() const
Returns the name of this member.
Definition: Reflection.h:325