| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) { | 44 GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) { |
| 45 return (GPBWireFormat)(tag & GPBWireFormatTagTypeMask); | 45 return (GPBWireFormat)(tag & GPBWireFormatTagTypeMask); |
| 46 } | 46 } |
| 47 | 47 |
| 48 uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) { | 48 uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) { |
| 49 return GPBLogicalRightShift32(tag, GPBWireFormatTagTypeBits); | 49 return GPBLogicalRightShift32(tag, GPBWireFormatTagTypeBits); |
| 50 } | 50 } |
| 51 | 51 |
| 52 BOOL GPBWireFormatIsValidTag(uint32_t tag) { | |
| 53 uint32_t formatBits = (tag & GPBWireFormatTagTypeMask); | |
| 54 // The valid GPBWireFormat* values are 0-5, anything else is not a valid tag. | |
| 55 BOOL result = (formatBits <= 5); | |
| 56 return result; | |
| 57 } | |
| 58 | |
| 59 GPBWireFormat GPBWireFormatForType(GPBDataType type, BOOL isPacked) { | 52 GPBWireFormat GPBWireFormatForType(GPBDataType type, BOOL isPacked) { |
| 60 if (isPacked) { | 53 if (isPacked) { |
| 61 return GPBWireFormatLengthDelimited; | 54 return GPBWireFormatLengthDelimited; |
| 62 } | 55 } |
| 63 | 56 |
| 64 static const GPBWireFormat format[GPBDataType_Count] = { | 57 static const GPBWireFormat format[GPBDataType_Count] = { |
| 65 GPBWireFormatVarint, // GPBDataTypeBool | 58 GPBWireFormatVarint, // GPBDataTypeBool |
| 66 GPBWireFormatFixed32, // GPBDataTypeFixed32 | 59 GPBWireFormatFixed32, // GPBDataTypeFixed32 |
| 67 GPBWireFormatFixed32, // GPBDataTypeSFixed32 | 60 GPBWireFormatFixed32, // GPBDataTypeSFixed32 |
| 68 GPBWireFormatFixed32, // GPBDataTypeFloat | 61 GPBWireFormatFixed32, // GPBDataTypeFloat |
| 69 GPBWireFormatFixed64, // GPBDataTypeFixed64 | 62 GPBWireFormatFixed64, // GPBDataTypeFixed64 |
| 70 GPBWireFormatFixed64, // GPBDataTypeSFixed64 | 63 GPBWireFormatFixed64, // GPBDataTypeSFixed64 |
| 71 GPBWireFormatFixed64, // GPBDataTypeDouble | 64 GPBWireFormatFixed64, // GPBDataTypeDouble |
| 72 GPBWireFormatVarint, // GPBDataTypeInt32 | 65 GPBWireFormatVarint, // GPBDataTypeInt32 |
| 73 GPBWireFormatVarint, // GPBDataTypeInt64 | 66 GPBWireFormatVarint, // GPBDataTypeInt64 |
| 74 GPBWireFormatVarint, // GPBDataTypeSInt32 | 67 GPBWireFormatVarint, // GPBDataTypeSInt32 |
| 75 GPBWireFormatVarint, // GPBDataTypeSInt64 | 68 GPBWireFormatVarint, // GPBDataTypeSInt64 |
| 76 GPBWireFormatVarint, // GPBDataTypeUInt32 | 69 GPBWireFormatVarint, // GPBDataTypeUInt32 |
| 77 GPBWireFormatVarint, // GPBDataTypeUInt64 | 70 GPBWireFormatVarint, // GPBDataTypeUInt64 |
| 78 GPBWireFormatLengthDelimited, // GPBDataTypeBytes | 71 GPBWireFormatLengthDelimited, // GPBDataTypeBytes |
| 79 GPBWireFormatLengthDelimited, // GPBDataTypeString | 72 GPBWireFormatLengthDelimited, // GPBDataTypeString |
| 80 GPBWireFormatLengthDelimited, // GPBDataTypeMessage | 73 GPBWireFormatLengthDelimited, // GPBDataTypeMessage |
| 81 GPBWireFormatStartGroup, // GPBDataTypeGroup | 74 GPBWireFormatStartGroup, // GPBDataTypeGroup |
| 82 GPBWireFormatVarint // GPBDataTypeEnum | 75 GPBWireFormatVarint // GPBDataTypeEnum |
| 83 }; | 76 }; |
| 84 return format[type]; | 77 return format[type]; |
| 85 } | 78 } |
| OLD | NEW |