Re: [protobuf] Re: FileDescriptorSet mania

2010-07-27 Thread Kenton Varda
On Mon, Jul 26, 2010 at 2:09 PM, yy  wrote:
>
>   DynamicMessage thisthing= DynamicMessage.parseFrom(
> myDescriptorProto.getDescriptorForType(),  inputM);
> thisthing.writeTo(System.out);
>

This writes raw binary to System.out.  Use
System.out.print(thisthing.toString()); or something like that.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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] Re: FileDescriptorSet mania

2010-07-21 Thread Mark
Kenton Varda  google.com> writes:

> 
> 
> On Tue, Jul 20, 2010 at 1:21 PM, Mark  yahoo.com> wrote:
> 
> 
> 
> Hi,
> 
> Using the latest release of PB, I am able to generate the FileDescriptorSet
> using protoc. my intent is to be able to parse incoming messages using the
> DynamicMessage class.  my understanding is that from the FileDescriptorSet, I
> can generate FileDescriptorProto, from which I get FileDescriptor, which I use
> with dynamic message. Is that right? Also, do you have any sample code that
> shows how to do this?
> 
> 
> Yes, that's correct.  What part isn't working?
> 
> 
> 
> 

ken,

i wanted to hear it from you that it is correct, as i am looking to convince 
others that it's possible.  i was looking for some sample code that does the 
above, in case it exists.  if not, i have already started coding it in Java. 

thanks again.


-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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] Re: FileDescriptorSet mania

2010-07-20 Thread Kenton Varda
On Tue, Jul 20, 2010 at 1:21 PM, Mark  wrote:

> Hi,
>
> Using the latest release of PB, I am able to generate the FileDescriptorSet
> using protoc. my intent is to be able to parse incoming messages using the
> DynamicMessage class.  my understanding is that from the FileDescriptorSet,
> I
> can generate FileDescriptorProto, from which I get FileDescriptor, which I
> use
> with dynamic message. Is that right? Also, do you have any sample code that
> shows how to do this?
>

Yes, that's correct.  What part isn't working?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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] Re: FileDescriptorSet mania

2010-07-20 Thread Mark

Kenton Varda  google.com> writes:

> 
> 
> I'd be open to a class like:
> 
> class DescriptorSetBuilder {
>   // Adds the file and all its dependencies, if they have not been added 
already.
>   // Returns this.
>   public DescriptorSetBuilder add(FileDescriptor file);
> 
> 
>   // Returns a FileDescriptorSet containing all files added with add() and
>   // their dependencies.  Files will be in topological order -- each file will
>   // appear before any files that import it.
> 
>   public FileDescriptorSet build();
> }
> 
> This way it's easy to build a set containing multiple independent files.  The 
next version of protoc will also output FileDescriptorSets in topological 
order, 
as a side effect of the plugins change I'm working on.On Sun, Nov 29, 2009 at 
12:57 AM, Christopher Smith  gmail.com> wrote:
> 
> Given that there is no Java version of protoc, it has been tempting to see 
> how 
far one can get with just using FileDescriptorSet's and dynamic messages. I 
ended up building this short function for iteratively adding all the 
dependencies of a particular Message in to a FileDescriptorSet. While it wasn't 
too much pain, it was a tad annoying, and I am wondering why this kind of 
functionality isn't built in to the Java API. Here's what I ended up with:    
/**     * Get the entire descriptor set needed to describe a message in     * 
dependency order.     *     *   param aMessage the message to inspect     * 
 
 return a complete descriptor set containing all the elements needed to 
parse this message
> 
> 
> 
>      */    static FileDescriptorSet getDescriptorSetFor(final Message 
aMessage) {        final FileDescriptor file = 
aMessage.getDescriptorForType().getFile();        final List 
fileDescriptors = new ArrayList();
> 
> 
> 
>         fileDescriptors.add(file);        //Don't use an iter as we intend to 
keep looping until the list        //stops growing        for (int i = 0; i < 
fileDescriptors.size(); ++i) {            final FileDescriptor nextElement = 
fileDescriptors.get(i);
> 
> 
> 
>             for (FileDescriptor dependency : nextElement.getDependencies()) 
{                if (!fileDescriptors.contains(dependency)) {                   
 
fileDescriptors.add(dependency);                }
> 
> 
> 
>             }        }        final FileDescriptorSet.Builder builder = 
FileDescriptorSet.newBuilder();        for (FileDescriptor descriptor : 
fileDescriptors) {            builder.addFile(descriptor.toProto());
> 
> 
> 
>         }        return builder.build();    }Is this really the right way to 
handle this, and if so, any chance we can get this built in to the protobuf 
library?-- Chris
> 
> 
> 
> --
> 
> 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+unsubscribe  
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+unsubscribe  
googlegroups.com.
> 
> For more options, visit this group at http://groups.google.com/group/protobuf?
hl=en.
> 


http://groups.google.com/group/protobuf?hl=en.


Hi,

Using the latest release of PB, I am able to generate the FileDescriptorSet 
using protoc. my intent is to be able to parse incoming messages using the 
DynamicMessage class.  my understanding is that from the FileDescriptorSet, I 
can generate FileDescriptorProto, from which I get FileDescriptor, which I use 
with dynamic message. Is that right? Also, do you have any sample code that 
shows how to do this?

thank you




-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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.