![]() |
Gorgon Game Engine
|
This namespace contains Gorgon Script parser and reflection facilities. More...
Namespaces | |
Compilers | |
This namespace contains compliers and any utilities related with it. | |
Types | |
Allows easy and fast access to integral types. | |
Classes | |
class | Array |
class | ConsoleInput |
Reads lines from the console. More... | |
class | Constant |
This class represents a static constant. More... | |
class | Data |
Data describes a piece of data. More... | |
class | EnumType |
Represents an enumeration type. More... | |
class | EventType |
Events allow an easy mechanism to program logic into actions instead of checking actions continuously. More... | |
class | FileInput |
Reads lines from a file. More... | |
class | Function |
Represents a function. More... | |
class | InputProvider |
class | InstanceMember |
This class represents an instance data member. More... | |
struct | Instruction |
A single instruction. More... | |
class | Library |
This class represents a library. More... | |
class | MappedEventType |
R_: return type, P_: parameters, E_: event object type. More... | |
class | MappedFunction |
This class wraps a C++ function into an overload. It can be constructed using MapFunction. More... | |
class | MappedInstanceMember |
This class allows a one to one mapping of a data member to a c++ data member. More... | |
class | MappedInstanceMember_Function |
This class allows mapping of a data member to c++ function data member. More... | |
class | MappedOperator |
This class makes working with operators easier. More... | |
class | MappedReferenceType |
This class allows embedded types to become scripting types that are passed around as references. More... | |
class | MappedROInstanceMember |
This class allows a one to one mapping of a data member to a c++ data member. More... | |
class | MappedROInstanceMember_Function |
This class allows mapping of a data member to c++ function data member. More... | |
class | MappedROStaticDataMember |
class | MappedStaticDataMember |
class | MappedStringEnum |
E_ is an enumeration with defined strings. More... | |
class | MappedValueType |
This class allows embedded types to become scripting types that are passed around as values. More... | |
class | Member |
Represents a member of a type. More... | |
class | Namespace |
Namespace contains other static members as members. More... | |
class | Parameter |
This class represents a function parameter description. More... | |
struct | ParameterTemplate |
This class holds information about a parameter without resolving constructs. More... | |
class | ReferenceCounter |
This class allows references to be counted and destroyed properly. More... | |
class | Return |
Represents what could be returned from a scope instance. More... | |
class | RuntimeOverload |
class | Scope |
A new scope is created automatically when a new input source or a function like construct is created. More... | |
class | ScopeInstance |
This is an instantiation of a scope. More... | |
class | SourceMarker |
This class uniquely represents a source code line. More... | |
class | StaticDataMember |
class | StaticMember |
This is the base class for all static members. More... | |
class | StreamInput |
Reads lines from a stream. More... | |
class | Symbol |
Represents a symbol, can be a variable, type, function or constant. More... | |
class | Type |
This class stores information about types. More... | |
struct | Value |
This class contains a parsed value. More... | |
class | Variable |
This class represents a variable. It contains the data and the name of the variable. More... | |
class | VirtualMachine |
This class defines a virtual environment for scripts to run. More... | |
Typedefs | |
using | InstanceMemberList = Containers::Hashmap< std::string, const InstanceMember, GetNameOf< InstanceMember >, std::map, String::CaseInsensitiveLess > |
typedef std::vector< Any > | OptionList |
using | ParameterList = std::vector< Parameter > |
template<class T_ > | |
using | ParseFn = T_(*)(const std::string &) |
using | StaticMemberList = Containers::Hashmap< std::string, const StaticMember, GetNameOf< StaticMember >, std::map, String::CaseInsensitiveLess > |
template<class T_ > | |
using | StringFromFn = std::string(*)(const T_ &) |
Enumerations | |
enum | InstructionType { Unknown, FunctionCall, MemberFunctionCall, MethodCall, MemberToTemp, MemberToVar, MemberAssignment, MemberMethodCall, Assignment, RemoveTemp, SaveToTemp, Jump, JumpFalse, JumpTrue, DeclOverload } |
Describes the type of an instruction. More... | |
enum | Tag { OptionalTag, ReferenceTag, InputTag, MethodTag, RepeatTag, StretchTag, KeywordTag, PrivateTag, PublicTag, StaticTag, OperatorTag, ConstTag, ReturnsConstTag, VariableTag, ImplicitTag, AllowNullTag, ReadonlyTag } |
Tags define behavior of reflection objects. More... | |
enum | ValueType { Temp, Literal, Variable, Identifier, None } |
Possible value types. More... | |
Functions | |
std::vector< StaticMember * > | ArrayFunctions () |
Type * | ArrayType () |
Array * | BuildArray (const Type *type, std::vector< Data > datav) |
std::string | ByteToString (const Gorgon::Byte &b) |
DefineEnumStringsCM (StaticMember, MemberType, {StaticMember::RegularType, "RegularType"}, {StaticMember::EventType, "EventType"}, {StaticMember::EnumType, "EnumType"}, {StaticMember::Namespace, "Namespace"}, {StaticMember::DataMember, "DataMember"}, {StaticMember::Function, "Function"}, {StaticMember::Constant, "Constant"},) | |
Library & | FilesystemLib () |
void | fixparameter (Data ¶m, const Type &pdef, bool ref, const std::string &error) |
Type * | FunctionType () |
template<class T_ > | |
std::string | GetHelpOf (const T_ &val) |
template<class T_ > | |
std::string | GetNameOf (const T_ &val) |
void | init_builtin () |
void | Initialize () |
Initializes the scripting system. More... | |
void | InitReflection () |
void | InitTypeType () |
Library | Integrals ("Integrals", "Integral types and functions") |
Library | Keywords ("Keywords", "Function like keywords.") |
template<class from_ , class to_ > | |
Scripting::Function::Overload * | MapConstDynamiccast (Type *from, Type *to, bool implicit=true) |
Maps a constructor for type casting, works for polymorphic types. More... | |
template<class from_ , class to_ > | |
Scripting::Function::Overload * | MapConstStaticcast (Type *from, Type *to, bool implicit=true) |
Maps a constructor for type casting, works for const reference types. More... | |
template<class from_ , class to_ > | |
Scripting::Function::Overload * | MapDynamiccast (Type *from, Type *to, bool implicit=true) |
Maps a constructor for type casting, works for polymorphic types. More... | |
template<class T_ , class I_ > | |
void | MapDynamicInheritance (Type *type, Type *inherited) |
template<class F_ , class ... P_> | |
Scripting::Function::Overload * | MapFunction (F_ fn, const Type *returntype, ParameterList parameters, bool stretchlast, bool repeatlast, bool accessible, bool constant, bool returnsref, bool returnsconst, bool implicit) |
template<class F_ , class ... P_> | |
Scripting::Function::Overload * | MapFunction (F_ fn, const Type *returntype, ParameterList parameters, P_ ...tags) |
template<class F_ > | |
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. More... | |
template<class F_ , class ... P_> | |
Scripting::Function::Overload * | MapOperator (F_ fn, const Type *returntype, const Type *rhs) |
template<class from_ , class to_ > | |
Scripting::Function::Overload * | MapStaticcast (Type *from, Type *to, bool implicit=true) |
Maps a constructor for type casting, works for reference types. More... | |
template<class from_ , class to_ > | |
Scripting::Function::Overload * | MapTypecast (Type *from, Type *to, bool implicit=true) |
Maps a constructor for type casting, works for value types. More... | |
std::ostream & | operator<< (std::ostream &out, const Data &data) |
This function parses the code and returns any syntax errors. More... | |
std::ostream & | operator<< (std::ostream &out, const Type &type) |
Allows printing of types. More... | |
std::ostream & | operator<< (std::ostream &out, std::ios_base::openmode mode) |
Type * | ParameterTemplateType () |
Type * | ParameterType () |
template<class T_ > | |
T_ | ParseThrow (const std::string &) |
Library | Reflection ("Reflection", "This library contains reflection objects") |
template<class T_ > | |
std::string | ToEmptyString (const T_ &) |
Type * | TypeType () |
Variables | |
Library | Integrals |
This library requires Initialize to be called. More... | |
std::set< std::string, String::CaseInsensitiveLess > | KeywordNames |
Library | Keywords |
Library | Math ("Math", "Maths library.") |
Library | Reflection |
This namespace contains Gorgon Script parser and reflection facilities.
using InstanceMemberList = Containers::Hashmap<std::string, const InstanceMember, GetNameOf<InstanceMember>, std::map, String::CaseInsensitiveLess> |
typedef std::vector<Any> OptionList |
using ParameterList = std::vector<Parameter> |
using ParseFn = T_(*)(const std::string &) |
using StaticMemberList = Containers::Hashmap<std::string, const StaticMember, GetNameOf<StaticMember>, std::map, String::CaseInsensitiveLess> |
using StringFromFn = std::string(*)(const T_ &) |
|
strong |
Describes the type of an instruction.
Enumerator | |
---|---|
Unknown | This value is not valid. |
FunctionCall | Marks instruction as a regular function call. Regular function calls can also be member functions, however, they cannot be data members. |
MemberFunctionCall | Marks this instruction as a member function call. This means the function is either a data member and will return or set the value of the member or a member function that will be called. |
MethodCall | Marks this instruction as a method call. |
MemberToTemp | Marks this instruction as access to a member, the result is stored in the given temporary. Member name is stored in RHS, temp index is stored in Store, and this pointer is stored in Parameters fields |
MemberToVar | Marks this instruction as access to a member, the result is stored in the given variable. Member name is stored in RHS and the variable name is stored in Name fields |
MemberAssignment | Marks this instruction as member assignment. Name of the member is stored in the Name field, and the value to be assigned is stored in the RHS field. |
MemberMethodCall | Marks this instruction as a member method call. Function name is passed in Name field. This pointer is the first element in the Parameters vector |
Assignment | Marks instruction as an assignment. |
RemoveTemp | Marks instruction as a removal of a temporary. Temporary index should be stored in the Store member. |
SaveToTemp | This instruction saves a value to the temporary. |
Jump | Unconditionally jumps by the given offset. Offset should be in JumpOffset field. |
JumpFalse | Jumps by the given offset if RHS is false. Offset should be in JumpOffset field. |
JumpTrue | Jumps by the given offset if RHS is true. Offset should be in JumpOffset field. |
DeclOverload | Declares a new function overload. If the function does not exists, it will define the function. |
enum Tag |
Tags define behavior of reflection objects.
Enumerator | |
---|---|
OptionalTag | Marks the object as optional. |
ReferenceTag | Marks the object as a reference. When this tag affects types, it marks the type as a reference type, meaning it will always be moved around as a reference. When this tag affects parameters, object becomes a reference to the parameter |
InputTag | Marks the object as input. |
MethodTag | Marks the object as output. This may set ReferenceTag and unset InputTag. Denotes that a function has a method variant |
RepeatTag | Marks an object as repeatable. |
StretchTag | Used only in functions with console dialect. When set, this tag allows last parameter to contain spaces |
KeywordTag | Marks object as a keyword. |
PrivateTag | Makes the object private, allowing only access from it parent. |
PublicTag | Makes the object public, allowing it to be accessed from all. |
StaticTag | Makes an object static. |
OperatorTag | Makes a function operator. |
ConstTag | Marks a parameter or a function constant. |
ReturnsConstTag | Denotes a function that returns const. |
VariableTag | Makes this parameter a variable accepting parameter. Variable parameters are type checked against supplied type, however, they are always passed as strings denoting the name of the variable |
ImplicitTag | Makes a constructor implicit. |
AllowNullTag | Allows a parameter to be NULL. |
ReadonlyTag | Marks a data member readonly, so that it can be manipulated, but cannot be changed. |
|
strong |
Possible value types.
std::vector< StaticMember * > ArrayFunctions | ( | ) |
References ArrayType(), Gorgon::Scripting::Types::Function(), and MapFunction().
Type * ArrayType | ( | ) |
std::string Gorgon::Scripting::ByteToString | ( | const Gorgon::Byte & | b | ) |
References Gorgon::String::From().
Gorgon::Scripting::DefineEnumStringsCM | ( | StaticMember | , |
MemberType | , | ||
{StaticMember::RegularType, "RegularType"} | , | ||
{StaticMember::EventType, "EventType"} | , | ||
{StaticMember::EnumType, "EnumType"} | , | ||
{StaticMember::Namespace, "Namespace"} | , | ||
{StaticMember::DataMember, "DataMember"} | , | ||
{StaticMember::Function, "Function"} | , | ||
{StaticMember::Constant, "Constant"} | |||
) |
References StaticMember::RegularType.
Library & FilesystemLib | ( | ) |
void Gorgon::Scripting::fixparameter | ( | Data & | param, |
const Type & | pdef, | ||
bool | ref, | ||
const std::string & | error | ||
) |
References Data::GetType(), Data::GetValue(), Type::MorphTo(), and Type::ToString().
Type* Gorgon::Scripting::FunctionType | ( | ) |
std::string Gorgon::Scripting::GetHelpOf | ( | const T_ & | val | ) |
std::string Gorgon::Scripting::GetNameOf | ( | const T_ & | val | ) |
void Gorgon::Scripting::init_builtin | ( | ) |
References Namespace::AddMember(), Namespace::AddMembers(), ArrayFunctions(), ArrayType(), Gorgon::Scripting::Types::Constant(), ConstTag, Gorgon::Resource::GID::Data, Gorgon::String::Extract(), Gorgon::Scripting::Types::Function(), VirtualMachine::Get(), Hashmap< K_, T_, KeyFn, M_, C_ >::GetCount(), Data::GetData(), VirtualMachine::GetOutput(), Data::GetType(), VirtualMachine::getvarref(), ImplicitTag, InitReflection(), Integrals, Data::Invalid(), Data::IsReference(), Gorgon::Graphics::internal::isspace(), Keywords, KeywordTag, Gorgon::Animation::log, MAP_COMPARE, MapFunction(), MapFunctionToInstanceMember(), MapOperator(), Math, Namespace::Members, Gorgon::Scripting::Types::Namespace(), OptionalTag, Type::Parse(), Any::Pointer(), ReferenceTag, RepeatTag, Gorgon::String::Replace(), VirtualMachine::ResetOutput(), VirtualMachine::SetOutput(), StretchTag, Gorgon::String::ToLower(), Gorgon::String::ToUpper(), Gorgon::String::Trim(), Gorgon::Scripting::Types::Type(), TypeType(), VirtualMachine::UnsetVariable(), and VariableTag.
void Gorgon::Scripting::Initialize | ( | ) |
Initializes the scripting system.
Initializes the filesystem module.
Gorgon system requires every module to have initialization function even if they are not used. Currently used for following tasks:
Set startup directory
There is a mechanism to ensure initialization is performed once.
References init_builtin().
void InitReflection | ( | ) |
References Namespace::AddMember(), Parameter::AllowsNull(), ArrayType(), Gorgon::Scripting::Types::Constant(), StaticMember::Constant, ConstTag, Hashmap< K_, T_, KeyFn, M_, C_ >::Exists(), Hashmap< K_, T_, KeyFn, M_, C_ >::First(), Gorgon::Scripting::Types::Function(), StaticMember::Function, VirtualMachine::Get(), Constant::Get(), Parameter::GetDefaultValue(), Parameter::GetHelp(), Member::GetHelp(), StaticMember::GetMemberType(), Parameter::GetName(), Member::GetName(), Member::GetOwner(), Function::GetOwner(), Member::GetQualifiedName(), Function::Overload::GetReturnType(), Parameter::GetType(), Constant::GetType(), Function::Overload::HasReturnType(), Parameter::IsConstant(), Function::Overload::IsConstant(), Function::Overload::IsImplicit(), StaticMember::IsInstanceable(), Member::IsInstanceMember(), Function::IsKeyword(), Function::IsMember(), Function::IsOperator(), Parameter::IsOptional(), Parameter::IsReference(), Function::IsStatic(), Parameter::IsVariable(), MapFunction(), MapFunctionToInstanceMember(), Namespace::Members, Function::Methods, Parameter::Options, Function::Overloads, Function::Overload::Parameters, VirtualMachine::References, ReferenceTag, Reflection, ReferenceCounter::Register(), Function::Overload::RepeatLast(), Function::Overload::ReturnsConst(), Function::Overload::ReturnsRef(), Function::Overload::StretchLast(), Gorgon::Scripting::Types::Type(), TypeType(), and Namespace::ValueOf().
void Gorgon::Scripting::InitTypeType | ( | ) |
Library Gorgon::Scripting::Integrals | ( | "Integrals" | , |
"Integral types and functions" | |||
) |
Library Gorgon::Scripting::Keywords | ( | "Keywords" | , |
"Function like keywords." | |||
) |
Scripting::Function::Overload* Gorgon::Scripting::MapConstDynamiccast | ( | Type * | from, |
Type * | to, | ||
bool | implicit = true |
||
) |
Maps a constructor for type casting, works for polymorphic types.
References ImplicitTag, and MapFunction().
Scripting::Function::Overload* Gorgon::Scripting::MapConstStaticcast | ( | Type * | from, |
Type * | to, | ||
bool | implicit = true |
||
) |
Maps a constructor for type casting, works for const reference types.
References ImplicitTag, and MapFunction().
Scripting::Function::Overload* Gorgon::Scripting::MapDynamiccast | ( | Type * | from, |
Type * | to, | ||
bool | implicit = true |
||
) |
Maps a constructor for type casting, works for polymorphic types.
References ImplicitTag, and MapFunction().
References Type::AddInheritance(), ASSERT, Gorgon::Resource::GID::Data, Data::IsConstant(), and Data::ReferenceValue().
Scripting::Function::Overload* Gorgon::Scripting::MapFunction | ( | F_ | fn, |
const Type * | returntype, | ||
ParameterList | parameters, | ||
bool | stretchlast, | ||
bool | repeatlast, | ||
bool | accessible, | ||
bool | constant, | ||
bool | returnsref, | ||
bool | returnsconst, | ||
bool | implicit | ||
) |
Scripting::Function::Overload* Gorgon::Scripting::MapFunction | ( | F_ | fn, |
const Type * | returntype, | ||
ParameterList | parameters, | ||
P_ ... | tags | ||
) |
InstanceMember* Gorgon::Scripting::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.
Scripting::Function::Overload* Gorgon::Scripting::MapOperator | ( | F_ | fn, |
const Type * | returntype, | ||
const Type * | rhs | ||
) |
References ConstTag.
Scripting::Function::Overload* Gorgon::Scripting::MapStaticcast | ( | Type * | from, |
Type * | to, | ||
bool | implicit = true |
||
) |
Maps a constructor for type casting, works for reference types.
References ImplicitTag, and MapFunction().
Scripting::Function::Overload* Gorgon::Scripting::MapTypecast | ( | Type * | from, |
Type * | to, | ||
bool | implicit = true |
||
) |
Maps a constructor for type casting, works for value types.
References ImplicitTag, and MapFunction().
std::ostream& Gorgon::Scripting::operator<< | ( | std::ostream & | out, |
const Data & | data | ||
) |
This function parses the code and returns any syntax errors.
This function cannot check parse errors that can be caused by type assignments. Additionally whether a function exists or not cannot be determined as functions can be dynamically defined at runtime. The given code will be tokenized into lines. Additionally, any referred files will also be parsed for errors. Prints out a data
References Data::GetType(), Data::IsValid(), and Type::ToString().
std::ostream& Gorgon::Scripting::operator<< | ( | std::ostream & | out, |
const Type & | type | ||
) |
Allows printing of types.
References Member::GetName().
std::ostream& Gorgon::Scripting::operator<< | ( | std::ostream & | out, |
std::ios_base::openmode | mode | ||
) |
Type * ParameterTemplateType | ( | ) |
Type* Gorgon::Scripting::ParameterType | ( | ) |
T_ Gorgon::Scripting::ParseThrow | ( | const std::string & | ) |
Library Gorgon::Scripting::Reflection | ( | "Reflection" | , |
"This library contains reflection objects" | |||
) |
std::string Gorgon::Scripting::ToEmptyString | ( | const T_ & | ) |
Type * TypeType | ( | ) |
Library Integrals |
This library requires Initialize to be called.
std::set< std::string, String::CaseInsensitiveLess > KeywordNames |
Library Keywords |
Library Math |
Library Reflection |