Error parsing enums
xaqbr opened this issue · 2 comments
xaqbr commented
oniksan commented
Only in v0.4.4?
oniksan commented
Apparently you have a specific proto scheme, send me the file, I'll see what can be done.
For enum from example:
syntax = "proto3";
enum TestEnum {
VALUE_0 = 0;
VALUE_1 = 1;
VALUE_2 = 2;
}
message B {
enum BEnum {
BVALUE_0 = 0;
BVALUE_1 = 1;
BVALUE_2 = 2;
}
}
message A {
TestEnum f1 = 1;
B.BEnum f2 = 2;
}
everything works fine
1. Parsing:
C:/Users/robo/Documents/godobuf-test-master/ttt.proto: parsing.
* Parsing completed successfully. *
2. Semantic analysis:
C:/Users/robo/Documents/godobuf-test-master/ttt.proto: analysis.
* Semantic analysis completed successfully. *
3. Output file creating:
Perform full semantic analysis.
Perform translation.
* Output file was created successfully. *
Out.gd fragment
############### USER DATA BEGIN ################
enum TestEnum {
VALUE_0 = 0,
VALUE_1 = 1,
VALUE_2 = 2
}
class B:
func _init():
var service
var data = {}
enum BEnum {
BVALUE_0 = 0,
BVALUE_1 = 1,
BVALUE_2 = 2
}
func to_string() -> String:
return PBPacker.message_to_string(data)
func to_bytes() -> PoolByteArray:
return PBPacker.pack_message(data)
func from_bytes(bytes : PoolByteArray, offset : int = 0, limit : int = -1) -> int:
var cur_limit = bytes.size()
if limit != -1:
cur_limit = limit
var result = PBPacker.unpack_message(data, bytes, offset, cur_limit)
if result == cur_limit:
if PBPacker.check_required(data):
if limit == -1:
return PB_ERR.NO_ERRORS
else:
return PB_ERR.REQUIRED_FIELDS
elif limit == -1 && result > 0:
return PB_ERR.PARSE_INCOMPLETE
return result
class A:
func _init():
var service
_f1 = PBField.new("f1", PB_DATA_TYPE.ENUM, PB_RULE.OPTIONAL, 1, true, DEFAULT_VALUES_3[PB_DATA_TYPE.ENUM])
service = PBServiceField.new()
service.field = _f1
data[_f1.tag] = service
_f2 = PBField.new("f2", PB_DATA_TYPE.ENUM, PB_RULE.OPTIONAL, 2, true, DEFAULT_VALUES_3[PB_DATA_TYPE.ENUM])
service = PBServiceField.new()
service.field = _f2
data[_f2.tag] = service
var data = {}
var _f1: PBField
func get_f1():
return _f1.value
func clear_f1() -> void:
data[1].state = PB_SERVICE_STATE.UNFILLED
_f1.value = DEFAULT_VALUES_3[PB_DATA_TYPE.ENUM]
func set_f1(value) -> void:
_f1.value = value
var _f2: PBField
func get_f2():
return _f2.value
func clear_f2() -> void:
data[2].state = PB_SERVICE_STATE.UNFILLED
_f2.value = DEFAULT_VALUES_3[PB_DATA_TYPE.ENUM]
func set_f2(value) -> void:
_f2.value = value
func to_string() -> String:
return PBPacker.message_to_string(data)
func to_bytes() -> PoolByteArray:
return PBPacker.pack_message(data)
func from_bytes(bytes : PoolByteArray, offset : int = 0, limit : int = -1) -> int:
var cur_limit = bytes.size()
if limit != -1:
cur_limit = limit
var result = PBPacker.unpack_message(data, bytes, offset, cur_limit)
if result == cur_limit:
if PBPacker.check_required(data):
if limit == -1:
return PB_ERR.NO_ERRORS
else:
return PB_ERR.REQUIRED_FIELDS
elif limit == -1 && result > 0:
return PB_ERR.PARSE_INCOMPLETE
return result
################ USER DATA END #################