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
1 change: 0 additions & 1 deletion cmd/protoc-gen-cpp-tableau-loader/embed/load.pc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ bool PatchMessage(google::protobuf::Message& dst, const google::protobuf::Messag
// Reference:
// https://github.com/protocolbuffers/protobuf/blob/95ef4134d3f65237b7adfb66e5e7aa10fcfa1fa3/src/google/protobuf/map_field.cc#L500
auto key_fd = fd->message_type()->map_key();
auto value_fd = fd->message_type()->map_value();
int src_count = src_reflection->FieldSize(src, fd);
int dst_count = dst_reflection->FieldSize(dst, fd);
switch (key_fd->cpp_type()) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/protoc-gen-cpp-tableau-loader/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/iancoleman/strcase"
"github.com/tableauio/loader/cmd/protoc-gen-cpp-tableau-loader/helper"
"github.com/tableauio/loader/internal/options"
"github.com/tableauio/tableau/proto/tableaupb"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/proto"
Expand All @@ -15,7 +16,7 @@ import (
func getAllOrderedFilesAndMessagers(gen *protogen.Plugin) (protofiles []string, fileMessagers map[string][]string) {
fileMessagers = map[string][]string{}
for _, f := range gen.Files {
if !f.Generate {
if !options.NeedGenFile(f) {
continue
}
opts := f.Desc.Options().(*descriptorpb.FileOptions)
Expand Down
1 change: 0 additions & 1 deletion test/cpp-tableau-loader/src/protoconf/load.pc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ bool PatchMessage(google::protobuf::Message& dst, const google::protobuf::Messag
// Reference:
// https://github.com/protocolbuffers/protobuf/blob/95ef4134d3f65237b7adfb66e5e7aa10fcfa1fa3/src/google/protobuf/map_field.cc#L500
auto key_fd = fd->message_type()->map_key();
auto value_fd = fd->message_type()->map_value();
int src_count = src_reflection->FieldSize(src, fd);
int dst_count = dst_reflection->FieldSize(dst, fd);
switch (key_fd->cpp_type()) {
Expand Down
44 changes: 44 additions & 0 deletions test/proto/union_conf.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";

package protoconf;

import "tableau/protobuf/tableau.proto";

option go_package = "github.com/tableauio/loader/test/go-tableau-loader/protoconf";
option (tableau.workbook) = {
name: "Union.xlsx"
};

message HeroTarget {
option (tableau.union) = {
name: "UnionType"
note: "HeroTarget note"
};

Type type = 9999 [(tableau.field) = { name: "Type" }];
oneof value {
option (tableau.oneof) = {
note: "HeroTarget note"
field: "Field"
};

StarUp star_up = 1; // Bound to enum value: TYPE_STAR_UP.
LevelUp level_up = 2; // Bound to enum value: TYPE_LEVEL_UP.
}

enum Type {
TYPE_INVALID = 0;
TYPE_STAR_UP = 1 [(tableau.evalue).name = "HeroStarUp"]; // HeroStarUp
TYPE_LEVEL_UP = 2 [(tableau.evalue).name = "HeroLevelUp"]; // HeroLevelUp
}

message StarUp {
uint32 id = 1 [(tableau.field) = { name: "ID" }];
int32 star = 2 [(tableau.field) = { name: "Star" }];
}
message LevelUp {
repeated uint32 id_list = 1 [(tableau.field) = { name: "ID" layout: LAYOUT_INCELL }];
int32 level = 2 [(tableau.field) = { name: "Level" }];
bool super = 3 [(tableau.field) = { name: "Super" }];
}
}