OGRE: Ogre::ScriptCompiler Class Reference - OGRE Documentation

# Ogre::ScriptCompiler Class Reference

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

`#include <OgreScriptCompiler.h>`

Inheritance diagram for Ogre::ScriptCompiler:

[legend]

List of all members.

## Public Types
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 }
enum | { ID_ON = 1, ID_OFF = 2, ID_TRUE = 1, ID_FALSE = 2, ID_YES = 1, ID_NO = 2 }
typedef std::map< String, uint32 > | IdMap
typedef SharedPtr< Error > | ErrorPtr
typedef std::list< ErrorPtr > | ErrorList
## Public Member Functions
| ScriptCompiler ()
virtual | ~ScriptCompiler ()
bool | compile (const String &str, const String &source, const String &group)
| Takes in a string of script code and compiles it into resources.
bool | compile (const ConcreteNodeListPtr &nodes, const String &group)
| Compiles resources from the given concrete node list.
bool | _compile (AbstractNodeListPtr nodes, const String &group)
| Compiles the given abstract syntax tree.
void | addError (uint32 code, const String &file, int line, const String &msg="")
| Adds the given error to the compiler's list of errors.
void | setListener (ScriptCompilerListener *listener)
| Sets the listener used by the compiler.
ScriptCompilerListener * | getListener ()
| Returns the currently set listener.
const String & | getResourceGroup () const
| Returns the resource group currently set for this compiler.
void | addNameExclusion (const String &type)
| Adds a name exclusion to the map.
void | removeNameExclusion (const String &type)
| Removes a name exclusion.
bool | _fireEvent (const String &name, const std::vector< Any > &args, Any *retval)
| Internal method for firing the handleEvent method.
Any | _fireCreateObject (const String &type, const std::vector< Any > &args)
| Internal method for firing the createObject event.
void * | operator new (size_t sz, const char *file, int line, const char *func)
| operator new, with debug line info
void * | operator new (size_t sz)
void * | operator new (size_t sz, void *ptr)
| placement operator new
void * | operator new[] (size_t sz, const char *file, int line, const char *func)
| array operator new, with debug line info
void * | operator new[] (size_t sz)
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 *)
## Static Public Member Functions
static String | formatErrorCode (uint32 code)
## Private Types
typedef std::map< String, String > | Environment
typedef std::map< String, AbstractNodeListPtr > | ImportCacheMap
typedef std::multimap< String, String > | ImportRequestMap
## Private Member Functions
AbstractNodeListPtr | convertToAST (const ConcreteNodeListPtr &nodes)
void | processImports (AbstractNodeListPtr &nodes)
| This built-in function processes import nodes.
AbstractNodeListPtr | loadImportPath (const String &name)
| Loads the requested script and converts it to an AST.
AbstractNodeListPtr | locateTarget (AbstractNodeList *nodes, const String &target)
| Returns the abstract nodes from the given tree which represent the target.
void | processObjects (AbstractNodeList *nodes, const AbstractNodeListPtr &top)
| Handles object inheritance and variable expansion.
void | processVariables (AbstractNodeList *nodes)
| Handles processing the variables.
void | overlayObject (const AbstractNodePtr &source, ObjectAbstractNode *dest)
| This function overlays the given object on the destination object following inheritance rules.
bool | isNameExcluded (const String &cls, AbstractNode *parent)
| Returns true if the given class is name excluded.
void | initWordMap ()
| This function sets up the initial values in word id map.
## Private Attributes
String | mGroup
IdMap | mIds
Environment | mEnv
ImportCacheMap | mImports
ImportRequestMap | mImportRequests
AbstractNodeList | mImportTable
ErrorList | mErrors
ScriptCompilerListener * | mListener
## Friends
class | AbstractTreeBuilder
## Classes
class | AbstractTreeBuilder
struct | Error

## 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 180 of file OgreScriptCompiler.h.

## Member Typedef Documentation

typedef std::map<String,uint32> Ogre::ScriptCompiler::IdMap

Definition at line 183 of file OgreScriptCompiler.h.

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

Definition at line 192 of file OgreScriptCompiler.h.

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

Definition at line 193 of file OgreScriptCompiler.h.

typedef std::map<String,String> Ogre::ScriptCompiler::Environment`[private]`

Definition at line 272 of file OgreScriptCompiler.h.

typedef std::map<String,AbstractNodeListPtr> Ogre::ScriptCompiler::ImportCacheMap`[private]`

Definition at line 275 of file OgreScriptCompiler.h.

typedef std::multimap<String,String> Ogre::ScriptCompiler::ImportRequestMap`[private]`

Definition at line 277 of file OgreScriptCompiler.h.

## Member Enumeration Documentation

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 196 of file OgreScriptCompiler.h.

anonymous enum

Enumerator:

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

Definition at line 304 of file OgreScriptCompiler.h.

## Constructor & Destructor Documentation

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

virtual Ogre::ScriptCompiler::~ScriptCompiler | ( |  | ) | `[virtual]`

Definition at line 214 of file OgreScriptCompiler.h.

## Member Function Documentation

static String Ogre::ScriptCompiler::formatErrorCode | ( | uint32 | code | ) | `[static]`

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

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

Compiles resources from the given concrete node list.

bool Ogre::ScriptCompiler::_compile | ( | AbstractNodeListPtr | nodes,
|  | const String & | group |
| ) |  |  |

Compiles the given abstract syntax tree.

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.

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

Sets the listener used by the compiler.

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

Returns the currently set listener.

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

Returns the resource group currently set for this compiler.

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.

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

Removes a name exclusion.

bool Ogre::ScriptCompiler::_fireEvent | ( | const String & | name,
|  | const std::vector< Any > & | args,
|  | Any * | retval |
| ) |  |  |

Internal method for firing the handleEvent method.

Any Ogre::ScriptCompiler::_fireCreateObject | ( | const String & | type,
|  | const std::vector< Any > & | args |
| ) |  |  |

Internal method for firing the createObject event.

AbstractNodeListPtr Ogre::ScriptCompiler::convertToAST | ( | const ConcreteNodeListPtr & | nodes | ) | `[private]`

void Ogre::ScriptCompiler::processImports | ( | AbstractNodeListPtr & | nodes | ) | `[private]`

This built-in function processes import nodes.

AbstractNodeListPtr Ogre::ScriptCompiler::loadImportPath | ( | const String & | name | ) | `[private]`

Loads the requested script and converts it to an AST.

Reimplemented in Ogre::CompositorScriptCompiler2, and Ogre::ParticleScriptCompiler.

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

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

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

Handles object inheritance and variable expansion.

void Ogre::ScriptCompiler::processVariables | ( | AbstractNodeList * | nodes | ) | `[private]`

Handles processing the variables.

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

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

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

Returns true if the given class is name excluded.

void Ogre::ScriptCompiler::initWordMap | ( |  | ) | `[private]`

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

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 62 of file OgreMemoryAllocatedObject.h.

template<class Alloc>

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

Definition at line 67 of file OgreMemoryAllocatedObject.h.

template<class Alloc>

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

placement operator new

Definition at line 73 of file OgreMemoryAllocatedObject.h.

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 79 of file OgreMemoryAllocatedObject.h.

template<class Alloc>

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

Definition at line 84 of file OgreMemoryAllocatedObject.h.

template<class Alloc>

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

Definition at line 89 of file OgreMemoryAllocatedObject.h.

template<class Alloc>

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

Definition at line 95 of file OgreMemoryAllocatedObject.h.

template<class Alloc>

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

Definition at line 101 of file OgreMemoryAllocatedObject.h.

template<class Alloc>

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

Definition at line 106 of file OgreMemoryAllocatedObject.h.

template<class Alloc>

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

Definition at line 112 of file OgreMemoryAllocatedObject.h.

## Friends And Related Function Documentation

friend class AbstractTreeBuilder`[friend]`

Definition at line 301 of file OgreScriptCompiler.h.

## Member Data Documentation

String Ogre::ScriptCompiler::mGroup`[private]`

Definition at line 268 of file OgreScriptCompiler.h.

IdMap Ogre::ScriptCompiler::mIds`[private]`

Definition at line 270 of file OgreScriptCompiler.h.

Environment Ogre::ScriptCompiler::mEnv`[private]`

Definition at line 273 of file OgreScriptCompiler.h.

ImportCacheMap Ogre::ScriptCompiler::mImports`[private]`

Definition at line 276 of file OgreScriptCompiler.h.

ImportRequestMap Ogre::ScriptCompiler::mImportRequests`[private]`

Definition at line 278 of file OgreScriptCompiler.h.

AbstractNodeList Ogre::ScriptCompiler::mImportTable`[private]`

Definition at line 281 of file OgreScriptCompiler.h.

ErrorList Ogre::ScriptCompiler::mErrors`[private]`

Definition at line 284 of file OgreScriptCompiler.h.

ScriptCompilerListener* Ogre::ScriptCompiler::mListener`[private]`

Reimplemented in Ogre::CompositorScriptCompiler2, and Ogre::ParticleScriptCompiler.

Definition at line 287 of file OgreScriptCompiler.h.

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

- OgreScriptCompiler.h

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 26 11:36:38 2009