package Ġpb and k . internal . binary Ċ Ċ import Ġcom . google . protobuf . CodedInputStream Ċ import Ġpb and k . Byte Arr Ċ import Ġpb and k . InvalidProtocolBufferException Ċ import Ġpb and k . Message Ċ import Ġpb and k . Unknown Field Ċ Ċ internal Ġclass ĠCode d Stream Binary Wire Decoder ( private Ġval Ġstream : ĠCode d InputStream ) Ġ: ĠBinary Wire Decoder Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġread Tag (): ĠTag Ġ= ĠTag ( stream . read Tag ()) ĊĊĠĠĠ Ġoverride Ġfun Ġread Double (): ĠDouble Ġ= Ġstream . read Double () ĊĊĠĠĠ Ġoverride Ġfun Ġread Float (): ĠFloat Ġ= Ġstream . read Float () ĊĊĠĠĠ Ġoverride Ġfun Ġread Int 3 2 (): ĠInt Ġ= Ġstream . readInt 3 2 () ĊĊĠĠĠ Ġoverride Ġfun Ġread Int 6 4 (): ĠLong Ġ= Ġstream . readInt 6 4 () ĊĊĠĠĠ Ġoverride Ġfun Ġread UInt 3 2 (): ĠInt Ġ= Ġstream . read UInt 3 2 () ĊĊĠĠĠ Ġoverride Ġfun Ġread UInt 6 4 (): ĠLong Ġ= Ġstream . read UInt 6 4 () ĊĊĠĠĠ Ġoverride Ġfun Ġread S Int 3 2 (): ĠInt Ġ= Ġstream . read S Int 3 2 () ĊĊĠĠĠ Ġoverride Ġfun Ġread S Int 6 4 (): ĠLong Ġ= Ġstream . read S Int 6 4 () ĊĊĠĠĠ Ġoverride Ġfun Ġread Fixed 3 2 (): ĠInt Ġ= Ġstream . read Fixed 3 2 () ĊĊĠĠĠ Ġoverride Ġfun Ġread Fixed 6 4 (): ĠLong Ġ= Ġstream . read Fixed 6 4 () ĊĊĠĠĠ Ġoverride Ġfun Ġread S Fixed 3 2 (): ĠInt Ġ= Ġstream . read S Fixed 3 2 () ĊĊĠĠĠ Ġoverride Ġfun Ġread S Fixed 6 4 (): ĠLong Ġ= Ġstream . read S Fixed 6 4 () ĊĊĠĠĠ Ġoverride Ġfun Ġread Bool (): ĠBoolean Ġ= Ġstream . read Bool () ĊĊĠĠĠ Ġoverride Ġfun Ġread String (): ĠString Ġ= Ġstream . readString Require Utf 8 () ĊĊĠĠĠ Ġoverride Ġfun Ġread Bytes (): ĠByte Arr Ġ= ĠByte Arr ( stream . read ByteArray ()) ĊĊĠĠĠ Ġoverride Ġfun Ġ< T Ġ: ĠMessage . Enum > Ġread Enum ( enum Companion : ĠMessage . Enum . Companion < T >): ĠT Ġ= ĊĠĠĠĠĠĠĠ Ġenum Companion . from Value ( stream . read Enum ()) ĊĊĠĠĠ Ġoverride Ġfun Ġ< T Ġ: ĠMessage > Ġread Message ( message Companion : ĠMessage . Companion < T >): ĠT Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġold Limit Ġ= Ġstream . push Limit ( stream . read Raw Varint 3 2 ()) ĊĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= Ġmessage Companion . decode With ( Binary Message Decoder ( this )) ĊĠĠĠĠĠĠĠ Ġif Ġ(! stream . is At End ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠInvalid ProtocolBufferException (" Not Ġat Ġthe Ġend Ġof Ġthe Ġcurrent Ġmessage Ġlimit Ġas Ġexpected ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġstream . pop Limit ( old Limit ) ĊĠĠĠĠĠĠĠ Ġreturn Ġmessage ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġ< T Ġ: ĠAny > Ġread Packed Repeated ( read Fn : ĠBinary Wire Decoder . () Ġ-> ĠT ): ĠSequence < T > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsequence Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġold Limit Ġ= Ġstream . push Limit ( stream . read Raw Varint 3 2 ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhile Ġ(! stream . is At End ) Ġyield ( read Fn ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstream . pop Limit ( old Limit ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġread Unknown Field ( field Num : ĠInt , ĠwireType : ĠWire Type ): ĠUnknown Field . Value ? Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTODO : Ġsupport Ġa Ġ` discard UnknownFields ` Ġoption Ġin Ġthe ĠBinary Message Decoder ĊĠĠĠĠĠĠĠ Ġ// val ĠunknownFields Ġ= Ġcurrent UnknownFields Ġ?: Ġreturn Ġrun Ġ{ Ġstream . skip Field ( tag ) Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġwhen Ġ( wire Type ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWire Type . VAR INT Ġ-> ĠUnknown Field . Value . Varint ( stream . readInt 6 4 ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWire Type . FIXED 6 4 Ġ-> ĠUnknown Field . Value . Fixed 6 4 ( stream . read Fixed 6 4 ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWire Type . LENGTH _ DE LIMIT ED Ġ-> ĠUnknown Field . Value . Length Delimited ( Byte Arr ( stream . read ByteArray ())) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWire Type . START _ GROUP Ġ-> ĠUnknown Field . Value . Start Group ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWire Type . END _ GROUP Ġ-> ĠUnknown Field . Value . End Group ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWire Type . FIXED 3 2 Ġ-> ĠUnknown Field . Value . Fixed 3 2 ( stream . read Fixed 3 2 ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġthrow ĠInvalid ProtocolBufferException (" Unrecognized Ġwire Ġtype : Ġ$ wire Type ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }