6 #ifndef MATERIALX_SYNTAX_H
7 #define MATERIALX_SYNTAX_H
52 DOUBLE_SQUARE_BRACKETS
66 void registerReservedWords(
const StringSet& names);
71 void registerInvalidTokens(
const StringMap& tokens);
109 const string& getDefaultValue(
TypeDesc type,
bool uniform =
false)
const;
131 virtual const string& getConstantQualifier()
const = 0;
139 virtual const string&
getNewline()
const {
return NEWLINE; };
160 virtual const string& getSourceFileExtension()
const = 0;
172 [[deprecated]]
virtual bool typeSupported(
const TypeDesc*
type)
const;
175 virtual void makeValidName(
string&
name)
const;
196 virtual bool remapEnumeration(
const string&
value,
TypeDesc type,
const string& enumNames,
197 std::pair<TypeDesc, ValuePtr>&
result)
const;
200 virtual StructTypeSyntaxPtr createStructSyntax(
const string& structTypeName,
const string& defaultValue,
201 const string& uniformDefaultValue,
const string& typeAlias,
202 const string& typeDefinition)
const;
238 const string&
getName()
const {
return _name; }
247 const string&
getDefaultValue(
bool uniform)
const {
return uniform ? _uniformDefaultValue : _defaultValue; }
263 TypeSyntax(
const Syntax* parent,
const string&
name,
const string& defaultValue,
const string& uniformDefaultValue,
264 const string& typeAlias,
const string& typeDefinition,
const StringVec& members);
303 const StringVec& members = EMPTY_MEMBERS);
314 const StringVec& members = EMPTY_MEMBERS);
static const std::unordered_map< char, size_t > CHANNELS_MAPPING
const string & getTypeDefinition() const
Returns a type definition if needed to define the type in the target language.
const string & getTypeName(const TypeDesc *type) const
const StringVec & getMembers() const
const StringSet & getReservedWords() const
Returns a set of names that are reserved words for this language syntax.
shared_ptr< StructTypeSyntax > StructTypeSyntaxPtr
Shared pointer to a StructTypeSyntax.
TypeDesc getType(const string &name) const
Return a type description for the given type name.
virtual const string & getEndMultiLineComment() const
Return the characters used to end a multi line comments block.
Specialization of TypeSyntax for scalar types.
string getArrayTypeSuffix(const TypeDesc *type, const Value &value) const
#define MATERIALX_NAMESPACE_BEGIN
vector< string > StringVec
A vector of strings.
virtual string getArrayTypeSuffix(TypeDesc, const Value &) const
Return the array suffix to use for declaring an array type.
const string & getName() const
Returns the type name.
virtual const string & getUniformQualifier() const
GLsizei const GLfloat * value
string getVariableName(const string &name, const TypeDesc *type, IdentifierMap &identifiers) const
string getOutputTypeName(const TypeDesc *type) const
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
shared_ptr< TypeSyntax > TypeSyntaxPtr
Shared pointer to a TypeSyntax.
const string & getTypeAlias() const
Returns a type alias if needed to define the type in the target language.
shared_ptr< Syntax > SyntaxPtr
Shared pointer to a Syntax.
const vector< TypeSyntaxPtr > & getTypeSyntaxes() const
Returns an array of all registered type syntax objects.
const string & getTypeAlias(const TypeDesc *type) const
shared_ptr< const Syntax > ConstSyntaxPtr
Shared pointer to a constant Syntax.
static const string INDENTATION
const string & getDefaultValue(bool uniform) const
Returns the default value for this type.
virtual const string & getOutputQualifier() const
virtual const string & getSingleLineComment() const
Return the characters used for single line comment.
const string & getDefaultValue(const TypeDesc *type, bool uniform=false) const
**But if you need a result
string getValue(const Value &value, bool uniform) const override
shared_ptr< class TypeSystem > TypeSystemPtr
__hostdev__ float getValue(uint32_t i) const
void registerTypeSyntax(const TypeDesc *type, TypeSyntaxPtr syntax)
virtual string getValue(const ShaderPort *port, bool uniform) const
GLint GLint GLsizei GLint GLenum GLenum type
A generic, discriminated value, whose type may be queried dynamically.
static const string END_MULTI_LINE_COMMENT
string _uniformDefaultValue
virtual const string & getIndentation() const
Return the characters used for a single indentation level.
virtual const string & getStringQuote() const
Return the characters used to begin/end a string definition.
static const string NEWLINE
Constants with commonly used strings.
GLuint const GLchar * name
const string & getTypeDefinition(const TypeDesc *type) const
virtual const string & getNewline() const
Return the characters used for a newline.
Specialization of TypeSyntax for aggregate types.
vector< TypeSyntaxPtr > _typeSyntaxes
Specialization of TypeSyntax for string types.
static const string INCLUDE_STATEMENT
const TypeSyntax & getTypeSyntax(const TypeDesc *type) const
static const StringVec EMPTY_MEMBERS
TypeSystemPtr _typeSystem
Punctuation
Punctuation types.
std::unordered_map< string, size_t > IdentifierMap
string getArrayVariableSuffix(const TypeDesc *type, const Value &value) const
std::unordered_map< string, string > StringMap
An unordered map with strings as both keys and values.
Specialization of TypeSyntax for struct types.
std::set< string > StringSet
A set of strings.
#define MATERIALX_NAMESPACE_END
static const string COMMA
static const string STRING_QUOTE
virtual const string & getBeginMultiLineComment() const
Return the characters used to begin a multi line comments block.
virtual const string & getIncludeStatement() const
Return the string pattern used for a file include statement.
std::unordered_map< TypeDesc, size_t, TypeDesc::Hasher > _typeSyntaxIndexByType
virtual const string & getInputQualifier() const
string getValue(const TypeDesc *type, const Value &value, bool uniform=false) const
static const string SINGLE_LINE_COMMENT
const StringMap & getInvalidTokens() const
Returns a mapping from disallowed tokens to replacement strings for this language syntax...
static const string BEGIN_MULTI_LINE_COMMENT
static const string SEMICOLON