Scala 协议缓冲区编译器
我正在考虑编写一个代码生成器来从 google protobuf 定义文件生成 scala。我认为它有价值的原因是 java 绑定太 Java 了,而在 scala 中可以做得更好。 例如,对于以下定义,
message Foo {
required int F1 = 1;
repeated string F2 = 2;
message Inner (
required int F3 = 1;
)
}
我希望能够像这样从 Scala 构造原型对象:
val foo = Foo (
F1(127),
F2("first", "second"),
Inner (
F3(911)
)
)
我的问题是,是否有人知道已经存在的这些内容,或者如果不知道,您是否认为值得开始一个新项目?
I was thinking about writing a code generator to generate scala from google protobuf definitions file. The reason I see it valuable is the java bindings are too Java-ish and one could do much better in scala.
For example for the following definition
message Foo {
required int F1 = 1;
repeated string F2 = 2;
message Inner (
required int F3 = 1;
)
}
I want to be able to construct the proto object from Scala like this:
val foo = Foo (
F1(127),
F2("first", "second"),
Inner (
F3(911)
)
)
My question is if anyone knows something along these lines already existing, or if not do you find it worthy to start a new project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我目前正在与我的导师 Viktor Klang 一起开发 Scala Protocol Buffers 编译器。这是我的 Google Summer of Code 项目,您可以在 github 上关注进度:https://github.com/SandroGrzicic/ScalaBuff。
[更新]主体部分已完成;我仍然需要实现扩展、组和字段选项支持。它是可用的,我邀请大家尝试并提供反馈;我愿意接受建议和功能请求。
I'm currently working on a Scala Protocol Buffers compiler with my mentor Viktor Klang. It's my Google Summer of Code project and you can follow the progress on github at https://github.com/SandroGrzicic/ScalaBuff.
[Update] The main part is complete; I still need to implement Extensions, Groups and field Options support. It's usable and I invite everyone to try it and give feedback; I'm open to suggestions and feature requests.
我刚刚遇到这些,但不能保证它们,因为我从未使用过它们。
http://code.google.com/p/protobuf-scala/
https://github.com/jeffplaisance/scala-protobuf
I just came across these but can not vouch for them as I've never used them.
http://code.google.com/p/protobuf-scala/
https://github.com/jeffplaisance/scala-protobuf
从 .proto 文件生成 Scala 和 Java 类的一个非常好的工具是 ScalaPB。该工具扩展了 sbt-protobuf 插件的功能。
A really good tool to generate both Scala and Java classes from .proto files is ScalaPB. The tool extends the functionality of the sbt-protobuf plugin.
有一个项目使用 Simple-Build-Tool 插件来实现这种效果: http:// github.com/codahale/protobuf-sbt?locale=sv
更新:
上述项目已不存在。 sbt-protobuf 插件扩展了原始项目的功能。但请注意,sbt-protobuf 生成 Java 类,而不是 Scala。
There's this project that uses Simple-Build-Tool plugins to achieve that effect: http://github.com/codahale/protobuf-sbt?locale=sv
Update:
The above project no longer exists. The sbt-protobuf plugin extended the functionality of that original project. Note, however, that sbt-protobuf generates Java classes, not Scala.
也许可以编写一个 Scala 编译器插件来读取和编译 .proto 文件?
Maybe it would be possible to write a Scala compiler plugin that read and compiled .proto files?