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
2 changes: 1 addition & 1 deletion cmd/protoc-gen-cpp-tableau-loader/indexes/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (x *Generator) genCppIndexFinders() {
messagerName := x.messagerName()

x.g.P("// Index: ", index.Index)
x.g.P("const ", messagerName, "::", mapType, "& ", messagerName, "::Find", index.Name(), "Map() const { return ", indexContainerName, " ;}")
x.g.P("const ", messagerName, "::", mapType, "& ", messagerName, "::Find", index.Name(), "Map() const { return ", indexContainerName, "; }")
x.g.P()

keys := x.indexKeys(index)
Expand Down
2 changes: 1 addition & 1 deletion cmd/protoc-gen-cpp-tableau-loader/indexes/ordered_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (x *Generator) genCppOrderedIndexFinders() {
messagerName := x.messagerName()

x.g.P("// OrderedIndex: ", index.Index)
x.g.P("const ", messagerName, "::", mapType, "& ", messagerName, "::Find", index.Name(), "Map() const { return ", indexContainerName, " ;}")
x.g.P("const ", messagerName, "::", mapType, "& ", messagerName, "::Find", index.Name(), "Map() const { return ", indexContainerName, "; }")
x.g.P()

keys := x.orderedIndexKeys(index)
Expand Down
4 changes: 2 additions & 2 deletions cmd/protoc-gen-cpp-tableau-loader/messager.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func genHppMessage(g *protogen.GeneratedFile, message *protogen.Message) {
orderedMapGenerator := orderedmap.NewGenerator(g, message)
indexGenerator := indexes.NewGenerator(g, indexDescriptor, message)

g.P("class ", message.Desc.Name(), " : public Messager {")
g.P("class ", message.Desc.Name(), " final : public Messager {")
g.P(" public:")
g.P(helper.Indent(1), "static const std::string& Name() { return kProtoName; }")
g.P(helper.Indent(1), "virtual bool Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr<const load::MessagerOptions> options = nullptr) override;")
Expand All @@ -96,7 +96,7 @@ func genHppMessage(g *protogen.GeneratedFile, message *protogen.Message) {

if orderedMapGenerator.NeedGenerate() || indexGenerator.NeedGenerate() {
g.P(" private:")
g.P(helper.Indent(1), "virtual bool ProcessAfterLoad() override final;")
g.P(helper.Indent(1), "virtual bool ProcessAfterLoad() override;")
g.P()
}

Expand Down
8 changes: 6 additions & 2 deletions cmd/protoc-gen-go-tableau-loader/indexes/orderedindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,14 @@ func (x *Generator) genOrderedIndexFinders() {
x.g.P("// Find", index.Name(), i, " finds a slice of all values of the given key(s) in the upper ", loadutil.Ordinal(i), "-level treemap")
x.g.P("// specified by (", partArgs, ").")
x.g.P("func (x *", messagerName, ") Find", index.Name(), i, "(", partParams, ", ", params, ") []*", x.mapValueType(index), " {")
x.g.P("m := x.Find", index.Name(), "Map", i, "(", partArgs, ")")
x.g.P("if m == nil {")
x.g.P("return nil")
x.g.P("}")
if len(index.ColFields) == 1 {
x.g.P("val, _ := x.Find", index.Name(), "Map", i, "(", partArgs, ").Get(", args, ")")
x.g.P("val, _ := m.Get(", args, ")")
} else {
x.g.P("val, _ := x.Find", index.Name(), "Map", i, "(", partArgs, ").Get(", x.orderedIndexMapKeyType(index), "{", args, "})")
x.g.P("val, _ := m.Get(", x.orderedIndexMapKeyType(index), "{", args, "})")
}
x.g.P("return val")
x.g.P("}")
Expand Down
6 changes: 3 additions & 3 deletions test/cpp-tableau-loader/src/protoconf/hero_conf.pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
#include "hero_conf.pb.h"

namespace tableau {
class HeroConf : public Messager {
class HeroConf final : public Messager {
public:
static const std::string& Name() { return kProtoName; }
virtual bool Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr<const load::MessagerOptions> options = nullptr) override;
const protoconf::HeroConf& Data() const { return data_; }
const google::protobuf::Message* Message() const override { return &data_; }

private:
virtual bool ProcessAfterLoad() override final;
virtual bool ProcessAfterLoad() override;

public:
const protoconf::HeroConf::Hero* Get(const std::string& name) const;
Expand All @@ -44,7 +44,7 @@ class HeroConf : public Messager {
OrderedMap_HeroMap ordered_map_;
};

class HeroBaseConf : public Messager {
class HeroBaseConf final : public Messager {
public:
static const std::string& Name() { return kProtoName; }
virtual bool Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr<const load::MessagerOptions> options = nullptr) override;
Expand Down
5 changes: 5 additions & 0 deletions test/cpp-tableau-loader/src/protoconf/hub.pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class Fruit3Conf;
template <>
const std::shared_ptr<Fruit3Conf> Hub::Get<Fruit3Conf>() const;

class Fruit4Conf;
template <>
const std::shared_ptr<Fruit4Conf> Hub::Get<Fruit4Conf>() const;

class FruitConf;
template <>
const std::shared_ptr<FruitConf> Hub::Get<FruitConf>() const;
Expand Down Expand Up @@ -188,6 +192,7 @@ class MessagerContainer {
std::shared_ptr<HeroConf> hero_conf_;
std::shared_ptr<Fruit2Conf> fruit_2_conf_;
std::shared_ptr<Fruit3Conf> fruit_3_conf_;
std::shared_ptr<Fruit4Conf> fruit_4_conf_;
std::shared_ptr<FruitConf> fruit_conf_;
std::shared_ptr<ItemConf> item_conf_;
std::shared_ptr<PatchMergeConf> patch_merge_conf_;
Expand Down
7 changes: 7 additions & 0 deletions test/cpp-tableau-loader/src/protoconf/hub_shard0.pc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const std::shared_ptr<Fruit3Conf> Hub::Get<Fruit3Conf>() const {
return GetMessagerContainerWithProvider()->fruit_3_conf_;
}

template <>
const std::shared_ptr<Fruit4Conf> Hub::Get<Fruit4Conf>() const {
return GetMessagerContainerWithProvider()->fruit_4_conf_;
}

template <>
const std::shared_ptr<FruitConf> Hub::Get<FruitConf>() const {
return GetMessagerContainerWithProvider()->fruit_conf_;
Expand All @@ -45,6 +50,7 @@ void MessagerContainer::InitShard0() {
hero_conf_ = std::dynamic_pointer_cast<HeroConf>(GetMessager(HeroConf::Name()));
fruit_2_conf_ = std::dynamic_pointer_cast<Fruit2Conf>(GetMessager(Fruit2Conf::Name()));
fruit_3_conf_ = std::dynamic_pointer_cast<Fruit3Conf>(GetMessager(Fruit3Conf::Name()));
fruit_4_conf_ = std::dynamic_pointer_cast<Fruit4Conf>(GetMessager(Fruit4Conf::Name()));
fruit_conf_ = std::dynamic_pointer_cast<FruitConf>(GetMessager(FruitConf::Name()));
item_conf_ = std::dynamic_pointer_cast<ItemConf>(GetMessager(ItemConf::Name()));
}
Expand All @@ -54,6 +60,7 @@ void Registry::InitShard0() {
Register<HeroConf>();
Register<Fruit2Conf>();
Register<Fruit3Conf>();
Register<Fruit4Conf>();
Register<FruitConf>();
Register<ItemConf>();
}
Expand Down
Loading