This page is no longer maintained — Please continue to the home page at www.scala-lang.org

[protobuf] [ANN] scala protobuf builder 0.1

No replies
Eugene Vigdorchik
Joined: 2010-03-30,
User offline. Last seen 35 weeks 3 days ago.

Hi all,
I'm pleased to announce the birth of scala-protobuf project. You can
find the sources at http://code.google.com/p/protobuf-scala .
The goal of the project is allowing easy construction of Google
protobuf (http://code.google.com/p/protobuf/) messages from Scala.
Unlike conventional protobuf code, protobuf-scala allows for a more
code-as-data way to write your protocol messages. Here is a short
example.

Given a protocol definition
message Artist {
required string name = 1;
message Album {
required string title = 1;
repeated string tracks = 2;
optional uint32 year_produced = 3;
}

repeated Album albums = 2;
}

one creates instances like this:

val BradMehldau = Artist (
name("Brad Mehldau"),
albums (
Album (
title("Day Is Done"),
tracks(
"50 ways to leave your lover",
"Grenada"
),
year_produced(2005)
)
)
)

As most of scalac plugins, protobuf-scala consists of a generator
plugin and a thin runtime layer in scala. The output of scala code
generator requries java classes produced with --java_output, so be
sure to produce it as well.
Hope those of you who use both scala and protobufs find it useful.

Cheers,
Eugene.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland