aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/extension_set.h
diff options
context:
space:
mode:
authortemporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-08-13 03:15:00 +0000
committertemporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-08-13 03:15:00 +0000
commit779f61c6a3ce02a119e28e802f229e61b69b9046 (patch)
tree9131ef5f0acdc3d708a795fc6703488674741ee0 /src/google/protobuf/extension_set.h
parenta0f27fcd96c5bf2509ca88cca54f00b78f7b8bc5 (diff)
downloadprotobuf-779f61c6a3ce02a119e28e802f229e61b69b9046.tar.gz
protobuf-779f61c6a3ce02a119e28e802f229e61b69b9046.tar.bz2
protobuf-779f61c6a3ce02a119e28e802f229e61b69b9046.zip
Integrate recent changes from google3.
protoc - New flags --encode and --decode can be used to convert between protobuf text format and binary format from the command-line. - New flag --descriptor_set_out can be used to write FileDescriptorProtos for all parsed files directly into a single output file. This is particularly useful if you wish to parse .proto files from programs written in languages other than C++: just run protoc as a background process and have it output a FileDescriptorList, then parse that natively. C++ - Reflection objects are now per-class rather than per-instance. To make this possible, the Reflection interface had to be changed such that all methods take the Message instance as a parameter. This change improves performance significantly in memory-bandwidth-limited use cases, since it makes the message objects smaller. Note that source-incompatible interface changes like this will not be made again after the library leaves beta. Python - MergeFrom(message) and CopyFrom(message) are now implemented. - SerializeToString() raises an exception if the message is missing required fields. - Code organization improvements. - Fixed doc comments for RpcController and RpcChannel, which had somehow been swapped.
Diffstat (limited to 'src/google/protobuf/extension_set.h')
-rw-r--r--src/google/protobuf/extension_set.h35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h
index 902ec736..c8e124f8 100644
--- a/src/google/protobuf/extension_set.h
+++ b/src/google/protobuf/extension_set.h
@@ -64,26 +64,28 @@ namespace internal {
class LIBPROTOBUF_EXPORT ExtensionSet {
public:
// Construct an ExtensionSet.
- // extendee: Descriptor for the type being extended.
+ // extendee: Descriptor for the type being extended. We pass in a pointer
+ // to a pointer to the extendee to get around an initialization
+ // problem: when we create the ExtensionSet for a message type,
+ // its descriptor may not exist yet. But we know where that
+ // descriptor pointer will be placed, and by the time it's used
+ // by this ExtensionSet it will be fully initialized, so passing
+ // a pointer to that location works. Note that this problem
+ // will only occur for messages defined in descriptor.proto.
// pool: DescriptorPool to search for extension definitions.
// factory: MessageFactory used to construct implementations of messages
// for extensions with message type. This factory must be able
// to construct any message type found in "pool".
// All three objects remain property of the caller and must outlive the
// ExtensionSet.
- ExtensionSet(const Descriptor* extendee,
+ ExtensionSet(const Descriptor* const* extendee,
const DescriptorPool* pool,
MessageFactory* factory);
~ExtensionSet();
- // Search for a known (compiled-in) extension of this type by name or number.
- // Returns NULL if no extension is known.
- const FieldDescriptor* FindKnownExtensionByName(const string& name) const;
- const FieldDescriptor* FindKnownExtensionByNumber(int number) const;
-
// Add all fields which are currently present to the given vector. This
- // is useful to implement Message::Reflection::ListFields().
+ // is useful to implement Reflection::ListFields().
void AppendToList(vector<const FieldDescriptor*>* output) const;
// =================================================================
@@ -110,7 +112,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
// die on an assert failure. The message objects returned by the message
// accessors are guaranteed to be of the correct linked-in type.
//
- // These methods pretty much match Message::Reflection except that:
+ // These methods pretty much match Reflection except that:
// - They're not virtual.
// - They identify fields by number rather than FieldDescriptors.
// - They identify enum values using integers rather than descriptors.
@@ -196,7 +198,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
bool IsInitialized() const;
// These parsing and serialization functions all want a pointer to the
- // reflection interface because they hand off the actual work to WireFormat,
+ // message object because they hand off the actual work to WireFormat,
// which works in terms of a reflection interface. Yes, this means there
// are some redundant virtual function calls that end up being made, but
// it probably doesn't matter much in practice, and the alternative would
@@ -204,8 +206,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
// Parses a single extension from the input. The input should start out
// positioned immediately after the tag.
- bool ParseField(uint32 tag, io::CodedInputStream* input,
- Message::Reflection* reflection);
+ bool ParseField(uint32 tag, io::CodedInputStream* input, Message* message);
// Write all extension fields with field numbers in the range
// [start_field_number, end_field_number)
@@ -213,11 +214,11 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
// last called. Note that the range bounds are inclusive-exclusive.
bool SerializeWithCachedSizes(int start_field_number,
int end_field_number,
- const Message::Reflection* reflection,
+ const Message& message,
io::CodedOutputStream* output) const;
// Returns the total serialized size of all the extensions.
- int ByteSize(const Message::Reflection* reflection) const;
+ int ByteSize(const Message& message) const;
private:
// Like FindKnownExtension(), but GOOGLE_CHECK-fail if not found.
@@ -265,9 +266,9 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
// Some helper methods for operations on a single Extension.
bool SerializeFieldWithCachedSizes(
- const Message::Reflection* reflection,
+ const Message& message,
io::CodedOutputStream* output) const;
- int64 ByteSize(const Message::Reflection* reflection) const;
+ int64 ByteSize(const Message& message) const;
void Clear();
int GetSize() const;
void Free();
@@ -280,7 +281,7 @@ class LIBPROTOBUF_EXPORT ExtensionSet {
// for 100 elements or more. Also, we want AppendToList() to order fields
// by field number.
map<int, Extension> extensions_;
- const Descriptor* extendee_;
+ const Descriptor* const* extendee_;
const DescriptorPool* descriptor_pool_;
MessageFactory* message_factory_;