oniksan / godobuf

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

feature request: setter for repeated fields #22

Closed conradhappeliv closed 2 years ago

conradhappeliv commented 2 years ago

Right now, the only way to "reset" a repeated field seems to be clearing the field (which I believe to be broken due to #21) and re-adding all entries in a loop - for example:

msg.clear_repeated_field()
for item in [1, 2, 3]:
    msg.add_repeated_field(item)

It would be super cool to get a method where we could do this in one statement - i.e. msg.set_repeated_field([1, 2, 3])!

oniksan commented 2 years ago

Hi, conradhappeliv.

Thank you for improving the product, but your PR breaks backwards compatibility.

If you want, you can write code that supports both (old and new) methods of setting repeated fields: In addition to this, you need: