HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MdlSyntax Class Reference

#include <MdlSyntax.h>

+ Inheritance diagram for MdlSyntax:

Public Member Functions

 MdlSyntax (TypeSystemPtr typeSystem)
 
const stringgetConstantQualifier () const override
 
const stringgetUniformQualifier () const override
 
const stringgetSourceFileExtension () const override
 Return the file extension used for source code files in this language. More...
 
string getArrayTypeSuffix (TypeDesc type, const Value &value) const override
 Override to return array type suffix. More...
 
string getArrayVariableSuffix (TypeDesc, const Value &) const override
 Override to indicate array variables have no array suffix. More...
 
TypeDesc getEnumeratedType (const string &value) const
 Get an type description for an enumeration based on member value. More...
 
bool remapEnumeration (const string &value, TypeDesc type, const string &enumNames, std::pair< TypeDesc, ValuePtr > &result) const override
 
void makeValidName (string &name) const override
 Modify the given name string to remove any invalid characters or tokens. More...
 
string modifyPortName (const string &word) const
 To avoid collisions with reserved names in MDL, input and output names are prefixed. More...
 
string replaceSourceCodeMarkers (const string &nodeName, const string &soureCode, std::function< string(const string &)> lambda) const
 
const stringgetMdlVersionSuffixMarker () const
 Get the MDL language versing marker: {{MDL_VERSION_SUFFIX}}. More...
 
- Public Member Functions inherited from Syntax
virtual ~Syntax ()
 
void registerTypeSyntax (TypeDesc type, TypeSyntaxPtr syntax)
 
void registerTypeSyntax (const TypeDesc *type, TypeSyntaxPtr syntax)
 
void registerReservedWords (const StringSet &names)
 
void registerInvalidTokens (const StringMap &tokens)
 
const StringSetgetReservedWords () const
 Returns a set of names that are reserved words for this language syntax. More...
 
const StringMapgetInvalidTokens () const
 Returns a mapping from disallowed tokens to replacement strings for this language syntax. More...
 
const TypeSyntaxgetTypeSyntax (TypeDesc type) const
 
const TypeSyntaxgetTypeSyntax (const TypeDesc *type) const
 
const vector< TypeSyntaxPtr > & getTypeSyntaxes () const
 Returns an array of all registered type syntax objects. More...
 
TypeDesc getType (const string &name) const
 Return a type description for the given type name. More...
 
const stringgetTypeName (TypeDesc type) const
 Returns the name syntax of the given type. More...
 
const stringgetTypeName (const TypeDesc *type) const
 
virtual string getOutputTypeName (TypeDesc type) const
 Returns the type name in an output context. More...
 
string getOutputTypeName (const TypeDesc *type) const
 
const stringgetTypeAlias (TypeDesc type) const
 
const stringgetTypeAlias (const TypeDesc *type) const
 
const stringgetTypeDefinition (TypeDesc type) const
 
const stringgetTypeDefinition (const TypeDesc *type) const
 
const stringgetDefaultValue (TypeDesc type, bool uniform=false) const
 Returns the default value string for the given type. More...
 
const stringgetDefaultValue (const TypeDesc *type, bool uniform=false) const
 
virtual string getValue (TypeDesc type, const Value &value, bool uniform=false) const
 Returns the value string for a given type and value object. More...
 
string getValue (const TypeDesc *type, const Value &value, bool uniform=false) const
 
virtual string getValue (const ShaderPort *port, bool uniform=false) const
 Returns the value string for a given shader port object. More...
 
virtual const stringgetInputQualifier () const
 
virtual const stringgetOutputQualifier () const
 
virtual const stringgetNewline () const
 Return the characters used for a newline. More...
 
virtual const stringgetIndentation () const
 Return the characters used for a single indentation level. More...
 
virtual const stringgetStringQuote () const
 Return the characters used to begin/end a string definition. More...
 
virtual const stringgetIncludeStatement () const
 Return the string pattern used for a file include statement. More...
 
virtual const stringgetSingleLineComment () const
 Return the characters used for single line comment. More...
 
virtual const stringgetBeginMultiLineComment () const
 Return the characters used to begin a multi line comments block. More...
 
virtual const stringgetEndMultiLineComment () const
 Return the characters used to end a multi line comments block. More...
 
string getArrayTypeSuffix (const TypeDesc *type, const Value &value) const
 
string getArrayVariableSuffix (const TypeDesc *type, const Value &value) const
 
virtual bool typeSupported (const TypeDesc *type) const
 
virtual void makeIdentifier (string &name, IdentifierMap &identifiers) const
 
virtual string getVariableName (const string &name, TypeDesc type, IdentifierMap &identifiers) const
 
string getVariableName (const string &name, const TypeDesc *type, IdentifierMap &identifiers) const
 
virtual StructTypeSyntaxPtr createStructSyntax (const string &structTypeName, const string &defaultValue, const string &uniformDefaultValue, const string &typeAlias, const string &typeDefinition) const
 

Static Public Member Functions

static SyntaxPtr create (TypeSystemPtr typeSystem)
 

Static Public Attributes

static const string CONST_QUALIFIER
 
static const string UNIFORM_QUALIFIER
 
static const string SOURCE_FILE_EXTENSION
 
static const StringVec VECTOR2_MEMBERS
 
static const StringVec VECTOR3_MEMBERS
 
static const StringVec VECTOR4_MEMBERS
 
static const StringVec COLOR3_MEMBERS
 
static const StringVec COLOR4_MEMBERS
 
static const StringVec ADDRESSMODE_MEMBERS
 
static const StringVec COORDINATESPACE_MEMBERS
 
static const StringVec FILTERLOOKUPMODE_MEMBERS
 
static const StringVec FILTERTYPE_MEMBERS
 
static const StringVec DISTRIBUTIONTYPE_MEMBERS
 
static const StringVec SCATTER_MODE_MEMBERS
 
static const StringVec SHEEN_MODE_MEMBERS
 
static const string PORT_NAME_PREFIX
 
- Static Public Attributes inherited from Syntax
static const string NEWLINE
 Constants with commonly used strings. More...
 
static const string SEMICOLON
 
static const string COMMA
 

Additional Inherited Members

- Public Types inherited from Syntax
enum  Punctuation { PARENTHESES, CURLY_BRACKETS, SQUARE_BRACKETS, DOUBLE_SQUARE_BRACKETS }
 Punctuation types. More...
 
- Protected Member Functions inherited from Syntax
 Syntax (TypeSystemPtr typeSystem)
 Protected constructor. More...
 
- Protected Attributes inherited from Syntax
TypeSystemPtr _typeSystem
 
vector< TypeSyntaxPtr_typeSyntaxes
 
std::unordered_map< TypeDesc,
size_t, TypeDesc::Hasher
_typeSyntaxIndexByType
 
StringSet _reservedWords
 
StringMap _invalidTokens
 
- Static Protected Attributes inherited from Syntax
static const string INDENTATION
 
static const string STRING_QUOTE
 
static const string INCLUDE_STATEMENT
 
static const string SINGLE_LINE_COMMENT
 
static const string BEGIN_MULTI_LINE_COMMENT
 
static const string END_MULTI_LINE_COMMENT
 
static const
std::unordered_map< char,
size_t > 
CHANNELS_MAPPING
 

Detailed Description

Syntax class for MDL (Material Definition Language)

Definition at line 25 of file MdlSyntax.h.

Constructor & Destructor Documentation

MdlSyntax::MdlSyntax ( TypeSystemPtr  typeSystem)

Member Function Documentation

static SyntaxPtr MdlSyntax::create ( TypeSystemPtr  typeSystem)
inlinestatic

Definition at line 30 of file MdlSyntax.h.

string MdlSyntax::getArrayTypeSuffix ( TypeDesc  type,
const Value value 
) const
overridevirtual

Override to return array type suffix.

Reimplemented from Syntax.

string MdlSyntax::getArrayVariableSuffix ( TypeDesc  ,
const Value  
) const
inlineoverridevirtual

Override to indicate array variables have no array suffix.

Reimplemented from Syntax.

Definition at line 40 of file MdlSyntax.h.

const string& MdlSyntax::getConstantQualifier ( ) const
inlineoverridevirtual

Get the qualifier used when declaring constant variables. Derived classes must define this method.

Implements Syntax.

Definition at line 32 of file MdlSyntax.h.

TypeDesc MdlSyntax::getEnumeratedType ( const string value) const

Get an type description for an enumeration based on member value.

const string& MdlSyntax::getMdlVersionSuffixMarker ( ) const

Get the MDL language versing marker: {{MDL_VERSION_SUFFIX}}.

const string& MdlSyntax::getSourceFileExtension ( ) const
inlineoverridevirtual

Return the file extension used for source code files in this language.

Implements Syntax.

Definition at line 34 of file MdlSyntax.h.

const string& MdlSyntax::getUniformQualifier ( ) const
inlineoverridevirtual

Get the qualifier used when declaring uniform variables. Default implementation returns empty string and derived syntax classes should override this method.

Reimplemented from Syntax.

Definition at line 33 of file MdlSyntax.h.

void MdlSyntax::makeValidName ( string name) const
overridevirtual

Modify the given name string to remove any invalid characters or tokens.

Reimplemented from Syntax.

string MdlSyntax::modifyPortName ( const string word) const

To avoid collisions with reserved names in MDL, input and output names are prefixed.

bool MdlSyntax::remapEnumeration ( const string value,
TypeDesc  type,
const string enumNames,
std::pair< TypeDesc, ValuePtr > &  result 
) const
overridevirtual

Given an input specification attempt to remap this to an enumeration which is accepted by the shader generator. The enumeration may be converted to a different type than the input.

Reimplemented from Syntax.

string MdlSyntax::replaceSourceCodeMarkers ( const string nodeName,
const string soureCode,
std::function< string(const string &)>  lambda 
) const

Replaces all markers in a source code string indicated by {{...}}. The replacement is defined by a callback function.

Member Data Documentation

const StringVec MdlSyntax::ADDRESSMODE_MEMBERS
static

Definition at line 50 of file MdlSyntax.h.

const StringVec MdlSyntax::COLOR3_MEMBERS
static

Definition at line 48 of file MdlSyntax.h.

const StringVec MdlSyntax::COLOR4_MEMBERS
static

Definition at line 49 of file MdlSyntax.h.

const string MdlSyntax::CONST_QUALIFIER
static

Definition at line 40 of file MdlSyntax.h.

const StringVec MdlSyntax::COORDINATESPACE_MEMBERS
static

Definition at line 51 of file MdlSyntax.h.

const StringVec MdlSyntax::DISTRIBUTIONTYPE_MEMBERS
static

Definition at line 54 of file MdlSyntax.h.

const StringVec MdlSyntax::FILTERLOOKUPMODE_MEMBERS
static

Definition at line 52 of file MdlSyntax.h.

const StringVec MdlSyntax::FILTERTYPE_MEMBERS
static

Definition at line 53 of file MdlSyntax.h.

const string MdlSyntax::PORT_NAME_PREFIX
static

Definition at line 57 of file MdlSyntax.h.

const StringVec MdlSyntax::SCATTER_MODE_MEMBERS
static

Definition at line 55 of file MdlSyntax.h.

const StringVec MdlSyntax::SHEEN_MODE_MEMBERS
static

Definition at line 56 of file MdlSyntax.h.

const string MdlSyntax::SOURCE_FILE_EXTENSION
static

Definition at line 44 of file MdlSyntax.h.

const string MdlSyntax::UNIFORM_QUALIFIER
static

Definition at line 43 of file MdlSyntax.h.

const StringVec MdlSyntax::VECTOR2_MEMBERS
static

Definition at line 45 of file MdlSyntax.h.

const StringVec MdlSyntax::VECTOR3_MEMBERS
static

Definition at line 46 of file MdlSyntax.h.

const StringVec MdlSyntax::VECTOR4_MEMBERS
static

Definition at line 47 of file MdlSyntax.h.


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