Ogre::ScriptCompiler Class Reference
Core » General

This is the main class for the compiler. More...

`#include <OgreScriptCompiler.h>`

Inheritance diagram for Ogre::ScriptCompiler:
[legend]

## Classes

class | AbstractTreeBuilder
struct | Error

## Public Types

enum | { ID_ON = 1, ID_OFF = 2, ID_TRUE = 1, ID_FALSE = 2, ID_YES = 1, ID_NO = 2 }
enum | { CE_STRINGEXPECTED, CE_NUMBEREXPECTED, CE_FEWERPARAMETERSEXPECTED, CE_VARIABLEEXPECTED, CE_UNDEFINEDVARIABLE, CE_OBJECTNAMEEXPECTED, CE_OBJECTALLOCATIONERROR, CE_INVALIDPARAMETERS, CE_DUPLICATEOVERRIDE, CE_UNEXPECTEDTOKEN, CE_OBJECTBASENOTFOUND, CE_UNSUPPORTEDBYRENDERSYSTEM, CE_REFERENCETOANONEXISTINGOBJECT }
typedef list< ErrorPtr >::type | ErrorList
typedef SharedPtr< Error > | ErrorPtr
typedef HashMap< String, uint32 > | IdMap

## Public Member Functions

| ScriptCompiler ()
virtual | ~ScriptCompiler ()
bool | _compile (AbstractNodeListPtr nodes, const String &group, bool doImports=true, bool doObjects=true, bool doVariables=true)
| Compiles the given abstract syntax tree. More...
bool | _fireEvent (ScriptCompilerEvent *evt, void *retval)
| Internal method for firing the handleEvent method. More...
AbstractNodeListPtr | _generateAST (const String &str, const String &source, bool doImports=false, bool doObjects=false, bool doVariables=false)
| Generates the AST from the given string script. More...
void | addError (uint32 code, const String &file, int line, const String &msg="")
| Adds the given error to the compiler's list of errors. More...
void | addNameExclusion (const String &type)
| Adds a name exclusion to the map. More...
bool | compile (const String &str, const String &source, const String &group)
| Takes in a string of script code and compiles it into resources. More...
bool | compile (const ConcreteNodeListPtr &nodes, const String &group)
| Compiles resources from the given concrete node list. More...
ScriptCompilerListener * | getListener ()
| Returns the currently set listener. More...
const String & | getResourceGroup () const
| Returns the resource group currently set for this compiler. More...
void | operator delete (void *ptr)
void | operator delete (void *ptr, void *)
void | operator delete (void *ptr, const char *, int, const char *)
void | operator delete[] (void *ptr)
void | operator delete[] (void *ptr, const char *, int, const char *)
void * | operator new (size_t sz, const char *file, int line, const char *func)
| operator new, with debug line info More...
void * | operator new (size_t sz)
void * | operator new (size_t sz, void *ptr)
| placement operator new More...
void * | operator new[] (size_t sz, const char *file, int line, const char *func)
| array operator new, with debug line info More...
void * | operator new[] (size_t sz)
void | removeNameExclusion (const String &type)
| Removes a name exclusion. More...
void | setListener (ScriptCompilerListener *listener)
| Sets the listener used by the compiler. More...

## Static Public Member Functions

static String | formatErrorCode (uint32 code)

## Private Types

typedef map< String, String >::type | Environment
typedef map< String, AbstractNodeListPtr >::type | ImportCacheMap
typedef multimap< String, String >::type | ImportRequestMap

## Private Member Functions

AbstractNodeListPtr | convertToAST (const ConcreteNodeListPtr &nodes)
void | initWordMap ()
| This function sets up the initial values in word id map. More...
bool | isNameExcluded (const String &cls, AbstractNode *parent)
| Returns true if the given class is name excluded. More...
AbstractNodeListPtr | loadImportPath (const String &name)
| Loads the requested script and converts it to an AST. More...
AbstractNodeListPtr | locateTarget (AbstractNodeList *nodes, const String &target)
| Returns the abstract nodes from the given tree which represent the target. More...
void | overlayObject (const AbstractNodePtr &source, ObjectAbstractNode *dest)
| This function overlays the given object on the destination object following inheritance rules. More...
void | processImports (AbstractNodeListPtr &nodes)
| This built-in function processes import nodes. More...
void | processObjects (AbstractNodeList *nodes, const AbstractNodeListPtr &top)
| Handles object inheritance and variable expansion. More...
void | processVariables (AbstractNodeList *nodes)
| Handles processing the variables. More...

## Private Attributes

Environment | mEnv
ErrorList | mErrors
String | mGroup
IdMap | mIds
ImportRequestMap | mImportRequests
ImportCacheMap | mImports
AbstractNodeList | mImportTable
ScriptCompilerListener * | mListener

## Friends

class | AbstractTreeBuilder

## Detailed Description

This is the main class for the compiler.

It calls the parser and processes the CST into an AST and then uses translators to translate the AST into the final resources.

Definition at line 188 of file OgreScriptCompiler.h.

## Member Typedef Documentation

## Environment

typedef map<String,String>::type Ogre::ScriptCompiler::Environment

private

Definition at line 281 of file OgreScriptCompiler.h.

## ErrorList

typedef list<ErrorPtr>::type Ogre::ScriptCompiler::ErrorList

Definition at line 202 of file OgreScriptCompiler.h.

## ErrorPtr

typedef SharedPtr<Error> Ogre::ScriptCompiler::ErrorPtr

Definition at line 201 of file OgreScriptCompiler.h.

## IdMap

typedef HashMap<String,uint32> Ogre::ScriptCompiler::IdMap

Definition at line 192 of file OgreScriptCompiler.h.

## ImportCacheMap

typedef map<String,AbstractNodeListPtr>::type Ogre::ScriptCompiler::ImportCacheMap

private

Definition at line 284 of file OgreScriptCompiler.h.

## ImportRequestMap

typedef multimap<String,String>::type Ogre::ScriptCompiler::ImportRequestMap

private

Definition at line 286 of file OgreScriptCompiler.h.

## Member Enumeration Documentation

## anonymous enum

anonymous enum

Enumerator
ID_ON |
ID_OFF |
ID_TRUE |
ID_FALSE |
ID_YES |
ID_NO |

Definition at line 313 of file OgreScriptCompiler.h.

## anonymous enum

anonymous enum

Enumerator
CE_STRINGEXPECTED |
CE_NUMBEREXPECTED |
CE_FEWERPARAMETERSEXPECTED |
CE_VARIABLEEXPECTED |
CE_UNDEFINEDVARIABLE |
CE_OBJECTNAMEEXPECTED |
CE_OBJECTALLOCATIONERROR |
CE_INVALIDPARAMETERS |
CE_DUPLICATEOVERRIDE |
CE_UNEXPECTEDTOKEN |
CE_OBJECTBASENOTFOUND |
CE_UNSUPPORTEDBYRENDERSYSTEM |
CE_REFERENCETOANONEXISTINGOBJECT |

Definition at line 205 of file OgreScriptCompiler.h.

## Constructor & Destructor Documentation

## ScriptCompiler()

Ogre::ScriptCompiler::ScriptCompiler | ( |  | ) |

## ~ScriptCompiler()

virtual Ogre::ScriptCompiler::~ScriptCompiler | ( |  | ) |

virtual

Definition at line 223 of file OgreScriptCompiler.h.

References Ogre::ConcreteNode::file, Ogre::ConcreteNode::line, Ogre::ConcreteNode::parent, and Ogre::ConcreteNode::type.

## Member Function Documentation

## _compile()

bool Ogre::ScriptCompiler::_compile | ( | AbstractNodeListPtr | nodes,
|  | const String & | group,
|  | bool | doImports = `true`,
|  | bool | doObjects = `true`,
|  | bool | doVariables = `true`
| ) |  |

Compiles the given abstract syntax tree.

## _fireEvent()

bool Ogre::ScriptCompiler::_fireEvent | ( | ScriptCompilerEvent * | evt,
|  | void * | retval
| ) |  |

Internal method for firing the handleEvent method.

## _generateAST()

AbstractNodeListPtr Ogre::ScriptCompiler::_generateAST | ( | const String & | str,
|  | const String & | source,
|  | bool | doImports = `false`,
|  | bool | doObjects = `false`,
|  | bool | doVariables = `false`
| ) |  |

Generates the AST from the given string script.

## addError()

void Ogre::ScriptCompiler::addError | ( | uint32 | code,
|  | const String & | file,
|  | int | line,
|  | const String & | msg = `""`
| ) |  |

Adds the given error to the compiler's list of errors.

## addNameExclusion()

void Ogre::ScriptCompiler::addNameExclusion | ( | const String & | type | ) |

Adds a name exclusion to the map.

Name exclusions identify object types which cannot accept names. This means that excluded types will always have empty names. All values in the object header are stored as object values.

## compile() [1/2]

bool Ogre::ScriptCompiler::compile | ( | const String & | str,
|  | const String & | source,
|  | const String & | group
| ) |  |

Takes in a string of script code and compiles it into resources.

Parameters

  str | The script code
  source | The source of the script code (e.g. a script file)
  group | The resource group to place the compiled resources into

## compile() [2/2]

bool Ogre::ScriptCompiler::compile | ( | const ConcreteNodeListPtr & | nodes,
|  | const String & | group
| ) |  |

Compiles resources from the given concrete node list.

## convertToAST()

AbstractNodeListPtr Ogre::ScriptCompiler::convertToAST | ( | const ConcreteNodeListPtr & | nodes | ) |

private

## formatErrorCode()

static String Ogre::ScriptCompiler::formatErrorCode | ( | uint32 | code | ) |

static

## getListener()

ScriptCompilerListener* Ogre::ScriptCompiler::getListener | ( |  | ) |

Returns the currently set listener.

## getResourceGroup()

const String& Ogre::ScriptCompiler::getResourceGroup | ( |  | ) | const

Returns the resource group currently set for this compiler.

## initWordMap()

void Ogre::ScriptCompiler::initWordMap | ( |  | ) |

private

This function sets up the initial values in word id map.

## isNameExcluded()

bool Ogre::ScriptCompiler::isNameExcluded | ( | const String & | cls,
|  | AbstractNode * | parent
| ) |  |

private

Returns true if the given class is name excluded.

## loadImportPath()

AbstractNodeListPtr Ogre::ScriptCompiler::loadImportPath | ( | const String & | name | ) |

private

Loads the requested script and converts it to an AST.

## locateTarget()

AbstractNodeListPtr Ogre::ScriptCompiler::locateTarget | ( | AbstractNodeList * | nodes,
|  | const String & | target
| ) |  |

private

Returns the abstract nodes from the given tree which represent the target.

## operator delete() [1/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr | ) |

inherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

## operator delete() [2/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | void * |
| ) |  |

inherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

## operator delete() [3/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 108 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [1/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr | ) |

inherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [2/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 119 of file OgreMemoryAllocatedObject.h.

## operator new() [1/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

## operator new() [2/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz | ) |

inherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

## operator new() [3/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | void * | ptr
| ) |  |

inherited

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

## operator new[]() [1/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

## operator new[]() [2/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz | ) |

inherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

## overlayObject()

void Ogre::ScriptCompiler::overlayObject | ( | const AbstractNodePtr & | source,
|  | ObjectAbstractNode * | dest
| ) |  |

private

This function overlays the given object on the destination object following inheritance rules.

## processImports()

void Ogre::ScriptCompiler::processImports | ( | AbstractNodeListPtr & | nodes | ) |

private

This built-in function processes import nodes.

## processObjects()

void Ogre::ScriptCompiler::processObjects | ( | AbstractNodeList * | nodes,
|  | const AbstractNodeListPtr & | top
| ) |  |

private

Handles object inheritance and variable expansion.

## processVariables()

void Ogre::ScriptCompiler::processVariables | ( | AbstractNodeList * | nodes | ) |

private

Handles processing the variables.

## removeNameExclusion()

void Ogre::ScriptCompiler::removeNameExclusion | ( | const String & | type | ) |

Removes a name exclusion.

## setListener()

void Ogre::ScriptCompiler::setListener | ( | ScriptCompilerListener * | listener | ) |

Sets the listener used by the compiler.

## Friends And Related Function Documentation

## AbstractTreeBuilder

friend class AbstractTreeBuilder

friend

Definition at line 310 of file OgreScriptCompiler.h.

## Member Data Documentation

## mEnv

Environment Ogre::ScriptCompiler::mEnv

private

Definition at line 282 of file OgreScriptCompiler.h.

## mErrors

ErrorList Ogre::ScriptCompiler::mErrors

private

Definition at line 293 of file OgreScriptCompiler.h.

## mGroup

String Ogre::ScriptCompiler::mGroup

private

Definition at line 277 of file OgreScriptCompiler.h.

## mIds

IdMap Ogre::ScriptCompiler::mIds

private

Definition at line 279 of file OgreScriptCompiler.h.

## mImportRequests

ImportRequestMap Ogre::ScriptCompiler::mImportRequests

private

Definition at line 287 of file OgreScriptCompiler.h.

## mImports

ImportCacheMap Ogre::ScriptCompiler::mImports

private

Definition at line 285 of file OgreScriptCompiler.h.

## mImportTable

AbstractNodeList Ogre::ScriptCompiler::mImportTable

private

Definition at line 290 of file OgreScriptCompiler.h.

## mListener

ScriptCompilerListener* Ogre::ScriptCompiler::mListener

private

Definition at line 296 of file OgreScriptCompiler.h.

The documentation for this class was generated from the following file:

- OgreScriptCompiler.h

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.