return out;
}
-typedef std::map<std::string, std::string> CYKeyMap;
+struct CYKey {
+ unsigned priority_ = 0;
+
+ std::string code_;
+ unsigned flags_;
+};
+
+typedef std::map<std::string, CYKey> CYKeyMap;
struct CYChildBaton {
CXTranslationUnit unit;
CYCXString spelling(cursor);
std::string name(spelling);
std::ostringstream value;
+ unsigned priority(2);
+ unsigned flags(0);
/*CXSourceLocation location(clang_getCursorLocation(cursor));
CYCXPosition<> position(location);
} break;
case CXCursor_StructDecl: {
- if (!clang_isCursorDefinition(cursor))
- goto skip;
if (spelling[0] == '\0')
goto skip;
+ if (!clang_isCursorDefinition(cursor))
+ priority = 1;
std::ostringstream types;
std::ostringstream names;
} break;
}
- baton.keys[name] = value.str();
+ {
+ CYKey &key(baton.keys[name]);
+ if (key.priority_ < priority) {
+ key.priority_ = priority;
+ key.code_ = value.str();
+ key.flags_ = flags;
+ }
+ }
skip:
return CXChildVisit_Continue;
clang_visitChildren(clang_getTranslationUnitCursor(unit), &CYChildVisit, &baton);
for (CYKeyMap::const_iterator key(keys.begin()); key != keys.end(); ++key) {
- std::string value(key->second);
- for (size_t i(0), e(value.size()); i != e; ++i)
- if (value[i] <= 0 || value[i] >= 0x7f || value[i] == '\n')
+ std::string code(key->second.code_);
+ for (size_t i(0), e(code.size()); i != e; ++i)
+ if (code[i] <= 0 || code[i] >= 0x7f || code[i] == '\n')
goto skip;
- std::cout << key->first << "|\"" << value << "\"" << std::endl;
+ std::cout << key->first << "|" << key->second.flags_ << "\"" << code << "\"" << std::endl;
skip:; }
clang_disposeTranslationUnit(unit);