Skip to content

Commit

Permalink
Fix not to emit type_name for attribute metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Apr 17, 2024
1 parent 4f8a003 commit 3e808fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/pprinter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ std::string print_prim_metas(const PrimMeta &meta, const uint32_t indent) {

// TODO: deprecate meta.meta and remove it.
for (const auto &item : meta.meta) {
ss << print_meta(item.second, indent + 1, item.first);
ss << print_meta(item.second, indent + 1, true, item.first);
}

// for (const auto &item : meta.stringData) {
Expand Down Expand Up @@ -704,7 +704,8 @@ std::string print_attr_metas(const AttrMeta &meta, const uint32_t indent) {

// other user defined metadataum.
for (const auto &item : meta.meta) {
ss << print_meta(item.second, indent, item.first);
// attribute meta does not emit type_name
ss << print_meta(item.second, indent, /* emit_type_name */false, item.first);
}

for (const auto &item : meta.stringData) {
Expand Down Expand Up @@ -1981,14 +1982,14 @@ std::string print_customData(const CustomDataType &customData,
ss << "{\n";
}
for (const auto &item : customData) {
ss << print_meta(item.second, indent + 1, item.first);
ss << print_meta(item.second, indent + 1, true, item.first);
}
ss << pprint::Indent(indent) << "}\n";

return ss.str();
}

std::string print_meta(const MetaVariable &meta, const uint32_t indent,
std::string print_meta(const MetaVariable &meta, const uint32_t indent, bool emit_type_name,
const std::string &varname) {
std::stringstream ss;

Expand All @@ -2013,11 +2014,15 @@ std::string print_meta(const MetaVariable &meta, const uint32_t indent,
}
ss << pprint::Indent(indent) << "dictionary " << name << " = {\n";
for (const auto &item : pv.value()) {
ss << print_meta(item.second, indent + 1, item.first);
ss << print_meta(item.second, indent + 1, /* emit_type_name */true, item.first);
}
ss << pprint::Indent(indent) << "}\n";
} else {
ss << pprint::Indent(indent) << meta.type_name() << " " << name << " = "
ss << pprint::Indent(indent);
if (emit_type_name) {
ss << meta.type_name() << " ";
}
ss << name << " = "
<< pprint_value(meta.get_raw_value()) << "\n";
}

Expand Down
2 changes: 1 addition & 1 deletion src/pprinter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ std::string print_xformOps(const std::vector<XformOp> &xformOps,
std::string print_attr_metas(const AttrMeta &meta, const uint32_t indent);

// varname = optional variable name which is used when meta.get_name() is empty.
std::string print_meta(const MetaVariable &meta, const uint32_t indent,
std::string print_meta(const MetaVariable &meta, const uint32_t indent, bool emit_type_name,
const std::string &varname = std::string());
std::string print_prim_metas(const PrimMeta &meta, const uint32_t indent);
std::string print_customData(const CustomDataType &customData,
Expand Down

0 comments on commit 3e808fc

Please sign in to comment.