Commit 274a200b authored by Chengzhao Li's avatar Chengzhao Li
Browse files

- add protocol buffer

parent b5b3537d
......@@ -85,6 +85,8 @@
9B2A23611D2428E800C6EEC5 /* ChatRoomScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B2A23601D2428E800C6EEC5 /* ChatRoomScene.m */; };
9B2A23621D2428E800C6EEC5 /* ChatRoomScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B2A23601D2428E800C6EEC5 /* ChatRoomScene.m */; };
9B2A23631D2428E800C6EEC5 /* ChatRoomScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B2A23601D2428E800C6EEC5 /* ChatRoomScene.m */; };
9B3EC30B1D525C0500EF4C0E /* GPBProtocolBuffers.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3EC2EF1D525C0500EF4C0E /* GPBProtocolBuffers.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
9B3EC30E1D525C2C00EF4C0E /* Messages.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3EC30C1D525C2C00EF4C0E /* Messages.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
9B6B1ED11D18944F0008B45D /* LoginScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6B1ED01D18944F0008B45D /* LoginScene.m */; };
9B6B1ED21D18944F0008B45D /* LoginScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6B1ED01D18944F0008B45D /* LoginScene.m */; };
9B6B1ED31D18944F0008B45D /* LoginScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6B1ED01D18944F0008B45D /* LoginScene.m */; };
......@@ -228,6 +230,36 @@
9B28F0251D219148008B35B3 /* NCMCAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NCMCAlertView.m; path = Source/NCMCAlertView.m; sourceTree = "<group>"; };
9B2A235F1D2428E800C6EEC5 /* ChatRoomScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChatRoomScene.h; path = Source/ChatRoomScene.h; sourceTree = "<group>"; };
9B2A23601D2428E800C6EEC5 /* ChatRoomScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ChatRoomScene.m; path = Source/ChatRoomScene.m; sourceTree = "<group>"; };
9B3EC2EF1D525C0500EF4C0E /* GPBProtocolBuffers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPBProtocolBuffers.m; path = Source/message/protobuf/GPBProtocolBuffers.m; sourceTree = "<group>"; };
9B3EC2F01D525C0500EF4C0E /* GPBArray_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBArray_PackagePrivate.h; path = Source/message/protobuf/GPBArray_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC2F11D525C0500EF4C0E /* GPBArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBArray.h; path = Source/message/protobuf/GPBArray.h; sourceTree = "<group>"; };
9B3EC2F21D525C0500EF4C0E /* GPBBootstrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBBootstrap.h; path = Source/message/protobuf/GPBBootstrap.h; sourceTree = "<group>"; };
9B3EC2F31D525C0500EF4C0E /* GPBCodedInputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBCodedInputStream_PackagePrivate.h; path = Source/message/protobuf/GPBCodedInputStream_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC2F41D525C0500EF4C0E /* GPBCodedInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBCodedInputStream.h; path = Source/message/protobuf/GPBCodedInputStream.h; sourceTree = "<group>"; };
9B3EC2F51D525C0500EF4C0E /* GPBCodedOutputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBCodedOutputStream.h; path = Source/message/protobuf/GPBCodedOutputStream.h; sourceTree = "<group>"; };
9B3EC2F61D525C0500EF4C0E /* GPBDescriptor_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBDescriptor_PackagePrivate.h; path = Source/message/protobuf/GPBDescriptor_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC2F71D525C0500EF4C0E /* GPBDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBDescriptor.h; path = Source/message/protobuf/GPBDescriptor.h; sourceTree = "<group>"; };
9B3EC2F81D525C0500EF4C0E /* GPBDictionary_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBDictionary_PackagePrivate.h; path = Source/message/protobuf/GPBDictionary_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC2F91D525C0500EF4C0E /* GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBDictionary.h; path = Source/message/protobuf/GPBDictionary.h; sourceTree = "<group>"; };
9B3EC2FA1D525C0500EF4C0E /* GPBExtensionInternals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBExtensionInternals.h; path = Source/message/protobuf/GPBExtensionInternals.h; sourceTree = "<group>"; };
9B3EC2FB1D525C0500EF4C0E /* GPBExtensionRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBExtensionRegistry.h; path = Source/message/protobuf/GPBExtensionRegistry.h; sourceTree = "<group>"; };
9B3EC2FC1D525C0500EF4C0E /* GPBMessage_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBMessage_PackagePrivate.h; path = Source/message/protobuf/GPBMessage_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC2FD1D525C0500EF4C0E /* GPBMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBMessage.h; path = Source/message/protobuf/GPBMessage.h; sourceTree = "<group>"; };
9B3EC2FE1D525C0500EF4C0E /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBProtocolBuffers_RuntimeSupport.h; path = Source/message/protobuf/GPBProtocolBuffers_RuntimeSupport.h; sourceTree = "<group>"; };
9B3EC2FF1D525C0500EF4C0E /* GPBProtocolBuffers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBProtocolBuffers.h; path = Source/message/protobuf/GPBProtocolBuffers.h; sourceTree = "<group>"; };
9B3EC3001D525C0500EF4C0E /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBRootObject_PackagePrivate.h; path = Source/message/protobuf/GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC3011D525C0500EF4C0E /* GPBRootObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBRootObject.h; path = Source/message/protobuf/GPBRootObject.h; sourceTree = "<group>"; };
9B3EC3021D525C0500EF4C0E /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBRuntimeTypes.h; path = Source/message/protobuf/GPBRuntimeTypes.h; sourceTree = "<group>"; };
9B3EC3031D525C0500EF4C0E /* GPBUnknownField_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBUnknownField_PackagePrivate.h; path = Source/message/protobuf/GPBUnknownField_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC3041D525C0500EF4C0E /* GPBUnknownField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBUnknownField.h; path = Source/message/protobuf/GPBUnknownField.h; sourceTree = "<group>"; };
9B3EC3051D525C0500EF4C0E /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBUnknownFieldSet_PackagePrivate.h; path = Source/message/protobuf/GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC3061D525C0500EF4C0E /* GPBUnknownFieldSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBUnknownFieldSet.h; path = Source/message/protobuf/GPBUnknownFieldSet.h; sourceTree = "<group>"; };
9B3EC3071D525C0500EF4C0E /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBUtilities_PackagePrivate.h; path = Source/message/protobuf/GPBUtilities_PackagePrivate.h; sourceTree = "<group>"; };
9B3EC3081D525C0500EF4C0E /* GPBUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBUtilities.h; path = Source/message/protobuf/GPBUtilities.h; sourceTree = "<group>"; };
9B3EC3091D525C0500EF4C0E /* GPBWellKnownTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBWellKnownTypes.h; path = Source/message/protobuf/GPBWellKnownTypes.h; sourceTree = "<group>"; };
9B3EC30A1D525C0500EF4C0E /* GPBWireFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPBWireFormat.h; path = Source/message/protobuf/GPBWireFormat.h; sourceTree = "<group>"; };
9B3EC30C1D525C2C00EF4C0E /* Messages.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Messages.pbobjc.m; path = Source/message/build/Messages.pbobjc.m; sourceTree = "<group>"; };
9B3EC30D1D525C2C00EF4C0E /* Messages.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Messages.pbobjc.h; path = Source/message/build/Messages.pbobjc.h; sourceTree = "<group>"; };
9B6B1ECF1D18944F0008B45D /* LoginScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LoginScene.h; path = Source/LoginScene.h; sourceTree = "<group>"; };
9B6B1ED01D18944F0008B45D /* LoginScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LoginScene.m; path = Source/LoginScene.m; sourceTree = "<group>"; };
9B6B1ED41D1895860008B45D /* SettingScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SettingScene.h; path = Source/SettingScene.h; sourceTree = "<group>"; };
......@@ -514,6 +546,51 @@
name = Core;
sourceTree = "<group>";
};
9B3EC2EB1D525B6400EF4C0E /* ProtocolBuffers */ = {
isa = PBXGroup;
children = (
9B3EC2EE1D525B6E00EF4C0E /* protobuf */,
9B3EC30C1D525C2C00EF4C0E /* Messages.pbobjc.m */,
9B3EC30D1D525C2C00EF4C0E /* Messages.pbobjc.h */,
);
name = ProtocolBuffers;
sourceTree = "<group>";
};
9B3EC2EE1D525B6E00EF4C0E /* protobuf */ = {
isa = PBXGroup;
children = (
9B3EC2EF1D525C0500EF4C0E /* GPBProtocolBuffers.m */,
9B3EC2F01D525C0500EF4C0E /* GPBArray_PackagePrivate.h */,
9B3EC2F11D525C0500EF4C0E /* GPBArray.h */,
9B3EC2F21D525C0500EF4C0E /* GPBBootstrap.h */,
9B3EC2F31D525C0500EF4C0E /* GPBCodedInputStream_PackagePrivate.h */,
9B3EC2F41D525C0500EF4C0E /* GPBCodedInputStream.h */,
9B3EC2F51D525C0500EF4C0E /* GPBCodedOutputStream.h */,
9B3EC2F61D525C0500EF4C0E /* GPBDescriptor_PackagePrivate.h */,
9B3EC2F71D525C0500EF4C0E /* GPBDescriptor.h */,
9B3EC2F81D525C0500EF4C0E /* GPBDictionary_PackagePrivate.h */,
9B3EC2F91D525C0500EF4C0E /* GPBDictionary.h */,
9B3EC2FA1D525C0500EF4C0E /* GPBExtensionInternals.h */,
9B3EC2FB1D525C0500EF4C0E /* GPBExtensionRegistry.h */,
9B3EC2FC1D525C0500EF4C0E /* GPBMessage_PackagePrivate.h */,
9B3EC2FD1D525C0500EF4C0E /* GPBMessage.h */,
9B3EC2FE1D525C0500EF4C0E /* GPBProtocolBuffers_RuntimeSupport.h */,
9B3EC2FF1D525C0500EF4C0E /* GPBProtocolBuffers.h */,
9B3EC3001D525C0500EF4C0E /* GPBRootObject_PackagePrivate.h */,
9B3EC3011D525C0500EF4C0E /* GPBRootObject.h */,
9B3EC3021D525C0500EF4C0E /* GPBRuntimeTypes.h */,
9B3EC3031D525C0500EF4C0E /* GPBUnknownField_PackagePrivate.h */,
9B3EC3041D525C0500EF4C0E /* GPBUnknownField.h */,
9B3EC3051D525C0500EF4C0E /* GPBUnknownFieldSet_PackagePrivate.h */,
9B3EC3061D525C0500EF4C0E /* GPBUnknownFieldSet.h */,
9B3EC3071D525C0500EF4C0E /* GPBUtilities_PackagePrivate.h */,
9B3EC3081D525C0500EF4C0E /* GPBUtilities.h */,
9B3EC3091D525C0500EF4C0E /* GPBWellKnownTypes.h */,
9B3EC30A1D525C0500EF4C0E /* GPBWireFormat.h */,
);
name = protobuf;
sourceTree = "<group>";
};
9B6B1EE71D1898DA0008B45D /* Scenes */ = {
isa = PBXGroup;
children = (
......@@ -561,6 +638,7 @@
isa = PBXGroup;
children = (
9B6B1EE41D1898340008B45D /* Parameters.h */,
9B3EC2EB1D525B6400EF4C0E /* ProtocolBuffers */,
D352B48019EC608A00829775 /* MetalShaders */,
7A40362019DDEF0D007B6E8F /* Platforms */,
9B6B1EE71D1898DA0008B45D /* Scenes */,
......@@ -964,10 +1042,12 @@
9B1F83C71D19AEEF00837DA1 /* NCMCPeerID.m in Sources */,
7A046D8C19E8A20E004C4763 /* LobbyScene.m in Sources */,
9B6B1ED11D18944F0008B45D /* LoginScene.m in Sources */,
9B3EC30B1D525C0500EF4C0E /* GPBProtocolBuffers.m in Sources */,
9B1F83C91D19AEEF00837DA1 /* NCMCSession.m in Sources */,
9B1F83CD1D19B5AF00837DA1 /* NCMCBluetoothLEManager.m in Sources */,
9B24307E1D1C849D00F5DFC1 /* NCMCDeviceInfo.m in Sources */,
9B1F83C81D19AEEF00837DA1 /* NCMCPeripheralService.m in Sources */,
9B3EC30E1D525C2C00EF4C0E /* Messages.pbobjc.m in Sources */,
5B121038197487F2004C1E1D /* AppDelegate.m in Sources */,
9B1F83C61D19AEEF00837DA1 /* NCMCCentralService.m in Sources */,
9B6B1ED61D1895860008B45D /* SettingScene.m in Sources */,
......@@ -1282,6 +1362,7 @@
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "Source/Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
USER_HEADER_SEARCH_PATHS = Source/message/protobuf;
WRAPPER_EXTENSION = app;
};
name = Debug;
......@@ -1314,6 +1395,7 @@
PRODUCT_NAME = NCMultipeerConnectivity;
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "Source/Bridging-Header.h";
USER_HEADER_SEARCH_PATHS = Source/message/protobuf;
VALIDATE_PRODUCT = YES;
WRAPPER_EXTENSION = app;
};
......
syntax = "proto3";
package ncmcchat;
message PingMessage {
enum MsgType {
PING = 0;
RESPONSE = 1;
}
uint32 token = 1;
MsgType messageType = 2;
double responseTime = 3;
bool isReliable = 4;
string message = 5;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import "GPBArray.h"
@class GPBMessage;
//%PDDM-DEFINE DECLARE_ARRAY_EXTRAS()
//%ARRAY_INTERFACE_EXTRAS(Int32, int32_t)
//%ARRAY_INTERFACE_EXTRAS(UInt32, uint32_t)
//%ARRAY_INTERFACE_EXTRAS(Int64, int64_t)
//%ARRAY_INTERFACE_EXTRAS(UInt64, uint64_t)
//%ARRAY_INTERFACE_EXTRAS(Float, float)
//%ARRAY_INTERFACE_EXTRAS(Double, double)
//%ARRAY_INTERFACE_EXTRAS(Bool, BOOL)
//%ARRAY_INTERFACE_EXTRAS(Enum, int32_t)
//%PDDM-DEFINE ARRAY_INTERFACE_EXTRAS(NAME, TYPE)
//%#pragma mark - NAME
//%
//%@interface GPB##NAME##Array () {
//% @package
//% GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
//%}
//%@end
//%
//%PDDM-EXPAND DECLARE_ARRAY_EXTRAS()
// This block of code is generated, do not edit it directly.
#pragma mark - Int32
@interface GPBInt32Array () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - UInt32
@interface GPBUInt32Array () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Int64
@interface GPBInt64Array () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - UInt64
@interface GPBUInt64Array () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Float
@interface GPBFloatArray () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Double
@interface GPBDoubleArray () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Bool
@interface GPBBoolArray () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
#pragma mark - Enum
@interface GPBEnumArray () {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
//%PDDM-EXPAND-END DECLARE_ARRAY_EXTRAS()
#pragma mark - NSArray Subclass
@interface GPBAutocreatedArray : NSMutableArray {
@package
GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator;
}
@end
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// The Objective C runtime has complete enough info that most protos don’t end
// up using this, so leaving it on is no cost or very little cost. If you
// happen to see it causing bloat, this is the way to disable it. If you do
// need to disable it, try only disabling it for Release builds as having
// full TextFormat can be useful for debugging.
#ifndef GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
#define GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS 0
#endif
// Most uses of protocol buffers don't need field options, by default the
// static data will be compiled out, define this to 1 to include it. The only
// time you need this is if you are doing introspection of the protocol buffers.
#ifndef GPBOBJC_INCLUDE_FIELD_OPTIONS
#define GPBOBJC_INCLUDE_FIELD_OPTIONS 0
#endif
// Used in the generated code to give sizes to enums. int32_t was chosen based
// on the fact that Protocol Buffers enums are limited to this range.
#if !__has_feature(objc_fixed_enum)
#error All supported Xcode versions should support objc_fixed_enum.
#endif
// If the headers are imported into Objective-C++, we can run into an issue
// where the defintion of NS_ENUM (really CF_ENUM) changes based on the C++
// standard that is in effect. If it isn't C++11 or higher, the definition
// doesn't allow us to forward declare. We work around this one case by
// providing a local definition. The default case has to use NS_ENUM for the
// magic that is Swift bridging of enums.
#if (__cplusplus && __cplusplus < 201103L)
#define GPB_ENUM(X) enum X : int32_t X; enum X : int32_t
#else
#define GPB_ENUM(X) NS_ENUM(int32_t, X)
#endif
// GPB_ENUM_FWD_DECLARE is used for forward declaring enums, ex:
// GPB_ENUM_FWD_DECLARE(Foo_Enum)
// @property (nonatomic) Foo_Enum value;
#define GPB_ENUM_FWD_DECLARE(X) enum X : int32_t
// Based upon CF_INLINE. Forces inlining in release.
#if !defined(DEBUG)
#define GPB_INLINE static __inline__ __attribute__((always_inline))
#else
#define GPB_INLINE static __inline__
#endif
// For use in public headers that might need to deal with ARC.
#ifndef GPB_UNSAFE_UNRETAINED
#if __has_feature(objc_arc)
#define GPB_UNSAFE_UNRETAINED __unsafe_unretained
#else
#define GPB_UNSAFE_UNRETAINED
#endif
#endif
// If property name starts with init we need to annotate it to get past ARC.
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
#define GPB_METHOD_FAMILY_NONE __attribute__((objc_method_family(none)))
// The protoc-gen-objc version which works with the current version of the
// generated Objective C sources. In general we don't want to change the
// runtime interfaces (or this version) as it means everything has to be
// regenerated.
#define GOOGLE_PROTOBUF_OBJC_GEN_VERSION 30000
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
@class GPBMessage;
@class GPBExtensionRegistry;
NS_ASSUME_NONNULL_BEGIN
// Reads and decodes protocol message fields.
// Subclassing of GPBCodedInputStream is NOT supported.
@interface GPBCodedInputStream : NSObject
+ (instancetype)streamWithData:(NSData *)data;
- (instancetype)initWithData:(NSData *)data;
// Attempt to read a field tag, returning zero if we have reached EOF.
// Protocol message parsers use this to read tags, since a protocol message
// may legally end wherever a tag occurs, and zero is not a valid tag number.
- (int32_t)readTag;
- (double)readDouble;
- (float)readFloat;
- (uint64_t)readUInt64;
- (uint32_t)readUInt32;
- (int64_t)readInt64;
- (int32_t)readInt32;
- (uint64_t)readFixed64;
- (uint32_t)readFixed32;
- (int32_t)readEnum;
- (int32_t)readSFixed32;
- (int64_t)readSFixed64;
- (int32_t)readSInt32;
- (int64_t)readSInt64;
- (BOOL)readBool;
- (NSString *)readString;
- (NSData *)readBytes;
// Read an embedded message field value from the stream.
- (void)readMessage:(GPBMessage *)message
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
// Reads and discards a single field, given its tag value. Returns NO if the
// tag is an endgroup tag, in which case nothing is skipped. Otherwise,
// returns YES.
- (BOOL)skipField:(int32_t)tag;
// Reads and discards an entire message. This will read either until EOF
// or until an endgroup tag, whichever comes first.
- (void)skipMessage;
// 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.
// Throws NSParseErrorException if value does not match the last tag.
- (void)checkLastTagWas:(int32_t)value;
@end
NS_ASSUME_NONNULL_END
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import "GPBCodedInputStream_PackagePrivate.h"
#import "GPBDictionary_PackagePrivate.h"
#import "GPBMessage_PackagePrivate.h"
#import "GPBUnknownFieldSet_PackagePrivate.h"
#import "GPBUtilities_PackagePrivate.h"
#import "GPBWireFormat.h"
static const NSUInteger kDefaultRecursionLimit = 64;
static void CheckSize(GPBCodedInputStreamState *state, size_t size) {
size_t newSize = state->bufferPos + size;
if (newSize > state->bufferSize) {
[NSException raise:NSParseErrorException format:@""];
}
if (newSize > state->currentLimit) {
// Fast forward to end of currentLimit;
state->bufferPos = state->currentLimit;
[NSException raise:NSParseErrorException format:@""];
}
}
static int8_t ReadRawByte(GPBCodedInputStreamState *state) {
CheckSize(state, sizeof(int8_t));
return ((int8_t *)state->bytes)[state->bufferPos++];
}
static int32_t ReadRawLittleEndian32(GPBCodedInputStreamState *state) {
CheckSize(state, sizeof(int32_t));
int32_t value = OSReadLittleInt32(state->bytes, state->bufferPos);
state->bufferPos += sizeof(int32_t);
return value;
}
static int64_t ReadRawLittleEndian64(GPBCodedInputStreamState *state) {
CheckSize(state, sizeof(int64_t));
int64_t value = OSReadLittleInt64(state->bytes, state->bufferPos);
state->bufferPos += sizeof(int64_t);
return value;
}
static int32_t ReadRawVarint32(GPBCodedInputStreamState *state) {
int8_t tmp = ReadRawByte(state);
if (tmp >= 0) {
return tmp;
}
int32_t result = tmp & 0x7f;
if ((tmp = ReadRawByte(state)) >= 0) {
result |= tmp << 7;
} else {
result |= (tmp & 0x7f) << 7;
if ((tmp = ReadRawByte(state)) >= 0) {
result |= tmp << 14;
} else {
result |= (tmp & 0x7f) << 14;
if ((tmp = ReadRawByte(state)) >= 0) {
result |= tmp << 21;
} else {
result |= (tmp & 0x7f) << 21;
result |= (tmp = ReadRawByte(state)) << 28;
if (tmp < 0) {
// Discard upper 32 bits.
for (int i = 0; i < 5; i++) {
if (ReadRawByte(state) >= 0) {
return result;
}
}
[NSException raise:NSParseErrorException
format:@"Unable to read varint32"];
}
}
}
}
return result;