6 #ifndef MATERIALX_SYNTAX_H
7 #define MATERIALX_SYNTAX_H
48 DOUBLE_SQUARE_BRACKETS
61 void registerReservedWords(
const StringSet& names);
66 void registerInvalidTokens(
const StringMap& tokens);
89 virtual string getOutputTypeName(
const TypeDesc*
type)
const;
97 const string& getTypeDefinition(
const TypeDesc*
type)
const;
100 const string& getDefaultValue(
const TypeDesc*
type,
bool uniform =
false)
const;
109 virtual string getSwizzledVariable(
const string& srcName,
const TypeDesc* srcType,
const string&
channels,
const TypeDesc* dstType)
const;
126 virtual const string& getConstantQualifier()
const = 0;
134 virtual const string&
getNewline()
const {
return NEWLINE; };
155 virtual const string& getSourceFileExtension()
const = 0;
168 virtual void makeValidName(
string&
name)
const;
188 virtual bool remapEnumeration(
const string&
value,
const TypeDesc*
type,
const string& enumNames,
189 std::pair<const TypeDesc*, ValuePtr>&
result)
const;
224 const string&
getName()
const {
return _name; }
233 const string&
getDefaultValue(
bool uniform)
const {
return uniform ? _uniformDefaultValue : _defaultValue; }
254 TypeSyntax(
const string&
name,
const string& defaultValue,
const string& uniformDefaultValue,
255 const string& typeAlias,
const string& typeDefinition,
const StringVec& members);
271 ScalarTypeSyntax(
const string&
name,
const string& defaultValue,
const string& uniformDefaultValue,
282 StringTypeSyntax(
const string&
name,
const string& defaultValue,
const string& uniformDefaultValue,
294 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 StringVec & getMembers() const
const StringSet & getReservedWords() const
Returns a set of names that are reserved words for this language syntax.
virtual const string & getEndMultiLineComment() const
Return the characters used to end a multi line comments block.
Specialization of TypeSyntax for scalar types.
#define MATERIALX_NAMESPACE_BEGIN
vector< string > StringVec
A vector of strings.
const string & getName() const
Returns the type name.
virtual string getArrayTypeSuffix(const TypeDesc *, const Value &) const
Return the array suffix to use for declaring an array type.
virtual const string & getUniformQualifier() 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.
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.
**But if you need a result
string getValue(const Value &value, bool uniform) const override
__hostdev__ float getValue(uint32_t i) const
virtual string getValue(const ShaderPort *port, bool uniform) const
std::unordered_map< const TypeDesc *, size_t > _typeSyntaxByType
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
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
GLenum GLsizei GLsizei GLint * values
static const StringVec EMPTY_MEMBERS
Punctuation
Punctuation types.
std::unordered_map< string, size_t > IdentifierMap
std::unordered_map< string, string > StringMap
An unordered map with strings as both keys and values.
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.
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
virtual const string & getInputQualifier() const
static const string SINGLE_LINE_COMMENT
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
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