Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

union(protogen): reuse same field type for different fields #81

Open
wenchy opened this issue Oct 25, 2023 · 0 comments
Open

union(protogen): reuse same field type for different fields #81

wenchy opened this issue Oct 25, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@wenchy
Copy link
Member

wenchy commented Oct 25, 2023

The concept is like Custom named struct.

Syntax: just after struct type name, use parentheses () to specify struct variable name: VariableType(VariableName).

Example

Name Alias Field1 Field2 Field3
Battle(PvpBattle) PVP BattleId
int32
Kills
uint32
Damage
int64
Battle(PveBattle) PVE BattleId
int32
Kills
uint32
Damage
int64
message ActivityTarget {
  option (tableau.union) = true;

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

    Battle pvp_battle = 1; // Bound to enum value: TYPE_PVP_BATTLE.
    Battle pve_battle = 2; // Bound to enum value: TYPE_PVE_BATTLE.
  }
  enum Type {
    TYPE_INVALID = 0;
    TYPE_PVP_BATTLE = 1 [(tableau.evalue).name = "PVP"];
    TYPE_PVE_BATTLE = 2 [(tableau.evalue).name = "PVE"];
  }
  message Battle {
    // ...
  }
}
@wenchy wenchy self-assigned this Oct 25, 2023
@wenchy wenchy added the enhancement New feature or request label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant