-
Notifications
You must be signed in to change notification settings - Fork 12
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
Protobuf Extensions and Oneof #42
Comments
certainly - also the dictionary feature might be useful before adopting protobuf 3, I'd like to see a stable release with solid Python bindings (currently considered alpha: https://github.com/google/protobuf/releases) |
Both features are available in protobuf 2.6. Especially Extensions could be very helpful. |
Example: package pb;
import "machinetalk/protobuf/message.proto";
enum MyCoolProtocolType {
COOL_PING = 1,
COOL_PONG = 2
}
message MyMessage {
required MyCoolProtocolType type = 1;
optional int32 easy = 2;
}
extend Container {
optional MyMessage testus = 1000;
} I think it is even possible to do this without recompiling the main Machinetalk library. The calling code looks a little bit different: from machinetalk.protobuf.message_pb2 import Container
import machinetalk.protobuf.types_pb1 as types
import machinetalk.protobuf.myprotocol_pb2 as pb
x = Container()
...
if (x.type == types.MT_REQ) and x.HasExtension(pb.testus):
testus = x.Extension[pb.testus]
if testus.type == pb.COOL_PING:
print(testus.easy) Looks pretty easy and keeps things in place. |
However, the |
DigitalReadOut.qml: set default values for machine with 5+ axes
The protobuf definitions might be easier to understand by using the Protobuf
Extensions
andOneof
features:https://developers.google.com/protocol-buffers/docs/proto?hl=en
E.g. message types for a certain service could be defined in separate file instead of the
types.proto
. It would simplify documentation of things that belong together.The text was updated successfully, but these errors were encountered: