Gorgon Game Engine
Gorgon::Scripting Namespace Reference

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< AnyOptionList
 
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 ()
 
TypeArrayType ()
 
ArrayBuildArray (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"},)
 
LibraryFilesystemLib ()
 
void fixparameter (Data &param, const Type &pdef, bool ref, const std::string &error)
 
TypeFunctionType ()
 
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::OverloadMapConstDynamiccast (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::OverloadMapConstStaticcast (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::OverloadMapDynamiccast (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::OverloadMapFunction (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::OverloadMapFunction (F_ fn, const Type *returntype, ParameterList parameters, P_ ...tags)
 
template<class F_ >
InstanceMemberMapFunctionToInstanceMember (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::OverloadMapOperator (F_ fn, const Type *returntype, const Type *rhs)
 
template<class from_ , class to_ >
Scripting::Function::OverloadMapStaticcast (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::OverloadMapTypecast (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)
 
TypeParameterTemplateType ()
 
TypeParameterType ()
 
template<class T_ >
T_ ParseThrow (const std::string &)
 
Library Reflection ("Reflection", "This library contains reflection objects")
 
template<class T_ >
std::string ToEmptyString (const T_ &)
 
TypeTypeType ()
 

Variables

Library Integrals
 This library requires Initialize to be called. More...
 
std::set< std::string, String::CaseInsensitiveLessKeywordNames
 
Library Keywords
 
Library Math ("Math", "Maths library.")
 
Library Reflection
 

Detailed Description

This namespace contains Gorgon Script parser and reflection facilities.

See also
GScript

Typedef Documentation

◆ InstanceMemberList

◆ OptionList

typedef std::vector<Any> OptionList

◆ ParameterList

using ParameterList = std::vector<Parameter>

◆ ParseFn

using ParseFn = T_(*)(const std::string &)

◆ StaticMemberList

◆ StringFromFn

using StringFromFn = std::string(*)(const T_ &)

Enumeration Type Documentation

◆ InstructionType

enum InstructionType
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.

◆ Tag

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.

◆ ValueType

enum ValueType
strong

Possible value types.

Enumerator
Temp 

This value is a temporary and refers to a value calculated as the result of a function call.

Literal 

This is a literal value.

Variable 

This is a variable.

Identifier 

Marks this value as an identifier, either a constant or a variable.

None 

For error checking purposes.

Function Documentation

◆ ArrayFunctions()

std::vector< StaticMember * > ArrayFunctions ( )

◆ ArrayType()

◆ BuildArray()

Array * BuildArray ( const Type type,
std::vector< Data datav 
)

◆ ByteToString()

std::string Gorgon::Scripting::ByteToString ( const Gorgon::Byte b)

◆ DefineEnumStringsCM()

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"}   
)

◆ FilesystemLib()

◆ fixparameter()

void Gorgon::Scripting::fixparameter ( Data param,
const Type pdef,
bool  ref,
const std::string &  error 
)

◆ FunctionType()

Type* Gorgon::Scripting::FunctionType ( )

◆ GetHelpOf()

std::string Gorgon::Scripting::GetHelpOf ( const T_ &  val)

◆ GetNameOf()

std::string Gorgon::Scripting::GetNameOf ( const T_ &  val)

◆ init_builtin()

◆ Initialize()

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().

◆ InitReflection()

◆ InitTypeType()

void Gorgon::Scripting::InitTypeType ( )

◆ Integrals()

Library Gorgon::Scripting::Integrals ( "Integrals"  ,
"Integral types and functions"   
)

◆ Keywords()

Library Gorgon::Scripting::Keywords ( "Keywords"  ,
"Function like keywords."   
)

◆ MapConstDynamiccast()

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().

◆ MapConstStaticcast()

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().

◆ MapDynamiccast()

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().

◆ MapDynamicInheritance()

void Gorgon::Scripting::MapDynamicInheritance ( Type type,
Type inherited 
)

◆ MapFunction() [1/2]

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 
)

◆ MapFunction() [2/2]

Scripting::Function::Overload* Gorgon::Scripting::MapFunction ( F_  fn,
const Type returntype,
ParameterList  parameters,
P_ ...  tags 
)

◆ MapFunctionToInstanceMember()

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.

◆ MapOperator()

Scripting::Function::Overload* Gorgon::Scripting::MapOperator ( F_  fn,
const Type returntype,
const Type rhs 
)

References ConstTag.

◆ MapStaticcast()

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().

◆ MapTypecast()

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().

◆ operator<<() [1/3]

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().

◆ operator<<() [2/3]

std::ostream& Gorgon::Scripting::operator<< ( std::ostream &  out,
const Type type 
)

Allows printing of types.

References Member::GetName().

◆ operator<<() [3/3]

std::ostream& Gorgon::Scripting::operator<< ( std::ostream &  out,
std::ios_base::openmode  mode 
)

◆ ParameterTemplateType()

Type * ParameterTemplateType ( )

◆ ParameterType()

Type* Gorgon::Scripting::ParameterType ( )

◆ ParseThrow()

T_ Gorgon::Scripting::ParseThrow ( const std::string &  )

◆ Reflection()

Library Gorgon::Scripting::Reflection ( "Reflection"  ,
"This library contains reflection objects"   
)

◆ ToEmptyString()

std::string Gorgon::Scripting::ToEmptyString ( const T_ &  )

◆ TypeType()

Type * TypeType ( )

Variable Documentation

◆ Integrals

Library Integrals

This library requires Initialize to be called.

◆ KeywordNames

std::set< std::string, String::CaseInsensitiveLess > KeywordNames

◆ Keywords

Library Keywords

◆ Math

Library Math

◆ Reflection

Library Reflection