Skip to content

Commit

Permalink
Support the PBMessage_Builder protocol.
Browse files Browse the repository at this point in the history
PBUnknownFieldSet_Builder needs to conform to the PBMessage_Builder
protocol in order for it to be used in all of the places expecting
id<PBMessage_Builder> values.

The protocol itself is pretty heavy, and some of the methods could be
made @optional, but for now we just raise exceptions for unsupported
calls (which is consistent with the rest of the runtime library).

This fixes the Apple LLVM compiler 3.0 warnings reported in booyah#16.
  • Loading branch information
Jon Parise committed Nov 15, 2011
1 parent 12293e0 commit 7764bd4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/runtime/Classes/UnknownFieldSet_Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

@interface PBUnknownFieldSet_Builder : NSObject {
#import "Message_Builder.h"

@interface PBUnknownFieldSet_Builder : NSObject <PBMessage_Builder> {
@private
NSMutableDictionary* fields;

Expand Down
39 changes: 38 additions & 1 deletion src/runtime/Classes/UnknownFieldSet_Builder.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,29 @@ - (PBUnknownFieldSet*) build {
return result;
}

- (PBUnknownFieldSet*) buildPartial {
@throw [NSException exceptionWithName:@"UnsupportedMethod" reason:@"" userInfo:nil];
}

- (PBUnknownFieldSet*) clone {
@throw [NSException exceptionWithName:@"UnsupportedMethod" reason:@"" userInfo:nil];
}

- (BOOL) isInitialized {
return YES;
}

- (PBUnknownFieldSet*) defaultInstance {
@throw [NSException exceptionWithName:@"UnsupportedMethod" reason:@"" userInfo:nil];
}

- (PBUnknownFieldSet*) unknownFields {
return [self build];
}

- (id<PBMessage_Builder>) setUnknownFields:(PBUnknownFieldSet*) unknownFields {
@throw [NSException exceptionWithName:@"UnsupportedMethod" reason:@"" userInfo:nil];
}

/** Check if the given field number is present in the set. */
- (BOOL) hasField:(int32_t) number {
Expand Down Expand Up @@ -168,10 +191,21 @@ - (PBUnknownFieldSet_Builder*) mergeFromData:(NSData*) data {
}


- (PBUnknownFieldSet_Builder*) mergeFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
PBCodedInputStream* input = [PBCodedInputStream streamWithData:data];
[self mergeFromCodedInputStream:input extensionRegistry:extensionRegistry];
[input checkLastTagWas:0];
return self;
}


- (PBUnknownFieldSet_Builder*) mergeFromInputStream:(NSInputStream*) input {
@throw [NSException exceptionWithName:@"" reason:@"" userInfo:nil];
@throw [NSException exceptionWithName:@"UnsupportedMethod" reason:@"" userInfo:nil];
}

- (PBUnknownFieldSet_Builder*) mergeFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
@throw [NSException exceptionWithName:@"UnsupportedMethod" reason:@"" userInfo:nil];
}

- (PBUnknownFieldSet_Builder*) mergeVarintField:(int32_t) number value:(int32_t) value {
if (number == 0) {
Expand Down Expand Up @@ -231,6 +265,9 @@ - (PBUnknownFieldSet_Builder*) mergeFromCodedInputStream:(PBCodedInputStream*) i
return self;
}

- (PBUnknownFieldSet_Builder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
@throw [NSException exceptionWithName:@"UnsupportedMethod" reason:@"" userInfo:nil];
}

- (PBUnknownFieldSet_Builder*) clear {
self.fields = [NSMutableDictionary dictionary];
Expand Down

0 comments on commit 7764bd4

Please sign in to comment.