blob: 6133df402ad559a4f2c06836a675e37c4bfc88f2 [file] [log] [blame]
// Copyright 2007 Google Inc. All rights reserved.
// Author: kenton@google.com (Kenton Varda)
//
// This is proto2's version of MessageSet. See net/proto/message_set.h to
// learn what MessageSets are and how they are used.
//
// In proto2, we implement MessageSet in terms of extensions, except with a
// special wire format for backwards-compatibily. To define a message that
// goes in a MessageSet in proto2, you must declare within that message's
// scope an extension of MessageSet named "message_set_extension" and with
// the field number matching the type ID. So, for example, this proto1 code:
// message Foo {
// enum TypeId { MESSAGE_TYPE_ID = 1234; }
// }
// becomes this proto2 code:
// message Foo {
// extend proto2.bridge.MessageSet {
// optional Foo message_set_extension = 1234;
// }
// }
//
// Now you can use the usual proto2 extensions accessors to access this
// message. For example, the proto1 code:
// MessageSet mset;
// Foo* foo = mset.get_mutable<Foo>();
// becomes this proto2 code:
// proto2::bridge::MessageSet mset;
// Foo* foo = mset.MutableExtension(Foo::message_set_extension);
//
// Of course, new code that doesn't have backwards-compatibility requirements
// should just use extensions themselves and not worry about MessageSet.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package proto2.bridge;
option java_outer_classname = "MessageSetProtos";
option java_multiple_files = true;
message MessageSet {
option message_set_wire_format = true;
extensions 4 to max;
}