oniksan / godobuf

A Google Protobuf implementation for Godot / GDScript
BSD 3-Clause "New" or "Revised" License
260 stars 36 forks source link

Duplicate has function for oneofs #45

Open Dantsz opened 2 months ago

Dantsz commented 2 months ago

Hi, I have to following .proto file:

syntax = "proto3";

message WorldJoinRequest {}
message WorldLeaveRequest {}

message ControlMessage{
    string sessionKey = 1;
    oneof MessageData {
        WorldJoinRequest joinMessage = 2;
        WorldLeaveRequest leaveMessage = 3;
    }
}

Running it throught the generator produces two has_ functions for the variants:

    func has_joinMessage() -> bool:
        return data[2].state == PB_SERVICE_STATE.FILLED
    func has_joinMessage() -> bool:
        if __joinMessage.value != null:
            return true
        return false
       ...
    var __leaveMessage: PBField
    func has_leaveMessage() -> bool:
        return data[3].state == PB_SERVICE_STATE.FILLED
    func has_leaveMessage() -> bool:
        if __leaveMessage.value != null:
            return true
        return false

I see a recent change in ec3c6bdada2f7a7a60d1bd90b6a613f3b2fc1bb7: https://github.com/oniksan/godobuf/blob/e677d2c7b89e76c1ab3d0ef963c9d1647164d9e5/addons/protobuf/parser.gd#L1813-L1815 maybe line 1813 is an error and should be removed?

oniksan commented 2 months ago

it looks like it is

omaliavkin commented 1 month ago

PR added by me to master were not tested by me. Therefore, they were not included in release. Unfortunately, there is no time for this yet. It seems that this happened here: https://github.com/oniksan/godobuf/pull/42/files I'll have to find time and test it Use release version