Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions source/MaterialXGenShader/ShaderGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ MATERIALX_NAMESPACE_BEGIN
// ShaderGraph methods
//

ShaderGraph::ShaderGraph(const ShaderGraph* parent, const string& name, ConstDocumentPtr document, const StringSet& reservedWords) :
ShaderGraph::ShaderGraph(const ShaderGraph* parent, const string& name, ConstDocumentPtr document, const StringSet& /*reservedWords*/) :
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps remove the reservedWords parameter completely since it's not used now?

This constructor is only ever called from within ShaderGraph.cpp, in the ShaderGraph::create methods, and I doubt anyone has ever used it explicitly from an integration. It's not exposed in python. So I think it should be safe to change the signature.

ShaderNode(parent, name),
_document(document)
{
// Add all reserved words as taken identifiers
for (const string& n : reservedWords)
{
_identifiers[n] = 1;
}
}

void ShaderGraph::addInputSockets(const InterfaceElement& elem, GenContext& context)
Expand Down
6 changes: 6 additions & 0 deletions source/MaterialXGenShader/Syntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ void Syntax::makeValidName(string& name) const
{
std::replace_if(name.begin(), name.end(), isInvalidChar, '_');
name = replaceSubstrings(name, _invalidTokens);
if (std::find(_reservedWords.begin(), _reservedWords.end(), name) != _reservedWords.end())
{
// We append "1" here because thats the prior behavior from makeIdentifier() below when
// the reservedWords were added to the identifiers list.
name = name+"1";
}
}

void Syntax::makeIdentifier(string& name, IdentifierMap& identifiers) const
Expand Down