void NativeBindingGeneratorCore::OpenNamespaces(OutputStream &stream, const StringView *identifiers, size_t numIdentifiers) { if (numIdentifiers > 1) { for (size_t i = 0; i < (numIdentifiers - 1); ++i) { stream.Print("namespace "); identifiers[i].PrintTo(stream); stream.Print("\n{\n"); } } }
void NativeBindingGeneratorCore::PrintQualifiedBondName(OutputStream &stream, const Symbol *symbol) { if ((symbol != nullptr) && (symbol->GetName() != nullptr)) { const Symbol *parent = symbol->GetParentSymbol(); if ((parent != nullptr) && (parent->GetName() != nullptr)) { PrintQualifiedBondName(stream, parent); stream.Print("."); } stream.Print("%s", symbol->GetName()->GetRawText()); } }
void NativeBindingGeneratorCore::PrintNamespaceStack(OutputStream &stream, NamespaceStack::Iterator &it) { if ((it != mNamespaceStack.end()) && !it->mPrinted) { NamespaceItem &item = *it++; PrintNamespaceStack(stream, it); stream.Print("namespace %s\n{\n", item.mName); item.mPrinted = true; } }
void NativeBindingGeneratorCore::CloseNamespaces(OutputStream &stream, size_t numIdentifiers) { if (numIdentifiers > 1) { for (size_t i = 0; i < (numIdentifiers - 1); ++i) { stream.Print("}\n"); } } }
void NativeBindingGeneratorCore::PrintQualifiedCppName(OutputStream &stream, const Symbol *symbol) { if ((symbol != nullptr) && (symbol->GetName() != nullptr)) { PrintQualifiedCppName(stream, symbol->GetParentSymbol()); const char *suffix = ""; switch (symbol->GetSymbolType()) { case Symbol::TYPE_NAMESPACE: suffix = "::"; break; case Symbol::TYPE_STRUCT: suffix = "__"; break; default: suffix = ""; break; } stream.Print("%s%s", symbol->GetName()->GetRawText(), suffix); } }