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

Duplicate has function for oneofs #45

Open
Dantsz opened this issue Aug 13, 2024 · 2 comments
Open

Duplicate has function for oneofs #45

Dantsz opened this issue Aug 13, 2024 · 2 comments

Comments

@Dantsz
Copy link

Dantsz commented Aug 13, 2024

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 ec3c6bd:

text += generate_has_oneof(field_index, nesting)
if f.qualificator != Analysis.FIELD_QUALIFICATOR.OPTIONAL:
text += generate_has_oneof(field_index, nesting)

maybe line 1813 is an error and should be removed?

@oniksan
Copy link
Owner

oniksan commented Aug 24, 2024

it looks like it is

@omaliavkin
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants