Skip to content

Commit

Permalink
Add required #imports and forward declarations for "independent" builds.
Browse files Browse the repository at this point in the history
This allows me to just import this library directly into my project to avoid
complicated build steps.

Signed-off-by: Jon Parise <[email protected]>
  • Loading branch information
Evan Jones authored and Jon Parise committed Dec 6, 2011
1 parent 7764bd4 commit d088378
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 1 deletion.
Binary file added src/compiler/.libs/protoc-gen-objc
Binary file not shown.
1 change: 1 addition & 0 deletions src/runtime/Classes/AbstractMessage_Builder.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#import "CodedInputStream.h"
#import "ExtensionRegistry.h"
#import "Message_Builder.h"
#import "UnknownFieldSet.h"
#import "UnknownFieldSet_Builder.h"

Expand Down
8 changes: 8 additions & 0 deletions src/runtime/Classes/ConcreteExtensionField.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

#import "ConcreteExtensionField.h"

#import "AbstractMessage.h"
#import "CodedInputStream.h"
#import "CodedOutputStream.h"
#import "ExtendableMessage_Builder.h"
#import "Message_Builder.h"
#import "Utilities.h"
#import "WireFormat.h"

@interface PBConcreteExtensionField()
@property PBExtensionType type;
@property (assign) Class extendedClass;
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/Classes/ExtendableMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#import "GeneratedMessage.h"

#import "ExtensionField.h"

/**
* Generated message classes for message types that contain extension ranges
* subclass this.
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/Classes/ExtendableMessage_Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#import "GeneratedMessage_Builder.h"

#import "ExtensionField.h"

@class PBExtendableMessage;

/**
* Generated message builders for message types that contain extension ranges
* subclass this.
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Classes/ExtendableMessage_Builder.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#import "ExtendableMessage_Builder.h"

#import "ExtendableMessage.h"
#import "ExtensionField.h"
#import "ExtensionRegistry.h"
#import "WireFormat.h"

@implementation PBExtendableMessage_Builder
Expand Down
6 changes: 6 additions & 0 deletions src/runtime/Classes/ExtensionField.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

#import "WireFormat.h"

@class PBCodedInputStream;
@class PBCodedOutputStream;
@class PBExtendableMessage_Builder;
@class PBExtensionRegistry;
@class PBUnknownFieldSet_Builder;

@protocol PBExtensionField
- (int32_t) fieldNumber;
- (PBWireFormat) wireType;
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/Classes/ExtensionRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
*
* @author Cyrus Najmabadi
*/

#import "ExtensionField.h"

@interface PBExtensionRegistry : NSObject {
@protected
NSDictionary* classMap;
Expand Down
1 change: 1 addition & 0 deletions src/runtime/Classes/Field.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

@class PBArray;
@class PBAppendableArray;
@class PBCodedOutputStream;

@interface PBField : NSObject
{
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/Classes/Field.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#import "CodedOutputStream.h"
#import "PBArray.h"
#import "UnknownFieldSet.h"
#import "Utilities.h"

@implementation PBField

Expand Down
2 changes: 2 additions & 0 deletions src/runtime/Classes/GeneratedMessage_Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#import "AbstractMessage_Builder.h"

@class PBUnknownFieldSet_Builder;

@interface PBGeneratedMessage_Builder : PBAbstractMessage_Builder {
}

Expand Down
9 changes: 9 additions & 0 deletions src/runtime/Classes/Message_Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/NSObject.h>

#import "Message.h"

#import "Message.h"

@class PBCodedInputStream;
@class PBExtensionRegistry;

/**
* Abstract interface implemented by Protocol Message builders.
*/
Expand Down
135 changes: 135 additions & 0 deletions src/runtime/Classes/Message_Builder.h.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Protocol Buffers for Objective C
//
// Copyright 2010 Booyah Inc.
// Copyright 2008 Cyrus Najmabadi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/NSObject.h>

#import "Message.h"

/**
* Abstract interface implemented by Protocol Message builders.
*/
@protocol PBMessage_Builder<NSObject>
/** Resets all fields to their default values. */
- (id<PBMessage_Builder>) clear;

/**
* Construct the final message. Once this is called, the Builder is no
* longer valid, and calling any other method may throw a
* NullPointerException. If you need to continue working with the builder
* after calling {@code build()}, {@code clone()} it first.
* @throws UninitializedMessageException The message is missing one or more
* required fields (i.e. {@link #isInitialized()} returns false).
* Use {@link #buildPartial()} to bypass this check.
*/
- (id<PBMessage>) build;

/**
* Like {@link #build()}, but does not throw an exception if the message
* is missing required fields. Instead, a partial message is returned.
*/
- (id<PBMessage>) buildPartial;
- (id<PBMessage_Builder>) clone;

/**
* Returns true if all required fields in the message and all embedded
* messages are set, false otherwise.
*/
- (BOOL) isInitialized;

/**
* Get the message's type's default instance.
* See {@link Message#getDefaultInstanceForType()}.
*/
- (id<PBMessage>) defaultInstance;

- (PBUnknownFieldSet*) unknownFields;
- (id<PBMessage_Builder>) setUnknownFields:(PBUnknownFieldSet*) unknownFields;

/**
* Merge some unknown fields into the {@link UnknownFieldSet} for this
* message.
*/
- (id<PBMessage_Builder>) mergeUnknownFields:(PBUnknownFieldSet*) unknownFields;

/**
* Parses a message of this type from the input and merges it with this
* message, as if using {@link Builder#mergeFrom(Message)}.
*
* <p>Warning: This does not verify that all required fields are present in
* the input message. If you call {@link #build()} without setting all
* required fields, it will throw an {@link UninitializedMessageException},
* which is a {@code RuntimeException} and thus might not be caught. There
* are a few good ways to deal with this:
* <ul>
* <li>Call {@link #isInitialized()} to verify that all required fields
* are set before building.
* <li>Parse the message separately using one of the static
* {@code parseFrom} methods, then use {@link #mergeFrom(Message)}
* to merge it with this one. {@code parseFrom} will throw an
* {@link InvalidProtocolBufferException} (an {@code IOException})
* if some required fields are missing.
* <li>Use {@code buildPartial()} to build, which ignores missing
* required fields.
* </ul>
*
* <p>Note: The caller should call
* {@link CodedInputStream#checkLastTagWas(int)} after calling this to
* verify that the last tag seen was the appropriate end-group tag,
* or zero for EOF.
*/
- (id<PBMessage_Builder>) mergeFromCodedInputStream:(PBCodedInputStream*) input;

/**
* Like {@link Builder#mergeFrom(CodedInputStream)}, but also
* parses extensions. The extensions that you want to be able to parse
* must be registered in {@code extensionRegistry}. Extensions not in
* the registry will be treated as unknown fields.
*/
- (id<PBMessage_Builder>) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;

/**
* Parse {@code data} as a message of this type and merge it with the
* message being built. This is just a small wrapper around
* {@link #mergeFrom(CodedInputStream)}.
*/
- (id<PBMessage_Builder>) mergeFromData:(NSData*) data;

/**
* Parse {@code data} as a message of this type and merge it with the
* message being built. This is just a small wrapper around
* {@link #mergeFrom(CodedInputStream,ExtensionRegistry)}.
*/
- (id<PBMessage_Builder>) mergeFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;

/**
* Parse a message of this type from {@code input} and merge it with the
* message being built. This is just a small wrapper around
* {@link #mergeFrom(CodedInputStream)}. Note that this method always
* reads the <i>entire</i> input (unless it throws an exception). If you
* want it to stop earlier, you will need to wrap your input in some
* wrapper stream that limits reading. Despite usually reading the entire
* input, this does not close the stream.
*/
- (id<PBMessage_Builder>) mergeFromInputStream:(NSInputStream*) input;

/**
* Parse a message of this type from {@code input} and merge it with the
* message being built. This is just a small wrapper around
* {@link #mergeFrom(CodedInputStream,ExtensionRegistry)}.
*/
- (id<PBMessage_Builder>) mergeFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
2 changes: 2 additions & 0 deletions src/runtime/Classes/MutableField.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#import "Field.h"

@class PBUnknownFieldSet;

@interface PBMutableField : PBField

+ (PBMutableField *)field;
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/Classes/UnknownFieldSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

@class PBCodedOutputStream;
@class PBField;
@class PBUnknownFieldSet_Builder;

@interface PBUnknownFieldSet : NSObject {
@private
NSDictionary* fields;
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/Classes/UnknownFieldSet_Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

#import "Message_Builder.h"

@class PBField;
@class PBMutableField;

@interface PBUnknownFieldSet_Builder : NSObject <PBMessage_Builder> {
@private
NSMutableDictionary* fields;
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/Classes/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import "Message.h"

int64_t convertFloat64ToInt64(Float64 f);
int32_t convertFloat32ToInt32(Float32 f);
Float64 convertInt64ToFloat64(int64_t f);
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/Classes/Utilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// limitations under the License.

#import "Utilities.h"

#import "UnknownFieldSet.h"
#import "WireFormat.h"

const int32_t LITTLE_ENDIAN_32_SIZE = 4;
Expand Down

0 comments on commit d088378

Please sign in to comment.