[protobuf] Re: Issue 253 in protobuf: Feature download is for an old version

2011-01-28 Thread protobuf

Updates:
Owner: liuj...@google.com

Comment #1 on issue 253 by liuj...@google.com: Feature download is for an  
old version

http://code.google.com/p/protobuf/issues/detail?id=253

We are still working on documentation. Will do, when we officially announce  
it:)


--
You received this message because you are subscribed to the Google Groups Protocol 
Buffers group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] inheritance.. well sort of... and FieldDescriptors

2011-01-28 Thread koert
i have several proto message definitions that all share the first 4
fields. its as if they are all subclasses of one protobuf message
format.
in java can i create the FieldDescriptors for these 4 fields once and
use them for the getters and setters of all these message classes? it
would save me a lot in terms of logic and maybe also lead to somewhat
bettter performance.
best koert

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Problem when generating classes

2011-01-28 Thread Marco@worldcorp
Hi all
 i am starting to learn protobuffers so that i can use them alongside
Netty

I have created this simple .proto file

package tutorial;

option java_package = com.example.messages;
option java_outer_classname = MessageProtos;

message Message {
  required string content = 1;

  enum MessageType {
TEST = 0;
DEBUG = 1;
DO_TASK = 2;
  }
  required MessageType type = 2;
}

THis has generated a class with two methods that Errors out due to
'Cannot dereference boolean'

public static com.example.messages.MessageProtos.Message
parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
  return newBuilder().mergeDelimitedFrom(input).buildParsed();
}
public static com.example.messages.MessageProtos.Message
parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
  return newBuilder().mergeDelimitedFrom(input, extensionRegistry)
   .buildParsed();
}

could anyone tell me what have i done wrong in my .proto file?

thanks and regards
 marco




-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] inheritance.. well sort of... and FieldDescriptors

2011-01-28 Thread TJ Rothwell
Is there a best practice for this use case?

Here are some options.

// Duplicate every field (sounds like you're doing this)
message FooRequest {
  required string prompt = 1;
  required int64 timeout = 2;
  required Foo foo = 3;
}

message BarRequest {
  required string prompt = 1;
  required int64 timeout = 2;
  required Bar bar = 3;
}

// Client code--something like this anyway
Foo foo = Foo.newBuilder().build();
FooRequest fooRequest = FooRequest.newBuilder().setPrompt().setTimeout(0).
setFoo(foo).build();
Bar bar = Bar.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().setPrompt().setTimeout(0).
setBar(bar).build();

// Share a base message and extend it
message BaseRequest {
  required string prompt = 1;
  required int64 timeout = 2;
  extensions 1000 to max; // reserved for extensions
}
message BazRequest {
  extends BaseRequest {
optional BazRequest baz = 1000;
  }
  required Baz baz = 1;
}

// Client Code
Baz baz = Baz.newBuilder().build();
BazRequest bazRequest = BazRequest.newBuilder().setBaz(baz).build();
BaseRequest request =
BaseRequest.newBuilder().setPrompt().setTimeout(0).setExtension(BazRequest.baz,
bazRequest).build();
// so given a BaseRequest, how do we know if it's is a Baz or something
else? -- lots of hasExtension() calls? that doesn't sound good and you have
to keep track of an ExtensionRegistry if you're using a generic
Reader/Writer.
// baz is a base? not so much
// baz has a base? sounds right
// this approach doesn't seem right

// Composition
message CommonRequest {
  required string prompt = 1;
  required int64 timeout = 2;
}
message QuxRequest {
  required CommonRequest common = 1;
  required Qux qux = 2;
}

// Client Code
Qux baz = Qux.newBuilder().build();
CommonRequest.Builder crb =
CommonRequest.newBuilder().setPrompt().setTimeout(0);
QuxRequest bazRequest
= QuxRequest.newBuilder().setCommon(crb).setQux(qux).build();
// the challenge here would be determining how the common message is
defined. If you have dozens of requests that match on some fields here, some
there... it may get complicated.

YMMV,
-- TJ


On Fri, Jan 28, 2011 at 12:59 PM, koert koertkuip...@gmail.com wrote:

 i have several proto message definitions that all share the first 4
 fields. its as if they are all subclasses of one protobuf message
 format.
 in java can i create the FieldDescriptors for these 4 fields once and
 use them for the getters and setters of all these message classes? it
 would save me a lot in terms of logic and maybe also lead to somewhat
 bettter performance.
 best koert

 --
 You received this message because you are subscribed to the Google Groups
 Protocol Buffers group.
 To post to this group, send email to protobuf@googlegroups.com.
 To unsubscribe from this group, send email to
 protobuf+unsubscr...@googlegroups.comprotobuf%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/protobuf?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.