OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::CPreprocessor Class Reference

This is a simplistic C/C++-like preprocessor. More...

#include <OgreGLSLPreprocessor.h>

+ Collaboration diagram for Ogre::CPreprocessor:

Classes

class  Macro
 A macro definition. More...
 
class  Token
 A input token. More...
 

Public Types

typedef void(* ErrorHandlerFunc )(void *iData, int iLine, const char *iError, const char *iToken, size_t iTokenLen)
 An error handler function type. More...
 
typedef void(* ErrorHandlerFunc )(void *iData, int iLine, const char *iError, const char *iToken, size_t iTokenLen)
 An error handler function type. More...
 
typedef void(* ErrorHandlerFunc )(void *iData, int iLine, const char *iError, const char *iToken, size_t iTokenLen)
 An error handler function type. More...
 

Public Member Functions

 CPreprocessor ()
 Create an empty preprocessor object. More...
 
 CPreprocessor ()
 Create an empty preprocessor object. More...
 
 CPreprocessor ()
 Create an empty preprocessor object. More...
 
virtual ~CPreprocessor ()
 Destroy the preprocessor object. More...
 
virtual ~CPreprocessor ()
 Destroy the preprocessor object. More...
 
virtual ~CPreprocessor ()
 Destroy the preprocessor object. More...
 
void Define (const char *iMacroName, size_t iMacroNameLen, const char *iMacroValue, size_t iMacroValueLen)
 Define a macro without parameters. More...
 
void Define (const char *iMacroName, size_t iMacroNameLen, const char *iMacroValue, size_t iMacroValueLen)
 Define a macro without parameters. More...
 
void Define (const char *iMacroName, size_t iMacroNameLen, const char *iMacroValue, size_t iMacroValueLen)
 Define a macro without parameters. More...
 
void Define (const char *iMacroName, size_t iMacroNameLen, long iMacroValue)
 Define a numerical macro. More...
 
void Define (const char *iMacroName, size_t iMacroNameLen, long iMacroValue)
 Define a numerical macro. More...
 
void Define (const char *iMacroName, size_t iMacroNameLen, long iMacroValue)
 Define a numerical macro. More...
 
char * Parse (const char *iSource, size_t iLength, size_t &oLength)
 Parse the input string and return a newly-allocated output string. More...
 
char * Parse (const char *iSource, size_t iLength, size_t &oLength)
 Parse the input string and return a newly-allocated output string. More...
 
char * Parse (const char *iSource, size_t iLength, size_t &oLength)
 Parse the input string and return a newly-allocated output string. More...
 
bool Undef (const char *iMacroName, size_t iMacroNameLen)
 Undefine a macro. More...
 
bool Undef (const char *iMacroName, size_t iMacroNameLen)
 Undefine a macro. More...
 
bool Undef (const char *iMacroName, size_t iMacroNameLen)
 Undefine a macro. More...
 

Public Attributes

void * ErrorData
 User-specific storage, passed to Error() More...
 

Static Public Attributes

static ErrorHandlerFunc ErrorHandler
 A pointer to the preprocessor's error handler. More...
 

Private Member Functions

 CPreprocessor (const Token &iToken, int iLine)
 Private constructor to re-parse a single token. More...
 
 CPreprocessor (const Token &iToken, int iLine)
 Private constructor to re-parse a single token. More...
 
 CPreprocessor (const Token &iToken, int iLine)
 Private constructor to re-parse a single token. More...
 
void Error (int iLine, const char *iError, const Token *iToken=NULL)
 Call the error handler. More...
 
void Error (int iLine, const char *iError, const Token *iToken=NULL)
 Call the error handler. More...
 
void Error (int iLine, const char *iError, const Token *iToken=NULL)
 Call the error handler. More...
 
Token ExpandMacro (const Token &iToken)
 Expand the given macro, if it exists. More...
 
Token ExpandMacro (const Token &iToken)
 Expand the given macro, if it exists. More...
 
Token ExpandMacro (const Token &iToken)
 Expand the given macro, if it exists. More...
 
Token GetArgument (Token &oArg, bool iExpand)
 Get a single function argument until next ',' or ')'. More...
 
Token GetArgument (Token &oArg, bool iExpand)
 Get a single function argument until next ',' or ')'. More...
 
Token GetArgument (Token &oArg, bool iExpand)
 Get a single function argument until next ',' or ')'. More...
 
Token GetArguments (int &oNumArgs, Token *&oArgs, bool iExpand)
 Get all the arguments of a macro: '(' arg1 { ',' arg2 { ',' ... More...
 
Token GetArguments (int &oNumArgs, Token *&oArgs, bool iExpand)
 Get all the arguments of a macro: '(' arg1 { ',' arg2 { ',' ... More...
 
Token GetArguments (int &oNumArgs, Token *&oArgs, bool iExpand)
 Get all the arguments of a macro: '(' arg1 { ',' arg2 { ',' ... More...
 
Token GetExpression (Token &oResult, int iLine, int iOpPriority=0)
 Parse an expression, compute it and return the result. More...
 
Token GetExpression (Token &oResult, int iLine, int iOpPriority=0)
 Parse an expression, compute it and return the result. More...
 
Token GetExpression (Token &oResult, int iLine, int iOpPriority=0)
 Parse an expression, compute it and return the result. More...
 
Token GetToken (bool iExpand)
 Stateless tokenizer: Parse the input text and return the next token. More...
 
Token GetToken (bool iExpand)
 Stateless tokenizer: Parse the input text and return the next token. More...
 
Token GetToken (bool iExpand)
 Stateless tokenizer: Parse the input text and return the next token. More...
 
bool GetValue (const Token &iToken, long &oValue, int iLine)
 Get the numeric value of a token. More...
 
bool GetValue (const Token &iToken, long &oValue, int iLine)
 Get the numeric value of a token. More...
 
bool GetValue (const Token &iToken, long &oValue, int iLine)
 Get the numeric value of a token. More...
 
bool HandleDefine (Token &iBody, int iLine)
 Handle a #define directive. More...
 
bool HandleDefine (Token &iBody, int iLine)
 Handle a #define directive. More...
 
bool HandleDefine (Token &iBody, int iLine)
 Handle a #define directive. More...
 
Token HandleDirective (Token &iToken, int iLine)
 Handle a preprocessor directive. More...
 
Token HandleDirective (Token &iToken, int iLine)
 Handle a preprocessor directive. More...
 
Token HandleDirective (Token &iToken, int iLine)
 Handle a preprocessor directive. More...
 
bool HandleElse (Token &iBody, int iLine)
 Handle an #else directive. More...
 
bool HandleElse (Token &iBody, int iLine)
 Handle an #else directive. More...
 
bool HandleElse (Token &iBody, int iLine)
 Handle an #else directive. More...
 
bool HandleEndIf (Token &iBody, int iLine)
 Handle an #endif directive. More...
 
bool HandleEndIf (Token &iBody, int iLine)
 Handle an #endif directive. More...
 
bool HandleEndIf (Token &iBody, int iLine)
 Handle an #endif directive. More...
 
bool HandleIf (Token &iBody, int iLine)
 Handle an #if directive. More...
 
bool HandleIf (Token &iBody, int iLine)
 Handle an #if directive. More...
 
bool HandleIf (Token &iBody, int iLine)
 Handle an #if directive. More...
 
bool HandleIfDef (Token &iBody, int iLine)
 Handle an #ifdef directive. More...
 
bool HandleIfDef (Token &iBody, int iLine)
 Handle an #ifdef directive. More...
 
bool HandleIfDef (Token &iBody, int iLine)
 Handle an #ifdef directive. More...
 
bool HandleUnDef (Token &iBody, int iLine)
 Undefine a previously defined macro. More...
 
bool HandleUnDef (Token &iBody, int iLine)
 Undefine a previously defined macro. More...
 
bool HandleUnDef (Token &iBody, int iLine)
 Undefine a previously defined macro. More...
 
MacroIsDefined (const Token &iToken)
 Check if a macro is defined, and if so, return it. More...
 
MacroIsDefined (const Token &iToken)
 Check if a macro is defined, and if so, return it. More...
 
MacroIsDefined (const Token &iToken)
 Check if a macro is defined, and if so, return it. More...
 
Token Parse (const Token &iSource)
 Parse the input string and return a token containing the whole output. More...
 
Token Parse (const Token &iSource)
 Parse the input string and return a token containing the whole output. More...
 
Token Parse (const Token &iSource)
 Parse the input string and return a token containing the whole output. More...
 

Static Private Member Functions

static Token ExpandDefined (CPreprocessor *iParent, int iNumArgs, Token *iArgs)
 The implementation of the defined() preprocessor function. More...
 
static Token ExpandDefined (CPreprocessor *iParent, int iNumArgs, Token *iArgs)
 The implementation of the defined() preprocessor function. More...
 
static Token ExpandDefined (CPreprocessor *iParent, int iNumArgs, Token *iArgs)
 The implementation of the defined() preprocessor function. More...
 

Private Attributes

bool BOL
 True if we are at beginning of line. More...
 
unsigned EnableOutput
 A stack of 32 booleans packed into one value :) More...
 
int Line
 Current line number. More...
 
MacroMacroList
 The list of macros defined so far. More...
 
const char * Source
 The current source text input. More...
 
const char * SourceEnd
 The end of the source text. More...
 

Friends

class CPreprocessor::Macro
 

Detailed Description

This is a simplistic C/C++-like preprocessor.

It takes an non-zero-terminated string on input and outputs a non-zero-terminated string buffer.

This preprocessor was designed specifically for GLSL shaders, so if you want to use it for other purposes you might want to check if the feature set it provides is enough for you.

Here's a list of supported features:

  • Fast memory allocation-less operation (mostly).
  • Line continuation (backslash-newline) is swallowed.
  • Line numeration is fully preserved by inserting empty lines where required. This is crucial if, say, GLSL compiler reports you an error with a line number.
  • #define: Parametrized and non-parametrized macros. Invoking a macro with less arguments than it takes assignes empty values to missing arguments.
  • #undef: Forget defined macros
  • #ifdef/#ifndef/#else/#endif: Conditional suppression of parts of code.
  • #if: Supports numeric expression of any complexity, also supports the defined() pseudo-function.

    takes an non-zero-terminated string on input and outputs a non-zero-terminated string buffer.

    This preprocessor was designed specifically for GLSL ES shaders, so if you want to use it for other purposes you might want to check if the feature set it provides is enough for you.

    Here's a list of supported features:

    • Fast memory allocation-less operation (mostly).
    • Line continuation (backslash-newline) is swallowed.
    • Line numeration is fully preserved by inserting empty lines where required. This is crucial if, say, GLSL ES compiler reports you an error with a line number.
    • #define: Parametrized and non-parametrized macros. Invoking a macro with less arguments than it takes assignes empty values to missing arguments.
    • #undef: Forget defined macros
    • #ifdef/#ifndef/#else/#endif: Conditional suppression of parts of code.
    • #if: Supports numeric expression of any complexity, also supports the defined() pseudo-function.

Definition at line 61 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

Member Typedef Documentation

typedef void(* Ogre::CPreprocessor::ErrorHandlerFunc)(void *iData, int iLine, const char *iError, const char *iToken, size_t iTokenLen)

An error handler function type.

The default implementation just drops a note to stderr and then the parser ends, returning NULL.

Parameters
iDataUser-specific pointer from the corresponding CPreprocessor object.
iLineThe line at which the error happened.
iErrorThe error string.
iTokenIf not NULL contains the erroneous token
iTokenLenThe length of iToken. iToken is never zero-terminated!

Definition at line 507 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

typedef void(* Ogre::CPreprocessor::ErrorHandlerFunc)(void *iData, int iLine, const char *iError, const char *iToken, size_t iTokenLen)

An error handler function type.

The default implementation just drops a note to stderr and then the parser ends, returning NULL.

Parameters
iDataUser-specific pointer from the corresponding CPreprocessor object.
iLineThe line at which the error happened.
iErrorThe error string.
iTokenIf not NULL contains the erroneous token
iTokenLenThe length of iToken. iToken is never zero-terminated!

Definition at line 507 of file Plus/src/GLSL/include/OgreGLSLPreprocessor.h.

typedef void(* Ogre::CPreprocessor::ErrorHandlerFunc)(void *iData, int iLine, const char *iError, const char *iToken, size_t iTokenLen)

An error handler function type.

The default implementation just drops a note to stderr and then the parser ends, returning NULL.

Parameters
iDataUser-specific pointer from the corresponding CPreprocessor object.
iLineThe line at which the error happened.
iErrorThe error string.
iTokenIf not NULL contains the erroneous token
iTokenLenThe length of iToken. iToken is never zero-terminated!

Definition at line 508 of file OgreGLSLESPreprocessor.h.

Constructor & Destructor Documentation

Ogre::CPreprocessor::CPreprocessor ( const Token iToken,
int  iLine 
)
private

Private constructor to re-parse a single token.

Ogre::CPreprocessor::CPreprocessor ( )
inline

Create an empty preprocessor object.

Definition at line 426 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

virtual Ogre::CPreprocessor::~CPreprocessor ( )
virtual

Destroy the preprocessor object.

Ogre::CPreprocessor::CPreprocessor ( const Token iToken,
int  iLine 
)
private

Private constructor to re-parse a single token.

Ogre::CPreprocessor::CPreprocessor ( )
inline

Create an empty preprocessor object.

Definition at line 426 of file Plus/src/GLSL/include/OgreGLSLPreprocessor.h.

virtual Ogre::CPreprocessor::~CPreprocessor ( )
virtual

Destroy the preprocessor object.

Ogre::CPreprocessor::CPreprocessor ( const Token iToken,
int  iLine 
)
private

Private constructor to re-parse a single token.

Ogre::CPreprocessor::CPreprocessor ( )
inline

Create an empty preprocessor object.

Definition at line 427 of file OgreGLSLESPreprocessor.h.

virtual Ogre::CPreprocessor::~CPreprocessor ( )
virtual

Destroy the preprocessor object.

Member Function Documentation

void Ogre::CPreprocessor::Define ( const char *  iMacroName,
size_t  iMacroNameLen,
const char *  iMacroValue,
size_t  iMacroValueLen 
)

Define a macro without parameters.

Parameters
iMacroNameThe name of the defined macro
iMacroNameLenThe length of the name of the defined macro
iMacroValueThe value of the defined macro
iMacroValueLenThe length of the value of the defined macro
void Ogre::CPreprocessor::Define ( const char *  iMacroName,
size_t  iMacroNameLen,
const char *  iMacroValue,
size_t  iMacroValueLen 
)

Define a macro without parameters.

Parameters
iMacroNameThe name of the defined macro
iMacroNameLenThe length of the name of the defined macro
iMacroValueThe value of the defined macro
iMacroValueLenThe length of the value of the defined macro
void Ogre::CPreprocessor::Define ( const char *  iMacroName,
size_t  iMacroNameLen,
const char *  iMacroValue,
size_t  iMacroValueLen 
)

Define a macro without parameters.

Parameters
iMacroNameThe name of the defined macro
iMacroNameLenThe length of the name of the defined macro
iMacroValueThe value of the defined macro
iMacroValueLenThe length of the value of the defined macro
void Ogre::CPreprocessor::Define ( const char *  iMacroName,
size_t  iMacroNameLen,
long  iMacroValue 
)

Define a numerical macro.

Parameters
iMacroNameThe name of the defined macro
iMacroNameLenThe length of the name of the defined macro
iMacroValueThe value of the defined macro
void Ogre::CPreprocessor::Define ( const char *  iMacroName,
size_t  iMacroNameLen,
long  iMacroValue 
)

Define a numerical macro.

Parameters
iMacroNameThe name of the defined macro
iMacroNameLenThe length of the name of the defined macro
iMacroValueThe value of the defined macro
void Ogre::CPreprocessor::Define ( const char *  iMacroName,
size_t  iMacroNameLen,
long  iMacroValue 
)

Define a numerical macro.

Parameters
iMacroNameThe name of the defined macro
iMacroNameLenThe length of the name of the defined macro
iMacroValueThe value of the defined macro
void Ogre::CPreprocessor::Error ( int  iLine,
const char *  iError,
const Token iToken = NULL 
)
private

Call the error handler.

Parameters
iLineThe line at which the error happened.
iErrorThe error string.
iTokenIf not NULL contains the erroneous token
void Ogre::CPreprocessor::Error ( int  iLine,
const char *  iError,
const Token iToken = NULL 
)
private

Call the error handler.

Parameters
iLineThe line at which the error happened.
iErrorThe error string.
iTokenIf not NULL contains the erroneous token
void Ogre::CPreprocessor::Error ( int  iLine,
const char *  iError,
const Token iToken = NULL 
)
private

Call the error handler.

Parameters
iLineThe line at which the error happened.
iErrorThe error string.
iTokenIf not NULL contains the erroneous token
static Token Ogre::CPreprocessor::ExpandDefined ( CPreprocessor iParent,
int  iNumArgs,
Token iArgs 
)
staticprivate

The implementation of the defined() preprocessor function.

Parameters
iParentThe parent preprocessor object
iNumArgsNumber of arguments
iArgsThe arguments themselves
Returns
The return value encapsulated in a token
static Token Ogre::CPreprocessor::ExpandDefined ( CPreprocessor iParent,
int  iNumArgs,
Token iArgs 
)
staticprivate

The implementation of the defined() preprocessor function.

Parameters
iParentThe parent preprocessor object
iNumArgsNumber of arguments
iArgsThe arguments themselves
Returns
The return value encapsulated in a token
static Token Ogre::CPreprocessor::ExpandDefined ( CPreprocessor iParent,
int  iNumArgs,
Token iArgs 
)
staticprivate

The implementation of the defined() preprocessor function.

Parameters
iParentThe parent preprocessor object
iNumArgsNumber of arguments
iArgsThe arguments themselves
Returns
The return value encapsulated in a token
Token Ogre::CPreprocessor::ExpandMacro ( const Token iToken)
private

Expand the given macro, if it exists.

If macro has arguments, they are collected from source stream.

Parameters
iTokenA KEYWORD token containing the (possible) macro name.
Returns
The expanded token or iToken if it is not a macro
Token Ogre::CPreprocessor::ExpandMacro ( const Token iToken)
private

Expand the given macro, if it exists.

If macro has arguments, they are collected from source stream.

Parameters
iTokenA KEYWORD token containing the (possible) macro name.
Returns
The expanded token or iToken if it is not a macro
Token Ogre::CPreprocessor::ExpandMacro ( const Token iToken)
private

Expand the given macro, if it exists.

If macro has arguments, they are collected from source stream.

Parameters
iTokenA KEYWORD token containing the (possible) macro name.
Returns
The expanded token or iToken if it is not a macro
Token Ogre::CPreprocessor::GetArgument ( Token oArg,
bool  iExpand 
)
private

Get a single function argument until next ',' or ')'.

Parameters
oArgThe argument is returned in this variable.
iExpandIf false, parameters are not expanded and no expressions are allowed; only a single keyword is expected per argument.
Returns
The first unhandled token after argument.
Token Ogre::CPreprocessor::GetArgument ( Token oArg,
bool  iExpand 
)
private

Get a single function argument until next ',' or ')'.

Parameters
oArgThe argument is returned in this variable.
iExpandIf false, parameters are not expanded and no expressions are allowed; only a single keyword is expected per argument.
Returns
The first unhandled token after argument.
Token Ogre::CPreprocessor::GetArgument ( Token oArg,
bool  iExpand 
)
private

Get a single function argument until next ',' or ')'.

Parameters
oArgThe argument is returned in this variable.
iExpandIf false, parameters are not expanded and no expressions are allowed; only a single keyword is expected per argument.
Returns
The first unhandled token after argument.
Token Ogre::CPreprocessor::GetArguments ( int &  oNumArgs,
Token *&  oArgs,
bool  iExpand 
)
private

Get all the arguments of a macro: '(' arg1 { ',' arg2 { ',' ...

}} ')'

Parameters
oNumArgsNumber of parsed arguments is stored into this variable.
oArgsThis is set to a pointer to an array of parsed arguments.
iExpandIf false, parameters are not expanded and no expressions are allowed; only a single keyword is expected per argument.
Token Ogre::CPreprocessor::GetArguments ( int &  oNumArgs,
Token *&  oArgs,
bool  iExpand 
)
private

Get all the arguments of a macro: '(' arg1 { ',' arg2 { ',' ...

}} ')'

Parameters
oNumArgsNumber of parsed arguments is stored into this variable.
oArgsThis is set to a pointer to an array of parsed arguments.
iExpandIf false, parameters are not expanded and no expressions are allowed; only a single keyword is expected per argument.
Token Ogre::CPreprocessor::GetArguments ( int &  oNumArgs,
Token *&  oArgs,
bool  iExpand 
)
private

Get all the arguments of a macro: '(' arg1 { ',' arg2 { ',' ...

}} ')'

Parameters
oNumArgsNumber of parsed arguments is stored into this variable.
oArgsThis is set to a pointer to an array of parsed arguments.
iExpandIf false, parameters are not expanded and no expressions are allowed; only a single keyword is expected per argument.
Token Ogre::CPreprocessor::GetExpression ( Token oResult,
int  iLine,
int  iOpPriority = 0 
)
private

Parse an expression, compute it and return the result.

Parameters
oResultA token containing the result of expression
iLineThe line at which the expression starts (for error reports)
iOpPriorityOperator priority (at which operator we will stop if proceeding recursively – used internally. Parser stops when it encounters an operator with higher or equal priority).
Returns
The last unhandled token after the expression
Token Ogre::CPreprocessor::GetExpression ( Token oResult,
int  iLine,
int  iOpPriority = 0 
)
private

Parse an expression, compute it and return the result.

Parameters
oResultA token containing the result of expression
iLineThe line at which the expression starts (for error reports)
iOpPriorityOperator priority (at which operator we will stop if proceeding recursively – used internally. Parser stops when it encounters an operator with higher or equal priority).
Returns
The last unhandled token after the expression
Token Ogre::CPreprocessor::GetExpression ( Token oResult,
int  iLine,
int  iOpPriority = 0 
)
private

Parse an expression, compute it and return the result.

Parameters
oResultA token containing the result of expression
iLineThe line at which the expression starts (for error reports)
iOpPriorityOperator priority (at which operator we will stop if proceeding recursively – used internally. Parser stops when it encounters an operator with higher or equal priority).
Returns
The last unhandled token after the expression
Token Ogre::CPreprocessor::GetToken ( bool  iExpand)
private

Stateless tokenizer: Parse the input text and return the next token.

Parameters
iExpandIf true, macros will be expanded to their values
Returns
The next token from the input stream
Token Ogre::CPreprocessor::GetToken ( bool  iExpand)
private

Stateless tokenizer: Parse the input text and return the next token.

Parameters
iExpandIf true, macros will be expanded to their values
Returns
The next token from the input stream
Token Ogre::CPreprocessor::GetToken ( bool  iExpand)
private

Stateless tokenizer: Parse the input text and return the next token.

Parameters
iExpandIf true, macros will be expanded to their values
Returns
The next token from the input stream
bool Ogre::CPreprocessor::GetValue ( const Token iToken,
long &  oValue,
int  iLine 
)
private

Get the numeric value of a token.

If the token was produced by expanding a macro, we will get an TEXT token which can contain a whole expression; in this case we will call GetExpression to parse it. Otherwise we just call the token's GetValue() method.

Parameters
iTokenThe token to get the numeric value of
oValueThe variable to put the value into
iLineThe line where the directive begins (for error reports)
Returns
true if ok, false if not
bool Ogre::CPreprocessor::GetValue ( const Token iToken,
long &  oValue,
int  iLine 
)
private

Get the numeric value of a token.

If the token was produced by expanding a macro, we will get an TEXT token which can contain a whole expression; in this case we will call GetExpression to parse it. Otherwise we just call the token's GetValue() method.

Parameters
iTokenThe token to get the numeric value of
oValueThe variable to put the value into
iLineThe line where the directive begins (for error reports)
Returns
true if ok, false if not
bool Ogre::CPreprocessor::GetValue ( const Token iToken,
long &  oValue,
int  iLine 
)
private

Get the numeric value of a token.

If the token was produced by expanding a macro, we will get an TEXT token which can contain a whole expression; in this case we will call GetExpression to parse it. Otherwise we just call the token's GetValue() method.

Parameters
iTokenThe token to get the numeric value of
oValueThe variable to put the value into
iLineThe line where the directive begins (for error reports)
Returns
true if ok, false if not
bool Ogre::CPreprocessor::HandleDefine ( Token iBody,
int  iLine 
)
private

Handle a #define directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleDefine ( Token iBody,
int  iLine 
)
private

Handle a #define directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleDefine ( Token iBody,
int  iLine 
)
private

Handle a #define directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
Token Ogre::CPreprocessor::HandleDirective ( Token iToken,
int  iLine 
)
private

Handle a preprocessor directive.

Parameters
iTokenThe whole preprocessor directive line (until EOL)
iLineThe line where the directive begins (for error reports)
Returns
The last input token that was not proceeded.
Token Ogre::CPreprocessor::HandleDirective ( Token iToken,
int  iLine 
)
private

Handle a preprocessor directive.

Parameters
iTokenThe whole preprocessor directive line (until EOL)
iLineThe line where the directive begins (for error reports)
Returns
The last input token that was not proceeded.
Token Ogre::CPreprocessor::HandleDirective ( Token iToken,
int  iLine 
)
private

Handle a preprocessor directive.

Parameters
iTokenThe whole preprocessor directive line (until EOL)
iLineThe line where the directive begins (for error reports)
Returns
The last input token that was not proceeded.
bool Ogre::CPreprocessor::HandleElse ( Token iBody,
int  iLine 
)
private

Handle an #else directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleElse ( Token iBody,
int  iLine 
)
private

Handle an #else directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleElse ( Token iBody,
int  iLine 
)
private

Handle an #else directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleEndIf ( Token iBody,
int  iLine 
)
private

Handle an #endif directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleEndIf ( Token iBody,
int  iLine 
)
private

Handle an #endif directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleEndIf ( Token iBody,
int  iLine 
)
private

Handle an #endif directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleIf ( Token iBody,
int  iLine 
)
private

Handle an #if directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleIf ( Token iBody,
int  iLine 
)
private

Handle an #if directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleIf ( Token iBody,
int  iLine 
)
private

Handle an #if directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleIfDef ( Token iBody,
int  iLine 
)
private

Handle an #ifdef directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleIfDef ( Token iBody,
int  iLine 
)
private

Handle an #ifdef directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleIfDef ( Token iBody,
int  iLine 
)
private

Handle an #ifdef directive.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleUnDef ( Token iBody,
int  iLine 
)
private

Undefine a previously defined macro.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleUnDef ( Token iBody,
int  iLine 
)
private

Undefine a previously defined macro.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
bool Ogre::CPreprocessor::HandleUnDef ( Token iBody,
int  iLine 
)
private

Undefine a previously defined macro.

Parameters
iBodyThe body of the directive (everything after the directive until end of line).
iLineThe line where the directive begins (for error reports)
Returns
true if everything went ok, false if not
Macro* Ogre::CPreprocessor::IsDefined ( const Token iToken)
private

Check if a macro is defined, and if so, return it.

Parameters
iTokenMacro name
Returns
The macro object or NULL if a macro with this name does not exist
Macro* Ogre::CPreprocessor::IsDefined ( const Token iToken)
private

Check if a macro is defined, and if so, return it.

Parameters
iTokenMacro name
Returns
The macro object or NULL if a macro with this name does not exist
Macro* Ogre::CPreprocessor::IsDefined ( const Token iToken)
private

Check if a macro is defined, and if so, return it.

Parameters
iTokenMacro name
Returns
The macro object or NULL if a macro with this name does not exist
Token Ogre::CPreprocessor::Parse ( const Token iSource)
private

Parse the input string and return a token containing the whole output.

Parameters
iSourceThe source text enclosed in a token
Returns
The output text enclosed in a token
Token Ogre::CPreprocessor::Parse ( const Token iSource)
private

Parse the input string and return a token containing the whole output.

Parameters
iSourceThe source text enclosed in a token
Returns
The output text enclosed in a token
Token Ogre::CPreprocessor::Parse ( const Token iSource)
private

Parse the input string and return a token containing the whole output.

Parameters
iSourceThe source text enclosed in a token
Returns
The output text enclosed in a token
char* Ogre::CPreprocessor::Parse ( const char *  iSource,
size_t  iLength,
size_t &  oLength 
)

Parse the input string and return a newly-allocated output string.

Note
The returned preprocessed string is NOT zero-terminated (just like the input string).
Parameters
iSourceThe source text
iLengthThe length of the source text in characters
oLengthThe length of the output string.
Returns
The output from preprocessor, allocated with malloc(). The parser can actually allocate more than needed for performance reasons, but this should not be a problem unless you will want to store the returned pointer for long time in which case you might want to realloc() it. If an error has been encountered, the function returns NULL. In some cases the function may return an unallocated address that's inside the source buffer. You must free() the result string only if the returned address is not inside the source text.
char* Ogre::CPreprocessor::Parse ( const char *  iSource,
size_t  iLength,
size_t &  oLength 
)

Parse the input string and return a newly-allocated output string.

Note
The returned preprocessed string is NOT zero-terminated (just like the input string).
Parameters
iSourceThe source text
iLengthThe length of the source text in characters
oLengthThe length of the output string.
Returns
The output from preprocessor, allocated with malloc(). The parser can actually allocate more than needed for performance reasons, but this should not be a problem unless you will want to store the returned pointer for long time in which case you might want to realloc() it. If an error has been encountered, the function returns NULL. In some cases the function may return an unallocated address that's inside the source buffer. You must free() the result string only if the returned address is not inside the source text.
char* Ogre::CPreprocessor::Parse ( const char *  iSource,
size_t  iLength,
size_t &  oLength 
)

Parse the input string and return a newly-allocated output string.

Note
The returned preprocessed string is NOT zero-terminated (just like the input string).
Parameters
iSourceThe source text
iLengthThe length of the source text in characters
oLengthThe length of the output string.
Returns
The output from preprocessor, allocated with malloc(). The parser can actually allocate more than needed for performance reasons, but this should not be a problem unless you will want to store the returned pointer for long time in which case you might want to realloc() it. If an error has been encountered, the function returns NULL. In some cases the function may return an unallocated address that's inside the source buffer. You must free() the result string only if the returned address is not inside the source text.
bool Ogre::CPreprocessor::Undef ( const char *  iMacroName,
size_t  iMacroNameLen 
)

Undefine a macro.

Parameters
iMacroNameThe name of the macro to undefine
iMacroNameLenThe length of the name of the macro to undefine
Returns
true if the macro has been undefined, false if macro doesn't exist
bool Ogre::CPreprocessor::Undef ( const char *  iMacroName,
size_t  iMacroNameLen 
)

Undefine a macro.

Parameters
iMacroNameThe name of the macro to undefine
iMacroNameLenThe length of the name of the macro to undefine
Returns
true if the macro has been undefined, false if macro doesn't exist
bool Ogre::CPreprocessor::Undef ( const char *  iMacroName,
size_t  iMacroNameLen 
)

Undefine a macro.

Parameters
iMacroNameThe name of the macro to undefine
iMacroNameLenThe length of the name of the macro to undefine
Returns
true if the macro has been undefined, false if macro doesn't exist

Friends And Related Function Documentation

Member Data Documentation

bool Ogre::CPreprocessor::BOL
private

True if we are at beginning of line.

Definition at line 213 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

unsigned Ogre::CPreprocessor::EnableOutput
private

A stack of 32 booleans packed into one value :)

Definition at line 215 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

void * Ogre::CPreprocessor::ErrorData

User-specific storage, passed to Error()

Definition at line 519 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

static ErrorHandlerFunc Ogre::CPreprocessor::ErrorHandler
static

A pointer to the preprocessor's error handler.

You can assign the address of your own function to this variable and implement your own error handling (e.g. throwing an exception etc).

Definition at line 516 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

int Ogre::CPreprocessor::Line
private

Current line number.

Definition at line 211 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

Macro * Ogre::CPreprocessor::MacroList
private

The list of macros defined so far.

Definition at line 217 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

const char * Ogre::CPreprocessor::Source
private

The current source text input.

Definition at line 207 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.

const char * Ogre::CPreprocessor::SourceEnd
private

The end of the source text.

Definition at line 209 of file Plus/include/GLSL/OgreGLSLPreprocessor.h.


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