diff options
Diffstat (limited to 'objectivec')
-rw-r--r-- | objectivec/GPBCodedInputStream.h | 21 | ||||
-rw-r--r-- | objectivec/GPBCodedInputStream.m | 8 | ||||
-rw-r--r-- | objectivec/GPBMessage.h | 11 | ||||
-rw-r--r-- | objectivec/README.md | 2 |
4 files changed, 40 insertions, 2 deletions
diff --git a/objectivec/GPBCodedInputStream.h b/objectivec/GPBCodedInputStream.h index de27b186..fbe5009c 100644 --- a/objectivec/GPBCodedInputStream.h +++ b/objectivec/GPBCodedInputStream.h @@ -218,6 +218,27 @@ CF_EXTERN_C_END - (size_t)position; /** + * Moves the limit to the given byte offset starting at the current location. + * + * @exception GPBCodedInputStreamException If the requested bytes exceeed the + * current limit. + * + * @param byteLimit The number of bytes to move the limit, offset to the current + * location. + * + * @return The limit offset before moving the new limit. + */ +- (size_t)pushLimit:(size_t)byteLimit; + +/** + * Moves the limit back to the offset as it was before calling pushLimit:. + * + * @param oldLimit The number of bytes to move the current limit. Usually this + * is the value returned by the pushLimit: method. + */ +- (void)popLimit:(size_t)oldLimit; + +/** * Verifies that the last call to -readTag returned the given tag value. This * is used to verify that a nested group ended with the correct end tag. * diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m index 2b578dd5..e8c8989c 100644 --- a/objectivec/GPBCodedInputStream.m +++ b/objectivec/GPBCodedInputStream.m @@ -400,6 +400,14 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, return state_.bufferPos; } +- (size_t)pushLimit:(size_t)byteLimit { + return GPBCodedInputStreamPushLimit(&state_, byteLimit); +} + +- (void)popLimit:(size_t)oldLimit { + GPBCodedInputStreamPopLimit(&state_, oldLimit); +} + - (double)readDouble { return GPBCodedInputStreamReadDouble(&state_); } diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h index 0cb74f9f..c07ec888 100644 --- a/objectivec/GPBMessage.h +++ b/objectivec/GPBMessage.h @@ -65,9 +65,18 @@ CF_EXTERN_C_END /** * Base class that each generated message subclasses from. + * + * @note While the class support NSSecureCoding, if the message has any + * extensions, they will end up reloaded in @c unknownFields as there is + * no way for the @c NSCoding plumbing to pass through a + * @c GPBExtensionRegistry. To support extensions, instead of passing the + * calls off to the Message, simple store the result of @c data, and then + * when loading, fetch the data and use + * @c +parseFromData:extensionRegistry:error: to provide an extension + * registry. **/ @interface GPBMessage : NSObject<NSSecureCoding, NSCopying> - + // If you add an instance method/property to this class that may conflict with // fields declared in protos, you need to update objective_helpers.cc. The main // cases are methods that take no arguments, or setFoo:/hasFoo: type methods. diff --git a/objectivec/README.md b/objectivec/README.md index 06118349..7226f0b9 100644 --- a/objectivec/README.md +++ b/objectivec/README.md @@ -44,7 +44,7 @@ Add `objectivec/\*.h` & `objectivec/\*.m` except for If the target is using ARC, remember to turn off ARC (`-fno-objc-arc`) for the `.m` files. -The files generated by `protoc` for the `*.proto` files (`\*.pbobjc.h' and +The files generated by `protoc` for the `*.proto` files (`\*.pbobjc.h` and `\*.pbobjc.m`) are then also added to the target. Usage |