diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / build / deps / github_hashes / facebook / folly - rev . txt <nl> ppp b / build / deps / github_hashes / facebook / folly - rev . txt <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit b5ba7c304285acb0b013c6016d06ca2e65dbe96e <nl> + Subproject commit f327ff50c75f985ac84d0c7a5af9e76b955346a7 <nl> mmm a / build / deps / github_hashes / facebook / wangle - rev . txt <nl> ppp b / build / deps / github_hashes / facebook / wangle - rev . txt <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit ededa5aac8cf86e0d97ef1cf793c893bf7392a68 <nl> + Subproject commit 633a2bf9c909d1c845d171531dd5c14f211fb14c <nl> | Updating submodules | facebook/watchman | 99f1c8a74d9648a5aa5b907470987f59153f9ae6 | 2018-11-08T02:25:39Z |
mmm a / tensorflow / lite / g3doc / guide / ops_select . md <nl> ppp b / tensorflow / lite / g3doc / guide / ops_select . md <nl> partially supported by TensorFlow Lite , and one would like to avoid those <nl> limitations . <nl> <nl> The following example shows how to use this feature in the <nl> - [ ` TFLiteConverter ` ] ( . / convert / python_api . md ) Python API . <nl> + [ ` TFLiteConverter ` ] ( . . / convert / python_api . md ) Python API . <nl> <nl> ` ` ` python <nl> import tensorflow as tf <nl> mmm a / tensorflow / lite / g3doc / performance / best_practices . md <nl> ppp b / tensorflow / lite / g3doc / performance / best_practices . md <nl> accuracy and latency tradeoffs for some common image classification models . <nl> <nl> One example of models optimized for mobile devices are <nl> [ MobileNets ] ( https : / / arxiv . org / abs / 1704 . 04861 ) , which are optimized for mobile <nl> - vision applications . [ Hosted models ] ( . . / models / hosted . md ) lists several other <nl> - models that have been optimized specifically for mobile and embedded devices . <nl> + vision applications . [ Hosted models ] ( . . / guide / hosted_models . md ) lists several <nl> + other models that have been optimized specifically for mobile and embedded <nl> + devices . <nl> <nl> You can retrain the listed models on your own dataset by using transfer <nl> learning . Check out our transfer learning tutorial for <nl> | Fix broken hyperlinks in guide docs | tensorflow/tensorflow | 44db81e3241f98e61d386aeb8b1ee0dee33e04b6 | 2020-06-16T08:20:25Z |
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> ERROR ( cannot_convert_to_return_type_nil , none , <nl> <nl> ERROR ( cannot_convert_thrown_type , none , <nl> " thrown expression type % 0 does not conform to ' Error ' " , ( Type ) ) <nl> + ERROR ( cannot_throw_error_code , none , <nl> + " thrown error code type % 0 does not conform to ' Error ' ; construct an % 1 " <nl> + " instance " , ( Type , Type ) ) <nl> + <nl> ERROR ( cannot_throw_nil , none , <nl> " cannot infer concrete Error for thrown ' nil ' value " , ( ) ) <nl> <nl> mmm a / lib / Sema / CSDiag . cpp <nl> ppp b / lib / Sema / CSDiag . cpp <nl> bool FailureDiagnosis : : diagnoseContextualConversionError ( ) { <nl> diagIDProtocol = diag : : cannot_convert_to_return_type_protocol ; <nl> nilDiag = diag : : cannot_convert_to_return_type_nil ; <nl> break ; <nl> - case CTP_ThrowStmt : <nl> + case CTP_ThrowStmt : { <nl> if ( isa < NilLiteralExpr > ( expr - > getValueProvidingExpr ( ) ) ) { <nl> diagnose ( expr - > getLoc ( ) , diag : : cannot_throw_nil ) ; <nl> return true ; <nl> bool FailureDiagnosis : : diagnoseContextualConversionError ( ) { <nl> if ( isUnresolvedOrTypeVarType ( exprType ) | | <nl> exprType - > isEqual ( contextualType ) ) <nl> return false ; <nl> - <nl> + <nl> + / / If we tried to throw the error code of an error type , suggest object <nl> + / / construction . <nl> + auto & TC = CS - > getTypeChecker ( ) ; <nl> + if ( auto errorCodeProtocol = <nl> + TC . Context . getProtocol ( KnownProtocolKind : : ErrorCodeProtocol ) ) { <nl> + ProtocolConformance * conformance = nullptr ; <nl> + if ( TC . conformsToProtocol ( expr - > getType ( ) , errorCodeProtocol , CS - > DC , <nl> + ConformanceCheckFlags : : InExpression , <nl> + & conformance ) & & <nl> + conformance ) { <nl> + Type errorCodeType = expr - > getType ( ) ; <nl> + Type errorType = <nl> + ProtocolConformance : : getTypeWitnessByName ( errorCodeType , conformance , <nl> + TC . Context . Id_ErrorType , <nl> + & TC ) - > getCanonicalType ( ) ; <nl> + if ( errorType ) { <nl> + auto diag = diagnose ( expr - > getLoc ( ) , diag : : cannot_throw_error_code , <nl> + errorCodeType , errorType ) ; <nl> + if ( auto unresolvedDot = dyn_cast < UnresolvedDotExpr > ( expr ) ) { <nl> + diag . fixItInsert ( unresolvedDot - > getDotLoc ( ) , " ( " ) ; <nl> + diag . fixItInsertAfter ( unresolvedDot - > getEndLoc ( ) , " ) " ) ; <nl> + } <nl> + return true ; <nl> + } <nl> + } <nl> + } <nl> + <nl> / / The conversion destination of throw is always ErrorType ( at the moment ) <nl> / / if this ever expands , this should be a specific form like ( ) is for <nl> / / return . <nl> diagnose ( expr - > getLoc ( ) , diag : : cannot_convert_thrown_type , exprType ) <nl> . highlight ( expr - > getSourceRange ( ) ) ; <nl> return true ; <nl> - <nl> + } <nl> + <nl> case CTP_EnumCaseRawValue : <nl> diagID = diag : : cannot_convert_raw_initializer_value ; <nl> diagIDProtocol = diag : : cannot_convert_raw_initializer_value ; <nl> mmm a / test / Constraints / ErrorBridging . swift <nl> ppp b / test / Constraints / ErrorBridging . swift <nl> extension Error { <nl> return self / / expected - error { { cannot convert return expression of type ' Self ' to return type ' NSError ' } } <nl> } <nl> } <nl> + <nl> + / / rdar : / / problem / 27543121 <nl> + func throwErrorCode ( ) throws { <nl> + throw FictionalServerError . meltedDown / / expected - error { { thrown error code type ' FictionalServerError . Code ' does not conform to ' Error ' ; construct an ' FictionalServerError ' instance } } { { 29 - 29 = ( } } { { 40 - 40 = ) } } <nl> + } <nl> mmm a / test / Inputs / clang - importer - sdk / swift - modules / Foundation . swift <nl> ppp b / test / Inputs / clang - importer - sdk / swift - modules / Foundation . swift <nl> func _convertNSErrorToError ( _ string : NSError ? ) - > Error <nl> <nl> @ _silgen_name ( " swift_convertErrorToNSError " ) <nl> func _convertErrorToNSError ( _ string : Error ) - > NSError <nl> + <nl> + / / / An internal protocol to represent Swift error enums that map to standard <nl> + / / / Cocoa NSError domains . <nl> + public protocol _ObjectiveCBridgeableError : Error { <nl> + / / / Produce a value of the error type corresponding to the given NSError , <nl> + / / / or return nil if it cannot be bridged . <nl> + init ? ( _bridgedNSError : NSError ) <nl> + } <nl> + <nl> + / / / Describes a bridged error that stores the underlying NSError , so <nl> + / / / it can be queried . <nl> + public protocol _BridgedStoredNSError : _ObjectiveCBridgeableError { <nl> + / / / The type of an error code . <nl> + associatedtype Code : _ErrorCodeProtocol <nl> + <nl> + / / / The error code for the given error . <nl> + var code : Code { get } <nl> + <nl> + / / / / Retrieves the embedded NSError . <nl> + var _nsError : NSError { get } <nl> + <nl> + / / / Create a new instance of the error type with the given embedded <nl> + / / / NSError . <nl> + / / / <nl> + / / / The \ c error must have the appropriate domain for this error <nl> + / / / type . <nl> + init ( _nsError error : NSError ) <nl> + } <nl> + <nl> + public protocol _ErrorCodeProtocol { <nl> + / / / The corresponding error code . <nl> + associatedtype _ErrorType <nl> + } <nl> + <nl> + public extension _BridgedStoredNSError { <nl> + public init ? ( _bridgedNSError error : NSError ) { <nl> + self . init ( _nsError : error ) <nl> + } <nl> + } <nl> + <nl> + / / / Various helper implementations for _BridgedStoredNSError <nl> + public extension _BridgedStoredNSError <nl> + where Code : RawRepresentable , Code . RawValue : SignedInteger { <nl> + / / FIXME : Generalize to Integer . <nl> + public var code : Code { <nl> + return Code ( rawValue : numericCast ( _nsError . code ) ) ! <nl> + } <nl> + <nl> + / / / Initialize an error within this domain with the given ` ` code ` ` <nl> + / / / and ` ` userInfo ` ` . <nl> + public init ( _ code : Code , userInfo : [ String : Any ] = [ : ] ) { <nl> + self . init ( _nsError : NSError ( domain : " " , code : 0 , userInfo : [ : ] ) ) <nl> + } <nl> + <nl> + / / / The user - info dictionary for an error that was bridged from <nl> + / / / NSError . <nl> + var userInfo : [ String : Any ] { return [ : ] } <nl> + } <nl> + <nl> + / / / Various helper implementations for _BridgedStoredNSError <nl> + public extension _BridgedStoredNSError <nl> + where Code : RawRepresentable , Code . RawValue : UnsignedInteger { <nl> + / / FIXME : Generalize to Integer . <nl> + public var code : Code { <nl> + return Code ( rawValue : numericCast ( _nsError . code ) ) ! <nl> + } <nl> + <nl> + / / / Initialize an error within this domain with the given ` ` code ` ` <nl> + / / / and ` ` userInfo ` ` . <nl> + public init ( _ code : Code , userInfo : [ String : Any ] = [ : ] ) { <nl> + self . init ( _nsError : NSError ( domain : " " , code : 0 , userInfo : [ : ] ) ) <nl> + } <nl> + } <nl> mmm a / test / Inputs / clang - importer - sdk / usr / include / Foundation . h <nl> ppp b / test / Inputs / clang - importer - sdk / usr / include / Foundation . h <nl> static const NSClothingStyle NSClothingStyleOfficeCasual __attribute__ ( ( availabi <nl> void acceptError ( NSError * _Nonnull error ) ; <nl> NSError * _Nonnull produceError ( void ) ; <nl> NSError * _Nullable produceOptionalError ( void ) ; <nl> + <nl> + extern NSString * const FictionalServerErrorDomain ; <nl> + <nl> + typedef enum __attribute__ ( ( ns_error_domain ( FictionalServerErrorDomain ) ) ) FictionalServerErrorCode : NSInteger { <nl> + FictionalServerErrorMeltedDown = 1 <nl> + } FictionalServerErrorCode ; <nl> + <nl> | [ Sema ] Improve diagnostics for attempt to throw an error * code * | apple/swift | 31edf710bf8eeabafe26c7284d2a65dd0e0f5fde | 2016-08-02T21:47:18Z |
mmm a / client / distlock . cpp <nl> ppp b / client / distlock . cpp <nl> namespace mongo { <nl> BSON ( " _id " < < _id [ " _id " ] . String ( ) < < " ts " < < oldLock [ " ts " ] . OID ( ) ) , <nl> BSON ( " $ set " < < BSON ( " state " < < 0 ) ) ) ; <nl> <nl> + / / Check that the lock was actually unlocked . . . if not , try again <nl> + BSONObj err = conn - > getLastErrorDetailed ( ) ; <nl> + string errMsg = DBClientWithCommands : : getLastErrorString ( err ) ; <nl> + <nl> + if ( ! errMsg . empty ( ) | | ! err [ " n " ] . type ( ) | | err [ " n " ] . numberInt ( ) < 1 ) { <nl> + warning ( ) < < " distributed lock unlock update failed , retrying " <nl> + < < ( errMsg . empty ( ) ? causedBy ( " ( update not registered ) " ) : causedBy ( errMsg ) ) < < endl ; <nl> + conn . done ( ) ; <nl> + continue ; <nl> + } <nl> + <nl> log ( logLvl - 1 ) < < " distributed lock ' " < < lockName < < " ' unlocked . " < < endl ; <nl> conn . done ( ) ; <nl> return ; <nl> | triple check that an update actually went through for a dist unlock - sort1 . js transient issue | mongodb/mongo | 9077e45482367076c7cb7693d39d10fae7109e5c | 2011-05-12T21:27:51Z |
mmm a / arangod / Aql / IndexBlock . cpp <nl> ppp b / arangod / Aql / IndexBlock . cpp <nl> bool IndexBlock : : initIndexes ( ) { <nl> THROW_ARANGO_EXCEPTION ( _cursor - > code ) ; <nl> } <nl> } else { <nl> + _cursor = nullptr ; <nl> / / We were not able to initialize any index with this condition <nl> return false ; <nl> } <nl> void IndexBlock : : startNextCursor ( ) { <nl> if ( _currentIndex < _indexes . size ( ) ) { <nl> / / This check will work as long as _indexes . size ( ) < MAX_SIZE_T <nl> _cursor = createCursor ( ) ; <nl> + } else { <nl> + _cursor = nullptr ; <nl> } <nl> } <nl> <nl> mmm a / arangod / Indexes / SkiplistIndex . cpp <nl> ppp b / arangod / Indexes / SkiplistIndex . cpp <nl> IndexIterator * SkiplistIndex : : iteratorForCondition ( <nl> } <nl> / / We have to add the value always , the key was added before <nl> value - > toVelocyPackValue ( searchValues ) ; <nl> + searchValues . close ( ) ; <nl> } <nl> <nl> / / Now handle the next element , which might be a range <nl> mmm a / arangod / Utils / OperationCursor . cpp <nl> ppp b / arangod / Utils / OperationCursor . cpp <nl> <nl> using namespace arangodb ; <nl> <nl> void OperationCursor : : reset ( ) { <nl> - _builder . clear ( ) ; <nl> - <nl> if ( _indexIterator ! = nullptr ) { <nl> _indexIterator - > reset ( ) ; <nl> _hasMore = true ; <nl> int OperationCursor : : getMore ( uint64_t batchSize , bool useExternals ) { <nl> / / You requested more even if you should have checked it before . <nl> return TRI_ERROR_FORBIDDEN ; <nl> } <nl> - / / We restart the builder <nl> - _builder . clear ( ) ; <nl> + VPackBuilder builder ( buffer ) ; <nl> <nl> <nl> - VPackArrayBuilder guard ( & _builder ) ; <nl> + VPackArrayBuilder guard ( & builder ) ; <nl> TRI_doc_mptr_t * mptr = nullptr ; <nl> / / TODO : Improve this for baby awareness <nl> while ( batchSize > 0 & & _limit > 0 & & ( mptr = _indexIterator - > next ( ) ) ! = nullptr ) { <nl> int OperationCursor : : getMore ( uint64_t batchSize , bool useExternals ) { <nl> - - _limit ; <nl> # if 0 <nl> if ( useExternals ) { <nl> - _builder . add ( VPackValue ( mptr - > vpack ( ) , VPackValueType : : External ) ) ; <nl> + builder . add ( VPackValue ( mptr - > vpack ( ) , VPackValueType : : External ) ) ; <nl> } else { <nl> # endif <nl> - _builder . add ( VPackSlice ( mptr - > vpack ( ) ) ) ; <nl> + builder . add ( VPackSlice ( mptr - > vpack ( ) ) ) ; <nl> # if 0 <nl> } <nl> # endif <nl> mmm a / arangod / Utils / OperationCursor . h <nl> ppp b / arangod / Utils / OperationCursor . h <nl> struct OperationCursor : public OperationResult { <nl> private : <nl> <nl> std : : shared_ptr < IndexIterator > _indexIterator ; <nl> - arangodb : : velocypack : : Builder _builder ; <nl> bool _hasMore ; <nl> uint64_t _limit ; <nl> uint64_t const _originalLimit ; <nl> struct OperationCursor : public OperationResult { <nl> public : <nl> <nl> explicit OperationCursor ( int code ) <nl> - : OperationResult ( code ) , _builder ( buffer ) , _hasMore ( false ) , _limit ( 0 ) , _originalLimit ( 0 ) , _batchSize ( 1000 ) { <nl> + : OperationResult ( code ) , _hasMore ( false ) , _limit ( 0 ) , _originalLimit ( 0 ) , _batchSize ( 1000 ) { <nl> } <nl> <nl> OperationCursor ( int code , std : : string const & message ) <nl> - : OperationResult ( code , message ) , _builder ( buffer ) , _hasMore ( false ) , _limit ( 0 ) , _originalLimit ( 0 ) , _batchSize ( 1000 ) { <nl> + : OperationResult ( code , message ) , _hasMore ( false ) , _limit ( 0 ) , _originalLimit ( 0 ) , _batchSize ( 1000 ) { <nl> } <nl> <nl> OperationCursor ( std : : shared_ptr < VPackBuffer < uint8_t > > buffer , <nl> struct OperationCursor : public OperationResult { <nl> int code , <nl> bool wasSynchronous ) <nl> : OperationResult ( buffer , handler , message , code , wasSynchronous ) , <nl> - _builder ( buffer ) , <nl> _hasMore ( false ) , <nl> _limit ( 0 ) , <nl> _originalLimit ( 0 ) , <nl> struct OperationCursor : public OperationResult { <nl> : OperationResult ( std : : make_shared < VPackBuffer < uint8_t > > ( ) , handler , " " , <nl> TRI_ERROR_NO_ERROR , false ) , <nl> _indexIterator ( iterator ) , <nl> - _builder ( buffer ) , <nl> _hasMore ( true ) , <nl> _limit ( limit ) , / / _limit is modified later on <nl> _originalLimit ( limit ) , <nl> mmm a / arangod / Utils / OperationResult . h <nl> ppp b / arangod / Utils / OperationResult . h <nl> struct OperationResult { <nl> <nl> explicit OperationResult ( int code ) <nl> : customTypeHandler ( ) , code ( code ) , wasSynchronous ( false ) { <nl> + buffer = std : : make_shared < VPackBuffer < uint8_t > > ( ) ; <nl> if ( code ! = TRI_ERROR_NO_ERROR ) { <nl> errorMessage = TRI_errno_string ( code ) ; <nl> } <nl> struct OperationResult { <nl> OperationResult ( int code , std : : string const & message ) <nl> : customTypeHandler ( ) , errorMessage ( message ) , code ( code ) , <nl> wasSynchronous ( false ) { <nl> + buffer = std : : make_shared < VPackBuffer < uint8_t > > ( ) ; <nl> TRI_ASSERT ( code ! = TRI_ERROR_NO_ERROR ) ; <nl> } <nl> <nl> | Fixed OperationCursor and SkiplistIndex . The builder in OperationCursor did not retain the _buffer . | arangodb/arangodb | 5d61b709bb543f746ab2862b11fe2512d3cb361a | 2016-03-15T07:56:37Z |
mmm a / hphp / CMakeLists . txt <nl> ppp b / hphp / CMakeLists . txt <nl> endif ( ) <nl> # Not working with off - the - shelf libevent <nl> list ( REMOVE_ITEM CXX_SOURCES $ { CMAKE_CURRENT_SOURCE_DIR } / runtime / server / server_name_indication . cpp ) <nl> <nl> + # Waiting on OSS fix : ( <nl> + list ( REMOVE_ITEM CXX_SOURCES $ { CMAKE_CURRENT_SOURCE_DIR } / runtime / vm / runtime_type_profiler . cpp ) <nl> + <nl> # remove ext_hhvm , and anything in a test folder <nl> foreach ( file $ { CXX_SOURCES } ) <nl> if ( $ { file } MATCHES " ext_hhvm " ) <nl> mmm a / hphp / doc / ir . specification <nl> ppp b / hphp / doc / ir . specification <nl> D : Cell = LdUnwinderValue <nl> DeleteUnwinderException <nl> <nl> Deletes the current unwinder exception . <nl> + <nl> + TypeProfileFunc S0 : Gen S1 : Int S2 : Func <nl> + <nl> + Profiles that function ' s parameter / return value . S1 is the parameter index <nl> + ( where - 1 is the return value ) . Calls into native c + + function . <nl> + <nl> mmm a / hphp / runtime / base / runtime_option . h <nl> ppp b / hphp / runtime / base / runtime_option . h <nl> class RuntimeOption { <nl> F ( uint32_t , VMInitialGlobalTableSize , \ <nl> kEvalVMInitialGlobalTableSizeDefault ) \ <nl> F ( bool , Jit , evalJitDefault ( ) ) \ <nl> + F ( bool , RuntimeTypeProfile , false ) \ <nl> F ( bool , AllowHhas , false ) \ <nl> F ( bool , CheckExtendedTypeHints , false ) \ <nl> F ( bool , JitNoGdb , true ) \ <nl> F ( bool , SpinOnCrash , false ) \ <nl> F ( bool , PerfPidMap , true ) \ <nl> F ( bool , KeepPerfPidMap , false ) \ <nl> + F ( uint32_t , RuntimeTypeProfileFreq , 1000 ) \ <nl> F ( uint32_t , JitTargetCacheSize , 64 < < 20 ) \ <nl> F ( uint32_t , HHBCArenaChunkSize , 64 < < 20 ) \ <nl> F ( bool , ProfileBC , false ) \ <nl> mmm a / hphp / runtime / base / type_string . cpp <nl> ppp b / hphp / runtime / base / type_string . cpp <nl> const StaticString <nl> s_string ( " string " ) , <nl> s_array ( " array " ) , <nl> s_object ( " object " ) , <nl> - s_resource ( " resource " ) ; <nl> + s_resource ( " resource " ) , <nl> + s_indirect ( " indirect " ) , <nl> + s_ref ( " reference " ) ; <nl> <nl> String getDataTypeString ( DataType t ) { <nl> switch ( t ) { <nl> String getDataTypeString ( DataType t ) { <nl> case KindOfString : return s_string ; <nl> case KindOfArray : return s_array ; <nl> case KindOfObject : return s_object ; <nl> + case KindOfRef : return s_ref ; <nl> + case KindOfIndirect : return s_indirect ; <nl> case KindOfResource : return s_object ; <nl> + <nl> default : <nl> assert ( false ) ; <nl> break ; <nl> mmm a / hphp / runtime / vm / jit / code - gen . cpp <nl> ppp b / hphp / runtime / vm / jit / code - gen . cpp <nl> CALL_OPCODE ( ConvObjToStr ) ; <nl> CALL_OPCODE ( ConvResToStr ) ; <nl> CALL_OPCODE ( ConvCellToStr ) ; <nl> <nl> + CALL_OPCODE ( TypeProfileFunc ) <nl> CALL_OPCODE ( CreateContFunc ) <nl> CALL_OPCODE ( CreateContMeth ) <nl> CALL_OPCODE ( NewArray ) <nl> mmm a / hphp / runtime / vm / jit / hhbc - translator . cpp <nl> ppp b / hphp / runtime / vm / jit / hhbc - translator . cpp <nl> void HhbcTranslator : : emitFCall ( uint32_t numParams , <nl> std : : memset ( params , 0 , sizeof params ) ; <nl> for ( uint32_t i = 0 ; i < numParams ; i + + ) { <nl> params [ numParams + 3 - i - 1 ] = popF ( ) ; <nl> + if ( RuntimeOption : : EvalRuntimeTypeProfile & & callee ! = nullptr <nl> + & & params [ numParams + 3 - i - 1 ] ! = nullptr ) { <nl> + gen ( TypeProfileFunc , params [ numParams + 3 - i - 1 ] , cns ( i ) , cns ( callee ) ) ; <nl> + } <nl> } <nl> params [ 0 ] = spillStack ( ) ; <nl> params [ 1 ] = cns ( returnBcOffset ) ; <nl> params [ 2 ] = callee ? cns ( callee ) : m_tb - > genDefNull ( ) ; <nl> SSATmp * * decayedPtr = params ; <nl> gen ( Call , std : : make_pair ( numParams + 3 , decayedPtr ) ) ; <nl> - <nl> if ( ! m_fpiStack . empty ( ) ) { <nl> m_fpiStack . pop ( ) ; <nl> } <nl> void HhbcTranslator : : emitRet ( Type type , bool freeInline ) { <nl> gen ( ReleaseVVOrExit , getExitSlowTrace ( ) , m_tb - > fp ( ) ) ; <nl> } <nl> SSATmp * retVal = pop ( type ) ; <nl> - <nl> + if ( RuntimeOption : : EvalRuntimeTypeProfile ) { <nl> + gen ( TypeProfileFunc , retVal , cns ( - 1 ) , cns ( curFunc ) ) ; <nl> + } <nl> SSATmp * sp ; <nl> if ( freeInline ) { <nl> SSATmp * useRet = emitDecRefLocalsInline ( retVal ) ; <nl> mmm a / hphp / runtime / vm / jit / ir . h <nl> ppp b / hphp / runtime / vm / jit / ir . h <nl> O ( EmptyElem , D ( Bool ) , C ( TCA ) \ <nl> S ( Cell ) \ <nl> S ( PtrToCell ) , E | N | Mem | Refs | Er ) \ <nl> O ( IncStat , ND , C ( Int ) C ( Int ) C ( Bool ) , E | Mem ) \ <nl> + O ( TypeProfileFunc , ND , S ( Gen ) \ <nl> + S ( Int ) \ <nl> + S ( Func ) , E | CallsNative ) \ <nl> O ( IncStatGrouped , ND , CStr CStr C ( Int ) , E | N | Mem ) \ <nl> O ( IncTransCounter , ND , NA , E ) \ <nl> O ( ArrayIdx , D ( Cell ) , C ( TCA ) \ <nl> mmm a / hphp / runtime / vm / jit / native - calls . cpp <nl> ppp b / hphp / runtime / vm / jit / native - calls . cpp <nl> <nl> # include " hphp / runtime / vm / jit / native - calls . h " <nl> <nl> # include " hphp / runtime / vm / runtime . h " <nl> + # include " hphp / runtime / vm / runtime_type_profiler . h " <nl> # include " hphp / runtime / base / stats . h " <nl> # include " hphp / runtime / base / tv_conversions . h " <nl> # include " hphp / runtime / vm / jit / target - cache . h " <nl> auto constexpr VecKeyIS = ArgType : : VecKeyIS ; <nl> * / <nl> static CallMap s_callMap { <nl> / * Opcode , Func , Dest , SyncPoint , Args * / <nl> + { TypeProfileFunc , profileOneArgument , DNone , SNone , <nl> + { { TV , 0 } , { SSA , 1 } , { SSA , 2 } } } , <nl> { ConvBoolToArr , convCellToArrHelper , DSSA , SNone , <nl> { { TV , 0 } } } , <nl> { ConvDblToArr , convCellToArrHelper , DSSA , SNone , <nl> new file mode 100644 <nl> index 00000000000 . . 43e1cf0a932 <nl> mmm / dev / null <nl> ppp b / hphp / runtime / vm / runtime_type_profiler . cpp <nl> <nl> + / * <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | HipHop for PHP | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Copyright ( c ) 2010 - 2013 Facebook , Inc . ( http : / / www . facebook . com ) | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | This source file is subject to version 3 . 01 of the PHP license , | <nl> + | that is bundled with this package in the file LICENSE , and is | <nl> + | available through the world - wide - web at the following url : | <nl> + | http : / / www . php . net / license / 3_01 . txt | <nl> + | If you did not receive a copy of the PHP license and are unable to | <nl> + | obtain it through the world - wide - web , please send a note to | <nl> + | license @ php . net so we can mail you a copy immediately . | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + * / <nl> + <nl> + <nl> + # include " hphp / runtime / vm / runtime_type_profiler . h " <nl> + <nl> + # include < iostream > <nl> + # include < fstream > <nl> + # include < sstream > <nl> + # include < string . h > <nl> + # include < stdio . h > <nl> + <nl> + # include " folly / AtomicHashMap . h " <nl> + # include " folly / dynamic . h " <nl> + # include " folly / json . h " <nl> + <nl> + # include " external / google_base / atomicops . h " <nl> + <nl> + <nl> + namespace HPHP { <nl> + <nl> + static FuncTypeCounter emptyFuncCounter ( 0 ) ; <nl> + static RuntimeProfileInfo allProfileInfo ( 100000 , & emptyFuncCounter ) ; <nl> + <nl> + void profileOneArgument ( const TypedValue value , <nl> + const int param , const Func * function ) { <nl> + const char * typeString = giveTypeString ( & value ) ; <nl> + if ( function - > fullName ( ) - > size ( ) ! = 0 ) { <nl> + logType ( function , typeString , param + 1 ) ; <nl> + } <nl> + } <nl> + <nl> + std : : string dumpRawParamInfo ( const Func * function ) { <nl> + folly : : dynamic info = { } ; <nl> + auto funcParamMap = allProfileInfo . get ( function - > getFuncId ( ) ) ; <nl> + for ( int i = 0 ; i < funcParamMap - > size ( ) ; i + + ) { <nl> + info . push_back ( folly : : dynamic : : object ) ; <nl> + auto typeCount = funcParamMap - > at ( i ) ; <nl> + for ( auto j = typeCount - > begin ( ) ; j ! = typeCount - > end ( ) ; j + + ) { <nl> + folly : : dynamic key = std : : string ( j - > first ) ; <nl> + folly : : dynamic value = j - > second ; <nl> + info [ i ] [ key ] = value ; <nl> + } <nl> + } <nl> + std : : string json = folly : : toJson ( info ) . toStdString ( ) ; <nl> + return json ; <nl> + } <nl> + <nl> + void writeProfileInformationToDisk ( ) { <nl> + folly : : dynamic all_info = folly : : dynamic : : object ; <nl> + for ( auto i = 0 ; i < = Func : : nextFuncId ( ) ; i + + ) { <nl> + folly : : dynamic info = { } ; <nl> + auto funcParamMap = allProfileInfo . get ( i ) ; <nl> + if ( * funcParamMap = = emptyFuncCounter ) { <nl> + continue ; <nl> + } <nl> + for ( auto j = 0 ; j < funcParamMap - > size ( ) ; j + + ) { <nl> + auto typeCount = funcParamMap - > at ( j ) ; <nl> + if ( typeCount = = nullptr ) { <nl> + continue ; <nl> + } <nl> + info . push_back ( folly : : dynamic : : object ) ; <nl> + for ( auto k = typeCount - > begin ( ) ; k ! = typeCount - > end ( ) ; k + + ) { <nl> + folly : : dynamic key = std : : string ( k - > first ) ; <nl> + folly : : dynamic value = k - > second ; <nl> + info [ j ] [ key ] = value ; <nl> + } <nl> + } <nl> + const Func * func = Func : : fromFuncId ( i ) ; <nl> + all_info [ std : : string ( func - > fullName ( ) - > data ( ) ) ] = info ; <nl> + } <nl> + std : : ofstream logfile ; <nl> + logfile . open ( " / tmp / profile " ) ; <nl> + logfile < < folly : : toJson ( all_info ) . toStdString ( ) ; <nl> + logfile . close ( ) ; <nl> + } <nl> + <nl> + <nl> + void logType ( const Func * func , const char * typeString , int64_t param ) { <nl> + if ( param < = func - > numParams ( ) ) { <nl> + if ( allProfileInfo . get ( func - > getFuncId ( ) ) = = & emptyFuncCounter ) <nl> + initFuncTypeProfileData ( func ) ; <nl> + auto it = allProfileInfo . get ( func - > getFuncId ( ) ) ; <nl> + TypeCounter * hashmap = it - > at ( param ) ; <nl> + auto success = hashmap - > insert ( std : : make_pair ( typeString , 1 ) ) ; <nl> + if ( ! success . second ) { <nl> + base : : subtle : : NoBarrier_AtomicIncrement ( & success . first - > second , 1 ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void initFuncTypeProfileData ( const Func * func ) { <nl> + bool success = allProfileInfo . compare_exchange ( <nl> + func - > getFuncId ( ) , & emptyFuncCounter , <nl> + new FuncTypeCounter ( func - > numParams ( ) ) ) ; <nl> + if ( success ) { <nl> + for ( long i = 0 ; i < func - > numParams ( ) + 1 ; i + + ) { <nl> + auto myVector = allProfileInfo . get ( func - > getFuncId ( ) ) ; <nl> + myVector - > insert ( myVector - > begin ( ) + i , std : : move ( new TypeCounter ( 20 ) ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + const char * giveTypeString ( const TypedValue * value ) { <nl> + const char * typeString ; <nl> + if ( value - > m_type = = KindOfObject ) { <nl> + typeString = value - > m_data . pobj - > o_getClassName ( ) - > data ( ) ; <nl> + } else { <nl> + typeString = getDataTypeString ( value - > m_type ) . c_str ( ) ; <nl> + } <nl> + return typeString ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 584168f742e <nl> mmm / dev / null <nl> ppp b / hphp / runtime / vm / runtime_type_profiler . h <nl> <nl> + / * <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | HipHop for PHP | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Copyright ( c ) 2010 - 2013 Facebook , Inc . ( http : / / www . facebook . com ) | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | This source file is subject to version 3 . 01 of the PHP license , | <nl> + | that is bundled with this package in the file LICENSE , and is | <nl> + | available through the world - wide - web at the following url : | <nl> + | http : / / www . php . net / license / 3_01 . txt | <nl> + | If you did not receive a copy of the PHP license and are unable to | <nl> + | obtain it through the world - wide - web , please send a note to | <nl> + | license @ php . net so we can mail you a copy immediately . | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + * / <nl> + <nl> + <nl> + # ifndef incl_HPHP_VM_PROFILER_H_ <nl> + # define incl_HPHP_VM_PROFILER_H_ <nl> + # include " hphp / runtime / vm / bytecode . h " <nl> + # include " hphp / runtime / vm / runtime . h " <nl> + # include " hphp / runtime / base / datatype . h " <nl> + <nl> + # include " hphp / util / atomic_vector . h " <nl> + namespace HPHP { <nl> + <nl> + # ifdef FACEBOOK <nl> + void profileOneArgument ( TypedValue value , int param , const Func * func ) ; <nl> + void logType ( const Func * func , const char * typeString , int64_t param ) ; <nl> + void writeProfileInformationToDisk ( ) ; <nl> + const char * giveTypeString ( const TypedValue * value ) ; <nl> + std : : string dumpRawParamInfo ( const Func * function ) ; <nl> + void initFuncTypeProfileData ( const Func * func ) ; <nl> + typedef folly : : AtomicHashMap < const char * , int64_t > TypeCounter ; <nl> + typedef vector < TypeCounter * > FuncTypeCounter ; <nl> + typedef AtomicVector < FuncTypeCounter * > RuntimeProfileInfo ; <nl> + # else <nl> + / / Waiting on a fix for OSS <nl> + static void profileOneArgument ( TypedValue value , int param , const Func * func ) { } <nl> + # endif <nl> + <nl> + } <nl> + <nl> + # endif <nl> mmm a / hphp / util / atomic_vector . h <nl> ppp b / hphp / util / atomic_vector . h <nl> class AtomicVector { <nl> <nl> void ensureSize ( size_t size ) ; <nl> Value exchange ( size_t i , const Value & val ) ; <nl> + bool compare_exchange ( size_t i , Value expect , const Value & val ) ; <nl> <nl> Value get ( size_t i ) const ; <nl> <nl> Value AtomicVector < Value > : : exchange ( size_t i , const Value & val ) { <nl> return m_next . load ( std : : memory_order_acquire ) - > exchange ( i - m_size , val ) ; <nl> } <nl> <nl> + template < typename Value > <nl> + bool AtomicVector < Value > : : compare_exchange ( size_t i , <nl> + Value expect , <nl> + const Value & val ) { <nl> + FTRACE ( 3 , " { } : : compare_exchange ( { } , { } ) , m_size = { } \ n " , <nl> + typeName ( ) , i , val , m_size ) ; <nl> + if ( i < m_size ) { <nl> + auto oldVal = m_vals [ i ] . compare_exchange_strong ( expect , val , <nl> + std : : memory_order_release , std : : memory_order_acquire ) ; <nl> + <nl> + FTRACE ( 3 , " { } : : compare_exchange returning { } \ n " , typeName ( ) , oldVal ) ; <nl> + return oldVal ; <nl> + } <nl> + <nl> + assert ( m_next ) ; <nl> + return m_next . load ( std : : memory_order_acquire ) - > <nl> + compare_exchange ( i - m_size , expect , val ) ; <nl> + } <nl> + <nl> template < typename Value > <nl> Value AtomicVector < Value > : : get ( size_t i ) const { <nl> FTRACE ( 4 , " { } : : get ( { } ) , m_size = { } \ n " , typeName ( ) , i , m_size ) ; <nl> | Type profiling implementation | facebook/hhvm | 76b6cdee6ac6bf3effa68eca9699d8c980220ea1 | 2013-08-02T18:10:32Z |
mmm a / include / swift / SIL / SILBuilder . h <nl> ppp b / include / swift / SIL / SILBuilder . h <nl> class SILBuilder { <nl> LoadInst ( getSILDebugLocation ( Loc ) , LV , Qualifier ) ) ; <nl> } <nl> <nl> + / / / Convenience function for calling emitLoad on the type lowering for <nl> + / / / non - address values . <nl> + SILValue emitLoadValueOperation ( SILLocation Loc , SILValue LV , <nl> + LoadOwnershipQualifier Qualifier ) { <nl> + assert ( LV - > getType ( ) . isLoadable ( F . getModule ( ) ) ) ; <nl> + const auto & lowering = getTypeLowering ( LV - > getType ( ) ) ; <nl> + return lowering . emitLoad ( * this , Loc , LV , Qualifier ) ; <nl> + } <nl> + <nl> LoadBorrowInst * createLoadBorrow ( SILLocation Loc , SILValue LV ) { <nl> assert ( LV - > getType ( ) . isLoadable ( F . getModule ( ) ) ) ; <nl> return insert ( new ( F . getModule ( ) ) <nl> class SILBuilder { <nl> DestAddr , Qualifier ) ) ; <nl> } <nl> <nl> + / / / Convenience function for calling emitStore on the type lowering for <nl> + / / / non - address values . <nl> + void emitStoreValueOperation ( SILLocation Loc , SILValue Src , SILValue DestAddr , <nl> + StoreOwnershipQualifier Qualifier ) { <nl> + assert ( ! Src - > getType ( ) . isAddress ( ) ) ; <nl> + const auto & lowering = getTypeLowering ( Src - > getType ( ) ) ; <nl> + return lowering . emitStore ( * this , Loc , Src , DestAddr , Qualifier ) ; <nl> + } <nl> + <nl> EndBorrowInst * createEndBorrow ( SILLocation Loc , SILValue Src , <nl> SILValue DestAddr ) { <nl> return insert ( new ( F . getModule ( ) ) <nl> mmm a / include / swift / SIL / TypeLowering . h <nl> ppp b / include / swift / SIL / TypeLowering . h <nl> <nl> # ifndef SWIFT_SIL_TYPELOWERING_H <nl> # define SWIFT_SIL_TYPELOWERING_H <nl> <nl> - # include " swift / AST / CaptureInfo . h " <nl> # include " swift / ABI / MetadataValues . h " <nl> + # include " swift / AST / CaptureInfo . h " <nl> # include " swift / SIL / AbstractionPattern . h " <nl> + # include " swift / SIL / SILDeclRef . h " <nl> + # include " swift / SIL / SILInstruction . h " <nl> # include " swift / SIL / SILLocation . h " <nl> # include " swift / SIL / SILValue . h " <nl> - # include " swift / SIL / SILDeclRef . h " <nl> # include " llvm / ADT / DenseMap . h " <nl> # include " llvm / ADT / Hashing . h " <nl> # include " llvm / ADT / SmallVector . h " <nl> class TypeLowering { <nl> SILValue addr , <nl> IsInitialization_t isInit ) const = 0 ; <nl> <nl> + / / / Emit a store of \ p value into \ p addr given the StoreOwnershipQualifier <nl> + / / / qual . <nl> + / / / <nl> + / / / This abstracts over the differences in between trivial and non - trivial <nl> + / / / types . <nl> + virtual void emitStore ( SILBuilder & B , SILLocation loc , SILValue value , <nl> + SILValue addr , StoreOwnershipQualifier qual ) const = 0 ; <nl> + <nl> + / / / Emit a load from \ p addr given the LoadOwnershipQualifier \ p qual . <nl> + / / / <nl> + / / / This abstracts over the differences in between trivial and non - trivial <nl> + / / / types . <nl> + virtual SILValue emitLoad ( SILBuilder & B , SILLocation loc , SILValue addr , <nl> + LoadOwnershipQualifier qual ) const = 0 ; <nl> + <nl> / / / Put an exact copy of the value in the source address in the <nl> / / / destination address . <nl> virtual void emitCopyInto ( SILBuilder & B , <nl> mmm a / lib / SIL / TypeLowering . cpp <nl> ppp b / lib / SIL / TypeLowering . cpp <nl> namespace { <nl> B . createStore ( loc , value , addr , StoreOwnershipQualifier : : Unqualified ) ; <nl> } <nl> <nl> + void emitStore ( SILBuilder & B , SILLocation loc , SILValue value , <nl> + SILValue addr , StoreOwnershipQualifier qual ) const override { <nl> + B . createStore ( loc , value , addr , StoreOwnershipQualifier : : Trivial ) ; <nl> + } <nl> + <nl> + SILValue emitLoad ( SILBuilder & B , SILLocation loc , SILValue addr , <nl> + LoadOwnershipQualifier qual ) const override { <nl> + return B . createLoad ( loc , addr , LoadOwnershipQualifier : : Trivial ) ; <nl> + } <nl> + <nl> void emitDestroyAddress ( SILBuilder & B , SILLocation loc , <nl> SILValue addr ) const override { <nl> / / Trivial <nl> namespace { <nl> if ( ! isInit ) <nl> emitDestroyValue ( B , loc , oldValue ) ; <nl> } <nl> + <nl> + void emitStore ( SILBuilder & B , SILLocation loc , SILValue value , <nl> + SILValue addr , StoreOwnershipQualifier qual ) const override { <nl> + B . createStore ( loc , value , addr , qual ) ; <nl> + } <nl> + <nl> + SILValue emitLoad ( SILBuilder & B , SILLocation loc , SILValue addr , <nl> + LoadOwnershipQualifier qual ) const override { <nl> + return B . createLoad ( loc , addr , qual ) ; <nl> + } <nl> } ; <nl> <nl> / / / A CRTP helper class for loadable but non - trivial aggregate types . <nl> namespace { <nl> llvm_unreachable ( " calling emitStoreOfCopy on non - loadable type " ) ; <nl> } <nl> <nl> + void emitStore ( SILBuilder & B , SILLocation loc , SILValue value , <nl> + SILValue addr , StoreOwnershipQualifier qual ) const override { <nl> + llvm_unreachable ( " calling emitStore on non - loadable type " ) ; <nl> + } <nl> + <nl> + SILValue emitLoad ( SILBuilder & B , SILLocation loc , SILValue addr , <nl> + LoadOwnershipQualifier qual ) const override { <nl> + llvm_unreachable ( " calling emitLoad on non - loadable type " ) ; <nl> + } <nl> + <nl> void emitDestroyAddress ( SILBuilder & B , SILLocation loc , <nl> SILValue addr ) const override { <nl> B . emitDestroyAddrAndFold ( loc , addr ) ; <nl> mmm a / lib / SILGen / ManagedValue . cpp <nl> ppp b / lib / SILGen / ManagedValue . cpp <nl> ManagedValue ManagedValue : : copy ( SILGenFunction & gen , SILLocation l ) { <nl> <nl> / / / Store a copy of this value with independent ownership into the given <nl> / / / uninitialized address . <nl> - void ManagedValue : : copyInto ( SILGenFunction & gen , SILValue dest , SILLocation L ) { <nl> + void ManagedValue : : copyInto ( SILGenFunction & gen , SILValue dest , <nl> + SILLocation loc ) { <nl> auto & lowering = gen . getTypeLowering ( getType ( ) ) ; <nl> if ( lowering . isAddressOnly ( ) ) { <nl> - gen . B . createCopyAddr ( L , getValue ( ) , dest , <nl> - IsNotTake , IsInitialization ) ; <nl> + gen . B . createCopyAddr ( loc , getValue ( ) , dest , IsNotTake , IsInitialization ) ; <nl> return ; <nl> } <nl> - lowering . emitCopyValue ( gen . B , L , getValue ( ) ) ; <nl> - gen . B . createStore ( L , getValue ( ) , dest , StoreOwnershipQualifier : : Unqualified ) ; <nl> + <nl> + SILValue copy = lowering . emitCopyValue ( gen . B , loc , getValue ( ) ) ; <nl> + lowering . emitStoreOfCopy ( gen . B , loc , copy , dest , IsInitialization ) ; <nl> } <nl> <nl> / / / This is the same operation as ' copy ' , but works on + 0 values that don ' t <nl> mmm a / lib / SILGen / SILGenApply . cpp <nl> ppp b / lib / SILGen / SILGenApply . cpp <nl> static Callee prepareArchetypeCallee ( SILGenFunction & gen , SILLocation loc , <nl> / / Store the reference into a temporary . <nl> auto temp = <nl> gen . emitTemporaryAllocation ( selfLoc , ref . getValue ( ) - > getType ( ) ) ; <nl> - gen . B . createStore ( selfLoc , ref . getValue ( ) , temp , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + gen . B . emitStoreValueOperation ( selfLoc , ref . getValue ( ) , temp , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> <nl> / / If we had a cleanup , create a cleanup at the new address . <nl> return maybeEnterCleanupForTransformed ( gen , ref , temp ) ; <nl> static ManagedValue emitMaterializeIntoTemporary ( SILGenFunction & gen , <nl> ManagedValue object ) { <nl> auto temporary = gen . emitTemporaryAllocation ( loc , object . getType ( ) ) ; <nl> bool hadCleanup = object . hasCleanup ( ) ; <nl> - gen . B . createStore ( loc , object . forward ( gen ) , temporary , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + gen . B . emitStoreValueOperation ( loc , object . forward ( gen ) , temporary , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> <nl> / / The temporary memory is + 0 if the value was . <nl> if ( hadCleanup ) { <nl> mmm a / lib / SILGen / SILGenBridging . cpp <nl> ppp b / lib / SILGen / SILGenBridging . cpp <nl> emitBridgeNativeToObjectiveC ( SILGenFunction & gen , <nl> if ( witnessFnTy . castTo < SILFunctionType > ( ) - > getParameters ( ) [ 0 ] . isIndirect ( ) <nl> & & ! swiftValue . getType ( ) . isAddress ( ) ) { <nl> auto tmp = gen . emitTemporaryAllocation ( loc , swiftValue . getType ( ) ) ; <nl> - gen . B . createStore ( loc , swiftValue . getValue ( ) , tmp , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + gen . B . emitStoreValueOperation ( loc , swiftValue . getValue ( ) , tmp , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> swiftValue = ManagedValue : : forUnmanaged ( tmp ) ; <nl> } <nl> <nl> ManagedValue SILGenFunction : : emitFuncToBlock ( SILLocation loc , <nl> / / Store the function to the block without claiming it , so that it still <nl> / / gets cleaned up in scope . Copying the block will create an independent <nl> / / reference . <nl> - B . createStore ( loc , fn . getValue ( ) , capture , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + B . emitStoreValueOperation ( loc , fn . getValue ( ) , capture , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> auto invokeFn = B . createFunctionRef ( loc , thunk ) ; <nl> <nl> auto stackBlock = B . createInitBlockStorageHeader ( loc , storage , invokeFn , <nl> mmm a / lib / SILGen / SILGenBuiltin . cpp <nl> ppp b / lib / SILGen / SILGenBuiltin . cpp <nl> emitBuiltinCastReference ( SILGenFunction & gen , <nl> / / a retain . The cast will load the reference from the source temp and <nl> / / store it into a dest temp effectively forwarding the cleanup . <nl> fromAddr = gen . emitTemporaryAllocation ( loc , srcVal - > getType ( ) ) ; <nl> - gen . B . createStore ( loc , srcVal , fromAddr , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + fromTL . emitStore ( gen . B , loc , srcVal , fromAddr , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> } else { <nl> / / The cast loads directly from the source address . <nl> fromAddr = srcVal ; <nl> static ManagedValue emitBuiltinReinterpretCast ( SILGenFunction & gen , <nl> / / If the from value is loadable , move it to a buffer . <nl> if ( fromTL . isLoadable ( ) ) { <nl> fromAddr = gen . emitTemporaryAllocation ( loc , args [ 0 ] . getValue ( ) - > getType ( ) ) ; <nl> - gen . B . createStore ( loc , args [ 0 ] . getValue ( ) , fromAddr , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + fromTL . emitStore ( gen . B , loc , args [ 0 ] . getValue ( ) , fromAddr , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> } else { <nl> fromAddr = args [ 0 ] . getValue ( ) ; <nl> } <nl> mmm a / lib / SILGen / SILGenConvert . cpp <nl> ppp b / lib / SILGen / SILGenConvert . cpp <nl> SILGenFunction : : emitPointerToPointer ( SILLocation loc , <nl> / / The generic function currently always requires indirection , but pointers <nl> / / are always loadable . <nl> auto origBuf = emitTemporaryAllocation ( loc , input . getType ( ) ) ; <nl> - B . createStore ( loc , input . forward ( * this ) , origBuf , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + B . emitStoreValueOperation ( loc , input . forward ( * this ) , origBuf , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> auto origValue = emitManagedBufferWithCleanup ( origBuf ) ; <nl> <nl> / / Invoke the conversion intrinsic to convert to the destination type . <nl> mmm a / lib / SILGen / SILGenDynamicCast . cpp <nl> ppp b / lib / SILGen / SILGenDynamicCast . cpp <nl> adjustForConditionalCheckedCastOperand ( SILLocation loc , ManagedValue src , <nl> / / Okay , if all we need to do is drop the value in an address , <nl> / / this is easy . <nl> if ( ! hasAbstraction ) { <nl> - SGF . B . createStore ( loc , src . forward ( SGF ) , init - > getAddress ( ) , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + SGF . B . emitStoreValueOperation ( loc , src . forward ( SGF ) , init - > getAddress ( ) , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> init - > finishInitialization ( SGF ) ; <nl> return init - > getManagedAddress ( ) ; <nl> } <nl> mmm a / lib / SILGen / SILGenFunction . h <nl> ppp b / lib / SILGen / SILGenFunction . h <nl> class SILGenBuilder : public SILBuilder { <nl> SILBasicBlock : : iterator insertInst ) <nl> : SILGenBuilder ( gen , & * insertBB , insertInst ) { } <nl> <nl> + SILGenModule & getSILGenModule ( ) const { return SGM ; } <nl> + <nl> / / Metatype instructions use the conformances necessary to instantiate the <nl> / / type . <nl> <nl> mmm a / lib / SILGen / SILGenLValue . cpp <nl> ppp b / lib / SILGen / SILGenLValue . cpp <nl> namespace { <nl> baseFormalType ) ; <nl> <nl> baseAddress = gen . emitTemporaryAllocation ( loc , base . getType ( ) ) ; <nl> - gen . B . createStore ( loc , base . getValue ( ) , baseAddress , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + gen . B . emitStoreValueOperation ( loc , base . getValue ( ) , baseAddress , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> } <nl> baseMetatype = gen . B . createMetatype ( loc , metatypeType ) ; <nl> <nl> ManagedValue SILGenFunction : : emitLoad ( SILLocation loc , SILValue addr , <nl> static void emitUnloweredStoreOfCopy ( SILGenBuilder & B , SILLocation loc , <nl> SILValue value , SILValue addr , <nl> IsInitialization_t isInit ) { <nl> - if ( isInit ) <nl> - B . createStore ( loc , value , addr , StoreOwnershipQualifier : : Unqualified ) ; <nl> - else <nl> + if ( isInit ) { <nl> + B . emitStoreValueOperation ( loc , value , addr , StoreOwnershipQualifier : : Init ) ; <nl> + } else { <nl> B . createAssign ( loc , value , addr ) ; <nl> + } <nl> } <nl> <nl> SILValue SILGenFunction : : emitConversionToSemanticRValue ( SILLocation loc , <nl> mmm a / lib / SILGen / SILGenMaterializeForSet . cpp <nl> ppp b / lib / SILGen / SILGenMaterializeForSet . cpp <nl> SILValue MaterializeForSetEmitter : : emitUsingAddressor ( SILGenFunction & gen , <nl> } else { <nl> SILValue allocatedCallbackBuffer = <nl> gen . B . createAllocValueBuffer ( loc , owner . getType ( ) , callbackBuffer ) ; <nl> - gen . B . createStore ( loc , owner . forward ( gen ) , allocatedCallbackBuffer , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + gen . B . emitStoreValueOperation ( loc , owner . forward ( gen ) , <nl> + allocatedCallbackBuffer , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> <nl> callback = createAddressorCallback ( gen . F , owner . getType ( ) , addressorKind ) ; <nl> } <nl> mmm a / lib / SILGen / SILGenPattern . cpp <nl> ppp b / lib / SILGen / SILGenPattern . cpp <nl> emitCastOperand ( SILGenFunction & SGF , SILLocation loc , <nl> / / Okay , if all we need to do is drop the value in an address , <nl> / / this is easy . <nl> if ( ! hasAbstraction ) { <nl> - SGF . B . createStore ( loc , src . getFinalManagedValue ( ) . forward ( SGF ) , <nl> - init - > getAddress ( ) , <nl> - StoreOwnershipQualifier : : Unqualified ) ; <nl> + SGF . B . emitStoreValueOperation ( <nl> + loc , src . getFinalManagedValue ( ) . forward ( SGF ) , init - > getAddress ( ) , <nl> + StoreOwnershipQualifier : : Init ) ; <nl> init - > finishInitialization ( SGF ) ; <nl> ConsumableManagedValue result = <nl> { init - > getManagedAddress ( ) , src . getFinalConsumption ( ) } ; <nl> mmm a / lib / SILGen / SILGenProlog . cpp <nl> ppp b / lib / SILGen / SILGenProlog . cpp <nl> static void emitCaptureArguments ( SILGenFunction & gen , CapturedValue capture , <nl> / / temporary within the closure to provide this address . <nl> if ( VD - > isSettable ( VD - > getDeclContext ( ) ) ) { <nl> auto addr = gen . emitTemporaryAllocation ( VD , ty ) ; <nl> - gen . B . createStore ( VD , val , addr , StoreOwnershipQualifier : : Unqualified ) ; <nl> + lowering . emitStore ( gen . B , VD , val , addr , StoreOwnershipQualifier : : Init ) ; <nl> val = addr ; <nl> } <nl> <nl> mmm a / test / SILGen / accessors . swift <nl> ppp b / test / SILGen / accessors . swift <nl> func test0 ( _ ref : A ) { <nl> / / CHECK - NEXT : [ [ TEMP : % . * ] ] = alloc_stack $ OrdinarySub <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = class_method % 0 : $ A , # A . array ! getter . 1 <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( % 0 ) <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ TEMP ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ init ] [ [ TEMP ] ] <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = load [ [ TEMP ] ] <nl> / / CHECK - NEXT : / / function_ref accessors . OrdinarySub . subscript . getter : ( Swift . Int ) - > Swift . Int <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = function_ref @ _TFV9accessors11OrdinarySubg9subscriptFSiSi <nl> func test0 ( _ ref : A ) { <nl> / / CHECK : [ [ WRITEBACK ] ] ( [ [ CALLBACK_ADDR : % . * ] ] : $ Builtin . RawPointer ) : <nl> / / CHECK - NEXT : [ [ CALLBACK : % . * ] ] = pointer_to_thin_function [ [ CALLBACK_ADDR ] ] : $ Builtin . RawPointer to $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout A , @ thick A . Type ) - > ( ) <nl> / / CHECK - NEXT : [ [ TEMP2 : % . * ] ] = alloc_stack $ A <nl> - / / CHECK - NEXT : store % 0 to [ [ TEMP2 ] ] : $ * A <nl> + / / CHECK - NEXT : store % 0 to [ init ] [ [ TEMP2 ] ] : $ * A <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = metatype $ @ thick A . Type <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = address_to_pointer [ [ ADDR ] ] : $ * OrdinarySub to $ Builtin . RawPointer <nl> / / CHECK - NEXT : apply [ [ CALLBACK ] ] ( [ [ T1 ] ] , [ [ STORAGE ] ] , [ [ TEMP2 ] ] , [ [ T0 ] ] ) <nl> func test1 ( _ ref : B ) { <nl> / / CHECK : [ [ WRITEBACK ] ] ( [ [ CALLBACK_ADDR : % . * ] ] : $ Builtin . RawPointer ) : <nl> / / CHECK - NEXT : [ [ CALLBACK : % . * ] ] = pointer_to_thin_function [ [ CALLBACK_ADDR ] ] : $ Builtin . RawPointer to $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout B , @ thick B . Type ) - > ( ) <nl> / / CHECK - NEXT : [ [ TEMP2 : % . * ] ] = alloc_stack $ B <nl> - / / CHECK - NEXT : store % 0 to [ [ TEMP2 ] ] : $ * B <nl> + / / CHECK - NEXT : store % 0 to [ init ] [ [ TEMP2 ] ] : $ * B <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = metatype $ @ thick B . Type <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = address_to_pointer [ [ ADDR ] ] : $ * MutatingSub to $ Builtin . RawPointer <nl> / / CHECK - NEXT : apply [ [ CALLBACK ] ] ( [ [ T1 ] ] , [ [ STORAGE ] ] , [ [ TEMP2 ] ] , [ [ T0 ] ] ) <nl> func test1 ( _ ref : B ) { <nl> / / CHECK : [ [ WRITEBACK ] ] ( [ [ CALLBACK_ADDR : % . * ] ] : $ Builtin . RawPointer ) : <nl> / / CHECK - NEXT : [ [ CALLBACK : % . * ] ] = pointer_to_thin_function [ [ CALLBACK_ADDR ] ] : $ Builtin . RawPointer to $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout B , @ thick B . Type ) - > ( ) <nl> / / CHECK - NEXT : [ [ TEMP2 : % . * ] ] = alloc_stack $ B <nl> - / / CHECK - NEXT : store % 0 to [ [ TEMP2 ] ] : $ * B <nl> + / / CHECK - NEXT : store % 0 to [ init ] [ [ TEMP2 ] ] : $ * B <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = metatype $ @ thick B . Type <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = address_to_pointer [ [ ADDR ] ] : $ * MutatingSub to $ Builtin . RawPointer <nl> / / CHECK - NEXT : apply [ [ CALLBACK ] ] ( [ [ T1 ] ] , [ [ STORAGE2 ] ] , [ [ TEMP2 ] ] , [ [ T0 ] ] ) <nl> mmm a / test / SILGen / auto_generated_super_init_call . swift <nl> ppp b / test / SILGen / auto_generated_super_init_call . swift <nl> class SomeDerivedClass : Parent { <nl> / / CHECK : [ [ INITCALL1 : % [ 0 - 9 ] + ] ] = function_ref @ _TFC30auto_generated_super_init_call6ParentcfT_S0_ : $ @ convention ( method ) ( @ owned Parent ) - > @ owned Parent <nl> / / CHECK - NEXT : [ [ RES1 : % [ 0 - 9 ] + ] ] = apply [ [ INITCALL1 ] ] ( [ [ PARENT ] ] ) <nl> / / CHECK - NEXT : [ [ DOWNCAST : % [ 0 - 9 ] + ] ] = unchecked_ref_cast [ [ RES1 ] ] : $ Parent to $ SomeDerivedClass <nl> - / / CHECK - NEXT : store [ [ DOWNCAST ] ] to [ [ SELF ] ] : $ * SomeDerivedClass <nl> + / / CHECK - NEXT : store [ [ DOWNCAST ] ] to [ init ] [ [ SELF ] ] : $ * SomeDerivedClass <nl> } <nl> <nl> init ( x : Int ) { <nl> mmm a / test / SILGen / boxed_existentials . swift <nl> ppp b / test / SILGen / boxed_existentials . swift <nl> func test_concrete_erasure ( _ x : ClericalError ) - > Error { <nl> / / CHECK - LABEL : sil hidden @ _TF18boxed_existentials21test_concrete_erasureFOS_13ClericalErrorPs5Error_ <nl> / / CHECK : [ [ EXISTENTIAL : % . * ] ] = alloc_existential_box $ Error , $ ClericalError <nl> / / CHECK : [ [ ADDR : % . * ] ] = project_existential_box $ ClericalError in [ [ EXISTENTIAL ] ] : $ Error <nl> - / / CHECK : store % 0 to [ [ ADDR ] ] : $ * ClericalError <nl> + / / CHECK : store % 0 to [ init ] [ [ ADDR ] ] : $ * ClericalError <nl> / / CHECK : return [ [ EXISTENTIAL ] ] : $ Error <nl> <nl> protocol HairType { } <nl> func test_class_composition_erasure ( _ x : HairClass & Error ) - > Error { <nl> / / CHECK : [ [ VALUE : % . * ] ] = open_existential_ref [ [ OLD_EXISTENTIAL : % . * ] ] : $ Error & HairClass to $ [ [ VALUE_TYPE : @ opened \ ( . * \ ) Error & HairClass ] ] <nl> / / CHECK : [ [ NEW_EXISTENTIAL : % . * ] ] = alloc_existential_box $ Error , $ [ [ VALUE_TYPE ] ] <nl> / / CHECK : [ [ ADDR : % . * ] ] = project_existential_box $ [ [ VALUE_TYPE ] ] in [ [ NEW_EXISTENTIAL ] ] : $ Error <nl> - / / CHECK : store [ [ VALUE ] ] to [ [ ADDR ] ] <nl> + / / CHECK : [ [ COPIED_VALUE : % . * ] ] = copy_value [ [ VALUE ] ] <nl> + / / CHECK : store [ [ COPIED_VALUE ] ] to [ [ ADDR ] ] <nl> / / CHECK : return [ [ NEW_EXISTENTIAL ] ] <nl> <nl> func test_property ( _ x : Error ) - > String { <nl> func test_property_of_lvalue ( _ x : Error ) - > String { <nl> / / CHECK : [ [ VAR : % . * ] ] = alloc_box $ Error <nl> / / CHECK - NEXT : [ [ PVAR : % . * ] ] = project_box [ [ VAR ] ] <nl> / / CHECK - NEXT : copy_value % 0 : $ Error <nl> - / / CHECK - NEXT : store % 0 to [ [ PVAR ] ] <nl> + / / CHECK - NEXT : store % 0 to [ init ] [ [ PVAR ] ] <nl> / / CHECK - NEXT : [ [ VALUE_BOX : % . * ] ] = load [ [ PVAR ] ] <nl> / / CHECK - NEXT : copy_value [ [ VALUE_BOX ] ] <nl> / / CHECK - NEXT : [ [ VALUE : % . * ] ] = open_existential_box [ [ VALUE_BOX ] ] : $ Error to $ * [ [ VALUE_TYPE : @ opened \ ( . * \ ) Error ] ] <nl> mmm a / test / SILGen / builtins . swift <nl> ppp b / test / SILGen / builtins . swift <nl> func assign_gen < T > ( _ x : T , y : Builtin . RawPointer ) { <nl> func init_pod ( _ x : Builtin . Int64 , y : Builtin . RawPointer ) { <nl> / / CHECK : [ [ ADDR : % . * ] ] = pointer_to_address { { % . * } } to [ strict ] $ * Builtin . Int64 <nl> / / CHECK - NOT : load [ [ ADDR ] ] <nl> - / / CHECK : store { { % . * } } to [ [ ADDR ] ] <nl> + / / CHECK : store { { % . * } } to [ trivial ] [ [ ADDR ] ] <nl> / / CHECK - NOT : destroy_value [ [ ADDR ] ] <nl> Builtin . initialize ( x , y ) <nl> } <nl> func init_pod ( _ x : Builtin . Int64 , y : Builtin . RawPointer ) { <nl> func init_obj ( _ x : Builtin . NativeObject , y : Builtin . RawPointer ) { <nl> / / CHECK : [ [ ADDR : % . * ] ] = pointer_to_address { { % . * } } to [ strict ] $ * Builtin . NativeObject <nl> / / CHECK - NOT : load [ [ ADDR ] ] <nl> - / / CHECK : store [ [ SRC : % . * ] ] to [ [ ADDR ] ] <nl> + / / CHECK : store [ [ SRC : % . * ] ] to [ init ] [ [ ADDR ] ] <nl> / / CHECK - NOT : destroy_value [ [ SRC ] ] <nl> Builtin . initialize ( x , y ) <nl> } <nl> func reinterpretAddrOnlyToTrivial < T > ( _ t : T ) - > Int { <nl> / / CHECK - LABEL : sil hidden @ _TF8builtins27reinterpretAddrOnlyLoadable <nl> func reinterpretAddrOnlyLoadable < T > ( _ a : Int , _ b : T ) - > ( T , Int ) { <nl> / / CHECK : [ [ BUF : % . * ] ] = alloc_stack $ Int <nl> - / / CHECK : store { { % . * } } to [ [ BUF ] ] <nl> + / / CHECK : store { { % . * } } to [ trivial ] [ [ BUF ] ] <nl> / / CHECK : [ [ RES1 : % . * ] ] = unchecked_addr_cast [ [ BUF ] ] : $ * Int to $ * T <nl> / / CHECK : copy_addr [ [ RES1 ] ] to [ initialization ] <nl> return ( Builtin . reinterpretCast ( a ) as T , <nl> mmm a / test / SILGen / cf_members . swift <nl> ppp b / test / SILGen / cf_members . swift <nl> public func foo ( _ x : Double ) { <nl> <nl> / / CHECK : [ [ FN : % . * ] ] = function_ref @ IAMStruct1Rotate : $ @ convention ( c ) ( @ in Struct1 , Double ) - > Struct1 <nl> / / CHECK : [ [ ZVAL : % . * ] ] = load [ [ Z ] ] <nl> - / / CHECK : store [ [ ZVAL ] ] to [ [ ZTMP : % . * ] ] : <nl> + / / CHECK : store [ [ ZVAL ] ] to [ trivial ] [ [ ZTMP : % . * ] ] : <nl> / / CHECK : apply [ [ FN ] ] ( [ [ ZTMP ] ] , [ [ X ] ] ) <nl> z = z . translate ( radians : x ) <nl> <nl> public func foo ( _ x : Double ) { <nl> / / z = h ( z , x ) <nl> <nl> / / CHECK : [ [ ZVAL : % . * ] ] = load [ [ Z ] ] <nl> - / / CHECK : store [ [ ZVAL ] ] to [ [ ZTMP : % . * ] ] : <nl> + / / CHECK : store [ [ ZVAL ] ] to [ trivial ] [ [ ZTMP : % . * ] ] : <nl> / / CHECK : [ [ GET : % . * ] ] = function_ref @ IAMStruct1GetRadius : $ @ convention ( c ) ( @ in Struct1 ) - > Double <nl> / / CHECK : apply [ [ GET ] ] ( [ [ ZTMP ] ] ) <nl> _ = z . radius <nl> public func foo ( _ x : Double ) { <nl> <nl> / / CHECK - LABEL : sil shared [ thunk ] @ _TTOFVSC7Struct19translatefT7radiansSd_S_ <nl> / / CHECK : bb0 ( [ [ X : % . * ] ] : $ Double , [ [ SELF : % . * ] ] : $ Struct1 ) : <nl> - / / CHECK : store [ [ SELF ] ] to [ [ TMP : % . * ] ] : <nl> + / / CHECK : store [ [ SELF ] ] to [ trivial ] [ [ TMP : % . * ] ] : <nl> / / CHECK : [ [ CFUNC : % . * ] ] = function_ref @ IAMStruct1Rotate <nl> / / CHECK : [ [ RET : % . * ] ] = apply [ [ CFUNC ] ] ( [ [ TMP ] ] , [ [ X ] ] ) <nl> / / CHECK : return [ [ RET ] ] <nl> mmm a / test / SILGen / class_bound_protocols . swift <nl> ppp b / test / SILGen / class_bound_protocols . swift <nl> func class_bound_generic < T : ClassBound > ( x : T ) - > T { <nl> / / CHECK : bb0 ( [ [ X : % . * ] ] : $ T ) : <nl> / / CHECK : [ [ X_ADDR : % . * ] ] = alloc_box $ T <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ X_ADDR ] ] <nl> - / / CHECK : store [ [ X ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ PB ] ] <nl> return x <nl> / / CHECK : [ [ X1 : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X1 ] ] <nl> func class_bound_generic_2 < T : ClassBound & NotClassBound > ( x : T ) - > T { <nl> / / CHECK : bb0 ( [ [ X : % . * ] ] : $ T ) : <nl> / / CHECK : [ [ X_ADDR : % . * ] ] = alloc_box $ T <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ X_ADDR ] ] <nl> - / / CHECK : store [ [ X ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ PB ] ] <nl> return x <nl> / / CHECK : [ [ X1 : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X1 ] ] <nl> func class_bound_protocol ( x : ClassBound ) - > ClassBound { <nl> / / CHECK : bb0 ( [ [ X : % . * ] ] : $ ClassBound ) : <nl> / / CHECK : [ [ X_ADDR : % . * ] ] = alloc_box $ ClassBound <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ X_ADDR ] ] <nl> - / / CHECK : store [ [ X ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ PB ] ] <nl> return x <nl> / / CHECK : [ [ X1 : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X1 ] ] <nl> func class_bound_protocol_composition ( x : ClassBound & NotClassBound ) <nl> / / CHECK : bb0 ( [ [ X : % . * ] ] : $ ClassBound & NotClassBound ) : <nl> / / CHECK : [ [ X_ADDR : % . * ] ] = alloc_box $ ClassBound & NotClassBound <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ X_ADDR ] ] <nl> - / / CHECK : store [ [ X ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ PB ] ] <nl> return x <nl> / / CHECK : [ [ X1 : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X1 ] ] <nl> func class_bound_to_unbound_existential_upcast <nl> return x <nl> / / CHECK : [ [ X_OPENED : % . * ] ] = open_existential_ref % 1 : $ ClassBound & NotClassBound to [ [ OPENED_TYPE : \ $ @ opened ( . * ) ClassBound & NotClassBound ] ] <nl> / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = init_existential_addr % 0 : $ * NotClassBound , [ [ OPENED_TYPE ] ] <nl> - / / CHECK : store [ [ X_OPENED ] ] to [ [ PAYLOAD_ADDR ] ] <nl> + / / CHECK : [ [ X_OPENED_COPY : % . * ] ] = copy_value [ [ X_OPENED ] ] <nl> + / / CHECK : store [ [ X_OPENED_COPY ] ] to [ [ PAYLOAD_ADDR ] ] <nl> } <nl> <nl> / / CHECK - LABEL : sil hidden @ _TF21class_bound_protocols18class_bound_method <nl> mmm a / test / SILGen / closures . swift <nl> ppp b / test / SILGen / closures . swift <nl> func uncaptured_locals ( _ x : Int ) - > ( Int , Int ) { <nl> / / CHECK : bb0 ( [ [ XARG : % [ 0 - 9 ] + ] ] : $ Int ) : <nl> / / CHECK : [ [ XADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ XADDR ] ] <nl> - / / CHECK : store [ [ XARG ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ XARG ] ] to [ trivial ] [ [ PB ] ] <nl> <nl> var y = zero <nl> / / CHECK : [ [ YADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> func closeOverLetLValue ( ) { <nl> / / CHECK - LABEL : sil shared @ _TFF8closures18closeOverLetLValueFT_T_U_FT_Si <nl> / / CHECK : bb0 ( % 0 : $ ClassWithIntProperty ) : <nl> / / CHECK - NEXT : [ [ TMP : % . * ] ] = alloc_stack $ ClassWithIntProperty , let , name " a " , argno 1 <nl> - / / CHECK - NEXT : store % 0 to [ [ TMP ] ] : $ * ClassWithIntProperty <nl> + / / CHECK - NEXT : store % 0 to [ init ] [ [ TMP ] ] : $ * ClassWithIntProperty <nl> / / CHECK - NEXT : { { . * } } = load [ [ TMP ] ] : $ * ClassWithIntProperty <nl> / / CHECK - NEXT : { { . * } } = ref_element_addr { { . * } } : $ ClassWithIntProperty , # ClassWithIntProperty . x <nl> / / CHECK - NEXT : { { . * } } = load { { . * } } : $ * Int <nl> class SuperSub : SuperBase { <nl> / / - - TODO : A lot of fussy r / r traffic and owned / unowned conversions here . <nl> / / - - strong + 1 , unowned + 1 <nl> / / CHECK : unowned_retain [ [ UNOWNED_SELF ] ] <nl> - / / CHECK : store [ [ UNOWNED_SELF ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ UNOWNED_SELF ] ] to [ init ] [ [ PB ] ] <nl> / / CHECK : [ [ UNOWNED_SELF : % . * ] ] = load [ [ PB ] ] <nl> / / - - strong + 2 , unowned + 1 <nl> / / CHECK : strong_retain_unowned [ [ UNOWNED_SELF ] ] <nl> mmm a / test / SILGen / complete_object_init . swift <nl> ppp b / test / SILGen / complete_object_init . swift <nl> class A { <nl> / / CHECK : [ [ X_META : % [ 0 - 9 ] + ] ] = metatype $ @ thin X . Type <nl> / / CHECK : [ [ X : % [ 0 - 9 ] + ] ] = apply [ [ X_INIT ] ] ( [ [ X_META ] ] ) : $ @ convention ( method ) ( @ thin X . Type ) - > X <nl> / / CHECK : [ [ INIT_RESULT : % [ 0 - 9 ] + ] ] = apply [ [ INIT ] ] ( [ [ X ] ] , [ [ SELFP ] ] ) : $ @ convention ( method ) ( X , @ owned A ) - > @ owned A <nl> - / / CHECK : store [ [ INIT_RESULT ] ] to [ [ SELF ] ] : $ * A <nl> + / / CHECK : store [ [ INIT_RESULT ] ] to [ init ] [ [ SELF ] ] : $ * A <nl> / / CHECK : [ [ RESULT : % [ 0 - 9 ] + ] ] = load [ [ SELF ] ] : $ * A <nl> / / CHECK : copy_value [ [ RESULT ] ] : $ A <nl> / / CHECK : destroy_value [ [ SELF_BOX ] ] : $ @ box A <nl> mmm a / test / SILGen / copy_lvalue_peepholes . swift <nl> ppp b / test / SILGen / copy_lvalue_peepholes . swift <nl> var computed : Int { <nl> / / CHECK - LABEL : sil hidden @ _TF21copy_lvalue_peepholes29init_var_from_computed_lvalue <nl> / / CHECK : [ [ GETTER : % . * ] ] = function_ref @ _TF21copy_lvalue_peepholesg8computedBi64_ <nl> / / CHECK : [ [ GOTTEN : % . * ] ] = apply [ [ GETTER ] ] ( ) <nl> - / / CHECK : store [ [ GOTTEN ] ] to { { % . * } } <nl> + / / CHECK : store [ [ GOTTEN ] ] to [ trivial ] { { % . * } } <nl> func init_var_from_computed_lvalue ( ) { <nl> var y = computed <nl> } <nl> mmm a / test / SILGen / decls . swift <nl> ppp b / test / SILGen / decls . swift <nl> func tuple_patterns ( ) { <nl> / / CHECK : [ [ E : % [ 0 - 9 ] + ] ] = tuple_extract { { . * } } , 0 <nl> / / CHECK : [ [ F : % [ 0 - 9 ] + ] ] = tuple_extract { { . * } } , 1 <nl> / / CHECK : [ [ H : % [ 0 - 9 ] + ] ] = tuple_extract { { . * } } , 2 <nl> - / / CHECK : store [ [ E ] ] to [ [ PBE ] ] <nl> - / / CHECK : store [ [ F ] ] to [ [ PBF ] ] <nl> - / / CHECK : store [ [ H ] ] to [ [ PBH ] ] <nl> + / / CHECK : store [ [ E ] ] to [ trivial ] [ [ PBE ] ] <nl> + / / CHECK : store [ [ F ] ] to [ trivial ] [ [ PBF ] ] <nl> + / / CHECK : store [ [ H ] ] to [ trivial ] [ [ PBH ] ] <nl> var ( e , f , g , h ) : ( Int , Float , ( ) , Double ) = MRV ( ) <nl> <nl> / / CHECK : [ [ IADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> func tuple_patterns ( ) { <nl> / / CHECK : [ [ J_K_ : % [ 0 - 9 ] + ] ] = apply <nl> / / CHECK : [ [ J : % [ 0 - 9 ] + ] ] = tuple_extract { { . * } } , 0 <nl> / / CHECK : [ [ K : % [ 0 - 9 ] + ] ] = tuple_extract { { . * } } , 2 <nl> - / / CHECK : store [ [ J ] ] to [ [ PBJ ] ] <nl> + / / CHECK : store [ [ J ] ] to [ trivial ] [ [ PBJ ] ] <nl> var ( j , _ , k , _ ) : ( Int , Float , ( ) , Double ) = MRV ( ) <nl> } <nl> <nl> func tuple_patterns ( ) { <nl> / / CHECK : bb0 ( % 0 : $ Int , % 1 : $ Int ) : <nl> / / CHECK : [ [ X : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK - NEXT : [ [ PBX : % . * ] ] = project_box [ [ X ] ] <nl> - / / CHECK - NEXT : store % 0 to [ [ PBX ] ] <nl> + / / CHECK - NEXT : store % 0 to [ trivial ] [ [ PBX ] ] <nl> / / CHECK - NEXT : [ [ Y : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK - NEXT : [ [ PBY : % [ 0 - 9 ] + ] ] = project_box [ [ Y ] ] <nl> - / / CHECK - NEXT : store % 1 to [ [ PBY ] ] <nl> + / / CHECK - NEXT : store % 1 to [ trivial ] [ [ PBY ] ] <nl> func simple_arguments ( x : Int , y : Int ) - > Int { <nl> var x = x <nl> var y = y <nl> mmm a / test / SILGen / default_constructor . swift <nl> ppp b / test / SILGen / default_constructor . swift <nl> class F : E { } <nl> / / CHECK - NEXT : [ [ ESELF : % [ 0 - 9 ] ] ] = apply [ [ E_CTOR ] ] ( [ [ E ] ] ) : $ @ convention ( method ) ( @ owned E ) - > @ owned E <nl> <nl> / / CHECK - NEXT : [ [ ESELFW : % [ 0 - 9 ] + ] ] = unchecked_ref_cast [ [ ESELF ] ] : $ E to $ F <nl> - / / CHECK - NEXT : store [ [ ESELFW ] ] to [ [ SELF ] ] : $ * F <nl> + / / CHECK - NEXT : store [ [ ESELFW ] ] to [ init ] [ [ SELF ] ] : $ * F <nl> / / CHECK - NEXT : [ [ SELFP : % [ 0 - 9 ] + ] ] = load [ [ SELF ] ] : $ * F <nl> / / CHECK - NEXT : copy_value [ [ SELFP ] ] : $ F <nl> / / CHECK - NEXT : destroy_value [ [ SELF_BOX ] ] : $ @ box F <nl> mmm a / test / SILGen / dynamic_lookup . swift <nl> ppp b / test / SILGen / dynamic_lookup . swift <nl> func direct_to_static_method ( _ obj : AnyObject ) { <nl> / / CHECK : [ [ START : [ A - Za - z0 - 9_ ] + ] ] ( [ [ OBJ : % [ 0 - 9 ] + ] ] : $ AnyObject ) : <nl> / / CHECK : [ [ OBJBOX : % [ 0 - 9 ] + ] ] = alloc_box $ AnyObject <nl> / / CHECK - NEXT : [ [ PBOBJ : % [ 0 - 9 ] + ] ] = project_box [ [ OBJBOX ] ] <nl> - / / CHECK : store [ [ OBJ ] ] to [ [ PBOBJ ] ] : $ * AnyObject <nl> + / / CHECK : store [ [ OBJ ] ] to [ init ] [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : [ [ OBJCOPY : % [ 0 - 9 ] + ] ] = load [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : [ [ OBJMETA : % [ 0 - 9 ] + ] ] = existential_metatype $ @ thick AnyObject . Type , [ [ OBJCOPY ] ] : $ AnyObject <nl> / / CHECK - NEXT : [ [ OPENMETA : % [ 0 - 9 ] + ] ] = open_existential_metatype [ [ OBJMETA ] ] : $ @ thick AnyObject . Type to $ @ thick ( @ opened ( [ [ UUID : " . * " ] ] ) AnyObject ) . Type <nl> func opt_to_class ( _ obj : AnyObject ) { <nl> / / CHECK : [ [ ENTRY : [ A - Za - z0 - 9 ] + ] ] ( [ [ PARAM : % [ 0 - 9 ] + ] ] : $ AnyObject ) <nl> / / CHECK : [ [ EXISTBOX : % [ 0 - 9 ] + ] ] = alloc_box $ AnyObject <nl> / / CHECK - NEXT : [ [ PBOBJ : % [ 0 - 9 ] + ] ] = project_box [ [ EXISTBOX ] ] <nl> - / / CHECK : store [ [ PARAM ] ] to [ [ PBOBJ ] ] <nl> + / / CHECK : store [ [ PARAM ] ] to [ init ] [ [ PBOBJ ] ] <nl> / / CHECK - NEXT : [ [ OPTBOX : % [ 0 - 9 ] + ] ] = alloc_box $ Optional < @ callee_owned ( ) - > ( ) > <nl> / / CHECK - NEXT : [ [ PBOPT : % . * ] ] = project_box [ [ OPTBOX ] ] <nl> / / CHECK - NEXT : [ [ EXISTVAL : % [ 0 - 9 ] + ] ] = load [ [ PBOBJ ] ] : $ * AnyObject <nl> func opt_to_class ( _ obj : AnyObject ) { <nl> / / CHECK - NEXT : copy_value [ [ OBJ_SELF ] ] <nl> / / CHECK - NEXT : [ [ PARTIAL : % [ 0 - 9 ] + ] ] = partial_apply [ [ UNCURRIED ] ] ( [ [ OBJ_SELF ] ] ) : $ @ convention ( objc_method ) ( @ opened ( { { . * } } ) AnyObject ) - > ( ) <nl> / / CHECK - NEXT : [ [ THUNK_PAYLOAD : % . * ] ] = init_enum_data_addr [ [ OPTIONAL : % [ 0 - 9 ] + ] ] <nl> - / / CHECK - NEXT : store [ [ PARTIAL ] ] to [ [ THUNK_PAYLOAD ] ] <nl> + / / CHECK - NEXT : store [ [ PARTIAL ] ] to [ init ] [ [ THUNK_PAYLOAD ] ] <nl> / / CHECK - NEXT : inject_enum_addr [ [ OPTIONAL ] ] { { . * } } some <nl> / / CHECK - NEXT : br [ [ CONTBB : [ a - zA - Z0 - 9 ] + ] ] <nl> <nl> func opt_to_class ( _ obj : AnyObject ) { <nl> / / Continuation block <nl> / / CHECK : [ [ CONTBB ] ] : <nl> / / CHECK - NEXT : [ [ OPT : % . * ] ] = load [ [ OPTTEMP ] ] <nl> - / / CHECK - NEXT : store [ [ OPT ] ] to [ [ PBOPT ] ] : $ * Optional < @ callee_owned ( ) - > ( ) > <nl> + / / CHECK - NEXT : store [ [ OPT ] ] to [ init ] [ [ PBOPT ] ] : $ * Optional < @ callee_owned ( ) - > ( ) > <nl> / / CHECK - NEXT : dealloc_stack [ [ OPTTEMP ] ] <nl> var of : ( ( ) - > ( ) ) ! = obj . f <nl> <nl> func opt_to_static_method ( _ obj : AnyObject ) { <nl> / / CHECK : [ [ ENTRY : [ A - Za - z0 - 9 ] + ] ] ( [ [ OBJ : % [ 0 - 9 ] + ] ] : $ AnyObject ) : <nl> / / CHECK : [ [ OBJBOX : % [ 0 - 9 ] + ] ] = alloc_box $ AnyObject <nl> / / CHECK - NEXT : [ [ PBOBJ : % [ 0 - 9 ] + ] ] = project_box [ [ OBJBOX ] ] <nl> - / / CHECK : store [ [ OBJ ] ] to [ [ PBOBJ ] ] : $ * AnyObject <nl> + / / CHECK : store [ [ OBJ ] ] to [ init ] [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : [ [ OPTBOX : % [ 0 - 9 ] + ] ] = alloc_box $ Optional < @ callee_owned ( ) - > ( ) > <nl> / / CHECK - NEXT : [ [ PBO : % . * ] ] = project_box [ [ OPTBOX ] ] <nl> / / CHECK - NEXT : [ [ OBJCOPY : % [ 0 - 9 ] + ] ] = load [ [ PBOBJ ] ] : $ * AnyObject <nl> func opt_to_property ( _ obj : AnyObject ) { <nl> / / CHECK : bb0 ( [ [ OBJ : % [ 0 - 9 ] + ] ] : $ AnyObject ) : <nl> / / CHECK : [ [ OBJ_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ AnyObject <nl> / / CHECK - NEXT : [ [ PBOBJ : % [ 0 - 9 ] + ] ] = project_box [ [ OBJ_BOX ] ] <nl> - / / CHECK : store [ [ OBJ ] ] to [ [ PBOBJ ] ] : $ * AnyObject <nl> + / / CHECK : store [ [ OBJ ] ] to [ init ] [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : [ [ INT_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK - NEXT : project_box [ [ INT_BOX ] ] <nl> / / CHECK - NEXT : [ [ OBJ : % [ 0 - 9 ] + ] ] = load [ [ PBOBJ ] ] : $ * AnyObject <nl> func opt_to_property ( _ obj : AnyObject ) { <nl> / / CHECK - NEXT : [ [ BOUND_METHOD : % [ 0 - 9 ] + ] ] = partial_apply [ [ METHOD ] ] ( [ [ RAWOBJ_SELF ] ] ) : $ @ convention ( objc_method ) ( @ opened ( { { . * } } ) AnyObject ) - > Int <nl> / / CHECK - NEXT : [ [ VALUE : % [ 0 - 9 ] + ] ] = apply [ [ BOUND_METHOD ] ] ( ) : $ @ callee_owned ( ) - > Int <nl> / / CHECK - NEXT : [ [ VALUETEMP : % . * ] ] = init_enum_data_addr [ [ OPTTEMP ] ] <nl> - / / CHECK - NEXT : store [ [ VALUE ] ] to [ [ VALUETEMP ] ] <nl> + / / CHECK - NEXT : store [ [ VALUE ] ] to [ trivial ] [ [ VALUETEMP ] ] <nl> / / CHECK - NEXT : inject_enum_addr [ [ OPTTEMP ] ] { { . * } } some <nl> / / CHECK - NEXT : br bb3 <nl> var i : Int = obj . value ! <nl> func direct_to_subscript ( _ obj : AnyObject , i : Int ) { <nl> / / CHECK : bb0 ( [ [ OBJ : % [ 0 - 9 ] + ] ] : $ AnyObject , [ [ I : % [ 0 - 9 ] + ] ] : $ Int ) : <nl> / / CHECK : [ [ OBJ_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ AnyObject <nl> / / CHECK - NEXT : [ [ PBOBJ : % [ 0 - 9 ] + ] ] = project_box [ [ OBJ_BOX ] ] <nl> - / / CHECK : store [ [ OBJ ] ] to [ [ PBOBJ ] ] : $ * AnyObject <nl> + / / CHECK : store [ [ OBJ ] ] to [ init ] [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : [ [ I_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK - NEXT : [ [ PBI : % . * ] ] = project_box [ [ I_BOX ] ] <nl> - / / CHECK - NEXT : store [ [ I ] ] to [ [ PBI ] ] : $ * Int <nl> + / / CHECK - NEXT : store [ [ I ] ] to [ trivial ] [ [ PBI ] ] : $ * Int <nl> / / CHECK - NEXT : alloc_box $ Int <nl> / / CHECK - NEXT : project_box <nl> / / CHECK - NEXT : [ [ OBJ : % [ 0 - 9 ] + ] ] = load [ [ PBOBJ ] ] : $ * AnyObject <nl> func direct_to_subscript ( _ obj : AnyObject , i : Int ) { <nl> / / CHECK - NEXT : [ [ GETTER_WITH_SELF : % [ 0 - 9 ] + ] ] = partial_apply [ [ GETTER ] ] ( [ [ OBJ_REF ] ] ) : $ @ convention ( objc_method ) ( Int , @ opened ( { { . * } } ) AnyObject ) - > Int <nl> / / CHECK - NEXT : [ [ RESULT : % [ 0 - 9 ] + ] ] = apply [ [ GETTER_WITH_SELF ] ] ( [ [ I ] ] ) : $ @ callee_owned ( Int ) - > Int <nl> / / CHECK - NEXT : [ [ RESULTTEMP : % . * ] ] = init_enum_data_addr [ [ OPTTEMP ] ] <nl> - / / CHECK - NEXT : store [ [ RESULT ] ] to [ [ RESULTTEMP ] ] <nl> + / / CHECK - NEXT : store [ [ RESULT ] ] to [ trivial ] [ [ RESULTTEMP ] ] <nl> / / CHECK - NEXT : inject_enum_addr [ [ OPTTEMP ] ] { { . * } } some <nl> / / CHECK - NEXT : br bb3 <nl> var x : Int = obj [ i ] ! <nl> func opt_to_subscript ( _ obj : AnyObject , i : Int ) { <nl> / / CHECK : bb0 ( [ [ OBJ : % [ 0 - 9 ] + ] ] : $ AnyObject , [ [ I : % [ 0 - 9 ] + ] ] : $ Int ) : <nl> / / CHECK : [ [ OBJ_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ AnyObject <nl> / / CHECK - NEXT : [ [ PBOBJ : % [ 0 - 9 ] + ] ] = project_box [ [ OBJ_BOX ] ] <nl> - / / CHECK : store [ [ OBJ ] ] to [ [ PBOBJ ] ] : $ * AnyObject <nl> + / / CHECK : store [ [ OBJ ] ] to [ init ] [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : [ [ I_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK - NEXT : [ [ PBI : % . * ] ] = project_box [ [ I_BOX ] ] <nl> - / / CHECK - NEXT : store [ [ I ] ] to [ [ PBI ] ] : $ * Int <nl> + / / CHECK - NEXT : store [ [ I ] ] to [ trivial ] [ [ PBI ] ] : $ * Int <nl> / / CHECK - NEXT : [ [ OBJ : % [ 0 - 9 ] + ] ] = load [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : copy_value [ [ OBJ ] ] : $ AnyObject <nl> / / CHECK - NEXT : [ [ OBJ_REF : % [ 0 - 9 ] + ] ] = open_existential_ref [ [ OBJ ] ] : $ AnyObject to $ @ opened ( { { . * } } ) AnyObject <nl> func opt_to_subscript ( _ obj : AnyObject , i : Int ) { <nl> / / CHECK - NEXT : [ [ GETTER_WITH_SELF : % [ 0 - 9 ] + ] ] = partial_apply [ [ GETTER ] ] ( [ [ OBJ_REF ] ] ) : $ @ convention ( objc_method ) ( Int , @ opened ( { { . * } } ) AnyObject ) - > Int <nl> / / CHECK - NEXT : [ [ RESULT : % [ 0 - 9 ] + ] ] = apply [ [ GETTER_WITH_SELF ] ] ( [ [ I ] ] ) : $ @ callee_owned ( Int ) - > Int <nl> / / CHECK - NEXT : [ [ RESULTTEMP : % . * ] ] = init_enum_data_addr [ [ OPTTEMP ] ] <nl> - / / CHECK - NEXT : store [ [ RESULT ] ] to [ [ RESULTTEMP ] ] <nl> + / / CHECK - NEXT : store [ [ RESULT ] ] to [ trivial ] [ [ RESULTTEMP ] ] <nl> / / CHECK - NEXT : inject_enum_addr [ [ OPTTEMP ] ] <nl> / / CHECK - NEXT : br bb3 <nl> obj [ i ] <nl> func downcast ( _ obj : AnyObject ) - > X { <nl> / / CHECK : bb0 ( [ [ OBJ : % [ 0 - 9 ] + ] ] : $ AnyObject ) : <nl> / / CHECK : [ [ OBJ_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ AnyObject <nl> / / CHECK - NEXT : [ [ PBOBJ : % [ 0 - 9 ] + ] ] = project_box [ [ OBJ_BOX ] ] <nl> - / / CHECK : store [ [ OBJ ] ] to [ [ PBOBJ ] ] : $ * AnyObject <nl> + / / CHECK : store [ [ OBJ ] ] to [ init ] [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : [ [ OBJ : % [ 0 - 9 ] + ] ] = load [ [ PBOBJ ] ] : $ * AnyObject <nl> / / CHECK - NEXT : copy_value [ [ OBJ ] ] : $ AnyObject <nl> / / CHECK - NEXT : [ [ X : % [ 0 - 9 ] + ] ] = unconditional_checked_cast [ [ OBJ ] ] : $ AnyObject to $ X <nl> func downcast ( _ obj : AnyObject ) - > X { <nl> / / CHECK : [ [ METHOD : % . * ] ] = partial_apply [ [ FN ] ] ( [ [ SELF ] ] ) : $ @ convention ( objc_method ) ( @ opened ( " { { . * } } " ) Fruit ) - > @ autoreleased Juice <nl> / / CHECK : [ [ RESULT : % . * ] ] = apply [ [ METHOD ] ] ( ) : $ @ callee_owned ( ) - > @ owned Juice <nl> / / CHECK : [ [ PAYLOAD : % . * ] ] = init_enum_data_addr [ [ BOX ] ] : $ * Optional < Juice > , # Optional . some ! enumelt . 1 <nl> - / / CHECK : store [ [ RESULT ] ] to [ [ PAYLOAD ] ] <nl> + / / CHECK : store [ [ RESULT ] ] to [ init ] [ [ PAYLOAD ] ] <nl> / / CHECK : inject_enum_addr [ [ BOX ] ] : $ * Optional < Juice > , # Optional . some ! enumelt . 1 <nl> / / CHECK : br bb3 <nl> <nl> mmm a / test / SILGen / dynamic_self . swift <nl> ppp b / test / SILGen / dynamic_self . swift <nl> func testObjCInit ( meta : ObjCInit . Type ) { <nl> / / CHECK : [ [ OBJ : % [ 0 - 9 ] + ] ] = alloc_ref_dynamic [ objc ] [ [ OBJC_META ] ] : $ @ objc_metatype ObjCInit . Type , $ ObjCInit <nl> / / CHECK : [ [ INIT : % [ 0 - 9 ] + ] ] = class_method [ volatile ] [ [ OBJ ] ] : $ ObjCInit , # ObjCInit . init ! initializer . 1 . foreign : ( ObjCInit . Type ) - > ( ) - > ObjCInit , $ @ convention ( objc_method ) ( @ owned ObjCInit ) - > @ owned ObjCInit <nl> / / CHECK : [ [ RESULT_OBJ : % [ 0 - 9 ] + ] ] = apply [ [ INIT ] ] ( [ [ OBJ ] ] ) : $ @ convention ( objc_method ) ( @ owned ObjCInit ) - > @ owned ObjCInit <nl> - / / CHECK : store [ [ RESULT_OBJ ] ] to [ [ PB ] ] : $ * ObjCInit <nl> + / / CHECK : store [ [ RESULT_OBJ ] ] to [ init ] [ [ PB ] ] : $ * ObjCInit <nl> / / CHECK : destroy_value [ [ O ] ] : $ @ box ObjCInit <nl> / / CHECK : [ [ RESULT : % [ 0 - 9 ] + ] ] = tuple ( ) <nl> / / CHECK : return [ [ RESULT ] ] : $ ( ) <nl> mmm a / test / SILGen / enum . swift <nl> ppp b / test / SILGen / enum . swift <nl> func AddressOnly_cases ( _ s : S ) { <nl> / / CHECK - NEXT : [ [ MERE : % . * ] ] = alloc_stack $ AddressOnly <nl> / / CHECK - NEXT : [ [ PAYLOAD : % . * ] ] = init_enum_data_addr [ [ MERE ] ] <nl> / / CHECK - NEXT : [ [ PAYLOAD_ADDR : % . * ] ] = init_existential_addr [ [ PAYLOAD ] ] <nl> - / / CHECK - NEXT : store % 0 to [ [ PAYLOAD_ADDR ] ] <nl> + / / CHECK - NEXT : store % 0 to [ trivial ] [ [ PAYLOAD_ADDR ] ] <nl> / / CHECK - NEXT : inject_enum_addr [ [ MERE ] ] <nl> / / CHECK - NEXT : destroy_addr [ [ MERE ] ] <nl> / / CHECK - NEXT : dealloc_stack [ [ MERE ] ] <nl> enum Foo { case A ( P , String ) } <nl> / / CHECK - NEXT : [ [ LEFT : % . * ] ] = tuple_element_addr [ [ PAYLOAD ] ] : $ * ( P , String ) , 0 <nl> / / CHECK - NEXT : [ [ RIGHT : % . * ] ] = tuple_element_addr [ [ PAYLOAD ] ] : $ * ( P , String ) , 1 <nl> / / CHECK - NEXT : copy_addr [ take ] % 1 to [ initialization ] [ [ LEFT ] ] : $ * P <nl> - / / CHECK - NEXT : store % 2 to [ [ RIGHT ] ] <nl> + / / CHECK - NEXT : store % 2 to [ init ] [ [ RIGHT ] ] <nl> / / CHECK - NEXT : inject_enum_addr % 0 : $ * Foo , # Foo . A ! enumelt . 1 <nl> / / CHECK : return <nl> / / CHECK - NEXT : } <nl> mmm a / test / SILGen / erasure_reabstraction . swift <nl> ppp b / test / SILGen / erasure_reabstraction . swift <nl> class Bar { } <nl> <nl> / / CHECK : [ [ CONCRETE : % . * ] ] = init_existential_addr [ [ EXISTENTIAL : % . * ] ] : $ * Any , $ Foo . Type <nl> / / CHECK : [ [ METATYPE : % . * ] ] = metatype $ @ thick Foo . Type <nl> - / / CHECK : store [ [ METATYPE ] ] to [ [ CONCRETE ] ] : $ * @ thick Foo . Type <nl> + / / CHECK : store [ [ METATYPE ] ] to [ trivial ] [ [ CONCRETE ] ] : $ * @ thick Foo . Type <nl> let x : Any = Foo . self <nl> <nl> <nl> let x : Any = Foo . self <nl> / / CHECK : [ [ CLOSURE_THICK : % . * ] ] = thin_to_thick_function [ [ CLOSURE ] ] <nl> / / CHECK : [ [ REABSTRACTION_THUNK : % . * ] ] = function_ref @ _TTRXFo___XFo_iT__iT__ <nl> / / CHECK : [ [ CLOSURE_REABSTRACTED : % . * ] ] = partial_apply [ [ REABSTRACTION_THUNK ] ] ( [ [ CLOSURE_THICK ] ] ) <nl> - / / CHECK : store [ [ CLOSURE_REABSTRACTED ] ] to [ [ CONCRETE ] ] <nl> + / / CHECK : store [ [ CLOSURE_REABSTRACTED ] ] to [ init ] [ [ CONCRETE ] ] <nl> let y : Any = { ( ) - > ( ) in ( ) } <nl> <nl> mmm a / test / SILGen / errors . swift <nl> ppp b / test / SILGen / errors . swift <nl> func make_a_cat ( ) throws - > Cat { <nl> / / CHECK - NEXT : [ [ ADDR : % . * ] ] = project_existential_box $ HomeworkError in [ [ BOX ] ] : $ Error <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = metatype $ @ thin HomeworkError . Type <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = enum $ HomeworkError , # HomeworkError . TooHard ! enumelt <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ init ] [ [ ADDR ] ] <nl> / / CHECK - NEXT : builtin " willThrow " <nl> / / CHECK - NEXT : throw [ [ BOX ] ] <nl> func dont_make_a_cat ( ) throws - > Cat { <nl> func dont_make_a_cat ( ) throws - > Cat { <nl> / / CHECK - NEXT : [ [ ADDR : % . * ] ] = project_existential_box $ HomeworkError in [ [ BOX ] ] : $ Error <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = metatype $ @ thin HomeworkError . Type <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = enum $ HomeworkError , # HomeworkError . TooMuch ! enumelt <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ init ] [ [ ADDR ] ] <nl> / / CHECK - NEXT : builtin " willThrow " <nl> / / CHECK - NEXT : destroy_addr % 1 : $ * T <nl> / / CHECK - NEXT : throw [ [ BOX ] ] <nl> func dont_return < T > ( _ argument : T ) throws - > T { <nl> / / Merge point for the ternary operator . Call dont_return with the result . <nl> / / CHECK : [ [ TERNARY_CONT ] ] ( [ [ T0 : % . * ] ] : $ Cat ) : <nl> / / CHECK - NEXT : [ [ ARG_TEMP : % . * ] ] = alloc_stack $ Cat <nl> - / / CHECK - NEXT : store [ [ T0 ] ] to [ [ ARG_TEMP ] ] <nl> + / / CHECK - NEXT : store [ [ T0 ] ] to [ init ] [ [ ARG_TEMP ] ] <nl> / / CHECK - NEXT : [ [ RET_TEMP : % . * ] ] = alloc_stack $ Cat <nl> / / CHECK - NEXT : try_apply [ [ DR_FN ] ] < Cat > ( [ [ RET_TEMP ] ] , [ [ ARG_TEMP ] ] ) : $ @ convention ( thin ) < τ_0_0 > ( @ in τ_0_0 ) - > ( @ out τ_0_0 , @ error Error ) , normal [ [ DR_NORMAL : bb [ 0 - 9 ] + ] ] , error [ [ DR_ERROR : bb [ 0 - 9 ] + ] ] <nl> / / CHECK : [ [ DR_NORMAL ] ] ( { { % . * } } : $ ( ) ) : <nl> func dont_return < T > ( _ argument : T ) throws - > T { <nl> / / Catch dispatch block . <nl> / / CHECK : [ [ CATCH : bb [ 0 - 9 ] + ] ] ( [ [ ERROR : % . * ] ] : $ Error ) : <nl> / / CHECK - NEXT : [ [ SRC_TEMP : % . * ] ] = alloc_stack $ Error <nl> - / / CHECK - NEXT : store [ [ ERROR ] ] to [ [ SRC_TEMP ] ] <nl> + / / CHECK - NEXT : store [ [ ERROR ] ] to [ init ] [ [ SRC_TEMP ] ] <nl> / / CHECK - NEXT : [ [ DEST_TEMP : % . * ] ] = alloc_stack $ HomeworkError <nl> / / CHECK - NEXT : checked_cast_addr_br copy_on_success Error in [ [ SRC_TEMP ] ] : $ * Error to HomeworkError in [ [ DEST_TEMP ] ] : $ * HomeworkError , [ [ IS_HWE : bb [ 0 - 9 ] + ] ] , [ [ NOT_HWE : bb [ 0 - 9 ] + ] ] <nl> <nl> func test_variadic ( _ cat : Cat ) throws { <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TF6errors10make_a_catFzT_CS_3Cat : $ @ convention ( thin ) ( ) - > ( @ owned Cat , @ error Error ) <nl> / / CHECK : try_apply [ [ T0 ] ] ( ) : $ @ convention ( thin ) ( ) - > ( @ owned Cat , @ error Error ) , normal [ [ NORM_0 : bb [ 0 - 9 ] + ] ] , error [ [ ERR_0 : bb [ 0 - 9 ] + ] ] <nl> / / CHECK : [ [ NORM_0 ] ] ( [ [ CAT0 : % . * ] ] : $ Cat ) : <nl> - / / CHECK - NEXT : store [ [ CAT0 ] ] to [ [ ELT0 ] ] <nl> + / / CHECK - NEXT : store [ [ CAT0 ] ] to [ init ] [ [ ELT0 ] ] <nl> / / Element 1 . <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = integer_literal $ Builtin . Word , 1 <nl> / / CHECK - NEXT : [ [ ELT1 : % . * ] ] = index_addr [ [ ELT0 ] ] : $ * Cat , [ [ T0 ] ] <nl> / / CHECK - NEXT : copy_value % 0 <nl> - / / CHECK - NEXT : store % 0 to [ [ ELT1 ] ] <nl> + / / CHECK - NEXT : store % 0 to [ init ] [ [ ELT1 ] ] <nl> / / Element 2 . <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = integer_literal $ Builtin . Word , 2 <nl> / / CHECK - NEXT : [ [ ELT2 : % . * ] ] = index_addr [ [ ELT0 ] ] : $ * Cat , [ [ T0 ] ] <nl> func test_variadic ( _ cat : Cat ) throws { <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = function_ref @ _TF6errors10make_a_catFzT_CS_3Cat : $ @ convention ( thin ) ( ) - > ( @ owned Cat , @ error Error ) <nl> / / CHECK - NEXT : try_apply [ [ T0 ] ] ( ) : $ @ convention ( thin ) ( ) - > ( @ owned Cat , @ error Error ) , normal [ [ NORM_2 : bb [ 0 - 9 ] + ] ] , error [ [ ERR_2 : bb [ 0 - 9 ] + ] ] <nl> / / CHECK : [ [ NORM_2 ] ] ( [ [ CAT2 : % . * ] ] : $ Cat ) : <nl> - / / CHECK - NEXT : store [ [ CAT2 ] ] to [ [ ELT2 ] ] <nl> + / / CHECK - NEXT : store [ [ CAT2 ] ] to [ init ] [ [ ELT2 ] ] <nl> / / Element 3 . <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = integer_literal $ Builtin . Word , 3 <nl> / / CHECK - NEXT : [ [ ELT3 : % . * ] ] = index_addr [ [ ELT0 ] ] : $ * Cat , [ [ T0 ] ] <nl> func test_variadic ( _ cat : Cat ) throws { <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = function_ref @ _TF6errors10make_a_catFzT_CS_3Cat : $ @ convention ( thin ) ( ) - > ( @ owned Cat , @ error Error ) <nl> / / CHECK - NEXT : try_apply [ [ T0 ] ] ( ) : $ @ convention ( thin ) ( ) - > ( @ owned Cat , @ error Error ) , normal [ [ NORM_3 : bb [ 0 - 9 ] + ] ] , error [ [ ERR_3 : bb [ 0 - 9 ] + ] ] <nl> / / CHECK : [ [ NORM_3 ] ] ( [ [ CAT3 : % . * ] ] : $ Cat ) : <nl> - / / CHECK - NEXT : store [ [ CAT3 ] ] to [ [ ELT3 ] ] <nl> + / / CHECK - NEXT : store [ [ CAT3 ] ] to [ init ] [ [ ELT3 ] ] <nl> / / Complete the call and return . <nl> / / CHECK - NEXT : try_apply [ [ TAKE_FN ] ] ( [ [ ARRAY ] ] ) : $ @ convention ( thin ) ( @ owned Array < Cat > ) - > @ error Error , normal [ [ NORM_CALL : bb [ 0 - 9 ] + ] ] , error [ [ ERR_CALL : bb [ 0 - 9 ] + ] ] <nl> / / CHECK : [ [ NORM_CALL ] ] ( [ [ T0 : % . * ] ] : $ ( ) ) : <nl> func supportStructure ( _ b : inout Bridge , name : String ) throws { <nl> / / CHECK - NEXT : [ [ GETTER : % . * ] ] = function_ref @ _TFV6errors6Bridgeg9subscriptFSSVS_5Pylon : <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = apply [ [ GETTER ] ] ( [ [ INDEX ] ] , [ [ BASE ] ] ) <nl> / / CHECK - NEXT : destroy_value [ [ BASE ] ] <nl> - / / CHECK - NEXT : store [ [ T0 ] ] to [ [ TEMP ] ] <nl> + / / CHECK - NEXT : store [ [ T0 ] ] to [ init ] [ [ TEMP ] ] <nl> / / CHECK - NEXT : try_apply [ [ SUPPORT ] ] ( [ [ TEMP ] ] ) : { { . * } } , normal [ [ BB_NORMAL : bb [ 0 - 9 ] + ] ] , error [ [ BB_ERROR : bb [ 0 - 9 ] + ] ] <nl> <nl> / / CHECK : [ [ BB_NORMAL ] ] <nl> func testOptionalTry ( ) { <nl> / / CHECK : [ [ FN : % . + ] ] = function_ref @ _TF6errors10make_a_catFzT_CS_3Cat <nl> / / CHECK - NEXT : try_apply [ [ FN ] ] ( ) : $ @ convention ( thin ) ( ) - > ( @ owned Cat , @ error Error ) , normal [ [ SUCCESS : [ ^ ] + ] ] , error [ [ CLEANUPS : [ ^ ] + ] ] , <nl> / / CHECK : [ [ SUCCESS ] ] ( [ [ VALUE : % . + ] ] : $ Cat ) <nl> - / / CHECK - NEXT : store [ [ VALUE ] ] to [ [ BOX_DATA ] ] : $ * Cat <nl> + / / CHECK - NEXT : store [ [ VALUE ] ] to [ init ] [ [ BOX_DATA ] ] : $ * Cat <nl> / / CHECK - NEXT : inject_enum_addr [ [ PB ] ] : $ * Optional < Cat > , # Optional . some ! enumelt . 1 <nl> / / CHECK - NEXT : br [ [ DONE : [ ^ ] + ] ] , <nl> / / CHECK : [ [ DONE ] ] : <nl> mmm a / test / SILGen / foreign_errors . swift <nl> ppp b / test / SILGen / foreign_errors . swift <nl> func test0 ( ) throws { <nl> / / CHECK : [ [ ERR_TEMP1 : % . * ] ] = alloc_stack $ @ sil_unmanaged Optional < NSError > <nl> / / CHECK : [ [ T0 : % . * ] ] = load [ [ ERR_TEMP0 ] ] <nl> / / CHECK : [ [ T1 : % . * ] ] = ref_to_unmanaged [ [ T0 ] ] <nl> - / / CHECK : store [ [ T1 ] ] to [ [ ERR_TEMP1 ] ] <nl> + / / CHECK : store [ [ T1 ] ] to [ trivial ] [ [ ERR_TEMP1 ] ] <nl> / / CHECK : address_to_pointer [ [ ERR_TEMP1 ] ] <nl> <nl> / / Call the method . <nl> extension NSObject { <nl> / / CHECK : [ [ OBJCERR : % . * ] ] = enum $ Optional < NSError > , # Optional . some ! enumelt . 1 , [ [ T1 ] ] : $ NSError <nl> / / CHECK : [ [ SETTER : % . * ] ] = function_ref @ _TFVs33AutoreleasingUnsafeMutablePointers7pointeex : <nl> / / CHECK : [ [ TEMP : % . * ] ] = alloc_stack $ Optional < NSError > <nl> - / / CHECK : store [ [ OBJCERR ] ] to [ [ TEMP ] ] <nl> + / / CHECK : store [ [ OBJCERR ] ] to [ init ] [ [ TEMP ] ] <nl> / / CHECK : apply [ [ SETTER ] ] < Optional < NSError > > ( [ [ TEMP ] ] , [ [ UNWRAPPED_OUT ] ] ) <nl> / / CHECK : dealloc_stack [ [ TEMP ] ] <nl> / / CHECK : br bb5 <nl> extension NSObject { <nl> / / CHECK : [ [ OBJCERR : % . * ] ] = enum $ Optional < NSError > , # Optional . some ! enumelt . 1 , [ [ T1 ] ] : $ NSError <nl> / / CHECK : [ [ SETTER : % . * ] ] = function_ref @ _TFVs33AutoreleasingUnsafeMutablePointers7pointeex : <nl> / / CHECK : [ [ TEMP : % . * ] ] = alloc_stack $ Optional < NSError > <nl> - / / CHECK : store [ [ OBJCERR ] ] to [ [ TEMP ] ] <nl> + / / CHECK : store [ [ OBJCERR ] ] to [ init ] [ [ TEMP ] ] <nl> / / CHECK : apply [ [ SETTER ] ] < Optional < NSError > > ( [ [ TEMP ] ] , [ [ UNWRAPPED_OUT ] ] ) <nl> / / CHECK : dealloc_stack [ [ TEMP ] ] <nl> / / CHECK : br bb5 <nl> mmm a / test / SILGen / functions . swift <nl> ppp b / test / SILGen / functions . swift <nl> func calls ( _ i : Int , j : Int , k : Int ) { <nl> / / CHECK : [ [ FADDR : % . * ] ] = project_box [ [ FBOX ] ] <nl> / / CHECK : [ [ FUNC_THIN : % [ 0 - 9 ] + ] ] = function_ref @ _TF9functions19standalone_function { { . * } } : $ @ convention ( thin ) ( Builtin . Int64 , Builtin . Int64 ) - > Builtin . Int64 <nl> / / CHECK : [ [ FUNC_THICK : % [ 0 - 9 ] + ] ] = thin_to_thick_function [ [ FUNC_THIN ] ] <nl> - / / CHECK : store [ [ FUNC_THICK ] ] to [ [ FADDR ] ] <nl> + / / CHECK : store [ [ FUNC_THICK ] ] to [ init ] [ [ FADDR ] ] <nl> var f = standalone_function <nl> / / CHECK : [ [ F : % [ 0 - 9 ] + ] ] = load [ [ FADDR ] ] <nl> / / CHECK : [ [ I : % [ 0 - 9 ] + ] ] = load [ [ IADDR ] ] <nl> mmm a / test / SILGen / guaranteed_self . swift <nl> ppp b / test / SILGen / guaranteed_self . swift <nl> class D : C { <nl> / / CHECK - NOT : [ [ SELF_ADDR ] ] <nl> / / CHECK : [ [ SUPER2 : % . * ] ] = apply { { . * } } ( [ [ SUPER1 ] ] ) <nl> / / CHECK - NEXT : [ [ SELF2 : % . * ] ] = unchecked_ref_cast [ [ SUPER2 ] ] <nl> - / / CHECK - NEXT : store [ [ SELF2 ] ] to [ [ SELF_ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ SELF2 ] ] to [ init ] [ [ SELF_ADDR ] ] <nl> / / CHECK - NOT : [ [ SELF_ADDR ] ] <nl> / / CHECK - NOT : [ [ SELF1 ] ] <nl> / / CHECK - NOT : [ [ SUPER1 ] ] <nl> class LetFieldClass { <nl> / / CHECK - NEXT : [ [ KRAKEN_ADDR : % . * ] ] = ref_element_addr [ [ CLS ] ] : $ LetFieldClass , # LetFieldClass . letk <nl> / / CHECK - NEXT : [ [ KRAKEN2 : % . * ] ] = load [ [ KRAKEN_ADDR ] ] <nl> / / CHECK - NEXT : copy_value [ [ KRAKEN2 ] ] <nl> - / / CHECK - NEXT : store [ [ KRAKEN2 ] ] to [ [ PB ] ] <nl> + / / CHECK - NEXT : store [ [ KRAKEN2 ] ] to [ init ] [ [ PB ] ] <nl> / / CHECK : [ [ DESTROY_SHIP_FUN : % . * ] ] = function_ref @ _TF15guaranteed_self11destroyShipFCS_6KrakenT_ : $ @ convention ( thin ) ( @ owned Kraken ) - > ( ) <nl> / / CHECK - NEXT : [ [ KRAKEN_COPY : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK - NEXT : copy_value [ [ KRAKEN_COPY ] ] <nl> class LetFieldClass { <nl> / / CHECK - NEXT : [ [ PB : % . * ] ] = project_box [ [ KRAKEN_BOX ] ] <nl> / / CHECK - NEXT : [ [ KRAKEN_GETTER_FUN : % . * ] ] = class_method [ [ CLS ] ] : $ LetFieldClass , # LetFieldClass . vark ! getter . 1 : ( LetFieldClass ) - > ( ) - > Kraken , $ @ convention ( method ) ( @ guaranteed LetFieldClass ) - > @ owned Kraken <nl> / / CHECK - NEXT : [ [ KRAKEN2 : % . * ] ] = apply [ [ KRAKEN_GETTER_FUN ] ] ( [ [ CLS ] ] ) <nl> - / / CHECK - NEXT : store [ [ KRAKEN2 ] ] to [ [ PB ] ] <nl> + / / CHECK - NEXT : store [ [ KRAKEN2 ] ] to [ init ] [ [ PB ] ] <nl> / / CHECK : [ [ DESTROY_SHIP_FUN : % . * ] ] = function_ref @ _TF15guaranteed_self11destroyShipFCS_6KrakenT_ : $ @ convention ( thin ) ( @ owned Kraken ) - > ( ) <nl> / / CHECK - NEXT : [ [ KRAKEN_COPY : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK - NEXT : copy_value [ [ KRAKEN_COPY ] ] <nl> mmm a / test / SILGen / if_while_binding . swift <nl> ppp b / test / SILGen / if_while_binding . swift <nl> func if_multi ( ) { <nl> <nl> / / CHECK : [ [ IF_BODY ] ] ( [ [ BVAL : % [ 0 - 9 ] + ] ] : $ String ) : <nl> if let a = foo ( ) , var b = bar ( ) { <nl> - / / CHECK : store [ [ BVAL ] ] to [ [ PB ] ] : $ * String <nl> + / / CHECK : store [ [ BVAL ] ] to [ init ] [ [ PB ] ] : $ * String <nl> / / CHECK : debug_value { { . * } } : $ String , let , name " c " <nl> / / CHECK : destroy_value [ [ B ] ] <nl> / / CHECK : destroy_value [ [ A ] ] <nl> func if_multi_else ( ) { <nl> <nl> / / CHECK : [ [ IF_BODY ] ] ( [ [ BVAL : % [ 0 - 9 ] + ] ] : $ String ) : <nl> if let a = foo ( ) , var b = bar ( ) { <nl> - / / CHECK : store [ [ BVAL ] ] to [ [ PB ] ] : $ * String <nl> + / / CHECK : store [ [ BVAL ] ] to [ init ] [ [ PB ] ] : $ * String <nl> / / CHECK : debug_value { { . * } } : $ String , let , name " c " <nl> / / CHECK : destroy_value [ [ B ] ] <nl> / / CHECK : destroy_value [ [ A ] ] <nl> mmm a / test / SILGen / implicitly_unwrapped_optional . swift <nl> ppp b / test / SILGen / implicitly_unwrapped_optional . swift <nl> func foo ( f f : ( ( ) - > ( ) ) ! ) { <nl> / / CHECK : bb0 ( [ [ T0 : % . * ] ] : $ Optional < @ callee_owned ( ) - > ( ) > ) : <nl> / / CHECK : [ [ F : % . * ] ] = alloc_box $ Optional < @ callee_owned ( ) - > ( ) > <nl> / / CHECK - NEXT : [ [ PF : % . * ] ] = project_box [ [ F ] ] <nl> - / / CHECK : store [ [ T0 ] ] to [ [ PF ] ] <nl> + / / CHECK : store [ [ T0 ] ] to [ init ] [ [ PF ] ] <nl> / / CHECK : [ [ T1 : % . * ] ] = select_enum_addr [ [ PF ] ] <nl> / / CHECK - NEXT : cond_br [ [ T1 ] ] , bb1 , bb3 <nl> / / If it does , project and load the value out of the implicitly unwrapped <nl> mmm a / test / SILGen / indirect_enum . swift <nl> ppp b / test / SILGen / indirect_enum . swift <nl> func TreeA_cases < T > ( _ t : T , l : TreeA < T > , r : TreeA < T > ) { <nl> / / CHECK - NEXT : [ [ LEFT : % . * ] ] = tuple_element_addr [ [ PB ] ] : $ * ( left : TreeA < T > , right : TreeA < T > ) , 0 <nl> / / CHECK - NEXT : [ [ RIGHT : % . * ] ] = tuple_element_addr [ [ PB ] ] : $ * ( left : TreeA < T > , right : TreeA < T > ) , 1 <nl> / / CHECK - NEXT : copy_value % 1 <nl> - / / CHECK - NEXT : store % 1 to [ [ LEFT ] ] <nl> + / / CHECK - NEXT : store % 1 to [ init ] [ [ LEFT ] ] <nl> / / CHECK - NEXT : copy_value % 2 <nl> - / / CHECK - NEXT : store % 2 to [ [ RIGHT ] ] <nl> + / / CHECK - NEXT : store % 2 to [ init ] [ [ RIGHT ] ] <nl> / / CHECK - NEXT : [ [ BRANCH : % . * ] ] = enum $ TreeA < T > , # TreeA . Branch ! enumelt . 1 , [ [ BOX ] ] <nl> / / CHECK - NEXT : destroy_value [ [ BRANCH ] ] <nl> / / CHECK - NEXT : destroy_value % 2 <nl> func TreeA_reabstract ( _ f : @ escaping ( Int ) - > Int ) { <nl> / / CHECK - NEXT : copy_value % 0 <nl> / / CHECK : [ [ THUNK : % . * ] ] = function_ref @ _TTRXFo_dSi_dSi_XFo_iSi_iSi_ <nl> / / CHECK - NEXT : [ [ FN : % . * ] ] = partial_apply [ [ THUNK ] ] ( % 0 ) <nl> - / / CHECK - NEXT : store [ [ FN ] ] to [ [ PB ] ] <nl> + / / CHECK - NEXT : store [ [ FN ] ] to [ init ] [ [ PB ] ] <nl> / / CHECK - NEXT : [ [ LEAF : % . * ] ] = enum $ TreeA < ( Int ) - > Int > , # TreeA . Leaf ! enumelt . 1 , [ [ BOX ] ] <nl> / / CHECK - NEXT : destroy_value [ [ LEAF ] ] <nl> / / CHECK - NEXT : destroy_value % 0 <nl> func TreeInt_cases ( _ t : Int , l : TreeInt , r : TreeInt ) { <nl> / / CHECK - NEXT : [ [ LEFT : % . * ] ] = tuple_element_addr [ [ PB ] ] <nl> / / CHECK - NEXT : [ [ RIGHT : % . * ] ] = tuple_element_addr [ [ PB ] ] <nl> / / CHECK - NEXT : copy_value % 1 <nl> - / / CHECK - NEXT : store % 1 to [ [ LEFT ] ] <nl> + / / CHECK - NEXT : store % 1 to [ init ] [ [ LEFT ] ] <nl> / / CHECK - NEXT : copy_value % 2 <nl> - / / CHECK - NEXT : store % 2 to [ [ RIGHT ] ] <nl> + / / CHECK - NEXT : store % 2 to [ init ] [ [ RIGHT ] ] <nl> / / CHECK - NEXT : [ [ BRANCH : % . * ] ] = enum $ TreeInt , # TreeInt . Branch ! enumelt . 1 , [ [ BOX ] ] <nl> / / CHECK - NEXT : destroy_value [ [ BRANCH ] ] <nl> / / CHECK - NEXT : destroy_value % 2 <nl> mmm a / test / SILGen / init_ref_delegation . swift <nl> ppp b / test / SILGen / init_ref_delegation . swift <nl> struct S2 { <nl> / / CHECK : [ [ X_META : % [ 0 - 9 ] + ] ] = metatype $ @ thin X . Type <nl> / / CHECK : [ [ X : % [ 0 - 9 ] + ] ] = apply [ [ X_INIT ] ] ( [ [ X_META ] ] ) : $ @ convention ( method ) ( @ thin X . Type ) - > X <nl> / / CHECK : [ [ X_BOX : % [ 0 - 9 ] + ] ] = alloc_stack $ X <nl> - / / CHECK : store [ [ X ] ] to [ [ X_BOX ] ] : $ * X <nl> + / / CHECK : store [ [ X ] ] to [ trivial ] [ [ X_BOX ] ] : $ * X <nl> / / CHECK : [ [ SELF_BOX1 : % [ 0 - 9 ] + ] ] = apply [ [ S2_DELEG_INIT ] ] < X > ( [ [ X_BOX ] ] , [ [ S2_META ] ] ) : $ @ convention ( method ) < τ_0_0 > ( @ in τ_0_0 , @ thin S2 . Type ) - > S2 <nl> / / CHECK : assign [ [ SELF_BOX1 ] ] to [ [ SELF ] ] : $ * S2 <nl> / / CHECK : dealloc_stack [ [ X_BOX ] ] : $ * X <nl> class C1 { <nl> <nl> / / CHECK : [ [ DELEG_INIT : % [ 0 - 9 ] + ] ] = class_method [ [ SELF_FROM_BOX ] ] : $ C1 , # C1 . init ! initializer . 1 : ( C1 . Type ) - > ( X , X ) - > C1 , $ @ convention ( method ) ( X , X , @ owned C1 ) - > @ owned C1 <nl> / / CHECK : [ [ SELFP : % [ 0 - 9 ] + ] ] = apply [ [ DELEG_INIT ] ] ( [ [ X ] ] , [ [ X ] ] , [ [ SELF_FROM_BOX ] ] ) : $ @ convention ( method ) ( X , X , @ owned C1 ) - > @ owned C1 <nl> - / / CHECK : store [ [ SELFP ] ] to [ [ SELF ] ] : $ * C1 <nl> + / / CHECK : store [ [ SELFP ] ] to [ init ] [ [ SELF ] ] : $ * C1 <nl> / / CHECK : [ [ SELFP : % [ 0 - 9 ] + ] ] = load [ [ SELF ] ] : $ * C1 <nl> / / CHECK : copy_value [ [ SELFP ] ] : $ C1 <nl> / / CHECK : destroy_value [ [ SELF_BOX ] ] : $ @ box C1 <nl> class C1 { <nl> <nl> / / CHECK : [ [ DELEG_INIT : % [ 0 - 9 ] + ] ] = class_method [ [ SELF ] ] : $ C2 , # C2 . init ! initializer . 1 : ( C2 . Type ) - > ( X , X ) - > C2 , $ @ convention ( method ) ( X , X , @ owned C2 ) - > @ owned C2 <nl> / / CHECK : [ [ REPLACE_SELF : % [ 0 - 9 ] + ] ] = apply [ [ DELEG_INIT ] ] ( [ [ X ] ] , [ [ X ] ] , [ [ SELF ] ] ) : $ @ convention ( method ) ( X , X , @ owned C2 ) - > @ owned C2 <nl> - / / CHECK : store [ [ REPLACE_SELF ] ] to [ [ UNINIT_SELF ] ] : $ * C2 <nl> + / / CHECK : store [ [ REPLACE_SELF ] ] to [ init ] [ [ UNINIT_SELF ] ] : $ * C2 <nl> / / CHECK : [ [ VAR_15 : % [ 0 - 9 ] + ] ] = load [ [ UNINIT_SELF ] ] : $ * C2 <nl> / / CHECK : copy_value [ [ VAR_15 ] ] : $ C2 <nl> / / CHECK : destroy_value [ [ SELF_BOX ] ] : $ @ box C2 <nl> mmm a / test / SILGen / lazy_globals . swift <nl> ppp b / test / SILGen / lazy_globals . swift <nl> <nl> / / CHECK : sil private @ globalinit_ [ [ T : . * ] ] _func0 : $ @ convention ( thin ) ( ) - > ( ) { <nl> / / CHECK : alloc_global @ _Tv12lazy_globals1xSi <nl> / / CHECK : [ [ XADDR : % . * ] ] = global_addr @ _Tv12lazy_globals1xSi : $ * Int <nl> - / / CHECK : store { { % . * } } to [ [ XADDR ] ] : $ * Int <nl> + / / CHECK : store { { % . * } } to [ trivial ] [ [ XADDR ] ] : $ * Int <nl> <nl> / / CHECK : sil hidden [ global_init ] @ _TF12lazy_globalsau1xSi : $ @ convention ( thin ) ( ) - > Builtin . RawPointer { <nl> / / CHECK : [ [ TOKEN_ADDR : % . * ] ] = global_addr @ globalinit_ [ [ T ] ] _token0 : $ * Builtin . Word <nl> var x : Int = 0 <nl> / / CHECK : sil private @ globalinit_ [ [ T : . * ] ] _func1 : $ @ convention ( thin ) ( ) - > ( ) { <nl> / / CHECK : alloc_global @ _TZvV12lazy_globals3Foo3fooSi <nl> / / CHECK : [ [ XADDR : % . * ] ] = global_addr @ _TZvV12lazy_globals3Foo3fooSi : $ * Int <nl> - / / CHECK : store { { . * } } to [ [ XADDR ] ] : $ * Int <nl> + / / CHECK : store { { . * } } to [ trivial ] [ [ XADDR ] ] : $ * Int <nl> / / CHECK : return <nl> <nl> struct Foo { <nl> struct Foo { <nl> / / CHECK : sil private @ globalinit_ [ [ T : . * ] ] _func3 : $ @ convention ( thin ) ( ) - > ( ) { <nl> / / CHECK : alloc_global @ _TZvO12lazy_globals3Bar3barSi <nl> / / CHECK : [ [ XADDR : % . * ] ] = global_addr @ _TZvO12lazy_globals3Bar3barSi : $ * Int <nl> - / / CHECK : store { { . * } } to [ [ XADDR ] ] : $ * Int <nl> + / / CHECK : store { { . * } } to [ trivial ] [ [ XADDR ] ] : $ * Int <nl> / / CHECK : return <nl> <nl> enum Bar { <nl> mmm a / test / SILGen / let_decls . swift <nl> ppp b / test / SILGen / let_decls . swift <nl> func test_weird_property ( _ v : WeirdPropertyTest , i : Int ) - > Int { <nl> var v = v <nl> / / CHECK : [ [ VBOX : % [ 0 - 9 ] + ] ] = alloc_box $ WeirdPropertyTest <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ VBOX ] ] <nl> - / / CHECK : store % 0 to [ [ PB ] ] <nl> + / / CHECK : store % 0 to [ trivial ] [ [ PB ] ] <nl> <nl> / / The setter isn ' t mutating , so we need to load the box . <nl> / / CHECK : [ [ VVAL : % [ 0 - 9 ] + ] ] = load [ [ PB ] ] <nl> struct LetPropertyStruct { <nl> / / CHECK : bb0 ( % 0 : $ LetPropertyStruct ) : <nl> / / CHECK : [ [ ABOX : % [ 0 - 9 ] + ] ] = alloc_box $ LetPropertyStruct <nl> / / CHECK : [ [ A : % [ 0 - 9 ] + ] ] = project_box [ [ ABOX ] ] <nl> - / / CHECK : store % 0 to [ [ A ] ] : $ * LetPropertyStruct <nl> + / / CHECK : store % 0 to [ trivial ] [ [ A ] ] : $ * LetPropertyStruct <nl> / / CHECK : [ [ STRUCT : % [ 0 - 9 ] + ] ] = load [ [ A ] ] : $ * LetPropertyStruct <nl> / / CHECK : [ [ PROP : % [ 0 - 9 ] + ] ] = struct_extract [ [ STRUCT ] ] : $ LetPropertyStruct , # LetPropertyStruct . lp <nl> / / CHECK : destroy_value [ [ ABOX ] ] : $ @ box LetPropertyStruct <nl> mmm a / test / SILGen / lifetime . swift <nl> ppp b / test / SILGen / lifetime . swift <nl> func reftype_arg ( _ a : Ref ) { <nl> / / CHECK : bb0 ( [ [ A : % [ 0 - 9 ] + ] ] : $ Ref ) : <nl> / / CHECK : [ [ AADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Ref <nl> / / CHECK : [ [ PA : % [ 0 - 9 ] + ] ] = project_box [ [ AADDR ] ] <nl> - / / CHECK : store [ [ A ] ] to [ [ PA ] ] <nl> + / / CHECK : store [ [ A ] ] to [ init ] [ [ PA ] ] <nl> / / CHECK : destroy_value [ [ AADDR ] ] <nl> / / CHECK : return <nl> } <nl> func reftype_call_store_to_local ( ) { <nl> / / CHECK : = function_ref @ _TF8lifetime12reftype_funcFT_CS_3Ref : $ @ convention ( thin ) ( ) - > @ owned Ref <nl> / / CHECK - NEXT : [ [ R : % [ 0 - 9 ] + ] ] = apply <nl> / / CHECK - NOT : copy_value [ [ R ] ] <nl> - / / CHECK : store [ [ R ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ R ] ] to [ init ] [ [ PB ] ] <nl> / / CHECK - NOT : destroy_value [ [ R ] ] <nl> / / CHECK : destroy_value [ [ A ] ] <nl> / / CHECK - NOT : destroy_value [ [ R ] ] <nl> func reftype_call_with_arg ( _ a : Ref ) { <nl> / / CHECK : bb0 ( [ [ A1 : % [ 0 - 9 ] + ] ] : $ Ref ) : <nl> / / CHECK : [ [ AADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Ref <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ AADDR ] ] <nl> - / / CHECK : store [ [ A1 ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ A1 ] ] to [ init ] [ [ PB ] ] <nl> <nl> reftype_func_with_arg ( a ) <nl> / / CHECK : [ [ RFWA : % [ 0 - 9 ] + ] ] = function_ref @ _TF8lifetime21reftype_func_with_arg <nl> struct Daleth { <nl> / / CHECK - LABEL : sil hidden @ _TFV8lifetime6DalethC { { . * } } : $ @ convention ( method ) ( @ owned Aleph , @ owned Beth , @ in Unloadable , @ thin Daleth . Type ) - > @ out Daleth { <nl> / / CHECK : bb0 ( [ [ THIS : % . * ] ] : $ * Daleth , [ [ A : % . * ] ] : $ Aleph , [ [ B : % . * ] ] : $ Beth , [ [ C : % . * ] ] : $ * Unloadable , { { % . * } } : $ @ thin Daleth . Type ) : <nl> / / CHECK - NEXT : [ [ A_ADDR : % . * ] ] = struct_element_addr [ [ THIS ] ] : $ * Daleth , # Daleth . a <nl> - / / CHECK - NEXT : store [ [ A ] ] to [ [ A_ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ A ] ] to [ init ] [ [ A_ADDR ] ] <nl> / / CHECK - NEXT : [ [ B_ADDR : % . * ] ] = struct_element_addr [ [ THIS ] ] : $ * Daleth , # Daleth . b <nl> - / / CHECK - NEXT : store [ [ B ] ] to [ [ B_ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ B ] ] to [ init ] [ [ B_ADDR ] ] <nl> / / CHECK - NEXT : [ [ C_ADDR : % . * ] ] = struct_element_addr [ [ THIS ] ] : $ * Daleth , # Daleth . c <nl> / / CHECK - NEXT : copy_addr [ take ] [ [ C ] ] to [ initialization ] [ [ C_ADDR ] ] <nl> / / CHECK - NEXT : tuple ( ) <nl> struct Zayin { <nl> / / CHECK - NEXT : [ [ THIS_A0_ADDR : % . * ] ] = tuple_element_addr [ [ THIS_A_ADDR ] ] : { { . * } } , 0 <nl> / / CHECK - NEXT : [ [ THIS_A1_ADDR : % . * ] ] = tuple_element_addr [ [ THIS_A_ADDR ] ] : { { . * } } , 1 <nl> / / CHECK - NEXT : copy_addr [ take ] [ [ A0 ] ] to [ initialization ] [ [ THIS_A0_ADDR ] ] <nl> - / / CHECK - NEXT : store [ [ A1 ] ] to [ [ THIS_A1_ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ A1 ] ] to [ trivial ] [ [ THIS_A1_ADDR ] ] <nl> / / CHECK - NEXT : [ [ THIS_B_ADDR : % . * ] ] = struct_element_addr [ [ THIS ] ] : $ * Zayin , # Zayin . b <nl> / / CHECK - NEXT : copy_addr [ take ] [ [ B ] ] to [ initialization ] [ [ THIS_B_ADDR ] ] <nl> / / CHECK - NEXT : tuple ( ) <nl> func logical_lvalue_lifetime ( _ r : RefWithProp , _ i : Int , _ v : Val ) { <nl> / / CHECK : [ [ PR : % [ 0 - 9 ] + ] ] = project_box [ [ RADDR ] ] <nl> / / CHECK : [ [ IADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK : [ [ PI : % [ 0 - 9 ] + ] ] = project_box [ [ IADDR ] ] <nl> - / / CHECK : store % 1 to [ [ PI ] ] <nl> + / / CHECK : store % 1 to [ trivial ] [ [ PI ] ] <nl> / / CHECK : [ [ VADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Val <nl> / / CHECK : [ [ PV : % [ 0 - 9 ] + ] ] = project_box [ [ VADDR ] ] <nl> <nl> func logical_lvalue_lifetime ( _ r : RefWithProp , _ i : Int , _ v : Val ) { <nl> / / CHECK : { { . * } } ( [ [ CALLBACK_ADDR : % . * ] ] : <nl> / / CHECK : [ [ CALLBACK : % . * ] ] = pointer_to_thin_function [ [ CALLBACK_ADDR ] ] : $ Builtin . RawPointer to $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout RefWithProp , @ thick RefWithProp . Type ) - > ( ) <nl> / / CHECK : [ [ TEMP : % . * ] ] = alloc_stack $ RefWithProp <nl> - / / CHECK : store [ [ R2 ] ] to [ [ TEMP ] ] <nl> + / / CHECK : store [ [ R2 ] ] to [ init ] [ [ TEMP ] ] <nl> / / CHECK : apply [ [ CALLBACK ] ] ( { { . * } } , [ [ STORAGE ] ] , [ [ TEMP ] ] , { { % . * } } ) <nl> } <nl> <nl> class Foo < T > { <nl> / / CHECK : [ [ THIS : % [ 0 - 9 ] + ] ] = mark_uninitialized <nl> / / CHECK : [ [ CHIADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK : [ [ PCHI : % [ 0 - 9 ] + ] ] = project_box [ [ CHIADDR ] ] <nl> - / / CHECK : store [ [ CHI ] ] to [ [ PCHI ] ] <nl> + / / CHECK : store [ [ CHI ] ] to [ trivial ] [ [ PCHI ] ] <nl> <nl> / / CHECK : ref_element_addr { { . * } } , # Foo . z <nl> <nl> class D : B { <nl> / / CHECK : store [ [ THIS ] ] to [ [ THISADDR ] ] <nl> / / CHECK : [ [ XADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK : [ [ PX : % [ 0 - 9 ] + ] ] = project_box [ [ XADDR ] ] <nl> - / / CHECK : store [ [ X ] ] to [ [ PX ] ] <nl> + / / CHECK : store [ [ X ] ] to [ trivial ] [ [ PX ] ] <nl> / / CHECK : [ [ YADDR : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK : [ [ PY : % [ 0 - 9 ] + ] ] = project_box [ [ YADDR ] ] <nl> - / / CHECK : store [ [ Y ] ] to [ [ PY ] ] <nl> + / / CHECK : store [ [ Y ] ] to [ trivial ] [ [ PY ] ] <nl> <nl> super . init ( y : y ) <nl> / / CHECK : [ [ THIS1 : % [ 0 - 9 ] + ] ] = load [ [ THISADDR ] ] <nl> mmm a / test / SILGen / materializeForSet . swift <nl> ppp b / test / SILGen / materializeForSet . swift <nl> class Base { <nl> / / CHECK : [ [ ADDR : % . * ] ] = pointer_to_address [ [ BUFFER ] ] : $ Builtin . RawPointer to [ strict ] $ * Int <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TFC17materializeForSet4Baseg8computedSi <nl> / / CHECK : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( [ [ SELF ] ] ) <nl> - / / CHECK : store [ [ T1 ] ] to [ [ ADDR ] ] : $ * Int <nl> + / / CHECK : store [ [ T1 ] ] to [ trivial ] [ [ ADDR ] ] : $ * Int <nl> / / CHECK : [ [ BUFFER : % . * ] ] = address_to_pointer [ [ ADDR ] ] <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TFFC17materializeForSet4Basem8computedSiU_T_ : $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout Base , @ thick Base . Type ) - > ( ) <nl> / / CHECK : [ [ T2 : % . * ] ] = thin_function_to_pointer [ [ T0 ] ] <nl> extension Derived : Abstractable { } <nl> / / CHECK - NEXT : [ [ TEMP : % . * ] ] = alloc_stack $ @ callee_owned ( ) - > Int <nl> / / CHECK - NEXT : [ [ FN : % . * ] ] = class_method [ [ SELF ] ] : $ Base , # Base . storedFunction ! getter . 1 <nl> / / CHECK - NEXT : [ [ RESULT : % . * ] ] = apply [ [ FN ] ] ( [ [ SELF ] ] ) <nl> - / / CHECK - NEXT : store [ [ RESULT ] ] to [ [ TEMP ] ] <nl> + / / CHECK - NEXT : store [ [ RESULT ] ] to [ init ] [ [ TEMP ] ] <nl> / / CHECK - NEXT : [ [ RESULT : % . * ] ] = load [ [ TEMP ] ] <nl> / / CHECK - NEXT : copy_value [ [ RESULT ] ] <nl> / / CHECK - NEXT : function_ref <nl> / / CHECK - NEXT : [ [ REABSTRACTOR : % . * ] ] = function_ref @ _TTRXFo__dSi_XFo__iSi_ : $ @ convention ( thin ) ( @ owned @ callee_owned ( ) - > Int ) - > @ out Int <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = partial_apply [ [ REABSTRACTOR ] ] ( [ [ RESULT ] ] ) <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ RESULT_ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ init ] [ [ RESULT_ADDR ] ] <nl> / / CHECK - NEXT : [ [ RESULT_PTR : % . * ] ] = address_to_pointer [ [ RESULT_ADDR ] ] : $ * @ callee_owned ( ) - > @ out Int to $ Builtin . RawPointer <nl> / / CHECK - NEXT : function_ref <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = function_ref @ _TTWC17materializeForSet7DerivedS_12AbstractableS_FFS1_m14storedFunctionFT_wx6ResultU_T_ <nl> extension Derived : Abstractable { } <nl> / / CHECK - NEXT : function_ref <nl> / / CHECK - NEXT : [ [ REABSTRACTOR : % . * ] ] = function_ref @ _TTRXFo__dSi_XFo__iSi_ : $ @ convention ( thin ) ( @ owned @ callee_owned ( ) - > Int ) - > @ out Int <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = partial_apply [ [ REABSTRACTOR ] ] ( [ [ RESULT ] ] ) <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ RESULT_ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ init ] [ [ RESULT_ADDR ] ] <nl> / / CHECK - NEXT : [ [ RESULT_PTR : % . * ] ] = address_to_pointer [ [ RESULT_ADDR ] ] : $ * @ callee_owned ( ) - > @ out Int to $ Builtin . RawPointer <nl> / / CHECK - NEXT : function_ref <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = function_ref @ _TTWC17materializeForSet7DerivedS_12AbstractableS_FFS1_m19finalStoredFunctionFT_wx6ResultU_T_ <nl> extension Derived : Abstractable { } <nl> / / CHECK - NEXT : [ [ OUT : % . * ] ] = alloc_stack $ @ callee_owned ( ) - > Int <nl> / / CHECK : [ [ GETTER : % . * ] ] = function_ref @ _TZFC17materializeForSet4Baseg14staticFunctionFT_Si : $ @ convention ( method ) ( @ thick Base . Type ) - > @ owned @ callee_owned ( ) - > Int <nl> / / CHECK - NEXT : [ [ VALUE : % . * ] ] = apply [ [ GETTER ] ] ( [ [ SELF ] ] ) : $ @ convention ( method ) ( @ thick Base . Type ) - > @ owned @ callee_owned ( ) - > Int <nl> - / / CHECK - NEXT : store [ [ VALUE ] ] to [ [ OUT ] ] : $ * @ callee_owned ( ) - > Int <nl> + / / CHECK - NEXT : store [ [ VALUE ] ] to [ init ] [ [ OUT ] ] : $ * @ callee_owned ( ) - > Int <nl> / / CHECK - NEXT : [ [ VALUE : % . * ] ] = load [ [ OUT ] ] : $ * @ callee_owned ( ) - > Int <nl> / / CHECK - NEXT : copy_value [ [ VALUE ] ] : $ @ callee_owned ( ) - > Int <nl> / / CHECK : [ [ REABSTRACTOR : % . * ] ] = function_ref @ _TTRXFo__dSi_XFo__iSi_ : $ @ convention ( thin ) ( @ owned @ callee_owned ( ) - > Int ) - > @ out Int <nl> / / CHECK - NEXT : [ [ NEWVALUE : % . * ] ] = partial_apply [ [ REABSTRACTOR ] ] ( [ [ VALUE ] ] ) <nl> - / / CHECK - NEXT : store [ [ NEWVALUE ] ] to [ [ RESULT_ADDR ] ] : $ * @ callee_owned ( ) - > @ out Int <nl> + / / CHECK - NEXT : store [ [ NEWVALUE ] ] to [ init ] [ [ RESULT_ADDR ] ] : $ * @ callee_owned ( ) - > @ out Int <nl> / / CHECK - NEXT : [ [ ADDR : % . * ] ] = address_to_pointer [ [ RESULT_ADDR ] ] : $ * @ callee_owned ( ) - > @ out Int to $ Builtin . RawPointer <nl> / / CHECK : [ [ CALLBACK_FN : % . * ] ] = function_ref @ _TTWC17materializeForSet7DerivedS_12AbstractableS_FZFS1_m14staticFunctionFT_wx6ResultU_T_ : $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout @ thick Derived . Type , @ thick Derived . Type . Type ) - > ( ) <nl> / / CHECK - NEXT : [ [ CALLBACK_ADDR : % . * ] ] = thin_function_to_pointer [ [ CALLBACK_FN ] ] : $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout @ thick Derived . Type , @ thick Derived . Type . Type ) - > ( ) to $ Builtin . RawPointer <nl> class HasDidSet : Base { <nl> / / CHECK : [ [ T2 : % . * ] ] = pointer_to_address [ [ BUFFER ] ] : $ Builtin . RawPointer to [ strict ] $ * Int <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TFC17materializeForSet9HasDidSetg6storedSi <nl> / / CHECK : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( [ [ SELF ] ] ) <nl> - / / CHECK : store [ [ T1 ] ] to [ [ T2 ] ] : $ * Int <nl> + / / CHECK : store [ [ T1 ] ] to [ trivial ] [ [ T2 ] ] : $ * Int <nl> / / CHECK : [ [ BUFFER : % . * ] ] = address_to_pointer [ [ T2 ] ] <nl> / / CHECK : [ [ CALLBACK_FN : % . * ] ] = function_ref @ _TFFC17materializeForSet9HasDidSetm6storedSiU_T_ : $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout HasDidSet , @ thick HasDidSet . Type ) - > ( ) <nl> / / CHECK : [ [ CALLBACK_ADDR : % . * ] ] = thin_function_to_pointer [ [ CALLBACK_FN ] ] <nl> class HasDidSet : Base { <nl> / / CHECK : [ [ T2 : % . * ] ] = pointer_to_address [ [ BUFFER ] ] : $ Builtin . RawPointer to [ strict ] $ * Int <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TFC17materializeForSet9HasDidSetg8computedSi <nl> / / CHECK : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( [ [ SELF ] ] ) <nl> - / / CHECK : store [ [ T1 ] ] to [ [ T2 ] ] : $ * Int <nl> + / / CHECK : store [ [ T1 ] ] to [ trivial ] [ [ T2 ] ] : $ * Int <nl> / / CHECK : [ [ BUFFER : % . * ] ] = address_to_pointer [ [ T2 ] ] <nl> / / CHECK : [ [ CALLBACK_FN : % . * ] ] = function_ref @ _TFFC17materializeForSet9HasDidSetm8computedSiU_T_ : $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout HasDidSet , @ thick HasDidSet . Type ) - > ( ) <nl> / / CHECK : [ [ CALLBACK_ADDR : % . * ] ] = thin_function_to_pointer [ [ CALLBACK_FN ] ] <nl> class HasStoredDidSet { <nl> / / CHECK : [ [ T2 : % . * ] ] = pointer_to_address [ [ BUFFER ] ] : $ Builtin . RawPointer to [ strict ] $ * Int <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TFC17materializeForSet15HasStoredDidSetg6storedSi <nl> / / CHECK : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( [ [ SELF ] ] ) <nl> - / / CHECK : store [ [ T1 ] ] to [ [ T2 ] ] : $ * Int <nl> + / / CHECK : store [ [ T1 ] ] to [ trivial ] [ [ T2 ] ] : $ * Int <nl> / / CHECK : [ [ BUFFER : % . * ] ] = address_to_pointer [ [ T2 ] ] <nl> / / CHECK : [ [ CALLBACK_FN : % . * ] ] = function_ref @ _TFFC17materializeForSet15HasStoredDidSetm6storedSiU_T_ : $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout HasStoredDidSet , @ thick HasStoredDidSet . Type ) - > ( ) <nl> / / CHECK : [ [ CALLBACK_ADDR : % . * ] ] = thin_function_to_pointer [ [ CALLBACK_FN ] ] <nl> class HasWeak { <nl> / / CHECK : [ [ T2 : % . * ] ] = pointer_to_address [ [ BUFFER ] ] : $ Builtin . RawPointer to [ strict ] $ * Optional < HasWeak > <nl> / / CHECK : [ [ T0 : % . * ] ] = ref_element_addr [ [ SELF ] ] : $ HasWeak , # HasWeak . weakvar <nl> / / CHECK : [ [ T1 : % . * ] ] = load_weak [ [ T0 ] ] : $ * @ sil_weak Optional < HasWeak > <nl> - / / CHECK : store [ [ T1 ] ] to [ [ T2 ] ] : $ * Optional < HasWeak > <nl> + / / CHECK : store [ [ T1 ] ] to [ init ] [ [ T2 ] ] : $ * Optional < HasWeak > <nl> / / CHECK : [ [ BUFFER : % . * ] ] = address_to_pointer [ [ T2 ] ] <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TFFC17materializeForSet7HasWeakm7weakvarXwGSqS0__U_T_ : $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout HasWeak , @ thick HasWeak . Type ) - > ( ) <nl> / / CHECK : [ [ T4 : % . * ] ] = tuple ( [ [ BUFFER ] ] : $ Builtin . RawPointer , { { . * } } : $ Optional < Builtin . RawPointer > ) <nl> func improveWizard ( _ wizard : inout Wizard ) { <nl> / / CHECK - NEXT : function_ref <nl> / / CHECK - NEXT : [ [ GETTER : % . * ] ] = function_ref @ _TFE17materializeForSetPS_5Magicg5hocusSi <nl> / / CHECK - NEXT : [ [ WTEMP : % . * ] ] = alloc_stack $ Wizard <nl> - / / CHECK - NEXT : store [ [ T0 ] ] to [ [ WTEMP ] ] <nl> + / / CHECK - NEXT : store [ [ T0 ] ] to [ trivial ] [ [ WTEMP ] ] <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = apply [ [ GETTER ] ] < Wizard > ( [ [ WTEMP ] ] ) <nl> - / / CHECK - NEXT : store [ [ T0 ] ] to [ [ TEMP ] ] <nl> + / / CHECK - NEXT : store [ [ T0 ] ] to [ trivial ] [ [ TEMP ] ] <nl> / / Call improve . <nl> / / CHECK - NEXT : apply [ [ IMPROVE ] ] ( [ [ TEMP ] ] ) <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = load [ [ TEMP ] ] <nl> mmm a / test / SILGen / metatype_abstraction . swift <nl> ppp b / test / SILGen / metatype_abstraction . swift <nl> func takeGenericMetatype < T > ( _ x : T . Type ) { } <nl> / / CHECK - LABEL : sil hidden @ _TFs23staticMetatypeToGeneric <nl> / / CHECK : [ [ MAT : % . * ] ] = alloc_stack $ @ thick S . Type <nl> / / CHECK : [ [ META : % . * ] ] = metatype $ @ thick S . Type <nl> - / / CHECK : store [ [ META ] ] to [ [ MAT ] ] : $ * @ thick S . Type <nl> + / / CHECK : store [ [ META ] ] to [ trivial ] [ [ MAT ] ] : $ * @ thick S . Type <nl> / / CHECK : apply { { % . * } } < S . Type > ( [ [ MAT ] ] ) <nl> func staticMetatypeToGeneric ( _ x : S . Type ) { <nl> takeGeneric ( x ) <nl> mmm a / test / SILGen / objc_blocks_bridging . swift <nl> ppp b / test / SILGen / objc_blocks_bridging . swift <nl> func callBlocks ( _ x : Foo , <nl> / / CHECK : [ [ FOO : % . * ] ] = class_method [ volatile ] % 0 : $ Foo , # Foo . foo ! 1 . foreign <nl> / / CHECK : [ [ F_BLOCK_STORAGE : % . * ] ] = alloc_stack $ @ block_storage <nl> / / CHECK : [ [ F_BLOCK_CAPTURE : % . * ] ] = project_block_storage [ [ F_BLOCK_STORAGE ] ] <nl> - / / CHECK : store % 1 to [ [ F_BLOCK_CAPTURE ] ] <nl> + / / CHECK : store % 1 to [ init ] [ [ F_BLOCK_CAPTURE ] ] <nl> / / CHECK : [ [ F_BLOCK_INVOKE : % . * ] ] = function_ref @ _TTRXFo_dSi_dSi_XFdCb_dSi_dSi_ <nl> / / CHECK : [ [ F_STACK_BLOCK : % . * ] ] = init_block_storage_header [ [ F_BLOCK_STORAGE ] ] : { { . * } } , invoke [ [ F_BLOCK_INVOKE ] ] <nl> / / CHECK : [ [ F_BLOCK : % . * ] ] = copy_block [ [ F_STACK_BLOCK ] ] <nl> mmm a / test / SILGen / objc_bridging_any . swift <nl> ppp b / test / SILGen / objc_bridging_any . swift <nl> func passingToId < T : CP , U > ( receiver : NSIdLover , <nl> <nl> / / CHECK : [ [ METHOD : % . * ] ] = class_method [ volatile ] [ [ SELF ] ] : $ NSIdLover , <nl> / / CHECK : [ [ TMP : % . * ] ] = alloc_stack $ KnownUnbridged <nl> - / / CHECK : store [ [ KNOWN_UNBRIDGED ] ] to [ [ TMP ] ] <nl> + / / CHECK : store [ [ KNOWN_UNBRIDGED ] ] to [ trivial ] [ [ TMP ] ] <nl> / / CHECK : [ [ BRIDGE_ANYTHING : % . * ] ] = function_ref @ _TFs27_bridgeAnythingToObjectiveC <nl> / / CHECK : [ [ ANYOBJECT : % . * ] ] = apply [ [ BRIDGE_ANYTHING ] ] < KnownUnbridged > ( [ [ TMP ] ] ) <nl> / / CHECK : apply [ [ METHOD ] ] ( [ [ ANYOBJECT ] ] , [ [ SELF ] ] ) <nl> func passingToId < T : CP , U > ( receiver : NSIdLover , <nl> / / CHECK : [ [ METHOD : % . * ] ] = class_method [ volatile ] [ [ SELF ] ] : $ NSIdLover , <nl> / / CHECK : [ [ BRIDGE_OPTIONAL : % . * ] ] = function_ref @ _TFSq19_bridgeToObjectiveCfT_Ps9AnyObject_ <nl> / / CHECK : [ [ TMP : % . * ] ] = alloc_stack $ Optional < String > <nl> - / / CHECK : store [ [ OPT_STRING ] ] to [ [ TMP ] ] <nl> + / / CHECK : store [ [ OPT_STRING ] ] to [ init ] [ [ TMP ] ] <nl> / / CHECK : [ [ ANYOBJECT : % . * ] ] = apply [ [ BRIDGE_OPTIONAL ] ] < String > ( [ [ TMP ] ] ) <nl> / / CHECK : apply [ [ METHOD ] ] ( [ [ ANYOBJECT ] ] , [ [ SELF ] ] ) <nl> receiver . takesId ( optionalA ) <nl> func passingToId < T : CP , U > ( receiver : NSIdLover , <nl> / / CHECK : [ [ METHOD : % . * ] ] = class_method [ volatile ] [ [ SELF ] ] : $ NSIdLover , <nl> / / CHECK : [ [ BRIDGE_OPTIONAL : % . * ] ] = function_ref @ _TFSq19_bridgeToObjectiveCfT_Ps9AnyObject_ <nl> / / CHECK : [ [ TMP : % . * ] ] = alloc_stack $ Optional < NSString > <nl> - / / CHECK : store [ [ OPT_NSSTRING ] ] to [ [ TMP ] ] <nl> + / / CHECK : store [ [ OPT_NSSTRING ] ] to [ init ] [ [ TMP ] ] <nl> / / CHECK : [ [ ANYOBJECT : % . * ] ] = apply [ [ BRIDGE_OPTIONAL ] ] < NSString > ( [ [ TMP ] ] ) <nl> / / CHECK : apply [ [ METHOD ] ] ( [ [ ANYOBJECT ] ] , [ [ SELF ] ] ) <nl> receiver . takesId ( optionalB ) <nl> func passingToNullableId < T : CP , U > ( receiver : NSIdLover , <nl> <nl> / / CHECK : [ [ METHOD : % . * ] ] = class_method [ volatile ] [ [ SELF ] ] : $ NSIdLover , <nl> / / CHECK : [ [ TMP : % . * ] ] = alloc_stack $ KnownUnbridged <nl> - / / CHECK : store [ [ KNOWN_UNBRIDGED ] ] to [ [ TMP ] ] <nl> + / / CHECK : store [ [ KNOWN_UNBRIDGED ] ] to [ trivial ] [ [ TMP ] ] <nl> / / CHECK : [ [ BRIDGE_ANYTHING : % . * ] ] = function_ref @ _TFs27_bridgeAnythingToObjectiveC <nl> / / CHECK : [ [ ANYOBJECT : % . * ] ] = apply [ [ BRIDGE_ANYTHING ] ] < KnownUnbridged > ( [ [ TMP ] ] ) <nl> / / CHECK : [ [ OPT_ANYOBJECT : % . * ] ] = enum { { . * } } [ [ ANYOBJECT ] ] <nl> class SwiftIdLover : NSObject , Anyable { <nl> / / CHECK - NEXT : destroy_value % 0 <nl> / / CHECK - NEXT : [ [ BLOCK_STORAGE : % . * ] ] = alloc_stack $ @ block_storage @ callee_owned ( @ in Any ) - > ( ) <nl> / / CHECK - NEXT : [ [ BLOCK_STORAGE_ADDR : % . * ] ] = project_block_storage [ [ BLOCK_STORAGE ] ] <nl> - / / CHECK - NEXT : store [ [ RESULT : % . * ] ] to [ [ BLOCK_STORAGE_ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ RESULT : % . * ] ] to [ init ] [ [ BLOCK_STORAGE_ADDR ] ] <nl> / / CHECK : [ [ THUNK_FN : % . * ] ] = function_ref @ _TTRXFo_iP___XFdCb_dPs9AnyObject___ <nl> / / CHECK - NEXT : [ [ BLOCK_HEADER : % . * ] ] = init_block_storage_header [ [ BLOCK_STORAGE ] ] : $ * @ block_storage @ callee_owned ( @ in Any ) - > ( ) , invoke [ [ THUNK_FN ] ] <nl> / / CHECK - NEXT : [ [ BLOCK : % . * ] ] = copy_block [ [ BLOCK_HEADER ] ] <nl> class SwiftIdLover : NSObject , Anyable { <nl> / / CHECK - NEXT : destroy_value % 0 <nl> / / CHECK - NEXT : [ [ BLOCK_STORAGE : % . * ] ] = alloc_stack $ @ block_storage @ callee_owned ( ) - > @ out Any <nl> / / CHECK - NEXT : [ [ BLOCK_STORAGE_ADDR : % . * ] ] = project_block_storage [ [ BLOCK_STORAGE ] ] <nl> - / / CHECK - NEXT : store [ [ FUNCTION ] ] to [ [ BLOCK_STORAGE_ADDR ] ] <nl> + / / CHECK - NEXT : store [ [ FUNCTION ] ] to [ init ] [ [ BLOCK_STORAGE_ADDR ] ] <nl> / / CHECK : [ [ THUNK_FN : % . * ] ] = function_ref @ _TTRXFo__iP__XFdCb__aPs9AnyObject__ <nl> / / CHECK - NEXT : [ [ BLOCK_HEADER : % . * ] ] = init_block_storage_header [ [ BLOCK_STORAGE ] ] : $ * @ block_storage @ callee_owned ( ) - > @ out Any , invoke [ [ THUNK_FN ] ] <nl> / / CHECK - NEXT : [ [ BLOCK : % . * ] ] = copy_block [ [ BLOCK_HEADER ] ] <nl> extension GenericClass { <nl> func pseudogenericAnyErasure ( x : T ) - > Any { <nl> / / CHECK : [ [ ANY_BUF : % . * ] ] = init_existential_addr % 0 : $ * Any , $ AnyObject <nl> / / CHECK : [ [ ANYOBJECT : % . * ] ] = init_existential_ref % 1 : $ T : $ T , $ AnyObject <nl> - / / CHECK : store [ [ ANYOBJECT ] ] to [ [ ANY_BUF ] ] <nl> + / / CHECK : store [ [ ANYOBJECT ] ] to [ init ] [ [ ANY_BUF ] ] <nl> return x <nl> } <nl> } <nl> mmm a / test / SILGen / objc_protocols . swift <nl> ppp b / test / SILGen / objc_protocols . swift <nl> func testInitializableExistential ( _ im : Initializable . Type , i : Int ) - > Initializ <nl> / / CHECK : [ [ INIT_WITNESS : % [ 0 - 9 ] + ] ] = witness_method [ volatile ] $ @ opened ( [ [ N ] ] ) Initializable , # Initializable . init ! initializer . 1 . foreign , [ [ ARCHETYPE_META ] ] { { . * } } : $ @ convention ( objc_method ) < τ_0_0 where τ_0_0 : Initializable > ( Int , @ owned τ_0_0 ) - > @ owned τ_0_0 <nl> / / CHECK : [ [ I2 : % [ 0 - 9 ] + ] ] = apply [ [ INIT_WITNESS ] ] < @ opened ( [ [ N ] ] ) Initializable > ( [ [ I ] ] , [ [ I2_ALLOC ] ] ) : $ @ convention ( objc_method ) < τ_0_0 where τ_0_0 : Initializable > ( Int , @ owned τ_0_0 ) - > @ owned τ_0_0 <nl> / / CHECK : [ [ I2_EXIST_CONTAINER : % [ 0 - 9 ] + ] ] = init_existential_ref [ [ I2 ] ] : $ @ opened ( [ [ N ] ] ) Initializable : $ @ opened ( [ [ N ] ] ) Initializable , $ Initializable <nl> - / / CHECK : store [ [ I2_EXIST_CONTAINER ] ] to [ [ PB ] ] : $ * Initializable <nl> + / / CHECK : store [ [ I2_EXIST_CONTAINER ] ] to [ init ] [ [ PB ] ] : $ * Initializable <nl> / / CHECK : [ [ I2 : % [ 0 - 9 ] + ] ] = load [ [ PB ] ] : $ * Initializable <nl> / / CHECK : copy_value [ [ I2 ] ] : $ Initializable <nl> / / CHECK : destroy_value [ [ I2_BOX ] ] : $ @ box Initializable <nl> mmm a / test / SILGen / objc_thunks . swift <nl> ppp b / test / SILGen / objc_thunks . swift <nl> extension Hoozit { <nl> var x = X ( ) <nl> / / CHECK : [ [ CTOR : % [ 0 - 9 ] + ] ] = class_method [ volatile ] [ [ SELF : % [ 0 - 9 ] + ] ] : $ Hoozit , # Hoozit . init ! initializer . 1 . foreign : ( Hoozit . Type ) - > ( Int ) - > Hoozit , $ @ convention ( objc_method ) ( Int , @ owned Hoozit ) - > @ owned Hoozit <nl> / / CHECK : [ [ NEW_SELF : % [ 0 - 9 ] + ] ] = apply [ [ CTOR ] ] <nl> - / / CHECK : store [ [ NEW_SELF ] ] to [ [ SELFMUI ] ] : $ * Hoozit <nl> + / / CHECK : store [ [ NEW_SELF ] ] to [ init ] [ [ SELFMUI ] ] : $ * Hoozit <nl> / / CHECK : [ [ NONNULL : % [ 0 - 9 ] + ] ] = is_nonnull [ [ NEW_SELF ] ] : $ Hoozit <nl> / / CHECK - NEXT : cond_br [ [ NONNULL ] ] , [ [ NONNULL_BB : bb [ 0 - 9 ] + ] ] , [ [ NULL_BB : bb [ 0 - 9 ] + ] ] <nl> / / CHECK : [ [ NULL_BB ] ] : <nl> mmm a / test / SILGen / objc_witnesses . swift <nl> ppp b / test / SILGen / objc_witnesses . swift <nl> extension Gizmo : Bells { <nl> / / CHECK : [ [ IUO_RESULT : % [ 0 - 9 ] + ] ] = apply [ [ INIT ] ] ( [ [ I ] ] , [ [ META ] ] ) : $ @ convention ( method ) ( Int , @ thick Gizmo . Type ) - > @ owned Optional < Gizmo > <nl> / / CHECK : switch_enum [ [ IUO_RESULT ] ] <nl> / / CHECK : [ [ UNWRAPPED_RESULT : % [ 0 - 9 ] + ] ] = unchecked_enum_data [ [ IUO_RESULT ] ] <nl> - / / CHECK : store [ [ UNWRAPPED_RESULT ] ] to [ [ SELF ] ] : $ * Gizmo <nl> + / / CHECK : store [ [ UNWRAPPED_RESULT ] ] to [ init ] [ [ SELF ] ] : $ * Gizmo <nl> <nl> / / Test extension of a native @ objc class to conform to a protocol with a <nl> / / subscript requirement . rdar : / / problem / 20371661 <nl> mmm a / test / SILGen / optional - cast . swift <nl> ppp b / test / SILGen / optional - cast . swift <nl> class B : A { } <nl> / / CHECK - NEXT : checked_cast_br [ [ VAL ] ] : $ A to $ B , [ [ IS_B : bb . * ] ] , [ [ NOT_B : bb [ 0 - 9 ] + ] ] <nl> / / If so , materialize that and inject it into x . <nl> / / CHECK : [ [ IS_B ] ] ( [ [ T0 : % . * ] ] : $ B ) : <nl> - / / CHECK - NEXT : store [ [ T0 ] ] to [ [ X_VALUE ] ] : $ * B <nl> + / / CHECK - NEXT : store [ [ T0 ] ] to [ init ] [ [ X_VALUE ] ] : $ * B <nl> / / CHECK - NEXT : inject_enum_addr [ [ PB ] ] : $ * Optional < B > , # Optional . some <nl> / / CHECK - NEXT : br [ [ CONT : bb [ 0 - 9 ] + ] ] <nl> / / If not , destroy_value the A and inject nothing into x . <nl> public struct TestAddressOnlyStruct < T > { <nl> / / CHECK - NEXT : [ [ X : % . * ] ] = alloc_box $ Optional < Int > , var , name " x " <nl> / / CHECK - NEXT : [ [ PB : % . * ] ] = project_box [ [ X ] ] <nl> / / CHECK - NEXT : [ [ CAST : % . * ] ] = unchecked_addr_cast [ [ PB ] ] : $ * Optional < Int > to $ * Optional < Int > <nl> - / / CHECK - NEXT : store % 0 to [ [ CAST ] ] : $ * Optional < Int > <nl> + / / CHECK - NEXT : store % 0 to [ trivial ] [ [ CAST ] ] : $ * Optional < Int > <nl> / / CHECK - NEXT : destroy_value [ [ X ] ] : $ @ box Optional < Int > <nl> func testContextualInitOfNonAddrOnlyType ( _ a : Int ? ) { <nl> var x : Int ! = a <nl> mmm a / test / SILGen / optional . swift <nl> ppp b / test / SILGen / optional . swift <nl> func testAddrOnlyCallResult < T > ( _ f : ( ( ) - > T ) ? ) { <nl> / / CHECK : bb0 ( [ [ T0 : % . * ] ] : $ Optional < @ callee_owned ( ) - > @ out T > ) : <nl> / / CHECK : [ [ F : % . * ] ] = alloc_box $ Optional < @ callee_owned ( ) - > @ out T > , var , name " f " <nl> / / CHECK - NEXT : [ [ PBF : % . * ] ] = project_box [ [ F ] ] <nl> - / / CHECK : store [ [ T0 ] ] to [ [ PBF ] ] <nl> + / / CHECK : store [ [ T0 ] ] to [ init ] [ [ PBF ] ] <nl> / / CHECK - NEXT : [ [ X : % . * ] ] = alloc_box $ Optional < T > , var , name " x " <nl> / / CHECK - NEXT : [ [ PBX : % . * ] ] = project_box [ [ X ] ] <nl> / / CHECK - NEXT : [ [ TEMP : % . * ] ] = init_enum_data_addr [ [ PBX ] ] <nl> mmm a / test / SILGen / partial_apply_protocol_class_refinement_method . swift <nl> ppp b / test / SILGen / partial_apply_protocol_class_refinement_method . swift <nl> protocol Q : class , P { } <nl> / / CHECK - LABEL : sil hidden @ _TF46partial_apply_protocol_class_refinement_method12partialApplyFPS_1Q_FT_T_ <nl> func partialApply ( _ q : Q ) - > ( ) - > ( ) { <nl> / / CHECK : [ [ OPENED : % . * ] ] = open_existential_ref <nl> - / / CHECK : store [ [ OPENED ] ] to [ [ TMP : % . * ] ] : <nl> + / / CHECK : store [ [ OPENED ] ] to [ init ] [ [ TMP : % . * ] ] : <nl> / / CHECK : copy_addr [ [ TMP : % . * ] ] to [ initialization ] [ [ CONSUMABLE_TMP : % . * ] ] : <nl> / / CHECK : apply { { % . * } } < { { . * } } > ( [ [ CONSUMABLE_TMP ] ] ) <nl> return q . foo <nl> mmm a / test / SILGen / pointer_conversion . swift <nl> ppp b / test / SILGen / pointer_conversion . swift <nl> func classInoutToPointer ( ) { <nl> / / CHECK : [ [ WRITEBACK : % . * ] ] = alloc_stack $ @ sil_unmanaged C <nl> / / CHECK : [ [ OWNED : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : [ [ UNOWNED : % . * ] ] = ref_to_unmanaged [ [ OWNED ] ] <nl> - / / CHECK : store [ [ UNOWNED ] ] to [ [ WRITEBACK ] ] <nl> + / / CHECK : store [ [ UNOWNED ] ] to [ trivial ] [ [ WRITEBACK ] ] <nl> / / CHECK : [ [ POINTER : % . * ] ] = address_to_pointer [ [ WRITEBACK ] ] <nl> / / CHECK : [ [ CONVERT : % . * ] ] = function_ref @ _TFs30_convertInOutToPointerArgument <nl> / / CHECK : apply [ [ CONVERT ] ] < AutoreleasingUnsafeMutablePointer < C > > ( { { % . * } } , [ [ POINTER ] ] ) <nl> mmm a / test / SILGen / properties . swift <nl> ppp b / test / SILGen / properties . swift <nl> func logical_struct_in_reftype_set ( _ value : inout Val , z1 : Int ) { <nl> / / CHECK : [ [ V_R_VP_Z_TUPLE : % [ 0 - 9 ] + ] ] = apply [ [ GET_Z_TUPLE_METHOD ] ] ( [ [ LD ] ] ) <nl> / / CHECK : [ [ T0 : % . * ] ] = tuple_extract [ [ V_R_VP_Z_TUPLE ] ] : { { . * } } , 0 <nl> / / CHECK : [ [ T1 : % . * ] ] = tuple_extract [ [ V_R_VP_Z_TUPLE ] ] : { { . * } } , 1 <nl> - / / CHECK : store [ [ T0 ] ] to [ [ A0 ] ] <nl> - / / CHECK : store [ [ T1 ] ] to [ [ A1 ] ] <nl> + / / CHECK : store [ [ T0 ] ] to [ trivial ] [ [ A0 ] ] <nl> + / / CHECK : store [ [ T1 ] ] to [ trivial ] [ [ A1 ] ] <nl> / / - - write to val . ref . val_prop . z_tuple . 1 <nl> / / CHECK : [ [ V_R_VP_Z_TUPLE_1 : % [ 0 - 9 ] + ] ] = tuple_element_addr [ [ V_R_VP_Z_TUPLE_MAT ] ] : { { . * } } , 1 <nl> / / CHECK : assign [ [ Z1 ] ] to [ [ V_R_VP_Z_TUPLE_1 ] ] <nl> func logical_struct_in_reftype_set ( _ value : inout Val , z1 : Int ) { <nl> / / CHECK : [ [ WRITEBACK ] ] ( [ [ CALLBACK_ADDR : % . * ] ] : $ Builtin . RawPointer ) : <nl> / / CHECK : [ [ CALLBACK : % . * ] ] = pointer_to_thin_function [ [ CALLBACK_ADDR ] ] : $ Builtin . RawPointer to $ @ convention ( thin ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout Ref , @ thick Ref . Type ) - > ( ) <nl> / / CHECK : [ [ REF_MAT : % . * ] ] = alloc_stack $ Ref <nl> - / / CHECK : store [ [ VAL_REF ] ] to [ [ REF_MAT ] ] <nl> + / / CHECK : store [ [ VAL_REF ] ] to [ init ] [ [ REF_MAT ] ] <nl> / / CHECK : [ [ T0 : % . * ] ] = metatype $ @ thick Ref . Type <nl> / / CHECK : [ [ T1 : % . * ] ] = address_to_pointer [ [ VAL_REF_VAL_PROP_MAT ] ] <nl> / / CHECK : apply [ [ CALLBACK ] ] ( [ [ T1 ] ] , [ [ STORAGE ] ] , [ [ REF_MAT ] ] , [ [ T0 ] ] ) <nl> func tuple_in_logical_struct_set ( _ value : inout Val , z1 : Int ) { <nl> / / CHECK : [ [ Z_TUPLE : % [ 0 - 9 ] + ] ] = apply [ [ Z_GET_METHOD ] ] ( [ [ VAL1 ] ] ) <nl> / / CHECK : [ [ T0 : % . * ] ] = tuple_extract [ [ Z_TUPLE ] ] : { { . * } } , 0 <nl> / / CHECK : [ [ T1 : % . * ] ] = tuple_extract [ [ Z_TUPLE ] ] : { { . * } } , 1 <nl> - / / CHECK : store [ [ T0 ] ] to [ [ A0 ] ] <nl> - / / CHECK : store [ [ T1 ] ] to [ [ A1 ] ] <nl> + / / CHECK : store [ [ T0 ] ] to [ trivial ] [ [ A0 ] ] <nl> + / / CHECK : store [ [ T1 ] ] to [ trivial ] [ [ A1 ] ] <nl> / / CHECK : [ [ Z_TUPLE_1 : % [ 0 - 9 ] + ] ] = tuple_element_addr [ [ Z_TUPLE_MATERIALIZED ] ] : { { . * } } , 1 <nl> / / CHECK : assign [ [ Z1 ] ] to [ [ Z_TUPLE_1 ] ] <nl> / / CHECK : [ [ Z_TUPLE_MODIFIED : % [ 0 - 9 ] + ] ] = load [ [ Z_TUPLE_MATERIALIZED ] ] <nl> func local_observing_property ( _ arg : Int ) { <nl> / / CHECK : bb0 ( [ [ ARG : % [ 0 - 9 ] + ] ] : $ Int ) <nl> / / CHECK : [ [ BOX : % [ 0 - 9 ] + ] ] = alloc_box $ Int <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ BOX ] ] <nl> - / / CHECK : store [ [ ARG ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ ARG ] ] to [ trivial ] [ [ PB ] ] <nl> <nl> <nl> <nl> struct MutatingGetterStruct { <nl> / / CHECK - LABEL : sil hidden @ _TZFV10properties20MutatingGetterStruct4test <nl> / / CHECK : [ [ X : % . * ] ] = alloc_box $ MutatingGetterStruct , var , name " x " <nl> / / CHECK - NEXT : [ [ PB : % . * ] ] = project_box [ [ X ] ] <nl> - / / CHECK : store { { . * } } to [ [ PB ] ] : $ * MutatingGetterStruct <nl> + / / CHECK : store { { . * } } to [ trivial ] [ [ PB ] ] : $ * MutatingGetterStruct <nl> / / CHECK : apply { { % . * } } ( [ [ PB ] ] ) : $ @ convention ( method ) ( @ inout MutatingGetterStruct ) - > Int <nl> static func test ( ) { <nl> var x = MutatingGetterStruct ( ) <nl> mmm a / test / SILGen / property_abstraction . swift <nl> ppp b / test / SILGen / property_abstraction . swift <nl> func inOutFunc ( _ f : inout ( ( Int ) - > Int ) ) { } <nl> / / CHECK : [ [ F_ORIG : % . * ] ] = load [ [ F_ADDR ] ] <nl> / / CHECK : [ [ REABSTRACT_FN : % . * ] ] = function_ref @ _TTR <nl> / / CHECK : [ [ F_SUBST_IN : % . * ] ] = partial_apply [ [ REABSTRACT_FN ] ] ( [ [ F_ORIG ] ] ) <nl> - / / CHECK : store [ [ F_SUBST_IN ] ] to [ [ F_SUBST_MAT ] ] <nl> + / / CHECK : store [ [ F_SUBST_IN ] ] to [ init ] [ [ F_SUBST_MAT ] ] <nl> / / CHECK : apply [ [ INOUTFUNC ] ] ( [ [ F_SUBST_MAT ] ] ) <nl> / / CHECK : [ [ F_SUBST_OUT : % . * ] ] = load [ [ F_SUBST_MAT ] ] <nl> / / CHECK : [ [ REABSTRACT_FN : % . * ] ] = function_ref @ _TTR <nl> mmm a / test / SILGen / property_behavior_init . swift <nl> ppp b / test / SILGen / property_behavior_init . swift <nl> struct Foo { <nl> / / CHECK : [ [ SELF : % . * ] ] = load [ [ UNINIT_SELF ] ] <nl> / / CHECK : [ [ GETTER : % . * ] ] = function_ref @ _TFV22property_behavior_init3Foog1xSi <nl> / / CHECK : [ [ VALUE : % . * ] ] = apply [ [ GETTER ] ] ( [ [ SELF ] ] ) <nl> - / / CHECK : store [ [ VALUE ] ] to [ [ INOUT ] ] <nl> + / / CHECK : store [ [ VALUE ] ] to [ trivial ] [ [ INOUT ] ] <nl> / / CHECK : apply [ [ WHACK ] ] < Int > ( [ [ INOUT ] ] ) <nl> / / CHECK : [ [ VALUE : % . * ] ] = load [ [ INOUT ] ] <nl> / / CHECK : [ [ SETTER : % . * ] ] = function_ref @ _TFV22property_behavior_init3Foos1xSi <nl> mmm a / test / SILGen / protocol_class_refinement . swift <nl> ppp b / test / SILGen / protocol_class_refinement . swift <nl> func getObjectUID < T : ObjectUID > ( x : T ) - > ( Int , Int , Int , Int ) { <nl> / / CHECK : [ [ X : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X ] ] <nl> / / CHECK : [ [ X_TMP : % . * ] ] = alloc_stack <nl> - / / CHECK : store [ [ X ] ] to [ [ X_TMP ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ X_TMP ] ] <nl> / / CHECK : [ [ GET_UID : % . * ] ] = witness_method $ T , # UID . uid ! 1 <nl> / / CHECK : [ [ UID : % . * ] ] = apply [ [ GET_UID ] ] < T > ( [ [ X_TMP ] ] ) <nl> / / CHECK : [ [ X2 : % . * ] ] = load [ [ X_TMP ] ] <nl> func getObjectUID < T : ObjectUID > ( x : T ) - > ( Int , Int , Int , Int ) { <nl> / / CHECK : [ [ X : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X ] ] <nl> / / CHECK : [ [ X_TMP : % . * ] ] = alloc_stack <nl> - / / CHECK : store [ [ X ] ] to [ [ X_TMP ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ X_TMP ] ] <nl> / / CHECK : [ [ GET_UID : % . * ] ] = witness_method $ T , # UID . uid ! 1 <nl> / / CHECK : [ [ UID : % . * ] ] = apply [ [ GET_UID ] ] < T > ( [ [ X_TMP ] ] ) <nl> / / CHECK : [ [ X2 : % . * ] ] = load [ [ X_TMP ] ] <nl> func getObjectUID < T : ObjectUID > ( x : T ) - > ( Int , Int , Int , Int ) { <nl> / / CHECK : [ [ X : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X ] ] <nl> / / CHECK : [ [ X_TMP : % . * ] ] = alloc_stack <nl> - / / CHECK : store [ [ X ] ] to [ [ X_TMP ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ X_TMP ] ] <nl> / / CHECK : [ [ GET_UID : % . * ] ] = witness_method $ T , # UID . uid ! 1 <nl> / / CHECK : [ [ UID : % . * ] ] = apply [ [ GET_UID ] ] < T > ( [ [ X_TMP ] ] ) <nl> / / CHECK : [ [ X2 : % . * ] ] = load [ [ X_TMP ] ] <nl> func getBaseObjectUID < T : UID where T : Base > ( x : T ) - > ( Int , Int , Int ) { <nl> / / CHECK : [ [ X : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X ] ] <nl> / / CHECK : [ [ X_TMP : % . * ] ] = alloc_stack <nl> - / / CHECK : store [ [ X ] ] to [ [ X_TMP ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ X_TMP ] ] <nl> / / CHECK : [ [ GET_UID : % . * ] ] = witness_method $ T , # UID . uid ! 1 <nl> / / CHECK : [ [ UID : % . * ] ] = apply [ [ GET_UID ] ] < T > ( [ [ X_TMP ] ] ) <nl> / / CHECK : [ [ X2 : % . * ] ] = load [ [ X_TMP ] ] <nl> func getBaseObjectUID < T : UID where T : Base > ( x : T ) - > ( Int , Int , Int ) { <nl> / / CHECK : [ [ X : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ X ] ] <nl> / / CHECK : [ [ X_TMP : % . * ] ] = alloc_stack <nl> - / / CHECK : store [ [ X ] ] to [ [ X_TMP ] ] <nl> + / / CHECK : store [ [ X ] ] to [ init ] [ [ X_TMP ] ] <nl> / / CHECK : [ [ GET_UID : % . * ] ] = witness_method $ T , # UID . uid ! 1 <nl> / / CHECK : [ [ UID : % . * ] ] = apply [ [ GET_UID ] ] < T > ( [ [ X_TMP ] ] ) <nl> / / CHECK : [ [ X2 : % . * ] ] = load [ [ X_TMP ] ] <nl> mmm a / test / SILGen / protocol_extensions . swift <nl> ppp b / test / SILGen / protocol_extensions . swift <nl> func testD ( _ m : MetaHolder , dd : D . Type , d : D ) { <nl> / / CHECK : [ [ RESULT : % . * ] ] = project_box [ [ D2 ] ] <nl> / / CHECK : [ [ FN : % [ 0 - 9 ] + ] ] = function_ref @ _TFE19protocol_extensionsPS_2P111returnsSelf { { . * } } <nl> / / CHECK : [ [ DCOPY : % [ 0 - 9 ] + ] ] = alloc_stack $ D <nl> - / / CHECK : store [ [ D ] ] to [ [ DCOPY ] ] : $ * D <nl> + / / CHECK : store [ [ D ] ] to [ init ] [ [ DCOPY ] ] : $ * D <nl> / / CHECK : apply [ [ FN ] ] < D > ( [ [ RESULT ] ] , [ [ DCOPY ] ] ) : $ @ convention ( method ) < τ_0_0 where τ_0_0 : P1 > ( @ in_guaranteed τ_0_0 ) - > @ out τ_0_0 <nl> var d2 : D = d . returnsSelf ( ) <nl> <nl> mmm a / test / SILGen / protocol_optional . swift <nl> ppp b / test / SILGen / protocol_optional . swift <nl> func optionalMethodGeneric < T : P1 > ( t t : T ) { <nl> / / CHECK : bb0 ( [ [ T : % [ 0 - 9 ] + ] ] : $ T ) : <nl> / / CHECK : [ [ TBOX : % [ 0 - 9 ] + ] ] = alloc_box $ T <nl> / / CHECK - NEXT : [ [ PT : % [ 0 - 9 ] + ] ] = project_box [ [ TBOX ] ] <nl> - / / CHECK : store [ [ T ] ] to [ [ PT ] ] : $ * T <nl> + / / CHECK : store [ [ T ] ] to [ init ] [ [ PT ] ] : $ * T <nl> / / CHECK - NEXT : [ [ OPT_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ Optional < @ callee_owned ( Int ) - > ( ) > <nl> / / CHECK - NEXT : project_box [ [ OPT_BOX ] ] <nl> / / CHECK - NEXT : [ [ T : % [ 0 - 9 ] + ] ] = load [ [ PT ] ] : $ * T <nl> func optionalPropertyGeneric < T : P1 > ( t t : T ) { <nl> / / CHECK : bb0 ( [ [ T : % [ 0 - 9 ] + ] ] : $ T ) : <nl> / / CHECK : [ [ TBOX : % [ 0 - 9 ] + ] ] = alloc_box $ T <nl> / / CHECK - NEXT : [ [ PT : % [ 0 - 9 ] + ] ] = project_box [ [ TBOX ] ] <nl> - / / CHECK : store [ [ T ] ] to [ [ PT ] ] : $ * T <nl> + / / CHECK : store [ [ T ] ] to [ init ] [ [ PT ] ] : $ * T <nl> / / CHECK - NEXT : [ [ OPT_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ Optional < Int > <nl> / / CHECK - NEXT : project_box [ [ OPT_BOX ] ] <nl> / / CHECK - NEXT : [ [ T : % [ 0 - 9 ] + ] ] = load [ [ PT ] ] : $ * T <nl> func optionalSubscriptGeneric < T : P1 > ( t t : T ) { <nl> / / CHECK : bb0 ( [ [ T : % [ 0 - 9 ] + ] ] : $ T ) : <nl> / / CHECK : [ [ TBOX : % [ 0 - 9 ] + ] ] = alloc_box $ T <nl> / / CHECK - NEXT : [ [ PT : % [ 0 - 9 ] + ] ] = project_box [ [ TBOX ] ] <nl> - / / CHECK : store [ [ T ] ] to [ [ PT ] ] : $ * T <nl> + / / CHECK : store [ [ T ] ] to [ init ] [ [ PT ] ] : $ * T <nl> / / CHECK - NEXT : [ [ OPT_BOX : % [ 0 - 9 ] + ] ] = alloc_box $ Optional < Int > <nl> / / CHECK - NEXT : project_box [ [ OPT_BOX ] ] <nl> / / CHECK - NEXT : [ [ T : % [ 0 - 9 ] + ] ] = load [ [ PT ] ] : $ * T <nl> mmm a / test / SILGen / reabstract_lvalue . swift <nl> ppp b / test / SILGen / reabstract_lvalue . swift <nl> func reabstractFunctionInOut ( ) { <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ BOX ] ] <nl> / / CHECK : [ [ ARG : % . * ] ] = function_ref @ _TF17reabstract_lvalue9transformFSiSd <nl> / / CHECK : [ [ THICK_ARG : % . * ] ] = thin_to_thick_function [ [ ARG ] ] <nl> - / / CHECK : store [ [ THICK_ARG : % . * ] ] to [ [ PB ] ] <nl> + / / CHECK : store [ [ THICK_ARG : % . * ] ] to [ init ] [ [ PB ] ] <nl> / / CHECK : [ [ FUNC : % . * ] ] = function_ref @ _TF17reabstract_lvalue19consumeGenericInOut <nl> / / CHECK : [ [ ABSTRACTED_BOX : % . * ] ] = alloc_stack $ @ callee_owned ( @ in Int ) - > @ out Double <nl> / / CHECK : [ [ THICK_ARG : % . * ] ] = load [ [ PB ] ] <nl> / / CHECK : copy_value [ [ THICK_ARG ] ] <nl> / / CHECK : [ [ THUNK1 : % . * ] ] = function_ref @ _TTRXFo_dSi_dSd_XFo_iSi_iSd_ <nl> / / CHECK : [ [ ABSTRACTED_ARG : % . * ] ] = partial_apply [ [ THUNK1 ] ] ( [ [ THICK_ARG ] ] ) <nl> - / / CHECK : store [ [ ABSTRACTED_ARG ] ] to [ [ ABSTRACTED_BOX ] ] <nl> + / / CHECK : store [ [ ABSTRACTED_ARG ] ] to [ init ] [ [ ABSTRACTED_BOX ] ] <nl> / / CHECK : apply [ [ FUNC ] ] < ( Int ) - > Double > ( [ [ ABSTRACTED_BOX ] ] ) <nl> / / CHECK : [ [ NEW_ABSTRACTED_ARG : % . * ] ] = load [ [ ABSTRACTED_BOX ] ] <nl> / / CHECK : [ [ THUNK2 : % . * ] ] = function_ref @ _TTRXFo_iSi_iSd_XFo_dSi_dSd_ <nl> func reabstractMetatypeInOut ( ) { <nl> / / CHECK : [ [ FUNC : % . * ] ] = function_ref @ _TF17reabstract_lvalue19consumeGenericInOut <nl> / / CHECK : [ [ BOX : % . * ] ] = alloc_stack $ @ thick MyMetatypeIsThin . Type <nl> / / CHECK : [ [ THICK : % . * ] ] = metatype $ @ thick MyMetatypeIsThin . Type <nl> - / / CHECK : store [ [ THICK ] ] to [ [ BOX ] ] <nl> + / / CHECK : store [ [ THICK ] ] to [ trivial ] [ [ BOX ] ] <nl> / / CHECK : apply [ [ FUNC ] ] < MyMetatypeIsThin . Type > ( [ [ BOX ] ] ) <nl> consumeGenericInOut ( & thinMetatype ) <nl> } <nl> mmm a / test / SILGen / scalar_to_tuple_args . swift <nl> ppp b / test / SILGen / scalar_to_tuple_args . swift <nl> tupleWithDefaults ( x : ( x , x ) ) <nl> / / CHECK : [ [ MEMORY : % . * ] ] = tuple_extract [ [ ALLOC_ARRAY ] ] { { . * } } , 1 <nl> / / CHECK : [ [ ADDR : % . * ] ] = pointer_to_address [ [ MEMORY ] ] <nl> / / CHECK : [ [ X : % . * ] ] = load [ [ X_ADDR ] ] <nl> - / / CHECK : store [ [ X ] ] to [ [ ADDR ] ] <nl> + / / CHECK : store [ [ X ] ] to [ trivial ] [ [ ADDR ] ] <nl> / / CHECK : apply [ [ VARIADIC_FIRST ] ] ( [ [ ARRAY ] ] ) <nl> variadicFirst ( x ) <nl> <nl> mmm a / test / SILGen / source_location . swift <nl> ppp b / test / SILGen / source_location . swift <nl> let FILE = # file , LINE = # line <nl> / / CHECK : [ [ FILE_ADDR : % . * ] ] = global_addr @ _Tv15source_location4FILESS <nl> / / CHECK : [ [ INPLACE_FILE_VAL : % . * ] ] = string_literal utf16 " inplace . swift " , <nl> / / CHECK : [ [ INPLACE_FILE : % . * ] ] = apply { { . * } } ( [ [ INPLACE_FILE_VAL ] ] , <nl> - / / CHECK : store [ [ INPLACE_FILE ] ] to [ [ FILE_ADDR ] ] <nl> + / / CHECK : store [ [ INPLACE_FILE ] ] to [ init ] [ [ FILE_ADDR ] ] <nl> / / CHECK : [ [ LINE_ADDR : % . * ] ] = global_addr @ _Tv15source_location4LINESi <nl> / / CHECK : [ [ INPLACE_LINE_VAL : % . * ] ] = integer_literal $ Builtin . Int { { [ 0 - 9 ] + } } , 20000 , <nl> / / CHECK : [ [ INPLACE_LINE : % . * ] ] = apply { { . * } } ( [ [ INPLACE_LINE_VAL ] ] , <nl> - / / CHECK : store [ [ INPLACE_LINE ] ] to [ [ LINE_ADDR ] ] <nl> + / / CHECK : store [ [ INPLACE_LINE ] ] to [ trivial ] [ [ LINE_ADDR ] ] <nl> mmm a / test / SILGen / super_init_refcounting . swift <nl> ppp b / test / SILGen / super_init_refcounting . swift <nl> class Bar : Foo { <nl> / / CHECK : [ [ SUPER_INIT : % [ 0 - 9 ] + ] ] = function_ref @ _TFC22super_init_refcounting3FoocfT_S0_ : $ @ convention ( method ) ( @ owned Foo ) - > @ owned Foo <nl> / / CHECK : [ [ NEW_SELF : % . * ] ] = apply [ [ SUPER_INIT ] ] ( [ [ ORIG_SELF_UP ] ] ) <nl> / / CHECK : [ [ NEW_SELF_DOWN : % . * ] ] = unchecked_ref_cast [ [ NEW_SELF ] ] <nl> - / / CHECK : store [ [ NEW_SELF_DOWN ] ] to [ [ SELF_MUI ] ] <nl> + / / CHECK : store [ [ NEW_SELF_DOWN ] ] to [ init ] [ [ SELF_MUI ] ] <nl> override init ( ) { <nl> super . init ( ) <nl> } <nl> extension Foo { <nl> / / CHECK - NOT : copy_value [ [ ORIG_SELF ] ] <nl> / / CHECK : [ [ SUPER_INIT : % . * ] ] = class_method <nl> / / CHECK : [ [ NEW_SELF : % . * ] ] = apply [ [ SUPER_INIT ] ] ( [ [ ORIG_SELF ] ] ) <nl> - / / CHECK : store [ [ NEW_SELF ] ] to [ [ SELF_MUI ] ] <nl> + / / CHECK : store [ [ NEW_SELF ] ] to [ init ] [ [ SELF_MUI ] ] <nl> convenience init ( x : Int ) { <nl> self . init ( ) <nl> } <nl> mmm a / test / SILGen / switch . swift <nl> ppp b / test / SILGen / switch . swift <nl> func testLabeledScalarPayload ( _ lsp : LabeledScalarPayload ) - > Any { <nl> / / CHECK : bb1 ( [ [ TUPLE : % . * ] ] : $ ( name : Int ) ) : <nl> / / CHECK : [ [ X : % . * ] ] = tuple_extract [ [ TUPLE ] ] <nl> / / CHECK : [ [ ANY_X_ADDR : % . * ] ] = init_existential_addr { { % . * } } , $ Int <nl> - / / CHECK : store [ [ X ] ] to [ [ ANY_X_ADDR ] ] <nl> + / / CHECK : store [ [ X ] ] to [ trivial ] [ [ ANY_X_ADDR ] ] <nl> case let . Payload ( x ) : <nl> return x <nl> } <nl> mmm a / test / SILGen / switch_var . swift <nl> ppp b / test / SILGen / switch_var . swift <nl> func test_mixed_let_var ( ) { <nl> case var x where runced ( ) : <nl> / / CHECK : [ [ BOX : % . * ] ] = alloc_box $ String , var , name " x " <nl> / / CHECK : [ [ PBOX : % . * ] ] = project_box [ [ BOX ] ] <nl> - / / CHECK : store [ [ VAL ] ] to [ [ PBOX ] ] <nl> + / / CHECK : [ [ VAL_COPY : % . * ] ] = copy_value [ [ VAL ] ] <nl> + / / CHECK : store [ [ VAL_COPY ] ] to [ [ PBOX ] ] <nl> / / CHECK : [ [ A : % . * ] ] = function_ref @ _TF10switch_var1aFT1xSS_T_ <nl> / / CHECK : [ [ X : % . * ] ] = load [ [ PBOX ] ] <nl> - / / CHECK : copy_value [ [ X ] ] <nl> / / CHECK : apply [ [ A ] ] ( [ [ X ] ] ) <nl> a ( x : x ) <nl> case let y where funged ( ) : <nl> func test_multiple_patterns5 ( ) { <nl> / / CHECK : [ [ A_X : % . * ] ] = tuple_extract <nl> / / CHECK : [ [ A_N : % . * ] ] = tuple_extract <nl> / / CHECK : [ [ A_BOX : % . * ] ] = project_box <nl> - / / CHECK : store [ [ A_X ] ] to [ [ A_BOX ] ] <nl> + / / CHECK : store [ [ A_X ] ] to [ trivial ] [ [ A_BOX ] ] <nl> / / CHECK : [ [ FUNC_A : % . * ] ] = function_ref @ _TF10switch_var3aaaFT1xRSi_T_ <nl> / / CHECK : apply [ [ FUNC_A ] ] ( [ [ A_BOX ] ] ) <nl> <nl> func test_multiple_patterns5 ( ) { <nl> / / CHECK : [ [ B_N : % . * ] ] = tuple_extract <nl> / / CHECK : [ [ B_X : % . * ] ] = tuple_extract <nl> / / CHECK : [ [ B_BOX : % . * ] ] = project_box <nl> - / / CHECK : store [ [ B_X ] ] to [ [ B_BOX ] ] <nl> + / / CHECK : store [ [ B_X ] ] to [ trivial ] [ [ B_BOX ] ] <nl> / / CHECK : [ [ FUNC_B : % . * ] ] = function_ref @ _TF10switch_var3aaaFT1xRSi_T_ <nl> / / CHECK : apply [ [ FUNC_B ] ] ( [ [ B_BOX ] ] ) <nl> <nl> / / CHECK : [ [ C ] ] ( { { % . * } } : $ ( Int , Int , Double ) ) : <nl> / / CHECK : [ [ Y_BOX : % . * ] ] = project_box <nl> - / / CHECK : store [ [ Y_X ] ] to [ [ Y_BOX ] ] <nl> + / / CHECK : store [ [ Y_X ] ] to [ trivial ] [ [ Y_BOX ] ] <nl> / / CHECK : [ [ FUNC_C : % . * ] ] = function_ref @ _TF10switch_var3aaaFT1xRSi_T_ <nl> / / CHECK : apply [ [ FUNC_C ] ] ( [ [ Y_BOX ] ] ) <nl> <nl> func test_multiple_patterns5 ( ) { <nl> / / CHECK : [ [ Z_X : % . * ] ] = tuple_extract <nl> / / CHECK : [ [ Z_F : % . * ] ] = tuple_extract <nl> / / CHECK : [ [ Z_BOX : % . * ] ] = project_box <nl> - / / CHECK : store [ [ Z_X ] ] to [ [ Z_BOX ] ] <nl> + / / CHECK : store [ [ Z_X ] ] to [ trivial ] [ [ Z_BOX ] ] <nl> / / CHECK : [ [ FUNC_Z : % . * ] ] = function_ref @ _TF10switch_var3aaaFT1xRSi_T_ <nl> / / CHECK : apply [ [ FUNC_Z ] ] ( [ [ Z_BOX ] ] ) <nl> aaa ( x : & x ) <nl> mmm a / test / SILGen / toplevel . swift <nl> ppp b / test / SILGen / toplevel . swift <nl> func trap ( ) - > Never { <nl> / / CHECK : alloc_global @ _Tv8toplevel1xSi <nl> / / CHECK : [ [ X : % [ 0 - 9 ] + ] ] = global_addr @ _Tv8toplevel1xSi : $ * Int <nl> / / CHECK : integer_literal $ Builtin . Int2048 , 999 <nl> - / / CHECK : store { { . * } } to [ [ X ] ] <nl> + / / CHECK : store { { . * } } to [ trivial ] [ [ X ] ] <nl> <nl> var x = 999 <nl> <nl> print_y ( ) <nl> / / CHECK - LABEL : function_ref toplevel . A . __allocating_init <nl> / / CHECK : switch_enum { { % . + } } : $ Optional < A > , case # Optional . some ! enumelt . 1 : [ [ SOME_CASE : . + ] ] , default <nl> / / CHECK : [ [ SOME_CASE ] ] ( [ [ VALUE : % . + ] ] : $ A ) : <nl> - / / CHECK : store [ [ VALUE ] ] to [ [ BOX : % . + ] ] : $ * A <nl> + / / CHECK : store [ [ VALUE ] ] to [ init ] [ [ BOX : % . + ] ] : $ * A <nl> / / CHECK - NOT : destroy_value <nl> / / CHECK : [ [ SINK : % . + ] ] = function_ref @ _TF8toplevel8markUsedurFxT_ <nl> / / CHECK - NOT : destroy_value <nl> mmm a / test / SILGen / toplevel_errors . swift <nl> ppp b / test / SILGen / toplevel_errors . swift <nl> throw MyError . A <nl> / / CHECK : [ [ ERR : % . * ] ] = alloc_existential_box $ Error , $ MyError <nl> / / CHECK : [ [ ADDR : % . * ] ] = project_existential_box $ MyError in [ [ ERR ] ] : $ Error <nl> / / CHECK : [ [ T0 : % . * ] ] = enum $ MyError , # MyError . A ! enumelt <nl> - / / CHECK : store [ [ T0 ] ] to [ [ ADDR ] ] : $ * MyError <nl> + / / CHECK : store [ [ T0 ] ] to [ trivial ] [ [ ADDR ] ] : $ * MyError <nl> / / CHECK : builtin " willThrow " ( [ [ ERR ] ] : $ Error ) <nl> / / CHECK : br bb2 ( [ [ ERR ] ] : $ Error ) <nl> <nl> mmm a / test / SILGen / tuples . swift <nl> ppp b / test / SILGen / tuples . swift <nl> func testShuffleOpaque ( ) { <nl> <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TF6tuples7make_xyFT_T1xSi1yPS_1P__ <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( [ [ PBX ] ] ) <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ PBY ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ trivial ] [ [ PBY ] ] <nl> var ( x , y ) : ( y : P , x : Int ) = make_xy ( ) <nl> <nl> / / CHECK - NEXT : [ [ PAIR : % . * ] ] = alloc_box $ ( y : P , x : Int ) <nl> func testShuffleOpaque ( ) { <nl> / / CHECK - NEXT : / / function_ref <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = function_ref @ _TF6tuples7make_xyFT_T1xSi1yPS_1P__ <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( [ [ PAIR_0 ] ] ) <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ PAIR_1 ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ trivial ] [ [ PAIR_1 ] ] <nl> var pair : ( y : P , x : Int ) = make_xy ( ) <nl> <nl> / / CHECK - NEXT : / / function_ref <nl> func testShuffleTuple ( ) { <nl> <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TF6tuples8make_intFT_Si <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( ) <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ PBY ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ trivial ] [ [ PBY ] ] <nl> / / CHECK - NEXT : / / function_ref <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = function_ref @ _TF6tuples6make_pFT_PS_1P_ <nl> / / CHECK - NEXT : apply [ [ T0 ] ] ( [ [ PBX ] ] ) <nl> func testShuffleTuple ( ) { <nl> / / CHECK - NEXT : / / function_ref <nl> / / CHECK : [ [ T0 : % . * ] ] = function_ref @ _TF6tuples8make_intFT_Si <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = apply [ [ T0 ] ] ( ) <nl> - / / CHECK - NEXT : store [ [ T1 ] ] to [ [ PAIR_1 ] ] <nl> + / / CHECK - NEXT : store [ [ T1 ] ] to [ trivial ] [ [ PAIR_1 ] ] <nl> / / CHECK - NEXT : / / function_ref <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = function_ref @ _TF6tuples6make_pFT_PS_1P_ <nl> / / CHECK - NEXT : apply [ [ T0 ] ] ( [ [ PAIR_0 ] ] ) <nl> mmm a / test / SILGen / unowned . swift <nl> ppp b / test / SILGen / unowned . swift <nl> _ = AddressOnly ( x : C ( ) , p : X ( ) ) <nl> / / CHECK : [ [ X_ADDR : % . * ] ] = struct_element_addr [ [ RET ] ] : $ * AddressOnly , # AddressOnly . x <nl> / / CHECK : [ [ X_UNOWNED : % . * ] ] = ref_to_unowned [ [ X ] ] : $ C to $ @ sil_unowned C <nl> / / CHECK : unowned_retain [ [ X_UNOWNED ] ] : $ @ sil_unowned C <nl> - / / CHECK : store [ [ X_UNOWNED ] ] to [ [ X_ADDR ] ] <nl> + / / CHECK : store [ [ X_UNOWNED ] ] to [ init ] [ [ X_ADDR ] ] <nl> / / CHECK : destroy_value [ [ X ] ] <nl> / / CHECK : } <nl> <nl> func test0 ( c c : C ) { <nl> / / CHECK - NEXT : [ [ PBX : % . * ] ] = project_box [ [ X ] ] <nl> / / CHECK - NEXT : [ [ T2 : % . * ] ] = ref_to_unowned % 0 : $ C to $ @ sil_unowned C <nl> / / CHECK - NEXT : unowned_retain [ [ T2 ] ] : $ @ sil_unowned C <nl> - / / CHECK - NEXT : store [ [ T2 ] ] to [ [ PBX ] ] : $ * @ sil_unowned C <nl> + / / CHECK - NEXT : store [ [ T2 ] ] to [ init ] [ [ PBX ] ] : $ * @ sil_unowned C <nl> <nl> a . x = c <nl> / / CHECK - NEXT : [ [ T1 : % . * ] ] = struct_element_addr [ [ A ] ] : $ * A , # A . x <nl> func unowned_local ( ) - > C { <nl> / / CHECK - NEXT : [ [ PB : % . * ] ] = project_box [ [ uc ] ] <nl> / / CHECK - NEXT : [ [ tmp1 : % . * ] ] = ref_to_unowned [ [ c ] ] : $ C to $ @ sil_unowned C <nl> / / CHECK - NEXT : unowned_retain [ [ tmp1 ] ] <nl> - / / CHECK - NEXT : store [ [ tmp1 ] ] to [ [ PB ] ] <nl> + / / CHECK - NEXT : store [ [ tmp1 ] ] to [ init ] [ [ PB ] ] <nl> unowned let uc = c <nl> <nl> / / CHECK - NEXT : [ [ tmp2 : % . * ] ] = load [ [ PB ] ] <nl> mmm a / test / SILGen / weak . swift <nl> ppp b / test / SILGen / weak . swift <nl> func test0 ( c c : C ) { <nl> / / CHECK - NEXT : debug_value_addr % 1 : $ * @ sil_weak Optional < C > , var , name " bC " , argno 1 <nl> / / CHECK - NEXT : % 3 = alloc_stack $ Optional < C > <nl> / / CHECK - NEXT : % 4 = load_weak % 1 : $ * @ sil_weak Optional < C > <nl> - / / CHECK - NEXT : store % 4 to % 3 : $ * Optional < C > <nl> + / / CHECK - NEXT : store % 4 to [ init ] % 3 : $ * Optional < C > <nl> func testClosureOverWeak ( ) { <nl> weak var bC = C ( ) <nl> takeClosure { bC ! . f ( ) } <nl> class CC { <nl> / / CHECK : [ [ PB : % . * ] ] = project_box [ [ FOO ] ] <nl> / / CHECK : [ [ X : % . * ] ] = ref_element_addr % 2 : $ CC , # CC . x <nl> / / CHECK : [ [ VALUE : % . * ] ] = load_weak [ [ X ] ] : $ * @ sil_weak Optional < CC > <nl> - / / CHECK : store [ [ VALUE ] ] to [ [ PB ] ] : $ * Optional < CC > <nl> + / / CHECK : store [ [ VALUE ] ] to [ init ] [ [ PB ] ] : $ * Optional < CC > <nl> init ( ) { <nl> var foo = x <nl> } <nl> mmm a / test / SILGen / witnesses . swift <nl> ppp b / test / SILGen / witnesses . swift <nl> struct ConformsWithMoreGeneric : X , Y { <nl> / / CHECK - LABEL : sil hidden [ transparent ] [ thunk ] @ _TTWV9witnesses23ConformsWithMoreGenericS_1XS_FS1_7classes { { . * } } : $ @ convention ( witness_method ) < τ_0_0 where τ_0_0 : Classes > ( @ owned τ_0_0 , @ inout ConformsWithMoreGeneric ) - > @ owned τ_0_0 { <nl> / / CHECK : bb0 ( % 0 : $ τ_0_0 , % 1 : $ * ConformsWithMoreGeneric ) : <nl> / / CHECK - NEXT : [ [ SELF_BOX : % . * ] ] = alloc_stack $ τ_0_0 <nl> - / / CHECK - NEXT : store % 0 to [ [ SELF_BOX ] ] : $ * τ_0_0 <nl> + / / CHECK - NEXT : store % 0 to [ init ] [ [ SELF_BOX ] ] : $ * τ_0_0 <nl> / / CHECK - NEXT : / / function_ref witnesses . ConformsWithMoreGeneric . classes <nl> / / CHECK - NEXT : [ [ WITNESS_FN : % . * ] ] = function_ref @ _TFV9witnesses23ConformsWithMoreGeneric7classes { { . * } } : $ @ convention ( method ) < τ_0_0 > ( @ in τ_0_0 , @ inout ConformsWithMoreGeneric ) - > @ out τ_0_0 <nl> / / CHECK - NEXT : [ [ RESULT_BOX : % . * ] ] = alloc_stack $ τ_0_0 <nl> struct IUOFailableModel : NonFailableRefinement , IUOFailableRequirement { <nl> / / CHECK : [ [ INIT : % [ 0 - 9 ] + ] ] = function_ref @ _TFV9witnesses16IUOFailableModelC { { . * } } : $ @ convention ( method ) ( Int , @ thin IUOFailableModel . Type ) - > Optional < IUOFailableModel > <nl> / / CHECK : [ [ IUO_RESULT : % [ 0 - 9 ] + ] ] = apply [ [ INIT ] ] ( [ [ FOO ] ] , [ [ META ] ] ) : $ @ convention ( method ) ( Int , @ thin IUOFailableModel . Type ) - > Optional < IUOFailableModel > <nl> / / CHECK : [ [ RESULT : % [ 0 - 9 ] + ] ] = unchecked_enum_data [ [ IUO_RESULT ] ] <nl> - / / CHECK : store [ [ RESULT ] ] to [ [ SELF ] ] : $ * IUOFailableModel <nl> + / / CHECK : store [ [ RESULT ] ] to [ trivial ] [ [ SELF ] ] : $ * IUOFailableModel <nl> / / CHECK : return <nl> init ! ( foo : Int ) { return nil } <nl> } <nl> mmm a / test / SILGen / writeback . swift <nl> ppp b / test / SILGen / writeback . swift <nl> x . foo ( ) <nl> / / CHECK : [ [ X_TEMP : % . * ] ] = alloc_stack $ Foo <nl> / / CHECK : [ [ GET_X : % . * ] ] = function_ref @ _TF9writebackg1xVS_3Foo : $ @ convention ( thin ) ( ) - > Foo <nl> / / CHECK : [ [ X : % . * ] ] = apply [ [ GET_X ] ] ( ) : $ @ convention ( thin ) ( ) - > Foo <nl> - / / CHECK : store [ [ X ] ] to [ [ X_TEMP ] ] <nl> + / / CHECK : store [ [ X ] ] to [ trivial ] [ [ X_TEMP ] ] <nl> / / CHECK : apply [ [ FOO ] ] ( [ [ X_TEMP ] ] ) : $ @ convention ( method ) ( @ inout Foo ) - > ( ) <nl> / / CHECK : [ [ X1 : % . * ] ] = load [ [ X_TEMP ] ] : $ * Foo <nl> / / CHECK : [ [ SET_X : % . * ] ] = function_ref @ _TF9writebacks1xVS_3Foo : $ @ convention ( thin ) ( Foo ) - > ( ) <nl> bar ( x : & x ) <nl> / / CHECK : [ [ X_TEMP : % . * ] ] = alloc_stack $ Foo <nl> / / CHECK : [ [ GET_X : % . * ] ] = function_ref @ _TF9writebackg1xVS_3Foo : $ @ convention ( thin ) ( ) - > Foo <nl> / / CHECK : [ [ X : % . * ] ] = apply [ [ GET_X ] ] ( ) : $ @ convention ( thin ) ( ) - > Foo <nl> - / / CHECK : store [ [ X ] ] to [ [ X_TEMP ] ] : $ * Foo <nl> + / / CHECK : store [ [ X ] ] to [ trivial ] [ [ X_TEMP ] ] : $ * Foo <nl> / / CHECK : apply [ [ BAR ] ] ( [ [ X_TEMP ] ] ) : $ @ convention ( thin ) ( @ inout Foo ) - > ( ) <nl> / / CHECK : [ [ X1 : % . * ] ] = load [ [ X_TEMP ] ] : $ * Foo <nl> / / CHECK : [ [ SET_X : % . * ] ] = function_ref @ _TF9writebacks1xVS_3Foo : $ @ convention ( thin ) ( Foo ) - > ( ) <nl> mmm a / test / Serialization / always_inline . swift <nl> ppp b / test / Serialization / always_inline . swift <nl> import def_always_inline <nl> / / SIL : [ [ RAW : % . + ] ] = global_addr @ _Tv13always_inline3rawSb : $ * Bool <nl> / / SIL : [ [ FUNC : % . + ] ] = function_ref @ _TF17def_always_inline16testAlwaysInlineFT1xSb_Sb : $ @ convention ( thin ) ( Bool ) - > Bool <nl> / / SIL : [ [ RESULT : % . + ] ] = apply [ [ FUNC ] ] ( { { % . + } } ) : $ @ convention ( thin ) ( Bool ) - > Bool <nl> - / / SIL : store [ [ RESULT ] ] to [ [ RAW ] ] : $ * Bool <nl> + / / SIL : store [ [ RESULT ] ] to [ trivial ] [ [ RAW ] ] : $ * Bool <nl> var raw = testAlwaysInline ( x : false ) <nl> <nl> / / SIL : [ [ FUNC2 : % . + ] ] = function_ref @ _TFV17def_always_inline22AlwaysInlineInitStructCfT1xSb_S0_ : $ @ convention ( method ) ( Bool , @ thin AlwaysInlineInitStruct . Type ) - > AlwaysInlineInitStruct <nl> mmm a / test / Serialization / function . swift <nl> ppp b / test / Serialization / function . swift <nl> func useEq < T : EqualOperator > ( _ x : T , y : T ) - > Bool { <nl> / / SIL : [ [ RAW : % . + ] ] = global_addr @ _Tv8function3rawSi : $ * Int <nl> / / SIL : [ [ ZERO : % . + ] ] = function_ref @ _TF8def_func7getZeroFT_Si : $ @ convention ( thin ) ( ) - > Int <nl> / / SIL : [ [ RESULT : % . + ] ] = apply [ [ ZERO ] ] ( ) : $ @ convention ( thin ) ( ) - > Int <nl> - / / SIL : store [ [ RESULT ] ] to [ [ RAW ] ] : $ * Int <nl> + / / SIL : store [ [ RESULT ] ] to [ trivial ] [ [ RAW ] ] : $ * Int <nl> var raw = getZero ( ) <nl> <nl> / / Check that ' raw ' is an Int <nl> mmm a / test / Serialization / noinline . swift <nl> ppp b / test / Serialization / noinline . swift <nl> import def_noinline <nl> / / SIL : [ [ RAW : % . + ] ] = global_addr @ _Tv8noinline3rawSb : $ * Bool <nl> / / SIL : [ [ FUNC : % . + ] ] = function_ref @ _TF12def_noinline12testNoinlineFT1xSb_Sb : $ @ convention ( thin ) ( Bool ) - > Bool <nl> / / SIL : [ [ RESULT : % . + ] ] = apply [ [ FUNC ] ] ( { { % . + } } ) : $ @ convention ( thin ) ( Bool ) - > Bool <nl> - / / SIL : store [ [ RESULT ] ] to [ [ RAW ] ] : $ * Bool <nl> + / / SIL : store [ [ RESULT ] ] to [ trivial ] [ [ RAW ] ] : $ * Bool <nl> var raw = testNoinline ( x : false ) <nl> <nl> / / SIL : [ [ FUNC2 : % . + ] ] = function_ref @ _TFV12def_noinline18NoInlineInitStructCfT1xSb_S0_ : $ @ convention ( method ) ( Bool , @ thin NoInlineInitStruct . Type ) - > NoInlineInitStruct <nl> mmm a / test / Serialization / transparent . swift <nl> ppp b / test / Serialization / transparent . swift <nl> import def_transparent <nl> / / SIL : [ [ RAW : % . + ] ] = global_addr @ _Tv11transparent3rawSb : $ * Bool <nl> / / SIL : [ [ FUNC : % . + ] ] = function_ref @ _TF15def_transparent15testTransparentFT1xSb_Sb : $ @ convention ( thin ) ( Bool ) - > Bool <nl> / / SIL : [ [ RESULT : % . + ] ] = apply [ [ FUNC ] ] ( { { % . + } } ) : $ @ convention ( thin ) ( Bool ) - > Bool <nl> - / / SIL : store [ [ RESULT ] ] to [ [ RAW ] ] : $ * Bool <nl> + / / SIL : store [ [ RESULT ] ] to [ trivial ] [ [ RAW ] ] : $ * Bool <nl> var raw = testTransparent ( x : false ) <nl> <nl> / / SIL : [ [ TMP : % . + ] ] = global_addr @ _Tv11transparent3tmpVs5Int32 : $ * Int32 <nl> / / SIL : [ [ FUNC2 : % . + ] ] = function_ref @ _TF15def_transparent11testBuiltinFT_Vs5Int32 : $ @ convention ( thin ) ( ) - > Int32 <nl> / / SIL : [ [ RESULT2 : % . + ] ] = apply [ [ FUNC2 ] ] ( ) : $ @ convention ( thin ) ( ) - > Int32 <nl> - / / SIL : store [ [ RESULT2 ] ] to [ [ TMP ] ] : $ * Int32 <nl> + / / SIL : store [ [ RESULT2 ] ] to [ trivial ] [ [ TMP ] ] : $ * Int32 <nl> var tmp = testBuiltin ( ) <nl> <nl> / / SIL - LABEL : sil public_external [ transparent ] [ fragile ] @ _TF15def_transparent15testTransparentFT1xSb_Sb : $ @ convention ( thin ) ( Bool ) - > Bool { <nl> | Merge pull request from gottesmm / change_silgen_emit_qualified_loadstrong | apple/swift | 468c4b36677ef8e04923e3e17df4dce8d14837ce | 2016-10-31T23:53:30Z |
mmm a / tensorflow / BUILD <nl> ppp b / tensorflow / BUILD <nl> <nl> # learning applications . <nl> <nl> load ( " @ bazel_skylib / / lib : selects . bzl " , " selects " ) <nl> + load ( " @ bazel_skylib / / rules : common_settings . bzl " , " bool_flag " ) <nl> load ( " / / tensorflow : tensorflow . bzl " , " VERSION " , " tf_cc_shared_object " , " tf_custom_op_library_additional_deps_impl " , " tf_native_cc_binary " ) <nl> load ( <nl> " / / tensorflow / core / platform : build_config . bzl " , <nl> selects . config_setting_group ( <nl> ] , <nl> ) <nl> <nl> + # ' enable_registration_v2 ' opts - in to a different implementation of op and <nl> + # kernel registration - REGISTER_OP , REGISTER_KERNEL_BUILDER , etc . <nl> + # <nl> + # This setting is currently experimental . The ' v2 ' implementation does _not_ <nl> + # correspond to a particular , finalized design ; rather , it relates to <nl> + # developing one . <nl> + # <nl> + # The current aim of the ' v2 ' implementation is to allow ' unused ' ops and <nl> + # kernels to be discarded by the linker ( to the benefit of binary size ) . <nl> + bool_flag ( <nl> + name = " enable_registration_v2 " , <nl> + build_setting_default = False , <nl> + visibility = [ " / / visibility : public " ] , <nl> + ) <nl> + <nl> + config_setting ( <nl> + name = " registration_v1 " , <nl> + flag_values = { " : enable_registration_v2 " : " False " } , <nl> + visibility = [ " / / visibility : public " ] , <nl> + ) <nl> + <nl> + config_setting ( <nl> + name = " registration_v2 " , <nl> + flag_values = { " : enable_registration_v2 " : " True " } , <nl> + visibility = [ " / / visibility : public " ] , <nl> + ) <nl> + <nl> # DO NOT ADD ANY NEW EXCEPTIONS TO THIS LIST ! <nl> # Instead , please use public APIs or public build rules TF provides . <nl> # If you need functionality that is not exposed , we will work with you to expand our public APIs . <nl> bzl_library ( <nl> " / / third_party / mkl : build_defs_bzl " , <nl> " / / third_party / mkl_dnn : build_defs_bzl " , <nl> " / / third_party / ngraph : build_defs_bzl " , <nl> + " @ bazel_skylib / / rules : common_settings " , <nl> " @ local_config_cuda / / cuda : build_defs_bzl " , <nl> " @ local_config_rocm / / rocm : build_defs_bzl " , <nl> " @ local_config_tensorrt / / : build_defs_bzl " , <nl> mmm a / tensorflow / core / BUILD <nl> ppp b / tensorflow / core / BUILD <nl> tf_cuda_library ( <nl> " / / tensorflow / core / framework : reader_op_kernel . h " , <nl> " / / tensorflow / core / framework : register_types . h " , <nl> " / / tensorflow / core / framework : register_types_traits . h " , <nl> + " / / tensorflow / core / framework : registration_options . h " , <nl> " / / tensorflow / core / framework : resource_mgr . h " , <nl> " / / tensorflow / core / framework : resource_op_kernel . h " , <nl> " / / tensorflow / core / framework : rng_alg . h " , <nl> mmm a / tensorflow / core / framework / BUILD <nl> ppp b / tensorflow / core / framework / BUILD <nl> load ( <nl> " tf_cc_tests " , <nl> " tf_copts " , <nl> " tf_cuda_library " , <nl> + " tf_gen_options_header " , <nl> ) <nl> <nl> # buildifier : disable = same - origin - load <nl> exports_files ( <nl> " op . h " , <nl> " op_def_builder . h " , <nl> " op_def_util . h " , <nl> + " registration_options " , <nl> " selective_registration . h " , <nl> " shape_inference . h " , <nl> ] , <nl> filegroup ( <nl> " reader_op_kernel . h " , <nl> " register_types . h " , <nl> " register_types_traits . h " , <nl> + " registration_options . h " , <nl> " rendezvous . h " , <nl> " resource_handle . h " , <nl> " resource_mgr . h " , <nl> filegroup ( <nl> " queue_interface . h " , <nl> " reader_interface . h " , <nl> " register_types_traits . h " , <nl> + " registration_options . h " , <nl> " rendezvous . cc " , <nl> " rendezvous . h " , <nl> " resource_mgr . cc " , <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> + tf_gen_options_header ( <nl> + name = " gen_registration_options " , <nl> + build_settings = { <nl> + " / / tensorflow : enable_registration_v2 " : " REGISTRATION_V2 " , <nl> + } , <nl> + output_header = " registration_options . h " , <nl> + template = " registration_options . h . tpl " , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " selective_registration " , <nl> - hdrs = [ " selective_registration . h " ] , <nl> + hdrs = [ <nl> + " registration_options . h " , <nl> + " selective_registration . h " , <nl> + ] , <nl> deps = tf_selective_registration_deps ( ) , <nl> ) <nl> <nl> new file mode 100644 <nl> index 0000000000000 . . 375a1088b5187 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / framework / registration_options . h . tpl <nl> <nl> + / * Copyright 2020 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # ifndef TENSORFLOW_CORE_FRAMEWORK_REGISTRATION_OPTIONS_TMPL_H_ <nl> + # define TENSORFLOW_CORE_FRAMEWORK_REGISTRATION_OPTIONS_TMPL_H_ <nl> + <nl> + / / This header is generated from a template ; see the tf_gen_options_header ( ) <nl> + / / build rule . Template placeholders of the form ' # define_option X ' result in <nl> + / / macros of the form ' TF_OPTION_X ( ) ' . <nl> + <nl> + # define_option REGISTRATION_V2 <nl> + <nl> + # endif / / TENSORFLOW_CORE_FRAMEWORK_REGISTRATION_OPTIONS_TMPL_H_ <nl> mmm a / tensorflow / core / framework / selective_registration . h <nl> ppp b / tensorflow / core / framework / selective_registration . h <nl> limitations under the License . <nl> # include < type_traits > <nl> # include < utility > <nl> <nl> + # include " tensorflow / core / framework / registration_options . h " <nl> + <nl> + # if ! TF_OPTION_REGISTRATION_V2 ( ) <nl> + <nl> # ifdef SELECTIVE_REGISTRATION <nl> <nl> / / Experimental selective registration support to reduce binary size . <nl> limitations under the License . <nl> ! defined ( SHOULD_REGISTER_OP_KERNEL ) ) <nl> static_assert ( false , " ops_to_register . h must define SHOULD_REGISTER macros " ) ; <nl> # endif <nl> - # else <nl> + # else / / SELECTIVE_REGISTRATION <nl> # define SHOULD_REGISTER_OP ( op ) true <nl> # define SHOULD_REGISTER_OP_GRADIENT true <nl> # define SHOULD_REGISTER_OP_KERNEL ( clz ) true <nl> + # endif / / SELECTIVE_REGISTRATION <nl> + <nl> + # else / / ! TF_OPTION_REGISTRATION_V2 ( ) <nl> + <nl> + # ifdef SELECTIVE_REGISTRATION <nl> + # error TF_OPTION_REGISTRATION_V2 ( ) : Compile - time selective registration is not supported <nl> # endif <nl> <nl> + # endif / / ! TF_OPTION_REGISTRATION_V2 ( ) <nl> + <nl> namespace tensorflow { <nl> <nl> / / An InitOnStartupMarker is ' initialized ' on program startup , purely for the <nl> mmm a / tensorflow / tensorflow . bzl <nl> ppp b / tensorflow / tensorflow . bzl <nl> load ( <nl> " / / third_party / ngraph : build_defs . bzl " , <nl> " if_ngraph " , <nl> ) <nl> + load ( " @ bazel_skylib / / rules : common_settings . bzl " , " BuildSettingInfo " ) <nl> <nl> # version for the shared libraries , can <nl> # not contain rc or alpha , only numbers . <nl> def if_libtpu ( if_true , if_false = [ ] ) : <nl> " / / conditions : default " : if_false , <nl> } ) <nl> <nl> + def if_registration_v2 ( if_true , if_false = [ ] ) : <nl> + return select ( { <nl> + " / / tensorflow : registration_v2 " : if_true , <nl> + " / / conditions : default " : if_false , <nl> + } ) <nl> + <nl> # Linux systems may required - lrt linker flag for e . g . clock_gettime <nl> # see https : / / github . com / tensorflow / tensorflow / issues / 15129 <nl> def lrt_if_needed ( ) : <nl> def internal_tfrt_deps ( ) : <nl> <nl> def internal_cuda_deps ( ) : <nl> return [ ] <nl> + <nl> + def _tf_gen_options_header_impl ( ctx ) : <nl> + header_depset = depset ( [ ctx . outputs . output_header ] ) <nl> + <nl> + define_vals = { True : " true " , False : " false " } <nl> + substitutions = { } <nl> + for target , identifier in ctx . attr . build_settings . items ( ) : <nl> + setting_val = target [ BuildSettingInfo ] . value <nl> + lines = [ <nl> + " / / % s " % target . label , <nl> + " # define TF_OPTION_ % s ( ) % s " % ( identifier , define_vals [ setting_val ] ) , <nl> + ] <nl> + substitutions [ " # define_option % s " % identifier ] = " \ n " . join ( lines ) <nl> + <nl> + ctx . actions . expand_template ( <nl> + template = ctx . file . template , <nl> + output = ctx . outputs . output_header , <nl> + substitutions = substitutions , <nl> + ) <nl> + <nl> + return [ <nl> + DefaultInfo ( files = header_depset ) , <nl> + ] <nl> + <nl> + tf_gen_options_header = rule ( <nl> + attrs = { <nl> + " output_header " : attr . output ( <nl> + doc = " File path for the generated header ( output ) " , <nl> + mandatory = True , <nl> + ) , <nl> + " template " : attr . label ( <nl> + doc = " " " Template for the header . <nl> + For each option name ' X ' ( see build_settings attribute ) , <nl> + ' # define_option X ' results in a macro ' TF_OPTION_X ( ) ' <nl> + " " " , <nl> + allow_single_file = True , <nl> + mandatory = True , <nl> + ) , <nl> + " build_settings " : attr . label_keyed_string_dict ( <nl> + doc = " " " Dictionary from build - setting labels to option names . Example : <nl> + { " / / tensorflow : x_setting " : " X " } <nl> + " " " , <nl> + providers = [ BuildSettingInfo ] , <nl> + ) , <nl> + } , <nl> + implementation = _tf_gen_options_header_impl , <nl> + doc = " " " <nl> + Generates a header file for Bazel build settings . <nl> + <nl> + This is an alternative to setting preprocessor defines on the compiler <nl> + command line . It has a few advantages : <nl> + - Usage of the options requires # include - ing the header , and thus a <nl> + Bazel - level dependency . <nl> + - Each option has a definition site in source code , which mentions the <nl> + corresponding Bazel setting . This is particularly useful when <nl> + navigating code with the assistance of static analysis ( e . g . <nl> + https : / / cs . opensource . google / tensorflow ) . <nl> + - Each option is represented as a FUNCTION ( ) - style macro , which is always <nl> + defined ( i . e . one uses # if instead of # ifdef ) . This allows forms like <nl> + ' if constexpr ( TF_OPTION_FOO ( ) ) { . . . } ' , and helps catch missing <nl> + dependencies ( if ' F ' is undefined , ' # if F ( ) ' results in an error ) . <nl> + " " " , <nl> + ) <nl> | Add a Bazel - level config setting for experimental changes to registration | tensorflow/tensorflow | 028e652150ca540259a4ec9536e0080c8566d706 | 2020-10-20T18:33:35Z |
mmm a / programs / cleos / main . cpp <nl> ppp b / programs / cleos / main . cpp <nl> bool print_response = false ; <nl> uint8_t tx_max_cpu_usage = 0 ; <nl> uint32_t tx_max_net_usage = 0 ; <nl> <nl> + uint32_t delaysec = 0 ; <nl> + <nl> vector < string > tx_permission ; <nl> <nl> eosio : : client : : http : : http_context context ; <nl> void add_standard_transaction_options ( CLI : : App * cmd , string default_permission = <nl> <nl> cmd - > add_option ( " - - max - cpu - usage - ms " , tx_max_cpu_usage , localized ( " set an upper limit on the milliseconds of cpu usage budget , for the execution of the transaction ( defaults to 0 which means no limit ) " ) ) ; <nl> cmd - > add_option ( " - - max - net - usage " , tx_max_net_usage , localized ( " set an upper limit on the net usage budget , in bytes , for the transaction ( defaults to 0 which means no limit ) " ) ) ; <nl> + <nl> + cmd - > add_option ( " - - delay - sec " , delaysec , localized ( " set the delay_sec seconds , defaults to 0s " ) ) ; <nl> } <nl> <nl> vector < chain : : permission_level > get_account_permissions ( const vector < string > & permissions ) { <nl> fc : : variant push_transaction ( signed_transaction & trx , int32_t extra_kcpu = 1000 <nl> <nl> trx . max_cpu_usage_ms = tx_max_cpu_usage ; <nl> trx . max_net_usage_words = ( tx_max_net_usage + 7 ) / 8 ; <nl> + trx . delay_sec = delaysec ; <nl> } <nl> <nl> if ( ! tx_skip_sign ) { <nl> | Merge pull request from jjnetcn / patch - 4 | EOSIO/eos | 73cf85f8782f9212dbdf4a34a980eda9be177ca6 | 2018-09-04T13:35:31Z |
mmm a / extensions / CCArmature / datas / CCDatas . h <nl> ppp b / extensions / CCArmature / datas / CCDatas . h <nl> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # ifndef __CCDATA_H__ <nl> - # define __CCDATA_H__ <nl> + # ifndef __CCARMATURE_DATAS_H__ <nl> + # define __CCARMATURE_DATAS_H__ <nl> <nl> # include " . . / utils / CCArmatureDefine . h " <nl> # include " . . / utils / CCTweenFunction . h " <nl> class CCTextureData : public CCObject <nl> <nl> NS_CC_EXT_END <nl> <nl> - # endif / * __CCDATA_H__ * / <nl> + # endif / * __CCARMATURE_DATAS_H__ * / <nl> | [ CCArmature ] Updating CCDatas . h . Why to name it ' CCDatas . h " ? ? ? ? ? | cocos2d/cocos2d-x | ab15cd8c7bf9447b2b31dc867a8158fded7668cb | 2013-06-08T08:45:25Z |
mmm a / include / osquery / events . h <nl> ppp b / include / osquery / events . h <nl> class EventSubscriberPlugin : public Plugin { <nl> * publishers . The namespace is a combination of the publisher and subscriber <nl> * registry plugin names . <nl> * / <nl> - virtual EventPublisherID & dbNamespace ( ) const = 0 ; <nl> + virtual EventPublisherID dbNamespace ( ) const = 0 ; <nl> <nl> / / / Disable event expiration for this subscriber . <nl> void doNotExpire ( ) { expire_events_ = false ; } <nl> class EventSubscriber : public EventSubscriberPlugin { <nl> * plugin name assigned to publishers . The corresponding publisher name is <nl> * interpreted as the subscriber ' s event ' type ' . <nl> * / <nl> - EventPublisherID & getType ( ) const { <nl> + virtual EventPublisherID & getType ( ) const { <nl> static EventPublisherID type = EventFactory : : getType < PUB > ( ) ; <nl> return type ; <nl> } <nl> <nl> / / / See getType for lookup rational . <nl> - EventPublisherID & dbNamespace ( ) const { <nl> - static EventPublisherID _ns = getType ( ) + ' . ' + getName ( ) ; <nl> - return _ns ; <nl> + virtual EventPublisherID dbNamespace ( ) const { <nl> + return getType ( ) + ' . ' + getName ( ) ; <nl> } <nl> <nl> public : <nl> mmm a / include / osquery / registry . h <nl> ppp b / include / osquery / registry . h <nl> class Plugin : private boost : : noncopyable { <nl> / / / Allow the plugin to introspect into the registered name ( for logging ) . <nl> void setName ( const std : : string & name ) { name_ = name ; } <nl> <nl> - const std : : string & getName ( ) const { return name_ ; } <nl> + virtual const std : : string & getName ( ) const { return name_ ; } <nl> <nl> / / / Allow a specialized plugin type to act when an external plugin is <nl> / / / registered ( e . g . , a TablePlugin will attach the table name ) . <nl> class RegistryHelperCore : private boost : : noncopyable { <nl> void setName ( const std : : string & name ) ; <nl> <nl> / / / Allow others to introspect into the registered name ( for reporting ) . <nl> - const std : : string & getName ( ) const { return name_ ; } <nl> + virtual const std : : string & getName ( ) const { return name_ ; } <nl> <nl> / / / Check if a given plugin name is considered internal . <nl> bool isInternal ( const std : : string & item_name ) const ; <nl> mmm a / osquery / events / events . cpp <nl> ppp b / osquery / events / events . cpp <nl> Status EventSubscriberPlugin : : add ( Row & r , EventTime event_time ) { <nl> / / Get and increment the EID for this module . <nl> EventID eid = getEventID ( ) ; <nl> / / Without encouraging a missing event time , do not support a 0 - time . <nl> - auto index_time = getUnixTime ( ) ; <nl> - if ( event_time = = 0 ) { <nl> - r [ " time " ] = std : : to_string ( index_time ) ; <nl> - } else { <nl> - r [ " time " ] = std : : to_string ( event_time ) ; <nl> - } <nl> + r [ " time " ] = std : : to_string ( ( event_time = = 0 ) ? getUnixTime ( ) : event_time ) ; <nl> <nl> / / Serialize and store the row data , for query - time retrieval . <nl> std : : string data ; <nl> mmm a / osquery / events / tests / events_tests . cpp <nl> ppp b / osquery / events / tests / events_tests . cpp <nl> class FakeEventSubscriber : public EventSubscriber < FakeEventPublisher > { <nl> sub_ctx - > require_this_value = 42 ; <nl> subscribe ( & FakeEventSubscriber : : SpecialCallback , sub_ctx , nullptr ) ; <nl> } <nl> + <nl> + private : <nl> + FRIEND_TEST ( EventsTests , test_subscriber_names ) ; <nl> } ; <nl> <nl> TEST_F ( EventsTests , test_event_sub ) { <nl> TEST_F ( EventsTests , test_fire_event ) { <nl> pub - > fire ( ec , 0 ) ; <nl> EXPECT_EQ ( kBellHathTolled , 4 ) ; <nl> } <nl> + <nl> + class SubFakeEventSubscriber : public FakeEventSubscriber { <nl> + public : <nl> + SubFakeEventSubscriber ( ) { setName ( " SubFakeSubscriber " ) ; } <nl> + <nl> + private : <nl> + FRIEND_TEST ( EventsTests , test_subscriber_names ) ; <nl> + } ; <nl> + <nl> + TEST_F ( EventsTests , test_subscriber_names ) { <nl> + auto pub = std : : make_shared < BasicEventPublisher > ( ) ; <nl> + EventFactory : : registerEventPublisher ( pub ) ; <nl> + <nl> + auto subsub = std : : make_shared < SubFakeEventSubscriber > ( ) ; <nl> + EXPECT_EQ ( subsub - > getType ( ) , " FakePublisher " ) ; <nl> + EXPECT_EQ ( subsub - > getName ( ) , " SubFakeSubscriber " ) ; <nl> + EXPECT_EQ ( subsub - > dbNamespace ( ) , " FakePublisher . SubFakeSubscriber " ) ; <nl> + <nl> + auto sub = std : : make_shared < FakeEventSubscriber > ( ) ; <nl> + EXPECT_EQ ( sub - > getName ( ) , " FakeSubscriber " ) ; <nl> + EXPECT_EQ ( sub - > dbNamespace ( ) , " FakePublisher . FakeSubscriber " ) ; <nl> + } <nl> } <nl> mmm a / osquery / tables / events / linux / passwd_changes . cpp <nl> ppp b / osquery / tables / events / linux / passwd_changes . cpp <nl> Status PasswdChangesEventSubscriber : : Callback ( const INotifyEventContextRef & ec , <nl> r [ " transaction_id " ] = INTEGER ( ec - > event - > cookie ) ; <nl> if ( ec - > action ! = " " & & ec - > action ! = " OPENED " ) { <nl> / / A callback is somewhat useless unless it changes the EventSubscriber <nl> - / / state <nl> - / / or calls ` add ` to store a marked up event . <nl> + / / state or calls ` add ` to store a marked up event . <nl> add ( r , ec - > time ) ; <nl> } <nl> return Status ( 0 , " OK " ) ; <nl> mmm a / osquery / tables / events / yara_events . cpp <nl> ppp b / osquery / tables / events / yara_events . cpp <nl> Status YARAEventSubscriber : : Callback ( const FileEventContextRef & ec , <nl> } <nl> } <nl> <nl> - if ( ec - > action ! = " " ) { <nl> + if ( ec - > action ! = " " & & r . at ( " matches " ) . size ( ) > 0 ) { <nl> add ( r , ec - > time ) ; <nl> } <nl> <nl> | [ Fix ] Allow subscription subclassing | osquery/osquery | d2effc539cc01f3b814094e7404bef4301dd9a1f | 2015-07-26T08:48:27Z |
mmm a / system / settings / settings . xml <nl> ppp b / system / settings / settings . xml <nl> <nl> < / setting > <nl> < setting id = " services . airplayvideosupport " type = " boolean " parent = " services . airplay " label = " 1268 " help = " 36549 " > <nl> < level > 3 < / level > <nl> - < default > true < / default > <nl> + < default > false < / default > <nl> < dependencies > <nl> < dependency type = " enable " setting = " services . airplay " > true < / dependency > <nl> < / dependencies > <nl> | Merge pull request from chewitt / airplay | xbmc/xbmc | 5d6e1229a8371049088f6ffcaf6f50f89319160e | 2017-12-10T09:37:38Z |
mmm a / xbmc / pvr / windows / GUIWindowPVRSearch . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRSearch . cpp <nl> void CGUIWindowPVRSearch : : OnPrepareFileItems ( CFileItemList & items ) <nl> { <nl> m_bSearchConfirmed = false ; <nl> <nl> - items . Clear ( ) ; <nl> bAddSpecialSearchItem = true ; <nl> <nl> CGUIDialogProgress * dlgProgress = ( CGUIDialogProgress * ) g_windowManager . GetWindow ( WINDOW_DIALOG_PROGRESS ) ; <nl> | [ PVR ] Fix search window init regression | xbmc/xbmc | 2c5086107a1f4629211aa89365e706eb274c1e81 | 2015-10-15T18:24:38Z |
mmm a / tensorflow / contrib / model_pruning / README . md <nl> ppp b / tensorflow / contrib / model_pruning / README . md <nl> For now , it is assumed that the underlying hardware platform will provide mechan <nl> <nl> # # Example : Pruning and training deep CNNs on the cifar10 dataset < a name = " example " > < / a > <nl> <nl> - Please see https : / / www . tensorflow . org / tutorials / deep_cnn for details on neural <nl> + Please see [ Advanced Convolutional Neural Networks <nl> + ] ( https : / / www . tensorflow . org / tutorials / images / deep_cnn ) for details on neural <nl> network architecture , setting up inputs etc . The additional changes needed to <nl> incorporate pruning are captured in the following : <nl> <nl> | Fixed invalid link | tensorflow/tensorflow | 852c4abf62ece829a0b7fe17ee88751bc5bdcbc2 | 2019-02-18T12:35:52Z |
mmm a / build / debian / changelog <nl> ppp b / build / debian / changelog <nl> <nl> redis - desktop - manager ( 0 . 0 . 0 ) unstable ; urgency = low <nl> <nl> - * Ubuntu release 0 . 0 . 0 <nl> + * Release 0 . 0 . 0 <nl> <nl> - - glide < u . glide @ gmail . com > Fri , 20 Sep 2013 13 : 00 : 54 - 0400 <nl> old mode 100644 <nl> new mode 100755 <nl> index a36f7ff4 . . 9af899e8 <nl> mmm a / build_package . sh <nl> ppp b / build_package . sh <nl> <nl> # ! / bin / sh <nl> - QTVER = 5 . 1 . 1 <nl> + QTVER = 5 . 3 . 0 <nl> QTDIR = / usr / local / Qt - $ QTVER <nl> <nl> export PATH = $ QTDIR / bin : $ PATH <nl> rm - fR $ BUILD_DIR / * <nl> mkdir $ BUILD_DIR <nl> <nl> cp - Rf . / redis - desktop - manager / * $ BUILD_DIR <nl> - chmod 755 $ BUILD_DIR / configure <nl> + chmod + x $ BUILD_DIR / configure <nl> mkdir $ BUILD_DIR / debian <nl> cp - Rf . / build / debian / * $ BUILD_DIR / debian <nl> echo = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> DEPS_LIB = $ BUILD_DIR / lib <nl> <nl> mkdir $ DEPS_LIB <nl> <nl> - # qt libs <nl> - mkdir $ DEPS_LIB / plugins <nl> - mkdir $ DEPS_LIB / plugins / platforms <nl> - mkdir $ DEPS_LIB / fonts <nl> - sudo cp - Rf $ QTDIR / plugins / platforms / lib * $ DEPS_LIB / plugins / platforms <nl> - sudo cp - Rf $ QTDIR / lib / fonts / * $ DEPS_LIB / fonts <nl> - cp - aR $ QTDIR / lib / libQt5Xml . so . $ QTVER $ DEPS_LIB / libQt5Xml . so . 5 <nl> - cp - aR $ QTDIR / lib / libQt5Widgets . so . $ QTVER $ DEPS_LIB / libQt5Widgets . so . 5 <nl> - cp - aR $ QTDIR / lib / libQt5Network . so . $ QTVER $ DEPS_LIB / libQt5Network . so . 5 <nl> - cp - aR $ QTDIR / lib / libQt5Gui . so . $ QTVER $ DEPS_LIB / libQt5Gui . so . 5 <nl> - cp - aR $ QTDIR / lib / libQt5Core . so . $ QTVER $ DEPS_LIB / libQt5Core . so . 5 <nl> - cp - aR $ QTDIR / lib / libQt5Concurrent . so . $ QTVER $ DEPS_LIB / libQt5Concurrent . so . 5 <nl> - cp - aR $ QTDIR / lib / libQt5DBus . s * $ DEPS_LIB <nl> - cp - aR / usr / lib / ` uname - m ` - linux - gnu / libxcb * . s * $ DEPS_LIB <nl> - <nl> # external libs <nl> - cp - aR / usr / local / lib / libssh2 . s * $ DEPS_LIB <nl> + cp - aR / usr / lib / i386 - linux - gnu / libxcb * . s * $ DEPS_LIB <nl> + cp - aR / usr / lib / ` uname - m ` - linux - gnu / libxcb * . s * $ DEPS_LIB <nl> <nl> <nl> echo <nl> mmm a / redis - desktop - manager / redis - desktop - manager . pro <nl> ppp b / redis - desktop - manager / redis - desktop - manager . pro <nl> unix { <nl> } <nl> else { # ubuntu & debian <nl> <nl> - CONFIG + = static <nl> + CONFIG + = static release <nl> + CONFIG - = debug <nl> <nl> FORMS + = \ <nl> $ $ PWD / forms / * . ui \ <nl> | Update build scripts | uglide/RedisDesktopManager | a16a2e5d5fe94b43e278b0fa5d9e668d2d2ac26d | 2014-06-07T10:58:57Z |
mmm a / README . md <nl> ppp b / README . md <nl> Caffe2 is released under the [ BSD 2 - Clause license ] ( https : / / github . com / Yangqing / <nl> <nl> [ ! [ Build Status ] ( https : / / travis - ci . org / caffe2 / caffe2 . svg ? branch = master ) ] ( https : / / travis - ci . org / caffe2 / caffe2 ) <nl> <nl> - git clone - - recursive https : / / github . com / bwasti / caffe2 . git <nl> + git clone - - recursive https : / / github . com / caffe2 / caffe2 . git <nl> cd caffe2 <nl> <nl> # # # # OS X <nl> | Fix git URL in README | pytorch/pytorch | b9f4977be9935a4849f48e0b272f8137ff92b0b4 | 2017-02-14T19:48:09Z |
mmm a / html5 / test / case / tester . js <nl> ppp b / html5 / test / case / tester . js <nl> describe ( ' test input and output ' , function ( ) { <nl> it ( ' promise case ' , ( ) = > checkOutput ( app , ' promise ' ) ) <nl> } ) <nl> <nl> - / / append - root - event <nl> - / / repeat - track - by <nl> - / / if - refresh <nl> - / / if - repeat - refresh <nl> - / / reset class style case <nl> - / / click <nl> - / / inline - click <nl> - / / refresh twice <nl> - / / a less wrong transformer version <nl> - / / a big wrong transformer version <nl> - / / input binding <nl> - / / use HTML5 timer API <nl> - / / use modal API <nl> - / / test callNative signals <nl> - <nl> - describe ( ' complex cases ' , function ( ) { <nl> + describe ( ' complex cases ' , function ( ) { <nl> let app <nl> <nl> beforeEach ( ( ) = > { <nl> describe ( ' test input and output ' , function ( ) { <nl> <nl> app . $ destroy ( ) <nl> } ) <nl> - } ) <nl> <nl> + it ( ' append - root - event case ' , ( ) = > { <nl> + const name = ' append - root - event ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + const actual = app . getRealRoot ( ) <nl> + expect ( actual ) . eql ( expected ) <nl> + <nl> + app . $ fireEvent ( app . doc . body . children [ 0 ] . ref , ' click ' , { } ) <nl> + const actual2 = app . getRealRoot ( ) <nl> + expect ( actual2 . children [ 0 ] . attr . value ) . eql ( 2 ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it ( ' repeat with array track - by case ' , ( ) = > { <nl> + const name = ' repeat - track - by ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + app . $ refresh ( { <nl> + titlelist : [ <nl> + { text : ' Hello World2 ' } , <nl> + { text : ' Hello World1 ' } <nl> + ] <nl> + } ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it ( ' if - refresh case ' , ( ) = > { <nl> + const name = ' if - refresh ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + app . $ refresh ( { showTitle : false } ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it ( ' if - repeat - refresh case ' , ( ) = > { <nl> + const name = ' if - repeat - refresh ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + app . $ refresh ( { <nl> + titlelist : [ <nl> + { showTitle : false , title : ' Hello World1 ' } , <nl> + { showTitle : true , title : ' Hello World2 ' } , <nl> + { showTitle : true , title : ' Hello World3 ' } <nl> + ] <nl> + } ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it ( ' click case ' , ( ) = > { <nl> + const name = ' click ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . $ fireEvent ( app . doc . body . children [ 0 ] . ref , ' click ' , { } ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it ( ' inline click case ' , ( ) = > { <nl> + const name = ' inline - click ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . $ fireEvent ( app . doc . body . children [ 0 ] . ref , ' click ' , { } ) <nl> + <nl> + expected . children [ 0 ] . attr . value = ' Hello World2 ' <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it . skip ( ' reset class style case ' , ( ) = > { <nl> + const name = ' reset - style ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + <nl> + app . $ fireEvent ( app . doc . body . children [ 0 ] . ref , ' click ' , { } ) <nl> + <nl> + setTimeout ( function ( ) { <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + } , 0 ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it ( ' refresh twice ' , ( ) = > { <nl> + const name = ' refresh2 ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( { type : ' container ' } ) <nl> + <nl> + app . $ refresh ( { ext : { showbar1 : false } } ) <nl> + app . $ refresh ( { ext : { showbar1 : true } } ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it ( ' a less wrong transformer version ' , ( ) = > { <nl> + const name = ' transformer2 ' <nl> + const inputCode = readInput ( name ) <nl> + <nl> + const result = app . $ create ( inputCode ) <nl> + expect ( result ) . to . be . an . instanceof ( Error ) <nl> + app . $ destroy ( ) <nl> + } ) <nl> <nl> - describe ( ' multi page cases ' , function ( ) { <nl> + it ( ' a bigger wrong transformer version ' , ( ) = > { <nl> + const name = ' transformer3 ' <nl> + const inputCode = readInput ( name ) <nl> + <nl> + const result = app . $ create ( inputCode ) <nl> + expect ( result ) . to . be . an . instanceof ( Error ) <nl> + app . $ destroy ( ) <nl> + } ) <nl> + <nl> + it ( ' input binding ' , ( ) = > { <nl> + const name = ' input - binding ' <nl> + const inputCode = readInput ( name ) <nl> + const outputCode = readOutput ( name ) <nl> + <nl> + app . $ create ( inputCode ) <nl> + const expected = eval ( ' ( ' + outputCode + ' ) ' ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . doc . body . children [ 0 ] . attr . value = ' abcdefg ' <nl> + app . $ fireEvent ( app . doc . body . children [ 0 ] . ref , ' change ' , { } , { attrs : { value : ' abcdefg ' } } ) <nl> + expected . children [ 0 ] . attr . value = ' abcdefg ' <nl> + expected . children . push ( { type : ' text ' , attr : { value : ' 1 - abcdefg ' } } ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . doc . body . children [ 0 ] . attr . value = ' 12345 ' <nl> + app . $ fireEvent ( app . doc . body . children [ 0 ] . ref , ' change ' , { } , { attrs : { value : ' 12345 ' } } ) <nl> + expected . children [ 0 ] . attr . value = ' 12345 ' <nl> + expected . children . push ( { type : ' text ' , attr : { value : ' 2 - 12345 ' } } ) <nl> + expect ( app . getRealRoot ( ) ) . eql ( expected ) <nl> + <nl> + app . $ destroy ( ) <nl> + } ) <nl> + } ) <nl> + <nl> + describe ( ' multi page cases ' , function ( ) { <nl> let app <nl> <nl> beforeEach ( ( ) = > { <nl> describe ( ' test input and output ' , function ( ) { <nl> app . $ create ( inputCodeA ) <nl> app2 . $ create ( inputCodeB ) <nl> <nl> - const actualB = app2 . getRealRoot ( ) <nl> expect ( app2 . getRealRoot ( ) ) . eql ( expectedB ) <nl> <nl> app2 . $ destroy ( ) <nl> describe ( ' test input and output ' , function ( ) { <nl> <nl> app . $ destroy ( ) <nl> } ) <nl> - <nl> } ) <nl> } ) <nl> | * [ jsfm ] add complex test case in tester | apache/incubator-weex | 2d1b79406461518df54160f4c71c601134b0fa40 | 2016-10-15T06:14:01Z |
mmm a / BUILD <nl> ppp b / BUILD <nl> cc_library ( <nl> " src / google / protobuf / compiler / java / java_shared_code_generator . cc " , <nl> " src / google / protobuf / compiler / java / java_string_field . cc " , <nl> " src / google / protobuf / compiler / java / java_string_field_lite . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_enum . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_enum_field . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_extension . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_field . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_file . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_generator . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_helpers . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_map_field . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_message . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_message_field . cc " , <nl> - " src / google / protobuf / compiler / javanano / javanano_primitive_field . cc " , <nl> " src / google / protobuf / compiler / js / js_generator . cc " , <nl> " src / google / protobuf / compiler / js / well_known_types_embed . cc " , <nl> " src / google / protobuf / compiler / objectivec / objectivec_enum . cc " , <nl> COMMON_TEST_SRCS = [ <nl> " src / google / protobuf / arena_test_util . cc " , <nl> " src / google / protobuf / map_test_util . cc " , <nl> " src / google / protobuf / test_util . cc " , <nl> + " src / google / protobuf / test_util . inc " , <nl> " src / google / protobuf / testing / file . cc " , <nl> " src / google / protobuf / testing / googletest . cc " , <nl> ] <nl> cc_test ( <nl> " src / google / protobuf / compiler / cpp / cpp_move_unittest . cc " , <nl> " src / google / protobuf / compiler / cpp / cpp_plugin_unittest . cc " , <nl> " src / google / protobuf / compiler / cpp / cpp_unittest . cc " , <nl> + " src / google / protobuf / compiler / cpp / cpp_unittest . inc " , <nl> " src / google / protobuf / compiler / cpp / metadata_test . cc " , <nl> " src / google / protobuf / compiler / csharp / csharp_bootstrap_unittest . cc " , <nl> " src / google / protobuf / compiler / csharp / csharp_generator_unittest . cc " , <nl> cc_test ( <nl> " src / google / protobuf / map_field_test . cc " , <nl> " src / google / protobuf / map_test . cc " , <nl> " src / google / protobuf / message_unittest . cc " , <nl> + " src / google / protobuf / message_unittest . inc " , <nl> " src / google / protobuf / no_field_presence_test . cc " , <nl> " src / google / protobuf / preserve_unknown_enum_test . cc " , <nl> " src / google / protobuf / proto3_arena_lite_unittest . cc " , <nl> mmm a / Makefile . am <nl> ppp b / Makefile . am <nl> java_EXTRA_DIST = <nl> java / util / src / test / java / com / google / protobuf / util / TimeUtilTest . java \ <nl> java / util / src / test / proto / com / google / protobuf / util / json_test . proto <nl> <nl> - javanano_EXTRA_DIST = \ <nl> - javanano / src / main / java / com / google / protobuf / nano / CodedOutputByteBufferNano . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / FieldData . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / FieldArray . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / WireFormatNano . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / Extension . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / CodedInputByteBufferNano . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / UnknownFieldData . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / MessageNano . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / InternalNano . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / InvalidProtocolBufferNanoException . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / MapFactories . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / ExtendableMessageNano . java \ <nl> - javanano / src / main / java / com / google / protobuf / nano / MessageNanoPrinter . java \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_accessors_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_enum_class_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_reference_types_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_extension_repeated_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_has_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_multiple_nameclash_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_single_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / NanoTest . java \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_simple_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_import_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_repeated_merge_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_extension_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_repeated_packables_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_extension_singular_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_recursive_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_extension_packed_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_enum_validity_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_stringutf8_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_multiple_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / unittest_enum_class_multiple_nano . proto \ <nl> - javanano / src / test / java / com / google / protobuf / nano / map_test . proto \ <nl> - javanano / README . md \ <nl> - javanano / pom . xml <nl> - <nl> objectivec_EXTRA_DIST = \ <nl> objectivec / DevTools / check_version_stamps . sh \ <nl> objectivec / DevTools / compile_testing_protos . sh \ <nl> js_EXTRA_DIST = \ <nl> js / testbinary . proto \ <nl> js / testempty . proto <nl> <nl> - all_EXTRA_DIST = $ ( csharp_EXTRA_DIST ) $ ( java_EXTRA_DIST ) $ ( javanano_EXTRA_DIST ) $ ( objectivec_EXTRA_DIST ) $ ( php_EXTRA_DIST ) $ ( python_EXTRA_DIST ) $ ( ruby_EXTRA_DIST ) $ ( js_EXTRA_DIST ) <nl> + all_EXTRA_DIST = $ ( csharp_EXTRA_DIST ) $ ( java_EXTRA_DIST ) $ ( objectivec_EXTRA_DIST ) $ ( php_EXTRA_DIST ) $ ( python_EXTRA_DIST ) $ ( ruby_EXTRA_DIST ) $ ( js_EXTRA_DIST ) <nl> <nl> EXTRA_DIST = $ ( @ DIST_LANG @ _EXTRA_DIST ) \ <nl> autogen . sh \ <nl> mmm a / README . md <nl> ppp b / README . md <nl> how to install protobuf runtime for that specific language : <nl> | Python | [ python ] ( python ) | <nl> | Objective - C | [ objectivec ] ( objectivec ) | <nl> | C # | [ csharp ] ( csharp ) | <nl> - | JavaNano | [ javanano ] ( javanano ) | <nl> | JavaScript | [ js ] ( js ) | <nl> | Ruby | [ ruby ] ( ruby ) | <nl> | Go | [ golang / protobuf ] ( https : / / github . com / golang / protobuf ) | <nl> mmm a / cmake / extract_includes . bat . in <nl> ppp b / cmake / extract_includes . bat . in <nl> mkdir include \ google \ protobuf \ compiler <nl> mkdir include \ google \ protobuf \ compiler \ cpp <nl> mkdir include \ google \ protobuf \ compiler \ csharp <nl> mkdir include \ google \ protobuf \ compiler \ java <nl> - mkdir include \ google \ protobuf \ compiler \ javanano <nl> mkdir include \ google \ protobuf \ compiler \ js <nl> mkdir include \ google \ protobuf \ compiler \ objectivec <nl> mkdir include \ google \ protobuf \ compiler \ php <nl> copy " $ { PROTOBUF_SOURCE_WIN32_PATH } \ . . \ src \ google \ protobuf \ compiler \ csharp \ cshar <nl> copy " $ { PROTOBUF_SOURCE_WIN32_PATH } \ . . \ src \ google \ protobuf \ compiler \ importer . h " include \ google \ protobuf \ compiler \ importer . h <nl> copy " $ { PROTOBUF_SOURCE_WIN32_PATH } \ . . \ src \ google \ protobuf \ compiler \ java \ java_generator . h " include \ google \ protobuf \ compiler \ java \ java_generator . h <nl> copy " $ { PROTOBUF_SOURCE_WIN32_PATH } \ . . \ src \ google \ protobuf \ compiler \ java \ java_names . h " include \ google \ protobuf \ compiler \ java \ java_names . h <nl> - copy " $ { PROTOBUF_SOURCE_WIN32_PATH } \ . . \ src \ google \ protobuf \ compiler \ javanano \ javanano_generator . h " include \ google \ protobuf \ compiler \ javanano \ javanano_generator . h <nl> copy " $ { PROTOBUF_SOURCE_WIN32_PATH } \ . . \ src \ google \ protobuf \ compiler \ js \ js_generator . h " include \ google \ protobuf \ compiler \ js \ js_generator . h <nl> copy " $ { PROTOBUF_SOURCE_WIN32_PATH } \ . . \ src \ google \ protobuf \ compiler \ js \ well_known_types_embed . h " include \ google \ protobuf \ compiler \ js \ well_known_types_embed . h <nl> copy " $ { PROTOBUF_SOURCE_WIN32_PATH } \ . . \ src \ google \ protobuf \ compiler \ objectivec \ objectivec_generator . h " include \ google \ protobuf \ compiler \ objectivec \ objectivec_generator . h <nl> mmm a / cmake / libprotoc . cmake <nl> ppp b / cmake / libprotoc . cmake <nl> set ( libprotoc_files <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_shared_code_generator . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_string_field . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_string_field_lite . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_enum . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_enum_field . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_extension . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_field . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_file . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_generator . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_helpers . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_map_field . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_message . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_message_field . cc <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_primitive_field . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / js / js_generator . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / js / well_known_types_embed . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_enum . cc <nl> set ( libprotoc_files <nl> ) <nl> <nl> set ( libprotoc_headers <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / code_generator . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / command_line_interface . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / importer . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / mock_code_generator . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / package_info . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / parser . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / plugin . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / plugin . pb . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / subprocess . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / zip_writer . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_enum . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_enum_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_extension . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_file . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_generator . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_helpers . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_map_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_message . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_message_field . h <nl> + $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_message_layout_helper . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_options . h <nl> + $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_padding_optimizer . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_primitive_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_service . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_string_field . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_unittest . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_doc_comment . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_enum . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_enum_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_field_base . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_generator . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_helpers . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_map_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_message . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_message_field . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_names . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_options . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_primitive_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_reflection_class . h <nl> set ( libprotoc_headers <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_extension_lite . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_file . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_generator . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_generator_factory . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_helpers . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_lazy_message_field . h <nl> set ( libprotoc_headers <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_message_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_message_field_lite . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_message_lite . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_names . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_name_resolver . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_options . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_primitive_field . h <nl> set ( libprotoc_headers <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_shared_code_generator . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_string_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / java / java_string_field_lite . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_enum . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_enum_field . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_extension . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_field . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_file . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_generator . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_helpers . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_map_field . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_message . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_message_field . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_params . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / javanano / javanano_primitive_field . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / js / js_generator . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / js / well_known_types_embed . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_enum . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_enum_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_extension . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_file . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_generator . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_helpers . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_map_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_message . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_message_field . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_oneof . h <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / objectivec / objectivec_primitive_field . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / php / php_generator . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / python / python_generator . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / ruby / ruby_generator . h <nl> - $ { protobuf_source_dir } / src / google / protobuf / compiler / plugin . pb . h <nl> + $ { protobuf_source_dir } / src / google / protobuf / compiler / subprocess . h <nl> + $ { protobuf_source_dir } / src / google / protobuf / compiler / zip_writer . h <nl> ) <nl> <nl> set ( js_well_known_types_sources <nl> mmm a / cmake / tests . cmake <nl> ppp b / cmake / tests . cmake <nl> set ( common_test_files <nl> $ { protobuf_source_dir } / src / google / protobuf / arena_test_util . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / map_test_util . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / test_util . cc <nl> + $ { protobuf_source_dir } / src / google / protobuf / test_util . inc <nl> $ { protobuf_source_dir } / src / google / protobuf / testing / file . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / testing / googletest . cc <nl> ) <nl> set ( tests_files <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_move_unittest . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_plugin_unittest . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_unittest . cc <nl> + $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / cpp_unittest . inc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / cpp / metadata_test . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_bootstrap_unittest . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / compiler / csharp / csharp_generator_unittest . cc <nl> set ( tests_files <nl> $ { protobuf_source_dir } / src / google / protobuf / map_field_test . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / map_test . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / message_unittest . cc <nl> + $ { protobuf_source_dir } / src / google / protobuf / message_unittest . inc <nl> $ { protobuf_source_dir } / src / google / protobuf / no_field_presence_test . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / preserve_unknown_enum_test . cc <nl> $ { protobuf_source_dir } / src / google / protobuf / proto3_arena_lite_unittest . cc <nl> deleted file mode 100644 <nl> index 6b13ecea7c . . 0000000000 <nl> mmm a / javanano / README . md <nl> ppp / dev / null <nl> <nl> - Protocol Buffers - Google ' s data interchange format <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - [ ! [ Build Status ] ( https : / / travis - ci . org / google / protobuf . svg ? branch = master ) ] ( https : / / travis - ci . org / google / protobuf ) <nl> - <nl> - Copyright 2008 Google Inc . <nl> - <nl> - This directory contains the Java Protocol Buffers Nano runtime library . <nl> - <nl> - * * Nano is no longer supported by protobuf team . We recommend Android users to <nl> - use protobuf lite runtime instead . * * <nl> - <nl> - Installation - With Maven <nl> mmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - The Protocol Buffers build is managed using Maven . If you would <nl> - rather build without Maven , see below . <nl> - <nl> - 1 ) Install Apache Maven if you don ' t have it : <nl> - <nl> - http : / / maven . apache . org / <nl> - <nl> - 2 ) Build the C + + code , or obtain a binary distribution of protoc . If <nl> - you install a binary distribution , make sure that it is the same <nl> - version as this package . If in doubt , run : <nl> - <nl> - $ protoc - - version <nl> - <nl> - You will need to place the protoc executable in . . / src . ( If you <nl> - built it yourself , it should already be there . ) <nl> - <nl> - 3 ) Run the tests : <nl> - <nl> - $ mvn test <nl> - <nl> - If some tests fail , this library may not work correctly on your <nl> - system . Continue at your own risk . <nl> - <nl> - 4 ) Install the library into your Maven repository : <nl> - <nl> - $ mvn install <nl> - <nl> - 5 ) If you do not use Maven to manage your own build , you can build a <nl> - . jar file to use : <nl> - <nl> - $ mvn package <nl> - <nl> - The . jar will be placed in the " target " directory . <nl> - <nl> - Installation - Without Maven <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - If you would rather not install Maven to build the library , you may <nl> - follow these instructions instead . Note that these instructions skip <nl> - running unit tests . <nl> - <nl> - 1 ) Build the C + + code , or obtain a binary distribution of protoc . If <nl> - you install a binary distribution , make sure that it is the same <nl> - version as this package . If in doubt , run : <nl> - <nl> - $ protoc - - version <nl> - <nl> - If you built the C + + code without installing , the compiler binary <nl> - should be located in . . / src . <nl> - <nl> - 2 ) Invoke protoc to build DescriptorProtos . java : <nl> - <nl> - $ protoc - - java_out = src / main / java - I . . / src \ <nl> - . . / src / google / protobuf / descriptor . proto <nl> - <nl> - 3 ) Compile the code in src / main / java using whatever means you prefer . <nl> - <nl> - 4 ) Install the classes wherever you prefer . <nl> - <nl> - Nano version <nl> mmmmmmmmmmmm - <nl> - <nl> - JavaNano is a special code generator and runtime library designed specially for <nl> - resource - restricted systems , like Android . It is very resource - friendly in both <nl> - the amount of code and the runtime overhead . Here is an overview of JavaNano <nl> - features compared with the official Java protobuf : <nl> - <nl> - - No descriptors or message builders . <nl> - - All messages are mutable ; fields are public Java fields . <nl> - - For optional fields only , encapsulation behind setter / getter / hazzer / <nl> - clearer functions is opt - in , which provide proper ' has ' state support . <nl> - - For proto2 , if not opted in , has state ( field presence ) is not available . <nl> - Serialization outputs all fields not equal to their defaults <nl> - ( see important implications below ) . <nl> - The behavior is consistent with proto3 semantics . <nl> - - Required fields ( proto2 only ) are always serialized . <nl> - - Enum constants are integers ; protection against invalid values only <nl> - when parsing from the wire . <nl> - - Enum constants can be generated into container interfaces bearing <nl> - the enum ' s name ( so the referencing code is in Java style ) . <nl> - - CodedInputByteBufferNano can only take byte [ ] ( not InputStream ) . <nl> - - Similarly CodedOutputByteBufferNano can only write to byte [ ] . <nl> - - Repeated fields are in arrays , not ArrayList or Vector . Null array <nl> - elements are allowed and silently ignored . <nl> - - Full support for serializing / deserializing repeated packed fields . <nl> - - Support extensions ( in proto2 ) . <nl> - - Unset messages / groups are null , not an immutable empty default <nl> - instance . <nl> - - toByteArray ( . . . ) and mergeFrom ( . . . ) are now static functions of <nl> - MessageNano . <nl> - - The ' bytes ' type translates to the Java type byte [ ] . <nl> - <nl> - The generated messages are not thread - safe for writes , but may be <nl> - used simultaneously from multiple threads in a read - only manner . <nl> - In other words , an appropriate synchronization mechanism ( such as <nl> - a ReadWriteLock ) must be used to ensure that a message , its <nl> - ancestors , and descendants are not accessed by any other threads <nl> - while the message is being modified . Field reads , getter methods <nl> - ( but not getExtension ( . . . ) ) , toByteArray ( . . . ) , writeTo ( . . . ) , <nl> - getCachedSize ( ) , and getSerializedSize ( ) are all considered read - only <nl> - operations . <nl> - <nl> - IMPORTANT : If you have fields with defaults and opt out of accessors <nl> - <nl> - How fields with defaults are serialized has changed . Because we don ' t <nl> - keep " has " state , any field equal to its default is assumed to be not <nl> - set and therefore is not serialized . Consider the situation where we <nl> - change the default value of a field . Senders compiled against an older <nl> - version of the proto continue to match against the old default , and <nl> - don ' t send values to the receiver even though the receiver assumes the <nl> - new default value . Therefore , think carefully about the implications <nl> - of changing the default value . Alternatively , turn on accessors and <nl> - enjoy the benefit of the explicit has ( ) checks . <nl> - <nl> - IMPORTANT : If you have " bytes " fields with non - empty defaults <nl> - <nl> - Because the byte buffer is now of mutable type byte [ ] , the default <nl> - static final cannot be exposed through a public field . Each time a <nl> - message ' s constructor or clear ( ) function is called , the default value <nl> - ( kept in a private byte [ ] ) is cloned . This causes a small memory <nl> - penalty . This is not a problem if the field has no default or is an <nl> - empty default . <nl> - <nl> - Nano Generator options <nl> mmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - ` ` ` <nl> - java_package - > < file - name > | < package - name > <nl> - java_outer_classname - > < file - name > | < package - name > <nl> - java_multiple_files - > true or false <nl> - java_nano_generate_has - > true or false [ DEPRECATED ] <nl> - optional_field_style - > default or accessors <nl> - enum_style - > c or java <nl> - ignore_services - > true or false <nl> - parcelable_messages - > true or false <nl> - generate_intdefs - > true or false <nl> - ` ` ` <nl> - <nl> - * * java_package = \ < file - name \ > | \ < package - name \ > * * ( no default ) <nl> - <nl> - This allows overriding the ' java_package ' option value <nl> - for the given file from the command line . Use multiple <nl> - java_package options to override the option for multiple <nl> - files . The final Java package for each file is the value <nl> - of this command line option if present , or the value of <nl> - the same option defined in the file if present , or the <nl> - proto package if present , or the default Java package . <nl> - <nl> - * * java_outer_classname = \ < file - name \ > | \ < outer - classname \ > * * ( no default ) <nl> - <nl> - This allows overriding the ' java_outer_classname ' option <nl> - for the given file from the command line . Use multiple <nl> - java_outer_classname options to override the option for <nl> - multiple files . The final Java outer class name for each <nl> - file is the value of this command line option if present , <nl> - or the value of the same option defined in the file if <nl> - present , or the file name converted to CamelCase . This <nl> - outer class will nest all classes and integer constants <nl> - generated from file - scope messages and enums . <nl> - <nl> - * * java_multiple_files = { true , false } * * ( no default ) <nl> - <nl> - This allows overriding the ' java_multiple_files ' option <nl> - in all source files and their imported files from the <nl> - command line . The final value of this option for each <nl> - file is the value defined in this command line option , or <nl> - the value of the same option defined in the file if <nl> - present , or false . This specifies whether to generate <nl> - package - level classes for the file - scope messages in the <nl> - same Java package as the outer class ( instead of nested <nl> - classes in the outer class ) . File - scope enum constants <nl> - are still generated as integer constants in the outer <nl> - class . This affects the fully qualified references in the <nl> - Java code . NOTE : because the command line option <nl> - overrides the value for all files and their imported <nl> - files , using this option inconsistently may result in <nl> - incorrect references to the imported messages and enum <nl> - constants . <nl> - <nl> - * * java_nano_generate_has = { true , false } * * ( default : false ) <nl> - <nl> - DEPRECATED . Use optional_field_style = accessors . <nl> - <nl> - If true , generates a public boolean variable has \ < fieldname \ > <nl> - accompanying each optional or required field ( not present for <nl> - repeated fields , groups or messages ) . It is set to false initially <nl> - and upon clear ( ) . If parseFrom ( . . . ) reads the field from the wire , <nl> - it is set to true . This is a way for clients to inspect the " has " <nl> - value upon parse . If it is set to true , writeTo ( . . . ) will ALWAYS <nl> - output that field ( even if field value is equal to its <nl> - default ) . <nl> - <nl> - IMPORTANT : This option costs an extra 4 bytes per primitive field in <nl> - the message . Think carefully about whether you really need this . In <nl> - many cases reading the default works and determining whether the <nl> - field was received over the wire is irrelevant . <nl> - <nl> - * * optional_field_style = { default , accessors , reftypes } * * ( default : default ) <nl> - <nl> - Defines the style of the generated code for fields . <nl> - <nl> - * default <nl> - <nl> - In the default style , optional fields translate into public mutable <nl> - Java fields , and the serialization process is as discussed in the <nl> - " IMPORTANT " section above . <nl> - <nl> - * accessors <nl> - <nl> - When set to ' accessors ' , each optional field is encapsulated behind <nl> - 4 accessors , namely get \ < fieldname \ > ( ) , set \ < fieldname \ > ( ) , has \ < fieldname \ > ( ) <nl> - and clear \ < fieldname \ > ( ) methods , with the standard semantics . The hazzer ' s <nl> - return value determines whether a field is serialized , so this style is <nl> - useful when you need to serialize a field with the default value , or check <nl> - if a field has been explicitly set to its default value from the wire . <nl> - <nl> - In the ' accessors ' style , required and nested message fields are still <nl> - translated to one public mutable Java field each , repeated fields are still <nl> - translated to arrays . No accessors are generated for them . <nl> - <nl> - IMPORTANT : When using the ' accessors ' style , ProGuard should always <nl> - be enabled with optimization ( don ' t use - dontoptimize ) and allowing <nl> - access modification ( use - allowaccessmodification ) . This removes the <nl> - unused accessors and maybe inline the rest at the call sites , <nl> - reducing the final code size . <nl> - TODO ( maxtroy ) : find ProGuard config that would work the best . <nl> - <nl> - * reftypes <nl> - <nl> - When set to ' reftypes ' , each proto field is generated as a public Java <nl> - field . For primitive types , these fields use the Java reference types <nl> - such as java . lang . Integer instead of primitive types such as int . <nl> - <nl> - In the ' reftypes ' style , fields are initialized to null ( or empty <nl> - arrays for repeated fields ) , and their default values are not available . <nl> - They are serialized over the wire based on equality to null . <nl> - <nl> - The ' reftypes ' mode has some additional cost due to autoboxing and usage <nl> - of reference types . In practice , many boxed types are cached , and so don ' t <nl> - result in object creation . However , references do take slightly more memory <nl> - than primitives . <nl> - <nl> - The ' reftypes ' mode is useful when you want to be able to serialize fields <nl> - with default values , or check if a field has been explicitly set to the <nl> - default over the wire without paying the extra method cost of the <nl> - ' accessors ' mode . <nl> - <nl> - Note that if you attempt to write null to a required field in the reftypes <nl> - mode , serialization of the proto will cause a NullPointerException . This is <nl> - an intentional indicator that you must set required fields . <nl> - <nl> - NOTE <nl> - optional_field_style = accessors or reftypes cannot be used together with <nl> - java_nano_generate_has = true . If you need the ' has ' flag for any <nl> - required field ( you have no reason to ) , you can only use <nl> - java_nano_generate_has = true . <nl> - <nl> - * * enum_style = { c , java } * * ( default : c ) <nl> - <nl> - Defines where to put the int constants generated from enum members . <nl> - <nl> - * c <nl> - <nl> - Use C - style , so the enum constants are available at the scope where <nl> - the enum is defined . A file - scope enum ' s members are referenced like <nl> - ' FileOuterClass . ENUM_VALUE ' ; a message - scope enum ' s members are <nl> - referenced as ' Message . ENUM_VALUE ' . The enum name is unavailable . <nl> - This complies with the Micro code generator ' s behavior . <nl> - <nl> - * java <nl> - <nl> - Use Java - style , so the enum constants are available under the enum <nl> - name and referenced like ' EnumName . ENUM_VALUE ' ( they are still int <nl> - constants ) . The enum name becomes the name of a public interface , at <nl> - the scope where the enum is defined . If the enum is file - scope and <nl> - the java_multiple_files option is on , the interface will be defined <nl> - in its own file . To reduce code size , this interface should not be <nl> - implemented and ProGuard shrinking should be used , so after the Java <nl> - compiler inlines all referenced enum constants into the call sites , <nl> - the interface remains unused and can be removed by ProGuard . <nl> - <nl> - * * ignore_services = { true , false } * * ( default : false ) <nl> - <nl> - Skips services definitions . <nl> - <nl> - Nano doesn ' t support services . By default , if a service is defined <nl> - it will generate a compilation error . If this flag is set to true , <nl> - services will be silently ignored , instead . <nl> - <nl> - * * parcelable_messages = { true , false } * * ( default : false ) <nl> - <nl> - Android - specific option to generate Parcelable messages . <nl> - <nl> - * * generate_intdefs = { true , false } * * ( default : false ) <nl> - Android - specific option to generate @ IntDef annotations for enums . <nl> - <nl> - If turned on , an ' @ IntDef ' annotation ( a public @ interface ) will be <nl> - generated for each enum , and every integer parameter and return <nl> - value in the generated code meant for this enum will be annotated <nl> - with it . This interface is generated with the same name and at the <nl> - same place as the enum members ' container interfaces described <nl> - above under ' enum_style = java ' , regardless of the enum_style option <nl> - used . When this is combined with enum_style = java , the interface <nl> - will be both the ' @ IntDef ' annotation and the container of the enum <nl> - members ; otherwise the interface has an empty body . <nl> - <nl> - Your app must declare a compile - time dependency on the <nl> - android - support - annotations library . <nl> - <nl> - For more information on how these @ IntDef annotations help with <nl> - compile - time type safety , see : <nl> - https : / / sites . google . com / a / android . com / tools / tech - docs / support - annotations <nl> - and <nl> - https : / / developer . android . com / reference / android / support / annotation / IntDef . html <nl> - <nl> - <nl> - To use nano protobufs within the Android repo : <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - - Set ' LOCAL_PROTOC_OPTIMIZE_TYPE : = nano ' in your local . mk file . <nl> - When building a Java library or an app ( package ) target , the build <nl> - system will add the Java nano runtime library to the <nl> - LOCAL_STATIC_JAVA_LIBRARIES variable , so you don ' t need to . <nl> - - Set ' LOCAL_PROTO_JAVA_OUTPUT_PARAMS : = . . . ' in your local . mk file <nl> - for any command - line options you need . Use commas to join multiple <nl> - options . In the nano flavor only , whitespace surrounding the option <nl> - names and values are ignored , so you can use backslash - newline or <nl> - ' + = ' to structure your make files nicely . <nl> - - The options will be applied to * all * proto files in LOCAL_SRC_FILES <nl> - when you build a Java library or package . In case different options <nl> - are needed for different proto files , build separate Java libraries <nl> - and reference them in your main target . Note : you should make sure <nl> - that , for each separate target , all proto files imported from any <nl> - proto file in LOCAL_SRC_FILES are included in LOCAL_SRC_FILES . This <nl> - is because the generator has to assume that the imported files are <nl> - built using the same options , and will generate code that reference <nl> - the fields and enums from the imported files using the same code <nl> - style . <nl> - - Hint : ' include $ ( CLEAR_VARS ) ' resets all LOCAL_ variables , including <nl> - the two above . <nl> - <nl> - To use nano protobufs outside of Android repo : <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - - Link with the generated jar file <nl> - \ < protobuf - root \ > java / target / protobuf - java - 2 . 3 . 0 - nano . jar . <nl> - - Invoke with - - javanano_out , e . g . : <nl> - ` ` ` <nl> - . / protoc ' - - javanano_out = \ <nl> - java_package = src / proto / simple - data . proto | my_package , \ <nl> - java_outer_classname = src / proto / simple - data . proto | OuterName \ <nl> - : . ' src / proto / simple - data . proto <nl> - ` ` ` <nl> - <nl> - Contributing to nano : <nl> mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Please add / edit tests in NanoTest . java . <nl> - <nl> - Please run the following steps to test : <nl> - <nl> - - cd external / protobuf <nl> - - . / configure <nl> - - Run " make - j12 check " and verify all tests pass . <nl> - - cd java <nl> - - Run " mvn test " and verify all tests pass . <nl> - - cd . . / . . / . . <nl> - - . build / envsetup . sh <nl> - - lunch 1 <nl> - - " make - j12 aprotoc libprotobuf - java - 2 . 3 . 0 - nano aprotoc - test - nano - params NanoAndroidTest " and <nl> - check for build errors . <nl> - - Plug in an Android device or start an emulator . <nl> - - adb install - r out / target / product / generic / data / app / NanoAndroidTest . apk <nl> - - Run : <nl> - " adb shell am instrument - w com . google . protobuf . nano . test / android . test . InstrumentationTestRunner " <nl> - and verify all tests pass . <nl> - - repo sync - c - j256 <nl> - - " make - j12 " and check for build errors <nl> - <nl> - Usage <nl> mmmmmm <nl> - <nl> - The complete documentation for Protocol Buffers is available via the <nl> - web at : <nl> - <nl> - https : / / developers . google . com / protocol - buffers / <nl> deleted file mode 100644 <nl> index 0395e8f2dc . . 0000000000 <nl> mmm a / javanano / pom . xml <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> - < project xmlns = " http : / / maven . apache . org / POM / 4 . 0 . 0 " <nl> - xmlns : xsi = " http : / / www . w3 . org / 2001 / XMLSchema - instance " <nl> - xsi : schemaLocation = " http : / / maven . apache . org / POM / 4 . 0 . 0 http : / / maven . apache . org / maven - v4_0_0 . xsd " > <nl> - < modelVersion > 4 . 0 . 0 < / modelVersion > <nl> - < parent > <nl> - < groupId > com . google < / groupId > <nl> - < artifactId > google < / artifactId > <nl> - < version > 1 < / version > <nl> - < / parent > <nl> - < groupId > com . google . protobuf . nano < / groupId > <nl> - < artifactId > protobuf - javanano < / artifactId > <nl> - < version > 3 . 2 . 0 < / version > <nl> - < packaging > bundle < / packaging > <nl> - < name > Protocol Buffer JavaNano API < / name > <nl> - < description > <nl> - Protocol Buffers are a way of encoding structured data in an efficient yet <nl> - extensible format . <nl> - < / description > <nl> - < inceptionYear > 2008 < / inceptionYear > <nl> - < url > https : / / developers . google . com / protocol - buffers / < / url > <nl> - < licenses > <nl> - < license > <nl> - < name > 3 - Clause BSD License < / name > <nl> - < url > https : / / opensource . org / licenses / BSD - 3 - Clause < / url > <nl> - < distribution > repo < / distribution > <nl> - < / license > <nl> - < / licenses > <nl> - < scm > <nl> - < url > https : / / github . com / google / protobuf < / url > <nl> - < connection > <nl> - scm : git : https : / / github . com / google / protobuf . git <nl> - < / connection > <nl> - < / scm > <nl> - < properties > <nl> - < project . build . sourceEncoding > UTF - 8 < / project . build . sourceEncoding > <nl> - < / properties > <nl> - < dependencies > <nl> - < dependency > <nl> - < groupId > junit < / groupId > <nl> - < artifactId > junit < / artifactId > <nl> - < version > 4 . 4 < / version > <nl> - < scope > test < / scope > <nl> - < / dependency > <nl> - < dependency > <nl> - < groupId > org . easymock < / groupId > <nl> - < artifactId > easymock < / artifactId > <nl> - < version > 2 . 2 < / version > <nl> - < scope > test < / scope > <nl> - < / dependency > <nl> - < dependency > <nl> - < groupId > org . easymock < / groupId > <nl> - < artifactId > easymockclassextension < / artifactId > <nl> - < version > 2 . 2 . 1 < / version > <nl> - < scope > test < / scope > <nl> - < / dependency > <nl> - < / dependencies > <nl> - < build > <nl> - < plugins > <nl> - < plugin > <nl> - < artifactId > maven - compiler - plugin < / artifactId > <nl> - < configuration > <nl> - < source > 1 . 5 < / source > <nl> - < target > 1 . 5 < / target > <nl> - < / configuration > <nl> - < / plugin > <nl> - < plugin > <nl> - < artifactId > maven - surefire - plugin < / artifactId > <nl> - < configuration > <nl> - < includes > <nl> - < include > * * / * Test . java < / include > <nl> - < / includes > <nl> - < / configuration > <nl> - < / plugin > <nl> - < plugin > <nl> - < artifactId > maven - antrun - plugin < / artifactId > <nl> - < executions > <nl> - < execution > <nl> - < id > generate - test - sources < / id > <nl> - < phase > generate - test - sources < / phase > <nl> - < configuration > <nl> - < tasks > <nl> - < mkdir dir = " target / generated - test - sources " / > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = generate_equals = true : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_simple_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_stringutf8_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_recursive_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_import_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_single_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_multiple_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_multiple_nameclash_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_enum_class_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_repeated_merge_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / map_test . proto " / > <nl> - < / exec > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = store_unknown_fields = true , generate_equals = true , generate_clone = true : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_extension_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_extension_singular_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_extension_repeated_nano . proto " / > <nl> - < / exec > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = store_unknown_fields = true , generate_clone = true : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_extension_packed_nano . proto " / > <nl> - < / exec > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = java_nano_generate_has = true , generate_equals = true , generate_clone = true : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_has_nano . proto " / > <nl> - < / exec > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = optional_field_style = accessors , generate_equals = true : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_accessors_nano . proto " / > <nl> - < / exec > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = enum_style = java : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_enum_class_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_enum_class_multiple_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_repeated_packables_nano . proto " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_enum_validity_nano . proto " / > <nl> - < / exec > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = <nl> - optional_field_style = accessors , <nl> - java_outer_classname = google / protobuf / nano / unittest_enum_validity_nano . proto | EnumValidityAccessors <nl> - : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_enum_validity_nano . proto " / > <nl> - < / exec > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = optional_field_style = reftypes , generate_equals = true : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_reference_types_nano . proto " / > <nl> - < / exec > <nl> - < exec executable = " . . / src / protoc " > <nl> - < arg value = " - - javanano_out = <nl> - optional_field_style = reftypes_compat_mode , <nl> - generate_equals = true , <nl> - java_outer_classname = google / protobuf / nano / unittest_reference_types_nano . proto | NanoReferenceTypesCompat <nl> - : target / generated - test - sources " / > <nl> - < arg value = " - - proto_path = src / test / java / com " / > <nl> - < arg value = " src / test / java / com / google / protobuf / nano / unittest_reference_types_nano . proto " / > <nl> - < / exec > <nl> - < / tasks > <nl> - < testSourceRoot > target / generated - test - sources < / testSourceRoot > <nl> - < / configuration > <nl> - < goals > <nl> - < goal > run < / goal > <nl> - < / goals > <nl> - < / execution > <nl> - < / executions > <nl> - < / plugin > <nl> - < plugin > <nl> - < groupId > org . apache . felix < / groupId > <nl> - < artifactId > maven - bundle - plugin < / artifactId > <nl> - < extensions > true < / extensions > <nl> - < configuration > <nl> - < instructions > <nl> - < Bundle - DocURL > https : / / developers . google . com / protocol - buffers / < / Bundle - DocURL > <nl> - < Bundle - SymbolicName > com . google . protobuf . nano < / Bundle - SymbolicName > <nl> - < Export - Package > com . google . protobuf . nano ; version = 3 . 0 . 0 - alpha - 7 < / Export - Package > <nl> - < / instructions > <nl> - < / configuration > <nl> - < / plugin > <nl> - < / plugins > <nl> - < / build > <nl> - < profiles > <nl> - < profile > <nl> - < id > release < / id > <nl> - < distributionManagement > <nl> - < snapshotRepository > <nl> - < id > sonatype - nexus - staging < / id > <nl> - < url > https : / / oss . sonatype . org / content / repositories / snapshots < / url > <nl> - < / snapshotRepository > <nl> - < repository > <nl> - < id > sonatype - nexus - staging < / id > <nl> - < url > https : / / oss . sonatype . org / service / local / staging / deploy / maven2 / < / url > <nl> - < / repository > <nl> - < / distributionManagement > <nl> - < build > <nl> - < plugins > <nl> - < plugin > <nl> - < groupId > org . apache . maven . plugins < / groupId > <nl> - < artifactId > maven - source - plugin < / artifactId > <nl> - < version > 2 . 2 . 1 < / version > <nl> - < executions > <nl> - < execution > <nl> - < id > attach - sources < / id > <nl> - < goals > <nl> - < goal > jar - no - fork < / goal > <nl> - < / goals > <nl> - < / execution > <nl> - < / executions > <nl> - < / plugin > <nl> - < plugin > <nl> - < groupId > org . apache . maven . plugins < / groupId > <nl> - < artifactId > maven - javadoc - plugin < / artifactId > <nl> - < version > 2 . 9 . 1 < / version > <nl> - < executions > <nl> - < execution > <nl> - < id > attach - javadocs < / id > <nl> - < goals > <nl> - < goal > jar < / goal > <nl> - < / goals > <nl> - < / execution > <nl> - < / executions > <nl> - < / plugin > <nl> - < plugin > <nl> - < groupId > org . apache . maven . plugins < / groupId > <nl> - < artifactId > maven - gpg - plugin < / artifactId > <nl> - < version > 1 . 5 < / version > <nl> - < executions > <nl> - < execution > <nl> - < id > sign - artifacts < / id > <nl> - < phase > verify < / phase > <nl> - < goals > <nl> - < goal > sign < / goal > <nl> - < / goals > <nl> - < / execution > <nl> - < / executions > <nl> - < / plugin > <nl> - < plugin > <nl> - < groupId > org . sonatype . plugins < / groupId > <nl> - < artifactId > nexus - staging - maven - plugin < / artifactId > <nl> - < version > 1 . 6 . 3 < / version > <nl> - < extensions > true < / extensions > <nl> - < configuration > <nl> - < serverId > sonatype - nexus - staging < / serverId > <nl> - < nexusUrl > https : / / oss . sonatype . org / < / nexusUrl > <nl> - < autoReleaseAfterClose > false < / autoReleaseAfterClose > <nl> - < / configuration > <nl> - < / plugin > <nl> - < / plugins > <nl> - < / build > <nl> - < / profile > <nl> - < / profiles > <nl> - < / project > <nl> deleted file mode 100644 <nl> index f399315511 . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / CodedInputByteBufferNano . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - <nl> - / * * <nl> - * Reads and decodes protocol message fields . <nl> - * <nl> - * This class contains two kinds of methods : methods that read specific <nl> - * protocol message constructs and field types ( e . g . { @ link # readTag ( ) } and <nl> - * { @ link # readInt32 ( ) } ) and methods that read low - level values ( e . g . <nl> - * { @ link # readRawVarint32 ( ) } and { @ link # readRawBytes } ) . If you are reading <nl> - * encoded protocol messages , you should use the former methods , but if you are <nl> - * reading some other format of your own design , use the latter . <nl> - * <nl> - * @ author kenton @ google . com Kenton Varda <nl> - * / <nl> - public final class CodedInputByteBufferNano { <nl> - / * * <nl> - * Create a new CodedInputStream wrapping the given byte array . <nl> - * / <nl> - public static CodedInputByteBufferNano newInstance ( final byte [ ] buf ) { <nl> - return newInstance ( buf , 0 , buf . length ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Create a new CodedInputStream wrapping the given byte array slice . <nl> - * / <nl> - public static CodedInputByteBufferNano newInstance ( final byte [ ] buf , final int off , <nl> - final int len ) { <nl> - return new CodedInputByteBufferNano ( buf , off , len ) ; <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / * * <nl> - * Attempt to read a field tag , returning zero if we have reached EOF . <nl> - * Protocol message parsers use this to read tags , since a protocol message <nl> - * may legally end wherever a tag occurs , and zero is not a valid tag number . <nl> - * / <nl> - public int readTag ( ) throws IOException { <nl> - if ( isAtEnd ( ) ) { <nl> - lastTag = 0 ; <nl> - return 0 ; <nl> - } <nl> - <nl> - lastTag = readRawVarint32 ( ) ; <nl> - if ( lastTag = = 0 ) { <nl> - / / If we actually read zero , that ' s not a valid tag . <nl> - throw InvalidProtocolBufferNanoException . invalidTag ( ) ; <nl> - } <nl> - return lastTag ; <nl> - } <nl> - <nl> - / * * <nl> - * Verifies that the last call to readTag ( ) returned the given tag value . <nl> - * This is used to verify that a nested group ended with the correct <nl> - * end tag . <nl> - * <nl> - * @ throws InvalidProtocolBufferNanoException { @ code value } does not match the <nl> - * last tag . <nl> - * / <nl> - public void checkLastTagWas ( final int value ) <nl> - throws InvalidProtocolBufferNanoException { <nl> - if ( lastTag ! = value ) { <nl> - throw InvalidProtocolBufferNanoException . invalidEndTag ( ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Reads and discards a single field , given its tag value . <nl> - * <nl> - * @ return { @ code false } if the tag is an endgroup tag , in which case <nl> - * nothing is skipped . Otherwise , returns { @ code true } . <nl> - * / <nl> - public boolean skipField ( final int tag ) throws IOException { <nl> - switch ( WireFormatNano . getTagWireType ( tag ) ) { <nl> - case WireFormatNano . WIRETYPE_VARINT : <nl> - readInt32 ( ) ; <nl> - return true ; <nl> - case WireFormatNano . WIRETYPE_FIXED64 : <nl> - readRawLittleEndian64 ( ) ; <nl> - return true ; <nl> - case WireFormatNano . WIRETYPE_LENGTH_DELIMITED : <nl> - skipRawBytes ( readRawVarint32 ( ) ) ; <nl> - return true ; <nl> - case WireFormatNano . WIRETYPE_START_GROUP : <nl> - skipMessage ( ) ; <nl> - checkLastTagWas ( <nl> - WireFormatNano . makeTag ( WireFormatNano . getTagFieldNumber ( tag ) , <nl> - WireFormatNano . WIRETYPE_END_GROUP ) ) ; <nl> - return true ; <nl> - case WireFormatNano . WIRETYPE_END_GROUP : <nl> - return false ; <nl> - case WireFormatNano . WIRETYPE_FIXED32 : <nl> - readRawLittleEndian32 ( ) ; <nl> - return true ; <nl> - default : <nl> - throw InvalidProtocolBufferNanoException . invalidWireType ( ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Reads and discards an entire message . This will read either until EOF <nl> - * or until an endgroup tag , whichever comes first . <nl> - * / <nl> - public void skipMessage ( ) throws IOException { <nl> - while ( true ) { <nl> - final int tag = readTag ( ) ; <nl> - if ( tag = = 0 | | ! skipField ( tag ) ) { <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / * * Read a { @ code double } field value from the stream . * / <nl> - public double readDouble ( ) throws IOException { <nl> - return Double . longBitsToDouble ( readRawLittleEndian64 ( ) ) ; <nl> - } <nl> - <nl> - / * * Read a { @ code float } field value from the stream . * / <nl> - public float readFloat ( ) throws IOException { <nl> - return Float . intBitsToFloat ( readRawLittleEndian32 ( ) ) ; <nl> - } <nl> - <nl> - / * * Read a { @ code uint64 } field value from the stream . * / <nl> - public long readUInt64 ( ) throws IOException { <nl> - return readRawVarint64 ( ) ; <nl> - } <nl> - <nl> - / * * Read an { @ code int64 } field value from the stream . * / <nl> - public long readInt64 ( ) throws IOException { <nl> - return readRawVarint64 ( ) ; <nl> - } <nl> - <nl> - / * * Read an { @ code int32 } field value from the stream . * / <nl> - public int readInt32 ( ) throws IOException { <nl> - return readRawVarint32 ( ) ; <nl> - } <nl> - <nl> - / * * Read a { @ code fixed64 } field value from the stream . * / <nl> - public long readFixed64 ( ) throws IOException { <nl> - return readRawLittleEndian64 ( ) ; <nl> - } <nl> - <nl> - / * * Read a { @ code fixed32 } field value from the stream . * / <nl> - public int readFixed32 ( ) throws IOException { <nl> - return readRawLittleEndian32 ( ) ; <nl> - } <nl> - <nl> - / * * Read a { @ code bool } field value from the stream . * / <nl> - public boolean readBool ( ) throws IOException { <nl> - return readRawVarint32 ( ) ! = 0 ; <nl> - } <nl> - <nl> - / * * Read a { @ code string } field value from the stream . * / <nl> - public String readString ( ) throws IOException { <nl> - final int size = readRawVarint32 ( ) ; <nl> - if ( size < = ( bufferSize - bufferPos ) & & size > 0 ) { <nl> - / / Fast path : We already have the bytes in a contiguous buffer , so <nl> - / / just copy directly from it . <nl> - final String result = new String ( buffer , bufferPos , size , InternalNano . UTF_8 ) ; <nl> - bufferPos + = size ; <nl> - return result ; <nl> - } else { <nl> - / / Slow path : Build a byte array first then copy it . <nl> - return new String ( readRawBytes ( size ) , InternalNano . UTF_8 ) ; <nl> - } <nl> - } <nl> - <nl> - / * * Read a { @ code group } field value from the stream . * / <nl> - public void readGroup ( final MessageNano msg , final int fieldNumber ) <nl> - throws IOException { <nl> - if ( recursionDepth > = recursionLimit ) { <nl> - throw InvalidProtocolBufferNanoException . recursionLimitExceeded ( ) ; <nl> - } <nl> - + + recursionDepth ; <nl> - msg . mergeFrom ( this ) ; <nl> - checkLastTagWas ( <nl> - WireFormatNano . makeTag ( fieldNumber , WireFormatNano . WIRETYPE_END_GROUP ) ) ; <nl> - - - recursionDepth ; <nl> - } <nl> - <nl> - public void readMessage ( final MessageNano msg ) <nl> - throws IOException { <nl> - final int length = readRawVarint32 ( ) ; <nl> - if ( recursionDepth > = recursionLimit ) { <nl> - throw InvalidProtocolBufferNanoException . recursionLimitExceeded ( ) ; <nl> - } <nl> - final int oldLimit = pushLimit ( length ) ; <nl> - + + recursionDepth ; <nl> - msg . mergeFrom ( this ) ; <nl> - checkLastTagWas ( 0 ) ; <nl> - - - recursionDepth ; <nl> - popLimit ( oldLimit ) ; <nl> - } <nl> - <nl> - / * * Read a { @ code bytes } field value from the stream . * / <nl> - public byte [ ] readBytes ( ) throws IOException { <nl> - final int size = readRawVarint32 ( ) ; <nl> - if ( size < = ( bufferSize - bufferPos ) & & size > 0 ) { <nl> - / / Fast path : We already have the bytes in a contiguous buffer , so <nl> - / / just copy directly from it . <nl> - final byte [ ] result = new byte [ size ] ; <nl> - System . arraycopy ( buffer , bufferPos , result , 0 , size ) ; <nl> - bufferPos + = size ; <nl> - return result ; <nl> - } else if ( size = = 0 ) { <nl> - return WireFormatNano . EMPTY_BYTES ; <nl> - } else { <nl> - / / Slow path : Build a byte array first then copy it . <nl> - return readRawBytes ( size ) ; <nl> - } <nl> - } <nl> - <nl> - / * * Read a { @ code uint32 } field value from the stream . * / <nl> - public int readUInt32 ( ) throws IOException { <nl> - return readRawVarint32 ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Read an enum field value from the stream . Caller is responsible <nl> - * for converting the numeric value to an actual enum . <nl> - * / <nl> - public int readEnum ( ) throws IOException { <nl> - return readRawVarint32 ( ) ; <nl> - } <nl> - <nl> - / * * Read an { @ code sfixed32 } field value from the stream . * / <nl> - public int readSFixed32 ( ) throws IOException { <nl> - return readRawLittleEndian32 ( ) ; <nl> - } <nl> - <nl> - / * * Read an { @ code sfixed64 } field value from the stream . * / <nl> - public long readSFixed64 ( ) throws IOException { <nl> - return readRawLittleEndian64 ( ) ; <nl> - } <nl> - <nl> - / * * Read an { @ code sint32 } field value from the stream . * / <nl> - public int readSInt32 ( ) throws IOException { <nl> - return decodeZigZag32 ( readRawVarint32 ( ) ) ; <nl> - } <nl> - <nl> - / * * Read an { @ code sint64 } field value from the stream . * / <nl> - public long readSInt64 ( ) throws IOException { <nl> - return decodeZigZag64 ( readRawVarint64 ( ) ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - / * * <nl> - * Read a raw Varint from the stream . If larger than 32 bits , discard the <nl> - * upper bits . <nl> - * / <nl> - public int readRawVarint32 ( ) throws IOException { <nl> - byte tmp = readRawByte ( ) ; <nl> - if ( tmp > = 0 ) { <nl> - return tmp ; <nl> - } <nl> - int result = tmp & 0x7f ; <nl> - if ( ( tmp = readRawByte ( ) ) > = 0 ) { <nl> - result | = tmp < < 7 ; <nl> - } else { <nl> - result | = ( tmp & 0x7f ) < < 7 ; <nl> - if ( ( tmp = readRawByte ( ) ) > = 0 ) { <nl> - result | = tmp < < 14 ; <nl> - } else { <nl> - result | = ( tmp & 0x7f ) < < 14 ; <nl> - if ( ( tmp = readRawByte ( ) ) > = 0 ) { <nl> - result | = tmp < < 21 ; <nl> - } else { <nl> - result | = ( tmp & 0x7f ) < < 21 ; <nl> - result | = ( tmp = readRawByte ( ) ) < < 28 ; <nl> - if ( tmp < 0 ) { <nl> - / / Discard upper 32 bits . <nl> - for ( int i = 0 ; i < 5 ; i + + ) { <nl> - if ( readRawByte ( ) > = 0 ) { <nl> - return result ; <nl> - } <nl> - } <nl> - throw InvalidProtocolBufferNanoException . malformedVarint ( ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - / * * Read a raw Varint from the stream . * / <nl> - public long readRawVarint64 ( ) throws IOException { <nl> - int shift = 0 ; <nl> - long result = 0 ; <nl> - while ( shift < 64 ) { <nl> - final byte b = readRawByte ( ) ; <nl> - result | = ( long ) ( b & 0x7F ) < < shift ; <nl> - if ( ( b & 0x80 ) = = 0 ) { <nl> - return result ; <nl> - } <nl> - shift + = 7 ; <nl> - } <nl> - throw InvalidProtocolBufferNanoException . malformedVarint ( ) ; <nl> - } <nl> - <nl> - / * * Read a 32 - bit little - endian integer from the stream . * / <nl> - public int readRawLittleEndian32 ( ) throws IOException { <nl> - final byte b1 = readRawByte ( ) ; <nl> - final byte b2 = readRawByte ( ) ; <nl> - final byte b3 = readRawByte ( ) ; <nl> - final byte b4 = readRawByte ( ) ; <nl> - return ( ( b1 & 0xff ) ) | <nl> - ( ( b2 & 0xff ) < < 8 ) | <nl> - ( ( b3 & 0xff ) < < 16 ) | <nl> - ( ( b4 & 0xff ) < < 24 ) ; <nl> - } <nl> - <nl> - / * * Read a 64 - bit little - endian integer from the stream . * / <nl> - public long readRawLittleEndian64 ( ) throws IOException { <nl> - final byte b1 = readRawByte ( ) ; <nl> - final byte b2 = readRawByte ( ) ; <nl> - final byte b3 = readRawByte ( ) ; <nl> - final byte b4 = readRawByte ( ) ; <nl> - final byte b5 = readRawByte ( ) ; <nl> - final byte b6 = readRawByte ( ) ; <nl> - final byte b7 = readRawByte ( ) ; <nl> - final byte b8 = readRawByte ( ) ; <nl> - return ( ( ( long ) b1 & 0xff ) ) | <nl> - ( ( ( long ) b2 & 0xff ) < < 8 ) | <nl> - ( ( ( long ) b3 & 0xff ) < < 16 ) | <nl> - ( ( ( long ) b4 & 0xff ) < < 24 ) | <nl> - ( ( ( long ) b5 & 0xff ) < < 32 ) | <nl> - ( ( ( long ) b6 & 0xff ) < < 40 ) | <nl> - ( ( ( long ) b7 & 0xff ) < < 48 ) | <nl> - ( ( ( long ) b8 & 0xff ) < < 56 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Decode a ZigZag - encoded 32 - bit value . ZigZag encodes signed integers <nl> - * into values that can be efficiently encoded with varint . ( Otherwise , <nl> - * negative values must be sign - extended to 64 bits to be varint encoded , <nl> - * thus always taking 10 bytes on the wire . ) <nl> - * <nl> - * @ param n An unsigned 32 - bit integer , stored in a signed int because <nl> - * Java has no explicit unsigned support . <nl> - * @ return A signed 32 - bit integer . <nl> - * / <nl> - public static int decodeZigZag32 ( final int n ) { <nl> - return ( n > > > 1 ) ^ - ( n & 1 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Decode a ZigZag - encoded 64 - bit value . ZigZag encodes signed integers <nl> - * into values that can be efficiently encoded with varint . ( Otherwise , <nl> - * negative values must be sign - extended to 64 bits to be varint encoded , <nl> - * thus always taking 10 bytes on the wire . ) <nl> - * <nl> - * @ param n An unsigned 64 - bit integer , stored in a signed int because <nl> - * Java has no explicit unsigned support . <nl> - * @ return A signed 64 - bit integer . <nl> - * / <nl> - public static long decodeZigZag64 ( final long n ) { <nl> - return ( n > > > 1 ) ^ - ( n & 1 ) ; <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - private final byte [ ] buffer ; <nl> - private int bufferStart ; <nl> - private int bufferSize ; <nl> - private int bufferSizeAfterLimit ; <nl> - private int bufferPos ; <nl> - private int lastTag ; <nl> - <nl> - / * * The absolute position of the end of the current message . * / <nl> - private int currentLimit = Integer . MAX_VALUE ; <nl> - <nl> - / * * See setRecursionLimit ( ) * / <nl> - private int recursionDepth ; <nl> - private int recursionLimit = DEFAULT_RECURSION_LIMIT ; <nl> - <nl> - / * * See setSizeLimit ( ) * / <nl> - private int sizeLimit = DEFAULT_SIZE_LIMIT ; <nl> - <nl> - private static final int DEFAULT_RECURSION_LIMIT = 64 ; <nl> - private static final int DEFAULT_SIZE_LIMIT = 64 < < 20 ; / / 64MB <nl> - <nl> - private CodedInputByteBufferNano ( final byte [ ] buffer , final int off , final int len ) { <nl> - this . buffer = buffer ; <nl> - bufferStart = off ; <nl> - bufferSize = off + len ; <nl> - bufferPos = off ; <nl> - } <nl> - <nl> - / * * <nl> - * Set the maximum message recursion depth . In order to prevent malicious <nl> - * messages from causing stack overflows , { @ code CodedInputStream } limits <nl> - * how deeply messages may be nested . The default limit is 64 . <nl> - * <nl> - * @ return the old limit . <nl> - * / <nl> - public int setRecursionLimit ( final int limit ) { <nl> - if ( limit < 0 ) { <nl> - throw new IllegalArgumentException ( <nl> - " Recursion limit cannot be negative : " + limit ) ; <nl> - } <nl> - final int oldLimit = recursionLimit ; <nl> - recursionLimit = limit ; <nl> - return oldLimit ; <nl> - } <nl> - <nl> - / * * <nl> - * Set the maximum message size . In order to prevent malicious <nl> - * messages from exhausting memory or causing integer overflows , <nl> - * { @ code CodedInputStream } limits how large a message may be . <nl> - * The default limit is 64MB . You should set this limit as small <nl> - * as you can without harming your app ' s functionality . Note that <nl> - * size limits only apply when reading from an { @ code InputStream } , not <nl> - * when constructed around a raw byte array . <nl> - * < p > <nl> - * If you want to read several messages from a single CodedInputStream , you <nl> - * could call { @ link # resetSizeCounter ( ) } after each one to avoid hitting the <nl> - * size limit . <nl> - * <nl> - * @ return the old limit . <nl> - * / <nl> - public int setSizeLimit ( final int limit ) { <nl> - if ( limit < 0 ) { <nl> - throw new IllegalArgumentException ( <nl> - " Size limit cannot be negative : " + limit ) ; <nl> - } <nl> - final int oldLimit = sizeLimit ; <nl> - sizeLimit = limit ; <nl> - return oldLimit ; <nl> - } <nl> - <nl> - / * * <nl> - * Resets the current size counter to zero ( see { @ link # setSizeLimit ( int ) } ) . <nl> - * / <nl> - public void resetSizeCounter ( ) { <nl> - } <nl> - <nl> - / * * <nl> - * Sets { @ code currentLimit } to ( current position ) + { @ code byteLimit } . This <nl> - * is called when descending into a length - delimited embedded message . <nl> - * <nl> - * @ return the old limit . <nl> - * / <nl> - public int pushLimit ( int byteLimit ) throws InvalidProtocolBufferNanoException { <nl> - if ( byteLimit < 0 ) { <nl> - throw InvalidProtocolBufferNanoException . negativeSize ( ) ; <nl> - } <nl> - byteLimit + = bufferPos ; <nl> - final int oldLimit = currentLimit ; <nl> - if ( byteLimit > oldLimit ) { <nl> - throw InvalidProtocolBufferNanoException . truncatedMessage ( ) ; <nl> - } <nl> - currentLimit = byteLimit ; <nl> - <nl> - recomputeBufferSizeAfterLimit ( ) ; <nl> - <nl> - return oldLimit ; <nl> - } <nl> - <nl> - private void recomputeBufferSizeAfterLimit ( ) { <nl> - bufferSize + = bufferSizeAfterLimit ; <nl> - final int bufferEnd = bufferSize ; <nl> - if ( bufferEnd > currentLimit ) { <nl> - / / Limit is in current buffer . <nl> - bufferSizeAfterLimit = bufferEnd - currentLimit ; <nl> - bufferSize - = bufferSizeAfterLimit ; <nl> - } else { <nl> - bufferSizeAfterLimit = 0 ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Discards the current limit , returning to the previous limit . <nl> - * <nl> - * @ param oldLimit The old limit , as returned by { @ code pushLimit } . <nl> - * / <nl> - public void popLimit ( final int oldLimit ) { <nl> - currentLimit = oldLimit ; <nl> - recomputeBufferSizeAfterLimit ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Returns the number of bytes to be read before the current limit . <nl> - * If no limit is set , returns - 1 . <nl> - * / <nl> - public int getBytesUntilLimit ( ) { <nl> - if ( currentLimit = = Integer . MAX_VALUE ) { <nl> - return - 1 ; <nl> - } <nl> - <nl> - final int currentAbsolutePosition = bufferPos ; <nl> - return currentLimit - currentAbsolutePosition ; <nl> - } <nl> - <nl> - / * * <nl> - * Returns true if the stream has reached the end of the input . This is the <nl> - * case if either the end of the underlying input source has been reached or <nl> - * if the stream has reached a limit created using { @ link # pushLimit ( int ) } . <nl> - * / <nl> - public boolean isAtEnd ( ) { <nl> - return bufferPos = = bufferSize ; <nl> - } <nl> - <nl> - / * * <nl> - * Get current position in buffer relative to beginning offset . <nl> - * / <nl> - public int getPosition ( ) { <nl> - return bufferPos - bufferStart ; <nl> - } <nl> - <nl> - / * * <nl> - * Retrieves a subset of data in the buffer . The returned array is not backed by the original <nl> - * buffer array . <nl> - * <nl> - * @ param offset the position ( relative to the buffer start position ) to start at . <nl> - * @ param length the number of bytes to retrieve . <nl> - * / <nl> - public byte [ ] getData ( int offset , int length ) { <nl> - if ( length = = 0 ) { <nl> - return WireFormatNano . EMPTY_BYTES ; <nl> - } <nl> - byte [ ] copy = new byte [ length ] ; <nl> - int start = bufferStart + offset ; <nl> - System . arraycopy ( buffer , start , copy , 0 , length ) ; <nl> - return copy ; <nl> - } <nl> - <nl> - / * * <nl> - * Rewind to previous position . Cannot go forward . <nl> - * / <nl> - public void rewindToPosition ( int position ) { <nl> - if ( position > bufferPos - bufferStart ) { <nl> - throw new IllegalArgumentException ( <nl> - " Position " + position + " is beyond current " + ( bufferPos - bufferStart ) ) ; <nl> - } <nl> - if ( position < 0 ) { <nl> - throw new IllegalArgumentException ( " Bad position " + position ) ; <nl> - } <nl> - bufferPos = bufferStart + position ; <nl> - } <nl> - <nl> - / * * <nl> - * Read one byte from the input . <nl> - * <nl> - * @ throws InvalidProtocolBufferNanoException The end of the stream or the current <nl> - * limit was reached . <nl> - * / <nl> - public byte readRawByte ( ) throws IOException { <nl> - if ( bufferPos = = bufferSize ) { <nl> - throw InvalidProtocolBufferNanoException . truncatedMessage ( ) ; <nl> - } <nl> - return buffer [ bufferPos + + ] ; <nl> - } <nl> - <nl> - / * * <nl> - * Read a fixed size of bytes from the input . <nl> - * <nl> - * @ throws InvalidProtocolBufferNanoException The end of the stream or the current <nl> - * limit was reached . <nl> - * / <nl> - public byte [ ] readRawBytes ( final int size ) throws IOException { <nl> - if ( size < 0 ) { <nl> - throw InvalidProtocolBufferNanoException . negativeSize ( ) ; <nl> - } <nl> - <nl> - if ( bufferPos + size > currentLimit ) { <nl> - / / Read to the end of the stream anyway . <nl> - skipRawBytes ( currentLimit - bufferPos ) ; <nl> - / / Then fail . <nl> - throw InvalidProtocolBufferNanoException . truncatedMessage ( ) ; <nl> - } <nl> - <nl> - if ( size < = bufferSize - bufferPos ) { <nl> - / / We have all the bytes we need already . <nl> - final byte [ ] bytes = new byte [ size ] ; <nl> - System . arraycopy ( buffer , bufferPos , bytes , 0 , size ) ; <nl> - bufferPos + = size ; <nl> - return bytes ; <nl> - } else { <nl> - throw InvalidProtocolBufferNanoException . truncatedMessage ( ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Reads and discards { @ code size } bytes . <nl> - * <nl> - * @ throws InvalidProtocolBufferNanoException The end of the stream or the current <nl> - * limit was reached . <nl> - * / <nl> - public void skipRawBytes ( final int size ) throws IOException { <nl> - if ( size < 0 ) { <nl> - throw InvalidProtocolBufferNanoException . negativeSize ( ) ; <nl> - } <nl> - <nl> - if ( bufferPos + size > currentLimit ) { <nl> - / / Read to the end of the stream anyway . <nl> - skipRawBytes ( currentLimit - bufferPos ) ; <nl> - / / Then fail . <nl> - throw InvalidProtocolBufferNanoException . truncatedMessage ( ) ; <nl> - } <nl> - <nl> - if ( size < = bufferSize - bufferPos ) { <nl> - / / We have all the bytes we need already . <nl> - bufferPos + = size ; <nl> - } else { <nl> - throw InvalidProtocolBufferNanoException . truncatedMessage ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / Read a primitive type . <nl> - Object readPrimitiveField ( int type ) throws IOException { <nl> - switch ( type ) { <nl> - case InternalNano . TYPE_DOUBLE : <nl> - return readDouble ( ) ; <nl> - case InternalNano . TYPE_FLOAT : <nl> - return readFloat ( ) ; <nl> - case InternalNano . TYPE_INT64 : <nl> - return readInt64 ( ) ; <nl> - case InternalNano . TYPE_UINT64 : <nl> - return readUInt64 ( ) ; <nl> - case InternalNano . TYPE_INT32 : <nl> - return readInt32 ( ) ; <nl> - case InternalNano . TYPE_FIXED64 : <nl> - return readFixed64 ( ) ; <nl> - case InternalNano . TYPE_FIXED32 : <nl> - return readFixed32 ( ) ; <nl> - case InternalNano . TYPE_BOOL : <nl> - return readBool ( ) ; <nl> - case InternalNano . TYPE_STRING : <nl> - return readString ( ) ; <nl> - case InternalNano . TYPE_BYTES : <nl> - return readBytes ( ) ; <nl> - case InternalNano . TYPE_UINT32 : <nl> - return readUInt32 ( ) ; <nl> - case InternalNano . TYPE_ENUM : <nl> - return readEnum ( ) ; <nl> - case InternalNano . TYPE_SFIXED32 : <nl> - return readSFixed32 ( ) ; <nl> - case InternalNano . TYPE_SFIXED64 : <nl> - return readSFixed64 ( ) ; <nl> - case InternalNano . TYPE_SINT32 : <nl> - return readSInt32 ( ) ; <nl> - case InternalNano . TYPE_SINT64 : <nl> - return readSInt64 ( ) ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unknown type " + type ) ; <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 322ada8e1f . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / CodedOutputByteBufferNano . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - import java . nio . BufferOverflowException ; <nl> - import java . nio . ByteBuffer ; <nl> - import java . nio . ByteOrder ; <nl> - import java . nio . ReadOnlyBufferException ; <nl> - <nl> - / * * <nl> - * Encodes and writes protocol message fields . <nl> - * <nl> - * < p > This class contains two kinds of methods : methods that write specific <nl> - * protocol message constructs and field types ( e . g . { @ link # writeTag } and <nl> - * { @ link # writeInt32 } ) and methods that write low - level values ( e . g . <nl> - * { @ link # writeRawVarint32 } and { @ link # writeRawBytes } ) . If you are <nl> - * writing encoded protocol messages , you should use the former methods , but if <nl> - * you are writing some other format of your own design , use the latter . <nl> - * <nl> - * < p > This class is totally unsynchronized . <nl> - * <nl> - * @ author kneton @ google . com Kenton Varda <nl> - * / <nl> - public final class CodedOutputByteBufferNano { <nl> - / * max bytes per java UTF - 16 char in UTF - 8 * / <nl> - private static final int MAX_UTF8_EXPANSION = 3 ; <nl> - private final ByteBuffer buffer ; <nl> - <nl> - private CodedOutputByteBufferNano ( final byte [ ] buffer , final int offset , <nl> - final int length ) { <nl> - this ( ByteBuffer . wrap ( buffer , offset , length ) ) ; <nl> - } <nl> - <nl> - private CodedOutputByteBufferNano ( final ByteBuffer buffer ) { <nl> - this . buffer = buffer ; <nl> - this . buffer . order ( ByteOrder . LITTLE_ENDIAN ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Create a new { @ code CodedOutputStream } that writes directly to the given <nl> - * byte array . If more bytes are written than fit in the array , <nl> - * { @ link OutOfSpaceException } will be thrown . Writing directly to a flat <nl> - * array is faster than writing to an { @ code OutputStream } . <nl> - * / <nl> - public static CodedOutputByteBufferNano newInstance ( final byte [ ] flatArray ) { <nl> - return newInstance ( flatArray , 0 , flatArray . length ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Create a new { @ code CodedOutputStream } that writes directly to the given <nl> - * byte array slice . If more bytes are written than fit in the slice , <nl> - * { @ link OutOfSpaceException } will be thrown . Writing directly to a flat <nl> - * array is faster than writing to an { @ code OutputStream } . <nl> - * / <nl> - public static CodedOutputByteBufferNano newInstance ( final byte [ ] flatArray , <nl> - final int offset , <nl> - final int length ) { <nl> - return new CodedOutputByteBufferNano ( flatArray , offset , length ) ; <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / * * Write a { @ code double } field , including tag , to the stream . * / <nl> - public void writeDouble ( final int fieldNumber , final double value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_FIXED64 ) ; <nl> - writeDoubleNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code float } field , including tag , to the stream . * / <nl> - public void writeFloat ( final int fieldNumber , final float value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_FIXED32 ) ; <nl> - writeFloatNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code uint64 } field , including tag , to the stream . * / <nl> - public void writeUInt64 ( final int fieldNumber , final long value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_VARINT ) ; <nl> - writeUInt64NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code int64 } field , including tag , to the stream . * / <nl> - public void writeInt64 ( final int fieldNumber , final long value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_VARINT ) ; <nl> - writeInt64NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code int32 } field , including tag , to the stream . * / <nl> - public void writeInt32 ( final int fieldNumber , final int value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_VARINT ) ; <nl> - writeInt32NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code fixed64 } field , including tag , to the stream . * / <nl> - public void writeFixed64 ( final int fieldNumber , final long value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_FIXED64 ) ; <nl> - writeFixed64NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code fixed32 } field , including tag , to the stream . * / <nl> - public void writeFixed32 ( final int fieldNumber , final int value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_FIXED32 ) ; <nl> - writeFixed32NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code bool } field , including tag , to the stream . * / <nl> - public void writeBool ( final int fieldNumber , final boolean value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_VARINT ) ; <nl> - writeBoolNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code string } field , including tag , to the stream . * / <nl> - public void writeString ( final int fieldNumber , final String value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_LENGTH_DELIMITED ) ; <nl> - writeStringNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code group } field , including tag , to the stream . * / <nl> - public void writeGroup ( final int fieldNumber , final MessageNano value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_START_GROUP ) ; <nl> - writeGroupNoTag ( value ) ; <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_END_GROUP ) ; <nl> - } <nl> - <nl> - / * * Write an embedded message field , including tag , to the stream . * / <nl> - public void writeMessage ( final int fieldNumber , final MessageNano value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_LENGTH_DELIMITED ) ; <nl> - writeMessageNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code bytes } field , including tag , to the stream . * / <nl> - public void writeBytes ( final int fieldNumber , final byte [ ] value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_LENGTH_DELIMITED ) ; <nl> - writeBytesNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code uint32 } field , including tag , to the stream . * / <nl> - public void writeUInt32 ( final int fieldNumber , final int value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_VARINT ) ; <nl> - writeUInt32NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Write an enum field , including tag , to the stream . Caller is responsible <nl> - * for converting the enum value to its numeric value . <nl> - * / <nl> - public void writeEnum ( final int fieldNumber , final int value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_VARINT ) ; <nl> - writeEnumNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code sfixed32 } field , including tag , to the stream . * / <nl> - public void writeSFixed32 ( final int fieldNumber , final int value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_FIXED32 ) ; <nl> - writeSFixed32NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code sfixed64 } field , including tag , to the stream . * / <nl> - public void writeSFixed64 ( final int fieldNumber , final long value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_FIXED64 ) ; <nl> - writeSFixed64NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code sint32 } field , including tag , to the stream . * / <nl> - public void writeSInt32 ( final int fieldNumber , final int value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_VARINT ) ; <nl> - writeSInt32NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code sint64 } field , including tag , to the stream . * / <nl> - public void writeSInt64 ( final int fieldNumber , final long value ) <nl> - throws IOException { <nl> - writeTag ( fieldNumber , WireFormatNano . WIRETYPE_VARINT ) ; <nl> - writeSInt64NoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Write a MessageSet extension field to the stream . For historical reasons , <nl> - * the wire format differs from normal fields . <nl> - * / <nl> - / / public void writeMessageSetExtension ( final int fieldNumber , <nl> - / / final MessageMicro value ) <nl> - / / throws IOException { <nl> - / / writeTag ( WireFormatMicro . MESSAGE_SET_ITEM , WireFormatMicro . WIRETYPE_START_GROUP ) ; <nl> - / / writeUInt32 ( WireFormatMicro . MESSAGE_SET_TYPE_ID , fieldNumber ) ; <nl> - / / writeMessage ( WireFormatMicro . MESSAGE_SET_MESSAGE , value ) ; <nl> - / / writeTag ( WireFormatMicro . MESSAGE_SET_ITEM , WireFormatMicro . WIRETYPE_END_GROUP ) ; <nl> - / / } <nl> - <nl> - / * * <nl> - * Write an unparsed MessageSet extension field to the stream . For <nl> - * historical reasons , the wire format differs from normal fields . <nl> - * / <nl> - / / public void writeRawMessageSetExtension ( final int fieldNumber , <nl> - / / final ByteStringMicro value ) <nl> - / / throws IOException { <nl> - / / writeTag ( WireFormatMicro . MESSAGE_SET_ITEM , WireFormatMicro . WIRETYPE_START_GROUP ) ; <nl> - / / writeUInt32 ( WireFormatMicro . MESSAGE_SET_TYPE_ID , fieldNumber ) ; <nl> - / / writeBytes ( WireFormatMicro . MESSAGE_SET_MESSAGE , value ) ; <nl> - / / writeTag ( WireFormatMicro . MESSAGE_SET_ITEM , WireFormatMicro . WIRETYPE_END_GROUP ) ; <nl> - / / } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / * * Write a { @ code double } field to the stream . * / <nl> - public void writeDoubleNoTag ( final double value ) throws IOException { <nl> - writeRawLittleEndian64 ( Double . doubleToLongBits ( value ) ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code float } field to the stream . * / <nl> - public void writeFloatNoTag ( final float value ) throws IOException { <nl> - writeRawLittleEndian32 ( Float . floatToIntBits ( value ) ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code uint64 } field to the stream . * / <nl> - public void writeUInt64NoTag ( final long value ) throws IOException { <nl> - writeRawVarint64 ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code int64 } field to the stream . * / <nl> - public void writeInt64NoTag ( final long value ) throws IOException { <nl> - writeRawVarint64 ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code int32 } field to the stream . * / <nl> - public void writeInt32NoTag ( final int value ) throws IOException { <nl> - if ( value > = 0 ) { <nl> - writeRawVarint32 ( value ) ; <nl> - } else { <nl> - / / Must sign - extend . <nl> - writeRawVarint64 ( value ) ; <nl> - } <nl> - } <nl> - <nl> - / * * Write a { @ code fixed64 } field to the stream . * / <nl> - public void writeFixed64NoTag ( final long value ) throws IOException { <nl> - writeRawLittleEndian64 ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code fixed32 } field to the stream . * / <nl> - public void writeFixed32NoTag ( final int value ) throws IOException { <nl> - writeRawLittleEndian32 ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code bool } field to the stream . * / <nl> - public void writeBoolNoTag ( final boolean value ) throws IOException { <nl> - writeRawByte ( value ? 1 : 0 ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code string } field to the stream . * / <nl> - public void writeStringNoTag ( final String value ) throws IOException { <nl> - / / UTF - 8 byte length of the string is at least its UTF - 16 code unit length ( value . length ( ) ) , <nl> - / / and at most 3 times of it . Optimize for the case where we know this length results in a <nl> - / / constant varint length - saves measuring length of the string . <nl> - try { <nl> - final int minLengthVarIntSize = computeRawVarint32Size ( value . length ( ) ) ; <nl> - final int maxLengthVarIntSize = computeRawVarint32Size ( value . length ( ) * MAX_UTF8_EXPANSION ) ; <nl> - if ( minLengthVarIntSize = = maxLengthVarIntSize ) { <nl> - int oldPosition = buffer . position ( ) ; <nl> - / / Buffer . position , when passed a position that is past its limit , throws <nl> - / / IllegalArgumentException , and this class is documented to throw <nl> - / / OutOfSpaceException instead . <nl> - if ( buffer . remaining ( ) < minLengthVarIntSize ) { <nl> - throw new OutOfSpaceException ( oldPosition + minLengthVarIntSize , buffer . limit ( ) ) ; <nl> - } <nl> - buffer . position ( oldPosition + minLengthVarIntSize ) ; <nl> - encode ( value , buffer ) ; <nl> - int newPosition = buffer . position ( ) ; <nl> - buffer . position ( oldPosition ) ; <nl> - writeRawVarint32 ( newPosition - oldPosition - minLengthVarIntSize ) ; <nl> - buffer . position ( newPosition ) ; <nl> - } else { <nl> - writeRawVarint32 ( encodedLength ( value ) ) ; <nl> - encode ( value , buffer ) ; <nl> - } <nl> - } catch ( BufferOverflowException e ) { <nl> - final OutOfSpaceException outOfSpaceException = new OutOfSpaceException ( buffer . position ( ) , <nl> - buffer . limit ( ) ) ; <nl> - outOfSpaceException . initCause ( e ) ; <nl> - throw outOfSpaceException ; <nl> - } <nl> - } <nl> - <nl> - / / These UTF - 8 handling methods are copied from Guava ' s Utf8 class . <nl> - / * * <nl> - * Returns the number of bytes in the UTF - 8 - encoded form of { @ code sequence } . For a string , <nl> - * this method is equivalent to { @ code string . getBytes ( UTF_8 ) . length } , but is more efficient in <nl> - * both time and space . <nl> - * <nl> - * @ throws IllegalArgumentException if { @ code sequence } contains ill - formed UTF - 16 ( unpaired <nl> - * surrogates ) <nl> - * / <nl> - private static int encodedLength ( CharSequence sequence ) { <nl> - / / Warning to maintainers : this implementation is highly optimized . <nl> - int utf16Length = sequence . length ( ) ; <nl> - int utf8Length = utf16Length ; <nl> - int i = 0 ; <nl> - <nl> - / / This loop optimizes for pure ASCII . <nl> - while ( i < utf16Length & & sequence . charAt ( i ) < 0x80 ) { <nl> - i + + ; <nl> - } <nl> - <nl> - / / This loop optimizes for chars less than 0x800 . <nl> - for ( ; i < utf16Length ; i + + ) { <nl> - char c = sequence . charAt ( i ) ; <nl> - if ( c < 0x800 ) { <nl> - utf8Length + = ( ( 0x7f - c ) > > > 31 ) ; / / branch free ! <nl> - } else { <nl> - utf8Length + = encodedLengthGeneral ( sequence , i ) ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - if ( utf8Length < utf16Length ) { <nl> - / / Necessary and sufficient condition for overflow because of maximum 3x expansion <nl> - throw new IllegalArgumentException ( " UTF - 8 length does not fit in int : " <nl> - + ( utf8Length + ( 1L < < 32 ) ) ) ; <nl> - } <nl> - return utf8Length ; <nl> - } <nl> - <nl> - private static int encodedLengthGeneral ( CharSequence sequence , int start ) { <nl> - int utf16Length = sequence . length ( ) ; <nl> - int utf8Length = 0 ; <nl> - for ( int i = start ; i < utf16Length ; i + + ) { <nl> - char c = sequence . charAt ( i ) ; <nl> - if ( c < 0x800 ) { <nl> - utf8Length + = ( 0x7f - c ) > > > 31 ; / / branch free ! <nl> - } else { <nl> - utf8Length + = 2 ; <nl> - / / jdk7 + : if ( Character . isSurrogate ( c ) ) { <nl> - if ( Character . MIN_SURROGATE < = c & & c < = Character . MAX_SURROGATE ) { <nl> - / / Check that we have a well - formed surrogate pair . <nl> - int cp = Character . codePointAt ( sequence , i ) ; <nl> - if ( cp < Character . MIN_SUPPLEMENTARY_CODE_POINT ) { <nl> - throw new IllegalArgumentException ( " Unpaired surrogate at index " + i ) ; <nl> - } <nl> - i + + ; <nl> - } <nl> - } <nl> - } <nl> - return utf8Length ; <nl> - } <nl> - <nl> - / * * <nl> - * Encodes { @ code sequence } into UTF - 8 , in { @ code byteBuffer } . For a string , this method is <nl> - * equivalent to { @ code buffer . put ( string . getBytes ( UTF_8 ) ) } , but is more efficient in both time <nl> - * and space . Bytes are written starting at the current position . This method requires paired <nl> - * surrogates , and therefore does not support chunking . <nl> - * <nl> - * < p > To ensure sufficient space in the output buffer , either call { @ link # encodedLength } to <nl> - * compute the exact amount needed , or leave room for { @ code 3 * sequence . length ( ) } , which is the <nl> - * largest possible number of bytes that any input can be encoded to . <nl> - * <nl> - * @ throws IllegalArgumentException if { @ code sequence } contains ill - formed UTF - 16 ( unpaired <nl> - * surrogates ) <nl> - * @ throws BufferOverflowException if { @ code sequence } encoded in UTF - 8 does not fit in <nl> - * { @ code byteBuffer } ' s remaining space . <nl> - * @ throws ReadOnlyBufferException if { @ code byteBuffer } is a read - only buffer . <nl> - * / <nl> - private static void encode ( CharSequence sequence , ByteBuffer byteBuffer ) { <nl> - if ( byteBuffer . isReadOnly ( ) ) { <nl> - throw new ReadOnlyBufferException ( ) ; <nl> - } else if ( byteBuffer . hasArray ( ) ) { <nl> - try { <nl> - int encoded = encode ( sequence , <nl> - byteBuffer . array ( ) , <nl> - byteBuffer . arrayOffset ( ) + byteBuffer . position ( ) , <nl> - byteBuffer . remaining ( ) ) ; <nl> - byteBuffer . position ( encoded - byteBuffer . arrayOffset ( ) ) ; <nl> - } catch ( ArrayIndexOutOfBoundsException e ) { <nl> - BufferOverflowException boe = new BufferOverflowException ( ) ; <nl> - boe . initCause ( e ) ; <nl> - throw boe ; <nl> - } <nl> - } else { <nl> - encodeDirect ( sequence , byteBuffer ) ; <nl> - } <nl> - } <nl> - <nl> - private static void encodeDirect ( CharSequence sequence , ByteBuffer byteBuffer ) { <nl> - int utf16Length = sequence . length ( ) ; <nl> - for ( int i = 0 ; i < utf16Length ; i + + ) { <nl> - final char c = sequence . charAt ( i ) ; <nl> - if ( c < 0x80 ) { / / ASCII <nl> - byteBuffer . put ( ( byte ) c ) ; <nl> - } else if ( c < 0x800 ) { / / 11 bits , two UTF - 8 bytes <nl> - byteBuffer . put ( ( byte ) ( ( 0xF < < 6 ) | ( c > > > 6 ) ) ) ; <nl> - byteBuffer . put ( ( byte ) ( 0x80 | ( 0x3F & c ) ) ) ; <nl> - } else if ( c < Character . MIN_SURROGATE | | Character . MAX_SURROGATE < c ) { <nl> - / / Maximium single - char code point is 0xFFFF , 16 bits , three UTF - 8 bytes <nl> - byteBuffer . put ( ( byte ) ( ( 0xF < < 5 ) | ( c > > > 12 ) ) ) ; <nl> - byteBuffer . put ( ( byte ) ( 0x80 | ( 0x3F & ( c > > > 6 ) ) ) ) ; <nl> - byteBuffer . put ( ( byte ) ( 0x80 | ( 0x3F & c ) ) ) ; <nl> - } else { <nl> - final char low ; <nl> - if ( i + 1 = = sequence . length ( ) <nl> - | | ! Character . isSurrogatePair ( c , ( low = sequence . charAt ( + + i ) ) ) ) { <nl> - throw new IllegalArgumentException ( " Unpaired surrogate at index " + ( i - 1 ) ) ; <nl> - } <nl> - int codePoint = Character . toCodePoint ( c , low ) ; <nl> - byteBuffer . put ( ( byte ) ( ( 0xF < < 4 ) | ( codePoint > > > 18 ) ) ) ; <nl> - byteBuffer . put ( ( byte ) ( 0x80 | ( 0x3F & ( codePoint > > > 12 ) ) ) ) ; <nl> - byteBuffer . put ( ( byte ) ( 0x80 | ( 0x3F & ( codePoint > > > 6 ) ) ) ) ; <nl> - byteBuffer . put ( ( byte ) ( 0x80 | ( 0x3F & codePoint ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - private static int encode ( CharSequence sequence , byte [ ] bytes , int offset , int length ) { <nl> - int utf16Length = sequence . length ( ) ; <nl> - int j = offset ; <nl> - int i = 0 ; <nl> - int limit = offset + length ; <nl> - / / Designed to take advantage of <nl> - / / https : / / wikis . oracle . com / display / HotSpotInternals / RangeCheckElimination <nl> - for ( char c ; i < utf16Length & & i + j < limit & & ( c = sequence . charAt ( i ) ) < 0x80 ; i + + ) { <nl> - bytes [ j + i ] = ( byte ) c ; <nl> - } <nl> - if ( i = = utf16Length ) { <nl> - return j + utf16Length ; <nl> - } <nl> - j + = i ; <nl> - for ( char c ; i < utf16Length ; i + + ) { <nl> - c = sequence . charAt ( i ) ; <nl> - if ( c < 0x80 & & j < limit ) { <nl> - bytes [ j + + ] = ( byte ) c ; <nl> - } else if ( c < 0x800 & & j < = limit - 2 ) { / / 11 bits , two UTF - 8 bytes <nl> - bytes [ j + + ] = ( byte ) ( ( 0xF < < 6 ) | ( c > > > 6 ) ) ; <nl> - bytes [ j + + ] = ( byte ) ( 0x80 | ( 0x3F & c ) ) ; <nl> - } else if ( ( c < Character . MIN_SURROGATE | | Character . MAX_SURROGATE < c ) & & j < = limit - 3 ) { <nl> - / / Maximum single - char code point is 0xFFFF , 16 bits , three UTF - 8 bytes <nl> - bytes [ j + + ] = ( byte ) ( ( 0xF < < 5 ) | ( c > > > 12 ) ) ; <nl> - bytes [ j + + ] = ( byte ) ( 0x80 | ( 0x3F & ( c > > > 6 ) ) ) ; <nl> - bytes [ j + + ] = ( byte ) ( 0x80 | ( 0x3F & c ) ) ; <nl> - } else if ( j < = limit - 4 ) { <nl> - / / Minimum code point represented by a surrogate pair is 0x10000 , 17 bits , four UTF - 8 bytes <nl> - final char low ; <nl> - if ( i + 1 = = sequence . length ( ) <nl> - | | ! Character . isSurrogatePair ( c , ( low = sequence . charAt ( + + i ) ) ) ) { <nl> - throw new IllegalArgumentException ( " Unpaired surrogate at index " + ( i - 1 ) ) ; <nl> - } <nl> - int codePoint = Character . toCodePoint ( c , low ) ; <nl> - bytes [ j + + ] = ( byte ) ( ( 0xF < < 4 ) | ( codePoint > > > 18 ) ) ; <nl> - bytes [ j + + ] = ( byte ) ( 0x80 | ( 0x3F & ( codePoint > > > 12 ) ) ) ; <nl> - bytes [ j + + ] = ( byte ) ( 0x80 | ( 0x3F & ( codePoint > > > 6 ) ) ) ; <nl> - bytes [ j + + ] = ( byte ) ( 0x80 | ( 0x3F & codePoint ) ) ; <nl> - } else { <nl> - throw new ArrayIndexOutOfBoundsException ( " Failed writing " + c + " at index " + j ) ; <nl> - } <nl> - } <nl> - return j ; <nl> - } <nl> - <nl> - / / End guava UTF - 8 methods <nl> - <nl> - <nl> - / * * Write a { @ code group } field to the stream . * / <nl> - public void writeGroupNoTag ( final MessageNano value ) throws IOException { <nl> - value . writeTo ( this ) ; <nl> - } <nl> - <nl> - / * * Write an embedded message field to the stream . * / <nl> - public void writeMessageNoTag ( final MessageNano value ) throws IOException { <nl> - writeRawVarint32 ( value . getCachedSize ( ) ) ; <nl> - value . writeTo ( this ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code bytes } field to the stream . * / <nl> - public void writeBytesNoTag ( final byte [ ] value ) throws IOException { <nl> - writeRawVarint32 ( value . length ) ; <nl> - writeRawBytes ( value ) ; <nl> - } <nl> - <nl> - / * * Write a { @ code uint32 } field to the stream . * / <nl> - public void writeUInt32NoTag ( final int value ) throws IOException { <nl> - writeRawVarint32 ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Write an enum field to the stream . Caller is responsible <nl> - * for converting the enum value to its numeric value . <nl> - * / <nl> - public void writeEnumNoTag ( final int value ) throws IOException { <nl> - writeRawVarint32 ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code sfixed32 } field to the stream . * / <nl> - public void writeSFixed32NoTag ( final int value ) throws IOException { <nl> - writeRawLittleEndian32 ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code sfixed64 } field to the stream . * / <nl> - public void writeSFixed64NoTag ( final long value ) throws IOException { <nl> - writeRawLittleEndian64 ( value ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code sint32 } field to the stream . * / <nl> - public void writeSInt32NoTag ( final int value ) throws IOException { <nl> - writeRawVarint32 ( encodeZigZag32 ( value ) ) ; <nl> - } <nl> - <nl> - / * * Write an { @ code sint64 } field to the stream . * / <nl> - public void writeSInt64NoTag ( final long value ) throws IOException { <nl> - writeRawVarint64 ( encodeZigZag64 ( value ) ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code double } field , including tag . <nl> - * / <nl> - public static int computeDoubleSize ( final int fieldNumber , <nl> - final double value ) { <nl> - return computeTagSize ( fieldNumber ) + computeDoubleSizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code float } field , including tag . <nl> - * / <nl> - public static int computeFloatSize ( final int fieldNumber , final float value ) { <nl> - return computeTagSize ( fieldNumber ) + computeFloatSizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code uint64 } field , including tag . <nl> - * / <nl> - public static int computeUInt64Size ( final int fieldNumber , final long value ) { <nl> - return computeTagSize ( fieldNumber ) + computeUInt64SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code int64 } field , including tag . <nl> - * / <nl> - public static int computeInt64Size ( final int fieldNumber , final long value ) { <nl> - return computeTagSize ( fieldNumber ) + computeInt64SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code int32 } field , including tag . <nl> - * / <nl> - public static int computeInt32Size ( final int fieldNumber , final int value ) { <nl> - return computeTagSize ( fieldNumber ) + computeInt32SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code fixed64 } field , including tag . <nl> - * / <nl> - public static int computeFixed64Size ( final int fieldNumber , <nl> - final long value ) { <nl> - return computeTagSize ( fieldNumber ) + computeFixed64SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code fixed32 } field , including tag . <nl> - * / <nl> - public static int computeFixed32Size ( final int fieldNumber , <nl> - final int value ) { <nl> - return computeTagSize ( fieldNumber ) + computeFixed32SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code bool } field , including tag . <nl> - * / <nl> - public static int computeBoolSize ( final int fieldNumber , <nl> - final boolean value ) { <nl> - return computeTagSize ( fieldNumber ) + computeBoolSizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code string } field , including tag . <nl> - * / <nl> - public static int computeStringSize ( final int fieldNumber , <nl> - final String value ) { <nl> - return computeTagSize ( fieldNumber ) + computeStringSizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code group } field , including tag . <nl> - * / <nl> - public static int computeGroupSize ( final int fieldNumber , <nl> - final MessageNano value ) { <nl> - return computeTagSize ( fieldNumber ) * 2 + computeGroupSizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * embedded message field , including tag . <nl> - * / <nl> - public static int computeMessageSize ( final int fieldNumber , <nl> - final MessageNano value ) { <nl> - return computeTagSize ( fieldNumber ) + computeMessageSizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code bytes } field , including tag . <nl> - * / <nl> - public static int computeBytesSize ( final int fieldNumber , <nl> - final byte [ ] value ) { <nl> - return computeTagSize ( fieldNumber ) + computeBytesSizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code uint32 } field , including tag . <nl> - * / <nl> - public static int computeUInt32Size ( final int fieldNumber , final int value ) { <nl> - return computeTagSize ( fieldNumber ) + computeUInt32SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * enum field , including tag . Caller is responsible for converting the <nl> - * enum value to its numeric value . <nl> - * / <nl> - public static int computeEnumSize ( final int fieldNumber , final int value ) { <nl> - return computeTagSize ( fieldNumber ) + computeEnumSizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code sfixed32 } field , including tag . <nl> - * / <nl> - public static int computeSFixed32Size ( final int fieldNumber , <nl> - final int value ) { <nl> - return computeTagSize ( fieldNumber ) + computeSFixed32SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code sfixed64 } field , including tag . <nl> - * / <nl> - public static int computeSFixed64Size ( final int fieldNumber , <nl> - final long value ) { <nl> - return computeTagSize ( fieldNumber ) + computeSFixed64SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code sint32 } field , including tag . <nl> - * / <nl> - public static int computeSInt32Size ( final int fieldNumber , final int value ) { <nl> - return computeTagSize ( fieldNumber ) + computeSInt32SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code sint64 } field , including tag . <nl> - * / <nl> - public static int computeSInt64Size ( final int fieldNumber , final long value ) { <nl> - return computeTagSize ( fieldNumber ) + computeSInt64SizeNoTag ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * MessageSet extension to the stream . For historical reasons , <nl> - * the wire format differs from normal fields . <nl> - * / <nl> - / / public static int computeMessageSetExtensionSize ( <nl> - / / final int fieldNumber , final MessageMicro value ) { <nl> - / / return computeTagSize ( WireFormatMicro . MESSAGE_SET_ITEM ) * 2 + <nl> - / / computeUInt32Size ( WireFormatMicro . MESSAGE_SET_TYPE_ID , fieldNumber ) + <nl> - / / computeMessageSize ( WireFormatMicro . MESSAGE_SET_MESSAGE , value ) ; <nl> - / / } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * unparsed MessageSet extension field to the stream . For <nl> - * historical reasons , the wire format differs from normal fields . <nl> - * / <nl> - / / public static int computeRawMessageSetExtensionSize ( <nl> - / / final int fieldNumber , final ByteStringMicro value ) { <nl> - / / return computeTagSize ( WireFormatMicro . MESSAGE_SET_ITEM ) * 2 + <nl> - / / computeUInt32Size ( WireFormatMicro . MESSAGE_SET_TYPE_ID , fieldNumber ) + <nl> - / / computeBytesSize ( WireFormatMicro . MESSAGE_SET_MESSAGE , value ) ; <nl> - / / } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code double } field , including tag . <nl> - * / <nl> - public static int computeDoubleSizeNoTag ( final double value ) { <nl> - return LITTLE_ENDIAN_64_SIZE ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code float } field , including tag . <nl> - * / <nl> - public static int computeFloatSizeNoTag ( final float value ) { <nl> - return LITTLE_ENDIAN_32_SIZE ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code uint64 } field , including tag . <nl> - * / <nl> - public static int computeUInt64SizeNoTag ( final long value ) { <nl> - return computeRawVarint64Size ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code int64 } field , including tag . <nl> - * / <nl> - public static int computeInt64SizeNoTag ( final long value ) { <nl> - return computeRawVarint64Size ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code int32 } field , including tag . <nl> - * / <nl> - public static int computeInt32SizeNoTag ( final int value ) { <nl> - if ( value > = 0 ) { <nl> - return computeRawVarint32Size ( value ) ; <nl> - } else { <nl> - / / Must sign - extend . <nl> - return 10 ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code fixed64 } field . <nl> - * / <nl> - public static int computeFixed64SizeNoTag ( final long value ) { <nl> - return LITTLE_ENDIAN_64_SIZE ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code fixed32 } field . <nl> - * / <nl> - public static int computeFixed32SizeNoTag ( final int value ) { <nl> - return LITTLE_ENDIAN_32_SIZE ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code bool } field . <nl> - * / <nl> - public static int computeBoolSizeNoTag ( final boolean value ) { <nl> - return 1 ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code string } field . <nl> - * / <nl> - public static int computeStringSizeNoTag ( final String value ) { <nl> - final int length = encodedLength ( value ) ; <nl> - return computeRawVarint32Size ( length ) + length ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code group } field . <nl> - * / <nl> - public static int computeGroupSizeNoTag ( final MessageNano value ) { <nl> - return value . getSerializedSize ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an embedded <nl> - * message field . <nl> - * / <nl> - public static int computeMessageSizeNoTag ( final MessageNano value ) { <nl> - final int size = value . getSerializedSize ( ) ; <nl> - return computeRawVarint32Size ( size ) + size ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code bytes } field . <nl> - * / <nl> - public static int computeBytesSizeNoTag ( final byte [ ] value ) { <nl> - return computeRawVarint32Size ( value . length ) + value . length ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a <nl> - * { @ code uint32 } field . <nl> - * / <nl> - public static int computeUInt32SizeNoTag ( final int value ) { <nl> - return computeRawVarint32Size ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an enum field . <nl> - * Caller is responsible for converting the enum value to its numeric value . <nl> - * / <nl> - public static int computeEnumSizeNoTag ( final int value ) { <nl> - return computeRawVarint32Size ( value ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code sfixed32 } field . <nl> - * / <nl> - public static int computeSFixed32SizeNoTag ( final int value ) { <nl> - return LITTLE_ENDIAN_32_SIZE ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code sfixed64 } field . <nl> - * / <nl> - public static int computeSFixed64SizeNoTag ( final long value ) { <nl> - return LITTLE_ENDIAN_64_SIZE ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code sint32 } field . <nl> - * / <nl> - public static int computeSInt32SizeNoTag ( final int value ) { <nl> - return computeRawVarint32Size ( encodeZigZag32 ( value ) ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode an <nl> - * { @ code sint64 } field . <nl> - * / <nl> - public static int computeSInt64SizeNoTag ( final long value ) { <nl> - return computeRawVarint64Size ( encodeZigZag64 ( value ) ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - / * * <nl> - * If writing to a flat array , return the space left in the array . <nl> - * Otherwise , throws { @ code UnsupportedOperationException } . <nl> - * / <nl> - public int spaceLeft ( ) { <nl> - return buffer . remaining ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Verifies that { @ link # spaceLeft ( ) } returns zero . It ' s common to create <nl> - * a byte array that is exactly big enough to hold a message , then write to <nl> - * it with a { @ code CodedOutputStream } . Calling { @ code checkNoSpaceLeft ( ) } <nl> - * after writing verifies that the message was actually as big as expected , <nl> - * which can help catch bugs . <nl> - * / <nl> - public void checkNoSpaceLeft ( ) { <nl> - if ( spaceLeft ( ) ! = 0 ) { <nl> - throw new IllegalStateException ( <nl> - " Did not write as much data as expected . " ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Returns the position within the internal buffer . <nl> - * / <nl> - public int position ( ) { <nl> - return buffer . position ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Resets the position within the internal buffer to zero . <nl> - * <nl> - * @ see # position <nl> - * @ see # spaceLeft <nl> - * / <nl> - public void reset ( ) { <nl> - buffer . clear ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * If you create a CodedOutputStream around a simple flat array , you must <nl> - * not attempt to write more bytes than the array has space . Otherwise , <nl> - * this exception will be thrown . <nl> - * / <nl> - public static class OutOfSpaceException extends IOException { <nl> - private static final long serialVersionUID = - 6947486886997889499L ; <nl> - <nl> - OutOfSpaceException ( int position , int limit ) { <nl> - super ( " CodedOutputStream was writing to a flat byte array and ran " + <nl> - " out of space ( pos " + position + " limit " + limit + " ) . " ) ; <nl> - } <nl> - } <nl> - <nl> - / * * Write a single byte . * / <nl> - public void writeRawByte ( final byte value ) throws IOException { <nl> - if ( ! buffer . hasRemaining ( ) ) { <nl> - / / We ' re writing to a single buffer . <nl> - throw new OutOfSpaceException ( buffer . position ( ) , buffer . limit ( ) ) ; <nl> - } <nl> - <nl> - buffer . put ( value ) ; <nl> - } <nl> - <nl> - / * * Write a single byte , represented by an integer value . * / <nl> - public void writeRawByte ( final int value ) throws IOException { <nl> - writeRawByte ( ( byte ) value ) ; <nl> - } <nl> - <nl> - / * * Write an array of bytes . * / <nl> - public void writeRawBytes ( final byte [ ] value ) throws IOException { <nl> - writeRawBytes ( value , 0 , value . length ) ; <nl> - } <nl> - <nl> - / * * Write part of an array of bytes . * / <nl> - public void writeRawBytes ( final byte [ ] value , int offset , int length ) <nl> - throws IOException { <nl> - if ( buffer . remaining ( ) > = length ) { <nl> - buffer . put ( value , offset , length ) ; <nl> - } else { <nl> - / / We ' re writing to a single buffer . <nl> - throw new OutOfSpaceException ( buffer . position ( ) , buffer . limit ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - / * * Encode and write a tag . * / <nl> - public void writeTag ( final int fieldNumber , final int wireType ) <nl> - throws IOException { <nl> - writeRawVarint32 ( WireFormatNano . makeTag ( fieldNumber , wireType ) ) ; <nl> - } <nl> - <nl> - / * * Compute the number of bytes that would be needed to encode a tag . * / <nl> - public static int computeTagSize ( final int fieldNumber ) { <nl> - return computeRawVarint32Size ( WireFormatNano . makeTag ( fieldNumber , 0 ) ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Encode and write a varint . { @ code value } is treated as <nl> - * unsigned , so it won ' t be sign - extended if negative . <nl> - * / <nl> - public void writeRawVarint32 ( int value ) throws IOException { <nl> - while ( true ) { <nl> - if ( ( value & ~ 0x7F ) = = 0 ) { <nl> - writeRawByte ( value ) ; <nl> - return ; <nl> - } else { <nl> - writeRawByte ( ( value & 0x7F ) | 0x80 ) ; <nl> - value > > > = 7 ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Compute the number of bytes that would be needed to encode a varint . <nl> - * { @ code value } is treated as unsigned , so it won ' t be sign - extended if <nl> - * negative . <nl> - * / <nl> - public static int computeRawVarint32Size ( final int value ) { <nl> - if ( ( value & ( 0xffffffff < < 7 ) ) = = 0 ) return 1 ; <nl> - if ( ( value & ( 0xffffffff < < 14 ) ) = = 0 ) return 2 ; <nl> - if ( ( value & ( 0xffffffff < < 21 ) ) = = 0 ) return 3 ; <nl> - if ( ( value & ( 0xffffffff < < 28 ) ) = = 0 ) return 4 ; <nl> - return 5 ; <nl> - } <nl> - <nl> - / * * Encode and write a varint . * / <nl> - public void writeRawVarint64 ( long value ) throws IOException { <nl> - while ( true ) { <nl> - if ( ( value & ~ 0x7FL ) = = 0 ) { <nl> - writeRawByte ( ( int ) value ) ; <nl> - return ; <nl> - } else { <nl> - writeRawByte ( ( ( int ) value & 0x7F ) | 0x80 ) ; <nl> - value > > > = 7 ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / * * Compute the number of bytes that would be needed to encode a varint . * / <nl> - public static int computeRawVarint64Size ( final long value ) { <nl> - if ( ( value & ( 0xffffffffffffffffL < < 7 ) ) = = 0 ) return 1 ; <nl> - if ( ( value & ( 0xffffffffffffffffL < < 14 ) ) = = 0 ) return 2 ; <nl> - if ( ( value & ( 0xffffffffffffffffL < < 21 ) ) = = 0 ) return 3 ; <nl> - if ( ( value & ( 0xffffffffffffffffL < < 28 ) ) = = 0 ) return 4 ; <nl> - if ( ( value & ( 0xffffffffffffffffL < < 35 ) ) = = 0 ) return 5 ; <nl> - if ( ( value & ( 0xffffffffffffffffL < < 42 ) ) = = 0 ) return 6 ; <nl> - if ( ( value & ( 0xffffffffffffffffL < < 49 ) ) = = 0 ) return 7 ; <nl> - if ( ( value & ( 0xffffffffffffffffL < < 56 ) ) = = 0 ) return 8 ; <nl> - if ( ( value & ( 0xffffffffffffffffL < < 63 ) ) = = 0 ) return 9 ; <nl> - return 10 ; <nl> - } <nl> - <nl> - / * * Write a little - endian 32 - bit integer . * / <nl> - public void writeRawLittleEndian32 ( final int value ) throws IOException { <nl> - if ( buffer . remaining ( ) < 4 ) { <nl> - throw new OutOfSpaceException ( buffer . position ( ) , buffer . limit ( ) ) ; <nl> - } <nl> - buffer . putInt ( value ) ; <nl> - } <nl> - <nl> - public static final int LITTLE_ENDIAN_32_SIZE = 4 ; <nl> - <nl> - / * * Write a little - endian 64 - bit integer . * / <nl> - public void writeRawLittleEndian64 ( final long value ) throws IOException { <nl> - if ( buffer . remaining ( ) < 8 ) { <nl> - throw new OutOfSpaceException ( buffer . position ( ) , buffer . limit ( ) ) ; <nl> - } <nl> - buffer . putLong ( value ) ; <nl> - } <nl> - <nl> - public static final int LITTLE_ENDIAN_64_SIZE = 8 ; <nl> - <nl> - / * * <nl> - * Encode a ZigZag - encoded 32 - bit value . ZigZag encodes signed integers <nl> - * into values that can be efficiently encoded with varint . ( Otherwise , <nl> - * negative values must be sign - extended to 64 bits to be varint encoded , <nl> - * thus always taking 10 bytes on the wire . ) <nl> - * <nl> - * @ param n A signed 32 - bit integer . <nl> - * @ return An unsigned 32 - bit integer , stored in a signed int because <nl> - * Java has no explicit unsigned support . <nl> - * / <nl> - public static int encodeZigZag32 ( final int n ) { <nl> - / / Note : the right - shift must be arithmetic <nl> - return ( n < < 1 ) ^ ( n > > 31 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Encode a ZigZag - encoded 64 - bit value . ZigZag encodes signed integers <nl> - * into values that can be efficiently encoded with varint . ( Otherwise , <nl> - * negative values must be sign - extended to 64 bits to be varint encoded , <nl> - * thus always taking 10 bytes on the wire . ) <nl> - * <nl> - * @ param n A signed 64 - bit integer . <nl> - * @ return An unsigned 64 - bit integer , stored in a signed int because <nl> - * Java has no explicit unsigned support . <nl> - * / <nl> - public static long encodeZigZag64 ( final long n ) { <nl> - / / Note : the right - shift must be arithmetic <nl> - return ( n < < 1 ) ^ ( n > > 63 ) ; <nl> - } <nl> - <nl> - static int computeFieldSize ( int number , int type , Object object ) { <nl> - switch ( type ) { <nl> - case InternalNano . TYPE_BOOL : <nl> - return computeBoolSize ( number , ( Boolean ) object ) ; <nl> - case InternalNano . TYPE_BYTES : <nl> - return computeBytesSize ( number , ( byte [ ] ) object ) ; <nl> - case InternalNano . TYPE_STRING : <nl> - return computeStringSize ( number , ( String ) object ) ; <nl> - case InternalNano . TYPE_FLOAT : <nl> - return computeFloatSize ( number , ( Float ) object ) ; <nl> - case InternalNano . TYPE_DOUBLE : <nl> - return computeDoubleSize ( number , ( Double ) object ) ; <nl> - case InternalNano . TYPE_ENUM : <nl> - return computeEnumSize ( number , ( Integer ) object ) ; <nl> - case InternalNano . TYPE_FIXED32 : <nl> - return computeFixed32Size ( number , ( Integer ) object ) ; <nl> - case InternalNano . TYPE_INT32 : <nl> - return computeInt32Size ( number , ( Integer ) object ) ; <nl> - case InternalNano . TYPE_UINT32 : <nl> - return computeUInt32Size ( number , ( Integer ) object ) ; <nl> - case InternalNano . TYPE_SINT32 : <nl> - return computeSInt32Size ( number , ( Integer ) object ) ; <nl> - case InternalNano . TYPE_SFIXED32 : <nl> - return computeSFixed32Size ( number , ( Integer ) object ) ; <nl> - case InternalNano . TYPE_INT64 : <nl> - return computeInt64Size ( number , ( Long ) object ) ; <nl> - case InternalNano . TYPE_UINT64 : <nl> - return computeUInt64Size ( number , ( Long ) object ) ; <nl> - case InternalNano . TYPE_SINT64 : <nl> - return computeSInt64Size ( number , ( Long ) object ) ; <nl> - case InternalNano . TYPE_FIXED64 : <nl> - return computeFixed64Size ( number , ( Long ) object ) ; <nl> - case InternalNano . TYPE_SFIXED64 : <nl> - return computeSFixed64Size ( number , ( Long ) object ) ; <nl> - case InternalNano . TYPE_MESSAGE : <nl> - return computeMessageSize ( number , ( MessageNano ) object ) ; <nl> - case InternalNano . TYPE_GROUP : <nl> - return computeGroupSize ( number , ( MessageNano ) object ) ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unknown type : " + type ) ; <nl> - } <nl> - } <nl> - <nl> - void writeField ( int number , int type , Object value ) <nl> - throws IOException { <nl> - switch ( type ) { <nl> - case InternalNano . TYPE_DOUBLE : <nl> - Double doubleValue = ( Double ) value ; <nl> - writeDouble ( number , doubleValue ) ; <nl> - break ; <nl> - case InternalNano . TYPE_FLOAT : <nl> - Float floatValue = ( Float ) value ; <nl> - writeFloat ( number , floatValue ) ; <nl> - break ; <nl> - case InternalNano . TYPE_INT64 : <nl> - Long int64Value = ( Long ) value ; <nl> - writeInt64 ( number , int64Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_UINT64 : <nl> - Long uint64Value = ( Long ) value ; <nl> - writeUInt64 ( number , uint64Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_INT32 : <nl> - Integer int32Value = ( Integer ) value ; <nl> - writeInt32 ( number , int32Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_FIXED64 : <nl> - Long fixed64Value = ( Long ) value ; <nl> - writeFixed64 ( number , fixed64Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_FIXED32 : <nl> - Integer fixed32Value = ( Integer ) value ; <nl> - writeFixed32 ( number , fixed32Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_BOOL : <nl> - Boolean boolValue = ( Boolean ) value ; <nl> - writeBool ( number , boolValue ) ; <nl> - break ; <nl> - case InternalNano . TYPE_STRING : <nl> - String stringValue = ( String ) value ; <nl> - writeString ( number , stringValue ) ; <nl> - break ; <nl> - case InternalNano . TYPE_BYTES : <nl> - byte [ ] bytesValue = ( byte [ ] ) value ; <nl> - writeBytes ( number , bytesValue ) ; <nl> - break ; <nl> - case InternalNano . TYPE_UINT32 : <nl> - Integer uint32Value = ( Integer ) value ; <nl> - writeUInt32 ( number , uint32Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_ENUM : <nl> - Integer enumValue = ( Integer ) value ; <nl> - writeEnum ( number , enumValue ) ; <nl> - break ; <nl> - case InternalNano . TYPE_SFIXED32 : <nl> - Integer sfixed32Value = ( Integer ) value ; <nl> - writeSFixed32 ( number , sfixed32Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_SFIXED64 : <nl> - Long sfixed64Value = ( Long ) value ; <nl> - writeSFixed64 ( number , sfixed64Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_SINT32 : <nl> - Integer sint32Value = ( Integer ) value ; <nl> - writeSInt32 ( number , sint32Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_SINT64 : <nl> - Long sint64Value = ( Long ) value ; <nl> - writeSInt64 ( number , sint64Value ) ; <nl> - break ; <nl> - case InternalNano . TYPE_MESSAGE : <nl> - MessageNano messageValue = ( MessageNano ) value ; <nl> - writeMessage ( number , messageValue ) ; <nl> - break ; <nl> - case InternalNano . TYPE_GROUP : <nl> - MessageNano groupValue = ( MessageNano ) value ; <nl> - writeGroup ( number , groupValue ) ; <nl> - break ; <nl> - default : <nl> - throw new IOException ( " Unknown type : " + type ) ; <nl> - } <nl> - } <nl> - <nl> - } <nl> deleted file mode 100644 <nl> index 87973d76f0 . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / ExtendableMessageNano . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - <nl> - / * * <nl> - * Base class of those Protocol Buffer messages that need to store unknown fields , <nl> - * such as extensions . <nl> - * / <nl> - public abstract class ExtendableMessageNano < M extends ExtendableMessageNano < M > > <nl> - extends MessageNano { <nl> - / * * <nl> - * A container for fields unknown to the message , including extensions . Extension fields can <nl> - * can be accessed through the { @ link # getExtension } and { @ link # setExtension } methods . <nl> - * / <nl> - protected FieldArray unknownFieldData ; <nl> - <nl> - @ Override <nl> - protected int computeSerializedSize ( ) { <nl> - int size = 0 ; <nl> - if ( unknownFieldData ! = null ) { <nl> - for ( int i = 0 ; i < unknownFieldData . size ( ) ; i + + ) { <nl> - FieldData field = unknownFieldData . dataAt ( i ) ; <nl> - size + = field . computeSerializedSize ( ) ; <nl> - } <nl> - } <nl> - return size ; <nl> - } <nl> - <nl> - @ Override <nl> - public void writeTo ( CodedOutputByteBufferNano output ) throws IOException { <nl> - if ( unknownFieldData = = null ) { <nl> - return ; <nl> - } <nl> - for ( int i = 0 ; i < unknownFieldData . size ( ) ; i + + ) { <nl> - FieldData field = unknownFieldData . dataAt ( i ) ; <nl> - field . writeTo ( output ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Checks if there is a value stored for the specified extension in this <nl> - * message . <nl> - * / <nl> - public final boolean hasExtension ( Extension < M , ? > extension ) { <nl> - if ( unknownFieldData = = null ) { <nl> - return false ; <nl> - } <nl> - FieldData field = unknownFieldData . get ( WireFormatNano . getTagFieldNumber ( extension . tag ) ) ; <nl> - return field ! = null ; <nl> - } <nl> - <nl> - / * * <nl> - * Gets the value stored in the specified extension of this message . <nl> - * / <nl> - public final < T > T getExtension ( Extension < M , T > extension ) { <nl> - if ( unknownFieldData = = null ) { <nl> - return null ; <nl> - } <nl> - FieldData field = unknownFieldData . get ( WireFormatNano . getTagFieldNumber ( extension . tag ) ) ; <nl> - return field = = null ? null : field . getValue ( extension ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Sets the value of the specified extension of this message . <nl> - * / <nl> - public final < T > M setExtension ( Extension < M , T > extension , T value ) { <nl> - int fieldNumber = WireFormatNano . getTagFieldNumber ( extension . tag ) ; <nl> - if ( value = = null ) { <nl> - if ( unknownFieldData ! = null ) { <nl> - unknownFieldData . remove ( fieldNumber ) ; <nl> - if ( unknownFieldData . isEmpty ( ) ) { <nl> - unknownFieldData = null ; <nl> - } <nl> - } <nl> - } else { <nl> - FieldData field = null ; <nl> - if ( unknownFieldData = = null ) { <nl> - unknownFieldData = new FieldArray ( ) ; <nl> - } else { <nl> - field = unknownFieldData . get ( fieldNumber ) ; <nl> - } <nl> - if ( field = = null ) { <nl> - unknownFieldData . put ( fieldNumber , new FieldData ( extension , value ) ) ; <nl> - } else { <nl> - field . setValue ( extension , value ) ; <nl> - } <nl> - } <nl> - <nl> - @ SuppressWarnings ( " unchecked " ) / / Generated code should guarantee type safety <nl> - M typedThis = ( M ) this ; <nl> - return typedThis ; <nl> - } <nl> - <nl> - / * * <nl> - * Stores the binary data of an unknown field . <nl> - * <nl> - * < p > Generated messages will call this for unknown fields if the store_unknown_fields <nl> - * option is on . <nl> - * <nl> - * < p > Note that the tag might be a end - group tag ( rather than the start of an unknown field ) in <nl> - * which case we do not want to add an unknown field entry . <nl> - * <nl> - * @ param input the input buffer . <nl> - * @ param tag the tag of the field . <nl> - <nl> - * @ return { @ literal true } unless the tag is an end - group tag . <nl> - * / <nl> - protected final boolean storeUnknownField ( CodedInputByteBufferNano input , int tag ) <nl> - throws IOException { <nl> - int startPos = input . getPosition ( ) ; <nl> - if ( ! input . skipField ( tag ) ) { <nl> - return false ; / / This wasn ' t an unknown field , it ' s an end - group tag . <nl> - } <nl> - int fieldNumber = WireFormatNano . getTagFieldNumber ( tag ) ; <nl> - int endPos = input . getPosition ( ) ; <nl> - byte [ ] bytes = input . getData ( startPos , endPos - startPos ) ; <nl> - UnknownFieldData unknownField = new UnknownFieldData ( tag , bytes ) ; <nl> - <nl> - FieldData field = null ; <nl> - if ( unknownFieldData = = null ) { <nl> - unknownFieldData = new FieldArray ( ) ; <nl> - } else { <nl> - field = unknownFieldData . get ( fieldNumber ) ; <nl> - } <nl> - if ( field = = null ) { <nl> - field = new FieldData ( ) ; <nl> - unknownFieldData . put ( fieldNumber , field ) ; <nl> - } <nl> - field . addUnknownField ( unknownField ) ; <nl> - return true ; <nl> - } <nl> - <nl> - @ Override <nl> - public M clone ( ) throws CloneNotSupportedException { <nl> - M cloned = ( M ) super . clone ( ) ; <nl> - InternalNano . cloneUnknownFieldData ( this , cloned ) ; <nl> - return cloned ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index c458f9b1fc . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / Extension . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - import java . lang . reflect . Array ; <nl> - import java . util . ArrayList ; <nl> - import java . util . List ; <nl> - <nl> - / * * <nl> - * Represents an extension . <nl> - * <nl> - * @ author bduff @ google . com ( Brian Duff ) <nl> - * @ author maxtroy @ google . com ( Max Cai ) <nl> - * @ param < M > the type of the extendable message this extension is for . <nl> - * @ param < T > the Java type of the extension ; see { @ link # clazz } . <nl> - * / <nl> - public class Extension < M extends ExtendableMessageNano < M > , T > { <nl> - <nl> - / * <nl> - * Because we typically only define message - typed extensions , the Extension class hierarchy is <nl> - * designed as follows , to allow a big amount of code in this file to be removed by ProGuard : <nl> - * <nl> - * Extension / / ready to use for message / group typed extensions <nl> - * Δ <nl> - * | <nl> - * PrimitiveExtension / / for primitive / enum typed extensions <nl> - * / <nl> - <nl> - public static final int TYPE_DOUBLE = InternalNano . TYPE_DOUBLE ; <nl> - public static final int TYPE_FLOAT = InternalNano . TYPE_FLOAT ; <nl> - public static final int TYPE_INT64 = InternalNano . TYPE_INT64 ; <nl> - public static final int TYPE_UINT64 = InternalNano . TYPE_UINT64 ; <nl> - public static final int TYPE_INT32 = InternalNano . TYPE_INT32 ; <nl> - public static final int TYPE_FIXED64 = InternalNano . TYPE_FIXED64 ; <nl> - public static final int TYPE_FIXED32 = InternalNano . TYPE_FIXED32 ; <nl> - public static final int TYPE_BOOL = InternalNano . TYPE_BOOL ; <nl> - public static final int TYPE_STRING = InternalNano . TYPE_STRING ; <nl> - public static final int TYPE_GROUP = InternalNano . TYPE_GROUP ; <nl> - public static final int TYPE_MESSAGE = InternalNano . TYPE_MESSAGE ; <nl> - public static final int TYPE_BYTES = InternalNano . TYPE_BYTES ; <nl> - public static final int TYPE_UINT32 = InternalNano . TYPE_UINT32 ; <nl> - public static final int TYPE_ENUM = InternalNano . TYPE_ENUM ; <nl> - public static final int TYPE_SFIXED32 = InternalNano . TYPE_SFIXED32 ; <nl> - public static final int TYPE_SFIXED64 = InternalNano . TYPE_SFIXED64 ; <nl> - public static final int TYPE_SINT32 = InternalNano . TYPE_SINT32 ; <nl> - public static final int TYPE_SINT64 = InternalNano . TYPE_SINT64 ; <nl> - <nl> - / * * <nl> - * Creates an { @ code Extension } of the given message type and tag number . <nl> - * Should be used by the generated code only . <nl> - * <nl> - * @ param type { @ link # TYPE_MESSAGE } or { @ link # TYPE_GROUP } <nl> - * @ deprecated use { @ link # createMessageTyped ( int , Class , long ) } instead . <nl> - * / <nl> - @ Deprecated <nl> - public static < M extends ExtendableMessageNano < M > , T extends MessageNano > <nl> - Extension < M , T > createMessageTyped ( int type , Class < T > clazz , int tag ) { <nl> - return new Extension < M , T > ( type , clazz , tag , false ) ; <nl> - } <nl> - <nl> - / / Note : these create . . . ( ) methods take a long for the tag parameter , <nl> - / / because tags are represented as unsigned ints , and these values exist <nl> - / / in generated code as long values . However , they can fit in 32 - bits , so <nl> - / / it ' s safe to cast them to int without loss of precision . <nl> - <nl> - / * * <nl> - * Creates an { @ code Extension } of the given message type and tag number . <nl> - * Should be used by the generated code only . <nl> - * <nl> - * @ param type { @ link # TYPE_MESSAGE } or { @ link # TYPE_GROUP } <nl> - * / <nl> - public static < M extends ExtendableMessageNano < M > , T extends MessageNano > <nl> - Extension < M , T > createMessageTyped ( int type , Class < T > clazz , long tag ) { <nl> - return new Extension < M , T > ( type , clazz , ( int ) tag , false ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Creates a repeated { @ code Extension } of the given message type and tag number . <nl> - * Should be used by the generated code only . <nl> - * <nl> - * @ param type { @ link # TYPE_MESSAGE } or { @ link # TYPE_GROUP } <nl> - * / <nl> - public static < M extends ExtendableMessageNano < M > , T extends MessageNano > <nl> - Extension < M , T [ ] > createRepeatedMessageTyped ( int type , Class < T [ ] > clazz , long tag ) { <nl> - return new Extension < M , T [ ] > ( type , clazz , ( int ) tag , true ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Creates an { @ code Extension } of the given primitive type and tag number . <nl> - * Should be used by the generated code only . <nl> - * <nl> - * @ param type one of { @ code TYPE_ * } , except { @ link # TYPE_MESSAGE } and { @ link # TYPE_GROUP } <nl> - * @ param clazz the boxed Java type of this extension <nl> - * / <nl> - public static < M extends ExtendableMessageNano < M > , T > <nl> - Extension < M , T > createPrimitiveTyped ( int type , Class < T > clazz , long tag ) { <nl> - return new PrimitiveExtension < M , T > ( type , clazz , ( int ) tag , false , 0 , 0 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Creates a repeated { @ code Extension } of the given primitive type and tag number . <nl> - * Should be used by the generated code only . <nl> - * <nl> - * @ param type one of { @ code TYPE_ * } , except { @ link # TYPE_MESSAGE } and { @ link # TYPE_GROUP } <nl> - * @ param clazz the Java array type of this extension , with an unboxed component type <nl> - * / <nl> - public static < M extends ExtendableMessageNano < M > , T > <nl> - Extension < M , T > createRepeatedPrimitiveTyped ( <nl> - int type , Class < T > clazz , long tag , long nonPackedTag , long packedTag ) { <nl> - return new PrimitiveExtension < M , T > ( type , clazz , ( int ) tag , true , <nl> - ( int ) nonPackedTag , ( int ) packedTag ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Protocol Buffer type of this extension ; one of the { @ code TYPE_ } constants . <nl> - * / <nl> - protected final int type ; <nl> - <nl> - / * * <nl> - * Java type of this extension . For a singular extension , this is the boxed Java type for the <nl> - * Protocol Buffer { @ link # type } ; for a repeated extension , this is an array type whose <nl> - * component type is the unboxed Java type for { @ link # type } . For example , for a singular <nl> - * { @ code int32 } / { @ link # TYPE_INT32 } extension , this equals { @ code Integer . class } ; for a <nl> - * repeated { @ code int32 } extension , this equals { @ code int [ ] . class } . <nl> - * / <nl> - protected final Class < T > clazz ; <nl> - <nl> - / * * <nl> - * Tag number of this extension . The data should be viewed as an unsigned 32 - bit value . <nl> - * / <nl> - public final int tag ; <nl> - <nl> - / * * <nl> - * Whether this extension is repeated . <nl> - * / <nl> - protected final boolean repeated ; <nl> - <nl> - private Extension ( int type , Class < T > clazz , int tag , boolean repeated ) { <nl> - this . type = type ; <nl> - this . clazz = clazz ; <nl> - this . tag = tag ; <nl> - this . repeated = repeated ; <nl> - } <nl> - <nl> - / * * <nl> - * Returns the value of this extension stored in the given list of unknown fields , or <nl> - * { @ code null } if no unknown fields matches this extension . <nl> - * <nl> - * @ param unknownFields a list of { @ link UnknownFieldData } . All of the elements must have a tag <nl> - * that matches this Extension ' s tag . <nl> - * <nl> - * / <nl> - final T getValueFrom ( List < UnknownFieldData > unknownFields ) { <nl> - if ( unknownFields = = null ) { <nl> - return null ; <nl> - } <nl> - return repeated ? getRepeatedValueFrom ( unknownFields ) : getSingularValueFrom ( unknownFields ) ; <nl> - } <nl> - <nl> - private T getRepeatedValueFrom ( List < UnknownFieldData > unknownFields ) { <nl> - / / For repeated extensions , read all matching unknown fields in their original order . <nl> - List < Object > resultList = new ArrayList < Object > ( ) ; <nl> - for ( int i = 0 ; i < unknownFields . size ( ) ; i + + ) { <nl> - UnknownFieldData data = unknownFields . get ( i ) ; <nl> - if ( data . bytes . length ! = 0 ) { <nl> - readDataInto ( data , resultList ) ; <nl> - } <nl> - } <nl> - <nl> - int resultSize = resultList . size ( ) ; <nl> - if ( resultSize = = 0 ) { <nl> - return null ; <nl> - } else { <nl> - T result = clazz . cast ( Array . newInstance ( clazz . getComponentType ( ) , resultSize ) ) ; <nl> - for ( int i = 0 ; i < resultSize ; i + + ) { <nl> - Array . set ( result , i , resultList . get ( i ) ) ; <nl> - } <nl> - return result ; <nl> - } <nl> - } <nl> - <nl> - private T getSingularValueFrom ( List < UnknownFieldData > unknownFields ) { <nl> - / / For singular extensions , get the last piece of data stored under this extension . <nl> - if ( unknownFields . isEmpty ( ) ) { <nl> - return null ; <nl> - } <nl> - UnknownFieldData lastData = unknownFields . get ( unknownFields . size ( ) - 1 ) ; <nl> - return clazz . cast ( readData ( CodedInputByteBufferNano . newInstance ( lastData . bytes ) ) ) ; <nl> - } <nl> - <nl> - protected Object readData ( CodedInputByteBufferNano input ) { <nl> - / / This implementation is for message / group extensions . <nl> - Class < ? > messageType = repeated ? clazz . getComponentType ( ) : clazz ; <nl> - try { <nl> - switch ( type ) { <nl> - case TYPE_GROUP : <nl> - MessageNano group = ( MessageNano ) messageType . newInstance ( ) ; <nl> - input . readGroup ( group , WireFormatNano . getTagFieldNumber ( tag ) ) ; <nl> - return group ; <nl> - case TYPE_MESSAGE : <nl> - MessageNano message = ( MessageNano ) messageType . newInstance ( ) ; <nl> - input . readMessage ( message ) ; <nl> - return message ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unknown type " + type ) ; <nl> - } <nl> - } catch ( InstantiationException e ) { <nl> - throw new IllegalArgumentException ( <nl> - " Error creating instance of class " + messageType , e ) ; <nl> - } catch ( IllegalAccessException e ) { <nl> - throw new IllegalArgumentException ( <nl> - " Error creating instance of class " + messageType , e ) ; <nl> - } catch ( IOException e ) { <nl> - throw new IllegalArgumentException ( " Error reading extension field " , e ) ; <nl> - } <nl> - } <nl> - <nl> - protected void readDataInto ( UnknownFieldData data , List < Object > resultList ) { <nl> - / / This implementation is for message / group extensions . <nl> - resultList . add ( readData ( CodedInputByteBufferNano . newInstance ( data . bytes ) ) ) ; <nl> - } <nl> - <nl> - void writeTo ( Object value , CodedOutputByteBufferNano output ) throws IOException { <nl> - if ( repeated ) { <nl> - writeRepeatedData ( value , output ) ; <nl> - } else { <nl> - writeSingularData ( value , output ) ; <nl> - } <nl> - } <nl> - <nl> - protected void writeSingularData ( Object value , CodedOutputByteBufferNano out ) { <nl> - / / This implementation is for message / group extensions . <nl> - try { <nl> - out . writeRawVarint32 ( tag ) ; <nl> - switch ( type ) { <nl> - case TYPE_GROUP : <nl> - MessageNano groupValue = ( MessageNano ) value ; <nl> - int fieldNumber = WireFormatNano . getTagFieldNumber ( tag ) ; <nl> - out . writeGroupNoTag ( groupValue ) ; <nl> - / / The endgroup tag must be included in the data payload . <nl> - out . writeTag ( fieldNumber , WireFormatNano . WIRETYPE_END_GROUP ) ; <nl> - break ; <nl> - case TYPE_MESSAGE : <nl> - MessageNano messageValue = ( MessageNano ) value ; <nl> - out . writeMessageNoTag ( messageValue ) ; <nl> - break ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unknown type " + type ) ; <nl> - } <nl> - } catch ( IOException e ) { <nl> - / / Should not happen <nl> - throw new IllegalStateException ( e ) ; <nl> - } <nl> - } <nl> - <nl> - protected void writeRepeatedData ( Object array , CodedOutputByteBufferNano output ) { <nl> - / / This implementation is for non - packed extensions . <nl> - int arrayLength = Array . getLength ( array ) ; <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - Object element = Array . get ( array , i ) ; <nl> - if ( element ! = null ) { <nl> - writeSingularData ( element , output ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - int computeSerializedSize ( Object value ) { <nl> - if ( repeated ) { <nl> - return computeRepeatedSerializedSize ( value ) ; <nl> - } else { <nl> - return computeSingularSerializedSize ( value ) ; <nl> - } <nl> - } <nl> - <nl> - protected int computeRepeatedSerializedSize ( Object array ) { <nl> - / / This implementation is for non - packed extensions . <nl> - int size = 0 ; <nl> - int arrayLength = Array . getLength ( array ) ; <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - Object element = Array . get ( array , i ) ; <nl> - if ( element ! = null ) { <nl> - size + = computeSingularSerializedSize ( Array . get ( array , i ) ) ; <nl> - } <nl> - } <nl> - return size ; <nl> - } <nl> - <nl> - protected int computeSingularSerializedSize ( Object value ) { <nl> - / / This implementation is for message / group extensions . <nl> - int fieldNumber = WireFormatNano . getTagFieldNumber ( tag ) ; <nl> - switch ( type ) { <nl> - case TYPE_GROUP : <nl> - MessageNano groupValue = ( MessageNano ) value ; <nl> - return CodedOutputByteBufferNano . computeGroupSize ( fieldNumber , groupValue ) ; <nl> - case TYPE_MESSAGE : <nl> - MessageNano messageValue = ( MessageNano ) value ; <nl> - return CodedOutputByteBufferNano . computeMessageSize ( fieldNumber , messageValue ) ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unknown type " + type ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Represents an extension of a primitive ( including enum ) type . If there is no primitive <nl> - * extensions , this subclass will be removable by ProGuard . <nl> - * / <nl> - private static class PrimitiveExtension < M extends ExtendableMessageNano < M > , T > <nl> - extends Extension < M , T > { <nl> - <nl> - / * * <nl> - * Tag of a piece of non - packed data from the wire compatible with this extension . <nl> - * / <nl> - private final int nonPackedTag ; <nl> - <nl> - / * * <nl> - * Tag of a piece of packed data from the wire compatible with this extension . <nl> - * 0 if the type of this extension is not packable . <nl> - * / <nl> - private final int packedTag ; <nl> - <nl> - public PrimitiveExtension ( int type , Class < T > clazz , int tag , boolean repeated , <nl> - int nonPackedTag , int packedTag ) { <nl> - super ( type , clazz , tag , repeated ) ; <nl> - this . nonPackedTag = nonPackedTag ; <nl> - this . packedTag = packedTag ; <nl> - } <nl> - <nl> - @ Override <nl> - protected Object readData ( CodedInputByteBufferNano input ) { <nl> - try { <nl> - return input . readPrimitiveField ( type ) ; <nl> - } catch ( IOException e ) { <nl> - throw new IllegalArgumentException ( " Error reading extension field " , e ) ; <nl> - } <nl> - } <nl> - <nl> - @ Override <nl> - protected void readDataInto ( UnknownFieldData data , List < Object > resultList ) { <nl> - / / This implementation is for primitive typed extensions , <nl> - / / which can read both packed and non - packed data . <nl> - if ( data . tag = = nonPackedTag ) { <nl> - resultList . add ( readData ( CodedInputByteBufferNano . newInstance ( data . bytes ) ) ) ; <nl> - } else { <nl> - CodedInputByteBufferNano buffer = <nl> - CodedInputByteBufferNano . newInstance ( data . bytes ) ; <nl> - try { <nl> - buffer . pushLimit ( buffer . readRawVarint32 ( ) ) ; / / length limit <nl> - } catch ( IOException e ) { <nl> - throw new IllegalArgumentException ( " Error reading extension field " , e ) ; <nl> - } <nl> - while ( ! buffer . isAtEnd ( ) ) { <nl> - resultList . add ( readData ( buffer ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - @ Override <nl> - protected final void writeSingularData ( Object value , CodedOutputByteBufferNano output ) { <nl> - try { <nl> - output . writeRawVarint32 ( tag ) ; <nl> - switch ( type ) { <nl> - case TYPE_DOUBLE : <nl> - Double doubleValue = ( Double ) value ; <nl> - output . writeDoubleNoTag ( doubleValue ) ; <nl> - break ; <nl> - case TYPE_FLOAT : <nl> - Float floatValue = ( Float ) value ; <nl> - output . writeFloatNoTag ( floatValue ) ; <nl> - break ; <nl> - case TYPE_INT64 : <nl> - Long int64Value = ( Long ) value ; <nl> - output . writeInt64NoTag ( int64Value ) ; <nl> - break ; <nl> - case TYPE_UINT64 : <nl> - Long uint64Value = ( Long ) value ; <nl> - output . writeUInt64NoTag ( uint64Value ) ; <nl> - break ; <nl> - case TYPE_INT32 : <nl> - Integer int32Value = ( Integer ) value ; <nl> - output . writeInt32NoTag ( int32Value ) ; <nl> - break ; <nl> - case TYPE_FIXED64 : <nl> - Long fixed64Value = ( Long ) value ; <nl> - output . writeFixed64NoTag ( fixed64Value ) ; <nl> - break ; <nl> - case TYPE_FIXED32 : <nl> - Integer fixed32Value = ( Integer ) value ; <nl> - output . writeFixed32NoTag ( fixed32Value ) ; <nl> - break ; <nl> - case TYPE_BOOL : <nl> - Boolean boolValue = ( Boolean ) value ; <nl> - output . writeBoolNoTag ( boolValue ) ; <nl> - break ; <nl> - case TYPE_STRING : <nl> - String stringValue = ( String ) value ; <nl> - output . writeStringNoTag ( stringValue ) ; <nl> - break ; <nl> - case TYPE_BYTES : <nl> - byte [ ] bytesValue = ( byte [ ] ) value ; <nl> - output . writeBytesNoTag ( bytesValue ) ; <nl> - break ; <nl> - case TYPE_UINT32 : <nl> - Integer uint32Value = ( Integer ) value ; <nl> - output . writeUInt32NoTag ( uint32Value ) ; <nl> - break ; <nl> - case TYPE_ENUM : <nl> - Integer enumValue = ( Integer ) value ; <nl> - output . writeEnumNoTag ( enumValue ) ; <nl> - break ; <nl> - case TYPE_SFIXED32 : <nl> - Integer sfixed32Value = ( Integer ) value ; <nl> - output . writeSFixed32NoTag ( sfixed32Value ) ; <nl> - break ; <nl> - case TYPE_SFIXED64 : <nl> - Long sfixed64Value = ( Long ) value ; <nl> - output . writeSFixed64NoTag ( sfixed64Value ) ; <nl> - break ; <nl> - case TYPE_SINT32 : <nl> - Integer sint32Value = ( Integer ) value ; <nl> - output . writeSInt32NoTag ( sint32Value ) ; <nl> - break ; <nl> - case TYPE_SINT64 : <nl> - Long sint64Value = ( Long ) value ; <nl> - output . writeSInt64NoTag ( sint64Value ) ; <nl> - break ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unknown type " + type ) ; <nl> - } <nl> - } catch ( IOException e ) { <nl> - / / Should not happen <nl> - throw new IllegalStateException ( e ) ; <nl> - } <nl> - } <nl> - <nl> - @ Override <nl> - protected void writeRepeatedData ( Object array , CodedOutputByteBufferNano output ) { <nl> - if ( tag = = nonPackedTag ) { <nl> - / / Use base implementation for non - packed data <nl> - super . writeRepeatedData ( array , output ) ; <nl> - } else if ( tag = = packedTag ) { <nl> - / / Packed . Note that the array element type is guaranteed to be primitive , so there <nl> - / / won ' t be any null elements , so no null check in this block . <nl> - int arrayLength = Array . getLength ( array ) ; <nl> - int dataSize = computePackedDataSize ( array ) ; <nl> - <nl> - try { <nl> - output . writeRawVarint32 ( tag ) ; <nl> - output . writeRawVarint32 ( dataSize ) ; <nl> - switch ( type ) { <nl> - case TYPE_BOOL : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeBoolNoTag ( Array . getBoolean ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_FIXED32 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeFixed32NoTag ( Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_SFIXED32 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeSFixed32NoTag ( Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_FLOAT : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeFloatNoTag ( Array . getFloat ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_FIXED64 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeFixed64NoTag ( Array . getLong ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_SFIXED64 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeSFixed64NoTag ( Array . getLong ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_DOUBLE : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeDoubleNoTag ( Array . getDouble ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_INT32 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeInt32NoTag ( Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_SINT32 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeSInt32NoTag ( Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_UINT32 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeUInt32NoTag ( Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_INT64 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeInt64NoTag ( Array . getLong ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_SINT64 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeSInt64NoTag ( Array . getLong ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_UINT64 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeUInt64NoTag ( Array . getLong ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_ENUM : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - output . writeEnumNoTag ( Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unpackable type " + type ) ; <nl> - } <nl> - } catch ( IOException e ) { <nl> - / / Should not happen . <nl> - throw new IllegalStateException ( e ) ; <nl> - } <nl> - } else { <nl> - throw new IllegalArgumentException ( " Unexpected repeated extension tag " + tag <nl> - + " , unequal to both non - packed variant " + nonPackedTag <nl> - + " and packed variant " + packedTag ) ; <nl> - } <nl> - } <nl> - <nl> - private int computePackedDataSize ( Object array ) { <nl> - int dataSize = 0 ; <nl> - int arrayLength = Array . getLength ( array ) ; <nl> - switch ( type ) { <nl> - case TYPE_BOOL : <nl> - / / Bools are stored as int32 but just as 0 or 1 , so 1 byte each . <nl> - dataSize = arrayLength ; <nl> - break ; <nl> - case TYPE_FIXED32 : <nl> - case TYPE_SFIXED32 : <nl> - case TYPE_FLOAT : <nl> - dataSize = arrayLength * CodedOutputByteBufferNano . LITTLE_ENDIAN_32_SIZE ; <nl> - break ; <nl> - case TYPE_FIXED64 : <nl> - case TYPE_SFIXED64 : <nl> - case TYPE_DOUBLE : <nl> - dataSize = arrayLength * CodedOutputByteBufferNano . LITTLE_ENDIAN_64_SIZE ; <nl> - break ; <nl> - case TYPE_INT32 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - dataSize + = CodedOutputByteBufferNano . computeInt32SizeNoTag ( <nl> - Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_SINT32 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - dataSize + = CodedOutputByteBufferNano . computeSInt32SizeNoTag ( <nl> - Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_UINT32 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - dataSize + = CodedOutputByteBufferNano . computeUInt32SizeNoTag ( <nl> - Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_INT64 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - dataSize + = CodedOutputByteBufferNano . computeInt64SizeNoTag ( <nl> - Array . getLong ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_SINT64 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - dataSize + = CodedOutputByteBufferNano . computeSInt64SizeNoTag ( <nl> - Array . getLong ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_UINT64 : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - dataSize + = CodedOutputByteBufferNano . computeUInt64SizeNoTag ( <nl> - Array . getLong ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - case TYPE_ENUM : <nl> - for ( int i = 0 ; i < arrayLength ; i + + ) { <nl> - dataSize + = CodedOutputByteBufferNano . computeEnumSizeNoTag ( <nl> - Array . getInt ( array , i ) ) ; <nl> - } <nl> - break ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unexpected non - packable type " + type ) ; <nl> - } <nl> - return dataSize ; <nl> - } <nl> - <nl> - @ Override <nl> - protected int computeRepeatedSerializedSize ( Object array ) { <nl> - if ( tag = = nonPackedTag ) { <nl> - / / Use base implementation for non - packed data <nl> - return super . computeRepeatedSerializedSize ( array ) ; <nl> - } else if ( tag = = packedTag ) { <nl> - / / Packed . <nl> - int dataSize = computePackedDataSize ( array ) ; <nl> - int payloadSize = <nl> - dataSize + CodedOutputByteBufferNano . computeRawVarint32Size ( dataSize ) ; <nl> - return payloadSize + CodedOutputByteBufferNano . computeRawVarint32Size ( tag ) ; <nl> - } else { <nl> - throw new IllegalArgumentException ( " Unexpected repeated extension tag " + tag <nl> - + " , unequal to both non - packed variant " + nonPackedTag <nl> - + " and packed variant " + packedTag ) ; <nl> - } <nl> - } <nl> - <nl> - @ Override <nl> - protected final int computeSingularSerializedSize ( Object value ) { <nl> - int fieldNumber = WireFormatNano . getTagFieldNumber ( tag ) ; <nl> - switch ( type ) { <nl> - case TYPE_DOUBLE : <nl> - Double doubleValue = ( Double ) value ; <nl> - return CodedOutputByteBufferNano . computeDoubleSize ( fieldNumber , doubleValue ) ; <nl> - case TYPE_FLOAT : <nl> - Float floatValue = ( Float ) value ; <nl> - return CodedOutputByteBufferNano . computeFloatSize ( fieldNumber , floatValue ) ; <nl> - case TYPE_INT64 : <nl> - Long int64Value = ( Long ) value ; <nl> - return CodedOutputByteBufferNano . computeInt64Size ( fieldNumber , int64Value ) ; <nl> - case TYPE_UINT64 : <nl> - Long uint64Value = ( Long ) value ; <nl> - return CodedOutputByteBufferNano . computeUInt64Size ( fieldNumber , uint64Value ) ; <nl> - case TYPE_INT32 : <nl> - Integer int32Value = ( Integer ) value ; <nl> - return CodedOutputByteBufferNano . computeInt32Size ( fieldNumber , int32Value ) ; <nl> - case TYPE_FIXED64 : <nl> - Long fixed64Value = ( Long ) value ; <nl> - return CodedOutputByteBufferNano . computeFixed64Size ( fieldNumber , fixed64Value ) ; <nl> - case TYPE_FIXED32 : <nl> - Integer fixed32Value = ( Integer ) value ; <nl> - return CodedOutputByteBufferNano . computeFixed32Size ( fieldNumber , fixed32Value ) ; <nl> - case TYPE_BOOL : <nl> - Boolean boolValue = ( Boolean ) value ; <nl> - return CodedOutputByteBufferNano . computeBoolSize ( fieldNumber , boolValue ) ; <nl> - case TYPE_STRING : <nl> - String stringValue = ( String ) value ; <nl> - return CodedOutputByteBufferNano . computeStringSize ( fieldNumber , stringValue ) ; <nl> - case TYPE_BYTES : <nl> - byte [ ] bytesValue = ( byte [ ] ) value ; <nl> - return CodedOutputByteBufferNano . computeBytesSize ( fieldNumber , bytesValue ) ; <nl> - case TYPE_UINT32 : <nl> - Integer uint32Value = ( Integer ) value ; <nl> - return CodedOutputByteBufferNano . computeUInt32Size ( fieldNumber , uint32Value ) ; <nl> - case TYPE_ENUM : <nl> - Integer enumValue = ( Integer ) value ; <nl> - return CodedOutputByteBufferNano . computeEnumSize ( fieldNumber , enumValue ) ; <nl> - case TYPE_SFIXED32 : <nl> - Integer sfixed32Value = ( Integer ) value ; <nl> - return CodedOutputByteBufferNano . computeSFixed32Size ( fieldNumber , <nl> - sfixed32Value ) ; <nl> - case TYPE_SFIXED64 : <nl> - Long sfixed64Value = ( Long ) value ; <nl> - return CodedOutputByteBufferNano . computeSFixed64Size ( fieldNumber , <nl> - sfixed64Value ) ; <nl> - case TYPE_SINT32 : <nl> - Integer sint32Value = ( Integer ) value ; <nl> - return CodedOutputByteBufferNano . computeSInt32Size ( fieldNumber , sint32Value ) ; <nl> - case TYPE_SINT64 : <nl> - Long sint64Value = ( Long ) value ; <nl> - return CodedOutputByteBufferNano . computeSInt64Size ( fieldNumber , sint64Value ) ; <nl> - default : <nl> - throw new IllegalArgumentException ( " Unknown type " + type ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index b49a97fa5a . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / FieldArray . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2014 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - <nl> - / * * <nl> - * A custom version of { @ code android . util . SparseArray } with the minimal API <nl> - * for storing { @ link FieldData } objects . <nl> - * <nl> - * < p > This class is an internal implementation detail of nano and should not <nl> - * be called directly by clients . <nl> - * <nl> - * Based on { @ code android . support . v4 . util . SpareArrayCompat } . <nl> - * / <nl> - public final class FieldArray implements Cloneable { <nl> - private static final FieldData DELETED = new FieldData ( ) ; <nl> - private boolean mGarbage = false ; <nl> - <nl> - private int [ ] mFieldNumbers ; <nl> - private FieldData [ ] mData ; <nl> - private int mSize ; <nl> - <nl> - / * * <nl> - * Creates a new FieldArray containing no fields . <nl> - * / <nl> - FieldArray ( ) { <nl> - this ( 10 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Creates a new FieldArray containing no mappings that will not <nl> - * require any additional memory allocation to store the specified <nl> - * number of mappings . <nl> - * / <nl> - FieldArray ( int initialCapacity ) { <nl> - initialCapacity = idealIntArraySize ( initialCapacity ) ; <nl> - mFieldNumbers = new int [ initialCapacity ] ; <nl> - mData = new FieldData [ initialCapacity ] ; <nl> - mSize = 0 ; <nl> - } <nl> - <nl> - / * * <nl> - * Gets the FieldData mapped from the specified fieldNumber , or < code > null < / code > <nl> - * if no such mapping has been made . <nl> - * / <nl> - FieldData get ( int fieldNumber ) { <nl> - int i = binarySearch ( fieldNumber ) ; <nl> - <nl> - if ( i < 0 | | mData [ i ] = = DELETED ) { <nl> - return null ; <nl> - } else { <nl> - return mData [ i ] ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Removes the data from the specified fieldNumber , if there was any . <nl> - * / <nl> - void remove ( int fieldNumber ) { <nl> - int i = binarySearch ( fieldNumber ) ; <nl> - <nl> - if ( i > = 0 & & mData [ i ] ! = DELETED ) { <nl> - mData [ i ] = DELETED ; <nl> - mGarbage = true ; <nl> - } <nl> - } <nl> - <nl> - private void gc ( ) { <nl> - int n = mSize ; <nl> - int o = 0 ; <nl> - int [ ] keys = mFieldNumbers ; <nl> - FieldData [ ] values = mData ; <nl> - <nl> - for ( int i = 0 ; i < n ; i + + ) { <nl> - FieldData val = values [ i ] ; <nl> - <nl> - if ( val ! = DELETED ) { <nl> - if ( i ! = o ) { <nl> - keys [ o ] = keys [ i ] ; <nl> - values [ o ] = val ; <nl> - values [ i ] = null ; <nl> - } <nl> - <nl> - o + + ; <nl> - } <nl> - } <nl> - <nl> - mGarbage = false ; <nl> - mSize = o ; <nl> - } <nl> - <nl> - / * * <nl> - * Adds a mapping from the specified fieldNumber to the specified data , <nl> - * replacing the previous mapping if there was one . <nl> - * / <nl> - void put ( int fieldNumber , FieldData data ) { <nl> - int i = binarySearch ( fieldNumber ) ; <nl> - <nl> - if ( i > = 0 ) { <nl> - mData [ i ] = data ; <nl> - } else { <nl> - i = ~ i ; <nl> - <nl> - if ( i < mSize & & mData [ i ] = = DELETED ) { <nl> - mFieldNumbers [ i ] = fieldNumber ; <nl> - mData [ i ] = data ; <nl> - return ; <nl> - } <nl> - <nl> - if ( mGarbage & & mSize > = mFieldNumbers . length ) { <nl> - gc ( ) ; <nl> - <nl> - / / Search again because indices may have changed . <nl> - i = ~ binarySearch ( fieldNumber ) ; <nl> - } <nl> - <nl> - if ( mSize > = mFieldNumbers . length ) { <nl> - int n = idealIntArraySize ( mSize + 1 ) ; <nl> - <nl> - int [ ] nkeys = new int [ n ] ; <nl> - FieldData [ ] nvalues = new FieldData [ n ] ; <nl> - <nl> - System . arraycopy ( mFieldNumbers , 0 , nkeys , 0 , mFieldNumbers . length ) ; <nl> - System . arraycopy ( mData , 0 , nvalues , 0 , mData . length ) ; <nl> - <nl> - mFieldNumbers = nkeys ; <nl> - mData = nvalues ; <nl> - } <nl> - <nl> - if ( mSize - i ! = 0 ) { <nl> - System . arraycopy ( mFieldNumbers , i , mFieldNumbers , i + 1 , mSize - i ) ; <nl> - System . arraycopy ( mData , i , mData , i + 1 , mSize - i ) ; <nl> - } <nl> - <nl> - mFieldNumbers [ i ] = fieldNumber ; <nl> - mData [ i ] = data ; <nl> - mSize + + ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Returns the number of key - value mappings that this FieldArray <nl> - * currently stores . <nl> - * / <nl> - int size ( ) { <nl> - if ( mGarbage ) { <nl> - gc ( ) ; <nl> - } <nl> - <nl> - return mSize ; <nl> - } <nl> - <nl> - public boolean isEmpty ( ) { <nl> - return size ( ) = = 0 ; <nl> - } <nl> - <nl> - / * * <nl> - * Given an index in the range < code > 0 . . . size ( ) - 1 < / code > , returns <nl> - * the value from the < code > index < / code > th key - value mapping that this <nl> - * FieldArray stores . <nl> - * / <nl> - FieldData dataAt ( int index ) { <nl> - if ( mGarbage ) { <nl> - gc ( ) ; <nl> - } <nl> - <nl> - return mData [ index ] ; <nl> - } <nl> - <nl> - @ Override <nl> - public boolean equals ( Object o ) { <nl> - if ( o = = this ) { <nl> - return true ; <nl> - } <nl> - if ( ! ( o instanceof FieldArray ) ) { <nl> - return false ; <nl> - } <nl> - <nl> - FieldArray other = ( FieldArray ) o ; <nl> - if ( size ( ) ! = other . size ( ) ) { / / size ( ) will call gc ( ) if necessary . <nl> - return false ; <nl> - } <nl> - return arrayEquals ( mFieldNumbers , other . mFieldNumbers , mSize ) & & <nl> - arrayEquals ( mData , other . mData , mSize ) ; <nl> - } <nl> - <nl> - @ Override <nl> - public int hashCode ( ) { <nl> - if ( mGarbage ) { <nl> - gc ( ) ; <nl> - } <nl> - int result = 17 ; <nl> - for ( int i = 0 ; i < mSize ; i + + ) { <nl> - result = 31 * result + mFieldNumbers [ i ] ; <nl> - result = 31 * result + mData [ i ] . hashCode ( ) ; <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - private int idealIntArraySize ( int need ) { <nl> - return idealByteArraySize ( need * 4 ) / 4 ; <nl> - } <nl> - <nl> - private int idealByteArraySize ( int need ) { <nl> - for ( int i = 4 ; i < 32 ; i + + ) <nl> - if ( need < = ( 1 < < i ) - 12 ) <nl> - return ( 1 < < i ) - 12 ; <nl> - <nl> - return need ; <nl> - } <nl> - <nl> - private int binarySearch ( int value ) { <nl> - int lo = 0 ; <nl> - int hi = mSize - 1 ; <nl> - <nl> - while ( lo < = hi ) { <nl> - int mid = ( lo + hi ) > > > 1 ; <nl> - int midVal = mFieldNumbers [ mid ] ; <nl> - <nl> - if ( midVal < value ) { <nl> - lo = mid + 1 ; <nl> - } else if ( midVal > value ) { <nl> - hi = mid - 1 ; <nl> - } else { <nl> - return mid ; / / value found <nl> - } <nl> - } <nl> - return ~ lo ; / / value not present <nl> - } <nl> - <nl> - private boolean arrayEquals ( int [ ] a , int [ ] b , int size ) { <nl> - for ( int i = 0 ; i < size ; i + + ) { <nl> - if ( a [ i ] ! = b [ i ] ) { <nl> - return false ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - private boolean arrayEquals ( FieldData [ ] a , FieldData [ ] b , int size ) { <nl> - for ( int i = 0 ; i < size ; i + + ) { <nl> - if ( ! a [ i ] . equals ( b [ i ] ) ) { <nl> - return false ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - @ Override <nl> - public final FieldArray clone ( ) { <nl> - / / Trigger GC so we compact and don ' t copy DELETED elements . <nl> - int size = size ( ) ; <nl> - FieldArray clone = new FieldArray ( size ) ; <nl> - System . arraycopy ( mFieldNumbers , 0 , clone . mFieldNumbers , 0 , size ) ; <nl> - for ( int i = 0 ; i < size ; i + + ) { <nl> - if ( mData [ i ] ! = null ) { <nl> - clone . mData [ i ] = mData [ i ] . clone ( ) ; <nl> - } <nl> - } <nl> - clone . mSize = size ; <nl> - return clone ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index ebebabc8e5 . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / FieldData . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2014 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - import java . util . ArrayList ; <nl> - import java . util . Arrays ; <nl> - import java . util . List ; <nl> - <nl> - / * * <nl> - * Stores unknown fields . These might be extensions or fields that the generated API doesn ' t <nl> - * know about yet . <nl> - * / <nl> - class FieldData implements Cloneable { <nl> - private Extension < ? , ? > cachedExtension ; <nl> - private Object value ; <nl> - / * * The serialised values for this object . Will be cleared if getValue is called * / <nl> - private List < UnknownFieldData > unknownFieldData ; <nl> - <nl> - < T > FieldData ( Extension < ? , T > extension , T newValue ) { <nl> - cachedExtension = extension ; <nl> - value = newValue ; <nl> - } <nl> - <nl> - FieldData ( ) { <nl> - unknownFieldData = new ArrayList < UnknownFieldData > ( ) ; <nl> - } <nl> - <nl> - void addUnknownField ( UnknownFieldData unknownField ) { <nl> - unknownFieldData . add ( unknownField ) ; <nl> - } <nl> - <nl> - UnknownFieldData getUnknownField ( int index ) { <nl> - if ( unknownFieldData = = null ) { <nl> - return null ; <nl> - } <nl> - if ( index < unknownFieldData . size ( ) ) { <nl> - return unknownFieldData . get ( index ) ; <nl> - } <nl> - return null ; <nl> - } <nl> - <nl> - int getUnknownFieldSize ( ) { <nl> - if ( unknownFieldData = = null ) { <nl> - return 0 ; <nl> - } <nl> - return unknownFieldData . size ( ) ; <nl> - } <nl> - <nl> - < T > T getValue ( Extension < ? , T > extension ) { <nl> - if ( value ! = null ) { <nl> - if ( cachedExtension ! = extension ) { / / Extension objects are singletons . <nl> - throw new IllegalStateException ( <nl> - " Tried to getExtension with a differernt Extension . " ) ; <nl> - } <nl> - } else { <nl> - cachedExtension = extension ; <nl> - value = extension . getValueFrom ( unknownFieldData ) ; <nl> - unknownFieldData = null ; <nl> - } <nl> - return ( T ) value ; <nl> - } <nl> - <nl> - < T > void setValue ( Extension < ? , T > extension , T newValue ) { <nl> - cachedExtension = extension ; <nl> - value = newValue ; <nl> - unknownFieldData = null ; <nl> - } <nl> - <nl> - int computeSerializedSize ( ) { <nl> - int size = 0 ; <nl> - if ( value ! = null ) { <nl> - size = cachedExtension . computeSerializedSize ( value ) ; <nl> - } else { <nl> - for ( UnknownFieldData unknownField : unknownFieldData ) { <nl> - size + = unknownField . computeSerializedSize ( ) ; <nl> - } <nl> - } <nl> - return size ; <nl> - } <nl> - <nl> - void writeTo ( CodedOutputByteBufferNano output ) throws IOException { <nl> - if ( value ! = null ) { <nl> - cachedExtension . writeTo ( value , output ) ; <nl> - } else { <nl> - for ( UnknownFieldData unknownField : unknownFieldData ) { <nl> - unknownField . writeTo ( output ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - @ Override <nl> - public boolean equals ( Object o ) { <nl> - if ( o = = this ) { <nl> - return true ; <nl> - } <nl> - if ( ! ( o instanceof FieldData ) ) { <nl> - return false ; <nl> - } <nl> - <nl> - FieldData other = ( FieldData ) o ; <nl> - if ( value ! = null & & other . value ! = null ) { <nl> - / / If both objects have deserialized values , compare those . <nl> - / / Since unknown fields are only compared if messages have generated equals methods <nl> - / / we know this will be a meaningful comparison ( not identity ) for all values . <nl> - if ( cachedExtension ! = other . cachedExtension ) { / / Extension objects are singletons . <nl> - return false ; <nl> - } <nl> - if ( ! cachedExtension . clazz . isArray ( ) ) { <nl> - / / Can ' t test ( ! cachedExtension . repeated ) due to ' bytes ' - > ' byte [ ] ' <nl> - return value . equals ( other . value ) ; <nl> - } <nl> - if ( value instanceof byte [ ] ) { <nl> - return Arrays . equals ( ( byte [ ] ) value , ( byte [ ] ) other . value ) ; <nl> - } else if ( value instanceof int [ ] ) { <nl> - return Arrays . equals ( ( int [ ] ) value , ( int [ ] ) other . value ) ; <nl> - } else if ( value instanceof long [ ] ) { <nl> - return Arrays . equals ( ( long [ ] ) value , ( long [ ] ) other . value ) ; <nl> - } else if ( value instanceof float [ ] ) { <nl> - return Arrays . equals ( ( float [ ] ) value , ( float [ ] ) other . value ) ; <nl> - } else if ( value instanceof double [ ] ) { <nl> - return Arrays . equals ( ( double [ ] ) value , ( double [ ] ) other . value ) ; <nl> - } else if ( value instanceof boolean [ ] ) { <nl> - return Arrays . equals ( ( boolean [ ] ) value , ( boolean [ ] ) other . value ) ; <nl> - } else { <nl> - return Arrays . deepEquals ( ( Object [ ] ) value , ( Object [ ] ) other . value ) ; <nl> - } <nl> - } <nl> - if ( unknownFieldData ! = null & & other . unknownFieldData ! = null ) { <nl> - / / If both objects have byte arrays compare those directly . <nl> - return unknownFieldData . equals ( other . unknownFieldData ) ; <nl> - } <nl> - try { <nl> - / / As a last resort , serialize and compare the resulting byte arrays . <nl> - return Arrays . equals ( toByteArray ( ) , other . toByteArray ( ) ) ; <nl> - } catch ( IOException e ) { <nl> - / / Should not happen . <nl> - throw new IllegalStateException ( e ) ; <nl> - } <nl> - } <nl> - <nl> - @ Override <nl> - public int hashCode ( ) { <nl> - int result = 17 ; <nl> - try { <nl> - / / The only way to generate a consistent hash is to use the serialized form . <nl> - result = 31 * result + Arrays . hashCode ( toByteArray ( ) ) ; <nl> - } catch ( IOException e ) { <nl> - / / Should not happen . <nl> - throw new IllegalStateException ( e ) ; <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - private byte [ ] toByteArray ( ) throws IOException { <nl> - byte [ ] result = new byte [ computeSerializedSize ( ) ] ; <nl> - CodedOutputByteBufferNano output = CodedOutputByteBufferNano . newInstance ( result ) ; <nl> - writeTo ( output ) ; <nl> - return result ; <nl> - } <nl> - <nl> - @ Override <nl> - public final FieldData clone ( ) { <nl> - FieldData clone = new FieldData ( ) ; <nl> - try { <nl> - clone . cachedExtension = cachedExtension ; <nl> - if ( unknownFieldData = = null ) { <nl> - clone . unknownFieldData = null ; <nl> - } else { <nl> - clone . unknownFieldData . addAll ( unknownFieldData ) ; <nl> - } <nl> - <nl> - / / Whether we need to deep clone value depends on its type . Primitive reference types <nl> - / / ( e . g . Integer , Long etc . ) are ok , since they ' re immutable . We need to clone arrays <nl> - / / and messages . <nl> - if ( value = = null ) { <nl> - / / No cloning required . <nl> - } else if ( value instanceof MessageNano ) { <nl> - clone . value = ( ( MessageNano ) value ) . clone ( ) ; <nl> - } else if ( value instanceof byte [ ] ) { <nl> - clone . value = ( ( byte [ ] ) value ) . clone ( ) ; <nl> - } else if ( value instanceof byte [ ] [ ] ) { <nl> - byte [ ] [ ] valueArray = ( byte [ ] [ ] ) value ; <nl> - byte [ ] [ ] cloneArray = new byte [ valueArray . length ] [ ] ; <nl> - clone . value = cloneArray ; <nl> - for ( int i = 0 ; i < valueArray . length ; i + + ) { <nl> - cloneArray [ i ] = valueArray [ i ] . clone ( ) ; <nl> - } <nl> - } else if ( value instanceof boolean [ ] ) { <nl> - clone . value = ( ( boolean [ ] ) value ) . clone ( ) ; <nl> - } else if ( value instanceof int [ ] ) { <nl> - clone . value = ( ( int [ ] ) value ) . clone ( ) ; <nl> - } else if ( value instanceof long [ ] ) { <nl> - clone . value = ( ( long [ ] ) value ) . clone ( ) ; <nl> - } else if ( value instanceof float [ ] ) { <nl> - clone . value = ( ( float [ ] ) value ) . clone ( ) ; <nl> - } else if ( value instanceof double [ ] ) { <nl> - clone . value = ( ( double [ ] ) value ) . clone ( ) ; <nl> - } else if ( value instanceof MessageNano [ ] ) { <nl> - MessageNano [ ] valueArray = ( MessageNano [ ] ) value ; <nl> - MessageNano [ ] cloneArray = new MessageNano [ valueArray . length ] ; <nl> - clone . value = cloneArray ; <nl> - for ( int i = 0 ; i < valueArray . length ; i + + ) { <nl> - cloneArray [ i ] = valueArray [ i ] . clone ( ) ; <nl> - } <nl> - } <nl> - return clone ; <nl> - } catch ( CloneNotSupportedException e ) { <nl> - throw new AssertionError ( e ) ; <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 278368a08b . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / InternalNano . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import com . google . protobuf . nano . MapFactories . MapFactory ; <nl> - <nl> - import java . io . IOException ; <nl> - import java . nio . charset . Charset ; <nl> - import java . util . Arrays ; <nl> - import java . util . Map ; <nl> - import java . util . Map . Entry ; <nl> - <nl> - / * * <nl> - * The classes contained within are used internally by the Protocol Buffer <nl> - * library and generated message implementations . They are public only because <nl> - * those generated messages do not reside in the { @ code protobuf } package . <nl> - * Others should not use this class directly . <nl> - * <nl> - * @ author kenton @ google . com ( Kenton Varda ) <nl> - * / <nl> - public final class InternalNano { <nl> - <nl> - public static final int TYPE_DOUBLE = 1 ; <nl> - public static final int TYPE_FLOAT = 2 ; <nl> - public static final int TYPE_INT64 = 3 ; <nl> - public static final int TYPE_UINT64 = 4 ; <nl> - public static final int TYPE_INT32 = 5 ; <nl> - public static final int TYPE_FIXED64 = 6 ; <nl> - public static final int TYPE_FIXED32 = 7 ; <nl> - public static final int TYPE_BOOL = 8 ; <nl> - public static final int TYPE_STRING = 9 ; <nl> - public static final int TYPE_GROUP = 10 ; <nl> - public static final int TYPE_MESSAGE = 11 ; <nl> - public static final int TYPE_BYTES = 12 ; <nl> - public static final int TYPE_UINT32 = 13 ; <nl> - public static final int TYPE_ENUM = 14 ; <nl> - public static final int TYPE_SFIXED32 = 15 ; <nl> - public static final int TYPE_SFIXED64 = 16 ; <nl> - public static final int TYPE_SINT32 = 17 ; <nl> - public static final int TYPE_SINT64 = 18 ; <nl> - <nl> - static final Charset UTF_8 = Charset . forName ( " UTF - 8 " ) ; <nl> - static final Charset ISO_8859_1 = Charset . forName ( " ISO - 8859 - 1 " ) ; <nl> - <nl> - private InternalNano ( ) { } <nl> - <nl> - / * * <nl> - * An object to provide synchronization when lazily initializing static fields <nl> - * of { @ link MessageNano } subclasses . <nl> - * < p > <nl> - * To enable earlier versions of ProGuard to inline short methods from a <nl> - * generated MessageNano subclass to the call sites , that class must not have <nl> - * a class initializer , which will be created if there is any static variable <nl> - * initializers . To lazily initialize the static variables in a thread - safe <nl> - * manner , the initialization code will synchronize on this object . <nl> - * / <nl> - public static final Object LAZY_INIT_LOCK = new Object ( ) ; <nl> - <nl> - / * * <nl> - * Helper called by generated code to construct default values for string <nl> - * fields . <nl> - * < p > <nl> - * The protocol compiler does not actually contain a UTF - 8 decoder - - it <nl> - * just pushes UTF - 8 - encoded text around without touching it . The one place <nl> - * where this presents a problem is when generating Java string literals . <nl> - * Unicode characters in the string literal would normally need to be encoded <nl> - * using a Unicode escape sequence , which would require decoding them . <nl> - * To get around this , protoc instead embeds the UTF - 8 bytes into the <nl> - * generated code and leaves it to the runtime library to decode them . <nl> - * < p > <nl> - * It gets worse , though . If protoc just generated a byte array , like : <nl> - * new byte [ ] { 0x12 , 0x34 , 0x56 , 0x78 } <nl> - * Java actually generates * code * which allocates an array and then fills <nl> - * in each value . This is much less efficient than just embedding the bytes <nl> - * directly into the bytecode . To get around this , we need another <nl> - * work - around . String literals are embedded directly , so protoc actually <nl> - * generates a string literal corresponding to the bytes . The easiest way <nl> - * to do this is to use the ISO - 8859 - 1 character set , which corresponds to <nl> - * the first 256 characters of the Unicode range . Protoc can then use <nl> - * good old CEscape to generate the string . <nl> - * < p > <nl> - * So we have a string literal which represents a set of bytes which <nl> - * represents another string . This function - - stringDefaultValue - - <nl> - * converts from the generated string to the string we actually want . The <nl> - * generated code calls this automatically . <nl> - * / <nl> - public static String stringDefaultValue ( String bytes ) { <nl> - return new String ( bytes . getBytes ( ISO_8859_1 ) , InternalNano . UTF_8 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Helper called by generated code to construct default values for bytes <nl> - * fields . <nl> - * < p > <nl> - * This is a lot like { @ link # stringDefaultValue } , but for bytes fields . <nl> - * In this case we only need the second of the two hacks - - allowing us to <nl> - * embed raw bytes as a string literal with ISO - 8859 - 1 encoding . <nl> - * / <nl> - public static byte [ ] bytesDefaultValue ( String bytes ) { <nl> - return bytes . getBytes ( ISO_8859_1 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Helper function to convert a string into UTF - 8 while turning the <nl> - * UnsupportedEncodingException to a RuntimeException . <nl> - * / <nl> - public static byte [ ] copyFromUtf8 ( final String text ) { <nl> - return text . getBytes ( InternalNano . UTF_8 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Checks repeated int field equality ; null - value and 0 - length fields are <nl> - * considered equal . <nl> - * / <nl> - public static boolean equals ( int [ ] field1 , int [ ] field2 ) { <nl> - if ( field1 = = null | | field1 . length = = 0 ) { <nl> - return field2 = = null | | field2 . length = = 0 ; <nl> - } else { <nl> - return Arrays . equals ( field1 , field2 ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Checks repeated long field equality ; null - value and 0 - length fields are <nl> - * considered equal . <nl> - * / <nl> - public static boolean equals ( long [ ] field1 , long [ ] field2 ) { <nl> - if ( field1 = = null | | field1 . length = = 0 ) { <nl> - return field2 = = null | | field2 . length = = 0 ; <nl> - } else { <nl> - return Arrays . equals ( field1 , field2 ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Checks repeated float field equality ; null - value and 0 - length fields are <nl> - * considered equal . <nl> - * / <nl> - public static boolean equals ( float [ ] field1 , float [ ] field2 ) { <nl> - if ( field1 = = null | | field1 . length = = 0 ) { <nl> - return field2 = = null | | field2 . length = = 0 ; <nl> - } else { <nl> - return Arrays . equals ( field1 , field2 ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Checks repeated double field equality ; null - value and 0 - length fields are <nl> - * considered equal . <nl> - * / <nl> - public static boolean equals ( double [ ] field1 , double [ ] field2 ) { <nl> - if ( field1 = = null | | field1 . length = = 0 ) { <nl> - return field2 = = null | | field2 . length = = 0 ; <nl> - } else { <nl> - return Arrays . equals ( field1 , field2 ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Checks repeated boolean field equality ; null - value and 0 - length fields are <nl> - * considered equal . <nl> - * / <nl> - public static boolean equals ( boolean [ ] field1 , boolean [ ] field2 ) { <nl> - if ( field1 = = null | | field1 . length = = 0 ) { <nl> - return field2 = = null | | field2 . length = = 0 ; <nl> - } else { <nl> - return Arrays . equals ( field1 , field2 ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Checks repeated bytes field equality . Only non - null elements are tested . <nl> - * Returns true if the two fields have the same sequence of non - null <nl> - * elements . Null - value fields and fields of any length with only null <nl> - * elements are considered equal . <nl> - * / <nl> - public static boolean equals ( byte [ ] [ ] field1 , byte [ ] [ ] field2 ) { <nl> - int index1 = 0 ; <nl> - int length1 = field1 = = null ? 0 : field1 . length ; <nl> - int index2 = 0 ; <nl> - int length2 = field2 = = null ? 0 : field2 . length ; <nl> - while ( true ) { <nl> - while ( index1 < length1 & & field1 [ index1 ] = = null ) { <nl> - index1 + + ; <nl> - } <nl> - while ( index2 < length2 & & field2 [ index2 ] = = null ) { <nl> - index2 + + ; <nl> - } <nl> - boolean atEndOf1 = index1 > = length1 ; <nl> - boolean atEndOf2 = index2 > = length2 ; <nl> - if ( atEndOf1 & & atEndOf2 ) { <nl> - / / no more non - null elements to test in both arrays <nl> - return true ; <nl> - } else if ( atEndOf1 ! = atEndOf2 ) { <nl> - / / one of the arrays have extra non - null elements <nl> - return false ; <nl> - } else if ( ! Arrays . equals ( field1 [ index1 ] , field2 [ index2 ] ) ) { <nl> - / / element mismatch <nl> - return false ; <nl> - } <nl> - index1 + + ; <nl> - index2 + + ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Checks repeated string / message field equality . Only non - null elements are <nl> - * tested . Returns true if the two fields have the same sequence of non - null <nl> - * elements . Null - value fields and fields of any length with only null <nl> - * elements are considered equal . <nl> - * / <nl> - public static boolean equals ( Object [ ] field1 , Object [ ] field2 ) { <nl> - int index1 = 0 ; <nl> - int length1 = field1 = = null ? 0 : field1 . length ; <nl> - int index2 = 0 ; <nl> - int length2 = field2 = = null ? 0 : field2 . length ; <nl> - while ( true ) { <nl> - while ( index1 < length1 & & field1 [ index1 ] = = null ) { <nl> - index1 + + ; <nl> - } <nl> - while ( index2 < length2 & & field2 [ index2 ] = = null ) { <nl> - index2 + + ; <nl> - } <nl> - boolean atEndOf1 = index1 > = length1 ; <nl> - boolean atEndOf2 = index2 > = length2 ; <nl> - if ( atEndOf1 & & atEndOf2 ) { <nl> - / / no more non - null elements to test in both arrays <nl> - return true ; <nl> - } else if ( atEndOf1 ! = atEndOf2 ) { <nl> - / / one of the arrays have extra non - null elements <nl> - return false ; <nl> - } else if ( ! field1 [ index1 ] . equals ( field2 [ index2 ] ) ) { <nl> - / / element mismatch <nl> - return false ; <nl> - } <nl> - index1 + + ; <nl> - index2 + + ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Computes the hash code of a repeated int field . Null - value and 0 - length <nl> - * fields have the same hash code . <nl> - * / <nl> - public static int hashCode ( int [ ] field ) { <nl> - return field = = null | | field . length = = 0 ? 0 : Arrays . hashCode ( field ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the hash code of a repeated long field . Null - value and 0 - length <nl> - * fields have the same hash code . <nl> - * / <nl> - public static int hashCode ( long [ ] field ) { <nl> - return field = = null | | field . length = = 0 ? 0 : Arrays . hashCode ( field ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the hash code of a repeated float field . Null - value and 0 - length <nl> - * fields have the same hash code . <nl> - * / <nl> - public static int hashCode ( float [ ] field ) { <nl> - return field = = null | | field . length = = 0 ? 0 : Arrays . hashCode ( field ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the hash code of a repeated double field . Null - value and 0 - length <nl> - * fields have the same hash code . <nl> - * / <nl> - public static int hashCode ( double [ ] field ) { <nl> - return field = = null | | field . length = = 0 ? 0 : Arrays . hashCode ( field ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the hash code of a repeated boolean field . Null - value and 0 - length <nl> - * fields have the same hash code . <nl> - * / <nl> - public static int hashCode ( boolean [ ] field ) { <nl> - return field = = null | | field . length = = 0 ? 0 : Arrays . hashCode ( field ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the hash code of a repeated bytes field . Only the sequence of all <nl> - * non - null elements are used in the computation . Null - value fields and fields <nl> - * of any length with only null elements have the same hash code . <nl> - * / <nl> - public static int hashCode ( byte [ ] [ ] field ) { <nl> - int result = 0 ; <nl> - for ( int i = 0 , size = field = = null ? 0 : field . length ; i < size ; i + + ) { <nl> - byte [ ] element = field [ i ] ; <nl> - if ( element ! = null ) { <nl> - result = 31 * result + Arrays . hashCode ( element ) ; <nl> - } <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the hash code of a repeated string / message field . Only the <nl> - * sequence of all non - null elements are used in the computation . Null - value <nl> - * fields and fields of any length with only null elements have the same hash <nl> - * code . <nl> - * / <nl> - public static int hashCode ( Object [ ] field ) { <nl> - int result = 0 ; <nl> - for ( int i = 0 , size = field = = null ? 0 : field . length ; i < size ; i + + ) { <nl> - Object element = field [ i ] ; <nl> - if ( element ! = null ) { <nl> - result = 31 * result + element . hashCode ( ) ; <nl> - } <nl> - } <nl> - return result ; <nl> - } <nl> - private static Object primitiveDefaultValue ( int type ) { <nl> - switch ( type ) { <nl> - case TYPE_BOOL : <nl> - return Boolean . FALSE ; <nl> - case TYPE_BYTES : <nl> - return WireFormatNano . EMPTY_BYTES ; <nl> - case TYPE_STRING : <nl> - return " " ; <nl> - case TYPE_FLOAT : <nl> - return Float . valueOf ( 0 ) ; <nl> - case TYPE_DOUBLE : <nl> - return Double . valueOf ( 0 ) ; <nl> - case TYPE_ENUM : <nl> - case TYPE_FIXED32 : <nl> - case TYPE_INT32 : <nl> - case TYPE_UINT32 : <nl> - case TYPE_SINT32 : <nl> - case TYPE_SFIXED32 : <nl> - return Integer . valueOf ( 0 ) ; <nl> - case TYPE_INT64 : <nl> - case TYPE_UINT64 : <nl> - case TYPE_SINT64 : <nl> - case TYPE_FIXED64 : <nl> - case TYPE_SFIXED64 : <nl> - return Long . valueOf ( 0L ) ; <nl> - case TYPE_MESSAGE : <nl> - case TYPE_GROUP : <nl> - default : <nl> - throw new IllegalArgumentException ( <nl> - " Type : " + type + " is not a primitive type . " ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Merges the map entry into the map field . Note this is only supposed to <nl> - * be called by generated messages . <nl> - * <nl> - * @ param map the map field ; may be null , in which case a map will be <nl> - * instantiated using the { @ link MapFactories . MapFactory } <nl> - * @ param input the input byte buffer <nl> - * @ param keyType key type , as defined in InternalNano . TYPE_ * <nl> - * @ param valueType value type , as defined in InternalNano . TYPE_ * <nl> - * @ param value an new instance of the value , if the value is a TYPE_MESSAGE ; <nl> - * otherwise this parameter can be null and will be ignored . <nl> - * @ param keyTag wire tag for the key <nl> - * @ param valueTag wire tag for the value <nl> - * @ return the map field <nl> - * @ throws IOException <nl> - * / <nl> - @ SuppressWarnings ( " unchecked " ) <nl> - public static final < K , V > Map < K , V > mergeMapEntry ( <nl> - CodedInputByteBufferNano input , <nl> - Map < K , V > map , <nl> - MapFactory mapFactory , <nl> - int keyType , <nl> - int valueType , <nl> - V value , <nl> - int keyTag , <nl> - int valueTag ) throws IOException { <nl> - map = mapFactory . forMap ( map ) ; <nl> - final int length = input . readRawVarint32 ( ) ; <nl> - final int oldLimit = input . pushLimit ( length ) ; <nl> - K key = null ; <nl> - while ( true ) { <nl> - int tag = input . readTag ( ) ; <nl> - if ( tag = = 0 ) { <nl> - break ; <nl> - } <nl> - if ( tag = = keyTag ) { <nl> - key = ( K ) input . readPrimitiveField ( keyType ) ; <nl> - } else if ( tag = = valueTag ) { <nl> - if ( valueType = = TYPE_MESSAGE ) { <nl> - input . readMessage ( ( MessageNano ) value ) ; <nl> - } else { <nl> - value = ( V ) input . readPrimitiveField ( valueType ) ; <nl> - } <nl> - } else { <nl> - if ( ! input . skipField ( tag ) ) { <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - input . checkLastTagWas ( 0 ) ; <nl> - input . popLimit ( oldLimit ) ; <nl> - <nl> - if ( key = = null ) { <nl> - / / key can only be primitive types . <nl> - key = ( K ) primitiveDefaultValue ( keyType ) ; <nl> - } <nl> - <nl> - if ( value = = null ) { <nl> - / / message type value will be initialized by code - gen . <nl> - value = ( V ) primitiveDefaultValue ( valueType ) ; <nl> - } <nl> - <nl> - map . put ( key , value ) ; <nl> - return map ; <nl> - } <nl> - <nl> - public static < K , V > void serializeMapField ( <nl> - CodedOutputByteBufferNano output , <nl> - Map < K , V > map , int number , int keyType , int valueType ) <nl> - throws IOException { <nl> - for ( Entry < K , V > entry : map . entrySet ( ) ) { <nl> - K key = entry . getKey ( ) ; <nl> - V value = entry . getValue ( ) ; <nl> - if ( key = = null | | value = = null ) { <nl> - throw new IllegalStateException ( <nl> - " keys and values in maps cannot be null " ) ; <nl> - } <nl> - int entrySize = <nl> - CodedOutputByteBufferNano . computeFieldSize ( 1 , keyType , key ) + <nl> - CodedOutputByteBufferNano . computeFieldSize ( 2 , valueType , value ) ; <nl> - output . writeTag ( number , WireFormatNano . WIRETYPE_LENGTH_DELIMITED ) ; <nl> - output . writeRawVarint32 ( entrySize ) ; <nl> - output . writeField ( 1 , keyType , key ) ; <nl> - output . writeField ( 2 , valueType , value ) ; <nl> - } <nl> - } <nl> - <nl> - public static < K , V > int computeMapFieldSize ( <nl> - Map < K , V > map , int number , int keyType , int valueType ) { <nl> - int size = 0 ; <nl> - int tagSize = CodedOutputByteBufferNano . computeTagSize ( number ) ; <nl> - for ( Entry < K , V > entry : map . entrySet ( ) ) { <nl> - K key = entry . getKey ( ) ; <nl> - V value = entry . getValue ( ) ; <nl> - if ( key = = null | | value = = null ) { <nl> - throw new IllegalStateException ( <nl> - " keys and values in maps cannot be null " ) ; <nl> - } <nl> - int entrySize = <nl> - CodedOutputByteBufferNano . computeFieldSize ( 1 , keyType , key ) + <nl> - CodedOutputByteBufferNano . computeFieldSize ( 2 , valueType , value ) ; <nl> - size + = tagSize + entrySize <nl> - + CodedOutputByteBufferNano . computeRawVarint32Size ( entrySize ) ; <nl> - } <nl> - return size ; <nl> - } <nl> - <nl> - / * * <nl> - * Checks whether two { @ link Map } are equal . We don ' t use the default equals <nl> - * method of { @ link Map } because it compares by identity not by content for <nl> - * byte arrays . <nl> - * / <nl> - public static < K , V > boolean equals ( Map < K , V > a , Map < K , V > b ) { <nl> - if ( a = = b ) { <nl> - return true ; <nl> - } <nl> - if ( a = = null ) { <nl> - return b . size ( ) = = 0 ; <nl> - } <nl> - if ( b = = null ) { <nl> - return a . size ( ) = = 0 ; <nl> - } <nl> - if ( a . size ( ) ! = b . size ( ) ) { <nl> - return false ; <nl> - } <nl> - for ( Entry < K , V > entry : a . entrySet ( ) ) { <nl> - if ( ! b . containsKey ( entry . getKey ( ) ) ) { <nl> - return false ; <nl> - } <nl> - if ( ! equalsMapValue ( entry . getValue ( ) , b . get ( entry . getKey ( ) ) ) ) { <nl> - return false ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - private static boolean equalsMapValue ( Object a , Object b ) { <nl> - if ( a = = null | | b = = null ) { <nl> - throw new IllegalStateException ( <nl> - " keys and values in maps cannot be null " ) ; <nl> - } <nl> - if ( a instanceof byte [ ] & & b instanceof byte [ ] ) { <nl> - return Arrays . equals ( ( byte [ ] ) a , ( byte [ ] ) b ) ; <nl> - } <nl> - return a . equals ( b ) ; <nl> - } <nl> - <nl> - public static < K , V > int hashCode ( Map < K , V > map ) { <nl> - if ( map = = null ) { <nl> - return 0 ; <nl> - } <nl> - int result = 0 ; <nl> - for ( Entry < K , V > entry : map . entrySet ( ) ) { <nl> - result + = hashCodeForMap ( entry . getKey ( ) ) <nl> - ^ hashCodeForMap ( entry . getValue ( ) ) ; <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - private static int hashCodeForMap ( Object o ) { <nl> - if ( o instanceof byte [ ] ) { <nl> - return Arrays . hashCode ( ( byte [ ] ) o ) ; <nl> - } <nl> - return o . hashCode ( ) ; <nl> - } <nl> - <nl> - / / This avoids having to make FieldArray public . <nl> - public static void cloneUnknownFieldData ( ExtendableMessageNano original , <nl> - ExtendableMessageNano cloned ) { <nl> - if ( original . unknownFieldData ! = null ) { <nl> - cloned . unknownFieldData = ( FieldArray ) original . unknownFieldData . clone ( ) ; <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 9a83d6d37c . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / InvalidProtocolBufferNanoException . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - <nl> - / * * <nl> - * Thrown when a protocol message being parsed is invalid in some way , <nl> - * e . g . it contains a malformed varint or a negative byte length . <nl> - * <nl> - * @ author kenton @ google . com Kenton Varda <nl> - * / <nl> - public class InvalidProtocolBufferNanoException extends IOException { <nl> - private static final long serialVersionUID = - 1616151763072450476L ; <nl> - <nl> - public InvalidProtocolBufferNanoException ( final String description ) { <nl> - super ( description ) ; <nl> - } <nl> - <nl> - static InvalidProtocolBufferNanoException truncatedMessage ( ) { <nl> - return new InvalidProtocolBufferNanoException ( <nl> - " While parsing a protocol message , the input ended unexpectedly " + <nl> - " in the middle of a field . This could mean either that the " + <nl> - " input has been truncated or that an embedded message " + <nl> - " misreported its own length . " ) ; <nl> - } <nl> - <nl> - static InvalidProtocolBufferNanoException negativeSize ( ) { <nl> - return new InvalidProtocolBufferNanoException ( <nl> - " CodedInputStream encountered an embedded string or message " + <nl> - " which claimed to have negative size . " ) ; <nl> - } <nl> - <nl> - static InvalidProtocolBufferNanoException malformedVarint ( ) { <nl> - return new InvalidProtocolBufferNanoException ( <nl> - " CodedInputStream encountered a malformed varint . " ) ; <nl> - } <nl> - <nl> - static InvalidProtocolBufferNanoException invalidTag ( ) { <nl> - return new InvalidProtocolBufferNanoException ( <nl> - " Protocol message contained an invalid tag ( zero ) . " ) ; <nl> - } <nl> - <nl> - static InvalidProtocolBufferNanoException invalidEndTag ( ) { <nl> - return new InvalidProtocolBufferNanoException ( <nl> - " Protocol message end - group tag did not match expected tag . " ) ; <nl> - } <nl> - <nl> - static InvalidProtocolBufferNanoException invalidWireType ( ) { <nl> - return new InvalidProtocolBufferNanoException ( <nl> - " Protocol message tag had invalid wire type . " ) ; <nl> - } <nl> - <nl> - static InvalidProtocolBufferNanoException recursionLimitExceeded ( ) { <nl> - return new InvalidProtocolBufferNanoException ( <nl> - " Protocol message had too many levels of nesting . May be malicious . " + <nl> - " Use CodedInputStream . setRecursionLimit ( ) to increase the depth limit . " ) ; <nl> - } <nl> - <nl> - static InvalidProtocolBufferNanoException sizeLimitExceeded ( ) { <nl> - return new InvalidProtocolBufferNanoException ( <nl> - " Protocol message was too large . May be malicious . " + <nl> - " Use CodedInputStream . setSizeLimit ( ) to increase the size limit . " ) ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 98fa4877bc . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / MapFactories . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . util . HashMap ; <nl> - import java . util . Map ; <nl> - <nl> - / * * <nl> - * Utility class for maps support . <nl> - * / <nl> - public final class MapFactories { <nl> - public static interface MapFactory { <nl> - < K , V > Map < K , V > forMap ( Map < K , V > oldMap ) ; <nl> - } <nl> - <nl> - / / NOTE ( liujisi ) : The factory setter is temporarily marked as package private . <nl> - / / The way to provide customized implementations of maps for different <nl> - / / platforms are still under discussion . Mark it as private to avoid exposing <nl> - / / the API in proto3 alpha release . <nl> - / * public * / static void setMapFactory ( MapFactory newMapFactory ) { <nl> - mapFactory = newMapFactory ; <nl> - } <nl> - <nl> - public static MapFactory getMapFactory ( ) { <nl> - return mapFactory ; <nl> - } <nl> - <nl> - private static class DefaultMapFactory implements MapFactory { <nl> - public < K , V > Map < K , V > forMap ( Map < K , V > oldMap ) { <nl> - if ( oldMap = = null ) { <nl> - return new HashMap < K , V > ( ) ; <nl> - } <nl> - return oldMap ; <nl> - } <nl> - } <nl> - private static volatile MapFactory mapFactory = new DefaultMapFactory ( ) ; <nl> - <nl> - private MapFactories ( ) { } <nl> - } <nl> deleted file mode 100644 <nl> index 2347502702 . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / MessageNano . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - import java . util . Arrays ; <nl> - <nl> - / * * <nl> - * Abstract interface implemented by Protocol Message objects . <nl> - * <nl> - * @ author wink @ google . com Wink Saville <nl> - * / <nl> - public abstract class MessageNano { <nl> - protected volatile int cachedSize = - 1 ; <nl> - <nl> - / * * <nl> - * Get the number of bytes required to encode this message . <nl> - * Returns the cached size or calls getSerializedSize which <nl> - * sets the cached size . This is used internally when serializing <nl> - * so the size is only computed once . If a member is modified <nl> - * then this could be stale call getSerializedSize if in doubt . <nl> - * / <nl> - public int getCachedSize ( ) { <nl> - if ( cachedSize < 0 ) { <nl> - / / getSerializedSize sets cachedSize <nl> - getSerializedSize ( ) ; <nl> - } <nl> - return cachedSize ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the number of bytes required to encode this message . <nl> - * The size is cached and the cached result can be retrieved <nl> - * using getCachedSize ( ) . <nl> - * / <nl> - public int getSerializedSize ( ) { <nl> - int size = computeSerializedSize ( ) ; <nl> - cachedSize = size ; <nl> - return size ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the number of bytes required to encode this message . This does not update the <nl> - * cached size . <nl> - * / <nl> - protected int computeSerializedSize ( ) { <nl> - / / This is overridden if the generated message has serialized fields . <nl> - return 0 ; <nl> - } <nl> - <nl> - / * * <nl> - * Serializes the message and writes it to { @ code output } . <nl> - * <nl> - * @ param output the output to receive the serialized form . <nl> - * @ throws IOException if an error occurred writing to { @ code output } . <nl> - * / <nl> - public void writeTo ( CodedOutputByteBufferNano output ) throws IOException { <nl> - / / Does nothing by default . Overridden by subclasses which have data to write . <nl> - } <nl> - <nl> - / * * <nl> - * Parse { @ code input } as a message of this type and merge it with the <nl> - * message being built . <nl> - * / <nl> - public abstract MessageNano mergeFrom ( CodedInputByteBufferNano input ) throws IOException ; <nl> - <nl> - / * * <nl> - * Serialize to a byte array . <nl> - * @ return byte array with the serialized data . <nl> - * / <nl> - public static final byte [ ] toByteArray ( MessageNano msg ) { <nl> - final byte [ ] result = new byte [ msg . getSerializedSize ( ) ] ; <nl> - toByteArray ( msg , result , 0 , result . length ) ; <nl> - return result ; <nl> - } <nl> - <nl> - / * * <nl> - * Serialize to a byte array starting at offset through length . The <nl> - * method getSerializedSize must have been called prior to calling <nl> - * this method so the proper length is know . If an attempt to <nl> - * write more than length bytes OutOfSpaceException will be thrown <nl> - * and if length bytes are not written then IllegalStateException <nl> - * is thrown . <nl> - * / <nl> - public static final void toByteArray ( MessageNano msg , byte [ ] data , int offset , int length ) { <nl> - try { <nl> - final CodedOutputByteBufferNano output = <nl> - CodedOutputByteBufferNano . newInstance ( data , offset , length ) ; <nl> - msg . writeTo ( output ) ; <nl> - output . checkNoSpaceLeft ( ) ; <nl> - } catch ( IOException e ) { <nl> - throw new RuntimeException ( " Serializing to a byte array threw an IOException " <nl> - + " ( should never happen ) . " , e ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Parse { @ code data } as a message of this type and merge it with the <nl> - * message being built . <nl> - * / <nl> - public static final < T extends MessageNano > T mergeFrom ( T msg , final byte [ ] data ) <nl> - throws InvalidProtocolBufferNanoException { <nl> - return mergeFrom ( msg , data , 0 , data . length ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Parse { @ code data } as a message of this type and merge it with the <nl> - * message being built . <nl> - * / <nl> - public static final < T extends MessageNano > T mergeFrom ( T msg , final byte [ ] data , <nl> - final int off , final int len ) throws InvalidProtocolBufferNanoException { <nl> - try { <nl> - final CodedInputByteBufferNano input = <nl> - CodedInputByteBufferNano . newInstance ( data , off , len ) ; <nl> - msg . mergeFrom ( input ) ; <nl> - input . checkLastTagWas ( 0 ) ; <nl> - return msg ; <nl> - } catch ( InvalidProtocolBufferNanoException e ) { <nl> - throw e ; <nl> - } catch ( IOException e ) { <nl> - throw new RuntimeException ( " Reading from a byte array threw an IOException ( should " <nl> - + " never happen ) . " ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Compares two { @ code MessageNano } s and returns true if the message ' s are the same class and <nl> - * have serialized form equality ( i . e . all of the field values are the same ) . <nl> - * / <nl> - public static final boolean messageNanoEquals ( MessageNano a , MessageNano b ) { <nl> - if ( a = = b ) { <nl> - return true ; <nl> - } <nl> - if ( a = = null | | b = = null ) { <nl> - return false ; <nl> - } <nl> - if ( a . getClass ( ) ! = b . getClass ( ) ) { <nl> - return false ; <nl> - } <nl> - final int serializedSize = a . getSerializedSize ( ) ; <nl> - if ( b . getSerializedSize ( ) ! = serializedSize ) { <nl> - return false ; <nl> - } <nl> - final byte [ ] aByteArray = new byte [ serializedSize ] ; <nl> - final byte [ ] bByteArray = new byte [ serializedSize ] ; <nl> - toByteArray ( a , aByteArray , 0 , serializedSize ) ; <nl> - toByteArray ( b , bByteArray , 0 , serializedSize ) ; <nl> - return Arrays . equals ( aByteArray , bByteArray ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Returns a string that is ( mostly ) compatible with ProtoBuffer ' s TextFormat . Note that groups <nl> - * ( which are deprecated ) are not serialized with the correct field name . <nl> - * <nl> - * < p > This is implemented using reflection , so it is not especially fast nor is it guaranteed <nl> - * to find all fields if you have method removal turned on for proguard . <nl> - * / <nl> - @ Override <nl> - public String toString ( ) { <nl> - return MessageNanoPrinter . print ( this ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Provides support for cloning . This only works if you specify the generate_clone method . <nl> - * / <nl> - @ Override <nl> - public MessageNano clone ( ) throws CloneNotSupportedException { <nl> - return ( MessageNano ) super . clone ( ) ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 5f329f02fb . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / MessageNanoPrinter . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . lang . reflect . Array ; <nl> - import java . lang . reflect . Field ; <nl> - import java . lang . reflect . InvocationTargetException ; <nl> - import java . lang . reflect . Method ; <nl> - import java . lang . reflect . Modifier ; <nl> - import java . util . Map ; <nl> - <nl> - / * * <nl> - * Static helper methods for printing nano protos . <nl> - * <nl> - * @ author flynn @ google . com Andrew Flynn <nl> - * / <nl> - public final class MessageNanoPrinter { <nl> - / / Do not allow instantiation <nl> - private MessageNanoPrinter ( ) { } <nl> - <nl> - private static final String INDENT = " " ; <nl> - private static final int MAX_STRING_LEN = 200 ; <nl> - <nl> - / * * <nl> - * Returns an text representation of a MessageNano suitable for debugging . The returned string <nl> - * is mostly compatible with Protocol Buffer ' s TextFormat ( as provided by non - nano protocol <nl> - * buffers ) - - groups ( which are deprecated ) are output with an underscore name ( e . g . foo_bar <nl> - * instead of FooBar ) and will thus not parse . <nl> - * <nl> - * < p > Employs Java reflection on the given object and recursively prints primitive fields , <nl> - * groups , and messages . < / p > <nl> - * / <nl> - public static < T extends MessageNano > String print ( T message ) { <nl> - if ( message = = null ) { <nl> - return " " ; <nl> - } <nl> - <nl> - StringBuffer buf = new StringBuffer ( ) ; <nl> - try { <nl> - print ( null , message , new StringBuffer ( ) , buf ) ; <nl> - } catch ( IllegalAccessException e ) { <nl> - return " Error printing proto : " + e . getMessage ( ) ; <nl> - } catch ( InvocationTargetException e ) { <nl> - return " Error printing proto : " + e . getMessage ( ) ; <nl> - } <nl> - return buf . toString ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Function that will print the given message / field into the StringBuffer . <nl> - * Meant to be called recursively . <nl> - * <nl> - * @ param identifier the identifier to use , or { @ code null } if this is the root message to <nl> - * print . <nl> - * @ param object the value to print . May in fact be a primitive value or byte array and not a <nl> - * message . <nl> - * @ param indentBuf the indentation each line should begin with . <nl> - * @ param buf the output buffer . <nl> - * / <nl> - private static void print ( String identifier , Object object , <nl> - StringBuffer indentBuf , StringBuffer buf ) throws IllegalAccessException , <nl> - InvocationTargetException { <nl> - if ( object = = null ) { <nl> - / / This can happen if . . . <nl> - / / - we ' re about to print a message , String , or byte [ ] , but it not present ; <nl> - / / - we ' re about to print a primitive , but " reftype " optional style is enabled , and <nl> - / / the field is unset . <nl> - / / In both cases the appropriate behavior is to output nothing . <nl> - } else if ( object instanceof MessageNano ) { / / Nano proto message <nl> - int origIndentBufLength = indentBuf . length ( ) ; <nl> - if ( identifier ! = null ) { <nl> - buf . append ( indentBuf ) . append ( deCamelCaseify ( identifier ) ) . append ( " < \ n " ) ; <nl> - indentBuf . append ( INDENT ) ; <nl> - } <nl> - Class < ? > clazz = object . getClass ( ) ; <nl> - <nl> - / / Proto fields follow one of two formats : <nl> - / / <nl> - / / 1 ) Public , non - static variables that do not begin or end with ' _ ' <nl> - / / Find and print these using declared public fields <nl> - for ( Field field : clazz . getFields ( ) ) { <nl> - int modifiers = field . getModifiers ( ) ; <nl> - String fieldName = field . getName ( ) ; <nl> - if ( " cachedSize " . equals ( fieldName ) ) { <nl> - / / TODO ( bduff ) : perhaps cachedSize should have a more obscure name . <nl> - continue ; <nl> - } <nl> - <nl> - if ( ( modifiers & Modifier . PUBLIC ) = = Modifier . PUBLIC <nl> - & & ( modifiers & Modifier . STATIC ) ! = Modifier . STATIC <nl> - & & ! fieldName . startsWith ( " _ " ) <nl> - & & ! fieldName . endsWith ( " _ " ) ) { <nl> - Class < ? > fieldType = field . getType ( ) ; <nl> - Object value = field . get ( object ) ; <nl> - <nl> - if ( fieldType . isArray ( ) ) { <nl> - Class < ? > arrayType = fieldType . getComponentType ( ) ; <nl> - <nl> - / / bytes is special since it ' s not repeated , but is represented by an array <nl> - if ( arrayType = = byte . class ) { <nl> - print ( fieldName , value , indentBuf , buf ) ; <nl> - } else { <nl> - int len = value = = null ? 0 : Array . getLength ( value ) ; <nl> - for ( int i = 0 ; i < len ; i + + ) { <nl> - Object elem = Array . get ( value , i ) ; <nl> - print ( fieldName , elem , indentBuf , buf ) ; <nl> - } <nl> - } <nl> - } else { <nl> - print ( fieldName , value , indentBuf , buf ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / 2 ) Fields that are accessed via getter methods ( when accessors <nl> - / / mode is turned on ) <nl> - / / Find and print these using getter methods . <nl> - for ( Method method : clazz . getMethods ( ) ) { <nl> - String name = method . getName ( ) ; <nl> - / / Check for the setter accessor method since getters and hazzers both have <nl> - / / non - proto - field name collisions ( hashCode ( ) and getSerializedSize ( ) ) <nl> - if ( name . startsWith ( " set " ) ) { <nl> - String subfieldName = name . substring ( 3 ) ; <nl> - <nl> - Method hazzer = null ; <nl> - try { <nl> - hazzer = clazz . getMethod ( " has " + subfieldName ) ; <nl> - } catch ( NoSuchMethodException e ) { <nl> - continue ; <nl> - } <nl> - / / If hazzer doesn ' t exist or returns false , no need to continue <nl> - if ( ! ( Boolean ) hazzer . invoke ( object ) ) { <nl> - continue ; <nl> - } <nl> - <nl> - Method getter = null ; <nl> - try { <nl> - getter = clazz . getMethod ( " get " + subfieldName ) ; <nl> - } catch ( NoSuchMethodException e ) { <nl> - continue ; <nl> - } <nl> - <nl> - print ( subfieldName , getter . invoke ( object ) , indentBuf , buf ) ; <nl> - } <nl> - } <nl> - if ( identifier ! = null ) { <nl> - indentBuf . setLength ( origIndentBufLength ) ; <nl> - buf . append ( indentBuf ) . append ( " > \ n " ) ; <nl> - } <nl> - } else if ( object instanceof Map ) { <nl> - Map < ? , ? > map = ( Map < ? , ? > ) object ; <nl> - identifier = deCamelCaseify ( identifier ) ; <nl> - <nl> - for ( Map . Entry < ? , ? > entry : map . entrySet ( ) ) { <nl> - buf . append ( indentBuf ) . append ( identifier ) . append ( " < \ n " ) ; <nl> - int origIndentBufLength = indentBuf . length ( ) ; <nl> - indentBuf . append ( INDENT ) ; <nl> - print ( " key " , entry . getKey ( ) , indentBuf , buf ) ; <nl> - print ( " value " , entry . getValue ( ) , indentBuf , buf ) ; <nl> - indentBuf . setLength ( origIndentBufLength ) ; <nl> - buf . append ( indentBuf ) . append ( " > \ n " ) ; <nl> - } <nl> - } else { <nl> - / / Non - null primitive value <nl> - identifier = deCamelCaseify ( identifier ) ; <nl> - buf . append ( indentBuf ) . append ( identifier ) . append ( " : " ) ; <nl> - if ( object instanceof String ) { <nl> - String stringMessage = sanitizeString ( ( String ) object ) ; <nl> - buf . append ( " \ " " ) . append ( stringMessage ) . append ( " \ " " ) ; <nl> - } else if ( object instanceof byte [ ] ) { <nl> - appendQuotedBytes ( ( byte [ ] ) object , buf ) ; <nl> - } else { <nl> - buf . append ( object ) ; <nl> - } <nl> - buf . append ( " \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Converts an identifier of the format " FieldName " into " field_name " . <nl> - * / <nl> - private static String deCamelCaseify ( String identifier ) { <nl> - StringBuffer out = new StringBuffer ( ) ; <nl> - for ( int i = 0 ; i < identifier . length ( ) ; i + + ) { <nl> - char currentChar = identifier . charAt ( i ) ; <nl> - if ( i = = 0 ) { <nl> - out . append ( Character . toLowerCase ( currentChar ) ) ; <nl> - } else if ( Character . isUpperCase ( currentChar ) ) { <nl> - out . append ( ' _ ' ) . append ( Character . toLowerCase ( currentChar ) ) ; <nl> - } else { <nl> - out . append ( currentChar ) ; <nl> - } <nl> - } <nl> - return out . toString ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Shortens and escapes the given string . <nl> - * / <nl> - private static String sanitizeString ( String str ) { <nl> - if ( ! str . startsWith ( " http " ) & & str . length ( ) > MAX_STRING_LEN ) { <nl> - / / Trim non - URL strings . <nl> - str = str . substring ( 0 , MAX_STRING_LEN ) + " [ . . . ] " ; <nl> - } <nl> - return escapeString ( str ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Escape everything except for low ASCII code points . <nl> - * / <nl> - private static String escapeString ( String str ) { <nl> - int strLen = str . length ( ) ; <nl> - StringBuilder b = new StringBuilder ( strLen ) ; <nl> - for ( int i = 0 ; i < strLen ; i + + ) { <nl> - char original = str . charAt ( i ) ; <nl> - if ( original > = ' ' & & original < = ' ~ ' & & original ! = ' " ' & & original ! = ' \ ' ' ) { <nl> - b . append ( original ) ; <nl> - } else { <nl> - b . append ( String . format ( " \ \ u % 04x " , ( int ) original ) ) ; <nl> - } <nl> - } <nl> - return b . toString ( ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Appends a quoted byte array to the provided { @ code StringBuffer } . <nl> - * / <nl> - private static void appendQuotedBytes ( byte [ ] bytes , StringBuffer builder ) { <nl> - if ( bytes = = null ) { <nl> - builder . append ( " \ " \ " " ) ; <nl> - return ; <nl> - } <nl> - <nl> - builder . append ( ' " ' ) ; <nl> - for ( int i = 0 ; i < bytes . length ; + + i ) { <nl> - int ch = bytes [ i ] & 0xff ; <nl> - if ( ch = = ' \ \ ' | | ch = = ' " ' ) { <nl> - builder . append ( ' \ \ ' ) . append ( ( char ) ch ) ; <nl> - } else if ( ch > = 32 & & ch < 127 ) { <nl> - builder . append ( ( char ) ch ) ; <nl> - } else { <nl> - builder . append ( String . format ( " \ \ % 03o " , ch ) ) ; <nl> - } <nl> - } <nl> - builder . append ( ' " ' ) ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index b1678d1b93 . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / UnknownFieldData . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - import java . util . Arrays ; <nl> - <nl> - / * * <nl> - * Stores unknown fields . These might be extensions or fields that the generated <nl> - * API doesn ' t know about yet . <nl> - * <nl> - * @ author bduff @ google . com ( Brian Duff ) <nl> - * / <nl> - final class UnknownFieldData { <nl> - <nl> - final int tag ; <nl> - / * * <nl> - * Important : this should be treated as immutable , even though it ' s possible <nl> - * to change the array values . <nl> - * / <nl> - final byte [ ] bytes ; <nl> - <nl> - UnknownFieldData ( int tag , byte [ ] bytes ) { <nl> - this . tag = tag ; <nl> - this . bytes = bytes ; <nl> - } <nl> - <nl> - int computeSerializedSize ( ) { <nl> - int size = 0 ; <nl> - size + = CodedOutputByteBufferNano . computeRawVarint32Size ( tag ) ; <nl> - size + = bytes . length ; <nl> - return size ; <nl> - } <nl> - <nl> - void writeTo ( CodedOutputByteBufferNano output ) throws IOException { <nl> - output . writeRawVarint32 ( tag ) ; <nl> - output . writeRawBytes ( bytes ) ; <nl> - } <nl> - <nl> - @ Override <nl> - public boolean equals ( Object o ) { <nl> - if ( o = = this ) { <nl> - return true ; <nl> - } <nl> - if ( ! ( o instanceof UnknownFieldData ) ) { <nl> - return false ; <nl> - } <nl> - <nl> - UnknownFieldData other = ( UnknownFieldData ) o ; <nl> - return tag = = other . tag & & Arrays . equals ( bytes , other . bytes ) ; <nl> - } <nl> - <nl> - @ Override <nl> - public int hashCode ( ) { <nl> - int result = 17 ; <nl> - result = 31 * result + tag ; <nl> - result = 31 * result + Arrays . hashCode ( bytes ) ; <nl> - return result ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index bbb6370a3e . . 0000000000 <nl> mmm a / javanano / src / main / java / com / google / protobuf / nano / WireFormatNano . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import java . io . IOException ; <nl> - <nl> - / * * <nl> - * This class is used internally by the Protocol Buffer library and generated <nl> - * message implementations . It is public only because those generated messages <nl> - * do not reside in the { @ code protobuf } package . Others should not use this <nl> - * class directly . <nl> - * <nl> - * This class contains constants and helper functions useful for dealing with <nl> - * the Protocol Buffer wire format . <nl> - * <nl> - * @ author kenton @ google . com Kenton Varda <nl> - * / <nl> - public final class WireFormatNano { <nl> - / / Do not allow instantiation . <nl> - private WireFormatNano ( ) { } <nl> - <nl> - static final int WIRETYPE_VARINT = 0 ; <nl> - static final int WIRETYPE_FIXED64 = 1 ; <nl> - static final int WIRETYPE_LENGTH_DELIMITED = 2 ; <nl> - static final int WIRETYPE_START_GROUP = 3 ; <nl> - static final int WIRETYPE_END_GROUP = 4 ; <nl> - static final int WIRETYPE_FIXED32 = 5 ; <nl> - <nl> - static final int TAG_TYPE_BITS = 3 ; <nl> - static final int TAG_TYPE_MASK = ( 1 < < TAG_TYPE_BITS ) - 1 ; <nl> - <nl> - / * * Given a tag value , determines the wire type ( the lower 3 bits ) . * / <nl> - static int getTagWireType ( final int tag ) { <nl> - return tag & TAG_TYPE_MASK ; <nl> - } <nl> - <nl> - / * * Given a tag value , determines the field number ( the upper 29 bits ) . * / <nl> - public static int getTagFieldNumber ( final int tag ) { <nl> - return tag > > > TAG_TYPE_BITS ; <nl> - } <nl> - <nl> - / * * Makes a tag value given a field number and wire type . * / <nl> - static int makeTag ( final int fieldNumber , final int wireType ) { <nl> - return ( fieldNumber < < TAG_TYPE_BITS ) | wireType ; <nl> - } <nl> - <nl> - public static final int EMPTY_INT_ARRAY [ ] = { } ; <nl> - public static final long EMPTY_LONG_ARRAY [ ] = { } ; <nl> - public static final float EMPTY_FLOAT_ARRAY [ ] = { } ; <nl> - public static final double EMPTY_DOUBLE_ARRAY [ ] = { } ; <nl> - public static final boolean EMPTY_BOOLEAN_ARRAY [ ] = { } ; <nl> - public static final String EMPTY_STRING_ARRAY [ ] = { } ; <nl> - public static final byte [ ] EMPTY_BYTES_ARRAY [ ] = { } ; <nl> - public static final byte [ ] EMPTY_BYTES = { } ; <nl> - <nl> - / * * <nl> - * Parses an unknown field . This implementation skips the field . <nl> - * <nl> - * < p > Generated messages will call this for unknown fields if the store_unknown_fields <nl> - * option is off . <nl> - * <nl> - * @ return { @ literal true } unless the tag is an end - group tag . <nl> - * / <nl> - public static boolean parseUnknownField ( <nl> - final CodedInputByteBufferNano input , <nl> - final int tag ) throws IOException { <nl> - return input . skipField ( tag ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Computes the array length of a repeated field . We assume that in the common case repeated <nl> - * fields are contiguously serialized but we still correctly handle interspersed values of a <nl> - * repeated field ( but with extra allocations ) . <nl> - * <nl> - * Rewinds to current input position before returning . <nl> - * <nl> - * @ param input stream input , pointing to the byte after the first tag <nl> - * @ param tag repeated field tag just read <nl> - * @ return length of array <nl> - * @ throws IOException <nl> - * / <nl> - public static final int getRepeatedFieldArrayLength ( <nl> - final CodedInputByteBufferNano input , <nl> - final int tag ) throws IOException { <nl> - int arrayLength = 1 ; <nl> - int startPos = input . getPosition ( ) ; <nl> - input . skipField ( tag ) ; <nl> - while ( input . readTag ( ) = = tag ) { <nl> - input . skipField ( tag ) ; <nl> - arrayLength + + ; <nl> - } <nl> - input . rewindToPosition ( startPos ) ; <nl> - return arrayLength ; <nl> - } <nl> - <nl> - } <nl> deleted file mode 100644 <nl> index 4d6e7f0903 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / NanoTest . java <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2013 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - package com . google . protobuf . nano ; <nl> - <nl> - import com . google . protobuf . nano . CodedOutputByteBufferNano ; <nl> - import com . google . protobuf . nano . EnumClassNanos . EnumClassNano ; <nl> - import com . google . protobuf . nano . EnumClassNanos . EnumClassNano . MessageScopeEnum ; <nl> - import com . google . protobuf . nano . EnumClassNanos . FileScopeEnum ; <nl> - import com . google . protobuf . nano . MapTestProto . TestMap ; <nl> - import com . google . protobuf . nano . MapTestProto . TestMap . MessageValue ; <nl> - import com . google . protobuf . nano . NanoAccessorsOuterClass . TestNanoAccessors ; <nl> - import com . google . protobuf . nano . NanoHasOuterClass . TestAllTypesNanoHas ; <nl> - import com . google . protobuf . nano . NanoOuterClass . TestAllTypesNano ; <nl> - import com . google . protobuf . nano . UnittestRecursiveNano . RecursiveMessageNano ; <nl> - import com . google . protobuf . nano . NanoReferenceTypesCompat ; <nl> - import com . google . protobuf . nano . UnittestSimpleNano . SimpleMessageNano ; <nl> - import com . google . protobuf . nano . UnittestSingleNano . SingleMessageNano ; <nl> - import com . google . protobuf . nano . testext . nano . Extensions ; <nl> - import com . google . protobuf . nano . testext . nano . Extensions . AnotherMessage ; <nl> - import com . google . protobuf . nano . testext . nano . Extensions . MessageWithGroup ; <nl> - import com . google . protobuf . nano . testimport . nano . UnittestImportNano ; <nl> - <nl> - import junit . framework . TestCase ; <nl> - <nl> - import java . util . Arrays ; <nl> - import java . util . HashMap ; <nl> - import java . util . Map ; <nl> - import java . util . TreeMap ; <nl> - <nl> - / * * <nl> - * Test nano runtime . <nl> - * <nl> - * @ author ulas @ google . com Ulas Kirazci <nl> - * / <nl> - public class NanoTest extends TestCase { <nl> - @ Override <nl> - public void setUp ( ) throws Exception { <nl> - } <nl> - <nl> - public void testSimpleMessageNano ( ) throws Exception { <nl> - SimpleMessageNano msg = new SimpleMessageNano ( ) ; <nl> - assertEquals ( 123 , msg . d ) ; <nl> - assertEquals ( null , msg . nestedMsg ) ; <nl> - assertEquals ( SimpleMessageNano . BAZ , msg . defaultNestedEnum ) ; <nl> - <nl> - msg . d = 456 ; <nl> - assertEquals ( 456 , msg . d ) ; <nl> - <nl> - SimpleMessageNano . NestedMessage nestedMsg = new SimpleMessageNano . NestedMessage ( ) ; <nl> - nestedMsg . bb = 2 ; <nl> - assertEquals ( 2 , nestedMsg . bb ) ; <nl> - msg . nestedMsg = nestedMsg ; <nl> - assertEquals ( 2 , msg . nestedMsg . bb ) ; <nl> - <nl> - msg . defaultNestedEnum = SimpleMessageNano . BAR ; <nl> - assertEquals ( SimpleMessageNano . BAR , msg . defaultNestedEnum ) ; <nl> - <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - SimpleMessageNano newMsg = SimpleMessageNano . parseFrom ( result ) ; <nl> - assertEquals ( 456 , newMsg . d ) ; <nl> - assertEquals ( 2 , msg . nestedMsg . bb ) ; <nl> - assertEquals ( SimpleMessageNano . BAR , msg . defaultNestedEnum ) ; <nl> - <nl> - msg . nestedMsg = null ; <nl> - assertTrue ( msgSerializedSize ! = msg . getSerializedSize ( ) ) ; <nl> - <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . getSerializedSize ( ) ) ; <nl> - } <nl> - <nl> - public void testRecursiveMessageNano ( ) throws Exception { <nl> - RecursiveMessageNano msg = new RecursiveMessageNano ( ) ; <nl> - assertTrue ( msg . repeatedRecursiveMessageNano . length = = 0 ) ; <nl> - <nl> - RecursiveMessageNano msg1 = new RecursiveMessageNano ( ) ; <nl> - msg1 . id = 1 ; <nl> - assertEquals ( 1 , msg1 . id ) ; <nl> - RecursiveMessageNano msg2 = new RecursiveMessageNano ( ) ; <nl> - msg2 . id = 2 ; <nl> - RecursiveMessageNano msg3 = new RecursiveMessageNano ( ) ; <nl> - msg3 . id = 3 ; <nl> - <nl> - RecursiveMessageNano . NestedMessage nestedMsg = new RecursiveMessageNano . NestedMessage ( ) ; <nl> - nestedMsg . a = msg1 ; <nl> - assertEquals ( 1 , nestedMsg . a . id ) ; <nl> - <nl> - msg . id = 0 ; <nl> - msg . nestedMessage = nestedMsg ; <nl> - msg . optionalRecursiveMessageNano = msg2 ; <nl> - msg . repeatedRecursiveMessageNano = new RecursiveMessageNano [ ] { msg3 } ; <nl> - <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 16 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - RecursiveMessageNano newMsg = RecursiveMessageNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedRecursiveMessageNano . length ) ; <nl> - <nl> - assertEquals ( 0 , newMsg . id ) ; <nl> - assertEquals ( 1 , newMsg . nestedMessage . a . id ) ; <nl> - assertEquals ( 2 , newMsg . optionalRecursiveMessageNano . id ) ; <nl> - assertEquals ( 3 , newMsg . repeatedRecursiveMessageNano [ 0 ] . id ) ; <nl> - } <nl> - <nl> - public void testMessageNoFields ( ) { <nl> - SingleMessageNano msg = new SingleMessageNano ( ) ; <nl> - assertEquals ( 0 , msg . getSerializedSize ( ) ) ; <nl> - assertEquals ( 0 , MessageNano . toByteArray ( msg ) . length ) ; <nl> - } <nl> - <nl> - public void testNanoRequiredInt32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . id = 123 ; <nl> - assertEquals ( 123 , msg . id ) ; <nl> - msg . clear ( ) . id = 456 ; <nl> - assertEquals ( 456 , msg . id ) ; <nl> - msg . clear ( ) ; <nl> - <nl> - msg . id = 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 3 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . id ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalInt32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalInt32 = 123 ; <nl> - assertEquals ( 123 , msg . optionalInt32 ) ; <nl> - msg . clear ( ) <nl> - . optionalInt32 = 456 ; <nl> - assertEquals ( 456 , msg . optionalInt32 ) ; <nl> - msg . clear ( ) ; <nl> - <nl> - msg . optionalInt32 = 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 5 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . optionalInt32 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalInt64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalInt64 = 123 ; <nl> - assertEquals ( 123 , msg . optionalInt64 ) ; <nl> - msg . clear ( ) <nl> - . optionalInt64 = 456 ; <nl> - assertEquals ( 456 , msg . optionalInt64 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalInt64 ) ; <nl> - <nl> - msg . optionalInt64 = 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 5 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . optionalInt64 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalUint32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalUint32 = 123 ; <nl> - assertEquals ( 123 , msg . optionalUint32 ) ; <nl> - msg . clear ( ) <nl> - . optionalUint32 = 456 ; <nl> - assertEquals ( 456 , msg . optionalUint32 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalUint32 ) ; <nl> - <nl> - msg . optionalUint32 = 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 5 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . optionalUint32 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalUint64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalUint64 = 123 ; <nl> - assertEquals ( 123 , msg . optionalUint64 ) ; <nl> - msg . clear ( ) <nl> - . optionalUint64 = 456 ; <nl> - assertEquals ( 456 , msg . optionalUint64 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalUint64 ) ; <nl> - <nl> - msg . optionalUint64 = 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 5 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . optionalUint64 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalSint32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalSint32 = 123 ; <nl> - assertEquals ( 123 , msg . optionalSint32 ) ; <nl> - msg . clear ( ) <nl> - . optionalSint32 = 456 ; <nl> - assertEquals ( 456 , msg . optionalSint32 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalSint32 ) ; <nl> - <nl> - msg . optionalSint32 = - 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( - 123 , newMsg . optionalSint32 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalSint64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalSint64 = 123 ; <nl> - assertEquals ( 123 , msg . optionalSint64 ) ; <nl> - msg . clear ( ) <nl> - . optionalSint64 = 456 ; <nl> - assertEquals ( 456 , msg . optionalSint64 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalSint64 ) ; <nl> - <nl> - msg . optionalSint64 = - 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( - 123 , newMsg . optionalSint64 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalFixed32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalFixed32 = 123 ; <nl> - assertEquals ( 123 , msg . optionalFixed32 ) ; <nl> - msg . clear ( ) <nl> - . optionalFixed32 = 456 ; <nl> - assertEquals ( 456 , msg . optionalFixed32 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalFixed32 ) ; <nl> - <nl> - msg . optionalFixed32 = 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . optionalFixed32 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalFixed64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalFixed64 = 123 ; <nl> - assertEquals ( 123 , msg . optionalFixed64 ) ; <nl> - msg . clear ( ) <nl> - . optionalFixed64 = 456 ; <nl> - assertEquals ( 456 , msg . optionalFixed64 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalFixed64 ) ; <nl> - <nl> - msg . optionalFixed64 = 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 12 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . optionalFixed64 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalSfixed32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalSfixed32 = 123 ; <nl> - assertEquals ( 123 , msg . optionalSfixed32 ) ; <nl> - msg . clear ( ) <nl> - . optionalSfixed32 = 456 ; <nl> - assertEquals ( 456 , msg . optionalSfixed32 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalSfixed32 ) ; <nl> - <nl> - msg . optionalSfixed32 = 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . optionalSfixed32 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalSfixed64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalSfixed64 = 123 ; <nl> - assertEquals ( 123 , msg . optionalSfixed64 ) ; <nl> - msg . clear ( ) <nl> - . optionalSfixed64 = 456 ; <nl> - assertEquals ( 456 , msg . optionalSfixed64 ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . optionalSfixed64 ) ; <nl> - <nl> - msg . optionalSfixed64 = - 123 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 12 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( - 123 , newMsg . optionalSfixed64 ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalFloat ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalFloat = 123f ; <nl> - assertTrue ( 123 . 0f = = msg . optionalFloat ) ; <nl> - msg . clear ( ) <nl> - . optionalFloat = 456 . 0f ; <nl> - assertTrue ( 456 . 0f = = msg . optionalFloat ) ; <nl> - msg . clear ( ) ; <nl> - assertTrue ( 0 . 0f = = msg . optionalFloat ) ; <nl> - <nl> - msg . optionalFloat = - 123 . 456f ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( - 123 . 456f = = newMsg . optionalFloat ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalDouble ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalDouble = 123 ; <nl> - assertTrue ( 123 . 0 = = msg . optionalDouble ) ; <nl> - msg . clear ( ) <nl> - . optionalDouble = 456 . 0 ; <nl> - assertTrue ( 456 . 0 = = msg . optionalDouble ) ; <nl> - msg . clear ( ) ; <nl> - assertTrue ( 0 . 0 = = msg . optionalDouble ) ; <nl> - <nl> - msg . optionalDouble = - 123 . 456 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 12 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( - 123 . 456 = = newMsg . optionalDouble ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalBool ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalBool = true ; <nl> - assertTrue ( msg . optionalBool ) ; <nl> - msg . clear ( ) <nl> - . optionalBool = true ; <nl> - assertTrue ( msg . optionalBool ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalBool ) ; <nl> - <nl> - msg . optionalBool = true ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 5 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalBool ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalString ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalString = " hello " ; <nl> - assertEquals ( " hello " , msg . optionalString ) ; <nl> - msg . clear ( ) ; <nl> - assertTrue ( msg . optionalString . isEmpty ( ) ) ; <nl> - msg . clear ( ) <nl> - . optionalString = " hello2 " ; <nl> - assertEquals ( " hello2 " , msg . optionalString ) ; <nl> - msg . clear ( ) ; <nl> - assertTrue ( msg . optionalString . isEmpty ( ) ) ; <nl> - <nl> - msg . optionalString = " bye " ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalString ! = null ) ; <nl> - assertEquals ( " bye " , newMsg . optionalString ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalBytes ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertFalse ( msg . optionalBytes . length > 0 ) ; <nl> - msg . optionalBytes = InternalNano . copyFromUtf8 ( " hello " ) ; <nl> - assertTrue ( msg . optionalBytes . length > 0 ) ; <nl> - assertEquals ( " hello " , new String ( msg . optionalBytes , InternalNano . UTF_8 ) ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalBytes . length > 0 ) ; <nl> - msg . clear ( ) <nl> - . optionalBytes = InternalNano . copyFromUtf8 ( " hello " ) ; <nl> - assertTrue ( msg . optionalBytes . length > 0 ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalBytes . length > 0 ) ; <nl> - <nl> - msg . optionalBytes = InternalNano . copyFromUtf8 ( " bye " ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalBytes . length > 0 ) ; <nl> - assertEquals ( " bye " , new String ( newMsg . optionalBytes , InternalNano . UTF_8 ) ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalGroup ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - TestAllTypesNano . OptionalGroup grp = new TestAllTypesNano . OptionalGroup ( ) ; <nl> - grp . a = 1 ; <nl> - assertFalse ( msg . optionalGroup ! = null ) ; <nl> - msg . optionalGroup = grp ; <nl> - assertTrue ( msg . optionalGroup ! = null ) ; <nl> - assertEquals ( 1 , msg . optionalGroup . a ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalGroup ! = null ) ; <nl> - msg . clear ( ) <nl> - . optionalGroup = new TestAllTypesNano . OptionalGroup ( ) ; <nl> - msg . optionalGroup . a = 2 ; <nl> - assertTrue ( msg . optionalGroup ! = null ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalGroup ! = null ) ; <nl> - <nl> - msg . optionalGroup = grp ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 10 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalGroup ! = null ) ; <nl> - assertEquals ( 1 , newMsg . optionalGroup . a ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalGroupWithUnknownFieldsEnabled ( ) throws Exception { <nl> - MessageWithGroup msg = new MessageWithGroup ( ) ; <nl> - MessageWithGroup . Group grp = new MessageWithGroup . Group ( ) ; <nl> - grp . a = 1 ; <nl> - msg . group = grp ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - MessageWithGroup parsed = MessageWithGroup . parseFrom ( serialized ) ; <nl> - assertEquals ( 1 , parsed . group . a ) ; <nl> - <nl> - byte [ ] serialized2 = MessageNano . toByteArray ( parsed ) ; <nl> - assertEquals ( serialized . length , serialized2 . length ) ; <nl> - MessageWithGroup parsed2 = MessageWithGroup . parseFrom ( serialized2 ) ; <nl> - assertEquals ( 1 , parsed2 . group . a ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalNestedMessage ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - TestAllTypesNano . NestedMessage nestedMsg = new TestAllTypesNano . NestedMessage ( ) ; <nl> - nestedMsg . bb = 1 ; <nl> - assertFalse ( msg . optionalNestedMessage ! = null ) ; <nl> - msg . optionalNestedMessage = nestedMsg ; <nl> - assertTrue ( msg . optionalNestedMessage ! = null ) ; <nl> - assertEquals ( 1 , msg . optionalNestedMessage . bb ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalNestedMessage ! = null ) ; <nl> - msg . clear ( ) <nl> - . optionalNestedMessage = new TestAllTypesNano . NestedMessage ( ) ; <nl> - msg . optionalNestedMessage . bb = 2 ; <nl> - assertTrue ( msg . optionalNestedMessage ! = null ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalNestedMessage ! = null ) ; <nl> - <nl> - msg . optionalNestedMessage = nestedMsg ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalNestedMessage ! = null ) ; <nl> - assertEquals ( 1 , newMsg . optionalNestedMessage . bb ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalForeignMessage ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - NanoOuterClass . ForeignMessageNano nestedMsg = new NanoOuterClass . ForeignMessageNano ( ) ; <nl> - nestedMsg . c = 1 ; <nl> - assertFalse ( msg . optionalForeignMessage ! = null ) ; <nl> - msg . optionalForeignMessage = nestedMsg ; <nl> - assertTrue ( msg . optionalForeignMessage ! = null ) ; <nl> - assertEquals ( 1 , msg . optionalForeignMessage . c ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalForeignMessage ! = null ) ; <nl> - msg . clear ( ) <nl> - . optionalForeignMessage = new NanoOuterClass . ForeignMessageNano ( ) ; <nl> - msg . optionalForeignMessage . c = 2 ; <nl> - assertTrue ( msg . optionalForeignMessage ! = null ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalForeignMessage ! = null ) ; <nl> - <nl> - msg . optionalForeignMessage = nestedMsg ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalForeignMessage ! = null ) ; <nl> - assertEquals ( 1 , newMsg . optionalForeignMessage . c ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalImportMessage ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - UnittestImportNano . ImportMessageNano nestedMsg = new UnittestImportNano . ImportMessageNano ( ) ; <nl> - nestedMsg . d = 1 ; <nl> - assertFalse ( msg . optionalImportMessage ! = null ) ; <nl> - msg . optionalImportMessage = nestedMsg ; <nl> - assertTrue ( msg . optionalImportMessage ! = null ) ; <nl> - assertEquals ( 1 , msg . optionalImportMessage . d ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalImportMessage ! = null ) ; <nl> - msg . clear ( ) <nl> - . optionalImportMessage = new UnittestImportNano . ImportMessageNano ( ) ; <nl> - msg . optionalImportMessage . d = 2 ; <nl> - assertTrue ( msg . optionalImportMessage ! = null ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . optionalImportMessage ! = null ) ; <nl> - <nl> - msg . optionalImportMessage = nestedMsg ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalImportMessage ! = null ) ; <nl> - assertEquals ( 1 , newMsg . optionalImportMessage . d ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalNestedEnum ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalNestedEnum = TestAllTypesNano . BAR ; <nl> - assertEquals ( TestAllTypesNano . BAR , msg . optionalNestedEnum ) ; <nl> - msg . clear ( ) <nl> - . optionalNestedEnum = TestAllTypesNano . BAZ ; <nl> - assertEquals ( TestAllTypesNano . BAZ , msg . optionalNestedEnum ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , msg . optionalNestedEnum ) ; <nl> - <nl> - msg . optionalNestedEnum = TestAllTypesNano . BAR ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , newMsg . optionalNestedEnum ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalForeignEnum ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalForeignEnum = NanoOuterClass . FOREIGN_NANO_BAR ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_BAR , msg . optionalForeignEnum ) ; <nl> - msg . clear ( ) <nl> - . optionalForeignEnum = NanoOuterClass . FOREIGN_NANO_BAZ ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_BAZ , msg . optionalForeignEnum ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_FOO , msg . optionalForeignEnum ) ; <nl> - <nl> - msg . optionalForeignEnum = NanoOuterClass . FOREIGN_NANO_BAR ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_BAR , newMsg . optionalForeignEnum ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalImportEnum ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalImportEnum = UnittestImportNano . IMPORT_NANO_BAR ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_BAR , msg . optionalImportEnum ) ; <nl> - msg . clear ( ) <nl> - . optionalImportEnum = UnittestImportNano . IMPORT_NANO_BAZ ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_BAZ , msg . optionalImportEnum ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_FOO , msg . optionalImportEnum ) ; <nl> - <nl> - msg . optionalImportEnum = UnittestImportNano . IMPORT_NANO_BAR ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_BAR , newMsg . optionalImportEnum ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalStringPiece ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalStringPiece = " hello " ; <nl> - assertEquals ( " hello " , msg . optionalStringPiece ) ; <nl> - msg . clear ( ) ; <nl> - assertTrue ( msg . optionalStringPiece . isEmpty ( ) ) ; <nl> - msg . clear ( ) <nl> - . optionalStringPiece = " hello2 " ; <nl> - assertEquals ( " hello2 " , msg . optionalStringPiece ) ; <nl> - msg . clear ( ) ; <nl> - assertTrue ( msg . optionalStringPiece . isEmpty ( ) ) ; <nl> - <nl> - msg . optionalStringPiece = " bye " ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalStringPiece ! = null ) ; <nl> - assertEquals ( " bye " , newMsg . optionalStringPiece ) ; <nl> - } <nl> - <nl> - public void testNanoOptionalCord ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalCord = " hello " ; <nl> - assertEquals ( " hello " , msg . optionalCord ) ; <nl> - msg . clear ( ) ; <nl> - assertTrue ( msg . optionalCord . isEmpty ( ) ) ; <nl> - msg . clear ( ) <nl> - . optionalCord = " hello2 " ; <nl> - assertEquals ( " hello2 " , msg . optionalCord ) ; <nl> - msg . clear ( ) ; <nl> - assertTrue ( msg . optionalCord . isEmpty ( ) ) ; <nl> - <nl> - msg . optionalCord = " bye " ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . optionalCord ! = null ) ; <nl> - assertEquals ( " bye " , newMsg . optionalCord ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedInt32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedInt32 . length ) ; <nl> - msg . repeatedInt32 = new int [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedInt32 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedInt32 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedInt32 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedInt32 = new int [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedInt32 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedInt32 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedInt32 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedInt32 = new int [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedInt32 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedInt32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedInt32 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedInt32 = new int [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedInt32 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 10 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedInt32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedInt32 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedInt32 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedInt64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedInt64 . length ) ; <nl> - msg . repeatedInt64 = new long [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedInt64 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedInt64 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedInt64 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedInt64 = new long [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedInt64 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedInt64 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedInt64 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedInt64 = new long [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedInt64 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedInt64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedInt64 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedInt64 = new long [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedInt64 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 10 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedInt64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedInt64 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedInt64 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedUint32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedUint32 . length ) ; <nl> - msg . repeatedUint32 = new int [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedUint32 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedUint32 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedUint32 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedUint32 = new int [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedUint32 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedUint32 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedUint32 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedUint32 = new int [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedUint32 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedUint32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedUint32 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedUint32 = new int [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedUint32 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 10 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedUint32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedUint32 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedUint32 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedUint64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedUint64 . length ) ; <nl> - msg . repeatedUint64 = new long [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedUint64 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedUint64 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedUint64 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedUint64 = new long [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedUint64 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedUint64 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedUint64 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedUint64 = new long [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedUint64 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedUint64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedUint64 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedUint64 = new long [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedUint64 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 10 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedUint64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedUint64 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedUint64 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedSint32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSint32 . length ) ; <nl> - msg . repeatedSint32 = new int [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedSint32 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedSint32 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSint32 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedSint32 = new int [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedSint32 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedSint32 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSint32 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedSint32 = new int [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedSint32 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 7 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedSint32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedSint32 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedSint32 = new int [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedSint32 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 11 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedSint32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedSint32 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedSint32 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedSint64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSint64 . length ) ; <nl> - msg . repeatedSint64 = new long [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedSint64 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedSint64 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSint64 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedSint64 = new long [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedSint64 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedSint64 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSint64 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedSint64 = new long [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedSint64 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 7 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedSint64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedSint64 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedSint64 = new long [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedSint64 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 11 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedSint64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedSint64 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedSint64 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedFixed32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFixed32 . length ) ; <nl> - msg . repeatedFixed32 = new int [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedFixed32 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedFixed32 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFixed32 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedFixed32 = new int [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedFixed32 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedFixed32 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFixed32 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedFixed32 = new int [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedFixed32 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedFixed32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedFixed32 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedFixed32 = new int [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedFixed32 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 15 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedFixed32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedFixed32 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedFixed32 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedFixed64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFixed64 . length ) ; <nl> - msg . repeatedFixed64 = new long [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedFixed64 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedFixed64 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFixed64 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedFixed64 = new long [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedFixed64 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedFixed64 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFixed64 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedFixed64 = new long [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedFixed64 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 13 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedFixed64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedFixed64 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedFixed64 = new long [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedFixed64 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 23 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedFixed64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedFixed64 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedFixed64 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedSfixed32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSfixed32 . length ) ; <nl> - msg . repeatedSfixed32 = new int [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedSfixed32 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedSfixed32 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSfixed32 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedSfixed32 = new int [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedSfixed32 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedSfixed32 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSfixed32 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedSfixed32 = new int [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedSfixed32 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedSfixed32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedSfixed32 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedSfixed32 = new int [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedSfixed32 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 15 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedSfixed32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedSfixed32 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedSfixed32 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedSfixed64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSfixed64 . length ) ; <nl> - msg . repeatedSfixed64 = new long [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedSfixed64 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedSfixed64 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSfixed64 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedSfixed64 = new long [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedSfixed64 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedSfixed64 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedSfixed64 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedSfixed64 = new long [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedSfixed64 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 13 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedSfixed64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedSfixed64 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedSfixed64 = new long [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedSfixed64 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 23 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedSfixed64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedSfixed64 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedSfixed64 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedFloat ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFloat . length ) ; <nl> - msg . repeatedFloat = new float [ ] { 123f , 789f , 456f } ; <nl> - assertEquals ( 789f , msg . repeatedFloat [ 1 ] ) ; <nl> - assertEquals ( 456f , msg . repeatedFloat [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFloat . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedFloat = new float [ ] { 456f } ; <nl> - assertEquals ( 1 , msg . repeatedFloat . length ) ; <nl> - assertEquals ( 456f , msg . repeatedFloat [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedFloat . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedFloat = new float [ ] { 123f } ; <nl> - assertEquals ( 1 , msg . repeatedFloat . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedFloat . length ) ; <nl> - assertEquals ( 123f , newMsg . repeatedFloat [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedFloat = new float [ ] { 123f , 456f } ; <nl> - assertEquals ( 2 , msg . repeatedFloat . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 15 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedFloat . length ) ; <nl> - assertEquals ( 123f , newMsg . repeatedFloat [ 0 ] ) ; <nl> - assertEquals ( 456f , newMsg . repeatedFloat [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedDouble ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedDouble . length ) ; <nl> - msg . repeatedDouble = new double [ ] { 123 . 0 , 789 . 0 , 456 . 0 } ; <nl> - assertEquals ( 789 . 0 , msg . repeatedDouble [ 1 ] ) ; <nl> - assertEquals ( 456 . 0 , msg . repeatedDouble [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedDouble . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedDouble = new double [ ] { 456 . 0 } ; <nl> - assertEquals ( 1 , msg . repeatedDouble . length ) ; <nl> - assertEquals ( 456 . 0 , msg . repeatedDouble [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedDouble . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedDouble = new double [ ] { 123 . 0 } ; <nl> - assertEquals ( 1 , msg . repeatedDouble . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 13 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedDouble . length ) ; <nl> - assertEquals ( 123 . 0 , newMsg . repeatedDouble [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedDouble = new double [ ] { 123 . 0 , 456 . 0 } ; <nl> - assertEquals ( 2 , msg . repeatedDouble . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 23 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedDouble . length ) ; <nl> - assertEquals ( 123 . 0 , newMsg . repeatedDouble [ 0 ] ) ; <nl> - assertEquals ( 456 . 0 , newMsg . repeatedDouble [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedBool ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedBool . length ) ; <nl> - msg . repeatedBool = new boolean [ ] { false , true , false } ; <nl> - assertTrue ( msg . repeatedBool [ 1 ] ) ; <nl> - assertFalse ( msg . repeatedBool [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedBool . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedBool = new boolean [ ] { true } ; <nl> - assertEquals ( 1 , msg . repeatedBool . length ) ; <nl> - assertTrue ( msg . repeatedBool [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedBool . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedBool = new boolean [ ] { false } ; <nl> - assertEquals ( 1 , msg . repeatedBool . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedBool . length ) ; <nl> - assertFalse ( newMsg . repeatedBool [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedBool = new boolean [ ] { true , false } ; <nl> - assertEquals ( 2 , msg . repeatedBool . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedBool . length ) ; <nl> - assertTrue ( newMsg . repeatedBool [ 0 ] ) ; <nl> - assertFalse ( newMsg . repeatedBool [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedString ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedString . length ) ; <nl> - msg . repeatedString = new String [ ] { " hello " , " bye " , " boo " } ; <nl> - assertEquals ( " bye " , msg . repeatedString [ 1 ] ) ; <nl> - assertEquals ( " boo " , msg . repeatedString [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedString . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedString = new String [ ] { " boo " } ; <nl> - assertEquals ( 1 , msg . repeatedString . length ) ; <nl> - assertEquals ( " boo " , msg . repeatedString [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedString . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedString = new String [ ] { " " } ; <nl> - assertEquals ( 1 , msg . repeatedString . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedString . length ) ; <nl> - assertTrue ( newMsg . repeatedString [ 0 ] . isEmpty ( ) ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedString = new String [ ] { " hello " , " world " } ; <nl> - assertEquals ( 2 , msg . repeatedString . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 19 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedString . length ) ; <nl> - assertEquals ( " hello " , newMsg . repeatedString [ 0 ] ) ; <nl> - assertEquals ( " world " , newMsg . repeatedString [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedBytes ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedBytes . length ) ; <nl> - msg . repeatedBytes = new byte [ ] [ ] { <nl> - InternalNano . copyFromUtf8 ( " hello " ) , <nl> - InternalNano . copyFromUtf8 ( " bye " ) , <nl> - InternalNano . copyFromUtf8 ( " boo " ) <nl> - } ; <nl> - assertEquals ( " bye " , new String ( msg . repeatedBytes [ 1 ] , InternalNano . UTF_8 ) ) ; <nl> - assertEquals ( " boo " , new String ( msg . repeatedBytes [ 2 ] , InternalNano . UTF_8 ) ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedBytes . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedBytes = new byte [ ] [ ] { InternalNano . copyFromUtf8 ( " boo " ) } ; <nl> - assertEquals ( 1 , msg . repeatedBytes . length ) ; <nl> - assertEquals ( " boo " , new String ( msg . repeatedBytes [ 0 ] , InternalNano . UTF_8 ) ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedBytes . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedBytes = new byte [ ] [ ] { InternalNano . copyFromUtf8 ( " " ) } ; <nl> - assertEquals ( 1 , msg . repeatedBytes . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedBytes . length ) ; <nl> - assertTrue ( newMsg . repeatedBytes [ 0 ] . length = = 0 ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedBytes = new byte [ ] [ ] { <nl> - InternalNano . copyFromUtf8 ( " hello " ) , <nl> - InternalNano . copyFromUtf8 ( " world " ) <nl> - } ; <nl> - assertEquals ( 2 , msg . repeatedBytes . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 19 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedBytes . length ) ; <nl> - assertEquals ( " hello " , new String ( newMsg . repeatedBytes [ 0 ] , InternalNano . UTF_8 ) ) ; <nl> - assertEquals ( " world " , new String ( newMsg . repeatedBytes [ 1 ] , InternalNano . UTF_8 ) ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedGroup ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - TestAllTypesNano . RepeatedGroup group0 = <nl> - new TestAllTypesNano . RepeatedGroup ( ) ; <nl> - group0 . a = 0 ; <nl> - TestAllTypesNano . RepeatedGroup group1 = <nl> - new TestAllTypesNano . RepeatedGroup ( ) ; <nl> - group1 . a = 1 ; <nl> - TestAllTypesNano . RepeatedGroup group2 = <nl> - new TestAllTypesNano . RepeatedGroup ( ) ; <nl> - group2 . a = 2 ; <nl> - <nl> - msg . repeatedGroup = new TestAllTypesNano . RepeatedGroup [ ] { group0 , group1 , group2 } ; <nl> - assertEquals ( 3 , msg . repeatedGroup . length ) ; <nl> - assertEquals ( 0 , msg . repeatedGroup [ 0 ] . a ) ; <nl> - assertEquals ( 1 , msg . repeatedGroup [ 1 ] . a ) ; <nl> - assertEquals ( 2 , msg . repeatedGroup [ 2 ] . a ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedGroup . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedGroup = new TestAllTypesNano . RepeatedGroup [ ] { group1 } ; <nl> - assertEquals ( 1 , msg . repeatedGroup . length ) ; <nl> - assertEquals ( 1 , msg . repeatedGroup [ 0 ] . a ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedGroup . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedGroup = new TestAllTypesNano . RepeatedGroup [ ] { group0 } ; <nl> - assertEquals ( 1 , msg . repeatedGroup . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 7 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedGroup . length ) ; <nl> - assertEquals ( 0 , newMsg . repeatedGroup [ 0 ] . a ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedGroup = new TestAllTypesNano . RepeatedGroup [ ] { group0 , group1 } ; <nl> - assertEquals ( 2 , msg . repeatedGroup . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 14 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedGroup . length ) ; <nl> - assertEquals ( 0 , newMsg . repeatedGroup [ 0 ] . a ) ; <nl> - assertEquals ( 1 , newMsg . repeatedGroup [ 1 ] . a ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedNestedMessage ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - TestAllTypesNano . NestedMessage nestedMsg0 = <nl> - new TestAllTypesNano . NestedMessage ( ) ; <nl> - nestedMsg0 . bb = 0 ; <nl> - TestAllTypesNano . NestedMessage nestedMsg1 = <nl> - new TestAllTypesNano . NestedMessage ( ) ; <nl> - nestedMsg1 . bb = 1 ; <nl> - TestAllTypesNano . NestedMessage nestedMsg2 = <nl> - new TestAllTypesNano . NestedMessage ( ) ; <nl> - nestedMsg2 . bb = 2 ; <nl> - <nl> - msg . repeatedNestedMessage = <nl> - new TestAllTypesNano . NestedMessage [ ] { nestedMsg0 , nestedMsg1 , nestedMsg2 } ; <nl> - assertEquals ( 3 , msg . repeatedNestedMessage . length ) ; <nl> - assertEquals ( 0 , msg . repeatedNestedMessage [ 0 ] . bb ) ; <nl> - assertEquals ( 1 , msg . repeatedNestedMessage [ 1 ] . bb ) ; <nl> - assertEquals ( 2 , msg . repeatedNestedMessage [ 2 ] . bb ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedNestedMessage . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ ] { nestedMsg1 } ; <nl> - assertEquals ( 1 , msg . repeatedNestedMessage . length ) ; <nl> - assertEquals ( 1 , msg . repeatedNestedMessage [ 0 ] . bb ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedNestedMessage . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ ] { nestedMsg0 } ; <nl> - assertEquals ( 1 , msg . repeatedNestedMessage . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedNestedMessage . length ) ; <nl> - assertEquals ( 0 , newMsg . repeatedNestedMessage [ 0 ] . bb ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ ] { nestedMsg0 , nestedMsg1 } ; <nl> - assertEquals ( 2 , msg . repeatedNestedMessage . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 11 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedNestedMessage . length ) ; <nl> - assertEquals ( 0 , newMsg . repeatedNestedMessage [ 0 ] . bb ) ; <nl> - assertEquals ( 1 , newMsg . repeatedNestedMessage [ 1 ] . bb ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedForeignMessage ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - NanoOuterClass . ForeignMessageNano foreignMsg0 = <nl> - new NanoOuterClass . ForeignMessageNano ( ) ; <nl> - foreignMsg0 . c = 0 ; <nl> - NanoOuterClass . ForeignMessageNano foreignMsg1 = <nl> - new NanoOuterClass . ForeignMessageNano ( ) ; <nl> - foreignMsg1 . c = 1 ; <nl> - NanoOuterClass . ForeignMessageNano foreignMsg2 = <nl> - new NanoOuterClass . ForeignMessageNano ( ) ; <nl> - foreignMsg2 . c = 2 ; <nl> - <nl> - msg . repeatedForeignMessage = <nl> - new NanoOuterClass . ForeignMessageNano [ ] { foreignMsg0 , foreignMsg1 , foreignMsg2 } ; <nl> - assertEquals ( 3 , msg . repeatedForeignMessage . length ) ; <nl> - assertEquals ( 0 , msg . repeatedForeignMessage [ 0 ] . c ) ; <nl> - assertEquals ( 1 , msg . repeatedForeignMessage [ 1 ] . c ) ; <nl> - assertEquals ( 2 , msg . repeatedForeignMessage [ 2 ] . c ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedForeignMessage . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedForeignMessage = new NanoOuterClass . ForeignMessageNano [ ] { foreignMsg1 } ; <nl> - assertEquals ( 1 , msg . repeatedForeignMessage . length ) ; <nl> - assertEquals ( 1 , msg . repeatedForeignMessage [ 0 ] . c ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedForeignMessage . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedForeignMessage = new NanoOuterClass . ForeignMessageNano [ ] { foreignMsg0 } ; <nl> - assertEquals ( 1 , msg . repeatedForeignMessage . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedForeignMessage . length ) ; <nl> - assertEquals ( 0 , newMsg . repeatedForeignMessage [ 0 ] . c ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedForeignMessage = new NanoOuterClass . ForeignMessageNano [ ] { foreignMsg0 , foreignMsg1 } ; <nl> - assertEquals ( 2 , msg . repeatedForeignMessage . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 11 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedForeignMessage . length ) ; <nl> - assertEquals ( 0 , newMsg . repeatedForeignMessage [ 0 ] . c ) ; <nl> - assertEquals ( 1 , newMsg . repeatedForeignMessage [ 1 ] . c ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedImportMessage ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - UnittestImportNano . ImportMessageNano foreignMsg0 = <nl> - new UnittestImportNano . ImportMessageNano ( ) ; <nl> - foreignMsg0 . d = 0 ; <nl> - UnittestImportNano . ImportMessageNano foreignMsg1 = <nl> - new UnittestImportNano . ImportMessageNano ( ) ; <nl> - foreignMsg1 . d = 1 ; <nl> - UnittestImportNano . ImportMessageNano foreignMsg2 = <nl> - new UnittestImportNano . ImportMessageNano ( ) ; <nl> - foreignMsg2 . d = 2 ; <nl> - <nl> - msg . repeatedImportMessage = <nl> - new UnittestImportNano . ImportMessageNano [ ] { foreignMsg0 , foreignMsg1 , foreignMsg2 } ; <nl> - assertEquals ( 3 , msg . repeatedImportMessage . length ) ; <nl> - assertEquals ( 0 , msg . repeatedImportMessage [ 0 ] . d ) ; <nl> - assertEquals ( 1 , msg . repeatedImportMessage [ 1 ] . d ) ; <nl> - assertEquals ( 2 , msg . repeatedImportMessage [ 2 ] . d ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedImportMessage . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedImportMessage = new UnittestImportNano . ImportMessageNano [ ] { foreignMsg1 } ; <nl> - assertEquals ( 1 , msg . repeatedImportMessage . length ) ; <nl> - assertEquals ( 1 , msg . repeatedImportMessage [ 0 ] . d ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedImportMessage . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedImportMessage = new UnittestImportNano . ImportMessageNano [ ] { foreignMsg0 } ; <nl> - assertEquals ( 1 , msg . repeatedImportMessage . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedImportMessage . length ) ; <nl> - assertEquals ( 0 , newMsg . repeatedImportMessage [ 0 ] . d ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedImportMessage = new UnittestImportNano . ImportMessageNano [ ] { foreignMsg0 , foreignMsg1 } ; <nl> - assertEquals ( 2 , msg . repeatedImportMessage . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 11 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedImportMessage . length ) ; <nl> - assertEquals ( 0 , newMsg . repeatedImportMessage [ 0 ] . d ) ; <nl> - assertEquals ( 1 , newMsg . repeatedImportMessage [ 1 ] . d ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedNestedEnum ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . repeatedNestedEnum = new int [ ] { <nl> - TestAllTypesNano . FOO , <nl> - TestAllTypesNano . BAR , <nl> - TestAllTypesNano . BAZ <nl> - } ; <nl> - assertEquals ( 3 , msg . repeatedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , msg . repeatedNestedEnum [ 0 ] ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , msg . repeatedNestedEnum [ 1 ] ) ; <nl> - assertEquals ( TestAllTypesNano . BAZ , msg . repeatedNestedEnum [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedNestedEnum . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedNestedEnum = new int [ ] { TestAllTypesNano . BAR } ; <nl> - assertEquals ( 1 , msg . repeatedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , msg . repeatedNestedEnum [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedNestedEnum . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedNestedEnum = new int [ ] { TestAllTypesNano . FOO } ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , msg . repeatedNestedEnum [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedNestedEnum = new int [ ] { TestAllTypesNano . FOO , TestAllTypesNano . BAR } ; <nl> - assertEquals ( 2 , msg . repeatedNestedEnum . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , msg . repeatedNestedEnum [ 0 ] ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , msg . repeatedNestedEnum [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedForeignEnum ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . repeatedForeignEnum = new int [ ] { <nl> - NanoOuterClass . FOREIGN_NANO_FOO , <nl> - NanoOuterClass . FOREIGN_NANO_BAR , <nl> - NanoOuterClass . FOREIGN_NANO_BAZ <nl> - } ; <nl> - assertEquals ( 3 , msg . repeatedForeignEnum . length ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_FOO , msg . repeatedForeignEnum [ 0 ] ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_BAR , msg . repeatedForeignEnum [ 1 ] ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_BAZ , msg . repeatedForeignEnum [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedForeignEnum . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedForeignEnum = new int [ ] { NanoOuterClass . FOREIGN_NANO_BAR } ; <nl> - assertEquals ( 1 , msg . repeatedForeignEnum . length ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_BAR , msg . repeatedForeignEnum [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedForeignEnum . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedForeignEnum = new int [ ] { NanoOuterClass . FOREIGN_NANO_FOO } ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedForeignEnum . length ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_FOO , msg . repeatedForeignEnum [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedForeignEnum = new int [ ] { <nl> - NanoOuterClass . FOREIGN_NANO_FOO , <nl> - NanoOuterClass . FOREIGN_NANO_BAR <nl> - } ; <nl> - assertEquals ( 2 , msg . repeatedForeignEnum . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedForeignEnum . length ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_FOO , msg . repeatedForeignEnum [ 0 ] ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_BAR , msg . repeatedForeignEnum [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedImportEnum ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . repeatedImportEnum = new int [ ] { <nl> - UnittestImportNano . IMPORT_NANO_FOO , <nl> - UnittestImportNano . IMPORT_NANO_BAR , <nl> - UnittestImportNano . IMPORT_NANO_BAZ <nl> - } ; <nl> - assertEquals ( 3 , msg . repeatedImportEnum . length ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_FOO , msg . repeatedImportEnum [ 0 ] ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_BAR , msg . repeatedImportEnum [ 1 ] ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_BAZ , msg . repeatedImportEnum [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedImportEnum . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedImportEnum = new int [ ] { UnittestImportNano . IMPORT_NANO_BAR } ; <nl> - assertEquals ( 1 , msg . repeatedImportEnum . length ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_BAR , msg . repeatedImportEnum [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedImportEnum . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedImportEnum = new int [ ] { UnittestImportNano . IMPORT_NANO_FOO } ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedImportEnum . length ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_FOO , msg . repeatedImportEnum [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedImportEnum = new int [ ] { <nl> - UnittestImportNano . IMPORT_NANO_FOO , <nl> - UnittestImportNano . IMPORT_NANO_BAR <nl> - } ; <nl> - assertEquals ( 2 , msg . repeatedImportEnum . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedImportEnum . length ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_FOO , msg . repeatedImportEnum [ 0 ] ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_BAR , msg . repeatedImportEnum [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedStringPiece ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedStringPiece . length ) ; <nl> - msg . repeatedStringPiece = new String [ ] { " hello " , " bye " , " boo " } ; <nl> - assertEquals ( " bye " , msg . repeatedStringPiece [ 1 ] ) ; <nl> - assertEquals ( " boo " , msg . repeatedStringPiece [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedStringPiece . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedStringPiece = new String [ ] { " boo " } ; <nl> - assertEquals ( 1 , msg . repeatedStringPiece . length ) ; <nl> - assertEquals ( " boo " , msg . repeatedStringPiece [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedStringPiece . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedStringPiece = new String [ ] { " " } ; <nl> - assertEquals ( 1 , msg . repeatedStringPiece . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedStringPiece . length ) ; <nl> - assertTrue ( newMsg . repeatedStringPiece [ 0 ] . isEmpty ( ) ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedStringPiece = new String [ ] { " hello " , " world " } ; <nl> - assertEquals ( 2 , msg . repeatedStringPiece . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 19 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedStringPiece . length ) ; <nl> - assertEquals ( " hello " , newMsg . repeatedStringPiece [ 0 ] ) ; <nl> - assertEquals ( " world " , newMsg . repeatedStringPiece [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedCord ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedCord . length ) ; <nl> - msg . repeatedCord = new String [ ] { " hello " , " bye " , " boo " } ; <nl> - assertEquals ( " bye " , msg . repeatedCord [ 1 ] ) ; <nl> - assertEquals ( " boo " , msg . repeatedCord [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedCord . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedCord = new String [ ] { " boo " } ; <nl> - assertEquals ( 1 , msg . repeatedCord . length ) ; <nl> - assertEquals ( " boo " , msg . repeatedCord [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedCord . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedCord = new String [ ] { " " } ; <nl> - assertEquals ( 1 , msg . repeatedCord . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 6 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedCord . length ) ; <nl> - assertTrue ( newMsg . repeatedCord [ 0 ] . isEmpty ( ) ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedCord = new String [ ] { " hello " , " world " } ; <nl> - assertEquals ( 2 , msg . repeatedCord . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 19 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedCord . length ) ; <nl> - assertEquals ( " hello " , newMsg . repeatedCord [ 0 ] ) ; <nl> - assertEquals ( " world " , newMsg . repeatedCord [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedPackedInt32 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedPackedInt32 . length ) ; <nl> - msg . repeatedPackedInt32 = new int [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedPackedInt32 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedPackedInt32 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedPackedInt32 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedPackedInt32 = new int [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedPackedInt32 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedPackedInt32 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedPackedInt32 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedPackedInt32 = new int [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedPackedInt32 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 7 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedPackedInt32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedPackedInt32 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedPackedInt32 = new int [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedPackedInt32 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 9 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedPackedInt32 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedPackedInt32 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedPackedInt32 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedPackedSfixed64 ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - assertEquals ( 0 , msg . repeatedPackedSfixed64 . length ) ; <nl> - msg . repeatedPackedSfixed64 = new long [ ] { 123 , 789 , 456 } ; <nl> - assertEquals ( 789 , msg . repeatedPackedSfixed64 [ 1 ] ) ; <nl> - assertEquals ( 456 , msg . repeatedPackedSfixed64 [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedPackedSfixed64 . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedPackedSfixed64 = new long [ ] { 456 } ; <nl> - assertEquals ( 1 , msg . repeatedPackedSfixed64 . length ) ; <nl> - assertEquals ( 456 , msg . repeatedPackedSfixed64 [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedPackedSfixed64 . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedPackedSfixed64 = new long [ ] { 123 } ; <nl> - assertEquals ( 1 , msg . repeatedPackedSfixed64 . length ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 14 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedPackedSfixed64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedPackedSfixed64 [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedPackedSfixed64 = new long [ ] { 123 , 456 } ; <nl> - assertEquals ( 2 , msg . repeatedPackedSfixed64 . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 22 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedPackedSfixed64 . length ) ; <nl> - assertEquals ( 123 , newMsg . repeatedPackedSfixed64 [ 0 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedPackedSfixed64 [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedPackedNestedEnum ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . repeatedPackedNestedEnum = new int [ ] { <nl> - TestAllTypesNano . FOO , <nl> - TestAllTypesNano . BAR , <nl> - TestAllTypesNano . BAZ <nl> - } ; <nl> - assertEquals ( 3 , msg . repeatedPackedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , msg . repeatedPackedNestedEnum [ 0 ] ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , msg . repeatedPackedNestedEnum [ 1 ] ) ; <nl> - assertEquals ( TestAllTypesNano . BAZ , msg . repeatedPackedNestedEnum [ 2 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedPackedNestedEnum . length ) ; <nl> - msg . clear ( ) <nl> - . repeatedPackedNestedEnum = new int [ ] { TestAllTypesNano . BAR } ; <nl> - assertEquals ( 1 , msg . repeatedPackedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , msg . repeatedPackedNestedEnum [ 0 ] ) ; <nl> - msg . clear ( ) ; <nl> - assertEquals ( 0 , msg . repeatedPackedNestedEnum . length ) ; <nl> - <nl> - / / Test 1 entry <nl> - msg . clear ( ) <nl> - . repeatedPackedNestedEnum = new int [ ] { TestAllTypesNano . FOO } ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 7 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 1 , newMsg . repeatedPackedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , msg . repeatedPackedNestedEnum [ 0 ] ) ; <nl> - <nl> - / / Test 2 entries <nl> - msg . clear ( ) <nl> - . repeatedPackedNestedEnum = new int [ ] { TestAllTypesNano . FOO , TestAllTypesNano . BAR } ; <nl> - assertEquals ( 2 , msg . repeatedPackedNestedEnum . length ) ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 8 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . repeatedPackedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , msg . repeatedPackedNestedEnum [ 0 ] ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , msg . repeatedPackedNestedEnum [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedPackedSerializedSize ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . repeatedPackedInt32 = new int [ ] { 123 , 789 , 456 } ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 11 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - TestAllTypesNano msg2 = new TestAllTypesNano ( ) ; <nl> - msg2 . repeatedPackedInt32 = new int [ ] { 123 , 789 , 456 } ; <nl> - byte [ ] result2 = new byte [ msgSerializedSize ] ; <nl> - MessageNano . toByteArray ( msg2 , result2 , 0 , msgSerializedSize ) ; <nl> - <nl> - / / Check equal size and content . <nl> - assertEquals ( msgSerializedSize , msg2 . getSerializedSize ( ) ) ; <nl> - assertTrue ( Arrays . equals ( result , result2 ) ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedInt32ReMerge ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . repeatedInt32 = new int [ ] { 234 } ; <nl> - byte [ ] result1 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - msg . clear ( ) . optionalInt32 = 789 ; <nl> - byte [ ] result2 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - msg . clear ( ) . repeatedInt32 = new int [ ] { 123 , 456 } ; <nl> - byte [ ] result3 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - / / Concatenate the three serializations and read as one message . <nl> - byte [ ] result = new byte [ result1 . length + result2 . length + result3 . length ] ; <nl> - System . arraycopy ( result1 , 0 , result , 0 , result1 . length ) ; <nl> - System . arraycopy ( result2 , 0 , result , result1 . length , result2 . length ) ; <nl> - System . arraycopy ( result3 , 0 , result , result1 . length + result2 . length , result3 . length ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 789 , newMsg . optionalInt32 ) ; <nl> - assertEquals ( 3 , newMsg . repeatedInt32 . length ) ; <nl> - assertEquals ( 234 , newMsg . repeatedInt32 [ 0 ] ) ; <nl> - assertEquals ( 123 , newMsg . repeatedInt32 [ 1 ] ) ; <nl> - assertEquals ( 456 , newMsg . repeatedInt32 [ 2 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedNestedEnumReMerge ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . repeatedNestedEnum = new int [ ] { TestAllTypesNano . FOO } ; <nl> - byte [ ] result1 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - msg . clear ( ) . optionalInt32 = 789 ; <nl> - byte [ ] result2 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - msg . clear ( ) . repeatedNestedEnum = new int [ ] { TestAllTypesNano . BAR , TestAllTypesNano . FOO } ; <nl> - byte [ ] result3 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - / / Concatenate the three serializations and read as one message . <nl> - byte [ ] result = new byte [ result1 . length + result2 . length + result3 . length ] ; <nl> - System . arraycopy ( result1 , 0 , result , 0 , result1 . length ) ; <nl> - System . arraycopy ( result2 , 0 , result , result1 . length , result2 . length ) ; <nl> - System . arraycopy ( result3 , 0 , result , result1 . length + result2 . length , result3 . length ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 789 , newMsg . optionalInt32 ) ; <nl> - assertEquals ( 3 , newMsg . repeatedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , newMsg . repeatedNestedEnum [ 0 ] ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , newMsg . repeatedNestedEnum [ 1 ] ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , newMsg . repeatedNestedEnum [ 2 ] ) ; <nl> - } <nl> - <nl> - public void testNanoRepeatedNestedMessageReMerge ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - TestAllTypesNano . NestedMessage nestedMsg0 = <nl> - new TestAllTypesNano . NestedMessage ( ) ; <nl> - nestedMsg0 . bb = 0 ; <nl> - TestAllTypesNano . NestedMessage nestedMsg1 = <nl> - new TestAllTypesNano . NestedMessage ( ) ; <nl> - nestedMsg1 . bb = 1 ; <nl> - TestAllTypesNano . NestedMessage nestedMsg2 = <nl> - new TestAllTypesNano . NestedMessage ( ) ; <nl> - nestedMsg2 . bb = 2 ; <nl> - <nl> - msg . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ ] { nestedMsg0 } ; <nl> - byte [ ] result1 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - msg . clear ( ) . optionalInt32 = 789 ; <nl> - byte [ ] result2 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - msg . clear ( ) . repeatedNestedMessage = <nl> - new TestAllTypesNano . NestedMessage [ ] { nestedMsg1 , nestedMsg2 } ; <nl> - byte [ ] result3 = MessageNano . toByteArray ( msg ) ; <nl> - <nl> - / / Concatenate the three serializations and read as one message . <nl> - byte [ ] result = new byte [ result1 . length + result2 . length + result3 . length ] ; <nl> - System . arraycopy ( result1 , 0 , result , 0 , result1 . length ) ; <nl> - System . arraycopy ( result2 , 0 , result , result1 . length , result2 . length ) ; <nl> - System . arraycopy ( result3 , 0 , result , result1 . length + result2 . length , result3 . length ) ; <nl> - <nl> - TestAllTypesNano newMsg = TestAllTypesNano . parseFrom ( result ) ; <nl> - assertEquals ( 789 , newMsg . optionalInt32 ) ; <nl> - assertEquals ( 3 , newMsg . repeatedNestedMessage . length ) ; <nl> - assertEquals ( nestedMsg0 . bb , newMsg . repeatedNestedMessage [ 0 ] . bb ) ; <nl> - assertEquals ( nestedMsg1 . bb , newMsg . repeatedNestedMessage [ 1 ] . bb ) ; <nl> - assertEquals ( nestedMsg2 . bb , newMsg . repeatedNestedMessage [ 2 ] . bb ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Tests that invalid enum values from the wire are not accepted . <nl> - * / <nl> - public void testNanoEnumValidity ( ) throws Exception { <nl> - final int invalid = 120 ; <nl> - final int alsoInvalid = 121 ; <nl> - <nl> - EnumValidity . M m = new EnumValidity . M ( ) ; <nl> - / / Sanity check & baseline of the assertions for the first case below . <nl> - assertEquals ( EnumValidity . E . default_ , m . optionalE ) ; <nl> - assertEquals ( EnumValidity . E . BAZ , m . defaultE ) ; <nl> - <nl> - m . optionalE = invalid ; <nl> - m . defaultE = invalid ; <nl> - / / E contains all valid values <nl> - m . repeatedE = new int [ ] { EnumValidity . E . FOO , EnumValidity . E . BAR } ; <nl> - m . packedE = new int [ ] { EnumValidity . E . FOO , EnumValidity . E . BAZ } ; <nl> - / / E2 contains some invalid values <nl> - m . repeatedE2 = new int [ ] { invalid , EnumValidity . E . BAR , alsoInvalid } ; <nl> - m . packedE2 = new int [ ] { EnumValidity . E . FOO , invalid , alsoInvalid } ; <nl> - / / E3 contains all invalid values <nl> - m . repeatedE3 = new int [ ] { invalid , invalid } ; <nl> - m . packedE3 = new int [ ] { alsoInvalid , alsoInvalid } ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - / / Sanity check that we do have all data in the byte array . <nl> - assertEquals ( 31 , serialized . length ) ; <nl> - <nl> - / / Test 1 : tests that invalid values aren ' t included in the deserialized message . <nl> - EnumValidity . M deserialized = MessageNano . mergeFrom ( new EnumValidity . M ( ) , serialized ) ; <nl> - assertEquals ( EnumValidity . E . default_ , deserialized . optionalE ) ; <nl> - assertEquals ( EnumValidity . E . BAZ , deserialized . defaultE ) ; <nl> - assertTrue ( Arrays . equals ( <nl> - new int [ ] { EnumValidity . E . FOO , EnumValidity . E . BAR } , deserialized . repeatedE ) ) ; <nl> - assertTrue ( Arrays . equals ( <nl> - new int [ ] { EnumValidity . E . FOO , EnumValidity . E . BAZ } , deserialized . packedE ) ) ; <nl> - assertTrue ( Arrays . equals ( <nl> - new int [ ] { EnumValidity . E . BAR } , deserialized . repeatedE2 ) ) ; <nl> - assertTrue ( Arrays . equals ( <nl> - new int [ ] { EnumValidity . E . FOO } , deserialized . packedE2 ) ) ; <nl> - assertEquals ( 0 , deserialized . repeatedE3 . length ) ; <nl> - assertEquals ( 0 , deserialized . packedE3 . length ) ; <nl> - <nl> - / / Test 2 : tests that invalid values do not override previous values in the field , including <nl> - / / arrays , including pre - existing invalid values . <nl> - deserialized . optionalE = EnumValidity . E . BAR ; <nl> - deserialized . defaultE = alsoInvalid ; <nl> - deserialized . repeatedE = new int [ ] { EnumValidity . E . BAZ } ; <nl> - deserialized . packedE = new int [ ] { EnumValidity . E . BAZ , alsoInvalid } ; <nl> - deserialized . repeatedE2 = new int [ ] { invalid , alsoInvalid } ; <nl> - deserialized . packedE2 = null ; <nl> - deserialized . repeatedE3 = null ; <nl> - deserialized . packedE3 = new int [ 0 ] ; <nl> - MessageNano . mergeFrom ( deserialized , serialized ) ; <nl> - assertEquals ( EnumValidity . E . BAR , deserialized . optionalE ) ; <nl> - assertEquals ( alsoInvalid , deserialized . defaultE ) ; <nl> - assertTrue ( Arrays . equals ( <nl> - new int [ ] { EnumValidity . E . BAZ , / * + * / EnumValidity . E . FOO , EnumValidity . E . BAR } , <nl> - deserialized . repeatedE ) ) ; <nl> - assertTrue ( Arrays . equals ( <nl> - new int [ ] { EnumValidity . E . BAZ , alsoInvalid , / * + * / EnumValidity . E . FOO , EnumValidity . E . BAZ } , <nl> - deserialized . packedE ) ) ; <nl> - assertTrue ( Arrays . equals ( <nl> - new int [ ] { invalid , alsoInvalid , / * + * / EnumValidity . E . BAR } , <nl> - deserialized . repeatedE2 ) ) ; <nl> - assertTrue ( Arrays . equals ( <nl> - new int [ ] { / * < null > + * / EnumValidity . E . FOO } , <nl> - deserialized . packedE2 ) ) ; <nl> - assertNull ( deserialized . repeatedE3 ) ; / / null + all invalid = = null <nl> - assertEquals ( 0 , deserialized . packedE3 . length ) ; / / empty + all invalid = = empty <nl> - <nl> - / / Test 3 : reading by alternative forms <nl> - EnumValidity . Alt alt = MessageNano . mergeFrom ( new EnumValidity . Alt ( ) , serialized ) ; <nl> - assertEquals ( EnumValidity . E . BAR , / / last valid value in m . repeatedE2 <nl> - alt . repeatedE2AsOptional ) ; <nl> - assertTrue ( Arrays . equals ( new int [ ] { EnumValidity . E . FOO } , alt . packedE2AsNonPacked ) ) ; <nl> - assertEquals ( 0 , alt . nonPackedE3AsPacked . length ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Tests the same as { @ link # testNanoEnumValidity ( ) } with accessor style . Repeated fields are <nl> - * not re - tested here because they are not affected by the accessor style . <nl> - * / <nl> - public void testNanoEnumValidityAccessors ( ) throws Exception { <nl> - final int invalid = 120 ; <nl> - final int alsoInvalid = 121 ; <nl> - <nl> - EnumValidityAccessors . M m = new EnumValidityAccessors . M ( ) ; <nl> - / / Sanity check & baseline of the assertions for the first case below . <nl> - assertEquals ( EnumValidityAccessors . default_ , m . getOptionalE ( ) ) ; <nl> - assertEquals ( EnumValidityAccessors . BAZ , m . getDefaultE ( ) ) ; <nl> - <nl> - m . setOptionalE ( invalid ) ; <nl> - m . setDefaultE ( invalid ) ; <nl> - / / Set repeatedE2 for Alt . repeatedE2AsOptional <nl> - m . repeatedE2 = new int [ ] { invalid , EnumValidityAccessors . BAR , alsoInvalid } ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - / / Sanity check that we do have all data in the byte array . <nl> - assertEquals ( 10 , serialized . length ) ; <nl> - <nl> - / / Test 1 : tests that invalid values aren ' t included in the deserialized message . <nl> - EnumValidityAccessors . M deserialized = <nl> - MessageNano . mergeFrom ( new EnumValidityAccessors . M ( ) , serialized ) ; <nl> - assertEquals ( EnumValidityAccessors . default_ , deserialized . getOptionalE ( ) ) ; <nl> - assertEquals ( EnumValidityAccessors . BAZ , deserialized . getDefaultE ( ) ) ; <nl> - <nl> - / / Test 2 : tests that invalid values do not override previous values in the field , including <nl> - / / pre - existing invalid values . <nl> - deserialized . setOptionalE ( EnumValidityAccessors . BAR ) ; <nl> - deserialized . setDefaultE ( alsoInvalid ) ; <nl> - MessageNano . mergeFrom ( deserialized , serialized ) ; <nl> - assertEquals ( EnumValidityAccessors . BAR , deserialized . getOptionalE ( ) ) ; <nl> - assertEquals ( alsoInvalid , deserialized . getDefaultE ( ) ) ; <nl> - <nl> - / / Test 3 : reading by alternative forms <nl> - EnumValidityAccessors . Alt alt = <nl> - MessageNano . mergeFrom ( new EnumValidityAccessors . Alt ( ) , serialized ) ; <nl> - assertEquals ( EnumValidityAccessors . BAR , / / last valid value in m . repeatedE2 <nl> - alt . getRepeatedE2AsOptional ( ) ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Tests that code generation correctly wraps a single message into its outer <nl> - * class . The class { @ code SingleMessageNano } is imported from the outer <nl> - * class { @ code UnittestSingleNano } , whose name is implicit . Any error would <nl> - * cause this method to fail compilation . <nl> - * / <nl> - public void testNanoSingle ( ) throws Exception { <nl> - SingleMessageNano msg = new SingleMessageNano ( ) ; <nl> - assertNotNull ( msg ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Tests that code generation correctly skips generating the outer class if <nl> - * unnecessary , letting a file - scope entity have the same name . The class <nl> - * { @ code MultipleNameClashNano } shares the same name with the file ' s outer <nl> - * class defined explicitly , but the file contains no other entities and has <nl> - * java_multiple_files set . Any error would cause this method to fail <nl> - * compilation . <nl> - * / <nl> - public void testNanoMultipleNameClash ( ) throws Exception { <nl> - MultipleNameClashNano msg = new MultipleNameClashNano ( ) ; <nl> - msg . field = 0 ; <nl> - } <nl> - <nl> - / * * <nl> - * Tests that code generation correctly handles enums in different scopes in <nl> - * a source file with the option java_multiple_files set to true . Any error <nl> - * would cause this method to fail compilation . <nl> - * / <nl> - public void testNanoMultipleEnumScoping ( ) throws Exception { <nl> - FileScopeEnumRefNano msg1 = new FileScopeEnumRefNano ( ) ; <nl> - msg1 . enumField = UnittestMultipleNano . ONE ; <nl> - MessageScopeEnumRefNano msg2 = new MessageScopeEnumRefNano ( ) ; <nl> - msg2 . enumField = MessageScopeEnumRefNano . TWO ; <nl> - } <nl> - <nl> - / * * <nl> - * Tests that code generation with mixed values of the java_multiple_files <nl> - * options between the main source file and the imported source files would <nl> - * generate correct references . Any error would cause this method to fail <nl> - * compilation . <nl> - * / <nl> - public void testNanoMultipleImportingNonMultiple ( ) throws Exception { <nl> - UnittestImportNano . ImportMessageNano importMsg = new UnittestImportNano . ImportMessageNano ( ) ; <nl> - MultipleImportingNonMultipleNano1 nano1 = new MultipleImportingNonMultipleNano1 ( ) ; <nl> - nano1 . field = importMsg ; <nl> - MultipleImportingNonMultipleNano2 nano2 = new MultipleImportingNonMultipleNano2 ( ) ; <nl> - nano2 . nano1 = nano1 ; <nl> - } <nl> - <nl> - public void testNanoDefaults ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - for ( int i = 0 ; i < 2 ; i + + ) { <nl> - assertEquals ( 41 , msg . defaultInt32 ) ; <nl> - assertEquals ( 42 , msg . defaultInt64 ) ; <nl> - assertEquals ( 43 , msg . defaultUint32 ) ; <nl> - assertEquals ( 44 , msg . defaultUint64 ) ; <nl> - assertEquals ( - 45 , msg . defaultSint32 ) ; <nl> - assertEquals ( 46 , msg . defaultSint64 ) ; <nl> - assertEquals ( 47 , msg . defaultFixed32 ) ; <nl> - assertEquals ( 48 , msg . defaultFixed64 ) ; <nl> - assertEquals ( 49 , msg . defaultSfixed32 ) ; <nl> - assertEquals ( - 50 , msg . defaultSfixed64 ) ; <nl> - assertTrue ( 51 . 5f = = msg . defaultFloat ) ; <nl> - assertTrue ( 52 . 0e3 = = msg . defaultDouble ) ; <nl> - assertEquals ( true , msg . defaultBool ) ; <nl> - assertEquals ( " hello " , msg . defaultString ) ; <nl> - assertEquals ( " world " , new String ( msg . defaultBytes , InternalNano . UTF_8 ) ) ; <nl> - assertEquals ( " dünya " , msg . defaultStringNonascii ) ; <nl> - assertEquals ( " dünyab " , new String ( msg . defaultBytesNonascii , InternalNano . UTF_8 ) ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , msg . defaultNestedEnum ) ; <nl> - assertEquals ( NanoOuterClass . FOREIGN_NANO_BAR , msg . defaultForeignEnum ) ; <nl> - assertEquals ( UnittestImportNano . IMPORT_NANO_BAR , msg . defaultImportEnum ) ; <nl> - assertEquals ( Float . POSITIVE_INFINITY , msg . defaultFloatInf ) ; <nl> - assertEquals ( Float . NEGATIVE_INFINITY , msg . defaultFloatNegInf ) ; <nl> - assertEquals ( Float . NaN , msg . defaultFloatNan ) ; <nl> - assertEquals ( Double . POSITIVE_INFINITY , msg . defaultDoubleInf ) ; <nl> - assertEquals ( Double . NEGATIVE_INFINITY , msg . defaultDoubleNegInf ) ; <nl> - assertEquals ( Double . NaN , msg . defaultDoubleNan ) ; <nl> - <nl> - / / Default values are not output , except for required fields . <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 3 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - msg . clear ( ) ; <nl> - } <nl> - } <nl> - <nl> - public void testDifferentStringLengthsNano ( ) throws Exception { <nl> - / / Test string serialization roundtrip using strings of the following lengths , <nl> - / / with ASCII and Unicode characters requiring different UTF - 8 byte counts per <nl> - / / char , hence causing the length delimiter varint to sometimes require more <nl> - / / bytes for the Unicode strings than the ASCII string of the same length . <nl> - int [ ] lengths = new int [ ] { <nl> - 0 , <nl> - 1 , <nl> - ( 1 < < 4 ) - 1 , / / 1 byte for ASCII and Unicode <nl> - ( 1 < < 7 ) - 1 , / / 1 byte for ASCII , 2 bytes for Unicode <nl> - ( 1 < < 11 ) - 1 , / / 2 bytes for ASCII and Unicode <nl> - ( 1 < < 14 ) - 1 , / / 2 bytes for ASCII , 3 bytes for Unicode <nl> - ( 1 < < 17 ) - 1 , / / 3 bytes for ASCII and Unicode <nl> - } ; <nl> - for ( int i : lengths ) { <nl> - testEncodingOfString ( ' q ' , i ) ; / / 1 byte per char <nl> - testEncodingOfString ( ' \ u07FF ' , i ) ; / / 2 bytes per char <nl> - testEncodingOfString ( ' \ u0981 ' , i ) ; / / 3 bytes per char <nl> - } <nl> - } <nl> - <nl> - / * * Regression test for https : / / github . com / google / protobuf / issues / 292 * / <nl> - public void testCorrectExceptionThrowWhenEncodingStringsWithoutEnoughSpace ( ) throws Exception { <nl> - String testCase = " Foooooooo " ; <nl> - assertEquals ( CodedOutputByteBufferNano . computeRawVarint32Size ( testCase . length ( ) ) , <nl> - CodedOutputByteBufferNano . computeRawVarint32Size ( testCase . length ( ) * 3 ) ) ; <nl> - assertEquals ( 11 , CodedOutputByteBufferNano . computeStringSize ( 1 , testCase ) ) ; <nl> - / / Tag is one byte , varint describing string length is 1 byte , string length is 9 bytes . <nl> - / / An array of size 1 will cause a failure when trying to write the varint . <nl> - for ( int i = 0 ; i < 11 ; i + + ) { <nl> - CodedOutputByteBufferNano bufferNano = CodedOutputByteBufferNano . newInstance ( new byte [ i ] ) ; <nl> - try { <nl> - bufferNano . writeString ( 1 , testCase ) ; <nl> - fail ( " Should have thrown an out of space exception " ) ; <nl> - } catch ( CodedOutputByteBufferNano . OutOfSpaceException expected ) { } <nl> - } <nl> - } <nl> - <nl> - private void testEncodingOfString ( char c , int length ) throws InvalidProtocolBufferNanoException { <nl> - TestAllTypesNano testAllTypesNano = new TestAllTypesNano ( ) ; <nl> - final String fullString = fullString ( c , length ) ; <nl> - testAllTypesNano . optionalString = fullString ; <nl> - final TestAllTypesNano resultNano = new TestAllTypesNano ( ) ; <nl> - MessageNano . mergeFrom ( resultNano , MessageNano . toByteArray ( testAllTypesNano ) ) ; <nl> - assertEquals ( fullString , resultNano . optionalString ) ; <nl> - } <nl> - <nl> - private String fullString ( char c , int length ) { <nl> - char [ ] result = new char [ length ] ; <nl> - Arrays . fill ( result , c ) ; <nl> - return new String ( result ) ; <nl> - } <nl> - <nl> - public void testNanoWithHasParseFrom ( ) throws Exception { <nl> - TestAllTypesNanoHas msg = null ; <nl> - / / Test false on creation , after clear and upon empty parse . <nl> - for ( int i = 0 ; i < 3 ; i + + ) { <nl> - if ( i = = 0 ) { <nl> - msg = new TestAllTypesNanoHas ( ) ; <nl> - } else if ( i = = 1 ) { <nl> - msg . clear ( ) ; <nl> - } else if ( i = = 2 ) { <nl> - msg = TestAllTypesNanoHas . parseFrom ( new byte [ 0 ] ) ; <nl> - } <nl> - assertFalse ( msg . hasOptionalInt32 ) ; <nl> - assertFalse ( msg . hasOptionalString ) ; <nl> - assertFalse ( msg . hasOptionalBytes ) ; <nl> - assertFalse ( msg . hasOptionalNestedEnum ) ; <nl> - assertFalse ( msg . hasDefaultInt32 ) ; <nl> - assertFalse ( msg . hasDefaultString ) ; <nl> - assertFalse ( msg . hasDefaultBytes ) ; <nl> - assertFalse ( msg . hasDefaultFloatNan ) ; <nl> - assertFalse ( msg . hasDefaultNestedEnum ) ; <nl> - assertFalse ( msg . hasId ) ; <nl> - assertFalse ( msg . hasRequiredEnum ) ; <nl> - msg . optionalInt32 = 123 ; <nl> - msg . optionalNestedMessage = new TestAllTypesNanoHas . NestedMessage ( ) ; <nl> - msg . optionalNestedMessage . bb = 2 ; <nl> - msg . optionalNestedEnum = TestAllTypesNano . BAZ ; <nl> - } <nl> - <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 10 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - / / Has fields true upon parse . <nl> - TestAllTypesNanoHas newMsg = TestAllTypesNanoHas . parseFrom ( result ) ; <nl> - assertEquals ( 123 , newMsg . optionalInt32 ) ; <nl> - assertTrue ( newMsg . hasOptionalInt32 ) ; <nl> - assertEquals ( 2 , newMsg . optionalNestedMessage . bb ) ; <nl> - assertTrue ( newMsg . optionalNestedMessage . hasBb ) ; <nl> - assertEquals ( TestAllTypesNanoHas . BAZ , newMsg . optionalNestedEnum ) ; <nl> - assertTrue ( newMsg . hasOptionalNestedEnum ) ; <nl> - } <nl> - <nl> - public void testNanoWithHasSerialize ( ) throws Exception { <nl> - TestAllTypesNanoHas msg = new TestAllTypesNanoHas ( ) ; <nl> - msg . hasOptionalInt32 = true ; <nl> - msg . hasOptionalString = true ; <nl> - msg . hasOptionalBytes = true ; <nl> - msg . optionalNestedMessage = new TestAllTypesNanoHas . NestedMessage ( ) ; <nl> - msg . optionalNestedMessage . hasBb = true ; <nl> - msg . hasOptionalNestedEnum = true ; <nl> - msg . hasDefaultInt32 = true ; <nl> - msg . hasDefaultString = true ; <nl> - msg . hasDefaultBytes = true ; <nl> - msg . hasDefaultFloatNan = true ; <nl> - msg . hasDefaultNestedEnum = true ; <nl> - msg . hasId = true ; <nl> - msg . hasRequiredEnum = true ; <nl> - <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - / / Now deserialize and find that all fields are set and equal to their defaults . <nl> - TestAllTypesNanoHas newMsg = TestAllTypesNanoHas . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . hasOptionalInt32 ) ; <nl> - assertTrue ( newMsg . hasOptionalString ) ; <nl> - assertTrue ( newMsg . hasOptionalBytes ) ; <nl> - assertTrue ( newMsg . optionalNestedMessage . hasBb ) ; <nl> - assertTrue ( newMsg . hasOptionalNestedEnum ) ; <nl> - assertTrue ( newMsg . hasDefaultInt32 ) ; <nl> - assertTrue ( newMsg . hasDefaultString ) ; <nl> - assertTrue ( newMsg . hasDefaultBytes ) ; <nl> - assertTrue ( newMsg . hasDefaultFloatNan ) ; <nl> - assertTrue ( newMsg . hasDefaultNestedEnum ) ; <nl> - assertTrue ( newMsg . hasId ) ; <nl> - assertTrue ( newMsg . hasRequiredEnum ) ; <nl> - assertEquals ( 0 , newMsg . optionalInt32 ) ; <nl> - assertEquals ( 0 , newMsg . optionalString . length ( ) ) ; <nl> - assertEquals ( 0 , newMsg . optionalBytes . length ) ; <nl> - assertEquals ( 0 , newMsg . optionalNestedMessage . bb ) ; <nl> - assertEquals ( TestAllTypesNanoHas . FOO , newMsg . optionalNestedEnum ) ; <nl> - assertEquals ( 41 , newMsg . defaultInt32 ) ; <nl> - assertEquals ( " hello " , newMsg . defaultString ) ; <nl> - assertEquals ( " world " , new String ( newMsg . defaultBytes , InternalNano . UTF_8 ) ) ; <nl> - assertEquals ( TestAllTypesNanoHas . BAR , newMsg . defaultNestedEnum ) ; <nl> - assertEquals ( Float . NaN , newMsg . defaultFloatNan ) ; <nl> - assertEquals ( 0 , newMsg . id ) ; <nl> - assertEquals ( TestAllTypesNanoHas . FOO , newMsg . requiredEnum ) ; <nl> - } <nl> - <nl> - public void testNanoWithAccessorsBasic ( ) throws Exception { <nl> - TestNanoAccessors msg = new TestNanoAccessors ( ) ; <nl> - <nl> - / / Makes sure required , repeated , and message fields are still public <nl> - msg . id = 3 ; <nl> - msg . repeatedBytes = new byte [ 2 ] [ 3 ] ; <nl> - msg . optionalNestedMessage = null ; <nl> - <nl> - / / Test accessors <nl> - assertEquals ( 0 , msg . getOptionalInt32 ( ) ) ; <nl> - assertFalse ( msg . hasOptionalInt32 ( ) ) ; <nl> - msg . setOptionalInt32 ( 135 ) ; <nl> - assertEquals ( 135 , msg . getOptionalInt32 ( ) ) ; <nl> - assertTrue ( msg . hasOptionalInt32 ( ) ) ; <nl> - msg . clearOptionalInt32 ( ) ; <nl> - assertFalse ( msg . hasOptionalInt32 ( ) ) ; <nl> - msg . setOptionalInt32 ( 0 ) ; / / default value <nl> - assertTrue ( msg . hasOptionalInt32 ( ) ) ; <nl> - <nl> - / / Test NPE <nl> - try { <nl> - msg . setOptionalBytes ( null ) ; <nl> - fail ( ) ; <nl> - } catch ( NullPointerException expected ) { } <nl> - try { <nl> - msg . setOptionalString ( null ) ; <nl> - fail ( ) ; <nl> - } catch ( NullPointerException expected ) { } <nl> - <nl> - / / Test has bit on bytes field with defaults and clear ( ) re - clones the default array <nl> - assertFalse ( msg . hasDefaultBytes ( ) ) ; <nl> - byte [ ] defaultBytes = msg . getDefaultBytes ( ) ; <nl> - msg . setDefaultBytes ( defaultBytes ) ; <nl> - assertTrue ( msg . hasDefaultBytes ( ) ) ; <nl> - msg . clearDefaultBytes ( ) ; <nl> - assertFalse ( msg . hasDefaultBytes ( ) ) ; <nl> - defaultBytes [ 0 ] + + ; / / modify original array <nl> - assertFalse ( Arrays . equals ( defaultBytes , msg . getDefaultBytes ( ) ) ) ; <nl> - <nl> - / / Test has bits that require additional bit fields <nl> - assertFalse ( msg . hasBitFieldCheck ( ) ) ; <nl> - msg . setBitFieldCheck ( 0 ) ; <nl> - assertTrue ( msg . hasBitFieldCheck ( ) ) ; <nl> - assertFalse ( msg . hasBeforeBitFieldCheck ( ) ) ; / / checks bit field does not leak <nl> - assertFalse ( msg . hasAfterBitFieldCheck ( ) ) ; <nl> - <nl> - / / Test clear ( ) clears has bits <nl> - msg . setOptionalString ( " hi " ) ; <nl> - msg . setDefaultString ( " there " ) ; <nl> - msg . clear ( ) ; <nl> - assertFalse ( msg . hasOptionalString ( ) ) ; <nl> - assertFalse ( msg . hasDefaultString ( ) ) ; <nl> - assertFalse ( msg . hasBitFieldCheck ( ) ) ; <nl> - <nl> - / / Test set ( ) and clear ( ) returns itself ( compiles = success ) <nl> - msg . clear ( ) <nl> - . setOptionalInt32 ( 3 ) <nl> - . clearDefaultBytes ( ) <nl> - . setOptionalString ( " 4 " ) ; <nl> - } <nl> - <nl> - public void testNanoWithAccessorsParseFrom ( ) throws Exception { <nl> - TestNanoAccessors msg = null ; <nl> - / / Test false on creation , after clear and upon empty parse . <nl> - for ( int i = 0 ; i < 3 ; i + + ) { <nl> - if ( i = = 0 ) { <nl> - msg = new TestNanoAccessors ( ) ; <nl> - } else if ( i = = 1 ) { <nl> - msg . clear ( ) ; <nl> - } else if ( i = = 2 ) { <nl> - msg = TestNanoAccessors . parseFrom ( new byte [ 0 ] ) ; <nl> - } <nl> - assertFalse ( msg . hasOptionalInt32 ( ) ) ; <nl> - assertFalse ( msg . hasOptionalString ( ) ) ; <nl> - assertFalse ( msg . hasOptionalBytes ( ) ) ; <nl> - assertFalse ( msg . hasOptionalNestedEnum ( ) ) ; <nl> - assertFalse ( msg . hasDefaultInt32 ( ) ) ; <nl> - assertFalse ( msg . hasDefaultString ( ) ) ; <nl> - assertFalse ( msg . hasDefaultBytes ( ) ) ; <nl> - assertFalse ( msg . hasDefaultFloatNan ( ) ) ; <nl> - assertFalse ( msg . hasDefaultNestedEnum ( ) ) ; <nl> - msg . optionalNestedMessage = new TestNanoAccessors . NestedMessage ( ) ; <nl> - msg . optionalNestedMessage . setBb ( 2 ) ; <nl> - msg . setOptionalNestedEnum ( TestNanoAccessors . BAZ ) ; <nl> - msg . setDefaultInt32 ( msg . getDefaultInt32 ( ) ) ; <nl> - } <nl> - <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - / / System . out . printf ( " mss = % d result . length = % d \ n " , msgSerializedSize , result . length ) ; <nl> - assertTrue ( msgSerializedSize = = 14 ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - / / Has fields true upon parse . <nl> - TestNanoAccessors newMsg = TestNanoAccessors . parseFrom ( result ) ; <nl> - assertEquals ( 2 , newMsg . optionalNestedMessage . getBb ( ) ) ; <nl> - assertTrue ( newMsg . optionalNestedMessage . hasBb ( ) ) ; <nl> - assertEquals ( TestNanoAccessors . BAZ , newMsg . getOptionalNestedEnum ( ) ) ; <nl> - assertTrue ( newMsg . hasOptionalNestedEnum ( ) ) ; <nl> - <nl> - / / Has field true on fields with explicit default values from wire . <nl> - assertTrue ( newMsg . hasDefaultInt32 ( ) ) ; <nl> - assertEquals ( 41 , newMsg . getDefaultInt32 ( ) ) ; <nl> - } <nl> - <nl> - public void testNanoWithAccessorsPublicFieldTypes ( ) throws Exception { <nl> - TestNanoAccessors msg = new TestNanoAccessors ( ) ; <nl> - assertNull ( msg . optionalNestedMessage ) ; <nl> - assertEquals ( 0 , msg . id ) ; <nl> - assertEquals ( 0 , msg . repeatedNestedEnum . length ) ; <nl> - <nl> - TestNanoAccessors newMsg = TestNanoAccessors . parseFrom ( MessageNano . toByteArray ( msg ) ) ; <nl> - assertNull ( newMsg . optionalNestedMessage ) ; <nl> - assertEquals ( 0 , newMsg . id ) ; <nl> - assertEquals ( 0 , newMsg . repeatedNestedEnum . length ) ; <nl> - <nl> - TestNanoAccessors . NestedMessage nestedMessage = new TestNanoAccessors . NestedMessage ( ) ; <nl> - nestedMessage . setBb ( 5 ) ; <nl> - newMsg . optionalNestedMessage = nestedMessage ; <nl> - newMsg . id = - 1 ; <nl> - newMsg . repeatedNestedEnum = new int [ ] { TestAllTypesNano . FOO } ; <nl> - <nl> - TestNanoAccessors newMsg2 = TestNanoAccessors . parseFrom ( MessageNano . toByteArray ( newMsg ) ) ; <nl> - assertEquals ( nestedMessage . getBb ( ) , newMsg2 . optionalNestedMessage . getBb ( ) ) ; <nl> - assertEquals ( - 1 , newMsg2 . id ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , newMsg2 . repeatedNestedEnum [ 0 ] ) ; <nl> - <nl> - newMsg2 . optionalNestedMessage = null ; <nl> - newMsg2 . id = 0 ; <nl> - newMsg2 . repeatedNestedEnum = null ; <nl> - <nl> - TestNanoAccessors newMsg3 = TestNanoAccessors . parseFrom ( MessageNano . toByteArray ( newMsg2 ) ) ; <nl> - assertNull ( newMsg3 . optionalNestedMessage ) ; <nl> - assertEquals ( 0 , newMsg3 . id ) ; <nl> - assertEquals ( 0 , newMsg3 . repeatedNestedEnum . length ) ; <nl> - } <nl> - <nl> - public void testNanoWithAccessorsSerialize ( ) throws Exception { <nl> - TestNanoAccessors msg = new TestNanoAccessors ( ) ; <nl> - msg . setOptionalInt32 ( msg . getOptionalInt32 ( ) ) ; <nl> - msg . setOptionalString ( msg . getOptionalString ( ) ) ; <nl> - msg . setOptionalBytes ( msg . getOptionalBytes ( ) ) ; <nl> - TestNanoAccessors . NestedMessage nestedMessage = new TestNanoAccessors . NestedMessage ( ) ; <nl> - nestedMessage . setBb ( nestedMessage . getBb ( ) ) ; <nl> - msg . optionalNestedMessage = nestedMessage ; <nl> - msg . setOptionalNestedEnum ( msg . getOptionalNestedEnum ( ) ) ; <nl> - msg . setDefaultInt32 ( msg . getDefaultInt32 ( ) ) ; <nl> - msg . setDefaultString ( msg . getDefaultString ( ) ) ; <nl> - msg . setDefaultBytes ( msg . getDefaultBytes ( ) ) ; <nl> - msg . setDefaultFloatNan ( msg . getDefaultFloatNan ( ) ) ; <nl> - msg . setDefaultNestedEnum ( msg . getDefaultNestedEnum ( ) ) ; <nl> - <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - assertEquals ( result . length , msgSerializedSize ) ; <nl> - <nl> - / / Now deserialize and find that all fields are set and equal to their defaults . <nl> - TestNanoAccessors newMsg = TestNanoAccessors . parseFrom ( result ) ; <nl> - assertTrue ( newMsg . hasOptionalInt32 ( ) ) ; <nl> - assertTrue ( newMsg . hasOptionalString ( ) ) ; <nl> - assertTrue ( newMsg . hasOptionalBytes ( ) ) ; <nl> - assertTrue ( newMsg . optionalNestedMessage . hasBb ( ) ) ; <nl> - assertTrue ( newMsg . hasOptionalNestedEnum ( ) ) ; <nl> - assertTrue ( newMsg . hasDefaultInt32 ( ) ) ; <nl> - assertTrue ( newMsg . hasDefaultString ( ) ) ; <nl> - assertTrue ( newMsg . hasDefaultBytes ( ) ) ; <nl> - assertTrue ( newMsg . hasDefaultFloatNan ( ) ) ; <nl> - assertTrue ( newMsg . hasDefaultNestedEnum ( ) ) ; <nl> - assertEquals ( 0 , newMsg . getOptionalInt32 ( ) ) ; <nl> - assertEquals ( 0 , newMsg . getOptionalString ( ) . length ( ) ) ; <nl> - assertEquals ( 0 , newMsg . getOptionalBytes ( ) . length ) ; <nl> - assertEquals ( 0 , newMsg . optionalNestedMessage . getBb ( ) ) ; <nl> - assertEquals ( TestNanoAccessors . FOO , newMsg . getOptionalNestedEnum ( ) ) ; <nl> - assertEquals ( 41 , newMsg . getDefaultInt32 ( ) ) ; <nl> - assertEquals ( " hello " , newMsg . getDefaultString ( ) ) ; <nl> - assertEquals ( " world " , new String ( newMsg . getDefaultBytes ( ) , InternalNano . UTF_8 ) ) ; <nl> - assertEquals ( TestNanoAccessors . BAR , newMsg . getDefaultNestedEnum ( ) ) ; <nl> - assertEquals ( Float . NaN , newMsg . getDefaultFloatNan ( ) ) ; <nl> - assertEquals ( 0 , newMsg . id ) ; <nl> - } <nl> - <nl> - public void testNanoJavaEnumStyle ( ) throws Exception { <nl> - EnumClassNanos . EnumClassNano msg = new EnumClassNanos . EnumClassNano ( ) ; <nl> - assertEquals ( EnumClassNanos . FileScopeEnum . ONE , msg . one ) ; <nl> - assertEquals ( EnumClassNanos . EnumClassNano . MessageScopeEnum . TWO , msg . two ) ; <nl> - <nl> - EnumClassNanoMultiple msg2 = new EnumClassNanoMultiple ( ) ; <nl> - assertEquals ( FileScopeEnumMultiple . THREE , msg2 . three ) ; <nl> - assertEquals ( EnumClassNanoMultiple . MessageScopeEnumMultiple . FOUR , msg2 . four ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Tests that fields with a default value of NaN are not serialized when <nl> - * set to NaN . This is a special case as NaN ! = NaN , so normal equality <nl> - * checks don ' t work . <nl> - * / <nl> - public void testNanoNotANumberDefaults ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . defaultDoubleNan = 0 ; <nl> - msg . defaultFloatNan = 0 ; <nl> - byte [ ] result = MessageNano . toByteArray ( msg ) ; <nl> - int msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - assertTrue ( result . length = = msgSerializedSize ) ; <nl> - assertTrue ( msgSerializedSize > 3 ) ; <nl> - <nl> - msg . defaultDoubleNan = Double . NaN ; <nl> - msg . defaultFloatNan = Float . NaN ; <nl> - result = MessageNano . toByteArray ( msg ) ; <nl> - msgSerializedSize = msg . getSerializedSize ( ) ; <nl> - assertEquals ( 3 , result . length ) ; <nl> - assertEquals ( 3 , msgSerializedSize ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Test that a bug in skipRawBytes ( ) has been fixed : if the skip skips <nl> - * exactly up to a limit , this should not break things . <nl> - * / <nl> - public void testSkipRawBytesBug ( ) throws Exception { <nl> - byte [ ] rawBytes = new byte [ ] { 1 , 2 } ; <nl> - CodedInputByteBufferNano input = CodedInputByteBufferNano . newInstance ( rawBytes ) ; <nl> - <nl> - int limit = input . pushLimit ( 1 ) ; <nl> - input . skipRawBytes ( 1 ) ; <nl> - input . popLimit ( limit ) ; <nl> - assertEquals ( 2 , input . readRawByte ( ) ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Test that a bug in skipRawBytes ( ) has been fixed : if the skip skips <nl> - * past the end of a buffer with a limit that has been set past the end of <nl> - * that buffer , this should not break things . <nl> - * / <nl> - public void testSkipRawBytesPastEndOfBufferWithLimit ( ) throws Exception { <nl> - byte [ ] rawBytes = new byte [ ] { 1 , 2 , 3 , 4 , 5 } ; <nl> - CodedInputByteBufferNano input = CodedInputByteBufferNano . newInstance ( rawBytes ) ; <nl> - <nl> - int limit = input . pushLimit ( 4 ) ; <nl> - / / In order to expose the bug we need to read at least one byte to prime the <nl> - / / buffer inside the CodedInputStream . <nl> - assertEquals ( 1 , input . readRawByte ( ) ) ; <nl> - / / Skip to the end of the limit . <nl> - input . skipRawBytes ( 3 ) ; <nl> - assertTrue ( input . isAtEnd ( ) ) ; <nl> - input . popLimit ( limit ) ; <nl> - assertEquals ( 5 , input . readRawByte ( ) ) ; <nl> - } <nl> - <nl> - / / Test a smattering of various proto types for printing <nl> - public void testMessageNanoPrinter ( ) { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . optionalInt32 = 14 ; <nl> - msg . optionalFloat = 42 . 3f ; <nl> - msg . optionalString = " String \ " with ' both quotes " ; <nl> - msg . optionalBytes = new byte [ ] { ' " ' , ' \ 0 ' , 1 , 8 } ; <nl> - msg . optionalGroup = new TestAllTypesNano . OptionalGroup ( ) ; <nl> - msg . optionalGroup . a = 15 ; <nl> - msg . repeatedInt64 = new long [ 2 ] ; <nl> - msg . repeatedInt64 [ 0 ] = 1L ; <nl> - msg . repeatedInt64 [ 1 ] = - 1L ; <nl> - msg . repeatedBytes = new byte [ 2 ] [ ] ; <nl> - msg . repeatedBytes [ 1 ] = new byte [ ] { ' h ' , ' e ' , ' l ' , ' l ' , ' o ' } ; <nl> - msg . repeatedGroup = new TestAllTypesNano . RepeatedGroup [ 2 ] ; <nl> - msg . repeatedGroup [ 0 ] = new TestAllTypesNano . RepeatedGroup ( ) ; <nl> - msg . repeatedGroup [ 0 ] . a = - 27 ; <nl> - msg . repeatedGroup [ 1 ] = new TestAllTypesNano . RepeatedGroup ( ) ; <nl> - msg . repeatedGroup [ 1 ] . a = - 72 ; <nl> - msg . optionalNestedMessage = new TestAllTypesNano . NestedMessage ( ) ; <nl> - msg . optionalNestedMessage . bb = 7 ; <nl> - msg . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ 2 ] ; <nl> - msg . repeatedNestedMessage [ 0 ] = new TestAllTypesNano . NestedMessage ( ) ; <nl> - msg . repeatedNestedMessage [ 0 ] . bb = 77 ; <nl> - msg . repeatedNestedMessage [ 1 ] = new TestAllTypesNano . NestedMessage ( ) ; <nl> - msg . repeatedNestedMessage [ 1 ] . bb = 88 ; <nl> - msg . optionalNestedEnum = TestAllTypesNano . BAZ ; <nl> - msg . repeatedNestedEnum = new int [ 2 ] ; <nl> - msg . repeatedNestedEnum [ 0 ] = TestAllTypesNano . BAR ; <nl> - msg . repeatedNestedEnum [ 1 ] = TestAllTypesNano . FOO ; <nl> - msg . repeatedStringPiece = new String [ ] { null , " world " } ; <nl> - msg . setOneofString ( " hello " ) ; <nl> - <nl> - String protoPrint = msg . toString ( ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_int32 : 14 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_float : 42 . 3 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_double : 0 . 0 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_string : \ " String \ \ u0022with \ \ u0027 both quotes \ " " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_bytes : \ " \ \ \ " \ \ 000 \ \ 001 \ \ 010 \ " " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_group < \ n a : 15 \ n > " ) ) ; <nl> - <nl> - assertTrue ( protoPrint . contains ( " repeated_int64 : 1 \ nrepeated_int64 : - 1 " ) ) ; <nl> - assertFalse ( protoPrint . contains ( " repeated_bytes : \ " \ " " ) ) ; / / null should be dropped <nl> - assertTrue ( protoPrint . contains ( " repeated_bytes : \ " hello \ " " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " repeated_group < \ n a : - 27 \ n > \ n " <nl> - + " repeated_group < \ n a : - 72 \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_nested_message < \ n bb : 7 \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " repeated_nested_message < \ n bb : 77 \ n > \ n " <nl> - + " repeated_nested_message < \ n bb : 88 \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_nested_enum : 3 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " repeated_nested_enum : 2 \ nrepeated_nested_enum : 1 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " default_int32 : 41 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " default_string : \ " hello \ " " ) ) ; <nl> - assertFalse ( protoPrint . contains ( " repeated_string_piece : \ " \ " " ) ) ; / / null should be dropped <nl> - assertTrue ( protoPrint . contains ( " repeated_string_piece : \ " world \ " " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " oneof_string : \ " hello \ " " ) ) ; <nl> - } <nl> - <nl> - public void testMessageNanoPrinterAccessors ( ) throws Exception { <nl> - TestNanoAccessors msg = new TestNanoAccessors ( ) ; <nl> - msg . setOptionalInt32 ( 13 ) ; <nl> - msg . setOptionalString ( " foo " ) ; <nl> - msg . setOptionalBytes ( new byte [ ] { ' " ' , ' \ 0 ' , 1 , 8 } ) ; <nl> - msg . optionalNestedMessage = new TestNanoAccessors . NestedMessage ( ) ; <nl> - msg . optionalNestedMessage . setBb ( 7 ) ; <nl> - msg . setOptionalNestedEnum ( TestNanoAccessors . BAZ ) ; <nl> - msg . repeatedInt32 = new int [ ] { 1 , - 1 } ; <nl> - msg . repeatedString = new String [ ] { " Hello " , " world " } ; <nl> - msg . repeatedBytes = new byte [ 2 ] [ ] ; <nl> - msg . repeatedBytes [ 1 ] = new byte [ ] { ' h ' , ' e ' , ' l ' , ' l ' , ' o ' } ; <nl> - msg . repeatedNestedMessage = new TestNanoAccessors . NestedMessage [ 2 ] ; <nl> - msg . repeatedNestedMessage [ 0 ] = new TestNanoAccessors . NestedMessage ( ) ; <nl> - msg . repeatedNestedMessage [ 0 ] . setBb ( 5 ) ; <nl> - msg . repeatedNestedMessage [ 1 ] = new TestNanoAccessors . NestedMessage ( ) ; <nl> - msg . repeatedNestedMessage [ 1 ] . setBb ( 6 ) ; <nl> - msg . repeatedNestedEnum = new int [ ] { TestNanoAccessors . FOO , TestNanoAccessors . BAR } ; <nl> - msg . id = 33 ; <nl> - <nl> - String protoPrint = msg . toString ( ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_int32 : 13 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_string : \ " foo \ " " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_bytes : \ " \ \ \ " \ \ 000 \ \ 001 \ \ 010 \ " " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_nested_message < \ n bb : 7 \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " optional_nested_enum : 3 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " repeated_int32 : 1 \ nrepeated_int32 : - 1 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " repeated_string : \ " Hello \ " \ nrepeated_string : \ " world \ " " ) ) ; <nl> - assertFalse ( protoPrint . contains ( " repeated_bytes : \ " \ " " ) ) ; / / null should be dropped <nl> - assertTrue ( protoPrint . contains ( " repeated_bytes : \ " hello \ " " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " repeated_nested_message < \ n bb : 5 \ n > \ n " <nl> - + " repeated_nested_message < \ n bb : 6 \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " repeated_nested_enum : 1 \ nrepeated_nested_enum : 2 " ) ) ; <nl> - assertTrue ( protoPrint . contains ( " id : 33 " ) ) ; <nl> - } <nl> - <nl> - public void testMessageNanoPrinterForMaps ( ) throws Exception { <nl> - TestMap msg = new TestMap ( ) ; <nl> - MessageValue msgValues [ ] = new MessageValue [ ] { <nl> - new MessageValue ( ) , new MessageValue ( ) <nl> - } ; <nl> - msgValues [ 0 ] . value = 1 ; <nl> - msgValues [ 1 ] . value = 2 ; <nl> - msg . int32ToBytesField = new HashMap < Integer , byte [ ] > ( ) ; <nl> - msg . int32ToBytesField . put ( 1 , new byte [ ] { ' " ' , ' \ 0 ' } ) ; <nl> - msg . int32ToBytesField . put ( 2 , new byte [ ] { 1 , 8 } ) ; <nl> - msg . stringToInt32Field = new HashMap < String , Integer > ( ) ; <nl> - msg . stringToInt32Field . put ( " hello " , 1 ) ; <nl> - msg . stringToInt32Field . put ( " world " , 2 ) ; <nl> - msg . int32ToMessageField = new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - msg . int32ToMessageField . put ( 0 , msgValues [ 0 ] ) ; <nl> - msg . int32ToMessageField . put ( 1 , msgValues [ 1 ] ) ; <nl> - msg . int32ToEnumField = new HashMap < Integer , Integer > ( ) ; <nl> - msg . int32ToEnumField . put ( 1 , 2 ) ; <nl> - msg . int32ToEnumField . put ( 2 , 3 ) ; <nl> - String protoPrint = msg . toString ( ) ; <nl> - <nl> - assertTrue ( protoPrint . contains ( <nl> - " int32_to_bytes_field < \ n key : 1 \ n value : \ " \ \ \ " \ \ 000 \ " \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( <nl> - " int32_to_bytes_field < \ n key : 2 \ n value : \ " \ \ 001 \ \ 010 \ " \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( <nl> - " string_to_int32_field < \ n key : \ " hello \ " \ n value : 1 \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( <nl> - " string_to_int32_field < \ n key : \ " world \ " \ n value : 2 \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( <nl> - " int32_to_message_field < \ n key : 0 \ n value < \ n value : 1 \ n " ) ) ; <nl> - assertTrue ( protoPrint . contains ( <nl> - " int32_to_message_field < \ n key : 1 \ n value < \ n value : 2 \ n " ) ) ; <nl> - assertTrue ( protoPrint . contains ( <nl> - " int32_to_enum_field < \ n key : 1 \ n value : 2 \ n > " ) ) ; <nl> - assertTrue ( protoPrint . contains ( <nl> - " int32_to_enum_field < \ n key : 2 \ n value : 3 \ n > " ) ) ; <nl> - } <nl> - <nl> - public void testExtensions ( ) throws Exception { <nl> - Extensions . ExtendableMessage message = new Extensions . ExtendableMessage ( ) ; <nl> - message . field = 5 ; <nl> - int [ ] int32s = { 1 , 2 } ; <nl> - int [ ] uint32s = { 3 , 4 } ; <nl> - int [ ] sint32s = { - 5 , - 6 } ; <nl> - long [ ] int64s = { 7 , 8 } ; <nl> - long [ ] uint64s = { 9 , 10 } ; <nl> - long [ ] sint64s = { - 11 , - 12 } ; <nl> - int [ ] fixed32s = { 13 , 14 } ; <nl> - int [ ] sfixed32s = { - 15 , - 16 } ; <nl> - long [ ] fixed64s = { 17 , 18 } ; <nl> - long [ ] sfixed64s = { - 19 , - 20 } ; <nl> - boolean [ ] bools = { true , false } ; <nl> - float [ ] floats = { 2 . 1f , 2 . 2f } ; <nl> - double [ ] doubles = { 2 . 3 , 2 . 4 } ; <nl> - int [ ] enums = { Extensions . SECOND_VALUE , Extensions . FIRST_VALUE } ; <nl> - String [ ] strings = { " vijfentwintig " , " twenty - six " } ; <nl> - byte [ ] [ ] bytess = { { 2 , 7 } , { 2 , 8 } } ; <nl> - AnotherMessage another1 = new AnotherMessage ( ) ; <nl> - another1 . string = " er shi jiu " ; <nl> - another1 . value = false ; <nl> - AnotherMessage another2 = new AnotherMessage ( ) ; <nl> - another2 . string = " trente " ; <nl> - another2 . value = true ; <nl> - AnotherMessage [ ] messages = { another1 , another2 } ; <nl> - RepeatedExtensions . RepeatedGroup group1 = new RepeatedExtensions . RepeatedGroup ( ) ; <nl> - group1 . a = 31 ; <nl> - RepeatedExtensions . RepeatedGroup group2 = new RepeatedExtensions . RepeatedGroup ( ) ; <nl> - group2 . a = 32 ; <nl> - RepeatedExtensions . RepeatedGroup [ ] groups = { group1 , group2 } ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedInt32 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedInt32 , int32s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedInt32 ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedUint32 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedUint32 , uint32s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedUint32 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedSint32 , sint32s ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedInt64 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedInt64 , int64s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedInt64 ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedUint64 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedUint64 , uint64s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedUint64 ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedSint64 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedSint64 , sint64s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedSint64 ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedFixed32 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedFixed32 , fixed32s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedFixed32 ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedSfixed32 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedSfixed32 , sfixed32s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedSfixed32 ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedFixed64 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedFixed64 , fixed64s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedFixed64 ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedSfixed64 ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedSfixed64 , sfixed64s ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedSfixed64 ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedBool ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedBool , bools ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedBool ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedFloat ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedFloat , floats ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedFloat ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedDouble ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedDouble , doubles ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedDouble ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedEnum ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedEnum , enums ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedEnum ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedString ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedString , strings ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedString ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedBytes ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedBytes , bytess ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedBytes ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedMessage ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedMessage , messages ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedMessage ) ) ; <nl> - assertFalse ( message . hasExtension ( RepeatedExtensions . repeatedGroup ) ) ; <nl> - message . setExtension ( RepeatedExtensions . repeatedGroup , groups ) ; <nl> - assertTrue ( message . hasExtension ( RepeatedExtensions . repeatedGroup ) ) ; <nl> - <nl> - byte [ ] data = MessageNano . toByteArray ( message ) ; <nl> - message = Extensions . ExtendableMessage . parseFrom ( data ) ; <nl> - assertEquals ( 5 , message . field ) ; <nl> - <nl> - / / Test reading back using SingularExtensions : the retrieved value should equal the last <nl> - / / in each array . <nl> - assertEquals ( int32s [ 1 ] , ( int ) message . getExtension ( SingularExtensions . someInt32 ) ) ; <nl> - assertEquals ( uint32s [ 1 ] , ( int ) message . getExtension ( SingularExtensions . someUint32 ) ) ; <nl> - assertEquals ( sint32s [ 1 ] , ( int ) message . getExtension ( SingularExtensions . someSint32 ) ) ; <nl> - assertEquals ( int64s [ 1 ] , ( long ) message . getExtension ( SingularExtensions . someInt64 ) ) ; <nl> - assertEquals ( uint64s [ 1 ] , ( long ) message . getExtension ( SingularExtensions . someUint64 ) ) ; <nl> - assertEquals ( sint64s [ 1 ] , ( long ) message . getExtension ( SingularExtensions . someSint64 ) ) ; <nl> - assertEquals ( fixed32s [ 1 ] , ( int ) message . getExtension ( SingularExtensions . someFixed32 ) ) ; <nl> - assertEquals ( sfixed32s [ 1 ] , ( int ) message . getExtension ( SingularExtensions . someSfixed32 ) ) ; <nl> - assertEquals ( fixed64s [ 1 ] , ( long ) message . getExtension ( SingularExtensions . someFixed64 ) ) ; <nl> - assertEquals ( sfixed64s [ 1 ] , ( long ) message . getExtension ( SingularExtensions . someSfixed64 ) ) ; <nl> - assertEquals ( bools [ 1 ] , ( boolean ) message . getExtension ( SingularExtensions . someBool ) ) ; <nl> - assertEquals ( floats [ 1 ] , ( float ) message . getExtension ( SingularExtensions . someFloat ) ) ; <nl> - assertEquals ( doubles [ 1 ] , ( double ) message . getExtension ( SingularExtensions . someDouble ) ) ; <nl> - assertEquals ( enums [ 1 ] , ( int ) message . getExtension ( SingularExtensions . someEnum ) ) ; <nl> - assertEquals ( strings [ 1 ] , message . getExtension ( SingularExtensions . someString ) ) ; <nl> - assertTrue ( Arrays . equals ( bytess [ 1 ] , message . getExtension ( SingularExtensions . someBytes ) ) ) ; <nl> - AnotherMessage deserializedMessage = message . getExtension ( SingularExtensions . someMessage ) ; <nl> - assertEquals ( another2 . string , deserializedMessage . string ) ; <nl> - assertEquals ( another2 . value , deserializedMessage . value ) ; <nl> - assertEquals ( group2 . a , message . getExtension ( SingularExtensions . someGroup ) . a ) ; <nl> - <nl> - / / Test reading back using RepeatedExtensions : the arrays should be equal . <nl> - message = Extensions . ExtendableMessage . parseFrom ( data ) ; <nl> - assertEquals ( 5 , message . field ) ; <nl> - assertTrue ( Arrays . equals ( int32s , message . getExtension ( RepeatedExtensions . repeatedInt32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( uint32s , message . getExtension ( RepeatedExtensions . repeatedUint32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sint32s , message . getExtension ( RepeatedExtensions . repeatedSint32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( int64s , message . getExtension ( RepeatedExtensions . repeatedInt64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( uint64s , message . getExtension ( RepeatedExtensions . repeatedUint64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sint64s , message . getExtension ( RepeatedExtensions . repeatedSint64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( fixed32s , message . getExtension ( RepeatedExtensions . repeatedFixed32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sfixed32s , message . getExtension ( RepeatedExtensions . repeatedSfixed32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( fixed64s , message . getExtension ( RepeatedExtensions . repeatedFixed64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sfixed64s , message . getExtension ( RepeatedExtensions . repeatedSfixed64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( bools , message . getExtension ( RepeatedExtensions . repeatedBool ) ) ) ; <nl> - assertTrue ( Arrays . equals ( floats , message . getExtension ( RepeatedExtensions . repeatedFloat ) ) ) ; <nl> - assertTrue ( Arrays . equals ( doubles , message . getExtension ( RepeatedExtensions . repeatedDouble ) ) ) ; <nl> - assertTrue ( Arrays . equals ( enums , message . getExtension ( RepeatedExtensions . repeatedEnum ) ) ) ; <nl> - assertTrue ( Arrays . equals ( strings , message . getExtension ( RepeatedExtensions . repeatedString ) ) ) ; <nl> - byte [ ] [ ] deserializedRepeatedBytes = message . getExtension ( RepeatedExtensions . repeatedBytes ) ; <nl> - assertEquals ( 2 , deserializedRepeatedBytes . length ) ; <nl> - assertTrue ( Arrays . equals ( bytess [ 0 ] , deserializedRepeatedBytes [ 0 ] ) ) ; <nl> - assertTrue ( Arrays . equals ( bytess [ 1 ] , deserializedRepeatedBytes [ 1 ] ) ) ; <nl> - AnotherMessage [ ] deserializedRepeatedMessage = <nl> - message . getExtension ( RepeatedExtensions . repeatedMessage ) ; <nl> - assertEquals ( 2 , deserializedRepeatedMessage . length ) ; <nl> - assertEquals ( another1 . string , deserializedRepeatedMessage [ 0 ] . string ) ; <nl> - assertEquals ( another1 . value , deserializedRepeatedMessage [ 0 ] . value ) ; <nl> - assertEquals ( another2 . string , deserializedRepeatedMessage [ 1 ] . string ) ; <nl> - assertEquals ( another2 . value , deserializedRepeatedMessage [ 1 ] . value ) ; <nl> - RepeatedExtensions . RepeatedGroup [ ] deserializedRepeatedGroup = <nl> - message . getExtension ( RepeatedExtensions . repeatedGroup ) ; <nl> - assertEquals ( 2 , deserializedRepeatedGroup . length ) ; <nl> - assertEquals ( group1 . a , deserializedRepeatedGroup [ 0 ] . a ) ; <nl> - assertEquals ( group2 . a , deserializedRepeatedGroup [ 1 ] . a ) ; <nl> - <nl> - message = Extensions . ExtendableMessage . parseFrom ( data ) ; <nl> - assertEquals ( 5 , message . field ) ; <nl> - / / Test hasExtension using PackedExtensions . <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedInt32 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedUint32 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedSint32 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedInt64 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedUint64 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedSint64 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedFixed32 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedSfixed32 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedFixed64 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedSfixed64 ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedBool ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedFloat ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedDouble ) ) ; <nl> - assertTrue ( message . hasExtension ( PackedExtensions . packedEnum ) ) ; <nl> - <nl> - / / Test reading back using PackedExtensions : the arrays should be equal , even the fields <nl> - / / are non - packed . <nl> - assertTrue ( Arrays . equals ( int32s , message . getExtension ( PackedExtensions . packedInt32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( uint32s , message . getExtension ( PackedExtensions . packedUint32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sint32s , message . getExtension ( PackedExtensions . packedSint32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( int64s , message . getExtension ( PackedExtensions . packedInt64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( uint64s , message . getExtension ( PackedExtensions . packedUint64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sint64s , message . getExtension ( PackedExtensions . packedSint64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( fixed32s , message . getExtension ( PackedExtensions . packedFixed32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sfixed32s , message . getExtension ( PackedExtensions . packedSfixed32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( fixed64s , message . getExtension ( PackedExtensions . packedFixed64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sfixed64s , message . getExtension ( PackedExtensions . packedSfixed64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( bools , message . getExtension ( PackedExtensions . packedBool ) ) ) ; <nl> - assertTrue ( Arrays . equals ( floats , message . getExtension ( PackedExtensions . packedFloat ) ) ) ; <nl> - assertTrue ( Arrays . equals ( doubles , message . getExtension ( PackedExtensions . packedDouble ) ) ) ; <nl> - assertTrue ( Arrays . equals ( enums , message . getExtension ( PackedExtensions . packedEnum ) ) ) ; <nl> - <nl> - / / Now set the packable extension values using PackedExtensions so they ' re serialized packed . <nl> - message . setExtension ( PackedExtensions . packedInt32 , int32s ) ; <nl> - message . setExtension ( PackedExtensions . packedUint32 , uint32s ) ; <nl> - message . setExtension ( PackedExtensions . packedSint32 , sint32s ) ; <nl> - message . setExtension ( PackedExtensions . packedInt64 , int64s ) ; <nl> - message . setExtension ( PackedExtensions . packedUint64 , uint64s ) ; <nl> - message . setExtension ( PackedExtensions . packedSint64 , sint64s ) ; <nl> - message . setExtension ( PackedExtensions . packedFixed32 , fixed32s ) ; <nl> - message . setExtension ( PackedExtensions . packedSfixed32 , sfixed32s ) ; <nl> - message . setExtension ( PackedExtensions . packedFixed64 , fixed64s ) ; <nl> - message . setExtension ( PackedExtensions . packedSfixed64 , sfixed64s ) ; <nl> - message . setExtension ( PackedExtensions . packedBool , bools ) ; <nl> - message . setExtension ( PackedExtensions . packedFloat , floats ) ; <nl> - message . setExtension ( PackedExtensions . packedDouble , doubles ) ; <nl> - message . setExtension ( PackedExtensions . packedEnum , enums ) ; <nl> - <nl> - / / And read back using non - packed RepeatedExtensions . <nl> - byte [ ] data2 = MessageNano . toByteArray ( message ) ; <nl> - message = MessageNano . mergeFrom ( new Extensions . ExtendableMessage ( ) , data2 ) ; <nl> - assertTrue ( Arrays . equals ( int32s , message . getExtension ( RepeatedExtensions . repeatedInt32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( uint32s , message . getExtension ( RepeatedExtensions . repeatedUint32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sint32s , message . getExtension ( RepeatedExtensions . repeatedSint32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( int64s , message . getExtension ( RepeatedExtensions . repeatedInt64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( uint64s , message . getExtension ( RepeatedExtensions . repeatedUint64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sint64s , message . getExtension ( RepeatedExtensions . repeatedSint64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( fixed32s , message . getExtension ( RepeatedExtensions . repeatedFixed32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sfixed32s , message . getExtension ( RepeatedExtensions . repeatedSfixed32 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( fixed64s , message . getExtension ( RepeatedExtensions . repeatedFixed64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( sfixed64s , message . getExtension ( RepeatedExtensions . repeatedSfixed64 ) ) ) ; <nl> - assertTrue ( Arrays . equals ( bools , message . getExtension ( RepeatedExtensions . repeatedBool ) ) ) ; <nl> - assertTrue ( Arrays . equals ( floats , message . getExtension ( RepeatedExtensions . repeatedFloat ) ) ) ; <nl> - assertTrue ( Arrays . equals ( doubles , message . getExtension ( RepeatedExtensions . repeatedDouble ) ) ) ; <nl> - assertTrue ( Arrays . equals ( enums , message . getExtension ( RepeatedExtensions . repeatedEnum ) ) ) ; <nl> - <nl> - / / Clone the message and ensure it ' s still equal . <nl> - Extensions . ExtendableMessage clone = message . clone ( ) ; <nl> - assertEquals ( clone , message ) ; <nl> - } <nl> - <nl> - public void testNullExtensions ( ) throws Exception { <nl> - / / Check that clearing the extension on an empty message is a no - op . <nl> - Extensions . ExtendableMessage message = new Extensions . ExtendableMessage ( ) ; <nl> - assertFalse ( message . hasExtension ( SingularExtensions . someMessage ) ) ; <nl> - message . setExtension ( SingularExtensions . someMessage , null ) ; <nl> - assertFalse ( message . hasExtension ( SingularExtensions . someMessage ) ) ; <nl> - assertEquals ( 0 , MessageNano . toByteArray ( message ) . length ) ; <nl> - <nl> - / / Check that the message is empty after setting and clearing an extension . <nl> - AnotherMessage another = new AnotherMessage ( ) ; <nl> - assertFalse ( message . hasExtension ( SingularExtensions . someMessage ) ) ; <nl> - message . setExtension ( SingularExtensions . someMessage , another ) ; <nl> - assertTrue ( message . hasExtension ( SingularExtensions . someMessage ) ) ; <nl> - assertTrue ( MessageNano . toByteArray ( message ) . length > 0 ) ; <nl> - message . setExtension ( SingularExtensions . someMessage , null ) ; <nl> - assertFalse ( message . hasExtension ( SingularExtensions . someMessage ) ) ; <nl> - assertEquals ( 0 , MessageNano . toByteArray ( message ) . length ) ; <nl> - } <nl> - <nl> - public void testExtensionsMutation ( ) { <nl> - Extensions . ExtendableMessage extendableMessage = new Extensions . ExtendableMessage ( ) ; <nl> - extendableMessage . setExtension ( SingularExtensions . someMessage , <nl> - new Extensions . AnotherMessage ( ) ) ; <nl> - <nl> - extendableMessage . getExtension ( SingularExtensions . someMessage ) . string = " not empty " ; <nl> - <nl> - assertEquals ( " not empty " , <nl> - extendableMessage . getExtension ( SingularExtensions . someMessage ) . string ) ; <nl> - } <nl> - <nl> - public void testExtensionsMutation_Equals ( ) throws InvalidProtocolBufferNanoException { <nl> - Extensions . ExtendableMessage extendableMessage = new Extensions . ExtendableMessage ( ) ; <nl> - extendableMessage . field = 5 ; <nl> - int int32 = 42 ; <nl> - int [ ] uint32s = { 3 , 4 } ; <nl> - int [ ] sint32s = { - 5 , - 6 } ; <nl> - long [ ] int64s = { 7 , 8 } ; <nl> - long [ ] uint64s = { 9 , 10 } ; <nl> - long [ ] sint64s = { - 11 , - 12 } ; <nl> - int [ ] fixed32s = { 13 , 14 } ; <nl> - int [ ] sfixed32s = { - 15 , - 16 } ; <nl> - long [ ] fixed64s = { 17 , 18 } ; <nl> - long [ ] sfixed64s = { - 19 , - 20 } ; <nl> - boolean [ ] bools = { true , false } ; <nl> - float [ ] floats = { 2 . 1f , 2 . 2f } ; <nl> - double [ ] doubles = { 2 . 3 , 2 . 4 } ; <nl> - int [ ] enums = { Extensions . SECOND_VALUE , Extensions . FIRST_VALUE } ; <nl> - String [ ] strings = { " vijfentwintig " , " twenty - six " } ; <nl> - byte [ ] [ ] bytess = { { 2 , 7 } , { 2 , 8 } } ; <nl> - AnotherMessage another1 = new AnotherMessage ( ) ; <nl> - another1 . string = " er shi jiu " ; <nl> - another1 . value = false ; <nl> - AnotherMessage another2 = new AnotherMessage ( ) ; <nl> - another2 . string = " trente " ; <nl> - another2 . value = true ; <nl> - AnotherMessage [ ] messages = { another1 , another2 } ; <nl> - RepeatedExtensions . RepeatedGroup group1 = new RepeatedExtensions . RepeatedGroup ( ) ; <nl> - group1 . a = 31 ; <nl> - RepeatedExtensions . RepeatedGroup group2 = new RepeatedExtensions . RepeatedGroup ( ) ; <nl> - group2 . a = 32 ; <nl> - RepeatedExtensions . RepeatedGroup [ ] groups = { group1 , group2 } ; <nl> - extendableMessage . setExtension ( SingularExtensions . someInt32 , int32 ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedUint32 , uint32s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedSint32 , sint32s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedInt64 , int64s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedUint64 , uint64s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedSint64 , sint64s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedFixed32 , fixed32s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedSfixed32 , sfixed32s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedFixed64 , fixed64s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedSfixed64 , sfixed64s ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedBool , bools ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedFloat , floats ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedDouble , doubles ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedEnum , enums ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedString , strings ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedBytes , bytess ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedMessage , messages ) ; <nl> - extendableMessage . setExtension ( RepeatedExtensions . repeatedGroup , groups ) ; <nl> - <nl> - byte [ ] data = MessageNano . toByteArray ( extendableMessage ) ; <nl> - <nl> - extendableMessage = Extensions . ExtendableMessage . parseFrom ( data ) ; <nl> - Extensions . ExtendableMessage messageCopy = Extensions . ExtendableMessage . parseFrom ( data ) ; <nl> - <nl> - / / Without deserialising . <nl> - assertEquals ( extendableMessage , messageCopy ) ; <nl> - assertEquals ( extendableMessage . hashCode ( ) , messageCopy . hashCode ( ) ) ; <nl> - <nl> - / / Only one deserialized . <nl> - extendableMessage . getExtension ( SingularExtensions . someInt32 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedUint32 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedSint32 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedInt64 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedUint64 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedSint64 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedFixed32 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedSfixed32 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedFixed64 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedSfixed64 ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedBool ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedFloat ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedDouble ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedEnum ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedString ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedBytes ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedMessage ) ; <nl> - extendableMessage . getExtension ( RepeatedExtensions . repeatedGroup ) ; <nl> - assertEquals ( extendableMessage , messageCopy ) ; <nl> - assertEquals ( extendableMessage . hashCode ( ) , messageCopy . hashCode ( ) ) ; <nl> - <nl> - / / Both deserialized . <nl> - messageCopy . getExtension ( SingularExtensions . someInt32 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedUint32 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedSint32 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedInt64 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedUint64 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedSint64 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedFixed32 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedSfixed32 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedFixed64 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedSfixed64 ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedBool ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedFloat ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedDouble ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedEnum ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedString ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedBytes ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedMessage ) ; <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedGroup ) ; <nl> - assertEquals ( extendableMessage , messageCopy ) ; <nl> - assertEquals ( extendableMessage . hashCode ( ) , messageCopy . hashCode ( ) ) ; <nl> - <nl> - / / Change one , make sure they are still different . <nl> - messageCopy . getExtension ( RepeatedExtensions . repeatedMessage ) [ 0 ] . string = " not empty " ; <nl> - assertFalse ( extendableMessage . equals ( messageCopy ) ) ; <nl> - <nl> - / / Even if the extension hasn ' t been deserialized . <nl> - extendableMessage = Extensions . ExtendableMessage . parseFrom ( data ) ; <nl> - assertFalse ( extendableMessage . equals ( messageCopy ) ) ; <nl> - } <nl> - <nl> - public void testExtensionsCaching ( ) { <nl> - Extensions . ExtendableMessage extendableMessage = new Extensions . ExtendableMessage ( ) ; <nl> - extendableMessage . setExtension ( SingularExtensions . someMessage , <nl> - new Extensions . AnotherMessage ( ) ) ; <nl> - assertSame ( " Consecutive calls to getExtensions should return the same object " , <nl> - extendableMessage . getExtension ( SingularExtensions . someMessage ) , <nl> - extendableMessage . getExtension ( SingularExtensions . someMessage ) ) ; <nl> - } <nl> - <nl> - public void testUnknownFields ( ) throws Exception { <nl> - / / Check that we roundtrip ( serialize and deserialize ) unrecognized fields . <nl> - AnotherMessage message = new AnotherMessage ( ) ; <nl> - message . string = " Hello World " ; <nl> - message . value = false ; <nl> - <nl> - byte [ ] bytes = MessageNano . toByteArray ( message ) ; <nl> - int extraFieldSize = CodedOutputByteBufferNano . computeStringSize ( <nl> - 1001 , " This is an unknown field " ) ; <nl> - byte [ ] newBytes = new byte [ bytes . length + extraFieldSize ] ; <nl> - System . arraycopy ( bytes , 0 , newBytes , 0 , bytes . length ) ; <nl> - CodedOutputByteBufferNano . newInstance ( newBytes , bytes . length , extraFieldSize ) <nl> - . writeString ( 1001 , " This is an unknown field " ) ; <nl> - <nl> - / / Deserialize with an unknown field . <nl> - AnotherMessage deserialized = AnotherMessage . parseFrom ( newBytes ) ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( deserialized ) ; <nl> - <nl> - assertEquals ( newBytes . length , serialized . length ) ; <nl> - <nl> - / / Clear , and make sure it clears everything . <nl> - deserialized . clear ( ) ; <nl> - assertEquals ( 0 , MessageNano . toByteArray ( deserialized ) . length ) ; <nl> - } <nl> - <nl> - public void testMergeFrom ( ) throws Exception { <nl> - SimpleMessageNano message = new SimpleMessageNano ( ) ; <nl> - message . d = 123 ; <nl> - byte [ ] bytes = MessageNano . toByteArray ( message ) ; <nl> - <nl> - SimpleMessageNano newMessage = MessageNano . mergeFrom ( new SimpleMessageNano ( ) , bytes ) ; <nl> - assertEquals ( message . d , newMessage . d ) ; <nl> - } <nl> - <nl> - public void testJavaKeyword ( ) throws Exception { <nl> - TestAllTypesNano msg = new TestAllTypesNano ( ) ; <nl> - msg . synchronized_ = 123 ; <nl> - assertEquals ( 123 , msg . synchronized_ ) ; <nl> - } <nl> - <nl> - public void testReferenceTypesForPrimitives ( ) throws Exception { <nl> - NanoReferenceTypes . TestAllTypesNano message = new NanoReferenceTypes . TestAllTypesNano ( ) ; <nl> - <nl> - / / Base check - when nothing is set , we serialize nothing . <nl> - assertHasWireData ( message , false ) ; <nl> - <nl> - message . defaultBool = true ; <nl> - assertHasWireData ( message , true ) ; <nl> - <nl> - message . defaultBool = false ; <nl> - assertHasWireData ( message , true ) ; <nl> - <nl> - message . defaultBool = null ; <nl> - assertHasWireData ( message , false ) ; <nl> - <nl> - message . defaultInt32 = 5 ; <nl> - assertHasWireData ( message , true ) ; <nl> - <nl> - message . defaultInt32 = null ; <nl> - assertHasWireData ( message , false ) ; <nl> - <nl> - message . defaultInt64 = 123456L ; <nl> - assertHasWireData ( message , true ) ; <nl> - <nl> - message . defaultInt64 = null ; <nl> - assertHasWireData ( message , false ) ; <nl> - <nl> - message . defaultFloat = 1f ; <nl> - assertHasWireData ( message , true ) ; <nl> - <nl> - message . defaultFloat = null ; <nl> - assertHasWireData ( message , false ) ; <nl> - <nl> - message . defaultDouble = 2 . 1 ; <nl> - assertHasWireData ( message , true ) ; <nl> - <nl> - message . defaultDouble = null ; <nl> - assertHasWireData ( message , false ) ; <nl> - <nl> - message . defaultString = " hello " ; <nl> - assertHasWireData ( message , true ) ; <nl> - <nl> - message . defaultString = null ; <nl> - assertHasWireData ( message , false ) ; <nl> - <nl> - message . defaultBytes = new byte [ ] { 1 , 2 , 3 } ; <nl> - assertHasWireData ( message , true ) ; <nl> - <nl> - message . defaultBytes = null ; <nl> - assertHasWireData ( message , false ) ; <nl> - } <nl> - <nl> - public void testHashCodeEquals ( ) throws Exception { <nl> - / / Complete equality : <nl> - TestAllTypesNano a = createMessageForHashCodeEqualsTest ( ) ; <nl> - TestAllTypesNano aEquivalent = createMessageForHashCodeEqualsTest ( ) ; <nl> - <nl> - assertTrue ( MessageNano . messageNanoEquals ( a , aEquivalent ) ) ; <nl> - assertFalse ( MessageNano . messageNanoEquals ( a , new TestAllTypesNano ( ) ) ) ; <nl> - <nl> - / / Null and empty array for repeated fields equality : <nl> - TestAllTypesNano b = createMessageForHashCodeEqualsTest ( ) ; <nl> - b . repeatedBool = null ; <nl> - b . repeatedFloat = new float [ 0 ] ; <nl> - TestAllTypesNano bEquivalent = createMessageForHashCodeEqualsTest ( ) ; <nl> - bEquivalent . repeatedBool = new boolean [ 0 ] ; <nl> - bEquivalent . repeatedFloat = null ; <nl> - <nl> - / / Ref - element - type repeated fields use non - null subsequence equality : <nl> - TestAllTypesNano c = createMessageForHashCodeEqualsTest ( ) ; <nl> - c . repeatedString = null ; <nl> - c . repeatedStringPiece = new String [ ] { null , " one " , null , " two " } ; <nl> - c . repeatedBytes = new byte [ ] [ ] { { 3 , 4 } , null } ; <nl> - TestAllTypesNano cEquivalent = createMessageForHashCodeEqualsTest ( ) ; <nl> - cEquivalent . repeatedString = new String [ 3 ] ; <nl> - cEquivalent . repeatedStringPiece = new String [ ] { " one " , " two " , null } ; <nl> - cEquivalent . repeatedBytes = new byte [ ] [ ] { { 3 , 4 } } ; <nl> - <nl> - / / Complete equality for messages with has fields : <nl> - TestAllTypesNanoHas d = createMessageWithHasForHashCodeEqualsTest ( ) ; <nl> - TestAllTypesNanoHas dEquivalent = createMessageWithHasForHashCodeEqualsTest ( ) ; <nl> - <nl> - / / If has - fields exist , fields with the same default values but <nl> - / / different has - field values are different . <nl> - TestAllTypesNanoHas e = createMessageWithHasForHashCodeEqualsTest ( ) ; <nl> - e . optionalInt32 + + ; / / make different from d <nl> - e . hasDefaultString = false ; <nl> - TestAllTypesNanoHas eDifferent = createMessageWithHasForHashCodeEqualsTest ( ) ; <nl> - eDifferent . optionalInt32 = e . optionalInt32 ; <nl> - eDifferent . hasDefaultString = true ; <nl> - <nl> - / / Complete equality for messages with accessors : <nl> - TestNanoAccessors f = createMessageWithAccessorsForHashCodeEqualsTest ( ) ; <nl> - TestNanoAccessors fEquivalent = createMessageWithAccessorsForHashCodeEqualsTest ( ) ; <nl> - <nl> - / / If using accessors , explicitly setting a field to its default value <nl> - / / should make the message different . <nl> - TestNanoAccessors g = createMessageWithAccessorsForHashCodeEqualsTest ( ) ; <nl> - g . setOptionalInt32 ( g . getOptionalInt32 ( ) + 1 ) ; / / make different from f <nl> - g . clearDefaultString ( ) ; <nl> - TestNanoAccessors gDifferent = createMessageWithAccessorsForHashCodeEqualsTest ( ) ; <nl> - gDifferent . setOptionalInt32 ( g . getOptionalInt32 ( ) ) ; <nl> - gDifferent . setDefaultString ( g . getDefaultString ( ) ) ; <nl> - <nl> - / / Complete equality for reference typed messages : <nl> - NanoReferenceTypes . TestAllTypesNano h = createRefTypedMessageForHashCodeEqualsTest ( ) ; <nl> - NanoReferenceTypes . TestAllTypesNano hEquivalent = createRefTypedMessageForHashCodeEqualsTest ( ) ; <nl> - <nl> - / / Inequality of null and default value for reference typed messages : <nl> - NanoReferenceTypes . TestAllTypesNano i = createRefTypedMessageForHashCodeEqualsTest ( ) ; <nl> - i . optionalInt32 = 1 ; / / make different from h <nl> - i . optionalFloat = null ; <nl> - NanoReferenceTypes . TestAllTypesNano iDifferent = createRefTypedMessageForHashCodeEqualsTest ( ) ; <nl> - iDifferent . optionalInt32 = i . optionalInt32 ; <nl> - iDifferent . optionalFloat = 0 . 0f ; <nl> - <nl> - HashMap < MessageNano , String > hashMap = new HashMap < MessageNano , String > ( ) ; <nl> - hashMap . put ( a , " a " ) ; <nl> - hashMap . put ( b , " b " ) ; <nl> - hashMap . put ( c , " c " ) ; <nl> - hashMap . put ( d , " d " ) ; <nl> - hashMap . put ( e , " e " ) ; <nl> - hashMap . put ( f , " f " ) ; <nl> - hashMap . put ( g , " g " ) ; <nl> - hashMap . put ( h , " h " ) ; <nl> - hashMap . put ( i , " i " ) ; <nl> - <nl> - assertEquals ( 9 , hashMap . size ( ) ) ; / / a - i should be different from each other . <nl> - <nl> - assertEquals ( " a " , hashMap . get ( a ) ) ; <nl> - assertEquals ( " a " , hashMap . get ( aEquivalent ) ) ; <nl> - <nl> - assertEquals ( " b " , hashMap . get ( b ) ) ; <nl> - assertEquals ( " b " , hashMap . get ( bEquivalent ) ) ; <nl> - <nl> - assertEquals ( " c " , hashMap . get ( c ) ) ; <nl> - assertEquals ( " c " , hashMap . get ( cEquivalent ) ) ; <nl> - <nl> - assertEquals ( " d " , hashMap . get ( d ) ) ; <nl> - assertEquals ( " d " , hashMap . get ( dEquivalent ) ) ; <nl> - <nl> - assertEquals ( " e " , hashMap . get ( e ) ) ; <nl> - assertNull ( hashMap . get ( eDifferent ) ) ; <nl> - <nl> - assertEquals ( " f " , hashMap . get ( f ) ) ; <nl> - assertEquals ( " f " , hashMap . get ( fEquivalent ) ) ; <nl> - <nl> - assertEquals ( " g " , hashMap . get ( g ) ) ; <nl> - assertNull ( hashMap . get ( gDifferent ) ) ; <nl> - <nl> - assertEquals ( " h " , hashMap . get ( h ) ) ; <nl> - assertEquals ( " h " , hashMap . get ( hEquivalent ) ) ; <nl> - <nl> - assertEquals ( " i " , hashMap . get ( i ) ) ; <nl> - assertNull ( hashMap . get ( iDifferent ) ) ; <nl> - } <nl> - <nl> - private TestAllTypesNano createMessageForHashCodeEqualsTest ( ) { <nl> - TestAllTypesNano message = new TestAllTypesNano ( ) ; <nl> - message . optionalInt32 = 5 ; <nl> - message . optionalInt64 = 777 ; <nl> - message . optionalFloat = 1 . 0f ; <nl> - message . optionalDouble = 2 . 0 ; <nl> - message . optionalBool = true ; <nl> - message . optionalString = " Hello " ; <nl> - message . optionalBytes = new byte [ ] { 1 , 2 , 3 } ; <nl> - message . optionalNestedMessage = new TestAllTypesNano . NestedMessage ( ) ; <nl> - message . optionalNestedMessage . bb = 27 ; <nl> - message . optionalNestedEnum = TestAllTypesNano . BAR ; <nl> - message . repeatedInt32 = new int [ ] { 5 , 6 , 7 , 8 } ; <nl> - message . repeatedInt64 = new long [ ] { 27L , 28L , 29L } ; <nl> - message . repeatedFloat = new float [ ] { 5 . 0f , 6 . 0f } ; <nl> - message . repeatedDouble = new double [ ] { 99 . 1 , 22 . 5 } ; <nl> - message . repeatedBool = new boolean [ ] { true , false , true } ; <nl> - message . repeatedString = new String [ ] { " One " , " Two " } ; <nl> - message . repeatedBytes = new byte [ ] [ ] { { 2 , 7 } , { 2 , 7 } } ; <nl> - message . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ ] { <nl> - message . optionalNestedMessage , <nl> - message . optionalNestedMessage <nl> - } ; <nl> - message . repeatedNestedEnum = new int [ ] { <nl> - TestAllTypesNano . BAR , <nl> - TestAllTypesNano . BAZ <nl> - } ; <nl> - message . setOneofUint32 ( 3 ) ; <nl> - return message ; <nl> - } <nl> - <nl> - private TestAllTypesNanoHas createMessageWithHasForHashCodeEqualsTest ( ) { <nl> - TestAllTypesNanoHas message = new TestAllTypesNanoHas ( ) ; <nl> - message . optionalInt32 = 5 ; <nl> - message . optionalString = " Hello " ; <nl> - message . optionalBytes = new byte [ ] { 1 , 2 , 3 } ; <nl> - message . optionalNestedMessage = new TestAllTypesNanoHas . NestedMessage ( ) ; <nl> - message . optionalNestedMessage . bb = 27 ; <nl> - message . optionalNestedEnum = TestAllTypesNano . BAR ; <nl> - message . repeatedInt32 = new int [ ] { 5 , 6 , 7 , 8 } ; <nl> - message . repeatedString = new String [ ] { " One " , " Two " } ; <nl> - message . repeatedBytes = new byte [ ] [ ] { { 2 , 7 } , { 2 , 7 } } ; <nl> - message . repeatedNestedMessage = new TestAllTypesNanoHas . NestedMessage [ ] { <nl> - message . optionalNestedMessage , <nl> - message . optionalNestedMessage <nl> - } ; <nl> - message . repeatedNestedEnum = new int [ ] { <nl> - TestAllTypesNano . BAR , <nl> - TestAllTypesNano . BAZ <nl> - } ; <nl> - return message ; <nl> - } <nl> - <nl> - private TestNanoAccessors createMessageWithAccessorsForHashCodeEqualsTest ( ) { <nl> - TestNanoAccessors message = new TestNanoAccessors ( ) <nl> - . setOptionalInt32 ( 5 ) <nl> - . setOptionalString ( " Hello " ) <nl> - . setOptionalBytes ( new byte [ ] { 1 , 2 , 3 } ) <nl> - . setOptionalNestedEnum ( TestNanoAccessors . BAR ) ; <nl> - message . optionalNestedMessage = new TestNanoAccessors . NestedMessage ( ) . setBb ( 27 ) ; <nl> - message . repeatedInt32 = new int [ ] { 5 , 6 , 7 , 8 } ; <nl> - message . repeatedString = new String [ ] { " One " , " Two " } ; <nl> - message . repeatedBytes = new byte [ ] [ ] { { 2 , 7 } , { 2 , 7 } } ; <nl> - message . repeatedNestedMessage = new TestNanoAccessors . NestedMessage [ ] { <nl> - message . optionalNestedMessage , <nl> - message . optionalNestedMessage <nl> - } ; <nl> - message . repeatedNestedEnum = new int [ ] { <nl> - TestAllTypesNano . BAR , <nl> - TestAllTypesNano . BAZ <nl> - } ; <nl> - return message ; <nl> - } <nl> - <nl> - private NanoReferenceTypes . TestAllTypesNano createRefTypedMessageForHashCodeEqualsTest ( ) { <nl> - NanoReferenceTypes . TestAllTypesNano message = new NanoReferenceTypes . TestAllTypesNano ( ) ; <nl> - message . optionalInt32 = 5 ; <nl> - message . optionalInt64 = 777L ; <nl> - message . optionalFloat = 1 . 0f ; <nl> - message . optionalDouble = 2 . 0 ; <nl> - message . optionalBool = true ; <nl> - message . optionalString = " Hello " ; <nl> - message . optionalBytes = new byte [ ] { 1 , 2 , 3 } ; <nl> - message . optionalNestedMessage = <nl> - new NanoReferenceTypes . TestAllTypesNano . NestedMessage ( ) ; <nl> - message . optionalNestedMessage . foo = 27 ; <nl> - message . optionalNestedEnum = NanoReferenceTypes . TestAllTypesNano . BAR ; <nl> - message . repeatedInt32 = new int [ ] { 5 , 6 , 7 , 8 } ; <nl> - message . repeatedInt64 = new long [ ] { 27L , 28L , 29L } ; <nl> - message . repeatedFloat = new float [ ] { 5 . 0f , 6 . 0f } ; <nl> - message . repeatedDouble = new double [ ] { 99 . 1 , 22 . 5 } ; <nl> - message . repeatedBool = new boolean [ ] { true , false , true } ; <nl> - message . repeatedString = new String [ ] { " One " , " Two " } ; <nl> - message . repeatedBytes = new byte [ ] [ ] { { 2 , 7 } , { 2 , 7 } } ; <nl> - message . repeatedNestedMessage = <nl> - new NanoReferenceTypes . TestAllTypesNano . NestedMessage [ ] { <nl> - message . optionalNestedMessage , <nl> - message . optionalNestedMessage <nl> - } ; <nl> - message . repeatedNestedEnum = new int [ ] { <nl> - NanoReferenceTypes . TestAllTypesNano . BAR , <nl> - NanoReferenceTypes . TestAllTypesNano . BAZ <nl> - } ; <nl> - return message ; <nl> - } <nl> - <nl> - public void testEqualsWithSpecialFloatingPointValues ( ) throws Exception { <nl> - / / Checks that the nano implementation complies with Object . equals ( ) when treating <nl> - / / floating point numbers , i . e . NaN = = NaN and + 0 . 0 ! = - 0 . 0 . <nl> - / / This test assumes that the generated equals ( ) implementations are symmetric , so <nl> - / / there will only be one direction for each equality check . <nl> - <nl> - TestAllTypesNano m1 = new TestAllTypesNano ( ) ; <nl> - m1 . optionalFloat = Float . NaN ; <nl> - m1 . optionalDouble = Double . NaN ; <nl> - TestAllTypesNano m2 = new TestAllTypesNano ( ) ; <nl> - m2 . optionalFloat = Float . NaN ; <nl> - m2 . optionalDouble = Double . NaN ; <nl> - assertTrue ( m1 . equals ( m2 ) ) ; <nl> - assertTrue ( m1 . equals ( <nl> - MessageNano . mergeFrom ( new TestAllTypesNano ( ) , MessageNano . toByteArray ( m1 ) ) ) ) ; <nl> - <nl> - m1 . optionalFloat = + 0f ; <nl> - m2 . optionalFloat = - 0f ; <nl> - assertFalse ( m1 . equals ( m2 ) ) ; <nl> - <nl> - m1 . optionalFloat = - 0f ; <nl> - m1 . optionalDouble = + 0d ; <nl> - m2 . optionalDouble = - 0d ; <nl> - assertFalse ( m1 . equals ( m2 ) ) ; <nl> - <nl> - m1 . optionalDouble = - 0d ; <nl> - assertTrue ( m1 . equals ( m2 ) ) ; <nl> - assertFalse ( m1 . equals ( new TestAllTypesNano ( ) ) ) ; / / - 0 does not equals ( ) the default + 0 <nl> - assertTrue ( m1 . equals ( <nl> - MessageNano . mergeFrom ( new TestAllTypesNano ( ) , MessageNano . toByteArray ( m1 ) ) ) ) ; <nl> - <nl> - / / mmmmmm - <nl> - <nl> - TestAllTypesNanoHas m3 = new TestAllTypesNanoHas ( ) ; <nl> - m3 . optionalFloat = Float . NaN ; <nl> - m3 . hasOptionalFloat = true ; <nl> - m3 . optionalDouble = Double . NaN ; <nl> - m3 . hasOptionalDouble = true ; <nl> - TestAllTypesNanoHas m4 = new TestAllTypesNanoHas ( ) ; <nl> - m4 . optionalFloat = Float . NaN ; <nl> - m4 . hasOptionalFloat = true ; <nl> - m4 . optionalDouble = Double . NaN ; <nl> - m4 . hasOptionalDouble = true ; <nl> - assertTrue ( m3 . equals ( m4 ) ) ; <nl> - assertTrue ( m3 . equals ( <nl> - MessageNano . mergeFrom ( new TestAllTypesNanoHas ( ) , MessageNano . toByteArray ( m3 ) ) ) ) ; <nl> - <nl> - m3 . optionalFloat = + 0f ; <nl> - m4 . optionalFloat = - 0f ; <nl> - assertFalse ( m3 . equals ( m4 ) ) ; <nl> - <nl> - m3 . optionalFloat = - 0f ; <nl> - m3 . optionalDouble = + 0d ; <nl> - m4 . optionalDouble = - 0d ; <nl> - assertFalse ( m3 . equals ( m4 ) ) ; <nl> - <nl> - m3 . optionalDouble = - 0d ; <nl> - m3 . hasOptionalFloat = false ; / / - 0 does not equals ( ) the default + 0 , <nl> - m3 . hasOptionalDouble = false ; / / so these incorrect ' has ' flags should be disregarded . <nl> - assertTrue ( m3 . equals ( m4 ) ) ; / / note : m4 has the ' has ' flags set . <nl> - assertFalse ( m3 . equals ( new TestAllTypesNanoHas ( ) ) ) ; / / note : the new message has + 0 defaults <nl> - assertTrue ( m3 . equals ( <nl> - MessageNano . mergeFrom ( new TestAllTypesNanoHas ( ) , MessageNano . toByteArray ( m3 ) ) ) ) ; <nl> - / / note : the deserialized message has the ' has ' flags set . <nl> - <nl> - / / mmmmmm - <nl> - <nl> - TestNanoAccessors m5 = new TestNanoAccessors ( ) ; <nl> - m5 . setOptionalFloat ( Float . NaN ) ; <nl> - m5 . setOptionalDouble ( Double . NaN ) ; <nl> - TestNanoAccessors m6 = new TestNanoAccessors ( ) ; <nl> - m6 . setOptionalFloat ( Float . NaN ) ; <nl> - m6 . setOptionalDouble ( Double . NaN ) ; <nl> - assertTrue ( m5 . equals ( m6 ) ) ; <nl> - assertTrue ( m5 . equals ( <nl> - MessageNano . mergeFrom ( new TestNanoAccessors ( ) , MessageNano . toByteArray ( m6 ) ) ) ) ; <nl> - <nl> - m5 . setOptionalFloat ( + 0f ) ; <nl> - m6 . setOptionalFloat ( - 0f ) ; <nl> - assertFalse ( m5 . equals ( m6 ) ) ; <nl> - <nl> - m5 . setOptionalFloat ( - 0f ) ; <nl> - m5 . setOptionalDouble ( + 0d ) ; <nl> - m6 . setOptionalDouble ( - 0d ) ; <nl> - assertFalse ( m5 . equals ( m6 ) ) ; <nl> - <nl> - m5 . setOptionalDouble ( - 0d ) ; <nl> - assertTrue ( m5 . equals ( m6 ) ) ; <nl> - assertFalse ( m5 . equals ( new TestNanoAccessors ( ) ) ) ; <nl> - assertTrue ( m5 . equals ( <nl> - MessageNano . mergeFrom ( new TestNanoAccessors ( ) , MessageNano . toByteArray ( m6 ) ) ) ) ; <nl> - <nl> - / / mmmmmm - <nl> - <nl> - NanoReferenceTypes . TestAllTypesNano m7 = new NanoReferenceTypes . TestAllTypesNano ( ) ; <nl> - m7 . optionalFloat = Float . NaN ; <nl> - m7 . optionalDouble = Double . NaN ; <nl> - NanoReferenceTypes . TestAllTypesNano m8 = new NanoReferenceTypes . TestAllTypesNano ( ) ; <nl> - m8 . optionalFloat = Float . NaN ; <nl> - m8 . optionalDouble = Double . NaN ; <nl> - assertTrue ( m7 . equals ( m8 ) ) ; <nl> - assertTrue ( m7 . equals ( MessageNano . mergeFrom ( <nl> - new NanoReferenceTypes . TestAllTypesNano ( ) , MessageNano . toByteArray ( m7 ) ) ) ) ; <nl> - <nl> - m7 . optionalFloat = + 0f ; <nl> - m8 . optionalFloat = - 0f ; <nl> - assertFalse ( m7 . equals ( m8 ) ) ; <nl> - <nl> - m7 . optionalFloat = - 0f ; <nl> - m7 . optionalDouble = + 0d ; <nl> - m8 . optionalDouble = - 0d ; <nl> - assertFalse ( m7 . equals ( m8 ) ) ; <nl> - <nl> - m7 . optionalDouble = - 0d ; <nl> - assertTrue ( m7 . equals ( m8 ) ) ; <nl> - assertFalse ( m7 . equals ( new NanoReferenceTypes . TestAllTypesNano ( ) ) ) ; <nl> - assertTrue ( m7 . equals ( MessageNano . mergeFrom ( <nl> - new NanoReferenceTypes . TestAllTypesNano ( ) , MessageNano . toByteArray ( m7 ) ) ) ) ; <nl> - } <nl> - <nl> - private static TestAllTypesNano generateMessageForOneof ( int caseNumber ) { <nl> - TestAllTypesNano result = new TestAllTypesNano ( ) ; <nl> - TestAllTypesNano . NestedMessage nested = <nl> - new TestAllTypesNano . NestedMessage ( ) ; <nl> - nested . bb = 2 ; <nl> - switch ( caseNumber ) { <nl> - case TestAllTypesNano . ONEOF_UINT32_FIELD_NUMBER : <nl> - result . setOneofUint32 ( 1 ) ; <nl> - break ; <nl> - case TestAllTypesNano . ONEOF_ENUM_FIELD_NUMBER : <nl> - result . setOneofEnum ( TestAllTypesNano . BAR ) ; <nl> - break ; <nl> - case TestAllTypesNano . ONEOF_NESTED_MESSAGE_FIELD_NUMBER : <nl> - result . setOneofNestedMessage ( nested ) ; <nl> - break ; <nl> - case TestAllTypesNano . ONEOF_BYTES_FIELD_NUMBER : <nl> - result . setOneofBytes ( new byte [ ] { 1 , 2 } ) ; <nl> - break ; <nl> - case TestAllTypesNano . ONEOF_STRING_FIELD_NUMBER : <nl> - result . setOneofString ( " hello " ) ; <nl> - break ; <nl> - case TestAllTypesNano . ONEOF_FIXED64_FIELD_NUMBER : <nl> - result . setOneofFixed64 ( - 1L ) ; <nl> - break ; <nl> - default : <nl> - throw new RuntimeException ( " unexpected case number : " + caseNumber ) ; <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - public void testOneofHashCodeEquals ( ) throws Exception { <nl> - TestAllTypesNano m1 = generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_UINT32_FIELD_NUMBER ) ; <nl> - assertEquals ( m1 , generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_UINT32_FIELD_NUMBER ) ) ; <nl> - assertFalse ( m1 . equals ( new TestAllTypesNano ( ) ) ) ; <nl> - <nl> - TestAllTypesNano m2 = generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_ENUM_FIELD_NUMBER ) ; <nl> - assertEquals ( m2 , generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_ENUM_FIELD_NUMBER ) ) ; <nl> - assertFalse ( m2 . equals ( new TestAllTypesNano ( ) ) ) ; <nl> - <nl> - TestAllTypesNano m3 = generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_NESTED_MESSAGE_FIELD_NUMBER ) ; <nl> - assertEquals ( m3 , generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_NESTED_MESSAGE_FIELD_NUMBER ) ) ; <nl> - assertFalse ( m3 . equals ( new TestAllTypesNano ( ) ) ) ; <nl> - <nl> - TestAllTypesNano m4 = generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_BYTES_FIELD_NUMBER ) ; <nl> - assertEquals ( m4 , generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_BYTES_FIELD_NUMBER ) ) ; <nl> - assertFalse ( m4 . equals ( new TestAllTypesNano ( ) ) ) ; <nl> - <nl> - TestAllTypesNano m5 = generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_STRING_FIELD_NUMBER ) ; <nl> - assertEquals ( m5 , generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_STRING_FIELD_NUMBER ) ) ; <nl> - assertFalse ( m5 . equals ( new TestAllTypesNano ( ) ) ) ; <nl> - <nl> - TestAllTypesNano m6 = generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_FIXED64_FIELD_NUMBER ) ; <nl> - assertEquals ( m6 , generateMessageForOneof ( <nl> - TestAllTypesNano . ONEOF_FIXED64_FIELD_NUMBER ) ) ; <nl> - assertFalse ( m6 . equals ( new TestAllTypesNano ( ) ) ) ; <nl> - <nl> - Map < TestAllTypesNano , Integer > map = <nl> - new HashMap < TestAllTypesNano , Integer > ( ) ; <nl> - map . put ( m1 , 1 ) ; <nl> - map . put ( m2 , 2 ) ; <nl> - map . put ( m3 , 3 ) ; <nl> - map . put ( m4 , 4 ) ; <nl> - map . put ( m5 , 5 ) ; <nl> - map . put ( m6 , 6 ) ; <nl> - <nl> - assertEquals ( 6 , map . size ( ) ) ; <nl> - } <nl> - <nl> - private void checkOneofCase ( TestAllTypesNano nano , int field ) <nl> - throws Exception { <nl> - assertEquals ( field , nano . getOneofFieldCase ( ) ) ; <nl> - assertEquals ( <nl> - field = = TestAllTypesNano . ONEOF_BYTES_FIELD_NUMBER , <nl> - nano . hasOneofBytes ( ) ) ; <nl> - assertEquals ( <nl> - field = = TestAllTypesNano . ONEOF_ENUM_FIELD_NUMBER , <nl> - nano . hasOneofEnum ( ) ) ; <nl> - assertEquals ( <nl> - field = = TestAllTypesNano . ONEOF_FIXED64_FIELD_NUMBER , <nl> - nano . hasOneofFixed64 ( ) ) ; <nl> - assertEquals ( <nl> - field = = TestAllTypesNano . ONEOF_NESTED_MESSAGE_FIELD_NUMBER , <nl> - nano . hasOneofNestedMessage ( ) ) ; <nl> - assertEquals ( <nl> - field = = TestAllTypesNano . ONEOF_STRING_FIELD_NUMBER , <nl> - nano . hasOneofString ( ) ) ; <nl> - assertEquals ( <nl> - field = = TestAllTypesNano . ONEOF_UINT32_FIELD_NUMBER , <nl> - nano . hasOneofUint32 ( ) ) ; <nl> - <nl> - } <nl> - <nl> - public void testOneofDefault ( ) throws Exception { <nl> - TestAllTypesNano m1 = new TestAllTypesNano ( ) ; <nl> - checkOneofCase ( m1 , 0 ) ; <nl> - assertEquals ( WireFormatNano . EMPTY_BYTES , m1 . getOneofBytes ( ) ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , m1 . getOneofEnum ( ) ) ; <nl> - assertEquals ( 0L , m1 . getOneofFixed64 ( ) ) ; <nl> - assertEquals ( null , m1 . getOneofNestedMessage ( ) ) ; <nl> - assertEquals ( " " , m1 . getOneofString ( ) ) ; <nl> - assertEquals ( 0 , m1 . getOneofUint32 ( ) ) ; <nl> - } <nl> - <nl> - public void testOneofExclusiveness ( ) throws Exception { <nl> - TestAllTypesNano m = new TestAllTypesNano ( ) ; <nl> - checkOneofCase ( m , 0 ) ; <nl> - <nl> - m . setOneofBytes ( new byte [ ] { 0 , 1 } ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_BYTES_FIELD_NUMBER ) ; <nl> - assertTrue ( Arrays . equals ( new byte [ ] { 0 , 1 } , m . getOneofBytes ( ) ) ) ; <nl> - <nl> - m . setOneofEnum ( TestAllTypesNano . BAZ ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_ENUM_FIELD_NUMBER ) ; <nl> - assertEquals ( TestAllTypesNano . BAZ , m . getOneofEnum ( ) ) ; <nl> - assertEquals ( WireFormatNano . EMPTY_BYTES , m . getOneofBytes ( ) ) ; <nl> - <nl> - m . setOneofFixed64 ( - 1L ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_FIXED64_FIELD_NUMBER ) ; <nl> - assertEquals ( - 1L , m . getOneofFixed64 ( ) ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , m . getOneofEnum ( ) ) ; <nl> - <nl> - m . setOneofNestedMessage ( new TestAllTypesNano . NestedMessage ( ) ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_NESTED_MESSAGE_FIELD_NUMBER ) ; <nl> - assertEquals ( <nl> - new TestAllTypesNano . NestedMessage ( ) , m . getOneofNestedMessage ( ) ) ; <nl> - assertEquals ( 0L , m . getOneofFixed64 ( ) ) ; <nl> - <nl> - m . setOneofString ( " hello " ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_STRING_FIELD_NUMBER ) ; <nl> - assertEquals ( " hello " , m . getOneofString ( ) ) ; <nl> - assertNull ( m . getOneofNestedMessage ( ) ) ; <nl> - <nl> - m . setOneofUint32 ( 10 ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_UINT32_FIELD_NUMBER ) ; <nl> - assertEquals ( 10 , m . getOneofUint32 ( ) ) ; <nl> - assertEquals ( " " , m . getOneofString ( ) ) ; <nl> - <nl> - m . setOneofBytes ( new byte [ ] { 0 , 1 } ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_BYTES_FIELD_NUMBER ) ; <nl> - assertTrue ( Arrays . equals ( new byte [ ] { 0 , 1 } , m . getOneofBytes ( ) ) ) ; <nl> - assertEquals ( 0 , m . getOneofUint32 ( ) ) ; <nl> - } <nl> - <nl> - public void testOneofClear ( ) throws Exception { <nl> - TestAllTypesNano m = new TestAllTypesNano ( ) ; <nl> - m . setOneofBytes ( new byte [ ] { 0 , 1 } ) ; <nl> - m . clearOneofField ( ) ; <nl> - checkOneofCase ( m , 0 ) ; <nl> - <nl> - m . setOneofEnum ( TestAllTypesNano . BAZ ) ; <nl> - m . clearOneofField ( ) ; <nl> - checkOneofCase ( m , 0 ) ; <nl> - <nl> - m . setOneofFixed64 ( - 1L ) ; <nl> - m . clearOneofField ( ) ; <nl> - checkOneofCase ( m , 0 ) ; <nl> - <nl> - m . setOneofNestedMessage ( new TestAllTypesNano . NestedMessage ( ) ) ; <nl> - m . clearOneofField ( ) ; <nl> - checkOneofCase ( m , 0 ) ; <nl> - <nl> - m . setOneofString ( " hello " ) ; <nl> - m . clearOneofField ( ) ; <nl> - checkOneofCase ( m , 0 ) ; <nl> - <nl> - m . setOneofUint32 ( 10 ) ; <nl> - m . clearOneofField ( ) ; <nl> - checkOneofCase ( m , 0 ) ; <nl> - } <nl> - <nl> - public void testOneofMarshaling ( ) throws Exception { <nl> - TestAllTypesNano m = new TestAllTypesNano ( ) ; <nl> - TestAllTypesNano parsed = new TestAllTypesNano ( ) ; <nl> - { <nl> - m . setOneofBytes ( new byte [ ] { 0 , 1 } ) ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - MessageNano . mergeFrom ( parsed , serialized ) ; <nl> - checkOneofCase ( parsed , TestAllTypesNano . ONEOF_BYTES_FIELD_NUMBER ) ; <nl> - assertTrue ( Arrays . equals ( new byte [ ] { 0 , 1 } , parsed . getOneofBytes ( ) ) ) ; <nl> - } <nl> - { <nl> - m . setOneofEnum ( TestAllTypesNano . BAZ ) ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - MessageNano . mergeFrom ( parsed , serialized ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_ENUM_FIELD_NUMBER ) ; <nl> - assertEquals ( TestAllTypesNano . BAZ , m . getOneofEnum ( ) ) ; <nl> - } <nl> - { <nl> - m . setOneofEnum ( TestAllTypesNano . BAZ ) ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - MessageNano . mergeFrom ( parsed , serialized ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_ENUM_FIELD_NUMBER ) ; <nl> - assertEquals ( TestAllTypesNano . BAZ , m . getOneofEnum ( ) ) ; <nl> - } <nl> - { <nl> - m . setOneofFixed64 ( - 1L ) ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - MessageNano . mergeFrom ( parsed , serialized ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_FIXED64_FIELD_NUMBER ) ; <nl> - assertEquals ( - 1L , m . getOneofFixed64 ( ) ) ; <nl> - } <nl> - { <nl> - m . setOneofNestedMessage ( new TestAllTypesNano . NestedMessage ( ) ) ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - MessageNano . mergeFrom ( parsed , serialized ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_NESTED_MESSAGE_FIELD_NUMBER ) ; <nl> - assertEquals ( <nl> - new TestAllTypesNano . NestedMessage ( ) , m . getOneofNestedMessage ( ) ) ; <nl> - } <nl> - { <nl> - m . setOneofString ( " hello " ) ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - MessageNano . mergeFrom ( parsed , serialized ) ; <nl> - assertEquals ( " hello " , m . getOneofString ( ) ) ; <nl> - assertNull ( m . getOneofNestedMessage ( ) ) ; <nl> - } <nl> - { <nl> - m . setOneofUint32 ( 10 ) ; <nl> - byte [ ] serialized = MessageNano . toByteArray ( m ) ; <nl> - MessageNano . mergeFrom ( parsed , serialized ) ; <nl> - checkOneofCase ( m , TestAllTypesNano . ONEOF_UINT32_FIELD_NUMBER ) ; <nl> - assertEquals ( 10 , m . getOneofUint32 ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - public void testOneofSerializedConcat ( ) throws Exception { <nl> - TestAllTypesNano m1 = new TestAllTypesNano ( ) ; <nl> - m1 . setOneofBytes ( new byte [ ] { 0 , 1 } ) ; <nl> - byte [ ] b1 = MessageNano . toByteArray ( m1 ) ; <nl> - TestAllTypesNano m2 = new TestAllTypesNano ( ) ; <nl> - m2 . setOneofEnum ( TestAllTypesNano . BAZ ) ; <nl> - byte [ ] b2 = MessageNano . toByteArray ( m2 ) ; <nl> - byte [ ] b3 = new byte [ b1 . length + b2 . length ] ; <nl> - System . arraycopy ( b1 , 0 , b3 , 0 , b1 . length ) ; <nl> - System . arraycopy ( b2 , 0 , b3 , b1 . length , b2 . length ) ; <nl> - TestAllTypesNano parsed = new TestAllTypesNano ( ) ; <nl> - MessageNano . mergeFrom ( parsed , b3 ) ; <nl> - / / the last on the wire wins . <nl> - checkOneofCase ( parsed , TestAllTypesNano . ONEOF_ENUM_FIELD_NUMBER ) ; <nl> - assertEquals ( TestAllTypesNano . BAZ , parsed . getOneofEnum ( ) ) ; <nl> - } <nl> - <nl> - public void testNullRepeatedFields ( ) throws Exception { <nl> - / / Check that serialization after explicitly setting a repeated field <nl> - / / to null doesn ' t NPE . <nl> - TestAllTypesNano message = new TestAllTypesNano ( ) ; <nl> - message . repeatedInt32 = null ; <nl> - MessageNano . toByteArray ( message ) ; / / should not NPE <nl> - message . toString ( ) ; / / should not NPE <nl> - <nl> - message . repeatedNestedEnum = null ; <nl> - MessageNano . toByteArray ( message ) ; / / should not NPE <nl> - message . toString ( ) ; / / should not NPE <nl> - <nl> - message . repeatedBytes = null ; <nl> - MessageNano . toByteArray ( message ) ; / / should not NPE <nl> - message . toString ( ) ; / / should not NPE <nl> - <nl> - message . repeatedNestedMessage = null ; <nl> - MessageNano . toByteArray ( message ) ; / / should not NPE <nl> - message . toString ( ) ; / / should not NPE <nl> - <nl> - message . repeatedPackedInt32 = null ; <nl> - MessageNano . toByteArray ( message ) ; / / should not NPE <nl> - message . toString ( ) ; / / should not NPE <nl> - <nl> - message . repeatedPackedNestedEnum = null ; <nl> - MessageNano . toByteArray ( message ) ; / / should not NPE <nl> - message . toString ( ) ; / / should not NPE <nl> - <nl> - / / Create a second message to merge into message . <nl> - TestAllTypesNano secondMessage = new TestAllTypesNano ( ) ; <nl> - secondMessage . repeatedInt32 = new int [ ] { 1 , 2 , 3 } ; <nl> - secondMessage . repeatedNestedEnum = new int [ ] { <nl> - TestAllTypesNano . FOO , TestAllTypesNano . BAR <nl> - } ; <nl> - secondMessage . repeatedBytes = new byte [ ] [ ] { { 1 , 2 } , { 3 , 4 } } ; <nl> - TestAllTypesNano . NestedMessage nested = <nl> - new TestAllTypesNano . NestedMessage ( ) ; <nl> - nested . bb = 55 ; <nl> - secondMessage . repeatedNestedMessage = <nl> - new TestAllTypesNano . NestedMessage [ ] { nested } ; <nl> - secondMessage . repeatedPackedInt32 = new int [ ] { 1 , 2 , 3 } ; <nl> - secondMessage . repeatedPackedNestedEnum = new int [ ] { <nl> - TestAllTypesNano . FOO , TestAllTypesNano . BAR <nl> - } ; <nl> - <nl> - / / Should not NPE <nl> - message . mergeFrom ( CodedInputByteBufferNano . newInstance ( <nl> - MessageNano . toByteArray ( secondMessage ) ) ) ; <nl> - assertEquals ( 3 , message . repeatedInt32 . length ) ; <nl> - assertEquals ( 3 , message . repeatedInt32 [ 2 ] ) ; <nl> - assertEquals ( 2 , message . repeatedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , message . repeatedNestedEnum [ 0 ] ) ; <nl> - assertEquals ( 2 , message . repeatedBytes . length ) ; <nl> - assertEquals ( 4 , message . repeatedBytes [ 1 ] [ 1 ] ) ; <nl> - assertEquals ( 1 , message . repeatedNestedMessage . length ) ; <nl> - assertEquals ( 55 , message . repeatedNestedMessage [ 0 ] . bb ) ; <nl> - assertEquals ( 3 , message . repeatedPackedInt32 . length ) ; <nl> - assertEquals ( 2 , message . repeatedPackedInt32 [ 1 ] ) ; <nl> - assertEquals ( 2 , message . repeatedPackedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , message . repeatedPackedNestedEnum [ 1 ] ) ; <nl> - } <nl> - <nl> - public void testNullRepeatedFieldElements ( ) throws Exception { <nl> - / / Check that serialization with null array elements doesn ' t NPE . <nl> - String string1 = " 1 " ; <nl> - String string2 = " 2 " ; <nl> - byte [ ] bytes1 = { 3 , 4 } ; <nl> - byte [ ] bytes2 = { 5 , 6 } ; <nl> - TestAllTypesNano . NestedMessage msg1 = new TestAllTypesNano . NestedMessage ( ) ; <nl> - msg1 . bb = 7 ; <nl> - TestAllTypesNano . NestedMessage msg2 = new TestAllTypesNano . NestedMessage ( ) ; <nl> - msg2 . bb = 8 ; <nl> - <nl> - TestAllTypesNano message = new TestAllTypesNano ( ) ; <nl> - message . repeatedString = new String [ ] { null , string1 , string2 } ; <nl> - message . repeatedBytes = new byte [ ] [ ] { bytes1 , null , bytes2 } ; <nl> - message . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ ] { msg1 , msg2 , null } ; <nl> - message . repeatedGroup = new TestAllTypesNano . RepeatedGroup [ ] { null , null , null } ; <nl> - <nl> - byte [ ] serialized = MessageNano . toByteArray ( message ) ; / / should not NPE <nl> - TestAllTypesNano deserialized = MessageNano . mergeFrom ( new TestAllTypesNano ( ) , serialized ) ; <nl> - assertEquals ( 2 , deserialized . repeatedString . length ) ; <nl> - assertEquals ( string1 , deserialized . repeatedString [ 0 ] ) ; <nl> - assertEquals ( string2 , deserialized . repeatedString [ 1 ] ) ; <nl> - assertEquals ( 2 , deserialized . repeatedBytes . length ) ; <nl> - assertTrue ( Arrays . equals ( bytes1 , deserialized . repeatedBytes [ 0 ] ) ) ; <nl> - assertTrue ( Arrays . equals ( bytes2 , deserialized . repeatedBytes [ 1 ] ) ) ; <nl> - assertEquals ( 2 , deserialized . repeatedNestedMessage . length ) ; <nl> - assertEquals ( msg1 . bb , deserialized . repeatedNestedMessage [ 0 ] . bb ) ; <nl> - assertEquals ( msg2 . bb , deserialized . repeatedNestedMessage [ 1 ] . bb ) ; <nl> - assertEquals ( 0 , deserialized . repeatedGroup . length ) ; <nl> - } <nl> - <nl> - public void testRepeatedMerge ( ) throws Exception { <nl> - / / Check that merging repeated fields cause the arrays to expand with <nl> - / / new data . <nl> - TestAllTypesNano first = new TestAllTypesNano ( ) ; <nl> - first . repeatedInt32 = new int [ ] { 1 , 2 , 3 } ; <nl> - TestAllTypesNano second = new TestAllTypesNano ( ) ; <nl> - second . repeatedInt32 = new int [ ] { 4 , 5 } ; <nl> - MessageNano . mergeFrom ( first , MessageNano . toByteArray ( second ) ) ; <nl> - assertEquals ( 5 , first . repeatedInt32 . length ) ; <nl> - assertEquals ( 1 , first . repeatedInt32 [ 0 ] ) ; <nl> - assertEquals ( 4 , first . repeatedInt32 [ 3 ] ) ; <nl> - <nl> - first = new TestAllTypesNano ( ) ; <nl> - first . repeatedNestedEnum = new int [ ] { TestAllTypesNano . BAR } ; <nl> - second = new TestAllTypesNano ( ) ; <nl> - second . repeatedNestedEnum = new int [ ] { TestAllTypesNano . FOO } ; <nl> - MessageNano . mergeFrom ( first , MessageNano . toByteArray ( second ) ) ; <nl> - assertEquals ( 2 , first . repeatedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , first . repeatedNestedEnum [ 0 ] ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , first . repeatedNestedEnum [ 1 ] ) ; <nl> - <nl> - first = new TestAllTypesNano ( ) ; <nl> - first . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ ] { <nl> - new TestAllTypesNano . NestedMessage ( ) <nl> - } ; <nl> - first . repeatedNestedMessage [ 0 ] . bb = 3 ; <nl> - second = new TestAllTypesNano ( ) ; <nl> - second . repeatedNestedMessage = new TestAllTypesNano . NestedMessage [ ] { <nl> - new TestAllTypesNano . NestedMessage ( ) <nl> - } ; <nl> - second . repeatedNestedMessage [ 0 ] . bb = 5 ; <nl> - MessageNano . mergeFrom ( first , MessageNano . toByteArray ( second ) ) ; <nl> - assertEquals ( 2 , first . repeatedNestedMessage . length ) ; <nl> - assertEquals ( 3 , first . repeatedNestedMessage [ 0 ] . bb ) ; <nl> - assertEquals ( 5 , first . repeatedNestedMessage [ 1 ] . bb ) ; <nl> - <nl> - first = new TestAllTypesNano ( ) ; <nl> - first . repeatedPackedSfixed64 = new long [ ] { - 1 , - 2 , - 3 } ; <nl> - second = new TestAllTypesNano ( ) ; <nl> - second . repeatedPackedSfixed64 = new long [ ] { - 4 , - 5 } ; <nl> - MessageNano . mergeFrom ( first , MessageNano . toByteArray ( second ) ) ; <nl> - assertEquals ( 5 , first . repeatedPackedSfixed64 . length ) ; <nl> - assertEquals ( - 1 , first . repeatedPackedSfixed64 [ 0 ] ) ; <nl> - assertEquals ( - 4 , first . repeatedPackedSfixed64 [ 3 ] ) ; <nl> - <nl> - first = new TestAllTypesNano ( ) ; <nl> - first . repeatedPackedNestedEnum = new int [ ] { TestAllTypesNano . BAR } ; <nl> - second = new TestAllTypesNano ( ) ; <nl> - second . repeatedPackedNestedEnum = new int [ ] { TestAllTypesNano . FOO } ; <nl> - MessageNano . mergeFrom ( first , MessageNano . toByteArray ( second ) ) ; <nl> - assertEquals ( 2 , first . repeatedPackedNestedEnum . length ) ; <nl> - assertEquals ( TestAllTypesNano . BAR , first . repeatedPackedNestedEnum [ 0 ] ) ; <nl> - assertEquals ( TestAllTypesNano . FOO , first . repeatedPackedNestedEnum [ 1 ] ) ; <nl> - <nl> - / / Now test repeated merging in a nested scope <nl> - TestRepeatedMergeNano firstContainer = new TestRepeatedMergeNano ( ) ; <nl> - firstContainer . contained = new TestAllTypesNano ( ) ; <nl> - firstContainer . contained . repeatedInt32 = new int [ ] { 10 , 20 } ; <nl> - TestRepeatedMergeNano secondContainer = new TestRepeatedMergeNano ( ) ; <nl> - secondContainer . contained = new TestAllTypesNano ( ) ; <nl> - secondContainer . contained . repeatedInt32 = new int [ ] { 30 } ; <nl> - MessageNano . mergeFrom ( firstContainer , MessageNano . toByteArray ( secondContainer ) ) ; <nl> - assertEquals ( 3 , firstContainer . contained . repeatedInt32 . length ) ; <nl> - assertEquals ( 20 , firstContainer . contained . repeatedInt32 [ 1 ] ) ; <nl> - assertEquals ( 30 , firstContainer . contained . repeatedInt32 [ 2 ] ) ; <nl> - } <nl> - <nl> - public void testRepeatedPackables ( ) throws Exception { <nl> - / / Check that repeated fields with packable types can accept both packed and unpacked <nl> - / / serialized forms . <nl> - NanoRepeatedPackables . NonPacked nonPacked = new NanoRepeatedPackables . NonPacked ( ) ; <nl> - / / Exaggerates the first values of varint - typed arrays . This is to test that the parsing code <nl> - / / of packed fields handles non - packed data correctly . If the code incorrectly thinks it is <nl> - / / reading from a packed tag , it will read the first value as the byte length of the field , <nl> - / / and the large number will cause the input to go out of bounds , thus capturing the error . <nl> - nonPacked . int32S = new int [ ] { 1000 , 2 , 3 } ; <nl> - nonPacked . int64S = new long [ ] { 4000 , 5 , 6 } ; <nl> - nonPacked . uint32S = new int [ ] { 7000 , 8 , 9 } ; <nl> - nonPacked . uint64S = new long [ ] { 10000 , 11 , 12 } ; <nl> - nonPacked . sint32S = new int [ ] { 13000 , 14 , 15 } ; <nl> - nonPacked . sint64S = new long [ ] { 16000 , 17 , 18 } ; <nl> - nonPacked . fixed32S = new int [ ] { 19 , 20 , 21 } ; <nl> - nonPacked . fixed64S = new long [ ] { 22 , 23 , 24 } ; <nl> - nonPacked . sfixed32S = new int [ ] { 25 , 26 , 27 } ; <nl> - nonPacked . sfixed64S = new long [ ] { 28 , 29 , 30 } ; <nl> - nonPacked . floats = new float [ ] { 31 , 32 , 33 } ; <nl> - nonPacked . doubles = new double [ ] { 34 , 35 , 36 } ; <nl> - nonPacked . bools = new boolean [ ] { false , true } ; <nl> - nonPacked . enums = new int [ ] { <nl> - NanoRepeatedPackables . Enum . OPTION_ONE , <nl> - NanoRepeatedPackables . Enum . OPTION_TWO , <nl> - } ; <nl> - nonPacked . noise = 13579 ; <nl> - <nl> - byte [ ] nonPackedSerialized = MessageNano . toByteArray ( nonPacked ) ; <nl> - <nl> - NanoRepeatedPackables . Packed packed = <nl> - MessageNano . mergeFrom ( new NanoRepeatedPackables . Packed ( ) , nonPackedSerialized ) ; <nl> - assertRepeatedPackablesEqual ( nonPacked , packed ) ; <nl> - <nl> - byte [ ] packedSerialized = MessageNano . toByteArray ( packed ) ; <nl> - / / Just a cautious check that the two serialized forms are different , <nl> - / / to make sure the remaining of this test is useful : <nl> - assertFalse ( Arrays . equals ( nonPackedSerialized , packedSerialized ) ) ; <nl> - <nl> - nonPacked = MessageNano . mergeFrom ( new NanoRepeatedPackables . NonPacked ( ) , packedSerialized ) ; <nl> - assertRepeatedPackablesEqual ( nonPacked , packed ) ; <nl> - <nl> - / / Test mixed serialized form . <nl> - byte [ ] mixedSerialized = new byte [ nonPackedSerialized . length + packedSerialized . length ] ; <nl> - System . arraycopy ( nonPackedSerialized , 0 , mixedSerialized , 0 , nonPackedSerialized . length ) ; <nl> - System . arraycopy ( packedSerialized , 0 , <nl> - mixedSerialized , nonPackedSerialized . length , packedSerialized . length ) ; <nl> - <nl> - nonPacked = MessageNano . mergeFrom ( new NanoRepeatedPackables . NonPacked ( ) , mixedSerialized ) ; <nl> - packed = MessageNano . mergeFrom ( new NanoRepeatedPackables . Packed ( ) , mixedSerialized ) ; <nl> - assertRepeatedPackablesEqual ( nonPacked , packed ) ; <nl> - assertTrue ( Arrays . equals ( new int [ ] { 1000 , 2 , 3 , 1000 , 2 , 3 } , nonPacked . int32S ) ) ; <nl> - assertTrue ( Arrays . equals ( new int [ ] { 13000 , 14 , 15 , 13000 , 14 , 15 } , nonPacked . sint32S ) ) ; <nl> - assertTrue ( Arrays . equals ( new int [ ] { 25 , 26 , 27 , 25 , 26 , 27 } , nonPacked . sfixed32S ) ) ; <nl> - assertTrue ( Arrays . equals ( new boolean [ ] { false , true , false , true } , nonPacked . bools ) ) ; <nl> - } <nl> - <nl> - public void testMapsSerializeAndParse ( ) throws Exception { <nl> - TestMap origin = new TestMap ( ) ; <nl> - setMapMessage ( origin ) ; <nl> - assertMapMessageSet ( origin ) ; <nl> - <nl> - byte [ ] output = MessageNano . toByteArray ( origin ) ; <nl> - TestMap parsed = new TestMap ( ) ; <nl> - MessageNano . mergeFrom ( parsed , output ) ; <nl> - } <nl> - <nl> - public void testMapSerializeRejectNull ( ) throws Exception { <nl> - TestMap primitiveMap = new TestMap ( ) ; <nl> - primitiveMap . int32ToInt32Field = new HashMap < Integer , Integer > ( ) ; <nl> - primitiveMap . int32ToInt32Field . put ( null , 1 ) ; <nl> - try { <nl> - MessageNano . toByteArray ( primitiveMap ) ; <nl> - fail ( " should reject null keys " ) ; <nl> - } catch ( IllegalStateException e ) { <nl> - / / pass . <nl> - } <nl> - <nl> - TestMap messageMap = new TestMap ( ) ; <nl> - messageMap . int32ToMessageField = <nl> - new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - messageMap . int32ToMessageField . put ( 0 , null ) ; <nl> - try { <nl> - MessageNano . toByteArray ( messageMap ) ; <nl> - fail ( " should reject null values " ) ; <nl> - } catch ( IllegalStateException e ) { <nl> - / / pass . <nl> - } <nl> - } <nl> - <nl> - / * * <nl> - * Tests that merging bytes containing conflicting keys with override the <nl> - * message value instead of merging the message value into the existing entry . <nl> - * / <nl> - public void testMapMergeOverrideMessageValues ( ) throws Exception { <nl> - TestMap . MessageValue origValue = new TestMap . MessageValue ( ) ; <nl> - origValue . value = 1 ; <nl> - origValue . value2 = 2 ; <nl> - TestMap . MessageValue newValue = new TestMap . MessageValue ( ) ; <nl> - newValue . value = 3 ; <nl> - <nl> - TestMap origMessage = new TestMap ( ) ; <nl> - origMessage . int32ToMessageField = <nl> - new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - origMessage . int32ToMessageField . put ( 1 , origValue ) ; <nl> - <nl> - TestMap newMessage = new TestMap ( ) ; <nl> - newMessage . int32ToMessageField = <nl> - new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - newMessage . int32ToMessageField . put ( 1 , newValue ) ; <nl> - MessageNano . mergeFrom ( origMessage , <nl> - MessageNano . toByteArray ( newMessage ) ) ; <nl> - TestMap . MessageValue mergedValue = origMessage . int32ToMessageField . get ( 1 ) ; <nl> - assertEquals ( 3 , mergedValue . value ) ; <nl> - assertEquals ( 0 , mergedValue . value2 ) ; <nl> - } <nl> - <nl> - / * * <nl> - * Tests that when merging with empty entries , <nl> - * we will use default for the key and value , instead of null . <nl> - * / <nl> - public void testMapMergeEmptyEntry ( ) throws Exception { <nl> - TestMap testMap = new TestMap ( ) ; <nl> - byte [ ] buffer = new byte [ 1024 ] ; <nl> - CodedOutputByteBufferNano output = <nl> - CodedOutputByteBufferNano . newInstance ( buffer ) ; <nl> - / / An empty entry for int32_to_int32 map . <nl> - output . writeTag ( 1 , WireFormatNano . WIRETYPE_LENGTH_DELIMITED ) ; <nl> - output . writeRawVarint32 ( 0 ) ; <nl> - / / An empty entry for int32_to_message map . <nl> - output . writeTag ( 5 , WireFormatNano . WIRETYPE_LENGTH_DELIMITED ) ; <nl> - output . writeRawVarint32 ( 0 ) ; <nl> - <nl> - CodedInputByteBufferNano input = CodedInputByteBufferNano . newInstance ( <nl> - buffer , 0 , buffer . length - output . spaceLeft ( ) ) ; <nl> - testMap . mergeFrom ( input ) ; <nl> - assertNotNull ( testMap . int32ToInt32Field ) ; ; <nl> - assertEquals ( 1 , testMap . int32ToInt32Field . size ( ) ) ; <nl> - assertEquals ( Integer . valueOf ( 0 ) , testMap . int32ToInt32Field . get ( 0 ) ) ; <nl> - assertNotNull ( testMap . int32ToMessageField ) ; <nl> - assertEquals ( 1 , testMap . int32ToMessageField . size ( ) ) ; <nl> - TestMap . MessageValue messageValue = testMap . int32ToMessageField . get ( 0 ) ; <nl> - assertNotNull ( messageValue ) ; <nl> - assertEquals ( 0 , messageValue . value ) ; <nl> - assertEquals ( 0 , messageValue . value2 ) ; <nl> - } <nl> - <nl> - public void testMapEquals ( ) throws Exception { <nl> - TestMap a = new TestMap ( ) ; <nl> - TestMap b = new TestMap ( ) ; <nl> - <nl> - / / empty and null map fields are equal . <nl> - assertTestMapEqual ( a , b ) ; <nl> - a . int32ToBytesField = new HashMap < Integer , byte [ ] > ( ) ; <nl> - assertTestMapEqual ( a , b ) ; <nl> - <nl> - a . int32ToInt32Field = new HashMap < Integer , Integer > ( ) ; <nl> - b . int32ToInt32Field = new HashMap < Integer , Integer > ( ) ; <nl> - setMap ( a . int32ToInt32Field , deepCopy ( int32Values ) , deepCopy ( int32Values ) ) ; <nl> - setMap ( b . int32ToInt32Field , deepCopy ( int32Values ) , deepCopy ( int32Values ) ) ; <nl> - assertTestMapEqual ( a , b ) ; <nl> - <nl> - a . int32ToMessageField = <nl> - new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - b . int32ToMessageField = <nl> - new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - setMap ( a . int32ToMessageField , <nl> - deepCopy ( int32Values ) , deepCopy ( messageValues ) ) ; <nl> - setMap ( b . int32ToMessageField , <nl> - deepCopy ( int32Values ) , deepCopy ( messageValues ) ) ; <nl> - assertTestMapEqual ( a , b ) ; <nl> - <nl> - a . stringToInt32Field = new HashMap < String , Integer > ( ) ; <nl> - b . stringToInt32Field = new HashMap < String , Integer > ( ) ; <nl> - setMap ( a . stringToInt32Field , deepCopy ( stringValues ) , deepCopy ( int32Values ) ) ; <nl> - setMap ( b . stringToInt32Field , deepCopy ( stringValues ) , deepCopy ( int32Values ) ) ; <nl> - assertTestMapEqual ( a , b ) ; <nl> - <nl> - a . int32ToBytesField = new HashMap < Integer , byte [ ] > ( ) ; <nl> - b . int32ToBytesField = new HashMap < Integer , byte [ ] > ( ) ; <nl> - setMap ( a . int32ToBytesField , deepCopy ( int32Values ) , deepCopy ( bytesValues ) ) ; <nl> - setMap ( b . int32ToBytesField , deepCopy ( int32Values ) , deepCopy ( bytesValues ) ) ; <nl> - assertTestMapEqual ( a , b ) ; <nl> - <nl> - / / Make sure the map implementation does not matter . <nl> - a . int32ToStringField = new TreeMap < Integer , String > ( ) ; <nl> - b . int32ToStringField = new HashMap < Integer , String > ( ) ; <nl> - setMap ( a . int32ToStringField , deepCopy ( int32Values ) , deepCopy ( stringValues ) ) ; <nl> - setMap ( b . int32ToStringField , deepCopy ( int32Values ) , deepCopy ( stringValues ) ) ; <nl> - assertTestMapEqual ( a , b ) ; <nl> - <nl> - a . clear ( ) ; <nl> - b . clear ( ) ; <nl> - <nl> - / / unequal cases : different value <nl> - a . int32ToInt32Field = new HashMap < Integer , Integer > ( ) ; <nl> - b . int32ToInt32Field = new HashMap < Integer , Integer > ( ) ; <nl> - a . int32ToInt32Field . put ( 1 , 1 ) ; <nl> - b . int32ToInt32Field . put ( 1 , 2 ) ; <nl> - assertTestMapUnequal ( a , b ) ; <nl> - / / unequal case : additional entry <nl> - b . int32ToInt32Field . put ( 1 , 1 ) ; <nl> - b . int32ToInt32Field . put ( 2 , 1 ) ; <nl> - assertTestMapUnequal ( a , b ) ; <nl> - a . int32ToInt32Field . put ( 2 , 1 ) ; <nl> - assertTestMapEqual ( a , b ) ; <nl> - <nl> - / / unequal case : different message value . <nl> - a . int32ToMessageField = <nl> - new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - b . int32ToMessageField = <nl> - new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - MessageValue va = new MessageValue ( ) ; <nl> - va . value = 1 ; <nl> - MessageValue vb = new MessageValue ( ) ; <nl> - vb . value = 1 ; <nl> - a . int32ToMessageField . put ( 1 , va ) ; <nl> - b . int32ToMessageField . put ( 1 , vb ) ; <nl> - assertTestMapEqual ( a , b ) ; <nl> - vb . value = 2 ; <nl> - assertTestMapUnequal ( a , b ) ; <nl> - } <nl> - <nl> - private static void assertTestMapEqual ( TestMap a , TestMap b ) <nl> - throws Exception { <nl> - assertEquals ( a . hashCode ( ) , b . hashCode ( ) ) ; <nl> - assertTrue ( a . equals ( b ) ) ; <nl> - assertTrue ( b . equals ( a ) ) ; <nl> - } <nl> - <nl> - private static void assertTestMapUnequal ( TestMap a , TestMap b ) <nl> - throws Exception { <nl> - assertFalse ( a . equals ( b ) ) ; <nl> - assertFalse ( b . equals ( a ) ) ; <nl> - } <nl> - <nl> - private static final Integer [ ] int32Values = new Integer [ ] { <nl> - 0 , 1 , - 1 , Integer . MAX_VALUE , Integer . MIN_VALUE , <nl> - } ; <nl> - <nl> - private static final Long [ ] int64Values = new Long [ ] { <nl> - 0L , 1L , - 1L , Long . MAX_VALUE , Long . MIN_VALUE , <nl> - } ; <nl> - <nl> - private static final String [ ] stringValues = new String [ ] { <nl> - " " , " hello " , " world " , " foo " , " bar " , <nl> - } ; <nl> - <nl> - private static final byte [ ] [ ] bytesValues = new byte [ ] [ ] { <nl> - new byte [ ] { } , <nl> - new byte [ ] { 0 } , <nl> - new byte [ ] { 1 , - 1 } , <nl> - new byte [ ] { 127 , - 128 } , <nl> - new byte [ ] { ' a ' , ' b ' , ' 0 ' , ' 1 ' } , <nl> - } ; <nl> - <nl> - private static final Boolean [ ] boolValues = new Boolean [ ] { <nl> - false , true , <nl> - } ; <nl> - <nl> - private static final Integer [ ] enumValues = new Integer [ ] { <nl> - TestMap . FOO , TestMap . BAR , TestMap . BAZ , TestMap . QUX , <nl> - Integer . MAX_VALUE / * unknown * / , <nl> - } ; <nl> - <nl> - private static final TestMap . MessageValue [ ] messageValues = <nl> - new TestMap . MessageValue [ ] { <nl> - newMapValueMessage ( 0 ) , <nl> - newMapValueMessage ( 1 ) , <nl> - newMapValueMessage ( - 1 ) , <nl> - newMapValueMessage ( Integer . MAX_VALUE ) , <nl> - newMapValueMessage ( Integer . MIN_VALUE ) , <nl> - } ; <nl> - <nl> - private static TestMap . MessageValue newMapValueMessage ( int value ) { <nl> - TestMap . MessageValue result = new TestMap . MessageValue ( ) ; <nl> - result . value = value ; <nl> - return result ; <nl> - } <nl> - <nl> - @ SuppressWarnings ( " unchecked " ) <nl> - private static < T > T [ ] deepCopy ( T [ ] orig ) throws Exception { <nl> - if ( orig instanceof MessageValue [ ] ) { <nl> - MessageValue [ ] result = new MessageValue [ orig . length ] ; <nl> - for ( int i = 0 ; i < orig . length ; i + + ) { <nl> - result [ i ] = new MessageValue ( ) ; <nl> - MessageNano . mergeFrom ( <nl> - result [ i ] , MessageNano . toByteArray ( ( MessageValue ) orig [ i ] ) ) ; <nl> - } <nl> - return ( T [ ] ) result ; <nl> - } <nl> - if ( orig instanceof byte [ ] [ ] ) { <nl> - byte [ ] [ ] result = new byte [ orig . length ] [ ] ; <nl> - for ( int i = 0 ; i < orig . length ; i + + ) { <nl> - byte [ ] origBytes = ( byte [ ] ) orig [ i ] ; <nl> - result [ i ] = Arrays . copyOf ( origBytes , origBytes . length ) ; <nl> - } <nl> - } <nl> - return Arrays . copyOf ( orig , orig . length ) ; <nl> - } <nl> - <nl> - private < K , V > void setMap ( Map < K , V > map , K [ ] keys , V [ ] values ) { <nl> - assert ( keys . length = = values . length ) ; <nl> - for ( int i = 0 ; i < keys . length ; i + + ) { <nl> - map . put ( keys [ i ] , values [ i ] ) ; <nl> - } <nl> - } <nl> - <nl> - private < K , V > void assertMapSet ( <nl> - Map < K , V > map , K [ ] keys , V [ ] values ) throws Exception { <nl> - assert ( keys . length = = values . length ) ; <nl> - for ( int i = 0 ; i < values . length ; i + + ) { <nl> - assertEquals ( values [ i ] , map . get ( keys [ i ] ) ) ; <nl> - } <nl> - assertEquals ( keys . length , map . size ( ) ) ; <nl> - } <nl> - <nl> - private void setMapMessage ( TestMap testMap ) { <nl> - testMap . int32ToInt32Field = new HashMap < Integer , Integer > ( ) ; <nl> - testMap . int32ToBytesField = new HashMap < Integer , byte [ ] > ( ) ; <nl> - testMap . int32ToEnumField = new HashMap < Integer , Integer > ( ) ; <nl> - testMap . int32ToMessageField = <nl> - new HashMap < Integer , MapTestProto . TestMap . MessageValue > ( ) ; <nl> - testMap . int32ToStringField = new HashMap < Integer , String > ( ) ; <nl> - testMap . stringToInt32Field = new HashMap < String , Integer > ( ) ; <nl> - testMap . boolToBoolField = new HashMap < Boolean , Boolean > ( ) ; <nl> - testMap . uint32ToUint32Field = new HashMap < Integer , Integer > ( ) ; <nl> - testMap . sint32ToSint32Field = new HashMap < Integer , Integer > ( ) ; <nl> - testMap . fixed32ToFixed32Field = new HashMap < Integer , Integer > ( ) ; <nl> - testMap . sfixed32ToSfixed32Field = new HashMap < Integer , Integer > ( ) ; <nl> - testMap . int64ToInt64Field = new HashMap < Long , Long > ( ) ; <nl> - testMap . uint64ToUint64Field = new HashMap < Long , Long > ( ) ; <nl> - testMap . sint64ToSint64Field = new HashMap < Long , Long > ( ) ; <nl> - testMap . fixed64ToFixed64Field = new HashMap < Long , Long > ( ) ; <nl> - testMap . sfixed64ToSfixed64Field = new HashMap < Long , Long > ( ) ; <nl> - setMap ( testMap . int32ToInt32Field , int32Values , int32Values ) ; <nl> - setMap ( testMap . int32ToBytesField , int32Values , bytesValues ) ; <nl> - setMap ( testMap . int32ToEnumField , int32Values , enumValues ) ; <nl> - setMap ( testMap . int32ToMessageField , int32Values , messageValues ) ; <nl> - setMap ( testMap . int32ToStringField , int32Values , stringValues ) ; <nl> - setMap ( testMap . stringToInt32Field , stringValues , int32Values ) ; <nl> - setMap ( testMap . boolToBoolField , boolValues , boolValues ) ; <nl> - setMap ( testMap . uint32ToUint32Field , int32Values , int32Values ) ; <nl> - setMap ( testMap . sint32ToSint32Field , int32Values , int32Values ) ; <nl> - setMap ( testMap . fixed32ToFixed32Field , int32Values , int32Values ) ; <nl> - setMap ( testMap . sfixed32ToSfixed32Field , int32Values , int32Values ) ; <nl> - setMap ( testMap . int64ToInt64Field , int64Values , int64Values ) ; <nl> - setMap ( testMap . uint64ToUint64Field , int64Values , int64Values ) ; <nl> - setMap ( testMap . sint64ToSint64Field , int64Values , int64Values ) ; <nl> - setMap ( testMap . fixed64ToFixed64Field , int64Values , int64Values ) ; <nl> - setMap ( testMap . sfixed64ToSfixed64Field , int64Values , int64Values ) ; <nl> - } <nl> - private void assertMapMessageSet ( TestMap testMap ) throws Exception { <nl> - assertMapSet ( testMap . int32ToInt32Field , int32Values , int32Values ) ; <nl> - assertMapSet ( testMap . int32ToBytesField , int32Values , bytesValues ) ; <nl> - assertMapSet ( testMap . int32ToEnumField , int32Values , enumValues ) ; <nl> - assertMapSet ( testMap . int32ToMessageField , int32Values , messageValues ) ; <nl> - assertMapSet ( testMap . int32ToStringField , int32Values , stringValues ) ; <nl> - assertMapSet ( testMap . stringToInt32Field , stringValues , int32Values ) ; <nl> - assertMapSet ( testMap . boolToBoolField , boolValues , boolValues ) ; <nl> - assertMapSet ( testMap . uint32ToUint32Field , int32Values , int32Values ) ; <nl> - assertMapSet ( testMap . sint32ToSint32Field , int32Values , int32Values ) ; <nl> - assertMapSet ( testMap . fixed32ToFixed32Field , int32Values , int32Values ) ; <nl> - assertMapSet ( testMap . sfixed32ToSfixed32Field , int32Values , int32Values ) ; <nl> - assertMapSet ( testMap . int64ToInt64Field , int64Values , int64Values ) ; <nl> - assertMapSet ( testMap . uint64ToUint64Field , int64Values , int64Values ) ; <nl> - assertMapSet ( testMap . sint64ToSint64Field , int64Values , int64Values ) ; <nl> - assertMapSet ( testMap . fixed64ToFixed64Field , int64Values , int64Values ) ; <nl> - assertMapSet ( testMap . sfixed64ToSfixed64Field , int64Values , int64Values ) ; <nl> - } <nl> - <nl> - public void testRepeatedFieldInitializedInReftypesCompatMode ( ) { <nl> - NanoReferenceTypesCompat . TestAllTypesNano proto = new NanoReferenceTypesCompat . TestAllTypesNano ( ) ; <nl> - assertNotNull ( proto . repeatedString ) ; <nl> - } <nl> - <nl> - private void assertRepeatedPackablesEqual ( <nl> - NanoRepeatedPackables . NonPacked nonPacked , NanoRepeatedPackables . Packed packed ) { <nl> - / / Not using MessageNano . equals ( ) - - that belongs to a separate test . <nl> - assertTrue ( Arrays . equals ( nonPacked . int32S , packed . int32S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . int64S , packed . int64S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . uint32S , packed . uint32S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . uint64S , packed . uint64S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . sint32S , packed . sint32S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . sint64S , packed . sint64S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . fixed32S , packed . fixed32S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . fixed64S , packed . fixed64S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . sfixed32S , packed . sfixed32S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . sfixed64S , packed . sfixed64S ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . floats , packed . floats ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . doubles , packed . doubles ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . bools , packed . bools ) ) ; <nl> - assertTrue ( Arrays . equals ( nonPacked . enums , packed . enums ) ) ; <nl> - } <nl> - <nl> - public void testClone ( ) throws Exception { <nl> - / / A simple message . <nl> - AnotherMessage anotherMessage = new AnotherMessage ( ) ; <nl> - anotherMessage . string = " Hello " ; <nl> - anotherMessage . value = true ; <nl> - anotherMessage . integers = new int [ ] { 1 , 2 , 3 } ; <nl> - <nl> - AnotherMessage clone = anotherMessage . clone ( ) ; <nl> - assertEquals ( clone , anotherMessage ) ; <nl> - <nl> - / / Verify it was a deep clone - changes to the clone shouldn ' t affect the <nl> - / / original . <nl> - clone . integers [ 1 ] = 100 ; <nl> - assertFalse ( clone . equals ( anotherMessage ) ) ; <nl> - } <nl> - <nl> - private void assertHasWireData ( MessageNano message , boolean expected ) { <nl> - byte [ ] bytes = MessageNano . toByteArray ( message ) ; <nl> - int wireLength = bytes . length ; <nl> - if ( expected ) { <nl> - assertFalse ( wireLength = = 0 ) ; <nl> - } else { <nl> - if ( wireLength ! = 0 ) { <nl> - fail ( " Expected no wire data for message \ n " + message <nl> - + " \ nBut got : \ n " <nl> - + hexDump ( bytes ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - private static String hexDump ( byte [ ] bytes ) { <nl> - StringBuilder sb = new StringBuilder ( ) ; <nl> - for ( byte b : bytes ) { <nl> - sb . append ( String . format ( " % 02x " , b ) ) ; <nl> - } <nl> - return sb . toString ( ) ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 51498a4925 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / map_test . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - syntax = " proto3 " ; <nl> - <nl> - package map_test ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " MapTestProto " ; <nl> - <nl> - message TestMap { <nl> - message MessageValue { <nl> - int32 value = 1 ; <nl> - int32 value2 = 2 ; <nl> - } <nl> - enum EnumValue { <nl> - FOO = 0 ; <nl> - BAR = 1 ; <nl> - BAZ = 2 ; <nl> - QUX = 3 ; <nl> - } <nl> - <nl> - map < int32 , int32 > int32_to_int32_field = 1 ; <nl> - map < int32 , string > int32_to_string_field = 2 ; <nl> - map < int32 , bytes > int32_to_bytes_field = 3 ; <nl> - map < int32 , EnumValue > int32_to_enum_field = 4 ; <nl> - map < int32 , MessageValue > int32_to_message_field = 5 ; <nl> - map < string , int32 > string_to_int32_field = 6 ; <nl> - map < bool , bool > bool_to_bool_field = 7 ; <nl> - <nl> - / / Test all the other primitive types . As the key and value are not coupled in <nl> - / / the implementation , we do not test all the combinations of key / value pairs , <nl> - / / so that we can keep the number of test cases manageable <nl> - map < uint32 , uint32 > uint32_to_uint32_field = 11 ; <nl> - map < sint32 , sint32 > sint32_to_sint32_field = 12 ; <nl> - map < fixed32 , fixed32 > fixed32_to_fixed32_field = 13 ; <nl> - map < sfixed32 , sfixed32 > sfixed32_to_sfixed32_field = 14 ; <nl> - map < int64 , int64 > int64_to_int64_field = 15 ; <nl> - map < uint64 , uint64 > uint64_to_uint64_field = 16 ; <nl> - map < sint64 , sint64 > sint64_to_sint64_field = 17 ; <nl> - map < fixed64 , fixed64 > fixed64_to_fixed64_field = 18 ; <nl> - map < sfixed64 , sfixed64 > sfixed64_to_sfixed64_field = 19 ; <nl> - } <nl> deleted file mode 100644 <nl> index 6511e4703b . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_accessors_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : maxtroy @ google . com ( Max Cai ) <nl> - <nl> - package protobuf_unittest ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " NanoAccessorsOuterClass " ; <nl> - <nl> - message TestNanoAccessors { <nl> - <nl> - message NestedMessage { <nl> - optional int32 bb = 1 ; <nl> - } <nl> - <nl> - enum NestedEnum { <nl> - FOO = 1 ; <nl> - BAR = 2 ; <nl> - BAZ = 3 ; <nl> - } <nl> - <nl> - / / Singular <nl> - optional int32 optional_int32 = 1 ; <nl> - optional float optional_float = 11 ; <nl> - optional double optional_double = 12 ; <nl> - optional string optional_string = 14 ; <nl> - optional bytes optional_bytes = 15 ; <nl> - <nl> - optional NestedMessage optional_nested_message = 18 ; <nl> - <nl> - optional NestedEnum optional_nested_enum = 21 ; <nl> - <nl> - / / Repeated <nl> - repeated int32 repeated_int32 = 31 ; <nl> - repeated string repeated_string = 44 ; <nl> - repeated bytes repeated_bytes = 45 ; <nl> - <nl> - repeated NestedMessage repeated_nested_message = 48 ; <nl> - <nl> - repeated NestedEnum repeated_nested_enum = 51 ; <nl> - <nl> - / / Singular with defaults <nl> - optional int32 default_int32 = 61 [ default = 41 ] ; <nl> - optional string default_string = 74 [ default = " hello " ] ; <nl> - optional bytes default_bytes = 75 [ default = " world " ] ; <nl> - <nl> - optional float default_float_nan = 99 [ default = nan ] ; <nl> - <nl> - optional NestedEnum default_nested_enum = 81 [ default = BAR ] ; <nl> - <nl> - / / Required <nl> - required int32 id = 86 ; <nl> - <nl> - / / Add enough optional fields to make 2 bit fields in total <nl> - optional int32 filler100 = 100 ; <nl> - optional int32 filler101 = 101 ; <nl> - optional int32 filler102 = 102 ; <nl> - optional int32 filler103 = 103 ; <nl> - optional int32 filler104 = 104 ; <nl> - optional int32 filler105 = 105 ; <nl> - optional int32 filler106 = 106 ; <nl> - optional int32 filler107 = 107 ; <nl> - optional int32 filler108 = 108 ; <nl> - optional int32 filler109 = 109 ; <nl> - optional int32 filler110 = 110 ; <nl> - optional int32 filler111 = 111 ; <nl> - optional int32 filler112 = 112 ; <nl> - optional int32 filler113 = 113 ; <nl> - optional int32 filler114 = 114 ; <nl> - optional int32 filler115 = 115 ; <nl> - optional int32 filler116 = 116 ; <nl> - optional int32 filler117 = 117 ; <nl> - optional int32 filler118 = 118 ; <nl> - optional int32 filler119 = 119 ; <nl> - optional int32 filler120 = 120 ; <nl> - optional int32 filler121 = 121 ; <nl> - optional int32 filler122 = 122 ; <nl> - optional int32 filler123 = 123 ; <nl> - optional int32 filler124 = 124 ; <nl> - optional int32 filler125 = 125 ; <nl> - optional int32 filler126 = 126 ; <nl> - optional int32 filler127 = 127 ; <nl> - optional int32 filler128 = 128 ; <nl> - optional int32 filler129 = 129 ; <nl> - optional int32 filler130 = 130 ; <nl> - <nl> - optional int32 before_bit_field_check = 139 ; <nl> - optional int32 bit_field_check = 140 ; <nl> - optional int32 after_bit_field_check = 141 ; <nl> - } <nl> deleted file mode 100644 <nl> index 958e1f17ca . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_enum_class_multiple_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : maxtroy @ google . com ( Max Cai ) <nl> - <nl> - package protobuf_unittest ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_multiple_files = true ; <nl> - <nl> - enum FileScopeEnumMultiple { <nl> - THREE = 3 ; <nl> - } <nl> - <nl> - message EnumClassNanoMultiple { <nl> - enum MessageScopeEnumMultiple { <nl> - FOUR = 4 ; <nl> - } <nl> - optional FileScopeEnumMultiple three = 3 [ default = THREE ] ; <nl> - optional MessageScopeEnumMultiple four = 4 [ default = FOUR ] ; <nl> - } <nl> deleted file mode 100644 <nl> index 3a1e07f6d9 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_enum_class_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : maxtroy @ google . com ( Max Cai ) <nl> - <nl> - package protobuf_unittest ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " EnumClassNanos " ; <nl> - <nl> - enum FileScopeEnum { <nl> - ONE = 1 ; <nl> - } <nl> - <nl> - message EnumClassNano { <nl> - enum MessageScopeEnum { <nl> - TWO = 2 ; <nl> - } <nl> - optional FileScopeEnum one = 1 [ default = ONE ] ; <nl> - optional MessageScopeEnum two = 2 [ default = TWO ] ; <nl> - } <nl> deleted file mode 100644 <nl> index c0da8b422e . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_enum_validity_nano . proto <nl> ppp / dev / null <nl> <nl> - package protobuf_unittest ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " EnumValidity " ; <nl> - <nl> - enum E { <nl> - default = 1 ; / / test java keyword renaming <nl> - FOO = 2 ; <nl> - BAR = 3 ; <nl> - BAZ = 4 ; <nl> - } <nl> - <nl> - message M { <nl> - optional E optional_e = 1 ; <nl> - optional E default_e = 2 [ default = BAZ ] ; <nl> - repeated E repeated_e = 3 ; <nl> - repeated E packed_e = 4 [ packed = true ] ; <nl> - repeated E repeated_e2 = 5 ; <nl> - repeated E packed_e2 = 6 [ packed = true ] ; <nl> - repeated E repeated_e3 = 7 ; <nl> - repeated E packed_e3 = 8 [ packed = true ] ; <nl> - } <nl> - <nl> - message Alt { <nl> - optional E repeated_e2_as_optional = 5 ; <nl> - repeated E packed_e2_as_non_packed = 6 ; <nl> - repeated E non_packed_e3_as_packed = 7 [ packed = true ] ; <nl> - } <nl> deleted file mode 100644 <nl> index ca56b3dd45 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_extension_nano . proto <nl> ppp / dev / null <nl> <nl> - syntax = " proto2 " ; <nl> - <nl> - option java_outer_classname = " Extensions " ; <nl> - option java_package = " com . google . protobuf . nano . testext " ; <nl> - <nl> - message ExtendableMessage { <nl> - optional int32 field = 1 ; <nl> - extensions 10 to max ; <nl> - } <nl> - <nl> - enum AnEnum { <nl> - FIRST_VALUE = 1 ; <nl> - SECOND_VALUE = 2 ; <nl> - } <nl> - <nl> - message AnotherMessage { <nl> - optional string string = 1 ; <nl> - optional bool value = 2 ; <nl> - repeated int32 integers = 3 ; <nl> - } <nl> - <nl> - message ContainerMessage { <nl> - extend ExtendableMessage { <nl> - optional bool another_thing = 100 ; <nl> - / / The largest permitted field number , per <nl> - / / https : / / developers . google . com / protocol - buffers / docs / proto # simple <nl> - optional bool large_field_number = 536870911 ; <nl> - } <nl> - } <nl> - <nl> - / / For testNanoOptionalGroupWithUnknownFieldsEnabled ; <nl> - / / not part of the extensions tests . <nl> - message MessageWithGroup { <nl> - optional group Group = 1 { <nl> - optional int32 a = 2 ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 3b7a004c9e . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_extension_packed_nano . proto <nl> ppp / dev / null <nl> <nl> - syntax = " proto2 " ; <nl> - <nl> - option java_multiple_files = true ; <nl> - option java_package = " com . google . protobuf " ; <nl> - <nl> - import " google / protobuf / nano / unittest_extension_nano . proto " ; <nl> - <nl> - / / Must be compiled separately due to extension number reuse . <nl> - / / The reuse is deliberate , for testing wire compatibility . <nl> - <nl> - message PackedExtensions { <nl> - extend ExtendableMessage { <nl> - repeated int32 packed_int32 = 10 [ packed = true ] ; <nl> - repeated uint32 packed_uint32 = 11 [ packed = true ] ; <nl> - repeated sint32 packed_sint32 = 12 [ packed = true ] ; <nl> - repeated int64 packed_int64 = 13 [ packed = true ] ; <nl> - repeated uint64 packed_uint64 = 14 [ packed = true ] ; <nl> - repeated sint64 packed_sint64 = 15 [ packed = true ] ; <nl> - repeated fixed32 packed_fixed32 = 16 [ packed = true ] ; <nl> - repeated sfixed32 packed_sfixed32 = 17 [ packed = true ] ; <nl> - repeated fixed64 packed_fixed64 = 18 [ packed = true ] ; <nl> - repeated sfixed64 packed_sfixed64 = 19 [ packed = true ] ; <nl> - repeated bool packed_bool = 20 [ packed = true ] ; <nl> - repeated float packed_float = 21 [ packed = true ] ; <nl> - repeated double packed_double = 22 [ packed = true ] ; <nl> - repeated AnEnum packed_enum = 23 [ packed = true ] ; <nl> - / / Non - packable types omitted . <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index e533c65b43 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_extension_repeated_nano . proto <nl> ppp / dev / null <nl> <nl> - syntax = " proto2 " ; <nl> - <nl> - option java_multiple_files = true ; <nl> - option java_package = " com . google . protobuf " ; <nl> - <nl> - import " google / protobuf / nano / unittest_extension_nano . proto " ; <nl> - <nl> - / / Must be compiled separately due to extension number reuse . <nl> - / / The reuse is deliberate , for testing wire compatibility . <nl> - <nl> - message RepeatedExtensions { <nl> - extend ExtendableMessage { <nl> - repeated int32 repeated_int32 = 10 ; <nl> - repeated uint32 repeated_uint32 = 11 ; <nl> - repeated sint32 repeated_sint32 = 12 ; <nl> - repeated int64 repeated_int64 = 13 ; <nl> - repeated uint64 repeated_uint64 = 14 ; <nl> - repeated sint64 repeated_sint64 = 15 ; <nl> - repeated fixed32 repeated_fixed32 = 16 ; <nl> - repeated sfixed32 repeated_sfixed32 = 17 ; <nl> - repeated fixed64 repeated_fixed64 = 18 ; <nl> - repeated sfixed64 repeated_sfixed64 = 19 ; <nl> - repeated bool repeated_bool = 20 ; <nl> - repeated float repeated_float = 21 ; <nl> - repeated double repeated_double = 22 ; <nl> - repeated AnEnum repeated_enum = 23 ; <nl> - repeated string repeated_string = 24 ; <nl> - repeated bytes repeated_bytes = 25 ; <nl> - repeated AnotherMessage repeated_message = 26 ; <nl> - repeated group RepeatedGroup = 27 { <nl> - optional int32 a = 1 ; <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 8b2d965888 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_extension_singular_nano . proto <nl> ppp / dev / null <nl> <nl> - syntax = " proto2 " ; <nl> - <nl> - option java_multiple_files = true ; <nl> - option java_package = " com . google . protobuf " ; <nl> - <nl> - import " google / protobuf / nano / unittest_extension_nano . proto " ; <nl> - <nl> - / / Must be compiled separately due to extension number reuse . <nl> - / / The reuse is deliberate , for testing wire compatibility . <nl> - <nl> - message SingularExtensions { <nl> - extend ExtendableMessage { <nl> - optional int32 some_int32 = 10 ; <nl> - optional uint32 some_uint32 = 11 ; <nl> - optional sint32 some_sint32 = 12 ; <nl> - optional int64 some_int64 = 13 ; <nl> - optional uint64 some_uint64 = 14 ; <nl> - optional sint64 some_sint64 = 15 ; <nl> - optional fixed32 some_fixed32 = 16 ; <nl> - optional sfixed32 some_sfixed32 = 17 ; <nl> - optional fixed64 some_fixed64 = 18 ; <nl> - optional sfixed64 some_sfixed64 = 19 ; <nl> - optional bool some_bool = 20 ; <nl> - optional float some_float = 21 ; <nl> - optional double some_double = 22 ; <nl> - optional AnEnum some_enum = 23 ; <nl> - optional string some_string = 24 ; <nl> - optional bytes some_bytes = 25 ; <nl> - optional AnotherMessage some_message = 26 ; <nl> - optional group SomeGroup = 27 { <nl> - optional int32 a = 1 ; <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index fe7d1794a7 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_has_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : ulas @ google . com ( Ulas Kirazci ) <nl> - <nl> - package protobuf_unittest ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " NanoHasOuterClass " ; <nl> - <nl> - message TestAllTypesNanoHas { <nl> - <nl> - message NestedMessage { <nl> - optional int32 bb = 1 ; <nl> - } <nl> - <nl> - enum NestedEnum { <nl> - FOO = 1 ; <nl> - BAR = 2 ; <nl> - BAZ = 3 ; <nl> - } <nl> - <nl> - / / Singular <nl> - optional int32 optional_int32 = 1 ; <nl> - optional float optional_float = 11 ; <nl> - optional double optional_double = 12 ; <nl> - optional string optional_string = 14 ; <nl> - optional bytes optional_bytes = 15 ; <nl> - <nl> - optional NestedMessage optional_nested_message = 18 ; <nl> - <nl> - optional NestedEnum optional_nested_enum = 21 ; <nl> - <nl> - / / Repeated <nl> - repeated int32 repeated_int32 = 31 ; <nl> - repeated string repeated_string = 44 ; <nl> - repeated bytes repeated_bytes = 45 ; <nl> - <nl> - repeated NestedMessage repeated_nested_message = 48 ; <nl> - <nl> - repeated NestedEnum repeated_nested_enum = 51 ; <nl> - <nl> - / / Singular with defaults <nl> - optional int32 default_int32 = 61 [ default = 41 ] ; <nl> - optional string default_string = 74 [ default = " hello " ] ; <nl> - optional bytes default_bytes = 75 [ default = " world " ] ; <nl> - <nl> - optional float default_float_nan = 99 [ default = nan ] ; <nl> - <nl> - optional NestedEnum default_nested_enum = 81 [ default = BAR ] ; <nl> - <nl> - required int32 id = 86 ; <nl> - required NestedEnum required_enum = 87 ; <nl> - <nl> - } <nl> deleted file mode 100644 <nl> index 1a3ddc57ea . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_import_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / <nl> - / / This is like unittest_import . proto but with optimize_for = NANO_RUNTIME . <nl> - <nl> - package protobuf_unittest_import ; <nl> - <nl> - option java_package = " com . google . protobuf . nano . testimport " ; <nl> - option java_outer_classname = " UnittestImportNano " ; <nl> - <nl> - message ImportMessageNano { <nl> - optional int32 d = 1 ; <nl> - } <nl> - <nl> - enum ImportEnumNano { <nl> - IMPORT_NANO_FOO = 7 ; <nl> - IMPORT_NANO_BAR = 8 ; <nl> - IMPORT_NANO_BAZ = 9 ; <nl> - } <nl> deleted file mode 100644 <nl> index b31c43994c . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_multiple_nameclash_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : maxtroy @ google . com ( Max Cai ) <nl> - <nl> - package protobuf_unittest_import ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " MultipleNameClashNano " ; <nl> - option java_multiple_files = true ; <nl> - <nl> - message MultipleNameClashNano { <nl> - optional int32 field = 1 ; <nl> - } <nl> deleted file mode 100644 <nl> index 406ab7741c . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_multiple_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : maxtroy @ google . com ( Max Cai ) <nl> - <nl> - package protobuf_unittest_import ; <nl> - <nl> - import " google / protobuf / nano / unittest_import_nano . proto " ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_multiple_files = true ; <nl> - <nl> - enum FileScopeEnum { <nl> - ONE = 1 ; <nl> - TWO = 2 ; <nl> - } <nl> - <nl> - message FileScopeEnumRefNano { <nl> - optional FileScopeEnum enum_field = 1 ; <nl> - } <nl> - <nl> - message MessageScopeEnumRefNano { <nl> - enum MessageScopeEnum { <nl> - ONE = 1 ; <nl> - TWO = 2 ; <nl> - } <nl> - optional MessageScopeEnum enum_field = 1 ; <nl> - } <nl> - <nl> - message MultipleImportingNonMultipleNano1 { <nl> - optional ImportMessageNano field = 1 ; <nl> - } <nl> - <nl> - message MultipleImportingNonMultipleNano2 { <nl> - optional MultipleImportingNonMultipleNano1 nano1 = 1 ; <nl> - } <nl> deleted file mode 100644 <nl> index 3fff24c0c4 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : wink @ google . com ( Wink Saville ) <nl> - <nl> - package protobuf_unittest ; <nl> - <nl> - import " google / protobuf / nano / unittest_import_nano . proto " ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " NanoOuterClass " ; <nl> - <nl> - / / Same as TestAllTypes but with the nano runtime . <nl> - message TestAllTypesNano { <nl> - <nl> - message NestedMessage { <nl> - optional int32 bb = 1 ; <nl> - } <nl> - <nl> - enum NestedEnum { <nl> - FOO = 1 ; <nl> - BAR = 2 ; <nl> - BAZ = 3 ; <nl> - } <nl> - <nl> - / / Singular <nl> - optional int32 optional_int32 = 1 ; <nl> - optional int64 optional_int64 = 2 ; <nl> - optional uint32 optional_uint32 = 3 ; <nl> - optional uint64 optional_uint64 = 4 ; <nl> - optional sint32 optional_sint32 = 5 ; <nl> - optional sint64 optional_sint64 = 6 ; <nl> - optional fixed32 optional_fixed32 = 7 ; <nl> - optional fixed64 optional_fixed64 = 8 ; <nl> - optional sfixed32 optional_sfixed32 = 9 ; <nl> - optional sfixed64 optional_sfixed64 = 10 ; <nl> - optional float optional_float = 11 ; <nl> - optional double optional_double = 12 ; <nl> - optional bool optional_bool = 13 ; <nl> - optional string optional_string = 14 ; <nl> - optional bytes optional_bytes = 15 ; <nl> - <nl> - optional group OptionalGroup = 16 { <nl> - optional int32 a = 17 ; <nl> - } <nl> - <nl> - optional NestedMessage optional_nested_message = 18 ; <nl> - optional ForeignMessageNano optional_foreign_message = 19 ; <nl> - optional protobuf_unittest_import . ImportMessageNano <nl> - optional_import_message = 20 ; <nl> - <nl> - optional NestedEnum optional_nested_enum = 21 ; <nl> - optional ForeignEnumNano optional_foreign_enum = 22 ; <nl> - optional protobuf_unittest_import . ImportEnumNano optional_import_enum = 23 ; <nl> - <nl> - optional string optional_string_piece = 24 [ ctype = STRING_PIECE ] ; <nl> - optional string optional_cord = 25 [ ctype = CORD ] ; <nl> - <nl> - / / Repeated <nl> - repeated int32 repeated_int32 = 31 ; <nl> - repeated int64 repeated_int64 = 32 ; <nl> - repeated uint32 repeated_uint32 = 33 ; <nl> - repeated uint64 repeated_uint64 = 34 ; <nl> - repeated sint32 repeated_sint32 = 35 ; <nl> - repeated sint64 repeated_sint64 = 36 ; <nl> - repeated fixed32 repeated_fixed32 = 37 ; <nl> - repeated fixed64 repeated_fixed64 = 38 ; <nl> - repeated sfixed32 repeated_sfixed32 = 39 ; <nl> - repeated sfixed64 repeated_sfixed64 = 40 ; <nl> - repeated float repeated_float = 41 ; <nl> - repeated double repeated_double = 42 ; <nl> - repeated bool repeated_bool = 43 ; <nl> - repeated string repeated_string = 44 ; <nl> - repeated bytes repeated_bytes = 45 ; <nl> - <nl> - repeated group RepeatedGroup = 46 { <nl> - optional int32 a = 47 ; <nl> - } <nl> - <nl> - repeated NestedMessage repeated_nested_message = 48 ; <nl> - repeated ForeignMessageNano repeated_foreign_message = 49 ; <nl> - repeated protobuf_unittest_import . ImportMessageNano <nl> - repeated_import_message = 50 ; <nl> - <nl> - repeated NestedEnum repeated_nested_enum = 51 ; <nl> - repeated ForeignEnumNano repeated_foreign_enum = 52 ; <nl> - repeated protobuf_unittest_import . ImportEnumNano repeated_import_enum = 53 ; <nl> - <nl> - repeated string repeated_string_piece = 54 [ ctype = STRING_PIECE ] ; <nl> - repeated string repeated_cord = 55 [ ctype = CORD ] ; <nl> - <nl> - / / Repeated packed <nl> - repeated int32 repeated_packed_int32 = 87 [ packed = true ] ; <nl> - repeated sfixed64 repeated_packed_sfixed64 = 88 [ packed = true ] ; <nl> - <nl> - repeated NestedEnum repeated_packed_nested_enum = 89 [ packed = true ] ; <nl> - <nl> - / / Singular with defaults <nl> - optional int32 default_int32 = 61 [ default = 41 ] ; <nl> - optional int64 default_int64 = 62 [ default = 42 ] ; <nl> - optional uint32 default_uint32 = 63 [ default = 43 ] ; <nl> - optional uint64 default_uint64 = 64 [ default = 44 ] ; <nl> - optional sint32 default_sint32 = 65 [ default = - 45 ] ; <nl> - optional sint64 default_sint64 = 66 [ default = 46 ] ; <nl> - optional fixed32 default_fixed32 = 67 [ default = 47 ] ; <nl> - optional fixed64 default_fixed64 = 68 [ default = 48 ] ; <nl> - optional sfixed32 default_sfixed32 = 69 [ default = 49 ] ; <nl> - optional sfixed64 default_sfixed64 = 70 [ default = - 50 ] ; <nl> - optional float default_float = 71 [ default = 51 . 5 ] ; <nl> - optional double default_double = 72 [ default = 52e3 ] ; <nl> - optional bool default_bool = 73 [ default = true ] ; <nl> - optional string default_string = 74 [ default = " hello " ] ; <nl> - optional bytes default_bytes = 75 [ default = " world " ] ; <nl> - <nl> - optional string default_string_nonascii = 76 [ default = " dünya " ] ; <nl> - optional bytes default_bytes_nonascii = 77 [ default = " dünyab " ] ; <nl> - <nl> - optional float default_float_inf = 97 [ default = inf ] ; <nl> - optional float default_float_neg_inf = 98 [ default = - inf ] ; <nl> - optional float default_float_nan = 99 [ default = nan ] ; <nl> - optional double default_double_inf = 100 [ default = inf ] ; <nl> - optional double default_double_neg_inf = 101 [ default = - inf ] ; <nl> - optional double default_double_nan = 102 [ default = nan ] ; <nl> - <nl> - optional NestedEnum default_nested_enum = 81 [ default = BAR ] ; <nl> - optional ForeignEnumNano default_foreign_enum = 82 <nl> - [ default = FOREIGN_NANO_BAR ] ; <nl> - optional protobuf_unittest_import . ImportEnumNano <nl> - default_import_enum = 83 [ default = IMPORT_NANO_BAR ] ; <nl> - <nl> - optional string default_string_piece = 84 [ ctype = STRING_PIECE , default = " abc " ] ; <nl> - optional string default_cord = 85 [ ctype = CORD , default = " 123 " ] ; <nl> - <nl> - required int32 id = 86 ; <nl> - <nl> - / / Try to cause conflicts . <nl> - optional int32 tag = 93 ; <nl> - optional int32 get_serialized_size = 94 ; <nl> - optional int32 write_to = 95 ; <nl> - <nl> - / / Try to fail with java reserved keywords <nl> - optional int32 synchronized = 96 ; <nl> - <nl> - oneof oneof_field { <nl> - uint32 oneof_uint32 = 111 ; <nl> - NestedMessage oneof_nested_message = 112 ; <nl> - string oneof_string = 123 ; <nl> - bytes oneof_bytes = 124 ; <nl> - fixed64 oneof_fixed64 = 115 ; <nl> - NestedEnum oneof_enum = 116 ; <nl> - } <nl> - } <nl> - <nl> - message ForeignMessageNano { <nl> - optional int32 c = 1 ; <nl> - } <nl> - <nl> - enum ForeignEnumNano { <nl> - FOREIGN_NANO_FOO = 4 ; <nl> - FOREIGN_NANO_BAR = 5 ; <nl> - FOREIGN_NANO_BAZ = 6 ; <nl> - } <nl> - <nl> - / / Test that deprecated fields work . We only verify that they compile ( at one <nl> - / / point this failed ) . <nl> - message TestDeprecatedNano { <nl> - optional int32 deprecated_field = 1 [ deprecated = true ] ; <nl> - } <nl> deleted file mode 100644 <nl> index 29b944f01f . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_recursive_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : wink @ google . com ( Wink Saville ) <nl> - / / <nl> - <nl> - package protobuf_unittest_import ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - / / Explicit outer classname to suppress legacy info . <nl> - option java_outer_classname = " UnittestRecursiveNano " ; <nl> - <nl> - message RecursiveMessageNano { <nl> - message NestedMessage { <nl> - optional RecursiveMessageNano a = 1 ; <nl> - } <nl> - <nl> - required int32 id = 1 ; <nl> - optional NestedMessage nested_message = 2 ; <nl> - optional RecursiveMessageNano optional_recursive_message_nano = 3 ; <nl> - repeated RecursiveMessageNano repeated_recursive_message_nano = 4 ; <nl> - } <nl> deleted file mode 100644 <nl> index 82eb8d1175 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_reference_types_nano . proto <nl> ppp / dev / null <nl> <nl> - package protobuf_unittest ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " NanoReferenceTypes " ; <nl> - <nl> - message TestAllTypesNano { <nl> - <nl> - enum NestedEnum { <nl> - FOO = 1 ; <nl> - BAR = 2 ; <nl> - BAZ = 3 ; <nl> - } <nl> - <nl> - message NestedMessage { <nl> - optional int32 foo = 1 ; <nl> - } <nl> - <nl> - / / Singular <nl> - optional int32 optional_int32 = 1 ; <nl> - optional int64 optional_int64 = 2 ; <nl> - optional uint32 optional_uint32 = 3 ; <nl> - optional uint64 optional_uint64 = 4 ; <nl> - optional sint32 optional_sint32 = 5 ; <nl> - optional sint64 optional_sint64 = 6 ; <nl> - optional fixed32 optional_fixed32 = 7 ; <nl> - optional fixed64 optional_fixed64 = 8 ; <nl> - optional sfixed32 optional_sfixed32 = 9 ; <nl> - optional sfixed64 optional_sfixed64 = 10 ; <nl> - optional float optional_float = 11 ; <nl> - optional double optional_double = 12 ; <nl> - optional bool optional_bool = 13 ; <nl> - optional string optional_string = 14 ; <nl> - optional bytes optional_bytes = 15 ; <nl> - <nl> - optional group OptionalGroup = 16 { <nl> - optional int32 a = 17 ; <nl> - } <nl> - <nl> - optional NestedMessage optional_nested_message = 18 ; <nl> - <nl> - optional NestedEnum optional_nested_enum = 21 ; <nl> - <nl> - optional string optional_string_piece = 24 [ ctype = STRING_PIECE ] ; <nl> - optional string optional_cord = 25 [ ctype = CORD ] ; <nl> - <nl> - / / Repeated <nl> - repeated int32 repeated_int32 = 31 ; <nl> - repeated int64 repeated_int64 = 32 ; <nl> - repeated uint32 repeated_uint32 = 33 ; <nl> - repeated uint64 repeated_uint64 = 34 ; <nl> - repeated sint32 repeated_sint32 = 35 ; <nl> - repeated sint64 repeated_sint64 = 36 ; <nl> - repeated fixed32 repeated_fixed32 = 37 ; <nl> - repeated fixed64 repeated_fixed64 = 38 ; <nl> - repeated sfixed32 repeated_sfixed32 = 39 ; <nl> - repeated sfixed64 repeated_sfixed64 = 40 ; <nl> - repeated float repeated_float = 41 ; <nl> - repeated double repeated_double = 42 ; <nl> - repeated bool repeated_bool = 43 ; <nl> - repeated string repeated_string = 44 ; <nl> - repeated bytes repeated_bytes = 45 ; <nl> - <nl> - repeated group RepeatedGroup = 46 { <nl> - optional int32 a = 47 ; <nl> - } <nl> - <nl> - repeated NestedMessage repeated_nested_message = 48 ; <nl> - <nl> - repeated NestedEnum repeated_nested_enum = 51 ; <nl> - <nl> - repeated string repeated_string_piece = 54 [ ctype = STRING_PIECE ] ; <nl> - repeated string repeated_cord = 55 [ ctype = CORD ] ; <nl> - <nl> - / / Repeated packed <nl> - repeated int32 repeated_packed_int32 = 87 [ packed = true ] ; <nl> - repeated sfixed64 repeated_packed_sfixed64 = 88 [ packed = true ] ; <nl> - <nl> - repeated NestedEnum repeated_packed_nested_enum = 89 [ packed = true ] ; <nl> - <nl> - / / Singular with defaults <nl> - optional int32 default_int32 = 61 [ default = 41 ] ; <nl> - optional int64 default_int64 = 62 [ default = 42 ] ; <nl> - optional uint32 default_uint32 = 63 [ default = 43 ] ; <nl> - optional uint64 default_uint64 = 64 [ default = 44 ] ; <nl> - optional sint32 default_sint32 = 65 [ default = - 45 ] ; <nl> - optional sint64 default_sint64 = 66 [ default = 46 ] ; <nl> - optional fixed32 default_fixed32 = 67 [ default = 47 ] ; <nl> - optional fixed64 default_fixed64 = 68 [ default = 48 ] ; <nl> - optional sfixed32 default_sfixed32 = 69 [ default = 49 ] ; <nl> - optional sfixed64 default_sfixed64 = 70 [ default = - 50 ] ; <nl> - optional float default_float = 71 [ default = 51 . 5 ] ; <nl> - optional double default_double = 72 [ default = 52e3 ] ; <nl> - optional bool default_bool = 73 [ default = true ] ; <nl> - optional string default_string = 74 [ default = " hello " ] ; <nl> - optional bytes default_bytes = 75 [ default = " world " ] ; <nl> - <nl> - <nl> - optional float default_float_inf = 97 [ default = inf ] ; <nl> - optional float default_float_neg_inf = 98 [ default = - inf ] ; <nl> - optional float default_float_nan = 99 [ default = nan ] ; <nl> - optional double default_double_inf = 100 [ default = inf ] ; <nl> - optional double default_double_neg_inf = 101 [ default = - inf ] ; <nl> - optional double default_double_nan = 102 [ default = nan ] ; <nl> - <nl> - } <nl> - <nl> - message ForeignMessageNano { <nl> - optional int32 c = 1 ; <nl> - } <nl> - <nl> - enum ForeignEnumNano { <nl> - FOREIGN_NANO_FOO = 4 ; <nl> - FOREIGN_NANO_BAR = 5 ; <nl> - FOREIGN_NANO_BAZ = 6 ; <nl> - } <nl> - <nl> deleted file mode 100644 <nl> index ef4e2d2f65 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_repeated_merge_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : maxtroy @ google . com ( Max Cai ) <nl> - <nl> - package protobuf_unittest ; <nl> - <nl> - import " google / protobuf / nano / unittest_nano . proto " ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_multiple_files = true ; <nl> - <nl> - / / A container message for testing the merging of repeated fields at a <nl> - / / nested level . Other tests will be done using the repeated fields in <nl> - / / TestAllTypesNano . <nl> - message TestRepeatedMergeNano { <nl> - <nl> - optional TestAllTypesNano contained = 1 ; <nl> - <nl> - } <nl> deleted file mode 100644 <nl> index 96af8856cf . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_repeated_packables_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : maxtroy @ google . com ( Max Cai ) <nl> - <nl> - package protobuf_unittest ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - option java_outer_classname = " NanoRepeatedPackables " ; <nl> - <nl> - enum Enum { <nl> - OPTION_ONE = 1 ; <nl> - OPTION_TWO = 2 ; <nl> - } <nl> - <nl> - / / Two almost identical messages with all packable repeated field types . <nl> - / / One with none marked as packed and the other all packed . For <nl> - / / compatibility , they should be able to parse each other ' s serialized <nl> - / / forms . <nl> - <nl> - message NonPacked { <nl> - <nl> - / / All packable types , none marked as packed . <nl> - <nl> - repeated int32 int32s = 1 ; <nl> - repeated int64 int64s = 2 ; <nl> - repeated uint32 uint32s = 3 ; <nl> - repeated uint64 uint64s = 4 ; <nl> - repeated sint32 sint32s = 5 ; <nl> - repeated sint64 sint64s = 6 ; <nl> - repeated fixed32 fixed32s = 7 ; <nl> - repeated fixed64 fixed64s = 8 ; <nl> - repeated sfixed32 sfixed32s = 9 ; <nl> - repeated sfixed64 sfixed64s = 10 ; <nl> - repeated float floats = 11 ; <nl> - repeated double doubles = 12 ; <nl> - repeated bool bools = 13 ; <nl> - repeated Enum enums = 14 ; <nl> - <nl> - / / Noise for testing merged deserialization . <nl> - optional int32 noise = 15 ; <nl> - <nl> - } <nl> - <nl> - message Packed { <nl> - <nl> - / / All packable types , all matching the field numbers in NonPacked , <nl> - / / all marked as packed . <nl> - <nl> - repeated int32 int32s = 1 [ packed = true ] ; <nl> - repeated int64 int64s = 2 [ packed = true ] ; <nl> - repeated uint32 uint32s = 3 [ packed = true ] ; <nl> - repeated uint64 uint64s = 4 [ packed = true ] ; <nl> - repeated sint32 sint32s = 5 [ packed = true ] ; <nl> - repeated sint64 sint64s = 6 [ packed = true ] ; <nl> - repeated fixed32 fixed32s = 7 [ packed = true ] ; <nl> - repeated fixed64 fixed64s = 8 [ packed = true ] ; <nl> - repeated sfixed32 sfixed32s = 9 [ packed = true ] ; <nl> - repeated sfixed64 sfixed64s = 10 [ packed = true ] ; <nl> - repeated float floats = 11 [ packed = true ] ; <nl> - repeated double doubles = 12 [ packed = true ] ; <nl> - repeated bool bools = 13 [ packed = true ] ; <nl> - repeated Enum enums = 14 [ packed = true ] ; <nl> - <nl> - / / Noise for testing merged deserialization . <nl> - optional int32 noise = 15 ; <nl> - <nl> - } <nl> deleted file mode 100644 <nl> index 25786cc227 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_simple_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : wink @ google . com ( Wink Saville ) <nl> - / / <nl> - <nl> - package protobuf_unittest_import ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - / / Explicit outer classname to suppress legacy info . <nl> - option java_outer_classname = " UnittestSimpleNano " ; <nl> - <nl> - message SimpleMessageNano { <nl> - message NestedMessage { <nl> - optional int32 bb = 1 ; <nl> - } <nl> - <nl> - enum NestedEnum { <nl> - FOO = 1 ; <nl> - BAR = 2 ; <nl> - BAZ = 3 ; <nl> - } <nl> - <nl> - optional int32 d = 1 [ default = 123 ] ; <nl> - optional NestedMessage nested_msg = 2 ; <nl> - optional NestedEnum default_nested_enum = 3 [ default = BAZ ] ; <nl> - } <nl> deleted file mode 100644 <nl> index 7de30c877d . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_single_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : maxtroy @ google . com ( Max Cai ) <nl> - <nl> - package protobuf_unittest_import ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - <nl> - message SingleMessageNano { <nl> - } <nl> deleted file mode 100644 <nl> index bbd677cfd6 . . 0000000000 <nl> mmm a / javanano / src / test / java / com / google / protobuf / nano / unittest_stringutf8_nano . proto <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / https : / / developers . google . com / protocol - buffers / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : wink @ google . com ( Wink Saville ) <nl> - / / <nl> - <nl> - package protobuf_unittest_import ; <nl> - <nl> - option java_package = " com . google . protobuf " ; <nl> - / / Explicit outer classname to suppress legacy info . <nl> - option java_outer_classname = " UnittestStringutf8Nano " ; <nl> - <nl> - message StringUtf8 { <nl> - optional string id = 1 ; <nl> - repeated string rs = 2 ; <nl> - } <nl> mmm a / src / Makefile . am <nl> ppp b / src / Makefile . am <nl> nobase_include_HEADERS = \ <nl> google / protobuf / compiler / csharp / csharp_names . h \ <nl> google / protobuf / compiler / java / java_generator . h \ <nl> google / protobuf / compiler / java / java_names . h \ <nl> - google / protobuf / compiler / javanano / javanano_generator . h \ <nl> google / protobuf / compiler / js / js_generator . h \ <nl> google / protobuf / compiler / js / well_known_types_embed . h \ <nl> google / protobuf / compiler / objectivec / objectivec_generator . h \ <nl> libprotoc_la_SOURCES = \ <nl> google / protobuf / compiler / java / java_doc_comment . h \ <nl> google / protobuf / compiler / js / js_generator . cc \ <nl> google / protobuf / compiler / js / well_known_types_embed . cc \ <nl> - google / protobuf / compiler / javanano / javanano_enum . cc \ <nl> - google / protobuf / compiler / javanano / javanano_enum . h \ <nl> - google / protobuf / compiler / javanano / javanano_enum_field . cc \ <nl> - google / protobuf / compiler / javanano / javanano_enum_field . h \ <nl> - google / protobuf / compiler / javanano / javanano_extension . cc \ <nl> - google / protobuf / compiler / javanano / javanano_extension . h \ <nl> - google / protobuf / compiler / javanano / javanano_field . cc \ <nl> - google / protobuf / compiler / javanano / javanano_field . h \ <nl> - google / protobuf / compiler / javanano / javanano_file . cc \ <nl> - google / protobuf / compiler / javanano / javanano_file . h \ <nl> - google / protobuf / compiler / javanano / javanano_generator . cc \ <nl> - google / protobuf / compiler / javanano / javanano_generator . h \ <nl> - google / protobuf / compiler / javanano / javanano_helpers . cc \ <nl> - google / protobuf / compiler / javanano / javanano_helpers . h \ <nl> - google / protobuf / compiler / javanano / javanano_map_field . cc \ <nl> - google / protobuf / compiler / javanano / javanano_map_field . h \ <nl> - google / protobuf / compiler / javanano / javanano_message . cc \ <nl> - google / protobuf / compiler / javanano / javanano_message . h \ <nl> - google / protobuf / compiler / javanano / javanano_message_field . cc \ <nl> - google / protobuf / compiler / javanano / javanano_message_field . h \ <nl> - google / protobuf / compiler / javanano / javanano_params . h \ <nl> - google / protobuf / compiler / javanano / javanano_primitive_field . cc \ <nl> - google / protobuf / compiler / javanano / javanano_primitive_field . h \ <nl> google / protobuf / compiler / objectivec / objectivec_enum . cc \ <nl> google / protobuf / compiler / objectivec / objectivec_enum . h \ <nl> google / protobuf / compiler / objectivec / objectivec_enum_field . cc \ <nl> deleted file mode 100644 <nl> index c6e8dfe90d . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_enum . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_enum . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / descriptor . pb . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - EnumGenerator : : EnumGenerator ( const EnumDescriptor * descriptor , const Params & params ) <nl> - : params_ ( params ) , descriptor_ ( descriptor ) { <nl> - for ( int i = 0 ; i < descriptor_ - > value_count ( ) ; i + + ) { <nl> - const EnumValueDescriptor * value = descriptor_ - > value ( i ) ; <nl> - const EnumValueDescriptor * canonical_value = <nl> - descriptor_ - > FindValueByNumber ( value - > number ( ) ) ; <nl> - <nl> - if ( value = = canonical_value ) { <nl> - canonical_values_ . push_back ( value ) ; <nl> - } else { <nl> - Alias alias ; <nl> - alias . value = value ; <nl> - alias . canonical_value = canonical_value ; <nl> - aliases_ . push_back ( alias ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - EnumGenerator : : ~ EnumGenerator ( ) { } <nl> - <nl> - void EnumGenerator : : Generate ( io : : Printer * printer ) { <nl> - printer - > Print ( <nl> - " \ n " <nl> - " / / enum $ classname $ \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - <nl> - const string classname = RenameJavaKeywords ( descriptor_ - > name ( ) ) ; <nl> - <nl> - / / Start of container interface <nl> - / / If generating intdefs , we use the container interface as the intdef if <nl> - / / present . Otherwise , we just make an empty @ interface parallel to the <nl> - / / constants . <nl> - bool use_intdef = params_ . generate_intdefs ( ) ; <nl> - bool use_shell_class = params_ . java_enum_style ( ) ; <nl> - if ( use_intdef ) { <nl> - / / @ IntDef annotation so tools can enforce correctness <nl> - / / Annotations will be discarded by the compiler <nl> - printer - > Print ( " @ java . lang . annotation . Retention ( " <nl> - " java . lang . annotation . RetentionPolicy . SOURCE ) \ n " <nl> - " @ android . support . annotation . IntDef ( { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - for ( int i = 0 ; i < canonical_values_ . size ( ) ; i + + ) { <nl> - const string constant_name = <nl> - RenameJavaKeywords ( canonical_values_ [ i ] - > name ( ) ) ; <nl> - if ( use_shell_class ) { <nl> - printer - > Print ( " $ classname $ . $ name $ , \ n " , <nl> - " classname " , classname , <nl> - " name " , constant_name ) ; <nl> - } else { <nl> - printer - > Print ( " $ name $ , \ n " , " name " , constant_name ) ; <nl> - } <nl> - } <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( " } ) \ n " ) ; <nl> - } <nl> - if ( use_shell_class | | use_intdef ) { <nl> - printer - > Print ( <nl> - " public $ at_for_intdef $ interface $ classname $ { \ n " , <nl> - " classname " , classname , <nl> - " at_for_intdef " , use_intdef ? " @ " : " " ) ; <nl> - if ( use_shell_class ) { <nl> - printer - > Indent ( ) ; <nl> - } else { <nl> - printer - > Print ( " } \ n \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - / / Canonical values <nl> - for ( int i = 0 ; i < canonical_values_ . size ( ) ; i + + ) { <nl> - printer - > Print ( <nl> - " public static final int $ name $ = $ canonical_value $ ; \ n " , <nl> - " name " , RenameJavaKeywords ( canonical_values_ [ i ] - > name ( ) ) , <nl> - " canonical_value " , SimpleItoa ( canonical_values_ [ i ] - > number ( ) ) ) ; <nl> - } <nl> - <nl> - / / Aliases <nl> - for ( int i = 0 ; i < aliases_ . size ( ) ; i + + ) { <nl> - printer - > Print ( <nl> - " public static final int $ name $ = $ canonical_name $ ; \ n " , <nl> - " name " , RenameJavaKeywords ( aliases_ [ i ] . value - > name ( ) ) , <nl> - " canonical_name " , RenameJavaKeywords ( aliases_ [ i ] . canonical_value - > name ( ) ) ) ; <nl> - } <nl> - <nl> - / / End of container interface <nl> - if ( use_shell_class ) { <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index 82e098fcc5 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_enum . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__ <nl> - <nl> - # include < string > <nl> - # include < vector > <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - # include < google / protobuf / descriptor . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace io { <nl> - class Printer ; / / printer . h <nl> - } <nl> - } <nl> - <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class EnumGenerator { <nl> - public : <nl> - explicit EnumGenerator ( const EnumDescriptor * descriptor , const Params & params ) ; <nl> - ~ EnumGenerator ( ) ; <nl> - <nl> - void Generate ( io : : Printer * printer ) ; <nl> - <nl> - private : <nl> - const Params & params_ ; <nl> - const EnumDescriptor * descriptor_ ; <nl> - <nl> - / / The proto language allows multiple enum constants to have the same numeric <nl> - / / value . Java , however , does not allow multiple enum constants to be <nl> - / / considered equivalent . We treat the first defined constant for any <nl> - / / given numeric value as " canonical " and the rest as aliases of that <nl> - / / canonical value . <nl> - std : : vector < const EnumValueDescriptor * > canonical_values_ ; <nl> - <nl> - struct Alias { <nl> - const EnumValueDescriptor * value ; <nl> - const EnumValueDescriptor * canonical_value ; <nl> - } ; <nl> - std : : vector < Alias > aliases_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( EnumGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__ <nl> deleted file mode 100644 <nl> index ea67a810d0 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_enum_field . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_enum_field . h > <nl> - # include < google / protobuf / stubs / common . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / wire_format . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - namespace { <nl> - <nl> - / / TODO ( kenton ) : Factor out a " SetCommonFieldVariables ( ) " to get rid of <nl> - / / repeat code between this and the other field types . <nl> - void SetEnumVariables ( const Params & params , <nl> - const FieldDescriptor * descriptor , std : : map < string , string > * variables ) { <nl> - ( * variables ) [ " name " ] = <nl> - RenameJavaKeywords ( UnderscoresToCamelCase ( descriptor ) ) ; <nl> - ( * variables ) [ " capitalized_name " ] = <nl> - RenameJavaKeywords ( UnderscoresToCapitalizedCamelCase ( descriptor ) ) ; <nl> - ( * variables ) [ " number " ] = SimpleItoa ( descriptor - > number ( ) ) ; <nl> - if ( params . use_reference_types_for_primitives ( ) <nl> - & & ! params . reftypes_primitive_enums ( ) <nl> - & & ! descriptor - > is_repeated ( ) ) { <nl> - ( * variables ) [ " type " ] = " java . lang . Integer " ; <nl> - ( * variables ) [ " default " ] = " null " ; <nl> - } else { <nl> - ( * variables ) [ " type " ] = " int " ; <nl> - ( * variables ) [ " default " ] = DefaultValue ( params , descriptor ) ; <nl> - } <nl> - ( * variables ) [ " repeated_default " ] = <nl> - " com . google . protobuf . nano . WireFormatNano . EMPTY_INT_ARRAY " ; <nl> - ( * variables ) [ " tag " ] = SimpleItoa ( internal : : WireFormat : : MakeTag ( descriptor ) ) ; <nl> - ( * variables ) [ " tag_size " ] = SimpleItoa ( <nl> - internal : : WireFormat : : TagSize ( descriptor - > number ( ) , descriptor - > type ( ) ) ) ; <nl> - ( * variables ) [ " non_packed_tag " ] = SimpleItoa ( <nl> - internal : : WireFormatLite : : MakeTag ( descriptor - > number ( ) , <nl> - internal : : WireFormat : : WireTypeForFieldType ( descriptor - > type ( ) ) ) ) ; <nl> - ( * variables ) [ " message_name " ] = descriptor - > containing_type ( ) - > name ( ) ; <nl> - const EnumDescriptor * enum_type = descriptor - > enum_type ( ) ; <nl> - ( * variables ) [ " message_type_intdef " ] = " @ " <nl> - + ToJavaName ( params , enum_type - > name ( ) , true , <nl> - enum_type - > containing_type ( ) , enum_type - > file ( ) ) ; <nl> - } <nl> - <nl> - void LoadEnumValues ( const Params & params , <nl> - const EnumDescriptor * enum_descriptor , std : : vector < string > * canonical_values ) { <nl> - string enum_class_name = ClassName ( params , enum_descriptor ) ; <nl> - for ( int i = 0 ; i < enum_descriptor - > value_count ( ) ; i + + ) { <nl> - const EnumValueDescriptor * value = enum_descriptor - > value ( i ) ; <nl> - const EnumValueDescriptor * canonical_value = <nl> - enum_descriptor - > FindValueByNumber ( value - > number ( ) ) ; <nl> - if ( value = = canonical_value ) { <nl> - canonical_values - > push_back ( <nl> - enum_class_name + " . " + RenameJavaKeywords ( value - > name ( ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PrintCaseLabels ( <nl> - io : : Printer * printer , const std : : vector < string > & canonical_values ) { <nl> - for ( int i = 0 ; i < canonical_values . size ( ) ; i + + ) { <nl> - printer - > Print ( <nl> - " case $ value $ : \ n " , <nl> - " value " , canonical_values [ i ] ) ; <nl> - } <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - EnumFieldGenerator : : <nl> - EnumFieldGenerator ( const FieldDescriptor * descriptor , const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetEnumVariables ( params , descriptor , & variables_ ) ; <nl> - LoadEnumValues ( params , descriptor - > enum_type ( ) , & canonical_values_ ) ; <nl> - } <nl> - <nl> - EnumFieldGenerator : : ~ EnumFieldGenerator ( ) { } <nl> - <nl> - void EnumFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool / * unused lazy_init * / ) const { <nl> - if ( params_ . generate_intdefs ( ) ) { <nl> - printer - > Print ( variables_ , " $ message_type_intdef $ \ n " ) ; <nl> - } <nl> - printer - > Print ( variables_ , " public $ type $ $ name $ ; \ n " ) ; <nl> - <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " public boolean has $ capitalized_name $ ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void EnumFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ = $ default $ ; \ n " ) ; <nl> - <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " has $ capitalized_name $ = false ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void EnumFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " int value = input . readInt32 ( ) ; \ n " <nl> - " switch ( value ) { \ n " ) ; <nl> - PrintCaseLabels ( printer , canonical_values_ ) ; <nl> - printer - > Print ( variables_ , <nl> - " this . $ name $ = value ; \ n " ) ; <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " has $ capitalized_name $ = true ; \ n " ) ; <nl> - } <nl> - printer - > Print ( <nl> - " break ; \ n " <nl> - " } \ n " ) ; <nl> - / / No default case : in case of invalid value from the wire , preserve old <nl> - / / field value . Also we are not storing the invalid value into the unknown <nl> - / / fields , because there is no way to get the value out . <nl> - } <nl> - <nl> - void EnumFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - if ( descriptor_ - > is_required ( ) & & ! params_ . generate_has ( ) ) { <nl> - / / Always serialize a required field if we don ' t have the ' has ' signal . <nl> - printer - > Print ( variables_ , <nl> - " output . writeInt32 ( $ number $ , this . $ name $ ) ; \ n " ) ; <nl> - } else { <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = $ default $ | | has $ capitalized_name $ ) { \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = $ default $ ) { \ n " ) ; <nl> - } <nl> - printer - > Print ( variables_ , <nl> - " output . writeInt32 ( $ number $ , this . $ name $ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void EnumFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - if ( descriptor_ - > is_required ( ) & & ! params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . computeInt32Size ( $ number $ , this . $ name $ ) ; \ n " ) ; <nl> - } else { <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = $ default $ | | has $ capitalized_name $ ) { \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = $ default $ ) { \ n " ) ; <nl> - } <nl> - printer - > Print ( variables_ , <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . computeInt32Size ( $ number $ , this . $ name $ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void EnumFieldGenerator : : GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - if ( params_ . use_reference_types_for_primitives ( ) <nl> - & & ! params_ . reftypes_primitive_enums ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ = = null ) { \ n " <nl> - " if ( other . $ name $ ! = null ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " } else if ( ! this . $ name $ . equals ( other . $ name $ ) ) { \ n " <nl> - " return false ; " <nl> - " } \ n " ) ; <nl> - } else { <nl> - / / We define equality as serialized form equality . If generate_has ( ) , <nl> - / / then if the field value equals the default value in both messages , <nl> - / / but one ' s ' has ' field is set and the other ' s is not , the serialized <nl> - / / forms are different and we should return false . <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = other . $ name $ " ) ; <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " \ n " <nl> - " | | ( this . $ name $ = = $ default $ \ n " <nl> - " & & this . has $ capitalized_name $ ! = other . has $ capitalized_name $ ) " ) ; <nl> - } <nl> - printer - > Print ( " ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void EnumFieldGenerator : : GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( <nl> - " result = 31 * result + " ) ; <nl> - if ( params_ . use_reference_types_for_primitives ( ) <nl> - & & ! params_ . reftypes_primitive_enums ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " ( this . $ name $ = = null ? 0 : this . $ name $ ) " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " this . $ name $ " ) ; <nl> - } <nl> - printer - > Print ( " ; \ n " ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - AccessorEnumFieldGenerator : : <nl> - AccessorEnumFieldGenerator ( const FieldDescriptor * descriptor , <nl> - const Params & params , int has_bit_index ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetEnumVariables ( params , descriptor , & variables_ ) ; <nl> - LoadEnumValues ( params , descriptor - > enum_type ( ) , & canonical_values_ ) ; <nl> - SetBitOperationVariables ( " has " , has_bit_index , & variables_ ) ; <nl> - } <nl> - <nl> - AccessorEnumFieldGenerator : : ~ AccessorEnumFieldGenerator ( ) { } <nl> - <nl> - void AccessorEnumFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool / * unused lazy_init * / ) const { <nl> - printer - > Print ( variables_ , " private int $ name $ _ ; \ n " ) ; <nl> - if ( params_ . generate_intdefs ( ) ) { <nl> - printer - > Print ( variables_ , " $ message_type_intdef $ \ n " ) ; <nl> - } <nl> - printer - > Print ( variables_ , <nl> - " public int get $ capitalized_name $ ( ) { \ n " <nl> - " return $ name $ _ ; \ n " <nl> - " } \ n " <nl> - " public $ message_name $ set $ capitalized_name $ ( " ) ; <nl> - if ( params_ . generate_intdefs ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " \ n " <nl> - " $ message_type_intdef $ " ) ; <nl> - } <nl> - printer - > Print ( variables_ , <nl> - " int value ) { \ n " <nl> - " $ name $ _ = value ; \ n " <nl> - " $ set_has $ ; \ n " <nl> - " return this ; \ n " <nl> - " } \ n " <nl> - " public boolean has $ capitalized_name $ ( ) { \ n " <nl> - " return $ get_has $ ; \ n " <nl> - " } \ n " <nl> - " public $ message_name $ clear $ capitalized_name $ ( ) { \ n " <nl> - " $ name $ _ = $ default $ ; \ n " <nl> - " $ clear_has $ ; \ n " <nl> - " return this ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void AccessorEnumFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ _ = $ default $ ; \ n " ) ; <nl> - } <nl> - <nl> - void AccessorEnumFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " int value = input . readInt32 ( ) ; \ n " <nl> - " switch ( value ) { \ n " ) ; <nl> - PrintCaseLabels ( printer , canonical_values_ ) ; <nl> - printer - > Print ( variables_ , <nl> - " $ name $ _ = value ; \ n " <nl> - " $ set_has $ ; \ n " <nl> - " break ; \ n " <nl> - " } \ n " ) ; <nl> - / / No default case : in case of invalid value from the wire , preserve old <nl> - / / field value . Also we are not storing the invalid value into the unknown <nl> - / / fields , because there is no way to get the value out . <nl> - } <nl> - <nl> - void AccessorEnumFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ get_has $ ) { \ n " <nl> - " output . writeInt32 ( $ number $ , $ name $ _ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void AccessorEnumFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ get_has $ ) { \ n " <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . computeInt32Size ( $ number $ , $ name $ _ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void AccessorEnumFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ different_has $ \ n " <nl> - " | | $ name $ _ ! = other . $ name $ _ ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void AccessorEnumFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + $ name $ _ ; \ n " ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - RepeatedEnumFieldGenerator : : <nl> - RepeatedEnumFieldGenerator ( const FieldDescriptor * descriptor , const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetEnumVariables ( params , descriptor , & variables_ ) ; <nl> - LoadEnumValues ( params , descriptor - > enum_type ( ) , & canonical_values_ ) ; <nl> - } <nl> - <nl> - RepeatedEnumFieldGenerator : : ~ RepeatedEnumFieldGenerator ( ) { } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool / * unused lazy_init * / ) const { <nl> - printer - > Print ( variables_ , <nl> - " public $ type $ [ ] $ name $ ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ = $ repeated_default $ ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - / / First , figure out the maximum length of the array , then parse , <nl> - / / and finally copy the valid values to the field . <nl> - printer - > Print ( variables_ , <nl> - " int length = com . google . protobuf . nano . WireFormatNano \ n " <nl> - " . getRepeatedFieldArrayLength ( input , $ non_packed_tag $ ) ; \ n " <nl> - " int [ ] validValues = new int [ length ] ; \ n " <nl> - " int validCount = 0 ; \ n " <nl> - " for ( int i = 0 ; i < length ; i + + ) { \ n " <nl> - " if ( i ! = 0 ) { / / tag for first value already consumed . \ n " <nl> - " input . readTag ( ) ; \ n " <nl> - " } \ n " <nl> - " int value = input . readInt32 ( ) ; \ n " <nl> - " switch ( value ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - PrintCaseLabels ( printer , canonical_values_ ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( variables_ , <nl> - " validValues [ validCount + + ] = value ; \ n " <nl> - " break ; \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " if ( validCount ! = 0 ) { \ n " <nl> - " int i = this . $ name $ = = null ? 0 : this . $ name $ . length ; \ n " <nl> - " if ( i = = 0 & & validCount = = validValues . length ) { \ n " <nl> - " this . $ name $ = validValues ; \ n " <nl> - " } else { \ n " <nl> - " int [ ] newArray = new int [ i + validCount ] ; \ n " <nl> - " if ( i ! = 0 ) { \ n " <nl> - " java . lang . System . arraycopy ( this . $ name $ , 0 , newArray , 0 , i ) ; \ n " <nl> - " } \ n " <nl> - " java . lang . System . arraycopy ( validValues , 0 , newArray , i , validCount ) ; \ n " <nl> - " this . $ name $ = newArray ; \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateMergingCodeFromPacked ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " int bytes = input . readRawVarint32 ( ) ; \ n " <nl> - " int limit = input . pushLimit ( bytes ) ; \ n " <nl> - " / / First pass to compute array length . \ n " <nl> - " int arrayLength = 0 ; \ n " <nl> - " int startPos = input . getPosition ( ) ; \ n " <nl> - " while ( input . getBytesUntilLimit ( ) > 0 ) { \ n " <nl> - " switch ( input . readInt32 ( ) ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - PrintCaseLabels ( printer , canonical_values_ ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( variables_ , <nl> - " arrayLength + + ; \ n " <nl> - " break ; \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " if ( arrayLength ! = 0 ) { \ n " <nl> - " input . rewindToPosition ( startPos ) ; \ n " <nl> - " int i = this . $ name $ = = null ? 0 : this . $ name $ . length ; \ n " <nl> - " int [ ] newArray = new int [ i + arrayLength ] ; \ n " <nl> - " if ( i ! = 0 ) { \ n " <nl> - " java . lang . System . arraycopy ( this . $ name $ , 0 , newArray , 0 , i ) ; \ n " <nl> - " } \ n " <nl> - " while ( input . getBytesUntilLimit ( ) > 0 ) { \ n " <nl> - " int value = input . readInt32 ( ) ; \ n " <nl> - " switch ( value ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - printer - > Indent ( ) ; <nl> - PrintCaseLabels ( printer , canonical_values_ ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( variables_ , <nl> - " newArray [ i + + ] = value ; \ n " <nl> - " break ; \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " this . $ name $ = newArray ; \ n " <nl> - " } \ n " <nl> - " input . popLimit ( limit ) ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateRepeatedDataSizeCode ( io : : Printer * printer ) const { <nl> - / / Creates a variable dataSize and puts the serialized size in there . <nl> - printer - > Print ( variables_ , <nl> - " int dataSize = 0 ; \ n " <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " int element = this . $ name $ [ i ] ; \ n " <nl> - " dataSize + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . computeInt32SizeNoTag ( element ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - if ( descriptor_ - > options ( ) . packed ( ) ) { <nl> - GenerateRepeatedDataSizeCode ( printer ) ; <nl> - printer - > Print ( variables_ , <nl> - " output . writeRawVarint32 ( $ tag $ ) ; \ n " <nl> - " output . writeRawVarint32 ( dataSize ) ; \ n " <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " output . writeRawVarint32 ( this . $ name $ [ i ] ) ; \ n " <nl> - " } \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " output . writeInt32 ( $ number $ , this . $ name $ [ i ] ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( variables_ , <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - GenerateRepeatedDataSizeCode ( printer ) ; <nl> - <nl> - printer - > Print ( <nl> - " size + = dataSize ; \ n " ) ; <nl> - if ( descriptor_ - > options ( ) . packed ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " size + = $ tag_size $ ; \ n " <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . computeRawVarint32Size ( dataSize ) ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " size + = $ tag_size $ * this . $ name $ . length ; \ n " ) ; <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - <nl> - printer - > Print ( <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateFixClonedCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " <nl> - " cloned . $ name $ = this . $ name $ . clone ( ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( ! com . google . protobuf . nano . InternalNano . equals ( \ n " <nl> - " this . $ name $ , other . $ name $ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedEnumFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result \ n " <nl> - " + com . google . protobuf . nano . InternalNano . hashCode ( this . $ name $ ) ; \ n " ) ; <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index 8cd0e248c8 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_enum_field . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__ <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - # include < vector > <nl> - # include < google / protobuf / compiler / javanano / javanano_field . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class EnumFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit EnumFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) ; <nl> - ~ EnumFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - std : : vector < string > canonical_values_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( EnumFieldGenerator ) ; <nl> - } ; <nl> - <nl> - class AccessorEnumFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit AccessorEnumFieldGenerator ( const FieldDescriptor * descriptor , <nl> - const Params & params , int has_bit_index ) ; <nl> - ~ AccessorEnumFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - std : : vector < string > canonical_values_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( AccessorEnumFieldGenerator ) ; <nl> - } ; <nl> - <nl> - class RepeatedEnumFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit RepeatedEnumFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) ; <nl> - ~ RepeatedEnumFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCodeFromPacked ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - void GenerateFixClonedCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - void GenerateRepeatedDataSizeCode ( io : : Printer * printer ) const ; <nl> - <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - std : : vector < string > canonical_values_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( RepeatedEnumFieldGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__ <nl> deleted file mode 100644 <nl> index 4c61f915c7 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_extension . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : bduff @ google . com ( Brian Duff ) <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_extension . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - # include < google / protobuf / wire_format . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - using internal : : WireFormat ; <nl> - using internal : : WireFormatLite ; <nl> - <nl> - namespace { <nl> - <nl> - const char * GetTypeConstantName ( const FieldDescriptor : : Type type ) { <nl> - switch ( type ) { <nl> - case FieldDescriptor : : TYPE_INT32 : return " TYPE_INT32 " ; <nl> - case FieldDescriptor : : TYPE_UINT32 : return " TYPE_UINT32 " ; <nl> - case FieldDescriptor : : TYPE_SINT32 : return " TYPE_SINT32 " ; <nl> - case FieldDescriptor : : TYPE_FIXED32 : return " TYPE_FIXED32 " ; <nl> - case FieldDescriptor : : TYPE_SFIXED32 : return " TYPE_SFIXED32 " ; <nl> - case FieldDescriptor : : TYPE_INT64 : return " TYPE_INT64 " ; <nl> - case FieldDescriptor : : TYPE_UINT64 : return " TYPE_UINT64 " ; <nl> - case FieldDescriptor : : TYPE_SINT64 : return " TYPE_SINT64 " ; <nl> - case FieldDescriptor : : TYPE_FIXED64 : return " TYPE_FIXED64 " ; <nl> - case FieldDescriptor : : TYPE_SFIXED64 : return " TYPE_SFIXED64 " ; <nl> - case FieldDescriptor : : TYPE_FLOAT : return " TYPE_FLOAT " ; <nl> - case FieldDescriptor : : TYPE_DOUBLE : return " TYPE_DOUBLE " ; <nl> - case FieldDescriptor : : TYPE_BOOL : return " TYPE_BOOL " ; <nl> - case FieldDescriptor : : TYPE_STRING : return " TYPE_STRING " ; <nl> - case FieldDescriptor : : TYPE_BYTES : return " TYPE_BYTES " ; <nl> - case FieldDescriptor : : TYPE_ENUM : return " TYPE_ENUM " ; <nl> - case FieldDescriptor : : TYPE_GROUP : return " TYPE_GROUP " ; <nl> - case FieldDescriptor : : TYPE_MESSAGE : return " TYPE_MESSAGE " ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / types are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return NULL ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - void SetVariables ( const FieldDescriptor * descriptor , const Params params , <nl> - std : : map < string , string > * variables ) { <nl> - ( * variables ) [ " extends " ] = ClassName ( params , descriptor - > containing_type ( ) ) ; <nl> - ( * variables ) [ " name " ] = RenameJavaKeywords ( UnderscoresToCamelCase ( descriptor ) ) ; <nl> - bool repeated = descriptor - > is_repeated ( ) ; <nl> - ( * variables ) [ " repeated " ] = repeated ? " Repeated " : " " ; <nl> - ( * variables ) [ " type " ] = GetTypeConstantName ( descriptor - > type ( ) ) ; <nl> - JavaType java_type = GetJavaType ( descriptor - > type ( ) ) ; <nl> - string tag = SimpleItoa ( WireFormat : : MakeTag ( descriptor ) ) ; <nl> - if ( java_type = = JAVATYPE_MESSAGE ) { <nl> - ( * variables ) [ " ext_type " ] = " MessageTyped " ; <nl> - string message_type = ClassName ( params , descriptor - > message_type ( ) ) ; <nl> - if ( repeated ) { <nl> - message_type + = " [ ] " ; <nl> - } <nl> - ( * variables ) [ " class " ] = message_type ; <nl> - / / For message typed extensions , tags_params contains a single tag <nl> - / / for both singular and repeated cases . <nl> - ( * variables ) [ " tag_params " ] = tag ; <nl> - } else { <nl> - ( * variables ) [ " ext_type " ] = " PrimitiveTyped " ; <nl> - if ( ! repeated ) { <nl> - ( * variables ) [ " class " ] = BoxedPrimitiveTypeName ( java_type ) ; <nl> - ( * variables ) [ " tag_params " ] = tag ; <nl> - } else { <nl> - ( * variables ) [ " class " ] = PrimitiveTypeName ( java_type ) + " [ ] " ; <nl> - if ( ! descriptor - > is_packable ( ) ) { <nl> - / / Non - packable : nonPackedTag = = tag , packedTag = = 0 <nl> - ( * variables ) [ " tag_params " ] = tag + " , " + tag + " , 0 " ; <nl> - } else if ( descriptor - > options ( ) . packed ( ) ) { <nl> - / / Packable and packed : tag = = packedTag <nl> - string non_packed_tag = SimpleItoa ( WireFormatLite : : MakeTag ( <nl> - descriptor - > number ( ) , <nl> - WireFormat : : WireTypeForFieldType ( descriptor - > type ( ) ) ) ) ; <nl> - ( * variables ) [ " tag_params " ] = tag + " , " + non_packed_tag + " , " + tag ; <nl> - } else { <nl> - / / Packable and not packed : tag = = nonPackedTag <nl> - string packed_tag = SimpleItoa ( WireFormatLite : : MakeTag ( <nl> - descriptor - > number ( ) , WireFormatLite : : WIRETYPE_LENGTH_DELIMITED ) ) ; <nl> - ( * variables ) [ " tag_params " ] = tag + " , " + tag + " , " + packed_tag ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - ExtensionGenerator : : <nl> - ExtensionGenerator ( const FieldDescriptor * descriptor , const Params & params ) <nl> - : params_ ( params ) , descriptor_ ( descriptor ) { <nl> - SetVariables ( descriptor , params , & variables_ ) ; <nl> - } <nl> - <nl> - ExtensionGenerator : : ~ ExtensionGenerator ( ) { } <nl> - <nl> - void ExtensionGenerator : : Generate ( io : : Printer * printer ) const { <nl> - printer - > Print ( " \ n " ) ; <nl> - PrintFieldComment ( printer , descriptor_ ) ; <nl> - printer - > Print ( variables_ , <nl> - " public static final com . google . protobuf . nano . Extension < \ n " <nl> - " $ extends $ , \ n " <nl> - " $ class $ > $ name $ = \ n " <nl> - " com . google . protobuf . nano . Extension . create $ repeated $ $ ext_type $ ( \ n " <nl> - " com . google . protobuf . nano . Extension . $ type $ , \ n " <nl> - " $ class $ . class , \ n " <nl> - " $ tag_params $ L ) ; \ n " ) ; <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> - <nl> deleted file mode 100644 <nl> index f4e9eb2d0b . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_extension . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : bduff @ google . com ( Brian Duff ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_ <nl> - <nl> - # include < google / protobuf / stubs / common . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - # include < google / protobuf / descriptor . pb . h > <nl> - <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace io { <nl> - class Printer ; / / printer . h <nl> - } <nl> - } <nl> - <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class ExtensionGenerator { <nl> - public : <nl> - explicit ExtensionGenerator ( const FieldDescriptor * descriptor , const Params & params ) ; <nl> - ~ ExtensionGenerator ( ) ; <nl> - <nl> - void Generate ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const Params & params_ ; <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( ExtensionGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> - <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_ <nl> deleted file mode 100644 <nl> index 0c134fe155 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_field . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_field . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_primitive_field . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_enum_field . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_map_field . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_message_field . h > <nl> - # include < google / protobuf / stubs / common . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - FieldGenerator : : ~ FieldGenerator ( ) { } <nl> - <nl> - bool FieldGenerator : : SavedDefaultNeeded ( ) const { <nl> - / / No saved default for this field by default . <nl> - / / Subclasses whose instances may need saved defaults will override this <nl> - / / and return the appropriate value . <nl> - return false ; <nl> - } <nl> - <nl> - void FieldGenerator : : GenerateInitSavedDefaultCode ( io : : Printer * printer ) const { <nl> - / / No saved default for this field by default . <nl> - / / Subclasses whose instances may need saved defaults will override this <nl> - / / and generate the appropriate init code to the printer . <nl> - } <nl> - <nl> - void FieldGenerator : : GenerateMergingCodeFromPacked ( io : : Printer * printer ) const { <nl> - / / Reaching here indicates a bug . Cases are : <nl> - / / - This FieldGenerator should support packing , but this method should be <nl> - / / overridden . <nl> - / / - This FieldGenerator doesn ' t support packing , and this method should <nl> - / / never have been called . <nl> - GOOGLE_LOG ( FATAL ) < < " GenerateParsingCodeFromPacked ( ) " <nl> - < < " called on field generator that does not support packing . " ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - FieldGeneratorMap : : FieldGeneratorMap ( <nl> - const Descriptor * descriptor , const Params & params ) <nl> - : descriptor_ ( descriptor ) , <nl> - field_generators_ ( <nl> - new std : : unique_ptr < FieldGenerator > [ descriptor - > field_count ( ) ] ) { <nl> - <nl> - int next_has_bit_index = 0 ; <nl> - bool saved_defaults_needed = false ; <nl> - / / Construct all the FieldGenerators . <nl> - for ( int i = 0 ; i < descriptor - > field_count ( ) ; i + + ) { <nl> - FieldGenerator * field_generator = MakeGenerator ( <nl> - descriptor - > field ( i ) , params , & next_has_bit_index ) ; <nl> - saved_defaults_needed = saved_defaults_needed <nl> - | | field_generator - > SavedDefaultNeeded ( ) ; <nl> - field_generators_ [ i ] . reset ( field_generator ) ; <nl> - } <nl> - total_bits_ = next_has_bit_index ; <nl> - saved_defaults_needed_ = saved_defaults_needed ; <nl> - } <nl> - <nl> - FieldGenerator * FieldGeneratorMap : : MakeGenerator ( const FieldDescriptor * field , <nl> - const Params & params , int * next_has_bit_index ) { <nl> - JavaType java_type = GetJavaType ( field ) ; <nl> - if ( field - > is_repeated ( ) ) { <nl> - switch ( java_type ) { <nl> - case JAVATYPE_MESSAGE : <nl> - if ( IsMapEntry ( field - > message_type ( ) ) ) { <nl> - return new MapFieldGenerator ( field , params ) ; <nl> - } else { <nl> - return new RepeatedMessageFieldGenerator ( field , params ) ; <nl> - } <nl> - case JAVATYPE_ENUM : <nl> - return new RepeatedEnumFieldGenerator ( field , params ) ; <nl> - default : <nl> - return new RepeatedPrimitiveFieldGenerator ( field , params ) ; <nl> - } <nl> - } else if ( field - > containing_oneof ( ) ) { <nl> - switch ( java_type ) { <nl> - case JAVATYPE_MESSAGE : <nl> - return new MessageOneofFieldGenerator ( field , params ) ; <nl> - case JAVATYPE_ENUM : <nl> - default : <nl> - return new PrimitiveOneofFieldGenerator ( field , params ) ; <nl> - } <nl> - } else if ( params . optional_field_accessors ( ) & & field - > is_optional ( ) <nl> - & & java_type ! = JAVATYPE_MESSAGE ) { <nl> - / / We need a has - bit for each primitive / enum field because their default <nl> - / / values could be same as explicitly set values . But we don ' t need it <nl> - / / for a message field because they have no defaults and Nano uses ' null ' <nl> - / / for unset messages , which cannot be set explicitly . <nl> - switch ( java_type ) { <nl> - case JAVATYPE_ENUM : <nl> - return new AccessorEnumFieldGenerator ( <nl> - field , params , ( * next_has_bit_index ) + + ) ; <nl> - default : <nl> - return new AccessorPrimitiveFieldGenerator ( <nl> - field , params , ( * next_has_bit_index ) + + ) ; <nl> - } <nl> - } else { <nl> - switch ( java_type ) { <nl> - case JAVATYPE_MESSAGE : <nl> - return new MessageFieldGenerator ( field , params ) ; <nl> - case JAVATYPE_ENUM : <nl> - return new EnumFieldGenerator ( field , params ) ; <nl> - default : <nl> - return new PrimitiveFieldGenerator ( field , params ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - FieldGeneratorMap : : ~ FieldGeneratorMap ( ) { } <nl> - <nl> - const FieldGenerator & FieldGeneratorMap : : get ( <nl> - const FieldDescriptor * field ) const { <nl> - GOOGLE_CHECK_EQ ( field - > containing_type ( ) , descriptor_ ) ; <nl> - return * field_generators_ [ field - > index ( ) ] ; <nl> - } <nl> - <nl> - void SetCommonOneofVariables ( const FieldDescriptor * descriptor , <nl> - std : : map < string , string > * variables ) { <nl> - ( * variables ) [ " oneof_name " ] = <nl> - UnderscoresToCamelCase ( descriptor - > containing_oneof ( ) ) ; <nl> - ( * variables ) [ " oneof_capitalized_name " ] = <nl> - UnderscoresToCapitalizedCamelCase ( descriptor - > containing_oneof ( ) ) ; <nl> - ( * variables ) [ " oneof_index " ] = <nl> - SimpleItoa ( descriptor - > containing_oneof ( ) - > index ( ) ) ; <nl> - ( * variables ) [ " set_oneof_case " ] = <nl> - " this . " + ( * variables ) [ " oneof_name " ] + <nl> - " Case_ = " + SimpleItoa ( descriptor - > number ( ) ) ; <nl> - ( * variables ) [ " clear_oneof_case " ] = <nl> - " this . " + ( * variables ) [ " oneof_name " ] + " Case_ = 0 " ; <nl> - ( * variables ) [ " has_oneof_case " ] = <nl> - " this . " + ( * variables ) [ " oneof_name " ] + " Case_ = = " + <nl> - SimpleItoa ( descriptor - > number ( ) ) ; <nl> - } <nl> - <nl> - void GenerateOneofFieldEquals ( const FieldDescriptor * descriptor , <nl> - const std : : map < string , string > & variables , <nl> - io : : Printer * printer ) { <nl> - if ( GetJavaType ( descriptor ) = = JAVATYPE_BYTES ) { <nl> - printer - > Print ( variables , <nl> - " if ( this . has $ capitalized_name $ ( ) ) { \ n " <nl> - " if ( ! java . util . Arrays . equals ( ( byte [ ] ) this . $ oneof_name $ _ , \ n " <nl> - " ( byte [ ] ) other . $ oneof_name $ _ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables , <nl> - " if ( this . has $ capitalized_name $ ( ) ) { \ n " <nl> - " if ( ! this . $ oneof_name $ _ . equals ( other . $ oneof_name $ _ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void GenerateOneofFieldHashCode ( const FieldDescriptor * descriptor , <nl> - const std : : map < string , string > & variables , <nl> - io : : Printer * printer ) { <nl> - if ( GetJavaType ( descriptor ) = = JAVATYPE_BYTES ) { <nl> - printer - > Print ( variables , <nl> - " result = 31 * result + ( $ has_oneof_case $ \ n " <nl> - " ? java . util . Arrays . hashCode ( ( byte [ ] ) this . $ oneof_name $ _ ) : 0 ) ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables , <nl> - " result = 31 * result + \ n " <nl> - " ( $ has_oneof_case $ ? this . $ oneof_name $ _ . hashCode ( ) : 0 ) ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index e3701f103e . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_field . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__ <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - # include < google / protobuf / stubs / common . h > <nl> - # include < google / protobuf / descriptor . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace io { <nl> - class Printer ; / / printer . h <nl> - } <nl> - } <nl> - <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class FieldGenerator { <nl> - public : <nl> - FieldGenerator ( const Params & params ) : params_ ( params ) { } <nl> - virtual ~ FieldGenerator ( ) ; <nl> - <nl> - virtual bool SavedDefaultNeeded ( ) const ; <nl> - virtual void GenerateInitSavedDefaultCode ( io : : Printer * printer ) const ; <nl> - <nl> - / / Generates code for Java fields and methods supporting this field . <nl> - / / If this field needs a saved default ( SavedDefaultNeeded ( ) is true ) , <nl> - / / then @ lazy_init controls how the static field for that default value <nl> - / / and its initialization code should be generated . If @ lazy_init is <nl> - / / true , the static field is not declared final and the initialization <nl> - / / code is generated only when GenerateInitSavedDefaultCode is called ; <nl> - / / otherwise , the static field is declared final and initialized inline . <nl> - / / GenerateInitSavedDefaultCode will not be called in the latter case . <nl> - virtual void GenerateMembers ( <nl> - io : : Printer * printer , bool lazy_init ) const = 0 ; <nl> - <nl> - virtual void GenerateClearCode ( io : : Printer * printer ) const = 0 ; <nl> - virtual void GenerateMergingCode ( io : : Printer * printer ) const = 0 ; <nl> - <nl> - / / Generates code to merge from packed serialized form . The default <nl> - / / implementation will fail ; subclasses which can handle packed serialized <nl> - / / forms will override this and print appropriate code to the printer . <nl> - virtual void GenerateMergingCodeFromPacked ( io : : Printer * printer ) const ; <nl> - <nl> - virtual void GenerateSerializationCode ( io : : Printer * printer ) const = 0 ; <nl> - virtual void GenerateSerializedSizeCode ( io : : Printer * printer ) const = 0 ; <nl> - virtual void GenerateEqualsCode ( io : : Printer * printer ) const = 0 ; <nl> - virtual void GenerateHashCodeCode ( io : : Printer * printer ) const = 0 ; <nl> - virtual void GenerateFixClonedCode ( io : : Printer * printer ) const { } <nl> - <nl> - protected : <nl> - const Params & params_ ; <nl> - private : <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( FieldGenerator ) ; <nl> - } ; <nl> - <nl> - / / Convenience class which constructs FieldGenerators for a Descriptor . <nl> - class FieldGeneratorMap { <nl> - public : <nl> - explicit FieldGeneratorMap ( const Descriptor * descriptor , const Params & params ) ; <nl> - ~ FieldGeneratorMap ( ) ; <nl> - <nl> - const FieldGenerator & get ( const FieldDescriptor * field ) const ; <nl> - int total_bits ( ) const { return total_bits_ ; } <nl> - bool saved_defaults_needed ( ) const { return saved_defaults_needed_ ; } <nl> - <nl> - private : <nl> - const Descriptor * descriptor_ ; <nl> - std : : unique_ptr < std : : unique_ptr < FieldGenerator > [ ] > field_generators_ ; <nl> - int total_bits_ ; <nl> - bool saved_defaults_needed_ ; <nl> - <nl> - static FieldGenerator * MakeGenerator ( const FieldDescriptor * field , <nl> - const Params & params , int * next_has_bit_index ) ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( FieldGeneratorMap ) ; <nl> - } ; <nl> - <nl> - void SetCommonOneofVariables ( const FieldDescriptor * descriptor , <nl> - std : : map < string , string > * variables ) ; <nl> - void GenerateOneofFieldEquals ( const FieldDescriptor * descriptor , <nl> - const std : : map < string , string > & variables , <nl> - io : : Printer * printer ) ; <nl> - void GenerateOneofFieldHashCode ( const FieldDescriptor * descriptor , <nl> - const std : : map < string , string > & variables , <nl> - io : : Printer * printer ) ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__ <nl> deleted file mode 100644 <nl> index 9acdc3b500 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_file . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < iostream > <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_file . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_enum . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_extension . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_message . h > <nl> - # include < google / protobuf / compiler / code_generator . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / io / zero_copy_stream . h > <nl> - # include < google / protobuf / descriptor . pb . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - namespace { <nl> - <nl> - / / Recursively searches the given message to see if it contains any extensions . <nl> - bool UsesExtensions ( const Message & message ) { <nl> - const Reflection * reflection = message . GetReflection ( ) ; <nl> - <nl> - / / We conservatively assume that unknown fields are extensions . <nl> - if ( reflection - > GetUnknownFields ( message ) . field_count ( ) > 0 ) return true ; <nl> - <nl> - std : : vector < const FieldDescriptor * > fields ; <nl> - reflection - > ListFields ( message , & fields ) ; <nl> - <nl> - for ( int i = 0 ; i < fields . size ( ) ; i + + ) { <nl> - if ( fields [ i ] - > is_extension ( ) ) return true ; <nl> - <nl> - if ( fields [ i ] - > cpp_type ( ) = = FieldDescriptor : : CPPTYPE_MESSAGE ) { <nl> - if ( fields [ i ] - > is_repeated ( ) ) { <nl> - int size = reflection - > FieldSize ( message , fields [ i ] ) ; <nl> - for ( int j = 0 ; j < size ; j + + ) { <nl> - const Message & sub_message = <nl> - reflection - > GetRepeatedMessage ( message , fields [ i ] , j ) ; <nl> - if ( UsesExtensions ( sub_message ) ) return true ; <nl> - } <nl> - } else { <nl> - const Message & sub_message = reflection - > GetMessage ( message , fields [ i ] ) ; <nl> - if ( UsesExtensions ( sub_message ) ) return true ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - FileGenerator : : FileGenerator ( const FileDescriptor * file , const Params & params ) <nl> - : file_ ( file ) , <nl> - params_ ( params ) , <nl> - java_package_ ( FileJavaPackage ( params , file ) ) , <nl> - classname_ ( FileClassName ( params , file ) ) { } <nl> - <nl> - FileGenerator : : ~ FileGenerator ( ) { } <nl> - <nl> - bool FileGenerator : : Validate ( string * error ) { <nl> - / / Check for extensions <nl> - FileDescriptorProto file_proto ; <nl> - file_ - > CopyTo ( & file_proto ) ; <nl> - if ( UsesExtensions ( file_proto ) & & ! params_ . store_unknown_fields ( ) ) { <nl> - error - > assign ( file_ - > name ( ) ) ; <nl> - error - > append ( <nl> - " : Java NANO_RUNTIME only supports extensions when the " <nl> - " ' store_unknown_fields ' generator option is ' true ' . " ) ; <nl> - return false ; <nl> - } <nl> - <nl> - if ( file_ - > service_count ( ) ! = 0 & & ! params_ . ignore_services ( ) ) { <nl> - error - > assign ( file_ - > name ( ) ) ; <nl> - error - > append ( <nl> - " : Java NANO_RUNTIME does not support services \ " " ) ; <nl> - return false ; <nl> - } <nl> - <nl> - if ( ! IsOuterClassNeeded ( params_ , file_ ) ) { <nl> - return true ; <nl> - } <nl> - <nl> - / / Check whether legacy javanano generator would omit the outer class . <nl> - if ( ! params_ . has_java_outer_classname ( file_ - > name ( ) ) <nl> - & & file_ - > message_type_count ( ) = = 1 <nl> - & & file_ - > enum_type_count ( ) = = 0 & & file_ - > extension_count ( ) = = 0 ) { <nl> - std : : cout < < " INFO : " < < file_ - > name ( ) < < " : " < < std : : endl ; <nl> - std : : cout < < " Javanano generator has changed to align with java generator . " <nl> - " An outer class will be created for this file and the single message " <nl> - " in the file will become a nested class . Use java_multiple_files to " <nl> - " skip generating the outer class , or set an explicit " <nl> - " java_outer_classname to suppress this message . " < < std : : endl ; <nl> - } <nl> - <nl> - / / Check that no class name matches the file ' s class name . This is a common <nl> - / / problem that leads to Java compile errors that can be hard to understand . <nl> - / / It ' s especially bad when using the java_multiple_files , since we would <nl> - / / end up overwriting the outer class with one of the inner ones . <nl> - bool found_conflict = false ; <nl> - for ( int i = 0 ; ! found_conflict & & i < file_ - > message_type_count ( ) ; i + + ) { <nl> - if ( file_ - > message_type ( i ) - > name ( ) = = classname_ ) { <nl> - found_conflict = true ; <nl> - } <nl> - } <nl> - if ( params_ . java_enum_style ( ) ) { <nl> - for ( int i = 0 ; ! found_conflict & & i < file_ - > enum_type_count ( ) ; i + + ) { <nl> - if ( file_ - > enum_type ( i ) - > name ( ) = = classname_ ) { <nl> - found_conflict = true ; <nl> - } <nl> - } <nl> - } <nl> - if ( found_conflict ) { <nl> - error - > assign ( file_ - > name ( ) ) ; <nl> - error - > append ( <nl> - " : Cannot generate Java output because the file ' s outer class name , \ " " ) ; <nl> - error - > append ( classname_ ) ; <nl> - error - > append ( <nl> - " \ " , matches the name of one of the types declared inside it . " <nl> - " Please either rename the type or use the java_outer_classname " <nl> - " option to specify a different outer class name for the . proto file . " ) ; <nl> - return false ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - void FileGenerator : : Generate ( io : : Printer * printer ) { <nl> - / / We don ' t import anything because we refer to all classes by their <nl> - / / fully - qualified names in the generated source . <nl> - printer - > Print ( <nl> - " / / Generated by the protocol buffer compiler . DO NOT EDIT ! \ n " ) ; <nl> - if ( ! java_package_ . empty ( ) ) { <nl> - printer - > Print ( <nl> - " \ n " <nl> - " package $ package $ ; \ n " , <nl> - " package " , java_package_ ) ; <nl> - } <nl> - <nl> - / / Note : constants ( from enums , emitted in the loop below ) may have the same names as constants <nl> - / / in the nested classes . This causes Java warnings , but is not fatal , so we suppress those <nl> - / / warnings here in the top - most class declaration . <nl> - printer - > Print ( <nl> - " \ n " <nl> - " @ SuppressWarnings ( \ " hiding \ " ) \ n " <nl> - " public interface $ classname $ { \ n " , <nl> - " classname " , classname_ ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / Extensions . <nl> - for ( int i = 0 ; i < file_ - > extension_count ( ) ; i + + ) { <nl> - ExtensionGenerator ( file_ - > extension ( i ) , params_ ) . Generate ( printer ) ; <nl> - } <nl> - <nl> - / / Enums . <nl> - for ( int i = 0 ; i < file_ - > enum_type_count ( ) ; i + + ) { <nl> - EnumGenerator ( file_ - > enum_type ( i ) , params_ ) . Generate ( printer ) ; <nl> - } <nl> - <nl> - / / Messages . <nl> - if ( ! params_ . java_multiple_files ( file_ - > name ( ) ) ) { <nl> - for ( int i = 0 ; i < file_ - > message_type_count ( ) ; i + + ) { <nl> - MessageGenerator ( file_ - > message_type ( i ) , params_ ) . Generate ( printer ) ; <nl> - } <nl> - } <nl> - <nl> - / / Static variables . <nl> - for ( int i = 0 ; i < file_ - > message_type_count ( ) ; i + + ) { <nl> - / / TODO ( kenton ) : Reuse MessageGenerator objects ? <nl> - MessageGenerator ( file_ - > message_type ( i ) , params_ ) . GenerateStaticVariables ( printer ) ; <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - template < typename GeneratorClass , typename DescriptorClass > <nl> - static void GenerateSibling ( const string & package_dir , <nl> - const string & java_package , <nl> - const DescriptorClass * descriptor , <nl> - GeneratorContext * output_directory , <nl> - std : : vector < string > * file_list , <nl> - const Params & params ) { <nl> - string filename = package_dir + descriptor - > name ( ) + " . java " ; <nl> - file_list - > push_back ( filename ) ; <nl> - <nl> - std : : unique_ptr < io : : ZeroCopyOutputStream > output ( <nl> - output_directory - > Open ( filename ) ) ; <nl> - io : : Printer printer ( output . get ( ) , ' $ ' ) ; <nl> - <nl> - printer . Print ( <nl> - " / / Generated by the protocol buffer compiler . DO NOT EDIT ! \ n " ) ; <nl> - if ( ! java_package . empty ( ) ) { <nl> - printer . Print ( <nl> - " \ n " <nl> - " package $ package $ ; \ n " , <nl> - " package " , java_package ) ; <nl> - } <nl> - <nl> - GeneratorClass ( descriptor , params ) . Generate ( & printer ) ; <nl> - } <nl> - <nl> - void FileGenerator : : GenerateSiblings ( const string & package_dir , <nl> - GeneratorContext * output_directory , <nl> - std : : vector < string > * file_list ) { <nl> - if ( params_ . java_multiple_files ( file_ - > name ( ) ) ) { <nl> - for ( int i = 0 ; i < file_ - > message_type_count ( ) ; i + + ) { <nl> - GenerateSibling < MessageGenerator > ( package_dir , java_package_ , <nl> - file_ - > message_type ( i ) , <nl> - output_directory , file_list , params_ ) ; <nl> - } <nl> - <nl> - if ( params_ . java_enum_style ( ) ) { <nl> - for ( int i = 0 ; i < file_ - > enum_type_count ( ) ; i + + ) { <nl> - GenerateSibling < EnumGenerator > ( package_dir , java_package_ , <nl> - file_ - > enum_type ( i ) , <nl> - output_directory , file_list , params_ ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index 4ad3868c83 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_file . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__ <nl> - <nl> - # include < string > <nl> - # include < vector > <nl> - # include < google / protobuf / stubs / common . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - class FileDescriptor ; / / descriptor . h <nl> - namespace io { <nl> - class Printer ; / / printer . h <nl> - } <nl> - namespace compiler { <nl> - class GeneratorContext ; / / code_generator . h <nl> - } <nl> - } <nl> - <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class FileGenerator { <nl> - public : <nl> - explicit FileGenerator ( const FileDescriptor * file , const Params & params ) ; <nl> - ~ FileGenerator ( ) ; <nl> - <nl> - / / Checks for problems that would otherwise lead to cryptic compile errors . <nl> - / / Returns true if there are no problems , or writes an error description to <nl> - / / the given string and returns false otherwise . <nl> - bool Validate ( string * error ) ; <nl> - <nl> - void Generate ( io : : Printer * printer ) ; <nl> - <nl> - / / If we aren ' t putting everything into one file , this will write all the <nl> - / / files other than the outer file ( i . e . one for each message , enum , and <nl> - / / service type ) . <nl> - void GenerateSiblings ( const string & package_dir , <nl> - GeneratorContext * output_directory , <nl> - std : : vector < string > * file_list ) ; <nl> - <nl> - const string & java_package ( ) { return java_package_ ; } <nl> - const string & classname ( ) { return classname_ ; } <nl> - <nl> - private : <nl> - const FileDescriptor * file_ ; <nl> - const Params & params_ ; <nl> - string java_package_ ; <nl> - string classname_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( FileGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__ <nl> deleted file mode 100644 <nl> index 64ba33361c . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_generator . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_generator . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_file . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / io / zero_copy_stream . h > <nl> - # include < google / protobuf / descriptor . pb . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - namespace { <nl> - <nl> - string TrimString ( const string & s ) { <nl> - string : : size_type start = s . find_first_not_of ( " \ n \ r \ t " ) ; <nl> - if ( start = = string : : npos ) { <nl> - return " " ; <nl> - } <nl> - string : : size_type end = s . find_last_not_of ( " \ n \ r \ t " ) + 1 ; <nl> - return s . substr ( start , end - start ) ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - void UpdateParamsRecursively ( Params & params , <nl> - const FileDescriptor * file ) { <nl> - / / Add any parameters for this file <nl> - if ( file - > options ( ) . has_java_outer_classname ( ) ) { <nl> - params . set_java_outer_classname ( <nl> - file - > name ( ) , file - > options ( ) . java_outer_classname ( ) ) ; <nl> - } <nl> - if ( file - > options ( ) . has_java_package ( ) ) { <nl> - string result = file - > options ( ) . java_package ( ) ; <nl> - if ( ! result . empty ( ) ) { <nl> - result + = " . " ; <nl> - } <nl> - result + = " nano " ; <nl> - params . set_java_package ( <nl> - file - > name ( ) , result ) ; <nl> - } <nl> - if ( file - > options ( ) . has_java_multiple_files ( ) ) { <nl> - params . set_java_multiple_files ( <nl> - file - > name ( ) , file - > options ( ) . java_multiple_files ( ) ) ; <nl> - } <nl> - <nl> - / / Loop through all dependent files recursively <nl> - / / adding dep <nl> - for ( int i = 0 ; i < file - > dependency_count ( ) ; i + + ) { <nl> - UpdateParamsRecursively ( params , file - > dependency ( i ) ) ; <nl> - } <nl> - } <nl> - <nl> - JavaNanoGenerator : : JavaNanoGenerator ( ) { } <nl> - JavaNanoGenerator : : ~ JavaNanoGenerator ( ) { } <nl> - <nl> - bool JavaNanoGenerator : : Generate ( const FileDescriptor * file , <nl> - const string & parameter , <nl> - GeneratorContext * output_directory , <nl> - string * error ) const { <nl> - std : : vector < std : : pair < string , string > > options ; <nl> - <nl> - ParseGeneratorParameter ( parameter , & options ) ; <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / parse generator options <nl> - <nl> - / / Name a file where we will write a list of generated file names , one <nl> - / / per line . <nl> - string output_list_file ; <nl> - Params params ( file - > name ( ) ) ; <nl> - <nl> - / / Update per file params <nl> - UpdateParamsRecursively ( params , file ) ; <nl> - <nl> - / / Replace any existing options with ones from command line <nl> - for ( int i = 0 ; i < options . size ( ) ; i + + ) { <nl> - string option_name = TrimString ( options [ i ] . first ) ; <nl> - string option_value = TrimString ( options [ i ] . second ) ; <nl> - if ( option_name = = " output_list_file " ) { <nl> - output_list_file = option_value ; <nl> - } else if ( option_name = = " java_package " ) { <nl> - std : : vector < string > parts ; <nl> - SplitStringUsing ( option_value , " | " , & parts ) ; <nl> - if ( parts . size ( ) ! = 2 ) { <nl> - * error = " Bad java_package , expecting filename | PackageName found ' " <nl> - + option_value + " ' " ; <nl> - return false ; <nl> - } <nl> - params . set_java_package ( parts [ 0 ] , parts [ 1 ] ) ; <nl> - } else if ( option_name = = " java_outer_classname " ) { <nl> - std : : vector < string > parts ; <nl> - SplitStringUsing ( option_value , " | " , & parts ) ; <nl> - if ( parts . size ( ) ! = 2 ) { <nl> - * error = " Bad java_outer_classname , " <nl> - " expecting filename | ClassName found ' " <nl> - + option_value + " ' " ; <nl> - return false ; <nl> - } <nl> - params . set_java_outer_classname ( parts [ 0 ] , parts [ 1 ] ) ; <nl> - } else if ( option_name = = " store_unknown_fields " ) { <nl> - params . set_store_unknown_fields ( option_value = = " true " ) ; <nl> - } else if ( option_name = = " java_multiple_files " ) { <nl> - params . set_override_java_multiple_files ( option_value = = " true " ) ; <nl> - } else if ( option_name = = " java_nano_generate_has " ) { <nl> - params . set_generate_has ( option_value = = " true " ) ; <nl> - } else if ( option_name = = " enum_style " ) { <nl> - params . set_java_enum_style ( option_value = = " java " ) ; <nl> - } else if ( option_name = = " optional_field_style " ) { <nl> - params . set_optional_field_accessors ( option_value = = " accessors " ) ; <nl> - params . set_use_reference_types_for_primitives ( option_value = = " reftypes " <nl> - | | option_value = = " reftypes_compat_mode " ) ; <nl> - params . set_reftypes_primitive_enums ( <nl> - option_value = = " reftypes_compat_mode " ) ; <nl> - if ( option_value = = " reftypes_compat_mode " ) { <nl> - params . set_generate_clear ( false ) ; <nl> - } <nl> - } else if ( option_name = = " generate_equals " ) { <nl> - params . set_generate_equals ( option_value = = " true " ) ; <nl> - } else if ( option_name = = " ignore_services " ) { <nl> - params . set_ignore_services ( option_value = = " true " ) ; <nl> - } else if ( option_name = = " parcelable_messages " ) { <nl> - params . set_parcelable_messages ( option_value = = " true " ) ; <nl> - } else if ( option_name = = " generate_clone " ) { <nl> - params . set_generate_clone ( option_value = = " true " ) ; <nl> - } else if ( option_name = = " generate_intdefs " ) { <nl> - params . set_generate_intdefs ( option_value = = " true " ) ; <nl> - } else if ( option_name = = " generate_clear " ) { <nl> - params . set_generate_clear ( option_value = = " true " ) ; <nl> - } else { <nl> - * error = " Ignore unknown javanano generator option : " + option_name ; <nl> - } <nl> - } <nl> - <nl> - / / Check illegal parameter combinations <nl> - / / Note : the enum - like optional_field_style generator param ensures <nl> - / / that we can never have illegal combinations of field styles <nl> - / / ( e . g . reftypes and accessors can ' t be on at the same time ) . <nl> - if ( params . generate_has ( ) <nl> - & & ( params . optional_field_accessors ( ) <nl> - | | params . use_reference_types_for_primitives ( ) ) ) { <nl> - error - > assign ( " java_nano_generate_has = true cannot be used in conjunction " <nl> - " with optional_field_style = accessors or optional_field_style = reftypes " ) ; <nl> - return false ; <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - FileGenerator file_generator ( file , params ) ; <nl> - if ( ! file_generator . Validate ( error ) ) { <nl> - return false ; <nl> - } <nl> - <nl> - string package_dir = <nl> - StringReplace ( file_generator . java_package ( ) , " . " , " / " , true ) ; <nl> - if ( ! package_dir . empty ( ) ) package_dir + = " / " ; <nl> - <nl> - std : : vector < string > all_files ; <nl> - <nl> - if ( IsOuterClassNeeded ( params , file ) ) { <nl> - string java_filename = package_dir ; <nl> - java_filename + = file_generator . classname ( ) ; <nl> - java_filename + = " . java " ; <nl> - all_files . push_back ( java_filename ) ; <nl> - <nl> - / / Generate main java file . <nl> - std : : unique_ptr < io : : ZeroCopyOutputStream > output ( <nl> - output_directory - > Open ( java_filename ) ) ; <nl> - io : : Printer printer ( output . get ( ) , ' $ ' ) ; <nl> - file_generator . Generate ( & printer ) ; <nl> - } <nl> - <nl> - / / Generate sibling files . <nl> - file_generator . GenerateSiblings ( package_dir , output_directory , & all_files ) ; <nl> - <nl> - / / Generate output list if requested . <nl> - if ( ! output_list_file . empty ( ) ) { <nl> - / / Generate output list . This is just a simple text file placed in a <nl> - / / deterministic location which lists the . java files being generated . <nl> - std : : unique_ptr < io : : ZeroCopyOutputStream > srclist_raw_output ( <nl> - output_directory - > Open ( output_list_file ) ) ; <nl> - io : : Printer srclist_printer ( srclist_raw_output . get ( ) , ' $ ' ) ; <nl> - for ( int i = 0 ; i < all_files . size ( ) ; i + + ) { <nl> - srclist_printer . Print ( " $ filename $ \ n " , " filename " , all_files [ i ] ) ; <nl> - } <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - } / / namespace java <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index 6f9f7f2a4a . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_generator . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - / / <nl> - / / Generates Java nano code for a given . proto file . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__ <nl> - <nl> - # include < string > <nl> - # include < google / protobuf / compiler / code_generator . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - / / CodeGenerator implementation which generates Java nano code . If you create your <nl> - / / own protocol compiler binary and you want it to support Java output for the <nl> - / / nano runtime , you can do so by registering an instance of this CodeGenerator with <nl> - / / the CommandLineInterface in your main ( ) function . <nl> - class LIBPROTOC_EXPORT JavaNanoGenerator : public CodeGenerator { <nl> - public : <nl> - JavaNanoGenerator ( ) ; <nl> - ~ JavaNanoGenerator ( ) ; <nl> - <nl> - / / implements CodeGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - bool Generate ( const FileDescriptor * file , <nl> - const string & parameter , <nl> - GeneratorContext * output_directory , <nl> - string * error ) const ; <nl> - <nl> - private : <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( JavaNanoGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__ <nl> deleted file mode 100644 <nl> index 1927ba12f2 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_helpers . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < limits > <nl> - # include < vector > <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - # include < google / protobuf / descriptor . pb . h > <nl> - # include < google / protobuf / stubs / hash . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - # include < google / protobuf / stubs / substitute . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - const char kThickSeparator [ ] = <nl> - " / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - const char kThinSeparator [ ] = <nl> - " / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - \ n " ; <nl> - <nl> - class RenameKeywords { <nl> - private : <nl> - hash_set < string > java_keywords_set_ ; <nl> - <nl> - public : <nl> - RenameKeywords ( ) { <nl> - static const char * kJavaKeywordsList [ ] = { <nl> - / / Reserved Java Keywords <nl> - " abstract " , " assert " , " boolean " , " break " , " byte " , " case " , " catch " , <nl> - " char " , " class " , " const " , " continue " , " default " , " do " , " double " , " else " , <nl> - " enum " , " extends " , " final " , " finally " , " float " , " for " , " goto " , " if " , <nl> - " implements " , " import " , " instanceof " , " int " , " interface " , " long " , <nl> - " native " , " new " , " package " , " private " , " protected " , " public " , " return " , <nl> - " short " , " static " , " strictfp " , " super " , " switch " , " synchronized " , <nl> - " this " , " throw " , " throws " , " transient " , " try " , " void " , " volatile " , " while " , <nl> - <nl> - / / Reserved Keywords for Literals <nl> - " false " , " null " , " true " <nl> - } ; <nl> - <nl> - for ( int i = 0 ; i < GOOGLE_ARRAYSIZE ( kJavaKeywordsList ) ; i + + ) { <nl> - java_keywords_set_ . insert ( kJavaKeywordsList [ i ] ) ; <nl> - } <nl> - } <nl> - <nl> - / / Used to rename the a field name if it ' s a java keyword . Specifically <nl> - / / this is used to rename the [ " name " ] or [ " capitalized_name " ] field params . <nl> - / / ( http : / / docs . oracle . com / javase / tutorial / java / nutsandbolts / _keywords . html ) <nl> - string RenameJavaKeywordsImpl ( const string & input ) { <nl> - string result = input ; <nl> - <nl> - if ( java_keywords_set_ . find ( result ) ! = java_keywords_set_ . end ( ) ) { <nl> - result + = " _ " ; <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - } ; <nl> - <nl> - static RenameKeywords sRenameKeywords ; <nl> - <nl> - namespace { <nl> - <nl> - const char * kDefaultPackage = " " ; <nl> - <nl> - const string & FieldName ( const FieldDescriptor * field ) { <nl> - / / Groups are hacky : The name of the field is just the lower - cased name <nl> - / / of the group type . In Java , though , we would like to retain the original <nl> - / / capitalization of the type name . <nl> - if ( field - > type ( ) = = FieldDescriptor : : TYPE_GROUP ) { <nl> - return field - > message_type ( ) - > name ( ) ; <nl> - } else { <nl> - return field - > name ( ) ; <nl> - } <nl> - } <nl> - <nl> - string UnderscoresToCamelCaseImpl ( const string & input , bool cap_next_letter ) { <nl> - string result ; <nl> - / / Note : I distrust ctype . h due to locales . <nl> - for ( int i = 0 ; i < input . size ( ) ; i + + ) { <nl> - if ( ' a ' < = input [ i ] & & input [ i ] < = ' z ' ) { <nl> - if ( cap_next_letter ) { <nl> - result + = input [ i ] + ( ' A ' - ' a ' ) ; <nl> - } else { <nl> - result + = input [ i ] ; <nl> - } <nl> - cap_next_letter = false ; <nl> - } else if ( ' A ' < = input [ i ] & & input [ i ] < = ' Z ' ) { <nl> - if ( i = = 0 & & ! cap_next_letter ) { <nl> - / / Force first letter to lower - case unless explicitly told to <nl> - / / capitalize it . <nl> - result + = input [ i ] + ( ' a ' - ' A ' ) ; <nl> - } else { <nl> - / / Capital letters after the first are left as - is . <nl> - result + = input [ i ] ; <nl> - } <nl> - cap_next_letter = false ; <nl> - } else if ( ' 0 ' < = input [ i ] & & input [ i ] < = ' 9 ' ) { <nl> - result + = input [ i ] ; <nl> - cap_next_letter = true ; <nl> - } else { <nl> - cap_next_letter = true ; <nl> - } <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - string UnderscoresToCamelCase ( const FieldDescriptor * field ) { <nl> - return UnderscoresToCamelCaseImpl ( FieldName ( field ) , false ) ; <nl> - } <nl> - <nl> - string UnderscoresToCapitalizedCamelCase ( const FieldDescriptor * field ) { <nl> - return UnderscoresToCamelCaseImpl ( FieldName ( field ) , true ) ; <nl> - } <nl> - <nl> - string UnderscoresToCamelCase ( const MethodDescriptor * method ) { <nl> - return UnderscoresToCamelCaseImpl ( method - > name ( ) , false ) ; <nl> - } <nl> - <nl> - string UnderscoresToCamelCase ( const OneofDescriptor * oneof ) { <nl> - return UnderscoresToCamelCaseImpl ( oneof - > name ( ) , false ) ; <nl> - } <nl> - <nl> - string UnderscoresToCapitalizedCamelCase ( const OneofDescriptor * oneof ) { <nl> - return UnderscoresToCamelCaseImpl ( oneof - > name ( ) , true ) ; <nl> - } <nl> - <nl> - string RenameJavaKeywords ( const string & input ) { <nl> - return sRenameKeywords . RenameJavaKeywordsImpl ( input ) ; <nl> - } <nl> - <nl> - string StripProto ( const string & filename ) { <nl> - if ( HasSuffixString ( filename , " . protodevel " ) ) { <nl> - return StripSuffixString ( filename , " . protodevel " ) ; <nl> - } else { <nl> - return StripSuffixString ( filename , " . proto " ) ; <nl> - } <nl> - } <nl> - <nl> - string FileClassName ( const Params & params , const FileDescriptor * file ) { <nl> - if ( params . has_java_outer_classname ( file - > name ( ) ) ) { <nl> - return params . java_outer_classname ( file - > name ( ) ) ; <nl> - } else { <nl> - / / Use the filename itself with underscores removed <nl> - / / and a CamelCase style name . <nl> - string basename ; <nl> - string : : size_type last_slash = file - > name ( ) . find_last_of ( ' / ' ) ; <nl> - if ( last_slash = = string : : npos ) { <nl> - basename = file - > name ( ) ; <nl> - } else { <nl> - basename = file - > name ( ) . substr ( last_slash + 1 ) ; <nl> - } <nl> - return UnderscoresToCamelCaseImpl ( StripProto ( basename ) , true ) ; <nl> - } <nl> - } <nl> - <nl> - string FileJavaPackage ( const Params & params , const FileDescriptor * file ) { <nl> - if ( params . has_java_package ( file - > name ( ) ) ) { <nl> - return params . java_package ( file - > name ( ) ) ; <nl> - } else { <nl> - string result = kDefaultPackage ; <nl> - if ( ! file - > package ( ) . empty ( ) ) { <nl> - if ( ! result . empty ( ) ) result + = ' . ' ; <nl> - result + = file - > package ( ) ; <nl> - } <nl> - <nl> - if ( ! result . empty ( ) ) { <nl> - result + = " . " ; <nl> - } <nl> - result + = " nano " ; <nl> - <nl> - return result ; <nl> - } <nl> - } <nl> - <nl> - bool IsOuterClassNeeded ( const Params & params , const FileDescriptor * file ) { <nl> - / / If java_multiple_files is false , the outer class is always needed . <nl> - if ( ! params . java_multiple_files ( file - > name ( ) ) ) { <nl> - return true ; <nl> - } <nl> - <nl> - / / File - scope extensions need the outer class as the scope . <nl> - if ( file - > extension_count ( ) ! = 0 ) { <nl> - return true ; <nl> - } <nl> - <nl> - / / If container interfaces are not generated , file - scope enums need the <nl> - / / outer class as the scope . <nl> - if ( file - > enum_type_count ( ) ! = 0 & & ! params . java_enum_style ( ) ) { <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - string ToJavaName ( const Params & params , const string & name , bool is_class , <nl> - const Descriptor * parent , const FileDescriptor * file ) { <nl> - string result ; <nl> - if ( parent ! = NULL ) { <nl> - result . append ( ClassName ( params , parent ) ) ; <nl> - } else if ( is_class & & params . java_multiple_files ( file - > name ( ) ) ) { <nl> - result . append ( FileJavaPackage ( params , file ) ) ; <nl> - } else { <nl> - result . append ( ClassName ( params , file ) ) ; <nl> - } <nl> - if ( ! result . empty ( ) ) result . append ( 1 , ' . ' ) ; <nl> - result . append ( RenameJavaKeywords ( name ) ) ; <nl> - return result ; <nl> - } <nl> - <nl> - string ClassName ( const Params & params , const FileDescriptor * descriptor ) { <nl> - string result = FileJavaPackage ( params , descriptor ) ; <nl> - if ( ! result . empty ( ) ) result + = ' . ' ; <nl> - result + = FileClassName ( params , descriptor ) ; <nl> - return result ; <nl> - } <nl> - <nl> - string ClassName ( const Params & params , const EnumDescriptor * descriptor ) { <nl> - const Descriptor * parent = descriptor - > containing_type ( ) ; <nl> - / / When using Java enum style , an enum ' s class name contains the enum name . <nl> - / / Use the standard ToJavaName translation . <nl> - if ( params . java_enum_style ( ) ) { <nl> - return ToJavaName ( params , descriptor - > name ( ) , true , parent , <nl> - descriptor - > file ( ) ) ; <nl> - } <nl> - / / Otherwise the enum members are accessed from the enclosing class . <nl> - if ( parent ! = NULL ) { <nl> - return ClassName ( params , parent ) ; <nl> - } else { <nl> - return ClassName ( params , descriptor - > file ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - string FieldConstantName ( const FieldDescriptor * field ) { <nl> - string name = field - > name ( ) + " _FIELD_NUMBER " ; <nl> - UpperString ( & name ) ; <nl> - return name ; <nl> - } <nl> - <nl> - string FieldDefaultConstantName ( const FieldDescriptor * field ) { <nl> - return " _ " + RenameJavaKeywords ( UnderscoresToCamelCase ( field ) ) + " Default " ; <nl> - } <nl> - <nl> - void PrintFieldComment ( io : : Printer * printer , const FieldDescriptor * field ) { <nl> - / / We don ' t want to print group bodies so we cut off after the first line <nl> - / / ( the second line for extensions ) . <nl> - string def = field - > DebugString ( ) ; <nl> - string : : size_type first_line_end = def . find_first_of ( ' \ n ' ) ; <nl> - printer - > Print ( " / / $ def $ \ n " , <nl> - " def " , def . substr ( 0 , first_line_end ) ) ; <nl> - if ( field - > is_extension ( ) ) { <nl> - string : : size_type second_line_start = first_line_end + 1 ; <nl> - string : : size_type second_line_length = <nl> - def . find ( ' \ n ' , second_line_start ) - second_line_start ; <nl> - printer - > Print ( " / / $ def $ \ n " , <nl> - " def " , def . substr ( second_line_start , second_line_length ) ) ; <nl> - } <nl> - } <nl> - <nl> - JavaType GetJavaType ( FieldDescriptor : : Type field_type ) { <nl> - switch ( field_type ) { <nl> - case FieldDescriptor : : TYPE_INT32 : <nl> - case FieldDescriptor : : TYPE_UINT32 : <nl> - case FieldDescriptor : : TYPE_SINT32 : <nl> - case FieldDescriptor : : TYPE_FIXED32 : <nl> - case FieldDescriptor : : TYPE_SFIXED32 : <nl> - return JAVATYPE_INT ; <nl> - <nl> - case FieldDescriptor : : TYPE_INT64 : <nl> - case FieldDescriptor : : TYPE_UINT64 : <nl> - case FieldDescriptor : : TYPE_SINT64 : <nl> - case FieldDescriptor : : TYPE_FIXED64 : <nl> - case FieldDescriptor : : TYPE_SFIXED64 : <nl> - return JAVATYPE_LONG ; <nl> - <nl> - case FieldDescriptor : : TYPE_FLOAT : <nl> - return JAVATYPE_FLOAT ; <nl> - <nl> - case FieldDescriptor : : TYPE_DOUBLE : <nl> - return JAVATYPE_DOUBLE ; <nl> - <nl> - case FieldDescriptor : : TYPE_BOOL : <nl> - return JAVATYPE_BOOLEAN ; <nl> - <nl> - case FieldDescriptor : : TYPE_STRING : <nl> - return JAVATYPE_STRING ; <nl> - <nl> - case FieldDescriptor : : TYPE_BYTES : <nl> - return JAVATYPE_BYTES ; <nl> - <nl> - case FieldDescriptor : : TYPE_ENUM : <nl> - return JAVATYPE_ENUM ; <nl> - <nl> - case FieldDescriptor : : TYPE_GROUP : <nl> - case FieldDescriptor : : TYPE_MESSAGE : <nl> - return JAVATYPE_MESSAGE ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / types are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return JAVATYPE_INT ; <nl> - } <nl> - <nl> - string PrimitiveTypeName ( JavaType type ) { <nl> - switch ( type ) { <nl> - case JAVATYPE_INT : return " int " ; <nl> - case JAVATYPE_LONG : return " long " ; <nl> - case JAVATYPE_FLOAT : return " float " ; <nl> - case JAVATYPE_DOUBLE : return " double " ; <nl> - case JAVATYPE_BOOLEAN : return " boolean " ; <nl> - case JAVATYPE_STRING : return " java . lang . String " ; <nl> - case JAVATYPE_BYTES : return " byte [ ] " ; <nl> - case JAVATYPE_ENUM : return " int " ; <nl> - case JAVATYPE_MESSAGE : return " " ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / JavaTypes are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return " " ; <nl> - } <nl> - <nl> - string BoxedPrimitiveTypeName ( JavaType type ) { <nl> - switch ( type ) { <nl> - case JAVATYPE_INT : return " java . lang . Integer " ; <nl> - case JAVATYPE_LONG : return " java . lang . Long " ; <nl> - case JAVATYPE_FLOAT : return " java . lang . Float " ; <nl> - case JAVATYPE_DOUBLE : return " java . lang . Double " ; <nl> - case JAVATYPE_BOOLEAN : return " java . lang . Boolean " ; <nl> - case JAVATYPE_STRING : return " java . lang . String " ; <nl> - case JAVATYPE_BYTES : return " byte [ ] " ; <nl> - case JAVATYPE_ENUM : return " java . lang . Integer " ; <nl> - case JAVATYPE_MESSAGE : return " " ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / JavaTypes are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return " " ; <nl> - } <nl> - <nl> - string EmptyArrayName ( const Params & params , const FieldDescriptor * field ) { <nl> - switch ( GetJavaType ( field ) ) { <nl> - case JAVATYPE_INT : return " com . google . protobuf . nano . WireFormatNano . EMPTY_INT_ARRAY " ; <nl> - case JAVATYPE_LONG : return " com . google . protobuf . nano . WireFormatNano . EMPTY_LONG_ARRAY " ; <nl> - case JAVATYPE_FLOAT : return " com . google . protobuf . nano . WireFormatNano . EMPTY_FLOAT_ARRAY " ; <nl> - case JAVATYPE_DOUBLE : return " com . google . protobuf . nano . WireFormatNano . EMPTY_DOUBLE_ARRAY " ; <nl> - case JAVATYPE_BOOLEAN : return " com . google . protobuf . nano . WireFormatNano . EMPTY_BOOLEAN_ARRAY " ; <nl> - case JAVATYPE_STRING : return " com . google . protobuf . nano . WireFormatNano . EMPTY_STRING_ARRAY " ; <nl> - case JAVATYPE_BYTES : return " com . google . protobuf . nano . WireFormatNano . EMPTY_BYTES_ARRAY " ; <nl> - case JAVATYPE_ENUM : return " com . google . protobuf . nano . WireFormatNano . EMPTY_INT_ARRAY " ; <nl> - case JAVATYPE_MESSAGE : return ClassName ( params , field - > message_type ( ) ) + " . EMPTY_ARRAY " ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / JavaTypes are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return " " ; <nl> - } <nl> - <nl> - string DefaultValue ( const Params & params , const FieldDescriptor * field ) { <nl> - if ( field - > label ( ) = = FieldDescriptor : : LABEL_REPEATED ) { <nl> - return EmptyArrayName ( params , field ) ; <nl> - } <nl> - <nl> - if ( params . use_reference_types_for_primitives ( ) ) { <nl> - if ( params . reftypes_primitive_enums ( ) <nl> - & & field - > cpp_type ( ) = = FieldDescriptor : : CPPTYPE_ENUM ) { <nl> - return " Integer . MIN_VALUE " ; <nl> - } <nl> - return " null " ; <nl> - } <nl> - <nl> - / / Switch on cpp_type since we need to know which default_value_ * method <nl> - / / of FieldDescriptor to call . <nl> - switch ( field - > cpp_type ( ) ) { <nl> - case FieldDescriptor : : CPPTYPE_INT32 : <nl> - return SimpleItoa ( field - > default_value_int32 ( ) ) ; <nl> - case FieldDescriptor : : CPPTYPE_UINT32 : <nl> - / / Need to print as a signed int since Java has no unsigned . <nl> - return SimpleItoa ( static_cast < int32 > ( field - > default_value_uint32 ( ) ) ) ; <nl> - case FieldDescriptor : : CPPTYPE_INT64 : <nl> - return SimpleItoa ( field - > default_value_int64 ( ) ) + " L " ; <nl> - case FieldDescriptor : : CPPTYPE_UINT64 : <nl> - return SimpleItoa ( static_cast < int64 > ( field - > default_value_uint64 ( ) ) ) + <nl> - " L " ; <nl> - case FieldDescriptor : : CPPTYPE_DOUBLE : { <nl> - double value = field - > default_value_double ( ) ; <nl> - if ( value = = std : : numeric_limits < double > : : infinity ( ) ) { <nl> - return " Double . POSITIVE_INFINITY " ; <nl> - } else if ( value = = - std : : numeric_limits < double > : : infinity ( ) ) { <nl> - return " Double . NEGATIVE_INFINITY " ; <nl> - } else if ( value ! = value ) { <nl> - return " Double . NaN " ; <nl> - } else { <nl> - return SimpleDtoa ( value ) + " D " ; <nl> - } <nl> - } <nl> - case FieldDescriptor : : CPPTYPE_FLOAT : { <nl> - float value = field - > default_value_float ( ) ; <nl> - if ( value = = std : : numeric_limits < float > : : infinity ( ) ) { <nl> - return " Float . POSITIVE_INFINITY " ; <nl> - } else if ( value = = - std : : numeric_limits < float > : : infinity ( ) ) { <nl> - return " Float . NEGATIVE_INFINITY " ; <nl> - } else if ( value ! = value ) { <nl> - return " Float . NaN " ; <nl> - } else { <nl> - return SimpleFtoa ( value ) + " F " ; <nl> - } <nl> - } <nl> - case FieldDescriptor : : CPPTYPE_BOOL : <nl> - return field - > default_value_bool ( ) ? " true " : " false " ; <nl> - case FieldDescriptor : : CPPTYPE_STRING : <nl> - if ( ! field - > default_value_string ( ) . empty ( ) ) { <nl> - / / Point it to the static final in the generated code . <nl> - return FieldDefaultConstantName ( field ) ; <nl> - } else { <nl> - if ( field - > type ( ) = = FieldDescriptor : : TYPE_BYTES ) { <nl> - return " com . google . protobuf . nano . WireFormatNano . EMPTY_BYTES " ; <nl> - } else { <nl> - return " \ " \ " " ; <nl> - } <nl> - } <nl> - <nl> - case FieldDescriptor : : CPPTYPE_ENUM : <nl> - return ClassName ( params , field - > enum_type ( ) ) + " . " + <nl> - RenameJavaKeywords ( field - > default_value_enum ( ) - > name ( ) ) ; <nl> - <nl> - case FieldDescriptor : : CPPTYPE_MESSAGE : <nl> - return " null " ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / types are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return " " ; <nl> - } <nl> - <nl> - <nl> - static const char * kBitMasks [ ] = { <nl> - " 0x00000001 " , <nl> - " 0x00000002 " , <nl> - " 0x00000004 " , <nl> - " 0x00000008 " , <nl> - " 0x00000010 " , <nl> - " 0x00000020 " , <nl> - " 0x00000040 " , <nl> - " 0x00000080 " , <nl> - <nl> - " 0x00000100 " , <nl> - " 0x00000200 " , <nl> - " 0x00000400 " , <nl> - " 0x00000800 " , <nl> - " 0x00001000 " , <nl> - " 0x00002000 " , <nl> - " 0x00004000 " , <nl> - " 0x00008000 " , <nl> - <nl> - " 0x00010000 " , <nl> - " 0x00020000 " , <nl> - " 0x00040000 " , <nl> - " 0x00080000 " , <nl> - " 0x00100000 " , <nl> - " 0x00200000 " , <nl> - " 0x00400000 " , <nl> - " 0x00800000 " , <nl> - <nl> - " 0x01000000 " , <nl> - " 0x02000000 " , <nl> - " 0x04000000 " , <nl> - " 0x08000000 " , <nl> - " 0x10000000 " , <nl> - " 0x20000000 " , <nl> - " 0x40000000 " , <nl> - " 0x80000000 " , <nl> - } ; <nl> - <nl> - string GetBitFieldName ( int index ) { <nl> - string var_name = " bitField " ; <nl> - var_name + = SimpleItoa ( index ) ; <nl> - var_name + = " _ " ; <nl> - return var_name ; <nl> - } <nl> - <nl> - string GetBitFieldNameForBit ( int bit_index ) { <nl> - return GetBitFieldName ( bit_index / 32 ) ; <nl> - } <nl> - <nl> - string GenerateGetBit ( int bit_index ) { <nl> - string var_name = GetBitFieldNameForBit ( bit_index ) ; <nl> - int bit_in_var_index = bit_index % 32 ; <nl> - <nl> - string mask = kBitMasks [ bit_in_var_index ] ; <nl> - string result = " ( ( " + var_name + " & " + mask + " ) ! = 0 ) " ; <nl> - return result ; <nl> - } <nl> - <nl> - string GenerateSetBit ( int bit_index ) { <nl> - string var_name = GetBitFieldNameForBit ( bit_index ) ; <nl> - int bit_in_var_index = bit_index % 32 ; <nl> - <nl> - string mask = kBitMasks [ bit_in_var_index ] ; <nl> - string result = var_name + " | = " + mask ; <nl> - return result ; <nl> - } <nl> - <nl> - string GenerateClearBit ( int bit_index ) { <nl> - string var_name = GetBitFieldNameForBit ( bit_index ) ; <nl> - int bit_in_var_index = bit_index % 32 ; <nl> - <nl> - string mask = kBitMasks [ bit_in_var_index ] ; <nl> - string result = var_name + " = ( " + var_name + " & ~ " + mask + " ) " ; <nl> - return result ; <nl> - } <nl> - <nl> - string GenerateDifferentBit ( int bit_index ) { <nl> - string var_name = GetBitFieldNameForBit ( bit_index ) ; <nl> - int bit_in_var_index = bit_index % 32 ; <nl> - <nl> - string mask = kBitMasks [ bit_in_var_index ] ; <nl> - string result = " ( ( " + var_name + " & " + mask <nl> - + " ) ! = ( other . " + var_name + " & " + mask + " ) ) " ; <nl> - return result ; <nl> - } <nl> - <nl> - void SetBitOperationVariables ( const string name , <nl> - int bitIndex , std : : map < string , string > * variables ) { <nl> - ( * variables ) [ " get_ " + name ] = GenerateGetBit ( bitIndex ) ; <nl> - ( * variables ) [ " set_ " + name ] = GenerateSetBit ( bitIndex ) ; <nl> - ( * variables ) [ " clear_ " + name ] = GenerateClearBit ( bitIndex ) ; <nl> - ( * variables ) [ " different_ " + name ] = GenerateDifferentBit ( bitIndex ) ; <nl> - } <nl> - <nl> - bool HasMapField ( const Descriptor * descriptor ) { <nl> - for ( int i = 0 ; i < descriptor - > field_count ( ) ; + + i ) { <nl> - const FieldDescriptor * field = descriptor - > field ( i ) ; <nl> - if ( field - > type ( ) = = FieldDescriptor : : TYPE_MESSAGE & & <nl> - IsMapEntry ( field - > message_type ( ) ) ) { <nl> - return true ; <nl> - } <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index 04b2d63353 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_helpers . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__ <nl> - <nl> - # include < string > <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - # include < google / protobuf / descriptor . pb . h > <nl> - # include < google / protobuf / descriptor . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - / / Commonly - used separator comments . Thick is a line of ' = ' , thin is a line <nl> - / / of ' - ' . <nl> - extern const char kThickSeparator [ ] ; <nl> - extern const char kThinSeparator [ ] ; <nl> - <nl> - / / Converts the field ' s name to camel - case , e . g . " foo_bar_baz " becomes <nl> - / / " fooBarBaz " or " FooBarBaz " , respectively . <nl> - string UnderscoresToCamelCase ( const FieldDescriptor * field ) ; <nl> - string UnderscoresToCamelCase ( const OneofDescriptor * oneof ) ; <nl> - string UnderscoresToCapitalizedCamelCase ( const FieldDescriptor * field ) ; <nl> - string UnderscoresToCapitalizedCamelCase ( const OneofDescriptor * oneof ) ; <nl> - <nl> - / / Appends an " _ " to the end of a field where the name is a reserved java <nl> - / / keyword . For example int32 public = 1 will generate int public_ . <nl> - string RenameJavaKeywords ( const string & input ) ; <nl> - <nl> - / / Similar , but for method names . ( Typically , this merely has the effect <nl> - / / of lower - casing the first letter of the name . ) <nl> - string UnderscoresToCamelCase ( const MethodDescriptor * method ) ; <nl> - <nl> - / / Strips " . proto " or " . protodevel " from the end of a filename . <nl> - string StripProto ( const string & filename ) ; <nl> - <nl> - / / Gets the unqualified class name for the file . Each . proto file becomes a <nl> - / / single Java class , with all its contents nested in that class . <nl> - string FileClassName ( const Params & params , const FileDescriptor * file ) ; <nl> - <nl> - / / Returns the file ' s Java package name . <nl> - string FileJavaPackage ( const Params & params , const FileDescriptor * file ) ; <nl> - <nl> - / / Returns whether the Java outer class is needed , i . e . whether the option <nl> - / / java_multiple_files is false , or the proto file contains any file - scope <nl> - / / enums / extensions . <nl> - bool IsOuterClassNeeded ( const Params & params , const FileDescriptor * file ) ; <nl> - <nl> - / / Converts the given simple name of a proto entity to its fully - qualified name <nl> - / / in the Java namespace , given that it is in the given file enclosed in the <nl> - / / given parent message ( or NULL for file - scope entities ) . Whether the file ' s <nl> - / / outer class name should be included in the return value depends on factors <nl> - / / inferrable from the given arguments , including is_class which indicates <nl> - / / whether the entity translates to a Java class . <nl> - string ToJavaName ( const Params & params , const string & name , bool is_class , <nl> - const Descriptor * parent , const FileDescriptor * file ) ; <nl> - <nl> - / / These return the fully - qualified class name corresponding to the given <nl> - / / descriptor . <nl> - inline string ClassName ( const Params & params , const Descriptor * descriptor ) { <nl> - return ToJavaName ( params , descriptor - > name ( ) , true , <nl> - descriptor - > containing_type ( ) , descriptor - > file ( ) ) ; <nl> - } <nl> - string ClassName ( const Params & params , const EnumDescriptor * descriptor ) ; <nl> - inline string ClassName ( const Params & params , <nl> - const ServiceDescriptor * descriptor ) { <nl> - return ToJavaName ( params , descriptor - > name ( ) , true , NULL , descriptor - > file ( ) ) ; <nl> - } <nl> - inline string ExtensionIdentifierName ( const Params & params , <nl> - const FieldDescriptor * descriptor ) { <nl> - return ToJavaName ( params , descriptor - > name ( ) , false , <nl> - descriptor - > extension_scope ( ) , descriptor - > file ( ) ) ; <nl> - } <nl> - string ClassName ( const Params & params , const FileDescriptor * descriptor ) ; <nl> - <nl> - / / Get the unqualified name that should be used for a field ' s field <nl> - / / number constant . <nl> - string FieldConstantName ( const FieldDescriptor * field ) ; <nl> - <nl> - string FieldDefaultConstantName ( const FieldDescriptor * field ) ; <nl> - <nl> - / / Print the field ' s proto - syntax definition as a comment . <nl> - void PrintFieldComment ( io : : Printer * printer , const FieldDescriptor * field ) ; <nl> - <nl> - enum JavaType { <nl> - JAVATYPE_INT , <nl> - JAVATYPE_LONG , <nl> - JAVATYPE_FLOAT , <nl> - JAVATYPE_DOUBLE , <nl> - JAVATYPE_BOOLEAN , <nl> - JAVATYPE_STRING , <nl> - JAVATYPE_BYTES , <nl> - JAVATYPE_ENUM , <nl> - JAVATYPE_MESSAGE <nl> - } ; <nl> - <nl> - JavaType GetJavaType ( FieldDescriptor : : Type field_type ) ; <nl> - <nl> - inline JavaType GetJavaType ( const FieldDescriptor * field ) { <nl> - return GetJavaType ( field - > type ( ) ) ; <nl> - } <nl> - <nl> - string PrimitiveTypeName ( JavaType type ) ; <nl> - <nl> - / / Get the fully - qualified class name for a boxed primitive type , e . g . <nl> - / / " java . lang . Integer " for JAVATYPE_INT . Returns NULL for enum and message <nl> - / / types . <nl> - string BoxedPrimitiveTypeName ( JavaType type ) ; <nl> - <nl> - string EmptyArrayName ( const Params & params , const FieldDescriptor * field ) ; <nl> - <nl> - string DefaultValue ( const Params & params , const FieldDescriptor * field ) ; <nl> - <nl> - <nl> - / / Methods for shared bitfields . <nl> - <nl> - / / Gets the name of the shared bitfield for the given field index . <nl> - string GetBitFieldName ( int index ) ; <nl> - <nl> - / / Gets the name of the shared bitfield for the given bit index . <nl> - / / Effectively , GetBitFieldName ( bit_index / 32 ) <nl> - string GetBitFieldNameForBit ( int bit_index ) ; <nl> - <nl> - / / Generates the java code for the expression that returns whether the bit at <nl> - / / the given bit index is set . <nl> - / / Example : " ( ( bitField1_ & 0x04000000 ) ! = 0 ) " <nl> - string GenerateGetBit ( int bit_index ) ; <nl> - <nl> - / / Generates the java code for the expression that sets the bit at the given <nl> - / / bit index . <nl> - / / Example : " bitField1_ | = 0x04000000 " <nl> - string GenerateSetBit ( int bit_index ) ; <nl> - <nl> - / / Generates the java code for the expression that clears the bit at the given <nl> - / / bit index . <nl> - / / Example : " bitField1_ = ( bitField1_ & ~ 0x04000000 ) " <nl> - string GenerateClearBit ( int bit_index ) ; <nl> - <nl> - / / Generates the java code for the expression that returns whether the bit at <nl> - / / the given bit index contains different values in the current object and <nl> - / / another object accessible via the variable ' other ' . <nl> - / / Example : " ( ( bitField1_ & 0x04000000 ) ! = ( other . bitField1_ & 0x04000000 ) ) " <nl> - string GenerateDifferentBit ( int bit_index ) ; <nl> - <nl> - / / Sets the ' get_ * ' , ' set_ * ' , ' clear_ * ' and ' different_ * ' variables , where * is <nl> - / / the given name of the bit , to the appropriate Java expressions for the given <nl> - / / bit index . <nl> - void SetBitOperationVariables ( const string name , <nl> - int bitIndex , std : : map < string , string > * variables ) ; <nl> - <nl> - inline bool IsMapEntry ( const Descriptor * descriptor ) { <nl> - / / TODO ( liujisi ) : Add an option to turn on maps for proto2 syntax as well . <nl> - return descriptor - > options ( ) . map_entry ( ) & & <nl> - descriptor - > file ( ) - > syntax ( ) = = FileDescriptor : : SYNTAX_PROTO3 ; <nl> - } <nl> - <nl> - bool HasMapField ( const Descriptor * descriptor ) ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__ <nl> deleted file mode 100644 <nl> index a4ab8858f2 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_map_field . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_map_field . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / stubs / common . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / wire_format . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - namespace { <nl> - <nl> - string TypeName ( const Params & params , const FieldDescriptor * field , <nl> - bool boxed ) { <nl> - JavaType java_type = GetJavaType ( field ) ; <nl> - switch ( java_type ) { <nl> - case JAVATYPE_MESSAGE : <nl> - return ClassName ( params , field - > message_type ( ) ) ; <nl> - case JAVATYPE_INT : <nl> - case JAVATYPE_LONG : <nl> - case JAVATYPE_FLOAT : <nl> - case JAVATYPE_DOUBLE : <nl> - case JAVATYPE_BOOLEAN : <nl> - case JAVATYPE_STRING : <nl> - case JAVATYPE_BYTES : <nl> - case JAVATYPE_ENUM : <nl> - if ( boxed ) { <nl> - return BoxedPrimitiveTypeName ( java_type ) ; <nl> - } else { <nl> - return PrimitiveTypeName ( java_type ) ; <nl> - } <nl> - / / No default because we want the compiler to complain if any new JavaTypes <nl> - / / are added . . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " should not reach here . " ; <nl> - return " " ; <nl> - } <nl> - <nl> - const FieldDescriptor * KeyField ( const FieldDescriptor * descriptor ) { <nl> - GOOGLE_CHECK_EQ ( FieldDescriptor : : TYPE_MESSAGE , descriptor - > type ( ) ) ; <nl> - const Descriptor * message = descriptor - > message_type ( ) ; <nl> - GOOGLE_CHECK ( message - > options ( ) . map_entry ( ) ) ; <nl> - return message - > FindFieldByName ( " key " ) ; <nl> - } <nl> - <nl> - const FieldDescriptor * ValueField ( const FieldDescriptor * descriptor ) { <nl> - GOOGLE_CHECK_EQ ( FieldDescriptor : : TYPE_MESSAGE , descriptor - > type ( ) ) ; <nl> - const Descriptor * message = descriptor - > message_type ( ) ; <nl> - GOOGLE_CHECK ( message - > options ( ) . map_entry ( ) ) ; <nl> - return message - > FindFieldByName ( " value " ) ; <nl> - } <nl> - <nl> - void SetMapVariables ( const Params & params , <nl> - const FieldDescriptor * descriptor , std : : map < string , string > * variables ) { <nl> - const FieldDescriptor * key = KeyField ( descriptor ) ; <nl> - const FieldDescriptor * value = ValueField ( descriptor ) ; <nl> - ( * variables ) [ " name " ] = <nl> - RenameJavaKeywords ( UnderscoresToCamelCase ( descriptor ) ) ; <nl> - ( * variables ) [ " number " ] = SimpleItoa ( descriptor - > number ( ) ) ; <nl> - ( * variables ) [ " key_type " ] = TypeName ( params , key , false ) ; <nl> - ( * variables ) [ " boxed_key_type " ] = TypeName ( params , key , true ) ; <nl> - ( * variables ) [ " key_desc_type " ] = <nl> - " TYPE_ " + ToUpper ( FieldDescriptor : : TypeName ( key - > type ( ) ) ) ; <nl> - ( * variables ) [ " key_tag " ] = SimpleItoa ( internal : : WireFormat : : MakeTag ( key ) ) ; <nl> - ( * variables ) [ " value_type " ] = TypeName ( params , value , false ) ; <nl> - ( * variables ) [ " boxed_value_type " ] = TypeName ( params , value , true ) ; <nl> - ( * variables ) [ " value_desc_type " ] = <nl> - " TYPE_ " + ToUpper ( FieldDescriptor : : TypeName ( value - > type ( ) ) ) ; <nl> - ( * variables ) [ " value_tag " ] = SimpleItoa ( internal : : WireFormat : : MakeTag ( value ) ) ; <nl> - ( * variables ) [ " type_parameters " ] = <nl> - ( * variables ) [ " boxed_key_type " ] + " , " + ( * variables ) [ " boxed_value_type " ] ; <nl> - ( * variables ) [ " value_default " ] = <nl> - value - > type ( ) = = FieldDescriptor : : TYPE_MESSAGE <nl> - ? " new " + ( * variables ) [ " value_type " ] + " ( ) " <nl> - : " null " ; <nl> - } <nl> - } / / namespace <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - MapFieldGenerator : : MapFieldGenerator ( const FieldDescriptor * descriptor , <nl> - const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetMapVariables ( params , descriptor , & variables_ ) ; <nl> - } <nl> - <nl> - MapFieldGenerator : : ~ MapFieldGenerator ( ) { } <nl> - <nl> - void MapFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool / * unused lazy_init * / ) const { <nl> - printer - > Print ( variables_ , <nl> - " public java . util . Map < $ type_parameters $ > $ name $ ; \ n " ) ; <nl> - } <nl> - <nl> - void MapFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ = null ; \ n " ) ; <nl> - } <nl> - <nl> - void MapFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " this . $ name $ = com . google . protobuf . nano . InternalNano . mergeMapEntry ( \ n " <nl> - " input , this . $ name $ , mapFactory , \ n " <nl> - " com . google . protobuf . nano . InternalNano . $ key_desc_type $ , \ n " <nl> - " com . google . protobuf . nano . InternalNano . $ value_desc_type $ , \ n " <nl> - " $ value_default $ , \ n " <nl> - " $ key_tag $ , $ value_tag $ ) ; \ n " <nl> - " \ n " ) ; <nl> - } <nl> - <nl> - void MapFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null ) { \ n " <nl> - " com . google . protobuf . nano . InternalNano . serializeMapField ( \ n " <nl> - " output , this . $ name $ , $ number $ , \ n " <nl> - " com . google . protobuf . nano . InternalNano . $ key_desc_type $ , \ n " <nl> - " com . google . protobuf . nano . InternalNano . $ value_desc_type $ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MapFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null ) { \ n " <nl> - " size + = com . google . protobuf . nano . InternalNano . computeMapFieldSize ( \ n " <nl> - " this . $ name $ , $ number $ , \ n " <nl> - " com . google . protobuf . nano . InternalNano . $ key_desc_type $ , \ n " <nl> - " com . google . protobuf . nano . InternalNano . $ value_desc_type $ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MapFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( ! com . google . protobuf . nano . InternalNano . equals ( \ n " <nl> - " this . $ name $ , other . $ name $ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MapFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + \ n " <nl> - " com . google . protobuf . nano . InternalNano . hashCode ( this . $ name $ ) ; \ n " ) ; <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index 81e5915dfe . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_map_field . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_MAP_FIELD_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_MAP_FIELD_H__ <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - # include < vector > <nl> - # include < google / protobuf / compiler / javanano / javanano_field . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class MapFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit MapFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) ; <nl> - ~ MapFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( MapFieldGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_MAP_FIELD_H__ <nl> deleted file mode 100644 <nl> index e849521b30 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_message . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < algorithm > <nl> - # include < google / protobuf / stubs / hash . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_message . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_enum . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_extension . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / io / coded_stream . h > <nl> - # include < google / protobuf / wire_format . h > <nl> - # include < google / protobuf / descriptor . pb . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - using internal : : WireFormat ; <nl> - using internal : : WireFormatLite ; <nl> - <nl> - namespace { <nl> - <nl> - struct FieldOrderingByNumber { <nl> - inline bool operator ( ) ( const FieldDescriptor * a , <nl> - const FieldDescriptor * b ) const { <nl> - return a - > number ( ) < b - > number ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - / / Sort the fields of the given Descriptor by number into a new [ ] ' d array <nl> - / / and return it . <nl> - const FieldDescriptor * * SortFieldsByNumber ( const Descriptor * descriptor ) { <nl> - const FieldDescriptor * * fields = <nl> - new const FieldDescriptor * [ descriptor - > field_count ( ) ] ; <nl> - for ( int i = 0 ; i < descriptor - > field_count ( ) ; i + + ) { <nl> - fields [ i ] = descriptor - > field ( i ) ; <nl> - } <nl> - std : : sort ( fields , fields + descriptor - > field_count ( ) , <nl> - FieldOrderingByNumber ( ) ) ; <nl> - return fields ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - MessageGenerator : : MessageGenerator ( const Descriptor * descriptor , const Params & params ) <nl> - : params_ ( params ) , <nl> - descriptor_ ( descriptor ) , <nl> - field_generators_ ( descriptor , params ) { <nl> - } <nl> - <nl> - MessageGenerator : : ~ MessageGenerator ( ) { } <nl> - <nl> - void MessageGenerator : : GenerateStaticVariables ( io : : Printer * printer ) { <nl> - / / Generate static members for all nested types . <nl> - for ( int i = 0 ; i < descriptor_ - > nested_type_count ( ) ; i + + ) { <nl> - / / TODO ( kenton ) : Reuse MessageGenerator objects ? <nl> - if ( IsMapEntry ( descriptor_ - > nested_type ( i ) ) ) continue ; <nl> - MessageGenerator ( descriptor_ - > nested_type ( i ) , params_ ) <nl> - . GenerateStaticVariables ( printer ) ; <nl> - } <nl> - } <nl> - <nl> - void MessageGenerator : : GenerateStaticVariableInitializers ( <nl> - io : : Printer * printer ) { <nl> - / / Generate static member initializers for all nested types . <nl> - for ( int i = 0 ; i < descriptor_ - > nested_type_count ( ) ; i + + ) { <nl> - / / TODO ( kenton ) : Reuse MessageGenerator objects ? <nl> - if ( IsMapEntry ( descriptor_ - > nested_type ( i ) ) ) continue ; <nl> - MessageGenerator ( descriptor_ - > nested_type ( i ) , params_ ) <nl> - . GenerateStaticVariableInitializers ( printer ) ; <nl> - } <nl> - } <nl> - <nl> - void MessageGenerator : : Generate ( io : : Printer * printer ) { <nl> - if ( ! params_ . store_unknown_fields ( ) & & <nl> - ( descriptor_ - > extension_count ( ) ! = 0 | | descriptor_ - > extension_range_count ( ) ! = 0 ) ) { <nl> - GOOGLE_LOG ( FATAL ) < < " Extensions are only supported in NANO_RUNTIME if the " <nl> - " ' store_unknown_fields ' generator option is ' true ' \ n " ; <nl> - } <nl> - <nl> - const string & file_name = descriptor_ - > file ( ) - > name ( ) ; <nl> - bool is_own_file = <nl> - params_ . java_multiple_files ( file_name ) <nl> - & & descriptor_ - > containing_type ( ) = = NULL ; <nl> - <nl> - if ( is_own_file ) { <nl> - / / Note : constants ( from enums and fields requiring stored defaults , emitted in the loop below ) <nl> - / / may have the same names as constants in the nested classes . This causes Java warnings , but <nl> - / / is not fatal , so we suppress those warnings here in the top - most class declaration . <nl> - printer - > Print ( <nl> - " \ n " <nl> - " @ SuppressWarnings ( \ " hiding \ " ) \ n " <nl> - " public final class $ classname $ extends \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - } else { <nl> - printer - > Print ( <nl> - " \ n " <nl> - " public static final class $ classname $ extends \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - } <nl> - if ( params_ . store_unknown_fields ( ) & & params_ . parcelable_messages ( ) ) { <nl> - printer - > Print ( <nl> - " com . google . protobuf . nano . android . ParcelableExtendableMessageNano < $ classname $ > " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - } else if ( params_ . store_unknown_fields ( ) ) { <nl> - printer - > Print ( <nl> - " com . google . protobuf . nano . ExtendableMessageNano < $ classname $ > " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - } else if ( params_ . parcelable_messages ( ) ) { <nl> - printer - > Print ( <nl> - " com . google . protobuf . nano . android . ParcelableMessageNano " ) ; <nl> - } else { <nl> - printer - > Print ( <nl> - " com . google . protobuf . nano . MessageNano " ) ; <nl> - } <nl> - if ( params_ . generate_clone ( ) ) { <nl> - printer - > Print ( " implements java . lang . Cloneable { \ n " ) ; <nl> - } else { <nl> - printer - > Print ( " { \ n " ) ; <nl> - } <nl> - printer - > Indent ( ) ; <nl> - <nl> - if ( params_ . parcelable_messages ( ) ) { <nl> - printer - > Print ( <nl> - " \ n " <nl> - " / / Used by Parcelable \ n " <nl> - " @ SuppressWarnings ( { \ " unused \ " } ) \ n " <nl> - " public static final android . os . Parcelable . Creator < $ classname $ > CREATOR = \ n " <nl> - " new com . google . protobuf . nano . android . ParcelableMessageNanoCreator < \ n " <nl> - " $ classname $ > ( $ classname $ . class ) ; \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - } <nl> - <nl> - / / Nested types and extensions <nl> - for ( int i = 0 ; i < descriptor_ - > extension_count ( ) ; i + + ) { <nl> - ExtensionGenerator ( descriptor_ - > extension ( i ) , params_ ) . Generate ( printer ) ; <nl> - } <nl> - <nl> - for ( int i = 0 ; i < descriptor_ - > enum_type_count ( ) ; i + + ) { <nl> - EnumGenerator ( descriptor_ - > enum_type ( i ) , params_ ) . Generate ( printer ) ; <nl> - } <nl> - <nl> - for ( int i = 0 ; i < descriptor_ - > nested_type_count ( ) ; i + + ) { <nl> - if ( IsMapEntry ( descriptor_ - > nested_type ( i ) ) ) continue ; <nl> - MessageGenerator ( descriptor_ - > nested_type ( i ) , params_ ) . Generate ( printer ) ; <nl> - } <nl> - <nl> - / / oneof <nl> - std : : map < string , string > vars ; <nl> - vars [ " message_name " ] = descriptor_ - > name ( ) ; <nl> - for ( int i = 0 ; i < descriptor_ - > oneof_decl_count ( ) ; i + + ) { <nl> - const OneofDescriptor * oneof_desc = descriptor_ - > oneof_decl ( i ) ; <nl> - vars [ " oneof_name " ] = UnderscoresToCamelCase ( oneof_desc ) ; <nl> - vars [ " oneof_capitalized_name " ] = <nl> - UnderscoresToCapitalizedCamelCase ( oneof_desc ) ; <nl> - vars [ " oneof_index " ] = SimpleItoa ( oneof_desc - > index ( ) ) ; <nl> - / / Oneof Constants <nl> - for ( int j = 0 ; j < oneof_desc - > field_count ( ) ; j + + ) { <nl> - const FieldDescriptor * field = oneof_desc - > field ( j ) ; <nl> - vars [ " number " ] = SimpleItoa ( field - > number ( ) ) ; <nl> - vars [ " cap_field_name " ] = ToUpper ( field - > name ( ) ) ; <nl> - printer - > Print ( vars , <nl> - " public static final int $ cap_field_name $ _FIELD_NUMBER = $ number $ ; \ n " ) ; <nl> - } <nl> - / / oneofCase_ and oneof_ <nl> - printer - > Print ( vars , <nl> - " private int $ oneof_name $ Case_ = 0 ; \ n " <nl> - " private java . lang . Object $ oneof_name $ _ ; \ n " ) ; <nl> - printer - > Print ( vars , <nl> - " public int get $ oneof_capitalized_name $ Case ( ) { \ n " <nl> - " return this . $ oneof_name $ Case_ ; \ n " <nl> - " } \ n " ) ; <nl> - / / Oneof clear <nl> - printer - > Print ( vars , <nl> - " public $ message_name $ clear $ oneof_capitalized_name $ ( ) { \ n " <nl> - " this . $ oneof_name $ Case_ = 0 ; \ n " <nl> - " this . $ oneof_name $ _ = null ; \ n " <nl> - " return this ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - / / Lazy initialization of otherwise static final fields can help prevent the <nl> - / / class initializer from being generated . We want to prevent it because it <nl> - / / stops ProGuard from inlining any methods in this class into call sites and <nl> - / / therefore reducing the method count . However , extensions are best kept as <nl> - / / public static final fields with initializers , so with their existence we <nl> - / / won ' t bother with lazy initialization . <nl> - bool lazy_init = descriptor_ - > extension_count ( ) = = 0 ; <nl> - <nl> - / / Empty array <nl> - if ( lazy_init ) { <nl> - printer - > Print ( <nl> - " \ n " <nl> - " private static volatile $ classname $ [ ] _emptyArray ; \ n " <nl> - " public static $ classname $ [ ] emptyArray ( ) { \ n " <nl> - " / / Lazily initializes the empty array \ n " <nl> - " if ( _emptyArray = = null ) { \ n " <nl> - " synchronized ( \ n " <nl> - " com . google . protobuf . nano . InternalNano . LAZY_INIT_LOCK ) { \ n " <nl> - " if ( _emptyArray = = null ) { \ n " <nl> - " _emptyArray = new $ classname $ [ 0 ] ; \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " return _emptyArray ; \ n " <nl> - " } \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - } else { <nl> - printer - > Print ( <nl> - " \ n " <nl> - " private static final $ classname $ [ ] EMPTY_ARRAY = { } ; \ n " <nl> - " public static $ classname $ [ ] emptyArray ( ) { \ n " <nl> - " return EMPTY_ARRAY ; \ n " <nl> - " } \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - } <nl> - <nl> - / / Integers for bit fields <nl> - int totalInts = ( field_generators_ . total_bits ( ) + 31 ) / 32 ; <nl> - if ( totalInts > 0 ) { <nl> - printer - > Print ( " \ n " ) ; <nl> - for ( int i = 0 ; i < totalInts ; i + + ) { <nl> - printer - > Print ( " private int $ bit_field_name $ ; \ n " , <nl> - " bit_field_name " , GetBitFieldName ( i ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / Fields and maybe their default values <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - printer - > Print ( " \ n " ) ; <nl> - PrintFieldComment ( printer , descriptor_ - > field ( i ) ) ; <nl> - field_generators_ . get ( descriptor_ - > field ( i ) ) . GenerateMembers ( <nl> - printer , lazy_init ) ; <nl> - } <nl> - <nl> - / / Constructor , with lazy init code if needed <nl> - if ( lazy_init & & field_generators_ . saved_defaults_needed ( ) ) { <nl> - printer - > Print ( <nl> - " \ n " <nl> - " private static volatile boolean _classInitialized ; \ n " <nl> - " \ n " <nl> - " public $ classname $ ( ) { \ n " <nl> - " / / Lazily initializes the field defaults \ n " <nl> - " if ( ! _classInitialized ) { \ n " <nl> - " synchronized ( \ n " <nl> - " com . google . protobuf . nano . InternalNano . LAZY_INIT_LOCK ) { \ n " <nl> - " if ( ! _classInitialized ) { \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - printer - > Indent ( ) ; <nl> - printer - > Indent ( ) ; <nl> - printer - > Indent ( ) ; <nl> - printer - > Indent ( ) ; <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - field_generators_ . get ( descriptor_ - > field ( i ) ) <nl> - . GenerateInitSavedDefaultCode ( printer ) ; <nl> - } <nl> - printer - > Outdent ( ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( <nl> - " _classInitialized = true ; \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - if ( params_ . generate_clear ( ) ) { <nl> - printer - > Print ( " clear ( ) ; \ n " ) ; <nl> - } <nl> - printer - > Print ( " } \ n " ) ; <nl> - } else { <nl> - printer - > Print ( <nl> - " \ n " <nl> - " public $ classname $ ( ) { \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - if ( params_ . generate_clear ( ) ) { <nl> - printer - > Print ( " clear ( ) ; \ n " ) ; <nl> - } else { <nl> - printer - > Indent ( ) ; <nl> - GenerateFieldInitializers ( printer ) ; <nl> - printer - > Outdent ( ) ; <nl> - } <nl> - printer - > Print ( " } \ n " ) ; <nl> - } <nl> - <nl> - / / Other methods in this class <nl> - <nl> - GenerateClear ( printer ) ; <nl> - <nl> - if ( params_ . generate_clone ( ) ) { <nl> - GenerateClone ( printer ) ; <nl> - } <nl> - <nl> - if ( params_ . generate_equals ( ) ) { <nl> - GenerateEquals ( printer ) ; <nl> - GenerateHashCode ( printer ) ; <nl> - } <nl> - <nl> - GenerateMessageSerializationMethods ( printer ) ; <nl> - GenerateMergeFromMethods ( printer ) ; <nl> - GenerateParseFromMethods ( printer ) ; <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( " } \ n " ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - void MessageGenerator : : <nl> - GenerateMessageSerializationMethods ( io : : Printer * printer ) { <nl> - / / Rely on the parent implementations of writeTo ( ) and getSerializedSize ( ) <nl> - / / if there are no fields to serialize in this message . <nl> - if ( descriptor_ - > field_count ( ) = = 0 ) { <nl> - return ; <nl> - } <nl> - <nl> - std : : unique_ptr < const FieldDescriptor * [ ] > sorted_fields ( <nl> - SortFieldsByNumber ( descriptor_ ) ) ; <nl> - <nl> - printer - > Print ( <nl> - " \ n " <nl> - " @ Override \ n " <nl> - " public void writeTo ( com . google . protobuf . nano . CodedOutputByteBufferNano output ) \ n " <nl> - " throws java . io . IOException { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - / / Output the fields in sorted order <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - GenerateSerializeOneField ( printer , sorted_fields [ i ] ) ; <nl> - } <nl> - <nl> - / / The parent implementation will write any unknown fields if necessary . <nl> - printer - > Print ( <nl> - " super . writeTo ( output ) ; \ n " ) ; <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( " } \ n " ) ; <nl> - <nl> - / / The parent implementation will get the serialized size for unknown <nl> - / / fields if necessary . <nl> - printer - > Print ( <nl> - " \ n " <nl> - " @ Override \ n " <nl> - " protected int computeSerializedSize ( ) { \ n " <nl> - " int size = super . computeSerializedSize ( ) ; \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - field_generators_ . get ( sorted_fields [ i ] ) . GenerateSerializedSizeCode ( printer ) ; <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( <nl> - " return size ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageGenerator : : GenerateMergeFromMethods ( io : : Printer * printer ) { <nl> - std : : unique_ptr < const FieldDescriptor * [ ] > sorted_fields ( <nl> - SortFieldsByNumber ( descriptor_ ) ) ; <nl> - <nl> - printer - > Print ( <nl> - " \ n " <nl> - " @ Override \ n " <nl> - " public $ classname $ mergeFrom ( \ n " <nl> - " com . google . protobuf . nano . CodedInputByteBufferNano input ) \ n " <nl> - " throws java . io . IOException { \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - <nl> - printer - > Indent ( ) ; <nl> - if ( HasMapField ( descriptor_ ) ) { <nl> - printer - > Print ( <nl> - " com . google . protobuf . nano . MapFactories . MapFactory mapFactory = \ n " <nl> - " com . google . protobuf . nano . MapFactories . getMapFactory ( ) ; \ n " ) ; <nl> - } <nl> - <nl> - printer - > Print ( <nl> - " while ( true ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - printer - > Print ( <nl> - " int tag = input . readTag ( ) ; \ n " <nl> - " switch ( tag ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - printer - > Print ( <nl> - " case 0 : \ n " / / zero signals EOF / limit reached <nl> - " return this ; \ n " <nl> - " default : { \ n " ) ; <nl> - <nl> - printer - > Indent ( ) ; <nl> - if ( params_ . store_unknown_fields ( ) ) { <nl> - printer - > Print ( <nl> - " if ( ! storeUnknownField ( input , tag ) ) { \ n " <nl> - " return this ; \ n " <nl> - " } \ n " ) ; <nl> - } else { <nl> - printer - > Print ( <nl> - " if ( ! com . google . protobuf . nano . WireFormatNano . parseUnknownField ( input , tag ) ) { \ n " <nl> - " return this ; \ n " / / it ' s an endgroup tag <nl> - " } \ n " ) ; <nl> - } <nl> - printer - > Print ( " break ; \ n " ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( " } \ n " ) ; <nl> - <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - const FieldDescriptor * field = sorted_fields [ i ] ; <nl> - uint32 tag = WireFormatLite : : MakeTag ( field - > number ( ) , <nl> - WireFormat : : WireTypeForFieldType ( field - > type ( ) ) ) ; <nl> - <nl> - printer - > Print ( <nl> - " case $ tag $ : { \ n " , <nl> - " tag " , SimpleItoa ( tag ) ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - field_generators_ . get ( field ) . GenerateMergingCode ( printer ) ; <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( <nl> - " break ; \ n " <nl> - " } \ n " ) ; <nl> - <nl> - if ( field - > is_packable ( ) ) { <nl> - / / To make packed = true wire compatible , we generate parsing code from a <nl> - / / packed version of this field regardless of field - > options ( ) . packed ( ) . <nl> - uint32 packed_tag = WireFormatLite : : MakeTag ( field - > number ( ) , <nl> - WireFormatLite : : WIRETYPE_LENGTH_DELIMITED ) ; <nl> - printer - > Print ( <nl> - " case $ tag $ : { \ n " , <nl> - " tag " , SimpleItoa ( packed_tag ) ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - field_generators_ . get ( field ) . GenerateMergingCodeFromPacked ( printer ) ; <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( <nl> - " break ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( <nl> - " } \ n " / / switch ( tag ) <nl> - " } \ n " / / while ( true ) <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageGenerator : : <nl> - GenerateParseFromMethods ( io : : Printer * printer ) { <nl> - / / Note : These are separate from GenerateMessageSerializationMethods ( ) <nl> - / / because they need to be generated even for messages that are optimized <nl> - / / for code size . <nl> - printer - > Print ( <nl> - " \ n " <nl> - " public static $ classname $ parseFrom ( byte [ ] data ) \ n " <nl> - " throws com . google . protobuf . nano . InvalidProtocolBufferNanoException { \ n " <nl> - " return com . google . protobuf . nano . MessageNano . mergeFrom ( new $ classname $ ( ) , data ) ; \ n " <nl> - " } \ n " <nl> - " \ n " <nl> - " public static $ classname $ parseFrom ( \ n " <nl> - " com . google . protobuf . nano . CodedInputByteBufferNano input ) \ n " <nl> - " throws java . io . IOException { \ n " <nl> - " return new $ classname $ ( ) . mergeFrom ( input ) ; \ n " <nl> - " } \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - } <nl> - <nl> - void MessageGenerator : : GenerateSerializeOneField ( <nl> - io : : Printer * printer , const FieldDescriptor * field ) { <nl> - field_generators_ . get ( field ) . GenerateSerializationCode ( printer ) ; <nl> - } <nl> - <nl> - void MessageGenerator : : GenerateClear ( io : : Printer * printer ) { <nl> - if ( ! params_ . generate_clear ( ) ) { <nl> - return ; <nl> - } <nl> - printer - > Print ( <nl> - " \ n " <nl> - " public $ classname $ clear ( ) { \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - GenerateFieldInitializers ( printer ) ; <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( <nl> - " return this ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageGenerator : : GenerateFieldInitializers ( io : : Printer * printer ) { <nl> - / / Clear bit fields . <nl> - int totalInts = ( field_generators_ . total_bits ( ) + 31 ) / 32 ; <nl> - for ( int i = 0 ; i < totalInts ; i + + ) { <nl> - printer - > Print ( " $ bit_field_name $ = 0 ; \ n " , <nl> - " bit_field_name " , GetBitFieldName ( i ) ) ; <nl> - } <nl> - <nl> - / / Call clear for all of the fields . <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - const FieldDescriptor * field = descriptor_ - > field ( i ) ; <nl> - field_generators_ . get ( field ) . GenerateClearCode ( printer ) ; <nl> - } <nl> - <nl> - / / Clear oneofs . <nl> - for ( int i = 0 ; i < descriptor_ - > oneof_decl_count ( ) ; i + + ) { <nl> - printer - > Print ( <nl> - " clear $ oneof_capitalized_name $ ( ) ; \ n " , <nl> - " oneof_capitalized_name " , UnderscoresToCapitalizedCamelCase ( <nl> - descriptor_ - > oneof_decl ( i ) ) ) ; <nl> - } <nl> - <nl> - / / Clear unknown fields . <nl> - if ( params_ . store_unknown_fields ( ) ) { <nl> - printer - > Print ( " unknownFieldData = null ; \ n " ) ; <nl> - } <nl> - printer - > Print ( " cachedSize = - 1 ; \ n " ) ; <nl> - } <nl> - <nl> - void MessageGenerator : : GenerateClone ( io : : Printer * printer ) { <nl> - printer - > Print ( <nl> - " @ Override \ n " <nl> - " public $ classname $ clone ( ) { \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - printer - > Print ( <nl> - " $ classname $ cloned ; \ n " <nl> - " try { \ n " <nl> - " cloned = ( $ classname $ ) super . clone ( ) ; \ n " <nl> - " } catch ( java . lang . CloneNotSupportedException e ) { \ n " <nl> - " throw new java . lang . AssertionError ( e ) ; \ n " <nl> - " } \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - field_generators_ . get ( descriptor_ - > field ( i ) ) . GenerateFixClonedCode ( printer ) ; <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( <nl> - " return cloned ; \ n " <nl> - " } \ n " <nl> - " \ n " ) ; <nl> - } <nl> - <nl> - void MessageGenerator : : GenerateEquals ( io : : Printer * printer ) { <nl> - / / Don ' t override if there are no fields . We could generate an <nl> - / / equals method that compares types , but often empty messages <nl> - / / are used as namespaces . <nl> - if ( descriptor_ - > field_count ( ) = = 0 & & ! params_ . store_unknown_fields ( ) ) { <nl> - return ; <nl> - } <nl> - <nl> - printer - > Print ( <nl> - " \ n " <nl> - " @ Override \ n " <nl> - " public boolean equals ( Object o ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - printer - > Print ( <nl> - " if ( o = = this ) { \ n " <nl> - " return true ; \ n " <nl> - " } \ n " <nl> - " if ( ! ( o instanceof $ classname $ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " $ classname $ other = ( $ classname $ ) o ; \ n " , <nl> - " classname " , descriptor_ - > name ( ) ) ; <nl> - <nl> - / / Checking oneof case before checking each oneof field . <nl> - for ( int i = 0 ; i < descriptor_ - > oneof_decl_count ( ) ; i + + ) { <nl> - const OneofDescriptor * oneof_desc = descriptor_ - > oneof_decl ( i ) ; <nl> - printer - > Print ( <nl> - " if ( this . $ oneof_name $ Case_ ! = other . $ oneof_name $ Case_ ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " , <nl> - " oneof_name " , UnderscoresToCamelCase ( oneof_desc ) ) ; <nl> - } <nl> - <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - const FieldDescriptor * field = descriptor_ - > field ( i ) ; <nl> - field_generators_ . get ( field ) . GenerateEqualsCode ( printer ) ; <nl> - } <nl> - <nl> - if ( params_ . store_unknown_fields ( ) ) { <nl> - printer - > Print ( <nl> - " if ( unknownFieldData = = null | | unknownFieldData . isEmpty ( ) ) { \ n " <nl> - " return other . unknownFieldData = = null | | other . unknownFieldData . isEmpty ( ) ; \ n " <nl> - " } else { \ n " <nl> - " return unknownFieldData . equals ( other . unknownFieldData ) ; \ n " <nl> - " } " ) ; <nl> - } else { <nl> - printer - > Print ( <nl> - " return true ; \ n " ) ; <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageGenerator : : GenerateHashCode ( io : : Printer * printer ) { <nl> - if ( descriptor_ - > field_count ( ) = = 0 & & ! params_ . store_unknown_fields ( ) ) { <nl> - return ; <nl> - } <nl> - <nl> - printer - > Print ( <nl> - " \ n " <nl> - " @ Override \ n " <nl> - " public int hashCode ( ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - printer - > Print ( " int result = 17 ; \ n " ) ; <nl> - printer - > Print ( " result = 31 * result + getClass ( ) . getName ( ) . hashCode ( ) ; \ n " ) ; <nl> - for ( int i = 0 ; i < descriptor_ - > field_count ( ) ; i + + ) { <nl> - const FieldDescriptor * field = descriptor_ - > field ( i ) ; <nl> - field_generators_ . get ( field ) . GenerateHashCodeCode ( printer ) ; <nl> - } <nl> - <nl> - if ( params_ . store_unknown_fields ( ) ) { <nl> - printer - > Print ( <nl> - " result = 31 * result + \ n " <nl> - " ( unknownFieldData = = null | | unknownFieldData . isEmpty ( ) ? 0 : \ n " <nl> - " unknownFieldData . hashCode ( ) ) ; \ n " ) ; <nl> - } <nl> - <nl> - printer - > Print ( " return result ; \ n " ) ; <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( " } \ n " ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index 281ec64fdd . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_message . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__ <nl> - <nl> - # include < string > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_field . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_params . h > <nl> - # include < google / protobuf / stubs / common . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace io { <nl> - class Printer ; / / printer . h <nl> - } <nl> - } <nl> - <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class MessageGenerator { <nl> - public : <nl> - explicit MessageGenerator ( const Descriptor * descriptor , const Params & params ) ; <nl> - ~ MessageGenerator ( ) ; <nl> - <nl> - / / All static variables have to be declared at the top - level of the file <nl> - / / so that we can control initialization order , which is important for <nl> - / / DescriptorProto bootstrapping to work . <nl> - void GenerateStaticVariables ( io : : Printer * printer ) ; <nl> - <nl> - / / Output code which initializes the static variables generated by <nl> - / / GenerateStaticVariables ( ) . <nl> - void GenerateStaticVariableInitializers ( io : : Printer * printer ) ; <nl> - <nl> - / / Generate the class itself . <nl> - void Generate ( io : : Printer * printer ) ; <nl> - <nl> - private : <nl> - void GenerateMessageSerializationMethods ( io : : Printer * printer ) ; <nl> - void GenerateMergeFromMethods ( io : : Printer * printer ) ; <nl> - void GenerateParseFromMethods ( io : : Printer * printer ) ; <nl> - void GenerateSerializeOneField ( io : : Printer * printer , <nl> - const FieldDescriptor * field ) ; <nl> - <nl> - void GenerateClear ( io : : Printer * printer ) ; <nl> - void GenerateFieldInitializers ( io : : Printer * printer ) ; <nl> - void GenerateEquals ( io : : Printer * printer ) ; <nl> - void GenerateHashCode ( io : : Printer * printer ) ; <nl> - void GenerateClone ( io : : Printer * printer ) ; <nl> - <nl> - const Params & params_ ; <nl> - const Descriptor * descriptor_ ; <nl> - FieldGeneratorMap field_generators_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( MessageGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__ <nl> deleted file mode 100644 <nl> index 2ed8a3aa66 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_message_field . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_message_field . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / wire_format . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - using internal : : WireFormat ; <nl> - using internal : : WireFormatLite ; <nl> - <nl> - namespace { <nl> - <nl> - / / TODO ( kenton ) : Factor out a " SetCommonFieldVariables ( ) " to get rid of <nl> - / / repeat code between this and the other field types . <nl> - void SetMessageVariables ( const Params & params , <nl> - const FieldDescriptor * descriptor , std : : map < string , string > * variables ) { <nl> - ( * variables ) [ " name " ] = <nl> - RenameJavaKeywords ( UnderscoresToCamelCase ( descriptor ) ) ; <nl> - ( * variables ) [ " capitalized_name " ] = <nl> - RenameJavaKeywords ( UnderscoresToCapitalizedCamelCase ( descriptor ) ) ; <nl> - ( * variables ) [ " number " ] = SimpleItoa ( descriptor - > number ( ) ) ; <nl> - ( * variables ) [ " type " ] = ClassName ( params , descriptor - > message_type ( ) ) ; <nl> - ( * variables ) [ " group_or_message " ] = <nl> - ( descriptor - > type ( ) = = FieldDescriptor : : TYPE_GROUP ) ? <nl> - " Group " : " Message " ; <nl> - ( * variables ) [ " message_name " ] = descriptor - > containing_type ( ) - > name ( ) ; <nl> - / / ( * variables ) [ " message_type " ] = descriptor - > message_type ( ) - > name ( ) ; <nl> - ( * variables ) [ " tag " ] = SimpleItoa ( WireFormat : : MakeTag ( descriptor ) ) ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - MessageFieldGenerator : : <nl> - MessageFieldGenerator ( const FieldDescriptor * descriptor , const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetMessageVariables ( params , descriptor , & variables_ ) ; <nl> - } <nl> - <nl> - MessageFieldGenerator : : ~ MessageFieldGenerator ( ) { } <nl> - <nl> - void MessageFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool / * unused lazy_init * / ) const { <nl> - printer - > Print ( variables_ , <nl> - " public $ type $ $ name $ ; \ n " ) ; <nl> - } <nl> - <nl> - void MessageFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ = null ; \ n " ) ; <nl> - } <nl> - <nl> - void MessageFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ = = null ) { \ n " <nl> - " this . $ name $ = new $ type $ ( ) ; \ n " <nl> - " } \ n " ) ; <nl> - <nl> - if ( descriptor_ - > type ( ) = = FieldDescriptor : : TYPE_GROUP ) { <nl> - printer - > Print ( variables_ , <nl> - " input . readGroup ( this . $ name $ , $ number $ ) ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " input . readMessage ( this . $ name $ ) ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void MessageFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null ) { \ n " <nl> - " output . write $ group_or_message $ ( $ number $ , this . $ name $ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null ) { \ n " <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . compute $ group_or_message $ Size ( $ number $ , this . $ name $ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageFieldGenerator : : <nl> - GenerateFixClonedCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null ) { \ n " <nl> - " cloned . $ name $ = this . $ name $ . clone ( ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ = = null ) { \ n " <nl> - " if ( other . $ name $ ! = null ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " } else { \ n " <nl> - " if ( ! this . $ name $ . equals ( other . $ name $ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + \ n " <nl> - " ( this . $ name $ = = null ? 0 : this . $ name $ . hashCode ( ) ) ; \ n " ) ; <nl> - } <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - MessageOneofFieldGenerator : : MessageOneofFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetMessageVariables ( params , descriptor , & variables_ ) ; <nl> - SetCommonOneofVariables ( descriptor , & variables_ ) ; <nl> - } <nl> - <nl> - MessageOneofFieldGenerator : : ~ MessageOneofFieldGenerator ( ) { } <nl> - <nl> - void MessageOneofFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool / * unused lazy_init * / ) const { <nl> - printer - > Print ( variables_ , <nl> - " public boolean has $ capitalized_name $ ( ) { \ n " <nl> - " return $ has_oneof_case $ ; \ n " <nl> - " } \ n " <nl> - " public $ type $ get $ capitalized_name $ ( ) { \ n " <nl> - " if ( $ has_oneof_case $ ) { \ n " <nl> - " return ( $ type $ ) this . $ oneof_name $ _ ; \ n " <nl> - " } \ n " <nl> - " return null ; \ n " <nl> - " } \ n " <nl> - " public $ message_name $ set $ capitalized_name $ ( $ type $ value ) { \ n " <nl> - " if ( value = = null ) { throw new java . lang . NullPointerException ( ) ; } \ n " <nl> - " $ set_oneof_case $ ; \ n " <nl> - " this . $ oneof_name $ _ = value ; \ n " <nl> - " return this ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageOneofFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - / / No clear method for oneof fields . <nl> - } <nl> - <nl> - void MessageOneofFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( ! ( $ has_oneof_case $ ) ) { \ n " <nl> - " this . $ oneof_name $ _ = new $ type $ ( ) ; \ n " <nl> - " } \ n " <nl> - " input . readMessage ( \ n " <nl> - " ( com . google . protobuf . nano . MessageNano ) this . $ oneof_name $ _ ) ; \ n " <nl> - " $ set_oneof_case $ ; \ n " ) ; <nl> - } <nl> - <nl> - void MessageOneofFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ has_oneof_case $ ) { \ n " <nl> - " output . writeMessage ( $ number $ , \ n " <nl> - " ( com . google . protobuf . nano . MessageNano ) this . $ oneof_name $ _ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageOneofFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ has_oneof_case $ ) { \ n " <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . computeMessageSize ( $ number $ , \ n " <nl> - " ( com . google . protobuf . nano . MessageNano ) this . $ oneof_name $ _ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageOneofFieldGenerator : : <nl> - GenerateFixClonedCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ oneof_name $ ! = null ) { \ n " <nl> - " cloned . $ oneof_name $ = this . $ oneof_name $ . clone ( ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void MessageOneofFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - GenerateOneofFieldEquals ( descriptor_ , variables_ , printer ) ; <nl> - } <nl> - <nl> - void MessageOneofFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - GenerateOneofFieldHashCode ( descriptor_ , variables_ , printer ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - RepeatedMessageFieldGenerator : : RepeatedMessageFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetMessageVariables ( params , descriptor , & variables_ ) ; <nl> - } <nl> - <nl> - RepeatedMessageFieldGenerator : : ~ RepeatedMessageFieldGenerator ( ) { } <nl> - <nl> - void RepeatedMessageFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool / * unused lazy_init * / ) const { <nl> - printer - > Print ( variables_ , <nl> - " public $ type $ [ ] $ name $ ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedMessageFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ = $ type $ . emptyArray ( ) ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedMessageFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - / / First , figure out the length of the array , then parse . <nl> - printer - > Print ( variables_ , <nl> - " int arrayLength = com . google . protobuf . nano . WireFormatNano \ n " <nl> - " . getRepeatedFieldArrayLength ( input , $ tag $ ) ; \ n " <nl> - " int i = this . $ name $ = = null ? 0 : this . $ name $ . length ; \ n " <nl> - " $ type $ [ ] newArray = \ n " <nl> - " new $ type $ [ i + arrayLength ] ; \ n " <nl> - " if ( i ! = 0 ) { \ n " <nl> - " java . lang . System . arraycopy ( this . $ name $ , 0 , newArray , 0 , i ) ; \ n " <nl> - " } \ n " <nl> - " for ( ; i < newArray . length - 1 ; i + + ) { \ n " <nl> - " newArray [ i ] = new $ type $ ( ) ; \ n " ) ; <nl> - <nl> - if ( descriptor_ - > type ( ) = = FieldDescriptor : : TYPE_GROUP ) { <nl> - printer - > Print ( variables_ , <nl> - " input . readGroup ( newArray [ i ] , $ number $ ) ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " input . readMessage ( newArray [ i ] ) ; \ n " ) ; <nl> - } <nl> - <nl> - printer - > Print ( variables_ , <nl> - " input . readTag ( ) ; \ n " <nl> - " } \ n " <nl> - " / / Last one without readTag . \ n " <nl> - " newArray [ i ] = new $ type $ ( ) ; \ n " ) ; <nl> - <nl> - if ( descriptor_ - > type ( ) = = FieldDescriptor : : TYPE_GROUP ) { <nl> - printer - > Print ( variables_ , <nl> - " input . readGroup ( newArray [ i ] , $ number $ ) ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " input . readMessage ( newArray [ i ] ) ; \ n " ) ; <nl> - } <nl> - <nl> - printer - > Print ( variables_ , <nl> - " this . $ name $ = newArray ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedMessageFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " $ type $ element = this . $ name $ [ i ] ; \ n " <nl> - " if ( element ! = null ) { \ n " <nl> - " output . write $ group_or_message $ ( $ number $ , element ) ; \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedMessageFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " $ type $ element = this . $ name $ [ i ] ; \ n " <nl> - " if ( element ! = null ) { \ n " <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . compute $ group_or_message $ Size ( $ number $ , element ) ; \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedMessageFieldGenerator : : <nl> - GenerateFixClonedCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " <nl> - " cloned . $ name $ = new $ type $ [ this . $ name $ . length ] ; \ n " <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " if ( this . $ name $ [ i ] ! = null ) { \ n " <nl> - " cloned . $ name $ [ i ] = this . $ name $ [ i ] . clone ( ) ; \ n " <nl> - " } \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedMessageFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( ! com . google . protobuf . nano . InternalNano . equals ( \ n " <nl> - " this . $ name $ , other . $ name $ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedMessageFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result \ n " <nl> - " + com . google . protobuf . nano . InternalNano . hashCode ( this . $ name $ ) ; \ n " ) ; <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index 0ae8879ba2 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_message_field . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__ <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - # include < google / protobuf / compiler / javanano / javanano_field . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class MessageFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit MessageFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) ; <nl> - ~ MessageFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - void GenerateFixClonedCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( MessageFieldGenerator ) ; <nl> - } ; <nl> - <nl> - class MessageOneofFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit MessageOneofFieldGenerator ( const FieldDescriptor * descriptor , <nl> - const Params & params ) ; <nl> - ~ MessageOneofFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - void GenerateFixClonedCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( MessageOneofFieldGenerator ) ; <nl> - } ; <nl> - <nl> - class RepeatedMessageFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit RepeatedMessageFieldGenerator ( const FieldDescriptor * descriptor , <nl> - const Params & params ) ; <nl> - ~ RepeatedMessageFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - void GenerateFixClonedCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( RepeatedMessageFieldGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__ <nl> deleted file mode 100644 <nl> index 3594767d67 . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_params . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2010 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : wink @ google . com ( Wink Saville ) <nl> - <nl> - # ifndef PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_ <nl> - # define PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_ <nl> - <nl> - # include < map > <nl> - # include < set > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - enum eMultipleFiles { JAVANANO_MUL_UNSET , JAVANANO_MUL_FALSE , JAVANANO_MUL_TRUE } ; <nl> - <nl> - / / Parameters for used by the generators <nl> - class Params { <nl> - public : <nl> - typedef std : : map < string , string > NameMap ; <nl> - typedef std : : set < string > NameSet ; <nl> - private : <nl> - string empty_ ; <nl> - string base_name_ ; <nl> - eMultipleFiles override_java_multiple_files_ ; <nl> - bool store_unknown_fields_ ; <nl> - NameMap java_packages_ ; <nl> - NameMap java_outer_classnames_ ; <nl> - NameSet java_multiple_files_ ; <nl> - bool generate_has_ ; <nl> - bool java_enum_style_ ; <nl> - bool optional_field_accessors_ ; <nl> - bool use_reference_types_for_primitives_ ; <nl> - bool generate_equals_ ; <nl> - bool ignore_services_ ; <nl> - bool parcelable_messages_ ; <nl> - bool reftypes_primitive_enums_ ; <nl> - bool generate_clear_ ; <nl> - bool generate_clone_ ; <nl> - bool generate_intdefs_ ; <nl> - <nl> - public : <nl> - Params ( const string & base_name ) : <nl> - empty_ ( " " ) , <nl> - base_name_ ( base_name ) , <nl> - override_java_multiple_files_ ( JAVANANO_MUL_UNSET ) , <nl> - store_unknown_fields_ ( false ) , <nl> - generate_has_ ( false ) , <nl> - java_enum_style_ ( false ) , <nl> - optional_field_accessors_ ( false ) , <nl> - use_reference_types_for_primitives_ ( false ) , <nl> - generate_equals_ ( false ) , <nl> - ignore_services_ ( false ) , <nl> - parcelable_messages_ ( false ) , <nl> - reftypes_primitive_enums_ ( false ) , <nl> - generate_clear_ ( true ) , <nl> - generate_clone_ ( false ) , <nl> - generate_intdefs_ ( false ) { <nl> - } <nl> - <nl> - const string & base_name ( ) const { <nl> - return base_name_ ; <nl> - } <nl> - <nl> - bool has_java_package ( const string & file_name ) const { <nl> - return java_packages_ . find ( file_name ) <nl> - ! = java_packages_ . end ( ) ; <nl> - } <nl> - void set_java_package ( const string & file_name , <nl> - const string & java_package ) { <nl> - java_packages_ [ file_name ] = java_package ; <nl> - } <nl> - const string & java_package ( const string & file_name ) const { <nl> - NameMap : : const_iterator itr ; <nl> - <nl> - itr = java_packages_ . find ( file_name ) ; <nl> - if ( itr = = java_packages_ . end ( ) ) { <nl> - return empty_ ; <nl> - } else { <nl> - return itr - > second ; <nl> - } <nl> - } <nl> - const NameMap & java_packages ( ) { <nl> - return java_packages_ ; <nl> - } <nl> - <nl> - bool has_java_outer_classname ( const string & file_name ) const { <nl> - return java_outer_classnames_ . find ( file_name ) <nl> - ! = java_outer_classnames_ . end ( ) ; <nl> - } <nl> - void set_java_outer_classname ( const string & file_name , <nl> - const string & java_outer_classname ) { <nl> - java_outer_classnames_ [ file_name ] = java_outer_classname ; <nl> - } <nl> - const string & java_outer_classname ( const string & file_name ) const { <nl> - NameMap : : const_iterator itr ; <nl> - <nl> - itr = java_outer_classnames_ . find ( file_name ) ; <nl> - if ( itr = = java_outer_classnames_ . end ( ) ) { <nl> - return empty_ ; <nl> - } else { <nl> - return itr - > second ; <nl> - } <nl> - } <nl> - const NameMap & java_outer_classnames ( ) { <nl> - return java_outer_classnames_ ; <nl> - } <nl> - <nl> - void set_override_java_multiple_files ( bool java_multiple_files ) { <nl> - if ( java_multiple_files ) { <nl> - override_java_multiple_files_ = JAVANANO_MUL_TRUE ; <nl> - } else { <nl> - override_java_multiple_files_ = JAVANANO_MUL_FALSE ; <nl> - } <nl> - } <nl> - void clear_override_java_multiple_files ( ) { <nl> - override_java_multiple_files_ = JAVANANO_MUL_UNSET ; <nl> - } <nl> - <nl> - void set_java_multiple_files ( const string & file_name , bool value ) { <nl> - if ( value ) { <nl> - java_multiple_files_ . insert ( file_name ) ; <nl> - } else { <nl> - java_multiple_files_ . erase ( file_name ) ; <nl> - } <nl> - } <nl> - bool java_multiple_files ( const string & file_name ) const { <nl> - switch ( override_java_multiple_files_ ) { <nl> - case JAVANANO_MUL_FALSE : <nl> - return false ; <nl> - case JAVANANO_MUL_TRUE : <nl> - return true ; <nl> - default : <nl> - return java_multiple_files_ . find ( file_name ) <nl> - ! = java_multiple_files_ . end ( ) ; <nl> - } <nl> - } <nl> - <nl> - void set_store_unknown_fields ( bool value ) { <nl> - store_unknown_fields_ = value ; <nl> - } <nl> - bool store_unknown_fields ( ) const { <nl> - return store_unknown_fields_ ; <nl> - } <nl> - <nl> - void set_generate_has ( bool value ) { <nl> - generate_has_ = value ; <nl> - } <nl> - bool generate_has ( ) const { <nl> - return generate_has_ ; <nl> - } <nl> - <nl> - void set_java_enum_style ( bool value ) { <nl> - java_enum_style_ = value ; <nl> - } <nl> - bool java_enum_style ( ) const { <nl> - return java_enum_style_ ; <nl> - } <nl> - <nl> - void set_optional_field_accessors ( bool value ) { <nl> - optional_field_accessors_ = value ; <nl> - } <nl> - bool optional_field_accessors ( ) const { <nl> - return optional_field_accessors_ ; <nl> - } <nl> - <nl> - void set_use_reference_types_for_primitives ( bool value ) { <nl> - use_reference_types_for_primitives_ = value ; <nl> - } <nl> - bool use_reference_types_for_primitives ( ) const { <nl> - return use_reference_types_for_primitives_ ; <nl> - } <nl> - <nl> - void set_generate_equals ( bool value ) { <nl> - generate_equals_ = value ; <nl> - } <nl> - bool generate_equals ( ) const { <nl> - return generate_equals_ ; <nl> - } <nl> - <nl> - void set_ignore_services ( bool value ) { <nl> - ignore_services_ = value ; <nl> - } <nl> - bool ignore_services ( ) const { <nl> - return ignore_services_ ; <nl> - } <nl> - <nl> - void set_parcelable_messages ( bool value ) { <nl> - parcelable_messages_ = value ; <nl> - } <nl> - bool parcelable_messages ( ) const { <nl> - return parcelable_messages_ ; <nl> - } <nl> - <nl> - void set_reftypes_primitive_enums ( bool value ) { <nl> - reftypes_primitive_enums_ = value ; <nl> - } <nl> - bool reftypes_primitive_enums ( ) const { <nl> - return reftypes_primitive_enums_ ; <nl> - } <nl> - <nl> - void set_generate_clear ( bool value ) { <nl> - generate_clear_ = value ; <nl> - } <nl> - bool generate_clear ( ) const { <nl> - return generate_clear_ ; <nl> - } <nl> - <nl> - void set_generate_clone ( bool value ) { <nl> - generate_clone_ = value ; <nl> - } <nl> - bool generate_clone ( ) const { <nl> - return generate_clone_ ; <nl> - } <nl> - <nl> - void set_generate_intdefs ( bool value ) { <nl> - generate_intdefs_ = value ; <nl> - } <nl> - bool generate_intdefs ( ) const { <nl> - return generate_intdefs_ ; <nl> - } <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> - # endif / / PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_ <nl> deleted file mode 100644 <nl> index 66a0ff057c . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_primitive_field . cc <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # include < map > <nl> - # include < math . h > <nl> - # include < string > <nl> - <nl> - # include < google / protobuf / compiler / javanano / javanano_primitive_field . h > <nl> - # include < google / protobuf / stubs / common . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_helpers . h > <nl> - # include < google / protobuf / io / printer . h > <nl> - # include < google / protobuf / wire_format . h > <nl> - # include < google / protobuf / stubs / strutil . h > <nl> - # include < google / protobuf / stubs / substitute . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - using internal : : WireFormat ; <nl> - using internal : : WireFormatLite ; <nl> - <nl> - namespace { <nl> - <nl> - bool IsReferenceType ( JavaType type ) { <nl> - switch ( type ) { <nl> - case JAVATYPE_INT : return false ; <nl> - case JAVATYPE_LONG : return false ; <nl> - case JAVATYPE_FLOAT : return false ; <nl> - case JAVATYPE_DOUBLE : return false ; <nl> - case JAVATYPE_BOOLEAN : return false ; <nl> - case JAVATYPE_STRING : return true ; <nl> - case JAVATYPE_BYTES : return true ; <nl> - case JAVATYPE_ENUM : return false ; <nl> - case JAVATYPE_MESSAGE : return true ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / JavaTypes are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return false ; <nl> - } <nl> - <nl> - bool IsArrayType ( JavaType type ) { <nl> - switch ( type ) { <nl> - case JAVATYPE_INT : return false ; <nl> - case JAVATYPE_LONG : return false ; <nl> - case JAVATYPE_FLOAT : return false ; <nl> - case JAVATYPE_DOUBLE : return false ; <nl> - case JAVATYPE_BOOLEAN : return false ; <nl> - case JAVATYPE_STRING : return false ; <nl> - case JAVATYPE_BYTES : return true ; <nl> - case JAVATYPE_ENUM : return false ; <nl> - case JAVATYPE_MESSAGE : return false ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / JavaTypes are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return false ; <nl> - } <nl> - <nl> - const char * GetCapitalizedType ( const FieldDescriptor * field ) { <nl> - switch ( field - > type ( ) ) { <nl> - case FieldDescriptor : : TYPE_INT32 : return " Int32 " ; <nl> - case FieldDescriptor : : TYPE_UINT32 : return " UInt32 " ; <nl> - case FieldDescriptor : : TYPE_SINT32 : return " SInt32 " ; <nl> - case FieldDescriptor : : TYPE_FIXED32 : return " Fixed32 " ; <nl> - case FieldDescriptor : : TYPE_SFIXED32 : return " SFixed32 " ; <nl> - case FieldDescriptor : : TYPE_INT64 : return " Int64 " ; <nl> - case FieldDescriptor : : TYPE_UINT64 : return " UInt64 " ; <nl> - case FieldDescriptor : : TYPE_SINT64 : return " SInt64 " ; <nl> - case FieldDescriptor : : TYPE_FIXED64 : return " Fixed64 " ; <nl> - case FieldDescriptor : : TYPE_SFIXED64 : return " SFixed64 " ; <nl> - case FieldDescriptor : : TYPE_FLOAT : return " Float " ; <nl> - case FieldDescriptor : : TYPE_DOUBLE : return " Double " ; <nl> - case FieldDescriptor : : TYPE_BOOL : return " Bool " ; <nl> - case FieldDescriptor : : TYPE_STRING : return " String " ; <nl> - case FieldDescriptor : : TYPE_BYTES : return " Bytes " ; <nl> - case FieldDescriptor : : TYPE_ENUM : return " Enum " ; <nl> - case FieldDescriptor : : TYPE_GROUP : return " Group " ; <nl> - case FieldDescriptor : : TYPE_MESSAGE : return " Message " ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / types are added . <nl> - } <nl> - <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return NULL ; <nl> - } <nl> - <nl> - / / For encodings with fixed sizes , returns that size in bytes . Otherwise <nl> - / / returns - 1 . <nl> - int FixedSize ( FieldDescriptor : : Type type ) { <nl> - switch ( type ) { <nl> - case FieldDescriptor : : TYPE_INT32 : return - 1 ; <nl> - case FieldDescriptor : : TYPE_INT64 : return - 1 ; <nl> - case FieldDescriptor : : TYPE_UINT32 : return - 1 ; <nl> - case FieldDescriptor : : TYPE_UINT64 : return - 1 ; <nl> - case FieldDescriptor : : TYPE_SINT32 : return - 1 ; <nl> - case FieldDescriptor : : TYPE_SINT64 : return - 1 ; <nl> - case FieldDescriptor : : TYPE_FIXED32 : return WireFormatLite : : kFixed32Size ; <nl> - case FieldDescriptor : : TYPE_FIXED64 : return WireFormatLite : : kFixed64Size ; <nl> - case FieldDescriptor : : TYPE_SFIXED32 : return WireFormatLite : : kSFixed32Size ; <nl> - case FieldDescriptor : : TYPE_SFIXED64 : return WireFormatLite : : kSFixed64Size ; <nl> - case FieldDescriptor : : TYPE_FLOAT : return WireFormatLite : : kFloatSize ; <nl> - case FieldDescriptor : : TYPE_DOUBLE : return WireFormatLite : : kDoubleSize ; <nl> - <nl> - case FieldDescriptor : : TYPE_BOOL : return WireFormatLite : : kBoolSize ; <nl> - case FieldDescriptor : : TYPE_ENUM : return - 1 ; <nl> - <nl> - case FieldDescriptor : : TYPE_STRING : return - 1 ; <nl> - case FieldDescriptor : : TYPE_BYTES : return - 1 ; <nl> - case FieldDescriptor : : TYPE_GROUP : return - 1 ; <nl> - case FieldDescriptor : : TYPE_MESSAGE : return - 1 ; <nl> - <nl> - / / No default because we want the compiler to complain if any new <nl> - / / types are added . <nl> - } <nl> - GOOGLE_LOG ( FATAL ) < < " Can ' t get here . " ; <nl> - return - 1 ; <nl> - } <nl> - <nl> - bool AllAscii ( const string & text ) { <nl> - for ( int i = 0 ; i < text . size ( ) ; i + + ) { <nl> - if ( ( text [ i ] & 0x80 ) ! = 0 ) { <nl> - return false ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - void SetPrimitiveVariables ( const FieldDescriptor * descriptor , const Params params , <nl> - std : : map < string , string > * variables ) { <nl> - ( * variables ) [ " name " ] = <nl> - RenameJavaKeywords ( UnderscoresToCamelCase ( descriptor ) ) ; <nl> - ( * variables ) [ " capitalized_name " ] = <nl> - RenameJavaKeywords ( UnderscoresToCapitalizedCamelCase ( descriptor ) ) ; <nl> - ( * variables ) [ " number " ] = SimpleItoa ( descriptor - > number ( ) ) ; <nl> - if ( params . use_reference_types_for_primitives ( ) <nl> - & & ! descriptor - > is_repeated ( ) ) { <nl> - ( * variables ) [ " type " ] = BoxedPrimitiveTypeName ( GetJavaType ( descriptor ) ) ; <nl> - } else { <nl> - ( * variables ) [ " type " ] = PrimitiveTypeName ( GetJavaType ( descriptor ) ) ; <nl> - } <nl> - / / Deals with defaults . For C + + - string types ( string and bytes ) , <nl> - / / we might need to have the generated code do the unicode decoding <nl> - / / ( see comments in InternalNano . java for gory details . ) . We would <nl> - / / like to do this once into a static field and re - use that from <nl> - / / then on . <nl> - if ( descriptor - > cpp_type ( ) = = FieldDescriptor : : CPPTYPE_STRING & & <nl> - ! descriptor - > default_value_string ( ) . empty ( ) & & <nl> - ! params . use_reference_types_for_primitives ( ) ) { <nl> - if ( descriptor - > type ( ) = = FieldDescriptor : : TYPE_BYTES ) { <nl> - ( * variables ) [ " default " ] = DefaultValue ( params , descriptor ) ; <nl> - ( * variables ) [ " default_constant " ] = FieldDefaultConstantName ( descriptor ) ; <nl> - ( * variables ) [ " default_constant_value " ] = strings : : Substitute ( <nl> - " com . google . protobuf . nano . InternalNano . bytesDefaultValue ( \ " $ 0 \ " ) " , <nl> - CEscape ( descriptor - > default_value_string ( ) ) ) ; <nl> - ( * variables ) [ " default_copy_if_needed " ] = <nl> - ( * variables ) [ " default " ] + " . clone ( ) " ; <nl> - } else if ( AllAscii ( descriptor - > default_value_string ( ) ) ) { <nl> - / / All chars are ASCII . In this case directly referencing a <nl> - / / CEscape ( ) ' d string literal works fine . <nl> - ( * variables ) [ " default " ] = <nl> - " \ " " + CEscape ( descriptor - > default_value_string ( ) ) + " \ " " ; <nl> - ( * variables ) [ " default_copy_if_needed " ] = ( * variables ) [ " default " ] ; <nl> - } else { <nl> - / / Strings where some chars are non - ASCII . We need to save the <nl> - / / default value . <nl> - ( * variables ) [ " default " ] = DefaultValue ( params , descriptor ) ; <nl> - ( * variables ) [ " default_constant " ] = FieldDefaultConstantName ( descriptor ) ; <nl> - ( * variables ) [ " default_constant_value " ] = strings : : Substitute ( <nl> - " com . google . protobuf . nano . InternalNano . stringDefaultValue ( \ " $ 0 \ " ) " , <nl> - CEscape ( descriptor - > default_value_string ( ) ) ) ; <nl> - ( * variables ) [ " default_copy_if_needed " ] = ( * variables ) [ " default " ] ; <nl> - } <nl> - } else { <nl> - / / Non - string , non - bytes field . Defaults are literals . <nl> - ( * variables ) [ " default " ] = DefaultValue ( params , descriptor ) ; <nl> - ( * variables ) [ " default_copy_if_needed " ] = ( * variables ) [ " default " ] ; <nl> - } <nl> - ( * variables ) [ " boxed_type " ] = BoxedPrimitiveTypeName ( GetJavaType ( descriptor ) ) ; <nl> - ( * variables ) [ " capitalized_type " ] = GetCapitalizedType ( descriptor ) ; <nl> - ( * variables ) [ " tag " ] = SimpleItoa ( WireFormat : : MakeTag ( descriptor ) ) ; <nl> - ( * variables ) [ " tag_size " ] = SimpleItoa ( <nl> - WireFormat : : TagSize ( descriptor - > number ( ) , descriptor - > type ( ) ) ) ; <nl> - ( * variables ) [ " non_packed_tag " ] = SimpleItoa ( <nl> - internal : : WireFormatLite : : MakeTag ( descriptor - > number ( ) , <nl> - internal : : WireFormat : : WireTypeForFieldType ( descriptor - > type ( ) ) ) ) ; <nl> - int fixed_size = FixedSize ( descriptor - > type ( ) ) ; <nl> - if ( fixed_size ! = - 1 ) { <nl> - ( * variables ) [ " fixed_size " ] = SimpleItoa ( fixed_size ) ; <nl> - } <nl> - ( * variables ) [ " message_name " ] = descriptor - > containing_type ( ) - > name ( ) ; <nl> - ( * variables ) [ " empty_array_name " ] = EmptyArrayName ( params , descriptor ) ; <nl> - } <nl> - } / / namespace <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - PrimitiveFieldGenerator : : <nl> - PrimitiveFieldGenerator ( const FieldDescriptor * descriptor , const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetPrimitiveVariables ( descriptor , params , & variables_ ) ; <nl> - } <nl> - <nl> - PrimitiveFieldGenerator : : ~ PrimitiveFieldGenerator ( ) { } <nl> - <nl> - bool PrimitiveFieldGenerator : : SavedDefaultNeeded ( ) const { <nl> - return variables_ . find ( " default_constant " ) ! = variables_ . end ( ) ; <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : GenerateInitSavedDefaultCode ( io : : Printer * printer ) const { <nl> - if ( variables_ . find ( " default_constant " ) ! = variables_ . end ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " $ default_constant $ = $ default_constant_value $ ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool lazy_init ) const { <nl> - if ( variables_ . find ( " default_constant " ) ! = variables_ . end ( ) ) { <nl> - / / Those primitive types that need a saved default . <nl> - if ( lazy_init ) { <nl> - printer - > Print ( variables_ , <nl> - " private static $ type $ $ default_constant $ ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " private static final $ type $ $ default_constant $ = \ n " <nl> - " $ default_constant_value $ ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - printer - > Print ( variables_ , <nl> - " public $ type $ $ name $ ; \ n " ) ; <nl> - <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " public boolean has $ capitalized_name $ ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ = $ default_copy_if_needed $ ; \ n " ) ; <nl> - <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " has $ capitalized_name $ = false ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " this . $ name $ = input . read $ capitalized_type $ ( ) ; \ n " ) ; <nl> - <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " has $ capitalized_name $ = true ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : <nl> - GenerateSerializationConditional ( io : : Printer * printer ) const { <nl> - if ( params_ . use_reference_types_for_primitives ( ) ) { <nl> - / / For reference type mode , serialize based on equality <nl> - / / to null . <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null ) { \ n " ) ; <nl> - return ; <nl> - } <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " if ( has $ capitalized_name $ | | " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " if ( " ) ; <nl> - } <nl> - JavaType java_type = GetJavaType ( descriptor_ ) ; <nl> - if ( IsArrayType ( java_type ) ) { <nl> - printer - > Print ( variables_ , <nl> - " ! java . util . Arrays . equals ( this . $ name $ , $ default $ ) ) { \ n " ) ; <nl> - } else if ( IsReferenceType ( java_type ) ) { <nl> - printer - > Print ( variables_ , <nl> - " ! this . $ name $ . equals ( $ default $ ) ) { \ n " ) ; <nl> - } else if ( java_type = = JAVATYPE_FLOAT ) { <nl> - printer - > Print ( variables_ , <nl> - " java . lang . Float . floatToIntBits ( this . $ name $ ) \ n " <nl> - " ! = java . lang . Float . floatToIntBits ( $ default $ ) ) { \ n " ) ; <nl> - } else if ( java_type = = JAVATYPE_DOUBLE ) { <nl> - printer - > Print ( variables_ , <nl> - " java . lang . Double . doubleToLongBits ( this . $ name $ ) \ n " <nl> - " ! = java . lang . Double . doubleToLongBits ( $ default $ ) ) { \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " this . $ name $ ! = $ default $ ) { \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - if ( descriptor_ - > is_required ( ) & & ! params_ . generate_has ( ) ) { <nl> - / / Always serialize a required field if we don ' t have the ' has ' signal . <nl> - printer - > Print ( variables_ , <nl> - " output . write $ capitalized_type $ ( $ number $ , this . $ name $ ) ; \ n " ) ; <nl> - } else { <nl> - GenerateSerializationConditional ( printer ) ; <nl> - printer - > Print ( variables_ , <nl> - " output . write $ capitalized_type $ ( $ number $ , this . $ name $ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - if ( descriptor_ - > is_required ( ) & & ! params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . compute $ capitalized_type $ Size ( $ number $ , this . $ name $ ) ; \ n " ) ; <nl> - } else { <nl> - GenerateSerializationConditional ( printer ) ; <nl> - printer - > Print ( variables_ , <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . compute $ capitalized_type $ Size ( $ number $ , this . $ name $ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateFixClonedCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " <nl> - " cloned . $ name $ = this . $ name $ . clone ( ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - / / We define equality as serialized form equality . If generate_has ( ) , <nl> - / / then if the field value equals the default value in both messages , <nl> - / / but one ' s ' has ' field is set and the other ' s is not , the serialized <nl> - / / forms are different and we should return false . <nl> - JavaType java_type = GetJavaType ( descriptor_ ) ; <nl> - if ( java_type = = JAVATYPE_BYTES ) { <nl> - printer - > Print ( variables_ , <nl> - " if ( ! java . util . Arrays . equals ( this . $ name $ , other . $ name $ ) " ) ; <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " \ n " <nl> - " | | ( java . util . Arrays . equals ( this . $ name $ , $ default $ ) \ n " <nl> - " & & this . has $ capitalized_name $ ! = other . has $ capitalized_name $ ) " ) ; <nl> - } <nl> - printer - > Print ( " ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } else if ( java_type = = JAVATYPE_STRING <nl> - | | params_ . use_reference_types_for_primitives ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ = = null ) { \ n " <nl> - " if ( other . $ name $ ! = null ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " } else if ( ! this . $ name $ . equals ( other . $ name $ ) " ) ; <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " \ n " <nl> - " | | ( this . $ name $ . equals ( $ default $ ) \ n " <nl> - " & & this . has $ capitalized_name $ ! = other . has $ capitalized_name $ ) " ) ; <nl> - } <nl> - printer - > Print ( " ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } else if ( java_type = = JAVATYPE_FLOAT ) { <nl> - printer - > Print ( variables_ , <nl> - " { \ n " <nl> - " int bits = java . lang . Float . floatToIntBits ( this . $ name $ ) ; \ n " <nl> - " if ( bits ! = java . lang . Float . floatToIntBits ( other . $ name $ ) " ) ; <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " \ n " <nl> - " | | ( bits = = java . lang . Float . floatToIntBits ( $ default $ ) \ n " <nl> - " & & this . has $ capitalized_name $ ! = other . has $ capitalized_name $ ) " ) ; <nl> - } <nl> - printer - > Print ( " ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } else if ( java_type = = JAVATYPE_DOUBLE ) { <nl> - printer - > Print ( variables_ , <nl> - " { \ n " <nl> - " long bits = java . lang . Double . doubleToLongBits ( this . $ name $ ) ; \ n " <nl> - " if ( bits ! = java . lang . Double . doubleToLongBits ( other . $ name $ ) " ) ; <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " \ n " <nl> - " | | ( bits = = java . lang . Double . doubleToLongBits ( $ default $ ) \ n " <nl> - " & & this . has $ capitalized_name $ ! = other . has $ capitalized_name $ ) " ) ; <nl> - } <nl> - printer - > Print ( " ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = other . $ name $ " ) ; <nl> - if ( params_ . generate_has ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " \ n " <nl> - " | | ( this . $ name $ = = $ default $ \ n " <nl> - " & & this . has $ capitalized_name $ ! = other . has $ capitalized_name $ ) " ) ; <nl> - } <nl> - printer - > Print ( " ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void PrimitiveFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - JavaType java_type = GetJavaType ( descriptor_ ) ; <nl> - if ( java_type = = JAVATYPE_BYTES ) { <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + java . util . Arrays . hashCode ( this . $ name $ ) ; \ n " ) ; <nl> - } else if ( java_type = = JAVATYPE_STRING <nl> - | | params_ . use_reference_types_for_primitives ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result \ n " <nl> - " + ( this . $ name $ = = null ? 0 : this . $ name $ . hashCode ( ) ) ; \ n " ) ; <nl> - } else { <nl> - switch ( java_type ) { <nl> - / / For all Java primitive types below , the hash codes match the <nl> - / / results of BoxedType . valueOf ( primitiveValue ) . hashCode ( ) . <nl> - case JAVATYPE_INT : <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + this . $ name $ ; \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_LONG : <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result \ n " <nl> - " + ( int ) ( this . $ name $ ^ ( this . $ name $ > > > 32 ) ) ; \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_FLOAT : <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result \ n " <nl> - " + java . lang . Float . floatToIntBits ( this . $ name $ ) ; \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_DOUBLE : <nl> - printer - > Print ( variables_ , <nl> - " { \ n " <nl> - " long v = java . lang . Double . doubleToLongBits ( this . $ name $ ) ; \ n " <nl> - " result = 31 * result + ( int ) ( v ^ ( v > > > 32 ) ) ; \ n " <nl> - " } \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_BOOLEAN : <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + ( this . $ name $ ? 1231 : 1237 ) ; \ n " ) ; <nl> - break ; <nl> - default : <nl> - GOOGLE_LOG ( ERROR ) < < " unknown java type for primitive field " ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - AccessorPrimitiveFieldGenerator : : <nl> - AccessorPrimitiveFieldGenerator ( const FieldDescriptor * descriptor , <nl> - const Params & params , int has_bit_index ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetPrimitiveVariables ( descriptor , params , & variables_ ) ; <nl> - SetBitOperationVariables ( " has " , has_bit_index , & variables_ ) ; <nl> - } <nl> - <nl> - AccessorPrimitiveFieldGenerator : : ~ AccessorPrimitiveFieldGenerator ( ) { } <nl> - <nl> - bool AccessorPrimitiveFieldGenerator : : SavedDefaultNeeded ( ) const { <nl> - return variables_ . find ( " default_constant " ) ! = variables_ . end ( ) ; <nl> - } <nl> - <nl> - void AccessorPrimitiveFieldGenerator : : <nl> - GenerateInitSavedDefaultCode ( io : : Printer * printer ) const { <nl> - if ( variables_ . find ( " default_constant " ) ! = variables_ . end ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " $ default_constant $ = $ default_constant_value $ ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void AccessorPrimitiveFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool lazy_init ) const { <nl> - if ( variables_ . find ( " default_constant " ) ! = variables_ . end ( ) ) { <nl> - / / Those primitive types that need a saved default . <nl> - if ( lazy_init ) { <nl> - printer - > Print ( variables_ , <nl> - " private static $ type $ $ default_constant $ ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " private static final $ type $ $ default_constant $ = \ n " <nl> - " $ default_constant_value $ ; \ n " ) ; <nl> - } <nl> - } <nl> - printer - > Print ( variables_ , <nl> - " private $ type $ $ name $ _ ; \ n " <nl> - " public $ type $ get $ capitalized_name $ ( ) { \ n " <nl> - " return $ name $ _ ; \ n " <nl> - " } \ n " <nl> - " public $ message_name $ set $ capitalized_name $ ( $ type $ value ) { \ n " ) ; <nl> - if ( IsReferenceType ( GetJavaType ( descriptor_ ) ) ) { <nl> - printer - > Print ( variables_ , <nl> - " if ( value = = null ) { \ n " <nl> - " throw new java . lang . NullPointerException ( ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - printer - > Print ( variables_ , <nl> - " $ name $ _ = value ; \ n " <nl> - " $ set_has $ ; \ n " <nl> - " return this ; \ n " <nl> - " } \ n " <nl> - " public boolean has $ capitalized_name $ ( ) { \ n " <nl> - " return $ get_has $ ; \ n " <nl> - " } \ n " <nl> - " public $ message_name $ clear $ capitalized_name $ ( ) { \ n " <nl> - " $ name $ _ = $ default_copy_if_needed $ ; \ n " <nl> - " $ clear_has $ ; \ n " <nl> - " return this ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void AccessorPrimitiveFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ _ = $ default_copy_if_needed $ ; \ n " ) ; <nl> - } <nl> - <nl> - void AccessorPrimitiveFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ _ = input . read $ capitalized_type $ ( ) ; \ n " <nl> - " $ set_has $ ; \ n " ) ; <nl> - } <nl> - <nl> - void AccessorPrimitiveFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ get_has $ ) { \ n " <nl> - " output . write $ capitalized_type $ ( $ number $ , $ name $ _ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void AccessorPrimitiveFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ get_has $ ) { \ n " <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . compute $ capitalized_type $ Size ( $ number $ , $ name $ _ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void AccessorPrimitiveFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - switch ( GetJavaType ( descriptor_ ) ) { <nl> - / / For all Java primitive types below , the equality checks match the <nl> - / / results of BoxedType . valueOf ( primitiveValue ) . equals ( otherValue ) . <nl> - case JAVATYPE_FLOAT : <nl> - printer - > Print ( variables_ , <nl> - " if ( $ different_has $ \ n " <nl> - " | | java . lang . Float . floatToIntBits ( $ name $ _ ) \ n " <nl> - " ! = java . lang . Float . floatToIntBits ( other . $ name $ _ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_DOUBLE : <nl> - printer - > Print ( variables_ , <nl> - " if ( $ different_has $ \ n " <nl> - " | | java . lang . Double . doubleToLongBits ( $ name $ _ ) \ n " <nl> - " ! = java . lang . Double . doubleToLongBits ( other . $ name $ _ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_INT : <nl> - case JAVATYPE_LONG : <nl> - case JAVATYPE_BOOLEAN : <nl> - printer - > Print ( variables_ , <nl> - " if ( $ different_has $ \ n " <nl> - " | | $ name $ _ ! = other . $ name $ _ ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_STRING : <nl> - / / Accessor style would guarantee $ name $ _ non - null <nl> - printer - > Print ( variables_ , <nl> - " if ( $ different_has $ \ n " <nl> - " | | ! $ name $ _ . equals ( other . $ name $ _ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_BYTES : <nl> - / / Accessor style would guarantee $ name $ _ non - null <nl> - printer - > Print ( variables_ , <nl> - " if ( $ different_has $ \ n " <nl> - " | | ! java . util . Arrays . equals ( $ name $ _ , other . $ name $ _ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - break ; <nl> - default : <nl> - GOOGLE_LOG ( ERROR ) < < " unknown java type for primitive field " ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - void AccessorPrimitiveFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - switch ( GetJavaType ( descriptor_ ) ) { <nl> - / / For all Java primitive types below , the hash codes match the <nl> - / / results of BoxedType . valueOf ( primitiveValue ) . hashCode ( ) . <nl> - case JAVATYPE_INT : <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + $ name $ _ ; \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_LONG : <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + ( int ) ( $ name $ _ ^ ( $ name $ _ > > > 32 ) ) ; \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_FLOAT : <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + \ n " <nl> - " java . lang . Float . floatToIntBits ( $ name $ _ ) ; \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_DOUBLE : <nl> - printer - > Print ( variables_ , <nl> - " { \ n " <nl> - " long v = java . lang . Double . doubleToLongBits ( $ name $ _ ) ; \ n " <nl> - " result = 31 * result + ( int ) ( v ^ ( v > > > 32 ) ) ; \ n " <nl> - " } \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_BOOLEAN : <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + ( $ name $ _ ? 1231 : 1237 ) ; \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_STRING : <nl> - / / Accessor style would guarantee $ name $ _ non - null <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + $ name $ _ . hashCode ( ) ; \ n " ) ; <nl> - break ; <nl> - case JAVATYPE_BYTES : <nl> - / / Accessor style would guarantee $ name $ _ non - null <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result + java . util . Arrays . hashCode ( $ name $ _ ) ; \ n " ) ; <nl> - break ; <nl> - default : <nl> - GOOGLE_LOG ( ERROR ) < < " unknown java type for primitive field " ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - PrimitiveOneofFieldGenerator : : PrimitiveOneofFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetPrimitiveVariables ( descriptor , params , & variables_ ) ; <nl> - SetCommonOneofVariables ( descriptor , & variables_ ) ; <nl> - } <nl> - <nl> - PrimitiveOneofFieldGenerator : : ~ PrimitiveOneofFieldGenerator ( ) { } <nl> - <nl> - void PrimitiveOneofFieldGenerator : : GenerateMembers ( <nl> - io : : Printer * printer , bool / * unused lazy_init * / ) const { <nl> - printer - > Print ( variables_ , <nl> - " public boolean has $ capitalized_name $ ( ) { \ n " <nl> - " return $ has_oneof_case $ ; \ n " <nl> - " } \ n " <nl> - " public $ type $ get $ capitalized_name $ ( ) { \ n " <nl> - " if ( $ has_oneof_case $ ) { \ n " <nl> - " return ( $ type $ ) ( $ boxed_type $ ) this . $ oneof_name $ _ ; \ n " <nl> - " } \ n " <nl> - " return $ default $ ; \ n " <nl> - " } \ n " <nl> - " public $ message_name $ set $ capitalized_name $ ( $ type $ value ) { \ n " <nl> - " $ set_oneof_case $ ; \ n " <nl> - " this . $ oneof_name $ _ = value ; \ n " <nl> - " return this ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void PrimitiveOneofFieldGenerator : : GenerateClearCode ( <nl> - io : : Printer * printer ) const { <nl> - / / No clear method for oneof fields . <nl> - } <nl> - <nl> - void PrimitiveOneofFieldGenerator : : GenerateMergingCode ( <nl> - io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " this . $ oneof_name $ _ = input . read $ capitalized_type $ ( ) ; \ n " <nl> - " $ set_oneof_case $ ; \ n " ) ; <nl> - } <nl> - <nl> - void PrimitiveOneofFieldGenerator : : GenerateSerializationCode ( <nl> - io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ has_oneof_case $ ) { \ n " <nl> - " output . write $ capitalized_type $ ( \ n " <nl> - " $ number $ , ( $ boxed_type $ ) this . $ oneof_name $ _ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void PrimitiveOneofFieldGenerator : : GenerateSerializedSizeCode ( <nl> - io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( $ has_oneof_case $ ) { \ n " <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . compute $ capitalized_type $ Size ( \ n " <nl> - " $ number $ , ( $ boxed_type $ ) this . $ oneof_name $ _ ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void PrimitiveOneofFieldGenerator : : GenerateEqualsCode ( <nl> - io : : Printer * printer ) const { <nl> - GenerateOneofFieldEquals ( descriptor_ , variables_ , printer ) ; <nl> - } <nl> - <nl> - void PrimitiveOneofFieldGenerator : : GenerateHashCodeCode ( <nl> - io : : Printer * printer ) const { <nl> - GenerateOneofFieldHashCode ( descriptor_ , variables_ , printer ) ; <nl> - } <nl> - <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - RepeatedPrimitiveFieldGenerator : : RepeatedPrimitiveFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) <nl> - : FieldGenerator ( params ) , descriptor_ ( descriptor ) { <nl> - SetPrimitiveVariables ( descriptor , params , & variables_ ) ; <nl> - } <nl> - <nl> - RepeatedPrimitiveFieldGenerator : : ~ RepeatedPrimitiveFieldGenerator ( ) { } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateMembers ( io : : Printer * printer , bool / * unused init_defaults * / ) const { <nl> - printer - > Print ( variables_ , <nl> - " public $ type $ [ ] $ name $ ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateClearCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " $ name $ = $ default $ ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateMergingCode ( io : : Printer * printer ) const { <nl> - / / First , figure out the length of the array , then parse . <nl> - printer - > Print ( variables_ , <nl> - " int arrayLength = com . google . protobuf . nano . WireFormatNano \ n " <nl> - " . getRepeatedFieldArrayLength ( input , $ non_packed_tag $ ) ; \ n " <nl> - " int i = this . $ name $ = = null ? 0 : this . $ name $ . length ; \ n " ) ; <nl> - <nl> - if ( GetJavaType ( descriptor_ ) = = JAVATYPE_BYTES ) { <nl> - printer - > Print ( variables_ , <nl> - " byte [ ] [ ] newArray = new byte [ i + arrayLength ] [ ] ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " $ type $ [ ] newArray = new $ type $ [ i + arrayLength ] ; \ n " ) ; <nl> - } <nl> - printer - > Print ( variables_ , <nl> - " if ( i ! = 0 ) { \ n " <nl> - " java . lang . System . arraycopy ( this . $ name $ , 0 , newArray , 0 , i ) ; \ n " <nl> - " } \ n " <nl> - " for ( ; i < newArray . length - 1 ; i + + ) { \ n " <nl> - " newArray [ i ] = input . read $ capitalized_type $ ( ) ; \ n " <nl> - " input . readTag ( ) ; \ n " <nl> - " } \ n " <nl> - " / / Last one without readTag . \ n " <nl> - " newArray [ i ] = input . read $ capitalized_type $ ( ) ; \ n " <nl> - " this . $ name $ = newArray ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateMergingCodeFromPacked ( io : : Printer * printer ) const { <nl> - printer - > Print ( <nl> - " int length = input . readRawVarint32 ( ) ; \ n " <nl> - " int limit = input . pushLimit ( length ) ; \ n " ) ; <nl> - <nl> - / / If we know the elements will all be of the same size , the arrayLength <nl> - / / can be calculated much more easily . However , FixedSize ( ) returns 1 for <nl> - / / repeated bool fields , which are guaranteed to have the fixed size of <nl> - / / 1 byte per value only if we control the output . On the wire they can <nl> - / / legally appear as variable - size integers , so we need to use the slow <nl> - / / way for repeated bool fields . <nl> - if ( descriptor_ - > type ( ) = = FieldDescriptor : : TYPE_BOOL <nl> - | | FixedSize ( descriptor_ - > type ( ) ) = = - 1 ) { <nl> - printer - > Print ( variables_ , <nl> - " / / First pass to compute array length . \ n " <nl> - " int arrayLength = 0 ; \ n " <nl> - " int startPos = input . getPosition ( ) ; \ n " <nl> - " while ( input . getBytesUntilLimit ( ) > 0 ) { \ n " <nl> - " input . read $ capitalized_type $ ( ) ; \ n " <nl> - " arrayLength + + ; \ n " <nl> - " } \ n " <nl> - " input . rewindToPosition ( startPos ) ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " int arrayLength = length / $ fixed_size $ ; \ n " ) ; <nl> - } <nl> - <nl> - printer - > Print ( variables_ , <nl> - " int i = this . $ name $ = = null ? 0 : this . $ name $ . length ; \ n " <nl> - " $ type $ [ ] newArray = new $ type $ [ i + arrayLength ] ; \ n " <nl> - " if ( i ! = 0 ) { \ n " <nl> - " java . lang . System . arraycopy ( this . $ name $ , 0 , newArray , 0 , i ) ; \ n " <nl> - " } \ n " <nl> - " for ( ; i < newArray . length ; i + + ) { \ n " <nl> - " newArray [ i ] = input . read $ capitalized_type $ ( ) ; \ n " <nl> - " } \ n " <nl> - " this . $ name $ = newArray ; \ n " <nl> - " input . popLimit ( limit ) ; \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateRepeatedDataSizeCode ( io : : Printer * printer ) const { <nl> - / / Creates a variable dataSize and puts the serialized size in there . <nl> - / / If the element type is a Java reference type , also generates <nl> - / / dataCount which stores the number of non - null elements in the field . <nl> - if ( IsReferenceType ( GetJavaType ( descriptor_ ) ) ) { <nl> - printer - > Print ( variables_ , <nl> - " int dataCount = 0 ; \ n " <nl> - " int dataSize = 0 ; \ n " <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " $ type $ element = this . $ name $ [ i ] ; \ n " <nl> - " if ( element ! = null ) { \ n " <nl> - " dataCount + + ; \ n " <nl> - " dataSize + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . compute $ capitalized_type $ SizeNoTag ( element ) ; \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } else if ( FixedSize ( descriptor_ - > type ( ) ) = = - 1 ) { <nl> - printer - > Print ( variables_ , <nl> - " int dataSize = 0 ; \ n " <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " $ type $ element = this . $ name $ [ i ] ; \ n " <nl> - " dataSize + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . compute $ capitalized_type $ SizeNoTag ( element ) ; \ n " <nl> - " } \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " int dataSize = $ fixed_size $ * this . $ name $ . length ; \ n " ) ; <nl> - } <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateSerializationCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - if ( descriptor_ - > is_packable ( ) & & descriptor_ - > options ( ) . packed ( ) ) { <nl> - GenerateRepeatedDataSizeCode ( printer ) ; <nl> - printer - > Print ( variables_ , <nl> - " output . writeRawVarint32 ( $ tag $ ) ; \ n " <nl> - " output . writeRawVarint32 ( dataSize ) ; \ n " <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " output . write $ capitalized_type $ NoTag ( this . $ name $ [ i ] ) ; \ n " <nl> - " } \ n " ) ; <nl> - } else if ( IsReferenceType ( GetJavaType ( descriptor_ ) ) ) { <nl> - printer - > Print ( variables_ , <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " $ type $ element = this . $ name $ [ i ] ; \ n " <nl> - " if ( element ! = null ) { \ n " <nl> - " output . write $ capitalized_type $ ( $ number $ , element ) ; \ n " <nl> - " } \ n " <nl> - " } \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " for ( int i = 0 ; i < this . $ name $ . length ; i + + ) { \ n " <nl> - " output . write $ capitalized_type $ ( $ number $ , this . $ name $ [ i ] ) ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - printer - > Print ( " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateSerializedSizeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( this . $ name $ ! = null & & this . $ name $ . length > 0 ) { \ n " ) ; <nl> - printer - > Indent ( ) ; <nl> - <nl> - GenerateRepeatedDataSizeCode ( printer ) ; <nl> - <nl> - printer - > Print ( <nl> - " size + = dataSize ; \ n " ) ; <nl> - if ( descriptor_ - > is_packable ( ) & & descriptor_ - > options ( ) . packed ( ) ) { <nl> - printer - > Print ( variables_ , <nl> - " size + = $ tag_size $ ; \ n " <nl> - " size + = com . google . protobuf . nano . CodedOutputByteBufferNano \ n " <nl> - " . computeRawVarint32Size ( dataSize ) ; \ n " ) ; <nl> - } else if ( IsReferenceType ( GetJavaType ( descriptor_ ) ) ) { <nl> - printer - > Print ( variables_ , <nl> - " size + = $ tag_size $ * dataCount ; \ n " ) ; <nl> - } else { <nl> - printer - > Print ( variables_ , <nl> - " size + = $ tag_size $ * this . $ name $ . length ; \ n " ) ; <nl> - } <nl> - <nl> - printer - > Outdent ( ) ; <nl> - <nl> - printer - > Print ( <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateEqualsCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " if ( ! com . google . protobuf . nano . InternalNano . equals ( \ n " <nl> - " this . $ name $ , other . $ name $ ) ) { \ n " <nl> - " return false ; \ n " <nl> - " } \ n " ) ; <nl> - } <nl> - <nl> - void RepeatedPrimitiveFieldGenerator : : <nl> - GenerateHashCodeCode ( io : : Printer * printer ) const { <nl> - printer - > Print ( variables_ , <nl> - " result = 31 * result \ n " <nl> - " + com . google . protobuf . nano . InternalNano . hashCode ( this . $ name $ ) ; \ n " ) ; <nl> - } <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - } / / namespace google <nl> deleted file mode 100644 <nl> index d7d72d578d . . 0000000000 <nl> mmm a / src / google / protobuf / compiler / javanano / javanano_primitive_field . h <nl> ppp / dev / null <nl> <nl> - / / Protocol Buffers - Google ' s data interchange format <nl> - / / Copyright 2008 Google Inc . All rights reserved . <nl> - / / http : / / code . google . com / p / protobuf / <nl> - / / <nl> - / / Redistribution and use in source and binary forms , with or without <nl> - / / modification , are permitted provided that the following conditions are <nl> - / / met : <nl> - / / <nl> - / / * Redistributions of source code must retain the above copyright <nl> - / / notice , this list of conditions and the following disclaimer . <nl> - / / * Redistributions in binary form must reproduce the above <nl> - / / copyright notice , this list of conditions and the following disclaimer <nl> - / / in the documentation and / or other materials provided with the <nl> - / / distribution . <nl> - / / * Neither the name of Google Inc . nor the names of its <nl> - / / contributors may be used to endorse or promote products derived from <nl> - / / this software without specific prior written permission . <nl> - / / <nl> - / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> - / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> - / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> - / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> - / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> - / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> - / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> - / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> - / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> - / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> - / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> - <nl> - / / Author : kenton @ google . com ( Kenton Varda ) <nl> - / / Based on original Protocol Buffers design by <nl> - / / Sanjay Ghemawat , Jeff Dean , and others . <nl> - <nl> - # ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_PRIMITIVE_FIELD_H__ <nl> - # define GOOGLE_PROTOBUF_COMPILER_JAVANANO_PRIMITIVE_FIELD_H__ <nl> - <nl> - # include < map > <nl> - # include < string > <nl> - # include < google / protobuf / compiler / javanano / javanano_field . h > <nl> - <nl> - namespace google { <nl> - namespace protobuf { <nl> - namespace compiler { <nl> - namespace javanano { <nl> - <nl> - class PrimitiveFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit PrimitiveFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) ; <nl> - ~ PrimitiveFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - bool SavedDefaultNeeded ( ) const ; <nl> - void GenerateInitSavedDefaultCode ( io : : Printer * printer ) const ; <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - void GenerateSerializationConditional ( io : : Printer * printer ) const ; <nl> - <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( PrimitiveFieldGenerator ) ; <nl> - } ; <nl> - <nl> - class AccessorPrimitiveFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit AccessorPrimitiveFieldGenerator ( const FieldDescriptor * descriptor , <nl> - const Params & params , int has_bit_index ) ; <nl> - ~ AccessorPrimitiveFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - bool SavedDefaultNeeded ( ) const ; <nl> - void GenerateInitSavedDefaultCode ( io : : Printer * printer ) const ; <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( AccessorPrimitiveFieldGenerator ) ; <nl> - } ; <nl> - <nl> - class PrimitiveOneofFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit PrimitiveOneofFieldGenerator ( <nl> - const FieldDescriptor * descriptor , const Params & params ) ; <nl> - ~ PrimitiveOneofFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( PrimitiveOneofFieldGenerator ) ; <nl> - } ; <nl> - <nl> - class RepeatedPrimitiveFieldGenerator : public FieldGenerator { <nl> - public : <nl> - explicit RepeatedPrimitiveFieldGenerator ( const FieldDescriptor * descriptor , <nl> - const Params & params ) ; <nl> - ~ RepeatedPrimitiveFieldGenerator ( ) ; <nl> - <nl> - / / implements FieldGenerator mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - void GenerateMembers ( io : : Printer * printer , bool lazy_init ) const ; <nl> - void GenerateClearCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCode ( io : : Printer * printer ) const ; <nl> - void GenerateMergingCodeFromPacked ( io : : Printer * printer ) const ; <nl> - void GenerateSerializationCode ( io : : Printer * printer ) const ; <nl> - void GenerateSerializedSizeCode ( io : : Printer * printer ) const ; <nl> - void GenerateEqualsCode ( io : : Printer * printer ) const ; <nl> - void GenerateHashCodeCode ( io : : Printer * printer ) const ; <nl> - void GenerateFixClonedCode ( io : : Printer * printer ) const ; <nl> - <nl> - private : <nl> - void GenerateRepeatedDataSizeCode ( io : : Printer * printer ) const ; <nl> - <nl> - const FieldDescriptor * descriptor_ ; <nl> - std : : map < string , string > variables_ ; <nl> - <nl> - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( RepeatedPrimitiveFieldGenerator ) ; <nl> - } ; <nl> - <nl> - } / / namespace javanano <nl> - } / / namespace compiler <nl> - } / / namespace protobuf <nl> - <nl> - } / / namespace google <nl> - # endif / / GOOGLE_PROTOBUF_COMPILER_JAVANANO_PRIMITIVE_FIELD_H__ <nl> mmm a / src / google / protobuf / compiler / main . cc <nl> ppp b / src / google / protobuf / compiler / main . cc <nl> <nl> <nl> # ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP <nl> # include < google / protobuf / compiler / csharp / csharp_generator . h > <nl> - # include < google / protobuf / compiler / javanano / javanano_generator . h > <nl> # include < google / protobuf / compiler / js / js_generator . h > <nl> # include < google / protobuf / compiler / objectivec / objectivec_generator . h > <nl> # include < google / protobuf / compiler / php / php_generator . h > <nl> int main ( int argc , char * argv [ ] ) { <nl> cli . RegisterGenerator ( " - - python_out " , & py_generator , <nl> " Generate Python source file . " ) ; <nl> <nl> - / / Java Nano <nl> - google : : protobuf : : compiler : : javanano : : JavaNanoGenerator javanano_generator ; <nl> - cli . RegisterGenerator ( " - - javanano_out " , & javanano_generator , <nl> - " Generate Java Nano source file . " ) ; <nl> - <nl> / / PHP <nl> google : : protobuf : : compiler : : php : : Generator php_generator ; <nl> cli . RegisterGenerator ( " - - php_out " , & php_generator , <nl> mmm a / update_file_lists . sh <nl> ppp b / update_file_lists . sh <nl> get_header_files ( ) { <nl> } <nl> <nl> get_source_files ( ) { <nl> - get_variable_value $ @ | grep " cc $ " <nl> + get_variable_value $ @ | grep " cc $ \ | inc $ " <nl> } <nl> <nl> get_proto_files_blacklisted ( ) { <nl> PUBLIC_HEADERS = $ ( sort_files $ GZHEADERS $ HEADERS ) <nl> LIBPROTOBUF_LITE_SOURCES = $ ( get_source_files $ MAKEFILE libprotobuf_lite_la_SOURCES ) <nl> LIBPROTOBUF_SOURCES = $ ( get_source_files $ MAKEFILE libprotobuf_la_SOURCES ) <nl> LIBPROTOC_SOURCES = $ ( get_source_files $ MAKEFILE libprotoc_la_SOURCES ) <nl> + LIBPROTOC_HEADERS = $ ( get_header_files $ MAKEFILE libprotoc_la_SOURCES ) <nl> LITE_PROTOS = $ ( get_proto_files $ MAKEFILE protoc_lite_outputs ) <nl> PROTOS = $ ( get_proto_files $ MAKEFILE protoc_outputs ) <nl> PROTOS_BLACKLISTED = $ ( get_proto_files_blacklisted $ MAKEFILE protoc_outputs ) <nl> CMAKE_PREFIX = " \ $ { protobuf_source_dir } / src / " <nl> set_cmake_value $ CMAKE_DIR / libprotobuf - lite . cmake libprotobuf_lite_files $ CMAKE_PREFIX $ LIBPROTOBUF_LITE_SOURCES <nl> set_cmake_value $ CMAKE_DIR / libprotobuf . cmake libprotobuf_files $ CMAKE_PREFIX $ LIBPROTOBUF_SOURCES <nl> set_cmake_value $ CMAKE_DIR / libprotoc . cmake libprotoc_files $ CMAKE_PREFIX $ LIBPROTOC_SOURCES <nl> + set_cmake_value $ CMAKE_DIR / libprotoc . cmake libprotoc_headers $ CMAKE_PREFIX $ LIBPROTOC_HEADERS <nl> set_cmake_value $ CMAKE_DIR / tests . cmake lite_test_protos " " $ LITE_PROTOS <nl> set_cmake_value $ CMAKE_DIR / tests . cmake tests_protos " " $ PROTOS_BLACKLISTED <nl> set_cmake_value $ CMAKE_DIR / tests . cmake common_test_files $ CMAKE_PREFIX $ COMMON_TEST_SOURCES <nl> | Remove javanano . | protocolbuffers/protobuf | d5a002417148ad16ac6b1854972f4a27fe766260 | 2018-03-26T19:59:28Z |
mmm a / Code / CryEngine / CryAISystem / Sequence / SequenceFlowNodes . cpp <nl> ppp b / Code / CryEngine / CryAISystem / Sequence / SequenceFlowNodes . cpp <nl> void CFlowNode_AISequenceBookmark : : ProcessEvent ( EFlowEvent event , SActivationInf <nl> { <nl> if ( IsPortActive ( pActInfo , InputPort_Set ) ) <nl> { <nl> - const SequenceId assignedSequenceId = GetAssignedSequenceId ( ) ; <nl> - assert ( assignedSequenceId ) ; <nl> - if ( ! assignedSequenceId ) <nl> - return ; <nl> - <nl> - GetAISystem ( ) - > GetSequenceManager ( ) - > SetBookmark ( assignedSequenceId , pActInfo - > myID ) ; <nl> - ActivateOutput ( pActInfo , OutputPort_Link , true ) ; <nl> + if ( const SequenceId assignedSequenceId = GetAssignedSequenceId ( ) ) <nl> + { <nl> + GetAISystem ( ) - > GetSequenceManager ( ) - > SetBookmark ( assignedSequenceId , pActInfo - > myID ) ; <nl> + ActivateOutput ( pActInfo , OutputPort_Link , true ) ; <nl> + } <nl> } <nl> } <nl> break ; <nl> void CFlowNode_AISequenceActionMoveAlongPath : : ProcessEvent ( EFlowEvent event , SAc <nl> case eFE_Activate : <nl> { <nl> m_actInfo = * pActInfo ; <nl> - const SequenceId assignedSequenceId = GetAssignedSequenceId ( ) ; <nl> - assert ( assignedSequenceId ) ; <nl> - if ( ! assignedSequenceId ) <nl> - return ; <nl> - <nl> - if ( IsPortActive ( pActInfo , InputPort_Start ) ) <nl> + if ( const SequenceId assignedSequenceId = GetAssignedSequenceId ( ) ) <nl> { <nl> - GetAISystem ( ) - > GetSequenceManager ( ) - > RequestActionStart ( assignedSequenceId , m_actInfo . myID ) ; <nl> + if ( IsPortActive ( pActInfo , InputPort_Start ) ) <nl> + { <nl> + GetAISystem ( ) - > GetSequenceManager ( ) - > RequestActionStart ( assignedSequenceId , m_actInfo . myID ) ; <nl> + } <nl> } <nl> } <nl> break ; <nl> void CFlowNode_AISequenceAction_Stance : : ProcessEvent ( EFlowEvent event , SActivati <nl> { <nl> m_actInfo = * pActInfo ; <nl> <nl> - const SequenceId assignedSequenceId = GetAssignedSequenceId ( ) ; <nl> - assert ( assignedSequenceId ) ; <nl> - if ( ! assignedSequenceId ) <nl> - return ; <nl> - <nl> - GetAISystem ( ) - > GetSequenceManager ( ) - > RequestActionStart ( assignedSequenceId , m_actInfo . myID ) ; <nl> + if ( const SequenceId assignedSequenceId = GetAssignedSequenceId ( ) ) <nl> + { <nl> + GetAISystem ( ) - > GetSequenceManager ( ) - > RequestActionStart ( assignedSequenceId , m_actInfo . myID ) ; <nl> + } <nl> } <nl> } <nl> } <nl> | ! B ( CE - 10899 ) ( AISystem ) Sequence nodes : changed the way how nodes react on invalid sequence IDs to prevent consequential errors from preceding errors ( Approved by samuelk ) | CRYTEK/CRYENGINE | 7e82904e25079629c601bd1e066946db1b93e55d | 2016-11-23T15:20:02Z |
mmm a / src / mongo / db / catalog / index_create . cpp <nl> ppp b / src / mongo / db / catalog / index_create . cpp <nl> namespace mongo { <nl> exec - > setYieldPolicy ( PlanExecutor : : WRITE_CONFLICT_RETRY_ONLY ) ; <nl> } <nl> <nl> - BSONObj objToIndex ; <nl> + Snapshotted < BSONObj > objToIndex ; <nl> RecordId loc ; <nl> PlanExecutor : : ExecState state ; <nl> - while ( PlanExecutor : : ADVANCED = = ( state = exec - > getNext ( & objToIndex , & loc ) ) ) { <nl> - { <nl> + int retries = 0 ; / / non - zero when retrying our last document . <nl> + while ( retries <nl> + | | ( PlanExecutor : : ADVANCED = = ( state = exec - > getNextSnapshotted ( & objToIndex , <nl> + & loc ) ) ) ) { <nl> + try { <nl> if ( _allowInterruption ) <nl> _txn - > checkForInterrupt ( ) ; <nl> <nl> - bool shouldCommitWUnit = true ; <nl> - WriteUnitOfWork wunit ( _txn ) ; <nl> - Status ret = insert ( objToIndex , loc ) ; <nl> - if ( ! ret . isOK ( ) ) { <nl> - if ( dupsOut & & ret . code ( ) = = ErrorCodes : : DuplicateKey ) { <nl> - / / If dupsOut is non - null , we should only fail the specific insert that <nl> - / / led to a DuplicateKey rather than the whole index build . <nl> - dupsOut - > insert ( loc ) ; <nl> - shouldCommitWUnit = false ; <nl> - } <nl> - else { <nl> - return ret ; <nl> - } <nl> + / / Make sure we are working with the latest version of the document . <nl> + if ( objToIndex . snapshotId ( ) ! = _txn - > recoveryUnit ( ) - > getSnapshotId ( ) <nl> + & & ! _collection - > findDoc ( _txn , loc , & objToIndex ) ) { <nl> + / / doc was deleted so don ' t index it . <nl> + retries = 0 ; <nl> + continue ; <nl> } <nl> <nl> - if ( shouldCommitWUnit ) <nl> - wunit . commit ( ) ; <nl> - } <nl> + / / Done before insert so we can retry document if it WCEs . <nl> + progress - > setTotalWhileRunning ( _collection - > numRecords ( _txn ) ) ; <nl> <nl> - n + + ; <nl> - progress - > hit ( ) ; <nl> + WriteUnitOfWork wunit ( _txn ) ; <nl> + Status ret = insert ( objToIndex . value ( ) , loc ) ; <nl> + if ( ret . isOK ( ) ) { <nl> + wunit . commit ( ) ; <nl> + } <nl> + else if ( dupsOut & & ret . code ( ) = = ErrorCodes : : DuplicateKey ) { <nl> + / / If dupsOut is non - null , we should only fail the specific insert that <nl> + / / led to a DuplicateKey rather than the whole index build . <nl> + dupsOut - > insert ( loc ) ; <nl> + } <nl> + else { <nl> + / / Fail the index build hard . <nl> + return ret ; <nl> + } <nl> <nl> - progress - > setTotalWhileRunning ( _collection - > numRecords ( _txn ) ) ; <nl> + / / Go to the next document <nl> + progress - > hit ( ) ; <nl> + n + + ; <nl> + retries = 0 ; <nl> + } <nl> + catch ( const WriteConflictException & wce ) { <nl> + _txn - > getCurOp ( ) - > debug ( ) . writeConflicts + + ; <nl> + retries + + ; / / logAndBackoff expects this to be 1 on first call . <nl> + wce . logAndBackoff ( retries , " index creation " , _collection - > ns ( ) . ns ( ) ) ; <nl> + <nl> + / / Can ' t use WRITE_CONFLICT_RETRY_LOOP macros since we need to save / restore exec <nl> + / / around call to commitAndRestart . <nl> + exec - > saveState ( ) ; <nl> + _txn - > recoveryUnit ( ) - > commitAndRestart ( ) ; <nl> + exec - > restoreState ( _txn ) ; / / Handles any WCEs internally . <nl> + } <nl> } <nl> <nl> if ( state ! = PlanExecutor : : IS_EOF ) { <nl> | SERVER - 17642 WCE retry loop per document in index build | mongodb/mongo | a853cabd7e65ca545636af6b6c957d1ee1d4b39d | 2015-03-31T18:53:44Z |
deleted file mode 100644 <nl> index c1ce033cf5c . . 00000000000 <nl> mmm a / arangod / HashIndex / hash - array . cpp <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief hash array implementation <nl> - / / / <nl> - / / / @ file <nl> - / / / <nl> - / / / DISCLAIMER <nl> - / / / <nl> - / / / Copyright 2014 ArangoDB GmbH , Cologne , Germany <nl> - / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> - / / / <nl> - / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / / you may not use this file except in compliance with the License . <nl> - / / / You may obtain a copy of the License at <nl> - / / / <nl> - / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / / <nl> - / / / Unless required by applicable law or agreed to in writing , software <nl> - / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / / See the License for the specific language governing permissions and <nl> - / / / limitations under the License . <nl> - / / / <nl> - / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> - / / / <nl> - / / / @ author Dr . Frank Celler <nl> - / / / @ author Dr . Oreste Costa - Panaia <nl> - / / / @ author Martin Schoenert <nl> - / / / @ author Copyright 2014 , ArangoDB GmbH , Cologne , Germany <nl> - / / / @ author Copyright 2004 - 2013 , triAGENS GmbH , Cologne , Germany <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / Indexes / HashIndex . cpp <nl> ppp b / arangod / Indexes / HashIndex . cpp <nl> static int FillIndexSearchValueByHashIndexElement ( HashIndex const * hashIndex , <nl> <nl> TRI_InspectShapedSub ( & element - > subObjects ( ) [ i ] , ptr , key - > _values [ i ] ) ; <nl> } <nl> - <nl> - return TRI_ERROR_NO_ERROR ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief locates a key within the hash array part <nl> - / / / it is the callers responsibility to destroy the result <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static TRI_vector_pointer_t HashIndex_find ( TRI_hash_array_t const * hashArray , <nl> - TRI_index_search_value_t * key ) { <nl> - TRI_vector_pointer_t results ; <nl> - TRI_InitVectorPointer ( & results , TRI_UNKNOWN_MEM_ZONE ) ; <nl> - <nl> - / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> - / / A find request means that a set of values for the " key " was sent . We need <nl> - / / to locate the hash array entry by key . <nl> - / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> - <nl> - TRI_index_element_t * result = hashArray - > findByKey ( key ) ; <nl> - <nl> - if ( result ! = nullptr ) { <nl> - / / unique hash index : maximum number is 1 <nl> - TRI_PushBackVectorPointer ( & results , result - > document ( ) ) ; <nl> - } <nl> - <nl> - return results ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief locates a key within the hash array part <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static int HashIndex_find ( TRI_hash_array_t const * hashArray , <nl> - TRI_index_search_value_t * key , <nl> - std : : vector < TRI_doc_mptr_copy_t > & result ) { <nl> - <nl> - / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> - / / A find request means that a set of values for the " key " was sent . We need <nl> - / / to locate the hash array entry by key . <nl> - / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> - <nl> - TRI_index_element_t * found = hashArray - > findByKey ( key ) ; <nl> - <nl> - if ( found ! = nullptr ) { <nl> - / / unique hash index : maximum number is 1 <nl> - result . emplace_back ( * ( found - > document ( ) ) ) ; <nl> - } <nl> + key - > _length = n ; <nl> <nl> return TRI_ERROR_NO_ERROR ; <nl> } <nl> HashIndex : : HashIndex ( TRI_idx_iid_t iid , <nl> } <nl> <nl> if ( unique ) { <nl> - _hashArray = nullptr ; <nl> + _uniqueArray . _hashArray = nullptr ; <nl> try { <nl> - _hashArray = new TRI_hash_array_t ( _paths . size ( ) , indexBuckets ) ; <nl> + _uniqueArray . _hashElement = new HashElementFunc ( _paths . size ( ) ) ; <nl> + _uniqueArray . _hashArray = new TRI_HashArray_t ( hashKey , <nl> + * _uniqueArray . _hashElement , <nl> + isEqualKeyElement , <nl> + isEqualElementElement , <nl> + indexBuckets <nl> + ) ; <nl> } <nl> catch ( . . . ) { <nl> THROW_ARANGO_EXCEPTION ( TRI_ERROR_OUT_OF_MEMORY ) ; <nl> } <nl> } <nl> else { <nl> - uint32_t indexBuckets = 1 ; <nl> - if ( collection ! = nullptr ) { <nl> - / / document is a nullptr in the coordinator case <nl> - indexBuckets = collection - > _info . _indexBuckets ; <nl> - } <nl> - <nl> _multi . _hashArray = nullptr ; <nl> _multi . _isEqualElElByKey = nullptr ; <nl> _multi . _hashElement = nullptr ; <nl> HashIndex : : HashIndex ( TRI_idx_iid_t iid , <nl> <nl> HashIndex : : ~ HashIndex ( ) { <nl> if ( _unique ) { <nl> - _hashArray - > invokeOnAllElements ( freeElement ) ; <nl> - delete _hashArray ; <nl> - _hashArray = nullptr ; <nl> + _uniqueArray . _hashArray - > invokeOnAllElements ( freeElement ) ; <nl> + delete _uniqueArray . _hashElement ; <nl> + delete _uniqueArray . _hashArray ; <nl> } <nl> else { <nl> _multi . _hashArray - > invokeOnAllElements ( freeElement ) ; <nl> double HashIndex : : selectivityEstimate ( ) const { <nl> <nl> size_t HashIndex : : memory ( ) const { <nl> if ( _unique ) { <nl> - return static_cast < size_t > ( keyEntrySize ( ) * _hashArray - > size ( ) + <nl> - _hashArray - > memoryUsage ( ) ) ; <nl> + return static_cast < size_t > ( keyEntrySize ( ) * _uniqueArray . _hashArray - > size ( ) + <nl> + _uniqueArray . _hashArray - > memoryUsage ( ) ) ; <nl> } <nl> <nl> return static_cast < size_t > ( keyEntrySize ( ) * _multi . _hashArray - > size ( ) + <nl> int HashIndex : : sizeHint ( size_t size ) { <nl> } <nl> <nl> if ( _unique ) { <nl> - return _hashArray - > resize ( this , size ) ; <nl> + return _uniqueArray . _hashArray - > resize ( size ) ; <nl> } <nl> else { <nl> return _multi . _hashArray - > resize ( size ) ; <nl> } <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief locates entries in the hash index given shaped json objects <nl> - / / / it is the callers responsibility to destroy the result <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - / / FIXME : use std : : vector here as well <nl> - TRI_vector_pointer_t HashIndex : : lookup ( TRI_index_search_value_t * searchValue ) const { <nl> - if ( _unique ) { <nl> - return HashIndex_find ( _hashArray , searchValue ) ; <nl> - } <nl> - <nl> - std : : vector < TRI_index_element_t * > * results <nl> - = _multi . _hashArray - > lookupByKey ( searchValue ) ; <nl> - TRI_vector_pointer_t resultsvec ; <nl> - int res = TRI_InitVectorPointer ( & resultsvec , TRI_UNKNOWN_MEM_ZONE , <nl> - results - > size ( ) ) ; <nl> - if ( res = = TRI_ERROR_NO_ERROR ) { <nl> - for ( size_t i = 0 ; i < results - > size ( ) ; i + + ) { <nl> - TRI_PushBackVectorPointer ( & resultsvec , ( * results ) [ i ] - > document ( ) ) ; <nl> - } <nl> - } <nl> - delete results ; <nl> - return resultsvec ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief locates entries in the hash index given shaped json objects <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> int HashIndex : : lookup ( TRI_index_search_value_t * searchValue , <nl> std : : vector < TRI_doc_mptr_copy_t > & documents ) const { <nl> <nl> if ( _unique ) { <nl> - return HashIndex_find ( _hashArray , searchValue , documents ) ; <nl> + TRI_index_element_t * found = _uniqueArray . _hashArray - > findByKey ( searchValue ) ; <nl> + <nl> + if ( found ! = nullptr ) { <nl> + / / unique hash index : maximum number is 1 <nl> + documents . emplace_back ( * ( found - > document ( ) ) ) ; <nl> + } <nl> + return TRI_ERROR_NO_ERROR ; <nl> } <nl> <nl> std : : vector < TRI_index_element_t * > * results = nullptr ; <nl> int HashIndex : : lookup ( TRI_index_search_value_t * searchValue , <nl> <nl> if ( _unique ) { <nl> next = nullptr ; <nl> - return HashIndex_find ( _hashArray , searchValue , documents ) ; <nl> + TRI_index_element_t * found = _uniqueArray . _hashArray - > findByKey ( searchValue ) ; <nl> + <nl> + if ( found ! = nullptr ) { <nl> + / / unique hash index : maximum number is 1 <nl> + documents . emplace_back ( * ( found - > document ( ) ) ) ; <nl> + } <nl> + return TRI_ERROR_NO_ERROR ; <nl> } <nl> <nl> std : : vector < TRI_index_element_t * > * results = nullptr ; <nl> int HashIndex : : insertUnique ( TRI_doc_mptr_t const * doc , <nl> std : : vector < TRI_index_element_t * > elements ; <nl> int res = fillElement ( allocate , elements , doc , paths ( ) , sparse ( ) ) ; <nl> <nl> - auto work = [ this ] ( TRI_index_element_t const * element , bool isRollback ) - > int { <nl> + auto work = [ this ] ( TRI_index_element_t * element , bool isRollback ) - > int { <nl> TRI_IF_FAILURE ( " InsertHashIndex " ) { <nl> return TRI_ERROR_DEBUG ; <nl> } <nl> int HashIndex : : insertUnique ( TRI_doc_mptr_t const * doc , <nl> return res ; <nl> } <nl> <nl> - res = _hashArray - > insert ( this , & key , element , isRollback ) ; <nl> + res = _uniqueArray . _hashArray - > insert ( & key , element , isRollback ) ; <nl> <nl> if ( key . _values ! = nullptr ) { <nl> TRI_Free ( TRI_UNKNOWN_MEM_ZONE , key . _values ) ; <nl> int HashIndex : : insertMulti ( TRI_doc_mptr_t const * doc , <nl> return res ; <nl> } <nl> <nl> - int HashIndex : : removeUniqueElement ( TRI_index_element_t * element , bool isRollback ) { <nl> + int HashIndex : : removeUniqueElement ( TRI_index_element_t * element , bool isRollback ) { <nl> TRI_IF_FAILURE ( " RemoveHashIndex " ) { <nl> return TRI_ERROR_DEBUG ; <nl> } <nl> <nl> - TRI_index_element_t * old = _hashArray - > remove ( this , element ) ; <nl> - <nl> + TRI_index_element_t * old = _uniqueArray . _hashArray - > remove ( element ) ; <nl> / / this might happen when rolling back <nl> if ( old = = nullptr ) { <nl> if ( isRollback ) { <nl> mmm a / arangod / Indexes / HashIndex . h <nl> ppp b / arangod / Indexes / HashIndex . h <nl> <nl> <nl> # include " Basics / Common . h " <nl> # include " Basics / AssocMulti . h " <nl> - # include " HashIndex / hash - array . h " <nl> + # include " Basics / AssocUnique . h " <nl> # include " Indexes / Index . h " <nl> # include " VocBase / shaped - json . h " <nl> # include " VocBase / vocbase . h " <nl> namespace triagens { <nl> HashElementFunc ( size_t s ) : _numFields ( s ) { <nl> } <nl> uint64_t operator ( ) ( TRI_index_element_t const * element , <nl> - bool byKey ) { <nl> + bool byKey = true ) { <nl> uint64_t hash = 0x0123456789abcdef ; <nl> <nl> for ( size_t j = 0 ; j < _numFields ; j + + ) { <nl> namespace triagens { <nl> uint32_t > <nl> TRI_HashArrayMulti_t ; <nl> <nl> + typedef triagens : : basics : : AssocUnique < TRI_index_search_value_t , <nl> + TRI_index_element_t > <nl> + TRI_HashArray_t ; <nl> + <nl> union { <nl> - TRI_hash_array_t * _hashArray ; / / the hash array itself , unique values <nl> + struct { <nl> + TRI_HashArray_t * _hashArray ; / / the hash array itself , unique values <nl> + HashElementFunc * _hashElement ; / / hash function for elements <nl> + } _uniqueArray ; <nl> struct { <nl> TRI_HashArrayMulti_t * _hashArray ; / / the hash array itself , non - unique values <nl> HashElementFunc * _hashElement ; / / hash function for elements <nl> mmm a / arangod / Makefile . files <nl> ppp b / arangod / Makefile . files <nl> arangod_libarangod_a_SOURCES = \ <nl> arangod / FulltextIndex / fulltext - result . cpp \ <nl> arangod / FulltextIndex / fulltext - wordlist . cpp \ <nl> arangod / GeoIndex / GeoIndex . cpp \ <nl> - arangod / HashIndex / hash - array . cpp \ <nl> arangod / HttpServer / ApplicationEndpointServer . cpp \ <nl> arangod / HttpServer / AsyncJobManager . cpp \ <nl> arangod / HttpServer / HttpCommTask . cpp \ <nl> mmm a / arangod / V8Server / v8 - query . cpp <nl> ppp b / arangod / V8Server / v8 - query . cpp <nl> static void ByExampleHashIndexQuery ( SingleCollectionReadOnlyTransaction & trx , <nl> } <nl> <nl> / / find the matches <nl> - TRI_vector_pointer_t list = static_cast < triagens : : arango : : HashIndex * > ( idx ) - > lookup ( & searchValue ) ; <nl> + std : : vector < TRI_doc_mptr_copy_t > list ; <nl> + static_cast < triagens : : arango : : HashIndex * > ( idx ) - > lookup ( & searchValue , list ) ; <nl> DestroySearchValue ( shaper - > memoryZone ( ) , searchValue ) ; <nl> <nl> / / convert result <nl> - size_t total = TRI_LengthVectorPointer ( & list ) ; <nl> + size_t total = list . size ( ) ; <nl> size_t count = 0 ; <nl> bool error = false ; <nl> <nl> static void ByExampleHashIndexQuery ( SingleCollectionReadOnlyTransaction & trx , <nl> for ( size_t i = s ; i < e ; + + i ) { <nl> v8 : : Handle < v8 : : Value > doc = WRAP_SHAPED_JSON ( trx , <nl> collection - > _cid , <nl> - static_cast < TRI_doc_mptr_t * > ( TRI_AtVectorPointer ( & list , i ) ) - > getDataPtr ( ) ) ; <nl> + list [ i ] . getDataPtr ( ) ) ; <nl> <nl> if ( doc . IsEmpty ( ) ) { <nl> error = true ; <nl> static void ByExampleHashIndexQuery ( SingleCollectionReadOnlyTransaction & trx , <nl> } <nl> } <nl> <nl> - / / free data allocated by hash index result <nl> - TRI_DestroyVectorPointer ( & list ) ; <nl> - <nl> result - > Set ( TRI_V8_ASCII_STRING ( " total " ) , v8 : : Number : : New ( isolate , ( double ) total ) ) ; <nl> result - > Set ( TRI_V8_ASCII_STRING ( " count " ) , v8 : : Number : : New ( isolate , ( double ) count ) ) ; <nl> <nl> mmm a / lib / Basics / AssocUnique . h <nl> ppp b / lib / Basics / AssocUnique . h <nl> namespace triagens { <nl> public : <nl> <nl> typedef std : : function < uint64_t ( Key const * ) > HashKeyFuncType ; <nl> - typedef std : : function < uint64_t ( Element const * , bool ) > HashElementFuncType ; <nl> + typedef std : : function < uint64_t ( Element const * ) > HashElementFuncType ; <nl> typedef std : : function < bool ( Key const * , Element const * ) > <nl> IsEqualKeyElementFuncType ; <nl> + typedef std : : function < bool ( Element const * , Element const * ) > <nl> + IsEqualElementElementFuncType ; <nl> + <nl> typedef std : : function < void ( Element * ) > CallbackElementFuncType ; <nl> <nl> private : <nl> - size_t _numFields ; / / the number of fields indexes <nl> - <nl> struct Bucket { <nl> <nl> uint64_t _nrAlloc ; / / the size of the table <nl> namespace triagens { <nl> HashKeyFuncType const _hashKey ; <nl> HashElementFuncType const _hashElement ; <nl> IsEqualKeyElementFuncType const _isEqualKeyElement ; <nl> + IsEqualElementElementFuncType const _isEqualElementElement ; <nl> <nl> std : : function < std : : string ( ) > _contextCallback ; <nl> <nl> namespace triagens { <nl> AssocUnique ( HashKeyFuncType hashKey , <nl> HashElementFuncType hashElement , <nl> IsEqualKeyElementFuncType isEqualKeyElement , <nl> - size_t numFields , <nl> + IsEqualElementElementFuncType isEqualElementElement , <nl> size_t numberBuckets = 1 , <nl> std : : function < std : : string ( ) > contextCallback = [ ] ( ) - > std : : string { return " " ; } ) : <nl> - _numFields ( numFields ) <nl> - _hashKey ( hashKey ) , <nl> + _hashKey ( hashKey ) , <nl> _hashElement ( hashElement ) , <nl> _isEqualKeyElement ( isEqualKeyElement ) , <nl> + _isEqualElementElement ( isEqualElementElement ) , <nl> _contextCallback ( contextCallback ) { <nl> <nl> / / Make the number of buckets a power of two : <nl> namespace triagens { <nl> return 251 ; <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief determines if a key corresponds to an element <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool isEqualKeyElement ( Key const * left , <nl> - Element const * right ) const ; <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief given a key generates a hash integer <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - uint64_t hashKey ( Key const * key ) const ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief given an element generates a hash integer <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - uint64_t hashElement ( Element const * element ) const ; <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief resizes the array <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> namespace triagens { <nl> size_t memoryUsage ( ) { <nl> size_t sum = 0 ; <nl> for ( auto & b : _buckets ) { <nl> - sum + = ( size_t ) ( b . _nrAlloc * sizeof ( TRI_index_element_t * ) ) ; <nl> + sum + = ( size_t ) ( b . _nrAlloc * sizeof ( Element * ) ) ; <nl> } <nl> return sum ; <nl> } <nl> namespace triagens { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> int insert ( Key const * key , <nl> - Element const * element , <nl> + Element * element , <nl> bool isRollback ) { <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> / / we are adding and the table is more than half full , extend it <nl> namespace triagens { <nl> return TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED ; <nl> } <nl> <nl> - b . _table [ i ] = element ; <nl> - TRI_ASSERT ( b . _table [ i ] ! = nullptr & & b . _table [ i ] - > document ( ) ! = nullptr ) ; <nl> + b . _table [ i ] = static_cast < Element * > ( element ) ; <nl> + TRI_ASSERT ( b . _table [ i ] ! = nullptr ) ; <nl> b . _nrUsed + + ; <nl> <nl> return TRI_ERROR_NO_ERROR ; <nl> namespace triagens { <nl> uint64_t k = i ; <nl> <nl> for ( ; i < n & & b . _table [ i ] ! = nullptr & & <nl> - element - > document ( ) ! = b . _table [ i ] - > document ( ) ; + + i ) ; <nl> + ! _isEqualElementElement ( element , b . _table [ i ] ) ; + + i ) ; <nl> if ( i = = n ) { <nl> for ( i = 0 ; i < k & & b . _table [ i ] ! = nullptr & & <nl> - element - > document ( ) ! = b . _table [ i ] - > document ( ) ; + + i ) ; <nl> + ! _isEqualElementElement ( element , b . _table [ i ] ) ; + + i ) ; <nl> } <nl> <nl> Element * old = b . _table [ i ] ; <nl> | AssocUnique is now a templated index . Foundation to move primary index to use it | arangodb/arangodb | ba8264eada7621af31ebe646613d9df49bd113e1 | 2015-08-24T14:41:16Z |
mmm a / torch / distributions / categorical . py <nl> ppp b / torch / distributions / categorical . py <nl> def sample ( self , sample_shape = torch . Size ( ) ) : <nl> def log_prob ( self , value ) : <nl> if self . _validate_args : <nl> self . _validate_sample ( value ) <nl> - value_shape = torch . _C . _infer_size ( value . size ( ) , self . batch_shape ) if self . batch_shape else value . size ( ) <nl> - param_shape = value_shape + ( self . _num_events , ) <nl> - value = value . expand ( value_shape ) <nl> - log_pmf = self . logits . expand ( param_shape ) <nl> - return log_pmf . gather ( - 1 , value . unsqueeze ( - 1 ) . long ( ) ) . squeeze ( - 1 ) <nl> + value = value . long ( ) . unsqueeze ( - 1 ) <nl> + value , log_pmf = torch . broadcast_tensors ( value , self . logits ) <nl> + value = value [ . . . , : 1 ] <nl> + return log_pmf . gather ( - 1 , value ) . squeeze ( - 1 ) <nl> <nl> def entropy ( self ) : <nl> p_log_p = self . logits * self . probs <nl> mmm a / torch / distributions / lowrank_multivariate_normal . py <nl> ppp b / torch / distributions / lowrank_multivariate_normal . py <nl> <nl> from torch . distributions import constraints <nl> from torch . distributions . distribution import Distribution <nl> from torch . distributions . multivariate_normal import ( _batch_diag , _batch_mahalanobis , _batch_mv , <nl> - _batch_potrf_lower , _batch_trtrs_lower , <nl> - _get_batch_shape ) <nl> + _batch_potrf_lower , _batch_trtrs_lower ) <nl> from torch . distributions . utils import lazy_property <nl> <nl> <nl> def __init__ ( self , loc , cov_factor , cov_diag , validate_args = None ) : <nl> if cov_diag . shape [ - 1 : ] ! = event_shape : <nl> raise ValueError ( " cov_diag must be a batch of vectors with shape { } " . format ( event_shape ) ) <nl> <nl> - scale_batch_shape = _get_batch_shape ( cov_factor , cov_diag ) <nl> + loc_ = loc . unsqueeze ( - 1 ) <nl> + cov_diag_ = cov_diag . unsqueeze ( - 1 ) <nl> try : <nl> - batch_shape = torch . _C . _infer_size ( loc . shape [ : - 1 ] , scale_batch_shape ) <nl> + loc_ , self . cov_factor , cov_diag_ = torch . broadcast_tensors ( loc_ , cov_factor , cov_diag_ ) <nl> except RuntimeError : <nl> raise ValueError ( " Incompatible batch shapes : loc { } , cov_factor { } , cov_diag { } " <nl> . format ( loc . shape , cov_factor . shape , cov_diag . shape ) ) <nl> + self . loc = loc_ [ . . . , 0 ] <nl> + self . cov_diag = cov_diag_ [ . . . , 0 ] <nl> + batch_shape = self . loc . shape [ : - 1 ] <nl> <nl> - loc_shape = batch_shape + event_shape <nl> - self . loc = loc . expand ( loc_shape ) <nl> - self . cov_factor = cov_factor . expand ( loc_shape + cov_factor . shape [ - 1 : ] ) <nl> - self . cov_diag = cov_diag . expand ( loc_shape ) <nl> self . _capacitance_tril = _batch_capacitance_tril ( self . cov_factor , self . cov_diag ) <nl> super ( LowRankMultivariateNormal , self ) . __init__ ( batch_shape , event_shape , <nl> validate_args = validate_args ) <nl> mmm a / torch / distributions / multivariate_normal . py <nl> ppp b / torch / distributions / multivariate_normal . py <nl> <nl> from torch . distributions . utils import lazy_property <nl> <nl> <nl> - def _get_batch_shape ( bmat , bvec ) : <nl> - r " " " <nl> - Given a batch of matrices and a batch of vectors , compute the combined ` batch_shape ` . <nl> - " " " <nl> - try : <nl> - vec_shape = torch . _C . _infer_size ( bvec . shape , bmat . shape [ : - 1 ] ) <nl> - except RuntimeError : <nl> - raise ValueError ( " Incompatible batch shapes : vector { } , matrix { } " . format ( bvec . shape , bmat . shape ) ) <nl> - return vec_shape [ : - 1 ] <nl> - <nl> - <nl> def _batch_mv ( bmat , bvec ) : <nl> r " " " <nl> Performs a batched matrix - vector product , with compatible but different batch shapes . <nl> class MultivariateNormal ( Distribution ) : <nl> def __init__ ( self , loc , covariance_matrix = None , precision_matrix = None , scale_tril = None , validate_args = None ) : <nl> if loc . dim ( ) < 1 : <nl> raise ValueError ( " loc must be at least one - dimensional . " ) <nl> - event_shape = loc . shape [ - 1 : ] <nl> if ( covariance_matrix is not None ) + ( scale_tril is not None ) + ( precision_matrix is not None ) ! = 1 : <nl> raise ValueError ( " Exactly one of covariance_matrix or precision_matrix or scale_tril may be specified . " ) <nl> + <nl> + loc_ = loc . unsqueeze ( - 1 ) # temporarily add dim on right <nl> if scale_tril is not None : <nl> if scale_tril . dim ( ) < 2 : <nl> raise ValueError ( " scale_tril matrix must be at least two - dimensional , " <nl> " with optional leading batch dimensions " ) <nl> self . _unbroadcasted_scale_tril = scale_tril <nl> - batch_shape = _get_batch_shape ( scale_tril , loc ) <nl> - self . scale_tril = scale_tril . expand ( batch_shape + event_shape + event_shape ) <nl> + self . scale_tril , loc_ = torch . broadcast_tensors ( scale_tril , loc_ ) <nl> elif covariance_matrix is not None : <nl> if covariance_matrix . dim ( ) < 2 : <nl> raise ValueError ( " covariance_matrix must be at least two - dimensional , " <nl> " with optional leading batch dimensions " ) <nl> self . _unbroadcasted_scale_tril = _batch_potrf_lower ( covariance_matrix ) <nl> - batch_shape = _get_batch_shape ( covariance_matrix , loc ) <nl> - self . covariance_matrix = covariance_matrix . expand ( batch_shape + event_shape + event_shape ) <nl> + self . covariance_matrix , loc_ = torch . broadcast_tensors ( covariance_matrix , loc_ ) <nl> else : <nl> if precision_matrix . dim ( ) < 2 : <nl> raise ValueError ( " precision_matrix must be at least two - dimensional , " <nl> " with optional leading batch dimensions " ) <nl> covariance_matrix = _batch_inverse ( precision_matrix ) <nl> self . _unbroadcasted_scale_tril = _batch_potrf_lower ( covariance_matrix ) <nl> - batch_shape = _get_batch_shape ( precision_matrix , loc ) <nl> - self . precision_matrix = precision_matrix . expand ( batch_shape + event_shape + event_shape ) <nl> - self . covariance_matrix = covariance_matrix . expand ( batch_shape + event_shape + event_shape ) <nl> + self . covariance_matrix , self . precision_matrix , loc_ = torch . broadcast_tensors ( <nl> + covariance_matrix , precision_matrix , loc_ ) <nl> + self . loc = loc_ [ . . . , 0 ] # drop rightmost dim <nl> <nl> - self . loc = loc . expand ( batch_shape + event_shape ) <nl> + batch_shape , event_shape = self . loc . shape [ : - 1 ] , self . loc . shape [ - 1 : ] <nl> super ( MultivariateNormal , self ) . __init__ ( batch_shape , event_shape , validate_args = validate_args ) <nl> <nl> @ lazy_property <nl> | Make more distributions jittable | pytorch/pytorch | fcfb1c1979b63c77b6fa6186b622dc08253f9791 | 2018-08-23T15:09:49Z |
mmm a / src / messages . cc <nl> ppp b / src / messages . cc <nl> Handle < Object > JSStackFrame : : GetFunctionName ( ) { <nl> <nl> namespace { <nl> <nl> - bool CheckMethodName ( Isolate * isolate , Handle < JSObject > obj , Handle < Name > name , <nl> - Handle < JSFunction > fun , <nl> + bool CheckMethodName ( Isolate * isolate , Handle < JSReceiver > receiver , <nl> + Handle < Name > name , Handle < JSFunction > fun , <nl> LookupIterator : : Configuration config ) { <nl> LookupIterator iter = <nl> - LookupIterator : : PropertyOrElement ( isolate , obj , name , config ) ; <nl> + LookupIterator : : PropertyOrElement ( isolate , receiver , name , config ) ; <nl> if ( iter . state ( ) = = LookupIterator : : DATA ) { <nl> return iter . GetDataValue ( ) . is_identical_to ( fun ) ; <nl> } else if ( iter . state ( ) = = LookupIterator : : ACCESSOR ) { <nl> Handle < Object > JSStackFrame : : GetMethodName ( ) { <nl> return isolate_ - > factory ( ) - > null_value ( ) ; <nl> } <nl> <nl> - Handle < JSReceiver > receiver = <nl> - Object : : ToObject ( isolate_ , receiver_ ) . ToHandleChecked ( ) ; <nl> - if ( ! receiver - > IsJSObject ( ) ) { <nl> + Handle < JSReceiver > receiver ; <nl> + if ( ! Object : : ToObject ( isolate_ , receiver_ ) . ToHandle ( & receiver ) ) { <nl> + DCHECK ( isolate_ - > has_pending_exception ( ) ) ; <nl> + isolate_ - > clear_pending_exception ( ) ; <nl> + isolate_ - > set_external_caught_exception ( false ) ; <nl> return isolate_ - > factory ( ) - > null_value ( ) ; <nl> } <nl> <nl> - Handle < JSObject > obj = Handle < JSObject > : : cast ( receiver ) ; <nl> Handle < String > name ( function_ - > shared ( ) - > name ( ) , isolate_ ) ; <nl> / / ES2015 gives getters and setters name prefixes which must <nl> / / be stripped to find the property name . <nl> Handle < Object > JSStackFrame : : GetMethodName ( ) { <nl> name - > IsUtf8EqualTo ( CStrVector ( " set " ) , true ) ) { <nl> name = isolate_ - > factory ( ) - > NewProperSubString ( name , 4 , name - > length ( ) ) ; <nl> } <nl> - if ( CheckMethodName ( isolate_ , obj , name , function_ , <nl> + if ( CheckMethodName ( isolate_ , receiver , name , function_ , <nl> LookupIterator : : PROTOTYPE_CHAIN_SKIP_INTERCEPTOR ) ) { <nl> return name ; <nl> } <nl> <nl> HandleScope outer_scope ( isolate_ ) ; <nl> Handle < Object > result ; <nl> - for ( PrototypeIterator iter ( isolate_ , obj , kStartAtReceiver ) ; ! iter . IsAtEnd ( ) ; <nl> - iter . Advance ( ) ) { <nl> + for ( PrototypeIterator iter ( isolate_ , receiver , kStartAtReceiver ) ; <nl> + ! iter . IsAtEnd ( ) ; iter . Advance ( ) ) { <nl> Handle < Object > current = PrototypeIterator : : GetCurrent ( iter ) ; <nl> if ( ! current - > IsJSObject ( ) ) break ; <nl> Handle < JSObject > current_obj = Handle < JSObject > : : cast ( current ) ; <nl> Handle < Object > JSStackFrame : : GetTypeName ( ) { <nl> / / TODO ( jgruber ) : Check for strict / constructor here as in <nl> / / CallSitePrototypeGetThis . <nl> <nl> - if ( receiver_ - > IsNullOrUndefined ( isolate_ ) ) <nl> + if ( receiver_ - > IsNullOrUndefined ( isolate_ ) ) { <nl> return isolate_ - > factory ( ) - > null_value ( ) ; <nl> + } else if ( receiver_ - > IsJSProxy ( ) ) { <nl> + return isolate_ - > factory ( ) - > Proxy_string ( ) ; <nl> + } <nl> <nl> - if ( receiver_ - > IsJSProxy ( ) ) return isolate_ - > factory ( ) - > Proxy_string ( ) ; <nl> + Handle < JSReceiver > receiver ; <nl> + if ( ! Object : : ToObject ( isolate_ , receiver_ ) . ToHandle ( & receiver ) ) { <nl> + DCHECK ( isolate_ - > has_pending_exception ( ) ) ; <nl> + isolate_ - > clear_pending_exception ( ) ; <nl> + isolate_ - > set_external_caught_exception ( false ) ; <nl> + return isolate_ - > factory ( ) - > null_value ( ) ; <nl> + } <nl> <nl> - Handle < JSReceiver > receiver_object = <nl> - Object : : ToObject ( isolate_ , receiver_ ) . ToHandleChecked ( ) ; <nl> - return JSReceiver : : GetConstructorName ( receiver_object ) ; <nl> + return JSReceiver : : GetConstructorName ( receiver ) ; <nl> } <nl> <nl> int JSStackFrame : : GetLineNumber ( ) { <nl> void AppendMethodCall ( Isolate * isolate , JSStackFrame * call_site , <nl> } <nl> } <nl> } else { <nl> - builder - > AppendString ( Handle < String > : : cast ( type_name ) ) ; <nl> - builder - > AppendCharacter ( ' . ' ) ; <nl> + if ( IsNonEmptyString ( type_name ) ) { <nl> + builder - > AppendString ( Handle < String > : : cast ( type_name ) ) ; <nl> + builder - > AppendCharacter ( ' . ' ) ; <nl> + } <nl> if ( IsNonEmptyString ( method_name ) ) { <nl> builder - > AppendString ( Handle < String > : : cast ( method_name ) ) ; <nl> } else { <nl> mmm a / test / mjsunit / regress / regress - 3718 . js <nl> ppp b / test / mjsunit / regress / regress - 3718 . js <nl> assertEquals ( " String " , getTypeName ( " " ) ) ; <nl> assertEquals ( " Boolean " , getTypeName ( false ) ) ; <nl> assertEquals ( " Object " , getTypeName ( { } ) ) ; <nl> assertEquals ( " Array " , getTypeName ( [ ] ) ) ; <nl> + assertEquals ( " Proxy " , getTypeName ( new Proxy ( { } , { } ) ) ) ; <nl> assertEquals ( " Custom " , getTypeName ( new ( function Custom ( ) { } ) ( ) ) ) ; <nl> mmm a / test / mjsunit / stack - traces - custom . js <nl> ppp b / test / mjsunit / stack - traces - custom . js <nl> try { <nl> assertEquals ( " k " , frames [ 4 ] . getMethodName ( ) ) ; <nl> assertEquals ( null , frames [ 5 ] . getMethodName ( ) ) ; <nl> } <nl> + <nl> + function testMethodName ( f , frameNumber , expectedName ) { <nl> + try { <nl> + Error . prepareStackTrace = function ( e , frames ) { return frames ; } <nl> + f ( ) ; <nl> + assertUnreachable ( ) ; <nl> + } catch ( e ) { <nl> + const frame = e . stack [ frameNumber ] ; <nl> + assertEquals ( expectedName , frame . getMethodName ( ) ) ; <nl> + } finally { <nl> + Error . prepareStackTrace = undefined ; <nl> + } <nl> + } <nl> + <nl> + const thrower = { valueOf : ( ) = > { throw new Error ( ) ; } } ; <nl> + <nl> + { <nl> + const str = " " ; <nl> + testMethodName ( ( ) = > { str . indexOf ( str , thrower ) ; } , 1 , " indexOf " ) ; <nl> + } <nl> + <nl> + { <nl> + const nr = 42 ; <nl> + testMethodName ( ( ) = > { nr . toString ( thrower ) ; } , 1 , " toString " ) ; <nl> + } <nl> | Fix type conversions in JSStackFrame accessors | v8/v8 | 6af8ca5e82e80d11b021e658300a3d775c7253ce | 2017-08-25T15:32:54Z |
mmm a / src / MainWindow . cpp <nl> ppp b / src / MainWindow . cpp <nl> void MainWindow : : on_actionWebsite_triggered ( ) <nl> QDesktopServices : : openUrl ( QUrl ( " https : / / sqlitebrowser . org " ) ) ; <nl> } <nl> <nl> + void MainWindow : : on_actionDonatePatreon_triggered ( ) <nl> + { <nl> + QDesktopServices : : openUrl ( QUrl ( " https : / / www . patreon . com / bePatron ? u = 11578749 " ) ) ; <nl> + } <nl> + <nl> void MainWindow : : updateBrowseDataColumnWidth ( int section , int / * old_size * / , int new_size ) <nl> { <nl> QSet < int > selectedCols ( ui - > dataTable - > selectedCols ( ) ) ; <nl> mmm a / src / MainWindow . h <nl> ppp b / src / MainWindow . h <nl> private slots : <nl> void on_actionBug_report_triggered ( ) ; <nl> void on_actionSqlCipherFaq_triggered ( ) ; <nl> void on_actionWebsite_triggered ( ) ; <nl> + void on_actionDonatePatreon_triggered ( ) ; <nl> void updateBrowseDataColumnWidth ( int section , int / * old_size * / , int new_size ) ; <nl> bool loadProject ( QString filename = QString ( ) , bool readOnly = false ) ; <nl> void saveProject ( ) ; <nl> mmm a / src / MainWindow . ui <nl> ppp b / src / MainWindow . ui <nl> You can drag SQL statements from an object row and drop them into other applicat <nl> < addaction name = " actionWiki " / > <nl> < addaction name = " actionSqlCipherFaq " / > <nl> < addaction name = " actionBug_report " / > <nl> + < addaction name = " actionDonatePatreon " / > <nl> < addaction name = " helpAboutAction " / > <nl> < / widget > <nl> < widget class = " QMenu " name = " menuTools " > <nl> You can drag SQL statements from the Schema column and drop them into the SQL ed <nl> < enum > QAction : : NoRole < / enum > <nl> < / property > <nl> < / action > <nl> + < action name = " actionDonatePatreon " > <nl> + < property name = " icon " > <nl> + < iconset resource = " icons / icons . qrc " > <nl> + < normaloff > : / icons / browser_open < / normaloff > : / icons / browser_open < / iconset > <nl> + < / property > <nl> + < property name = " text " > <nl> + < string > & amp ; Donate on Patreon . . . < / string > <nl> + < / property > <nl> + < property name = " menuRole " > <nl> + < enum > QAction : : NoRole < / enum > <nl> + < / property > <nl> + < / action > <nl> < action name = " actionSaveProject " > <nl> < property name = " icon " > <nl> < iconset resource = " icons / icons . qrc " > <nl> | Add menu item for our Patreon page | sqlitebrowser/sqlitebrowser | 1a780ebddcf12d086f7f581ecb5391b047f798e6 | 2018-08-12T20:25:02Z |
mmm a / cocos / scripting / lua - bindings / auto / api / Layout . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / Layout . lua <nl> <nl> - - @ param self <nl> - - @ return size_table # size_table ret ( return value : size_table ) <nl> <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + - - @ function [ parent = # Layout ] forceDoLayout <nl> + - - @ param self <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # Layout ] getLayoutType <nl> - - @ param self <nl> mmm a / cocos / scripting / lua - bindings / auto / api / Node . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / Node . lua <nl> <nl> - - @ param # string str <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm @ function [ parent = # Node ] removeComponent <nl> + - - @ overload self , cc . Component <nl> + - - @ overload self , string <nl> + - - @ function [ parent = # Node ] removeComponent <nl> - - @ param self <nl> - - @ param # string str <nl> mmm @ return bool # bool ret ( return value : bool ) <nl> - <nl> + - - @ return bool # bool ret ( retunr value : bool ) <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # Node ] setPhysicsBody <nl> - - @ param self <nl> mmm a / cocos / scripting / lua - bindings / auto / lua_cocos2dx_auto . cpp <nl> ppp b / cocos / scripting / lua - bindings / auto / lua_cocos2dx_auto . cpp <nl> int lua_cocos2dx_Node_removeComponent ( lua_State * tolua_S ) <nl> int argc = 0 ; <nl> cocos2d : : Node * cobj = nullptr ; <nl> bool ok = true ; <nl> - <nl> # if COCOS2D_DEBUG > = 1 <nl> tolua_Error tolua_err ; <nl> # endif <nl> <nl> - <nl> # if COCOS2D_DEBUG > = 1 <nl> if ( ! tolua_isusertype ( tolua_S , 1 , " cc . Node " , 0 , & tolua_err ) ) goto tolua_lerror ; <nl> # endif <nl> - <nl> cobj = ( cocos2d : : Node * ) tolua_tousertype ( tolua_S , 1 , 0 ) ; <nl> - <nl> # if COCOS2D_DEBUG > = 1 <nl> - if ( ! cobj ) <nl> + if ( ! cobj ) <nl> { <nl> tolua_error ( tolua_S , " invalid ' cobj ' in function ' lua_cocos2dx_Node_removeComponent ' " , nullptr ) ; <nl> return 0 ; <nl> } <nl> # endif <nl> - <nl> argc = lua_gettop ( tolua_S ) - 1 ; <nl> - if ( argc = = 1 ) <nl> - { <nl> - std : : string arg0 ; <nl> + do { <nl> + if ( argc = = 1 ) { <nl> + cocos2d : : Component * arg0 ; <nl> + ok & = luaval_to_object < cocos2d : : Component > ( tolua_S , 2 , " cc . Component " , & arg0 ) ; <nl> <nl> - ok & = luaval_to_std_string ( tolua_S , 2 , & arg0 ) ; <nl> - if ( ! ok ) <nl> - return 0 ; <nl> - bool ret = cobj - > removeComponent ( arg0 ) ; <nl> - tolua_pushboolean ( tolua_S , ( bool ) ret ) ; <nl> - return 1 ; <nl> - } <nl> + if ( ! ok ) { break ; } <nl> + bool ret = cobj - > removeComponent ( arg0 ) ; <nl> + tolua_pushboolean ( tolua_S , ( bool ) ret ) ; <nl> + return 1 ; <nl> + } <nl> + } while ( 0 ) ; <nl> + ok = true ; <nl> + do { <nl> + if ( argc = = 1 ) { <nl> + std : : string arg0 ; <nl> + ok & = luaval_to_std_string ( tolua_S , 2 , & arg0 ) ; <nl> + <nl> + if ( ! ok ) { break ; } <nl> + bool ret = cobj - > removeComponent ( arg0 ) ; <nl> + tolua_pushboolean ( tolua_S , ( bool ) ret ) ; <nl> + return 1 ; <nl> + } <nl> + } while ( 0 ) ; <nl> + ok = true ; <nl> CCLOG ( " % s has wrong number of arguments : % d , was expecting % d \ n " , " removeComponent " , argc , 1 ) ; <nl> return 0 ; <nl> <nl> mmm a / cocos / scripting / lua - bindings / auto / lua_cocos2dx_ui_auto . cpp <nl> ppp b / cocos / scripting / lua - bindings / auto / lua_cocos2dx_ui_auto . cpp <nl> int lua_cocos2dx_ui_Layout_getBackGroundImageTextureSize ( lua_State * tolua_S ) <nl> <nl> return 0 ; <nl> } <nl> + int lua_cocos2dx_ui_Layout_forceDoLayout ( lua_State * tolua_S ) <nl> + { <nl> + int argc = 0 ; <nl> + cocos2d : : ui : : Layout * cobj = nullptr ; <nl> + bool ok = true ; <nl> + <nl> + # if COCOS2D_DEBUG > = 1 <nl> + tolua_Error tolua_err ; <nl> + # endif <nl> + <nl> + <nl> + # if COCOS2D_DEBUG > = 1 <nl> + if ( ! tolua_isusertype ( tolua_S , 1 , " ccui . Layout " , 0 , & tolua_err ) ) goto tolua_lerror ; <nl> + # endif <nl> + <nl> + cobj = ( cocos2d : : ui : : Layout * ) tolua_tousertype ( tolua_S , 1 , 0 ) ; <nl> + <nl> + # if COCOS2D_DEBUG > = 1 <nl> + if ( ! cobj ) <nl> + { <nl> + tolua_error ( tolua_S , " invalid ' cobj ' in function ' lua_cocos2dx_ui_Layout_forceDoLayout ' " , nullptr ) ; <nl> + return 0 ; <nl> + } <nl> + # endif <nl> + <nl> + argc = lua_gettop ( tolua_S ) - 1 ; <nl> + if ( argc = = 0 ) <nl> + { <nl> + if ( ! ok ) <nl> + return 0 ; <nl> + cobj - > forceDoLayout ( ) ; <nl> + return 0 ; <nl> + } <nl> + CCLOG ( " % s has wrong number of arguments : % d , was expecting % d \ n " , " forceDoLayout " , argc , 0 ) ; <nl> + return 0 ; <nl> + <nl> + # if COCOS2D_DEBUG > = 1 <nl> + tolua_lerror : <nl> + tolua_error ( tolua_S , " # ferror in function ' lua_cocos2dx_ui_Layout_forceDoLayout ' . " , & tolua_err ) ; <nl> + # endif <nl> + <nl> + return 0 ; <nl> + } <nl> int lua_cocos2dx_ui_Layout_getLayoutType ( lua_State * tolua_S ) <nl> { <nl> int argc = 0 ; <nl> int lua_register_cocos2dx_ui_Layout ( lua_State * tolua_S ) <nl> tolua_function ( tolua_S , " isPassFocusToChild " , lua_cocos2dx_ui_Layout_isPassFocusToChild ) ; <nl> tolua_function ( tolua_S , " setBackGroundImageCapInsets " , lua_cocos2dx_ui_Layout_setBackGroundImageCapInsets ) ; <nl> tolua_function ( tolua_S , " getBackGroundImageTextureSize " , lua_cocos2dx_ui_Layout_getBackGroundImageTextureSize ) ; <nl> + tolua_function ( tolua_S , " forceDoLayout " , lua_cocos2dx_ui_Layout_forceDoLayout ) ; <nl> tolua_function ( tolua_S , " getLayoutType " , lua_cocos2dx_ui_Layout_getLayoutType ) ; <nl> tolua_function ( tolua_S , " setPassFocusToChild " , lua_cocos2dx_ui_Layout_setPassFocusToChild ) ; <nl> tolua_function ( tolua_S , " getBackGroundStartColor " , lua_cocos2dx_ui_Layout_getBackGroundStartColor ) ; <nl> mmm a / cocos / scripting / lua - bindings / auto / lua_cocos2dx_ui_auto . hpp <nl> ppp b / cocos / scripting / lua - bindings / auto / lua_cocos2dx_ui_auto . hpp <nl> int register_all_cocos2dx_ui ( lua_State * tolua_S ) ; <nl> <nl> <nl> <nl> + <nl> <nl> <nl> # endif / / __cocos2dx_ui_h__ <nl> | [ AUTO ] : updating luabinding automatically | cocos2d/cocos2d-x | c8c17b68dfeb620a92527ad33bc33233e4dfefd5 | 2014-07-22T09:11:18Z |
mmm a / test / brpc_http_rpc_protocol_unittest . cpp <nl> ppp b / test / brpc_http_rpc_protocol_unittest . cpp <nl> <nl> # include " butil / time . h " <nl> # include " butil / macros . h " <nl> # include " butil / files / scoped_file . h " <nl> + # include " butil / fd_guard . h " <nl> # include " brpc / socket . h " <nl> # include " brpc / acceptor . h " <nl> # include " brpc / server . h " <nl> TEST_F ( HttpTest , http2_header_after_data ) { <nl> ASSERT_EQ ( * user_defined2 , " b " ) ; <nl> } <nl> <nl> - TEST_F ( HttpTest , http2_goaway ) { <nl> + TEST_F ( HttpTest , http2_goaway_sanity ) { <nl> brpc : : Controller cntl ; <nl> / / Prepare request <nl> butil : : IOBuf req_out ; <nl> TEST_F ( HttpTest , http2_goaway ) { <nl> ASSERT_TRUE ( st . error_data ( ) . ends_with ( " the connection just issued GOAWAY " ) ) ; <nl> } <nl> <nl> + class AfterRecevingGoAway : public : : google : : protobuf : : Closure { <nl> + public : <nl> + void Run ( ) { <nl> + ASSERT_EQ ( brpc : : EHTTP , cntl . ErrorCode ( ) ) ; <nl> + delete this ; <nl> + } <nl> + brpc : : Controller cntl ; <nl> + } ; <nl> + <nl> + TEST_F ( HttpTest , http2_handle_goaway_streams ) { <nl> + const butil : : EndPoint ep ( butil : : IP_ANY , 5961 ) ; <nl> + butil : : fd_guard listenfd ( butil : : tcp_listen ( ep ) ) ; <nl> + ASSERT_GT ( listenfd , 0 ) ; <nl> + <nl> + brpc : : Channel channel ; <nl> + brpc : : ChannelOptions options ; <nl> + options . protocol = brpc : : PROTOCOL_H2 ; <nl> + ASSERT_EQ ( 0 , channel . Init ( ep , & options ) ) ; <nl> + <nl> + int req_size = 10 ; <nl> + std : : vector < brpc : : CallId > ids ( req_size ) ; <nl> + for ( int i = 0 ; i < req_size ; i + + ) { <nl> + AfterRecevingGoAway * done = new AfterRecevingGoAway ; <nl> + brpc : : Controller & cntl = done - > cntl ; <nl> + ids . push_back ( cntl . call_id ( ) ) ; <nl> + cntl . set_timeout_ms ( - 1 ) ; <nl> + cntl . http_request ( ) . uri ( ) = " / it - doesnt - matter " ; <nl> + channel . CallMethod ( NULL , & cntl , NULL , NULL , done ) ; <nl> + } <nl> + <nl> + int servfd = accept ( listenfd , NULL , NULL ) ; <nl> + ASSERT_GT ( servfd , 0 ) ; <nl> + / / Sleep for a while to make sure that server has received all data . <nl> + bthread_usleep ( 2000 ) ; <nl> + char goawaybuf [ brpc : : policy : : FRAME_HEAD_SIZE + 8 ] ; <nl> + SerializeFrameHead ( goawaybuf , 8 , brpc : : policy : : H2_FRAME_GOAWAY , 0 , 0 ) ; <nl> + SaveUint32 ( goawaybuf + brpc : : policy : : FRAME_HEAD_SIZE , 0 ) ; <nl> + SaveUint32 ( goawaybuf + brpc : : policy : : FRAME_HEAD_SIZE + 4 , 0 ) ; <nl> + ASSERT_EQ ( brpc : : policy : : FRAME_HEAD_SIZE + 8 , : : write ( servfd , goawaybuf , brpc : : policy : : FRAME_HEAD_SIZE + 8 ) ) ; <nl> + <nl> + / / After receving GOAWAY , the callbacks in client should be run correctly . <nl> + for ( int i = 0 ; i < req_size ; i + + ) { <nl> + brpc : : Join ( ids [ i ] ) ; <nl> + } <nl> + } <nl> } / / namespace <nl> | add UT : http2_handle_goaway_streams | apache/incubator-brpc | ccb9018820372fa1c9345a61de435f3b61b84f29 | 2019-05-28T05:59:20Z |
mmm a / lib / SIL / SILGen / Cleanup . cpp <nl> ppp b / lib / SIL / SILGen / Cleanup . cpp <nl> void CleanupManager : : emitReturnAndCleanups ( SILLocation loc , Value returnValue ) { <nl> for ( auto & cleanup : Stack ) <nl> if ( cleanup . isActive ( ) ) <nl> cleanup . emit ( Gen ) ; <nl> - if ( Gen . destructorCleanupBB ) { <nl> - assert ( Gen . hasVoidReturn & & " destructor with non - void return ? ! " ) ; <nl> - B . createBranch ( Gen . destructorCleanupBB ) ; <nl> + if ( Gen . epilogBB ) { <nl> + assert ( Gen . hasVoidReturn & & " ctor or dtor with non - void return ? ! " ) ; <nl> + B . createBranch ( Gen . epilogBB ) ; <nl> } else { <nl> B . createReturn ( loc , returnValue ) ; <nl> } <nl> mmm a / lib / SIL / SILGen / SILGen . cpp <nl> ppp b / lib / SIL / SILGen / SILGen . cpp <nl> <nl> # include " SILGen . h " <nl> # include " llvm / ADT / Optional . h " <nl> # include " swift / AST / AST . h " <nl> + # include " swift / SIL / BBArgument . h " <nl> using namespace swift ; <nl> using namespace Lowering ; <nl> <nl> SILGenFunction : : SILGenFunction ( SILGenModule & SGM , Function & F , <nl> : SGM ( SGM ) , F ( F ) , B ( new ( F . getModule ( ) ) BasicBlock ( & F ) , F ) , <nl> Cleanups ( * this ) , <nl> hasVoidReturn ( hasVoidReturn ) , <nl> - destructorCleanupBB ( nullptr ) { <nl> + epilogBB ( nullptr ) { <nl> } <nl> <nl> SILGenFunction : : SILGenFunction ( SILGenModule & SGM , Function & F , FuncExpr * FE ) <nl> SILGenFunction : : SILGenFunction ( SILGenModule & SGM , Function & F , <nl> emitDestructorProlog ( DD ) ; <nl> } <nl> <nl> + SILGenFunction : : SILGenFunction ( SILGenModule & SGM , Function & F , <nl> + ConstructorDecl * CD ) <nl> + / / Although a constructor implicitly returns ' this ' , from the body ' s <nl> + / / perspective it looks like a void function , hence the hasVoidReturn flag . <nl> + : SILGenFunction ( SGM , F , / * hasVoidReturn = * / true ) <nl> + { <nl> + / / In addition to the declared arguments , the constructor implicitly takes <nl> + / / the metatype as its first argument , like a static function . <nl> + Type metatype = CD - > getType ( ) - > castTo < AnyFunctionType > ( ) - > getInput ( ) ; <nl> + new ( F . getModule ( ) ) BBArgument ( getLoweredType ( metatype ) , F . begin ( ) ) ; <nl> + <nl> + emitProlog ( CD - > getArguments ( ) , CD - > getImplicitThisDecl ( ) - > getType ( ) ) ; <nl> + } <nl> + <nl> / / / SILGenFunction destructor - called after the entire function ' s AST has been <nl> / / / visited . This handles " falling off the end of the function " logic . <nl> SILGenFunction : : ~ SILGenFunction ( ) { <nl> SILGenFunction : : ~ SILGenFunction ( ) { <nl> / / If we have an unterminated block , it is either an implicit return of an <nl> / / empty tuple , or a dynamically unreachable location . <nl> if ( hasVoidReturn ) { <nl> + assert ( ! epilogBB & & " epilog bb not terminated ? ! " ) ; <nl> Value emptyTuple = B . createEmptyTuple ( SILLocation ( ) ) ; <nl> Cleanups . emitReturnAndCleanups ( SILLocation ( ) , emptyTuple ) ; <nl> } else { <nl> Function * SILGenModule : : emitFunction ( SILConstant : : Loc decl , FuncExpr * fe ) { <nl> return f ; <nl> } <nl> <nl> + Function * SILGenModule : : emitConstructor ( ConstructorDecl * decl ) { <nl> + / / Ignore prototypes . <nl> + / / FIXME : generate default constructor , which appears in the AST as a <nl> + / / prototype <nl> + if ( decl - > getBody ( ) = = nullptr ) return nullptr ; <nl> + <nl> + SILConstant constant ( decl ) ; <nl> + Function * f = preEmitFunction ( constant , decl ) ; <nl> + SILGenFunction ( * this , * f , decl ) . emitConstructorBody ( decl ) ; <nl> + postEmitFunction ( constant , f ) ; <nl> + <nl> + return f ; <nl> + } <nl> + <nl> Function * SILGenModule : : emitClosure ( ClosureExpr * ce ) { <nl> SILConstant constant ( ce ) ; <nl> Function * f = preEmitFunction ( constant , ce ) ; <nl> mmm a / lib / SIL / SILGen / SILGen . h <nl> ppp b / lib / SIL / SILGen / SILGen . h <nl> class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor < SILGenModule > { <nl> / / / emitClosure - Generates code for the given ClosureExpr and adds the <nl> / / / Function to the current SILModule under the name SILConstant ( ce ) . <nl> Function * emitClosure ( ClosureExpr * ce ) ; <nl> + / / / emitConstructor - Generates code for the given ConstructorDecl and adds <nl> + / / / the Function to the current SILModule under the name SILConstant ( decl ) . <nl> + Function * emitConstructor ( ConstructorDecl * decl ) ; <nl> / / / emitDestructor - Generates code for the given DestructorDecl and adds <nl> / / / the Function to the current SILModule under the name SILConstant ( dd ) . <nl> / / / FIXME : implicit destructors <nl> class LLVM_LIBRARY_VISIBILITY SILGenType : public ASTVisitor < SILGenType > { <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> void visitNominalTypeDecl ( NominalTypeDecl * ntd ) ; <nl> void visitFuncDecl ( FuncDecl * fd ) ; <nl> + void visitConstructorDecl ( ConstructorDecl * cd ) ; <nl> / / FIXME : implicit destructors <nl> void visitDestructorDecl ( DestructorDecl * dd ) ; <nl> - / / FIXME : constructor , other special members <nl> + / / FIXME : other special members ? <nl> <nl> - <nl> - / / no - ops . We don ' t deal with the layout of types . <nl> + / / no - ops . We don ' t deal with the layout of types here . <nl> void visitPatternBindingDecl ( PatternBindingDecl * ) { } <nl> void visitVarDecl ( VarDecl * ) { } <nl> } ; <nl> class LLVM_LIBRARY_VISIBILITY SILGenFunction <nl> / / / function is valid . <nl> bool hasVoidReturn ; <nl> <nl> - / / / In a destructor context , the basic block for the implicit destruction <nl> - / / / behavior . This is where ' return ' ing from or reaching the end of the <nl> - / / / destructor will jump to . Null in non - destructor contexts . <nl> - BasicBlock * destructorCleanupBB ; <nl> + / / / In a constructor or destructor context , returning from the body doesn ' t <nl> + / / / return from the current SIL function but instead branches to an epilog <nl> + / / / block that executes implicit behavior . epilogBB points to the epilog <nl> + / / / block that ' return ' jumps to in those contexts , or ' null ' if returning <nl> + / / / can return normally from the function . <nl> + BasicBlock * epilogBB ; <nl> <nl> public : <nl> SILGenFunction ( SILGenModule & SGM , Function & F , bool hasVoidReturn ) ; <nl> SILGenFunction ( SILGenModule & SGM , Function & F , FuncExpr * FE ) ; <nl> SILGenFunction ( SILGenModule & SGM , Function & F , ClosureExpr * CE ) ; <nl> SILGenFunction ( SILGenModule & SGM , Function & F , DestructorDecl * DD ) ; <nl> + SILGenFunction ( SILGenModule & SGM , Function & F , ConstructorDecl * CD ) ; <nl> ~ SILGenFunction ( ) ; <nl> <nl> / / / emitProlog - Generates prolog code to allocate and clean up mutable <nl> / / / storage for closure captures and local arguments . <nl> void emitProlog ( CapturingExpr * ce , ArrayRef < Pattern * > paramPatterns , <nl> Type resultType ) ; <nl> + void emitProlog ( ArrayRef < Pattern * > paramPatterns , <nl> + Type resultType ) ; <nl> / / / emitDestructorProlog - Generates prolog code for a destructor . Unlike <nl> / / / a normal function , the destructor does not consume its <nl> / / / ' this ' argument at + 1 retain count . <nl> void emitDestructorProlog ( DestructorDecl * DD ) ; <nl> + <nl> / / / emitClosureBody - Generates code for a ClosureExpr body . This is akin <nl> / / / to visiting the body as if wrapped in a ReturnStmt . <nl> void emitClosureBody ( Expr * body ) ; <nl> - / / / emitDestructorBody - Generates code for a DestructorDecl body . <nl> + / / / emitDestructorBody - Generates code for a DestructorDecl body . This <nl> + / / / implicitly releases the elements of the class and calls the base <nl> + / / / class d <nl> void emitDestructorBody ( DestructorDecl * dd ) ; <nl> + / / / emitConstructorBody - Generates code for a ConstructorDecl body . This <nl> + / / / implicitly allocates the new ' this ' value , invokes the base <nl> + / / / constructor if any , and returns the ' this ' value . <nl> + / / / FIXME : allocating and non - allocating entry points <nl> + void emitConstructorBody ( ConstructorDecl * ctor ) ; <nl> <nl> / / / Return a stable reference to the current cleanup . <nl> CleanupsDepth getCleanupsDepth ( ) const { <nl> mmm a / lib / SIL / SILGen / SILGenDecl . cpp <nl> ppp b / lib / SIL / SILGen / SILGenDecl . cpp <nl> void SILGenFunction : : emitProlog ( CapturingExpr * ce , <nl> for ( auto capture : ce - > getCaptures ( ) ) { <nl> makeCaptureBBArguments ( * this , capture ) ; <nl> } <nl> - <nl> + <nl> + emitProlog ( paramPatterns , resultType ) ; <nl> + } <nl> + <nl> + void SILGenFunction : : emitProlog ( ArrayRef < Pattern * > paramPatterns , <nl> + Type resultType ) { <nl> / / Emit the argument variables . <nl> for ( auto & paramPattern : paramPatterns ) { <nl> / / Allocate the local mutable argument storage and set up an Initialization . <nl> llvm : : OwningPtr < Initialization > argInit ( <nl> - InitializationForPattern ( * this ) . visit ( paramPattern ) ) ; <nl> + InitializationForPattern ( * this ) . visit ( paramPattern ) ) ; <nl> <nl> / / Add the BBArguments and use them to initialize the local argument values . <nl> ArgumentInitVisitor ( * this , F ) . visit ( paramPattern , argInit . get ( ) ) ; <nl> void SILGenFunction : : emitProlog ( CapturingExpr * ce , <nl> if ( returnTI . isAddressOnly ( ) ) { <nl> IndirectReturnAddress = new ( SGM . M ) BBArgument ( returnTI . getLoweredType ( ) , <nl> F . begin ( ) ) ; <nl> - } <nl> + } <nl> } <nl> <nl> namespace { <nl> namespace { <nl> Value thisAddr ; <nl> public : <nl> CleanupDestructorThis ( Value thisAddr ) : thisAddr ( thisAddr ) { <nl> - llvm : : errs ( ) < < " make cleanup \ n " ; <nl> } <nl> <nl> void emit ( SILGenFunction & gen ) override { <nl> - llvm : : errs ( ) < < " emit cleanup \ n " ; <nl> gen . B . createDeallocVar ( SILLocation ( ) , AllocKind : : Stack , thisAddr ) ; <nl> } <nl> } ; <nl> void SILGenFunction : : emitDestructorProlog ( DestructorDecl * DD ) { <nl> Value thisAddr = B . createAllocVar ( DD , AllocKind : : Stack , thisType ) ; <nl> Cleanups . pushCleanup < CleanupDestructorThis > ( thisAddr ) ; <nl> B . createStore ( DD , thisValue , thisAddr ) ; <nl> - VarLocs [ thisDecl ] = { Value ( ) , thisAddr } ; <nl> - <nl> - / / Create a basic block to jump to for the implicit destruction behavior <nl> - / / of releasing the elements and calling the base class destructor . <nl> - / / We won ' t actually emit the block until we finish with the destructor body . <nl> - destructorCleanupBB = new ( SGM . M ) BasicBlock ( & F , " destructor " ) ; <nl> + VarLocs [ thisDecl ] = { Value ( ) , thisAddr } ; <nl> } <nl> <nl> static void rrLoadableValueElement ( SILGenFunction & gen , SILLocation loc , <nl> void SILGenType : : visitFuncDecl ( FuncDecl * fd ) { <nl> void SILGenType : : visitDestructorDecl ( DestructorDecl * dd ) { <nl> SGM . emitDestructor ( dd ) ; <nl> } <nl> + <nl> + void SILGenType : : visitConstructorDecl ( ConstructorDecl * cd ) { <nl> + SGM . emitConstructor ( cd ) ; <nl> + } <nl> mmm a / lib / SIL / SILGen / SILGenExpr . cpp <nl> ppp b / lib / SIL / SILGen / SILGenExpr . cpp <nl> void SILGenFunction : : emitClosureBody ( Expr * body ) { <nl> } <nl> <nl> void SILGenFunction : : emitDestructorBody ( swift : : DestructorDecl * dd ) { <nl> - / / Emit the destructor body normally . <nl> + / / Create a basic block to jump to for the implicit destruction behavior <nl> + / / of releasing the elements and calling the base class destructor . <nl> + / / We won ' t actually emit the block until we finish with the destructor body . <nl> + epilogBB = new ( SGM . M ) BasicBlock ( & F , " destructor " ) ; <nl> + <nl> + / / Emit the destructor body . <nl> visit ( dd - > getBody ( ) ) ; <nl> + <nl> / / Returning from the destructor body jumps to the cleanup block . <nl> if ( B . hasValidInsertionPoint ( ) ) <nl> Cleanups . emitReturnAndCleanups ( dd , Value ( ) ) ; <nl> <nl> / / Emit the cleanup block . <nl> - assert ( destructorCleanupBB & & <nl> - " did not create cleanup block for destructor ? ! " ) ; <nl> - B . emitBlock ( destructorCleanupBB ) ; <nl> + assert ( epilogBB & & <nl> + " did not create epilog block for destructor ? ! " ) ; <nl> + B . emitBlock ( epilogBB ) ; <nl> <nl> assert ( ! F . begin ( ) - > bbarg_empty ( ) & & " destructor has no this argument ? ! " ) ; <nl> Value thisValue = * F . begin ( ) - > bbarg_begin ( ) ; <nl> void SILGenFunction : : emitDestructorBody ( swift : : DestructorDecl * dd ) { <nl> B . createReturn ( dd , B . createEmptyTuple ( dd ) ) ; <nl> } <nl> <nl> + namespace { <nl> + class CleanupMaterializeThisValue : public Cleanup { <nl> + ConstructorDecl * ctor ; <nl> + Value thisLV ; <nl> + Value & thisValue ; <nl> + public : <nl> + CleanupMaterializeThisValue ( ConstructorDecl * ctor , <nl> + Value thisLV , Value & thisValue ) <nl> + : ctor ( ctor ) , thisLV ( thisLV ) , thisValue ( thisValue ) { } <nl> + <nl> + void emit ( SILGenFunction & gen ) override { <nl> + thisValue = gen . B . createLoad ( ctor , thisLV ) ; <nl> + gen . B . createDeallocVar ( ctor , AllocKind : : Stack , thisLV ) ; <nl> + } <nl> + } ; <nl> + } <nl> + <nl> + void SILGenFunction : : emitConstructorBody ( ConstructorDecl * ctor ) { <nl> + / / <nl> + / / Create the ' this ' value . <nl> + / / <nl> + VarDecl * thisDecl = ctor - > getImplicitThisDecl ( ) ; <nl> + SILType thisTy = getLoweredType ( thisDecl - > getType ( ) ) ; <nl> + Value thisLV , thisValue ; <nl> + assert ( ( ! ctor - > getAllocThisExpr ( ) | | thisTy . hasReferenceSemantics ( ) ) <nl> + & & " alloc_this expr for value type ? ! " ) ; <nl> + if ( thisTy . hasReferenceSemantics ( ) ) { <nl> + if ( ctor - > getAllocThisExpr ( ) ) { <nl> + FullExpr allocThisScope ( Cleanups ) ; <nl> + / / If the constructor has an alloc - this expr , emit it to get " this " . <nl> + thisValue = visit ( ctor - > getAllocThisExpr ( ) ) . forward ( * this ) ; <nl> + assert ( thisValue . getType ( ) = = thisTy & & <nl> + " alloc - this expr type did not match this type ? ! " ) ; <nl> + } else { <nl> + / / Otherwise , emit an alloc_ref instruction . <nl> + / / FIXME : should have a cleanup in case of exception <nl> + thisValue = B . createAllocRef ( ctor , AllocKind : : Heap , thisTy ) ; <nl> + } <nl> + <nl> + / / Materialize an lvalue for ' this ' . <nl> + thisLV = B . createAllocVar ( ctor , AllocKind : : Stack , thisTy ) ; <nl> + Cleanups . pushCleanup < CleanupMaterializeAllocation > ( thisLV ) ; <nl> + B . createRetain ( ctor , thisValue ) ; <nl> + B . createStore ( ctor , thisValue , thisLV ) ; <nl> + Cleanups . pushCleanup < CleanupMaterializeValue > ( thisLV ) ; <nl> + } else if ( thisTy . isAddressOnly ( ) ) { <nl> + / / If ' this ' is of an address - only value type , then we can construct the <nl> + / / indirect return argument directly . <nl> + assert ( IndirectReturnAddress & & <nl> + " address - only constructor without indirect return ? ! " ) ; <nl> + thisLV = IndirectReturnAddress ; <nl> + } else { <nl> + / / Materialize a temporary for the loadable value type . <nl> + thisLV = B . createAllocVar ( ctor , AllocKind : : Stack , <nl> + thisTy ) ; <nl> + Cleanups . pushCleanup < CleanupMaterializeThisValue > ( ctor , thisLV , thisValue ) ; <nl> + } <nl> + VarLocs [ thisDecl ] = { Value ( ) , thisLV } ; <nl> + <nl> + / / Create a basic block to jump to for the implicit ' this ' return . <nl> + / / We won ' t emit this until after we ' ve emitted the body . <nl> + epilogBB = new ( SGM . M ) BasicBlock ( & F , " constructor " ) ; <nl> + <nl> + / / <nl> + / / Emit the constructor body . <nl> + / / FIXME : call base class constructor <nl> + / / <nl> + visit ( ctor - > getBody ( ) ) ; <nl> + / / Returning from the body takes us to the epilog block . <nl> + if ( B . hasValidInsertionPoint ( ) ) <nl> + Cleanups . emitReturnAndCleanups ( ctor , Value ( ) ) ; <nl> + <nl> + / / <nl> + / / Return ' this ' . <nl> + / / <nl> + B . emitBlock ( epilogBB ) ; <nl> + if ( thisTy . isAddressOnly ( ) ) { <nl> + / / We already initialized the return value in - place . <nl> + B . createReturn ( ctor , B . createEmptyTuple ( ctor ) ) ; <nl> + } else { <nl> + assert ( thisValue & & " thisValue not initialized ? ! " ) ; <nl> + B . createReturn ( ctor , thisValue ) ; <nl> + } <nl> + } <nl> + <nl> ManagedValue SILGenFunction : : visitInterpolatedStringLiteralExpr ( <nl> InterpolatedStringLiteralExpr * E , <nl> SGFContext C ) <nl> | SILGen : Generate explicit constructors . | apple/swift | 984f1dad91f4c84bcedd9071b0c9f40eb80a49c4 | 2013-01-03T20:12:35Z |
mmm a / debian / mongo . 1 <nl> ppp b / debian / mongo . 1 <nl> If JavaScript files are specified on the command line , the shell will run non \ - i <nl> . B mongo <nl> start the shell , connecting to the server at localhost : 27017 and using the test database <nl> . TP <nl> - . B mongod foo <nl> + . B mongo foo <nl> start the shell using the foo database at localhost : 27017 <nl> . TP <nl> - . B mongod 192 . 169 . 0 . 5 / foo <nl> + . B mongo 192 . 169 . 0 . 5 / foo <nl> start the shell using the foo database at 192 . 169 . 0 . 5 : 27017 <nl> . TP <nl> - . B mongod 192 . 169 . 0 . 5 : 9999 / foo <nl> + . B mongo 192 . 169 . 0 . 5 : 9999 / foo <nl> start the shell using the foo database at 192 . 169 . 0 . 5 : 9999 <nl> . TP <nl> - . B mongod script1 . js script2 . js script3 . js <nl> + . B mongo script1 . js script2 . js script3 . js <nl> run three scripts and exit <nl> . SH " OPTIONS " <nl> . TP <nl> | Fix typos in debian / mongo . 1 for SERVER - 1131 | mongodb/mongo | 7f50e165b60c576d331b3d878ec54c13fd554fad | 2010-05-17T19:44:26Z |
mmm a / xbmc / GUIInfoManager . cpp <nl> ppp b / xbmc / GUIInfoManager . cpp <nl> int CGUIInfoManager : : TranslateSingleString ( const CStdString & strCondition ) <nl> return AddMultiInfo ( GUIInfo ( SYSTEM_ADDON_ICON , ConditionalStringParameter ( label ) , 1 ) ) ; <nl> } <nl> else if ( property = = " idletime " ) <nl> - { / / TODO : switch to GUIInfo <nl> - int time = atoi ( info [ 1 ] . second . c_str ( ) ) ; <nl> - if ( time > SYSTEM_IDLE_TIME_FINISH - SYSTEM_IDLE_TIME_START ) <nl> - time = SYSTEM_IDLE_TIME_FINISH - SYSTEM_IDLE_TIME_START ; <nl> - if ( time > 0 ) <nl> - return SYSTEM_IDLE_TIME_START + time ; <nl> - } <nl> + return AddMultiInfo ( GUIInfo ( SYSTEM_IDLE_TIME , atoi ( info [ 1 ] . second . c_str ( ) ) ) ) ; <nl> else if ( property = = " alarmlessorequal " ) <nl> { <nl> vector < CStdString > params ; <nl> bool CGUIInfoManager : : GetBool ( int condition1 , int contextWindow , const CGUIListI <nl> bReturn = false ; <nl> else if ( condition = = SYSTEM_ETHERNET_LINK_ACTIVE ) <nl> bReturn = true ; <nl> - else if ( condition > SYSTEM_IDLE_TIME_START & & condition < = SYSTEM_IDLE_TIME_FINISH ) <nl> - bReturn = ( g_application . GlobalIdleTime ( ) > = condition - SYSTEM_IDLE_TIME_START ) ; <nl> else if ( condition = = WINDOW_IS_MEDIA ) <nl> { / / note : This doesn ' t return true for dialogs ( content , favourites , login , videoinfo ) <nl> CGUIWindow * pWindow = g_windowManager . GetWindow ( g_windowManager . GetActiveWindow ( ) ) ; <nl> bool CGUIInfoManager : : GetMultiInfoBool ( const GUIInfo & info , int contextWindow , c <nl> bReturn = false ; <nl> } <nl> break ; <nl> + case SYSTEM_IDLE_TIME : <nl> + bReturn = g_application . GlobalIdleTime ( ) > = ( int ) info . GetData1 ( ) ; <nl> + break ; <nl> case CONTROL_GROUP_HAS_FOCUS : <nl> { <nl> CGUIWindow * window = GetWindowWithCondition ( contextWindow , 0 ) ; <nl> mmm a / xbmc / GUIInfoManager . h <nl> ppp b / xbmc / GUIInfoManager . h <nl> namespace INFO <nl> # define SYSTEM_ADDON_TITLE 712 <nl> # define SYSTEM_ADDON_ICON 713 <nl> # define SYSTEM_BATTERY_LEVEL 714 <nl> + # define SYSTEM_IDLE_TIME 715 <nl> <nl> # define LIBRARY_HAS_MUSIC 720 <nl> # define LIBRARY_HAS_VIDEO 721 <nl> namespace INFO <nl> # define WINDOW_IS_MEDIA 9998 <nl> # define WINDOW_IS_ACTIVE 9999 <nl> <nl> - # define SYSTEM_IDLE_TIME_START 20000 <nl> - # define SYSTEM_IDLE_TIME_FINISH 21000 / / 1000 seconds <nl> - <nl> # define CONTROL_GET_LABEL 29996 <nl> # define CONTROL_IS_ENABLED 29997 <nl> # define CONTROL_IS_VISIBLE 29998 <nl> | move system . idletime to use GUIInfo | xbmc/xbmc | 42e7a32cd9526e1ede70d6140a438dbda6fe5db3 | 2011-08-02T04:25:22Z |
mmm a / stdlib / public / core / Arrays . swift . gyb <nl> ppp b / stdlib / public / core / Arrays . swift . gyb <nl> extension $ { Self } : RangeReplaceableCollection , _ArrayProtocol { <nl> } <nl> } <nl> <nl> + / / Since RangeReplaceableCollection now has a version of filter that is less <nl> + / / efficient , we should make the default implementation coming from Sequence <nl> + / / preferred . <nl> + @ _inlineable <nl> + public func filter ( <nl> + _ isIncluded : ( Element ) throws - > Bool <nl> + ) rethrows - > [ Element ] { <nl> + return try _filter ( isIncluded ) <nl> + } <nl> + <nl> / / = = = mmm algorithms mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> <nl> @ _inlineable <nl> mmm a / stdlib / public / core / RangeReplaceableCollection . swift . gyb <nl> ppp b / stdlib / public / core / RangeReplaceableCollection . swift . gyb <nl> public func + = < <nl> lhs . append ( contentsOf : rhs ) <nl> } <nl> <nl> + extension RangeReplaceableCollection { <nl> + / / / Returns a new collection of the same type containing , in order , the <nl> + / / / elements of the original collection that satisfy the given predicate . <nl> + / / / <nl> + / / / In this example , ` filter ( _ : ) ` is used to include only names shorter than <nl> + / / / five characters . <nl> + / / / <nl> + / / / let cast = [ " Vivien " , " Marlon " , " Kim " , " Karl " ] <nl> + / / / let shortNames = cast . filter { $ 0 . count < 5 } <nl> + / / / print ( shortNames ) <nl> + / / / / / Prints " [ " Kim " , " Karl " ] " <nl> + / / / <nl> + / / / - Parameter isIncluded : A closure that takes an element of the <nl> + / / / sequence as its argument and returns a Boolean value indicating <nl> + / / / whether the element should be included in the returned array . <nl> + / / / - Returns : An array of the elements that ` isIncluded ` allowed . <nl> + @ _inlineable <nl> + @ available ( swift , introduced : 4 . 0 ) <nl> + public func filter ( <nl> + _ isIncluded : ( Element ) throws - > Bool <nl> + ) rethrows - > Self { <nl> + return try Self ( self . lazy . filter ( isIncluded ) ) <nl> + } <nl> + } <nl> + <nl> @ available ( * , unavailable , renamed : " RangeReplaceableCollection " ) <nl> public typealias RangeReplaceableCollectionType = RangeReplaceableCollection <nl> <nl> mmm a / stdlib / public / core / Sequence . swift <nl> ppp b / stdlib / public / core / Sequence . swift <nl> extension Sequence { <nl> public func filter ( <nl> _ isIncluded : ( Element ) throws - > Bool <nl> ) rethrows - > [ Element ] { <nl> + return try _filter ( isIncluded ) <nl> + } <nl> + <nl> + @ _transparent <nl> + public func _filter ( <nl> + _ isIncluded : ( Element ) throws - > Bool <nl> + ) rethrows - > [ Element ] { <nl> <nl> var result = ContiguousArray < Element > ( ) <nl> <nl> new file mode 100644 <nl> index 000000000000 . . eb77828b50e9 <nl> mmm / dev / null <nl> ppp b / test / stdlib / RangeReplaceableFilterCompatibility . swift <nl> <nl> + / / RUN : rm - rf % t ; mkdir - p % t <nl> + / / RUN : % target - build - swift % s - o % t / a . out3 - swift - version 3 & & % target - run % t / a . out3 <nl> + / / RUN : % target - build - swift % s - o % t / a . out4 - swift - version 4 & & % target - run % t / a . out4 <nl> + <nl> + import StdlibUnittest <nl> + <nl> + var tests = TestSuite ( " RangeReplaceableFilterCompatibility " ) <nl> + <nl> + tests . test ( " String . filter return type " ) { <nl> + var filtered = " Hello , World " . filter { $ 0 < " A " } <nl> + # if swift ( > = 4 ) <nl> + expectType ( String . self , & filtered ) <nl> + # else <nl> + expectType ( [ Character ] . self , & filtered ) <nl> + # endif <nl> + } <nl> + <nl> + tests . test ( " Array . filter return type " ) { <nl> + var filtered = Array ( 0 . . < 10 ) . filter { $ 0 % 2 = = 0 } <nl> + expectType ( [ Int ] . self , & filtered ) <nl> + } <nl> + <nl> + tests . test ( " String . filter can return [ Character ] " ) { <nl> + let filtered = " Hello , World " . filter { " A " < = $ 0 & & $ 0 < = " Z " } as [ Character ] <nl> + expectEqualSequence ( " HW " , filtered ) <nl> + } <nl> + <nl> + <nl> + runAllTests ( ) <nl> | [ stdlib ] Adding RangeReplaceable . filter returning Self | apple/swift | fd2ac31c6e8a6c18da0b40bfe1c93407b076e463 | 2017-05-18T19:24:13Z |
mmm a / selfdrive / camerad / cameras / camera_webcam . h <nl> ppp b / selfdrive / camerad / cameras / camera_webcam . h <nl> <nl> # define FRAME_BUF_COUNT 16 <nl> <nl> typedef struct CameraState { <nl> - int camera_id ; <nl> CameraInfo ci ; <nl> - <nl> int fps ; <nl> float digital_gain ; <nl> - <nl> - float cur_gain_frac ; <nl> - <nl> mat3 transform ; <nl> - <nl> CameraBuf buf ; <nl> } CameraState ; <nl> <nl> <nl> typedef struct MultiCameraState { <nl> - int ispif_fd ; <nl> - <nl> CameraState rear ; <nl> CameraState front ; <nl> <nl> | webcam cleanup : remove unused variables ( ) | commaai/openpilot | c21ccccd613d624b647be447f2377d88d2b43ac0 | 2020-10-30T03:30:46Z |
mmm a / Source / CNTK / CNTK . vcxproj <nl> ppp b / Source / CNTK / CNTK . vcxproj <nl> <nl> < PropertyGroup Label = " UserMacros " / > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | x64 ' " > <nl> < LinkIncremental > true < / LinkIncremental > <nl> - < IncludePath > . . \ ActionsLib ; . . \ SequenceTrainingLib ; . . \ SGDLib ; . . \ ComputationNetworkLib ; . . \ Math ; . . \ Common \ Include ; . . \ CNTK \ BrainScript ; . . \ . . \ DataReader \ HTKMLFReader ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Include ; $ ( CUDA_PATH ) \ include ; $ ( VCInstallDir ) include ; $ ( WindowsSDK_IncludePath ) ; < / IncludePath > <nl> - < LibraryPath > C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Lib \ x64 ; $ ( SolutionDir ) $ ( Platform ) \ $ ( Configuration ) ; $ ( SolutionDir ) . . \ Common \ lib ; $ ( VCInstallDir ) lib \ amd64 ; $ ( WindowsSDK_LibraryPath_x64 ) ; $ ( CUDA_PATH ) \ lib \ $ ( Platform ) < / LibraryPath > <nl> + < IncludePath > . . \ . . \ Multiverso \ include ; $ ( MSMPI_INC ) ; . . \ ActionsLib ; . . \ SequenceTrainingLib ; . . \ SGDLib ; . . \ ComputationNetworkLib ; . . \ Math ; . . \ Common \ Include ; . . \ CNTK \ BrainScript ; . . \ . . \ DataReader \ HTKMLFReader ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Include ; $ ( CUDA_PATH ) \ include ; $ ( VCInstallDir ) include ; $ ( WindowsSDK_IncludePath ) ; < / IncludePath > <nl> + < LibraryPath > . . \ . . \ Multiverso \ x64 \ $ ( Configuration ) ; $ ( MSMPI_LIB64 ) ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Lib \ x64 ; $ ( SolutionDir ) $ ( Platform ) \ $ ( Configuration ) ; $ ( SolutionDir ) . . \ Common \ lib ; $ ( VCInstallDir ) lib \ amd64 ; $ ( WindowsSDK_LibraryPath_x64 ) ; $ ( CUDA_PATH ) \ lib \ $ ( Platform ) < / LibraryPath > <nl> < CustomBuildAfterTargets > Build < / CustomBuildAfterTargets > <nl> < IntDir > $ ( Platform ) \ $ ( Configuration ) \ $ ( ProjectName ) \ < / IntDir > <nl> < / PropertyGroup > <nl> mmm a / Source / ComputationNetworkLib / ComputationNetworkLib . vcxproj <nl> ppp b / Source / ComputationNetworkLib / ComputationNetworkLib . vcxproj <nl> <nl> < PropertyGroup Label = " UserMacros " / > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | x64 ' " > <nl> < LinkIncremental > true < / LinkIncremental > <nl> - < IncludePath > . . \ SequenceTrainingLib ; . . \ Math ; . . \ Common \ Include ; . . \ CNTK \ BrainScript ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Include ; $ ( CUDA_PATH ) \ include ; $ ( VCInstallDir ) include ; . . \ . . \ DataReader \ HTKMLFReader ; $ ( WindowsSDK_IncludePath ) < / IncludePath > <nl> - < LibraryPath > C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Lib \ x64 ; $ ( SolutionDir ) $ ( Platform ) \ $ ( Configuration ) ; $ ( SolutionDir ) . . \ Common \ lib ; $ ( VCInstallDir ) lib \ amd64 ; $ ( WindowsSDK_LibraryPath_x64 ) ; $ ( CUDA_PATH ) \ lib \ $ ( Platform ) < / LibraryPath > <nl> + < IncludePath > $ ( MSMPI_INC ) ; . . \ SequenceTrainingLib ; . . \ Math ; . . \ Common \ Include ; . . \ CNTK \ BrainScript ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Include ; $ ( CUDA_PATH ) \ include ; $ ( VCInstallDir ) include ; . . \ . . \ DataReader \ HTKMLFReader ; $ ( WindowsSDK_IncludePath ) < / IncludePath > <nl> + < LibraryPath > $ ( MSMPI_LIB64 ) ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Lib \ x64 ; $ ( SolutionDir ) $ ( Platform ) \ $ ( Configuration ) ; $ ( SolutionDir ) . . \ Common \ lib ; $ ( VCInstallDir ) lib \ amd64 ; $ ( WindowsSDK_LibraryPath_x64 ) ; $ ( CUDA_PATH ) \ lib \ $ ( Platform ) < / LibraryPath > <nl> < CustomBuildAfterTargets > Build < / CustomBuildAfterTargets > <nl> < IntDir > $ ( Platform ) \ $ ( Configuration ) \ $ ( ProjectName ) \ < / IntDir > <nl> < PreBuildEventUseInBuild > false < / PreBuildEventUseInBuild > <nl> mmm a / Source / EvalDll / EvalDll . vcxproj <nl> ppp b / Source / EvalDll / EvalDll . vcxproj <nl> <nl> < PropertyGroup Label = " UserMacros " / > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | x64 ' " > <nl> < LinkIncremental > true < / LinkIncremental > <nl> - < IncludePath > . . \ SGDLib ; . . \ ComputationNetworkLib ; . . \ SequenceTrainingLib ; . . \ Math ; . . \ Common \ Include ; . . \ CNTK \ BrainScript ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Include ; $ ( CUDA_PATH ) \ include ; $ ( VCInstallDir ) include ; $ ( WindowsSDK_IncludePath ) < / IncludePath > <nl> - < LibraryPath > . . \ ComputationNetworkLib ; . . \ Math ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Lib \ x64 ; $ ( CUDA_PATH ) \ lib \ $ ( Platform ) ; $ ( VCInstallDir ) lib \ amd64 ; $ ( WindowsSDK_LibraryPath_x64 ) ; $ ( Platform ) < / LibraryPath > <nl> + < IncludePath > $ ( MSMPI_INC ) ; . . \ SGDLib ; . . \ ComputationNetworkLib ; . . \ SequenceTrainingLib ; . . \ Math ; . . \ Common \ Include ; . . \ CNTK \ BrainScript ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Include ; $ ( CUDA_PATH ) \ include ; $ ( VCInstallDir ) include ; $ ( WindowsSDK_IncludePath ) < / IncludePath > <nl> + < LibraryPath > $ ( MSMPI_LIB64 ) ; . . \ ComputationNetworkLib ; . . \ Math ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Lib \ x64 ; $ ( CUDA_PATH ) \ lib \ $ ( Platform ) ; $ ( VCInstallDir ) lib \ amd64 ; $ ( WindowsSDK_LibraryPath_x64 ) ; $ ( Platform ) < / LibraryPath > <nl> < IntDir > $ ( Platform ) \ $ ( Configuration ) \ $ ( ProjectName ) \ < / IntDir > <nl> < TargetName > EvalDll < / TargetName > <nl> < / PropertyGroup > <nl> mmm a / Source / SGDLib / SGDLib . vcxproj <nl> ppp b / Source / SGDLib / SGDLib . vcxproj <nl> <nl> < PropertyGroup Label = " UserMacros " / > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | x64 ' " > <nl> < LinkIncremental > true < / LinkIncremental > <nl> - < IncludePath > . . \ SequenceTrainingLib ; . . \ ComputationNetworkLib ; . . \ Math ; . . \ Common \ Include ; . . \ CNTK \ BrainScript ; . . \ . . \ DataReader \ HTKMLFReader ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Include ; $ ( CUDA_PATH ) \ include ; $ ( VCInstallDir ) include ; $ ( WindowsSDK_IncludePath ) < / IncludePath > <nl> - < LibraryPath > C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Lib \ x64 ; $ ( SolutionDir ) $ ( Platform ) \ $ ( Configuration ) ; $ ( SolutionDir ) . . \ Common \ lib ; $ ( VCInstallDir ) lib \ amd64 ; $ ( WindowsSDK_LibraryPath_x64 ) ; $ ( CUDA_PATH ) \ lib \ $ ( Platform ) < / LibraryPath > <nl> + < IncludePath > . . \ . . \ Multiverso \ include ; $ ( MSMPI_INC ) ; . . \ SequenceTrainingLib ; . . \ ComputationNetworkLib ; . . \ Math ; . . \ Common \ Include ; . . \ CNTK \ BrainScript ; . . \ . . \ DataReader \ HTKMLFReader ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Include ; $ ( CUDA_PATH ) \ include ; $ ( VCInstallDir ) include ; $ ( WindowsSDK_IncludePath ) < / IncludePath > <nl> + < LibraryPath > . . \ . . \ Multiverso \ x64 \ $ ( Configuration ) ; $ ( MSMPI_LIB64 ) ; C : \ Program Files ( x86 ) \ Microsoft SDKs \ MPI \ Lib \ x64 ; $ ( SolutionDir ) $ ( Platform ) \ $ ( Configuration ) ; $ ( SolutionDir ) . . \ Common \ lib ; $ ( VCInstallDir ) lib \ amd64 ; $ ( WindowsSDK_LibraryPath_x64 ) ; $ ( CUDA_PATH ) \ lib \ $ ( Platform ) < / LibraryPath > <nl> < CustomBuildAfterTargets > Build < / CustomBuildAfterTargets > <nl> < IntDir > $ ( Platform ) \ $ ( Configuration ) \ $ ( ProjectName ) \ < / IntDir > <nl> < PreBuildEventUseInBuild > false < / PreBuildEventUseInBuild > <nl> | Adding include path for debug profile | microsoft/CNTK | 28e34826a7c628cbd9fa92f766a595593f9d39ec | 2015-12-17T07:57:45Z |
mmm a / dlib / optimization / optimization_stop_strategies . h <nl> ppp b / dlib / optimization / optimization_stop_strategies . h <nl> <nl> # include " . . / matrix . h " <nl> # include " . . / algs . h " <nl> # include " optimization_stop_strategies_abstract . h " <nl> + # include < iostream > <nl> <nl> namespace dlib <nl> { <nl> namespace dlib <nl> public : <nl> objective_delta_stop_strategy ( <nl> double min_delta = 1e - 7 <nl> - ) : _been_used ( false ) , _min_delta ( min_delta ) , _max_iter ( 0 ) , _cur_iter ( 0 ) , _prev_funct_value ( 0 ) <nl> + ) : _verbose ( false ) , _been_used ( false ) , _min_delta ( min_delta ) , _max_iter ( 0 ) , _cur_iter ( 0 ) , _prev_funct_value ( 0 ) <nl> { <nl> DLIB_ASSERT ( <nl> min_delta > = 0 , <nl> namespace dlib <nl> objective_delta_stop_strategy ( <nl> double min_delta , <nl> unsigned long max_iter <nl> - ) : _been_used ( false ) , _min_delta ( min_delta ) , _max_iter ( max_iter ) , _cur_iter ( 0 ) , _prev_funct_value ( 0 ) <nl> + ) : _verbose ( false ) , _been_used ( false ) , _min_delta ( min_delta ) , _max_iter ( max_iter ) , _cur_iter ( 0 ) , _prev_funct_value ( 0 ) <nl> { <nl> DLIB_ASSERT ( <nl> min_delta > = 0 & & max_iter > 0 , <nl> namespace dlib <nl> ) ; <nl> } <nl> <nl> + const objective_delta_stop_strategy & be_verbose ( <nl> + ) const <nl> + { <nl> + _verbose = true ; <nl> + return * this ; <nl> + } <nl> + <nl> template < typename T > <nl> bool should_continue_search ( <nl> const T & , <nl> namespace dlib <nl> const T & <nl> ) <nl> { <nl> + if ( _verbose ) <nl> + { <nl> + using namespace std ; <nl> + cout < < " iteration : " < < _cur_iter < < " objective : " < < funct_value < < endl ; <nl> + } <nl> + <nl> + + _cur_iter ; <nl> if ( _been_used ) <nl> { <nl> namespace dlib <nl> } <nl> <nl> private : <nl> + mutable bool _verbose ; <nl> <nl> bool _been_used ; <nl> double _min_delta ; <nl> namespace dlib <nl> public : <nl> gradient_norm_stop_strategy ( <nl> double min_norm = 1e - 7 <nl> - ) : _min_norm ( min_norm ) , _max_iter ( 0 ) , _cur_iter ( 0 ) <nl> + ) : _verbose ( false ) , _min_norm ( min_norm ) , _max_iter ( 0 ) , _cur_iter ( 0 ) <nl> { <nl> DLIB_ASSERT ( <nl> min_norm > = 0 , <nl> namespace dlib <nl> gradient_norm_stop_strategy ( <nl> double min_norm , <nl> unsigned long max_iter <nl> - ) : _min_norm ( min_norm ) , _max_iter ( max_iter ) , _cur_iter ( 0 ) <nl> + ) : _verbose ( false ) , _min_norm ( min_norm ) , _max_iter ( max_iter ) , _cur_iter ( 0 ) <nl> { <nl> DLIB_ASSERT ( <nl> min_norm > = 0 & & max_iter > 0 , <nl> namespace dlib <nl> ) ; <nl> } <nl> <nl> + const gradient_norm_stop_strategy & be_verbose ( <nl> + ) const <nl> + { <nl> + _verbose = true ; <nl> + return * this ; <nl> + } <nl> + <nl> template < typename T > <nl> bool should_continue_search ( <nl> const T & , <nl> - const double , <nl> + const double funct_value , <nl> const T & funct_derivative <nl> ) <nl> { <nl> + if ( _verbose ) <nl> + { <nl> + using namespace std ; <nl> + cout < < " iteration : " < < _cur_iter < < " objective : " < < funct_value < < " derivative norm : " < < length ( funct_derivative ) < < endl ; <nl> + } <nl> + <nl> + + _cur_iter ; <nl> <nl> / / Check if we have hit the max allowable number of iterations . ( but only <nl> namespace dlib <nl> } <nl> <nl> private : <nl> + mutable bool _verbose ; <nl> <nl> double _min_norm ; <nl> unsigned long _max_iter ; <nl> mmm a / dlib / optimization / optimization_stop_strategies_abstract . h <nl> ppp b / dlib / optimization / optimization_stop_strategies_abstract . h <nl> namespace dlib <nl> executed . <nl> ! * / <nl> <nl> + const objective_delta_stop_strategy & be_verbose ( <nl> + ) const ; <nl> + / * ! <nl> + ensures <nl> + - causes this object to print status messages to standard out <nl> + every time should_continue_search ( ) is called . <nl> + - returns * this <nl> + ! * / <nl> + <nl> template < typename T > <nl> bool should_continue_search ( <nl> const T & x , <nl> namespace dlib <nl> max_iter iterations has been executed . <nl> ! * / <nl> <nl> + const gradient_norm_stop_strategy & be_verbose ( <nl> + ) const ; <nl> + / * ! <nl> + ensures <nl> + - causes this object to print status messages to standard out <nl> + every time should_continue_search ( ) is called . <nl> + - returns * this <nl> + ! * / <nl> + <nl> template < typename T > <nl> bool should_continue_search ( <nl> const T & x , <nl> | Added be_verbose ( ) functions to the stop strategies . Now you can tell them | davisking/dlib | d286560e8eb002a9e04f2437f79e1e1aca588153 | 2010-07-24T19:46:41Z |
mmm a / test / IRGen / existentials_opaque_boxed . sil <nl> ppp b / test / IRGen / existentials_opaque_boxed . sil <nl> entry ( % 0 : $ * T ) : <nl> return % t : $ ( ) <nl> } <nl> <nl> - / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden % swift . opaque * @ __swift_allocate_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * ) <nl> + / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden % swift . opaque * @ __swift_allocate_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * % 0 ) <nl> / / CHECK : [ [ METATYPE_ADDR : % . * ] ] = getelementptr inbounds % __opaque_existential_type_1 , % __opaque_existential_type_1 * % 0 , i32 0 , i32 1 <nl> / / CHECK : [ [ METATYPE : % . * ] ] = load % swift . type * , % swift . type * * [ [ METATYPE_ADDR ] ] <nl> / / CHECK : [ [ CAST : % . * ] ] = bitcast % swift . type * [ [ METATYPE ] ] <nl> entry : <nl> return % t : $ ( ) <nl> } <nl> <nl> - / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden void @ __swift_deallocate_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * ) <nl> + / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden void @ __swift_deallocate_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * % 0 ) <nl> / / CHECK : [ [ META_ADDR : % . * ] ] = getelementptr inbounds % __opaque_existential_type_1 , % __opaque_existential_type_1 * % 0 , i32 0 , i32 1 <nl> / / CHECK : [ [ META : % . * ] ] = load % swift . type * , % swift . type * * [ [ META_ADDR ] ] <nl> / / CHECK : [ [ CAST : % . * ] ] = bitcast % swift . type * [ [ META ] ] to i8 * * * <nl> bb0 ( % 0 : $ * Existential ) : <nl> return % t : $ ( ) <nl> } <nl> <nl> - / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden % swift . opaque * @ __swift_project_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * , % swift . type * ) <nl> + / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden % swift . opaque * @ __swift_project_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * % 0 , % swift . type * % 1 ) <nl> / / CHECK : [ [ CAST : % . * ] ] = bitcast % swift . type * % 1 to i8 * * * <nl> / / CHECK : [ [ VWT_ADDR : % . * ] ] = getelementptr inbounds i8 * * , i8 * * * [ [ CAST ] ] , { { ( i64 | i32 ) } } - 1 <nl> / / CHECK : [ [ VWT : % . * ] ] = load i8 * * , i8 * * * [ [ VWT_ADDR ] ] <nl> bb0 ( % 0 : $ * Existential ) : <nl> return % t : $ ( ) <nl> } <nl> <nl> - / / CHECK : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden % swift . opaque * @ __swift_mutable_project_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * , % swift . type * ) <nl> + / / CHECK : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden % swift . opaque * @ __swift_mutable_project_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * % 0 , % swift . type * % 1 ) <nl> / / CHECK : [ [ CAST : % . * ] ] = bitcast % swift . type * % 1 to i8 * * * <nl> / / CHECK : [ [ VWT_ADDR : % . * ] ] = getelementptr inbounds i8 * * , i8 * * * [ [ CAST ] ] , { { ( i64 | i32 ) } } - 1 <nl> / / CHECK : [ [ VWT : % . * ] ] = load i8 * * , i8 * * * [ [ VWT_ADDR ] ] <nl> bb0 ( % 0 : $ * OtherExistential ) : <nl> return % t : $ ( ) <nl> } <nl> <nl> - / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden void @ __swift_destroy_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * ) <nl> + / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden void @ __swift_destroy_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * % 0 ) <nl> / / CHECK : [ [ METADATA_ADDR : % . * ] ] = getelementptr inbounds % __opaque_existential_type_1 , % __opaque_existential_type_1 * % 0 , i32 0 , i32 1 <nl> / / CHECK : [ [ METADATA : % . * ] ] = load % swift . type * , % swift . type * * [ [ METADATA_ADDR ] ] <nl> / / CHECK : [ [ BUFFER_ADDR : % . * ] ] = getelementptr inbounds % __opaque_existential_type_1 , % __opaque_existential_type_1 * % 0 , i32 0 , i32 0 <nl> bb0 ( % 0 : $ * OtherExistential ) : <nl> return % t : $ ( ) <nl> } <nl> <nl> - / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden void @ __swift_assign_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * , % __opaque_existential_type_1 * ) <nl> + / / CHECK - LABEL : define { { ( dllexport ) ? } } { { ( protected ) ? } } linkonce_odr hidden void @ __swift_assign_boxed_opaque_existential_1 ( % __opaque_existential_type_1 * % 0 , % __opaque_existential_type_1 * % 1 ) <nl> / / CHECK : [ [ TMPBUFFER : % . * ] ] = alloca [ { { ( 24 | 12 ) } } x i8 ] <nl> / / CHECK : [ [ SELFASSIGN : % . * ] ] = icmp eq % __opaque_existential_type_1 * % 0 , % 1 <nl> / / CHECK : br i1 [ [ SELFASSIGN ] ] , label % done , label % cont <nl> bb0 ( % 0 : $ * OtherExistential ) : <nl> return % t : $ ( ) <nl> } <nl> <nl> - / / CHECK - LABEL : define linkonce_odr hidden % T25existentials_opaque_boxed11ExistentialP * @ " $ s25existentials_opaque_boxed11Existential_pWOb " ( % T25existentials_opaque_boxed11ExistentialP * , % T25existentials_opaque_boxed11ExistentialP * ) <nl> + / / CHECK - LABEL : define linkonce_odr hidden % T25existentials_opaque_boxed11ExistentialP * @ " $ s25existentials_opaque_boxed11Existential_pWOb " ( % T25existentials_opaque_boxed11ExistentialP * % 0 , % T25existentials_opaque_boxed11ExistentialP * % 1 ) <nl> / / CHECK : % 2 = bitcast % T25existentials_opaque_boxed11ExistentialP * % 1 to i8 * <nl> / / CHECK : % 3 = bitcast % T25existentials_opaque_boxed11ExistentialP * % 0 to i8 * <nl> / / CHECK : call void @ llvm . memcpy . p0i8 . p0i8 . { { ( i64 | i32 ) } } ( i8 * align { { ( 8 | 4 ) } } % 2 , i8 * align { { ( 8 | 4 ) } } % 3 , { { ( i64 40 | i32 20 ) } } , i1 false ) <nl> | Fix test / IRGen / existentials_opaque_boxed . sil | apple/swift | 27ac0052ee66ffede827ab45cd0308c8858a9070 | 2020-01-10T15:51:48Z |
mmm a / src / core / client_config / subchannel . c <nl> ppp b / src / core / client_config / subchannel . c <nl> static void subchannel_destroy ( grpc_subchannel * c ) ; <nl> <nl> static void connection_destroy ( connection * c ) { <nl> GPR_ASSERT ( c - > refs = = 0 ) ; <nl> - gpr_log ( GPR_DEBUG , " CONNECTION_DESTROY % p " , c ) ; <nl> grpc_channel_stack_destroy ( CHANNEL_STACK_FROM_CONNECTION ( c ) ) ; <nl> gpr_free ( c ) ; <nl> } <nl> static void on_state_changed ( void * p , int iomgr_success ) { <nl> goto done ; <nl> } <nl> <nl> - gpr_log ( GPR_DEBUG , " TRANSPORT STATE : % d " , sw - > connectivity_state ) ; <nl> - <nl> switch ( sw - > connectivity_state ) { <nl> case GRPC_CHANNEL_CONNECTING : <nl> case GRPC_CHANNEL_READY : <nl> | Spam cleanup | grpc/grpc | a9a3362f5cd460d7dc08bf99f94c4fb98865a719 | 2015-07-01T17:35:56Z |
mmm a / src / Interpreters / MySQL / InterpretersMySQLDDLQuery . cpp <nl> ppp b / src / Interpreters / MySQL / InterpretersMySQLDDLQuery . cpp <nl> static inline std : : tuple < NamesAndTypesList , NamesAndTypesList , NamesAndTypesList <nl> <nl> if ( indices_define & & ! indices_define - > children . empty ( ) ) <nl> { <nl> + NameSet columns_name_set ; <nl> + const Names & columns_name = columns . getNames ( ) ; <nl> + columns_name_set . insert ( columns_name . begin ( ) , columns_name . end ( ) ) ; <nl> + <nl> + const auto & remove_prefix_key = [ & ] ( const ASTPtr & node ) - > ASTPtr <nl> + { <nl> + auto res = std : : make_shared < ASTExpressionList > ( ) ; <nl> + for ( const auto & index_expression : node - > children ) <nl> + { <nl> + res - > children . emplace_back ( index_expression ) ; <nl> + <nl> + if ( const auto & function = index_expression - > as < ASTFunction > ( ) ) <nl> + { <nl> + / / / column_name ( int64 literal ) <nl> + if ( columns_name_set . contains ( function - > name ) & & function - > arguments - > children . size ( ) = = 1 ) <nl> + { <nl> + const auto & prefix_limit = function - > arguments - > children [ 0 ] - > as < ASTLiteral > ( ) ; <nl> + <nl> + if ( prefix_limit & & isInt64FieldType ( prefix_limit - > value . getType ( ) ) ) <nl> + res - > children . back ( ) = std : : make_shared < ASTIdentifier > ( function - > name ) ; <nl> + } <nl> + } <nl> + } <nl> + return res ; <nl> + } ; <nl> + <nl> for ( const auto & declare_index_ast : indices_define - > children ) <nl> { <nl> const auto & declare_index = declare_index_ast - > as < MySQLParser : : ASTDeclareIndex > ( ) ; <nl> + const auto & index_columns = remove_prefix_key ( declare_index - > index_columns ) ; <nl> <nl> / / / flatten <nl> if ( startsWith ( declare_index - > index_type , " KEY_ " ) ) <nl> keys - > arguments - > children . insert ( keys - > arguments - > children . end ( ) , <nl> - declare_index - > index_columns - > children . begin ( ) , declare_index - > index_columns - > children . end ( ) ) ; <nl> + index_columns - > children . begin ( ) , index_columns - > children . end ( ) ) ; <nl> else if ( startsWith ( declare_index - > index_type , " UNIQUE_ " ) ) <nl> unique_keys - > arguments - > children . insert ( keys - > arguments - > children . end ( ) , <nl> - declare_index - > index_columns - > children . begin ( ) , declare_index - > index_columns - > children . end ( ) ) ; <nl> + index_columns - > children . begin ( ) , index_columns - > children . end ( ) ) ; <nl> if ( startsWith ( declare_index - > index_type , " PRIMARY_KEY_ " ) ) <nl> primary_keys - > arguments - > children . insert ( keys - > arguments - > children . end ( ) , <nl> - declare_index - > index_columns - > children . begin ( ) , declare_index - > index_columns - > children . end ( ) ) ; <nl> + index_columns - > children . begin ( ) , index_columns - > children . end ( ) ) ; <nl> } <nl> } <nl> <nl> mmm a / src / Interpreters / MySQL / tests / gtest_create_rewritten . cpp <nl> ppp b / src / Interpreters / MySQL / tests / gtest_create_rewritten . cpp <nl> TEST ( MySQLCreateRewritten , RewrittenQueryWithPrimaryKey ) <nl> " ReplacingMergeTree ( _version ) PARTITION BY intDiv ( key_2 , 4294967 ) ORDER BY ( key_1 , key_2 ) " ) ; <nl> } <nl> <nl> + TEST ( MySQLCreateRewritten , RewrittenQueryWithPrefixKey ) <nl> + { <nl> + tryRegisterFunctions ( ) ; <nl> + const auto & context_holder = getContext ( ) ; <nl> + <nl> + EXPECT_EQ ( queryToString ( tryRewrittenCreateQuery ( <nl> + " CREATE TABLE ` test_database ` . ` test_table_1 ` ( ` key ` int NOT NULL PRIMARY KEY , ` prefix_key ` varchar ( 200 ) NOT NULL , KEY prefix_key_index ( prefix_key ( 2 ) ) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 " , context_holder . context ) ) , <nl> + " CREATE TABLE test_database . test_table_1 ( ` key ` Int32 , ` prefix_key ` String , ` _sign ` Int8 ( ) MATERIALIZED 1 , ` _version ` UInt64 ( ) MATERIALIZED 1 ) ENGINE = " <nl> + " ReplacingMergeTree ( _version ) PARTITION BY intDiv ( key , 4294967 ) ORDER BY ( key , prefix_key ) " ) ; <nl> + } <nl> + <nl> | Merge pull request from zhang2014 / fix / ISSUES - 15187 | ClickHouse/ClickHouse | 60aef3d5291bed69947bba7c82e12f5fcd85e7b4 | 2020-12-10T16:42:38Z |
mmm a / cmake / modules / FindCdio . cmake <nl> ppp b / cmake / modules / FindCdio . cmake <nl> <nl> # CDIO : : CDIO - The cdio library <nl> <nl> if ( PKG_CONFIG_FOUND ) <nl> - pkg_check_modules ( PC_CDIO libcdio > = 0 . 84 libiso9660 QUIET ) <nl> + pkg_check_modules ( PC_CDIO libcdio > = 0 . 78 libiso9660 QUIET ) <nl> endif ( ) <nl> <nl> find_path ( CDIO_INCLUDE_DIR NAMES cdio / cdio . h <nl> mmm a / xbmc / music / tags / MusicInfoTagLoaderCDDA . cpp <nl> ppp b / xbmc / music / tags / MusicInfoTagLoaderCDDA . cpp <nl> using namespace MEDIA_DETECT ; <nl> using namespace CDDB ; <nl> # endif <nl> <nl> + / / ! @ todo - remove after Ubuntu 16 . 04 ( Xenial ) is EOL <nl> + # if ! defined ( LIBCDIO_VERSION_NUM ) | | ( LIBCDIO_VERSION_NUM < = 83 ) <nl> + # define CDTEXT_FIELD_TITLE CDTEXT_TITLE <nl> + # define CDTEXT_FIELD_PERFORMER CDTEXT_PERFORMER <nl> + # define CDTEXT_FIELD_GENRE CDTEXT_GENRE <nl> + # endif <nl> + <nl> CMusicInfoTagLoaderCDDA : : CMusicInfoTagLoaderCDDA ( void ) = default ; <nl> <nl> CMusicInfoTagLoaderCDDA : : ~ CMusicInfoTagLoaderCDDA ( ) = default ; <nl> mmm a / xbmc / storage / cdioSupport . cpp <nl> ppp b / xbmc / storage / cdioSupport . cpp <nl> void CCdIoSupport : : GetCdTextInfo ( xbmc_cdtext_t & xcdt , int trackNum ) <nl> CSingleLock lock ( * m_cdio ) ; <nl> <nl> / / Get the CD - Text , if any <nl> + # if defined ( LIBCDIO_VERSION_NUM ) & & ( LIBCDIO_VERSION_NUM > = 84 ) <nl> cdtext_t * pcdtext = static_cast < cdtext_t * > ( cdio_get_cdtext ( cdio ) ) ; <nl> + # else <nl> + / / ! @ todo - remove after Ubuntu 16 . 04 ( Xenial ) is EOL <nl> + cdtext_t * pcdtext = ( cdtext_t * ) : : cdio_get_cdtext ( cdio , trackNum ) ; <nl> + # endif <nl> <nl> if ( pcdtext = = NULL ) <nl> return ; <nl> <nl> + # if defined ( LIBCDIO_VERSION_NUM ) & & ( LIBCDIO_VERSION_NUM > = 84 ) <nl> for ( int i = 0 ; i < MAX_CDTEXT_FIELDS ; i + + ) <nl> if ( cdtext_get_const ( pcdtext , ( cdtext_field_t ) i , trackNum ) ) <nl> xcdt [ ( cdtext_field_t ) i ] = cdtext_field2str ( ( cdtext_field_t ) i ) ; <nl> + # else <nl> + / / ! @ todo - remove after Ubuntu 16 . 04 ( Xenial ) is EOL <nl> + / / Same ids used in libcdio and for our structure + the ids are consecutive make this copy loop safe . <nl> + for ( int i = 0 ; i < MAX_CDTEXT_FIELDS ; i + + ) <nl> + if ( pcdtext - > field [ i ] ) <nl> + xcdt [ ( cdtext_field_t ) i ] = pcdtext - > field [ ( cdtext_field_t ) i ] ; <nl> + # endif <nl> # endif / / TARGET_WINDOWS <nl> } <nl> <nl> | Merge pull request from Rechi / fix / cdioUbuntuXenial | xbmc/xbmc | 1ed0d617631f1ee69432802ec7d0d6d9a302d5cb | 2018-02-28T13:24:09Z |
mmm a / docs / config . md <nl> ppp b / docs / config . md <nl> In this page we will look at the config file of trojan . Trojan uses [ ` JSON ` ] ( htt <nl> " verify_hostname " : true , <nl> " cert " : " / path / to / ca_certs . pem " , <nl> " cipher " : " ECDHE - ECDSA - AES128 - GCM - SHA256 : ECDHE - RSA - AES128 - GCM - SHA256 : ECDHE - ECDSA - CHACHA20 - POLY1305 : ECDHE - RSA - CHACHA20 - POLY1305 : ECDHE - ECDSA - AES256 - GCM - SHA384 : ECDHE - RSA - AES256 - GCM - SHA384 : ECDHE - ECDSA - AES256 - SHA : ECDHE - ECDSA - AES128 - SHA : ECDHE - RSA - AES128 - SHA : ECDHE - RSA - AES256 - SHA : DHE - RSA - AES128 - SHA : DHE - RSA - AES256 - SHA : AES128 - SHA : AES256 - SHA : DES - CBC3 - SHA " , <nl> + " sni " : " example . com " , <nl> " alpn " : [ <nl> " h2 " , <nl> " http / 1 . 1 " <nl> In this page we will look at the config file of trojan . Trojan uses [ ` JSON ` ] ( htt <nl> - ` log_level ` : specify how much log to dump . 0 : ALL ; 1 : INFO ; 2 : WARN ; 3 : ERROR ; 4 : FATAL ; 5 : OFF . <nl> - ` ssl ` : ` SSL ` specific configurations <nl> - ` verify ` : whether to verify ` SSL ` certificate * * STRONGLY RECOMMENDED * * <nl> - - ` verify_hostname ` : whether to verify ` SSL ` hostname * * STRONGLY RECOMMENDED * * <nl> + - ` verify_hostname ` : whether to verify ` SSL ` hostname ( specified in the ` sni ` field ) * * STRONGLY RECOMMENDED * * <nl> - ` cert ` : if ` verify ` is set to ` true ` , a collection of ` CA ` certificates should be provided . A client may also use the same certificate used by the server . Note that if you leave this field blank , ` OpenSSL ` will try to look for a system ` CA ` and will be likely to fail . <nl> - ` cipher ` : specify a cipher list to send and use <nl> + - ` sni ` : specify the Server Name Indication field in the ` SSL ` handshake <nl> - ` alpn ` : specify a list of ` ALPN ` protocols to send <nl> - ` reuse_session ` : whether to reuse ` SSL ` session <nl> - ` curves ` : specify ` ECC ` curves to send and use <nl> mmm a / docs / protocol . md <nl> ppp b / docs / protocol . md <nl> We will now show how a trojan server will react to a * * valid Trojan Protocol * * , <nl> <nl> # # Valid Trojan Protocol <nl> <nl> - When a trojan client connects to a server , it first performs a * * real * * TLS handshake . If the handshake succeeds , all subsequent traffic will be protected by ` TLS ` ; otherwise , the server will close the connection immediately , as any ` HTTPS ` server would . Then the client sends the following structure : <nl> + When a trojan client connects to a server , it first performs a * * real * * ` TLS ` handshake . If the handshake succeeds , all subsequent traffic will be protected by ` TLS ` ; otherwise , the server will close the connection immediately , as any ` HTTPS ` server would . Then the client sends the following structure : <nl> <nl> ` ` ` <nl> + mmmmmmmmmmmmmmmmmmmmm - - + mmmmmmmmm + mmmmmmmmmmmmmmm - + mmmmmmmmm + mmmmmmmmm - + <nl> More information on ` SOCKS5 ` requests can be found [ here ] ( https : / / tools . ietf . org <nl> <nl> * * Note that ` UDP ASSOCIATE ` has not been implemented in current version . The ` CMD ` field is reserved for future implementation ( if needed ) . * * <nl> <nl> - When the server receives the first data packet , it unwraps the TLS packet and looks for the two ` CRLF ` s . Then it checks if the hashed password is correct and the Trojan Request is valid . On failure at any step , the protocol is considered " other protocols " ( see next section ) . Note that the first packet will have payload ( Application Data ) appended . This avoids length pattern detection and may reduce the number of packets to be sent . <nl> + When the server receives the first data packet , it unwraps the ` TLS ` packet and looks for the two ` CRLF ` s . Then it checks if the hashed password is correct and the Trojan Request is valid . On failure at any step , the protocol is considered " other protocols " ( see next section ) . Note that the first packet will have payload ( Application Data ) appended . This avoids length pattern detection and may reduce the number of packets to be sent . <nl> <nl> If the request is valid , the trojan server connects to the endpoint indicated by the ` DST . ADDR ` and ` DST . PORT ` field and opens a direct tunnel between the endpoint and trojan client . <nl> <nl> mmm a / examples / client . json - example <nl> ppp b / examples / client . json - example <nl> <nl> " verify_hostname " : true , <nl> " cert " : " / path / to / ca_certs . pem " , <nl> " cipher " : " ECDHE - ECDSA - AES128 - GCM - SHA256 : ECDHE - RSA - AES128 - GCM - SHA256 : ECDHE - ECDSA - CHACHA20 - POLY1305 : ECDHE - RSA - CHACHA20 - POLY1305 : ECDHE - ECDSA - AES256 - GCM - SHA384 : ECDHE - RSA - AES256 - GCM - SHA384 : ECDHE - ECDSA - AES256 - SHA : ECDHE - ECDSA - AES128 - SHA : ECDHE - RSA - AES128 - SHA : ECDHE - RSA - AES256 - SHA : DHE - RSA - AES128 - SHA : DHE - RSA - AES256 - SHA : AES128 - SHA : AES256 - SHA : DES - CBC3 - SHA " , <nl> + " sni " : " example . com " , <nl> " alpn " : [ <nl> " h2 " , <nl> " http / 1 . 1 " <nl> mmm a / src / clientsession . cpp <nl> ppp b / src / clientsession . cpp <nl> boost : : asio : : basic_socket < tcp , boost : : asio : : stream_socket_service < tcp > > & Client <nl> void ClientSession : : start ( ) { <nl> in_endpoint = in_socket . remote_endpoint ( ) ; <nl> auto ssl = out_socket . native_handle ( ) ; <nl> - if ( config . ssl . verify_hostname ) { <nl> - SSL_set_tlsext_host_name ( ssl , config . remote_addr . c_str ( ) ) ; <nl> + if ( config . ssl . sni ! = " " ) { <nl> + SSL_set_tlsext_host_name ( ssl , config . ssl . sni . c_str ( ) ) ; <nl> } <nl> if ( config . ssl . reuse_session & & ssl_session ) { <nl> SSL_set_session ( ssl , ssl_session ) ; <nl> mmm a / src / config . cpp <nl> ppp b / src / config . cpp <nl> void Config : : load ( const string & filename ) { <nl> ssl . key_password = tree . get ( " ssl . key_password " , string ( ) ) ; <nl> ssl . cipher = tree . get ( " ssl . cipher " , string ( ) ) ; <nl> ssl . prefer_server_cipher = tree . get ( " ssl . prefer_server_cipher " , true ) ; <nl> + ssl . sni = tree . get ( " ssl . sni " , string ( ) ) ; <nl> for ( auto & item : tree . get_child ( " ssl . alpn " ) ) { <nl> string proto = item . second . get_value < string > ( ) ; <nl> ssl . alpn + = ( char ) ( ( unsigned char ) ( proto . length ( ) ) ) ; <nl> mmm a / src / config . h <nl> ppp b / src / config . h <nl> class Config { <nl> std : : string key_password ; <nl> std : : string cipher ; <nl> bool prefer_server_cipher ; <nl> + std : : string sni ; <nl> std : : string alpn ; <nl> bool reuse_session ; <nl> long session_timeout ; <nl> mmm a / src / service . cpp <nl> ppp b / src / service . cpp <nl> Service : : Service ( Config & config ) : <nl> ssl_context . load_verify_file ( config . ssl . cert ) ; <nl> } <nl> if ( config . ssl . verify_hostname ) { <nl> - ssl_context . set_verify_callback ( rfc2818_verification ( config . remote_addr ) ) ; <nl> + ssl_context . set_verify_callback ( rfc2818_verification ( config . ssl . sni ) ) ; <nl> } <nl> } else { <nl> ssl_context . set_verify_mode ( verify_none ) ; <nl> mmm a / tests / LinuxSmokeTest / basic . sh <nl> ppp b / tests / LinuxSmokeTest / basic . sh <nl> pid4 = $ ! <nl> <nl> sleep 1 <nl> <nl> - whoami = ` curl - v - - socks5 127 . 0 . 0 . 1 : 11080 http : / / 127 . 0 . 0 . 3 : 10081 / whoami . txt ` <nl> + whoami = ` curl - v - - socks5 127 . 0 . 0 . 1 : 11080 http : / / 127 . 0 . 0 . 1 : 10081 / whoami . txt ` <nl> kill $ pid1 $ pid2 $ pid3 $ pid4 <nl> if [ " $ whoami " = true ] ; then <nl> rm - rf $ tmpdir <nl> mmm a / tests / LinuxSmokeTest / client . json <nl> ppp b / tests / LinuxSmokeTest / client . json <nl> <nl> " run_type " : " client " , <nl> " local_addr " : " 127 . 0 . 0 . 1 " , <nl> " local_port " : 11080 , <nl> - " remote_addr " : " 127 . 0 . 0 . 2 " , <nl> + " remote_addr " : " 127 . 0 . 0 . 1 " , <nl> " remote_port " : 10443 , <nl> " password " : [ " linux - smoke - test - password " ] , <nl> " log_level " : 0 , <nl> <nl> " verify_hostname " : false , <nl> " cert " : " " , <nl> " cipher " : " " , <nl> + " sni " : " " , <nl> " alpn " : [ ] , <nl> " reuse_session " : false , <nl> " curves " : " " , <nl> mmm a / tests / LinuxSmokeTest / fake - client . json <nl> ppp b / tests / LinuxSmokeTest / fake - client . json <nl> <nl> " run_type " : " client " , <nl> " local_addr " : " 127 . 0 . 0 . 1 " , <nl> " local_port " : 11080 , <nl> - " remote_addr " : " 127 . 0 . 0 . 2 " , <nl> + " remote_addr " : " 127 . 0 . 0 . 1 " , <nl> " remote_port " : 10443 , <nl> " password " : [ " wrong - password " ] , <nl> " log_level " : 0 , <nl> <nl> " verify_hostname " : false , <nl> " cert " : " " , <nl> " cipher " : " " , <nl> + " sni " : " " , <nl> " alpn " : [ ] , <nl> " reuse_session " : false , <nl> " curves " : " " , <nl> mmm a / tests / LinuxSmokeTest / fake - client . sh <nl> ppp b / tests / LinuxSmokeTest / fake - client . sh <nl> pid4 = $ ! <nl> <nl> sleep 1 <nl> <nl> - whoami = ` curl - v - - socks5 127 . 0 . 0 . 1 : 11080 http : / / 127 . 0 . 0 . 3 : 10081 / whoami . txt ` <nl> - whoami2 = ` curl - v - - insecure https : / / 127 . 0 . 0 . 2 : 10443 / whoami . txt ` <nl> + whoami = ` curl - v - - socks5 127 . 0 . 0 . 1 : 11080 http : / / 127 . 0 . 0 . 1 : 10081 / whoami . txt ` <nl> + whoami2 = ` curl - v - - insecure https : / / 127 . 0 . 0 . 1 : 10443 / whoami . txt ` <nl> kill $ pid1 $ pid2 $ pid3 $ pid4 <nl> if [ " $ whoami " ! = true - a " $ whoami2 " = fake ] ; then <nl> rm - rf $ tmpdir <nl> mmm a / tests / LinuxSmokeTest / server . json <nl> ppp b / tests / LinuxSmokeTest / server . json <nl> <nl> { <nl> " run_type " : " server " , <nl> - " local_addr " : " 127 . 0 . 0 . 2 " , <nl> + " local_addr " : " 127 . 0 . 0 . 1 " , <nl> " local_port " : 10443 , <nl> " remote_addr " : " 127 . 0 . 0 . 1 " , <nl> " remote_port " : 10080 , <nl> | Add sni field and fix broken test | trojan-gfw/trojan | 11bc6b10a7a3741ab40706b99adc7d82636586f6 | 2018-01-01T12:10:30Z |
mmm a / src / bootstrapper . cc <nl> ppp b / src / bootstrapper . cc <nl> static void InstallBuiltinFunctionId ( Handle < JSObject > holder , <nl> <nl> void Genesis : : InstallBuiltinFunctionIds ( ) { <nl> HandleScope scope ( isolate ( ) ) ; <nl> + struct BuiltinFunctionIds { <nl> + const char * holder_expr ; <nl> + const char * fun_name ; <nl> + BuiltinFunctionId id ; <nl> + } ; <nl> + <nl> # define INSTALL_BUILTIN_ID ( holder_expr , fun_name , name ) \ <nl> - { \ <nl> - Handle < JSObject > holder = ResolveBuiltinIdHolder ( \ <nl> - native_context ( ) , # holder_expr ) ; \ <nl> - BuiltinFunctionId id = k # # name ; \ <nl> - InstallBuiltinFunctionId ( holder , # fun_name , id ) ; \ <nl> - } <nl> - FUNCTIONS_WITH_ID_LIST ( INSTALL_BUILTIN_ID ) <nl> + { # holder_expr , # fun_name , k # # name } \ <nl> + , <nl> + const BuiltinFunctionIds builtins [ ] = { <nl> + FUNCTIONS_WITH_ID_LIST ( INSTALL_BUILTIN_ID ) } ; <nl> # undef INSTALL_BUILTIN_ID <nl> + <nl> + for ( const BuiltinFunctionIds & builtin : builtins ) { <nl> + Handle < JSObject > holder = <nl> + ResolveBuiltinIdHolder ( native_context ( ) , builtin . holder_expr ) ; <nl> + InstallBuiltinFunctionId ( holder , builtin . fun_name , builtin . id ) ; <nl> + } <nl> } <nl> <nl> <nl> | Avoid repeating code when creating builtins . | v8/v8 | bd21d72d507625e5caf70f31ee11c8c21ead1651 | 2015-02-27T15:21:52Z |
new file mode 100755 <nl> index 00000000 . . 0baff345 <nl> Binary files / dev / null and b / src / bindings / go / libopenalprgo . so differ <nl> mmm a / src / bindings / go / openalpr / openalpr . go <nl> ppp b / src / bindings / go / openalpr / openalpr . go <nl> type Alpr struct { <nl> <nl> type AlprResults struct { <nl> EpochTime int64 ` json : " epoch_time " ` <nl> - ImgWidth int ` json : " img_witdh " ` <nl> + ImgWidth int ` json : " img_width " ` <nl> ImgHeight int ` json : " img_height " ` <nl> TotalProcessingTimeMs float32 ` json : " processing_time_ms " ` <nl> Plates [ ] AlprPlateResult ` json : " results " ` <nl> | Merge pull request from marktheunissen / go_json_typo | openalpr/openalpr | c41b184c86c582ba0c2ffc5ba1f74f5e5ca3e639 | 2016-08-03T01:45:19Z |
mmm a / etc / evergreen . yml <nl> ppp b / etc / evergreen . yml <nl> functions : <nl> binary_file = $ ( echo $ core_file | sed " s / . * \ / / / ; s / dump_ / / ; s / \ . . * \ . core / / ; s / \ . . * \ . mdmp / / " ) <nl> # Locate the binary file . Since the base file name might be truncated , the find <nl> # may return more than 1 file . <nl> - binary_file_locations = $ ( / usr / bin / find - H . - name " $ binary_file * $ { exe } " 2 > / dev / null ) <nl> + binary_file_locations = $ ( / usr / bin / find - H . - executable - name " $ binary_file * $ { exe } " 2 > / dev / null ) <nl> fi <nl> if [ - z " $ binary_file_locations " ] ; then <nl> echo " Cannot locate the unittest binary file ( $ binary_file ) that generated the core file $ core_file " <nl> | SERVER - 47769 Ensure that gather_failed_unittests does not target . cpp files | mongodb/mongo | c511c2951b30ac612a57c3639fb3760f24a8389c | 2020-06-09T15:08:38Z |
mmm a / stdlib / public / core / LazyCollection . swift <nl> ppp b / stdlib / public / core / LazyCollection . swift <nl> public protocol LazyCollectionProtocol <nl> / / / possibly with a simpler type . <nl> / / / <nl> / / / - See also : ` elements ` <nl> - associatedtype Elements : Collection = Self <nl> + associatedtype Elements : Collection = Self <nl> } <nl> <nl> / / / When there ' s no special associated ` Elements ` type , the ` elements ` <nl> public struct LazyCollection < Base : Collection > <nl> <nl> / / / Construct an instance with ` base ` as its underlying Collection <nl> / / / instance . <nl> - internal init ( _ base : Base ) { <nl> - self . _base = base <nl> + internal init ( _base : Base ) { <nl> + self . _base = _base <nl> } <nl> <nl> internal var _base : Base <nl> extension Collection { <nl> / / / <nl> / / / - See Also : ` LazySequenceProtocol ` , ` LazyCollectionProtocol ` . <nl> public var lazy : LazyCollection < Self > { <nl> - return LazyCollection ( self ) <nl> + return LazyCollection ( _base : self ) <nl> } <nl> } <nl> <nl> mmm a / stdlib / public / core / LazySequence . swift <nl> ppp b / stdlib / public / core / LazySequence . swift <nl> public protocol LazySequenceProtocol : Sequence { <nl> / / / possibly with a simpler type . <nl> / / / <nl> / / / - See also : ` elements ` <nl> - associatedtype Elements : Sequence = Self <nl> + associatedtype Elements : Sequence = Self <nl> <nl> / / / A sequence containing the same elements as this one , possibly with <nl> / / / a simpler type . <nl> public protocol LazySequenceProtocol : Sequence { <nl> / / / Note : this property need not be implemented by conforming types , <nl> / / / it has a default implementation in a protocol extension that <nl> / / / just returns ` self ` . <nl> - var elements : Elements { get } <nl> + var elements : Elements { get } <nl> } <nl> <nl> / / / When there ' s no special associated ` Elements ` type , the ` elements ` <nl> public struct LazySequence < Base : Sequence > <nl> / / / Creates a sequence that has the same elements as ` base ` , but on <nl> / / / which some operations such as ` map ` and ` filter ` are implemented <nl> / / / lazily . <nl> - internal init ( _ base : Base ) { <nl> - self . _base = base <nl> + internal init ( _base : Base ) { <nl> + self . _base = _base <nl> } <nl> - <nl> + <nl> public var _base : Base <nl> <nl> / / / The ` Base ` ( presumably non - lazy ) sequence from which ` self ` was created . <nl> extension Sequence { <nl> / / / <nl> / / / - See also : ` LazySequenceProtocol ` , ` LazySequence ` <nl> public var lazy : LazySequence < Self > { <nl> - return LazySequence ( self ) <nl> + return LazySequence ( _base : self ) <nl> } <nl> } <nl> <nl> extension LazySequenceProtocol { <nl> } <nl> } <nl> <nl> - <nl> @ available ( * , unavailable , renamed = " LazyCollectionProtocol " ) <nl> public typealias LazySequenceType = LazySequenceProtocol <nl> <nl> | stdlib : fix coding style | apple/swift | 9293c1f5cc82f108f7c0ed37e08aa084aedaa7a1 | 2016-02-19T06:30:58Z |
mmm a / cmake / OpenCVDetectTBB . cmake <nl> ppp b / cmake / OpenCVDetectTBB . cmake <nl> if ( NOT HAVE_TBB ) <nl> set ( _TBB_LIB_PATH " $ { _TBB_LIB_PATH } / vc10 " ) <nl> elseif ( MSVC11 ) <nl> set ( _TBB_LIB_PATH " $ { _TBB_LIB_PATH } / vc11 " ) <nl> + elseif ( MSVC12 ) <nl> + set ( _TBB_LIB_PATH " $ { _TBB_LIB_PATH } / vc12 " ) <nl> endif ( ) <nl> set ( TBB_LIB_DIR " $ { _TBB_LIB_PATH } " CACHE PATH " Full path of TBB library directory " ) <nl> link_directories ( " $ { TBB_LIB_DIR } " ) <nl> | Added suuport for finding Intel TBB for Visual Studio 2013 | opencv/opencv | 26c8b3a38e46cecbffd6dae53e3171fd66bfbaf6 | 2014-04-28T11:23:49Z |
mmm a / RELEASES . md <nl> ppp b / RELEASES . md <nl> <nl> Version 0 . 7 . 10 ( 2020 - 10 - 26 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = <nl> - * NEOS update required <nl> + * NEOS update : update to Python 3 . 8 . 2 and lower CPU frequency <nl> + * Improved thermals due to reduced CPU frequency <nl> * Reduced offroad power consumption <nl> * Various system stability improvements <nl> * Acura RDX 2020 support thanks to csouers ! <nl> | update release notes | commaai/openpilot | 9b79f6345aecc30c41939e83528ab63e221c34dc | 2020-10-21T09:35:03Z |
mmm a / java / RocksDBSample . java <nl> ppp b / java / RocksDBSample . java <nl> public static void main ( String [ ] args ) { <nl> . setMaxWriteBufferNumber ( 3 ) <nl> . setDisableSeekCompaction ( true ) <nl> . setBlockSize ( 64 * SizeUnit . KB ) <nl> - . setMaxBackgroundCompactions ( 10 ) ; <nl> + . setMaxBackgroundCompactions ( 10 ) <nl> + . createBloomFilter ( 10 ) ; <nl> Statistics stats = options . statisticsPtr ( ) ; <nl> <nl> assert ( options . createIfMissing ( ) = = true ) ; <nl> mmm a / java / org / rocksdb / Options . java <nl> ppp b / java / org / rocksdb / Options . java <nl> public long blockSize ( ) { <nl> assert ( isInitialized ( ) ) ; <nl> return blockSize ( nativeHandle_ ) ; <nl> } <nl> + <nl> + / * * <nl> + * Filters are stored in rocksdb and are consulted automatically <nl> + * by rocksdb to decide whether or not to read some <nl> + * information from disk . In many cases , a filter can cut down the <nl> + * number of disk seeks form a handful to a single disk seek per <nl> + * DB : : Get ( ) call . <nl> + * <nl> + * This function a new filter policy that uses a bloom filter <nl> + * with approximately the specified number of bits per key . <nl> + * A good value for bitsPerKey is 10 , which yields a filter <nl> + * with ~ 1 % false positive rate . <nl> + * <nl> + * @ param Bits per key for bloom filter . <nl> + * @ return the instance of the current Options . <nl> + * @ see RocksDB . open ( ) <nl> + * / <nl> + public Options createBloomFilter ( int bitsPerKey ) { <nl> + assert ( isInitialized ( ) ) ; <nl> + createBloomFilter0 ( nativeHandle_ , bitsPerKey ) ; <nl> + return this ; <nl> + } <nl> <nl> / * <nl> * Disable compaction triggered by seek . <nl> private native void setMaxBackgroundCompactions ( <nl> <nl> private native void useFixedLengthPrefixExtractor ( <nl> long handle , int prefixLength ) ; <nl> + <nl> + private native void createBloomFilter0 ( long handle , int bitsPerKey ) ; <nl> <nl> long nativeHandle_ ; <nl> long cacheSize_ ; <nl> mmm a / java / rocksjni / options . cc <nl> ppp b / java / rocksjni / options . cc <nl> <nl> # include " rocksdb / memtablerep . h " <nl> # include " rocksdb / table . h " <nl> # include " rocksdb / slice_transform . h " <nl> + # include " rocksdb / filter_policy . h " <nl> <nl> / * <nl> * Class : org_rocksdb_Options <nl> jlong Java_org_rocksdb_Options_statisticsPtr ( <nl> return reinterpret_cast < jlong > ( st ) ; <nl> } <nl> <nl> + / * <nl> + * Class : org_rocksdb_Options <nl> + * Method : createBloomFilter0 <nl> + * Signature : ( JI ) V <nl> + * / <nl> + void Java_org_rocksdb_Options_createBloomFilter0 ( <nl> + JNIEnv * env , jobject jobj , jlong jhandle , jint jbits_per_key ) { <nl> + rocksdb : : Options * opt = reinterpret_cast < rocksdb : : Options * > ( jhandle ) ; <nl> + <nl> + / / Delete previously allocated pointer <nl> + if ( opt - > filter_policy ) { <nl> + delete opt - > filter_policy ; <nl> + } <nl> + <nl> + opt - > filter_policy = rocksdb : : NewBloomFilterPolicy ( jbits_per_key ) ; <nl> + } <nl> + <nl> / * <nl> * Class : org_rocksdb_Options <nl> * Method : maxWriteBufferNumber <nl> | Add bloom filters | facebook/rocksdb | dc4b27ac486dbc3e7ef7c02881d23495fb6307b8 | 2014-04-22T03:25:30Z |
mmm a / src / core / hle / kernel / address_arbiter . cpp <nl> ppp b / src / core / hle / kernel / address_arbiter . cpp <nl> class AddressArbiter : public Object { <nl> <nl> / / / Arbitrate an address <nl> ResultCode ArbitrateAddress ( Handle handle , ArbitrationType type , u32 address , s32 value , u64 nanoseconds ) { <nl> - Object * object = Kernel : : g_handle_table . GetGeneric ( handle ) . get ( ) ; <nl> + AddressArbiter * object = Kernel : : g_handle_table . Get < AddressArbiter > ( handle ) . get ( ) ; <nl> + <nl> if ( object = = nullptr ) <nl> return InvalidHandle ( ErrorModule : : Kernel ) ; <nl> <nl> ResultCode ArbitrateAddress ( Handle handle , ArbitrationType type , u32 address , s3 <nl> case ArbitrationType : : Signal : <nl> / / Negative value means resume all threads <nl> if ( value < 0 ) { <nl> - ArbitrateAllThreads ( object , address ) ; <nl> + ArbitrateAllThreads ( address ) ; <nl> } else { <nl> / / Resume first N threads <nl> for ( int i = 0 ; i < value ; i + + ) <nl> - ArbitrateHighestPriorityThread ( object , address ) ; <nl> + ArbitrateHighestPriorityThread ( address ) ; <nl> } <nl> break ; <nl> <nl> / / Wait current thread ( acquire the arbiter ) . . . <nl> case ArbitrationType : : WaitIfLessThan : <nl> if ( ( s32 ) Memory : : Read32 ( address ) < = value ) { <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_ARB , object , address ) ; <nl> + Kernel : : WaitCurrentThread_ArbitrateAddress ( address ) ; <nl> HLE : : Reschedule ( __func__ ) ; <nl> } <nl> break ; <nl> case ArbitrationType : : WaitIfLessThanWithTimeout : <nl> if ( ( s32 ) Memory : : Read32 ( address ) < = value ) { <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_ARB , object , address ) ; <nl> + Kernel : : WaitCurrentThread_ArbitrateAddress ( address ) ; <nl> Kernel : : WakeThreadAfterDelay ( GetCurrentThread ( ) , nanoseconds ) ; <nl> HLE : : Reschedule ( __func__ ) ; <nl> } <nl> ResultCode ArbitrateAddress ( Handle handle , ArbitrationType type , u32 address , s3 <nl> s32 memory_value = Memory : : Read32 ( address ) - 1 ; <nl> Memory : : Write32 ( address , memory_value ) ; <nl> if ( memory_value < = value ) { <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_ARB , object , address ) ; <nl> + Kernel : : WaitCurrentThread_ArbitrateAddress ( address ) ; <nl> HLE : : Reschedule ( __func__ ) ; <nl> } <nl> break ; <nl> ResultCode ArbitrateAddress ( Handle handle , ArbitrationType type , u32 address , s3 <nl> s32 memory_value = Memory : : Read32 ( address ) - 1 ; <nl> Memory : : Write32 ( address , memory_value ) ; <nl> if ( memory_value < = value ) { <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_ARB , object , address ) ; <nl> + Kernel : : WaitCurrentThread_ArbitrateAddress ( address ) ; <nl> Kernel : : WakeThreadAfterDelay ( GetCurrentThread ( ) , nanoseconds ) ; <nl> HLE : : Reschedule ( __func__ ) ; <nl> } <nl> mmm a / src / core / hle / kernel / event . cpp <nl> ppp b / src / core / hle / kernel / event . cpp <nl> <nl> <nl> namespace Kernel { <nl> <nl> - class Event : public Object { <nl> + class Event : public WaitObject { <nl> public : <nl> std : : string GetTypeName ( ) const override { return " Event " ; } <nl> std : : string GetName ( ) const override { return name ; } <nl> class Event : public Object { <nl> ResetType intitial_reset_type ; / / / < ResetType specified at Event initialization <nl> ResetType reset_type ; / / / < Current ResetType <nl> <nl> - bool locked ; / / / < Event signal wait <nl> - bool permanent_locked ; / / / < Hack - to set event permanent state ( for easy passthrough ) <nl> - std : : vector < Handle > waiting_threads ; / / / < Threads that are waiting for the event <nl> + bool signaled ; / / / < Whether the event has already been signaled <nl> std : : string name ; / / / < Name of event ( optional ) <nl> <nl> - ResultVal < bool > WaitSynchronization ( ) override { <nl> - bool wait = locked ; <nl> - if ( locked ) { <nl> - Handle thread = GetCurrentThread ( ) - > GetHandle ( ) ; <nl> - if ( std : : find ( waiting_threads . begin ( ) , waiting_threads . end ( ) , thread ) = = waiting_threads . end ( ) ) { <nl> - waiting_threads . push_back ( thread ) ; <nl> - } <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_EVENT , this ) ; <nl> - } <nl> - if ( reset_type ! = RESETTYPE_STICKY & & ! permanent_locked ) { <nl> - locked = true ; <nl> - } <nl> - return MakeResult < bool > ( wait ) ; <nl> + bool ShouldWait ( ) override { <nl> + return ! signaled ; <nl> } <nl> - } ; <nl> - <nl> - / * * <nl> - * Hackish function to set an events permanent lock state , used to pass through synch blocks <nl> - * @ param handle Handle to event to change <nl> - * @ param permanent_locked Boolean permanent locked value to set event <nl> - * @ return Result of operation , 0 on success , otherwise error code <nl> - * / <nl> - ResultCode SetPermanentLock ( Handle handle , const bool permanent_locked ) { <nl> - Event * evt = g_handle_table . Get < Event > ( handle ) . get ( ) ; <nl> - if ( evt = = nullptr ) return InvalidHandle ( ErrorModule : : Kernel ) ; <nl> - <nl> - evt - > permanent_locked = permanent_locked ; <nl> - return RESULT_SUCCESS ; <nl> - } <nl> <nl> - / * * <nl> - * Changes whether an event is locked or not <nl> - * @ param handle Handle to event to change <nl> - * @ param locked Boolean locked value to set event <nl> - * @ return Result of operation , 0 on success , otherwise error code <nl> - * / <nl> - ResultCode SetEventLocked ( const Handle handle , const bool locked ) { <nl> - Event * evt = g_handle_table . Get < Event > ( handle ) . get ( ) ; <nl> - if ( evt = = nullptr ) return InvalidHandle ( ErrorModule : : Kernel ) ; <nl> + void Acquire ( ) override { <nl> + _assert_msg_ ( Kernel , ! ShouldWait ( ) , " object unavailable ! " ) ; <nl> <nl> - if ( ! evt - > permanent_locked ) { <nl> - evt - > locked = locked ; <nl> + / / Release the event if it ' s not sticky . . . <nl> + if ( reset_type ! = RESETTYPE_STICKY ) <nl> + signaled = false ; <nl> } <nl> - return RESULT_SUCCESS ; <nl> - } <nl> + } ; <nl> <nl> - / * * <nl> - * Signals an event <nl> - * @ param handle Handle to event to signal <nl> - * @ return Result of operation , 0 on success , otherwise error code <nl> - * / <nl> ResultCode SignalEvent ( const Handle handle ) { <nl> Event * evt = g_handle_table . Get < Event > ( handle ) . get ( ) ; <nl> - if ( evt = = nullptr ) return InvalidHandle ( ErrorModule : : Kernel ) ; <nl> - <nl> - / / Resume threads waiting for event to signal <nl> - bool event_caught = false ; <nl> - for ( size_t i = 0 ; i < evt - > waiting_threads . size ( ) ; + + i ) { <nl> - Thread * thread = Kernel : : g_handle_table . Get < Thread > ( evt - > waiting_threads [ i ] ) . get ( ) ; <nl> - if ( thread ! = nullptr ) <nl> - thread - > ResumeFromWait ( ) ; <nl> - <nl> - / / If any thread is signalled awake by this event , assume the event was " caught " and reset <nl> - / / the event . This will result in the next thread waiting on the event to block . Otherwise , <nl> - / / the event will not be reset , and the next thread to call WaitSynchronization on it will <nl> - / / not block . Not sure if this is correct behavior , but it seems to work . <nl> - event_caught = true ; <nl> - } <nl> - evt - > waiting_threads . clear ( ) ; <nl> + if ( evt = = nullptr ) <nl> + return InvalidHandle ( ErrorModule : : Kernel ) ; <nl> + <nl> + evt - > signaled = true ; <nl> + evt - > WakeupAllWaitingThreads ( ) ; <nl> <nl> - if ( ! evt - > permanent_locked ) { <nl> - evt - > locked = event_caught ; <nl> - } <nl> return RESULT_SUCCESS ; <nl> } <nl> <nl> - / * * <nl> - * Clears an event <nl> - * @ param handle Handle to event to clear <nl> - * @ return Result of operation , 0 on success , otherwise error code <nl> - * / <nl> ResultCode ClearEvent ( Handle handle ) { <nl> Event * evt = g_handle_table . Get < Event > ( handle ) . get ( ) ; <nl> - if ( evt = = nullptr ) return InvalidHandle ( ErrorModule : : Kernel ) ; <nl> + if ( evt = = nullptr ) <nl> + return InvalidHandle ( ErrorModule : : Kernel ) ; <nl> + <nl> + evt - > signaled = false ; <nl> <nl> - if ( ! evt - > permanent_locked ) { <nl> - evt - > locked = true ; <nl> - } <nl> return RESULT_SUCCESS ; <nl> } <nl> <nl> Event * CreateEvent ( Handle & handle , const ResetType reset_type , const std : : string <nl> / / TOOD ( yuriks ) : Fix error reporting <nl> handle = Kernel : : g_handle_table . Create ( evt ) . ValueOr ( INVALID_HANDLE ) ; <nl> <nl> - evt - > locked = true ; <nl> - evt - > permanent_locked = false ; <nl> + evt - > signaled = false ; <nl> evt - > reset_type = evt - > intitial_reset_type = reset_type ; <nl> evt - > name = name ; <nl> <nl> return evt ; <nl> } <nl> <nl> - / * * <nl> - * Creates an event <nl> - * @ param reset_type ResetType describing how to create event <nl> - * @ param name Optional name of event <nl> - * @ return Handle to newly created Event object <nl> - * / <nl> Handle CreateEvent ( const ResetType reset_type , const std : : string & name ) { <nl> Handle handle ; <nl> Event * evt = CreateEvent ( handle , reset_type , name ) ; <nl> mmm a / src / core / hle / kernel / event . h <nl> ppp b / src / core / hle / kernel / event . h <nl> <nl> <nl> namespace Kernel { <nl> <nl> - / * * <nl> - * Changes whether an event is locked or not <nl> - * @ param handle Handle to event to change <nl> - * @ param locked Boolean locked value to set event <nl> - * / <nl> - ResultCode SetEventLocked ( const Handle handle , const bool locked ) ; <nl> - <nl> - / * * <nl> - * Hackish function to set an events permanent lock state , used to pass through synch blocks <nl> - * @ param handle Handle to event to change <nl> - * @ param permanent_locked Boolean permanent locked value to set event <nl> - * / <nl> - ResultCode SetPermanentLock ( Handle handle , const bool permanent_locked ) ; <nl> - <nl> / * * <nl> * Signals an event <nl> * @ param handle Handle to event to signal <nl> + * @ return Result of operation , 0 on success , otherwise error code <nl> * / <nl> ResultCode SignalEvent ( const Handle handle ) ; <nl> <nl> / * * <nl> * Clears an event <nl> * @ param handle Handle to event to clear <nl> + * @ return Result of operation , 0 on success , otherwise error code <nl> * / <nl> ResultCode ClearEvent ( Handle handle ) ; <nl> <nl> mmm a / src / core / hle / kernel / kernel . cpp <nl> ppp b / src / core / hle / kernel / kernel . cpp <nl> SharedPtr < Thread > g_main_thread = nullptr ; <nl> HandleTable g_handle_table ; <nl> u64 g_program_id = 0 ; <nl> <nl> + void WaitObject : : AddWaitingThread ( Thread * thread ) { <nl> + auto itr = std : : find ( waiting_threads . begin ( ) , waiting_threads . end ( ) , thread ) ; <nl> + if ( itr = = waiting_threads . end ( ) ) <nl> + waiting_threads . push_back ( thread ) ; <nl> + } <nl> + <nl> + void WaitObject : : RemoveWaitingThread ( Thread * thread ) { <nl> + auto itr = std : : find ( waiting_threads . begin ( ) , waiting_threads . end ( ) , thread ) ; <nl> + if ( itr ! = waiting_threads . end ( ) ) <nl> + waiting_threads . erase ( itr ) ; <nl> + } <nl> + <nl> + Thread * WaitObject : : WakeupNextThread ( ) { <nl> + if ( waiting_threads . empty ( ) ) <nl> + return nullptr ; <nl> + <nl> + auto next_thread = waiting_threads . front ( ) ; <nl> + waiting_threads . erase ( waiting_threads . begin ( ) ) ; <nl> + <nl> + next_thread - > ReleaseWaitObject ( this ) ; <nl> + <nl> + return next_thread ; <nl> + } <nl> + <nl> + void WaitObject : : WakeupAllWaitingThreads ( ) { <nl> + auto waiting_threads_copy = waiting_threads ; <nl> + <nl> + / / We use a copy because ReleaseWaitObject will remove the thread from this object ' s <nl> + / / waiting_threads list <nl> + for ( auto thread : waiting_threads_copy ) <nl> + thread - > ReleaseWaitObject ( this ) ; <nl> + <nl> + _assert_msg_ ( Kernel , waiting_threads . empty ( ) , " failed to awaken all waiting threads ! " ) ; <nl> + } <nl> + <nl> HandleTable : : HandleTable ( ) { <nl> next_generation = 1 ; <nl> Clear ( ) ; <nl> mmm a / src / core / hle / kernel / kernel . h <nl> ppp b / src / core / hle / kernel / kernel . h <nl> <nl> <nl> # include < array > <nl> # include < string > <nl> + # include < vector > <nl> + <nl> # include " common / common . h " <nl> # include " core / hle / result . h " <nl> <nl> class Object : NonCopyable { <nl> public : <nl> virtual ~ Object ( ) { } <nl> Handle GetHandle ( ) const { return handle ; } <nl> + <nl> virtual std : : string GetTypeName ( ) const { return " [ BAD KERNEL OBJECT TYPE ] " ; } <nl> virtual std : : string GetName ( ) const { return " [ UNKNOWN KERNEL OBJECT ] " ; } <nl> virtual Kernel : : HandleType GetHandleType ( ) const = 0 ; <nl> <nl> / * * <nl> - * Wait for kernel object to synchronize . <nl> - * @ return True if the current thread should wait as a result of the wait <nl> + * Check if a thread can wait on the object <nl> + * @ return True if a thread can wait on the object , otherwise false <nl> * / <nl> - virtual ResultVal < bool > WaitSynchronization ( ) { <nl> - LOG_ERROR ( Kernel , " ( UNIMPLEMENTED ) " ) ; <nl> - return UnimplementedFunction ( ErrorModule : : Kernel ) ; <nl> + bool IsWaitable ( ) const { <nl> + switch ( GetHandleType ( ) ) { <nl> + case HandleType : : Session : <nl> + case HandleType : : Event : <nl> + case HandleType : : Mutex : <nl> + case HandleType : : Thread : <nl> + case HandleType : : Semaphore : <nl> + case HandleType : : Timer : <nl> + return true ; <nl> + <nl> + case HandleType : : Unknown : <nl> + case HandleType : : Port : <nl> + case HandleType : : SharedMemory : <nl> + case HandleType : : Redirection : <nl> + case HandleType : : Process : <nl> + case HandleType : : AddressArbiter : <nl> + return false ; <nl> + } <nl> + <nl> + return false ; <nl> } <nl> <nl> private : <nl> inline void intrusive_ptr_release ( Object * object ) { <nl> template < typename T > <nl> using SharedPtr = boost : : intrusive_ptr < T > ; <nl> <nl> + / / / Class that represents a Kernel object that a thread can be waiting on <nl> + class WaitObject : public Object { <nl> + public : <nl> + <nl> + / * * <nl> + * Check if the current thread should wait until the object is available <nl> + * @ return True if the current thread should wait due to this object being unavailable <nl> + * / <nl> + virtual bool ShouldWait ( ) = 0 ; <nl> + <nl> + / / / Acquire / lock the object if it is available <nl> + virtual void Acquire ( ) = 0 ; <nl> + <nl> + / * * <nl> + * Add a thread to wait on this object <nl> + * @ param thread Pointer to thread to add <nl> + * / <nl> + void AddWaitingThread ( Thread * thread ) ; <nl> + <nl> + / * * <nl> + * Removes a thread from waiting on this object ( e . g . if it was resumed already ) <nl> + * @ param thread Pointer to thread to remove <nl> + * / <nl> + void RemoveWaitingThread ( Thread * thead ) ; <nl> + <nl> + / * * <nl> + * Wake up the next thread waiting on this object <nl> + * @ return Pointer to the thread that was resumed , nullptr if no threads are waiting <nl> + * / <nl> + Thread * WakeupNextThread ( ) ; <nl> + <nl> + / / / Wake up all threads waiting on this object <nl> + void WakeupAllWaitingThreads ( ) ; <nl> + <nl> + private : <nl> + std : : vector < Thread * > waiting_threads ; / / / < Threads waiting for this object to become available <nl> + } ; <nl> + <nl> / * * <nl> * This class allows the creation of Handles , which are references to objects that can be tested <nl> * for validity and looked up . Here they are used to pass references to kernel objects to / from the <nl> class HandleTable final : NonCopyable { <nl> <nl> / * * <nl> * Looks up a handle . <nl> - * @ returns Pointer to the looked - up object , or ` nullptr ` if the handle is not valid . <nl> + * @ return Pointer to the looked - up object , or ` nullptr ` if the handle is not valid . <nl> * / <nl> SharedPtr < Object > GetGeneric ( Handle handle ) const ; <nl> <nl> / * * <nl> * Looks up a handle while verifying its type . <nl> - * @ returns Pointer to the looked - up object , or ` nullptr ` if the handle is not valid or its <nl> - * type differs from the handle type ` T : : HANDLE_TYPE ` . <nl> + * @ return Pointer to the looked - up object , or ` nullptr ` if the handle is not valid or its <nl> + * type differs from the handle type ` T : : HANDLE_TYPE ` . <nl> * / <nl> template < class T > <nl> SharedPtr < T > Get ( Handle handle ) const { <nl> class HandleTable final : NonCopyable { <nl> return nullptr ; <nl> } <nl> <nl> + / * * <nl> + * Looks up a handle while verifying that it is an object that a thread can wait on <nl> + * @ return Pointer to the looked - up object , or ` nullptr ` if the handle is not valid or it is <nl> + * not a waitable object . <nl> + * / <nl> + SharedPtr < WaitObject > GetWaitObject ( Handle handle ) const { <nl> + SharedPtr < Object > object = GetGeneric ( handle ) ; <nl> + if ( object ! = nullptr & & object - > IsWaitable ( ) ) { <nl> + return boost : : static_pointer_cast < WaitObject > ( std : : move ( object ) ) ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> / / / Closes all handles held in this table . <nl> void Clear ( ) ; <nl> <nl> mmm a / src / core / hle / kernel / mutex . cpp <nl> ppp b / src / core / hle / kernel / mutex . cpp <nl> <nl> <nl> namespace Kernel { <nl> <nl> - class Mutex : public Object { <nl> + class Mutex : public WaitObject { <nl> public : <nl> std : : string GetTypeName ( ) const override { return " Mutex " ; } <nl> std : : string GetName ( ) const override { return name ; } <nl> class Mutex : public Object { <nl> <nl> bool initial_locked ; / / / < Initial lock state when mutex was created <nl> bool locked ; / / / < Current locked state <nl> - Handle lock_thread ; / / / < Handle to thread that currently has mutex <nl> - std : : vector < Handle > waiting_threads ; / / / < Threads that are waiting for the mutex <nl> std : : string name ; / / / < Name of mutex ( optional ) <nl> + SharedPtr < Thread > holding_thread ; / / / < Thread that has acquired the mutex <nl> <nl> - ResultVal < bool > WaitSynchronization ( ) override ; <nl> + bool ShouldWait ( ) override ; <nl> + void Acquire ( ) override ; <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef std : : multimap < Handle , Handle > MutexMap ; <nl> + typedef std : : multimap < SharedPtr < Thread > , SharedPtr < Mutex > > MutexMap ; <nl> static MutexMap g_mutex_held_locks ; <nl> <nl> / * * <nl> * Acquires the specified mutex for the specified thread <nl> * @ param mutex Mutex that is to be acquired <nl> - * @ param thread Thread that will acquired <nl> + * @ param thread Thread that will acquire the mutex <nl> * / <nl> - void MutexAcquireLock ( Mutex * mutex , Handle thread = GetCurrentThread ( ) - > GetHandle ( ) ) { <nl> - g_mutex_held_locks . insert ( std : : make_pair ( thread , mutex - > GetHandle ( ) ) ) ; <nl> - mutex - > lock_thread = thread ; <nl> - } <nl> - <nl> - bool ReleaseMutexForThread ( Mutex * mutex , Handle thread_handle ) { <nl> - MutexAcquireLock ( mutex , thread_handle ) ; <nl> - <nl> - Thread * thread = Kernel : : g_handle_table . Get < Thread > ( thread_handle ) . get ( ) ; <nl> - if ( thread = = nullptr ) { <nl> - LOG_ERROR ( Kernel , " Called with invalid handle : % 08X " , thread_handle ) ; <nl> - return false ; <nl> - } <nl> - <nl> - thread - > ResumeFromWait ( ) ; <nl> - return true ; <nl> + void MutexAcquireLock ( Mutex * mutex , Thread * thread ) { <nl> + g_mutex_held_locks . insert ( std : : make_pair ( thread , mutex ) ) ; <nl> + mutex - > holding_thread = thread ; <nl> } <nl> <nl> / * * <nl> bool ReleaseMutexForThread ( Mutex * mutex , Handle thread_handle ) { <nl> * / <nl> void ResumeWaitingThread ( Mutex * mutex ) { <nl> / / Find the next waiting thread for the mutex . . . <nl> - if ( mutex - > waiting_threads . empty ( ) ) { <nl> + auto next_thread = mutex - > WakeupNextThread ( ) ; <nl> + if ( next_thread ! = nullptr ) { <nl> + MutexAcquireLock ( mutex , next_thread ) ; <nl> + } else { <nl> / / Reset mutex lock thread handle , nothing is waiting <nl> mutex - > locked = false ; <nl> - mutex - > lock_thread = - 1 ; <nl> - } <nl> - else { <nl> - / / Resume the next waiting thread and re - lock the mutex <nl> - std : : vector < Handle > : : iterator iter = mutex - > waiting_threads . begin ( ) ; <nl> - ReleaseMutexForThread ( mutex , * iter ) ; <nl> - mutex - > waiting_threads . erase ( iter ) ; <nl> + mutex - > holding_thread = nullptr ; <nl> } <nl> } <nl> <nl> - void MutexEraseLock ( Mutex * mutex ) { <nl> - Handle handle = mutex - > GetHandle ( ) ; <nl> - auto locked = g_mutex_held_locks . equal_range ( mutex - > lock_thread ) ; <nl> - for ( MutexMap : : iterator iter = locked . first ; iter ! = locked . second ; + + iter ) { <nl> - if ( iter - > second = = handle ) { <nl> - g_mutex_held_locks . erase ( iter ) ; <nl> - break ; <nl> - } <nl> - } <nl> - mutex - > lock_thread = - 1 ; <nl> - } <nl> - <nl> - void ReleaseThreadMutexes ( Handle thread ) { <nl> + void ReleaseThreadMutexes ( Thread * thread ) { <nl> auto locked = g_mutex_held_locks . equal_range ( thread ) ; <nl> <nl> / / Release every mutex that the thread holds , and resume execution on the waiting threads <nl> - for ( MutexMap : : iterator iter = locked . first ; iter ! = locked . second ; + + iter ) { <nl> - Mutex * mutex = g_handle_table . Get < Mutex > ( iter - > second ) . get ( ) ; <nl> - ResumeWaitingThread ( mutex ) ; <nl> + for ( auto iter = locked . first ; iter ! = locked . second ; + + iter ) { <nl> + ResumeWaitingThread ( iter - > second . get ( ) ) ; <nl> } <nl> <nl> / / Erase all the locks that this thread holds <nl> g_mutex_held_locks . erase ( thread ) ; <nl> } <nl> <nl> - bool LockMutex ( Mutex * mutex ) { <nl> - / / Mutex alread locked ? <nl> + bool ReleaseMutex ( Mutex * mutex ) { <nl> if ( mutex - > locked ) { <nl> - return false ; <nl> - } <nl> - MutexAcquireLock ( mutex ) ; <nl> - return true ; <nl> - } <nl> + auto locked = g_mutex_held_locks . equal_range ( mutex - > holding_thread ) ; <nl> <nl> - bool ReleaseMutex ( Mutex * mutex ) { <nl> - MutexEraseLock ( mutex ) ; <nl> - ResumeWaitingThread ( mutex ) ; <nl> + for ( MutexMap : : iterator iter = locked . first ; iter ! = locked . second ; + + iter ) { <nl> + if ( iter - > second = = mutex ) { <nl> + g_mutex_held_locks . erase ( iter ) ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + ResumeWaitingThread ( mutex ) ; <nl> + } <nl> return true ; <nl> } <nl> <nl> Mutex * CreateMutex ( Handle & handle , bool initial_locked , const std : : string & name ) <nl> <nl> mutex - > locked = mutex - > initial_locked = initial_locked ; <nl> mutex - > name = name ; <nl> + mutex - > holding_thread = nullptr ; <nl> <nl> / / Acquire mutex with current thread if initialized as locked . . . <nl> - if ( mutex - > locked ) { <nl> - MutexAcquireLock ( mutex ) ; <nl> + if ( mutex - > locked ) <nl> + MutexAcquireLock ( mutex , GetCurrentThread ( ) ) ; <nl> <nl> - / / Otherwise , reset lock thread handle <nl> - } else { <nl> - mutex - > lock_thread = - 1 ; <nl> - } <nl> return mutex ; <nl> } <nl> <nl> Handle CreateMutex ( bool initial_locked , const std : : string & name ) { <nl> return handle ; <nl> } <nl> <nl> - ResultVal < bool > Mutex : : WaitSynchronization ( ) { <nl> - bool wait = locked ; <nl> - if ( locked ) { <nl> - waiting_threads . push_back ( GetCurrentThread ( ) - > GetHandle ( ) ) ; <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_MUTEX , this ) ; <nl> - } else { <nl> - / / Lock the mutex when the first thread accesses it <nl> - locked = true ; <nl> - MutexAcquireLock ( this ) ; <nl> - } <nl> + bool Mutex : : ShouldWait ( ) { <nl> + return locked & & holding_thread ! = GetCurrentThread ( ) ; <nl> + } <nl> <nl> - return MakeResult < bool > ( wait ) ; <nl> + void Mutex : : Acquire ( ) { <nl> + _assert_msg_ ( Kernel , ! ShouldWait ( ) , " object unavailable ! " ) ; <nl> + locked = true ; <nl> + MutexAcquireLock ( this , GetCurrentThread ( ) ) ; <nl> } <nl> + <nl> } / / namespace <nl> mmm a / src / core / hle / kernel / mutex . h <nl> ppp b / src / core / hle / kernel / mutex . h <nl> Handle CreateMutex ( bool initial_locked , const std : : string & name = " Unknown " ) ; <nl> * Releases all the mutexes held by the specified thread <nl> * @ param thread Thread that is holding the mutexes <nl> * / <nl> - void ReleaseThreadMutexes ( Handle thread ) ; <nl> + void ReleaseThreadMutexes ( Thread * thread ) ; <nl> <nl> } / / namespace <nl> mmm a / src / core / hle / kernel / semaphore . cpp <nl> ppp b / src / core / hle / kernel / semaphore . cpp <nl> <nl> <nl> namespace Kernel { <nl> <nl> - class Semaphore : public Object { <nl> + class Semaphore : public WaitObject { <nl> public : <nl> std : : string GetTypeName ( ) const override { return " Semaphore " ; } <nl> std : : string GetName ( ) const override { return name ; } <nl> class Semaphore : public Object { <nl> <nl> s32 max_count ; / / / < Maximum number of simultaneous holders the semaphore can have <nl> s32 available_count ; / / / < Number of free slots left in the semaphore <nl> - std : : queue < Handle > waiting_threads ; / / / < Threads that are waiting for the semaphore <nl> std : : string name ; / / / < Name of semaphore ( optional ) <nl> <nl> - / * * <nl> - * Tests whether a semaphore still has free slots <nl> - * @ return Whether the semaphore is available <nl> - * / <nl> - bool IsAvailable ( ) const { <nl> - return available_count > 0 ; <nl> + bool ShouldWait ( ) override { <nl> + return available_count < = 0 ; <nl> } <nl> <nl> - ResultVal < bool > WaitSynchronization ( ) override { <nl> - bool wait = ! IsAvailable ( ) ; <nl> - <nl> - if ( wait ) { <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_SEMA , this ) ; <nl> - waiting_threads . push ( GetCurrentThread ( ) - > GetHandle ( ) ) ; <nl> - } else { <nl> - - - available_count ; <nl> - } <nl> - <nl> - return MakeResult < bool > ( wait ) ; <nl> + void Acquire ( ) override { <nl> + _assert_msg_ ( Kernel , ! ShouldWait ( ) , " object unavailable ! " ) ; <nl> + - - available_count ; <nl> } <nl> } ; <nl> <nl> ResultCode ReleaseSemaphore ( s32 * count , Handle handle , s32 release_count ) { <nl> <nl> / / Notify some of the threads that the semaphore has been released <nl> / / stop once the semaphore is full again or there are no more waiting threads <nl> - while ( ! semaphore - > waiting_threads . empty ( ) & & semaphore - > IsAvailable ( ) ) { <nl> - Thread * thread = Kernel : : g_handle_table . Get < Thread > ( semaphore - > waiting_threads . front ( ) ) . get ( ) ; <nl> - if ( thread ! = nullptr ) <nl> - thread - > ResumeFromWait ( ) ; <nl> - semaphore - > waiting_threads . pop ( ) ; <nl> - - - semaphore - > available_count ; <nl> + while ( ! semaphore - > ShouldWait ( ) & & semaphore - > WakeupNextThread ( ) ! = nullptr ) { <nl> + semaphore - > Acquire ( ) ; <nl> } <nl> <nl> return RESULT_SUCCESS ; <nl> mmm a / src / core / hle / kernel / session . h <nl> ppp b / src / core / hle / kernel / session . h <nl> inline static u32 * GetCommandBuffer ( const int offset = 0 ) { <nl> * CTR - OS so that IPC calls can be optionally handled by the real implementations of processes , as <nl> * opposed to HLE simulations . <nl> * / <nl> - class Session : public Object { <nl> + class Session : public WaitObject { <nl> public : <nl> std : : string GetTypeName ( ) const override { return " Session " ; } <nl> <nl> class Session : public Object { <nl> * aren ' t supported yet . <nl> * / <nl> virtual ResultVal < bool > SyncRequest ( ) = 0 ; <nl> + <nl> + / / TODO ( bunnei ) : These functions exist to satisfy a hardware test with a Session object <nl> + / / passed into WaitSynchronization . Figure out the meaning of them . <nl> + <nl> + bool ShouldWait ( ) override { <nl> + return true ; <nl> + } <nl> + <nl> + void Acquire ( ) override { <nl> + _assert_msg_ ( Kernel , ! ShouldWait ( ) , " object unavailable ! " ) ; <nl> + } <nl> } ; <nl> <nl> } <nl> mmm a / src / core / hle / kernel / thread . cpp <nl> ppp b / src / core / hle / kernel / thread . cpp <nl> <nl> <nl> namespace Kernel { <nl> <nl> - ResultVal < bool > Thread : : WaitSynchronization ( ) { <nl> - const bool wait = status ! = THREADSTATUS_DORMANT ; <nl> - if ( wait ) { <nl> - Thread * thread = GetCurrentThread ( ) ; <nl> - if ( std : : find ( waiting_threads . begin ( ) , waiting_threads . end ( ) , thread ) = = waiting_threads . end ( ) ) { <nl> - waiting_threads . push_back ( thread ) ; <nl> - } <nl> - WaitCurrentThread ( WAITTYPE_THREADEND , this ) ; <nl> - } <nl> + bool Thread : : ShouldWait ( ) { <nl> + return status ! = THREADSTATUS_DORMANT ; <nl> + } <nl> <nl> - return MakeResult < bool > ( wait ) ; <nl> + void Thread : : Acquire ( ) { <nl> + _assert_msg_ ( Kernel , ! ShouldWait ( ) , " object unavailable ! " ) ; <nl> } <nl> <nl> / / Lists all thread ids that aren ' t deleted / etc . <nl> static void ResetThread ( Thread * t , u32 arg , s32 lowest_priority ) { <nl> if ( t - > current_priority < lowest_priority ) { <nl> t - > current_priority = t - > initial_priority ; <nl> } <nl> - t - > wait_type = WAITTYPE_NONE ; <nl> - t - > wait_object = nullptr ; <nl> + <nl> + t - > wait_objects . clear ( ) ; <nl> t - > wait_address = 0 ; <nl> } <nl> <nl> static void ChangeReadyState ( Thread * t , bool ready ) { <nl> } <nl> } <nl> <nl> - / / / Check if a thread is blocking on a specified wait type <nl> - static bool CheckWaitType ( const Thread * thread , WaitType type ) { <nl> - return ( type = = thread - > wait_type ) & & ( thread - > IsWaiting ( ) ) ; <nl> - } <nl> + / / / Check if a thread is waiting on a the specified wait object <nl> + static bool CheckWait_WaitObject ( const Thread * thread , WaitObject * wait_object ) { <nl> + auto itr = std : : find ( thread - > wait_objects . begin ( ) , thread - > wait_objects . end ( ) , wait_object ) ; <nl> + <nl> + if ( itr ! = thread - > wait_objects . end ( ) ) <nl> + return thread - > IsWaiting ( ) ; <nl> <nl> - / / / Check if a thread is blocking on a specified wait type with a specified handle <nl> - static bool CheckWaitType ( const Thread * thread , WaitType type , Object * wait_object ) { <nl> - return CheckWaitType ( thread , type ) & & wait_object = = thread - > wait_object ; <nl> + return false ; <nl> } <nl> <nl> - / / / Check if a thread is blocking on a specified wait type with a specified handle and address <nl> - static bool CheckWaitType ( const Thread * thread , WaitType type , Object * wait_object , VAddr wait_address ) { <nl> - return CheckWaitType ( thread , type , wait_object ) & & ( wait_address = = thread - > wait_address ) ; <nl> + / / / Check if the specified thread is waiting on the specified address to be arbitrated <nl> + static bool CheckWait_AddressArbiter ( const Thread * thread , VAddr wait_address ) { <nl> + return thread - > IsWaiting ( ) & & thread - > wait_objects . empty ( ) & & wait_address = = thread - > wait_address ; <nl> } <nl> <nl> / / / Stops the current thread <nl> void Thread : : Stop ( const char * reason ) { <nl> / / Release all the mutexes that this thread holds <nl> - ReleaseThreadMutexes ( GetHandle ( ) ) ; <nl> + ReleaseThreadMutexes ( this ) ; <nl> <nl> ChangeReadyState ( this , false ) ; <nl> status = THREADSTATUS_DORMANT ; <nl> - for ( auto & waiting_thread : waiting_threads ) { <nl> - if ( CheckWaitType ( waiting_thread . get ( ) , WAITTYPE_THREADEND , this ) ) <nl> - waiting_thread - > ResumeFromWait ( ) ; <nl> - } <nl> - waiting_threads . clear ( ) ; <nl> + WakeupAllWaitingThreads ( ) ; <nl> <nl> / / Stopped threads are never waiting . <nl> - wait_type = WAITTYPE_NONE ; <nl> - wait_object = nullptr ; <nl> + wait_objects . clear ( ) ; <nl> wait_address = 0 ; <nl> } <nl> <nl> static void ChangeThreadState ( Thread * t , ThreadStatus new_status ) { <nl> } <nl> ChangeReadyState ( t , ( new_status & THREADSTATUS_READY ) ! = 0 ) ; <nl> t - > status = new_status ; <nl> - <nl> - if ( new_status = = THREADSTATUS_WAIT ) { <nl> - if ( t - > wait_type = = WAITTYPE_NONE ) { <nl> - LOG_ERROR ( Kernel , " Waittype none not allowed " ) ; <nl> - } <nl> - } <nl> } <nl> <nl> / / / Arbitrate the highest priority thread that is waiting <nl> - Thread * ArbitrateHighestPriorityThread ( Object * arbiter , u32 address ) { <nl> + Thread * ArbitrateHighestPriorityThread ( u32 address ) { <nl> Thread * highest_priority_thread = nullptr ; <nl> s32 priority = THREADPRIO_LOWEST ; <nl> <nl> / / Iterate through threads , find highest priority thread that is waiting to be arbitrated . . . <nl> for ( auto & thread : thread_list ) { <nl> - if ( ! CheckWaitType ( thread . get ( ) , WAITTYPE_ARB , arbiter , address ) ) <nl> + if ( ! CheckWait_AddressArbiter ( thread . get ( ) , address ) ) <nl> continue ; <nl> <nl> if ( thread = = nullptr ) <nl> - continue ; / / TODO ( yuriks ) : Thread handle will hang around forever . Should clean up . <nl> + continue ; <nl> <nl> if ( thread - > current_priority < = priority ) { <nl> highest_priority_thread = thread . get ( ) ; <nl> Thread * ArbitrateHighestPriorityThread ( Object * arbiter , u32 address ) { <nl> } <nl> <nl> / / / Arbitrate all threads currently waiting <nl> - void ArbitrateAllThreads ( Object * arbiter , u32 address ) { <nl> + void ArbitrateAllThreads ( u32 address ) { <nl> <nl> / / Iterate through threads , find highest priority thread that is waiting to be arbitrated . . . <nl> for ( auto & thread : thread_list ) { <nl> - if ( CheckWaitType ( thread . get ( ) , WAITTYPE_ARB , arbiter , address ) ) <nl> + if ( CheckWait_AddressArbiter ( thread . get ( ) , address ) ) <nl> thread - > ResumeFromWait ( ) ; <nl> } <nl> } <nl> void ArbitrateAllThreads ( Object * arbiter , u32 address ) { <nl> / / / Calls a thread by marking it as " ready " ( note : will not actually execute until current thread yields ) <nl> static void CallThread ( Thread * t ) { <nl> / / Stop waiting <nl> - if ( t - > wait_type ! = WAITTYPE_NONE ) { <nl> - t - > wait_type = WAITTYPE_NONE ; <nl> - } <nl> ChangeThreadState ( t , THREADSTATUS_READY ) ; <nl> } <nl> <nl> static void SwitchContext ( Thread * t ) { <nl> current_thread = t ; <nl> ChangeReadyState ( t , false ) ; <nl> t - > status = ( t - > status | THREADSTATUS_RUNNING ) & ~ THREADSTATUS_READY ; <nl> - t - > wait_type = WAITTYPE_NONE ; <nl> Core : : g_app_core - > LoadContext ( t - > context ) ; <nl> } else { <nl> current_thread = nullptr ; <nl> static Thread * NextThread ( ) { <nl> return next ; <nl> } <nl> <nl> - void WaitCurrentThread ( WaitType wait_type , Object * wait_object ) { <nl> + void WaitCurrentThread_Sleep ( ) { <nl> Thread * thread = GetCurrentThread ( ) ; <nl> - thread - > wait_type = wait_type ; <nl> - thread - > wait_object = wait_object ; <nl> ChangeThreadState ( thread , ThreadStatus ( THREADSTATUS_WAIT | ( thread - > status & THREADSTATUS_SUSPEND ) ) ) ; <nl> } <nl> <nl> - void WaitCurrentThread ( WaitType wait_type , Object * wait_object , VAddr wait_address ) { <nl> - WaitCurrentThread ( wait_type , wait_object ) ; <nl> - GetCurrentThread ( ) - > wait_address = wait_address ; <nl> + void WaitCurrentThread_WaitSynchronization ( SharedPtr < WaitObject > wait_object , bool wait_set_output , bool wait_all ) { <nl> + Thread * thread = GetCurrentThread ( ) ; <nl> + thread - > wait_set_output = wait_set_output ; <nl> + thread - > wait_all = wait_all ; <nl> + <nl> + / / It ' s possible to call WaitSynchronizationN without any objects passed in . . . <nl> + if ( wait_object ! = nullptr ) <nl> + thread - > wait_objects . push_back ( wait_object ) ; <nl> + <nl> + ChangeThreadState ( thread , ThreadStatus ( THREADSTATUS_WAIT | ( thread - > status & THREADSTATUS_SUSPEND ) ) ) ; <nl> + } <nl> + <nl> + void WaitCurrentThread_ArbitrateAddress ( VAddr wait_address ) { <nl> + Thread * thread = GetCurrentThread ( ) ; <nl> + thread - > wait_address = wait_address ; <nl> + ChangeThreadState ( thread , ThreadStatus ( THREADSTATUS_WAIT | ( thread - > status & THREADSTATUS_SUSPEND ) ) ) ; <nl> } <nl> <nl> / / / Event type for the thread wake up event <nl> static void ThreadWakeupCallback ( u64 parameter , int cycles_late ) { <nl> return ; <nl> } <nl> <nl> + thread - > SetWaitSynchronizationResult ( ResultCode ( ErrorDescription : : Timeout , ErrorModule : : OS , <nl> + ErrorSummary : : StatusChanged , ErrorLevel : : Info ) ) ; <nl> + <nl> + if ( thread - > wait_set_output ) <nl> + thread - > SetWaitSynchronizationOutput ( - 1 ) ; <nl> + <nl> thread - > ResumeFromWait ( ) ; <nl> } <nl> <nl> void WakeThreadAfterDelay ( Thread * thread , s64 nanoseconds ) { <nl> CoreTiming : : ScheduleEvent ( usToCycles ( microseconds ) , ThreadWakeupEventType , thread - > GetHandle ( ) ) ; <nl> } <nl> <nl> - / / / Resumes a thread from waiting by marking it as " ready " <nl> + void Thread : : ReleaseWaitObject ( WaitObject * wait_object ) { <nl> + if ( wait_objects . empty ( ) ) { <nl> + LOG_CRITICAL ( Kernel , " thread is not waiting on any objects ! " ) ; <nl> + return ; <nl> + } <nl> + <nl> + / / Remove this thread from the waiting object ' s thread list <nl> + wait_object - > RemoveWaitingThread ( this ) ; <nl> + <nl> + unsigned index = 0 ; <nl> + bool wait_all_failed = false ; / / Will be set to true if any object is unavailable <nl> + <nl> + / / Iterate through all waiting objects to check availability . . . <nl> + for ( auto itr = wait_objects . begin ( ) ; itr ! = wait_objects . end ( ) ; + + itr ) { <nl> + if ( ( * itr ) - > ShouldWait ( ) ) <nl> + wait_all_failed = true ; <nl> + <nl> + / / The output should be the last index of wait_object <nl> + if ( * itr = = wait_object ) <nl> + index = itr - wait_objects . begin ( ) ; <nl> + } <nl> + <nl> + / / If we are waiting on all objects . . . <nl> + if ( wait_all ) { <nl> + / / Resume the thread only if all are available . . . <nl> + if ( ! wait_all_failed ) { <nl> + SetWaitSynchronizationResult ( RESULT_SUCCESS ) ; <nl> + SetWaitSynchronizationOutput ( - 1 ) ; <nl> + <nl> + ResumeFromWait ( ) ; <nl> + } <nl> + } else { <nl> + / / Otherwise , resume <nl> + SetWaitSynchronizationResult ( RESULT_SUCCESS ) ; <nl> + <nl> + if ( wait_set_output ) <nl> + SetWaitSynchronizationOutput ( index ) ; <nl> + <nl> + ResumeFromWait ( ) ; <nl> + } <nl> + } <nl> + <nl> void Thread : : ResumeFromWait ( ) { <nl> / / Cancel any outstanding wakeup events <nl> CoreTiming : : UnscheduleEvent ( ThreadWakeupEventType , GetHandle ( ) ) ; <nl> <nl> status & = ~ THREADSTATUS_WAIT ; <nl> - wait_object = nullptr ; <nl> - wait_type = WAITTYPE_NONE ; <nl> + <nl> + / / Remove this thread from all other WaitObjects <nl> + for ( auto wait_object : wait_objects ) <nl> + wait_object - > RemoveWaitingThread ( this ) ; <nl> + <nl> + wait_objects . clear ( ) ; <nl> + wait_set_output = false ; <nl> + wait_all = false ; <nl> + wait_address = 0 ; <nl> + <nl> if ( ! ( status & ( THREADSTATUS_WAITSUSPEND | THREADSTATUS_DORMANT | THREADSTATUS_DEAD ) ) ) { <nl> ChangeReadyState ( this , true ) ; <nl> } <nl> ResultVal < SharedPtr < Thread > > Thread : : Create ( std : : string name , VAddr entry_point , <nl> thread - > stack_size = stack_size ; <nl> thread - > initial_priority = thread - > current_priority = priority ; <nl> thread - > processor_id = processor_id ; <nl> - thread - > wait_type = WAITTYPE_NONE ; <nl> - thread - > wait_object = nullptr ; <nl> + thread - > wait_set_output = false ; <nl> + thread - > wait_all = false ; <nl> + thread - > wait_objects . clear ( ) ; <nl> thread - > wait_address = 0 ; <nl> thread - > name = std : : move ( name ) ; <nl> <nl> void Reschedule ( ) { <nl> LOG_TRACE ( Kernel , " cannot context switch from 0x % 08X , no higher priority thread ! " , prev - > GetHandle ( ) ) ; <nl> <nl> for ( auto & thread : thread_list ) { <nl> - LOG_TRACE ( Kernel , " \ thandle = 0x % 08X prio = 0x % 02X , status = 0x % 08X wait_type = 0x % 08X wait_handle = 0x % 08X " , <nl> - thread - > GetHandle ( ) , thread - > current_priority , thread - > status , thread - > wait_type , <nl> - ( thread - > wait_object ? thread - > wait_object - > GetHandle ( ) : INVALID_HANDLE ) ) ; <nl> + LOG_TRACE ( Kernel , " \ thandle = 0x % 08X prio = 0x % 02X , status = 0x % 08X " , thread - > GetHandle ( ) , <nl> + thread - > current_priority , thread - > status ) ; <nl> } <nl> } <nl> } <nl> <nl> + void Thread : : SetWaitSynchronizationResult ( ResultCode result ) { <nl> + context . cpu_registers [ 0 ] = result . raw ; <nl> + } <nl> + <nl> + void Thread : : SetWaitSynchronizationOutput ( s32 output ) { <nl> + context . cpu_registers [ 1 ] = output ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> void ThreadingInit ( ) { <nl> mmm a / src / core / hle / kernel / thread . h <nl> ppp b / src / core / hle / kernel / thread . h <nl> enum ThreadStatus { <nl> THREADSTATUS_WAITSUSPEND = THREADSTATUS_WAIT | THREADSTATUS_SUSPEND <nl> } ; <nl> <nl> - enum WaitType { <nl> - WAITTYPE_NONE , <nl> - WAITTYPE_SLEEP , <nl> - WAITTYPE_SEMA , <nl> - WAITTYPE_EVENT , <nl> - WAITTYPE_THREADEND , <nl> - WAITTYPE_MUTEX , <nl> - WAITTYPE_SYNCH , <nl> - WAITTYPE_ARB , <nl> - WAITTYPE_TIMER , <nl> - } ; <nl> - <nl> namespace Kernel { <nl> <nl> - class Thread : public Kernel : : Object { <nl> + class Thread : public WaitObject { <nl> public : <nl> static ResultVal < SharedPtr < Thread > > Create ( std : : string name , VAddr entry_point , s32 priority , <nl> u32 arg , s32 processor_id , VAddr stack_top , u32 stack_size ) ; <nl> class Thread : public Kernel : : Object { <nl> inline bool IsSuspended ( ) const { return ( status & THREADSTATUS_SUSPEND ) ! = 0 ; } <nl> inline bool IsIdle ( ) const { return idle ; } <nl> <nl> - ResultVal < bool > WaitSynchronization ( ) override ; <nl> + bool ShouldWait ( ) override ; <nl> + void Acquire ( ) override ; <nl> <nl> s32 GetPriority ( ) const { return current_priority ; } <nl> void SetPriority ( s32 priority ) ; <nl> class Thread : public Kernel : : Object { <nl> u32 GetThreadId ( ) const { return thread_id ; } <nl> <nl> void Stop ( const char * reason ) ; <nl> - / / / Resumes a thread from waiting by marking it as " ready " . <nl> + <nl> + / * * <nl> + * Release an acquired wait object <nl> + * @ param wait_object WaitObject to release <nl> + * / <nl> + void ReleaseWaitObject ( WaitObject * wait_object ) ; <nl> + <nl> + / / / Resumes a thread from waiting by marking it as " ready " <nl> void ResumeFromWait ( ) ; <nl> <nl> + / * * <nl> + * Sets the result after the thread awakens ( from either WaitSynchronization SVC ) <nl> + * @ param result Value to set to the returned result <nl> + * / <nl> + void SetWaitSynchronizationResult ( ResultCode result ) ; <nl> + <nl> + / * * <nl> + * Sets the output parameter value after the thread awakens ( from WaitSynchronizationN SVC only ) <nl> + * @ param output Value to set to the output parameter <nl> + * / <nl> + void SetWaitSynchronizationOutput ( s32 output ) ; <nl> + <nl> Core : : ThreadContext context ; <nl> <nl> u32 thread_id ; <nl> class Thread : public Kernel : : Object { <nl> <nl> s32 processor_id ; <nl> <nl> - WaitType wait_type ; <nl> - Object * wait_object ; <nl> - VAddr wait_address ; <nl> + std : : vector < SharedPtr < WaitObject > > wait_objects ; / / / < Objects that the thread is waiting on <nl> <nl> - std : : vector < SharedPtr < Thread > > waiting_threads ; <nl> + VAddr wait_address ; / / / < If waiting on an AddressArbiter , this is the arbitration address <nl> + bool wait_all ; / / / < True if the thread is waiting on all objects before resuming <nl> + bool wait_set_output ; / / / < True if the output parameter should be set on thread wakeup <nl> <nl> std : : string name ; <nl> <nl> class Thread : public Kernel : : Object { <nl> bool idle = false ; <nl> <nl> private : <nl> + <nl> Thread ( ) = default ; <nl> } ; <nl> <nl> SharedPtr < Thread > SetupMainThread ( s32 priority , u32 stack_size ) ; <nl> void Reschedule ( ) ; <nl> <nl> / / / Arbitrate the highest priority thread that is waiting <nl> - Thread * ArbitrateHighestPriorityThread ( Object * arbiter , u32 address ) ; <nl> + Thread * ArbitrateHighestPriorityThread ( u32 address ) ; <nl> <nl> / / / Arbitrate all threads currently waiting . . . <nl> - void ArbitrateAllThreads ( Object * arbiter , u32 address ) ; <nl> + void ArbitrateAllThreads ( u32 address ) ; <nl> <nl> / / / Gets the current thread <nl> Thread * GetCurrentThread ( ) ; <nl> <nl> - / * * <nl> - * Puts the current thread in the wait state for the given type <nl> - * @ param wait_type Type of wait <nl> - * @ param wait_object Kernel object that we are waiting on , defaults to current thread <nl> - * / <nl> - void WaitCurrentThread ( WaitType wait_type , Object * wait_object = GetCurrentThread ( ) ) ; <nl> + / / / Waits the current thread on a sleep <nl> + void WaitCurrentThread_Sleep ( ) ; <nl> <nl> / * * <nl> - * Schedules an event to wake up the specified thread after the specified delay . <nl> - * @ param thread The thread to wake after the delay . <nl> - * @ param nanoseconds The time this thread will be allowed to sleep for . <nl> + * Waits the current thread from a WaitSynchronization call <nl> + * @ param wait_object Kernel object that we are waiting on <nl> + * @ param wait_set_output If true , set the output parameter on thread wakeup ( for WaitSynchronizationN only ) <nl> + * @ param wait_all If true , wait on all objects before resuming ( for WaitSynchronizationN only ) <nl> * / <nl> - void WakeThreadAfterDelay ( Thread * thread , s64 nanoseconds ) ; <nl> + void WaitCurrentThread_WaitSynchronization ( SharedPtr < WaitObject > wait_object , bool wait_set_output , bool wait_all ) ; <nl> <nl> / * * <nl> - * Puts the current thread in the wait state for the given type <nl> - * @ param wait_type Type of wait <nl> - * @ param wait_object Kernel object that we are waiting on <nl> + * Waits the current thread from an ArbitrateAddress call <nl> * @ param wait_address Arbitration address used to resume from wait <nl> * / <nl> - void WaitCurrentThread ( WaitType wait_type , Object * wait_object , VAddr wait_address ) ; <nl> - <nl> + void WaitCurrentThread_ArbitrateAddress ( VAddr wait_address ) ; <nl> <nl> + / * * <nl> + * Schedules an event to wake up the specified thread after the specified delay . <nl> + * @ param handle The thread handle . <nl> + * @ param nanoseconds The time this thread will be allowed to sleep for . <nl> + * / <nl> + void WakeThreadAfterDelay ( Thread * thread , s64 nanoseconds ) ; <nl> <nl> / * * <nl> * Sets up the idle thread , this is a thread that is intended to never execute instructions , <nl> void WaitCurrentThread ( WaitType wait_type , Object * wait_object , VAddr wait_addre <nl> * @ returns The handle of the idle thread <nl> * / <nl> Handle SetupIdleThread ( ) ; <nl> + <nl> / / / Initialize threading <nl> void ThreadingInit ( ) ; <nl> <nl> mmm a / src / core / hle / kernel / timer . cpp <nl> ppp b / src / core / hle / kernel / timer . cpp <nl> <nl> <nl> namespace Kernel { <nl> <nl> - class Timer : public Object { <nl> + class Timer : public WaitObject { <nl> public : <nl> std : : string GetTypeName ( ) const override { return " Timer " ; } <nl> std : : string GetName ( ) const override { return name ; } <nl> class Timer : public Object { <nl> ResetType reset_type ; / / / < The ResetType of this timer <nl> <nl> bool signaled ; / / / < Whether the timer has been signaled or not <nl> - std : : set < Handle > waiting_threads ; / / / < Threads that are waiting for the timer <nl> std : : string name ; / / / < Name of timer ( optional ) <nl> <nl> u64 initial_delay ; / / / < The delay until the timer fires for the first time <nl> u64 interval_delay ; / / / < The delay until the timer fires after the first time <nl> <nl> - ResultVal < bool > WaitSynchronization ( ) override { <nl> - bool wait = ! signaled ; <nl> - if ( wait ) { <nl> - waiting_threads . insert ( GetCurrentThread ( ) - > GetHandle ( ) ) ; <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_TIMER , this ) ; <nl> - } <nl> - return MakeResult < bool > ( wait ) ; <nl> + bool ShouldWait ( ) override { <nl> + return ! signaled ; <nl> + } <nl> + <nl> + void Acquire ( ) override { <nl> + _assert_msg_ ( Kernel , ! ShouldWait ( ) , " object unavailable ! " ) ; <nl> } <nl> } ; <nl> <nl> static void TimerCallback ( u64 timer_handle , int cycles_late ) { <nl> timer - > signaled = true ; <nl> <nl> / / Resume all waiting threads <nl> - for ( Handle thread_handle : timer - > waiting_threads ) { <nl> - if ( SharedPtr < Thread > thread = Kernel : : g_handle_table . Get < Thread > ( thread_handle ) ) <nl> - thread - > ResumeFromWait ( ) ; <nl> - } <nl> - <nl> - timer - > waiting_threads . clear ( ) ; <nl> + timer - > WakeupAllWaitingThreads ( ) ; <nl> <nl> if ( timer - > reset_type = = RESETTYPE_ONESHOT ) <nl> timer - > signaled = false ; <nl> mmm a / src / core / hle / service / apt_u . cpp <nl> ppp b / src / core / hle / service / apt_u . cpp <nl> void Initialize ( Service : : Interface * self ) { <nl> cmd_buff [ 3 ] = notification_event_handle ; <nl> cmd_buff [ 4 ] = pause_event_handle ; <nl> <nl> - Kernel : : SetEventLocked ( notification_event_handle , true ) ; <nl> - Kernel : : SetEventLocked ( pause_event_handle , false ) ; / / Fire start event <nl> + Kernel : : ClearEvent ( notification_event_handle ) ; <nl> + Kernel : : SignalEvent ( pause_event_handle ) ; / / Fire start event <nl> <nl> _assert_msg_ ( KERNEL , ( 0 ! = lock_handle ) , " Cannot initialize without lock " ) ; <nl> Kernel : : ReleaseMutex ( lock_handle ) ; <nl> mmm a / src / core / hle / service / srv . cpp <nl> ppp b / src / core / hle / service / srv . cpp <nl> static void GetProcSemaphore ( Service : : Interface * self ) { <nl> <nl> / / TODO ( bunnei ) : Change to a semaphore once these have been implemented <nl> g_event_handle = Kernel : : CreateEvent ( RESETTYPE_ONESHOT , " SRV : Event " ) ; <nl> - Kernel : : SetEventLocked ( g_event_handle , false ) ; <nl> + Kernel : : ClearEvent ( g_event_handle ) ; <nl> <nl> cmd_buff [ 1 ] = 0 ; / / No error <nl> cmd_buff [ 3 ] = g_event_handle ; <nl> mmm a / src / core / hle / svc . cpp <nl> ppp b / src / core / hle / svc . cpp <nl> using Kernel : : SharedPtr ; <nl> <nl> namespace SVC { <nl> <nl> + / / / An invalid result code that is meant to be overwritten when a thread resumes from waiting <nl> + const ResultCode RESULT_INVALID ( 0xDEADC0DE ) ; <nl> + <nl> enum ControlMemoryOperation { <nl> MEMORY_OPERATION_HEAP = 0x00000003 , <nl> MEMORY_OPERATION_GSP_HEAP = 0x00010003 , <nl> static Result SendSyncRequest ( Handle handle ) { <nl> <nl> LOG_TRACE ( Kernel_SVC , " called handle = 0x % 08X ( % s ) " , handle , session - > GetName ( ) . c_str ( ) ) ; <nl> <nl> - ResultVal < bool > wait = session - > SyncRequest ( ) ; <nl> - if ( wait . Succeeded ( ) & & * wait ) { <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_SYNCH ) ; / / TODO ( bunnei ) : Is this correct ? <nl> - } <nl> - <nl> - return wait . Code ( ) . raw ; <nl> + return session - > SyncRequest ( ) . Code ( ) . raw ; <nl> } <nl> <nl> / / / Close a handle <nl> static Result CloseHandle ( Handle handle ) { <nl> <nl> / / / Wait for a handle to synchronize , timeout after the specified nanoseconds <nl> static Result WaitSynchronization1 ( Handle handle , s64 nano_seconds ) { <nl> - SharedPtr < Kernel : : Object > object = Kernel : : g_handle_table . GetGeneric ( handle ) ; <nl> + auto object = Kernel : : g_handle_table . GetWaitObject ( handle ) ; <nl> if ( object = = nullptr ) <nl> return InvalidHandle ( ErrorModule : : Kernel ) . raw ; <nl> <nl> LOG_TRACE ( Kernel_SVC , " called handle = 0x % 08X ( % s : % s ) , nanoseconds = % lld " , handle , <nl> object - > GetTypeName ( ) . c_str ( ) , object - > GetName ( ) . c_str ( ) , nano_seconds ) ; <nl> <nl> - ResultVal < bool > wait = object - > WaitSynchronization ( ) ; <nl> - <nl> / / Check for next thread to schedule <nl> - if ( wait . Succeeded ( ) & & * wait ) { <nl> + if ( object - > ShouldWait ( ) ) { <nl> + <nl> + object - > AddWaitingThread ( Kernel : : GetCurrentThread ( ) ) ; <nl> + Kernel : : WaitCurrentThread_WaitSynchronization ( object , false , false ) ; <nl> + <nl> / / Create an event to wake the thread up after the specified nanosecond delay has passed <nl> Kernel : : WakeThreadAfterDelay ( Kernel : : GetCurrentThread ( ) , nano_seconds ) ; <nl> + <nl> HLE : : Reschedule ( __func__ ) ; <nl> + <nl> + / / NOTE : output of this SVC will be set later depending on how the thread resumes <nl> + return RESULT_INVALID . raw ; <nl> } <nl> <nl> - return wait . Code ( ) . raw ; <nl> + object - > Acquire ( ) ; <nl> + <nl> + return RESULT_SUCCESS . raw ; <nl> } <nl> <nl> / / / Wait for the given handles to synchronize , timeout after the specified nanoseconds <nl> - static Result WaitSynchronizationN ( s32 * out , Handle * handles , s32 handle_count , bool wait_all , <nl> - s64 nano_seconds ) { <nl> - <nl> - / / TODO ( bunnei ) : Do something with nano_seconds , currently ignoring this <nl> - bool unlock_all = true ; <nl> - bool wait_infinite = ( nano_seconds = = - 1 ) ; / / Used to wait until a thread has terminated <nl> - <nl> - LOG_TRACE ( Kernel_SVC , " called handle_count = % d , wait_all = % s , nanoseconds = % lld " , <nl> - handle_count , ( wait_all ? " true " : " false " ) , nano_seconds ) ; <nl> - <nl> - / / Iterate through each handle , synchronize kernel object <nl> - for ( s32 i = 0 ; i < handle_count ; i + + ) { <nl> - SharedPtr < Kernel : : Object > object = Kernel : : g_handle_table . GetGeneric ( handles [ i ] ) ; <nl> - if ( object = = nullptr ) <nl> - return InvalidHandle ( ErrorModule : : Kernel ) . raw ; <nl> - <nl> - LOG_TRACE ( Kernel_SVC , " \ thandle [ % d ] = 0x % 08X ( % s : % s ) " , i , handles [ i ] , <nl> - object - > GetTypeName ( ) . c_str ( ) , object - > GetName ( ) . c_str ( ) ) ; <nl> - <nl> - / / TODO ( yuriks ) : Verify how the real function behaves when an error happens here <nl> - ResultVal < bool > wait_result = object - > WaitSynchronization ( ) ; <nl> - bool wait = wait_result . Succeeded ( ) & & * wait_result ; <nl> - <nl> - if ( ! wait & & ! wait_all ) { <nl> - * out = i ; <nl> - return RESULT_SUCCESS . raw ; <nl> - } else { <nl> - unlock_all = false ; <nl> + static Result WaitSynchronizationN ( s32 * out , Handle * handles , s32 handle_count , bool wait_all , s64 nano_seconds ) { <nl> + bool wait_thread = ! wait_all ; <nl> + int handle_index = 0 ; <nl> + <nl> + / / Check if ' handles ' is invalid <nl> + if ( handles = = nullptr ) <nl> + return ResultCode ( ErrorDescription : : InvalidPointer , ErrorModule : : Kernel , ErrorSummary : : InvalidArgument , ErrorLevel : : Permanent ) . raw ; <nl> + <nl> + / / NOTE : on real hardware , there is no nullptr check for ' out ' ( tested with firmware 4 . 4 ) . If <nl> + / / this happens , the running application will crash . <nl> + _assert_msg_ ( Kernel , out ! = nullptr , " invalid output pointer specified ! " ) ; <nl> + <nl> + / / Check if ' handle_count ' is invalid <nl> + if ( handle_count < 0 ) <nl> + return ResultCode ( ErrorDescription : : OutOfRange , ErrorModule : : OS , ErrorSummary : : InvalidArgument , ErrorLevel : : Usage ) . raw ; <nl> + <nl> + / / If ' handle_count ' is non - zero , iterate through each handle and wait the current thread if <nl> + / / necessary <nl> + if ( handle_count ! = 0 ) { <nl> + bool selected = false ; / / True once an object has been selected <nl> + for ( int i = 0 ; i < handle_count ; + + i ) { <nl> + auto object = Kernel : : g_handle_table . GetWaitObject ( handles [ i ] ) ; <nl> + if ( object = = nullptr ) <nl> + return InvalidHandle ( ErrorModule : : Kernel ) . raw ; <nl> + <nl> + / / Check if the current thread should wait on this object . . . <nl> + if ( object - > ShouldWait ( ) ) { <nl> + <nl> + / / Check we are waiting on all objects . . . <nl> + if ( wait_all ) <nl> + / / Wait the thread <nl> + wait_thread = true ; <nl> + } else { <nl> + / / Do not wait on this object , check if this object should be selected . . . <nl> + if ( ! wait_all & & ! selected ) { <nl> + / / Do not wait the thread <nl> + wait_thread = false ; <nl> + handle_index = i ; <nl> + selected = true ; <nl> + } <nl> + } <nl> + } <nl> + } else { <nl> + / / If no handles were passed in , put the thread to sleep only when ' wait_all ' is false <nl> + / / NOTE : This should deadlock the current thread if no timeout was specified <nl> + if ( ! wait_all ) { <nl> + wait_thread = true ; <nl> + Kernel : : WaitCurrentThread_WaitSynchronization ( nullptr , true , wait_all ) ; <nl> + } <nl> + } <nl> + <nl> + / / If thread should wait , then set its state to waiting and then reschedule . . . <nl> + if ( wait_thread ) { <nl> + <nl> + / / Actually wait the current thread on each object if we decided to wait . . . <nl> + for ( int i = 0 ; i < handle_count ; + + i ) { <nl> + auto object = Kernel : : g_handle_table . GetWaitObject ( handles [ i ] ) ; <nl> + object - > AddWaitingThread ( Kernel : : GetCurrentThread ( ) ) ; <nl> + Kernel : : WaitCurrentThread_WaitSynchronization ( object , true , wait_all ) ; <nl> } <nl> + <nl> + / / Create an event to wake the thread up after the specified nanosecond delay has passed <nl> + Kernel : : WakeThreadAfterDelay ( Kernel : : GetCurrentThread ( ) , nano_seconds ) ; <nl> + <nl> + HLE : : Reschedule ( __func__ ) ; <nl> + <nl> + / / NOTE : output of this SVC will be set later depending on how the thread resumes <nl> + return RESULT_INVALID . raw ; <nl> } <nl> <nl> - if ( wait_all & & unlock_all ) { <nl> - * out = handle_count ; <nl> - return RESULT_SUCCESS . raw ; <nl> + / / Acquire objects if we did not wait . . . <nl> + for ( int i = 0 ; i < handle_count ; + + i ) { <nl> + auto object = Kernel : : g_handle_table . GetWaitObject ( handles [ i ] ) ; <nl> + <nl> + / / Acquire the object if it is not waiting . . . <nl> + if ( ! object - > ShouldWait ( ) ) { <nl> + object - > Acquire ( ) ; <nl> + <nl> + / / If this was the first non - waiting object and ' wait_all ' is false , don ' t acquire <nl> + / / any other objects <nl> + if ( ! wait_all ) <nl> + break ; <nl> + } <nl> } <nl> <nl> - / / Check for next thread to schedule <nl> - HLE : : Reschedule ( __func__ ) ; <nl> + / / TODO ( bunnei ) : If ' wait_all ' is true , this is probably wrong . However , real hardware does <nl> + / / not seem to set it to any meaningful value . <nl> + * out = wait_all ? 0 : handle_index ; <nl> <nl> return RESULT_SUCCESS . raw ; <nl> } <nl> static Result DuplicateHandle ( Handle * out , Handle handle ) { <nl> / / / Signals an event <nl> static Result SignalEvent ( Handle evt ) { <nl> LOG_TRACE ( Kernel_SVC , " called event = 0x % 08X " , evt ) ; <nl> + HLE : : Reschedule ( __func__ ) ; <nl> return Kernel : : SignalEvent ( evt ) . raw ; <nl> } <nl> <nl> static void SleepThread ( s64 nanoseconds ) { <nl> LOG_TRACE ( Kernel_SVC , " called nanoseconds = % lld " , nanoseconds ) ; <nl> <nl> / / Sleep current thread and check for next thread to schedule <nl> - Kernel : : WaitCurrentThread ( WAITTYPE_SLEEP ) ; <nl> + Kernel : : WaitCurrentThread_Sleep ( ) ; <nl> <nl> / / Create an event to wake the thread up after the specified nanosecond delay has passed <nl> Kernel : : WakeThreadAfterDelay ( Kernel : : GetCurrentThread ( ) , nanoseconds ) ; <nl> | Merge pull request from bunnei / fix - waitsynch | yuzu-emu/yuzu | 24a63662ba6c7816001bba399e85d8c131a89489 | 2015-01-22T02:09:47Z |
mmm a / src / Interpreters / AggregateFunctionOfGroupByKeysVisitor . h <nl> ppp b / src / Interpreters / AggregateFunctionOfGroupByKeysVisitor . h <nl> <nl> # include < Parsers / ASTTablesInSelectQuery . h > <nl> # include < Parsers / IAST . h > <nl> # include < Common / typeid_cast . h > <nl> + # include < Parsers / ASTSubquery . h > <nl> <nl> namespace DB <nl> { <nl> class SelectAggregateFunctionOfGroupByKeysMatcher <nl> <nl> static bool needChildVisit ( const ASTPtr & node , const ASTPtr & ) <nl> { <nl> - return ! ( node - > as < ASTFunction > ( ) ) ; <nl> + return ! node - > as < ASTSubquery > ( ) & & ! ( node - > as < ASTFunction > ( ) ) ; <nl> } <nl> <nl> static void visit ( ASTPtr & ast , Data & data ) <nl> mmm a / src / Interpreters / TreeOptimizer . cpp <nl> ppp b / src / Interpreters / TreeOptimizer . cpp <nl> void optimizeGroupByFunctionKeys ( ASTSelectQuery * select_query ) <nl> } <nl> <nl> / / / Eliminates min / max / any - aggregators of functions of GROUP BY keys <nl> - void optimizeAggregateFunctionsOfGroupByKeys ( ASTSelectQuery * select_query ) <nl> + void optimizeAggregateFunctionsOfGroupByKeys ( ASTSelectQuery * select_query , ASTPtr & node ) <nl> { <nl> if ( ! select_query - > groupBy ( ) ) <nl> return ; <nl> void optimizeAggregateFunctionsOfGroupByKeys ( ASTSelectQuery * select_query ) <nl> <nl> GroupByKeysInfo group_by_keys_data = getGroupByKeysInfo ( group_keys ) ; <nl> <nl> - auto select = select_query - > select ( ) ; <nl> - <nl> SelectAggregateFunctionOfGroupByKeysVisitor : : Data visitor_data { group_by_keys_data . key_names } ; <nl> - SelectAggregateFunctionOfGroupByKeysVisitor ( visitor_data ) . visit ( select ) ; <nl> + SelectAggregateFunctionOfGroupByKeysVisitor ( visitor_data ) . visit ( node ) ; <nl> } <nl> <nl> / / / Remove duplicate items from ORDER BY . <nl> void TreeOptimizer : : apply ( ASTPtr & query , Aliases & aliases , const NameSet & sou <nl> <nl> / / / Eliminate min / max / any aggregators of functions of GROUP BY keys <nl> if ( settings . optimize_aggregators_of_group_by_keys ) <nl> - optimizeAggregateFunctionsOfGroupByKeys ( select_query ) ; <nl> + optimizeAggregateFunctionsOfGroupByKeys ( select_query , query ) ; <nl> <nl> / / / Remove duplicate items from ORDER BY . <nl> optimizeDuplicatesInOrderBy ( select_query ) ; <nl> | ISSUES - 12513 try fix difference expressions with same alias | ClickHouse/ClickHouse | d79d0127ad7fa16f6019ae36df504bb9393ba0a9 | 2020-10-13T05:30:56Z |
mmm a / INSTALL . md <nl> ppp b / INSTALL . md <nl> And then <nl> cd aseprite <nl> mkdir build <nl> cd build <nl> - cmake - DCMAKE_BUILD_TYPE = RelWithDebInfo - DLAF_BACKEND = skia - DSKIA_DIR = C : \ deps \ skia - DSKIA_LIBRARY_DIR = C : \ deps \ skia \ out \ Release - x64 - G Ninja . . <nl> + cmake - DCMAKE_BUILD_TYPE = RelWithDebInfo - DLAF_BACKEND = skia - DSKIA_DIR = C : \ deps \ skia - DSKIA_LIBRARY_DIR = C : \ deps \ skia \ out \ Release - x64 - DSKIA_LIBRARY = C : \ deps \ skia \ out \ Release - x64 \ skia . lib - G Ninja . . <nl> ninja aseprite <nl> <nl> In this case , ` C : \ deps \ skia ` is the directory where Skia was compiled <nl> Run ` cmake ` with the following parameters and then ` ninja ` : <nl> - DLAF_BACKEND = skia \ <nl> - DSKIA_DIR = $ HOME / deps / skia \ <nl> - DSKIA_LIBRARY_DIR = $ HOME / deps / skia / out / Release - x64 \ <nl> + - DSKIA_LIBRARY = $ HOME / deps / skia / out / Release - x64 / libskia . a \ <nl> - G Ninja \ <nl> . . <nl> ninja aseprite <nl> Run ` cmake ` with the following parameters and then ` ninja ` : <nl> - DLAF_BACKEND = skia \ <nl> - DSKIA_DIR = $ HOME / deps / skia \ <nl> - DSKIA_LIBRARY_DIR = $ HOME / deps / skia / out / Release - x64 \ <nl> + - DSKIA_LIBRARY = $ HOME / deps / skia / out / Release - x64 / libskia . a \ <nl> - G Ninja \ <nl> . . <nl> ninja aseprite <nl> | Add - DSKIA_LIBRARY flag for laf library in compilation instructions | aseprite/aseprite | 88f9fbebecdcbcd023750c99db5555198dbdc2d2 | 2020-08-17T14:57:05Z |
mmm a / dbms / tests / integration / test_distributed_ddl / test . py <nl> ppp b / dbms / tests / integration / test_distributed_ddl / test . py <nl> def test_optimize_query ( started_cluster ) : <nl> ddl_check_query ( instance , " DROP TABLE IF EXISTS test_optimize ON CLUSTER cluster FORMAT TSV " ) <nl> ddl_check_query ( instance , " CREATE TABLE test_optimize ON CLUSTER cluster ( p Date , i Int32 ) ENGINE = MergeTree ( p , p , 8192 ) " ) <nl> ddl_check_query ( instance , " OPTIMIZE TABLE test_optimize ON CLUSTER cluster FORMAT TSV " ) <nl> - <nl> + <nl> <nl> def test_create_as_select ( started_cluster ) : <nl> instance = cluster . instances [ ' ch2 ' ] <nl> - ddl_check_query ( instance , " CREATE TABLE test_as_select ON CLUSTER cluster ENGINE = Memory AS ( SELECT number FROM system . numbers_mt LIMIT 5 ) " ) <nl> - assert TSV ( instance . query ( " SELECT number FROM test_as_select ORDER BY number " ) ) = = TSV ( " 0 \ n1 \ n2 \ n3 \ n4 \ n " ) <nl> + ddl_check_query ( instance , " CREATE TABLE test_as_select ON CLUSTER cluster ENGINE = Memory AS ( SELECT 1 AS x UNION ALL SELECT 2 AS x ) " ) <nl> + assert TSV ( instance . query ( " SELECT x FROM test_as_select ORDER BY x " ) ) = = TSV ( " 1 \ n2 \ n " ) <nl> ddl_check_query ( instance , " DROP TABLE IF EXISTS test_as_select ON CLUSTER cluster " ) <nl> <nl> <nl> | update test | ClickHouse/ClickHouse | a4fac0907325b3a27eafb6446e675856eeeb3463 | 2018-09-28T16:43:41Z |
mmm a / tensorflow / core / data / service / dispatcher_impl . cc <nl> ppp b / tensorflow / core / data / service / dispatcher_impl . cc <nl> Status DataServiceDispatcherImpl : : Start ( ) { <nl> if ( ! config_ . fault_tolerant_mode ( ) ) { <nl> LOG ( INFO ) < < " Running with fault_tolerant_mode = False . The dispatcher will " <nl> " not be able to recover its state on restart . " ; <nl> + started_ = true ; <nl> return Status : : OK ( ) ; <nl> } <nl> journal_writer_ = absl : : make_unique < FileJournalWriter > ( <nl> Status DataServiceDispatcherImpl : : Start ( ) { <nl> / / Initialize the journal writer in ` Start ` so that we fail fast in case it <nl> / / can ' t be initialized . <nl> TF_RETURN_IF_ERROR ( journal_writer_ . value ( ) - > EnsureInitialized ( ) ) ; <nl> + started_ = true ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> Status DataServiceDispatcherImpl : : WorkerHeartbeat ( <nl> const WorkerHeartbeatRequest * request , WorkerHeartbeatResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> VLOG ( 3 ) < < " Received worker heartbeat request from worker " <nl> < < request - > worker_address ( ) ; <nl> mutex_lock l ( mu_ ) ; <nl> Status DataServiceDispatcherImpl : : WorkerHeartbeat ( <nl> <nl> Status DataServiceDispatcherImpl : : WorkerUpdate ( <nl> const WorkerUpdateRequest * request , WorkerUpdateResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> mutex_lock l ( mu_ ) ; <nl> for ( auto & update : request - > updates ( ) ) { <nl> int64 task_id = update . task_id ( ) ; <nl> Status DataServiceDispatcherImpl : : WorkerUpdate ( <nl> <nl> Status DataServiceDispatcherImpl : : GetDatasetDef ( <nl> const GetDatasetDefRequest * request , GetDatasetDefResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> mutex_lock l ( mu_ ) ; <nl> std : : shared_ptr < const Dataset > dataset ; <nl> TF_RETURN_IF_ERROR ( state_ . DatasetFromId ( request - > dataset_id ( ) , dataset ) ) ; <nl> Status DataServiceDispatcherImpl : : GetDatasetDef ( <nl> Status DataServiceDispatcherImpl : : GetOrRegisterDataset ( <nl> const GetOrRegisterDatasetRequest * request , <nl> GetOrRegisterDatasetResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> uint64 fingerprint ; <nl> const GraphDef & graph = request - > dataset ( ) . graph ( ) ; <nl> TF_RETURN_IF_ERROR ( HashGraph ( graph , & fingerprint ) ) ; <nl> Status DataServiceDispatcherImpl : : RegisterDataset ( uint64 fingerprint , <nl> <nl> Status DataServiceDispatcherImpl : : CreateJob ( const CreateJobRequest * request , <nl> CreateJobResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> VLOG ( 3 ) < < " Received create job request for dataset id " <nl> < < request - > dataset_id ( ) ; <nl> ProcessingMode processing_mode = ProcessingMode ( request - > processing_mode ( ) ) ; <nl> Status DataServiceDispatcherImpl : : CreateJob ( const CreateJobRequest * request , <nl> <nl> Status DataServiceDispatcherImpl : : GetOrCreateJob ( <nl> const GetOrCreateJobRequest * request , GetOrCreateJobResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> VLOG ( 3 ) < < " Received get or create job request for dataset id " <nl> < < request - > dataset_id ( ) < < " with name " < < request - > job_name ( ) <nl> < < " and index " < < request - > job_name_index ( ) ; <nl> Status DataServiceDispatcherImpl : : GetOrCreateJob ( <nl> Status DataServiceDispatcherImpl : : ReleaseJobClient ( <nl> const ReleaseJobClientRequest * request , <nl> ReleaseJobClientResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> mutex_lock l ( mu_ ) ; <nl> int64 job_client_id = request - > job_client_id ( ) ; <nl> std : : shared_ptr < const Job > job ; <nl> Status DataServiceDispatcherImpl : : AssignTask ( std : : shared_ptr < const Task > task ) <nl> <nl> Status DataServiceDispatcherImpl : : GetTasks ( const GetTasksRequest * request , <nl> GetTasksResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> mutex_lock l ( mu_ ) ; <nl> VLOG ( 3 ) < < " Looking up tasks for job client id " < < request - > job_client_id ( ) ; <nl> std : : shared_ptr < const Job > job ; <nl> Status DataServiceDispatcherImpl : : GetTasks ( const GetTasksRequest * request , <nl> <nl> Status DataServiceDispatcherImpl : : GetWorkers ( const GetWorkersRequest * request , <nl> GetWorkersResponse * response ) { <nl> + TF_RETURN_IF_ERROR ( CheckStarted ( ) ) ; <nl> mutex_lock l ( mu_ ) ; <nl> VLOG ( 3 ) < < " Enter GetWorkers " ; <nl> std : : vector < std : : shared_ptr < const Worker > > workers = state_ . ListWorkers ( ) ; <nl> Status DataServiceDispatcherImpl : : GetWorkers ( const GetWorkersRequest * request , <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + Status DataServiceDispatcherImpl : : CheckStarted ( ) LOCKS_EXCLUDED ( mu_ ) { <nl> + mutex_lock l ( mu_ ) ; <nl> + if ( ! started_ ) { <nl> + return errors : : Unavailable ( " Dispatcher has not started yet . " ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> Status DataServiceDispatcherImpl : : ApplyWithoutJournaling ( const Update & update ) <nl> EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) { <nl> return state_ . Apply ( update ) ; <nl> mmm a / tensorflow / core / data / service / dispatcher_impl . h <nl> ppp b / tensorflow / core / data / service / dispatcher_impl . h <nl> class DataServiceDispatcherImpl { <nl> Status ValidateMatchingJob ( std : : shared_ptr < const DispatcherState : : Job > job , <nl> ProcessingMode processing_mode , int64 dataset_id ) <nl> EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> + / / Checks that the dispatcher has started , returning UNAVAILABLE if it hasn ' t . <nl> + Status CheckStarted ( ) LOCKS_EXCLUDED ( mu_ ) ; <nl> / / Applies a state update , updating both the journal and the in - memory state . <nl> Status Apply ( const Update & update ) EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> / / Applies a state update , but doesn ' t update the journal . Only meant to be <nl> class DataServiceDispatcherImpl { <nl> Env * env_ ; <nl> <nl> mutex mu_ ; <nl> + bool started_ TF_GUARDED_BY ( mu_ ) = false ; <nl> bool cancelled_ TF_GUARDED_BY ( mu_ ) = false ; <nl> <nl> / / Cached worker stubs for communicating with workers . <nl> | [ tf . data service ] Avoid serving RPCs while dispatcher is starting . | tensorflow/tensorflow | 1a8805d3ed91f97aef068121778a9fd3ea4bf106 | 2020-09-10T23:16:50Z |
mmm a / xbmc / Application . cpp <nl> ppp b / xbmc / Application . cpp <nl> bool CApplication : : PlayFile ( const CFileItem & item , bool bRestart ) <nl> # ifdef HAS_DVD_DRIVE <nl> / / Display the Play Eject dialog <nl> if ( CGUIDialogPlayEject : : ShowAndGetInput ( item ) ) <nl> - return MEDIA_DETECT : : CAutorun : : PlayDiscAskResume ( item . GetPath ( ) ) ; <nl> + / / PlayDiscAskResume takes path to disc . No parameter means default DVD drive . <nl> + / / Can ' t do better as CGUIDialogPlayEject calls CMediaManager : : IsDiscInDrive , which assumes default DVD drive anyway <nl> + return MEDIA_DETECT : : CAutorun : : PlayDiscAskResume ( ) ; <nl> # endif <nl> return true ; <nl> } <nl> bool CApplication : : PlayFile ( const CFileItem & item , bool bRestart ) <nl> options . starttime = 0 . 0f ; <nl> CBookmark bookmark ; <nl> CStdString path = item . GetPath ( ) ; <nl> - if ( item . IsDVD ( ) ) <nl> + if ( item . HasVideoInfoTag ( ) & & item . GetVideoInfoTag ( ) - > m_strFileNameAndPath . Find ( " removable : / / " ) = = 0 ) <nl> path = item . GetVideoInfoTag ( ) - > m_strFileNameAndPath ; <nl> - if ( item . HasProperty ( " original_listitem_url " ) & & URIUtils : : IsPlugin ( item . GetProperty ( " original_listitem_url " ) . asString ( ) ) ) <nl> + else if ( item . HasProperty ( " original_listitem_url " ) & & URIUtils : : IsPlugin ( item . GetProperty ( " original_listitem_url " ) . asString ( ) ) ) <nl> path = item . GetProperty ( " original_listitem_url " ) . asString ( ) ; <nl> if ( dbs . GetResumeBookMark ( path , bookmark ) ) <nl> { <nl> mmm a / xbmc / Autorun . cpp <nl> ppp b / xbmc / Autorun . cpp <nl> void CAutorun : : ExecuteAutorun ( bool bypassSettings , bool ignoreplaying , bool sta <nl> g_application . ResetScreenSaver ( ) ; <nl> g_application . WakeUpScreenSaverAndDPMS ( ) ; / / turn off the screensaver if it ' s active <nl> <nl> - RunMedia ( bypassSettings , startFromBeginning ) ; <nl> + PlayDisc ( " " , bypassSettings , startFromBeginning ) ; <nl> } <nl> <nl> bool CAutorun : : RunCdda ( ) <nl> bool CAutorun : : RunCdda ( ) <nl> return true ; <nl> } <nl> <nl> - void CAutorun : : RunMedia ( bool bypassSettings , bool startFromBeginning ) <nl> + bool CAutorun : : PlayDisc ( const CStdString & path , bool bypassSettings , bool startFromBeginning ) <nl> { <nl> if ( ! bypassSettings & & ! g_guiSettings . GetBool ( " audiocds . autorun " ) & & ! g_guiSettings . GetBool ( " dvds . autorun " ) ) <nl> - return ; <nl> + return false ; <nl> <nl> int nSize = g_playlistPlayer . GetPlaylist ( PLAYLIST_MUSIC ) . size ( ) ; <nl> int nAddedToPlaylist = 0 ; <nl> - # ifdef _WIN32 <nl> - auto_ptr < IDirectory > pDir ( CFactoryDirectory : : Create ( g_mediaManager . TranslateDevicePath ( " " ) ) ) ; <nl> - bool bPlaying = RunDisc ( pDir . get ( ) , g_mediaManager . TranslateDevicePath ( " " ) , nAddedToPlaylist , true , bypassSettings , startFromBeginning ) ; <nl> - # else <nl> - CCdInfo * pInfo = g_mediaManager . GetCdInfo ( ) ; <nl> <nl> - if ( pInfo = = NULL ) <nl> - return ; <nl> + CStdString mediaPath = path ; <nl> <nl> - bool bPlaying ; <nl> - if ( pInfo - > IsISOUDF ( 1 ) | | pInfo - > IsISOHFS ( 1 ) | | pInfo - > IsIso9660 ( 1 ) | | pInfo - > IsIso9660Interactive ( 1 ) ) <nl> - { <nl> - auto_ptr < IDirectory > pDir ( CFactoryDirectory : : Create ( " iso9660 : / / " ) ) ; <nl> - bPlaying = RunDisc ( pDir . get ( ) , " iso9660 : / / " , nAddedToPlaylist , true , bypassSettings , startFromBeginning ) ; <nl> - } <nl> - else <nl> + # ifdef _WIN32 <nl> + if ( mediaPath . IsEmpty ( ) ) <nl> + mediaPath = g_mediaManager . TranslateDevicePath ( " " ) ; <nl> + <nl> + # else <nl> + if ( mediaPath . IsEmpty ( ) ) <nl> { <nl> - auto_ptr < IDirectory > pDir ( CFactoryDirectory : : Create ( " D : \ \ " ) ) ; <nl> - bPlaying = RunDisc ( pDir . get ( ) , " D : \ \ " , nAddedToPlaylist , true , bypassSettings , startFromBeginning ) ; <nl> + CCdInfo * pInfo = g_mediaManager . GetCdInfo ( ) ; <nl> + if ( pInfo = = NULL ) <nl> + return false ; <nl> + <nl> + if ( pInfo - > IsISOUDF ( 1 ) | | pInfo - > IsISOHFS ( 1 ) | | pInfo - > IsIso9660 ( 1 ) | | pInfo - > IsIso9660Interactive ( 1 ) ) <nl> + mediaPath = " iso9660 : / / " ; <nl> + else <nl> + mediaPath = " D : \ \ " ; / / Is this XBOX remnant ? ? <nl> } <nl> # endif <nl> + <nl> + auto_ptr < IDirectory > pDir ( CFactoryDirectory : : Create ( mediaPath ) ) ; <nl> + bool bPlaying = RunDisc ( pDir . get ( ) , mediaPath , nAddedToPlaylist , true , bypassSettings , startFromBeginning ) ; <nl> + <nl> if ( ! bPlaying & & nAddedToPlaylist > 0 ) <nl> { <nl> CGUIMessage msg ( GUI_MSG_PLAYLIST_CHANGED , 0 , 0 ) ; <nl> g_windowManager . SendMessage ( msg ) ; <nl> g_playlistPlayer . SetCurrentPlaylist ( PLAYLIST_MUSIC ) ; <nl> / / Start playing the items we inserted <nl> - g_playlistPlayer . Play ( nSize ) ; <nl> + return g_playlistPlayer . Play ( nSize ) ; <nl> } <nl> + <nl> + return bPlaying ; <nl> } <nl> <nl> / * * <nl> bool CAutorun : : IsEnabled ( ) const <nl> return m_bEnable ; <nl> } <nl> <nl> - bool CAutorun : : PlayDisc ( const CStdString & path , bool startFromBeginning ) <nl> - { <nl> - int nSize = g_playlistPlayer . GetPlaylist ( PLAYLIST_MUSIC ) . size ( ) ; <nl> - int nAddedToPlaylist = 0 ; <nl> - auto_ptr < IDirectory > pDir ( CFactoryDirectory : : Create ( path ) ) ; <nl> - bool bPlaying = RunDisc ( pDir . get ( ) , path , nAddedToPlaylist , true , true , startFromBeginning ) ; <nl> - if ( ! bPlaying & & nAddedToPlaylist > 0 ) <nl> - { <nl> - CGUIMessage msg ( GUI_MSG_PLAYLIST_CHANGED , 0 , 0 ) ; <nl> - g_windowManager . SendMessage ( msg ) ; <nl> - g_playlistPlayer . SetCurrentPlaylist ( PLAYLIST_MUSIC ) ; <nl> - / / Start playing the items we inserted <nl> - g_playlistPlayer . Play ( nSize ) ; <nl> - bPlaying = true ; <nl> - } <nl> - return bPlaying ; <nl> - } <nl> - <nl> bool CAutorun : : PlayDiscAskResume ( const CStdString & path ) <nl> { <nl> - return PlayDisc ( path , ! CanResumePlayDVD ( path ) | | CGUIDialogYesNo : : ShowAndGetInput ( 341 , - 1 , - 1 , - 1 , 13404 , 12021 ) ) ; <nl> + return PlayDisc ( path , true , ! CanResumePlayDVD ( path ) | | CGUIDialogYesNo : : ShowAndGetInput ( 341 , - 1 , - 1 , - 1 , 13404 , 12021 ) ) ; <nl> } <nl> <nl> bool CAutorun : : CanResumePlayDVD ( const CStdString & path ) <nl> mmm a / xbmc / Autorun . h <nl> ppp b / xbmc / Autorun . h <nl> class CAutorun <nl> CAutorun ( ) ; <nl> virtual ~ CAutorun ( ) ; <nl> static bool CanResumePlayDVD ( const CStdString & path ) ; <nl> - static bool PlayDisc ( const CStdString & path , bool startFromBeginning ) ; <nl> - static bool PlayDiscAskResume ( const CStdString & path ) ; <nl> + static bool PlayDisc ( const CStdString & path = " " , bool bypassSettings = false , bool startFromBeginning = false ) ; <nl> + static bool PlayDiscAskResume ( const CStdString & path = " " ) ; <nl> bool IsEnabled ( ) const ; <nl> void Enable ( ) ; <nl> void Disable ( ) ; <nl> class CAutorun <nl> static void ExecuteAutorun ( bool bypassSettings = false , bool ignoreplaying = false , bool startFromBeginning = false ) ; <nl> protected : <nl> static bool RunCdda ( ) ; <nl> - static void RunMedia ( bool bypassSettings , bool startFromBeginning ) ; <nl> static bool RunDisc ( XFILE : : IDirectory * pDir , const CStdString & strDrive , int & nAddedToPlaylist , bool bRoot , bool bypassSettings , bool startFromBeginning ) ; <nl> bool m_bEnable ; <nl> } ; <nl> mmm a / xbmc / dialogs / GUIDialogContextMenu . cpp <nl> ppp b / xbmc / dialogs / GUIDialogContextMenu . cpp <nl> bool CGUIDialogContextMenu : : OnContextButton ( const CStdString & type , const CFileI <nl> <nl> # ifdef HAS_DVD_DRIVE <nl> case CONTEXT_BUTTON_PLAY_DISC : <nl> - return MEDIA_DETECT : : CAutorun : : PlayDisc ( item - > GetPath ( ) , true ) ; / / restart <nl> + return MEDIA_DETECT : : CAutorun : : PlayDisc ( item - > GetPath ( ) , true , true ) ; / / restart <nl> <nl> case CONTEXT_BUTTON_RESUME_DISC : <nl> - return MEDIA_DETECT : : CAutorun : : PlayDisc ( item - > GetPath ( ) , false ) ; / / resume <nl> + return MEDIA_DETECT : : CAutorun : : PlayDisc ( item - > GetPath ( ) , true , false ) ; / / resume <nl> <nl> case CONTEXT_BUTTON_EJECT_DISC : <nl> # ifdef _WIN32 <nl> mmm a / xbmc / interfaces / Builtins . cpp <nl> ppp b / xbmc / interfaces / Builtins . cpp <nl> int CBuiltins : : Execute ( const CStdString & execString ) <nl> bool restart = false ; <nl> if ( params . size ( ) > 0 & & params [ 0 ] . CompareNoCase ( " restart " ) = = 0 ) <nl> restart = true ; <nl> - CAutorun : : PlayDisc ( g_mediaManager . GetDiscPath ( ) , restart ) ; <nl> + CAutorun : : PlayDisc ( g_mediaManager . GetDiscPath ( ) , true , restart ) ; <nl> # endif <nl> } <nl> else if ( execute . Equals ( " ripcd " ) ) <nl> mmm a / xbmc / utils / SaveFileStateJob . h <nl> ppp b / xbmc / utils / SaveFileStateJob . h <nl> class CSaveFileStateJob : public CJob <nl> bool CSaveFileStateJob : : DoWork ( ) <nl> { <nl> CStdString progressTrackingFile = m_item . GetPath ( ) ; <nl> - if ( m_item . HasProperty ( " original_listitem_url " ) & & <nl> + if ( m_item . HasVideoInfoTag ( ) & & m_item . GetVideoInfoTag ( ) - > m_strFileNameAndPath . Find ( " removable : / / " ) = = 0 ) <nl> + progressTrackingFile = m_item . GetVideoInfoTag ( ) - > m_strFileNameAndPath ; / / this variable contains removable : / / suffixed by disc label + uniqueid or is empty if label not uniquely identified <nl> + else if ( m_item . HasProperty ( " original_listitem_url " ) & & <nl> URIUtils : : IsPlugin ( m_item . GetProperty ( " original_listitem_url " ) . asString ( ) ) ) <nl> progressTrackingFile = m_item . GetProperty ( " original_listitem_url " ) . asString ( ) ; <nl> <nl> - if ( m_item . IsDVD ( ) ) <nl> - progressTrackingFile = m_item . GetVideoInfoTag ( ) - > m_strFileNameAndPath ; / / this variable contains removable : / / suffixed by disc label + uniqueid or is empty if label not uniquely identified <nl> - <nl> if ( progressTrackingFile ! = " " ) <nl> { <nl> if ( m_item . IsVideo ( ) ) <nl> | Merge pull request from Voyager - xbmc / fix - resume - dvd | xbmc/xbmc | 90c88c1f87a2031d2c94e1b7693c162632836bff | 2011-12-28T17:47:27Z |
mmm a / go / README . md <nl> ppp b / go / README . md <nl> INSTALL <nl> mmmmmm - <nl> <nl> ` ` ` sh <nl> - $ go get - u github . com / grpc - common / go / greeter_client <nl> - $ go get - u github . com / grpc - common / go / greeter_server <nl> + $ go get - u github . com / grpc / grpc - common / go / greeter_client <nl> + $ go get - u github . com / grpc / grpc - common / go / greeter_server <nl> ` ` ` <nl> <nl> TRY IT ! <nl> | Adding grpc org to path | grpc/grpc | 4a8feaac4cc48be2cfcda99a5ec9eea5736ea58d | 2015-02-24T19:52:49Z |
mmm a / src / video_core / engines / maxwell_dma . cpp <nl> ppp b / src / video_core / engines / maxwell_dma . cpp <nl> void MaxwellDMA : : HandleCopy ( ) { <nl> ASSERT ( regs . src_params . pos_y = = 0 ) ; <nl> ASSERT ( regs . dst_params . pos_x = = 0 ) ; <nl> ASSERT ( regs . dst_params . pos_y = = 0 ) ; <nl> - ASSERT ( regs . exec . is_dst_linear ! = regs . exec . is_src_linear ) ; <nl> + <nl> + if ( regs . exec . is_dst_linear = = regs . exec . is_src_linear ) { <nl> + Memory : : CopyBlock ( dest_cpu , source_cpu , regs . x_count * regs . y_count ) ; <nl> + return ; <nl> + } <nl> <nl> u8 * src_buffer = Memory : : GetPointer ( source_cpu ) ; <nl> u8 * dst_buffer = Memory : : GetPointer ( dest_cpu ) ; <nl> | GPU : Directly copy the pixels when performing a same - layout DMA . | yuzu-emu/yuzu | ca633a5a3c156491d75e715c3c9481a36bbe2bae | 2018-07-02T14:46:33Z |
mmm a / src / core / iomgr / tcp_client_posix . c <nl> ppp b / src / core / iomgr / tcp_client_posix . c <nl> <nl> # include < grpc / support / string_util . h > <nl> # include < grpc / support / time . h > <nl> <nl> + extern int grpc_tcp_trace ; <nl> + <nl> typedef struct { <nl> void ( * cb ) ( void * arg , grpc_endpoint * tcp ) ; <nl> void * cb_arg ; <nl> static int prepare_socket ( const struct sockaddr * addr , int fd ) { <nl> static void tc_on_alarm ( void * acp , int success ) { <nl> int done ; <nl> async_connect * ac = acp ; <nl> + if ( grpc_tcp_trace ) { <nl> + gpr_log ( GPR_DEBUG , " CLIENT_CONNECT : % s : on_alarm : success = % d " , ac - > addr_str , <nl> + success ) ; <nl> + } <nl> gpr_mu_lock ( & ac - > mu ) ; <nl> if ( ac - > fd ! = NULL ) { <nl> grpc_fd_shutdown ( ac - > fd ) ; <nl> static void on_writable ( void * acp , int success ) { <nl> void * cb_arg = ac - > cb_arg ; <nl> grpc_fd * fd ; <nl> <nl> + if ( grpc_tcp_trace ) { <nl> + gpr_log ( GPR_DEBUG , " CLIENT_CONNECT : % s : on_writable : success = % d " , <nl> + ac - > addr_str , success ) ; <nl> + } <nl> + <nl> gpr_mu_lock ( & ac - > mu ) ; <nl> GPR_ASSERT ( ac - > fd ) ; <nl> fd = ac - > fd ; <nl> void grpc_tcp_client_connect ( void ( * cb ) ( void * arg , grpc_endpoint * ep ) , <nl> ac - > write_closure . cb = on_writable ; <nl> ac - > write_closure . cb_arg = ac ; <nl> <nl> + if ( grpc_tcp_trace ) { <nl> + gpr_log ( GPR_DEBUG , " CLIENT_CONNECT : % s : asynchronously connecting " , <nl> + ac - > addr_str ) ; <nl> + } <nl> + <nl> gpr_mu_lock ( & ac - > mu ) ; <nl> grpc_alarm_init ( & ac - > alarm , <nl> gpr_convert_clock_type ( deadline , GPR_CLOCK_MONOTONIC ) , <nl> mmm a / src / core / iomgr / tcp_server_posix . c <nl> ppp b / src / core / iomgr / tcp_server_posix . c <nl> static void on_read ( void * arg , int success ) { <nl> addr_str = grpc_sockaddr_to_uri ( ( struct sockaddr * ) & addr ) ; <nl> gpr_asprintf ( & name , " tcp - server - connection : % s " , addr_str ) ; <nl> <nl> + if ( grpc_tcp_trace ) { <nl> + gpr_log ( GPR_DEBUG , " SERVER_CONNECT : incoming connection : % s " , addr_str ) ; <nl> + } <nl> + <nl> fdobj = grpc_fd_create ( fd , name ) ; <nl> / * TODO ( ctiller ) : revise this when we have server - side sharding <nl> of channels - - we certainly should not be automatically adding every <nl> | Merge pull request from ctiller / cowabunga | grpc/grpc | 34619572cbe159e4eeddfd6800b2d313e6b3583b | 2015-09-16T18:01:14Z |
mmm a / dbms / src / DataStreams / CubeBlockInputStream . cpp <nl> ppp b / dbms / src / DataStreams / CubeBlockInputStream . cpp <nl> Block CubeBlockInputStream : : getHeader ( ) const <nl> <nl> Block CubeBlockInputStream : : readImpl ( ) <nl> { <nl> - / * * After reading a block from input stream , <nl> + / * * After reading all blocks from input stream , <nl> * we will calculate all subsets of columns on next iterations of readImpl <nl> * by zeroing columns at positions , where bits are zero in current bitmask . <nl> * / <nl> - if ( mask ) <nl> + <nl> + if ( ! is_data_read ) <nl> { <nl> - - - mask ; <nl> - Block cube_block = source_block ; <nl> - for ( size_t i = 0 ; i < keys . size ( ) ; + + i ) <nl> + BlocksList source_blocks ; <nl> + while ( auto block = children [ 0 ] - > read ( ) ) <nl> + source_blocks . push_back ( block ) ; <nl> + <nl> + if ( source_blocks . empty ( ) ) <nl> + return { } ; <nl> + <nl> + is_data_read = true ; <nl> + mask = ( 1 < < keys . size ( ) ) - 1 ; <nl> + <nl> + if ( source_blocks . size ( ) > 1 ) <nl> + source_block = aggregator . mergeBlocks ( source_blocks , false ) ; <nl> + else <nl> + source_block = std : : move ( source_blocks . front ( ) ) ; <nl> + <nl> + zero_block = source_block . cloneEmpty ( ) ; <nl> + for ( auto key : keys ) <nl> { <nl> - if ( ! ( ( mask > > i ) & 1 ) ) <nl> - { <nl> - size_t pos = keys . size ( ) - i - 1 ; <nl> - auto & current = cube_block . getByPosition ( keys [ pos ] ) ; <nl> - current . column = zero_block . getByPosition ( keys [ pos ] ) . column ; <nl> - } <nl> + auto & current = zero_block . getByPosition ( key ) ; <nl> + current . column = current . column - > cloneResized ( source_block . rows ( ) ) ; <nl> } <nl> <nl> - BlocksList cube_blocks = { cube_block } ; <nl> - Block finalized = aggregator . mergeBlocks ( cube_blocks , true ) ; <nl> + auto finalized = source_block ; <nl> + finalizeBlock ( finalized ) ; <nl> return finalized ; <nl> } <nl> <nl> - source_block = children [ 0 ] - > read ( ) ; <nl> - if ( ! source_block ) <nl> - return source_block ; <nl> + if ( ! mask ) <nl> + return { } ; <nl> + <nl> + - - mask ; <nl> + auto cube_block = source_block ; <nl> <nl> - zero_block = source_block . cloneEmpty ( ) ; <nl> - for ( auto key : keys ) <nl> + for ( size_t i = 0 ; i < keys . size ( ) ; + + i ) <nl> { <nl> - auto & current = zero_block . getByPosition ( key ) ; <nl> - current . column = current . column - > cloneResized ( source_block . rows ( ) ) ; <nl> + if ( ! ( ( mask > > i ) & 1 ) ) <nl> + { <nl> + size_t pos = keys . size ( ) - i - 1 ; <nl> + auto & current = cube_block . getByPosition ( keys [ pos ] ) ; <nl> + current . column = zero_block . getByPosition ( keys [ pos ] ) . column ; <nl> + } <nl> } <nl> - Block finalized = source_block ; <nl> - finalizeBlock ( finalized ) ; <nl> - mask = ( 1 < < keys . size ( ) ) - 1 ; <nl> <nl> + BlocksList cube_blocks = { cube_block } ; <nl> + Block finalized = aggregator . mergeBlocks ( cube_blocks , true ) ; <nl> return finalized ; <nl> } <nl> } <nl> mmm a / dbms / src / DataStreams / CubeBlockInputStream . h <nl> ppp b / dbms / src / DataStreams / CubeBlockInputStream . h <nl> class CubeBlockInputStream : public IBlockInputStream <nl> UInt32 mask = 0 ; <nl> Block source_block ; <nl> Block zero_block ; <nl> + bool is_data_read = false ; <nl> } ; <nl> <nl> } <nl> mmm a / dbms / src / DataStreams / RollupBlockInputStream . cpp <nl> ppp b / dbms / src / DataStreams / RollupBlockInputStream . cpp <nl> Block RollupBlockInputStream : : readImpl ( ) <nl> * by zeroing out every column one - by - one and re - merging a block . <nl> * / <nl> <nl> - if ( current_key > = 0 ) <nl> + if ( ! is_data_read ) <nl> { <nl> - auto & current = rollup_block . getByPosition ( keys [ current_key ] ) ; <nl> - current . column = current . column - > cloneEmpty ( ) - > cloneResized ( rollup_block . rows ( ) ) ; <nl> - - - current_key ; <nl> + BlocksList source_blocks ; <nl> + while ( auto block = children [ 0 ] - > read ( ) ) <nl> + source_blocks . push_back ( block ) ; <nl> <nl> - BlocksList rollup_blocks = { rollup_block } ; <nl> - rollup_block = aggregator . mergeBlocks ( rollup_blocks , false ) ; <nl> + if ( source_blocks . empty ( ) ) <nl> + return { } ; <nl> <nl> - Block finalized = rollup_block ; <nl> + is_data_read = true ; <nl> + if ( source_blocks . size ( ) > 1 ) <nl> + rollup_block = aggregator . mergeBlocks ( source_blocks , false ) ; <nl> + else <nl> + rollup_block = std : : move ( source_blocks . front ( ) ) ; <nl> + <nl> + current_key = keys . size ( ) - 1 ; <nl> + <nl> + auto finalized = rollup_block ; <nl> finalizeBlock ( finalized ) ; <nl> return finalized ; <nl> } <nl> <nl> - Block block = children [ 0 ] - > read ( ) ; <nl> - current_key = keys . size ( ) - 1 ; <nl> + if ( current_key < 0 ) <nl> + return { } ; <nl> + <nl> + auto & current = rollup_block . getByPosition ( keys [ current_key ] ) ; <nl> + current . column = current . column - > cloneEmpty ( ) - > cloneResized ( rollup_block . rows ( ) ) ; <nl> + - - current_key ; <nl> <nl> - rollup_block = block ; <nl> - finalizeBlock ( block ) ; <nl> + BlocksList rollup_blocks = { rollup_block } ; <nl> + rollup_block = aggregator . mergeBlocks ( rollup_blocks , false ) ; <nl> <nl> - return block ; <nl> + auto finalized = rollup_block ; <nl> + finalizeBlock ( finalized ) ; <nl> + return finalized ; <nl> } <nl> } <nl> mmm a / dbms / src / DataStreams / RollupBlockInputStream . h <nl> ppp b / dbms / src / DataStreams / RollupBlockInputStream . h <nl> class RollupBlockInputStream : public IBlockInputStream <nl> ColumnNumbers keys ; <nl> ssize_t current_key = - 1 ; <nl> Block rollup_block ; <nl> + bool is_data_read = false ; <nl> } ; <nl> <nl> } <nl> mmm a / dbms / tests / queries / 0_stateless / 00701_rollup . reference <nl> ppp b / dbms / tests / queries / 0_stateless / 00701_rollup . reference <nl> a 70 4 <nl> b 50 4 <nl> <nl> 120 8 <nl> + 120 8 <nl> + a 70 4 <nl> + b 50 4 <nl> + 0 120 8 <nl> + a 0 70 4 <nl> + a 1 25 2 <nl> + a 2 45 2 <nl> + b 0 50 4 <nl> + b 1 15 2 <nl> + b 2 35 2 <nl> mmm a / dbms / tests / queries / 0_stateless / 00701_rollup . sql <nl> ppp b / dbms / tests / queries / 0_stateless / 00701_rollup . sql <nl> <nl> DROP TABLE IF EXISTS rollup ; <nl> CREATE TABLE rollup ( a String , b Int32 , s Int32 ) ENGINE = Memory ; <nl> <nl> - INSERT INTO rollup VALUES ( ' a ' , 1 , 10 ) ; <nl> - INSERT INTO rollup VALUES ( ' a ' , 1 , 15 ) ; <nl> - INSERT INTO rollup VALUES ( ' a ' , 2 , 20 ) ; <nl> - INSERT INTO rollup VALUES ( ' a ' , 2 , 25 ) ; <nl> - INSERT INTO rollup VALUES ( ' b ' , 1 , 10 ) ; <nl> - INSERT INTO rollup VALUES ( ' b ' , 1 , 5 ) ; <nl> - INSERT INTO rollup VALUES ( ' b ' , 2 , 20 ) ; <nl> - INSERT INTO rollup VALUES ( ' b ' , 2 , 15 ) ; <nl> + INSERT INTO rollup VALUES ( ' a ' , 1 , 10 ) , ( ' a ' , 1 , 15 ) , ( ' a ' , 2 , 20 ) ; <nl> + INSERT INTO rollup VALUES ( ' a ' , 2 , 25 ) , ( ' b ' , 1 , 10 ) , ( ' b ' , 1 , 5 ) ; <nl> + INSERT INTO rollup VALUES ( ' b ' , 2 , 20 ) , ( ' b ' , 2 , 15 ) ; <nl> <nl> SELECT a , b , sum ( s ) , count ( ) from rollup GROUP BY ROLLUP ( a , b ) ORDER BY a , b ; <nl> <nl> SELECT a , sum ( s ) , count ( ) from rollup GROUP BY a WITH ROLLUP ORDER BY a ; <nl> <nl> SELECT a , sum ( s ) , count ( ) from rollup GROUP BY a WITH ROLLUP WITH TOTALS ORDER BY a ; <nl> <nl> + SET group_by_two_level_threshold = 1 ; <nl> + <nl> + SELECT a , sum ( s ) , count ( ) from rollup GROUP BY a WITH ROLLUP ORDER BY a ; <nl> + SELECT a , b , sum ( s ) , count ( ) from rollup GROUP BY a , b WITH ROLLUP ORDER BY a , b ; <nl> + <nl> DROP TABLE rollup ; <nl> mmm a / dbms / tests / queries / 0_stateless / 00720_with_cube . reference <nl> ppp b / dbms / tests / queries / 0_stateless / 00720_with_cube . reference <nl> b 1 15 2 <nl> b 2 35 2 <nl> <nl> 0 120 8 <nl> - 1 40 4 <nl> 0 120 8 <nl> + 1 40 4 <nl> 2 80 4 <nl> a 0 70 4 <nl> a 1 25 2 <nl> a 2 45 2 <nl> b 0 50 4 <nl> b 1 15 2 <nl> b 2 35 2 <nl> - 1 40 4 <nl> 0 120 8 <nl> + 1 40 4 <nl> 2 80 4 <nl> a 0 70 4 <nl> a 1 25 2 <nl> b 1 15 2 <nl> b 2 35 2 <nl> <nl> 0 120 8 <nl> + 0 120 8 <nl> + 1 40 4 <nl> + 2 80 4 <nl> + a 0 70 4 <nl> + a 1 25 2 <nl> + a 2 45 2 <nl> + b 0 50 4 <nl> + b 1 15 2 <nl> + b 2 35 2 <nl> mmm a / dbms / tests / queries / 0_stateless / 00720_with_cube . sql <nl> ppp b / dbms / tests / queries / 0_stateless / 00720_with_cube . sql <nl> <nl> - DROP TABLE IF EXISTS rollup ; <nl> - CREATE TABLE rollup ( a String , b Int32 , s Int32 ) ENGINE = Memory ; <nl> + DROP TABLE IF EXISTS cube ; <nl> + CREATE TABLE cube ( a String , b Int32 , s Int32 ) ENGINE = Memory ; <nl> <nl> - INSERT INTO rollup VALUES ( ' a ' , 1 , 10 ) ; <nl> - INSERT INTO rollup VALUES ( ' a ' , 1 , 15 ) ; <nl> - INSERT INTO rollup VALUES ( ' a ' , 2 , 20 ) ; <nl> - INSERT INTO rollup VALUES ( ' a ' , 2 , 25 ) ; <nl> - INSERT INTO rollup VALUES ( ' b ' , 1 , 10 ) ; <nl> - INSERT INTO rollup VALUES ( ' b ' , 1 , 5 ) ; <nl> - INSERT INTO rollup VALUES ( ' b ' , 2 , 20 ) ; <nl> - INSERT INTO rollup VALUES ( ' b ' , 2 , 15 ) ; <nl> + - - SET experimental_use_processors = 1 ; <nl> <nl> - SELECT a , b , sum ( s ) , count ( ) from rollup GROUP BY CUBE ( a , b ) ORDER BY a , b ; <nl> + INSERT INTO cube VALUES ( ' a ' , 1 , 10 ) , ( ' a ' , 1 , 15 ) , ( ' a ' , 2 , 20 ) ; <nl> + INSERT INTO cube VALUES ( ' a ' , 2 , 25 ) , ( ' b ' , 1 , 10 ) , ( ' b ' , 1 , 5 ) ; <nl> + INSERT INTO cube VALUES ( ' b ' , 2 , 20 ) , ( ' b ' , 2 , 15 ) ; <nl> <nl> - SELECT a , b , sum ( s ) , count ( ) from rollup GROUP BY CUBE ( a , b ) WITH TOTALS ORDER BY a , b ; <nl> + SELECT a , b , sum ( s ) , count ( ) from cube GROUP BY CUBE ( a , b ) ORDER BY a , b ; <nl> <nl> - SELECT a , b , sum ( s ) , count ( ) from rollup GROUP BY a , b WITH CUBE ORDER BY a ; <nl> + SELECT a , b , sum ( s ) , count ( ) from cube GROUP BY CUBE ( a , b ) WITH TOTALS ORDER BY a , b ; <nl> <nl> - SELECT a , b , sum ( s ) , count ( ) from rollup GROUP BY a , b WITH CUBE WITH TOTALS ORDER BY a ; <nl> + SELECT a , b , sum ( s ) , count ( ) from cube GROUP BY a , b WITH CUBE ORDER BY a , b ; <nl> <nl> - DROP TABLE rollup ; <nl> + SELECT a , b , sum ( s ) , count ( ) from cube GROUP BY a , b WITH CUBE WITH TOTALS ORDER BY a , b ; <nl> + <nl> + SET group_by_two_level_threshold = 1 ; <nl> + SELECT a , b , sum ( s ) , count ( ) from cube GROUP BY a , b WITH CUBE ORDER BY a , b ; <nl> + <nl> + DROP TABLE cube ; <nl> | Merge pull request from CurtizJ / withcube - fix | ClickHouse/ClickHouse | 8949ef6dd3b4fd639919b1c524ffe2d09b70de9c | 2019-07-30T21:54:35Z |
mmm a / lang / tests / mpm . cpp <nl> ppp b / lang / tests / mpm . cpp <nl> TC_TEST ( " simd_mpm " ) { <nl> SLP ( slp ) ; <nl> auto contrib = Eval ( mv - affine * fx ) ; <nl> SLP ( 1 ) ; <nl> - for ( int i = 0 ; i < T ; i + + ) { <nl> - auto contrib0 = Eval ( contrib + real ( i ) * affine . col ( 0 ) ) ; <nl> - for ( int j = 0 ; j < T ; j + + ) { <nl> - auto contrib1 = Eval ( contrib0 + real ( j ) * affine . col ( 1 ) ) ; <nl> - for ( int k = 0 ; k < T ; k + + ) { <nl> - auto contrib2 = Eval ( contrib1 + real ( k ) * affine . col ( 2 ) ) ; <nl> - grid [ base_offset + ( 0 ) ] + = contrib2 ; <nl> - } <nl> - } <nl> - } <nl> + grid [ base_offset + ( 0 ) ] + = contrib ; <nl> } ) ; <nl> } ) ; <nl> <nl> | still fails | taichi-dev/taichi | 33085c2db6a61870244c06a566d2f31aa09d3627 | 2019-03-10T03:11:17Z |
mmm a / modules / perception / conf / perception_lowcost . conf <nl> ppp b / modules / perception / conf / perception_lowcost . conf <nl> <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # Front camera parameters <nl> mmmfront_camera_extrinsics_file = data / params / front_camera_extrinsics . yaml <nl> mmmfront_camera_intrinsics_file = data / params / front_camera_intrinsics . yaml <nl> - <nl> + - - front_camera_extrinsics_file = / data / params / front_camera_extrinsics . yaml <nl> + - - front_camera_intrinsics_file = / data / params / front_camera_intrinsics . yaml <nl> mmm a / modules / perception / obstacle / onboard / motion_service . cc <nl> ppp b / modules / perception / obstacle / onboard / motion_service . cc <nl> void MotionService : : OnLocalization ( <nl> timestamp_diff = 0 ; <nl> } else { <nl> vehicle_status . yaw_rate = localization . pose ( ) . angular_velocity_vrf ( ) . z ( ) ; <nl> - timestamp_diff = localization . measurement_time ( ) - pre_timestamp ; <nl> + timestamp_diff = localization . measurement_time ( ) - pre_timestamp_ ; <nl> } <nl> <nl> VehicleInformation vehicle_information ; <nl> void MotionService : : OnLocalization ( <nl> MutexLock lock ( & mutex_ ) ; <nl> vehicle_information_buffer_ . push_back ( vehicle_information ) ; <nl> } <nl> - pre_timestamp = localization . measurement_time ( ) ; <nl> + pre_timestamp_ = localization . measurement_time ( ) ; <nl> <nl> / / add motion to buffer <nl> double camera_timestamp = camera_shared_data_ - > GetLatestTimestamp ( ) ; <nl> - if ( std : : abs ( pre_timestamp - camera_timestamp ) < <nl> + if ( std : : abs ( pre_timestamp_ - camera_timestamp ) < <nl> std : : numeric_limits < double > : : epsilon ( ) ) { <nl> / / exactly same timestamp <nl> vehicle_planemotion_ - > add_new_motion ( & vehicle_status , timestamp_diff , <nl> PlaneMotion : : ACCUM_PUSH_MOTION ) ; <nl> - } else if ( pre_timestamp < camera_timestamp ) { <nl> + } else if ( pre_timestamp_ < camera_timestamp ) { <nl> vehicle_planemotion_ - > add_new_motion ( & vehicle_status , timestamp_diff , <nl> PlaneMotion : : ACCUM_MOTION ) ; <nl> } else { <nl> mmm a / modules / perception / obstacle / onboard / motion_service . h <nl> ppp b / modules / perception / obstacle / onboard / motion_service . h <nl> struct VehicleInformation { <nl> class MotionService : public Subnode { <nl> public : <nl> MotionService ( ) = default ; <nl> - virtual ~ MotionService ( ) { delete vehicle_planemotion_ ; } <nl> + virtual ~ MotionService ( ) { <nl> + delete vehicle_planemotion_ ; <nl> + } <nl> <nl> - common : : Status ProcEvents ( ) override { return common : : Status : : OK ( ) ; } <nl> + common : : Status ProcEvents ( ) override { <nl> + return common : : Status : : OK ( ) ; <nl> + } <nl> <nl> void GetVehicleInformation ( float timestamp , <nl> VehicleInformation * vehicle_informatino ) ; <nl> class MotionService : public Subnode { <nl> void OnLocalization ( const localization : : LocalizationEstimate & localization ) ; <nl> PlaneMotion * vehicle_planemotion_ = nullptr ; <nl> double pre_azimuth = 0 ; / / a invalid value <nl> - double pre_timestamp = 0 ; <nl> + double pre_timestamp_ = 0 ; <nl> / / double pre_camera_timestamp = 0 ; <nl> bool start_flag_ = false ; <nl> const int motion_buffer_size_ = 6000 ; <nl> new file mode 100755 <nl> index 00000000000 . . 5328a2c612a <nl> mmm / dev / null <nl> ppp b / scripts / perception_offline_visualizer . sh <nl> <nl> + # ! / usr / bin / env bash <nl> + <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + # Copyright 2018 The Apollo Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + <nl> + <nl> + DIR = " $ ( cd " $ ( dirname " $ { BASH_SOURCE [ 0 ] } " ) " & & pwd ) " <nl> + <nl> + source " $ { DIR } / apollo_base . sh " <nl> + # run function from apollo_base . sh <nl> + # run command_name module_name <nl> + $ APOLLO_BIN_PREFIX / modules / perception / perception - - flagfile = / apollo / modules / perception / conf / perception_lowcost . conf - - dag_config_path = / apollo / modules / perception / conf / dag_camera_obstacle_offline . config <nl> | Perception : fix offline_visualizer conf path and add scripts | ApolloAuto/apollo | ddae77f2827eea9b64834dd77d1684fb9ae2c53e | 2018-03-22T16:14:00Z |
deleted file mode 100644 <nl> index 17cda1482ec . . 00000000000 <nl> mmm a / system / include / execinfo . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - * Copyright ( c ) 2003 Maxim Sobolev < sobomax @ FreeBSD . org > <nl> - * All rights reserved . <nl> - * <nl> - * Redistribution and use in source and binary forms , with or without <nl> - * modification , are permitted provided that the following conditions <nl> - * are met : <nl> - * 1 . Redistributions of source code must retain the above copyright <nl> - * notice , this list of conditions and the following disclaimer . <nl> - * 2 . Redistributions in binary form must reproduce the above copyright <nl> - * notice , this list of conditions and the following disclaimer in the <nl> - * documentation and / or other materials provided with the distribution . <nl> - * <nl> - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ` ` AS IS ' ' AND <nl> - * ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE <nl> - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE <nl> - * ARE DISCLAIMED . IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE <nl> - * FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL <nl> - * DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS <nl> - * OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) <nl> - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT <nl> - * LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY <nl> - * OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF <nl> - * SUCH DAMAGE . <nl> - * <nl> - * $ Id : execinfo . h , v 1 . 2 2004 / 07 / 19 05 : 20 : 29 sobomax Exp $ <nl> - * / <nl> - <nl> - # ifndef COMPAT_EXECINFO_H_INCLUDED <nl> - # define COMPAT_EXECINFO_H_INCLUDED <nl> - <nl> - # ifdef __cplusplus <nl> - extern " C " { <nl> - # endif <nl> - <nl> - int backtrace ( void * * , int ) ; <nl> - char * * backtrace_symbols ( void * const * , int ) ; <nl> - void backtrace_symbols_fd ( void * const * , int , int ) ; <nl> - <nl> - # ifdef __cplusplus <nl> - } <nl> - # endif <nl> - <nl> - # endif / * COMPAT_EXECINFO_H_INCLUDED * / <nl> deleted file mode 100644 <nl> index f8d43d0d0e1 . . 00000000000 <nl> mmm a / system / include / unwind . h <nl> ppp / dev / null <nl> <nl> - / * libunwind - a platform - independent unwind library <nl> - Copyright ( C ) 2003 Hewlett - Packard Co <nl> - Contributed by David Mosberger - Tang < davidm @ hpl . hp . com > <nl> - <nl> - This file is part of libunwind . <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining <nl> - a copy of this software and associated documentation files ( the <nl> - " Software " ) , to deal in the Software without restriction , including <nl> - without limitation the rights to use , copy , modify , merge , publish , <nl> - distribute , sublicense , and / or sell copies of the Software , and to <nl> - permit persons to whom the Software is furnished to do so , subject to <nl> - the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be <nl> - included in all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , <nl> - EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF <nl> - MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND <nl> - NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE <nl> - LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION <nl> - OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION <nl> - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - <nl> - # ifndef _UNWIND_H <nl> - # define _UNWIND_H <nl> - <nl> - / * For uint64_t * / <nl> - # include < stdint . h > <nl> - <nl> - # ifdef __cplusplus <nl> - extern " C " { <nl> - # endif <nl> - <nl> - / * Minimal interface as per C + + ABI draft standard : <nl> - <nl> - http : / / www . codesourcery . com / cxx - abi / abi - eh . html * / <nl> - <nl> - typedef enum <nl> - { <nl> - _URC_NO_REASON = 0 , <nl> - _URC_FOREIGN_EXCEPTION_CAUGHT = 1 , <nl> - _URC_FATAL_PHASE2_ERROR = 2 , <nl> - _URC_FATAL_PHASE1_ERROR = 3 , <nl> - _URC_NORMAL_STOP = 4 , <nl> - _URC_END_OF_STACK = 5 , <nl> - _URC_HANDLER_FOUND = 6 , <nl> - _URC_INSTALL_CONTEXT = 7 , <nl> - _URC_CONTINUE_UNWIND = 8 <nl> - } <nl> - _Unwind_Reason_Code ; <nl> - <nl> - typedef int _Unwind_Action ; <nl> - <nl> - # define _UA_SEARCH_PHASE 1 <nl> - # define _UA_CLEANUP_PHASE 2 <nl> - # define _UA_HANDLER_FRAME 4 <nl> - # define _UA_FORCE_UNWIND 8 <nl> - <nl> - struct _Unwind_Context ; / * opaque data - structure * / <nl> - struct _Unwind_Exception ; / * forward - declaration * / <nl> - <nl> - typedef void ( * _Unwind_Exception_Cleanup_Fn ) ( _Unwind_Reason_Code , <nl> - struct _Unwind_Exception * ) ; <nl> - <nl> - typedef _Unwind_Reason_Code ( * _Unwind_Stop_Fn ) ( int , _Unwind_Action , <nl> - uint64_t , <nl> - struct _Unwind_Exception * , <nl> - struct _Unwind_Context * , <nl> - void * ) ; <nl> - <nl> - / * The C + + ABI requires exception_class , private_1 , and private_2 to <nl> - be of type uint64 and the entire structure to be <nl> - double - word - aligned . Please note that exception_class stays 64 - bit <nl> - even on 32 - bit machines for gcc compatibility . * / <nl> - struct _Unwind_Exception <nl> - { <nl> - uint64_t exception_class ; <nl> - _Unwind_Exception_Cleanup_Fn exception_cleanup ; <nl> - unsigned long private_1 ; <nl> - unsigned long private_2 ; <nl> - } __attribute__ ( ( __aligned__ ) ) ; <nl> - <nl> - extern _Unwind_Reason_Code _Unwind_RaiseException ( struct _Unwind_Exception * ) ; <nl> - extern _Unwind_Reason_Code _Unwind_ForcedUnwind ( struct _Unwind_Exception * , <nl> - _Unwind_Stop_Fn , void * ) ; <nl> - extern void _Unwind_Resume ( struct _Unwind_Exception * ) ; <nl> - extern void _Unwind_DeleteException ( struct _Unwind_Exception * ) ; <nl> - extern unsigned long _Unwind_GetGR ( struct _Unwind_Context * , int ) ; <nl> - extern void _Unwind_SetGR ( struct _Unwind_Context * , int , unsigned long ) ; <nl> - extern unsigned long _Unwind_GetIP ( struct _Unwind_Context * ) ; <nl> - extern unsigned long _Unwind_GetIPInfo ( struct _Unwind_Context * , int * ) ; <nl> - extern void _Unwind_SetIP ( struct _Unwind_Context * , unsigned long ) ; <nl> - extern unsigned long _Unwind_GetLanguageSpecificData ( struct _Unwind_Context * ) ; <nl> - extern unsigned long _Unwind_GetRegionStart ( struct _Unwind_Context * ) ; <nl> - <nl> - # ifdef _GNU_SOURCE <nl> - <nl> - / * Callback for _Unwind_Backtrace ( ) . The backtrace stops immediately <nl> - if the callback returns any value other than _URC_NO_REASON . * / <nl> - typedef _Unwind_Reason_Code ( * _Unwind_Trace_Fn ) ( struct _Unwind_Context * , <nl> - void * ) ; <nl> - <nl> - / * See http : / / gcc . gnu . org / ml / gcc - patches / 2001 - 09 / msg00082 . html for why <nl> - _UA_END_OF_STACK exists . * / <nl> - # define _UA_END_OF_STACK 16 <nl> - <nl> - / * If the unwind was initiated due to a forced unwind , resume that <nl> - operation , else re - raise the exception . This is used by <nl> - __cxa_rethrow ( ) . * / <nl> - extern _Unwind_Reason_Code <nl> - _Unwind_Resume_or_Rethrow ( struct _Unwind_Exception * ) ; <nl> - <nl> - / * See http : / / gcc . gnu . org / ml / gcc - patches / 2003 - 09 / msg00154 . html for why <nl> - _Unwind_GetBSP ( ) exists . * / <nl> - extern unsigned long _Unwind_GetBSP ( struct _Unwind_Context * ) ; <nl> - <nl> - / * Return the " canonical frame address " for the given context . <nl> - This is used by NPTL . . . * / <nl> - extern unsigned long _Unwind_GetCFA ( struct _Unwind_Context * ) ; <nl> - <nl> - / * Return the base - address for data references . * / <nl> - extern unsigned long _Unwind_GetDataRelBase ( struct _Unwind_Context * ) ; <nl> - <nl> - / * Return the base - address for text references . * / <nl> - extern unsigned long _Unwind_GetTextRelBase ( struct _Unwind_Context * ) ; <nl> - <nl> - / * Call _Unwind_Trace_Fn once for each stack - frame , without doing any <nl> - cleanup . The first frame for which the callback is invoked is the <nl> - one for the caller of _Unwind_Backtrace ( ) . _Unwind_Backtrace ( ) <nl> - returns _URC_END_OF_STACK when the backtrace stopped due to <nl> - reaching the end of the call - chain or _URC_FATAL_PHASE1_ERROR if it <nl> - stops for any other reason . * / <nl> - extern _Unwind_Reason_Code _Unwind_Backtrace ( _Unwind_Trace_Fn , void * ) ; <nl> - <nl> - / * Find the start - address of the procedure containing the specified IP <nl> - or NULL if it cannot be found ( e . g . , because the function has no <nl> - unwind info ) . Note : there is not necessarily a one - to - one <nl> - correspondence between source - level functions and procedures : some <nl> - functions don ' t have unwind - info and others are split into multiple <nl> - procedures . * / <nl> - extern void * _Unwind_FindEnclosingFunction ( void * ) ; <nl> - <nl> - / * See also Linux Standard Base Spec : <nl> - http : / / www . linuxbase . org / spec / refspecs / LSB_1 . 3 . 0 / gLSB / gLSB / libgcc - s . html * / <nl> - <nl> - # endif / * _GNU_SOURCE * / <nl> - <nl> - # ifdef __cplusplus <nl> - } ; <nl> - # endif <nl> - <nl> - # endif / * _UNWIND_H * / <nl> | Merge pull request from waywardmonkeys / remove - unused - headers | emscripten-core/emscripten | 5840e88177f1480feb215b606704d0a502bb841b | 2014-02-22T01:24:59Z |
mmm a / caffe2 / utils / threadpool / WorkersPool . h <nl> ppp b / caffe2 / utils / threadpool / WorkersPool . h <nl> class WorkersPool { <nl> CreateWorkers ( workers_count ) ; <nl> assert ( workers_count < = workers_ . size ( ) ) ; <nl> counter_to_decrement_when_ready_ . Reset ( workers_count ) ; <nl> - int n = 0 ; <nl> - std : : for_each ( + + tasks . begin ( ) , tasks . end ( ) , [ this , & n ] ( auto & task ) { <nl> - workers_ [ n + + ] - > StartWork ( task . get ( ) ) ; <nl> - } ) ; <nl> + for ( auto task = 1 ; task < tasks . size ( ) ; + + task ) { <nl> + workers_ [ task - 1 ] - > StartWork ( tasks [ task ] . get ( ) ) ; <nl> + } <nl> / / Execute the remaining workload immediately on the current thread . <nl> auto & task = tasks . front ( ) ; <nl> task - > Run ( ) ; <nl> | Hotfix the OSS build error | pytorch/pytorch | bdeafe49ac8c713b7aa6365e0feccba2170d571b | 2017-08-29T06:53:18Z |
mmm a / src / ast / ast . h <nl> ppp b / src / ast / ast . h <nl> class AstNode : public ZoneObject { <nl> void * operator new ( size_t size ) ; <nl> <nl> int position_ ; <nl> - class NodeTypeField : public BitField < NodeType , 0 , 6 > { } ; <nl> + using NodeTypeField = BitField < NodeType , 0 , 6 > ; <nl> <nl> protected : <nl> uint32_t bit_field_ ; <nl> class Expression : public AstNode { <nl> } <nl> <nl> private : <nl> - class IsParenthesizedField <nl> - : public BitField < bool , AstNode : : kNextBitFieldIndex , 1 > { } ; <nl> + using IsParenthesizedField = BitField < bool , AstNode : : kNextBitFieldIndex , 1 > ; <nl> <nl> protected : <nl> Expression ( int pos , NodeType type ) : AstNode ( pos , type ) { <nl> class BreakableStatement : public Statement { <nl> } <nl> <nl> private : <nl> - class BreakableTypeField <nl> - : public BitField < BreakableType , Statement : : kNextBitFieldIndex , 1 > { } ; <nl> + using BreakableTypeField = <nl> + BitField < BreakableType , Statement : : kNextBitFieldIndex , 1 > ; <nl> <nl> protected : <nl> BreakableStatement ( BreakableType breakable_type , int position , NodeType type ) <nl> class Block : public BreakableStatement { <nl> ZonePtrList < Statement > statements_ ; <nl> Scope * scope_ ; <nl> <nl> - class IgnoreCompletionField <nl> - : public BitField < bool , BreakableStatement : : kNextBitFieldIndex , 1 > { } ; <nl> - class IsLabeledField <nl> - : public BitField < bool , IgnoreCompletionField : : kNext , 1 > { } ; <nl> + using IgnoreCompletionField = <nl> + BitField < bool , BreakableStatement : : kNextBitFieldIndex , 1 > ; <nl> + using IsLabeledField = BitField < bool , IgnoreCompletionField : : kNext , 1 > ; <nl> <nl> protected : <nl> Block ( Zone * zone , ZonePtrList < const AstRawString > * labels , int capacity , <nl> class VariableDeclaration : public Declaration { <nl> private : <nl> friend class AstNodeFactory ; <nl> <nl> - class IsNestedField <nl> - : public BitField < bool , Declaration : : kNextBitFieldIndex , 1 > { } ; <nl> + using IsNestedField = BitField < bool , Declaration : : kNextBitFieldIndex , 1 > ; <nl> <nl> protected : <nl> explicit VariableDeclaration ( int pos , bool is_nested = false ) <nl> class ReturnStatement final : public JumpStatement { <nl> Expression * expression_ ; <nl> int end_position_ ; <nl> <nl> - class TypeField <nl> - : public BitField < Type , JumpStatement : : kNextBitFieldIndex , 1 > { } ; <nl> + using TypeField = BitField < Type , JumpStatement : : kNextBitFieldIndex , 1 > ; <nl> } ; <nl> <nl> <nl> class SloppyBlockFunctionStatement final : public Statement { <nl> private : <nl> friend class AstNodeFactory ; <nl> <nl> - class TokenField <nl> - : public BitField < Token : : Value , Statement : : kNextBitFieldIndex , 8 > { } ; <nl> + using TokenField = BitField < Token : : Value , Statement : : kNextBitFieldIndex , 8 > ; <nl> <nl> SloppyBlockFunctionStatement ( int pos , Variable * var , Token : : Value init , <nl> Statement * statement ) <nl> class Literal final : public Expression { <nl> private : <nl> friend class AstNodeFactory ; <nl> <nl> - class TypeField : public BitField < Type , Expression : : kNextBitFieldIndex , 4 > { } ; <nl> + using TypeField = BitField < Type , Expression : : kNextBitFieldIndex , 4 > ; <nl> <nl> Literal ( int smi , int position ) : Expression ( position , kLiteral ) , smi_ ( smi ) { <nl> bit_field_ = TypeField : : update ( bit_field_ , kSmi ) ; <nl> class AggregateLiteral : public MaterializedLiteral { <nl> <nl> private : <nl> int depth_ : 31 ; <nl> - class NeedsInitialAllocationSiteField <nl> - : public BitField < bool , MaterializedLiteral : : kNextBitFieldIndex , 1 > { } ; <nl> - class IsSimpleField <nl> - : public BitField < bool , NeedsInitialAllocationSiteField : : kNext , 1 > { } ; <nl> + using NeedsInitialAllocationSiteField = <nl> + BitField < bool , MaterializedLiteral : : kNextBitFieldIndex , 1 > ; <nl> + using IsSimpleField = <nl> + BitField < bool , NeedsInitialAllocationSiteField : : kNext , 1 > ; <nl> <nl> protected : <nl> friend class AstNodeFactory ; <nl> class ObjectLiteral final : public AggregateLiteral { <nl> Handle < ObjectBoilerplateDescription > boilerplate_description_ ; <nl> ZoneList < Property * > properties_ ; <nl> <nl> - class HasElementsField <nl> - : public BitField < bool , AggregateLiteral : : kNextBitFieldIndex , 1 > { } ; <nl> - class HasRestPropertyField <nl> - : public BitField < bool , HasElementsField : : kNext , 1 > { } ; <nl> - class FastElementsField <nl> - : public BitField < bool , HasRestPropertyField : : kNext , 1 > { } ; <nl> - class HasNullPrototypeField <nl> - : public BitField < bool , FastElementsField : : kNext , 1 > { } ; <nl> + using HasElementsField = <nl> + BitField < bool , AggregateLiteral : : kNextBitFieldIndex , 1 > ; <nl> + using HasRestPropertyField = BitField < bool , HasElementsField : : kNext , 1 > ; <nl> + using FastElementsField = BitField < bool , HasRestPropertyField : : kNext , 1 > ; <nl> + using HasNullPrototypeField = BitField < bool , FastElementsField : : kNext , 1 > ; <nl> } ; <nl> <nl> / / An array literal has a literals object that is used <nl> class VariableProxy final : public Expression { <nl> <nl> explicit VariableProxy ( const VariableProxy * copy_from ) ; <nl> <nl> - class IsAssignedField <nl> - : public BitField < bool , Expression : : kNextBitFieldIndex , 1 > { } ; <nl> - class IsResolvedField : public BitField < bool , IsAssignedField : : kNext , 1 > { } ; <nl> - class IsRemovedFromUnresolvedField <nl> - : public BitField < bool , IsResolvedField : : kNext , 1 > { } ; <nl> - class IsNewTargetField <nl> - : public BitField < bool , IsRemovedFromUnresolvedField : : kNext , 1 > { } ; <nl> - class HoleCheckModeField <nl> - : public BitField < HoleCheckMode , IsNewTargetField : : kNext , 1 > { } ; <nl> + using IsAssignedField = BitField < bool , Expression : : kNextBitFieldIndex , 1 > ; <nl> + using IsResolvedField = BitField < bool , IsAssignedField : : kNext , 1 > ; <nl> + using IsRemovedFromUnresolvedField = <nl> + BitField < bool , IsResolvedField : : kNext , 1 > ; <nl> + using IsNewTargetField = <nl> + BitField < bool , IsRemovedFromUnresolvedField : : kNext , 1 > ; <nl> + using HoleCheckModeField = <nl> + BitField < HoleCheckMode , IsNewTargetField : : kNext , 1 > ; <nl> <nl> union { <nl> const AstRawString * raw_name_ ; / / if ! is_resolved_ <nl> class Call final : public Expression { <nl> arguments . CopyTo ( & arguments_ , zone ) ; <nl> } <nl> <nl> - class IsPossiblyEvalField <nl> - : public BitField < bool , Expression : : kNextBitFieldIndex , 1 > { } ; <nl> - class IsTaggedTemplateField <nl> - : public BitField < bool , IsPossiblyEvalField : : kNext , 1 > { } ; <nl> + using IsPossiblyEvalField = BitField < bool , Expression : : kNextBitFieldIndex , 1 > ; <nl> + using IsTaggedTemplateField = BitField < bool , IsPossiblyEvalField : : kNext , 1 > ; <nl> <nl> Expression * expression_ ; <nl> ZonePtrList < Expression > arguments_ ; <nl> class UnaryOperation final : public Expression { <nl> <nl> Expression * expression_ ; <nl> <nl> - class OperatorField <nl> - : public BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > { } ; <nl> + using OperatorField = <nl> + BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > ; <nl> } ; <nl> <nl> <nl> class BinaryOperation final : public Expression { <nl> Expression * left_ ; <nl> Expression * right_ ; <nl> <nl> - class OperatorField <nl> - : public BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > { } ; <nl> + using OperatorField = <nl> + BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > ; <nl> } ; <nl> <nl> class NaryOperation final : public Expression { <nl> class NaryOperation final : public Expression { <nl> } ; <nl> ZoneVector < NaryOperationEntry > subsequent_ ; <nl> <nl> - class OperatorField <nl> - : public BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > { } ; <nl> + using OperatorField = <nl> + BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > ; <nl> } ; <nl> <nl> class CountOperation final : public Expression { <nl> class CountOperation final : public Expression { <nl> bit_field_ | = IsPrefixField : : encode ( is_prefix ) | TokenField : : encode ( op ) ; <nl> } <nl> <nl> - class IsPrefixField <nl> - : public BitField < bool , Expression : : kNextBitFieldIndex , 1 > { } ; <nl> - class TokenField : public BitField < Token : : Value , IsPrefixField : : kNext , 7 > { } ; <nl> + using IsPrefixField = BitField < bool , Expression : : kNextBitFieldIndex , 1 > ; <nl> + using TokenField = BitField < Token : : Value , IsPrefixField : : kNext , 7 > ; <nl> <nl> Expression * expression_ ; <nl> } ; <nl> class CompareOperation final : public Expression { <nl> Expression * left_ ; <nl> Expression * right_ ; <nl> <nl> - class OperatorField <nl> - : public BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > { } ; <nl> + using OperatorField = <nl> + BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > ; <nl> } ; <nl> <nl> <nl> class Assignment : public Expression { <nl> private : <nl> friend class AstNodeFactory ; <nl> <nl> - class TokenField <nl> - : public BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > { } ; <nl> - class LookupHoistingModeField : public BitField < bool , TokenField : : kNext , 1 > { <nl> - } ; <nl> + using TokenField = BitField < Token : : Value , Expression : : kNextBitFieldIndex , 7 > ; <nl> + using LookupHoistingModeField = BitField < bool , TokenField : : kNext , 1 > ; <nl> <nl> Expression * target_ ; <nl> Expression * value_ ; <nl> class Suspend : public Expression { <nl> <nl> Expression * expression_ ; <nl> <nl> - class OnAbruptResumeField <nl> - : public BitField < OnAbruptResume , Expression : : kNextBitFieldIndex , 1 > { } ; <nl> + using OnAbruptResumeField = <nl> + BitField < OnAbruptResume , Expression : : kNextBitFieldIndex , 1 > ; <nl> } ; <nl> <nl> class Yield final : public Suspend { <nl> class FunctionLiteral final : public Expression { <nl> body . CopyTo ( & body_ , zone ) ; <nl> } <nl> <nl> - class FunctionTypeBits <nl> - : public BitField < FunctionType , Expression : : kNextBitFieldIndex , 3 > { } ; <nl> - class Pretenure : public BitField < bool , FunctionTypeBits : : kNext , 1 > { } ; <nl> - class HasDuplicateParameters : public BitField < bool , Pretenure : : kNext , 1 > { } ; <nl> - class DontOptimizeReasonField <nl> - : public BitField < BailoutReason , HasDuplicateParameters : : kNext , 8 > { } ; <nl> - class RequiresInstanceMembersInitializer <nl> - : public BitField < bool , DontOptimizeReasonField : : kNext , 1 > { } ; <nl> - class HasBracesField <nl> - : public BitField < bool , RequiresInstanceMembersInitializer : : kNext , 1 > { } ; <nl> - class OneshotIIFEBit : public BitField < bool , HasBracesField : : kNext , 1 > { } ; <nl> + using FunctionTypeBits = <nl> + BitField < FunctionType , Expression : : kNextBitFieldIndex , 3 > ; <nl> + using Pretenure = BitField < bool , FunctionTypeBits : : kNext , 1 > ; <nl> + using HasDuplicateParameters = BitField < bool , Pretenure : : kNext , 1 > ; <nl> + using DontOptimizeReasonField = <nl> + BitField < BailoutReason , HasDuplicateParameters : : kNext , 8 > ; <nl> + using RequiresInstanceMembersInitializer = <nl> + BitField < bool , DontOptimizeReasonField : : kNext , 1 > ; <nl> + using HasBracesField = <nl> + BitField < bool , RequiresInstanceMembersInitializer : : kNext , 1 > ; <nl> + using OneshotIIFEBit = BitField < bool , HasBracesField : : kNext , 1 > ; <nl> <nl> / / expected_property_count_ is the sum of instance fields and properties . <nl> / / It can vary depending on whether a function is lazily or eagerly parsed . <nl> class ClassLiteral final : public Expression { <nl> ZonePtrList < Property > * properties_ ; <nl> FunctionLiteral * static_fields_initializer_ ; <nl> FunctionLiteral * instance_members_initializer_function_ ; <nl> - class HasNameStaticProperty <nl> - : public BitField < bool , Expression : : kNextBitFieldIndex , 1 > { } ; <nl> - class HasStaticComputedNames <nl> - : public BitField < bool , HasNameStaticProperty : : kNext , 1 > { } ; <nl> - class IsAnonymousExpression <nl> - : public BitField < bool , HasStaticComputedNames : : kNext , 1 > { } ; <nl> + using HasNameStaticProperty = <nl> + BitField < bool , Expression : : kNextBitFieldIndex , 1 > ; <nl> + using HasStaticComputedNames = <nl> + BitField < bool , HasNameStaticProperty : : kNext , 1 > ; <nl> + using IsAnonymousExpression = <nl> + BitField < bool , HasStaticComputedNames : : kNext , 1 > ; <nl> } ; <nl> <nl> <nl> mmm a / src / ast / variables . h <nl> ppp b / src / ast / variables . h <nl> class Variable final : public ZoneObject { <nl> bit_field_ = MaybeAssignedFlagField : : update ( bit_field_ , kMaybeAssigned ) ; <nl> } <nl> <nl> - class VariableModeField : public BitField16 < VariableMode , 0 , 3 > { } ; <nl> - class VariableKindField <nl> - : public BitField16 < VariableKind , VariableModeField : : kNext , 3 > { } ; <nl> - class LocationField <nl> - : public BitField16 < VariableLocation , VariableKindField : : kNext , 3 > { } ; <nl> - class ForceContextAllocationField <nl> - : public BitField16 < bool , LocationField : : kNext , 1 > { } ; <nl> - class IsUsedField <nl> - : public BitField16 < bool , ForceContextAllocationField : : kNext , 1 > { } ; <nl> - class InitializationFlagField <nl> - : public BitField16 < InitializationFlag , IsUsedField : : kNext , 1 > { } ; <nl> - class ForceHoleInitializationField <nl> - : public BitField16 < bool , InitializationFlagField : : kNext , 1 > { } ; <nl> - class MaybeAssignedFlagField <nl> - : public BitField16 < MaybeAssignedFlag , <nl> - ForceHoleInitializationField : : kNext , 1 > { } ; <nl> - class RequiresBrandCheckField <nl> - : public BitField16 < RequiresBrandCheckFlag , MaybeAssignedFlagField : : kNext , <nl> - 1 > { } ; <nl> + using VariableModeField = BitField16 < VariableMode , 0 , 3 > ; <nl> + using VariableKindField = <nl> + BitField16 < VariableKind , VariableModeField : : kNext , 3 > ; <nl> + using LocationField = <nl> + BitField16 < VariableLocation , VariableKindField : : kNext , 3 > ; <nl> + using ForceContextAllocationField = BitField16 < bool , LocationField : : kNext , 1 > ; <nl> + using IsUsedField = BitField16 < bool , ForceContextAllocationField : : kNext , 1 > ; <nl> + using InitializationFlagField = <nl> + BitField16 < InitializationFlag , IsUsedField : : kNext , 1 > ; <nl> + using ForceHoleInitializationField = <nl> + BitField16 < bool , InitializationFlagField : : kNext , 1 > ; <nl> + using MaybeAssignedFlagField = <nl> + BitField16 < MaybeAssignedFlag , ForceHoleInitializationField : : kNext , 1 > ; <nl> + using RequiresBrandCheckField = <nl> + BitField16 < RequiresBrandCheckFlag , MaybeAssignedFlagField : : kNext , 1 > ; <nl> Variable * * next ( ) { return & next_ ; } <nl> friend List ; <nl> friend base : : ThreadedListTraits < Variable > ; <nl> mmm a / src / builtins / builtins - array . cc <nl> ppp b / src / builtins / builtins - array . cc <nl> class ArrayConcatVisitor { <nl> storage_ = isolate_ - > global_handles ( ) - > Create ( storage ) ; <nl> } <nl> <nl> - class FastElementsField : public BitField < bool , 0 , 1 > { } ; <nl> - class ExceedsLimitField : public BitField < bool , 1 , 1 > { } ; <nl> - class IsFixedArrayField : public BitField < bool , 2 , 1 > { } ; <nl> - class HasSimpleElementsField : public BitField < bool , 3 , 1 > { } ; <nl> + using FastElementsField = BitField < bool , 0 , 1 > ; <nl> + using ExceedsLimitField = BitField < bool , 1 , 1 > ; <nl> + using IsFixedArrayField = BitField < bool , 2 , 1 > ; <nl> + using HasSimpleElementsField = BitField < bool , 3 , 1 > ; <nl> <nl> bool fast_elements ( ) const { return FastElementsField : : decode ( bit_field_ ) ; } <nl> void set_fast_elements ( bool fast ) { <nl> mmm a / src / codegen / handler - table . h <nl> ppp b / src / codegen / handler - table . h <nl> class V8_EXPORT_PRIVATE HandlerTable { <nl> static const int kReturnEntrySize = 2 ; <nl> <nl> / / Encoding of the { handler } field . <nl> - class HandlerPredictionField : public BitField < CatchPrediction , 0 , 3 > { } ; <nl> - class HandlerOffsetField : public BitField < int , 3 , 29 > { } ; <nl> + using HandlerPredictionField = BitField < CatchPrediction , 0 , 3 > ; <nl> + using HandlerOffsetField = BitField < int , 3 , 29 > ; <nl> } ; <nl> <nl> } / / namespace internal <nl> mmm a / src / codegen / ia32 / assembler - ia32 . h <nl> ppp b / src / codegen / ia32 / assembler - ia32 . h <nl> class Displacement { <nl> private : <nl> int data_ ; <nl> <nl> - class TypeField : public BitField < Type , 0 , 2 > { } ; <nl> - class NextField : public BitField < int , 2 , 32 - 2 > { } ; <nl> + using TypeField = BitField < Type , 0 , 2 > ; <nl> + using NextField = BitField < int , 2 , 32 - 2 > ; <nl> <nl> void init ( Label * L , Type type ) ; <nl> } ; <nl> mmm a / src / codegen / source - position - table . cc <nl> ppp b / src / codegen / source - position - table . cc <nl> namespace internal { <nl> namespace { <nl> <nl> / / Each byte is encoded as MoreBit | ValueBits . <nl> - class MoreBit : public BitField8 < bool , 7 , 1 > { } ; <nl> - class ValueBits : public BitField8 < unsigned , 0 , 7 > { } ; <nl> + using MoreBit = BitField8 < bool , 7 , 1 > ; <nl> + using ValueBits = BitField8 < unsigned , 0 , 7 > ; <nl> <nl> / / Helper : Add the offsets from ' other ' to ' value ' . Also set is_statement . <nl> void AddAndSetEntry ( PositionTableEntry & value , / / NOLINT ( runtime / references ) <nl> mmm a / src / common / assert - scope . cc <nl> ppp b / src / common / assert - scope . cc <nl> bool PerThreadAssertScope < kType , kAllow > : : IsAllowed ( ) { <nl> return current_data = = nullptr | | current_data - > Get ( kType ) ; <nl> } <nl> <nl> - template < PerIsolateAssertType kType , bool kAllow > <nl> - class PerIsolateAssertScope < kType , kAllow > : : DataBit <nl> - : public BitField < bool , kType , 1 > { } ; <nl> + namespace { <nl> + template < PerIsolateAssertType kType > <nl> + using DataBit = BitField < bool , kType , 1 > ; <nl> + } <nl> <nl> template < PerIsolateAssertType kType , bool kAllow > <nl> PerIsolateAssertScope < kType , kAllow > : : PerIsolateAssertScope ( Isolate * isolate ) <nl> : isolate_ ( isolate ) , old_data_ ( isolate - > per_isolate_assert_data ( ) ) { <nl> DCHECK_NOT_NULL ( isolate ) ; <nl> STATIC_ASSERT ( kType < 32 ) ; <nl> - isolate_ - > set_per_isolate_assert_data ( DataBit : : update ( old_data_ , kAllow ) ) ; <nl> + isolate_ - > set_per_isolate_assert_data ( <nl> + DataBit < kType > : : update ( old_data_ , kAllow ) ) ; <nl> } <nl> <nl> template < PerIsolateAssertType kType , bool kAllow > <nl> PerIsolateAssertScope < kType , kAllow > : : ~ PerIsolateAssertScope ( ) { <nl> / / static <nl> template < PerIsolateAssertType kType , bool kAllow > <nl> bool PerIsolateAssertScope < kType , kAllow > : : IsAllowed ( Isolate * isolate ) { <nl> - return DataBit : : decode ( isolate - > per_isolate_assert_data ( ) ) ; <nl> + return DataBit < kType > : : decode ( isolate - > per_isolate_assert_data ( ) ) ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm a / src / common / assert - scope . h <nl> ppp b / src / common / assert - scope . h <nl> class PerIsolateAssertScope { <nl> static bool IsAllowed ( Isolate * isolate ) ; <nl> <nl> private : <nl> - class DataBit ; <nl> - <nl> Isolate * isolate_ ; <nl> uint32_t old_data_ ; <nl> <nl> mmm a / src / compiler / backend / instruction . h <nl> ppp b / src / compiler / backend / instruction . h <nl> class V8_EXPORT_PRIVATE InstructionOperand { <nl> <nl> inline uint64_t GetCanonicalizedValue ( ) const ; <nl> <nl> - class KindField : public BitField64 < Kind , 0 , 3 > { } ; <nl> + using KindField = BitField64 < Kind , 0 , 3 > ; <nl> <nl> uint64_t value_ ; <nl> } ; <nl> class UnallocatedOperand final : public InstructionOperand { <nl> <nl> STATIC_ASSERT ( KindField : : kSize = = 3 ) ; <nl> <nl> - class VirtualRegisterField : public BitField64 < uint32_t , 3 , 32 > { } ; <nl> + using VirtualRegisterField = BitField64 < uint32_t , 3 , 32 > ; <nl> <nl> / / BitFields for all unallocated operands . <nl> - class BasicPolicyField : public BitField64 < BasicPolicy , 35 , 1 > { } ; <nl> + using BasicPolicyField = BitField64 < BasicPolicy , 35 , 1 > ; <nl> <nl> / / BitFields specific to BasicPolicy : : FIXED_SLOT . <nl> - class FixedSlotIndexField : public BitField64 < int , 36 , 28 > { } ; <nl> + using FixedSlotIndexField = BitField64 < int , 36 , 28 > ; <nl> <nl> / / BitFields specific to BasicPolicy : : EXTENDED_POLICY . <nl> - class ExtendedPolicyField : public BitField64 < ExtendedPolicy , 36 , 3 > { } ; <nl> - class LifetimeField : public BitField64 < Lifetime , 39 , 1 > { } ; <nl> - class HasSecondaryStorageField : public BitField64 < bool , 40 , 1 > { } ; <nl> - class FixedRegisterField : public BitField64 < int , 41 , 6 > { } ; <nl> - class SecondaryStorageField : public BitField64 < int , 47 , 3 > { } ; <nl> + using ExtendedPolicyField = BitField64 < ExtendedPolicy , 36 , 3 > ; <nl> + using LifetimeField = BitField64 < Lifetime , 39 , 1 > ; <nl> + using HasSecondaryStorageField = BitField64 < bool , 40 , 1 > ; <nl> + using FixedRegisterField = BitField64 < int , 41 , 6 > ; <nl> + using SecondaryStorageField = BitField64 < int , 47 , 3 > ; <nl> <nl> private : <nl> explicit UnallocatedOperand ( int virtual_register ) <nl> class ConstantOperand : public InstructionOperand { <nl> INSTRUCTION_OPERAND_CASTS ( ConstantOperand , CONSTANT ) <nl> <nl> STATIC_ASSERT ( KindField : : kSize = = 3 ) ; <nl> - class VirtualRegisterField : public BitField64 < uint32_t , 3 , 32 > { } ; <nl> + using VirtualRegisterField = BitField64 < uint32_t , 3 , 32 > ; <nl> } ; <nl> <nl> class ImmediateOperand : public InstructionOperand { <nl> class ImmediateOperand : public InstructionOperand { <nl> INSTRUCTION_OPERAND_CASTS ( ImmediateOperand , IMMEDIATE ) <nl> <nl> STATIC_ASSERT ( KindField : : kSize = = 3 ) ; <nl> - class TypeField : public BitField64 < ImmediateType , 3 , 1 > { } ; <nl> - class ValueField : public BitField64 < int32_t , 32 , 32 > { } ; <nl> + using TypeField = BitField64 < ImmediateType , 3 , 1 > ; <nl> + using ValueField = BitField64 < int32_t , 32 , 32 > ; <nl> } ; <nl> <nl> class LocationOperand : public InstructionOperand { <nl> class LocationOperand : public InstructionOperand { <nl> } <nl> <nl> STATIC_ASSERT ( KindField : : kSize = = 3 ) ; <nl> - class LocationKindField : public BitField64 < LocationKind , 3 , 2 > { } ; <nl> - class RepresentationField : public BitField64 < MachineRepresentation , 5 , 8 > { } ; <nl> - class IndexField : public BitField64 < int32_t , 35 , 29 > { } ; <nl> + using LocationKindField = BitField64 < LocationKind , 3 , 2 > ; <nl> + using RepresentationField = BitField64 < MachineRepresentation , 5 , 8 > ; <nl> + using IndexField = BitField64 < int32_t , 35 , 29 > ; <nl> } ; <nl> <nl> class V8_EXPORT_PRIVATE ExplicitOperand <nl> mmm a / src / compiler / linkage . h <nl> ppp b / src / compiler / linkage . h <nl> class LinkageLocation { <nl> private : <nl> enum LocationType { REGISTER , STACK_SLOT } ; <nl> <nl> - class TypeField : public BitField < LocationType , 0 , 1 > { } ; <nl> - class LocationField : public BitField < int32_t , TypeField : : kNext , 31 > { } ; <nl> + using TypeField = BitField < LocationType , 0 , 1 > ; <nl> + using LocationField = BitField < int32_t , TypeField : : kNext , 31 > ; <nl> <nl> static constexpr int32_t ANY_REGISTER = - 1 ; <nl> static constexpr int32_t MAX_STACK_SLOT = 32767 ; <nl> mmm a / src / handles / global - handles . cc <nl> ppp b / src / handles / global - handles . cc <nl> class GlobalHandles : : Node final : public NodeBase < GlobalHandles : : Node > { <nl> <nl> / / This stores three flags ( independent , partially_dependent and <nl> / / in_young_list ) and a State . <nl> - class NodeState : public BitField8 < State , 0 , 3 > { } ; <nl> - class IsInYoungList : public BitField8 < bool , NodeState : : kNext , 1 > { } ; <nl> - class NodeWeaknessType <nl> - : public BitField8 < WeaknessType , IsInYoungList : : kNext , 2 > { } ; <nl> + using NodeState = BitField8 < State , 0 , 3 > ; <nl> + using IsInYoungList = BitField8 < bool , NodeState : : kNext , 1 > ; <nl> + using NodeWeaknessType = BitField8 < WeaknessType , IsInYoungList : : kNext , 2 > ; <nl> <nl> / / Handle specific callback - might be a weak reference in disguise . <nl> WeakCallbackInfo < void > : : Callback weak_callback_ ; <nl> class GlobalHandles : : TracedNode final <nl> } <nl> <nl> protected : <nl> - class NodeState : public BitField8 < State , 0 , 2 > { } ; <nl> - class IsInYoungList : public BitField8 < bool , NodeState : : kNext , 1 > { } ; <nl> - class IsRoot : public BitField8 < bool , IsInYoungList : : kNext , 1 > { } ; <nl> + using NodeState = BitField8 < State , 0 , 2 > ; <nl> + using IsInYoungList = BitField8 < bool , NodeState : : kNext , 1 > ; <nl> + using IsRoot = BitField8 < bool , IsInYoungList : : kNext , 1 > ; <nl> <nl> void ClearImplFields ( ) { <nl> set_root ( true ) ; <nl> mmm a / src / heap / slot - set . h <nl> ppp b / src / heap / slot - set . h <nl> class V8_EXPORT_PRIVATE TypedSlots { <nl> void Merge ( TypedSlots * other ) ; <nl> <nl> protected : <nl> - class OffsetField : public BitField < int , 0 , 29 > { } ; <nl> - class TypeField : public BitField < SlotType , 29 , 3 > { } ; <nl> + using OffsetField = BitField < int , 0 , 29 > ; <nl> + using TypeField = BitField < SlotType , 29 , 3 > ; <nl> struct TypedSlot { <nl> uint32_t type_and_offset ; <nl> } ; <nl> mmm a / src / ic / handler - configuration . h <nl> ppp b / src / ic / handler - configuration . h <nl> class LoadHandler final : public DataHandler { <nl> kNonExistent , <nl> kModuleExport <nl> } ; <nl> - class KindBits : public BitField < Kind , 0 , 4 > { } ; <nl> + using KindBits = BitField < Kind , 0 , 4 > ; <nl> <nl> / / Defines whether access rights check should be done on receiver object . <nl> / / Applicable to named property kinds only when loading value from prototype <nl> / / chain . Ignored when loading from holder . <nl> - class DoAccessCheckOnReceiverBits <nl> - : public BitField < bool , KindBits : : kNext , 1 > { } ; <nl> + using DoAccessCheckOnReceiverBits = BitField < bool , KindBits : : kNext , 1 > ; <nl> <nl> / / Defines whether a lookup should be done on receiver object before <nl> / / proceeding to the prototype chain . Applicable to named property kinds only <nl> / / when loading value from prototype chain . Ignored when loading from holder . <nl> - class LookupOnReceiverBits <nl> - : public BitField < bool , DoAccessCheckOnReceiverBits : : kNext , 1 > { } ; <nl> + using LookupOnReceiverBits = <nl> + BitField < bool , DoAccessCheckOnReceiverBits : : kNext , 1 > ; <nl> <nl> / / <nl> / / Encoding when KindBits contains kForConstants . <nl> / / <nl> <nl> / / Index of a value entry in the descriptor array . <nl> - class DescriptorBits : public BitField < unsigned , LookupOnReceiverBits : : kNext , <nl> - kDescriptorIndexBitCount > { } ; <nl> + using DescriptorBits = <nl> + BitField < unsigned , LookupOnReceiverBits : : kNext , kDescriptorIndexBitCount > ; <nl> / / Make sure we don ' t overflow the smi . <nl> STATIC_ASSERT ( DescriptorBits : : kNext < = kSmiValueSize ) ; <nl> <nl> / / <nl> / / Encoding when KindBits contains kField . <nl> / / <nl> - class IsInobjectBits : public BitField < bool , LookupOnReceiverBits : : kNext , 1 > { <nl> - } ; <nl> - class IsDoubleBits : public BitField < bool , IsInobjectBits : : kNext , 1 > { } ; <nl> + using IsInobjectBits = BitField < bool , LookupOnReceiverBits : : kNext , 1 > ; <nl> + using IsDoubleBits = BitField < bool , IsInobjectBits : : kNext , 1 > ; <nl> / / + 1 here is to cover all possible JSObject header sizes . <nl> - class FieldIndexBits : public BitField < unsigned , IsDoubleBits : : kNext , <nl> - kDescriptorIndexBitCount + 1 > { } ; <nl> + using FieldIndexBits = <nl> + BitField < unsigned , IsDoubleBits : : kNext , kDescriptorIndexBitCount + 1 > ; <nl> / / Make sure we don ' t overflow the smi . <nl> STATIC_ASSERT ( FieldIndexBits : : kNext < = kSmiValueSize ) ; <nl> <nl> / / <nl> / / Encoding when KindBits contains kElement or kIndexedString . <nl> / / <nl> - class AllowOutOfBoundsBits <nl> - : public BitField < bool , LookupOnReceiverBits : : kNext , 1 > { } ; <nl> + using AllowOutOfBoundsBits = BitField < bool , LookupOnReceiverBits : : kNext , 1 > ; <nl> <nl> / / <nl> / / Encoding when KindBits contains kElement . <nl> / / <nl> - class IsJsArrayBits : public BitField < bool , AllowOutOfBoundsBits : : kNext , 1 > { <nl> - } ; <nl> - class ConvertHoleBits : public BitField < bool , IsJsArrayBits : : kNext , 1 > { } ; <nl> - class ElementsKindBits <nl> - : public BitField < ElementsKind , ConvertHoleBits : : kNext , 8 > { } ; <nl> + using IsJsArrayBits = BitField < bool , AllowOutOfBoundsBits : : kNext , 1 > ; <nl> + using ConvertHoleBits = BitField < bool , IsJsArrayBits : : kNext , 1 > ; <nl> + using ElementsKindBits = BitField < ElementsKind , ConvertHoleBits : : kNext , 8 > ; <nl> / / Make sure we don ' t overflow the smi . <nl> STATIC_ASSERT ( ElementsKindBits : : kNext < = kSmiValueSize ) ; <nl> <nl> / / <nl> / / Encoding when KindBits contains kModuleExport . <nl> / / <nl> - class ExportsIndexBits <nl> - : public BitField < unsigned , LookupOnReceiverBits : : kNext , <nl> - kSmiValueSize - LookupOnReceiverBits : : kNext > { } ; <nl> + using ExportsIndexBits = <nl> + BitField < unsigned , LookupOnReceiverBits : : kNext , <nl> + kSmiValueSize - LookupOnReceiverBits : : kNext > ; <nl> <nl> / / Decodes kind from Smi - handler . <nl> static inline Kind GetHandlerKind ( Smi smi_handler ) ; <nl> class StoreHandler final : public DataHandler { <nl> kProxy , <nl> kKindsNumber / / Keep last <nl> } ; <nl> - class KindBits : public BitField < Kind , 0 , 4 > { } ; <nl> + using KindBits = BitField < Kind , 0 , 4 > ; <nl> <nl> enum FieldRepresentation { kSmi , kDouble , kHeapObject , kTagged } ; <nl> <nl> / / Applicable to kGlobalProxy , kProxy kinds . <nl> <nl> / / Defines whether access rights check should be done on receiver object . <nl> - class DoAccessCheckOnReceiverBits <nl> - : public BitField < bool , KindBits : : kNext , 1 > { } ; <nl> + using DoAccessCheckOnReceiverBits = BitField < bool , KindBits : : kNext , 1 > ; <nl> <nl> / / Defines whether a lookup should be done on receiver object before <nl> / / proceeding to the prototype chain . Applicable to named property kinds only <nl> / / when storing through prototype chain . Ignored when storing to holder . <nl> - class LookupOnReceiverBits <nl> - : public BitField < bool , DoAccessCheckOnReceiverBits : : kNext , 1 > { } ; <nl> + using LookupOnReceiverBits = <nl> + BitField < bool , DoAccessCheckOnReceiverBits : : kNext , 1 > ; <nl> <nl> / / Applicable to kField , kTransitionToField and kTransitionToConstant <nl> / / kinds . <nl> <nl> / / Index of a value entry in the descriptor array . <nl> - class DescriptorBits : public BitField < unsigned , LookupOnReceiverBits : : kNext , <nl> - kDescriptorIndexBitCount > { } ; <nl> + using DescriptorBits = <nl> + BitField < unsigned , LookupOnReceiverBits : : kNext , kDescriptorIndexBitCount > ; <nl> / / <nl> / / Encoding when KindBits contains kTransitionToConstant . <nl> / / <nl> class StoreHandler final : public DataHandler { <nl> / / <nl> / / Encoding when KindBits contains kField or kTransitionToField . <nl> / / <nl> - class IsInobjectBits : public BitField < bool , DescriptorBits : : kNext , 1 > { } ; <nl> - class FieldRepresentationBits <nl> - : public BitField < FieldRepresentation , IsInobjectBits : : kNext , 2 > { } ; <nl> + using IsInobjectBits = BitField < bool , DescriptorBits : : kNext , 1 > ; <nl> + using FieldRepresentationBits = <nl> + BitField < FieldRepresentation , IsInobjectBits : : kNext , 2 > ; <nl> / / + 1 here is to cover all possible JSObject header sizes . <nl> - class FieldIndexBits <nl> - : public BitField < unsigned , FieldRepresentationBits : : kNext , <nl> - kDescriptorIndexBitCount + 1 > { } ; <nl> + using FieldIndexBits = BitField < unsigned , FieldRepresentationBits : : kNext , <nl> + kDescriptorIndexBitCount + 1 > ; <nl> / / Make sure we don ' t overflow the smi . <nl> STATIC_ASSERT ( FieldIndexBits : : kNext < = kSmiValueSize ) ; <nl> <nl> mmm a / src / interpreter / bytecode - flags . h <nl> ppp b / src / interpreter / bytecode - flags . h <nl> namespace interpreter { <nl> <nl> class CreateArrayLiteralFlags { <nl> public : <nl> - class FlagsBits : public BitField8 < int , 0 , 5 > { } ; <nl> - class FastCloneSupportedBit : public BitField8 < bool , FlagsBits : : kNext , 1 > { } ; <nl> + using FlagsBits = BitField8 < int , 0 , 5 > ; <nl> + using FastCloneSupportedBit = BitField8 < bool , FlagsBits : : kNext , 1 > ; <nl> <nl> static uint8_t Encode ( bool use_fast_shallow_clone , int runtime_flags ) ; <nl> <nl> class CreateArrayLiteralFlags { <nl> <nl> class CreateObjectLiteralFlags { <nl> public : <nl> - class FlagsBits : public BitField8 < int , 0 , 5 > { } ; <nl> - class FastCloneSupportedBit : public BitField8 < bool , FlagsBits : : kNext , 1 > { } ; <nl> + using FlagsBits = BitField8 < int , 0 , 5 > ; <nl> + using FastCloneSupportedBit = BitField8 < bool , FlagsBits : : kNext , 1 > ; <nl> <nl> static uint8_t Encode ( int runtime_flags , bool fast_clone_supported ) ; <nl> <nl> class CreateObjectLiteralFlags { <nl> <nl> class CreateClosureFlags { <nl> public : <nl> - class PretenuredBit : public BitField8 < bool , 0 , 1 > { } ; <nl> - class FastNewClosureBit : public BitField8 < bool , PretenuredBit : : kNext , 1 > { } ; <nl> + using PretenuredBit = BitField8 < bool , 0 , 1 > ; <nl> + using FastNewClosureBit = BitField8 < bool , PretenuredBit : : kNext , 1 > ; <nl> <nl> static uint8_t Encode ( bool pretenure , bool is_function_scope , <nl> bool might_always_opt ) ; <nl> class TestTypeOfFlags { <nl> <nl> class StoreLookupSlotFlags { <nl> public : <nl> - class LanguageModeBit : public BitField8 < LanguageMode , 0 , 1 > { } ; <nl> - class LookupHoistingModeBit <nl> - : public BitField8 < bool , LanguageModeBit : : kNext , 1 > { } ; <nl> + using LanguageModeBit = BitField8 < LanguageMode , 0 , 1 > ; <nl> + using LookupHoistingModeBit = BitField8 < bool , LanguageModeBit : : kNext , 1 > ; <nl> STATIC_ASSERT ( LanguageModeSize < = LanguageModeBit : : kNumValues ) ; <nl> <nl> static uint8_t Encode ( LanguageMode language_mode , <nl> mmm a / src / objects / allocation - site . h <nl> ppp b / src / objects / allocation - site . h <nl> class AllocationSite : public Struct { <nl> bool IsNested ( ) ; <nl> <nl> / / transition_info bitfields , for constructed array transition info . <nl> - class ElementsKindBits : public BitField < ElementsKind , 0 , 5 > { } ; <nl> - class DoNotInlineBit : public BitField < bool , 5 , 1 > { } ; <nl> + using ElementsKindBits = BitField < ElementsKind , 0 , 5 > ; <nl> + using DoNotInlineBit = BitField < bool , 5 , 1 > ; <nl> / / Unused bits 6 - 30 . <nl> <nl> / / Bitfields for pretenure_data <nl> - class MementoFoundCountBits : public BitField < int , 0 , 26 > { } ; <nl> - class PretenureDecisionBits : public BitField < PretenureDecision , 26 , 3 > { } ; <nl> - class DeoptDependentCodeBit : public BitField < bool , 29 , 1 > { } ; <nl> + using MementoFoundCountBits = BitField < int , 0 , 26 > ; <nl> + using PretenureDecisionBits = BitField < PretenureDecision , 26 , 3 > ; <nl> + using DeoptDependentCodeBit = BitField < bool , 29 , 1 > ; <nl> STATIC_ASSERT ( PretenureDecisionBits : : kMax > = kLastPretenureDecisionValue ) ; <nl> <nl> / / Increments the mementos found counter and returns true when the first <nl> mmm a / src / objects / bigint . h <nl> ppp b / src / objects / bigint . h <nl> class BigIntBase : public HeapObject { <nl> / / able to read the length concurrently , the getters and setters are atomic . <nl> static const int kLengthFieldBits = 30 ; <nl> STATIC_ASSERT ( kMaxLength < = ( ( 1 < < kLengthFieldBits ) - 1 ) ) ; <nl> - class SignBits : public BitField < bool , 0 , 1 > { } ; <nl> - class LengthBits : public BitField < int , SignBits : : kNext , kLengthFieldBits > { } ; <nl> + using SignBits = BitField < bool , 0 , 1 > ; <nl> + using LengthBits = BitField < int , SignBits : : kNext , kLengthFieldBits > ; <nl> STATIC_ASSERT ( LengthBits : : kNext < = 32 ) ; <nl> <nl> / / Layout description . <nl> mmm a / src / objects / code . h <nl> ppp b / src / objects / code . h <nl> class DependentCode : public WeakFixedArray { <nl> <nl> inline int flags ( ) ; <nl> inline void set_flags ( int flags ) ; <nl> - class GroupField : public BitField < int , 0 , 3 > { } ; <nl> - class CountField : public BitField < int , 3 , 27 > { } ; <nl> + using GroupField = BitField < int , 0 , 3 > ; <nl> + using CountField = BitField < int , 3 , 27 > ; <nl> STATIC_ASSERT ( kGroupCount < = GroupField : : kMax + 1 ) ; <nl> <nl> OBJECT_CONSTRUCTORS ( DependentCode , WeakFixedArray ) ; <nl> mmm a / src / objects / field - index . h <nl> ppp b / src / objects / field - index . h <nl> class FieldIndex final { <nl> ( kDescriptorIndexBitCount + 1 + kTaggedSizeLog2 ) ; <nl> <nl> / / Index from beginning of object . <nl> - class OffsetBits : public BitField64 < int , 0 , kOffsetBitsSize > { } ; <nl> - class IsInObjectBits : public BitField64 < bool , OffsetBits : : kNext , 1 > { } ; <nl> - class EncodingBits : public BitField64 < Encoding , IsInObjectBits : : kNext , 2 > { } ; <nl> + using OffsetBits = BitField64 < int , 0 , kOffsetBitsSize > ; <nl> + using IsInObjectBits = BitField64 < bool , OffsetBits : : kNext , 1 > ; <nl> + using EncodingBits = BitField64 < Encoding , IsInObjectBits : : kNext , 2 > ; <nl> / / Number of inobject properties . <nl> - class InObjectPropertyBits <nl> - : public BitField64 < int , EncodingBits : : kNext , kDescriptorIndexBitCount > { <nl> - } ; <nl> + using InObjectPropertyBits = <nl> + BitField64 < int , EncodingBits : : kNext , kDescriptorIndexBitCount > ; <nl> / / Offset of first inobject property from beginning of object . <nl> - class FirstInobjectPropertyOffsetBits <nl> - : public BitField64 < int , InObjectPropertyBits : : kNext , <nl> - kFirstInobjectPropertyOffsetBitCount > { } ; <nl> + using FirstInobjectPropertyOffsetBits = <nl> + BitField64 < int , InObjectPropertyBits : : kNext , <nl> + kFirstInobjectPropertyOffsetBitCount > ; <nl> STATIC_ASSERT ( FirstInobjectPropertyOffsetBits : : kNext < = 64 ) ; <nl> <nl> uint64_t bit_field_ ; <nl> mmm a / src / objects / js - promise . h <nl> ppp b / src / objects / js - promise . h <nl> class JSPromise : public JSObject { <nl> static const int kStatusBits = 2 ; <nl> static const int kHasHandlerBit = 2 ; <nl> static const int kHandledHintBit = 3 ; <nl> - class AsyncTaskIdField : public BitField < int , kHandledHintBit + 1 , 22 > { } ; <nl> + using AsyncTaskIdField = BitField < int , kHandledHintBit + 1 , 22 > ; <nl> <nl> static const int kStatusShift = 0 ; <nl> static const int kStatusMask = 0x3 ; <nl> mmm a / src / objects / js - weak - refs . h <nl> ppp b / src / objects / js - weak - refs . h <nl> class JSFinalizationGroup : public JSObject { <nl> TORQUE_GENERATED_JSFINALIZATION_GROUP_FIELDS ) <nl> <nl> / / Bitfields in flags . <nl> - class ScheduledForCleanupField : public BitField < bool , 0 , 1 > { } ; <nl> + using ScheduledForCleanupField = BitField < bool , 0 , 1 > ; <nl> <nl> OBJECT_CONSTRUCTORS ( JSFinalizationGroup , JSObject ) ; <nl> } ; <nl> mmm a / src / objects / name . h <nl> ppp b / src / objects / name . h <nl> class Name : public TorqueGeneratedName < Name , HeapObject > { <nl> STATIC_ASSERT ( kArrayIndexLengthBits > 0 ) ; <nl> STATIC_ASSERT ( kMaxArrayIndexSize < ( 1 < < kArrayIndexLengthBits ) ) ; <nl> <nl> - class ArrayIndexValueBits <nl> - : public BitField < unsigned int , kNofHashBitFields , kArrayIndexValueBits > { <nl> - } ; / / NOLINT <nl> - class ArrayIndexLengthBits <nl> - : public BitField < unsigned int , kNofHashBitFields + kArrayIndexValueBits , <nl> - kArrayIndexLengthBits > { } ; / / NOLINT <nl> + using ArrayIndexValueBits = <nl> + BitField < unsigned int , kNofHashBitFields , kArrayIndexValueBits > ; <nl> + using ArrayIndexLengthBits = <nl> + BitField < unsigned int , kNofHashBitFields + kArrayIndexValueBits , <nl> + kArrayIndexLengthBits > ; <nl> <nl> / / Check that kMaxCachedArrayIndexLength + 1 is a power of two so we <nl> / / could use a mask to test if the length of string is less than or equal to <nl> mmm a / src / objects / property - array . h <nl> ppp b / src / objects / property - array . h <nl> class PropertyArray : public HeapObject { <nl> using BodyDescriptor = FlexibleBodyDescriptor < kHeaderSize > ; <nl> <nl> static const int kLengthFieldSize = 10 ; <nl> - class LengthField : public BitField < int , 0 , kLengthFieldSize > { } ; <nl> + using LengthField = BitField < int , 0 , kLengthFieldSize > ; <nl> static const int kMaxLength = LengthField : : kMax ; <nl> - class HashField : public BitField < int , kLengthFieldSize , <nl> - kSmiValueSize - kLengthFieldSize - 1 > { } ; <nl> + using HashField = <nl> + BitField < int , kLengthFieldSize , kSmiValueSize - kLengthFieldSize - 1 > ; <nl> <nl> static const int kNoHashSentinel = 0 ; <nl> <nl> mmm a / src / objects / property - details . h <nl> ppp b / src / objects / property - details . h <nl> class PropertyDetails { <nl> <nl> / / Bit fields in value_ ( type , shift , size ) . Must be public so the <nl> / / constants can be embedded in generated code . <nl> - class KindField : public BitField < PropertyKind , 0 , 1 > { } ; <nl> - class LocationField : public BitField < PropertyLocation , KindField : : kNext , 1 > { <nl> - } ; <nl> - class ConstnessField <nl> - : public BitField < PropertyConstness , LocationField : : kNext , 1 > { } ; <nl> - class AttributesField <nl> - : public BitField < PropertyAttributes , ConstnessField : : kNext , 3 > { } ; <nl> + using KindField = BitField < PropertyKind , 0 , 1 > ; <nl> + using LocationField = BitField < PropertyLocation , KindField : : kNext , 1 > ; <nl> + using ConstnessField = BitField < PropertyConstness , LocationField : : kNext , 1 > ; <nl> + using AttributesField = <nl> + BitField < PropertyAttributes , ConstnessField : : kNext , 3 > ; <nl> static const int kAttributesReadOnlyMask = <nl> ( READ_ONLY < < AttributesField : : kShift ) ; <nl> static const int kAttributesDontDeleteMask = <nl> class PropertyDetails { <nl> ( DONT_ENUM < < AttributesField : : kShift ) ; <nl> <nl> / / Bit fields for normalized objects . <nl> - class PropertyCellTypeField <nl> - : public BitField < PropertyCellType , AttributesField : : kNext , 2 > { } ; <nl> - class DictionaryStorageField <nl> - : public BitField < uint32_t , PropertyCellTypeField : : kNext , 23 > { } ; <nl> + using PropertyCellTypeField = <nl> + BitField < PropertyCellType , AttributesField : : kNext , 2 > ; <nl> + using DictionaryStorageField = <nl> + BitField < uint32_t , PropertyCellTypeField : : kNext , 23 > ; <nl> <nl> / / Bit fields for fast objects . <nl> - class RepresentationField <nl> - : public BitField < uint32_t , AttributesField : : kNext , 3 > { } ; <nl> - class DescriptorPointer <nl> - : public BitField < uint32_t , RepresentationField : : kNext , <nl> - kDescriptorIndexBitCount > { } ; / / NOLINT <nl> - class FieldIndexField : public BitField < uint32_t , DescriptorPointer : : kNext , <nl> - kDescriptorIndexBitCount > { <nl> - } ; / / NOLINT <nl> + using RepresentationField = BitField < uint32_t , AttributesField : : kNext , 3 > ; <nl> + using DescriptorPointer = <nl> + BitField < uint32_t , RepresentationField : : kNext , kDescriptorIndexBitCount > ; <nl> + using FieldIndexField = <nl> + BitField < uint32_t , DescriptorPointer : : kNext , kDescriptorIndexBitCount > ; <nl> <nl> / / All bits for both fast and slow objects must fit in a smi . <nl> STATIC_ASSERT ( DictionaryStorageField : : kNext < = 31 ) ; <nl> mmm a / src / objects / scope - info . h <nl> ppp b / src / objects / scope - info . h <nl> class ScopeInfo : public FixedArray { <nl> enum VariableAllocationInfo { NONE , STACK , CONTEXT , UNUSED } ; <nl> <nl> / / Properties of scopes . <nl> - class ScopeTypeField : public BitField < ScopeType , 0 , 4 > { } ; <nl> - class CallsSloppyEvalField : public BitField < bool , ScopeTypeField : : kNext , 1 > { <nl> - } ; <nl> + using ScopeTypeField = BitField < ScopeType , 0 , 4 > ; <nl> + using CallsSloppyEvalField = BitField < bool , ScopeTypeField : : kNext , 1 > ; <nl> STATIC_ASSERT ( LanguageModeSize = = 2 ) ; <nl> - class LanguageModeField <nl> - : public BitField < LanguageMode , CallsSloppyEvalField : : kNext , 1 > { } ; <nl> - class DeclarationScopeField <nl> - : public BitField < bool , LanguageModeField : : kNext , 1 > { } ; <nl> - class ReceiverVariableField <nl> - : public BitField < VariableAllocationInfo , DeclarationScopeField : : kNext , <nl> - 2 > { } ; <nl> - class HasClassBrandField <nl> - : public BitField < bool , ReceiverVariableField : : kNext , 1 > { } ; <nl> - class HasNewTargetField <nl> - : public BitField < bool , HasClassBrandField : : kNext , 1 > { } ; <nl> - class FunctionVariableField <nl> - : public BitField < VariableAllocationInfo , HasNewTargetField : : kNext , 2 > { } ; <nl> + using LanguageModeField = <nl> + BitField < LanguageMode , CallsSloppyEvalField : : kNext , 1 > ; <nl> + using DeclarationScopeField = BitField < bool , LanguageModeField : : kNext , 1 > ; <nl> + using ReceiverVariableField = <nl> + BitField < VariableAllocationInfo , DeclarationScopeField : : kNext , 2 > ; <nl> + using HasClassBrandField = BitField < bool , ReceiverVariableField : : kNext , 1 > ; <nl> + using HasNewTargetField = BitField < bool , HasClassBrandField : : kNext , 1 > ; <nl> + using FunctionVariableField = <nl> + BitField < VariableAllocationInfo , HasNewTargetField : : kNext , 2 > ; <nl> / / TODO ( cbruni ) : Combine with function variable field when only storing the <nl> / / function name . <nl> - class HasInferredFunctionNameField <nl> - : public BitField < bool , FunctionVariableField : : kNext , 1 > { } ; <nl> - class IsAsmModuleField <nl> - : public BitField < bool , HasInferredFunctionNameField : : kNext , 1 > { } ; <nl> - class HasSimpleParametersField <nl> - : public BitField < bool , IsAsmModuleField : : kNext , 1 > { } ; <nl> - class FunctionKindField <nl> - : public BitField < FunctionKind , HasSimpleParametersField : : kNext , 5 > { } ; <nl> - class HasOuterScopeInfoField <nl> - : public BitField < bool , FunctionKindField : : kNext , 1 > { } ; <nl> - class IsDebugEvaluateScopeField <nl> - : public BitField < bool , HasOuterScopeInfoField : : kNext , 1 > { } ; <nl> - class ForceContextAllocationField <nl> - : public BitField < bool , IsDebugEvaluateScopeField : : kNext , 1 > { } ; <nl> + using HasInferredFunctionNameField = <nl> + BitField < bool , FunctionVariableField : : kNext , 1 > ; <nl> + using IsAsmModuleField = <nl> + BitField < bool , HasInferredFunctionNameField : : kNext , 1 > ; <nl> + using HasSimpleParametersField = BitField < bool , IsAsmModuleField : : kNext , 1 > ; <nl> + using FunctionKindField = <nl> + BitField < FunctionKind , HasSimpleParametersField : : kNext , 5 > ; <nl> + using HasOuterScopeInfoField = BitField < bool , FunctionKindField : : kNext , 1 > ; <nl> + using IsDebugEvaluateScopeField = <nl> + BitField < bool , HasOuterScopeInfoField : : kNext , 1 > ; <nl> + using ForceContextAllocationField = <nl> + BitField < bool , IsDebugEvaluateScopeField : : kNext , 1 > ; <nl> <nl> STATIC_ASSERT ( kLastFunctionKind < = FunctionKindField : : kMax ) ; <nl> <nl> class ScopeInfo : public FixedArray { <nl> static const int kPositionInfoEntries = 2 ; <nl> <nl> / / Properties of variables . <nl> - class VariableModeField : public BitField < VariableMode , 0 , 3 > { } ; <nl> - class InitFlagField : public BitField < InitializationFlag , 3 , 1 > { } ; <nl> - class MaybeAssignedFlagField : public BitField < MaybeAssignedFlag , 4 , 1 > { } ; <nl> - class RequiresBrandCheckField <nl> - : public BitField < RequiresBrandCheckFlag , MaybeAssignedFlagField : : kNext , <nl> - 1 > { } ; <nl> - class ParameterNumberField <nl> - : public BitField < uint32_t , RequiresBrandCheckField : : kNext , 16 > { } ; <nl> + using VariableModeField = BitField < VariableMode , 0 , 3 > ; <nl> + using InitFlagField = BitField < InitializationFlag , 3 , 1 > ; <nl> + using MaybeAssignedFlagField = BitField < MaybeAssignedFlag , 4 , 1 > ; <nl> + using RequiresBrandCheckField = <nl> + BitField < RequiresBrandCheckFlag , MaybeAssignedFlagField : : kNext , 1 > ; <nl> + using ParameterNumberField = <nl> + BitField < uint32_t , RequiresBrandCheckField : : kNext , 16 > ; <nl> <nl> friend class ScopeIterator ; <nl> friend std : : ostream & operator < < ( std : : ostream & os , <nl> mmm a / src / objects / templates . h <nl> ppp b / src / objects / templates . h <nl> class ObjectTemplateInfo : public TemplateInfo { <nl> inline ObjectTemplateInfo GetParent ( Isolate * isolate ) ; <nl> <nl> private : <nl> - class IsImmutablePrototype : public BitField < bool , 0 , 1 > { } ; <nl> - class EmbedderFieldCount <nl> - : public BitField < int , IsImmutablePrototype : : kNext , 29 > { } ; <nl> + using IsImmutablePrototype = BitField < bool , 0 , 1 > ; <nl> + using EmbedderFieldCount = BitField < int , IsImmutablePrototype : : kNext , 29 > ; <nl> <nl> OBJECT_CONSTRUCTORS ( ObjectTemplateInfo , TemplateInfo ) ; <nl> } ; <nl> mmm a / src / parsing / preparse - data . cc <nl> ppp b / src / parsing / preparse - data . cc <nl> namespace internal { <nl> <nl> namespace { <nl> <nl> - class ScopeCallsSloppyEvalField : public BitField8 < bool , 0 , 1 > { } ; <nl> - class InnerScopeCallsEvalField <nl> - : public BitField8 < bool , ScopeCallsSloppyEvalField : : kNext , 1 > { } ; <nl> - <nl> - class VariableMaybeAssignedField : public BitField8 < bool , 0 , 1 > { } ; <nl> - class VariableContextAllocatedField <nl> - : public BitField8 < bool , VariableMaybeAssignedField : : kNext , 1 > { } ; <nl> - <nl> - class HasDataField : public BitField < bool , 0 , 1 > { } ; <nl> - class LengthEqualsParametersField <nl> - : public BitField < bool , HasDataField : : kNext , 1 > { } ; <nl> - class NumberOfParametersField <nl> - : public BitField < uint16_t , LengthEqualsParametersField : : kNext , 16 > { } ; <nl> - <nl> - class LanguageField : public BitField8 < LanguageMode , 0 , 1 > { } ; <nl> - class UsesSuperField : public BitField8 < bool , LanguageField : : kNext , 1 > { } ; <nl> + using ScopeCallsSloppyEvalField = BitField8 < bool , 0 , 1 > ; <nl> + using InnerScopeCallsEvalField = <nl> + BitField8 < bool , ScopeCallsSloppyEvalField : : kNext , 1 > ; <nl> + <nl> + using VariableMaybeAssignedField = BitField8 < bool , 0 , 1 > ; <nl> + using VariableContextAllocatedField = <nl> + BitField8 < bool , VariableMaybeAssignedField : : kNext , 1 > ; <nl> + <nl> + using HasDataField = BitField < bool , 0 , 1 > ; <nl> + using LengthEqualsParametersField = BitField < bool , HasDataField : : kNext , 1 > ; <nl> + using NumberOfParametersField = <nl> + BitField < uint16_t , LengthEqualsParametersField : : kNext , 16 > ; <nl> + <nl> + using LanguageField = BitField8 < LanguageMode , 0 , 1 > ; <nl> + using UsesSuperField = BitField8 < bool , LanguageField : : kNext , 1 > ; <nl> STATIC_ASSERT ( LanguageModeSize < = LanguageField : : kNumValues ) ; <nl> <nl> } / / namespace <nl> mmm a / src / parsing / token . h <nl> ppp b / src / parsing / token . h <nl> class V8_EXPORT_PRIVATE Token { <nl> return name_ [ token ] ; <nl> } <nl> <nl> - class IsKeywordBits : public BitField8 < bool , 0 , 1 > { } ; <nl> - class IsPropertyNameBits : public BitField8 < bool , IsKeywordBits : : kNext , 1 > { } ; <nl> + using IsKeywordBits = BitField8 < bool , 0 , 1 > ; <nl> + using IsPropertyNameBits = BitField8 < bool , IsKeywordBits : : kNext , 1 > ; <nl> <nl> / / Predicates <nl> static bool IsKeyword ( Value token ) { <nl> mmm a / src / profiler / heap - snapshot - generator . h <nl> ppp b / src / profiler / heap - snapshot - generator . h <nl> class HeapGraphEdge { <nl> V8_INLINE HeapSnapshot * snapshot ( ) const ; <nl> int from_index ( ) const { return FromIndexField : : decode ( bit_field_ ) ; } <nl> <nl> - class TypeField : public BitField < Type , 0 , 3 > { } ; <nl> - class FromIndexField : public BitField < int , 3 , 29 > { } ; <nl> + using TypeField = BitField < Type , 0 , 3 > ; <nl> + using FromIndexField = BitField < int , 3 , 29 > ; <nl> uint32_t bit_field_ ; <nl> HeapEntry * to_entry_ ; <nl> union { <nl> mmm a / src / runtime / runtime . h <nl> ppp b / src / runtime / runtime . h <nl> V8_EXPORT_PRIVATE std : : ostream & operator < < ( std : : ostream & , Runtime : : FunctionId ) ; <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> / / Constants used by interface to runtime functions . <nl> <nl> - class AllocateDoubleAlignFlag : public BitField < bool , 0 , 1 > { } ; <nl> + using AllocateDoubleAlignFlag = BitField < bool , 0 , 1 > ; <nl> <nl> - class AllowLargeObjectAllocationFlag : public BitField < bool , 1 , 1 > { } ; <nl> + using AllowLargeObjectAllocationFlag = BitField < bool , 1 , 1 > ; <nl> <nl> - class DeclareGlobalsEvalFlag : public BitField < bool , 0 , 1 > { } ; <nl> + using DeclareGlobalsEvalFlag = BitField < bool , 0 , 1 > ; <nl> <nl> / / A set of bits returned by Runtime_GetOptimizationStatus . <nl> / / These bits must be in sync with bits defined in test / mjsunit / mjsunit . js <nl> mmm a / src / snapshot / references . h <nl> ppp b / src / snapshot / references . h <nl> class SerializerReference { <nl> } <nl> <nl> private : <nl> - class SpaceBits : public BitField < SnapshotSpace , 0 , kSpaceTagSize > { } ; <nl> - class ChunkIndexBits <nl> - : public BitField < uint32_t , SpaceBits : : kNext , 32 - kSpaceTagSize > { } ; <nl> - class SpecialValueTypeBits <nl> - : public BitField < SpecialValueType , SpaceBits : : kNext , <nl> - 32 - kSpaceTagSize > { } ; <nl> + using SpaceBits = BitField < SnapshotSpace , 0 , kSpaceTagSize > ; <nl> + using ChunkIndexBits = <nl> + BitField < uint32_t , SpaceBits : : kNext , 32 - kSpaceTagSize > ; <nl> + using SpecialValueTypeBits = <nl> + BitField < SpecialValueType , SpaceBits : : kNext , 32 - kSpaceTagSize > ; <nl> <nl> / / We use two fields to store a reference . <nl> / / In case of a normal back reference , the bitfield_ stores the space and <nl> mmm a / src / snapshot / serializer - common . h <nl> ppp b / src / snapshot / serializer - common . h <nl> class ExternalReferenceEncoder { <nl> uint32_t index ( ) const { return Index : : decode ( value_ ) ; } <nl> <nl> private : <nl> - class Index : public BitField < uint32_t , 0 , 31 > { } ; <nl> - class IsFromAPI : public BitField < bool , 31 , 1 > { } ; <nl> + using Index = BitField < uint32_t , 0 , 31 > ; <nl> + using IsFromAPI = BitField < bool , 31 , 1 > ; <nl> uint32_t value_ ; <nl> } ; <nl> <nl> class SerializedData { <nl> <nl> uint32_t GetMagicNumber ( ) const { return GetHeaderValue ( kMagicNumberOffset ) ; } <nl> <nl> - class ChunkSizeBits : public BitField < uint32_t , 0 , 31 > { } ; <nl> - class IsLastChunkBits : public BitField < bool , 31 , 1 > { } ; <nl> + using ChunkSizeBits = BitField < uint32_t , 0 , 31 > ; <nl> + using IsLastChunkBits = BitField < bool , 31 , 1 > ; <nl> <nl> static constexpr uint32_t kMagicNumberOffset = 0 ; <nl> static constexpr uint32_t kMagicNumber = <nl> mmm a / src / strings / unicode . h <nl> ppp b / src / strings / unicode . h <nl> class Predicate { <nl> bool value ( ) const { return ValueField : : decode ( bit_field_ ) ; } <nl> <nl> private : <nl> - class CodePointField : public v8 : : internal : : BitField < uchar , 0 , 21 > { } ; <nl> - class ValueField : public v8 : : internal : : BitField < bool , 21 , 1 > { } ; <nl> + using CodePointField = v8 : : internal : : BitField < uchar , 0 , 21 > ; <nl> + using ValueField = v8 : : internal : : BitField < bool , 21 , 1 > ; <nl> <nl> uint32_t bit_field_ ; <nl> } ; <nl> mmm a / src / utils / utils . h <nl> ppp b / src / utils / utils . h <nl> T SaturateSub ( T a , T b ) { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> / / BitField is a help template for encoding and decode bitfield with <nl> / / unsigned content . <nl> + / / Instantiate them via ' using ' , which is cheaper than deriving a new class : <nl> + / / using MyBitField = BitField < int , 4 , 2 , MyEnum > ; <nl> + / / The BitField class is final to enforce this style over derivation . <nl> <nl> template < class T , int shift , int size , class U = uint32_t > <nl> - class BitField { <nl> + class BitField final { <nl> public : <nl> STATIC_ASSERT ( std : : is_unsigned < U > : : value ) ; <nl> STATIC_ASSERT ( shift < 8 * sizeof ( U ) ) ; / / Otherwise shifts by { shift } are UB . <nl> mmm a / src / wasm / module - compiler . cc <nl> ppp b / src / wasm / module - compiler . cc <nl> class CompilationStateImpl { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> / / Encoding of fields in the { compilation_progress_ } vector . <nl> - class RequiredBaselineTierField : public BitField8 < ExecutionTier , 0 , 2 > { } ; <nl> - class RequiredTopTierField : public BitField8 < ExecutionTier , 2 , 2 > { } ; <nl> - class ReachedTierField : public BitField8 < ExecutionTier , 4 , 2 > { } ; <nl> + using RequiredBaselineTierField = BitField8 < ExecutionTier , 0 , 2 > ; <nl> + using RequiredTopTierField = BitField8 < ExecutionTier , 2 , 2 > ; <nl> + using ReachedTierField = BitField8 < ExecutionTier , 4 , 2 > ; <nl> } ; <nl> <nl> CompilationStateImpl * Impl ( CompilationState * compilation_state ) { <nl> mmm a / test / cctest / test - code - stub - assembler . cc <nl> ppp b / test / cctest / test - code - stub - assembler . cc <nl> TEST ( DecodeWordFromWord32 ) { <nl> CodeAssemblerTester asm_tester ( isolate ) ; <nl> CodeStubAssembler m ( asm_tester . state ( ) ) ; <nl> <nl> - class TestBitField : public BitField < unsigned , 3 , 3 > { } ; <nl> + using TestBitField = BitField < unsigned , 3 , 3 > ; <nl> m . Return ( m . SmiTag ( <nl> m . Signed ( m . DecodeWordFromWord32 < TestBitField > ( m . Int32Constant ( 0x2F ) ) ) ) ) ; <nl> FunctionTester ft ( asm_tester . GenerateCode ( ) ) ; <nl> mmm a / test / cctest / test - conversions . cc <nl> ppp b / test / cctest / test - conversions . cc <nl> TEST ( ExponentNumberStr ) { <nl> CHECK_EQ ( 1e - 106 , StringToDouble ( " . 000001e - 100 " , NO_FLAGS ) ) ; <nl> } <nl> <nl> - <nl> - class OneBit1 : public BitField < uint32_t , 0 , 1 > { } ; <nl> - class OneBit2 : public BitField < uint32_t , 7 , 1 > { } ; <nl> - class EightBit1 : public BitField < uint32_t , 0 , 8 > { } ; <nl> - class EightBit2 : public BitField < uint32_t , 13 , 8 > { } ; <nl> + using OneBit1 = BitField < uint32_t , 0 , 1 > ; <nl> + using OneBit2 = BitField < uint32_t , 7 , 1 > ; <nl> + using EightBit1 = BitField < uint32_t , 0 , 8 > ; <nl> + using EightBit2 = BitField < uint32_t , 13 , 8 > ; <nl> <nl> TEST ( BitField ) { <nl> uint32_t x ; <nl> TEST ( BitField ) { <nl> CHECK ( ! EightBit2 : : is_valid ( 256 ) ) ; <nl> } <nl> <nl> - <nl> - class UpperBits : public BitField64 < int , 61 , 3 > { } ; <nl> - class MiddleBits : public BitField64 < int , 31 , 2 > { } ; <nl> + using UpperBits = BitField64 < int , 61 , 3 > ; <nl> + using MiddleBits = BitField64 < int , 31 , 2 > ; <nl> <nl> TEST ( BitField64 ) { <nl> uint64_t x ; <nl> | Reland " [ utils ] Make BitField final " | v8/v8 | 0cabc6a0e5d604e448cbcde14b57efeb0062dfce | 2019-07-29T14:20:58Z |
mmm a / tensorflow / tensorboard / components / vz - projector / scatterWebGL . ts <nl> ppp b / tensorflow / tensorboard / components / vz - projector / scatterWebGL . ts <nl> export abstract class ScatterWebGL implements Scatter { <nl> private setNearestPointToMouse ( e : MouseEvent ) { <nl> if ( this . pickingTexture = = null ) { <nl> this . nearestPoint = null ; <nl> + return ; <nl> } <nl> <nl> / / Create buffer for reading a single pixel . <nl> mmm a / tensorflow / tensorboard / components / vz - projector / scatterWebGLPointsCanvasLabels . ts <nl> ppp b / tensorflow / tensorboard / components / vz - projector / scatterWebGLPointsCanvasLabels . ts <nl> const FRAGMENT_SHADER = ` <nl> uniform bool isImage ; <nl> <nl> void main ( ) { <nl> - / / A mystery variable that is required to make the THREE shaderchunk for fog <nl> - / / work correctly . <nl> - vec3 outgoingLight = vec3 ( 0 . 0 ) ; <nl> - <nl> if ( isImage ) { <nl> / / Coordinates of the vertex within the entire sprite image . <nl> vec2 coords = ( gl_PointCoord + xyIndex ) / vec2 ( imageWidth , imageHeight ) ; <nl> export class ScatterWebGLPointsCanvasLabels extends ScatterWebGL { <nl> } <nl> } <nl> <nl> - / * * Removes all traces from the scene . * / <nl> private removeAllTraces ( scene : THREE . Scene ) { <nl> if ( ! this . traces ) { <nl> return ; <nl> export class ScatterWebGLPointsCanvasLabels extends ScatterWebGL { <nl> this . traces = [ ] ; <nl> } <nl> <nl> - / * * <nl> - * Returns the color of a point along a trace . <nl> - * / <nl> private getPointInTraceColor ( index : number , totalPoints : number ) { <nl> let hue = TRACE_START_HUE + <nl> ( TRACE_END_HUE - TRACE_START_HUE ) * index / totalPoints ; <nl> export class ScatterWebGLPointsCanvasLabels extends ScatterWebGL { <nl> if ( this . points = = null ) { <nl> return ; <nl> } <nl> - / / First , remove all old labels . <nl> this . removeAllLabels ( ) ; <nl> <nl> if ( ! labeledPoints . length ) { <nl> | Remove unused variable from fragment shader . Delete some redundant comments | tensorflow/tensorflow | dc4bf5a513893baff298a24b372203b054931420 | 2016-09-16T21:17:39Z |
mmm a / libraries / chain / controller . cpp <nl> ppp b / libraries / chain / controller . cpp <nl> signed_block_ptr controller : : fetch_block_by_number ( uint32_t block_num ) const { <nl> return my - > blog . read_block_by_num ( block_num ) ; <nl> } FC_CAPTURE_AND_RETHROW ( ( block_num ) ) } <nl> <nl> + block_state_ptr controller : : fetch_block_state_by_id ( block_id_type id ) const { <nl> + auto state = my - > fork_db . get_block ( id ) ; <nl> + return state ; <nl> + } <nl> + <nl> + block_state_ptr controller : : fetch_block_state_by_number ( uint32_t block_num ) const { try { <nl> + auto blk_state = my - > fork_db . get_block_in_current_chain_by_num ( block_num ) ; <nl> + return blk_state ; <nl> + } FC_CAPTURE_AND_RETHROW ( ( block_num ) ) } <nl> + <nl> block_id_type controller : : get_block_id_for_num ( uint32_t block_num ) const { try { <nl> auto blk_state = my - > fork_db . get_block_in_current_chain_by_num ( block_num ) ; <nl> if ( blk_state ) { <nl> mmm a / libraries / chain / include / eosio / chain / controller . hpp <nl> ppp b / libraries / chain / include / eosio / chain / controller . hpp <nl> namespace eosio { namespace chain { <nl> signed_block_ptr fetch_block_by_number ( uint32_t block_num ) const ; <nl> signed_block_ptr fetch_block_by_id ( block_id_type id ) const ; <nl> <nl> + block_state_ptr fetch_block_state_by_number ( uint32_t block_num ) const ; <nl> + block_state_ptr fetch_block_state_by_id ( block_id_type id ) const ; <nl> + <nl> block_id_type get_block_id_for_num ( uint32_t block_num ) const ; <nl> <nl> void check_contract_list ( account_name code ) const ; <nl> mmm a / plugins / chain_api_plugin / chain_api_plugin . cpp <nl> ppp b / plugins / chain_api_plugin / chain_api_plugin . cpp <nl> void chain_api_plugin : : plugin_startup ( ) { <nl> app ( ) . get_plugin < http_plugin > ( ) . add_api ( { <nl> CHAIN_RO_CALL ( get_info , 200l ) , <nl> CHAIN_RO_CALL ( get_block , 200 ) , <nl> + CHAIN_RO_CALL ( get_block_header_state , 200 ) , <nl> CHAIN_RO_CALL ( get_account , 200 ) , <nl> CHAIN_RO_CALL ( get_code , 200 ) , <nl> CHAIN_RO_CALL ( get_table_rows , 200 ) , <nl> mmm a / plugins / chain_plugin / chain_plugin . cpp <nl> ppp b / plugins / chain_plugin / chain_plugin . cpp <nl> fc : : variant read_only : : get_block ( const read_only : : get_block_params & params ) cons <nl> ( " ref_block_prefix " , ref_block_prefix ) ; <nl> } <nl> <nl> + fc : : variant read_only : : get_block_header_state ( const get_block_header_state_params & params ) const { <nl> + block_state_ptr b ; <nl> + optional < uint64_t > block_num ; <nl> + std : : exception_ptr e ; <nl> + try { <nl> + block_num = fc : : to_uint64 ( params . block_num_or_id ) ; <nl> + } catch ( . . . ) { } <nl> + <nl> + if ( block_num . valid ( ) ) { <nl> + b = db . fetch_block_state_by_number ( * block_num ) ; <nl> + } else { <nl> + try { <nl> + b = db . fetch_block_state_by_id ( fc : : json : : from_string ( params . block_num_or_id ) . as < block_id_type > ( ) ) ; <nl> + } EOS_RETHROW_EXCEPTIONS ( chain : : block_id_type_exception , " Invalid block ID : $ { block_num_or_id } " , ( " block_num_or_id " , params . block_num_or_id ) ) <nl> + } <nl> + <nl> + EOS_ASSERT ( b , unknown_block_exception , " Could not find reversible block : $ { block } " , ( " block " , params . block_num_or_id ) ) ; <nl> + <nl> + fc : : variant vo ; <nl> + fc : : to_variant ( static_cast < const block_header_state & > ( * b ) , vo ) ; <nl> + return vo ; <nl> + } <nl> + <nl> void read_write : : push_block ( const read_write : : push_block_params & params , next_function < read_write : : push_block_results > next ) { <nl> try { <nl> app ( ) . get_method < incoming : : methods : : block_sync > ( ) ( std : : make_shared < signed_block > ( params ) ) ; <nl> mmm a / plugins / chain_plugin / include / eosio / chain_plugin / chain_plugin . hpp <nl> ppp b / plugins / chain_plugin / include / eosio / chain_plugin / chain_plugin . hpp <nl> class read_only { <nl> <nl> fc : : variant get_block ( const get_block_params & params ) const ; <nl> <nl> + struct get_block_header_state_params { <nl> + string block_num_or_id ; <nl> + } ; <nl> + <nl> + fc : : variant get_block_header_state ( const get_block_header_state_params & params ) const ; <nl> + <nl> struct get_table_rows_params { <nl> bool json = false ; <nl> name code ; <nl> FC_REFLECT ( eosio : : chain_apis : : empty , ) <nl> FC_REFLECT ( eosio : : chain_apis : : read_only : : get_info_results , <nl> ( server_version ) ( chain_id ) ( head_block_num ) ( last_irreversible_block_num ) ( last_irreversible_block_id ) ( head_block_id ) ( head_block_time ) ( head_block_producer ) ( virtual_block_cpu_limit ) ( virtual_block_net_limit ) ( block_cpu_limit ) ( block_net_limit ) ) <nl> FC_REFLECT ( eosio : : chain_apis : : read_only : : get_block_params , ( block_num_or_id ) ) <nl> + FC_REFLECT ( eosio : : chain_apis : : read_only : : get_block_header_state_params , ( block_num_or_id ) ) <nl> <nl> FC_REFLECT ( eosio : : chain_apis : : read_write : : push_transaction_results , ( transaction_id ) ( processed ) ) <nl> <nl> mmm a / programs / cleos / httpc . hpp <nl> ppp b / programs / cleos / httpc . hpp <nl> namespace eosio { namespace client { namespace http { <nl> const string push_txns_func = chain_func_base + " / push_transactions " ; <nl> const string json_to_bin_func = chain_func_base + " / abi_json_to_bin " ; <nl> const string get_block_func = chain_func_base + " / get_block " ; <nl> + const string get_block_header_state_func = chain_func_base + " / get_block_header_state " ; <nl> const string get_account_func = chain_func_base + " / get_account " ; <nl> const string get_table_func = chain_func_base + " / get_table_rows " ; <nl> const string get_code_func = chain_func_base + " / get_code " ; <nl> mmm a / programs / cleos / main . cpp <nl> ppp b / programs / cleos / main . cpp <nl> int main ( int argc , char * * argv ) { <nl> <nl> / / get block <nl> string blockArg ; <nl> + bool get_bhs = false ; <nl> auto getBlock = get - > add_subcommand ( " block " , localized ( " Retrieve a full block from the blockchain " ) , false ) ; <nl> getBlock - > add_option ( " block " , blockArg , localized ( " The number or ID of the block to retrieve " ) ) - > required ( ) ; <nl> - getBlock - > set_callback ( [ & blockArg ] { <nl> + getBlock - > add_flag ( " - - header - state " , get_bhs , localized ( " Get block header state from fork database instead " ) ) ; <nl> + getBlock - > set_callback ( [ & blockArg , & get_bhs ] { <nl> auto arg = fc : : mutable_variant_object ( " block_num_or_id " , blockArg ) ; <nl> - std : : cout < < fc : : json : : to_pretty_string ( call ( get_block_func , arg ) ) < < std : : endl ; <nl> + if ( get_bhs ) { <nl> + std : : cout < < fc : : json : : to_pretty_string ( call ( get_block_header_state_func , arg ) ) < < std : : endl ; <nl> + } else { <nl> + std : : cout < < fc : : json : : to_pretty_string ( call ( get_block_func , arg ) ) < < std : : endl ; <nl> + } <nl> } ) ; <nl> <nl> / / get account <nl> | Merge pull request from EOSIO / 3807 - get - block - header - state | EOSIO/eos | f8957c9c5a076d053fc8c3b9505090bddf4ac2c0 | 2018-06-05T13:52:28Z |
mmm a / docs / api / sandbox - option . md <nl> ppp b / docs / api / sandbox - option . md <nl> window . open = customWindowOpen <nl> Important things to notice in the preload script : <nl> <nl> - Even though the sandboxed renderer doesn ' t have Node . js running , it still has <nl> - access to a limited node - like environment : ` Buffer ` , ` process ` , ` setImmediate ` <nl> - and ` require ` are available . <nl> + access to a limited node - like environment : ` Buffer ` , ` process ` , ` setImmediate ` , <nl> + ` clearImmediate ` and ` require ` are available . <nl> - The preload script can indirectly access all APIs from the main process through the <nl> ` remote ` and ` ipcRenderer ` modules . <nl> - The preload script must be contained in a single script , but it is possible to have <nl> feature . We are still not aware of the security implications of exposing some <nl> Electron renderer APIs to the preload script , but here are some things to <nl> consider before rendering untrusted content : <nl> <nl> - - A preload script can accidentally leak privileged APIs to untrusted code . <nl> + - A preload script can accidentally leak privileged APIs to untrusted code , <nl> + unless [ ` contextIsolation ` ] ( . . / tutorial / security . md # 3 - enable - context - isolation - for - remote - content ) <nl> + is also enabled . <nl> - Some bug in V8 engine may allow malicious code to access the renderer preload <nl> APIs , effectively granting full access to the system through the ` remote ` <nl> - module . <nl> + module . Therefore , it is highly recommended to <nl> + [ disable the ` remote ` module ] ( . . / tutorial / security . md # 15 - disable - the - remote - module ) . <nl> + If disabling is not feasible , you should selectively <nl> + [ filter the ` remote ` module ] ( . . / tutorial / security . md # 16 - filter - the - remote - module ) . <nl> <nl> Since rendering untrusted content in Electron is still uncharted territory , <nl> the APIs exposed to the sandbox preload script should be considered more <nl> unstable than the rest of Electron APIs , and may have breaking changes to fix <nl> security issues . <nl> - <nl> - One planned enhancement that should greatly increase security is to block IPC <nl> - messages from sandboxed renderers by default , allowing the main process to <nl> - explicitly define a set of messages the renderer is allowed to send . <nl> | docs : update sandbox - option . md ( ) | electron/electron | dbb8617214aaa8b56b827deef1265d9ee38765bd | 2019-05-20T15:34:57Z |
mmm a / tensorflow / g3doc / api_docs / python / functions_and_classes / shard0 / tf . TensorArray . md <nl> ppp b / tensorflow / g3doc / api_docs / python / functions_and_classes / shard0 / tf . TensorArray . md <nl> must all match . <nl> <nl> - - - <nl> <nl> - # # # # ` tf . TensorArray . pack ( name = None ) ` { # TensorArray . pack } <nl> + # # # # ` tf . TensorArray . pack ( * args , * * kwargs ) ` { # TensorArray . pack } <nl> <nl> - Return the values in the TensorArray as a packed ` Tensor ` . <nl> + Return the values in the TensorArray as a stacked ` Tensor ` . <nl> <nl> All of the values must have been written and their shapes must all match . <nl> + If input shapes have rank - ` R ` , then output shape will have rank - ` ( R + 1 ) ` . <nl> <nl> # # # # # Args : <nl> <nl> All of the values must have been written and their shapes must all match . <nl> <nl> # # # # # Returns : <nl> <nl> - All the tensors in the TensorArray packed into one tensor . <nl> + All the tensors in the TensorArray stacked into one tensor . <nl> <nl> <nl> - - - <nl> Scatter the values of a ` Tensor ` in specific indices of a ` TensorArray ` . <nl> <nl> - - - <nl> <nl> - # # # # ` tf . TensorArray . unpack ( value , name = None ) ` { # TensorArray . unpack } <nl> + # # # # ` tf . TensorArray . unpack ( * args , * * kwargs ) ` { # TensorArray . unpack } <nl> <nl> - Pack the values of a ` Tensor ` in the TensorArray . <nl> + Unstack the values of a ` Tensor ` in the TensorArray . <nl> + <nl> + If input value shapes have rank - ` R ` , then the output TensorArray will <nl> + contain elements whose shapes are rank - ` ( R - 1 ) ` . <nl> <nl> # # # # # Args : <nl> <nl> <nl> - * < b > ` value ` < / b > : ( N + 1 ) - D . Tensor of type ` dtype ` . The Tensor to unpack . <nl> + * < b > ` value ` < / b > : ( N + 1 ) - D . Tensor of type ` dtype ` . The Tensor to unstack . <nl> * < b > ` name ` < / b > : A name for the operation ( optional ) . <nl> <nl> # # # # # Returns : <nl> <nl> - A new TensorArray object with flow that ensures the unpack occurs . <nl> + A new TensorArray object with flow that ensures the unstack occurs . <nl> Use this object all for subsequent operations . <nl> <nl> # # # # # Raises : <nl> The data type of this TensorArray . <nl> Return the size of the TensorArray . <nl> <nl> <nl> + - - - <nl> + <nl> + # # # # ` tf . TensorArray . stack ( name = None ) ` { # TensorArray . stack } <nl> + <nl> + Return the values in the TensorArray as a stacked ` Tensor ` . <nl> + <nl> + All of the values must have been written and their shapes must all match . <nl> + If input shapes have rank - ` R ` , then output shape will have rank - ` ( R + 1 ) ` . <nl> + <nl> + # # # # # Args : <nl> + <nl> + <nl> + * < b > ` name ` < / b > : A name for the operation ( optional ) . <nl> + <nl> + # # # # # Returns : <nl> + <nl> + All the tensors in the TensorArray stacked into one tensor . <nl> + <nl> + <nl> + - - - <nl> + <nl> + # # # # ` tf . TensorArray . unstack ( value , name = None ) ` { # TensorArray . unstack } <nl> + <nl> + Unstack the values of a ` Tensor ` in the TensorArray . <nl> + <nl> + If input value shapes have rank - ` R ` , then the output TensorArray will <nl> + contain elements whose shapes are rank - ` ( R - 1 ) ` . <nl> + <nl> + # # # # # Args : <nl> + <nl> + <nl> + * < b > ` value ` < / b > : ( N + 1 ) - D . Tensor of type ` dtype ` . The Tensor to unstack . <nl> + * < b > ` name ` < / b > : A name for the operation ( optional ) . <nl> + <nl> + # # # # # Returns : <nl> + <nl> + A new TensorArray object with flow that ensures the unstack occurs . <nl> + Use this object all for subsequent operations . <nl> + <nl> + # # # # # Raises : <nl> + <nl> + <nl> + * < b > ` ValueError ` < / b > : if the shape inference fails . <nl> + <nl> + <nl> new file mode 100644 <nl> index 0000000000000 . . a4caa4625842b <nl> mmm / dev / null <nl> ppp b / tensorflow / g3doc / api_docs / python / functions_and_classes / shard5 / tf . nn . atrous_conv2d_transpose . md <nl> <nl> + # # # ` tf . nn . atrous_conv2d_transpose ( value , filters , output_shape , rate , padding , name = None ) ` { # atrous_conv2d_transpose } <nl> + <nl> + The transpose of ` atrous_conv2d ` . <nl> + <nl> + This operation is sometimes called " deconvolution " after [ Deconvolutional <nl> + Networks ] ( http : / / www . matthewzeiler . com / pubs / cvpr2010 / cvpr2010 . pdf ) , but is <nl> + actually the transpose ( gradient ) of ` atrous_conv2d ` rather than an actual <nl> + deconvolution . <nl> + <nl> + # # # # # Args : <nl> + <nl> + <nl> + * < b > ` value ` < / b > : A 4 - D ` Tensor ` of type ` float ` . It needs to be in the default ` NHWC ` <nl> + format . Its shape is ` [ batch , in_height , in_width , in_channels ] ` . <nl> + * < b > ` filters ` < / b > : A 4 - D ` Tensor ` with the same type as ` value ` and shape <nl> + ` [ filter_height , filter_width , out_channels , in_channels ] ` . ` filters ` ' <nl> + ` in_channels ` dimension must match that of ` value ` . Atrous convolution is <nl> + equivalent to standard convolution with upsampled filters with effective <nl> + height ` filter_height + ( filter_height - 1 ) * ( rate - 1 ) ` and effective <nl> + width ` filter_width + ( filter_width - 1 ) * ( rate - 1 ) ` , produced by <nl> + inserting ` rate - 1 ` zeros along consecutive elements across the <nl> + ` filters ` ' spatial dimensions . <nl> + * < b > ` output_shape ` < / b > : A 1 - D ` Tensor ` of shape representing the output shape of the <nl> + deconvolution op . <nl> + * < b > ` rate ` < / b > : A positive int32 . The stride with which we sample input values across <nl> + the ` height ` and ` width ` dimensions . Equivalently , the rate by which we <nl> + upsample the filter values by inserting zeros across the ` height ` and <nl> + ` width ` dimensions . In the literature , the same parameter is sometimes <nl> + called ` input stride ` or ` dilation ` . <nl> + * < b > ` padding ` < / b > : A string , either ` ' VALID ' ` or ` ' SAME ' ` . The padding algorithm . <nl> + * < b > ` name ` < / b > : Optional name for the returned tensor . <nl> + <nl> + # # # # # Returns : <nl> + <nl> + A ` Tensor ` with the same type as ` value ` . <nl> + <nl> + # # # # # Raises : <nl> + <nl> + <nl> + * < b > ` ValueError ` < / b > : If input / output depth does not match ` filters ` ' shape , or if <nl> + padding is other than ` ' VALID ' ` or ` ' SAME ' ` , or if the ` rate ` is less <nl> + than one , or if the output_shape is not a tensor with 4 elements . <nl> + <nl> mmm a / tensorflow / g3doc / api_docs / python / index . md <nl> ppp b / tensorflow / g3doc / api_docs / python / index . md <nl> <nl> <nl> * * * [ Neural Network ] ( . . / . . / api_docs / python / nn . md ) * * : <nl> * [ ` atrous_conv2d ` ] ( . . / . . / api_docs / python / nn . md # atrous_conv2d ) <nl> + * [ ` atrous_conv2d_transpose ` ] ( . . / . . / api_docs / python / nn . md # atrous_conv2d_transpose ) <nl> * [ ` avg_pool ` ] ( . . / . . / api_docs / python / nn . md # avg_pool ) <nl> * [ ` avg_pool3d ` ] ( . . / . . / api_docs / python / nn . md # avg_pool3d ) <nl> * [ ` batch_norm_with_global_normalization ` ] ( . . / . . / api_docs / python / nn . md # batch_norm_with_global_normalization ) <nl> mmm a / tensorflow / g3doc / api_docs / python / nn . md <nl> ppp b / tensorflow / g3doc / api_docs / python / nn . md <nl> inputs are identical . <nl> padding is other than ` ' VALID ' ` or ` ' SAME ' ` . <nl> <nl> <nl> + - - - <nl> + <nl> + # # # ` tf . nn . atrous_conv2d_transpose ( value , filters , output_shape , rate , padding , name = None ) ` { # atrous_conv2d_transpose } <nl> + <nl> + The transpose of ` atrous_conv2d ` . <nl> + <nl> + This operation is sometimes called " deconvolution " after [ Deconvolutional <nl> + Networks ] ( http : / / www . matthewzeiler . com / pubs / cvpr2010 / cvpr2010 . pdf ) , but is <nl> + actually the transpose ( gradient ) of ` atrous_conv2d ` rather than an actual <nl> + deconvolution . <nl> + <nl> + # # # # # Args : <nl> + <nl> + <nl> + * < b > ` value ` < / b > : A 4 - D ` Tensor ` of type ` float ` . It needs to be in the default ` NHWC ` <nl> + format . Its shape is ` [ batch , in_height , in_width , in_channels ] ` . <nl> + * < b > ` filters ` < / b > : A 4 - D ` Tensor ` with the same type as ` value ` and shape <nl> + ` [ filter_height , filter_width , out_channels , in_channels ] ` . ` filters ` ' <nl> + ` in_channels ` dimension must match that of ` value ` . Atrous convolution is <nl> + equivalent to standard convolution with upsampled filters with effective <nl> + height ` filter_height + ( filter_height - 1 ) * ( rate - 1 ) ` and effective <nl> + width ` filter_width + ( filter_width - 1 ) * ( rate - 1 ) ` , produced by <nl> + inserting ` rate - 1 ` zeros along consecutive elements across the <nl> + ` filters ` ' spatial dimensions . <nl> + * < b > ` output_shape ` < / b > : A 1 - D ` Tensor ` of shape representing the output shape of the <nl> + deconvolution op . <nl> + * < b > ` rate ` < / b > : A positive int32 . The stride with which we sample input values across <nl> + the ` height ` and ` width ` dimensions . Equivalently , the rate by which we <nl> + upsample the filter values by inserting zeros across the ` height ` and <nl> + ` width ` dimensions . In the literature , the same parameter is sometimes <nl> + called ` input stride ` or ` dilation ` . <nl> + * < b > ` padding ` < / b > : A string , either ` ' VALID ' ` or ` ' SAME ' ` . The padding algorithm . <nl> + * < b > ` name ` < / b > : Optional name for the returned tensor . <nl> + <nl> + # # # # # Returns : <nl> + <nl> + A ` Tensor ` with the same type as ` value ` . <nl> + <nl> + # # # # # Raises : <nl> + <nl> + <nl> + * < b > ` ValueError ` < / b > : If input / output depth does not match ` filters ` ' shape , or if <nl> + padding is other than ` ' VALID ' ` or ` ' SAME ' ` , or if the ` rate ` is less <nl> + than one , or if the output_shape is not a tensor with 4 elements . <nl> + <nl> + <nl> - - - <nl> <nl> # # # ` tf . nn . conv2d_transpose ( value , filter , output_shape , strides , padding = ' SAME ' , data_format = ' NHWC ' , name = None ) ` { # conv2d_transpose } <nl> mmm a / tensorflow / g3doc / api_docs / python / tensor_array_ops . md <nl> ppp b / tensorflow / g3doc / api_docs / python / tensor_array_ops . md <nl> must all match . <nl> <nl> - - - <nl> <nl> - # # # # ` tf . TensorArray . pack ( name = None ) ` { # TensorArray . pack } <nl> + # # # # ` tf . TensorArray . pack ( * args , * * kwargs ) ` { # TensorArray . pack } <nl> <nl> - Return the values in the TensorArray as a packed ` Tensor ` . <nl> + Return the values in the TensorArray as a stacked ` Tensor ` . <nl> <nl> All of the values must have been written and their shapes must all match . <nl> + If input shapes have rank - ` R ` , then output shape will have rank - ` ( R + 1 ) ` . <nl> <nl> # # # # # Args : <nl> <nl> All of the values must have been written and their shapes must all match . <nl> <nl> # # # # # Returns : <nl> <nl> - All the tensors in the TensorArray packed into one tensor . <nl> + All the tensors in the TensorArray stacked into one tensor . <nl> <nl> <nl> - - - <nl> Scatter the values of a ` Tensor ` in specific indices of a ` TensorArray ` . <nl> <nl> - - - <nl> <nl> - # # # # ` tf . TensorArray . unpack ( value , name = None ) ` { # TensorArray . unpack } <nl> + # # # # ` tf . TensorArray . unpack ( * args , * * kwargs ) ` { # TensorArray . unpack } <nl> <nl> - Pack the values of a ` Tensor ` in the TensorArray . <nl> + Unstack the values of a ` Tensor ` in the TensorArray . <nl> + <nl> + If input value shapes have rank - ` R ` , then the output TensorArray will <nl> + contain elements whose shapes are rank - ` ( R - 1 ) ` . <nl> <nl> # # # # # Args : <nl> <nl> <nl> - * < b > ` value ` < / b > : ( N + 1 ) - D . Tensor of type ` dtype ` . The Tensor to unpack . <nl> + * < b > ` value ` < / b > : ( N + 1 ) - D . Tensor of type ` dtype ` . The Tensor to unstack . <nl> * < b > ` name ` < / b > : A name for the operation ( optional ) . <nl> <nl> # # # # # Returns : <nl> <nl> - A new TensorArray object with flow that ensures the unpack occurs . <nl> + A new TensorArray object with flow that ensures the unstack occurs . <nl> Use this object all for subsequent operations . <nl> <nl> # # # # # Raises : <nl> The data type of this TensorArray . <nl> Return the size of the TensorArray . <nl> <nl> <nl> + - - - <nl> + <nl> + # # # # ` tf . TensorArray . stack ( name = None ) ` { # TensorArray . stack } <nl> + <nl> + Return the values in the TensorArray as a stacked ` Tensor ` . <nl> + <nl> + All of the values must have been written and their shapes must all match . <nl> + If input shapes have rank - ` R ` , then output shape will have rank - ` ( R + 1 ) ` . <nl> + <nl> + # # # # # Args : <nl> + <nl> + <nl> + * < b > ` name ` < / b > : A name for the operation ( optional ) . <nl> + <nl> + # # # # # Returns : <nl> + <nl> + All the tensors in the TensorArray stacked into one tensor . <nl> + <nl> + <nl> + - - - <nl> + <nl> + # # # # ` tf . TensorArray . unstack ( value , name = None ) ` { # TensorArray . unstack } <nl> + <nl> + Unstack the values of a ` Tensor ` in the TensorArray . <nl> + <nl> + If input value shapes have rank - ` R ` , then the output TensorArray will <nl> + contain elements whose shapes are rank - ` ( R - 1 ) ` . <nl> + <nl> + # # # # # Args : <nl> + <nl> + <nl> + * < b > ` value ` < / b > : ( N + 1 ) - D . Tensor of type ` dtype ` . The Tensor to unstack . <nl> + * < b > ` name ` < / b > : A name for the operation ( optional ) . <nl> + <nl> + # # # # # Returns : <nl> + <nl> + A new TensorArray object with flow that ensures the unstack occurs . <nl> + Use this object all for subsequent operations . <nl> + <nl> + # # # # # Raises : <nl> + <nl> + <nl> + * < b > ` ValueError ` < / b > : if the shape inference fails . <nl> + <nl> + <nl> <nl> | Update generated Python Op docs . | tensorflow/tensorflow | 05ee548222df4dc3dcae1c8f9b30147bf3b3d271 | 2016-12-01T20:27:15Z |
mmm a / include / grpcpp / impl / codegen / call_op_set . h <nl> ppp b / include / grpcpp / impl / codegen / call_op_set . h <nl> class CallOpSendMessage { <nl> template < class M > <nl> Status SendMessage ( const M & message ) GRPC_MUST_USE_RESULT ; <nl> <nl> + / / / Send \ a message using \ a options for the write . The \ a options are cleared <nl> + / / / after use . This form of SendMessage allows gRPC to reference \ a message <nl> + / / / beyond the lifetime of SendMessage . <nl> + template < class M > <nl> + Status SendMessagePtr ( const M * message , <nl> + WriteOptions options ) GRPC_MUST_USE_RESULT ; <nl> + <nl> + / / / This form of SendMessage allows gRPC to reference \ a message beyond the <nl> + / / / lifetime of SendMessage . <nl> + template < class M > <nl> + Status SendMessagePtr ( const M * message ) GRPC_MUST_USE_RESULT ; <nl> + <nl> protected : <nl> void AddOp ( grpc_op * ops , size_t * nops ) { <nl> if ( ! send_buf_ . Valid ( ) | | hijacked_ ) return ; <nl> class CallOpSendMessage { <nl> if ( ! send_buf_ . Valid ( ) ) return ; <nl> interceptor_methods - > AddInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : PRE_SEND_MESSAGE ) ; <nl> - interceptor_methods - > SetSendMessage ( & send_buf_ ) ; <nl> + interceptor_methods - > SetSendMessage ( & send_buf_ , msg_ ) ; <nl> } <nl> <nl> void SetFinishInterceptionHookPoint ( <nl> InterceptorBatchMethodsImpl * interceptor_methods ) { <nl> / / The contents of the SendMessage value that was previously set <nl> / / has had its references stolen by core ' s operations <nl> - interceptor_methods - > SetSendMessage ( nullptr ) ; <nl> + interceptor_methods - > SetSendMessage ( nullptr , nullptr ) ; <nl> } <nl> <nl> void SetHijackingState ( InterceptorBatchMethodsImpl * interceptor_methods ) { <nl> class CallOpSendMessage { <nl> } <nl> <nl> private : <nl> + const void * msg_ = nullptr ; / / The original non - serialized message <nl> bool hijacked_ = false ; <nl> ByteBuffer send_buf_ ; <nl> WriteOptions write_options_ ; <nl> Status CallOpSendMessage : : SendMessage ( const M & message ) { <nl> return SendMessage ( message , WriteOptions ( ) ) ; <nl> } <nl> <nl> + template < class M > <nl> + Status CallOpSendMessage : : SendMessagePtr ( const M * message , <nl> + WriteOptions options ) { <nl> + msg_ = message ; <nl> + return SendMessage ( * message , options ) ; <nl> + } <nl> + <nl> + template < class M > <nl> + Status CallOpSendMessage : : SendMessagePtr ( const M * message ) { <nl> + msg_ = message ; <nl> + return SendMessage ( * message , WriteOptions ( ) ) ; <nl> + } <nl> + <nl> template < class R > <nl> class CallOpRecvMessage { <nl> public : <nl> mmm a / include / grpcpp / impl / codegen / client_callback . h <nl> ppp b / include / grpcpp / impl / codegen / client_callback . h <nl> class CallbackUnaryCallImpl { <nl> CallbackWithStatusTag ( call . call ( ) , on_completion , ops ) ; <nl> <nl> / / TODO ( vjpai ) : Unify code with sync API as much as possible <nl> - Status s = ops - > SendMessage ( * request ) ; <nl> + Status s = ops - > SendMessagePtr ( request ) ; <nl> if ( ! s . ok ( ) ) { <nl> tag - > force_run ( s ) ; <nl> return ; <nl> class ClientCallbackReaderWriterImpl <nl> start_corked_ = false ; <nl> } <nl> / / TODO ( vjpai ) : don ' t assert <nl> - GPR_CODEGEN_ASSERT ( write_ops_ . SendMessage ( * msg ) . ok ( ) ) ; <nl> + GPR_CODEGEN_ASSERT ( write_ops_ . SendMessagePtr ( msg ) . ok ( ) ) ; <nl> <nl> if ( options . is_last_message ( ) ) { <nl> options . set_buffer_hint ( ) ; <nl> class ClientCallbackReaderImpl <nl> : context_ ( context ) , call_ ( call ) , reactor_ ( reactor ) { <nl> this - > BindReactor ( reactor ) ; <nl> / / TODO ( vjpai ) : don ' t assert <nl> - GPR_CODEGEN_ASSERT ( start_ops_ . SendMessage ( * request ) . ok ( ) ) ; <nl> + GPR_CODEGEN_ASSERT ( start_ops_ . SendMessagePtr ( request ) . ok ( ) ) ; <nl> start_ops_ . ClientSendClose ( ) ; <nl> } <nl> <nl> class ClientCallbackWriterImpl <nl> start_corked_ = false ; <nl> } <nl> / / TODO ( vjpai ) : don ' t assert <nl> - GPR_CODEGEN_ASSERT ( write_ops_ . SendMessage ( * msg ) . ok ( ) ) ; <nl> + GPR_CODEGEN_ASSERT ( write_ops_ . SendMessagePtr ( msg ) . ok ( ) ) ; <nl> <nl> if ( options . is_last_message ( ) ) { <nl> options . set_buffer_hint ( ) ; <nl> mmm a / include / grpcpp / impl / codegen / client_unary_call . h <nl> ppp b / include / grpcpp / impl / codegen / client_unary_call . h <nl> class BlockingUnaryCallImpl { <nl> CallOpRecvInitialMetadata , CallOpRecvMessage < OutputMessage > , <nl> CallOpClientSendClose , CallOpClientRecvStatus > <nl> ops ; <nl> - status_ = ops . SendMessage ( request ) ; <nl> + status_ = ops . SendMessagePtr ( & request ) ; <nl> if ( ! status_ . ok ( ) ) { <nl> return ; <nl> } <nl> mmm a / include / grpcpp / impl / codegen / interceptor . h <nl> ppp b / include / grpcpp / impl / codegen / interceptor . h <nl> class InterceptorBatchMethods { <nl> / / / Returns a modifable ByteBuffer holding the serialized form of the message <nl> / / / that is going to be sent . Valid for PRE_SEND_MESSAGE interceptions . <nl> / / / A return value of nullptr indicates that this ByteBuffer is not valid . <nl> - virtual ByteBuffer * GetSendMessage ( ) = 0 ; <nl> + virtual ByteBuffer * GetSerializedSendMessage ( ) = 0 ; <nl> + <nl> + / / / Returns a non - modifiable pointer to the original non - serialized form of <nl> + / / / the message . Valid for PRE_SEND_MESSAGE interceptions . A return value of <nl> + / / / nullptr indicates that this field is not valid . Also note that this is <nl> + / / / only supported for sync and callback APIs at the present moment . <nl> + virtual const void * GetSendMessage ( ) = 0 ; <nl> <nl> / / / Returns a modifiable multimap of the initial metadata to be sent . Valid <nl> / / / for PRE_SEND_INITIAL_METADATA interceptions . A value of nullptr indicates <nl> mmm a / include / grpcpp / impl / codegen / interceptor_common . h <nl> ppp b / include / grpcpp / impl / codegen / interceptor_common . h <nl> class InterceptorBatchMethodsImpl <nl> hooks_ [ static_cast < size_t > ( type ) ] = true ; <nl> } <nl> <nl> - ByteBuffer * GetSendMessage ( ) override { return send_message_ ; } <nl> + ByteBuffer * GetSerializedSendMessage ( ) override { return send_message_ ; } <nl> + <nl> + const void * GetSendMessage ( ) override { return orig_send_message_ ; } <nl> <nl> std : : multimap < grpc : : string , grpc : : string > * GetSendInitialMetadata ( ) override { <nl> return send_initial_metadata_ ; <nl> class InterceptorBatchMethodsImpl <nl> return recv_trailing_metadata_ - > map ( ) ; <nl> } <nl> <nl> - void SetSendMessage ( ByteBuffer * buf ) { send_message_ = buf ; } <nl> + void SetSendMessage ( ByteBuffer * buf , const void * msg ) { <nl> + send_message_ = buf ; <nl> + orig_send_message_ = msg ; <nl> + } <nl> <nl> void SetSendInitialMetadata ( <nl> std : : multimap < grpc : : string , grpc : : string > * metadata ) { <nl> class InterceptorBatchMethodsImpl <nl> std : : function < void ( void ) > callback_ ; <nl> <nl> ByteBuffer * send_message_ = nullptr ; <nl> + const void * orig_send_message_ = nullptr ; <nl> <nl> std : : multimap < grpc : : string , grpc : : string > * send_initial_metadata_ ; <nl> <nl> class CancelInterceptorBatchMethods <nl> " Cancel notification " ) ; <nl> } <nl> <nl> - ByteBuffer * GetSendMessage ( ) override { <nl> + ByteBuffer * GetSerializedSendMessage ( ) override { <nl> GPR_CODEGEN_ASSERT ( false & & <nl> " It is illegal to call GetSendMessage on a method which " <nl> " has a Cancel notification " ) ; <nl> return nullptr ; <nl> } <nl> <nl> + const void * GetSendMessage ( ) override { <nl> + GPR_CODEGEN_ASSERT ( <nl> + false & & <nl> + " It is illegal to call GetOriginalSendMessage on a method which " <nl> + " has a Cancel notification " ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> std : : multimap < grpc : : string , grpc : : string > * GetSendInitialMetadata ( ) override { <nl> GPR_CODEGEN_ASSERT ( false & & <nl> " It is illegal to call GetSendInitialMetadata on a " <nl> mmm a / include / grpcpp / impl / codegen / method_handler_impl . h <nl> ppp b / include / grpcpp / impl / codegen / method_handler_impl . h <nl> class RpcMethodHandler : public MethodHandler { <nl> ops . set_compression_level ( param . server_context - > compression_level ( ) ) ; <nl> } <nl> if ( status . ok ( ) ) { <nl> - status = ops . SendMessage ( rsp ) ; <nl> + status = ops . SendMessagePtr ( & rsp ) ; <nl> } <nl> ops . ServerSendStatus ( & param . server_context - > trailing_metadata_ , status ) ; <nl> param . call - > PerformOps ( & ops ) ; <nl> class ClientStreamingHandler : public MethodHandler { <nl> } <nl> } <nl> if ( status . ok ( ) ) { <nl> - status = ops . SendMessage ( rsp ) ; <nl> + status = ops . SendMessagePtr ( & rsp ) ; <nl> } <nl> ops . ServerSendStatus ( & param . server_context - > trailing_metadata_ , status ) ; <nl> param . call - > PerformOps ( & ops ) ; <nl> mmm a / include / grpcpp / impl / codegen / server_callback . h <nl> ppp b / include / grpcpp / impl / codegen / server_callback . h <nl> class CallbackUnaryHandler : public MethodHandler { <nl> / / The response is dropped if the status is not OK . <nl> if ( s . ok ( ) ) { <nl> finish_ops_ . ServerSendStatus ( & ctx_ - > trailing_metadata_ , <nl> - finish_ops_ . SendMessage ( resp_ ) ) ; <nl> + finish_ops_ . SendMessagePtr ( & resp_ ) ) ; <nl> } else { <nl> finish_ops_ . ServerSendStatus ( & ctx_ - > trailing_metadata_ , s ) ; <nl> } <nl> class CallbackClientStreamingHandler : public MethodHandler { <nl> / / The response is dropped if the status is not OK . <nl> if ( s . ok ( ) ) { <nl> finish_ops_ . ServerSendStatus ( & ctx_ - > trailing_metadata_ , <nl> - finish_ops_ . SendMessage ( resp_ ) ) ; <nl> + finish_ops_ . SendMessagePtr ( & resp_ ) ) ; <nl> } else { <nl> finish_ops_ . ServerSendStatus ( & ctx_ - > trailing_metadata_ , s ) ; <nl> } <nl> class CallbackServerStreamingHandler : public MethodHandler { <nl> ctx_ - > sent_initial_metadata_ = true ; <nl> } <nl> / / TODO ( vjpai ) : don ' t assert <nl> - GPR_CODEGEN_ASSERT ( write_ops_ . SendMessage ( * resp , options ) . ok ( ) ) ; <nl> + GPR_CODEGEN_ASSERT ( write_ops_ . SendMessagePtr ( resp , options ) . ok ( ) ) ; <nl> call_ . PerformOps ( & write_ops_ ) ; <nl> } <nl> <nl> class CallbackServerStreamingHandler : public MethodHandler { <nl> / / Don ' t send any message if the status is bad <nl> if ( s . ok ( ) ) { <nl> / / TODO ( vjpai ) : don ' t assert <nl> - GPR_CODEGEN_ASSERT ( finish_ops_ . SendMessage ( * resp , options ) . ok ( ) ) ; <nl> + GPR_CODEGEN_ASSERT ( finish_ops_ . SendMessagePtr ( resp , options ) . ok ( ) ) ; <nl> } <nl> Finish ( std : : move ( s ) ) ; <nl> } <nl> class CallbackBidiHandler : public MethodHandler { <nl> ctx_ - > sent_initial_metadata_ = true ; <nl> } <nl> / / TODO ( vjpai ) : don ' t assert <nl> - GPR_CODEGEN_ASSERT ( write_ops_ . SendMessage ( * resp , options ) . ok ( ) ) ; <nl> + GPR_CODEGEN_ASSERT ( write_ops_ . SendMessagePtr ( resp , options ) . ok ( ) ) ; <nl> call_ . PerformOps ( & write_ops_ ) ; <nl> } <nl> <nl> class CallbackBidiHandler : public MethodHandler { <nl> / / Don ' t send any message if the status is bad <nl> if ( s . ok ( ) ) { <nl> / / TODO ( vjpai ) : don ' t assert <nl> - GPR_CODEGEN_ASSERT ( finish_ops_ . SendMessage ( * resp , options ) . ok ( ) ) ; <nl> + GPR_CODEGEN_ASSERT ( finish_ops_ . SendMessagePtr ( resp , options ) . ok ( ) ) ; <nl> } <nl> Finish ( std : : move ( s ) ) ; <nl> } <nl> mmm a / include / grpcpp / impl / codegen / sync_stream . h <nl> ppp b / include / grpcpp / impl / codegen / sync_stream . h <nl> class ClientReader final : public ClientReaderInterface < R > { <nl> ops . SendInitialMetadata ( & context - > send_initial_metadata_ , <nl> context - > initial_metadata_flags ( ) ) ; <nl> / / TODO ( ctiller ) : don ' t assert <nl> - GPR_CODEGEN_ASSERT ( ops . SendMessage ( request ) . ok ( ) ) ; <nl> + GPR_CODEGEN_ASSERT ( ops . SendMessagePtr ( & request ) . ok ( ) ) ; <nl> ops . ClientSendClose ( ) ; <nl> call_ . PerformOps ( & ops ) ; <nl> cq_ . Pluck ( & ops ) ; <nl> class ClientWriter : public ClientWriterInterface < W > { <nl> context_ - > initial_metadata_flags ( ) ) ; <nl> context_ - > set_initial_metadata_corked ( false ) ; <nl> } <nl> - if ( ! ops . SendMessage ( msg , options ) . ok ( ) ) { <nl> + if ( ! ops . SendMessagePtr ( & msg , options ) . ok ( ) ) { <nl> return false ; <nl> } <nl> <nl> class ClientReaderWriter final : public ClientReaderWriterInterface < W , R > { <nl> context_ - > initial_metadata_flags ( ) ) ; <nl> context_ - > set_initial_metadata_corked ( false ) ; <nl> } <nl> - if ( ! ops . SendMessage ( msg , options ) . ok ( ) ) { <nl> + if ( ! ops . SendMessagePtr ( & msg , options ) . ok ( ) ) { <nl> return false ; <nl> } <nl> <nl> class ServerWriter final : public ServerWriterInterface < W > { <nl> options . set_buffer_hint ( ) ; <nl> } <nl> <nl> - if ( ! ctx_ - > pending_ops_ . SendMessage ( msg , options ) . ok ( ) ) { <nl> + if ( ! ctx_ - > pending_ops_ . SendMessagePtr ( & msg , options ) . ok ( ) ) { <nl> return false ; <nl> } <nl> if ( ! ctx_ - > sent_initial_metadata_ ) { <nl> class ServerReaderWriterBody final { <nl> if ( options . is_last_message ( ) ) { <nl> options . set_buffer_hint ( ) ; <nl> } <nl> - if ( ! ctx_ - > pending_ops_ . SendMessage ( msg , options ) . ok ( ) ) { <nl> + if ( ! ctx_ - > pending_ops_ . SendMessagePtr ( & msg , options ) . ok ( ) ) { <nl> return false ; <nl> } <nl> if ( ! ctx_ - > sent_initial_metadata_ ) { <nl> mmm a / test / cpp / end2end / client_interceptors_end2end_test . cc <nl> ppp b / test / cpp / end2end / client_interceptors_end2end_test . cc <nl> class HijackingInterceptor : public experimental : : Interceptor { <nl> if ( methods - > QueryInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : PRE_SEND_MESSAGE ) ) { <nl> EchoRequest req ; <nl> - auto * buffer = methods - > GetSendMessage ( ) ; <nl> + auto * buffer = methods - > GetSerializedSendMessage ( ) ; <nl> auto copied_buffer = * buffer ; <nl> EXPECT_TRUE ( <nl> SerializationTraits < EchoRequest > : : Deserialize ( & copied_buffer , & req ) <nl> class HijackingInterceptorMakesAnotherCall : public experimental : : Interceptor { <nl> if ( methods - > QueryInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : PRE_SEND_MESSAGE ) ) { <nl> EchoRequest req ; <nl> - auto * buffer = methods - > GetSendMessage ( ) ; <nl> + auto * buffer = methods - > GetSerializedSendMessage ( ) ; <nl> auto copied_buffer = * buffer ; <nl> EXPECT_TRUE ( <nl> SerializationTraits < EchoRequest > : : Deserialize ( & copied_buffer , & req ) <nl> class LoggingInterceptor : public experimental : : Interceptor { <nl> if ( methods - > QueryInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : PRE_SEND_MESSAGE ) ) { <nl> EchoRequest req ; <nl> - auto * buffer = methods - > GetSendMessage ( ) ; <nl> + auto * buffer = methods - > GetSerializedSendMessage ( ) ; <nl> auto copied_buffer = * buffer ; <nl> EXPECT_TRUE ( <nl> SerializationTraits < EchoRequest > : : Deserialize ( & copied_buffer , & req ) <nl> . ok ( ) ) ; <nl> - EXPECT_TRUE ( req . message ( ) . find ( " Hello " ) = = 0 ) ; <nl> + EXPECT_TRUE ( req . message ( ) . find ( " Hello " ) = = 0u ) ; <nl> + EXPECT_EQ ( static_cast < const EchoRequest * > ( methods - > GetSendMessage ( ) ) <nl> + - > message ( ) <nl> + . find ( " Hello " ) , <nl> + 0u ) ; <nl> } <nl> if ( methods - > QueryInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : PRE_SEND_CLOSE ) ) { <nl> class LoggingInterceptor : public experimental : : Interceptor { <nl> experimental : : InterceptionHookPoints : : POST_RECV_MESSAGE ) ) { <nl> EchoResponse * resp = <nl> static_cast < EchoResponse * > ( methods - > GetRecvMessage ( ) ) ; <nl> - EXPECT_TRUE ( resp - > message ( ) . find ( " Hello " ) = = 0 ) ; <nl> + EXPECT_TRUE ( resp - > message ( ) . find ( " Hello " ) = = 0u ) ; <nl> } <nl> if ( methods - > QueryInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : POST_RECV_STATUS ) ) { <nl> mmm a / test / cpp / end2end / server_interceptors_end2end_test . cc <nl> ppp b / test / cpp / end2end / server_interceptors_end2end_test . cc <nl> class LoggingInterceptor : public experimental : : Interceptor { <nl> type = = experimental : : ServerRpcInfo : : Type : : BIDI_STREAMING ) ) ; <nl> } <nl> <nl> - virtual void Intercept ( experimental : : InterceptorBatchMethods * methods ) { <nl> + void Intercept ( experimental : : InterceptorBatchMethods * methods ) override { <nl> if ( methods - > QueryInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : PRE_SEND_INITIAL_METADATA ) ) { <nl> auto * map = methods - > GetSendInitialMetadata ( ) ; <nl> class LoggingInterceptor : public experimental : : Interceptor { <nl> if ( methods - > QueryInterceptionHookPoint ( <nl> experimental : : InterceptionHookPoints : : PRE_SEND_MESSAGE ) ) { <nl> EchoRequest req ; <nl> - auto * buffer = methods - > GetSendMessage ( ) ; <nl> + auto * buffer = methods - > GetSerializedSendMessage ( ) ; <nl> auto copied_buffer = * buffer ; <nl> EXPECT_TRUE ( <nl> SerializationTraits < EchoRequest > : : Deserialize ( & copied_buffer , & req ) <nl> class LoggingInterceptorFactory <nl> } <nl> } ; <nl> <nl> + / / Test if GetSendMessage works as expected <nl> + class GetSendMessageTester : public experimental : : Interceptor { <nl> + public : <nl> + GetSendMessageTester ( experimental : : ServerRpcInfo * info ) { } <nl> + <nl> + void Intercept ( experimental : : InterceptorBatchMethods * methods ) override { <nl> + if ( methods - > QueryInterceptionHookPoint ( <nl> + experimental : : InterceptionHookPoints : : PRE_SEND_MESSAGE ) ) { <nl> + EXPECT_EQ ( static_cast < const EchoRequest * > ( methods - > GetSendMessage ( ) ) <nl> + - > message ( ) <nl> + . find ( " Hello " ) , <nl> + 0u ) ; <nl> + } <nl> + methods - > Proceed ( ) ; <nl> + } <nl> + } ; <nl> + <nl> + class GetSendMessageTesterFactory <nl> + : public experimental : : ServerInterceptorFactoryInterface { <nl> + public : <nl> + virtual experimental : : Interceptor * CreateServerInterceptor ( <nl> + experimental : : ServerRpcInfo * info ) override { <nl> + return new GetSendMessageTester ( info ) ; <nl> + } <nl> + } ; <nl> + <nl> void MakeBidiStreamingCall ( const std : : shared_ptr < Channel > & channel ) { <nl> auto stub = grpc : : testing : : EchoTestService : : NewStub ( channel ) ; <nl> ClientContext ctx ; <nl> class ServerInterceptorsEnd2endSyncUnaryTest : public : : testing : : Test { <nl> creators . push_back ( <nl> std : : unique_ptr < experimental : : ServerInterceptorFactoryInterface > ( <nl> new LoggingInterceptorFactory ( ) ) ) ; <nl> + creators . push_back ( <nl> + std : : unique_ptr < experimental : : ServerInterceptorFactoryInterface > ( <nl> + new GetSendMessageTesterFactory ( ) ) ) ; <nl> / / Add 20 dummy interceptor factories and null interceptor factories <nl> for ( auto i = 0 ; i < 20 ; i + + ) { <nl> creators . push_back ( std : : unique_ptr < DummyInterceptorFactory > ( <nl> class ServerInterceptorsEnd2endSyncStreamingTest : public : : testing : : Test { <nl> creators . push_back ( <nl> std : : unique_ptr < experimental : : ServerInterceptorFactoryInterface > ( <nl> new LoggingInterceptorFactory ( ) ) ) ; <nl> + creators . push_back ( <nl> + std : : unique_ptr < experimental : : ServerInterceptorFactoryInterface > ( <nl> + new GetSendMessageTesterFactory ( ) ) ) ; <nl> for ( auto i = 0 ; i < 20 ; i + + ) { <nl> creators . push_back ( std : : unique_ptr < DummyInterceptorFactory > ( <nl> new DummyInterceptorFactory ( ) ) ) ; <nl> | Merge pull request from yashykt / nocopyinterception | grpc/grpc | 2dda0bb21bbe6e0914cd12fbf3ffa013111cc8a3 | 2019-01-03T23:01:35Z |
similarity index 100 % <nl> rename from contrib / boost - win32 . yml <nl> rename to contrib / gitian - descriptors / boost - win32 . yml <nl> similarity index 100 % <nl> rename from contrib / gitian - win32 . yml <nl> rename to contrib / gitian - descriptors / gitian - win32 . yml <nl> similarity index 100 % <nl> rename from contrib / gitian . yml <nl> rename to contrib / gitian - descriptors / gitian . yml <nl> similarity index 100 % <nl> rename from contrib / wxwidgets - win32 . yml <nl> rename to contrib / gitian - descriptors / wxwidgets - win32 . yml <nl> similarity index 100 % <nl> rename from contrib / wxwidgets . yml <nl> rename to contrib / gitian - descriptors / wxwidgets . yml <nl> new file mode 100644 <nl> index 000000000000 . . d21bb07808b2 <nl> mmm / dev / null <nl> ppp b / contrib / gitian - downloader / bitcoin - download - config <nl> <nl> + mmm <nl> + name : bitcoin <nl> + urls : <nl> + - http : / / bitcoin . org / bitcoin - latest - linux - gitian . zip <nl> + rss : <nl> + - url : http : / / sourceforge . net / api / file / index / project - id / 244765 / mtime / desc / limit / 100 / rss <nl> + xpath : / / item / link / text ( ) <nl> + pattern : bitcoin - \ d + . \ d + . \ d + - linux - gitian . zip <nl> + signers : <nl> + 0A82509767C7D4A5D14DA2301AE1D35043E08E54 : <nl> + weight : 40 <nl> + name : BlueMatt <nl> + key : bluematt <nl> + BF6273FAEF7CC0BA1F562E50989F6B3048A116B5 : <nl> + weight : 40 <nl> + name : Devrandom <nl> + key : devrandom <nl> + D762373D24904A3E42F33B08B9A408E71DAAC974 : <nl> + weight : 40 <nl> + name : Sipa <nl> + key : sipa <nl> + 77E72E69DA7EE0A148C06B21B34821D4944DE5F7 : <nl> + weight : 40 <nl> + name : tcatm <nl> + key : tcatm <nl> + 01CDF4627A3B88AAE4A571C87588242FBE38D3A8 : <nl> + weight : 40 <nl> + name : " Gavin Andresen " <nl> + key : gavinandresen <nl> + minimum_weight : 120 <nl> new file mode 100644 <nl> index 000000000000 . . fb6d9eb28423 <nl> Binary files / dev / null and b / contrib / gitian - downloader / bluematt - key . pgp differ <nl> new file mode 100644 <nl> index 000000000000 . . 71898127ba0d <nl> Binary files / dev / null and b / contrib / gitian - downloader / devrandom - key . pgp differ <nl> new file mode 100644 <nl> index 000000000000 . . f81f44e87470 <nl> Binary files / dev / null and b / contrib / gitian - downloader / gavinandresen - key . pgp differ <nl> new file mode 100644 <nl> index 000000000000 . . 086c9eb42e4a <nl> Binary files / dev / null and b / contrib / gitian - downloader / sipa - key . pgp differ <nl> new file mode 100644 <nl> index 000000000000 . . baaec76b8c65 <nl> Binary files / dev / null and b / contrib / gitian - downloader / tcatm - key . pgp differ <nl> | Merge pull request from TheBlueMatt / gitian - downloader | bitcoin/bitcoin | c7eb151ad0ed441d6fd598551059a9bbfb09e99e | 2011-09-22T20:54:42Z |
mmm a / tensorflow / compiler / xla / shape_layout . cc <nl> ppp b / tensorflow / compiler / xla / shape_layout . cc <nl> void ShapeLayout : : ResetLayout ( const Layout & layout ) { <nl> TF_CHECK_OK ( ShapeUtil : : ValidateShape ( shape_ ) ) ; <nl> } <nl> <nl> + void ShapeLayout : : ResetLayout ( const Layout & layout , <nl> + ShapeIndexView shape_index ) { <nl> + CHECK ( ShapeUtil : : IsTuple ( shape_ ) ) ; <nl> + * ShapeUtil : : GetMutableSubshape ( & shape_ , shape_index ) - > mutable_layout ( ) = <nl> + layout ; <nl> + TF_CHECK_OK ( ShapeUtil : : ValidateShape ( shape_ ) ) ; <nl> + } <nl> + <nl> bool ShapeLayout : : operator = = ( const ShapeLayout & other ) const { <nl> return ShapeUtil : : Equal ( shape_ , other . shape_ ) ; <nl> } <nl> mmm a / tensorflow / compiler / xla / shape_layout . h <nl> ppp b / tensorflow / compiler / xla / shape_layout . h <nl> class ShapeLayout { <nl> / / tuple . <nl> void ResetLayout ( const Layout & layout ) ; <nl> <nl> + / / Resets the layout on the shape at the provided ShapeIndex to the provided <nl> + / / layout . Shape must be a tuple . <nl> + void ResetLayout ( const Layout & layout , ShapeIndexView shape_index ) ; <nl> + <nl> / / Returns a string representation of this object . <nl> string ToString ( ) const { return ShapeUtil : : HumanStringWithLayout ( shape_ ) ; } <nl> <nl> mmm a / tensorflow / compiler / xla / tests / hlo_test_base . h <nl> ppp b / tensorflow / compiler / xla / tests / hlo_test_base . h <nl> class HloTestBase : public : : testing : : Test { <nl> - > ResetLayout ( layout ) ; <nl> } <nl> <nl> + void ForceResultLayout ( HloModule * module , const Layout & layout , <nl> + ShapeIndexView shape_index ) { <nl> + module - > mutable_entry_computation_layout ( ) <nl> + - > mutable_result_layout ( ) <nl> + - > ResetLayout ( layout , shape_index ) ; <nl> + } <nl> + <nl> / / Convenience method to clear the layout of the computation result in <nl> / / ' module ' . <nl> void ForceClearResultLayout ( HloModule * module ) { <nl> | [ XLA ] Enable tests to force result layouts for tuple results . | tensorflow/tensorflow | f71040900c8512116f38b5b727f91c9e0f4e14e4 | 2018-07-11T20:46:43Z |
mmm a / src / shell . js <nl> ppp b / src / shell . js <nl> <nl> try { <nl> this [ ' Module ' ] = Module ; <nl> + Module . test ; <nl> } catch ( e ) { <nl> this [ ' Module ' ] = Module = { } ; <nl> } <nl> mmm a / tests / runner . py <nl> ppp b / tests / runner . py <nl> def test_add_function ( self ) : <nl> Settings . ALIASING_FUNCTION_POINTERS = 1 - Settings . ALIASING_FUNCTION_POINTERS # flip the test <nl> self . do_run ( src , ' ' ' Hello 7 from JS ! ' ' ' ) <nl> <nl> + def test_embind ( self ) : <nl> + if self . emcc_args is None : return self . skip ( ' requires emcc ' ) <nl> + Building . COMPILER_TEST_OPTS + = [ ' - - bind ' ] <nl> + <nl> + src = r ' ' ' <nl> + # include < stdio . h > <nl> + # include < emscripten / val . h > <nl> + <nl> + using namespace emscripten ; <nl> + <nl> + int main ( ) { <nl> + val Math = val : : global ( " Math " ) ; <nl> + printf ( " abs ( - 10 ) : % d \ n " , Math . call < int > ( " abs " , - 10 ) ) ; <nl> + return 0 ; <nl> + } <nl> + ' ' ' <nl> + self . do_run ( src , ' abs ( - 10 ) : 10 ' ) ; <nl> + <nl> def test_scriptaclass ( self ) : <nl> if self . emcc_args is None : return self . skip ( ' requires emcc ' ) <nl> <nl> | additional embind testing | emscripten-core/emscripten | ba658e862ef48eae7adc40f1fbcccf47f0530e5d | 2013-05-25T16:52:18Z |
mmm a / src / Interpreters / PartLog . cpp <nl> ppp b / src / Interpreters / PartLog . cpp <nl> <nl> # include < Interpreters / PartLog . h > <nl> # include < Interpreters / Context . h > <nl> <nl> + # include < Common / CurrentThread . h > <nl> <nl> namespace DB <nl> { <nl> Block PartLogElement : : createBlock ( ) <nl> <nl> return <nl> { <nl> + { ColumnString : : create ( ) , std : : make_shared < DataTypeString > ( ) , " query_id " } , <nl> { ColumnInt8 : : create ( ) , std : : move ( event_type_datatype ) , " event_type " } , <nl> { ColumnUInt16 : : create ( ) , std : : make_shared < DataTypeDate > ( ) , " event_date " } , <nl> { ColumnUInt32 : : create ( ) , std : : make_shared < DataTypeDateTime > ( ) , " event_time " } , <nl> void PartLogElement : : appendToBlock ( MutableColumns & columns ) const <nl> { <nl> size_t i = 0 ; <nl> <nl> + columns [ i + + ] - > insert ( query_id ) ; <nl> columns [ i + + ] - > insert ( event_type ) ; <nl> columns [ i + + ] - > insert ( DateLUT : : instance ( ) . toDayNum ( event_time ) ) ; <nl> columns [ i + + ] - > insert ( event_time ) ; <nl> bool PartLog : : addNewParts ( Context & current_context , const PartLog : : MutableDataP <nl> if ( ! part_log ) <nl> return false ; <nl> <nl> + auto query_id = CurrentThread : : getQueryId ( ) ; <nl> + <nl> for ( const auto & part : parts ) <nl> { <nl> PartLogElement elem ; <nl> <nl> + if ( query_id . data & & query_id . size ) <nl> + elem . query_id . insert ( 0 , query_id . data , query_id . size ) ; <nl> + <nl> elem . event_type = PartLogElement : : NEW_PART ; <nl> elem . event_time = time ( nullptr ) ; <nl> elem . duration_ms = elapsed_ns / 1000000 ; <nl> mmm a / src / Interpreters / PartLog . h <nl> ppp b / src / Interpreters / PartLog . h <nl> struct PartLogElement <nl> MOVE_PART = 6 , <nl> } ; <nl> <nl> + String query_id ; <nl> + <nl> Type event_type = NEW_PART ; <nl> <nl> time_t event_time = 0 ; <nl> | add query_id column to system . part_log | ClickHouse/ClickHouse | 4c2295e69cf6adee7a7b361f9f3e3faefdad1cd9 | 2020-12-31T02:30:13Z |
mmm a / source / common / protobuf / utility . h <nl> ppp b / source / common / protobuf / utility . h <nl> class RepeatedPtrUtil { <nl> } <nl> <nl> / * * <nl> - * Converts a proto repeated field into a generic vector of const Protobuf : : Message unique_ptr ' s . <nl> + * Converts a proto repeated field into a container of const Protobuf : : Message unique_ptr ' s . <nl> * <nl> * @ param repeated_field the proto repeated field to convert . <nl> - * @ return ProtobufType : : ConstMessagePtrVector the vector of const Message pointers . <nl> + * @ return ReturnType the container of const Message pointers . <nl> * / <nl> - template < typename ProtoType > <nl> - static ProtobufTypes : : ConstMessagePtrVector <nl> - convertToConstMessagePtrVector ( const Protobuf : : RepeatedPtrField < ProtoType > & repeated_field ) { <nl> - ProtobufTypes : : ConstMessagePtrVector ret_vector ; <nl> - std : : transform ( repeated_field . begin ( ) , repeated_field . end ( ) , std : : back_inserter ( ret_vector ) , <nl> + template < typename ProtoType , typename ReturnType > <nl> + static ReturnType <nl> + convertToConstMessagePtrContainer ( const Protobuf : : RepeatedPtrField < ProtoType > & repeated_field ) { <nl> + ReturnType ret_container ; <nl> + std : : transform ( repeated_field . begin ( ) , repeated_field . end ( ) , std : : back_inserter ( ret_container ) , <nl> [ ] ( const ProtoType & proto_message ) - > std : : unique_ptr < const Protobuf : : Message > { <nl> Protobuf : : Message * clone = proto_message . New ( ) ; <nl> clone - > MergeFrom ( proto_message ) ; <nl> return std : : unique_ptr < const Protobuf : : Message > ( clone ) ; <nl> } ) ; <nl> - return ret_vector ; <nl> + return ret_container ; <nl> } <nl> } ; <nl> <nl> mmm a / source / common / router / scoped_rds . cc <nl> ppp b / source / common / router / scoped_rds . cc <nl> create ( const envoy : : config : : filter : : network : : http_connection_manager : : v2 : : HttpCo <nl> ScopedRouteConfigurationsList & scoped_route_list = <nl> config . scoped_routes ( ) . scoped_route_configurations_list ( ) ; <nl> return scoped_routes_config_provider_manager . createStaticConfigProvider ( <nl> - RepeatedPtrUtil : : convertToConstMessagePtrVector ( <nl> + RepeatedPtrUtil : : convertToConstMessagePtrContainer < envoy : : api : : v2 : : ScopedRouteConfiguration , <nl> + ProtobufTypes : : ConstMessagePtrVector > ( <nl> scoped_route_list . scoped_route_configurations ( ) ) , <nl> factory_context , <nl> ScopedRoutesConfigProviderManagerOptArg ( config . scoped_routes ( ) . name ( ) , <nl> mmm a / test / integration / load_stats_integration_test . cc <nl> ppp b / test / integration / load_stats_integration_test . cc <nl> class LoadStatsIntegrationTest : public testing : : TestWithParam < Network : : Address : <nl> upstream_locality_stats - > set_total_successful_requests ( <nl> upstream_locality_stats - > total_successful_requests ( ) + <nl> local_upstream_locality_stats . total_successful_requests ( ) ) ; <nl> - upstream_locality_stats - > set_total_requests_in_progress ( <nl> - upstream_locality_stats - > total_requests_in_progress ( ) + <nl> - local_upstream_locality_stats . total_requests_in_progress ( ) ) ; <nl> upstream_locality_stats - > set_total_error_requests ( <nl> upstream_locality_stats - > total_error_requests ( ) + <nl> local_upstream_locality_stats . total_error_requests ( ) ) ; <nl> upstream_locality_stats - > set_total_issued_requests ( <nl> upstream_locality_stats - > total_issued_requests ( ) + <nl> local_upstream_locality_stats . total_issued_requests ( ) ) ; <nl> + / / Unlike most stats , current requests in progress replaces old requests in progress . <nl> break ; <nl> } <nl> } <nl> class LoadStatsIntegrationTest : public testing : : TestWithParam < Network : : Address : <nl> upstream_locality_stats - > CopyFrom ( local_upstream_locality_stats ) ; <nl> } <nl> } <nl> + <nl> + / / Unfortunately because we don ' t issue an update when total_requests_in_progress goes from <nl> + / / non - zero to zero , we have to go through and zero it out for any locality stats we didn ' t see . <nl> + for ( int i = 0 ; i < cluster_stats - > upstream_locality_stats_size ( ) ; + + i ) { <nl> + auto upstream_locality_stats = cluster_stats - > mutable_upstream_locality_stats ( i ) ; <nl> + bool found = false ; <nl> + for ( int j = 0 ; j < local_cluster_stats . upstream_locality_stats_size ( ) ; + + j ) { <nl> + auto & local_upstream_locality_stats = local_cluster_stats . upstream_locality_stats ( j ) ; <nl> + if ( TestUtility : : protoEqual ( upstream_locality_stats - > locality ( ) , <nl> + local_upstream_locality_stats . locality ( ) ) & & <nl> + upstream_locality_stats - > priority ( ) = = local_upstream_locality_stats . priority ( ) ) { <nl> + found = true ; <nl> + break ; <nl> + } <nl> + } <nl> + if ( ! found ) { <nl> + upstream_locality_stats - > set_total_requests_in_progress ( 0 ) ; <nl> + } <nl> + } <nl> } <nl> <nl> void waitForLoadStatsRequest ( <nl> class LoadStatsIntegrationTest : public testing : : TestWithParam < Network : : Address : <nl> EXPECT_EQ ( " application / grpc " , <nl> loadstats_stream_ - > headers ( ) . ContentType ( ) - > value ( ) . getStringView ( ) ) ; <nl> } while ( ! TestUtility : : assertRepeatedPtrFieldEqual ( expected_cluster_stats , <nl> - loadstats_request . cluster_stats ( ) ) ) ; <nl> + loadstats_request . cluster_stats ( ) , true ) ) ; <nl> } <nl> <nl> void waitForUpstreamResponse ( uint32_t endpoint_index , uint32_t response_code = 200 ) { <nl> TEST_P ( LoadStatsIntegrationTest , LocalityWeighted ) { <nl> locality_weighted_lb_ = true ; <nl> initialize ( ) ; <nl> <nl> - / / Debug logs for # 6874 <nl> - std : : cerr < < " Waiting for load stats stream . " < < std : : endl ; <nl> waitForLoadStatsStream ( ) ; <nl> - std : : cerr < < " Waiting for load stats request . " < < std : : endl ; <nl> waitForLoadStatsRequest ( { } ) ; <nl> <nl> - std : : cerr < < " Done waiting . " < < std : : endl ; <nl> loadstats_stream_ - > startGrpcStream ( ) ; <nl> - std : : cerr < < " Starting response . " < < std : : endl ; <nl> requestLoadStatsResponse ( { " cluster_0 " } ) ; <nl> - std : : cerr < < " Updating assignments . " < < std : : endl ; <nl> <nl> / / Simple 33 % / 67 % split between dragon / winter localities . <nl> / / Even though there are more endpoints in the dragon locality , the winter locality gets the <nl> / / expected weighting in the WRR locality schedule . <nl> updateClusterLoadAssignment ( { { 0 } , 2 } , { { 1 , 2 } , 1 } , { } , { } ) ; <nl> - std : : cerr < < " Sending traffic . " < < std : : endl ; <nl> <nl> sendAndReceiveUpstream ( 0 ) ; <nl> sendAndReceiveUpstream ( 1 ) ; <nl> TEST_P ( LoadStatsIntegrationTest , LocalityWeighted ) { <nl> sendAndReceiveUpstream ( 0 ) ; <nl> <nl> / / Verify we get the expect request distribution . <nl> - std : : cerr < < " Waiting for load stats request 2 . " < < std : : endl ; <nl> waitForLoadStatsRequest ( <nl> { localityStats ( " winter " , 4 , 0 , 0 , 4 ) , localityStats ( " dragon " , 2 , 0 , 0 , 2 ) } ) ; <nl> - std : : cerr < < " Done waiting . " < < std : : endl ; <nl> <nl> EXPECT_EQ ( 1 , test_server_ - > counter ( " load_reporter . requests " ) - > value ( ) ) ; <nl> / / On slow machines , more than one load stats response may be pushed while we are simulating load . <nl> mmm a / test / test_common / utility . h <nl> ppp b / test / test_common / utility . h <nl> class TestUtility { <nl> * <nl> * @ param lhs RepeatedPtrField on LHS . <nl> * @ param rhs RepeatedPtrField on RHS . <nl> + * @ param ignore_ordering if ordering should be ignored . Note if true this turns <nl> + * comparison into an N ^ 2 operation . <nl> * @ return bool indicating whether the RepeatedPtrField are equal . TestUtility : : protoEqual ( ) is <nl> * used for individual element testing . <nl> * / <nl> - template < class ProtoType > <nl> + template < typename ProtoType > <nl> static bool repeatedPtrFieldEqual ( const Protobuf : : RepeatedPtrField < ProtoType > & lhs , <nl> - const Protobuf : : RepeatedPtrField < ProtoType > & rhs ) { <nl> + const Protobuf : : RepeatedPtrField < ProtoType > & rhs , <nl> + bool ignore_ordering = false ) { <nl> if ( lhs . size ( ) ! = rhs . size ( ) ) { <nl> return false ; <nl> } <nl> <nl> - for ( int i = 0 ; i < lhs . size ( ) ; + + i ) { <nl> - if ( ! TestUtility : : protoEqual ( lhs [ i ] , rhs [ i ] , / * ignore_repeated_field_ordering = * / false ) ) { <nl> + if ( ! ignore_ordering ) { <nl> + for ( int i = 0 ; i < lhs . size ( ) ; + + i ) { <nl> + if ( ! TestUtility : : protoEqual ( lhs [ i ] , rhs [ i ] , / * ignore_ordering = * / false ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + typedef std : : list < std : : unique_ptr < const Protobuf : : Message > > ProtoList ; <nl> + / / Iterate through using protoEqual as ignore_ordering is true , and fields <nl> + / / in the sub - protos may also be out of order . <nl> + ProtoList lhs_list = <nl> + RepeatedPtrUtil : : convertToConstMessagePtrContainer < ProtoType , ProtoList > ( lhs ) ; <nl> + ProtoList rhs_list = <nl> + RepeatedPtrUtil : : convertToConstMessagePtrContainer < ProtoType , ProtoList > ( rhs ) ; <nl> + while ( ! lhs_list . empty ( ) ) { <nl> + bool found = false ; <nl> + for ( auto it = rhs_list . begin ( ) ; it ! = rhs_list . end ( ) ; + + it ) { <nl> + if ( TestUtility : : protoEqual ( * lhs_list . front ( ) , * * it , <nl> + / * ignore_ordering = * / true ) ) { <nl> + lhs_list . pop_front ( ) ; <nl> + rhs_list . erase ( it ) ; <nl> + found = true ; <nl> + break ; <nl> + } <nl> + } <nl> + if ( ! found ) { <nl> return false ; <nl> } <nl> } <nl> - <nl> return true ; <nl> } <nl> <nl> template < class ProtoType > <nl> static AssertionResult <nl> assertRepeatedPtrFieldEqual ( const Protobuf : : RepeatedPtrField < ProtoType > & lhs , <nl> - const Protobuf : : RepeatedPtrField < ProtoType > & rhs ) { <nl> - if ( ! repeatedPtrFieldEqual ( lhs , rhs ) ) { <nl> + const Protobuf : : RepeatedPtrField < ProtoType > & rhs , <nl> + bool ignore_ordering = false ) { <nl> + if ( ! repeatedPtrFieldEqual ( lhs , rhs , ignore_ordering ) ) { <nl> return AssertionFailure ( ) < < RepeatedPtrUtil : : debugString ( lhs ) < < " does not match " <nl> < < RepeatedPtrUtil : : debugString ( rhs ) ; <nl> } <nl> | test : deflaking * / LoadStatsIntegrationTest . LocalityWeighted / * ( ) | envoyproxy/envoy | b166f11f3710e9084d95436365ba61e8947ece4d | 2019-06-19T18:36:45Z |
mmm a / ports / grpc / CONTROL <nl> ppp b / ports / grpc / CONTROL <nl> <nl> Source : grpc <nl> Version : 1 . 32 . 0 <nl> + Port - Version : 1 <nl> Build - Depends : zlib , openssl , protobuf , c - ares ( ! uwp ) , upb , abseil , re2 <nl> Homepage : https : / / github . com / grpc / grpc <nl> Description : An RPC library and framework <nl> <nl> Feature : absl - sync <nl> - Description : Use abseil synchronization module <nl> \ No newline at end of file <nl> + Description : Use abseil synchronization module <nl> mmm a / ports / grpc / portfile . cmake <nl> ppp b / ports / grpc / portfile . cmake <nl> vcpkg_from_github ( <nl> snprintf . patch <nl> ) <nl> <nl> - if ( VCPKG_TARGET_IS_UWP OR VCPKG_TARGET_ARCHITECTURE STREQUAL " arm " OR VCPKG_TARGET_ARCHITECTURE STREQUAL " arm64 " ) <nl> + if ( ( NOT VCPKG_TARGET_IS_LINUX ) AND ( VCPKG_TARGET_IS_UWP OR VCPKG_TARGET_ARCHITECTURE STREQUAL " arm " OR VCPKG_TARGET_ARCHITECTURE STREQUAL " arm64 " ) ) <nl> set ( gRPC_BUILD_CODEGEN OFF ) <nl> else ( ) <nl> set ( gRPC_BUILD_CODEGEN ON ) <nl> file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / debug / include ) <nl> <nl> vcpkg_copy_pdbs ( ) <nl> <nl> - file ( INSTALL $ { SOURCE_PATH } / LICENSE DESTINATION $ { CURRENT_PACKAGES_DIR } / share / $ { PORT } RENAME copyright ) <nl> \ No newline at end of file <nl> + file ( INSTALL $ { SOURCE_PATH } / LICENSE DESTINATION $ { CURRENT_PACKAGES_DIR } / share / $ { PORT } RENAME copyright ) <nl> | [ grpc ] [ arm - linux ] Missing grpc plugins . ( ) | microsoft/vcpkg | 45149130088dc1ff5a3476e714b814f37933b63d | 2020-10-27T07:50:56Z |
deleted file mode 100644 <nl> index e6f2ad94e29 . . 00000000000 <nl> mmm a / example / notebooks / alexnet . ipynb <nl> ppp / dev / null <nl> <nl> - { <nl> - " cells " : [ <nl> - { <nl> - " cell_type " : " markdown " , <nl> - " metadata " : { } , <nl> - " source " : [ <nl> - " Basic AlexNet Example \ n " , <nl> - " mmmmmm - - \ n " , <nl> - " \ n " , <nl> - " This notebook shows how to use MXNet construct AlexNet . AlexNet is made by Alex Krizhevsky in 2012 . \ n " , <nl> - " \ n " , <nl> - " We will show how to train AlexNet in Python with single / multi GPU . All you need is to write a piece of Python code to describe network , then MXNet will help you finish all work without any of your effort . \ n " , <nl> - " \ n " , <nl> - " Notice : This notebook is a basic demo to show MXNet flavor . To train a full state - of - art network , please refer our ` ` ` Inception ` ` ` example . \ n " , <nl> - " \ n " , <nl> - " Generally , we need \ n " , <nl> - " \ n " , <nl> - " - Declare symbol network \ n " , <nl> - " - Declare data iterator \ n " , <nl> - " - Bind symbol network to device to model \ n " , <nl> - " - Fit the model " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : 1 , <nl> - " metadata " : { <nl> - " collapsed " : false <nl> - } , <nl> - " outputs " : [ ] , <nl> - " source " : [ <nl> - " import mxnet as mx " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " markdown " , <nl> - " metadata " : { } , <nl> - " source " : [ <nl> - " Now we have successully load MXNet . we will start declare a symbolic network . " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : 2 , <nl> - " metadata " : { <nl> - " collapsed " : false <nl> - } , <nl> - " outputs " : [ ] , <nl> - " source " : [ <nl> - " input_data = mx . symbol . Variable ( name = \ " data \ " ) " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " markdown " , <nl> - " metadata " : { } , <nl> - " source " : [ <nl> - " We use a special symbol ` ` ` Variable ` ` ` to represent input data . " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : 3 , <nl> - " metadata " : { <nl> - " collapsed " : false <nl> - } , <nl> - " outputs " : [ ] , <nl> - " source " : [ <nl> - " # stage 1 \ n " , <nl> - " conv1 = mx . symbol . Convolution ( data = input_data , kernel = ( 11 , 11 ) , stride = ( 4 , 4 ) , num_filter = 96 ) \ n " , <nl> - " relu1 = mx . symbol . Activation ( data = conv1 , act_type = \ " relu \ " ) \ n " , <nl> - " pool1 = mx . symbol . Pooling ( data = relu1 , pool_type = \ " max \ " , kernel = ( 3 , 3 ) , stride = ( 2 , 2 ) ) \ n " , <nl> - " lrn1 = mx . symbol . LRN ( data = pool1 , alpha = 0 . 0001 , beta = 0 . 75 , knorm = 1 , nsize = 5 ) \ n " , <nl> - " # stage 2 \ n " , <nl> - " conv2 = mx . symbol . Convolution ( data = lrn1 , kernel = ( 5 , 5 ) , pad = ( 2 , 2 ) , num_filter = 256 ) \ n " , <nl> - " relu2 = mx . symbol . Activation ( data = conv2 , act_type = \ " relu \ " ) \ n " , <nl> - " pool2 = mx . symbol . Pooling ( data = relu2 , kernel = ( 3 , 3 ) , stride = ( 2 , 2 ) ) \ n " , <nl> - " lrn2 = mx . symbol . LRN ( data = pool2 , alpha = 0 . 0001 , beta = 0 . 75 , knorm = 1 , nsize = 5 ) \ n " , <nl> - " # stage 3 \ n " , <nl> - " conv3 = mx . symbol . Convolution ( data = lrn2 , kernel = ( 3 , 3 ) , pad = ( 1 , 1 ) , num_filter = 384 ) \ n " , <nl> - " relu3 = mx . symbol . Activation ( data = conv3 , act_type = \ " relu \ " ) \ n " , <nl> - " conv4 = mx . symbol . Convolution ( data = relu3 , kernel = ( 3 , 3 ) , pad = ( 1 , 1 ) , num_filter = 384 ) \ n " , <nl> - " relu4 = mx . symbol . Activation ( data = conv4 , act_type = \ " relu \ " ) \ n " , <nl> - " conv5 = mx . symbol . Convolution ( data = relu4 , kernel = ( 3 , 3 ) , pad = ( 1 , 1 ) , num_filter = 256 ) \ n " , <nl> - " relu5 = mx . symbol . Activation ( data = conv5 , act_type = \ " relu \ " ) \ n " , <nl> - " pool3 = mx . symbol . Pooling ( data = relu5 , kernel = ( 3 , 3 ) , stride = ( 2 , 2 ) ) \ n " , <nl> - " # stage 4 \ n " , <nl> - " flatten = mx . symbol . Flatten ( data = pool3 ) \ n " , <nl> - " fc1 = mx . symbol . FullyConnected ( data = flatten , num_hidden = 4096 ) \ n " , <nl> - " relu6 = mx . symbol . Activation ( data = fc1 , act_type = \ " relu \ " ) \ n " , <nl> - " dropout1 = mx . symbol . Dropout ( data = relu6 , p = 0 . 5 ) \ n " , <nl> - " # stage 5 \ n " , <nl> - " fc2 = mx . symbol . FullyConnected ( data = dropout1 , num_hidden = 4096 ) \ n " , <nl> - " relu7 = mx . symbol . Activation ( data = fc2 , act_type = \ " relu \ " ) \ n " , <nl> - " dropout2 = mx . symbol . Dropout ( data = relu7 , p = 0 . 5 ) \ n " , <nl> - " # stage 6 \ n " , <nl> - " fc3 = mx . symbol . FullyConnected ( data = dropout2 , num_hidden = 1000 ) \ n " , <nl> - " softmax = mx . symbol . Softmax ( data = fc3 ) " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " markdown " , <nl> - " metadata " : { } , <nl> - " source " : [ <nl> - " Now we have a AlexNet in symbolic level . The ` ` ` softmax ` ` ` symbol contains all network structures . By indicate ` ` ` data ` ` ` for each symbol , the last symbol composite all info we need . We can visualize our network structure . ( require ` ` ` graphviz ` ` ` package ) " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : 4 , <nl> - " metadata " : { <nl> - " collapsed " : false <nl> - } , <nl> - " outputs " : [ <nl> - { <nl> - " data " : { <nl> - " image / svg + xml " : [ <nl> - " < ? xml version = \ " 1 . 0 \ " encoding = \ " UTF - 8 \ " standalone = \ " no \ " ? > \ n " , <nl> - " < ! DOCTYPE svg PUBLIC \ " - / / W3C / / DTD SVG 1 . 1 / / EN \ " \ n " , <nl> - " \ " http : / / www . w3 . org / Graphics / SVG / 1 . 1 / DTD / svg11 . dtd \ " > \ n " , <nl> - " < ! - - Generated by graphviz version 2 . 38 . 0 ( 20140413 . 2041 ) \ n " , <nl> - " - - > \ n " , <nl> - " < ! - - Title : AlexNet Pages : 1 - - > \ n " , <nl> - " < svg width = \ " 102pt \ " height = \ " 2322pt \ " \ n " , <nl> - " viewBox = \ " 0 . 00 0 . 00 102 . 00 2322 . 00 \ " xmlns = \ " http : / / www . w3 . org / 2000 / svg \ " xmlns : xlink = \ " http : / / www . w3 . org / 1999 / xlink \ " > \ n " , <nl> - " < g id = \ " graph0 \ " class = \ " graph \ " transform = \ " scale ( 1 1 ) rotate ( 0 ) translate ( 4 2318 ) \ " > \ n " , <nl> - " < title > AlexNet < / title > \ n " , <nl> - " < polygon fill = \ " white \ " stroke = \ " none \ " points = \ " - 4 , 4 - 4 , - 2318 98 , - 2318 98 , 4 - 4 , 4 \ " / > \ n " , <nl> - " < ! - - null_0 - - > \ n " , <nl> - " < g id = \ " node1 \ " class = \ " node \ " > < title > null_0 < / title > \ n " , <nl> - " < polygon fill = \ " lightgrey \ " stroke = \ " black \ " points = \ " 94 , - 58 - 7 . 10543e - 15 , - 58 - 7 . 10543e - 15 , - 0 94 , - 0 94 , - 58 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 25 . 3 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > data < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_3 - - > \ n " , <nl> - " < g id = \ " node2 \ " class = \ " node \ " > < title > Convolution_3 < / title > \ n " , <nl> - " < polygon fill = \ " # 4876ff \ " stroke = \ " # 4876ff \ " points = \ " 94 , - 152 - 7 . 10543e - 15 , - 152 - 7 . 10543e - 15 , - 94 94 , - 94 94 , - 152 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 126 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Convolution < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 111 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > 11x11 / 4 , 96 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_3 & # 45 ; & gt ; null_0 - - > \ n " , <nl> - " < g id = \ " edge1 \ " class = \ " edge \ " > < title > Convolution_3 & # 45 ; & gt ; null_0 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 83 . 7443C47 , - 75 . 2043 47 , - 66 . 2977 47 , - 58 . 2479 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 83 . 897 47 , - 93 . 8971 50 . 5001 , - 83 . 8971 43 . 5001 , - 83 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_4 - - > \ n " , <nl> - " < g id = \ " node3 \ " class = \ " node \ " > < title > Activation_4 < / title > \ n " , <nl> - " < polygon fill = \ " salmon \ " stroke = \ " salmon \ " points = \ " 94 , - 246 - 7 . 10543e - 15 , - 246 - 7 . 10543e - 15 , - 188 94 , - 188 94 , - 246 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 220 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Activation < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 205 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > relu < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_4 & # 45 ; & gt ; Convolution_3 - - > \ n " , <nl> - " < g id = \ " edge2 \ " class = \ " edge \ " > < title > Activation_4 & # 45 ; & gt ; Convolution_3 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 177 . 744C47 , - 169 . 204 47 , - 160 . 298 47 , - 152 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 177 . 897 47 , - 187 . 897 50 . 5001 , - 177 . 897 43 . 5001 , - 177 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Pooling_5 - - > \ n " , <nl> - " < g id = \ " node4 \ " class = \ " node \ " > < title > Pooling_5 < / title > \ n " , <nl> - " < polygon fill = \ " # ee2c2c \ " stroke = \ " # ee2c2c \ " points = \ " 94 , - 340 - 7 . 10543e - 15 , - 340 - 7 . 10543e - 15 , - 282 94 , - 282 94 , - 340 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 314 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Pooling < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 299 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > max , 3x3 / 2 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Pooling_5 & # 45 ; & gt ; Activation_4 - - > \ n " , <nl> - " < g id = \ " edge3 \ " class = \ " edge \ " > < title > Pooling_5 & # 45 ; & gt ; Activation_4 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 271 . 744C47 , - 263 . 204 47 , - 254 . 298 47 , - 246 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 271 . 897 47 , - 281 . 897 50 . 5001 , - 271 . 897 43 . 5001 , - 271 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - LRN_6 - - > \ n " , <nl> - " < g id = \ " node5 \ " class = \ " node \ " > < title > LRN_6 < / title > \ n " , <nl> - " < polygon fill = \ " # c0ff3e \ " stroke = \ " # c0ff3e \ " points = \ " 94 , - 434 - 7 . 10543e - 15 , - 434 - 7 . 10543e - 15 , - 376 94 , - 376 94 , - 434 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 401 . 3 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > LRN < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - LRN_6 & # 45 ; & gt ; Pooling_5 - - > \ n " , <nl> - " < g id = \ " edge4 \ " class = \ " edge \ " > < title > LRN_6 & # 45 ; & gt ; Pooling_5 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 365 . 744C47 , - 357 . 204 47 , - 348 . 298 47 , - 340 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 365 . 897 47 , - 375 . 897 50 . 5001 , - 365 . 897 43 . 5001 , - 365 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_9 - - > \ n " , <nl> - " < g id = \ " node6 \ " class = \ " node \ " > < title > Convolution_9 < / title > \ n " , <nl> - " < polygon fill = \ " # 4876ff \ " stroke = \ " # 4876ff \ " points = \ " 94 , - 528 - 7 . 10543e - 15 , - 528 - 7 . 10543e - 15 , - 470 94 , - 470 94 , - 528 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 502 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Convolution < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 487 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > 5x5 / 1 , 256 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_9 & # 45 ; & gt ; LRN_6 - - > \ n " , <nl> - " < g id = \ " edge5 \ " class = \ " edge \ " > < title > Convolution_9 & # 45 ; & gt ; LRN_6 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 459 . 744C47 , - 451 . 204 47 , - 442 . 298 47 , - 434 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 459 . 897 47 , - 469 . 897 50 . 5001 , - 459 . 897 43 . 5001 , - 459 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_10 - - > \ n " , <nl> - " < g id = \ " node7 \ " class = \ " node \ " > < title > Activation_10 < / title > \ n " , <nl> - " < polygon fill = \ " salmon \ " stroke = \ " salmon \ " points = \ " 94 , - 622 - 7 . 10543e - 15 , - 622 - 7 . 10543e - 15 , - 564 94 , - 564 94 , - 622 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 596 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Activation < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 581 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > relu < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_10 & # 45 ; & gt ; Convolution_9 - - > \ n " , <nl> - " < g id = \ " edge6 \ " class = \ " edge \ " > < title > Activation_10 & # 45 ; & gt ; Convolution_9 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 553 . 744C47 , - 545 . 204 47 , - 536 . 298 47 , - 528 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 553 . 897 47 , - 563 . 897 50 . 5001 , - 553 . 897 43 . 5001 , - 553 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Pooling_11 - - > \ n " , <nl> - " < g id = \ " node8 \ " class = \ " node \ " > < title > Pooling_11 < / title > \ n " , <nl> - " < polygon fill = \ " # ee2c2c \ " stroke = \ " # ee2c2c \ " points = \ " 94 , - 716 - 7 . 10543e - 15 , - 716 - 7 . 10543e - 15 , - 658 94 , - 658 94 , - 716 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 690 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Pooling < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 675 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > max , 3x3 / 2 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Pooling_11 & # 45 ; & gt ; Activation_10 - - > \ n " , <nl> - " < g id = \ " edge7 \ " class = \ " edge \ " > < title > Pooling_11 & # 45 ; & gt ; Activation_10 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 647 . 744C47 , - 639 . 204 47 , - 630 . 298 47 , - 622 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 647 . 897 47 , - 657 . 897 50 . 5001 , - 647 . 897 43 . 5001 , - 647 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - LRN_12 - - > \ n " , <nl> - " < g id = \ " node9 \ " class = \ " node \ " > < title > LRN_12 < / title > \ n " , <nl> - " < polygon fill = \ " # c0ff3e \ " stroke = \ " # c0ff3e \ " points = \ " 94 , - 810 - 7 . 10543e - 15 , - 810 - 7 . 10543e - 15 , - 752 94 , - 752 94 , - 810 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 777 . 3 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > LRN < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - LRN_12 & # 45 ; & gt ; Pooling_11 - - > \ n " , <nl> - " < g id = \ " edge8 \ " class = \ " edge \ " > < title > LRN_12 & # 45 ; & gt ; Pooling_11 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 741 . 744C47 , - 733 . 204 47 , - 724 . 298 47 , - 716 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 741 . 897 47 , - 751 . 897 50 . 5001 , - 741 . 897 43 . 5001 , - 741 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_15 - - > \ n " , <nl> - " < g id = \ " node10 \ " class = \ " node \ " > < title > Convolution_15 < / title > \ n " , <nl> - " < polygon fill = \ " # 4876ff \ " stroke = \ " # 4876ff \ " points = \ " 94 , - 904 - 7 . 10543e - 15 , - 904 - 7 . 10543e - 15 , - 846 94 , - 846 94 , - 904 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 878 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Convolution < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 863 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > 3x3 / 1 , 384 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_15 & # 45 ; & gt ; LRN_12 - - > \ n " , <nl> - " < g id = \ " edge9 \ " class = \ " edge \ " > < title > Convolution_15 & # 45 ; & gt ; LRN_12 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 835 . 744C47 , - 827 . 204 47 , - 818 . 298 47 , - 810 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 835 . 897 47 , - 845 . 897 50 . 5001 , - 835 . 897 43 . 5001 , - 835 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_16 - - > \ n " , <nl> - " < g id = \ " node11 \ " class = \ " node \ " > < title > Activation_16 < / title > \ n " , <nl> - " < polygon fill = \ " salmon \ " stroke = \ " salmon \ " points = \ " 94 , - 998 - 7 . 10543e - 15 , - 998 - 7 . 10543e - 15 , - 940 94 , - 940 94 , - 998 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 972 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Activation < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 957 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > relu < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_16 & # 45 ; & gt ; Convolution_15 - - > \ n " , <nl> - " < g id = \ " edge10 \ " class = \ " edge \ " > < title > Activation_16 & # 45 ; & gt ; Convolution_15 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 929 . 744C47 , - 921 . 204 47 , - 912 . 298 47 , - 904 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 929 . 897 47 , - 939 . 897 50 . 5001 , - 929 . 897 43 . 5001 , - 929 . 897 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_19 - - > \ n " , <nl> - " < g id = \ " node12 \ " class = \ " node \ " > < title > Convolution_19 < / title > \ n " , <nl> - " < polygon fill = \ " # 4876ff \ " stroke = \ " # 4876ff \ " points = \ " 94 , - 1092 - 7 . 10543e - 15 , - 1092 - 7 . 10543e - 15 , - 1034 94 , - 1034 94 , - 1092 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1066 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Convolution < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1051 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > 3x3 / 1 , 384 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_19 & # 45 ; & gt ; Activation_16 - - > \ n " , <nl> - " < g id = \ " edge11 \ " class = \ " edge \ " > < title > Convolution_19 & # 45 ; & gt ; Activation_16 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1023 . 74C47 , - 1015 . 2 47 , - 1006 . 3 47 , - 998 . 248 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1023 . 9 47 , - 1033 . 9 50 . 5001 , - 1023 . 9 43 . 5001 , - 1023 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_20 - - > \ n " , <nl> - " < g id = \ " node13 \ " class = \ " node \ " > < title > Activation_20 < / title > \ n " , <nl> - " < polygon fill = \ " salmon \ " stroke = \ " salmon \ " points = \ " 94 , - 1186 - 7 . 10543e - 15 , - 1186 - 7 . 10543e - 15 , - 1128 94 , - 1128 94 , - 1186 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1160 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Activation < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1145 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > relu < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_20 & # 45 ; & gt ; Convolution_19 - - > \ n " , <nl> - " < g id = \ " edge12 \ " class = \ " edge \ " > < title > Activation_20 & # 45 ; & gt ; Convolution_19 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1117 . 74C47 , - 1109 . 2 47 , - 1100 . 3 47 , - 1092 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1117 . 9 47 , - 1127 . 9 50 . 5001 , - 1117 . 9 43 . 5001 , - 1117 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_23 - - > \ n " , <nl> - " < g id = \ " node14 \ " class = \ " node \ " > < title > Convolution_23 < / title > \ n " , <nl> - " < polygon fill = \ " # 4876ff \ " stroke = \ " # 4876ff \ " points = \ " 94 , - 1280 - 7 . 10543e - 15 , - 1280 - 7 . 10543e - 15 , - 1222 94 , - 1222 94 , - 1280 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1254 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Convolution < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1239 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > 3x3 / 1 , 256 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Convolution_23 & # 45 ; & gt ; Activation_20 - - > \ n " , <nl> - " < g id = \ " edge13 \ " class = \ " edge \ " > < title > Convolution_23 & # 45 ; & gt ; Activation_20 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1211 . 74C47 , - 1203 . 2 47 , - 1194 . 3 47 , - 1186 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1211 . 9 47 , - 1221 . 9 50 . 5001 , - 1211 . 9 43 . 5001 , - 1211 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_24 - - > \ n " , <nl> - " < g id = \ " node15 \ " class = \ " node \ " > < title > Activation_24 < / title > \ n " , <nl> - " < polygon fill = \ " salmon \ " stroke = \ " salmon \ " points = \ " 94 , - 1374 - 7 . 10543e - 15 , - 1374 - 7 . 10543e - 15 , - 1316 94 , - 1316 94 , - 1374 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1348 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Activation < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1333 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > relu < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_24 & # 45 ; & gt ; Convolution_23 - - > \ n " , <nl> - " < g id = \ " edge14 \ " class = \ " edge \ " > < title > Activation_24 & # 45 ; & gt ; Convolution_23 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1305 . 74C47 , - 1297 . 2 47 , - 1288 . 3 47 , - 1280 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1305 . 9 47 , - 1315 . 9 50 . 5001 , - 1305 . 9 43 . 5001 , - 1305 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Pooling_25 - - > \ n " , <nl> - " < g id = \ " node16 \ " class = \ " node \ " > < title > Pooling_25 < / title > \ n " , <nl> - " < polygon fill = \ " # ee2c2c \ " stroke = \ " # ee2c2c \ " points = \ " 94 , - 1468 - 7 . 10543e - 15 , - 1468 - 7 . 10543e - 15 , - 1410 94 , - 1410 94 , - 1468 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1442 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Pooling < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1427 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > max , 3x3 / 2 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Pooling_25 & # 45 ; & gt ; Activation_24 - - > \ n " , <nl> - " < g id = \ " edge15 \ " class = \ " edge \ " > < title > Pooling_25 & # 45 ; & gt ; Activation_24 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1399 . 74C47 , - 1391 . 2 47 , - 1382 . 3 47 , - 1374 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1399 . 9 47 , - 1409 . 9 50 . 5001 , - 1399 . 9 43 . 5001 , - 1399 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Flatten_26 - - > \ n " , <nl> - " < g id = \ " node17 \ " class = \ " node \ " > < title > Flatten_26 < / title > \ n " , <nl> - " < polygon fill = \ " # 54ff9f \ " stroke = \ " # 54ff9f \ " points = \ " 94 , - 1562 - 7 . 10543e - 15 , - 1562 - 7 . 10543e - 15 , - 1504 94 , - 1504 94 , - 1562 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1529 . 3 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Flatten < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Flatten_26 & # 45 ; & gt ; Pooling_25 - - > \ n " , <nl> - " < g id = \ " edge16 \ " class = \ " edge \ " > < title > Flatten_26 & # 45 ; & gt ; Pooling_25 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1493 . 74C47 , - 1485 . 2 47 , - 1476 . 3 47 , - 1468 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1493 . 9 47 , - 1503 . 9 50 . 5001 , - 1493 . 9 43 . 5001 , - 1493 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - FullyConnected_29 - - > \ n " , <nl> - " < g id = \ " node18 \ " class = \ " node \ " > < title > FullyConnected_29 < / title > \ n " , <nl> - " < polygon fill = \ " # 4876ff \ " stroke = \ " # 4876ff \ " points = \ " 94 , - 1656 - 7 . 10543e - 15 , - 1656 - 7 . 10543e - 15 , - 1598 94 , - 1598 94 , - 1656 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1630 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > FullyConnected < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1615 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > 4096 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - FullyConnected_29 & # 45 ; & gt ; Flatten_26 - - > \ n " , <nl> - " < g id = \ " edge17 \ " class = \ " edge \ " > < title > FullyConnected_29 & # 45 ; & gt ; Flatten_26 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1587 . 74C47 , - 1579 . 2 47 , - 1570 . 3 47 , - 1562 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1587 . 9 47 , - 1597 . 9 50 . 5001 , - 1587 . 9 43 . 5001 , - 1587 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_30 - - > \ n " , <nl> - " < g id = \ " node19 \ " class = \ " node \ " > < title > Activation_30 < / title > \ n " , <nl> - " < polygon fill = \ " salmon \ " stroke = \ " salmon \ " points = \ " 94 , - 1750 - 7 . 10543e - 15 , - 1750 - 7 . 10543e - 15 , - 1692 94 , - 1692 94 , - 1750 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1724 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Activation < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1709 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > relu < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_30 & # 45 ; & gt ; FullyConnected_29 - - > \ n " , <nl> - " < g id = \ " edge18 \ " class = \ " edge \ " > < title > Activation_30 & # 45 ; & gt ; FullyConnected_29 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1681 . 74C47 , - 1673 . 2 47 , - 1664 . 3 47 , - 1656 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1681 . 9 47 , - 1691 . 9 50 . 5001 , - 1681 . 9 43 . 5001 , - 1681 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Dropout_31 - - > \ n " , <nl> - " < g id = \ " node20 \ " class = \ " node \ " > < title > Dropout_31 < / title > \ n " , <nl> - " < polygon fill = \ " # c0ff3e \ " stroke = \ " # c0ff3e \ " points = \ " 94 , - 1844 - 7 . 10543e - 15 , - 1844 - 7 . 10543e - 15 , - 1786 94 , - 1786 94 , - 1844 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1811 . 3 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Dropout < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Dropout_31 & # 45 ; & gt ; Activation_30 - - > \ n " , <nl> - " < g id = \ " edge19 \ " class = \ " edge \ " > < title > Dropout_31 & # 45 ; & gt ; Activation_30 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1775 . 74C47 , - 1767 . 2 47 , - 1758 . 3 47 , - 1750 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1775 . 9 47 , - 1785 . 9 50 . 5001 , - 1775 . 9 43 . 5001 , - 1775 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - FullyConnected_34 - - > \ n " , <nl> - " < g id = \ " node21 \ " class = \ " node \ " > < title > FullyConnected_34 < / title > \ n " , <nl> - " < polygon fill = \ " # 4876ff \ " stroke = \ " # 4876ff \ " points = \ " 94 , - 1938 - 7 . 10543e - 15 , - 1938 - 7 . 10543e - 15 , - 1880 94 , - 1880 94 , - 1938 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1912 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > FullyConnected < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1897 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > 4096 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - FullyConnected_34 & # 45 ; & gt ; Dropout_31 - - > \ n " , <nl> - " < g id = \ " edge20 \ " class = \ " edge \ " > < title > FullyConnected_34 & # 45 ; & gt ; Dropout_31 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1869 . 74C47 , - 1861 . 2 47 , - 1852 . 3 47 , - 1844 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1869 . 9 47 , - 1879 . 9 50 . 5001 , - 1869 . 9 43 . 5001 , - 1869 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_35 - - > \ n " , <nl> - " < g id = \ " node22 \ " class = \ " node \ " > < title > Activation_35 < / title > \ n " , <nl> - " < polygon fill = \ " salmon \ " stroke = \ " salmon \ " points = \ " 94 , - 2032 - 7 . 10543e - 15 , - 2032 - 7 . 10543e - 15 , - 1974 94 , - 1974 94 , - 2032 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 2006 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Activation < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 1991 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > relu < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Activation_35 & # 45 ; & gt ; FullyConnected_34 - - > \ n " , <nl> - " < g id = \ " edge21 \ " class = \ " edge \ " > < title > Activation_35 & # 45 ; & gt ; FullyConnected_34 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 1963 . 74C47 , - 1955 . 2 47 , - 1946 . 3 47 , - 1938 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 1963 . 9 47 , - 1973 . 9 50 . 5001 , - 1963 . 9 43 . 5001 , - 1963 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Dropout_36 - - > \ n " , <nl> - " < g id = \ " node23 \ " class = \ " node \ " > < title > Dropout_36 < / title > \ n " , <nl> - " < polygon fill = \ " # c0ff3e \ " stroke = \ " # c0ff3e \ " points = \ " 94 , - 2126 - 7 . 10543e - 15 , - 2126 - 7 . 10543e - 15 , - 2068 94 , - 2068 94 , - 2126 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 2093 . 3 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Dropout < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Dropout_36 & # 45 ; & gt ; Activation_35 - - > \ n " , <nl> - " < g id = \ " edge22 \ " class = \ " edge \ " > < title > Dropout_36 & # 45 ; & gt ; Activation_35 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 2057 . 74C47 , - 2049 . 2 47 , - 2040 . 3 47 , - 2032 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 2057 . 9 47 , - 2067 . 9 50 . 5001 , - 2057 . 9 43 . 5001 , - 2057 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - FullyConnected_39 - - > \ n " , <nl> - " < g id = \ " node24 \ " class = \ " node \ " > < title > FullyConnected_39 < / title > \ n " , <nl> - " < polygon fill = \ " # 4876ff \ " stroke = \ " # 4876ff \ " points = \ " 94 , - 2220 - 7 . 10543e - 15 , - 2220 - 7 . 10543e - 15 , - 2162 94 , - 2162 94 , - 2220 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 2194 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > FullyConnected < / text > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 2179 . 8 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > 1000 < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - FullyConnected_39 & # 45 ; & gt ; Dropout_36 - - > \ n " , <nl> - " < g id = \ " edge23 \ " class = \ " edge \ " > < title > FullyConnected_39 & # 45 ; & gt ; Dropout_36 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 2151 . 74C47 , - 2143 . 2 47 , - 2134 . 3 47 , - 2126 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 2151 . 9 47 , - 2161 . 9 50 . 5001 , - 2151 . 9 43 . 5001 , - 2151 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Softmax_41 - - > \ n " , <nl> - " < g id = \ " node25 \ " class = \ " node \ " > < title > Softmax_41 < / title > \ n " , <nl> - " < polygon fill = \ " # c0ff3e \ " stroke = \ " # c0ff3e \ " points = \ " 94 , - 2314 - 7 . 10543e - 15 , - 2314 - 7 . 10543e - 15 , - 2256 94 , - 2256 94 , - 2314 \ " / > \ n " , <nl> - " < text text - anchor = \ " middle \ " x = \ " 47 \ " y = \ " - 2281 . 3 \ " font - family = \ " Times , serif \ " font - size = \ " 14 . 00 \ " > Softmax < / text > \ n " , <nl> - " < / g > \ n " , <nl> - " < ! - - Softmax_41 & # 45 ; & gt ; FullyConnected_39 - - > \ n " , <nl> - " < g id = \ " edge24 \ " class = \ " edge \ " > < title > Softmax_41 & # 45 ; & gt ; FullyConnected_39 < / title > \ n " , <nl> - " < path fill = \ " none \ " stroke = \ " black \ " d = \ " M47 , - 2245 . 74C47 , - 2237 . 2 47 , - 2228 . 3 47 , - 2220 . 25 \ " / > \ n " , <nl> - " < polygon fill = \ " black \ " stroke = \ " black \ " points = \ " 43 . 5001 , - 2245 . 9 47 , - 2255 . 9 50 . 5001 , - 2245 . 9 43 . 5001 , - 2245 . 9 \ " / > \ n " , <nl> - " < / g > \ n " , <nl> - " < / g > \ n " , <nl> - " < / svg > \ n " <nl> - ] , <nl> - " text / plain " : [ <nl> - " < graphviz . dot . Digraph at 0x7f08a1121198 > " <nl> - ] <nl> - } , <nl> - " execution_count " : 4 , <nl> - " metadata " : { } , <nl> - " output_type " : " execute_result " <nl> - } <nl> - ] , <nl> - " source " : [ <nl> - " mx . viz . plot_network ( softmax ) " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " markdown " , <nl> - " metadata " : { <nl> - " collapsed " : true <nl> - } , <nl> - " source " : [ <nl> - " The next step is declare data iterator . We provide high perfomance RecordIO image iterator for ImageNet task . Please pack the images into record file before use . For how to pack image and more details about image data iterator and build - in io iterator , please read [ io doc ] ( https : / / github . com / dmlc / mxnet / blob / master / doc / python / io . md ) " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : 5 , <nl> - " metadata " : { <nl> - " collapsed " : true <nl> - } , <nl> - " outputs " : [ ] , <nl> - " source " : [ <nl> - " # We set batch size for to 256 \ n " , <nl> - " batch_size = 256 \ n " , <nl> - " # We need to set correct path to image record file \ n " , <nl> - " # For ` ` ` mean_image ` ` ` . if it doesn ' t exist , the iterator will generate one \ n " , <nl> - " # On HDD , single thread is able to process 800 images / sec \ n " , <nl> - " # the input shape is in format ( channel , height , width ) \ n " , <nl> - " # rand_crop option make source image randomly cropped to input_shape ( 3 , 224 , 224 ) \ n " , <nl> - " # rand_mirror option make source image randomly mirrored \ n " , <nl> - " # We use 2 threads to processing our data \ n " , <nl> - " train_dataiter = mx . io . ImageRecordIter ( \ n " , <nl> - " shuffle = True , \ n " , <nl> - " path_imgrec = \ " . / Data / ImageNet / train . rec \ " , \ n " , <nl> - " mean_img = \ " . / Data / ImageNet / mean_224 . bin \ " , \ n " , <nl> - " rand_crop = True , \ n " , <nl> - " rand_mirror = True , \ n " , <nl> - " data_shape = ( 3 , 224 , 224 ) , \ n " , <nl> - " batch_size = batch_size , \ n " , <nl> - " prefetch_buffer = 4 , \ n " , <nl> - " preprocess_threads = 2 ) \ n " , <nl> - " # similarly , we can declare our validation iterator \ n " , <nl> - " val_dataiter = mx . io . ImageRecordIter ( \ n " , <nl> - " path_imgrec = \ " . / Data / ImageNet / val . rec \ " , \ n " , <nl> - " mean_img = \ " . / Data / ImageNet / mean_224 . bin \ " , \ n " , <nl> - " rand_crop = False , \ n " , <nl> - " rand_mirror = False , \ n " , <nl> - " data_shape = ( 3 , 224 , 224 ) , \ n " , <nl> - " batch_size = batch_size , \ n " , <nl> - " prefetch_buffer = 4 , \ n " , <nl> - " preprocess_threads = 2 ) " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " markdown " , <nl> - " metadata " : { } , <nl> - " source " : [ <nl> - " Next step , we will initialize our model from symbol . To run on a single GPU , we need to declare : " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : 9 , <nl> - " metadata " : { <nl> - " collapsed " : false <nl> - } , <nl> - " outputs " : [ ] , <nl> - " source " : [ <nl> - " # For demo purpose , we just run 1 epoch \ n " , <nl> - " num_round = 1 \ n " , <nl> - " # set context to GPU , if you want to use cpu , set it to mx . cpu ( ) \ n " , <nl> - " ctx = mx . gpu ( ) \ n " , <nl> - " # note : for input shape in model , we must contain batch size \ n " , <nl> - " data_shape = ( batch_size , 3 , 224 , 224 ) \ n " , <nl> - " \ n " , <nl> - " model = mx . model . FeedForward ( symbol = softmax , ctx = ctx , input_shape = data_shape , num_round = num_round , \ n " , <nl> - " learning_rate = 0 . 01 , momentum = 0 . 9 , wd = 0 . 0001 ) " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " markdown " , <nl> - " metadata " : { } , <nl> - " source " : [ <nl> - " To run on multiply GPU , we need to declare " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : null , <nl> - " metadata " : { <nl> - " collapsed " : true <nl> - } , <nl> - " outputs " : [ ] , <nl> - " source " : [ <nl> - " # For demo purpose , we just run 1 epoch \ n " , <nl> - " num_round = 1 \ n " , <nl> - " # Assume we have 4 GPU , we can make a context list contains 4 device \ n " , <nl> - " num_devs = 4 \ n " , <nl> - " ctx = [ mx . gpu ( i ) for i in range ( num_devs ) ] \ n " , <nl> - " # note : for input shape in model , we must contain batch size \ n " , <nl> - " data_shape = ( batch_size , 3 , 224 , 224 ) \ n " , <nl> - " \ n " , <nl> - " model = mx . model . FeedForward ( symbol = softmax , ctx = ctx , input_shape = data_shape , num_round = num_round , \ n " , <nl> - " learning_rate = 0 . 01 , momentum = 0 . 9 , wd = 0 . 0001 ) " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : 10 , <nl> - " metadata " : { <nl> - " collapsed " : false <nl> - } , <nl> - " outputs " : [ <nl> - { <nl> - " ename " : " MXNetError " , <nl> - " evalue " : " [ 12 : 00 : 28 ] src / ndarray / ndarray . cc : 157 : Check failed : from . shape ( ) = = to - > shape ( ) operands shape mismatch " , <nl> - " output_type " : " error " , <nl> - " traceback " : [ <nl> - " \ u001b [ 1 ; 31mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm \ u001b [ 0m " , <nl> - " \ u001b [ 1 ; 31mMXNetError \ u001b [ 0m Traceback ( most recent call last ) " , <nl> - " \ u001b [ 1 ; 32m < ipython - input - 10 - 8ca28bf9d513 > \ u001b [ 0m in \ u001b [ 0 ; 36m < module > \ u001b [ 1 ; 34m ( ) \ u001b [ 0m \ n \ u001b [ 0 ; 32m 3 \ u001b [ 0m \ u001b [ 1 ; 31m # In this case , eval_data is also a data iterator \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 4 \ u001b [ 0m \ u001b [ 1 ; 31m # We will use accuracy to measure our model ' s performace \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 1 ; 32mmmm - > 5 \ u001b [ 1 ; 33m \ u001b [ 0mmodel \ u001b [ 0m \ u001b [ 1 ; 33m . \ u001b [ 0m \ u001b [ 0mfit \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mX \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0mtrain_dataiter \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0meval_data \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0mval_dataiter \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0meval_metric \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 1 ; 34m ' acc ' \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0mverbose \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 1 ; 32mTrue \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0m " , <nl> - " \ u001b [ 1 ; 32m / home / bing / wtf / mxnet / python / mxnet / model . py \ u001b [ 0m in \ u001b [ 0 ; 36mfit \ u001b [ 1 ; 34m ( self , X , y , eval_data , eval_metric , verbose ) \ u001b [ 0m \ n \ u001b [ 0 ; 32m 304 \ u001b [ 0m \ u001b [ 0mtrain_data \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0mX \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0meval_data \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0meval_data \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 305 \ u001b [ 0m \ u001b [ 0meval_metric \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0meval_metric \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 1 ; 32m - - > 306 \ u001b [ 1 ; 33m verbose = verbose ) \ n \ u001b [ 0m " , <nl> - " \ u001b [ 1 ; 32m / home / bing / wtf / mxnet / python / mxnet / model . py \ u001b [ 0m in \ u001b [ 0 ; 36m_train \ u001b [ 1 ; 34m ( symbol , ctx , input_shape , arg_params , aux_params , begin_round , end_round , optimizer , train_data , eval_data , eval_metric , iter_end_callback , verbose ) \ u001b [ 0m \ n \ u001b [ 0 ; 32m 85 \ u001b [ 0m \ u001b [ 1 ; 32mfor \ u001b [ 0m \ u001b [ 0mkey \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0mweight \ u001b [ 0m \ u001b [ 1 ; 32min \ u001b [ 0m \ u001b [ 0mlist \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mzip \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0marg_names \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0marg_arrays \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 86 \ u001b [ 0m \ u001b [ 1 ; 32mif \ u001b [ 0m \ u001b [ 0mkey \ u001b [ 0m \ u001b [ 1 ; 32min \ u001b [ 0m \ u001b [ 0marg_params \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 1 ; 32mmmm > 87 \ u001b [ 1 ; 33m \ u001b [ 0marg_params \ u001b [ 0m \ u001b [ 1 ; 33m [ \ u001b [ 0m \ u001b [ 0mkey \ u001b [ 0m \ u001b [ 1 ; 33m ] \ u001b [ 0m \ u001b [ 1 ; 33m . \ u001b [ 0m \ u001b [ 0mcopyto \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mweight \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0m \ u001b [ 0 ; 32m 88 \ u001b [ 0m \ u001b [ 1 ; 32mfor \ u001b [ 0m \ u001b [ 0mkey \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0mweight \ u001b [ 0m \ u001b [ 1 ; 32min \ u001b [ 0m \ u001b [ 0mlist \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mzip \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0maux_names \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0maux_arrays \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 89 \ u001b [ 0m \ u001b [ 1 ; 32mif \ u001b [ 0m \ u001b [ 0mkey \ u001b [ 0m \ u001b [ 1 ; 32min \ u001b [ 0m \ u001b [ 0maux_params \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n " , <nl> - " \ u001b [ 1 ; 32m / home / bing / wtf / mxnet / python / mxnet / ndarray . py \ u001b [ 0m in \ u001b [ 0 ; 36mcopyto \ u001b [ 1 ; 34m ( self , other ) \ u001b [ 0m \ n \ u001b [ 0 ; 32m 306 \ u001b [ 0m RuntimeWarning ) \ n \ u001b [ 0 ; 32m 307 \ u001b [ 0m \ u001b [ 1 ; 32mreturn \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 1 ; 32m - - > 308 \ u001b [ 1 ; 33m \ u001b [ 1 ; 32mreturn \ u001b [ 0m \ u001b [ 0mNDArray \ u001b [ 0m \ u001b [ 1 ; 33m . \ u001b [ 0m \ u001b [ 0m_copyto \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mself \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0mout \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0mother \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0m \ u001b [ 0 ; 32m 309 \ u001b [ 0m \ u001b [ 1 ; 32melif \ u001b [ 0m \ u001b [ 0misinstance \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mother \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0mContext \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 310 \ u001b [ 0m \ u001b [ 0mhret \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0mNDArray \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0m_new_alloc_handle \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mself \ u001b [ 0m \ u001b [ 1 ; 33m . \ u001b [ 0m \ u001b [ 0mshape \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0mother \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 1 ; 32mTrue \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n " , <nl> - " \ u001b [ 1 ; 32m / home / bing / wtf / mxnet / python / mxnet / ndarray . py \ u001b [ 0m in \ u001b [ 0 ; 36mgeneric_ndarray_function \ u001b [ 1 ; 34m ( * args , * * kwargs ) \ u001b [ 0m \ n \ u001b [ 0 ; 32m 618 \ u001b [ 0m \ u001b [ 0mc_array \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mNDArrayHandle \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 1 ; 33m [ \ u001b [ 0m \ u001b [ 0margs \ u001b [ 0m \ u001b [ 1 ; 33m [ \ u001b [ 0m \ u001b [ 0mi \ u001b [ 0m \ u001b [ 1 ; 33m ] \ u001b [ 0m \ u001b [ 1 ; 33m . \ u001b [ 0m \ u001b [ 0mhandle \ u001b [ 0m \ u001b [ 1 ; 32mfor \ u001b [ 0m \ u001b [ 0mi \ u001b [ 0m \ u001b [ 1 ; 32min \ u001b [ 0m \ u001b [ 0muse_vars_range \ u001b [ 0m \ u001b [ 1 ; 33m ] \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0 ; 31m \ u001b [ 0m \ u001b [ 0 ; 31m \ \ \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 619 \ u001b [ 0m \ u001b [ 0mc_array \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mmx_float \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 1 ; 33m [ \ u001b [ 0m \ u001b [ 0margs \ u001b [ 0m \ u001b [ 1 ; 33m [ \ u001b [ 0m \ u001b [ 0mi \ u001b [ 0m \ u001b [ 1 ; 33m ] \ u001b [ 0m \ u001b [ 1 ; 32mfor \ u001b [ 0m \ u001b [ 0mi \ u001b [ 0m \ u001b [ 1 ; 32min \ u001b [ 0m \ u001b [ 0mscalar_range \ u001b [ 0m \ u001b [ 1 ; 33m ] \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0 ; 31m \ u001b [ 0m \ u001b [ 0 ; 31m \ \ \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 1 ; 32m - - > 620 \ u001b [ 1 ; 33m c_array ( NDArrayHandle , [ v . handle for v in mutate_vars ] ) ) ) \ n \ u001b [ 0m \ u001b [ 0 ; 32m 621 \ u001b [ 0m \ u001b [ 1 ; 32mif \ u001b [ 0m \ u001b [ 0mn_mutate_vars \ u001b [ 0m \ u001b [ 1 ; 33m = = \ u001b [ 0m \ u001b [ 1 ; 36m1 \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 622 \ u001b [ 0m \ u001b [ 1 ; 32mreturn \ u001b [ 0m \ u001b [ 0mmutate_vars \ u001b [ 0m \ u001b [ 1 ; 33m [ \ u001b [ 0m \ u001b [ 1 ; 36m0 \ u001b [ 0m \ u001b [ 1 ; 33m ] \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n " , <nl> - " \ u001b [ 1 ; 32m / home / bing / wtf / mxnet / python / mxnet / base . py \ u001b [ 0m in \ u001b [ 0 ; 36mcheck_call \ u001b [ 1 ; 34m ( ret ) \ u001b [ 0m \ n \ u001b [ 0 ; 32m 95 \ u001b [ 0m \ " \ " \ " \ n \ u001b [ 0 ; 32m 96 \ u001b [ 0m \ u001b [ 1 ; 32mif \ u001b [ 0m \ u001b [ 0mret \ u001b [ 0m \ u001b [ 1 ; 33m ! = \ u001b [ 0m \ u001b [ 1 ; 36m0 \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 1 ; 32mmmm > 97 \ u001b [ 1 ; 33m \ u001b [ 1 ; 32mraise \ u001b [ 0m \ u001b [ 0mMXNetError \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mpy_str \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0m_LIB \ u001b [ 0m \ u001b [ 1 ; 33m . \ u001b [ 0m \ u001b [ 0mMXGetLastError \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0m \ u001b [ 0 ; 32m 98 \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 99 \ u001b [ 0m \ u001b [ 1 ; 32mdef \ u001b [ 0m \ u001b [ 0mc_str \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mstring \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n " , <nl> - " \ u001b [ 1 ; 31mMXNetError \ u001b [ 0m : [ 12 : 00 : 28 ] src / ndarray / ndarray . cc : 157 : Check failed : from . shape ( ) = = to - > shape ( ) operands shape mismatch " <nl> - ] <nl> - } <nl> - ] , <nl> - " source " : [ <nl> - " # Now we can fit the model with data iterators \ n " , <nl> - " # When we use data iterator , we don ' t need to set y because label comes from data iterator directly \ n " , <nl> - " # In this case , eval_data is also a data iterator \ n " , <nl> - " # We will use accuracy to measure our model ' s performace \ n " , <nl> - " model . fit ( X = train_dataiter , eval_data = val_dataiter , eval_metric = ' acc ' ) \ n " , <nl> - " # You need to wait for a while to get the result " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " markdown " , <nl> - " metadata " : { } , <nl> - " source " : [ <nl> - " That ' s all ! " <nl> - ] <nl> - } , <nl> - { <nl> - " cell_type " : " code " , <nl> - " execution_count " : null , <nl> - " metadata " : { <nl> - " collapsed " : true <nl> - } , <nl> - " outputs " : [ ] , <nl> - " source " : [ ] <nl> - } <nl> - ] , <nl> - " metadata " : { <nl> - " kernelspec " : { <nl> - " display_name " : " Python 3 " , <nl> - " language " : " python " , <nl> - " name " : " python3 " <nl> - } , <nl> - " language_info " : { <nl> - " codemirror_mode " : { <nl> - " name " : " ipython " , <nl> - " version " : 3 <nl> - } , <nl> - " file_extension " : " . py " , <nl> - " mimetype " : " text / x - python " , <nl> - " name " : " python " , <nl> - " nbconvert_exporter " : " python " , <nl> - " pygments_lexer " : " ipython3 " , <nl> - " version " : " 3 . 4 . 2 " <nl> - } <nl> - } , <nl> - " nbformat " : 4 , <nl> - " nbformat_minor " : 0 <nl> - } <nl> mmm a / example / notebooks / cifar - recipe . ipynb <nl> ppp b / example / notebooks / cifar - recipe . ipynb <nl> <nl> } , <nl> { <nl> " cell_type " : " code " , <nl> - " execution_count " : 11 , <nl> + " execution_count " : 10 , <nl> " metadata " : { <nl> " collapsed " : false <nl> } , <nl> <nl> " output_type " : " stream " , <nl> " text " : [ <nl> " INFO : root : Start training with [ gpu ( 0 ) ] \ n " , <nl> - " INFO : root : Batch [ 50 ] \ tSpeed : 1091 . 84 samples / sec \ n " , <nl> - " INFO : root : Batch [ 100 ] \ tSpeed : 1084 . 80 samples / sec \ n " , <nl> - " INFO : root : Batch [ 150 ] \ tSpeed : 1084 . 55 samples / sec \ n " , <nl> - " INFO : root : Batch [ 200 ] \ tSpeed : 1077 . 30 samples / sec \ n " , <nl> - " INFO : root : Batch [ 250 ] \ tSpeed : 1074 . 73 samples / sec \ n " , <nl> - " INFO : root : Batch [ 300 ] \ tSpeed : 1075 . 67 samples / sec \ n " , <nl> - " INFO : root : Batch [ 350 ] \ tSpeed : 1067 . 09 samples / sec \ n " , <nl> - " INFO : root : Iteration [ 0 ] Train - accuracy = 0 . 525695 \ n " , <nl> - " INFO : root : Iteration [ 0 ] Time cost = 47 . 012 \ n " , <nl> - " INFO : root : Iteration [ 0 ] Validation - accuracy = 0 . 660008 \ n " <nl> + " INFO : root : Batch [ 50 ] \ tSpeed : 1003 . 50 samples / sec \ n " , <nl> + " INFO : root : Batch [ 100 ] \ tSpeed : 976 . 31 samples / sec \ n " , <nl> + " INFO : root : Batch [ 150 ] \ tSpeed : 975 . 57 samples / sec \ n " , <nl> + " INFO : root : Batch [ 200 ] \ tSpeed : 964 . 21 samples / sec \ n " , <nl> + " INFO : root : Batch [ 250 ] \ tSpeed : 963 . 53 samples / sec \ n " , <nl> + " INFO : root : Batch [ 300 ] \ tSpeed : 963 . 95 samples / sec \ n " , <nl> + " INFO : root : Batch [ 350 ] \ tSpeed : 963 . 71 samples / sec \ n " , <nl> + " INFO : root : Iteration [ 0 ] Train - accuracy = 0 . 520520 \ n " , <nl> + " INFO : root : Iteration [ 0 ] Time cost = 52 . 424 \ n " , <nl> + " INFO : root : Iteration [ 0 ] Validation - accuracy = 0 . 652393 \ n " <nl> ] <nl> } <nl> ] , <nl> <nl> " # eval_data = test_dataiter , \ n " , <nl> " # eval_metric = \ " accuracy \ " , \ n " , <nl> " # epoch_end_callback = mx . helper . Speedometer ( batch_size ) , \ n " , <nl> - " # iter_end_callback = mx . model . do_checkpoint ( model_prefix ) ) \ n " <nl> + " # iter_end_callback = mx . callback . do_checkpoint ( model_prefix ) ) \ n " <nl> ] <nl> } , <nl> { <nl> " cell_type " : " markdown " , <nl> " metadata " : { } , <nl> " source " : [ <nl> - " After only 1 epoch , our model is able to acheive about 66 % accuracy on testset . \ n " , <nl> + " After only 1 epoch , our model is able to acheive about 65 % accuracy on testset . \ n " , <nl> " We can save our model by calling either ` ` ` save ` ` ` or using ` ` ` pickle ` ` ` . \ n " <nl> ] <nl> } , <nl> <nl> " output_type " : " stream " , <nl> " text " : [ <nl> " INFO : root : Finish predict . . . \ n " , <nl> - " INFO : root : final accuracy = 0 . 651000 \ n " <nl> + " INFO : root : final accuracy = 0 . 652600 \ n " <nl> ] <nl> } <nl> ] , <nl> <nl> } , <nl> { <nl> " cell_type " : " code " , <nl> - " execution_count " : 17 , <nl> + " execution_count " : 14 , <nl> " metadata " : { <nl> " collapsed " : false <nl> } , <nl> " outputs " : [ <nl> { <nl> - " ename " : " TypeError " , <nl> - " evalue " : " Symbol only support integer index to fetch i - th output " , <nl> - " output_type " : " error " , <nl> - " traceback " : [ <nl> - " \ u001b [ 1 ; 31mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm \ u001b [ 0m " , <nl> - " \ u001b [ 1 ; 31mTypeError \ u001b [ 0m Traceback ( most recent call last ) " , <nl> - " \ u001b [ 1 ; 32m < ipython - input - 17 - 0e3d13f4a151 > \ u001b [ 0m in \ u001b [ 0 ; 36m < module > \ u001b [ 1 ; 34m ( ) \ u001b [ 0m \ n \ u001b [ 0 ; 32m 2 \ u001b [ 0m \ u001b [ 0minternals \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0msoftmax \ u001b [ 0m \ u001b [ 1 ; 33m . \ u001b [ 0m \ u001b [ 0mget_internals \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 3 \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 1 ; 32mmmm - > 4 \ u001b [ 1 ; 33m \ u001b [ 0mfea_symbol \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0minternals \ u001b [ 0m \ u001b [ 1 ; 33m [ \ u001b [ 0m \ u001b [ 1 ; 34m \ " global_avg_output \ " \ u001b [ 0m \ u001b [ 1 ; 33m ] \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0m \ u001b [ 0 ; 32m 5 \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 6 \ u001b [ 0m feature_extractor = mx . model . FeedForward ( ctx = mx . gpu ( ) , symbol = group , \ n " , <nl> - " \ u001b [ 1 ; 32m / home / bing / wtf / mxnet / python / mxnet / symbol . py \ u001b [ 0m in \ u001b [ 0 ; 36m__getitem__ \ u001b [ 1 ; 34m ( self , index ) \ u001b [ 0m \ n \ u001b [ 0 ; 32m 156 \ u001b [ 0m \ u001b [ 1 ; 32mdef \ u001b [ 0m \ u001b [ 0m__getitem__ \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mself \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0mindex \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 157 \ u001b [ 0m \ u001b [ 1 ; 32mif \ u001b [ 0m \ u001b [ 1 ; 32mnot \ u001b [ 0m \ u001b [ 0misinstance \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 0mindex \ u001b [ 0m \ u001b [ 1 ; 33m , \ u001b [ 0m \ u001b [ 0mint \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m : \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 1 ; 32m - - > 158 \ u001b [ 1 ; 33m \ u001b [ 1 ; 32mraise \ u001b [ 0m \ u001b [ 0mTypeError \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 1 ; 34m ' Symbol only support integer index to fetch i - th output ' \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0m \ u001b [ 0 ; 32m 159 \ u001b [ 0m \ u001b [ 0mhandle \ u001b [ 0m \ u001b [ 1 ; 33m = \ u001b [ 0m \ u001b [ 0mSymbolHandle \ u001b [ 0m \ u001b [ 1 ; 33m ( \ u001b [ 0m \ u001b [ 1 ; 33m ) \ u001b [ 0m \ u001b [ 1 ; 33m \ u001b [ 0m \ u001b [ 0m \ n \ u001b [ 0 ; 32m 160 \ u001b [ 0m check_call ( _LIB . MXSymbolGetOutput ( \ n " , <nl> - " \ u001b [ 1 ; 31mTypeError \ u001b [ 0m : Symbol only support integer index to fetch i - th output " <nl> + " name " : " stdout " , <nl> + " output_type " : " stream " , <nl> + " text " : [ <nl> + " ( 10000 , 336 , 1 , 1 ) \ n " <nl> ] <nl> } <nl> ] , <nl> " source " : [ <nl> - " # predict internal featuremaps \ n " , <nl> + " # Predict internal featuremaps \ n " , <nl> + " # From a symbol , we are able to get all internals . Note it is still a symbol \ n " , <nl> " internals = softmax . get_internals ( ) \ n " , <nl> - " \ n " , <nl> + " # We get get an internal symbol for the feature . \ n " , <nl> + " # By default , the symbol is named as \ " symbol_name + _output \ " \ n " , <nl> + " # in this case we ' d like to get global_avg \ " layer ' s output as feature , so its \ " global_avg_output \ " \ n " , <nl> + " # You may call ` ` ` internals . list_outputs ( ) ` ` ` to find the target \ n " , <nl> + " # but we strongly suggests set a special name for special symbol \ n " , <nl> " fea_symbol = internals [ \ " global_avg_output \ " ] \ n " , <nl> " \ n " , <nl> - " feature_extractor = mx . model . FeedForward ( ctx = mx . gpu ( ) , symbol = group , \ n " , <nl> + " # Make a new model by using an internal symbol . We can reuse all parameters from model we trained before \ n " , <nl> + " # In this case , we must set ` ` ` allow_extra_params ` ` ` to True \ n " , <nl> + " feature_extractor = mx . model . FeedForward ( ctx = mx . gpu ( ) , symbol = fea_symbol , \ n " , <nl> " arg_params = model . arg_params , aux_params = model . aux_params , \ n " , <nl> " allow_extra_params = True ) \ n " , <nl> + " # Predict as normal \ n " , <nl> " global_pooling_feature = feature_extractor . predict ( test_dataiter ) \ n " , <nl> " print ( global_pooling_feature . shape ) " <nl> ] <nl> mmm a / python / mxnet / __init__ . py <nl> ppp b / python / mxnet / __init__ . py <nl> <nl> from . import optimizer <nl> from . import model <nl> from . import initializer <nl> + # use mx . init as short for mx . initializer <nl> + from . import initializer as init <nl> from . import visualization <nl> # use viz as short for mx . ndarray <nl> from . import visualization as viz <nl> mmm a / python / mxnet / ndarray . py <nl> ppp b / python / mxnet / ndarray . py <nl> def _slice ( self , start , stop ) : <nl> self . handle , start , stop , ctypes . byref ( handle ) ) ) <nl> return NDArray ( handle = handle , writable = self . writable ) <nl> <nl> + def clip ( self , value ) : <nl> + " " " Clip NDArray to range [ - value , value ] and remove NaN <nl> + <nl> + Parameters <nl> + mmmmmmmmm - <nl> + value : float <nl> + cliped range <nl> + " " " <nl> + return NDArray . _clip_scalar ( self , float ( value ) ) <nl> + <nl> def wait_to_read ( self ) : <nl> " " " Block until all pending writes operations on current NDArray are finished . <nl> <nl> def generic_ndarray_function ( * args , * * kwargs ) : <nl> ret_function . __name__ = func_name <nl> ret_function . __doc__ = doc_str <nl> return ret_function <nl> + <nl> + <nl> + <nl> # pylint : enable = too - many - locals , invalid - name <nl> <nl> def _init_ndarray_module ( ) : <nl> mmm a / python / mxnet / optimizer . py <nl> ppp b / python / mxnet / optimizer . py <nl> class SGD ( Optimizer ) : <nl> <nl> rescale_grad : float , optional <nl> rescaling factor of gradient . <nl> + <nl> + clip_gradient : float , optional <nl> + clip gradient in range [ - clip_gradient , clip_gradient ] <nl> " " " <nl> def __init__ ( self , learning_rate = 0 . 01 , momentum = 0 . 0 , <nl> - wd = 0 . 0001 , rescale_grad = 1 , lr_scheduler = None ) : <nl> + wd = 0 . 0001 , rescale_grad = 1 , clip_gradient = None , <nl> + lr_scheduler = None ) : <nl> super ( SGD , self ) . __init__ ( ) <nl> self . lr = learning_rate <nl> self . momentum = momentum <nl> self . wd = wd <nl> self . rescale_grad = rescale_grad <nl> + self . clip_gradient = clip_gradient <nl> self . lr_scheduler = lr_scheduler <nl> if lr_scheduler ! = None : <nl> self . lr_scheduler . base_lr = learning_rate <nl> def update ( self , index , weight , grad , state ) : <nl> if state : <nl> mom = state <nl> mom [ : ] * = self . momentum <nl> - mom [ : ] + = - lr * ( grad * self . rescale_grad + self . wd * weight ) <nl> + if self . clip_gradient = = None : <nl> + mom [ : ] + = - lr * ( grad * self . rescale_grad + self . wd * weight ) <nl> + else : <nl> + mom [ : ] + = - lr * ( grad . clip ( self . clip_gradient ) * self . rescale_grad + <nl> + self . wd * weight ) <nl> weight [ : ] + = mom <nl> else : <nl> assert self . momentum = = 0 . 0 <nl> mmm a / src / ndarray / ndarray . cc <nl> ppp b / src / ndarray / ndarray . cc <nl> NDArray operator * ( const NDArray & lhs , const real_t & rhs ) { <nl> NDArray operator / ( const NDArray & lhs , const real_t & rhs ) { <nl> return ScalarOpRet < ndarray : : Div , false > ( lhs , rhs ) ; <nl> } <nl> + <nl> / / Binary <nl> NDArray & NDArray : : operator = ( real_t scalar ) { <nl> SetValueOp ( scalar , this ) ; <nl> MXNET_REGISTER_NDARRAY_FUN ( _plus_scalar ) . set_function ( ScalarOp < ndarray : : Plus , fa <nl> MXNET_REGISTER_NDARRAY_FUN ( _minus_scalar ) . set_function ( ScalarOp < ndarray : : Minus , false > ) ; <nl> MXNET_REGISTER_NDARRAY_FUN ( _mul_scalar ) . set_function ( ScalarOp < ndarray : : Mul , false > ) ; <nl> MXNET_REGISTER_NDARRAY_FUN ( _div_scalar ) . set_function ( ScalarOp < ndarray : : Div , false > ) ; <nl> - <nl> + MXNET_REGISTER_NDARRAY_FUN ( _clip_scalar ) . set_function ( ScalarOp < ndarray : : Clip , false > ) ; <nl> / / register API function <nl> / / scalar , reverse scalar <nl> MXNET_REGISTER_NDARRAY_FUN ( _rminus_scalar ) . set_function ( ScalarOp < ndarray : : Minus , true > ) ; <nl> mmm a / src / ndarray / ndarray_function - inl . h <nl> ppp b / src / ndarray / ndarray_function - inl . h <nl> DECL_SCALAR ( DEVICE , Plus , EvalScalar_ , true ) <nl> DECL_SCALAR ( DEVICE , Minus , EvalScalar_ , true ) <nl> DECL_SCALAR ( DEVICE , Mul , EvalScalar_ , true ) <nl> DECL_SCALAR ( DEVICE , Div , EvalScalar_ , true ) <nl> + DECL_SCALAR ( DEVICE , Clip , EvalScalar_ , true ) <nl> / / for reverse seq <nl> DECL_SCALAR ( DEVICE , Plus , EvalScalar_ , false ) <nl> DECL_SCALAR ( DEVICE , Minus , EvalScalar_ , false ) <nl> DECL_SCALAR ( DEVICE , Mul , EvalScalar_ , false ) <nl> DECL_SCALAR ( DEVICE , Div , EvalScalar_ , false ) <nl> + DECL_SCALAR ( DEVICE , Clip , EvalScalar_ , false ) <nl> } / / namespace ndarray <nl> } / / namespace mxnet <nl> <nl> mmm a / src / ndarray / ndarray_function . h <nl> ppp b / src / ndarray / ndarray_function . h <nl> struct Div : public BinaryBase { <nl> typedef mshadow : : op : : div mshadow_op ; <nl> } ; <nl> <nl> + struct Clip : public BinaryBase { <nl> + struct mshadow_op { <nl> + MSHADOW_XINLINE static real_t Map ( real_t a , real_t b ) { <nl> + if ( isnan ( a ) ) return 0 . 0f ; <nl> + if ( a < - b ) return - b ; <nl> + if ( a > b ) return b ; <nl> + return a ; <nl> + } <nl> + } ; <nl> + } ; <nl> / / type holder for random number generators <nl> struct UniformDistribution { } ; <nl> <nl> | [ NDArray ] add clip op | apache/incubator-mxnet | 594773f817e1dc306860be661358c335a44737f1 | 2015-09-24T05:35:17Z |
mmm a / modules / gpu / test / test_optflow . cpp <nl> ppp b / modules / gpu / test / test_optflow . cpp <nl> GPU_TEST_P ( BroxOpticalFlow , Regression ) <nl> for ( int i = 0 ; i < v_gold . rows ; + + i ) <nl> f . read ( v_gold . ptr < char > ( i ) , v_gold . cols * sizeof ( float ) ) ; <nl> <nl> - EXPECT_MAT_NEAR ( u_gold , u , 0 ) ; <nl> - EXPECT_MAT_NEAR ( v_gold , v , 0 ) ; <nl> + EXPECT_MAT_SIMILAR ( u_gold , u , 1e - 3 ) ; <nl> + EXPECT_MAT_SIMILAR ( v_gold , v , 1e - 3 ) ; <nl> # else <nl> std : : ofstream f ( fname . c_str ( ) , std : : ios_base : : binary ) ; <nl> <nl> | fixed BroxOpticalFlow regression test | opencv/opencv | 516e5b2563100329882948f68aceb15b5fe8fe60 | 2013-06-04T09:58:45Z |
mmm a / torch / optim / lr_scheduler . py <nl> ppp b / torch / optim / lr_scheduler . py <nl> def step ( self , epoch = None ) : <nl> > > > iters = len ( dataloader ) <nl> > > > for epoch in range ( 20 ) : <nl> > > > for i , sample in enumerate ( dataloader ) : <nl> - > > > inputs , labels = sample [ ' inputs ' ] , sample [ ' labels ' ] <nl> + > > > inputs , labels = sample [ ' inputs ' ] , sample [ ' labels ' ] <nl> > > > scheduler . step ( epoch + i / iters ) <nl> > > > optimizer . zero_grad ( ) <nl> > > > outputs = net ( inputs ) <nl> | Remove tab . ( ) | pytorch/pytorch | 74bdcd44c4ea52896e56aef62369168abbf4a48e | 2019-05-20T18:57:18Z |
mmm a / util / file_allocator . cpp <nl> ppp b / util / file_allocator . cpp <nl> namespace mongo { <nl> / / TODO : we should to avoid fragmentation <nl> } <nl> <nl> + bool FileAllocator : : hasFailed ( ) const { <nl> + return false ; <nl> + } <nl> + <nl> # else <nl> <nl> FileAllocator : : FileAllocator ( ) <nl> namespace mongo { <nl> } <nl> } <nl> <nl> + bool FileAllocator : : hasFailed ( ) const { <nl> + return _failed ; <nl> + } <nl> + <nl> void FileAllocator : : checkFailure ( ) { <nl> if ( _failed ) { <nl> / / we want to log the problem ( diskfull . js expects it ) but we do not want to dump a stack tracke <nl> mmm a / util / file_allocator . h <nl> ppp b / util / file_allocator . h <nl> namespace mongo { <nl> void allocateAsap ( const string & name , unsigned long long & size ) ; <nl> <nl> void waitUntilFinished ( ) const ; <nl> + <nl> + bool hasFailed ( ) const ; <nl> <nl> static void ensureLength ( int fd , long size ) ; <nl> <nl> / * * @ return the singletone * / <nl> static FileAllocator * get ( ) ; <nl> - <nl> + <nl> private : <nl> <nl> FileAllocator ( ) ; <nl> | FileAllocator : : hasFailed method | mongodb/mongo | 651d142fdf64b14f697cab5dd7c32b0e6222fa43 | 2011-04-06T22:10:52Z |
mmm a / test / unit . cpp <nl> ppp b / test / unit . cpp <nl> TEST_CASE ( " parser class " ) <nl> CHECK ( json : : parser ( " { } " ) . parse ( ) = = json ( json : : value_t : : object ) ) ; <nl> CHECK ( json : : parser ( " { } " ) . parse ( ) = = json ( json : : value_t : : object ) ) ; <nl> } <nl> + <nl> + SECTION ( " nonempty object " ) <nl> + { <nl> + CHECK ( json : : parser ( " { \ " \ " : true , \ " one \ " : 1 , \ " two \ " : null } " ) . parse ( ) = = json ( { { " " , true } , { " one " , 1 } , { " two " , nullptr } } ) ) ; <nl> + } <nl> } <nl> <nl> SECTION ( " number " ) <nl> TEST_CASE ( " parser class " ) <nl> } <nl> } <nl> <nl> + SECTION ( " floating - point " ) <nl> + { <nl> + SECTION ( " without exponent " ) <nl> + { <nl> + CHECK ( json : : parser ( " - 128 . 5 " ) . parse ( ) = = json ( - 128 . 5 ) ) ; <nl> + CHECK ( json : : parser ( " 0 . 999 " ) . parse ( ) = = json ( 0 . 999 ) ) ; <nl> + CHECK ( json : : parser ( " 128 . 5 " ) . parse ( ) = = json ( 128 . 5 ) ) ; <nl> + } <nl> + } <nl> + <nl> SECTION ( " invalid numbers " ) <nl> { <nl> CHECK_THROWS_AS ( json : : parser ( " 01 " ) . parse ( ) , std : : invalid_argument ) ; <nl> | more test cases ( objects , floats ) | nlohmann/json | c1bf0025229e875310ae430c999381c0ca993b6c | 2015-02-11T10:57:36Z |
mmm a / src / catch2 / reporters / catch_reporter_cumulative_base . cpp <nl> ppp b / src / catch2 / reporters / catch_reporter_cumulative_base . cpp <nl> namespace Catch { <nl> BySectionInfo ( BySectionInfo const & other ) : <nl> m_other ( other . m_other ) { } <nl> bool operator ( ) ( <nl> - std : : shared_ptr < CumulativeReporterBase : : SectionNode > const & <nl> + Detail : : unique_ptr < CumulativeReporterBase : : SectionNode > const & <nl> node ) const { <nl> return ( <nl> ( node - > stats . sectionInfo . name = = m_other . name ) & & <nl> namespace Catch { <nl> void <nl> CumulativeReporterBase : : sectionStarting ( SectionInfo const & sectionInfo ) { <nl> SectionStats incompleteStats ( sectionInfo , Counts ( ) , 0 , false ) ; <nl> - std : : shared_ptr < SectionNode > node ; <nl> + SectionNode * node ; <nl> if ( m_sectionStack . empty ( ) ) { <nl> - if ( ! m_rootSection ) <nl> + if ( ! m_rootSection ) { <nl> m_rootSection = <nl> - std : : make_shared < SectionNode > ( incompleteStats ) ; <nl> - node = m_rootSection ; <nl> + Detail : : make_unique < SectionNode > ( incompleteStats ) ; <nl> + } <nl> + node = m_rootSection . get ( ) ; <nl> } else { <nl> SectionNode & parentNode = * m_sectionStack . back ( ) ; <nl> auto it = std : : find_if ( parentNode . childSections . begin ( ) , <nl> parentNode . childSections . end ( ) , <nl> BySectionInfo ( sectionInfo ) ) ; <nl> if ( it = = parentNode . childSections . end ( ) ) { <nl> - node = std : : make_shared < SectionNode > ( incompleteStats ) ; <nl> - parentNode . childSections . push_back ( node ) ; <nl> + auto newNode = <nl> + Detail : : make_unique < SectionNode > ( incompleteStats ) ; <nl> + node = newNode . get ( ) ; <nl> + parentNode . childSections . push_back ( std : : move ( newNode ) ) ; <nl> } else { <nl> - node = * it ; <nl> + node = it - > get ( ) ; <nl> } <nl> } <nl> <nl> - m_deepestSection = node . get ( ) ; <nl> - m_sectionStack . push_back ( node . get ( ) ) ; <nl> + m_deepestSection = node ; <nl> + m_sectionStack . push_back ( node ) ; <nl> } <nl> <nl> bool CumulativeReporterBase : : assertionEnded ( <nl> namespace Catch { <nl> <nl> void CumulativeReporterBase : : testCaseEnded ( <nl> TestCaseStats const & testCaseStats ) { <nl> - auto node = std : : make_shared < TestCaseNode > ( testCaseStats ) ; <nl> + auto node = Detail : : make_unique < TestCaseNode > ( testCaseStats ) ; <nl> assert ( m_sectionStack . size ( ) = = 0 ) ; <nl> - node - > children . push_back ( m_rootSection ) ; <nl> - m_testCases . push_back ( node ) ; <nl> - m_rootSection . reset ( ) ; <nl> + node - > children . push_back ( std : : move ( m_rootSection ) ) ; <nl> + m_testCases . push_back ( std : : move ( node ) ) ; <nl> <nl> assert ( m_deepestSection ) ; <nl> m_deepestSection - > stdOut = testCaseStats . stdOut ; <nl> namespace Catch { <nl> <nl> void CumulativeReporterBase : : testGroupEnded ( <nl> TestGroupStats const & testGroupStats ) { <nl> - auto node = std : : make_shared < TestGroupNode > ( testGroupStats ) ; <nl> + auto node = Detail : : make_unique < TestGroupNode > ( testGroupStats ) ; <nl> node - > children . swap ( m_testCases ) ; <nl> - m_testGroups . push_back ( node ) ; <nl> + m_testGroups . push_back ( std : : move ( node ) ) ; <nl> } <nl> <nl> void CumulativeReporterBase : : testRunEnded ( TestRunStats const & testRunStats ) { <nl> mmm a / src / catch2 / reporters / catch_reporter_cumulative_base . hpp <nl> ppp b / src / catch2 / reporters / catch_reporter_cumulative_base . hpp <nl> namespace Catch { <nl> struct Node { <nl> explicit Node ( T const & _value ) : value ( _value ) { } <nl> <nl> - using ChildNodes = std : : vector < std : : shared_ptr < ChildNodeT > > ; <nl> + using ChildNodes = std : : vector < Detail : : unique_ptr < ChildNodeT > > ; <nl> T value ; <nl> ChildNodes children ; <nl> } ; <nl> namespace Catch { <nl> } <nl> <nl> SectionStats stats ; <nl> - std : : vector < std : : shared_ptr < SectionNode > > childSections ; <nl> + std : : vector < Detail : : unique_ptr < SectionNode > > childSections ; <nl> std : : vector < AssertionStats > assertions ; <nl> std : : string stdOut ; <nl> std : : string stdErr ; <nl> namespace Catch { <nl> std : : ostream & stream ; <nl> / / Note : We rely on pointer identity being stable , which is why <nl> / / which is why we store around pointers rather than values . <nl> - std : : vector < std : : shared_ptr < TestCaseNode > > m_testCases ; <nl> - std : : vector < std : : shared_ptr < TestGroupNode > > m_testGroups ; <nl> + std : : vector < Detail : : unique_ptr < TestCaseNode > > m_testCases ; <nl> + std : : vector < Detail : : unique_ptr < TestGroupNode > > m_testGroups ; <nl> <nl> std : : vector < TestRunNode > m_testRuns ; <nl> <nl> - std : : shared_ptr < SectionNode > m_rootSection ; <nl> + Detail : : unique_ptr < SectionNode > m_rootSection ; <nl> SectionNode * m_deepestSection = nullptr ; <nl> std : : vector < SectionNode * > m_sectionStack ; <nl> } ; <nl> mmm a / src / catch2 / reporters / catch_reporter_sonarqube . cpp <nl> ppp b / src / catch2 / reporters / catch_reporter_sonarqube . cpp <nl> namespace Catch { <nl> } <nl> <nl> void SonarQubeReporter : : writeGroup ( TestGroupNode const & groupNode ) { <nl> - std : : map < std : : string , TestGroupNode : : ChildNodes > testsPerFile ; <nl> - for ( auto const & child : groupNode . children ) <nl> - testsPerFile [ child - > value . testInfo - > lineInfo . file ] . push_back ( child ) ; <nl> + std : : map < std : : string , std : : vector < TestCaseNode const * > > testsPerFile ; <nl> + for ( auto const & child : groupNode . children ) { <nl> + testsPerFile [ child - > value . testInfo - > lineInfo . file ] . push_back ( <nl> + child . get ( ) ) ; <nl> + } <nl> <nl> for ( auto const & kv : testsPerFile ) <nl> writeTestFile ( kv . first , kv . second ) ; <nl> } <nl> <nl> - void SonarQubeReporter : : writeTestFile ( std : : string const & filename , TestGroupNode : : ChildNodes const & testCaseNodes ) { <nl> + void SonarQubeReporter : : writeTestFile ( std : : string const & filename , std : : vector < TestCaseNode const * > const & testCaseNodes ) { <nl> XmlWriter : : ScopedElement e = xml . scopedElement ( " file " ) ; <nl> xml . writeAttribute ( " path " , filename ) ; <nl> <nl> mmm a / src / catch2 / reporters / catch_reporter_sonarqube . hpp <nl> ppp b / src / catch2 / reporters / catch_reporter_sonarqube . hpp <nl> namespace Catch { <nl> <nl> void writeGroup ( TestGroupNode const & groupNode ) ; <nl> <nl> - void writeTestFile ( std : : string const & filename , TestGroupNode : : ChildNodes const & testCaseNodes ) ; <nl> + void writeTestFile ( std : : string const & filename , std : : vector < TestCaseNode const * > const & testCaseNodes ) ; <nl> <nl> void writeTestCase ( TestCaseNode const & testCaseNode ) ; <nl> <nl> | Replace shared_ptrs with unique_ptrs in CumulativeReporterBase nodes | catchorg/Catch2 | 677adf8ade28e78fb0056cffce4227bd47b0e53a | 2020-11-26T13:45:27Z |
mmm a / arangod / Aql / ExecutionEngine . cpp <nl> ppp b / arangod / Aql / ExecutionEngine . cpp <nl> struct Instanciator : public WalkerWorker < ExecutionNode > { <nl> / / - - SECTION - - walker class for ExecutionNode to instanciate <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> + / / Here is a description of how the instanciation of an execution plan <nl> + / / works in the cluster . See below for a complete example <nl> + / / <nl> + / / The instanciation of this works as follows : <nl> + / / ( 0 ) Variable usage and register planning is done in the global plan <nl> + / / ( 1 ) A walk with subqueries is done on the whole plan <nl> + / / The purpose is to plan how many ExecutionEngines we need , where they <nl> + / / have to be instanciated and which plan nodes belong to each of them . <nl> + / / Such a walk is depth first and visits subqueries after it has visited <nl> + / / the dependencies of the subquery node recursively . Whenever the <nl> + / / walk passes by a RemoteNode it switches location between coordinator <nl> + / / and DBserver and starts a new engine . The nodes of an engine are <nl> + / / collected in the after method . <nl> + / / This walk results in a list of engines and a list of nodes for <nl> + / / each engine . It follows that the order in these lists is as follows : <nl> + / / The first engine is the main one on the coordinator , it has id 0 . <nl> + / / The order of the engines is exactly as they are discovered in the <nl> + / / walk . That is , engines closer to the root are earlier and engines <nl> + / / in subqueries are later . The nodes in each engine are always <nl> + / / done in a way such that a dependency D of a node N is earlier in the <nl> + / / list as N , and a subquery node is later in the list than the nodes <nl> + / / of the subquery . <nl> + / / ( 2 ) buildEngines is called with that data . It proceeds engine by engine , <nl> + / / starting from the back of the list . This means that an engine that <nl> + / / is referred to in a RemoteNode ( because its nodes are dependencies <nl> + / / of that node ) are always already instanciated before the RemoteNode <nl> + / / is instanciated . The corresponding query ids are collected in a <nl> + / / global hash table , for which the key consists of the id of the <nl> + / / RemoteNode using the query and the actual query id . For each engine , <nl> + / / the nodes are instanciated along the list of nodes for that engine . <nl> + / / This means that all dependencies of a node N are already instanciated <nl> + / / when N is instanciated . We distintuish the coordinator and the <nl> + / / DBserver case . In the former one we have to clone a part of the <nl> + / / plan and in the latter we have to send a part to a DBserver via HTTP . <nl> + / / <nl> + / / Here is a fully worked out example : <nl> + / / <nl> + / / FOR i IN [ 1 , 2 ] <nl> + / / FOR d IN coll <nl> + / / FILTER d . pass = = i <nl> + / / LET s = ( FOR e IN coll2 FILTER e . name = = d . name RETURN e ) <nl> + / / RETURN { d : d , s : s } <nl> + / / <nl> + / / this is optimized to , variable and register planning is done in this plan : <nl> + / / <nl> + / / Singleton <nl> + / / ^ <nl> + / / EnumList [ 1 , 2 ] Singleton <nl> + / / ^ ^ <nl> + / / Scatter ( 2 ) Enum coll2 <nl> + / / ^ ^ <nl> + / / Remote Calc e . name = = d . name <nl> + / / ^ ^ <nl> + / / Enum coll Filter ( 3 ) <nl> + / / ^ ^ <nl> + / / Calc d . pass = = i Remote <nl> + / / ^ ^ <nl> + / / Filter ( 1 ) Gather <nl> + / / ^ ^ <nl> + / / Remote Return <nl> + / / ^ ^ <nl> + / / Gather | <nl> + / / ^ | <nl> + / / Subquery mmmmmmmmmmmmmmmmmm - / <nl> + / / ^ <nl> + / / Calc { d : d , s : s } <nl> + / / ^ <nl> + / / Return ( 0 ) <nl> + / / <nl> + / / There are 4 engines here , their corresponding root nodes are labelled <nl> + / / in the above picture in round brackets with the ids of the engine . <nl> + / / Engines 1 and 3 have to be replicated for each shard of coll or coll2 <nl> + / / respectively , and sent to the right DBserver via HTTP . Engine 0 is the <nl> + / / main one on the coordinator and engine 2 is a non - main part on the <nl> + / / coordinator . Recall that the walk goes first to the dependencies before <nl> + / / it visits the nodes of the subquery . Thus , the walk builds up the lists <nl> + / / in this order : <nl> + / / engine 0 : [ Remote , Gather , Remote , Gather , Return , Subquery , Calc , Return ] <nl> + / / engine 1 : [ Remote , Enum coll , Calc d . pass = = i , Filter ] <nl> + / / engine 2 : [ Singleton , EnumList [ 1 , 2 ] , Scatter ] <nl> + / / engine 3 : [ Singleton , Enum coll2 , Calc e . name = = d . name , Filter ] <nl> + / / buildEngines will then do engines in the order 3 , 2 , 1 , 0 and for each <nl> + / / of them the nodes from left to right in these lists . In the end , we have <nl> + / / a proper instanciation of the whole thing . <nl> + <nl> + <nl> struct CoordinatorInstanciator : public WalkerWorker < ExecutionNode > { <nl> enum EngineLocation { <nl> COORDINATOR , <nl> | Add an explanation of the instanciation procedure . | arangodb/arangodb | 534ae76279702a0898c78624ad6949fc365d4b13 | 2014-10-29T12:09:11Z |
mmm a / build / deps / github_hashes / facebook / fbthrift - rev . txt <nl> ppp b / build / deps / github_hashes / facebook / fbthrift - rev . txt <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 72178dba37544dcda6ed7786364c0c968abd0d21 <nl> + Subproject commit 0a64c41c48454bff198d689c1d415d1a2635a95b <nl> mmm a / build / deps / github_hashes / facebook / folly - rev . txt <nl> ppp b / build / deps / github_hashes / facebook / folly - rev . txt <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit b84db9a9718c661208e984b4a4c91e01cc69bf4b <nl> + Subproject commit d7f0e32081e0af0a248ac05dcd4545c5246e3ab3 <nl> mmm a / build / deps / github_hashes / facebook / wangle - rev . txt <nl> ppp b / build / deps / github_hashes / facebook / wangle - rev . txt <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit fb428ea4698949d6c14d66569835c68cce65c1f9 <nl> + Subproject commit 323a2bc3e5755738ad31eb9270d689d06ba0d430 <nl> | Updating submodules | facebook/watchman | 656a7fb79626cd5d3553471e3ad030d81e7002e9 | 2020-01-06T00:22:03Z |
new file mode 100644 <nl> index 0000000000 . . 71dd7cbfd9 <nl> mmm / dev / null <nl> ppp b / code / unclassified / spiral_print_array / spiral_print_array . py <nl> <nl> + <nl> + ' ' ' <nl> + Part of Cosmos by OpenGenus Foundation <nl> + ' ' ' <nl> + <nl> + <nl> + <nl> + matrix = lambda x : map ( list , zip ( * [ iter ( range ( 1 , x * x + 1 ) ) ] * x ) ) <nl> + " " " <nl> + matrix = [ <nl> + [ 1 , 2 , 3 , 4 , 5 ] , <nl> + [ 6 , 7 , 8 , 9 , 10 ] , <nl> + [ 11 , 12 , 13 , 14 , 15 ] , <nl> + [ 16 , 17 , 18 , 19 , 20 ] , <nl> + [ 21 , 22 , 23 , 24 , 25 ] <nl> + ] <nl> + " " " <nl> + def main ( size ) : <nl> + a = matrix ( size ) <nl> + center = int ( size / 2 ) <nl> + r = c = center <nl> + l = 1 <nl> + while l < = center : <nl> + while c < = center + l : # right <nl> + print a [ r ] [ c ] <nl> + c + = 1 <nl> + c - = 1 <nl> + r + = 1 <nl> + while r < = center + l : # down <nl> + print a [ r ] [ c ] <nl> + r + = 1 <nl> + r - = 1 <nl> + c - = 1 <nl> + while c > = center - l : # left <nl> + print a [ r ] [ c ] <nl> + c - = 1 <nl> + c + = 1 <nl> + r - = 1 <nl> + while r > = center - l : # up <nl> + print a [ r ] [ c ] <nl> + r - = 1 <nl> + r + = 1 <nl> + c + = 1 <nl> + l + = 1 <nl> + for i in a [ r ] [ c : ] : <nl> + print i <nl> + main ( 5 ) <nl> + # One can change the size and matrix accordingly <nl> \ No newline at end of file <nl> | Merge pull request from sudhanshuchopra / master | OpenGenus/cosmos | dbde97891c469c54b0dd4b38193bc62d060aa60d | 2017-10-02T15:03:37Z |
mmm a / src / json . hpp <nl> ppp b / src / json . hpp <nl> class basic_json <nl> { <nl> / / avoid reading too many characters <nl> const size_t max_length = static_cast < size_t > ( limit - start ) ; <nl> - return std : : string ( start + offset , std : : min ( length , max_length - offset ) ) ; <nl> + return std : : string ( start + offset , ( std : : min ) ( length , max_length - offset ) ) ; <nl> } <nl> <nl> private : <nl> | Add parentheses around std : : min so it bypasses the macro introduced by windows . h . | nlohmann/json | 04a1666ef2e16de1af840f8bfb5f8e473271159a | 2017-06-17T20:01:18Z |
mmm a / caffe2 / python / task . py <nl> ppp b / caffe2 / python / task . py <nl> def __init__ ( self , workspace_type = None ) : <nl> self . _report_steps = [ ] <nl> self . _workspace_type = workspace_type <nl> self . _tasks_by_node = None <nl> + self . _remote_nets = [ ] <nl> + <nl> + def add_remote_net ( self , net ) : <nl> + self . _remote_nets . append ( net ) <nl> + <nl> + def remote_nets ( self ) : <nl> + return self . _remote_nets <nl> <nl> def add ( self , task ) : <nl> assert not self . _already_used , ( <nl> | Allowing TaskGroups to carry remote nets ( ) | pytorch/pytorch | e392d428b11128bcf203a4fe5b5f24b04bf545c9 | 2018-11-27T21:34:11Z |
mmm a / script / lib / config . py <nl> ppp b / script / lib / config . py <nl> <nl> BASE_URL = os . getenv ( ' LIBCHROMIUMCONTENT_MIRROR ' ) or \ <nl> ' https : / / s3 . amazonaws . com / github - janky - artifacts / libchromiumcontent ' <nl> LIBCHROMIUMCONTENT_COMMIT = os . getenv ( ' LIBCHROMIUMCONTENT_COMMIT ' ) or \ <nl> - ' 292bc81e83686ae5e7125163290928bf9b839560 ' <nl> + ' 82751b122d7f5cbedee5c662acc8cd1f1be8036d ' <nl> <nl> PLATFORM = { <nl> ' cygwin ' : ' win32 ' , <nl> | Merge pull request from electron / initialize - direct - write - font - proxy | electron/electron | ebaeec16774ea47f4db87de7c8e677e8aa8b459c | 2016-10-05T05:15:55Z |
mmm a / torch / lib / c10d / Store . cpp <nl> ppp b / torch / lib / c10d / Store . cpp <nl> constexpr std : : chrono : : milliseconds Store : : kNoTimeout ; <nl> Store : : ~ Store ( ) { } <nl> <nl> / / Set timeout function <nl> - void Store : : setTimeout ( const std : : chrono : : seconds & timeoutSec ) { <nl> - if ( timeoutSec . count ( ) = = 0 ) { <nl> + void Store : : setTimeout ( const std : : chrono : : milliseconds & timeout ) { <nl> + if ( timeout . count ( ) = = 0 ) { <nl> timeout_ = kNoTimeout ; <nl> } <nl> - timeout_ = timeoutSec ; <nl> + timeout_ = timeout ; <nl> } <nl> <nl> } / / namespace c10d <nl> mmm a / torch / lib / c10d / Store . hpp <nl> ppp b / torch / lib / c10d / Store . hpp <nl> class Store { <nl> const std : : vector < std : : string > & keys , <nl> const std : : chrono : : milliseconds & timeout ) = 0 ; <nl> <nl> - void setTimeout ( const std : : chrono : : seconds & timeoutSec ) ; <nl> + void setTimeout ( const std : : chrono : : milliseconds & timeout ) ; <nl> <nl> protected : <nl> std : : chrono : : milliseconds timeout_ ; <nl> | Make Store : : setTimeout take milliseconds ( ) | pytorch/pytorch | f924fc6eb10577cc119ab388873ebdb7c8f57151 | 2019-01-30T00:15:25Z |
mmm a / modules / core / include / opencv2 / core / ocl . hpp <nl> ppp b / modules / core / include / opencv2 / core / ocl . hpp <nl> class CV_EXPORTS Kernel <nl> Kernel ( ) ; <nl> Kernel ( const char * kname , const Program & prog ) ; <nl> Kernel ( const char * kname , const ProgramSource2 & prog , <nl> - const String & buildopts , String * errmsg = 0 ) ; <nl> + const String & buildopts = String ( ) , String * errmsg = 0 ) ; <nl> ~ Kernel ( ) ; <nl> Kernel ( const Kernel & k ) ; <nl> Kernel & operator = ( const Kernel & k ) ; <nl> mmm a / modules / core / src / umatrix . cpp <nl> ppp b / modules / core / src / umatrix . cpp <nl> Mat UMat : : getMat ( int accessFlags ) const <nl> u - > currAllocator - > map ( u , accessFlags | ACCESS_READ ) ; <nl> CV_Assert ( u - > data ! = 0 ) ; <nl> Mat hdr ( dims , size . p , type ( ) , u - > data + offset , step . p ) ; <nl> + hdr . flags = flags ; <nl> hdr . u = u ; <nl> hdr . datastart = u - > data ; <nl> hdr . data = hdr . datastart + offset ; <nl> mmm a / modules / imgproc / src / imgwarp . cpp <nl> ppp b / modules / imgproc / src / imgwarp . cpp <nl> static bool ocl_resize ( InputArray _src , OutputArray _dst , Size dsize , <nl> iscale_x , iscale_y , 1 . 0f / ( iscale_x * iscale_y ) ) ; <nl> <nl> k . create ( " resizeAREA_FAST " , ocl : : imgproc : : resize_oclsrc , buildOption ) ; <nl> + if ( k . empty ( ) ) <nl> + return false ; <nl> <nl> int smap_tab_size = dst . cols * iscale_x + dst . rows * iscale_y ; <nl> AutoBuffer < int > dmap_tab ( dst . cols + dst . rows ) , smap_tab ( smap_tab_size ) ; <nl> static bool ocl_resize ( InputArray _src , OutputArray _dst , Size dsize , <nl> { <nl> buildOption = buildOption + format ( " - D convertToT = % s " , ocl : : convertTypeStr ( wdepth , depth , cn , cvt [ 0 ] ) ) ; <nl> k . create ( " resizeAREA " , ocl : : imgproc : : resize_oclsrc , buildOption ) ; <nl> + if ( k . empty ( ) ) <nl> + return false ; <nl> <nl> Size ssize = src . size ( ) ; <nl> int xytab_size = ( ssize . width + ssize . height ) < < 1 ; <nl> class RemapInvoker : <nl> const void * ctab ; <nl> } ; <nl> <nl> + static bool ocl_remap ( InputArray _src , OutputArray _dst , InputArray _map1 , InputArray _map2 , <nl> + int interpolation , int borderType , const Scalar & borderValue ) <nl> + { <nl> + int cn = _src . channels ( ) , type = _src . type ( ) , depth = _src . depth ( ) ; <nl> + <nl> + if ( borderType = = BORDER_TRANSPARENT | | cn = = 3 | | ! ( interpolation = = INTER_LINEAR | | interpolation = = INTER_NEAREST ) <nl> + | | _map1 . type ( ) = = CV_16SC1 | | _map2 . type ( ) = = CV_16SC1 ) <nl> + return false ; <nl> + <nl> + UMat src = _src . getUMat ( ) , map1 = _map1 . getUMat ( ) , map2 = _map2 . getUMat ( ) ; <nl> + <nl> + if ( ( map1 . type ( ) = = CV_16SC2 & & ( map2 . type ( ) = = CV_16UC1 | | map2 . empty ( ) ) ) | | <nl> + ( map2 . type ( ) = = CV_16SC2 & & ( map1 . type ( ) = = CV_16UC1 | | map1 . empty ( ) ) ) ) <nl> + { <nl> + if ( map1 . type ( ) ! = CV_16SC2 ) <nl> + std : : swap ( map1 , map2 ) ; <nl> + } <nl> + else <nl> + CV_Assert ( map1 . type ( ) = = CV_32FC2 | | ( map1 . type ( ) = = CV_32FC1 & & map2 . type ( ) = = CV_32FC1 ) ) ; <nl> + <nl> + _dst . create ( map1 . size ( ) , type ) ; <nl> + UMat dst = _dst . getUMat ( ) ; <nl> + <nl> + String kernelName = " remap " ; <nl> + if ( map1 . type ( ) = = CV_32FC2 & & map2 . empty ( ) ) <nl> + kernelName + = " _32FC2 " ; <nl> + else if ( map1 . type ( ) = = CV_16SC2 ) <nl> + { <nl> + kernelName + = " _16SC2 " ; <nl> + if ( ! map2 . empty ( ) ) <nl> + kernelName + = " _16UC1 " ; <nl> + } <nl> + else if ( map1 . type ( ) = = CV_32FC1 & & map2 . type ( ) = = CV_32FC1 ) <nl> + kernelName + = " _2_32FC1 " ; <nl> + else <nl> + CV_Error ( Error : : StsBadArg , " Unsupported map types " ) ; <nl> + <nl> + static const char * const interMap [ ] = { " INTER_NEAREST " , " INTER_LINEAR " , " INTER_CUBIC " , " INTER_LINEAR " , " INTER_LANCZOS " } ; <nl> + static const char * const borderMap [ ] = { " BORDER_CONSTANT " , " BORDER_REPLICATE " , " BORDER_REFLECT " , " BORDER_WRAP " , <nl> + " BORDER_REFLECT_101 " , " BORDER_TRANSPARENT " } ; <nl> + String buildOptions = format ( " - D % s - D % s - D T = % s " , interMap [ interpolation ] , borderMap [ borderType ] , ocl : : typeToStr ( type ) ) ; <nl> + <nl> + if ( interpolation ! = INTER_NEAREST ) <nl> + { <nl> + char cvt [ 3 ] [ 40 ] ; <nl> + int wdepth = std : : max ( CV_32F , dst . depth ( ) ) ; <nl> + buildOptions = buildOptions <nl> + + format ( " - D WT = % s - D convertToT = % s - D convertToWT = % s " <nl> + " - D convertToWT2 = % s - D WT2 = % s " , <nl> + ocl : : typeToStr ( CV_MAKE_TYPE ( wdepth , cn ) ) , <nl> + ocl : : convertTypeStr ( wdepth , depth , cn , cvt [ 0 ] ) , <nl> + ocl : : convertTypeStr ( depth , wdepth , cn , cvt [ 1 ] ) , <nl> + ocl : : convertTypeStr ( CV_32S , wdepth , 2 , cvt [ 2 ] ) , <nl> + ocl : : typeToStr ( CV_MAKE_TYPE ( wdepth , 2 ) ) ) ; <nl> + } <nl> + <nl> + ocl : : Kernel k ( kernelName . c_str ( ) , ocl : : imgproc : : remap_oclsrc , buildOptions ) ; <nl> + <nl> + Mat scalar ( 1 , 1 , type , borderValue ) ; <nl> + ocl : : KernelArg srcarg = ocl : : KernelArg : : ReadOnly ( src ) , dstarg = ocl : : KernelArg : : WriteOnly ( dst ) , <nl> + map1arg = ocl : : KernelArg : : ReadOnlyNoSize ( map1 ) , <nl> + scalararg = ocl : : KernelArg : : Constant ( ( void * ) scalar . data , scalar . elemSize ( ) ) ; <nl> + <nl> + if ( map2 . empty ( ) ) <nl> + k . args ( srcarg , dstarg , map1arg , scalararg ) ; <nl> + else <nl> + k . args ( srcarg , dstarg , map1arg , ocl : : KernelArg : : ReadOnlyNoSize ( map2 ) , scalararg ) ; <nl> + <nl> + size_t globalThreads [ 2 ] = { dst . cols , dst . rows } ; <nl> + return k . run ( 2 , globalThreads , NULL , false ) ; <nl> + } <nl> + <nl> } <nl> <nl> void cv : : remap ( InputArray _src , OutputArray _dst , <nl> void cv : : remap ( InputArray _src , OutputArray _dst , <nl> remapLanczos4 < Cast < double , double > , float , 1 > , 0 <nl> } ; <nl> <nl> - Mat src = _src . getMat ( ) , map1 = _map1 . getMat ( ) , map2 = _map2 . getMat ( ) ; <nl> + CV_Assert ( _map1 . size ( ) . area ( ) > 0 ) ; <nl> + CV_Assert ( _map2 . empty ( ) | | ( _map2 . size ( ) = = _map1 . size ( ) ) ) ; <nl> <nl> - CV_Assert ( map1 . size ( ) . area ( ) > 0 ) ; <nl> - CV_Assert ( ! map2 . data | | ( map2 . size ( ) = = map1 . size ( ) ) ) ; <nl> + if ( ocl : : useOpenCL ( ) & & _dst . isUMat ( ) & & ocl_remap ( _src , _dst , _map1 , _map2 , interpolation , borderType , borderValue ) ) <nl> + return ; <nl> <nl> + Mat src = _src . getMat ( ) , map1 = _map1 . getMat ( ) , map2 = _map2 . getMat ( ) ; <nl> _dst . create ( map1 . size ( ) , src . type ( ) ) ; <nl> Mat dst = _dst . getMat ( ) ; <nl> if ( dst . data = = src . data ) <nl> class IPPwarpAffineInvoker : <nl> } ; <nl> # endif <nl> <nl> + enum { OCL_OP_PERSPECTIVE = 1 , OCL_OP_AFFINE = 0 } ; <nl> + <nl> + static bool ocl_warpTransform ( InputArray _src , OutputArray _dst , InputArray _M0 , <nl> + Size dsize , int flags , int borderType , const Scalar & borderValue , <nl> + int op_type ) <nl> + { <nl> + CV_Assert ( op_type = = OCL_OP_AFFINE | | op_type = = OCL_OP_PERSPECTIVE ) ; <nl> + <nl> + int type = _src . type ( ) , depth = CV_MAT_DEPTH ( type ) , cn = CV_MAT_CN ( type ) , wdepth = depth ; <nl> + double doubleSupport = ocl : : Device : : getDefault ( ) . doubleFPConfig ( ) > 0 ; <nl> + <nl> + int interpolation = flags & INTER_MAX ; <nl> + if ( interpolation = = INTER_AREA ) <nl> + interpolation = INTER_LINEAR ; <nl> + <nl> + if ( ! ( borderType = = cv : : BORDER_CONSTANT & & <nl> + ( interpolation = = cv : : INTER_NEAREST | | interpolation = = cv : : INTER_LINEAR | | interpolation = = cv : : INTER_CUBIC ) ) | | <nl> + ( ! doubleSupport & & depth = = CV_64F ) | | cn > 4 | | cn = = 3 ) <nl> + return false ; <nl> + <nl> + const char * const interpolationMap [ 3 ] = { " NEAREST " , " LINEAR " , " CUBIC " } ; <nl> + ocl : : ProgramSource2 program = op_type = = OCL_OP_AFFINE ? <nl> + ocl : : imgproc : : warp_affine_oclsrc : ocl : : imgproc : : warp_perspective_oclsrc ; <nl> + const char * const kernelName = op_type = = OCL_OP_AFFINE ? " warpAffine " : " warpPerspective " ; <nl> + <nl> + ocl : : Kernel k ; <nl> + if ( interpolation = = INTER_NEAREST ) <nl> + { <nl> + k . create ( kernelName , program , <nl> + format ( " - D INTER_NEAREST - D T = % s % s " , ocl : : typeToStr ( type ) , <nl> + doubleSupport ? " - D DOUBLE_SUPPORT " : " " ) ) ; <nl> + } <nl> + else <nl> + { <nl> + char cvt [ 2 ] [ 50 ] ; <nl> + wdepth = std : : max ( CV_32S , depth ) ; <nl> + k . create ( kernelName , program , <nl> + format ( " - D INTER_ % s - D T = % s - D WT = % s - D depth = % d - D convertToWT = % s - D convertToT = % s % s " , <nl> + interpolationMap [ interpolation ] , ocl : : typeToStr ( type ) , <nl> + ocl : : typeToStr ( CV_MAKE_TYPE ( wdepth , cn ) ) , depth , <nl> + ocl : : convertTypeStr ( depth , wdepth , cn , cvt [ 0 ] ) , <nl> + ocl : : convertTypeStr ( wdepth , depth , cn , cvt [ 1 ] ) , <nl> + doubleSupport ? " - D DOUBLE_SUPPORT " : " " ) ) ; <nl> + } <nl> + if ( k . empty ( ) ) <nl> + return false ; <nl> + <nl> + UMat src = _src . getUMat ( ) , M0 ; <nl> + _dst . create ( dsize . area ( ) = = 0 ? src . size ( ) : dsize , src . type ( ) ) ; <nl> + UMat dst = _dst . getUMat ( ) ; <nl> + <nl> + double M [ 9 ] ; <nl> + int matRows = ( op_type = = OCL_OP_AFFINE ? 2 : 3 ) ; <nl> + Mat matM ( matRows , 3 , CV_64F , M ) , M1 = _M0 . getMat ( ) ; <nl> + CV_Assert ( ( M1 . type ( ) = = CV_32F | | M1 . type ( ) = = CV_64F ) & & <nl> + M1 . rows = = matRows & & M1 . cols = = 3 ) ; <nl> + M1 . convertTo ( matM , matM . type ( ) ) ; <nl> + <nl> + if ( ! ( flags & WARP_INVERSE_MAP ) ) <nl> + { <nl> + if ( op_type = = OCL_OP_PERSPECTIVE ) <nl> + invert ( matM , matM ) ; <nl> + else <nl> + { <nl> + double D = M [ 0 ] * M [ 4 ] - M [ 1 ] * M [ 3 ] ; <nl> + D = D ! = 0 ? 1 . / D : 0 ; <nl> + double A11 = M [ 4 ] * D , A22 = M [ 0 ] * D ; <nl> + M [ 0 ] = A11 ; M [ 1 ] * = - D ; <nl> + M [ 3 ] * = - D ; M [ 4 ] = A22 ; <nl> + double b1 = - M [ 0 ] * M [ 2 ] - M [ 1 ] * M [ 5 ] ; <nl> + double b2 = - M [ 3 ] * M [ 2 ] - M [ 4 ] * M [ 5 ] ; <nl> + M [ 2 ] = b1 ; M [ 5 ] = b2 ; <nl> + } <nl> + } <nl> + matM . convertTo ( M0 , doubleSupport ? CV_64F : CV_32F ) ; <nl> + <nl> + k . args ( ocl : : KernelArg : : ReadOnly ( src ) , ocl : : KernelArg : : WriteOnly ( dst ) , ocl : : KernelArg : : PtrReadOnly ( M0 ) , <nl> + ocl : : KernelArg : : Constant ( Mat ( 1 , 1 , CV_MAKE_TYPE ( wdepth , cn ) , borderValue ) ) ) ; <nl> + <nl> + size_t globalThreads [ 2 ] = { dst . cols , dst . rows } ; <nl> + return k . run ( 2 , globalThreads , NULL , false ) ; <nl> + } <nl> + <nl> } <nl> <nl> <nl> void cv : : warpAffine ( InputArray _src , OutputArray _dst , <nl> InputArray _M0 , Size dsize , <nl> int flags , int borderType , const Scalar & borderValue ) <nl> { <nl> + if ( ocl : : useOpenCL ( ) & & _dst . isUMat ( ) & & <nl> + ocl_warpTransform ( _src , _dst , _M0 , dsize , flags , borderType , <nl> + borderValue , OCL_OP_AFFINE ) ) <nl> + return ; <nl> + <nl> Mat src = _src . getMat ( ) , M0 = _M0 . getMat ( ) ; <nl> _dst . create ( dsize . area ( ) = = 0 ? src . size ( ) : dsize , src . type ( ) ) ; <nl> Mat dst = _dst . getMat ( ) ; <nl> class IPPwarpPerspectiveInvoker : <nl> void cv : : warpPerspective ( InputArray _src , OutputArray _dst , InputArray _M0 , <nl> Size dsize , int flags , int borderType , const Scalar & borderValue ) <nl> { <nl> + CV_Assert ( _src . total ( ) > 0 ) ; <nl> + <nl> + if ( ocl : : useOpenCL ( ) & & _dst . isUMat ( ) & & <nl> + ocl_warpTransform ( _src , _dst , _M0 , dsize , flags , borderType , borderValue , <nl> + OCL_OP_PERSPECTIVE ) ) <nl> + return ; <nl> + <nl> Mat src = _src . getMat ( ) , M0 = _M0 . getMat ( ) ; <nl> _dst . create ( dsize . area ( ) = = 0 ? src . size ( ) : dsize , src . type ( ) ) ; <nl> Mat dst = _dst . getMat ( ) ; <nl> <nl> - CV_Assert ( src . cols > 0 & & src . rows > 0 ) ; <nl> if ( dst . data = = src . data ) <nl> src = src . clone ( ) ; <nl> <nl> new file mode 100644 <nl> index 00000000000 . . aaa9dc371b4 <nl> mmm / dev / null <nl> ppp b / modules / imgproc / src / opencl / remap . cl <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2010 - 2012 , Institute Of Software Chinese Academy Of Science , all rights reserved . <nl> + / / Copyright ( C ) 2010 - 2012 , Advanced Micro Devices , Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / @ Authors <nl> + / / Wu Zailong , bullet @ yeah . net <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors as is and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # ifdef DOUBLE_SUPPORT <nl> + # ifdef cl_amd_fp64 <nl> + # pragma OPENCL EXTENSION cl_amd_fp64 : enable <nl> + # elif defined ( cl_khr_fp64 ) <nl> + # pragma OPENCL EXTENSION cl_khr_fp64 : enable <nl> + # endif <nl> + # endif <nl> + <nl> + # define noconvert <nl> + <nl> + enum <nl> + { <nl> + INTER_BITS = 5 , <nl> + INTER_TAB_SIZE = 1 < < INTER_BITS , <nl> + INTER_TAB_SIZE2 = INTER_TAB_SIZE * INTER_TAB_SIZE <nl> + } ; <nl> + <nl> + # ifdef INTER_NEAREST <nl> + # define convertToWT <nl> + # endif <nl> + <nl> + # ifdef BORDER_CONSTANT <nl> + # define EXTRAPOLATE ( v2 , v ) v = scalar ; <nl> + # elif defined BORDER_REPLICATE <nl> + # define EXTRAPOLATE ( v2 , v ) \ <nl> + { \ <nl> + v2 = max ( min ( v2 , ( int2 ) ( src_cols - 1 , src_rows - 1 ) ) , ( int2 ) ( 0 ) ) ; \ <nl> + v = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( v2 . y , src_step , v2 . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; \ <nl> + } <nl> + # elif defined BORDER_WRAP <nl> + # define EXTRAPOLATE ( v2 , v ) \ <nl> + { \ <nl> + if ( v2 . x < 0 ) \ <nl> + v2 . x - = ( ( v2 . x - src_cols + 1 ) / src_cols ) * src_cols ; \ <nl> + if ( v2 . x > = src_cols ) \ <nl> + v2 . x % = src_cols ; \ <nl> + \ <nl> + if ( v2 . y < 0 ) \ <nl> + v2 . y - = ( ( v2 . y - src_rows + 1 ) / src_rows ) * src_rows ; \ <nl> + if ( v2 . y > = src_rows ) \ <nl> + v2 . y % = src_rows ; \ <nl> + v = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( v2 . y , src_step , v2 . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; \ <nl> + } <nl> + # elif defined ( BORDER_REFLECT ) | | defined ( BORDER_REFLECT_101 ) <nl> + # ifdef BORDER_REFLECT <nl> + # define DELTA int delta = 0 <nl> + # else <nl> + # define DELTA int delta = 1 <nl> + # endif <nl> + # define EXTRAPOLATE ( v2 , v ) \ <nl> + { \ <nl> + DELTA ; \ <nl> + if ( src_cols = = 1 ) \ <nl> + v2 . x = 0 ; \ <nl> + else \ <nl> + do \ <nl> + { \ <nl> + if ( v2 . x < 0 ) \ <nl> + v2 . x = - v2 . x - 1 + delta ; \ <nl> + else \ <nl> + v2 . x = src_cols - 1 - ( v2 . x - src_cols ) - delta ; \ <nl> + } \ <nl> + while ( v2 . x > = src_cols | | v2 . x < 0 ) ; \ <nl> + \ <nl> + if ( src_rows = = 1 ) \ <nl> + v2 . y = 0 ; \ <nl> + else \ <nl> + do \ <nl> + { \ <nl> + if ( v2 . y < 0 ) \ <nl> + v2 . y = - v2 . y - 1 + delta ; \ <nl> + else \ <nl> + v2 . y = src_rows - 1 - ( v2 . y - src_rows ) - delta ; \ <nl> + } \ <nl> + while ( v2 . y > = src_rows | | v2 . y < 0 ) ; \ <nl> + v = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( v2 . y , src_step , v2 . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; \ <nl> + } <nl> + # else <nl> + # error No extrapolation method <nl> + # endif <nl> + <nl> + # define NEED_EXTRAPOLATION ( gx , gy ) ( gx > = src_cols | | gy > = src_rows | | gx < 0 | | gy < 0 ) <nl> + <nl> + # ifdef INTER_NEAREST <nl> + <nl> + __kernel void remap_2_32FC1 ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __global const uchar * map1ptr , int map1_step , int map1_offset , <nl> + __global const uchar * map2ptr , int map2_step , int map2_offset , <nl> + T scalar ) <nl> + { <nl> + int x = get_global_id ( 0 ) ; <nl> + int y = get_global_id ( 1 ) ; <nl> + <nl> + if ( x < dst_cols & & y < dst_rows ) <nl> + { <nl> + int map1_index = mad24 ( y , map1_step , x * ( int ) sizeof ( float ) + map1_offset ) ; <nl> + int map2_index = mad24 ( y , map2_step , x * ( int ) sizeof ( float ) + map2_offset ) ; <nl> + int dst_index = mad24 ( y , dst_step , x * ( int ) sizeof ( T ) + dst_offset ) ; <nl> + <nl> + __global const float * map1 = ( __global const float * ) ( map1ptr + map1_index ) ; <nl> + __global const float * map2 = ( __global const float * ) ( map2ptr + map2_index ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + int gx = convert_int_sat_rte ( map1 [ 0 ] ) ; <nl> + int gy = convert_int_sat_rte ( map2 [ 0 ] ) ; <nl> + <nl> + if ( NEED_EXTRAPOLATION ( gx , gy ) ) <nl> + { <nl> + # ifndef BORDER_CONSTANT <nl> + int2 gxy = ( int2 ) ( gx , gy ) ; <nl> + # endif <nl> + EXTRAPOLATE ( gxy , dst [ 0 ] ) <nl> + } <nl> + else <nl> + { <nl> + int src_index = mad24 ( gy , src_step , gx * ( int ) sizeof ( T ) + src_offset ) ; <nl> + dst [ 0 ] = * ( ( __global const T * ) ( srcptr + src_index ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + __kernel void remap_32FC2 ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __global const uchar * mapptr , int map_step , int map_offset , <nl> + T scalar ) <nl> + { <nl> + int x = get_global_id ( 0 ) ; <nl> + int y = get_global_id ( 1 ) ; <nl> + <nl> + if ( x < dst_cols & & y < dst_rows ) <nl> + { <nl> + int dst_index = mad24 ( y , dst_step , x * ( int ) sizeof ( T ) + dst_offset ) ; <nl> + int map_index = mad24 ( y , map_step , x * ( int ) sizeof ( float2 ) + map_offset ) ; <nl> + <nl> + __global const float2 * map = ( __global const float2 * ) ( mapptr + map_index ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + int2 gxy = convert_int2_sat_rte ( map [ 0 ] ) ; <nl> + int gx = gxy . x , gy = gxy . y ; <nl> + <nl> + if ( NEED_EXTRAPOLATION ( gx , gy ) ) <nl> + EXTRAPOLATE ( gxy , dst [ 0 ] ) <nl> + else <nl> + { <nl> + int src_index = mad24 ( gy , src_step , gx * ( int ) sizeof ( T ) + src_offset ) ; <nl> + dst [ 0 ] = * ( ( __global const T * ) ( srcptr + src_index ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + __kernel void remap_16SC2 ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __global const uchar * mapptr , int map_step , int map_offset , <nl> + T scalar ) <nl> + { <nl> + int x = get_global_id ( 0 ) ; <nl> + int y = get_global_id ( 1 ) ; <nl> + <nl> + if ( x < dst_cols & & y < dst_rows ) <nl> + { <nl> + int dst_index = mad24 ( y , dst_step , x * ( int ) sizeof ( T ) + dst_offset ) ; <nl> + int map_index = mad24 ( y , map_step , x * ( int ) sizeof ( short2 ) + map_offset ) ; <nl> + <nl> + __global const short2 * map = ( __global const short2 * ) ( mapptr + map_index ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + int2 gxy = convert_int2 ( map [ 0 ] ) ; <nl> + int gx = gxy . x , gy = gxy . y ; <nl> + <nl> + if ( NEED_EXTRAPOLATION ( gx , gy ) ) <nl> + EXTRAPOLATE ( gxy , dst [ 0 ] ) <nl> + else <nl> + { <nl> + int src_index = mad24 ( gy , src_step , gx * ( int ) sizeof ( T ) + src_offset ) ; <nl> + dst [ 0 ] = * ( ( __global const T * ) ( srcptr + src_index ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + __kernel void remap_16SC2_16UC1 ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __global const uchar * map1ptr , int map1_step , int map1_offset , <nl> + __global const uchar * map2ptr , int map2_step , int map2_offset , <nl> + T scalar ) <nl> + { <nl> + int x = get_global_id ( 0 ) ; <nl> + int y = get_global_id ( 1 ) ; <nl> + <nl> + if ( x < dst_cols & & y < dst_rows ) <nl> + { <nl> + int dst_index = mad24 ( y , dst_step , x * ( int ) sizeof ( T ) + dst_offset ) ; <nl> + int map1_index = mad24 ( y , map1_step , x * ( int ) sizeof ( short2 ) + map1_offset ) ; <nl> + int map2_index = mad24 ( y , map2_step , x * ( int ) sizeof ( ushort ) + map2_offset ) ; <nl> + <nl> + __global const short2 * map1 = ( __global const short2 * ) ( map1ptr + map1_index ) ; <nl> + __global const ushort * map2 = ( __global const ushort * ) ( map2ptr + map2_index ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + int map2Value = convert_int ( map2 [ 0 ] ) & ( INTER_TAB_SIZE2 - 1 ) ; <nl> + int dx = ( map2Value & ( INTER_TAB_SIZE - 1 ) ) < ( INTER_TAB_SIZE > > 1 ) ? 1 : 0 ; <nl> + int dy = ( map2Value > > INTER_BITS ) < ( INTER_TAB_SIZE > > 1 ) ? 1 : 0 ; <nl> + int2 gxy = convert_int2 ( map1 [ 0 ] ) + ( int2 ) ( dx , dy ) ; <nl> + int gx = gxy . x , gy = gxy . y ; <nl> + <nl> + if ( NEED_EXTRAPOLATION ( gx , gy ) ) <nl> + EXTRAPOLATE ( gxy , dst [ 0 ] ) <nl> + else <nl> + { <nl> + int src_index = mad24 ( gy , src_step , gx * ( int ) sizeof ( T ) + src_offset ) ; <nl> + dst [ 0 ] = * ( ( __global const T * ) ( srcptr + src_index ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + # elif INTER_LINEAR <nl> + <nl> + __kernel void remap_16SC2_16UC1 ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __global const uchar * map1ptr , int map1_step , int map1_offset , <nl> + __global const uchar * map2ptr , int map2_step , int map2_offset , <nl> + T nVal ) <nl> + { <nl> + int x = get_global_id ( 0 ) ; <nl> + int y = get_global_id ( 1 ) ; <nl> + <nl> + if ( x < dst_cols & & y < dst_rows ) <nl> + { <nl> + int dst_index = mad24 ( y , dst_step , x * ( int ) sizeof ( T ) + dst_offset ) ; <nl> + int map1_index = mad24 ( y , map1_step , x * ( int ) sizeof ( short2 ) + map1_offset ) ; <nl> + int map2_index = mad24 ( y , map2_step , x * ( int ) sizeof ( ushort ) + map2_offset ) ; <nl> + <nl> + __global const short2 * map1 = ( __global const short2 * ) ( map1ptr + map1_index ) ; <nl> + __global const ushort * map2 = ( __global const ushort * ) ( map2ptr + map2_index ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + int2 map_dataA = convert_int2 ( map1 [ 0 ] ) ; <nl> + int2 map_dataB = ( int2 ) ( map_dataA . x + 1 , map_dataA . y ) ; <nl> + int2 map_dataC = ( int2 ) ( map_dataA . x , map_dataA . y + 1 ) ; <nl> + int2 map_dataD = ( int2 ) ( map_dataA . x + 1 , map_dataA . y + 1 ) ; <nl> + <nl> + ushort map2Value = ( ushort ) ( map2 [ 0 ] & ( INTER_TAB_SIZE2 - 1 ) ) ; <nl> + WT2 u = ( WT2 ) ( map2Value & ( INTER_TAB_SIZE - 1 ) , map2Value > > INTER_BITS ) / ( WT2 ) ( INTER_TAB_SIZE ) ; <nl> + <nl> + WT scalar = convertToWT ( nVal ) ; <nl> + WT a = scalar , b = scalar , c = scalar , d = scalar ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataA . x , map_dataA . y ) ) <nl> + a = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataA . y , src_step , map_dataA . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataA , a ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataB . x , map_dataB . y ) ) <nl> + b = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataB . y , src_step , map_dataB . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataB , b ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataC . x , map_dataC . y ) ) <nl> + c = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataC . y , src_step , map_dataC . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataC , c ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataD . x , map_dataD . y ) ) <nl> + d = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataD . y , src_step , map_dataD . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataD , d ) ; <nl> + <nl> + WT dst_data = a * ( 1 - u . x ) * ( 1 - u . y ) + <nl> + b * ( u . x ) * ( 1 - u . y ) + <nl> + c * ( 1 - u . x ) * ( u . y ) + <nl> + d * ( u . x ) * ( u . y ) ; <nl> + dst [ 0 ] = convertToT ( dst_data ) ; <nl> + } <nl> + } <nl> + <nl> + __kernel void remap_2_32FC1 ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __global const uchar * map1ptr , int map1_step , int map1_offset , <nl> + __global const uchar * map2ptr , int map2_step , int map2_offset , <nl> + T nVal ) <nl> + { <nl> + int x = get_global_id ( 0 ) ; <nl> + int y = get_global_id ( 1 ) ; <nl> + <nl> + if ( x < dst_cols & & y < dst_rows ) <nl> + { <nl> + int dst_index = mad24 ( y , dst_step , x * ( int ) sizeof ( T ) + dst_offset ) ; <nl> + int map1_index = mad24 ( y , map1_step , x * ( int ) sizeof ( float ) + map1_offset ) ; <nl> + int map2_index = mad24 ( y , map2_step , x * ( int ) sizeof ( float ) + map2_offset ) ; <nl> + <nl> + __global const float * map1 = ( __global const float * ) ( map1ptr + map1_index ) ; <nl> + __global const float * map2 = ( __global const float * ) ( map2ptr + map2_index ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + float2 map_data = ( float2 ) ( map1 [ 0 ] , map2 [ 0 ] ) ; <nl> + <nl> + int2 map_dataA = convert_int2_sat_rtn ( map_data ) ; <nl> + int2 map_dataB = ( int2 ) ( map_dataA . x + 1 , map_dataA . y ) ; <nl> + int2 map_dataC = ( int2 ) ( map_dataA . x , map_dataA . y + 1 ) ; <nl> + int2 map_dataD = ( int2 ) ( map_dataA . x + 1 , map_dataA . y + 1 ) ; <nl> + <nl> + float2 _u = map_data - convert_float2 ( map_dataA ) ; <nl> + WT2 u = convertToWT2 ( convert_int2_rte ( convertToWT2 ( _u ) * ( WT2 ) INTER_TAB_SIZE ) ) / ( WT2 ) INTER_TAB_SIZE ; <nl> + WT scalar = convertToWT ( nVal ) ; <nl> + WT a = scalar , b = scalar , c = scalar , d = scalar ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataA . x , map_dataA . y ) ) <nl> + a = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataA . y , src_step , map_dataA . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataA , a ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataB . x , map_dataB . y ) ) <nl> + b = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataB . y , src_step , map_dataB . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataB , b ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataC . x , map_dataC . y ) ) <nl> + c = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataC . y , src_step , map_dataC . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataC , c ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataD . x , map_dataD . y ) ) <nl> + d = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataD . y , src_step , map_dataD . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataD , d ) ; <nl> + <nl> + WT dst_data = a * ( 1 - u . x ) * ( 1 - u . y ) + <nl> + b * ( u . x ) * ( 1 - u . y ) + <nl> + c * ( 1 - u . x ) * ( u . y ) + <nl> + d * ( u . x ) * ( u . y ) ; <nl> + dst [ 0 ] = convertToT ( dst_data ) ; <nl> + } <nl> + } <nl> + <nl> + __kernel void remap_32FC2 ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __global const uchar * mapptr , int map_step , int map_offset , <nl> + T nVal ) <nl> + { <nl> + int x = get_global_id ( 0 ) ; <nl> + int y = get_global_id ( 1 ) ; <nl> + <nl> + if ( x < dst_cols & & y < dst_rows ) <nl> + { <nl> + int dst_index = mad24 ( y , dst_step , x * ( int ) sizeof ( T ) + dst_offset ) ; <nl> + int map_index = mad24 ( y , map_step , x * ( int ) sizeof ( float2 ) + map_offset ) ; <nl> + <nl> + __global const float2 * map = ( __global const float2 * ) ( mapptr + map_index ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + float2 map_data = map [ 0 ] ; <nl> + int2 map_dataA = convert_int2_sat_rtn ( map_data ) ; <nl> + int2 map_dataB = ( int2 ) ( map_dataA . x + 1 , map_dataA . y ) ; <nl> + int2 map_dataC = ( int2 ) ( map_dataA . x , map_dataA . y + 1 ) ; <nl> + int2 map_dataD = ( int2 ) ( map_dataA . x + 1 , map_dataA . y + 1 ) ; <nl> + <nl> + float2 _u = map_data - convert_float2 ( map_dataA ) ; <nl> + WT2 u = convertToWT2 ( convert_int2_rte ( convertToWT2 ( _u ) * ( WT2 ) INTER_TAB_SIZE ) ) / ( WT2 ) INTER_TAB_SIZE ; <nl> + WT scalar = convertToWT ( nVal ) ; <nl> + WT a = scalar , b = scalar , c = scalar , d = scalar ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataA . x , map_dataA . y ) ) <nl> + a = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataA . y , src_step , map_dataA . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataA , a ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataB . x , map_dataB . y ) ) <nl> + b = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataB . y , src_step , map_dataB . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataB , b ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataC . x , map_dataC . y ) ) <nl> + c = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataC . y , src_step , map_dataC . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataC , c ) ; <nl> + <nl> + if ( ! NEED_EXTRAPOLATION ( map_dataD . x , map_dataD . y ) ) <nl> + d = convertToWT ( * ( ( __global const T * ) ( srcptr + mad24 ( map_dataD . y , src_step , map_dataD . x * ( int ) sizeof ( T ) + src_offset ) ) ) ) ; <nl> + else <nl> + EXTRAPOLATE ( map_dataD , d ) ; <nl> + <nl> + WT dst_data = a * ( 1 - u . x ) * ( 1 - u . y ) + <nl> + b * ( u . x ) * ( 1 - u . y ) + <nl> + c * ( 1 - u . x ) * ( u . y ) + <nl> + d * ( u . x ) * ( u . y ) ; <nl> + dst [ 0 ] = convertToT ( dst_data ) ; <nl> + } <nl> + } <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 340cfdd8e07 <nl> mmm / dev / null <nl> ppp b / modules / imgproc / src / opencl / warp_affine . cl <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2010 - 2012 , Institute Of Software Chinese Academy Of Science , all rights reserved . <nl> + / / Copyright ( C ) 2010 - 2012 , Advanced Micro Devices , Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / @ Authors <nl> + / / Zhang Ying , zhangying913 @ gmail . com <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors as is and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # ifdef DOUBLE_SUPPORT <nl> + # ifdef cl_amd_fp64 <nl> + # pragma OPENCL EXTENSION cl_amd_fp64 : enable <nl> + # elif defined ( cl_khr_fp64 ) <nl> + # pragma OPENCL EXTENSION cl_khr_fp64 : enable <nl> + # endif <nl> + # define CT double <nl> + # else <nl> + # define CT float <nl> + # endif <nl> + <nl> + # define INTER_BITS 5 <nl> + # define INTER_TAB_SIZE ( 1 < < INTER_BITS ) <nl> + # define INTER_SCALE 1 . f / INTER_TAB_SIZE <nl> + # define AB_BITS max ( 10 , ( int ) INTER_BITS ) <nl> + # define AB_SCALE ( 1 < < AB_BITS ) <nl> + # define INTER_REMAP_COEF_BITS 15 <nl> + # define INTER_REMAP_COEF_SCALE ( 1 < < INTER_REMAP_COEF_BITS ) <nl> + <nl> + # define noconvert <nl> + <nl> + # ifdef INTER_NEAREST <nl> + <nl> + __kernel void warpAffine ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __constant CT * M , T scalar ) <nl> + { <nl> + int dx = get_global_id ( 0 ) ; <nl> + int dy = get_global_id ( 1 ) ; <nl> + <nl> + if ( dx < dst_cols & & dy < dst_rows ) <nl> + { <nl> + int round_delta = ( AB_SCALE > > 1 ) ; <nl> + <nl> + int X0 = rint ( M [ 0 ] * dx * AB_SCALE ) ; <nl> + int Y0 = rint ( M [ 3 ] * dx * AB_SCALE ) ; <nl> + X0 + = rint ( ( M [ 1 ] * dy + M [ 2 ] ) * AB_SCALE ) + round_delta ; <nl> + Y0 + = rint ( ( M [ 4 ] * dy + M [ 5 ] ) * AB_SCALE ) + round_delta ; <nl> + <nl> + short sx = convert_short_sat ( X0 > > AB_BITS ) ; <nl> + short sy = convert_short_sat ( Y0 > > AB_BITS ) ; <nl> + <nl> + int dst_index = mad24 ( dy , dst_step , dst_offset + dx * ( int ) sizeof ( T ) ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + if ( sx > = 0 & & sx < src_cols & & sy > = 0 & & sy < src_rows ) <nl> + { <nl> + int src_index = mad24 ( sy , src_step , src_offset + sx * ( int ) sizeof ( T ) ) ; <nl> + __global const T * src = ( __global const T * ) ( srcptr + src_index ) ; <nl> + dst [ 0 ] = src [ 0 ] ; <nl> + } <nl> + else <nl> + dst [ 0 ] = scalar ; <nl> + } <nl> + } <nl> + <nl> + # elif defined INTER_LINEAR <nl> + <nl> + __kernel void warpAffine ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __constant CT * M , WT scalar ) <nl> + { <nl> + int dx = get_global_id ( 0 ) ; <nl> + int dy = get_global_id ( 1 ) ; <nl> + <nl> + if ( dx < dst_cols & & dy < dst_rows ) <nl> + { <nl> + int round_delta = AB_SCALE / INTER_TAB_SIZE / 2 ; <nl> + <nl> + int tmp = ( dx < < AB_BITS ) ; <nl> + int X0 = rint ( M [ 0 ] * tmp ) ; <nl> + int Y0 = rint ( M [ 3 ] * tmp ) ; <nl> + X0 + = rint ( ( M [ 1 ] * dy + M [ 2 ] ) * AB_SCALE ) + round_delta ; <nl> + Y0 + = rint ( ( M [ 4 ] * dy + M [ 5 ] ) * AB_SCALE ) + round_delta ; <nl> + X0 = X0 > > ( AB_BITS - INTER_BITS ) ; <nl> + Y0 = Y0 > > ( AB_BITS - INTER_BITS ) ; <nl> + <nl> + short sx = convert_short_sat ( X0 > > INTER_BITS ) ; <nl> + short sy = convert_short_sat ( Y0 > > INTER_BITS ) ; <nl> + short ax = convert_short ( X0 & ( INTER_TAB_SIZE - 1 ) ) ; <nl> + short ay = convert_short ( Y0 & ( INTER_TAB_SIZE - 1 ) ) ; <nl> + <nl> + WT v0 = ( sx > = 0 & & sx < src_cols & & sy > = 0 & & sy < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy , src_step , src_offset + sx * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + WT v1 = ( sx + 1 > = 0 & & sx + 1 < src_cols & & sy > = 0 & & sy < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy , src_step , src_offset + ( sx + 1 ) * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + WT v2 = ( sx > = 0 & & sx < src_cols & & sy + 1 > = 0 & & sy + 1 < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy + 1 , src_step , src_offset + sx * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + WT v3 = ( sx + 1 > = 0 & & sx + 1 < src_cols & & sy + 1 > = 0 & & sy + 1 < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy + 1 , src_step , src_offset + ( sx + 1 ) * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + <nl> + float taby = 1 . f / INTER_TAB_SIZE * ay ; <nl> + float tabx = 1 . f / INTER_TAB_SIZE * ax ; <nl> + <nl> + int dst_index = mad24 ( dy , dst_step , dst_offset + dx * ( int ) sizeof ( T ) ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + # if depth < = 4 <nl> + int itab0 = convert_short_sat_rte ( ( 1 . 0f - taby ) * ( 1 . 0f - tabx ) * INTER_REMAP_COEF_SCALE ) ; <nl> + int itab1 = convert_short_sat_rte ( ( 1 . 0f - taby ) * tabx * INTER_REMAP_COEF_SCALE ) ; <nl> + int itab2 = convert_short_sat_rte ( taby * ( 1 . 0f - tabx ) * INTER_REMAP_COEF_SCALE ) ; <nl> + int itab3 = convert_short_sat_rte ( taby * tabx * INTER_REMAP_COEF_SCALE ) ; <nl> + <nl> + WT val = v0 * itab0 + v1 * itab1 + v2 * itab2 + v3 * itab3 ; <nl> + dst [ 0 ] = convertToT ( ( val + ( 1 < < ( INTER_REMAP_COEF_BITS - 1 ) ) ) > > INTER_REMAP_COEF_BITS ) ; <nl> + # else <nl> + float tabx2 = 1 . 0f - tabx , taby2 = 1 . 0f - taby ; <nl> + WT val = v0 * tabx2 * taby2 + v1 * tabx * taby2 + v2 * tabx2 * taby + v3 * tabx * taby ; <nl> + dst [ 0 ] = convertToT ( val ) ; <nl> + # endif <nl> + } <nl> + } <nl> + <nl> + # elif defined INTER_CUBIC <nl> + <nl> + inline void interpolateCubic ( float x , float * coeffs ) <nl> + { <nl> + const float A = - 0 . 75f ; <nl> + <nl> + coeffs [ 0 ] = ( ( A * ( x + 1 . f ) - 5 . 0f * A ) * ( x + 1 . f ) + 8 . 0f * A ) * ( x + 1 . f ) - 4 . 0f * A ; <nl> + coeffs [ 1 ] = ( ( A + 2 . f ) * x - ( A + 3 . f ) ) * x * x + 1 . f ; <nl> + coeffs [ 2 ] = ( ( A + 2 . f ) * ( 1 . f - x ) - ( A + 3 . f ) ) * ( 1 . f - x ) * ( 1 . f - x ) + 1 . f ; <nl> + coeffs [ 3 ] = 1 . f - coeffs [ 0 ] - coeffs [ 1 ] - coeffs [ 2 ] ; <nl> + } <nl> + <nl> + __kernel void warpAffine ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __constant CT * M , WT scalar ) <nl> + { <nl> + int dx = get_global_id ( 0 ) ; <nl> + int dy = get_global_id ( 1 ) ; <nl> + <nl> + if ( dx < dst_cols & & dy < dst_rows ) <nl> + { <nl> + int round_delta = ( ( AB_SCALE > > INTER_BITS ) > > 1 ) ; <nl> + <nl> + int tmp = ( dx < < AB_BITS ) ; <nl> + int X0 = rint ( M [ 0 ] * tmp ) ; <nl> + int Y0 = rint ( M [ 3 ] * tmp ) ; <nl> + X0 + = rint ( ( M [ 1 ] * dy + M [ 2 ] ) * AB_SCALE ) + round_delta ; <nl> + Y0 + = rint ( ( M [ 4 ] * dy + M [ 5 ] ) * AB_SCALE ) + round_delta ; <nl> + X0 = X0 > > ( AB_BITS - INTER_BITS ) ; <nl> + Y0 = Y0 > > ( AB_BITS - INTER_BITS ) ; <nl> + <nl> + int sx = ( short ) ( X0 > > INTER_BITS ) - 1 ; <nl> + int sy = ( short ) ( Y0 > > INTER_BITS ) - 1 ; <nl> + int ay = ( short ) ( Y0 & ( INTER_TAB_SIZE - 1 ) ) ; <nl> + int ax = ( short ) ( X0 & ( INTER_TAB_SIZE - 1 ) ) ; <nl> + <nl> + WT v [ 16 ] ; <nl> + # pragma unroll <nl> + for ( int y = 0 ; y < 4 ; y + + ) <nl> + # pragma unroll <nl> + for ( int x = 0 ; x < 4 ; x + + ) <nl> + v [ mad24 ( y , 4 , x ) ] = ( sx + x > = 0 & & sx + x < src_cols & & sy + y > = 0 & & sy + y < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy + y , src_step , src_offset + ( sx + x ) * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + <nl> + float tab1y [ 4 ] , tab1x [ 4 ] ; <nl> + <nl> + float ayy = INTER_SCALE * ay ; <nl> + float axx = INTER_SCALE * ax ; <nl> + interpolateCubic ( ayy , tab1y ) ; <nl> + interpolateCubic ( axx , tab1x ) ; <nl> + <nl> + int dst_index = mad24 ( dy , dst_step , dst_offset + dx * ( int ) sizeof ( T ) ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + WT sum = ( WT ) ( 0 ) ; <nl> + # if depth < = 4 <nl> + int itab [ 16 ] ; <nl> + <nl> + # pragma unroll <nl> + for ( int i = 0 ; i < 16 ; i + + ) <nl> + itab [ i ] = rint ( tab1y [ ( i > > 2 ) ] * tab1x [ ( i & 3 ) ] * INTER_REMAP_COEF_SCALE ) ; <nl> + <nl> + # pragma unroll <nl> + for ( int i = 0 ; i < 16 ; i + + ) <nl> + sum + = v [ i ] * itab [ i ] ; <nl> + dst [ 0 ] = convertToT ( ( sum + ( 1 < < ( INTER_REMAP_COEF_BITS - 1 ) ) ) > > INTER_REMAP_COEF_BITS ) ; <nl> + # else <nl> + # pragma unroll <nl> + for ( int i = 0 ; i < 16 ; i + + ) <nl> + sum + = v [ i ] * tab1y [ ( i > > 2 ) ] * tab1x [ ( i & 3 ) ] ; <nl> + dst [ 0 ] = convertToT ( sum ) ; <nl> + # endif <nl> + } <nl> + } <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 211433e7090 <nl> mmm / dev / null <nl> ppp b / modules / imgproc / src / opencl / warp_perspective . cl <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2010 - 2012 , Institute Of Software Chinese Academy Of Science , all rights reserved . <nl> + / / Copyright ( C ) 2010 - 2012 , Advanced Micro Devices , Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / @ Authors <nl> + / / Zhang Ying , zhangying913 @ gmail . com <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors as is and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # ifdef DOUBLE_SUPPORT <nl> + # ifdef cl_amd_fp64 <nl> + # pragma OPENCL EXTENSION cl_amd_fp64 : enable <nl> + # elif defined ( cl_khr_fp64 ) <nl> + # pragma OPENCL EXTENSION cl_khr_fp64 : enable <nl> + # endif <nl> + # define CT double <nl> + # else <nl> + # define CT float <nl> + # endif <nl> + <nl> + # define INTER_BITS 5 <nl> + # define INTER_TAB_SIZE ( 1 < < INTER_BITS ) <nl> + # define INTER_SCALE 1 . f / INTER_TAB_SIZE <nl> + # define AB_BITS max ( 10 , ( int ) INTER_BITS ) <nl> + # define AB_SCALE ( 1 < < AB_BITS ) <nl> + # define INTER_REMAP_COEF_BITS 15 <nl> + # define INTER_REMAP_COEF_SCALE ( 1 < < INTER_REMAP_COEF_BITS ) <nl> + <nl> + # define noconvert <nl> + <nl> + # ifdef INTER_NEAREST <nl> + <nl> + __kernel void warpPerspective ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __constant CT * M , T scalar ) <nl> + { <nl> + int dx = get_global_id ( 0 ) ; <nl> + int dy = get_global_id ( 1 ) ; <nl> + <nl> + if ( dx < dst_cols & & dy < dst_rows ) <nl> + { <nl> + CT X0 = M [ 0 ] * dx + M [ 1 ] * dy + M [ 2 ] ; <nl> + CT Y0 = M [ 3 ] * dx + M [ 4 ] * dy + M [ 5 ] ; <nl> + CT W = M [ 6 ] * dx + M [ 7 ] * dy + M [ 8 ] ; <nl> + W = W ! = 0 . 0f ? 1 . f / W : 0 . 0f ; <nl> + short sx = convert_short_sat_rte ( X0 * W ) ; <nl> + short sy = convert_short_sat_rte ( Y0 * W ) ; <nl> + <nl> + int dst_index = mad24 ( dy , dst_step , dx * ( int ) sizeof ( T ) + dst_offset ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + if ( sx > = 0 & & sx < src_cols & & sy > = 0 & & sy < src_rows ) <nl> + { <nl> + int src_index = mad24 ( sy , src_step , sx * ( int ) sizeof ( T ) + src_offset ) ; <nl> + __global const T * src = ( __global const T * ) ( srcptr + src_index ) ; <nl> + dst [ 0 ] = src [ 0 ] ; <nl> + } <nl> + else <nl> + dst [ 0 ] = scalar ; <nl> + } <nl> + } <nl> + <nl> + # elif defined INTER_LINEAR <nl> + <nl> + __kernel void warpPerspective ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __constant CT * M , WT scalar ) <nl> + { <nl> + int dx = get_global_id ( 0 ) ; <nl> + int dy = get_global_id ( 1 ) ; <nl> + <nl> + if ( dx < dst_cols & & dy < dst_rows ) <nl> + { <nl> + CT X0 = M [ 0 ] * dx + M [ 1 ] * dy + M [ 2 ] ; <nl> + CT Y0 = M [ 3 ] * dx + M [ 4 ] * dy + M [ 5 ] ; <nl> + CT W = M [ 6 ] * dx + M [ 7 ] * dy + M [ 8 ] ; <nl> + W = W ! = 0 . 0f ? INTER_TAB_SIZE / W : 0 . 0f ; <nl> + int X = rint ( X0 * W ) , Y = rint ( Y0 * W ) ; <nl> + <nl> + short sx = convert_short_sat ( X > > INTER_BITS ) ; <nl> + short sy = convert_short_sat ( Y > > INTER_BITS ) ; <nl> + short ay = ( short ) ( Y & ( INTER_TAB_SIZE - 1 ) ) ; <nl> + short ax = ( short ) ( X & ( INTER_TAB_SIZE - 1 ) ) ; <nl> + <nl> + WT v0 = ( sx > = 0 & & sx < src_cols & & sy > = 0 & & sy < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy , src_step , src_offset + sx * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + WT v1 = ( sx + 1 > = 0 & & sx + 1 < src_cols & & sy > = 0 & & sy < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy , src_step , src_offset + ( sx + 1 ) * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + WT v2 = ( sx > = 0 & & sx < src_cols & & sy + 1 > = 0 & & sy + 1 < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy + 1 , src_step , src_offset + sx * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + WT v3 = ( sx + 1 > = 0 & & sx + 1 < src_cols & & sy + 1 > = 0 & & sy + 1 < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy + 1 , src_step , src_offset + ( sx + 1 ) * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + <nl> + float taby = 1 . f / INTER_TAB_SIZE * ay ; <nl> + float tabx = 1 . f / INTER_TAB_SIZE * ax ; <nl> + <nl> + int dst_index = mad24 ( dy , dst_step , dst_offset + dx * ( int ) sizeof ( T ) ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + # if depth < = 4 <nl> + int itab0 = convert_short_sat_rte ( ( 1 . 0f - taby ) * ( 1 . 0f - tabx ) * INTER_REMAP_COEF_SCALE ) ; <nl> + int itab1 = convert_short_sat_rte ( ( 1 . 0f - taby ) * tabx * INTER_REMAP_COEF_SCALE ) ; <nl> + int itab2 = convert_short_sat_rte ( taby * ( 1 . 0f - tabx ) * INTER_REMAP_COEF_SCALE ) ; <nl> + int itab3 = convert_short_sat_rte ( taby * tabx * INTER_REMAP_COEF_SCALE ) ; <nl> + <nl> + WT val = v0 * itab0 + v1 * itab1 + v2 * itab2 + v3 * itab3 ; <nl> + dst [ 0 ] = convertToT ( ( val + ( 1 < < ( INTER_REMAP_COEF_BITS - 1 ) ) ) > > INTER_REMAP_COEF_BITS ) ; <nl> + # else <nl> + float tabx2 = 1 . 0f - tabx , taby2 = 1 . 0f - taby ; <nl> + WT val = v0 * tabx2 * taby2 + v1 * tabx * taby2 + v2 * tabx2 * taby + v3 * tabx * taby ; <nl> + dst [ 0 ] = convertToT ( val ) ; <nl> + # endif <nl> + } <nl> + } <nl> + <nl> + # elif defined INTER_CUBIC <nl> + <nl> + inline void interpolateCubic ( float x , float * coeffs ) <nl> + { <nl> + const float A = - 0 . 75f ; <nl> + <nl> + coeffs [ 0 ] = ( ( A * ( x + 1 . f ) - 5 . 0f * A ) * ( x + 1 . f ) + 8 . 0f * A ) * ( x + 1 . f ) - 4 . 0f * A ; <nl> + coeffs [ 1 ] = ( ( A + 2 . f ) * x - ( A + 3 . f ) ) * x * x + 1 . f ; <nl> + coeffs [ 2 ] = ( ( A + 2 . f ) * ( 1 . f - x ) - ( A + 3 . f ) ) * ( 1 . f - x ) * ( 1 . f - x ) + 1 . f ; <nl> + coeffs [ 3 ] = 1 . f - coeffs [ 0 ] - coeffs [ 1 ] - coeffs [ 2 ] ; <nl> + } <nl> + <nl> + __kernel void warpPerspective ( __global const uchar * srcptr , int src_step , int src_offset , int src_rows , int src_cols , <nl> + __global uchar * dstptr , int dst_step , int dst_offset , int dst_rows , int dst_cols , <nl> + __constant CT * M , WT scalar ) <nl> + { <nl> + int dx = get_global_id ( 0 ) ; <nl> + int dy = get_global_id ( 1 ) ; <nl> + <nl> + if ( dx < dst_cols & & dy < dst_rows ) <nl> + { <nl> + CT X0 = M [ 0 ] * dx + M [ 1 ] * dy + M [ 2 ] ; <nl> + CT Y0 = M [ 3 ] * dx + M [ 4 ] * dy + M [ 5 ] ; <nl> + CT W = M [ 6 ] * dx + M [ 7 ] * dy + M [ 8 ] ; <nl> + W = W ! = 0 . 0f ? INTER_TAB_SIZE / W : 0 . 0f ; <nl> + int X = rint ( X0 * W ) , Y = rint ( Y0 * W ) ; <nl> + <nl> + short sx = convert_short_sat ( X > > INTER_BITS ) - 1 ; <nl> + short sy = convert_short_sat ( Y > > INTER_BITS ) - 1 ; <nl> + short ay = ( short ) ( Y & ( INTER_TAB_SIZE - 1 ) ) ; <nl> + short ax = ( short ) ( X & ( INTER_TAB_SIZE - 1 ) ) ; <nl> + <nl> + WT v [ 16 ] ; <nl> + # pragma unroll <nl> + for ( int y = 0 ; y < 4 ; y + + ) <nl> + # pragma unroll <nl> + for ( int x = 0 ; x < 4 ; x + + ) <nl> + v [ mad24 ( y , 4 , x ) ] = ( sx + x > = 0 & & sx + x < src_cols & & sy + y > = 0 & & sy + y < src_rows ) ? <nl> + convertToWT ( * ( __global const T * ) ( srcptr + mad24 ( sy + y , src_step , src_offset + ( sx + x ) * ( int ) sizeof ( T ) ) ) ) : scalar ; <nl> + <nl> + float tab1y [ 4 ] , tab1x [ 4 ] ; <nl> + <nl> + float ayy = INTER_SCALE * ay ; <nl> + float axx = INTER_SCALE * ax ; <nl> + interpolateCubic ( ayy , tab1y ) ; <nl> + interpolateCubic ( axx , tab1x ) ; <nl> + <nl> + int dst_index = mad24 ( dy , dst_step , dst_offset + dx * ( int ) sizeof ( T ) ) ; <nl> + __global T * dst = ( __global T * ) ( dstptr + dst_index ) ; <nl> + <nl> + WT sum = ( WT ) ( 0 ) ; <nl> + # if depth < = 4 <nl> + int itab [ 16 ] ; <nl> + <nl> + # pragma unroll <nl> + for ( int i = 0 ; i < 16 ; i + + ) <nl> + itab [ i ] = rint ( tab1y [ ( i > > 2 ) ] * tab1x [ ( i & 3 ) ] * INTER_REMAP_COEF_SCALE ) ; <nl> + <nl> + # pragma unroll <nl> + for ( int i = 0 ; i < 16 ; i + + ) <nl> + sum + = v [ i ] * itab [ i ] ; <nl> + dst [ 0 ] = convertToT ( ( sum + ( 1 < < ( INTER_REMAP_COEF_BITS - 1 ) ) ) > > INTER_REMAP_COEF_BITS ) ; <nl> + # else <nl> + # pragma unroll <nl> + for ( int i = 0 ; i < 16 ; i + + ) <nl> + sum + = v [ i ] * tab1y [ ( i > > 2 ) ] * tab1x [ ( i & 3 ) ] ; <nl> + dst [ 0 ] = convertToT ( sum ) ; <nl> + # endif <nl> + } <nl> + } <nl> + <nl> + # endif <nl> mmm a / modules / imgproc / test / ocl / test_warp . cpp <nl> ppp b / modules / imgproc / test / ocl / test_warp . cpp <nl> <nl> namespace cvtest { <nl> namespace ocl { <nl> <nl> + enum <nl> + { <nl> + noType = - 1 <nl> + } ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / warpAffine & warpPerspective <nl> + <nl> + PARAM_TEST_CASE ( WarpTestBase , MatType , Interpolation , bool , bool ) <nl> + { <nl> + int type , interpolation ; <nl> + Size dsize ; <nl> + bool useRoi , mapInverse ; <nl> + <nl> + TEST_DECLARE_INPUT_PARAMETER ( src ) <nl> + TEST_DECLARE_OUTPUT_PARAMETER ( dst ) <nl> + <nl> + virtual void SetUp ( ) <nl> + { <nl> + type = GET_PARAM ( 0 ) ; <nl> + interpolation = GET_PARAM ( 1 ) ; <nl> + mapInverse = GET_PARAM ( 2 ) ; <nl> + useRoi = GET_PARAM ( 3 ) ; <nl> + <nl> + if ( mapInverse ) <nl> + interpolation | = WARP_INVERSE_MAP ; <nl> + } <nl> + <nl> + void random_roi ( ) <nl> + { <nl> + dsize = randomSize ( 1 , MAX_VALUE ) ; <nl> + <nl> + Size roiSize = randomSize ( 1 , MAX_VALUE ) ; <nl> + Border srcBorder = randomBorder ( 0 , useRoi ? MAX_VALUE : 0 ) ; <nl> + randomSubMat ( src , src_roi , roiSize , srcBorder , type , - MAX_VALUE , MAX_VALUE ) ; <nl> + <nl> + Border dstBorder = randomBorder ( 0 , useRoi ? MAX_VALUE : 0 ) ; <nl> + randomSubMat ( dst , dst_roi , dsize , dstBorder , type , - MAX_VALUE , MAX_VALUE ) ; <nl> + <nl> + UMAT_UPLOAD_INPUT_PARAMETER ( src ) <nl> + UMAT_UPLOAD_OUTPUT_PARAMETER ( dst ) <nl> + } <nl> + <nl> + void Near ( double threshold = 0 . 0 ) <nl> + { <nl> + EXPECT_MAT_NEAR ( dst , udst , threshold ) ; <nl> + EXPECT_MAT_NEAR ( dst_roi , udst_roi , threshold ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / / / / warpAffine <nl> + <nl> + typedef WarpTestBase WarpAffine ; <nl> + <nl> + OCL_TEST_P ( WarpAffine , Mat ) <nl> + { <nl> + for ( int j = 0 ; j < test_loop_times ; j + + ) <nl> + { <nl> + random_roi ( ) ; <nl> + <nl> + Mat M = getRotationMatrix2D ( Point2f ( src_roi . cols / 2 . 0f , src_roi . rows / 2 . 0f ) , <nl> + rng . uniform ( - 180 . f , 180 . f ) , rng . uniform ( 0 . 4f , 2 . 0f ) ) ; <nl> + <nl> + OCL_OFF ( cv : : warpAffine ( src_roi , dst_roi , M , dsize , interpolation ) ) ; <nl> + OCL_ON ( cv : : warpAffine ( usrc_roi , udst_roi , M , dsize , interpolation ) ) ; <nl> + <nl> + Near ( 1 . 0 ) ; <nl> + } <nl> + } <nl> + <nl> + / / / / warpPerspective <nl> + <nl> + typedef WarpTestBase WarpPerspective ; <nl> + <nl> + OCL_TEST_P ( WarpPerspective , Mat ) <nl> + { <nl> + for ( int j = 0 ; j < test_loop_times ; j + + ) <nl> + { <nl> + random_roi ( ) ; <nl> + <nl> + float cols = static_cast < float > ( src_roi . cols ) , rows = static_cast < float > ( src_roi . rows ) ; <nl> + float cols2 = cols / 2 . 0f , rows2 = rows / 2 . 0f ; <nl> + Point2f sp [ ] = { Point2f ( 0 . 0f , 0 . 0f ) , Point2f ( cols , 0 . 0f ) , Point2f ( 0 . 0f , rows ) , Point2f ( cols , rows ) } ; <nl> + Point2f dp [ ] = { Point2f ( rng . uniform ( 0 . 0f , cols2 ) , rng . uniform ( 0 . 0f , rows2 ) ) , <nl> + Point2f ( rng . uniform ( cols2 , cols ) , rng . uniform ( 0 . 0f , rows2 ) ) , <nl> + Point2f ( rng . uniform ( 0 . 0f , cols2 ) , rng . uniform ( rows2 , rows ) ) , <nl> + Point2f ( rng . uniform ( cols2 , cols ) , rng . uniform ( rows2 , rows ) ) } ; <nl> + Mat M = getPerspectiveTransform ( sp , dp ) ; <nl> + <nl> + OCL_OFF ( cv : : warpPerspective ( src_roi , dst_roi , M , dsize , interpolation ) ) ; <nl> + OCL_ON ( cv : : warpPerspective ( usrc_roi , udst_roi , M , dsize , interpolation ) ) ; <nl> + <nl> + Near ( 1 . 0 ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / resize <nl> + / / / / resize <nl> <nl> PARAM_TEST_CASE ( Resize , MatType , double , double , Interpolation , bool ) <nl> { <nl> OCL_TEST_P ( Resize , Mat ) <nl> } <nl> } <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / remap <nl> + <nl> + PARAM_TEST_CASE ( Remap , MatDepth , Channels , std : : pair < MatType , MatType > , Border , bool ) <nl> + { <nl> + int srcType , map1Type , map2Type ; <nl> + int borderType ; <nl> + bool useRoi ; <nl> + <nl> + Scalar val ; <nl> + <nl> + TEST_DECLARE_INPUT_PARAMETER ( src ) <nl> + TEST_DECLARE_INPUT_PARAMETER ( map1 ) <nl> + TEST_DECLARE_INPUT_PARAMETER ( map2 ) <nl> + TEST_DECLARE_OUTPUT_PARAMETER ( dst ) <nl> + <nl> + virtual void SetUp ( ) <nl> + { <nl> + srcType = CV_MAKE_TYPE ( GET_PARAM ( 0 ) , GET_PARAM ( 1 ) ) ; <nl> + map1Type = GET_PARAM ( 2 ) . first ; <nl> + map2Type = GET_PARAM ( 2 ) . second ; <nl> + borderType = GET_PARAM ( 3 ) ; <nl> + useRoi = GET_PARAM ( 4 ) ; <nl> + } <nl> + <nl> + void random_roi ( ) <nl> + { <nl> + val = randomScalar ( - MAX_VALUE , MAX_VALUE ) ; <nl> + Size srcROISize = randomSize ( 1 , MAX_VALUE ) ; <nl> + Size dstROISize = randomSize ( 1 , MAX_VALUE ) ; <nl> + <nl> + Border srcBorder = randomBorder ( 0 , useRoi ? MAX_VALUE : 0 ) ; <nl> + randomSubMat ( src , src_roi , srcROISize , srcBorder , srcType , 5 , 256 ) ; <nl> + <nl> + Border dstBorder = randomBorder ( 0 , useRoi ? MAX_VALUE : 0 ) ; <nl> + randomSubMat ( dst , dst_roi , dstROISize , dstBorder , srcType , - MAX_VALUE , MAX_VALUE ) ; <nl> + <nl> + int mapMaxValue = MAX_VALUE < < 2 ; <nl> + Border map1Border = randomBorder ( 0 , useRoi ? MAX_VALUE : 0 ) ; <nl> + randomSubMat ( map1 , map1_roi , dstROISize , map1Border , map1Type , - mapMaxValue , mapMaxValue ) ; <nl> + <nl> + Border map2Border = randomBorder ( 0 , useRoi ? MAX_VALUE : 0 ) ; <nl> + if ( map2Type ! = noType ) <nl> + { <nl> + int mapMinValue = - mapMaxValue ; <nl> + if ( map2Type = = CV_16UC1 | | map2Type = = CV_16SC1 ) <nl> + mapMinValue = 0 , mapMaxValue = INTER_TAB_SIZE2 ; <nl> + randomSubMat ( map2 , map2_roi , dstROISize , map2Border , map2Type , mapMinValue , mapMaxValue ) ; <nl> + } <nl> + <nl> + UMAT_UPLOAD_INPUT_PARAMETER ( src ) <nl> + UMAT_UPLOAD_INPUT_PARAMETER ( map1 ) <nl> + UMAT_UPLOAD_OUTPUT_PARAMETER ( dst ) <nl> + if ( noType ! = map2Type ) <nl> + UMAT_UPLOAD_INPUT_PARAMETER ( map2 ) <nl> + } <nl> + <nl> + void Near ( double threshold = 0 . 0 ) <nl> + { <nl> + EXPECT_MAT_NEAR ( dst , udst , threshold ) ; <nl> + EXPECT_MAT_NEAR ( dst_roi , udst_roi , threshold ) ; <nl> + } <nl> + } ; <nl> + <nl> + typedef Remap Remap_INTER_NEAREST ; <nl> + <nl> + OCL_TEST_P ( Remap_INTER_NEAREST , Mat ) <nl> + { <nl> + for ( int j = 0 ; j < test_loop_times ; j + + ) <nl> + { <nl> + random_roi ( ) ; <nl> + <nl> + OCL_OFF ( cv : : remap ( src_roi , dst_roi , map1_roi , map2_roi , INTER_NEAREST , borderType , val ) ) ; <nl> + OCL_ON ( cv : : remap ( usrc_roi , udst_roi , umap1_roi , umap2_roi , INTER_NEAREST , borderType , val ) ) ; <nl> + <nl> + Near ( 1 . 0 ) ; <nl> + } <nl> + } <nl> + <nl> + typedef Remap Remap_INTER_LINEAR ; <nl> + <nl> + OCL_TEST_P ( Remap_INTER_LINEAR , Mat ) <nl> + { <nl> + for ( int j = 0 ; j < test_loop_times ; j + + ) <nl> + { <nl> + random_roi ( ) ; <nl> + <nl> + OCL_OFF ( cv : : remap ( src_roi , dst_roi , map1_roi , map2_roi , INTER_LINEAR , borderType , val ) ) ; <nl> + OCL_ON ( cv : : remap ( usrc_roi , udst_roi , umap1_roi , umap2_roi , INTER_LINEAR , borderType , val ) ) ; <nl> + <nl> + Near ( 2 . 0 ) ; <nl> + } <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - OCL_INSTANTIATE_TEST_CASE_P ( ImgprocWarpResize , Resize , Combine ( <nl> - Values ( ( MatType ) CV_8UC1 , CV_8UC4 , CV_32FC1 , CV_32FC4 ) , <nl> - Values ( 0 . 7 , 0 . 4 , 2 . 0 ) , <nl> - Values ( 0 . 3 , 0 . 6 , 2 . 0 ) , <nl> + OCL_INSTANTIATE_TEST_CASE_P ( ImgprocWarp , WarpAffine , Combine ( <nl> + Values ( CV_8UC1 , CV_8UC3 , CV_8UC4 , CV_32FC1 , CV_32FC3 , CV_32FC4 ) , <nl> + Values ( ( Interpolation ) INTER_NEAREST , ( Interpolation ) INTER_LINEAR , ( Interpolation ) INTER_CUBIC ) , <nl> + Bool ( ) , <nl> + Bool ( ) ) ) ; <nl> + <nl> + OCL_INSTANTIATE_TEST_CASE_P ( ImgprocWarp , WarpPerspective , Combine ( <nl> + Values ( CV_8UC1 , CV_8UC3 , CV_8UC4 , CV_32FC1 , CV_32FC3 , CV_32FC4 ) , <nl> + Values ( ( Interpolation ) INTER_NEAREST , ( Interpolation ) INTER_LINEAR , ( Interpolation ) INTER_CUBIC ) , <nl> + Bool ( ) , <nl> + Bool ( ) ) ) ; <nl> + <nl> + OCL_INSTANTIATE_TEST_CASE_P ( ImgprocWarp , Resize , Combine ( <nl> + Values ( CV_8UC1 , CV_8UC4 , CV_16UC2 , CV_32FC1 , CV_32FC4 ) , <nl> + Values ( 0 . 5 , 1 . 5 , 2 . 0 ) , <nl> + Values ( 0 . 5 , 1 . 5 , 2 . 0 ) , <nl> Values ( ( Interpolation ) INTER_NEAREST , ( Interpolation ) INTER_LINEAR ) , <nl> Bool ( ) ) ) ; <nl> <nl> OCL_INSTANTIATE_TEST_CASE_P ( ImgprocWarpResizeArea , Resize , Combine ( <nl> Values ( ( Interpolation ) INTER_AREA ) , <nl> Bool ( ) ) ) ; <nl> <nl> + OCL_INSTANTIATE_TEST_CASE_P ( ImgprocWarp , Remap_INTER_LINEAR , Combine ( <nl> + Values ( CV_8U , CV_16U , CV_32F ) , <nl> + Values ( 1 , 4 ) , <nl> + Values ( std : : pair < MatType , MatType > ( ( MatType ) CV_32FC1 , ( MatType ) CV_32FC1 ) , <nl> + std : : pair < MatType , MatType > ( ( MatType ) CV_16SC2 , ( MatType ) CV_16UC1 ) , <nl> + std : : pair < MatType , MatType > ( ( MatType ) CV_32FC2 , noType ) ) , <nl> + Values ( ( Border ) BORDER_CONSTANT , <nl> + ( Border ) BORDER_REPLICATE , <nl> + ( Border ) BORDER_WRAP , <nl> + ( Border ) BORDER_REFLECT , <nl> + ( Border ) BORDER_REFLECT_101 ) , <nl> + Bool ( ) ) ) ; <nl> + <nl> + OCL_INSTANTIATE_TEST_CASE_P ( ImgprocWarp , Remap_INTER_NEAREST , Combine ( <nl> + Values ( CV_8U , CV_16U , CV_32F ) , <nl> + Values ( 1 , 4 ) , <nl> + Values ( std : : pair < MatType , MatType > ( ( MatType ) CV_32FC1 , ( MatType ) CV_32FC1 ) , <nl> + std : : pair < MatType , MatType > ( ( MatType ) CV_32FC2 , noType ) , <nl> + std : : pair < MatType , MatType > ( ( MatType ) CV_16SC2 , ( MatType ) CV_16UC1 ) , <nl> + std : : pair < MatType , MatType > ( ( MatType ) CV_16SC2 , noType ) ) , <nl> + Values ( ( Border ) BORDER_CONSTANT , <nl> + ( Border ) BORDER_REPLICATE , <nl> + ( Border ) BORDER_WRAP , <nl> + ( Border ) BORDER_REFLECT , <nl> + ( Border ) BORDER_REFLECT_101 ) , <nl> + Bool ( ) ) ) ; <nl> + <nl> } } / / namespace cvtest : : ocl <nl> <nl> # endif / / HAVE_OPENCL <nl> mmm a / modules / ts / include / opencv2 / ts / ocl_test . hpp <nl> ppp b / modules / ts / include / opencv2 / ts / ocl_test . hpp <nl> IMPLEMENT_PARAM_CLASS ( Channels , int ) <nl> # define OCL_ALL_CHANNELS Values ( 1 , 2 , 3 , 4 ) <nl> <nl> CV_ENUM ( Interpolation , INTER_NEAREST , INTER_LINEAR , INTER_CUBIC , INTER_AREA ) <nl> + CV_ENUM ( Border , BORDER_CONSTANT , BORDER_REPLICATE , BORDER_WRAP , BORDER_REFLECT , BORDER_REFLECT_101 ) <nl> <nl> # define OCL_INSTANTIATE_TEST_CASE_P ( prefix , test_case_name , generator ) \ <nl> INSTANTIATE_TEST_CASE_P ( OCL_ # # prefix , test_case_name , generator ) <nl> | Merge pull request from ilya - lavrenov : tapi_warp | opencv/opencv | e585f145f641d4f138dffc609edb0508fc4749c1 | 2013-12-04T07:34:52Z |
mmm a / thirdparty / jansson / jansson . h <nl> ppp b / thirdparty / jansson / jansson . h <nl> json_ref json_deep_copy ( const json_t * value ) ; <nl> # define JSON_DISABLE_EOF_CHECK 0x2 <nl> # define JSON_DECODE_ANY 0x4 <nl> <nl> - typedef size_t ( * json_load_callback_t ) ( void * buffer , size_t buflen , void * data ) ; <nl> - <nl> json_ref json_loads ( const char * input , size_t flags , json_error_t * error ) ; <nl> json_ref json_loadb ( <nl> const char * buffer , <nl> json_ref json_loadb ( <nl> json_error_t * error ) ; <nl> json_ref json_loadf ( FILE * input , size_t flags , json_error_t * error ) ; <nl> json_ref json_load_file ( const char * path , size_t flags , json_error_t * error ) ; <nl> - json_ref json_load_callback ( <nl> - json_load_callback_t callback , <nl> - void * data , <nl> - size_t flags , <nl> - json_error_t * error ) ; <nl> <nl> / * encoding * / <nl> <nl> mmm a / thirdparty / jansson / load . cpp <nl> ppp b / thirdparty / jansson / load . cpp <nl> json_ref json_load_file ( const char * path , size_t flags , json_error_t * error ) <nl> fclose ( fp ) ; <nl> return result ; <nl> } <nl> - <nl> - # define MAX_BUF_LEN 1024 <nl> - <nl> - typedef struct <nl> - { <nl> - char data [ MAX_BUF_LEN ] ; <nl> - size_t len ; <nl> - size_t pos ; <nl> - json_load_callback_t callback ; <nl> - void * arg ; <nl> - } callback_data_t ; <nl> - <nl> - static int callback_get ( void * data ) <nl> - { <nl> - char c ; <nl> - auto stream = ( callback_data_t * ) data ; <nl> - <nl> - if ( stream - > pos > = stream - > len ) { <nl> - stream - > pos = 0 ; <nl> - stream - > len = stream - > callback ( stream - > data , MAX_BUF_LEN , stream - > arg ) ; <nl> - if ( stream - > len = = 0 | | stream - > len = = ( size_t ) - 1 ) <nl> - return EOF ; <nl> - } <nl> - <nl> - c = stream - > data [ stream - > pos ] ; <nl> - stream - > pos + + ; <nl> - return ( unsigned char ) c ; <nl> - } <nl> - <nl> - json_ref json_load_callback ( <nl> - json_load_callback_t callback , <nl> - void * arg , <nl> - size_t flags , <nl> - json_error_t * error ) { <nl> - lex_t lex ; <nl> - <nl> - callback_data_t stream_data ; <nl> - <nl> - memset ( & stream_data , 0 , sizeof ( stream_data ) ) ; <nl> - stream_data . callback = callback ; <nl> - stream_data . arg = arg ; <nl> - <nl> - jsonp_error_init ( error , " < callback > " ) ; <nl> - <nl> - if ( callback = = nullptr ) { <nl> - error_set ( error , nullptr , " wrong arguments " ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> - if ( lex_init ( & lex , ( get_func ) callback_get , & stream_data ) ) <nl> - return nullptr ; <nl> - <nl> - auto result = parse_json ( & lex , flags , error ) ; <nl> - <nl> - lex_close ( & lex ) ; <nl> - return result ; <nl> - } <nl> | watchman : deadcode : remove unused json_load_callback function | facebook/watchman | ed6facbafb698de1de8e730f12cd56639a47ed68 | 2019-10-10T13:55:17Z |
mmm a / src / mongo / db / storage / wiredtiger / wiredtiger_index . cpp <nl> ppp b / src / mongo / db / storage / wiredtiger / wiredtiger_index . cpp <nl> namespace { <nl> <nl> / / Separate out a prefix and suffix in the default string . User configuration will <nl> / / override values in the prefix , but not values in the suffix . <nl> - ss < < " type = file , leaf_page_max = 16k , " ; <nl> + ss < < " type = file , leaf_page_max = 16k , prefix_compression , " ; <nl> <nl> ss < < extraConfig ; <nl> <nl> | SERVER - 16222 Turn prefix_compression on by default for WT indexes | mongodb/mongo | 403626141dde63d673db50417d484746079d027b | 2014-12-08T16:35:38Z |
mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> ValueDecl : : getAccessSemanticsFromContext ( const DeclContext * UseDC ) const { <nl> / / TODO : What about static properties ? <nl> switch ( var - > getStorageKind ( ) ) { <nl> case AbstractStorageDecl : : Stored : <nl> - case AbstractStorageDecl : : StoredWithTrivialAccessors : <nl> case AbstractStorageDecl : : Addressed : <nl> - case AbstractStorageDecl : : AddressedWithTrivialAccessors : <nl> - if ( ! isPolymorphic ( var ) ) <nl> - return AccessSemantics : : DirectToStorage ; <nl> - break ; <nl> + / / The storage is completely trivial . Always do direct access . <nl> + return AccessSemantics : : DirectToStorage ; <nl> + <nl> + case AbstractStorageDecl : : StoredWithTrivialAccessors : <nl> + case AbstractStorageDecl : : AddressedWithTrivialAccessors : { <nl> + / / If the property is defined in a non - final class or a protocol , the <nl> + / / accessors are dynamically dispatched , and we cannot do direct access . <nl> + if ( isPolymorphic ( var ) ) <nl> + return AccessSemantics : : Ordinary ; <nl> + <nl> + / / If the property is defined in a nominal type which must be accessed <nl> + / / resiliently from the current module , we cannot do direct access . <nl> + auto VarDC = var - > getDeclContext ( ) ; <nl> + if ( auto * nominal = VarDC - > isNominalTypeOrNominalTypeExtensionContext ( ) ) <nl> + if ( ! nominal - > hasFixedLayout ( UseDC - > getParentModule ( ) ) ) <nl> + return AccessSemantics : : Ordinary ; <nl> + <nl> + / / We know enough about the property to perform direct access . <nl> + return AccessSemantics : : DirectToStorage ; <nl> + } <nl> <nl> case AbstractStorageDecl : : StoredWithObservers : <nl> case AbstractStorageDecl : : InheritedWithObservers : <nl> case AbstractStorageDecl : : Computed : <nl> case AbstractStorageDecl : : ComputedWithMutableAddress : <nl> case AbstractStorageDecl : : AddressedWithObservers : <nl> + / / Property is not trivially backed by storage , do not perform <nl> + / / direct access . <nl> break ; <nl> } <nl> } <nl> AbstractStorageDecl : : getAccessStrategy ( AccessSemantics semantics , <nl> SWIFT_FALLTHROUGH ; <nl> <nl> case StoredWithTrivialAccessors : <nl> - case AddressedWithTrivialAccessors : <nl> - / / If the storage is polymorphic , either the getter or the <nl> - / / setter could be overridden by something more interesting . <nl> + case AddressedWithTrivialAccessors : { <nl> + / / If the property is defined in a non - final class or a protocol , the <nl> + / / accessors are dynamically dispatched , and we cannot do direct access . <nl> if ( isPolymorphic ( this ) ) <nl> return AccessStrategy : : DispatchToAccessor ; <nl> <nl> - / / Otherwise , just access the storage directly . <nl> + / / If we end up here with a stored property of a type that ' s resilient <nl> + / / from some resilience domain , we cannot do direct access . <nl> + / / <nl> + / / As an optimization , we do want to perform direct accesses of stored <nl> + / / properties of resilient types in the same resilience domain as the <nl> + / / access . <nl> + / / <nl> + / / This is done by using DirectToStorage semantics above , with the <nl> + / / understanding that the access semantics are with respect to the <nl> + / / resilience domain of the accessor ' s caller . <nl> + auto DC = getDeclContext ( ) ; <nl> + if ( auto * nominal = DC - > isNominalTypeOrNominalTypeExtensionContext ( ) ) <nl> + if ( ! nominal - > hasFixedLayout ( ) ) <nl> + return AccessStrategy : : DirectToAccessor ; <nl> + <nl> if ( storageKind = = StoredWithObservers | | <nl> storageKind = = StoredWithTrivialAccessors ) { <nl> return AccessStrategy : : Storage ; <nl> AbstractStorageDecl : : getAccessStrategy ( AccessSemantics semantics , <nl> storageKind = = AddressedWithTrivialAccessors ) ; <nl> return AccessStrategy : : Addressor ; <nl> } <nl> + } <nl> <nl> case ComputedWithMutableAddress : <nl> if ( isPolymorphic ( this ) ) <nl> mmm a / lib / Sema / CodeSynthesis . cpp <nl> ppp b / lib / Sema / CodeSynthesis . cpp <nl> static void createPropertyStoreOrCallSuperclassSetter ( FuncDecl * accessor , <nl> IsImplicit ) ) ; <nl> } <nl> <nl> + / / / Mark the accessor as transparent if we can . <nl> + / / / <nl> + / / / If the storage is inside a fixed - layout nominal type , we can mark the <nl> + / / / accessor as transparent , since in this case we just want it for abstraction <nl> + / / / purposes ( i . e . , to make access to the variable uniform and to be able to <nl> + / / / put the getter in a vtable ) . <nl> + static void maybeMarkTransparent ( FuncDecl * accessor , <nl> + AbstractStorageDecl * storage , <nl> + TypeChecker & TC ) { <nl> + auto * NTD = storage - > getDeclContext ( ) <nl> + - > isNominalTypeOrNominalTypeExtensionContext ( ) ; <nl> + <nl> + / / FIXME : resilient global variables <nl> + if ( ! NTD | | NTD - > hasFixedLayout ( ) ) <nl> + accessor - > getAttrs ( ) . add ( new ( TC . Context ) TransparentAttr ( IsImplicit ) ) ; <nl> + } <nl> <nl> / / / Synthesize the body of a trivial getter . For a non - member vardecl or one <nl> / / / which is not an override of a base class property , it performs a a direct <nl> static void synthesizeTrivialGetter ( FuncDecl * getter , <nl> SourceLoc loc = storage - > getLoc ( ) ; <nl> getter - > setBody ( BraceStmt : : create ( ctx , loc , returnStmt , loc , true ) ) ; <nl> <nl> - / / Mark it transparent , there is no user benefit to this actually existing , we <nl> - / / just want it for abstraction purposes ( i . e . , to make access to the variable <nl> - / / uniform and to be able to put the getter in a vtable ) . <nl> - getter - > getAttrs ( ) . add ( new ( ctx ) TransparentAttr ( IsImplicit ) ) ; <nl> - <nl> + maybeMarkTransparent ( getter , storage , TC ) ; <nl> + <nl> / / Register the accessor as an external decl if the storage was imported . <nl> if ( needsToBeRegisteredAsExternalDecl ( storage ) ) <nl> TC . Context . addedExternalDecl ( getter ) ; <nl> static void synthesizeTrivialSetter ( FuncDecl * setter , <nl> setterBody , TC ) ; <nl> setter - > setBody ( BraceStmt : : create ( ctx , loc , setterBody , loc , true ) ) ; <nl> <nl> - / / Mark it transparent , there is no user benefit to this actually existing . <nl> - setter - > getAttrs ( ) . add ( new ( ctx ) TransparentAttr ( IsImplicit ) ) ; <nl> + maybeMarkTransparent ( setter , storage , TC ) ; <nl> <nl> / / Register the accessor as an external decl if the storage was imported . <nl> if ( needsToBeRegisteredAsExternalDecl ( storage ) ) <nl> static void synthesizeStoredMaterializeForSet ( FuncDecl * materializeForSet , <nl> SourceLoc loc = storage - > getLoc ( ) ; <nl> materializeForSet - > setBody ( BraceStmt : : create ( ctx , loc , returnStmt , loc , true ) ) ; <nl> <nl> - / / Mark it transparent , there is no user benefit to this actually existing . <nl> - materializeForSet - > getAttrs ( ) . add ( new ( ctx ) TransparentAttr ( IsImplicit ) ) ; <nl> + maybeMarkTransparent ( materializeForSet , storage , TC ) ; <nl> <nl> TC . typeCheckDecl ( materializeForSet , true ) ; <nl> <nl> void swift : : maybeAddAccessorsToVariable ( VarDecl * var , TypeChecker & TC ) { <nl> if ( var - > getGetter ( ) | | var - > isBeingTypeChecked ( ) | | isa < ParamDecl > ( var ) ) <nl> return ; <nl> <nl> - / / Lazy variables need accessors . <nl> + / / Lazy properties get accessors . <nl> if ( var - > getAttrs ( ) . hasAttribute < LazyAttr > ( ) ) { <nl> var - > setIsBeingTypeChecked ( ) ; <nl> <nl> void swift : : maybeAddAccessorsToVariable ( VarDecl * var , TypeChecker & TC ) { <nl> return ; <nl> <nl> } <nl> + / / Stored properties in SIL mode don ' t get auto - synthesized accessors . <nl> + bool isInSILMode = false ; <nl> + if ( auto sourceFile = var - > getDeclContext ( ) - > getParentSourceFile ( ) ) <nl> + isInSILMode = sourceFile - > Kind = = SourceFileKind : : SIL ; <nl> + <nl> + auto nominal = var - > getDeclContext ( ) - > isNominalTypeOrNominalTypeExtensionContext ( ) ; <nl> + if ( var - > hasAccessorFunctions ( ) | | <nl> + var - > isImplicit ( ) | | <nl> + nominal = = nullptr ) <nl> + return ; <nl> <nl> - / / Class instance variables also need accessors , because it affects <nl> + / / Non - NSManaged class instance variables get accessors , because it affects <nl> / / vtable layout . <nl> - if ( ! var - > hasAccessorFunctions ( ) & & ! var - > isImplicit ( ) & & <nl> - var - > getDeclContext ( ) - > isClassOrClassExtensionContext ( ) ) { <nl> + if ( isa < ClassDecl > ( nominal ) ) { <nl> if ( var - > getAttrs ( ) . hasAttribute < NSManagedAttr > ( ) ) { <nl> var - > setIsBeingTypeChecked ( ) ; <nl> convertNSManagedStoredVarToComputed ( var , TC ) ; <nl> var - > setIsBeingTypeChecked ( false ) ; <nl> - } else { <nl> - / / Variables in SIL mode don ' t get auto - synthesized getters . <nl> - bool isInSILMode = false ; <nl> - if ( auto sourceFile = var - > getDeclContext ( ) - > getParentSourceFile ( ) ) <nl> - isInSILMode = sourceFile - > Kind = = SourceFileKind : : SIL ; <nl> - <nl> - if ( ! isInSILMode ) { <nl> - var - > setIsBeingTypeChecked ( ) ; <nl> - addTrivialAccessorsToStorage ( var , TC ) ; <nl> - var - > setIsBeingTypeChecked ( false ) ; <nl> - } <nl> + } else if ( ! isInSILMode ) { <nl> + var - > setIsBeingTypeChecked ( ) ; <nl> + addTrivialAccessorsToStorage ( var , TC ) ; <nl> + var - > setIsBeingTypeChecked ( false ) ; <nl> + } <nl> + } <nl> + <nl> + / / Public instance variables of resilient structs get accessors . <nl> + if ( auto structDecl = dyn_cast < StructDecl > ( nominal ) ) { <nl> + if ( ! structDecl - > hasFixedLayout ( ) & & ! isInSILMode ) { <nl> + var - > setIsBeingTypeChecked ( ) ; <nl> + addTrivialAccessorsToStorage ( var , TC ) ; <nl> + var - > setIsBeingTypeChecked ( false ) ; <nl> } <nl> - return ; <nl> } <nl> } <nl> <nl> mmm a / test / SILGen / struct_resilience . swift <nl> ppp b / test / SILGen / struct_resilience . swift <nl> import resilient_struct <nl> <nl> / / CHECK - LABEL : sil hidden @ _TF17struct_resilience26functionWithResilientTypesFTV16resilient_struct4Size1fFS1_S1__S1_ : $ @ convention ( thin ) ( @ out Size , @ in Size , @ owned @ callee_owned ( @ out Size , @ in Size ) - > ( ) ) - > ( ) <nl> / / CHECK : bb0 ( % 0 : $ * Size , % 1 : $ * Size , % 2 : $ @ callee_owned ( @ out Size , @ in Size ) - > ( ) ) : <nl> + func functionWithResilientTypes ( s : Size , f : Size - > Size ) - > Size { <nl> + <nl> + / / Stored properties of resilient structs from outside our resilience <nl> + / / domain are accessed through accessors <nl> + <nl> + / / CHECK : copy_addr % 1 to [ initialization ] [ [ OTHER_SIZE_BOX : % . * ] ] # 1 : $ * Size <nl> + var s2 = s <nl> + <nl> + / / CHECK : copy_addr % 1 to [ initialization ] [ [ SIZE_BOX : % . * ] ] # 1 : $ * Size <nl> + / / CHECK : [ [ FN : % . * ] ] = function_ref @ _TFV16resilient_struct4Sizeg1wSi : $ @ convention ( method ) ( @ in_guaranteed Size ) - > Int <nl> + / / CHECK : [ [ RESULT : % . * ] ] = apply [ [ FN ] ] ( [ [ SIZE_BOX ] ] # 1 ) <nl> + / / CHECK : [ [ FN : % . * ] ] = function_ref @ _TFV16resilient_struct4Sizes1wSi : $ @ convention ( method ) ( Int , @ inout Size ) - > ( ) <nl> + / / CHECK : apply [ [ FN ] ] ( [ [ RESULT ] ] , [ [ OTHER_SIZE_BOX ] ] # 1 ) <nl> + s2 . w = s . w <nl> + <nl> + / / CHECK : copy_addr % 1 to [ initialization ] [ [ SIZE_BOX : % . * ] ] # 1 : $ * Size <nl> + / / CHECK : [ [ FN : % . * ] ] = function_ref @ _TFV16resilient_struct4Sizeg1hSi : $ @ convention ( method ) ( @ in_guaranteed Size ) - > Int <nl> + / / CHECK : [ [ RESULT : % . * ] ] = apply [ [ FN ] ] ( [ [ SIZE_BOX ] ] # 1 ) <nl> + _ = s . h <nl> + <nl> / / CHECK : copy_addr % 1 to [ initialization ] [ [ SIZE_BOX : % . * ] ] # 1 : $ * Size <nl> / / CHECK : apply % 2 ( % 0 , [ [ SIZE_BOX ] ] # 1 ) <nl> - func functionWithResilientTypes ( s : Size , f : Size - > Size ) - > Size { <nl> + / / CHECK : return <nl> return f ( s ) <nl> } <nl> <nl> func functionWithResilientTypes ( s : Size , f : Size - > Size ) - > Size { <nl> <nl> / / CHECK - LABEL : sil hidden @ _TF17struct_resilience28functionWithFixedLayoutTypesFTV16resilient_struct5Point1fFS1_S1__S1_ : $ @ convention ( thin ) ( Point , @ owned @ callee_owned ( Point ) - > Point ) - > Point <nl> / / CHECK : bb0 ( % 0 : $ Point , % 1 : $ @ callee_owned ( Point ) - > Point ) : <nl> + func functionWithFixedLayoutTypes ( p : Point , f : Point - > Point ) - > Point { <nl> + <nl> + / / Stored properties of fixed layout structs are accessed directly <nl> + var p2 = p <nl> + <nl> + / / CHECK : [ [ RESULT : % . * ] ] = struct_extract % 0 : $ Point , # Point . x <nl> + / / CHECK : [ [ DEST : % . * ] ] = struct_element_addr [ [ POINT_BOX : % . * ] ] # 1 : $ * Point , # Point . x <nl> + / / CHECK : assign [ [ RESULT ] ] to [ [ DEST ] ] : $ * Int <nl> + p2 . x = p . x <nl> + <nl> + / / CHECK : [ [ RESULT : % . * ] ] = struct_extract % 0 : $ Point , # Point . y <nl> + _ = p . y <nl> + <nl> / / CHECK : [ [ NEW_POINT : % . * ] ] = apply % 1 ( % 0 ) <nl> / / CHECK : return [ [ NEW_POINT ] ] <nl> - func functionWithFixedLayoutTypes ( p : Point , f : Point - > Point ) - > Point { <nl> return f ( p ) <nl> } <nl> <nl> func functionWithFixedLayoutTypes ( p : Point , f : Point - > Point ) - > Point { <nl> func functionWithFixedLayoutOfResilientTypes ( r : Rectangle , f : Rectangle - > Rectangle ) - > Rectangle { <nl> return f ( r ) <nl> } <nl> + <nl> + / / Make sure we generate getters and setters for stored properties of <nl> + / / resilient structs <nl> + <nl> + public struct MySize { <nl> + <nl> + / / CHECK - LABEL : sil @ _TFV17struct_resilience6MySizeg1wSi : $ @ convention ( method ) ( @ in_guaranteed MySize ) - > Int <nl> + / / CHECK - LABEL : sil @ _TFV17struct_resilience6MySizes1wSi : $ @ convention ( method ) ( Int , @ inout MySize ) - > ( ) <nl> + / / CHECK - LABEL : sil @ _TFV17struct_resilience6MySizem1wSi : $ @ convention ( method ) ( Builtin . RawPointer , @ inout Builtin . UnsafeValueBuffer , @ inout MySize ) - > ( Builtin . RawPointer , Optional < @ convention ( thin ) ( Builtin . RawPointer , inout Builtin . UnsafeValueBuffer , inout MySize , @ thick MySize . Type ) - > ( ) > ) <nl> + public var w : Int <nl> + <nl> + / / CHECK - LABEL : sil @ _TFV17struct_resilience6MySizeg1hSi : $ @ convention ( method ) ( @ in_guaranteed MySize ) - > Int <nl> + public let h : Int <nl> + } <nl> + <nl> + / / CHECK - LABEL : sil @ _TF17struct_resilience28functionWithMyResilientTypesFTVS_6MySize1fFS0_S0__S0_ : $ @ convention ( thin ) ( @ out MySize , @ in MySize , @ owned @ callee_owned ( @ out MySize , @ in MySize ) - > ( ) ) - > ( ) <nl> + public func functionWithMyResilientTypes ( s : MySize , f : MySize - > MySize ) - > MySize { <nl> + <nl> + / / Stored properties of resilient structs from inside our resilience <nl> + / / domain are accessed directly <nl> + <nl> + / / CHECK : copy_addr % 1 to [ initialization ] [ [ SIZE_BOX : % . * ] ] # 1 : $ * MySize <nl> + var s2 = s <nl> + <nl> + / / CHECK : [ [ SRC_ADDR : % . * ] ] = struct_element_addr % 1 : $ * MySize , # MySize . w <nl> + / / CHECK : [ [ SRC : % . * ] ] = load [ [ SRC_ADDR ] ] : $ * Int <nl> + / / CHECK : [ [ DEST_ADDR : % . * ] ] = struct_element_addr [ [ SIZE_BOX ] ] # 1 : $ * MySize , # MySize . w <nl> + / / CHECK : assign [ [ SRC ] ] to [ [ DEST_ADDR ] ] : $ * Int <nl> + s2 . w = s . w <nl> + <nl> + / / CHECK : [ [ RESULT_ADDR : % . * ] ] = struct_element_addr % 1 : $ * MySize , # MySize . h <nl> + / / CHECK : [ [ RESULT : % . * ] ] = load [ [ RESULT_ADDR ] ] : $ * Int <nl> + _ = s . h <nl> + <nl> + / / CHECK : copy_addr % 1 to [ initialization ] [ [ SIZE_BOX : % . * ] ] # 1 : $ * MySize <nl> + / / CHECK : apply % 2 ( % 0 , [ [ SIZE_BOX ] ] # 1 ) <nl> + / / CHECK : return <nl> + return f ( s ) <nl> + } <nl> | Sema : Access stored properties of resilient structs through accessors | apple/swift | 693d3d339f2cded7d3b596964ad65ea14c6f1c8a | 2015-11-12T10:30:07Z |
mmm a / tools / push - to - trunk / common_includes . py <nl> ppp b / tools / push - to - trunk / common_includes . py <nl> def PrepareBranch ( self ) : <nl> self . DeleteBranch ( self . _config [ " BRANCHNAME " ] ) <nl> <nl> def CommonCleanup ( self ) : <nl> - self . GitCheckout ( self [ " current_branch " ] ) <nl> + if ' ' in self [ " current_branch " ] : <nl> + self . GitCheckout ( ' master ' ) <nl> + else : <nl> + self . GitCheckout ( self [ " current_branch " ] ) <nl> if self . _config [ " BRANCHNAME " ] ! = self [ " current_branch " ] : <nl> self . GitDeleteBranch ( self . _config [ " BRANCHNAME " ] ) <nl> <nl> | Make release script cleanup more robust . | v8/v8 | 935702e65564e8189967035d0fe8023badbb5511 | 2014-10-14T12:19:32Z |
mmm a / src / parseTools . js <nl> ppp b / src / parseTools . js <nl> function isBSS ( item ) { <nl> return false ; <nl> } <nl> <nl> + if ( item . external ) return false ; / / externals are typically implemented in a JS library , and must be accessed by name , explicitly <nl> + <nl> / / return true if a global is uninitialized or initialized to 0 <nl> - return item . external | | <nl> - ( item . value & & item . value . intertype = = = ' emptystruct ' ) | | <nl> - ( item . value & & item . value . value ! = = undefined & & item . value . value = = = ' 0 ' ) ; <nl> + return ( item . value & & item . value . intertype = = = ' emptystruct ' ) | | <nl> + ( item . value & & item . value . value ! = = undefined & & item . value . value = = = ' 0 ' ) ; <nl> } <nl> <nl> function makeGlobalDef ( ident ) { <nl> | do not include externals in BSS | emscripten-core/emscripten | d476e649c3fa794c88a4d30a58ac4bd33848fe92 | 2013-06-29T03:47:42Z |
mmm a / xbmc / addons / interfaces / AudioEngine . cpp <nl> ppp b / xbmc / addons / interfaces / AudioEngine . cpp <nl> void Interface_AudioEngine : : Init ( AddonGlobalInterface * addonInterface ) <nl> addonInterface - > toKodi - > kodi_audioengine = ( AddonToKodiFuncTable_kodi_audioengine * ) malloc ( sizeof ( AddonToKodiFuncTable_kodi_audioengine ) ) ; <nl> <nl> / / write KODI audio DSP specific add - on function addresses to callback table <nl> - addonInterface - > toKodi - > kodi_audioengine - > MakeStream = AudioEngine_MakeStream ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > FreeStream = AudioEngine_FreeStream ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > GetCurrentSinkFormat = AudioEngine_GetCurrentSinkFormat ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > make_stream = audioengine_make_stream ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > free_stream = audioengine_free_stream ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > get_current_sink_format = audioengine_get_current_sink_format ; <nl> <nl> / / AEStream add - on function callback table <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetSpace = AEStream_GetSpace ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_AddData = AEStream_AddData ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetDelay = AEStream_GetDelay ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_IsBuffering = AEStream_IsBuffering ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetCacheTime = AEStream_GetCacheTime ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetCacheTotal = AEStream_GetCacheTotal ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_Pause = AEStream_Pause ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_Resume = AEStream_Resume ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_Drain = AEStream_Drain ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_IsDraining = AEStream_IsDraining ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_IsDrained = AEStream_IsDrained ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_Flush = AEStream_Flush ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetVolume = AEStream_GetVolume ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_SetVolume = AEStream_SetVolume ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetAmplification = AEStream_GetAmplification ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_SetAmplification = AEStream_SetAmplification ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetFrameSize = AEStream_GetFrameSize ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetChannelCount = AEStream_GetChannelCount ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetSampleRate = AEStream_GetSampleRate ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetDataFormat = AEStream_GetDataFormat ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_GetResampleRatio = AEStream_GetResampleRatio ; <nl> - addonInterface - > toKodi - > kodi_audioengine - > AEStream_SetResampleRatio = AEStream_SetResampleRatio ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_space = aestream_get_space ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_add_data = aestream_add_data ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_delay = aestream_get_delay ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_is_buffering = aestream_is_buffering ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_cache_time = aestream_get_cache_time ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_cache_total = aestream_get_cache_total ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_pause = aestream_pause ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_resume = aestream_resume ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_drain = aestream_drain ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_is_draining = aestream_is_draining ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_is_drained = aestream_is_drained ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_flush = aestream_flush ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_volume = aestream_get_volume ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_set_volume = aestream_set_volume ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_amplification = aestream_get_amplification ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_set_amplification = aestream_set_amplification ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_frame_size = aestream_get_frame_size ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_channel_count = aestream_get_channel_count ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_sample_rate = aestream_get_sample_rate ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_data_format = aestream_get_data_format ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_get_resample_ratio = aestream_get_resample_ratio ; <nl> + addonInterface - > toKodi - > kodi_audioengine - > aestream_set_resample_ratio = aestream_set_resample_ratio ; <nl> } <nl> <nl> void Interface_AudioEngine : : DeInit ( AddonGlobalInterface * addonInterface ) <nl> void Interface_AudioEngine : : DeInit ( AddonGlobalInterface * addonInterface ) <nl> } <nl> } <nl> <nl> - AEStreamHandle * Interface_AudioEngine : : AudioEngine_MakeStream ( void * kodiBase , AudioEngineFormat streamFormat , unsigned int options ) <nl> + AEStreamHandle * Interface_AudioEngine : : audioengine_make_stream ( void * kodiBase , AudioEngineFormat * streamFormat , unsigned int options ) <nl> { <nl> - if ( ! kodiBase ) <nl> + if ( ! kodiBase | | ! streamFormat ) <nl> { <nl> - CLog : : Log ( LOGERROR , " Interface_AudioEngine : : % s - invalid stream data ( kodiBase = ' % p ' ) " , __FUNCTION__ , kodiBase ) ; <nl> + CLog : : Log ( LOGERROR , " Interface_AudioEngine : : % s - invalid stream data ( kodiBase = ' % p ' , streamFormat = ' % p ' ) " , __FUNCTION__ , kodiBase , streamFormat ) ; <nl> return nullptr ; <nl> } <nl> <nl> AEAudioFormat format ; <nl> - format . m_dataFormat = streamFormat . m_dataFormat ; <nl> - format . m_sampleRate = streamFormat . m_sampleRate ; <nl> - format . m_channelLayout = streamFormat . m_channels ; <nl> + format . m_dataFormat = streamFormat - > m_dataFormat ; <nl> + format . m_sampleRate = streamFormat - > m_sampleRate ; <nl> + format . m_channelLayout = streamFormat - > m_channels ; <nl> <nl> / * Translate addon options to kodi ' s options * / <nl> int kodiOption = 0 ; <nl> AEStreamHandle * Interface_AudioEngine : : AudioEngine_MakeStream ( void * kodiBase , Au <nl> return CServiceBroker : : GetActiveAE ( ) . MakeStream ( format , kodiOption ) ; <nl> } <nl> <nl> - void Interface_AudioEngine : : AudioEngine_FreeStream ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + void Interface_AudioEngine : : audioengine_free_stream ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> void Interface_AudioEngine : : AudioEngine_FreeStream ( void * kodiBase , AEStreamHandl <nl> CServiceBroker : : GetActiveAE ( ) . FreeStream ( static_cast < IAEStream * > ( streamHandle ) ) ; <nl> } <nl> <nl> - bool Interface_AudioEngine : : AudioEngine_GetCurrentSinkFormat ( void * kodiBase , AudioEngineFormat * format ) <nl> + bool Interface_AudioEngine : : audioengine_get_current_sink_format ( void * kodiBase , AudioEngineFormat * format ) <nl> { <nl> if ( ! kodiBase | | ! format ) <nl> { <nl> bool Interface_AudioEngine : : AudioEngine_GetCurrentSinkFormat ( void * kodiBase , Aud <nl> return true ; <nl> } <nl> <nl> - unsigned int Interface_AudioEngine : : AEStream_GetSpace ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + unsigned int Interface_AudioEngine : : aestream_get_space ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> unsigned int Interface_AudioEngine : : AEStream_GetSpace ( void * kodiBase , AEStreamHa <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetSpace ( ) ; <nl> } <nl> <nl> - unsigned int Interface_AudioEngine : : AEStream_AddData ( void * kodiBase , AEStreamHandle * streamHandle , uint8_t * const * data , <nl> + unsigned int Interface_AudioEngine : : aestream_add_data ( void * kodiBase , AEStreamHandle * streamHandle , uint8_t * const * data , <nl> unsigned int offset , unsigned int frames , double pts ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> unsigned int Interface_AudioEngine : : AEStream_AddData ( void * kodiBase , AEStreamHan <nl> return static_cast < IAEStream * > ( streamHandle ) - > AddData ( data , offset , frames , pts ) ; <nl> } <nl> <nl> - double Interface_AudioEngine : : AEStream_GetDelay ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + double Interface_AudioEngine : : aestream_get_delay ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> double Interface_AudioEngine : : AEStream_GetDelay ( void * kodiBase , AEStreamHandle * <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetDelay ( ) ; <nl> } <nl> <nl> - bool Interface_AudioEngine : : AEStream_IsBuffering ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + bool Interface_AudioEngine : : aestream_is_buffering ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> bool Interface_AudioEngine : : AEStream_IsBuffering ( void * kodiBase , AEStreamHandle * <nl> return static_cast < IAEStream * > ( streamHandle ) - > IsBuffering ( ) ; <nl> } <nl> <nl> - double Interface_AudioEngine : : AEStream_GetCacheTime ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + double Interface_AudioEngine : : aestream_get_cache_time ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> double Interface_AudioEngine : : AEStream_GetCacheTime ( void * kodiBase , AEStreamHand <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetCacheTime ( ) ; <nl> } <nl> <nl> - double Interface_AudioEngine : : AEStream_GetCacheTotal ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + double Interface_AudioEngine : : aestream_get_cache_total ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> double Interface_AudioEngine : : AEStream_GetCacheTotal ( void * kodiBase , AEStreamHan <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetCacheTotal ( ) ; <nl> } <nl> <nl> - void Interface_AudioEngine : : AEStream_Pause ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + void Interface_AudioEngine : : aestream_pause ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> void Interface_AudioEngine : : AEStream_Pause ( void * kodiBase , AEStreamHandle * strea <nl> static_cast < IAEStream * > ( streamHandle ) - > Pause ( ) ; <nl> } <nl> <nl> - void Interface_AudioEngine : : AEStream_Resume ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + void Interface_AudioEngine : : aestream_resume ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> void Interface_AudioEngine : : AEStream_Resume ( void * kodiBase , AEStreamHandle * stre <nl> static_cast < IAEStream * > ( streamHandle ) - > Resume ( ) ; <nl> } <nl> <nl> - void Interface_AudioEngine : : AEStream_Drain ( void * kodiBase , AEStreamHandle * streamHandle , bool wait ) <nl> + void Interface_AudioEngine : : aestream_drain ( void * kodiBase , AEStreamHandle * streamHandle , bool wait ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> void Interface_AudioEngine : : AEStream_Drain ( void * kodiBase , AEStreamHandle * strea <nl> static_cast < IAEStream * > ( streamHandle ) - > Drain ( wait ) ; <nl> } <nl> <nl> - bool Interface_AudioEngine : : AEStream_IsDraining ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + bool Interface_AudioEngine : : aestream_is_draining ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> bool Interface_AudioEngine : : AEStream_IsDraining ( void * kodiBase , AEStreamHandle * <nl> return static_cast < IAEStream * > ( streamHandle ) - > IsDraining ( ) ; <nl> } <nl> <nl> - bool Interface_AudioEngine : : AEStream_IsDrained ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + bool Interface_AudioEngine : : aestream_is_drained ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> bool Interface_AudioEngine : : AEStream_IsDrained ( void * kodiBase , AEStreamHandle * s <nl> return static_cast < IAEStream * > ( streamHandle ) - > IsDrained ( ) ; <nl> } <nl> <nl> - void Interface_AudioEngine : : AEStream_Flush ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + void Interface_AudioEngine : : aestream_flush ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> void Interface_AudioEngine : : AEStream_Flush ( void * kodiBase , AEStreamHandle * strea <nl> static_cast < IAEStream * > ( streamHandle ) - > Flush ( ) ; <nl> } <nl> <nl> - float Interface_AudioEngine : : AEStream_GetVolume ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + float Interface_AudioEngine : : aestream_get_volume ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> float Interface_AudioEngine : : AEStream_GetVolume ( void * kodiBase , AEStreamHandle * <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetVolume ( ) ; <nl> } <nl> <nl> - void Interface_AudioEngine : : AEStream_SetVolume ( void * kodiBase , AEStreamHandle * streamHandle , float volume ) <nl> + void Interface_AudioEngine : : aestream_set_volume ( void * kodiBase , AEStreamHandle * streamHandle , float volume ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> void Interface_AudioEngine : : AEStream_SetVolume ( void * kodiBase , AEStreamHandle * <nl> static_cast < IAEStream * > ( streamHandle ) - > SetVolume ( volume ) ; <nl> } <nl> <nl> - float Interface_AudioEngine : : AEStream_GetAmplification ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + float Interface_AudioEngine : : aestream_get_amplification ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> float Interface_AudioEngine : : AEStream_GetAmplification ( void * kodiBase , AEStreamH <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetAmplification ( ) ; <nl> } <nl> <nl> - void Interface_AudioEngine : : AEStream_SetAmplification ( void * kodiBase , AEStreamHandle * streamHandle , float amplify ) <nl> + void Interface_AudioEngine : : aestream_set_amplification ( void * kodiBase , AEStreamHandle * streamHandle , float amplify ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> void Interface_AudioEngine : : AEStream_SetAmplification ( void * kodiBase , AEStreamHa <nl> static_cast < IAEStream * > ( streamHandle ) - > SetAmplification ( amplify ) ; <nl> } <nl> <nl> - unsigned int Interface_AudioEngine : : AEStream_GetFrameSize ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + unsigned int Interface_AudioEngine : : aestream_get_frame_size ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> unsigned int Interface_AudioEngine : : AEStream_GetFrameSize ( void * kodiBase , AEStre <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetFrameSize ( ) ; <nl> } <nl> <nl> - unsigned int Interface_AudioEngine : : AEStream_GetChannelCount ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + unsigned int Interface_AudioEngine : : aestream_get_channel_count ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> unsigned int Interface_AudioEngine : : AEStream_GetChannelCount ( void * kodiBase , AES <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetChannelCount ( ) ; <nl> } <nl> <nl> - unsigned int Interface_AudioEngine : : AEStream_GetSampleRate ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + unsigned int Interface_AudioEngine : : aestream_get_sample_rate ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> unsigned int Interface_AudioEngine : : AEStream_GetSampleRate ( void * kodiBase , AEStr <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetSampleRate ( ) ; <nl> } <nl> <nl> - AEDataFormat Interface_AudioEngine : : AEStream_GetDataFormat ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + AEDataFormat Interface_AudioEngine : : aestream_get_data_format ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> AEDataFormat Interface_AudioEngine : : AEStream_GetDataFormat ( void * kodiBase , AEStr <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetDataFormat ( ) ; <nl> } <nl> <nl> - double Interface_AudioEngine : : AEStream_GetResampleRatio ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> + double Interface_AudioEngine : : aestream_get_resample_ratio ( void * kodiBase , AEStreamHandle * streamHandle ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> double Interface_AudioEngine : : AEStream_GetResampleRatio ( void * kodiBase , AEStream <nl> return static_cast < IAEStream * > ( streamHandle ) - > GetResampleRatio ( ) ; <nl> } <nl> <nl> - void Interface_AudioEngine : : AEStream_SetResampleRatio ( void * kodiBase , AEStreamHandle * streamHandle , double ratio ) <nl> + void Interface_AudioEngine : : aestream_set_resample_ratio ( void * kodiBase , AEStreamHandle * streamHandle , double ratio ) <nl> { <nl> if ( ! kodiBase | | ! streamHandle ) <nl> { <nl> mmm a / xbmc / addons / interfaces / AudioEngine . h <nl> ppp b / xbmc / addons / interfaces / AudioEngine . h <nl> namespace ADDON <nl> * @ param [ in ] options A bit field of stream options ( see : enum AEStreamOptions ) <nl> * @ return a new Handle to an IAEStream that will accept data in the requested format <nl> * / <nl> - static AEStreamHandle * AudioEngine_MakeStream ( void * kodiBase , AudioEngineFormat streamFormat , unsigned int options ) ; <nl> + static AEStreamHandle * audioengine_make_stream ( void * kodiBase , AudioEngineFormat * streamFormat , unsigned int options ) ; <nl> <nl> / * * <nl> * This method will remove the specifyed stream from the engine . <nl> * For OSX / IOS this is essential to reconfigure the audio output . <nl> * @ param [ in ] streamHandle The stream to be altered <nl> * / <nl> - static void AudioEngine_FreeStream ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static void audioengine_free_stream ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Get the current sink data format <nl> namespace ADDON <nl> * @ param [ in ] sinkFormat sink data format . For more details see AudioEngineFormat . <nl> * @ return Returns true on success , else false . <nl> * / <nl> - static bool AudioEngine_GetCurrentSinkFormat ( void * kodiBase , AudioEngineFormat * sinkFormat ) ; <nl> + static bool audioengine_get_current_sink_format ( void * kodiBase , AudioEngineFormat * sinkFormat ) ; <nl> <nl> / * * <nl> * Returns the amount of space available in the stream <nl> * @ return The number of bytes AddData will consume <nl> * / <nl> - static unsigned int AEStream_GetSpace ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static unsigned int aestream_get_space ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Add planar or interleaved PCM data to the stream <nl> namespace ADDON <nl> * @ param [ in ] frames number of frames <nl> * @ return The number of frames consumed <nl> * / <nl> - static unsigned int AEStream_AddData ( void * kodiBase , AEStreamHandle * streamHandle , uint8_t * const * data , <nl> - unsigned int offset , unsigned int frames , double pts ) ; <nl> + static unsigned int aestream_add_data ( void * kodiBase , AEStreamHandle * streamHandle , uint8_t * const * data , <nl> + unsigned int offset , unsigned int frames , double pts ) ; <nl> <nl> / * * <nl> * Returns the time in seconds that it will take <nl> * for the next added packet to be heard from the speakers . <nl> * @ return seconds <nl> * / <nl> - static double AEStream_GetDelay ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static double aestream_get_delay ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Returns if the stream is buffering <nl> * @ return True if the stream is buffering <nl> * / <nl> - static bool AEStream_IsBuffering ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static bool aestream_is_buffering ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Returns the time in seconds that it will take <nl> * to underrun the cache if no sample is added . <nl> * @ return seconds <nl> * / <nl> - static double AEStream_GetCacheTime ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static double aestream_get_cache_time ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Returns the total time in seconds of the cache <nl> * @ return seconds <nl> * / <nl> - static double AEStream_GetCacheTotal ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static double aestream_get_cache_total ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Pauses the stream playback <nl> * / <nl> - static void AEStream_Pause ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static void aestream_pause ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Resumes the stream after pausing <nl> * / <nl> - static void AEStream_Resume ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static void aestream_resume ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Start draining the stream <nl> * @ note Once called AddData will not consume more data . <nl> * / <nl> - static void AEStream_Drain ( void * kodiBase , AEStreamHandle * streamHandle , bool wait ) ; <nl> + static void aestream_drain ( void * kodiBase , AEStreamHandle * streamHandle , bool wait ) ; <nl> <nl> / * * <nl> * Returns true if the is stream draining <nl> * / <nl> - static bool AEStream_IsDraining ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static bool aestream_is_draining ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Returns true if the is stream has finished draining <nl> * / <nl> - static bool AEStream_IsDrained ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static bool aestream_is_drained ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Flush all buffers dropping the audio data <nl> * / <nl> - static void AEStream_Flush ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static void aestream_flush ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Return the stream ' s current volume level <nl> * @ return The volume level between 0 . 0 and 1 . 0 <nl> * / <nl> - static float AEStream_GetVolume ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static float aestream_get_volume ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Set the stream ' s volume level <nl> * @ param volume The new volume level between 0 . 0 and 1 . 0 <nl> * / <nl> - static void AEStream_SetVolume ( void * kodiBase , AEStreamHandle * streamHandle , float volume ) ; <nl> + static void aestream_set_volume ( void * kodiBase , AEStreamHandle * streamHandle , float volume ) ; <nl> <nl> / * * <nl> * Gets the stream ' s volume amplification in linear units . <nl> * @ return The volume amplification factor between 1 . 0 and 1000 . 0 <nl> * / <nl> - static float AEStream_GetAmplification ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static float aestream_get_amplification ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Sets the stream ' s volume amplification in linear units . <nl> * @ param amplify The volume amplification factor between 1 . 0 and 1000 . 0 <nl> * / <nl> - static void AEStream_SetAmplification ( void * kodiBase , AEStreamHandle * streamHandle , float amplify ) ; <nl> + static void aestream_set_amplification ( void * kodiBase , AEStreamHandle * streamHandle , float amplify ) ; <nl> <nl> / * * <nl> * Returns the size of one audio frame in bytes ( channelCount * resolution ) <nl> * @ return The size in bytes of one frame <nl> * / <nl> - static unsigned int AEStream_GetFrameSize ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static unsigned int aestream_get_frame_size ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Returns the number of channels the stream is configured to accept <nl> * @ return The channel count <nl> * / <nl> - static unsigned int AEStream_GetChannelCount ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static unsigned int aestream_get_channel_count ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Returns the stream ' s sample rate , if the stream is using a dynamic sample rate , this value will NOT reflect any changes made by calls to SetResampleRatio ( ) <nl> * @ return The stream ' s sample rate ( eg , 48000 ) <nl> * / <nl> - static unsigned int AEStream_GetSampleRate ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static unsigned int aestream_get_sample_rate ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Return the data format the stream has been configured with <nl> * @ return The stream ' s data format ( eg , AE_FMT_S16LE ) <nl> * / <nl> - static AEDataFormat AEStream_GetDataFormat ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static AEDataFormat aestream_get_data_format ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Return the resample ratio <nl> * @ note This will return an undefined value if the stream is not resampling <nl> * @ return the current resample ratio or undefined if the stream is not resampling <nl> * / <nl> - static double AEStream_GetResampleRatio ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> + static double aestream_get_resample_ratio ( void * kodiBase , AEStreamHandle * streamHandle ) ; <nl> <nl> / * * <nl> * Sets the resample ratio <nl> * @ note This function may return false if the stream is not resampling , if you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option <nl> * @ param [ in ] ratio the new sample rate ratio , calculated by ( ( double ) desiredRate / ( double ) GetSampleRate ( ) ) <nl> * / <nl> - static void AEStream_SetResampleRatio ( void * kodiBase , AEStreamHandle * streamHandle , double ratio ) ; <nl> + static void aestream_set_resample_ratio ( void * kodiBase , AEStreamHandle * streamHandle , double ratio ) ; <nl> } ; <nl> <nl> } / * namespace ADDON * / <nl> mmm a / xbmc / addons / kodi - addon - dev - kit / include / kodi / AudioEngine . h <nl> ppp b / xbmc / addons / kodi - addon - dev - kit / include / kodi / AudioEngine . h <nl> extern " C " <nl> } <nl> } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> } ; <nl> / / @ } <nl> extern " C " <nl> * / <nl> typedef struct AddonToKodiFuncTable_kodi_audioengine <nl> { <nl> - AEStreamHandle * ( * MakeStream ) ( void * kodiBase , AudioEngineFormat format , unsigned int options ) ; <nl> - void ( * FreeStream ) ( void * kodiBase , AEStreamHandle * stream ) ; <nl> - bool ( * GetCurrentSinkFormat ) ( void * kodiBase , AudioEngineFormat * SinkFormat ) ; <nl> + AEStreamHandle * ( * make_stream ) ( void * kodiBase , AudioEngineFormat * format , unsigned int options ) ; <nl> + void ( * free_stream ) ( void * kodiBase , AEStreamHandle * stream ) ; <nl> + bool ( * get_current_sink_format ) ( void * kodiBase , AudioEngineFormat * sink_format ) ; <nl> <nl> / / Audio Engine Stream definitions <nl> - unsigned int ( * AEStream_GetSpace ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - unsigned int ( * AEStream_AddData ) ( void * kodiBase , AEStreamHandle * handle , uint8_t * const * data , <nl> + unsigned int ( * aestream_get_space ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + unsigned int ( * aestream_add_data ) ( void * kodiBase , AEStreamHandle * handle , uint8_t * const * data , <nl> unsigned int offset , unsigned int frames , double pts ) ; <nl> - double ( * AEStream_GetDelay ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - bool ( * AEStream_IsBuffering ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - double ( * AEStream_GetCacheTime ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - double ( * AEStream_GetCacheTotal ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - void ( * AEStream_Pause ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - void ( * AEStream_Resume ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - void ( * AEStream_Drain ) ( void * kodiBase , AEStreamHandle * handle , bool Wait ) ; <nl> - bool ( * AEStream_IsDraining ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - bool ( * AEStream_IsDrained ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - void ( * AEStream_Flush ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - float ( * AEStream_GetVolume ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - void ( * AEStream_SetVolume ) ( void * kodiBase , AEStreamHandle * handle , float Volume ) ; <nl> - float ( * AEStream_GetAmplification ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - void ( * AEStream_SetAmplification ) ( void * kodiBase , AEStreamHandle * handle , float Amplify ) ; <nl> - unsigned int ( * AEStream_GetFrameSize ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - unsigned int ( * AEStream_GetChannelCount ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - unsigned int ( * AEStream_GetSampleRate ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - AEDataFormat ( * AEStream_GetDataFormat ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - double ( * AEStream_GetResampleRatio ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> - void ( * AEStream_SetResampleRatio ) ( void * kodiBase , AEStreamHandle * handle , double Ratio ) ; <nl> + double ( * aestream_get_delay ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + bool ( * aestream_is_buffering ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + double ( * aestream_get_cache_time ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + double ( * aestream_get_cache_total ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + void ( * aestream_pause ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + void ( * aestream_resume ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + void ( * aestream_drain ) ( void * kodiBase , AEStreamHandle * handle , bool wait ) ; <nl> + bool ( * aestream_is_draining ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + bool ( * aestream_is_drained ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + void ( * aestream_flush ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + float ( * aestream_get_volume ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + void ( * aestream_set_volume ) ( void * kodiBase , AEStreamHandle * handle , float volume ) ; <nl> + float ( * aestream_get_amplification ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + void ( * aestream_set_amplification ) ( void * kodiBase , AEStreamHandle * handle , float amplify ) ; <nl> + unsigned int ( * aestream_get_frame_size ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + unsigned int ( * aestream_get_channel_count ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + unsigned int ( * aestream_get_sample_rate ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + AEDataFormat ( * aestream_get_data_format ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + double ( * aestream_get_resample_ratio ) ( void * kodiBase , AEStreamHandle * handle ) ; <nl> + void ( * aestream_set_resample_ratio ) ( void * kodiBase , AEStreamHandle * handle , double ratio ) ; <nl> } AddonToKodiFuncTable_kodi_audioengine ; <nl> <nl> } / * extern " C " * / <nl> namespace audioengine <nl> / / / <nl> / / / * * Bit options to pass to CAELib_Stream ( on Kodi by < c > IAE : : MakeStream < / c > ) * * <nl> / / / <nl> - / / / | enum AEStreamOptions | Value : | Description : <nl> - / / / | mmmmmmmmmmmmmmmmmmmmmmmm - : | : mmmmmm : | : mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / / | AE_STREAM_FORCE_RESAMPLE | 1 < < 0 | Force resample even if rates match <nl> - / / / | AE_STREAM_PAUSED | 1 < < 1 | Create the stream paused <nl> - / / / | AE_STREAM_AUTOSTART | 1 < < 2 | Autostart the stream when enough data is buffered <nl> - / / / | AE_STREAM_BYPASS_ADSP | 1 < < 3 | if this option is set the ADSP - System is bypassed and the raw stream will be passed through IAESink . <nl> + / / / | enum AEStreamOptions | Value : | Description : <nl> + / / / | mmmmmmmmmmmmmmmmmmmmmmmmmmm - : | : mmmmmm : | : mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / / | AUDIO_STREAM_FORCE_RESAMPLE | 1 < < 0 | Force resample even if rates match <nl> + / / / | AUDIO_STREAM_PAUSED | 1 < < 1 | Create the stream paused <nl> + / / / | AUDIO_STREAM_AUTOSTART | 1 < < 2 | Autostart the stream when enough data is buffered <nl> + / / / | AUDIO_STREAM_BYPASS_ADSP | 1 < < 3 | if this option is set the ADSP - System is bypassed and the raw stream will be passed through IAESink . <nl> / / / <nl> / / / <nl> / / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> namespace audioengine <nl> / / / <nl> / / / . . . <nl> / / / <nl> - / / / CAddonAEStream * stream = new CAddonAEStream ( AE_FMT_S16LE , AE_STREAM_AUTOSTART | AE_STREAM_BYPASS_ADSP ) ; <nl> + / / / AudioEngineFormat format ; <nl> + / / / format . m_dataFormat = AE_FMT_FLOAT ; <nl> + / / / format . m_channelCount = 2 ; <nl> + / / / format . m_channels [ 0 ] = AE_CH_FL ; <nl> + / / / format . m_channels [ 1 ] = AE_CH_FR ; <nl> + / / / format . m_channels [ 2 ] = AE_CH_NULL ; <nl> + / / / format . m_sampleRate = 48000 ; <nl> + / / / format . m_frameSize = sizeof ( float ) * format . m_channelCount ; <nl> + / / / format . m_frames = 512 ; <nl> + / / / CAddonAEStream * stream = new CAddonAEStream ( format , AE_STREAM_AUTOSTART | AE_STREAM_BYPASS_ADSP ) ; <nl> / / / <nl> / / / ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <nl> / / / <nl> namespace audioengine <nl> : m_kodiBase ( : : kodi : : addon : : CAddonBase : : m_interface - > toKodi - > kodiBase ) , <nl> m_cb ( : : kodi : : addon : : CAddonBase : : m_interface - > toKodi - > kodi_audioengine ) <nl> { <nl> - m_StreamHandle = m_cb - > MakeStream ( m_kodiBase , format , options ) ; <nl> + m_StreamHandle = m_cb - > make_stream ( m_kodiBase , & format , options ) ; <nl> if ( m_StreamHandle = = nullptr ) <nl> { <nl> - kodi : : Log ( ADDON_LOG_FATAL , " CAddonAEStream : MakeStream failed ! " ) ; <nl> + kodi : : Log ( ADDON_LOG_FATAL , " CAddonAEStream : make_stream failed ! " ) ; <nl> } <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / / @ ingroup cpp_kodi_audioengine_CAddonAEStream <nl> + / / / @ brief Class destructor <nl> + / / / <nl> ~ CAddonAEStream ( ) <nl> { <nl> if ( m_StreamHandle ) <nl> { <nl> - m_cb - > FreeStream ( m_kodiBase , m_StreamHandle ) ; <nl> + m_cb - > free_stream ( m_kodiBase , m_StreamHandle ) ; <nl> m_StreamHandle = nullptr ; <nl> } <nl> } <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> / / / @ ingroup cpp_kodi_audioengine_CAddonAEStream <nl> namespace audioengine <nl> / / / <nl> unsigned int GetSpace ( ) <nl> { <nl> - return m_cb - > AEStream_GetSpace ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_space ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / @ ingroup cpp_kodi_audioengine_CAddonAEStream <nl> / / / @ brief Add planar or interleaved PCM data to the stream <nl> / / / <nl> - / / / @ param data array of pointers to the planes <nl> - / / / @ param offset to frame in frames <nl> - / / / @ param frames number of frames <nl> - / / / @ param pts presentation timestamp <nl> + / / / @ param [ in ] data array of pointers to the planes <nl> + / / / @ param [ in ] offset to frame in frames <nl> + / / / @ param [ in ] frames number of frames <nl> + / / / @ param [ in ] pts presentation timestamp <nl> / / / @ return The number of frames consumed <nl> / / / <nl> unsigned int AddData ( uint8_t * const * data , unsigned int offset , unsigned int frames , double pts = 0 . 0 ) <nl> { <nl> - return m_cb - > AEStream_AddData ( m_kodiBase , m_StreamHandle , data , offset , frames , pts ) ; <nl> + return m_cb - > aestream_add_data ( m_kodiBase , m_StreamHandle , data , offset , frames , pts ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> double GetDelay ( ) <nl> { <nl> - return m_cb - > AEStream_GetDelay ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_delay ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> bool IsBuffering ( ) <nl> { <nl> - return m_cb - > AEStream_IsBuffering ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_is_buffering ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> double GetCacheTime ( ) <nl> { <nl> - return m_cb - > AEStream_GetCacheTime ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_cache_time ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> double GetCacheTotal ( ) <nl> { <nl> - return m_cb - > AEStream_GetCacheTotal ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_cache_total ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> void Pause ( ) <nl> { <nl> - return m_cb - > AEStream_Pause ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_pause ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> void Resume ( ) <nl> { <nl> - return m_cb - > AEStream_Resume ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_resume ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> / / / @ note Once called AddData will not consume more data . <nl> / / / <nl> - void Drain ( bool wait ) <nl> + void Drain ( bool wait = true ) <nl> { <nl> - return m_cb - > AEStream_Drain ( m_kodiBase , m_StreamHandle , wait = true ) ; <nl> + return m_cb - > aestream_drain ( m_kodiBase , m_StreamHandle , wait ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> bool IsDraining ( ) <nl> { <nl> - return m_cb - > AEStream_IsDraining ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_is_draining ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> bool IsDrained ( ) <nl> { <nl> - return m_cb - > AEStream_IsDrained ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_is_drained ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> void Flush ( ) <nl> { <nl> - return m_cb - > AEStream_Flush ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_flush ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> float GetVolume ( ) <nl> { <nl> - return m_cb - > AEStream_GetVolume ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_volume ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> void SetVolume ( float volume ) <nl> { <nl> - return m_cb - > AEStream_SetVolume ( m_kodiBase , m_StreamHandle , volume ) ; <nl> + return m_cb - > aestream_set_volume ( m_kodiBase , m_StreamHandle , volume ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> float GetAmplification ( ) <nl> { <nl> - return m_cb - > AEStream_GetAmplification ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_amplification ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> void SetAmplification ( float amplify ) <nl> { <nl> - return m_cb - > AEStream_SetAmplification ( m_kodiBase , m_StreamHandle , amplify ) ; <nl> + return m_cb - > aestream_set_amplification ( m_kodiBase , m_StreamHandle , amplify ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> unsigned int GetFrameSize ( ) const <nl> { <nl> - return m_cb - > AEStream_GetFrameSize ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_frame_size ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> unsigned int GetChannelCount ( ) const <nl> { <nl> - return m_cb - > AEStream_GetChannelCount ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_channel_count ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> unsigned int GetSampleRate ( ) const <nl> { <nl> - return m_cb - > AEStream_GetSampleRate ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_sample_rate ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> AEDataFormat GetDataFormat ( ) const <nl> { <nl> - return m_cb - > AEStream_GetDataFormat ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_data_format ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> double GetResampleRatio ( ) <nl> { <nl> - return m_cb - > AEStream_GetResampleRatio ( m_kodiBase , m_StreamHandle ) ; <nl> + return m_cb - > aestream_get_resample_ratio ( m_kodiBase , m_StreamHandle ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> void SetResampleRatio ( double ratio ) <nl> { <nl> - m_cb - > AEStream_SetResampleRatio ( m_kodiBase , m_StreamHandle , ratio ) ; <nl> + m_cb - > aestream_set_resample_ratio ( m_kodiBase , m_StreamHandle , ratio ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> namespace audioengine <nl> / / / <nl> inline bool GetCurrentSinkFormat ( AudioEngineFormat & format ) <nl> { <nl> - return : : kodi : : addon : : CAddonBase : : m_interface - > toKodi - > kodi_audioengine - > GetCurrentSinkFormat ( : : kodi : : addon : : CAddonBase : : m_interface - > toKodi - > kodiBase , & format ) ; <nl> + using namespace kodi : : addon ; <nl> + return CAddonBase : : m_interface - > toKodi - > kodi_audioengine - > get_current_sink_format ( CAddonBase : : m_interface - > toKodi - > kodiBase , & format ) ; <nl> } <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> mmm a / xbmc / addons / kodi - addon - dev - kit / include / kodi / versions . h <nl> ppp b / xbmc / addons / kodi - addon - dev - kit / include / kodi / versions . h <nl> <nl> # define ADDON_GLOBAL_VERSION_GUI_XML_ID " kodi . binary . global . gui " <nl> # define ADDON_GLOBAL_VERSION_GUI_DEPENDS " libKODI_guilib . h " <nl> <nl> - # define ADDON_GLOBAL_VERSION_AUDIOENGINE " 1 . 0 . 0 " <nl> - # define ADDON_GLOBAL_VERSION_AUDIOENGINE_MIN " 1 . 0 . 0 " <nl> + # define ADDON_GLOBAL_VERSION_AUDIOENGINE " 1 . 0 . 1 " <nl> + # define ADDON_GLOBAL_VERSION_AUDIOENGINE_MIN " 1 . 0 . 1 " <nl> # define ADDON_GLOBAL_VERSION_AUDIOENGINE_XML_ID " kodi . binary . global . audioengine " <nl> # define ADDON_GLOBAL_VERSION_AUDIOENGINE_DEPENDS " AudioEngine . h " <nl> <nl> | [ addons ] cleanup audio engine | xbmc/xbmc | 46162b5f63c5d25d5c326b104cef25b09290dc78 | 2017-08-29T19:21:07Z |
Binary files a / csharp / src / Google . Protobuf . Test / testprotos . pb and b / csharp / src / Google . Protobuf . Test / testprotos . pb differ <nl> | Update C # generated proto file | protocolbuffers/protobuf | ef5e8f4aa7337a23e3f943117d78b05eee60dad0 | 2019-06-17T21:05:40Z |
mmm a / modules / core / include / opencv2 / core / cvdef . h <nl> ppp b / modules / core / include / opencv2 / core / cvdef . h <nl> Cv64suf ; <nl> # define CV_FINAL final <nl> # endif <nl> <nl> + # ifndef CV_NOEXCEPT <nl> + # if __cplusplus > = 201103L | | ( defined ( _MSC_VER ) & & _MSC_VER > = 1900 / * MSVS 2015 * / ) <nl> + # define CV_NOEXCEPT noexcept <nl> + # endif <nl> + # endif <nl> + # ifndef CV_NOEXCEPT <nl> + # define CV_NOEXCEPT <nl> + # endif <nl> + <nl> <nl> / / Integer types portatibility <nl> # ifdef OPENCV_STDINT_HEADER <nl> mmm a / modules / core / include / opencv2 / core / types . hpp <nl> ppp b / modules / core / include / opencv2 / core / types . hpp <nl> template < typename _Tp > class Point_ <nl> Point_ ( ) ; <nl> Point_ ( _Tp _x , _Tp _y ) ; <nl> Point_ ( const Point_ & pt ) ; <nl> - Point_ ( Point_ & & pt ) noexcept ; <nl> + Point_ ( Point_ & & pt ) CV_NOEXCEPT ; <nl> Point_ ( const Size_ < _Tp > & sz ) ; <nl> Point_ ( const Vec < _Tp , 2 > & v ) ; <nl> <nl> Point_ & operator = ( const Point_ & pt ) ; <nl> - Point_ & operator = ( Point_ & & pt ) noexcept ; <nl> + Point_ & operator = ( Point_ & & pt ) CV_NOEXCEPT ; <nl> / / ! conversion to another data type <nl> template < typename _Tp2 > operator Point_ < _Tp2 > ( ) const ; <nl> <nl> template < typename _Tp > class Point3_ <nl> Point3_ ( ) ; <nl> Point3_ ( _Tp _x , _Tp _y , _Tp _z ) ; <nl> Point3_ ( const Point3_ & pt ) ; <nl> - Point3_ ( Point3_ & & pt ) noexcept ; <nl> + Point3_ ( Point3_ & & pt ) CV_NOEXCEPT ; <nl> explicit Point3_ ( const Point_ < _Tp > & pt ) ; <nl> Point3_ ( const Vec < _Tp , 3 > & v ) ; <nl> <nl> Point3_ & operator = ( const Point3_ & pt ) ; <nl> - Point3_ & operator = ( Point3_ & & pt ) noexcept ; <nl> + Point3_ & operator = ( Point3_ & & pt ) CV_NOEXCEPT ; <nl> / / ! conversion to another data type <nl> template < typename _Tp2 > operator Point3_ < _Tp2 > ( ) const ; <nl> / / ! conversion to cv : : Vec < > <nl> template < typename _Tp > class Size_ <nl> Size_ ( ) ; <nl> Size_ ( _Tp _width , _Tp _height ) ; <nl> Size_ ( const Size_ & sz ) ; <nl> - Size_ ( Size_ & & sz ) noexcept ; <nl> + Size_ ( Size_ & & sz ) CV_NOEXCEPT ; <nl> Size_ ( const Point_ < _Tp > & pt ) ; <nl> <nl> Size_ & operator = ( const Size_ & sz ) ; <nl> - Size_ & operator = ( Size_ & & sz ) noexcept ; <nl> + Size_ & operator = ( Size_ & & sz ) CV_NOEXCEPT ; <nl> / / ! the area ( width * height ) <nl> _Tp area ( ) const ; <nl> / / ! aspect ratio ( width / height ) <nl> template < typename _Tp > class Rect_ <nl> Rect_ ( ) ; <nl> Rect_ ( _Tp _x , _Tp _y , _Tp _width , _Tp _height ) ; <nl> Rect_ ( const Rect_ & r ) ; <nl> - Rect_ ( Rect_ & & r ) noexcept ; <nl> + Rect_ ( Rect_ & & r ) CV_NOEXCEPT ; <nl> Rect_ ( const Point_ < _Tp > & org , const Size_ < _Tp > & sz ) ; <nl> Rect_ ( const Point_ < _Tp > & pt1 , const Point_ < _Tp > & pt2 ) ; <nl> <nl> Rect_ & operator = ( const Rect_ & r ) ; <nl> - Rect_ & operator = ( Rect_ & & r ) noexcept ; <nl> + Rect_ & operator = ( Rect_ & & r ) CV_NOEXCEPT ; <nl> / / ! the top - left corner <nl> Point_ < _Tp > tl ( ) const ; <nl> / / ! the bottom - right corner <nl> template < typename _Tp > class Scalar_ : public Vec < _Tp , 4 > <nl> Scalar_ ( _Tp v0 ) ; <nl> <nl> Scalar_ ( const Scalar_ & s ) ; <nl> - Scalar_ ( Scalar_ & & s ) noexcept ; <nl> + Scalar_ ( Scalar_ & & s ) CV_NOEXCEPT ; <nl> <nl> Scalar_ & operator = ( const Scalar_ & s ) ; <nl> - Scalar_ & operator = ( Scalar_ & & s ) noexcept ; <nl> + Scalar_ & operator = ( Scalar_ & & s ) CV_NOEXCEPT ; <nl> <nl> template < typename _Tp2 , int cn > <nl> Scalar_ ( const Vec < _Tp2 , cn > & v ) ; <nl> Point_ < _Tp > : : Point_ ( const Point_ & pt ) <nl> : x ( pt . x ) , y ( pt . y ) { } <nl> <nl> template < typename _Tp > inline <nl> - Point_ < _Tp > : : Point_ ( Point_ & & pt ) noexcept <nl> + Point_ < _Tp > : : Point_ ( Point_ & & pt ) CV_NOEXCEPT <nl> : x ( std : : move ( pt . x ) ) , y ( std : : move ( pt . y ) ) { } <nl> <nl> template < typename _Tp > inline <nl> Point_ < _Tp > & Point_ < _Tp > : : operator = ( const Point_ & pt ) <nl> } <nl> <nl> template < typename _Tp > inline <nl> - Point_ < _Tp > & Point_ < _Tp > : : operator = ( Point_ & & pt ) noexcept <nl> + Point_ < _Tp > & Point_ < _Tp > : : operator = ( Point_ & & pt ) CV_NOEXCEPT <nl> { <nl> x = std : : move ( pt . x ) ; y = std : : move ( pt . y ) ; <nl> return * this ; <nl> Point3_ < _Tp > : : Point3_ ( const Point3_ & pt ) <nl> : x ( pt . x ) , y ( pt . y ) , z ( pt . z ) { } <nl> <nl> template < typename _Tp > inline <nl> - Point3_ < _Tp > : : Point3_ ( Point3_ & & pt ) noexcept <nl> + Point3_ < _Tp > : : Point3_ ( Point3_ & & pt ) CV_NOEXCEPT <nl> : x ( std : : move ( pt . x ) ) , y ( std : : move ( pt . y ) ) , z ( std : : move ( pt . z ) ) { } <nl> <nl> template < typename _Tp > inline <nl> Point3_ < _Tp > & Point3_ < _Tp > : : operator = ( const Point3_ & pt ) <nl> } <nl> <nl> template < typename _Tp > inline <nl> - Point3_ < _Tp > & Point3_ < _Tp > : : operator = ( Point3_ & & pt ) noexcept <nl> + Point3_ < _Tp > & Point3_ < _Tp > : : operator = ( Point3_ & & pt ) CV_NOEXCEPT <nl> { <nl> x = std : : move ( pt . x ) ; y = std : : move ( pt . y ) ; z = std : : move ( pt . z ) ; <nl> return * this ; <nl> Size_ < _Tp > : : Size_ ( const Size_ & sz ) <nl> : width ( sz . width ) , height ( sz . height ) { } <nl> <nl> template < typename _Tp > inline <nl> - Size_ < _Tp > : : Size_ ( Size_ & & sz ) noexcept <nl> + Size_ < _Tp > : : Size_ ( Size_ & & sz ) CV_NOEXCEPT <nl> : width ( std : : move ( sz . width ) ) , height ( std : : move ( sz . height ) ) { } <nl> <nl> template < typename _Tp > inline <nl> Size_ < _Tp > & Size_ < _Tp > : : operator = ( const Size_ < _Tp > & sz ) <nl> } <nl> <nl> template < typename _Tp > inline <nl> - Size_ < _Tp > & Size_ < _Tp > : : operator = ( Size_ < _Tp > & & sz ) noexcept <nl> + Size_ < _Tp > & Size_ < _Tp > : : operator = ( Size_ < _Tp > & & sz ) CV_NOEXCEPT <nl> { <nl> width = std : : move ( sz . width ) ; height = std : : move ( sz . height ) ; <nl> return * this ; <nl> Rect_ < _Tp > : : Rect_ ( const Rect_ < _Tp > & r ) <nl> : x ( r . x ) , y ( r . y ) , width ( r . width ) , height ( r . height ) { } <nl> <nl> template < typename _Tp > inline <nl> - Rect_ < _Tp > : : Rect_ ( Rect_ < _Tp > & & r ) noexcept <nl> + Rect_ < _Tp > : : Rect_ ( Rect_ < _Tp > & & r ) CV_NOEXCEPT <nl> : x ( std : : move ( r . x ) ) , y ( std : : move ( r . y ) ) , width ( std : : move ( r . width ) ) , height ( std : : move ( r . height ) ) { } <nl> <nl> template < typename _Tp > inline <nl> Rect_ < _Tp > & Rect_ < _Tp > : : operator = ( const Rect_ < _Tp > & r ) <nl> } <nl> <nl> template < typename _Tp > inline <nl> - Rect_ < _Tp > & Rect_ < _Tp > : : operator = ( Rect_ < _Tp > & & r ) noexcept <nl> + Rect_ < _Tp > & Rect_ < _Tp > : : operator = ( Rect_ < _Tp > & & r ) CV_NOEXCEPT <nl> { <nl> x = std : : move ( r . x ) ; <nl> y = std : : move ( r . y ) ; <nl> Scalar_ < _Tp > : : Scalar_ ( const Scalar_ < _Tp > & s ) : Vec < _Tp , 4 > ( s ) { <nl> } <nl> <nl> template < typename _Tp > inline <nl> - Scalar_ < _Tp > : : Scalar_ ( Scalar_ < _Tp > & & s ) noexcept { <nl> + Scalar_ < _Tp > : : Scalar_ ( Scalar_ < _Tp > & & s ) CV_NOEXCEPT { <nl> this - > val [ 0 ] = std : : move ( s . val [ 0 ] ) ; <nl> this - > val [ 1 ] = std : : move ( s . val [ 1 ] ) ; <nl> this - > val [ 2 ] = std : : move ( s . val [ 2 ] ) ; <nl> Scalar_ < _Tp > & Scalar_ < _Tp > : : operator = ( const Scalar_ < _Tp > & s ) { <nl> } <nl> <nl> template < typename _Tp > inline <nl> - Scalar_ < _Tp > & Scalar_ < _Tp > : : operator = ( Scalar_ < _Tp > & & s ) noexcept { <nl> + Scalar_ < _Tp > & Scalar_ < _Tp > : : operator = ( Scalar_ < _Tp > & & s ) CV_NOEXCEPT { <nl> this - > val [ 0 ] = std : : move ( s . val [ 0 ] ) ; <nl> this - > val [ 1 ] = std : : move ( s . val [ 1 ] ) ; <nl> this - > val [ 2 ] = std : : move ( s . val [ 2 ] ) ; <nl> | fix build error on Visual Studio 2013 and earlier | opencv/opencv | 9df7517dea6376fd66c872a56739805cf5f5d7bc | 2018-07-18T09:56:02Z |
mmm a / tensorflow / python / BUILD <nl> ppp b / tensorflow / python / BUILD <nl> cc_library ( <nl> deps = [ " : python_op_gen " ] , <nl> ) <nl> <nl> - # What is needed for tf_gen_op_wrapper_py . <nl> py_library ( <nl> name = " framework_for_generated_wrappers " , <nl> - srcs = [ <nl> - " framework / constant_op . py " , <nl> - " framework / device . py " , <nl> - " framework / dtypes . py " , <nl> - " framework / function . py " , <nl> - " framework / op_def_library . py " , <nl> - " framework / op_def_registry . py " , <nl> - " framework / ops . py " , <nl> - " framework / registry . py " , <nl> - " framework / tensor_shape . py " , <nl> - " framework / versions . py " , <nl> + srcs_version = " PY2AND3 " , <nl> + visibility = [ " / / visibility : public " ] , <nl> + deps = [ <nl> + " : constant_op " , <nl> + " : device " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : function " , <nl> + " : op_def_library " , <nl> + " : op_def_registry " , <nl> + " : registry " , <nl> + " : tensor_shape " , <nl> + " : versions " , <nl> ] , <nl> + ) <nl> + <nl> + # What is needed for tf_gen_op_wrapper_py . This is the same as <nl> + # " framework_for_generated_wrappers " minus the " function " dep . This is to avoid <nl> + # circular dependencies , as " function " uses generated op wrappers . <nl> + py_library ( <nl> + name = " framework_for_generated_wrappers_v2 " , <nl> srcs_version = " PY2AND3 " , <nl> visibility = [ " / / visibility : public " ] , <nl> deps = [ <nl> - " : platform " , <nl> - " : util " , <nl> - " / / tensorflow / core : protos_all_py " , <nl> - " / / third_party / py / numpy " , <nl> - " @ six_archive / / : six " , <nl> + " : constant_op " , <nl> + " : device " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : op_def_library " , <nl> + " : op_def_registry " , <nl> + " : registry " , <nl> + " : tensor_shape " , <nl> + " : versions " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> name = " framework " , <nl> srcs = [ <nl> - " framework / common_shapes . py " , <nl> " framework / framework_lib . py " , <nl> " framework / graph_io . py " , <nl> - " framework / graph_util . py " , <nl> - " framework / graph_util_impl . py " , <nl> " framework / importer . py " , <nl> " framework / load_library . py " , <nl> " framework / meta_graph . py " , <nl> - " framework / random_seed . py " , <nl> - " framework / sparse_tensor . py " , <nl> " framework / subscribe . py " , <nl> - " framework / tensor_util . py " , <nl> ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " : common_shapes " , <nl> " : cpp_shape_inference_proto_py " , <nl> " : errors " , <nl> " : framework_for_generated_wrappers " , <nl> + " : graph_util " , <nl> " : lib " , <nl> " : platform " , <nl> " : pywrap_tensorflow " , <nl> + " : random_seed " , <nl> + " : sparse_tensor " , <nl> + " : tensor_util " , <nl> " : util " , <nl> " / / third_party / py / numpy " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> ) <nl> <nl> + py_library ( <nl> + name = " common_shapes " , <nl> + srcs = [ " framework / common_shapes . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : cpp_shape_inference_proto_py " , <nl> + " : errors " , <nl> + " : framework_ops " , <nl> + " : pywrap_tensorflow " , <nl> + " : tensor_shape " , <nl> + " : tensor_util " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " constant_op " , <nl> + srcs = [ " framework / constant_op . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : tensor_shape " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " device " , <nl> + srcs = [ " framework / device . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " dtypes " , <nl> + srcs = [ " framework / dtypes . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " / / tensorflow / core : protos_all_py " , <nl> + ] , <nl> + ) <nl> + <nl> py_library ( <nl> name = " errors " , <nl> srcs = [ <nl> py_library ( <nl> deps = [ " : util " ] , <nl> ) <nl> <nl> + py_library ( <nl> + name = " function " , <nl> + srcs = [ " framework / function . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : array_ops " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : op_def_registry " , <nl> + " : util " , <nl> + " : variable_scope " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " graph_util " , <nl> + srcs = [ <nl> + " framework / graph_util . py " , <nl> + " framework / graph_util_impl . py " , <nl> + ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : platform " , <nl> + " : tensor_util " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " op_def_library " , <nl> + srcs = [ " framework / op_def_library . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : platform " , <nl> + " : tensor_shape " , <nl> + " : util " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> + " @ six_archive / / : six " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " op_def_registry " , <nl> + srcs = [ " framework / op_def_registry . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " / / tensorflow / core : protos_all_py " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " framework_ops " , # " ops " is already the name of a deprecated target <nl> + srcs = [ " framework / ops . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : device " , <nl> + " : dtypes " , <nl> + " : op_def_registry " , <nl> + " : platform " , <nl> + " : registry " , <nl> + " : tensor_shape " , <nl> + " : util " , <nl> + " : versions " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> + " @ six_archive / / : six " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " random_seed " , <nl> + srcs = [ " framework / random_seed . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : framework_ops " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " registry " , <nl> + srcs = [ " framework / registry . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : platform " , <nl> + " : util " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " sparse_tensor " , <nl> + srcs = [ " framework / sparse_tensor . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : tensor_util " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " tensor_shape " , <nl> + srcs = [ " framework / tensor_shape . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : util " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " tensor_util " , <nl> + srcs = [ " framework / tensor_util . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : tensor_shape " , <nl> + " : util " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> + ] , <nl> + ) <nl> + <nl> + py_library ( <nl> + name = " versions " , <nl> + srcs = [ " framework / versions . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : pywrap_tensorflow " , <nl> + ] , <nl> + ) <nl> + <nl> # load ( " / / third_party / py / cython : build_defs . bzl " , " pyx_library " ) <nl> <nl> py_library ( <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> + " : constant_op " , <nl> " : control_flow_ops " , <nl> - " : framework " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : framework_ops " , <nl> " : functional_ops_gen " , <nl> + " : sparse_tensor " , <nl> " : tensor_array_ops " , <nl> + " : tensor_shape " , <nl> " : util " , <nl> " : variable_scope " , <nl> ] , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops_gen " , <nl> - " : framework " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : common_shapes " , <nl> + " : constant_op " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> " : math_ops_gen " , <nl> + " : sparse_tensor " , <nl> + " : tensor_shape " , <nl> + " : tensor_util " , <nl> " : util " , <nl> " / / third_party / py / numpy " , <nl> " @ six_archive / / : six " , <nl> py_library ( <nl> srcs = [ " ops / control_flow_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " tensor_shape " , <nl> " : array_ops " , <nl> " : array_ops_gen " , <nl> + " : constant_op " , <nl> " : control_flow_ops_gen " , <nl> " : data_flow_ops_gen " , <nl> - " : framework " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> " : logging_ops_gen " , <nl> " : math_ops " , <nl> " : platform " , <nl> + " : sparse_tensor " , <nl> " : tensor_array_ops " , <nl> " : util " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> ) <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : constant_op " , <nl> + " : dtypes " , <nl> " : linalg_ops " , <nl> " : math_ops " , <nl> " : nn_ops " , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> " : linalg_ops_gen " , <nl> " : math_ops " , <nl> " / / third_party / py / numpy " , <nl> py_library ( <nl> srcs = [ " ops / math_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> + " constant_op " , <nl> " : array_ops " , <nl> + " : common_shapes " , <nl> " : control_flow_ops_gen " , <nl> " : data_flow_ops_gen " , <nl> - " : framework " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : graph_util " , <nl> " : math_ops_gen " , <nl> " : sparse_ops_gen " , <nl> + " : sparse_tensor " , <nl> " : state_ops " , <nl> " : state_ops_gen " , <nl> + " : tensor_shape " , <nl> " : util " , <nl> " / / third_party / py / numpy " , <nl> ] , <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : framework_ops " , <nl> " : resource_variable_ops_gen " , <nl> + " : tensor_shape " , <nl> " : util " , <nl> " : variables " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> " : array_ops " , <nl> - " : framework " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> + " : graph_util " , <nl> " : math_ops " , <nl> " : nn_ops_gen " , <nl> " : random_ops " , <nl> + " : tensor_shape " , <nl> + " : tensor_util " , <nl> " / / third_party / py / numpy " , <nl> ] , <nl> ) <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : control_flow_ops " , <nl> - " : framework " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> " : math_ops " , <nl> " : random_ops_gen " , <nl> + " : random_seed " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> srcs = [ " ops / state_ops . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : framework_for_generated_wrappers " , <nl> + " : framework_ops " , <nl> " : resource_variable_ops_gen " , <nl> " : state_ops_gen " , <nl> + " : tensor_shape " , <nl> ] , <nl> ) <nl> <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : data_flow_ops_gen " , <nl> - " : framework " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : framework_ops " , <nl> " : math_ops " , <nl> + " : tensor_shape " , <nl> + " : tensor_util " , <nl> " : util " , <nl> ] , <nl> ) <nl> py_library ( <nl> srcs = [ " ops / variable_scope . py " ] , <nl> srcs_version = " PY2AND3 " , <nl> deps = [ <nl> - " : array_ops " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> " : init_ops " , <nl> " : platform " , <nl> " : resource_variable_ops " , <nl> + " : tensor_shape " , <nl> " : variables " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> py_library ( <nl> deps = [ <nl> " : array_ops " , <nl> " : control_flow_ops " , <nl> - " : framework_for_generated_wrappers " , <nl> + " : dtypes " , <nl> + " : framework_ops " , <nl> " : math_ops " , <nl> " : state_ops " , <nl> + " : tensor_shape " , <nl> " : util " , <nl> + " / / tensorflow / core : protos_all_py " , <nl> ] , <nl> ) <nl> <nl> mmm a / tensorflow / tensorflow . bzl <nl> ppp b / tensorflow / tensorflow . bzl <nl> def tf_gen_op_wrapper_py ( name , out = None , hidden = None , visibility = None , deps = [ ] , <nl> srcs_version = " PY2AND3 " , <nl> visibility = visibility , <nl> deps = [ <nl> - " / / tensorflow / python : framework_for_generated_wrappers " , <nl> + " / / tensorflow / python : framework_for_generated_wrappers_v2 " , <nl> ] , ) <nl> <nl> # Define a bazel macro that creates cc_test for tensorflow . <nl> | Refactor python BUILD targets . | tensorflow/tensorflow | cd5d96735f18bcf32fff7026fac6ff8271f571f4 | 2017-03-01T01:40:07Z |
mmm a / src / brpc / policy / http2_rpc_protocol . cpp <nl> ppp b / src / brpc / policy / http2_rpc_protocol . cpp <nl> H2Context : : H2Context ( Socket * socket , const Server * server ) <nl> : _socket ( socket ) <nl> , _remote_window_left ( H2Settings : : DEFAULT_INITIAL_WINDOW_SIZE ) <nl> , _conn_state ( H2_CONNECTION_UNINITIALIZED ) <nl> - , _last_receive_stream_id ( - 1 ) <nl> - , _last_send_stream_id ( 1 ) <nl> - , _goaway_received ( false ) <nl> + , _last_received_stream_id ( - 1 ) <nl> + , _last_sent_stream_id ( 1 ) <nl> + , _goaway_stream_id ( - 1 ) <nl> , _goaway_sent ( false ) <nl> , _deferred_window_update ( 0 ) { <nl> / / Stop printing the field which is useless for remote settings . <nl> H2Context : : H2Context ( Socket * socket , const Server * server ) <nl> _unack_local_settings . connection_window_size = FLAGS_h2_client_connection_window_size ; <nl> } <nl> # if defined ( UNIT_TEST ) <nl> - / / In ut , we hope _last_send_stream_id run out quickly to test the correctness <nl> + / / In ut , we hope _last_sent_stream_id run out quickly to test the correctness <nl> / / of creating new h2 socket . This value is 10 , 000 less than 0x7FFFFFFF . <nl> - _last_send_stream_id = 0x7fffd8ef ; <nl> + _last_sent_stream_id = 0x7fffd8ef ; <nl> # endif <nl> } <nl> <nl> void H2Context : : RemoveGoAwayStreams ( <nl> StreamMap tmp ; <nl> { <nl> std : : unique_lock < butil : : Mutex > mu ( _stream_mutex ) ; <nl> - _goaway_received = true ; <nl> + _goaway_stream_id = goaway_stream_id ; <nl> _pending_streams . swap ( tmp ) ; <nl> } <nl> for ( StreamMap : : const_iterator it = tmp . begin ( ) ; it ! = tmp . end ( ) ; + + it ) { <nl> void H2Context : : RemoveGoAwayStreams ( <nl> } <nl> } else { <nl> std : : unique_lock < butil : : Mutex > mu ( _stream_mutex ) ; <nl> - _goaway_received = true ; <nl> + _goaway_stream_id = goaway_stream_id ; <nl> for ( StreamMap : : const_iterator it = _pending_streams . begin ( ) ; <nl> it ! = _pending_streams . end ( ) ; + + it ) { <nl> if ( it - > first > goaway_stream_id ) { <nl> H2StreamContext * H2Context : : FindStream ( int stream_id ) { <nl> <nl> int H2Context : : TryToInsertStream ( int stream_id , H2StreamContext * ctx ) { <nl> std : : unique_lock < butil : : Mutex > mu ( _stream_mutex ) ; <nl> - if ( _goaway_received ) { <nl> + if ( _goaway_stream_id > = 0 & & stream_id > _goaway_stream_id ) { <nl> return 1 ; <nl> } <nl> H2StreamContext * & sctx = _pending_streams [ stream_id ] ; <nl> ParseResult H2Context : : Consume ( <nl> } else { / / send GOAWAY <nl> char goawaybuf [ FRAME_HEAD_SIZE + 8 ] ; <nl> SerializeFrameHead ( goawaybuf , 8 , H2_FRAME_GOAWAY , 0 , 0 ) ; <nl> - SaveUint32 ( goawaybuf + FRAME_HEAD_SIZE , _last_receive_stream_id ) ; <nl> + SaveUint32 ( goawaybuf + FRAME_HEAD_SIZE , _last_received_stream_id ) ; <nl> SaveUint32 ( goawaybuf + FRAME_HEAD_SIZE + 4 , h2_res . error ( ) ) ; <nl> if ( WriteAck ( _socket , goawaybuf , sizeof ( goawaybuf ) ) ! = 0 ) { <nl> LOG ( WARNING ) < < " Fail to send GOAWAY to " < < * _socket ; <nl> H2ParseResult H2Context : : OnHeaders ( <nl> frag_size - = pad_length ; <nl> H2StreamContext * sctx = NULL ; <nl> if ( is_server_side ( ) & & <nl> - frame_head . stream_id > _last_receive_stream_id ) { / / new stream <nl> + frame_head . stream_id > _last_received_stream_id ) { / / new stream <nl> if ( ( frame_head . stream_id & 1 ) = = 0 ) { <nl> LOG ( ERROR ) < < " stream_id = " < < frame_head . stream_id <nl> < < " created by client is not odd " ; <nl> return MakeH2Error ( H2_PROTOCOL_ERROR ) ; <nl> } <nl> - _last_receive_stream_id = frame_head . stream_id ; <nl> + _last_received_stream_id = frame_head . stream_id ; <nl> sctx = new H2StreamContext ( _socket - > is_read_progressive ( ) ) ; <nl> sctx - > Init ( this , frame_head . stream_id ) ; <nl> const int rc = TryToInsertStream ( frame_head . stream_id , sctx ) ; <nl> void H2Context : : Describe ( std : : ostream & os , const DescribeOptions & opt ) const { <nl> } <nl> const char sep = ( opt . verbose ? ' \ n ' : ' ' ) ; <nl> os < < " conn_state = " < < H2ConnectionState2Str ( _conn_state ) ; <nl> - os < < sep < < " last_receive_stream_id = " < < _last_receive_stream_id ; <nl> - os < < sep < < " last_send_stream_id = " < < _last_send_stream_id ; <nl> + os < < sep < < " last_received_stream_id = " < < _last_received_stream_id <nl> + < < sep < < " last_sent_stream_id = " < < _last_sent_stream_id ; <nl> os < < sep < < " deferred_window_update = " <nl> < < _deferred_window_update . load ( butil : : memory_order_relaxed ) <nl> < < sep < < " remote_conn_window_left = " <nl> mmm a / src / brpc / policy / http2_rpc_protocol . h <nl> ppp b / src / brpc / policy / http2_rpc_protocol . h <nl> friend void InitFrameHandlers ( ) ; <nl> Socket * _socket ; <nl> butil : : atomic < int64_t > _remote_window_left ; <nl> H2ConnectionState _conn_state ; <nl> - int _last_receive_stream_id ; <nl> - uint32_t _last_send_stream_id ; <nl> - bool _goaway_received ; <nl> + int _last_received_stream_id ; <nl> + uint32_t _last_sent_stream_id ; <nl> + int _goaway_stream_id ; <nl> bool _goaway_sent ; <nl> H2Settings _remote_settings ; <nl> H2Settings _local_settings ; <nl> inline int H2Context : : AllocateClientStreamId ( ) { <nl> < < _last_client_stream_id ; <nl> return - 1 ; <nl> } <nl> - const int id = _last_send_stream_id ; <nl> - _last_send_stream_id + = 2 ; <nl> + const int id = _last_sent_stream_id ; <nl> + _last_sent_stream_id + = 2 ; <nl> return id ; <nl> } <nl> <nl> inline bool H2Context : : RunOutStreams ( ) const { <nl> - return ( _last_send_stream_id > 0x7FFFFFFF ) ; <nl> + return ( _last_sent_stream_id > 0x7FFFFFFF ) ; <nl> } <nl> <nl> inline std : : ostream & operator < < ( std : : ostream & os , const H2UnsentRequest & req ) { <nl> | remove _goaway_received and use _goaway_stream_id | apache/incubator-brpc | abec711ad9ab3faa85ae4b3cb4bb2ce20c9238fa | 2018-10-11T06:24:53Z |
mmm a / Telegram / Resources / basic . style <nl> ppp b / Telegram / Resources / basic . style <nl> botDescSkip : 8px ; <nl> suppressAll : 0 . 2 ; <nl> suppressSong : 0 . 05 ; <nl> <nl> - playerHeight : 44px ; <nl> - playerBg : # e4e9ef ; <nl> - playerFg : # 54748f ; <nl> - playerTimeFg : # a4afba ; <nl> - playerLineHeight : 3px ; <nl> - playerMoverSize : size ( 2px , 7px ) ; <nl> - playerLineActive : # 6389a8 ; <nl> - playerLineInactive : # bac7d4 ; <nl> - playerSkip : 8px ; <nl> - playerNameStyle : textStyle ( defaultTextStyle ) { <nl> - linkFg : # 6389a8 ; <nl> - linkFgDown : # 6389a8 ; <nl> - linkFlags : semiboldFont ; <nl> - linkFlagsOver : semiboldFont ; <nl> - } <nl> - playerPlay : sprite ( 377px , 109px , 19px , 22px ) ; <nl> - playerPause : sprite ( 379px , 131px , 17px , 20px ) ; <nl> - playerNext : sprite ( 374px , 151px , 22px , 14px ) ; <nl> - playerPrev : sprite ( 374px , 165px , 22px , 14px ) ; <nl> - playerClose : sprite ( 361px , 97px , 12px , 12px ) ; <nl> - playerFull : sprite ( 365px , 109px , 12px , 12px ) ; <nl> - playerRepeat : sprite ( 365px , 121px , 12px , 14px ) ; <nl> - playerVolume : sprite ( 352px , 179px , 44px , 12px ) ; <nl> - playerInactiveOpacity : 0 . 8 ; <nl> - playerUnavailableOpacity : 0 . 3 ; <nl> - playerDuration : 200 ; <nl> - <nl> inlineResultsLeft : 11px ; <nl> inlineResultsSkip : 3px ; <nl> inlineMediaHeight : 96px ; <nl> new file mode 100644 <nl> index 00000000000 . . d27dd6b704e <nl> Binary files / dev / null and b / Telegram / Resources / icons / player_close . png differ <nl> new file mode 100644 <nl> index 00000000000 . . cf0e108d831 <nl> Binary files / dev / null and b / Telegram / Resources / icons / player_close @ 2x . png differ <nl> Binary files a / Telegram / Resources / icons / player_next . png and b / Telegram / Resources / icons / player_next . png differ <nl> Binary files a / Telegram / Resources / icons / player_next @ 2x . png and b / Telegram / Resources / icons / player_next @ 2x . png differ <nl> new file mode 100644 <nl> index 00000000000 . . 2649ce5d756 <nl> Binary files / dev / null and b / Telegram / Resources / icons / player_panel_next . png differ <nl> new file mode 100644 <nl> index 00000000000 . . 2c93ed70eae <nl> Binary files / dev / null and b / Telegram / Resources / icons / player_panel_next @ 2x . png differ <nl> new file mode 100644 <nl> index 00000000000 . . 809ba432786 <nl> Binary files / dev / null and b / Telegram / Resources / icons / player_panel_pin . png differ <nl> new file mode 100644 <nl> index 00000000000 . . 07e07315c0f <nl> Binary files / dev / null and b / Telegram / Resources / icons / player_panel_pin @ 2x . png differ <nl> new file mode 100644 <nl> index 00000000000 . . 4460c3dafd6 <nl> Binary files / dev / null and b / Telegram / Resources / icons / player_panel_previous . png differ <nl> new file mode 100644 <nl> index 00000000000 . . bb31bf5311b <nl> Binary files / dev / null and b / Telegram / Resources / icons / player_panel_previous @ 2x . png differ <nl> Binary files a / Telegram / Resources / icons / player_previous . png and b / Telegram / Resources / icons / player_previous . png differ <nl> Binary files a / Telegram / Resources / icons / player_previous @ 2x . png and b / Telegram / Resources / icons / player_previous @ 2x . png differ <nl> Binary files a / Telegram / Resources / icons / title_button_close @ 2x . png and b / Telegram / Resources / icons / title_button_close @ 2x . png differ <nl> mmm a / Telegram / SourceFiles / app . cpp <nl> ppp b / Telegram / SourceFiles / app . cpp <nl> namespace { <nl> <nl> switch ( user . type ( ) ) { <nl> case mtpc_userEmpty : { <nl> - auto & d ( user . c_userEmpty ( ) ) ; <nl> + auto & d = user . c_userEmpty ( ) ; <nl> <nl> - PeerId peer ( peerFromUser ( d . vid . v ) ) ; <nl> + auto peer = peerFromUser ( d . vid . v ) ; <nl> data = App : : user ( peer ) ; <nl> auto canShareThisContact = data - > canShareThisContactFast ( ) ; <nl> wasContact = data - > isContact ( ) ; <nl> namespace { <nl> if ( wasContact ! = data - > isContact ( ) ) update . flags | = UpdateFlag : : UserIsContact ; <nl> } break ; <nl> case mtpc_user : { <nl> - auto & d ( user . c_user ( ) ) ; <nl> + auto & d = user . c_user ( ) ; <nl> minimal = d . is_min ( ) ; <nl> <nl> - PeerId peer ( peerFromUser ( d . vid . v ) ) ; <nl> + auto peer = peerFromUser ( d . vid . v ) ; <nl> data = App : : user ( peer ) ; <nl> auto canShareThisContact = data - > canShareThisContactFast ( ) ; <nl> wasContact = data - > isContact ( ) ; <nl> namespace { <nl> } <nl> <nl> bool checkEntitiesAndViewsUpdate ( const MTPDmessage & m ) { <nl> - PeerId peerId = peerFromMTP ( m . vto_id ) ; <nl> + auto peerId = peerFromMTP ( m . vto_id ) ; <nl> if ( m . has_from_id ( ) & & peerToUser ( peerId ) = = MTP : : authedId ( ) ) { <nl> peerId = peerFromUser ( m . vfrom_id ) ; <nl> } <nl> - if ( HistoryItem * existing = App : : histItemById ( peerToChannel ( peerId ) , m . vid . v ) ) { <nl> + if ( auto existing = App : : histItemById ( peerToChannel ( peerId ) , m . vid . v ) ) { <nl> auto text = qs ( m . vmessage ) ; <nl> auto entities = m . has_entities ( ) ? entitiesFromMTP ( m . ventities . c_vector ( ) . v ) : EntitiesInText ( ) ; <nl> existing - > setText ( { text , entities } ) ; <nl> namespace { <nl> HistoryItem * histItemById ( ChannelId channelId , MsgId itemId ) { <nl> if ( ! itemId ) return nullptr ; <nl> <nl> - MsgsData * data = fetchMsgsData ( channelId , false ) ; <nl> + auto data = fetchMsgsData ( channelId , false ) ; <nl> if ( ! data ) return nullptr ; <nl> <nl> auto i = data - > constFind ( itemId ) ; <nl> mmm a / Telegram / SourceFiles / boxes / abstractbox . h <nl> ppp b / Telegram / SourceFiles / boxes / abstractbox . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # pragma once <nl> <nl> # include " layerwidget . h " <nl> + # include " ui / widgets / shadow . h " <nl> <nl> class BlueTitleShadow : public TWidget { <nl> public : <nl> public slots : <nl> <nl> } ; <nl> <nl> - class ScrollableBoxShadow : public PlainShadow { <nl> + class ScrollableBoxShadow : public Ui : : PlainShadow { <nl> public : <nl> - ScrollableBoxShadow ( QWidget * parent ) : PlainShadow ( parent , st : : boxScrollShadowBg ) { <nl> + ScrollableBoxShadow ( QWidget * parent ) : Ui : : PlainShadow ( parent , st : : boxScrollShadowBg ) { <nl> } <nl> } ; <nl> <nl> mmm a / Telegram / SourceFiles / boxes / stickersetbox . cpp <nl> ppp b / Telegram / SourceFiles / boxes / stickersetbox . cpp <nl> void StickersBox : : setup ( ) { <nl> int bottomSkip = st : : boxPadding . bottom ( ) ; <nl> if ( _section = = Section : : Installed ) { <nl> _aboutHeight = st : : stickersReorderPadding . top ( ) + _about . countHeight ( _aboutWidth ) + st : : stickersReorderPadding . bottom ( ) ; <nl> - _topShadow = new PlainShadow ( this , st : : contactsAboutShadow ) ; <nl> + _topShadow . create ( this , st : : contactsAboutShadow ) ; <nl> <nl> - _save = new BoxButton ( this , lang ( lng_settings_save ) , st : : defaultBoxButton ) ; <nl> + _save . create ( this , lang ( lng_settings_save ) , st : : defaultBoxButton ) ; <nl> connect ( _save , SIGNAL ( clicked ( ) ) , this , SLOT ( onSave ( ) ) ) ; <nl> <nl> - _cancel = new BoxButton ( this , lang ( lng_cancel ) , st : : cancelBoxButton ) ; <nl> + _cancel . create ( this , lang ( lng_cancel ) , st : : cancelBoxButton ) ; <nl> connect ( _cancel , SIGNAL ( clicked ( ) ) , this , SLOT ( onClose ( ) ) ) ; <nl> <nl> - _bottomShadow = new ScrollableBoxShadow ( this ) ; <nl> + _bottomShadow . create ( this ) ; <nl> bottomSkip = st : : boxButtonPadding . top ( ) + _save - > height ( ) + st : : boxButtonPadding . bottom ( ) ; <nl> } else if ( _section = = Section : : ArchivedPart ) { <nl> _aboutHeight = st : : stickersReorderPadding . top ( ) + _about . countHeight ( _aboutWidth ) + st : : stickersReorderPadding . bottom ( ) ; <nl> - _topShadow = new PlainShadow ( this , st : : contactsAboutShadow ) ; <nl> + _topShadow . create ( this , st : : contactsAboutShadow ) ; <nl> <nl> - _save = new BoxButton ( this , lang ( lng_box_ok ) , st : : defaultBoxButton ) ; <nl> + _save . create ( this , lang ( lng_box_ok ) , st : : defaultBoxButton ) ; <nl> connect ( _save , SIGNAL ( clicked ( ) ) , this , SLOT ( onClose ( ) ) ) ; <nl> } else if ( _section = = Section : : Archived ) { <nl> _aboutHeight = st : : stickersReorderPadding . top ( ) + _about . countHeight ( _aboutWidth ) + st : : stickersReorderPadding . bottom ( ) ; <nl> - _topShadow = new PlainShadow ( this , st : : contactsAboutShadow ) ; <nl> + _topShadow . create ( this , st : : contactsAboutShadow ) ; <nl> } <nl> ItemListBox : : init ( _inner , bottomSkip , st : : boxTitleHeight + _aboutHeight ) ; <nl> setMaxHeight ( snap ( countHeight ( ) , int32 ( st : : sessionsHeight ) , int32 ( st : : boxMaxListHeight ) ) ) ; <nl> mmm a / Telegram / SourceFiles / boxes / stickersetbox . h <nl> ppp b / Telegram / SourceFiles / boxes / stickersetbox . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " core / vector_of_moveable . h " <nl> <nl> class ConfirmBox ; <nl> + namespace Ui { <nl> + class PlainShadow ; <nl> + } / / namespace Ui <nl> <nl> class StickerSetInner : public ScrolledWidget , public RPCSender , private base : : Subscriber { <nl> Q_OBJECT <nl> private slots : <nl> ChildWidget < BoxButton > _cancel = { nullptr } ; <nl> OrderedSet < mtpRequestId > _disenableRequests ; <nl> mtpRequestId _reorderRequest = 0 ; <nl> - ChildWidget < PlainShadow > _topShadow = { nullptr } ; <nl> + ChildWidget < Ui : : PlainShadow > _topShadow = { nullptr } ; <nl> ChildWidget < ScrollableBoxShadow > _bottomShadow = { nullptr } ; <nl> <nl> QTimer _scrollTimer ; <nl> mmm a / Telegram / SourceFiles / core / click_handler . cpp <nl> ppp b / Telegram / SourceFiles / core / click_handler . cpp <nl> bool ClickHandler : : setActive ( const ClickHandlerPtr & p , ClickHandlerHost * host ) { <nl> } <nl> } <nl> if ( p ) { <nl> - _active . makeIfNull ( ) ; <nl> + _active . createIfNull ( ) ; <nl> * _active = p ; <nl> if ( ( _activeHost = host ) ) { <nl> bool emitClickHandlerActiveChanged = ( ! _pressed | | ! * _pressed | | * _pressed = = * _active ) ; <nl> mmm a / Telegram / SourceFiles / core / click_handler . h <nl> ppp b / Telegram / SourceFiles / core / click_handler . h <nl> class ClickHandler { <nl> if ( ! _active | | ! * _active ) { <nl> return ; <nl> } <nl> - _pressed . makeIfNull ( ) ; <nl> + _pressed . createIfNull ( ) ; <nl> * _pressed = * _active ; <nl> if ( ( _pressedHost = _activeHost ) ) { <nl> _pressedHost - > clickHandlerPressedChanged ( * _pressed , true ) ; <nl> mmm a / Telegram / SourceFiles / core / stl_subset . h <nl> ppp b / Telegram / SourceFiles / core / stl_subset . h <nl> class unique_ptr { <nl> std : : swap ( _p , other . _p ) ; <nl> } <nl> ~ unique_ptr ( ) noexcept { <nl> - delete _p ; <nl> + if ( _p ) { <nl> + delete _p ; <nl> + _p = nullptr ; <nl> + } <nl> } <nl> <nl> T & operator * ( ) const { <nl> mmm a / Telegram / SourceFiles / core / utils . h <nl> ppp b / Telegram / SourceFiles / core / utils . h <nl> class NeverFreedPointer { <nl> NeverFreedPointer ( const NeverFreedPointer < T > & other ) = delete ; <nl> NeverFreedPointer & operator = ( const NeverFreedPointer < T > & other ) = delete ; <nl> <nl> - template < typename U > <nl> - void createIfNull ( U creator ) { <nl> - if ( isNull ( ) ) { <nl> - reset ( creator ( ) ) ; <nl> - } <nl> - } <nl> - <nl> template < typename . . . Args > <nl> - void makeIfNull ( Args & & . . . args ) { <nl> + void createIfNull ( Args & & . . . args ) { <nl> if ( isNull ( ) ) { <nl> reset ( new T ( std_ : : forward < Args > ( args ) . . . ) ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / data / data_abstract_structure . cpp <nl> ppp b / Telegram / SourceFiles / data / data_abstract_structure . cpp <nl> NeverFreedPointer < DataStructures > structures ; <nl> namespace internal { <nl> <nl> void registerAbstractStructure ( AbstractStructure * * p ) { <nl> - structures . makeIfNull ( ) ; <nl> + structures . createIfNull ( ) ; <nl> structures - > insert ( p ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / facades . cpp <nl> ppp b / Telegram / SourceFiles / facades . cpp <nl> struct Data { <nl> <nl> int32 DebugLoggingFlags = 0 ; <nl> <nl> + float64 RememberedSongVolume = kDefaultVolume ; <nl> float64 SongVolume = kDefaultVolume ; <nl> + base : : Observable < void > SongVolumeChanged ; <nl> float64 VideoVolume = kDefaultVolume ; <nl> + base : : Observable < void > VideoVolumeChanged ; <nl> <nl> / / config <nl> int32 ChatSizeMax = 200 ; <nl> DefineVar ( Global , bool , ScreenIsLocked ) ; <nl> <nl> DefineVar ( Global , int32 , DebugLoggingFlags ) ; <nl> <nl> + DefineVar ( Global , float64 , RememberedSongVolume ) ; <nl> DefineVar ( Global , float64 , SongVolume ) ; <nl> + DefineRefVar ( Global , base : : Observable < void > , SongVolumeChanged ) ; <nl> DefineVar ( Global , float64 , VideoVolume ) ; <nl> + DefineRefVar ( Global , base : : Observable < void > , VideoVolumeChanged ) ; <nl> <nl> / / config <nl> DefineVar ( Global , int32 , ChatSizeMax ) ; <nl> mmm a / Telegram / SourceFiles / facades . h <nl> ppp b / Telegram / SourceFiles / facades . h <nl> bool started ( ) ; <nl> void start ( ) ; <nl> void finish ( ) ; <nl> <nl> - constexpr float64 kDefaultVolume = 0 . 9 ; <nl> - <nl> DeclareReadOnlyVar ( uint64 , LaunchId ) ; <nl> DeclareRefVar ( SingleDelayedCall , HandleHistoryUpdate ) ; <nl> DeclareRefVar ( SingleDelayedCall , HandleUnreadCounterUpdate ) ; <nl> DeclareVar ( bool , ScreenIsLocked ) ; <nl> <nl> DeclareVar ( int32 , DebugLoggingFlags ) ; <nl> <nl> + constexpr float64 kDefaultVolume = 0 . 9 ; <nl> + <nl> + DeclareVar ( float64 , RememberedSongVolume ) ; <nl> DeclareVar ( float64 , SongVolume ) ; <nl> + DeclareRefVar ( base : : Observable < void > , SongVolumeChanged ) ; <nl> DeclareVar ( float64 , VideoVolume ) ; <nl> + DeclareRefVar ( base : : Observable < void > , VideoVolumeChanged ) ; <nl> <nl> / / config <nl> DeclareVar ( int32 , ChatSizeMax ) ; <nl> mmm a / Telegram / SourceFiles / history / history_media_types . cpp <nl> ppp b / Telegram / SourceFiles / history / history_media_types . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " mainwidget . h " <nl> # include " mainwindow . h " <nl> # include " localstorage . h " <nl> - # include " playerwidget . h " <nl> # include " media / media_audio . h " <nl> # include " media / media_clip_reader . h " <nl> + # include " media / player / media_player_instance . h " <nl> # include " boxes / confirmbox . h " <nl> # include " boxes / addcontactbox . h " <nl> # include " core / click_handler_types . h " <nl> bool HistoryDocument : : updateStatusText ( ) const { <nl> showPause = ( playbackState . state = = AudioPlayerPlaying | | playbackState . state = = AudioPlayerResuming | | playbackState . state = = AudioPlayerStarting ) ; <nl> } else { <nl> } <nl> - if ( ! showPause & & ( playing = = AudioMsgId ( _data , _parent - > fullId ( ) ) ) & & App : : main ( ) & & App : : main ( ) - > player ( ) - > seekingSong ( playing ) ) { <nl> - showPause = true ; <nl> + if ( ! showPause & & ( playing = = AudioMsgId ( _data , _parent - > fullId ( ) ) ) ) { <nl> + showPause = ( Media : : Player : : exists ( ) & & Media : : Player : : instance ( ) - > isSeeking ( ) ) ; <nl> } <nl> } <nl> } <nl> mmm a / Telegram / SourceFiles / historywidget . cpp <nl> ppp b / Telegram / SourceFiles / historywidget . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " window / top_bar_widget . h " <nl> # include " window / chat_background . h " <nl> # include " observer_peer . h " <nl> - # include " playerwidget . h " <nl> # include " core / qthelp_regex . h " <nl> <nl> namespace { <nl> HistoryWidget : : HistoryWidget ( QWidget * parent ) : TWidget ( parent ) <nl> _attachDragDocument - > hide ( ) ; <nl> _attachDragPhoto - > hide ( ) ; <nl> <nl> - _topShadow . hide ( ) ; <nl> + _topShadow - > hide ( ) ; <nl> <nl> connect ( _attachDragDocument , SIGNAL ( dropped ( const QMimeData * ) ) , this , SLOT ( onDocumentDrop ( const QMimeData * ) ) ) ; <nl> connect ( _attachDragPhoto , SIGNAL ( dropped ( const QMimeData * ) ) , this , SLOT ( onPhotoDrop ( const QMimeData * ) ) ) ; <nl> bool HistoryWidget : : canWriteMessage ( ) const { <nl> <nl> void HistoryWidget : : updateControlsVisibility ( ) { <nl> if ( ! _a_show . animating ( ) ) { <nl> - _topShadow . setVisible ( _peer ? true : false ) ; <nl> + _topShadow - > setVisible ( _peer ? true : false ) ; <nl> } <nl> updateToEndVisibility ( ) ; <nl> if ( ! _history | | _a_show . animating ( ) ) { <nl> void HistoryWidget : : updateControlsVisibility ( ) { <nl> _attachType - > hide ( ) ; <nl> _emojiPan - > hide ( ) ; <nl> if ( _pinnedBar ) { <nl> - _pinnedBar - > cancel . hide ( ) ; <nl> - _pinnedBar - > shadow . hide ( ) ; <nl> + _pinnedBar - > cancel - > hide ( ) ; <nl> + _pinnedBar - > shadow - > hide ( ) ; <nl> } <nl> return ; <nl> } <nl> <nl> if ( _pinnedBar ) { <nl> - _pinnedBar - > cancel . show ( ) ; <nl> - _pinnedBar - > shadow . show ( ) ; <nl> + _pinnedBar - > cancel - > show ( ) ; <nl> + _pinnedBar - > shadow - > show ( ) ; <nl> } <nl> if ( _firstLoadRequest & & ! _scroll . isHidden ( ) ) { <nl> _scroll . hide ( ) ; <nl> void HistoryWidget : : showAnimated ( Window : : SlideDirection direction , const Window : <nl> <nl> _cacheUnder = params . oldContentCache ; <nl> show ( ) ; <nl> - _topShadow . setVisible ( params . withTopBarShadow ? false : true ) ; <nl> + _topShadow - > setVisible ( params . withTopBarShadow ? false : true ) ; <nl> _historyToEnd - > finishAnimation ( ) ; <nl> _cacheOver = App : : main ( ) - > grabForShowAnimation ( params ) ; <nl> App : : main ( ) - > topBar ( ) - > startAnim ( ) ; <nl> - _topShadow . setVisible ( params . withTopBarShadow ? true : false ) ; <nl> + _topShadow - > setVisible ( params . withTopBarShadow ? true : false ) ; <nl> <nl> _scroll . hide ( ) ; <nl> _kbScroll . hide ( ) ; <nl> void HistoryWidget : : showAnimated ( Window : : SlideDirection direction , const Window : <nl> _joinChannel . hide ( ) ; <nl> _muteUnmute . hide ( ) ; <nl> if ( _pinnedBar ) { <nl> - _pinnedBar - > shadow . hide ( ) ; <nl> - _pinnedBar - > cancel . hide ( ) ; <nl> + _pinnedBar - > shadow - > hide ( ) ; <nl> + _pinnedBar - > cancel - > hide ( ) ; <nl> } <nl> <nl> int delta = st : : slideShift ; <nl> void HistoryWidget : : step_show ( float64 ms , bool timer ) { <nl> float64 dt = ms / st : : slideDuration ; <nl> if ( dt > = 1 ) { <nl> _a_show . stop ( ) ; <nl> - _topShadow . setVisible ( _peer ? true : false ) ; <nl> + _topShadow - > setVisible ( _peer ? true : false ) ; <nl> _historyToEnd - > finishAnimation ( ) ; <nl> <nl> a_coordUnder . finish ( ) ; <nl> void HistoryWidget : : doneShow ( ) { <nl> void HistoryWidget : : animStop ( ) { <nl> if ( ! _a_show . animating ( ) ) return ; <nl> _a_show . stop ( ) ; <nl> - _topShadow . setVisible ( _peer ? true : false ) ; <nl> + _topShadow - > setVisible ( _peer ? true : false ) ; <nl> _historyToEnd - > finishAnimation ( ) ; <nl> } <nl> <nl> void HistoryWidget : : peerMessagesUpdated ( ) { <nl> if ( _list ) peerMessagesUpdated ( _peer - > id ) ; <nl> } <nl> <nl> + void HistoryWidget : : grapWithoutTopBarShadow ( ) { <nl> + grabStart ( ) ; <nl> + _topShadow - > hide ( ) ; <nl> + } <nl> + <nl> + void HistoryWidget : : grabFinish ( ) { <nl> + _inGrab = false ; <nl> + resizeEvent ( 0 ) ; <nl> + _topShadow - > show ( ) ; <nl> + } <nl> + <nl> bool HistoryWidget : : isItemVisible ( HistoryItem * item ) { <nl> if ( isHidden ( ) | | _a_show . animating ( ) | | ! _list ) { <nl> return false ; <nl> void HistoryWidget : : resizeEvent ( QResizeEvent * e ) { <nl> _reportSpamPanel . move ( 0 , st : : replyHeight ) ; <nl> _fieldAutocomplete - > setBoundings ( _scroll . geometry ( ) ) ; <nl> } <nl> - _pinnedBar - > cancel . move ( width ( ) - _pinnedBar - > cancel . width ( ) , 0 ) ; <nl> - _pinnedBar - > shadow . setGeometry ( 0 , st : : replyHeight , width ( ) , st : : lineWidth ) ; <nl> + _pinnedBar - > cancel - > move ( width ( ) - _pinnedBar - > cancel - > width ( ) , 0 ) ; <nl> + _pinnedBar - > shadow - > setGeometry ( 0 , st : : replyHeight , width ( ) , st : : lineWidth ) ; <nl> } else if ( _scroll . y ( ) ! = 0 ) { <nl> _scroll . move ( 0 , 0 ) ; <nl> _reportSpamPanel . move ( 0 , 0 ) ; <nl> void HistoryWidget : : resizeEvent ( QResizeEvent * e ) { <nl> break ; <nl> } <nl> <nl> - _topShadow . resize ( width ( ) - ( ( ! Adaptive : : OneColumn ( ) & & ! _inGrab ) ? st : : lineWidth : 0 ) , st : : lineWidth ) ; <nl> - _topShadow . moveToLeft ( ( ! Adaptive : : OneColumn ( ) & & ! _inGrab ) ? st : : lineWidth : 0 , 0 ) ; <nl> + _topShadow - > resize ( width ( ) - ( ( ! Adaptive : : OneColumn ( ) & & ! _inGrab ) ? st : : lineWidth : 0 ) , st : : lineWidth ) ; <nl> + _topShadow - > moveToLeft ( ( ! Adaptive : : OneColumn ( ) & & ! _inGrab ) ? st : : lineWidth : 0 , 0 ) ; <nl> } <nl> <nl> void HistoryWidget : : itemRemoved ( HistoryItem * item ) { <nl> void HistoryWidget : : onInlineResultSend ( InlineBots : : Result * result , UserData * bot <nl> <nl> HistoryWidget : : PinnedBar : : PinnedBar ( MsgId msgId , HistoryWidget * parent ) <nl> : msgId ( msgId ) <nl> - , msg ( 0 ) <nl> , cancel ( parent , st : : replyCancel ) <nl> , shadow ( parent , st : : shadowColor ) { <nl> } <nl> bool HistoryWidget : : pinnedMsgVisibilityUpdated ( ) { <nl> if ( ! _pinnedBar ) { <nl> _pinnedBar = new PinnedBar ( pinnedMsgId , this ) ; <nl> if ( _a_show . animating ( ) ) { <nl> - _pinnedBar - > cancel . hide ( ) ; <nl> - _pinnedBar - > shadow . hide ( ) ; <nl> + _pinnedBar - > cancel - > hide ( ) ; <nl> + _pinnedBar - > shadow - > hide ( ) ; <nl> } else { <nl> - _pinnedBar - > cancel . show ( ) ; <nl> - _pinnedBar - > shadow . show ( ) ; <nl> + _pinnedBar - > cancel - > show ( ) ; <nl> + _pinnedBar - > shadow - > show ( ) ; <nl> } <nl> - connect ( & _pinnedBar - > cancel , SIGNAL ( clicked ( ) ) , this , SLOT ( onPinnedHide ( ) ) ) ; <nl> + connect ( _pinnedBar - > cancel , SIGNAL ( clicked ( ) ) , this , SLOT ( onPinnedHide ( ) ) ) ; <nl> _reportSpamPanel . raise ( ) ; <nl> - _topShadow . raise ( ) ; <nl> + _topShadow - > raise ( ) ; <nl> if ( _membersDropdown ) { <nl> _membersDropdown - > raise ( ) ; <nl> } <nl> void HistoryWidget : : drawPinnedBar ( Painter & p ) { <nl> p . drawText ( left , st : : msgReplyPadding . top ( ) + st : : msgServiceNameFont - > ascent , lang ( lng_pinned_message ) ) ; <nl> <nl> p . setPen ( ( ( ( _pinnedBar - > msg - > toHistoryMessage ( ) & & _pinnedBar - > msg - > toHistoryMessage ( ) - > emptyText ( ) ) | | _pinnedBar - > msg - > serviceMsg ( ) ) ? st : : msgInDateFg : st : : msgColor ) - > p ) ; <nl> - _pinnedBar - > text . drawElided ( p , left , st : : msgReplyPadding . top ( ) + st : : msgServiceNameFont - > height , width ( ) - left - _pinnedBar - > cancel . width ( ) - st : : msgReplyPadding . right ( ) ) ; <nl> + _pinnedBar - > text . drawElided ( p , left , st : : msgReplyPadding . top ( ) + st : : msgServiceNameFont - > height , width ( ) - left - _pinnedBar - > cancel - > width ( ) - st : : msgReplyPadding . right ( ) ) ; <nl> } else { <nl> p . setFont ( st : : msgDateFont ) ; <nl> p . setPen ( st : : msgInDateFg ) ; <nl> - p . drawText ( left , st : : msgReplyPadding . top ( ) + ( st : : msgReplyBarSize . height ( ) - st : : msgDateFont - > height ) / 2 + st : : msgDateFont - > ascent , st : : msgDateFont - > elided ( lang ( lng_profile_loading ) , width ( ) - left - _pinnedBar - > cancel . width ( ) - st : : msgReplyPadding . right ( ) ) ) ; <nl> + p . drawText ( left , st : : msgReplyPadding . top ( ) + ( st : : msgReplyBarSize . height ( ) - st : : msgDateFont - > height ) / 2 + st : : msgDateFont - > ascent , st : : msgDateFont - > elided ( lang ( lng_profile_loading ) , width ( ) - left - _pinnedBar - > cancel - > width ( ) - st : : msgReplyPadding . right ( ) ) ) ; <nl> } <nl> } <nl> <nl> void HistoryWidget : : paintEvent ( QPaintEvent * e ) { <nl> } <nl> <nl> QRect fill ( 0 , 0 , width ( ) , App : : main ( ) - > height ( ) ) ; <nl> - int fromy = ( hasTopBar ? ( - st : : topBarHeight ) : 0 ) , x = 0 , y = 0 ; <nl> + int fromy = App : : main ( ) - > backgroundFromY ( ) , x = 0 , y = 0 ; <nl> QPixmap cached = App : : main ( ) - > cachedBackground ( fill , x , y ) ; <nl> if ( cached . isNull ( ) ) { <nl> auto & pix = Window : : chatBackground ( ) - > image ( ) ; <nl> void HistoryWidget : : paintEvent ( QPaintEvent * e ) { <nl> if ( _recording ) drawRecording ( p ) ; <nl> } <nl> } <nl> - if ( _pinnedBar & & ! _pinnedBar - > cancel . isHidden ( ) ) { <nl> + if ( _pinnedBar & & ! _pinnedBar - > cancel - > isHidden ( ) ) { <nl> drawPinnedBar ( p ) ; <nl> } <nl> if ( _scroll . isHidden ( ) ) { <nl> mmm a / Telegram / SourceFiles / historywidget . h <nl> ppp b / Telegram / SourceFiles / historywidget . h <nl> class Result ; <nl> namespace Ui { <nl> class HistoryDownButton ; <nl> class InnerDropdown ; <nl> + class PlainShadow ; <nl> } / / namespace Ui <nl> <nl> class Dropdown ; <nl> class HistoryWidget : public TWidget , public RPCSender , private base : : Subscriber <nl> Q_OBJECT <nl> <nl> public : <nl> - <nl> HistoryWidget ( QWidget * parent ) ; <nl> <nl> void start ( ) ; <nl> class HistoryWidget : public TWidget , public RPCSender , private base : : Subscriber <nl> _inGrab = true ; <nl> resizeEvent ( 0 ) ; <nl> } <nl> - void grapWithoutTopBarShadow ( ) { <nl> - grabStart ( ) ; <nl> - _topShadow . hide ( ) ; <nl> - } <nl> - void grabFinish ( ) override { <nl> - _inGrab = false ; <nl> - resizeEvent ( 0 ) ; <nl> - _topShadow . show ( ) ; <nl> - } <nl> + void grapWithoutTopBarShadow ( ) ; <nl> + void grabFinish ( ) override ; <nl> <nl> bool isItemVisible ( HistoryItem * item ) ; <nl> <nl> private slots : <nl> MsgId msgId = 0 ; <nl> HistoryItem * msg = nullptr ; <nl> Text text ; <nl> - IconedButton cancel ; <nl> - PlainShadow shadow ; <nl> + ChildWidget < IconedButton > cancel ; <nl> + ChildWidget < Ui : : PlainShadow > shadow ; <nl> } ; <nl> PinnedBar * _pinnedBar = nullptr ; <nl> void updatePinnedBar ( bool force = false ) ; <nl> private slots : <nl> bool _saveDraftText = false ; <nl> QTimer _saveDraftTimer , _saveCloudDraftTimer ; <nl> <nl> - PlainShadow _topShadow ; <nl> + ChildWidget < Ui : : PlainShadow > _topShadow ; <nl> bool _inGrab = false ; <nl> <nl> } ; <nl> mmm a / Telegram / SourceFiles / inline_bots / inline_bot_layout_internal . cpp <nl> ppp b / Telegram / SourceFiles / inline_bots / inline_bot_layout_internal . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " styles / style_overview . h " <nl> # include " styles / style_history . h " <nl> # include " inline_bots / inline_bot_result . h " <nl> + # include " media / media_audio . h " <nl> # include " media / media_clip_reader . h " <nl> # include " media / player / media_player_instance . h " <nl> # include " history / history_location_manager . h " <nl> # include " localstorage . h " <nl> # include " mainwidget . h " <nl> # include " lang . h " <nl> - # include " playerwidget . h " <nl> <nl> namespace InlineBots { <nl> namespace Layout { <nl> mmm a / Telegram / SourceFiles / inline_bots / inline_bot_layout_item . cpp <nl> ppp b / Telegram / SourceFiles / inline_bots / inline_bot_layout_item . cpp <nl> const DocumentItems * documentItems ( ) { <nl> namespace internal { <nl> <nl> void regDocumentItem ( DocumentData * document , ItemBase * item ) { <nl> - documentItemsMap . makeIfNull ( ) ; <nl> + documentItemsMap . createIfNull ( ) ; <nl> ( * documentItemsMap ) [ document ] . insert ( item ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / inline_bots / inline_bot_result . cpp <nl> ppp b / Telegram / SourceFiles / inline_bots / inline_bot_result . cpp <nl> bool Result : : onChoose ( Layout : : ItemBase * layout ) { <nl> } else if ( _document - > loading ( ) ) { <nl> _document - > cancel ( ) ; <nl> } else { <nl> - DocumentOpenClickHandler : : doOpen ( _document , ActionOnLoadNone ) ; <nl> + DocumentOpenClickHandler : : doOpen ( _document , nullptr , ActionOnLoadNone ) ; <nl> } <nl> return false ; <nl> } <nl> mmm a / Telegram / SourceFiles / layout . cpp <nl> ppp b / Telegram / SourceFiles / layout . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " fileuploader . h " <nl> # include " mainwindow . h " <nl> # include " ui / filedialog . h " <nl> - # include " playerwidget . h " <nl> # include " boxes / addcontactbox . h " <nl> # include " boxes / confirmbox . h " <nl> # include " media / media_audio . h " <nl> mmm a / Telegram / SourceFiles / localimageloader . cpp <nl> ppp b / Telegram / SourceFiles / localimageloader . cpp <nl> void TaskQueueWorker : : onTaskAdded ( ) { <nl> FileLoadTask : : FileLoadTask ( const QString & filepath , PrepareMediaType type , const FileLoadTo & to , FileLoadForceConfirmType confirm ) : _id ( rand_value < uint64 > ( ) ) <nl> , _to ( to ) <nl> , _filepath ( filepath ) <nl> - , _duration ( 0 ) <nl> , _type ( type ) <nl> - , _confirm ( confirm ) <nl> - , _result ( 0 ) { <nl> + , _confirm ( confirm ) { <nl> } <nl> <nl> FileLoadTask : : FileLoadTask ( const QByteArray & content , PrepareMediaType type , const FileLoadTo & to ) : _id ( rand_value < uint64 > ( ) ) <nl> , _to ( to ) <nl> , _content ( content ) <nl> - , _duration ( 0 ) <nl> - , _type ( type ) <nl> - , _confirm ( FileLoadNoForceConfirm ) <nl> - , _result ( 0 ) { <nl> + , _type ( type ) { <nl> } <nl> <nl> FileLoadTask : : FileLoadTask ( const QImage & image , PrepareMediaType type , const FileLoadTo & to , FileLoadForceConfirmType confirm , const QString & originalText ) : _id ( rand_value < uint64 > ( ) ) <nl> , _to ( to ) <nl> , _image ( image ) <nl> - , _duration ( 0 ) <nl> , _type ( type ) <nl> , _confirm ( confirm ) <nl> - , _originalText ( originalText ) <nl> - , _result ( 0 ) { <nl> + , _originalText ( originalText ) { <nl> } <nl> <nl> FileLoadTask : : FileLoadTask ( const QByteArray & voice , int32 duration , const VoiceWaveform & waveform , const FileLoadTo & to ) : _id ( rand_value < uint64 > ( ) ) <nl> FileLoadTask : : FileLoadTask ( const QByteArray & voice , int32 duration , const VoiceW <nl> , _content ( voice ) <nl> , _duration ( duration ) <nl> , _waveform ( waveform ) <nl> - , _type ( PrepareAudio ) <nl> - , _confirm ( FileLoadNoForceConfirm ) <nl> - , _result ( 0 ) { <nl> + , _type ( PrepareAudio ) { <nl> } <nl> <nl> void FileLoadTask : : process ( ) { <nl> mmm a / Telegram / SourceFiles / localimageloader . h <nl> ppp b / Telegram / SourceFiles / localimageloader . h <nl> class FileLoadTask : public Task { <nl> QString _filepath ; <nl> QImage _image ; <nl> QByteArray _content ; <nl> - int32 _duration ; <nl> + int32 _duration = 0 ; <nl> VoiceWaveform _waveform ; <nl> PrepareMediaType _type ; <nl> - FileLoadForceConfirmType _confirm ; <nl> + FileLoadForceConfirmType _confirm = FileLoadNoForceConfirm ; <nl> QString _originalText ; <nl> <nl> FileLoadResultPtr _result ; <nl> mmm a / Telegram / SourceFiles / mainwidget . cpp <nl> ppp b / Telegram / SourceFiles / mainwidget . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " styles / style_dialogs . h " <nl> # include " ui / buttons / peer_avatar_button . h " <nl> # include " ui / buttons / round_button . h " <nl> + # include " ui / widgets / shadow . h " <nl> # include " window / section_memento . h " <nl> # include " window / section_widget . h " <nl> # include " window / top_bar_widget . h " <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " dialogswidget . h " <nl> # include " historywidget . h " <nl> # include " overviewwidget . h " <nl> - # include " playerwidget . h " <nl> # include " lang . h " <nl> # include " boxes / addcontactbox . h " <nl> # include " fileuploader . h " <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " localstorage . h " <nl> # include " shortcuts . h " <nl> # include " media / media_audio . h " <nl> + # include " media / player / media_player_panel . h " <nl> # include " media / player / media_player_widget . h " <nl> + # include " media / player / media_player_volume_controller . h " <nl> # include " media / player / media_player_instance . h " <nl> # include " core / qthelp_regex . h " <nl> # include " core / qthelp_url . h " <nl> # include " window / chat_background . h " <nl> + # include " window / player_wrap_widget . h " <nl> <nl> StackItemSection : : StackItemSection ( std_ : : unique_ptr < Window : : SectionMemento > & & memento ) : StackItem ( nullptr ) <nl> , _memento ( std_ : : move ( memento ) ) { <nl> StackItemSection : : StackItemSection ( std_ : : unique_ptr < Window : : SectionMemento > & & me <nl> StackItemSection : : ~ StackItemSection ( ) { <nl> } <nl> <nl> - # include " boxes / confirmphonebox . h " <nl> - <nl> MainWidget : : MainWidget ( MainWindow * window ) : TWidget ( window ) <nl> , _a_show ( animation ( this , & MainWidget : : step_show ) ) <nl> , _dialogsWidth ( st : : dialogsWidthMin ) <nl> , _sideShadow ( this , st : : shadowColor ) <nl> , _dialogs ( this ) <nl> , _history ( this ) <nl> - , _player ( this ) <nl> , _topBar ( this ) <nl> , _mediaType ( this ) <nl> , _api ( new ApiWrap ( this ) ) { <nl> MainWidget : : MainWidget ( MainWindow * window ) : TWidget ( window ) <nl> App : : wnd ( ) - > getTitle ( ) - > updateControlsVisibility ( ) ; <nl> _topBar - > hide ( ) ; <nl> <nl> - _player - > hidePlayer ( ) ; <nl> - <nl> orderWidgets ( ) ; <nl> <nl> MTP : : setGlobalFailHandler ( rpcFail ( & MainWidget : : updateFail ) ) ; <nl> void MainWidget : : overviewPreloaded ( PeerData * peer , const MTPmessages_Messages & r <nl> } <nl> <nl> void MainWidget : : mediaOverviewUpdated ( PeerData * peer , MediaOverviewType type ) { <nl> - if ( ! _player - > isHidden ( ) ) _player - > mediaOverviewUpdated ( peer , type ) ; <nl> if ( _overview & & ( _overview - > peer ( ) = = peer | | _overview - > peer ( ) - > migrateFrom ( ) = = peer ) ) { <nl> _overview - > mediaOverviewUpdated ( peer , type ) ; <nl> <nl> void MainWidget : : handleAudioUpdate ( const AudioMsgId & audioId ) { <nl> } <nl> <nl> if ( playing = = audioId & & audioId . type ( ) = = AudioMsgId : : Type : : Song ) { <nl> - if ( ! _mediaPlayer & & Media : : Player : : exists ( ) ) { <nl> - _mediaPlayer . create ( this ) ; <nl> - updateMediaPlayerPosition ( ) ; <nl> - orderWidgets ( ) ; <nl> - Media : : Player : : instance ( ) - > createdNotifier ( ) . notify ( Media : : Player : : CreatedEvent ( _mediaPlayer ) , true ) ; <nl> - } <nl> - <nl> - _player - > updateState ( playing , playbackState ) ; <nl> - <nl> - if ( ! ( playbackState . state & AudioPlayerStoppedMask ) & & playbackState . state ! = AudioPlayerFinishing ) { <nl> - if ( ! _player - > isOpened ( ) ) { <nl> - _player - > openPlayer ( ) ; <nl> - if ( _player - > isHidden ( ) & & ! _a_show . animating ( ) ) { <nl> - _player - > showPlayer ( ) ; <nl> - _playerHeight = _contentScrollAddToY = _player - > height ( ) ; <nl> - resizeEvent ( 0 ) ; <nl> - } <nl> - } <nl> + if ( ! _playerPanel & & ! _player & & Media : : Player : : exists ( ) ) { <nl> + createPlayer ( ) ; <nl> } <nl> } <nl> <nl> void MainWidget : : handleAudioUpdate ( const AudioMsgId & audioId ) { <nl> } <nl> } <nl> <nl> - void MainWidget : : closePlayer ( ) { <nl> - if ( _player - > isOpened ( ) ) { <nl> - _player - > closePlayer ( ) ; <nl> - if ( ! _player - > isHidden ( ) & & ! _a_show . animating ( ) ) { <nl> - _player - > hidePlayer ( ) ; <nl> - _contentScrollAddToY = - _player - > height ( ) ; <nl> - _playerHeight = 0 ; <nl> - resizeEvent ( 0 ) ; <nl> + void MainWidget : : switchToPanelPlayer ( ) { <nl> + _player - > slideUp ( ) ; <nl> + _playerVolume . destroyDelayed ( ) ; <nl> + if ( ! _playerPanel ) { <nl> + _playerPanel . create ( this , Media : : Player : : Panel : : Layout : : Full ) ; <nl> + _playerPanel - > setPinCallback ( [ this ] { switchToFixedPlayer ( ) ; } ) ; <nl> + updateMediaPlayerPosition ( ) ; <nl> + orderWidgets ( ) ; <nl> + Media : : Player : : instance ( ) - > createdNotifier ( ) . notify ( Media : : Player : : PanelEvent ( _playerPanel ) , true ) ; <nl> + } <nl> + } <nl> + <nl> + void MainWidget : : switchToFixedPlayer ( ) { <nl> + _playerPanel . destroyDelayed ( ) ; <nl> + if ( ! _player ) { <nl> + createPlayer ( ) ; <nl> + } else { <nl> + _player - > slideDown ( ) ; <nl> + if ( ! _playerVolume ) { <nl> + _playerVolume . create ( this ) ; <nl> + _player - > entity ( ) - > volumeWidgetCreated ( _playerVolume ) ; <nl> + updateMediaPlayerPosition ( ) ; <nl> } <nl> } <nl> } <nl> <nl> + void MainWidget : : createPlayer ( ) { <nl> + _player . create ( this , [ this ] { playerHeightUpdated ( ) ; } ) ; <nl> + _player - > entity ( ) - > setCloseCallback ( [ this ] { switchToPanelPlayer ( ) ; } ) ; <nl> + _playerVolume . create ( this ) ; <nl> + _player - > entity ( ) - > volumeWidgetCreated ( _playerVolume ) ; <nl> + orderWidgets ( ) ; <nl> + if ( _a_show . animating ( ) ) { <nl> + _player - > showFast ( ) ; <nl> + _player - > hide ( ) ; <nl> + } else { <nl> + _player - > hideFast ( ) ; <nl> + _player - > slideDown ( ) ; <nl> + _playerHeight = _contentScrollAddToY = _player - > contentHeight ( ) ; <nl> + updateControlsGeometry ( ) ; <nl> + } <nl> + } <nl> + <nl> + void MainWidget : : playerHeightUpdated ( ) { <nl> + auto playerHeight = _player - > contentHeight ( ) ; <nl> + if ( playerHeight ! = _playerHeight ) { <nl> + _contentScrollAddToY + = playerHeight - _playerHeight ; <nl> + _playerHeight = playerHeight ; <nl> + updateControlsGeometry ( ) ; <nl> + } <nl> + if ( _playerPanel & & ! _playerHeight & & _player - > isHidden ( ) ) { <nl> + _playerVolume . destroyDelayed ( ) ; <nl> + _player . destroyDelayed ( ) ; <nl> + } <nl> + } <nl> + <nl> void MainWidget : : documentLoadProgress ( FileLoader * loader ) { <nl> if ( auto mtpLoader = loader ? loader - > mtpLoader ( ) : nullptr ) { <nl> documentLoadProgress ( App : : document ( mtpLoader - > objId ( ) ) ) ; <nl> void MainWidget : : documentLoadProgress ( DocumentData * document ) { <nl> App : : wnd ( ) - > documentUpdated ( document ) ; <nl> <nl> if ( ! document - > loaded ( ) & & document - > song ( ) ) { <nl> - if ( audioPlayer ( ) & & document - > loading ( ) ) { <nl> - AudioMsgId playing ; <nl> - auto playbackState = audioPlayer ( ) - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> - if ( playing . audio ( ) = = document & & ! _player - > isHidden ( ) ) { <nl> - _player - > updateState ( playing , playbackState ) ; <nl> - } <nl> - } <nl> if ( Media : : Player : : exists ( ) ) { <nl> Media : : Player : : instance ( ) - > documentLoadProgress ( document ) ; <nl> } <nl> Window : : SectionSlideParams MainWidget : : prepareShowAnimation ( bool willHaveTopBarS <nl> result . withTopBarShadow = false ; <nl> } <nl> <nl> + if ( _player ) { <nl> + _player - > hideShadow ( ) ; <nl> + } <nl> if ( selectingPeer ( ) & & Adaptive : : OneColumn ( ) ) { <nl> result . oldContentCache = myGrab ( this , QRect ( 0 , _playerHeight , _dialogsWidth , height ( ) - _playerHeight ) ) ; <nl> } else if ( _wideSection ) { <nl> Window : : SectionSlideParams MainWidget : : prepareShowAnimation ( bool willHaveTopBarS <nl> if ( Adaptive : : OneColumn ( ) ) { <nl> result . oldContentCache = myGrab ( this , QRect ( 0 , _playerHeight , _dialogsWidth , height ( ) - _playerHeight ) ) ; <nl> } else { <nl> - _sideShadow . hide ( ) ; <nl> + _sideShadow - > hide ( ) ; <nl> result . oldContentCache = myGrab ( this , QRect ( _dialogsWidth , _playerHeight , width ( ) - _dialogsWidth , height ( ) - _playerHeight ) ) ; <nl> - _sideShadow . show ( ) ; <nl> + _sideShadow - > show ( ) ; <nl> } <nl> if ( _overview ) _overview - > grabFinish ( ) ; <nl> _history - > grabFinish ( ) ; <nl> } <nl> + if ( _player ) { <nl> + _player - > showShadow ( ) ; <nl> + } <nl> <nl> return result ; <nl> } <nl> void MainWidget : : showBackFromStack ( ) { <nl> <nl> void MainWidget : : orderWidgets ( ) { <nl> _topBar - > raise ( ) ; <nl> - _player - > raise ( ) ; <nl> _dialogs - > raise ( ) ; <nl> + if ( _player ) { <nl> + _player - > raise ( ) ; <nl> + } <nl> + if ( _playerVolume ) { <nl> + _playerVolume - > raise ( ) ; <nl> + } <nl> _mediaType - > raise ( ) ; <nl> - _sideShadow . raise ( ) ; <nl> - if ( _mediaPlayer ) _mediaPlayer - > raise ( ) ; <nl> + _sideShadow - > raise ( ) ; <nl> + if ( _playerPanel ) _playerPanel - > raise ( ) ; <nl> if ( _hider ) _hider - > raise ( ) ; <nl> } <nl> <nl> QRect MainWidget : : historyRect ( ) const { <nl> QPixmap MainWidget : : grabForShowAnimation ( const Window : : SectionSlideParams & params ) { <nl> _topBar - > stopAnim ( ) ; <nl> QPixmap result ; <nl> + if ( _player ) { <nl> + _player - > hideShadow ( ) ; <nl> + } <nl> if ( Adaptive : : OneColumn ( ) ) { <nl> result = myGrab ( this , QRect ( 0 , _playerHeight , _dialogsWidth , height ( ) - _playerHeight ) ) ; <nl> } else { <nl> - _sideShadow . hide ( ) ; <nl> + _sideShadow - > hide ( ) ; <nl> result = myGrab ( this , QRect ( _dialogsWidth , _playerHeight , width ( ) - _dialogsWidth , height ( ) - _playerHeight ) ) ; <nl> - _sideShadow . show ( ) ; <nl> + _sideShadow - > show ( ) ; <nl> + } <nl> + if ( _player ) { <nl> + _player - > showShadow ( ) ; <nl> } <nl> return result ; <nl> } <nl> void MainWidget : : hideAll ( ) { <nl> if ( _overview ) { <nl> _overview - > hide ( ) ; <nl> } <nl> - _sideShadow . hide ( ) ; <nl> + _sideShadow - > hide ( ) ; <nl> _topBar - > hide ( ) ; <nl> _mediaType - > hide ( ) ; <nl> - if ( _player - > isOpened ( ) & & ! _player - > isHidden ( ) ) { <nl> - _player - > hidePlayer ( ) ; <nl> + if ( _player ) { <nl> + _player - > hide ( ) ; <nl> _playerHeight = 0 ; <nl> } <nl> } <nl> void MainWidget : : showAll ( ) { <nl> Ui : : showLayer ( new InformBox ( lang ( lng_signin_password_removed ) ) ) ; <nl> } <nl> if ( Adaptive : : OneColumn ( ) ) { <nl> - _sideShadow . hide ( ) ; <nl> + _sideShadow - > hide ( ) ; <nl> if ( _hider ) { <nl> _hider - > hide ( ) ; <nl> if ( ! _forwardConfirm & & _hider - > wasOffered ( ) ) { <nl> void MainWidget : : showAll ( ) { <nl> } <nl> } <nl> } else { <nl> - _sideShadow . show ( ) ; <nl> + _sideShadow - > show ( ) ; <nl> if ( _hider ) { <nl> _hider - > show ( ) ; <nl> if ( _forwardConfirm ) { <nl> void MainWidget : : showAll ( ) { <nl> _topBar - > show ( ) ; <nl> } <nl> } <nl> - if ( _player - > isOpened ( ) & & _player - > isHidden ( ) ) { <nl> - _player - > showPlayer ( ) ; <nl> - _playerHeight = _player - > height ( ) ; <nl> + if ( _player ) { <nl> + _player - > show ( ) ; <nl> + _playerHeight = _player - > contentHeight ( ) ; <nl> } <nl> resizeEvent ( 0 ) ; <nl> <nl> inline int chatsListWidth ( int windowWidth ) { <nl> } / / namespace <nl> <nl> void MainWidget : : resizeEvent ( QResizeEvent * e ) { <nl> - int32 tbh = _topBar - > isHidden ( ) ? 0 : st : : topBarHeight ; <nl> - updateMediaPlayerPosition ( ) ; <nl> + updateControlsGeometry ( ) ; <nl> + } <nl> + <nl> + void MainWidget : : updateControlsGeometry ( ) { <nl> + auto tbh = _topBar - > isHidden ( ) ? 0 : st : : topBarHeight ; <nl> if ( Adaptive : : OneColumn ( ) ) { <nl> _dialogsWidth = width ( ) ; <nl> - _player - > setGeometry ( 0 , 0 , _dialogsWidth , _player - > height ( ) ) ; <nl> + if ( _player ) { <nl> + _player - > resizeToWidth ( _dialogsWidth ) ; <nl> + _player - > moveToLeft ( 0 , 0 ) ; <nl> + } <nl> _dialogs - > setGeometry ( 0 , _playerHeight , _dialogsWidth , height ( ) - _playerHeight ) ; <nl> _topBar - > setGeometry ( 0 , _playerHeight , _dialogsWidth , st : : topBarHeight ) ; <nl> _history - > setGeometry ( 0 , _playerHeight + tbh , _dialogsWidth , height ( ) - _playerHeight - tbh ) ; <nl> if ( _hider ) _hider - > setGeometry ( 0 , 0 , _dialogsWidth , height ( ) ) ; <nl> } else { <nl> _dialogsWidth = chatsListWidth ( width ( ) ) ; <nl> - _dialogs - > resize ( _dialogsWidth , height ( ) ) ; <nl> - _dialogs - > moveToLeft ( 0 , 0 ) ; <nl> - _sideShadow . resize ( st : : lineWidth , height ( ) ) ; <nl> - _sideShadow . moveToLeft ( _dialogsWidth , 0 ) ; <nl> - _player - > resize ( width ( ) - _dialogsWidth , _player - > height ( ) ) ; <nl> - _player - > moveToLeft ( _dialogsWidth , 0 ) ; <nl> - _topBar - > resize ( width ( ) - _dialogsWidth , st : : topBarHeight ) ; <nl> - _topBar - > moveToLeft ( _dialogsWidth , _playerHeight ) ; <nl> - _history - > resize ( width ( ) - _dialogsWidth , height ( ) - _playerHeight - tbh ) ; <nl> - _history - > moveToLeft ( _dialogsWidth , _playerHeight + tbh ) ; <nl> + auto sectionWidth = width ( ) - _dialogsWidth ; <nl> + <nl> + _dialogs - > setGeometryToLeft ( 0 , 0 , _dialogsWidth , height ( ) ) ; <nl> + _sideShadow - > setGeometryToLeft ( _dialogsWidth , 0 , st : : lineWidth , height ( ) ) ; <nl> + if ( _player ) { <nl> + _player - > resizeToWidth ( sectionWidth ) ; <nl> + _player - > moveToLeft ( _dialogsWidth , 0 ) ; <nl> + } <nl> + _topBar - > setGeometryToLeft ( _dialogsWidth , _playerHeight , sectionWidth , st : : topBarHeight ) ; <nl> + _history - > setGeometryToLeft ( _dialogsWidth , _playerHeight + tbh , sectionWidth , height ( ) - _playerHeight - tbh ) ; <nl> if ( _hider ) { <nl> - _hider - > resize ( width ( ) - _dialogsWidth , height ( ) ) ; <nl> - _hider - > moveToLeft ( _dialogsWidth , 0 ) ; <nl> + _hider - > setGeometryToLeft ( _dialogsWidth , 0 , sectionWidth , height ( ) ) ; <nl> } <nl> } <nl> _mediaType - > moveToLeft ( width ( ) - _mediaType - > width ( ) , _playerHeight + st : : topBarHeight ) ; <nl> void MainWidget : : resizeEvent ( QResizeEvent * e ) { <nl> _wideSection - > setGeometryWithTopMoved ( wideSectionGeometry , _contentScrollAddToY ) ; <nl> } <nl> if ( _overview ) _overview - > setGeometry ( _history - > geometry ( ) ) ; <nl> + updateMediaPlayerPosition ( ) ; <nl> _contentScrollAddToY = 0 ; <nl> } <nl> <nl> void MainWidget : : updateMediaPlayerPosition ( ) { <nl> - if ( _mediaPlayer ) { <nl> - _mediaPlayer - > moveToRight ( 0 , 0 ) ; <nl> + if ( _playerPanel ) { <nl> + _playerPanel - > moveToRight ( 0 , 0 ) ; <nl> + } <nl> + if ( _playerVolume & & _player ) { <nl> + auto relativePosition = _player - > entity ( ) - > getPositionForVolumeWidget ( ) ; <nl> + auto playerMargins = _playerVolume - > getMargin ( ) ; <nl> + _playerVolume - > moveToLeft ( _player - > x ( ) + relativePosition . x ( ) - playerMargins . left ( ) , _player - > y ( ) + relativePosition . y ( ) - playerMargins . top ( ) ) ; <nl> } <nl> } <nl> <nl> void MainWidget : : keyPressEvent ( QKeyEvent * e ) { <nl> <nl> void MainWidget : : updateAdaptiveLayout ( ) { <nl> showAll ( ) ; <nl> - _sideShadow . setVisible ( ! Adaptive : : OneColumn ( ) ) ; <nl> + _sideShadow - > setVisible ( ! Adaptive : : OneColumn ( ) ) ; <nl> + if ( _player ) { <nl> + _player - > updateAdaptiveLayout ( ) ; <nl> + } <nl> } <nl> <nl> bool MainWidget : : needBackButton ( ) { <nl> Window : : TopBarWidget * MainWidget : : topBar ( ) { <nl> return _topBar ; <nl> } <nl> <nl> - PlayerWidget * MainWidget : : player ( ) { <nl> - return _player ; <nl> + int MainWidget : : backgroundFromY ( ) const { <nl> + return ( _topBar - > isHidden ( ) ? 0 : ( - st : : topBarHeight ) ) - _playerHeight ; <nl> } <nl> <nl> void MainWidget : : onTopBarClick ( ) { <nl> void MainWidget : : onSelfParticipantUpdated ( ChannelData * channel ) { <nl> <nl> bool MainWidget : : contentOverlapped ( const QRect & globalRect ) { <nl> return ( _history - > contentOverlapped ( globalRect ) | | <nl> + ( _playerPanel & & _playerPanel - > overlaps ( globalRect ) ) | | <nl> + ( _playerVolume & & _playerVolume - > overlaps ( globalRect ) ) | | <nl> _mediaType - > overlaps ( globalRect ) ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / mainwidget . h <nl> ppp b / Telegram / SourceFiles / mainwidget . h <nl> class Row ; <nl> namespace Media { <nl> namespace Player { <nl> class Widget ; <nl> + class VolumeWidget ; <nl> + class Panel ; <nl> } / / namespace Player <nl> } / / namespace Media <nl> <nl> namespace Ui { <nl> class PeerAvatarButton ; <nl> + class PlainShadow ; <nl> } / / namespace Ui <nl> <nl> namespace Window { <nl> + class PlayerWrapWidget ; <nl> class TopBarWidget ; <nl> class SectionMemento ; <nl> class SectionWidget ; <nl> class ConfirmBox ; <nl> class DialogsWidget ; <nl> class HistoryWidget ; <nl> class OverviewWidget ; <nl> - class PlayerWidget ; <nl> class HistoryHider ; <nl> class Dropdown ; <nl> <nl> enum NotifySettingStatus { <nl> <nl> namespace InlineBots { <nl> namespace Layout { <nl> - <nl> class ItemBase ; <nl> - <nl> } / / namespace Layout <nl> } / / namespace InlineBots <nl> <nl> class MainWidget : public TWidget , public RPCSender , private base : : Subscriber { <nl> QRect getMembersShowAreaGeometry ( ) const ; <nl> void setMembersShowAreaActive ( bool active ) ; <nl> Window : : TopBarWidget * topBar ( ) ; <nl> + int backgroundFromY ( ) const ; <nl> <nl> - PlayerWidget * player ( ) ; <nl> int contentScrollAddToY ( ) const ; <nl> <nl> void animShow ( const QPixmap & bgAnimCache , bool back = false ) ; <nl> class MainWidget : public TWidget , public RPCSender , private base : : Subscriber { <nl> <nl> bool isItemVisible ( HistoryItem * item ) ; <nl> <nl> - void closePlayer ( ) ; <nl> - <nl> void documentLoadProgress ( DocumentData * document ) ; <nl> <nl> void app_sendBotCallback ( const HistoryMessageReplyMarkup : : Button * button , const HistoryItem * msg , int row , int col ) ; <nl> public slots : <nl> void updateAdaptiveLayout ( ) ; <nl> void handleAudioUpdate ( const AudioMsgId & audioId ) ; <nl> void updateMediaPlayerPosition ( ) ; <nl> + void updateControlsGeometry ( ) ; <nl> + <nl> + void createPlayer ( ) ; <nl> + void switchToPanelPlayer ( ) ; <nl> + void switchToFixedPlayer ( ) ; <nl> + void playerHeightUpdated ( ) ; <nl> <nl> void sendReadRequest ( PeerData * peer , MsgId upTo ) ; <nl> void channelReadDone ( PeerData * peer , const MTPBool & result ) ; <nl> public slots : <nl> <nl> int _dialogsWidth ; <nl> <nl> - PlainShadow _sideShadow ; <nl> - <nl> + ChildWidget < Ui : : PlainShadow > _sideShadow ; <nl> ChildWidget < DialogsWidget > _dialogs ; <nl> ChildWidget < HistoryWidget > _history ; <nl> ChildWidget < Window : : SectionWidget > _wideSection = { nullptr } ; <nl> ChildWidget < OverviewWidget > _overview = { nullptr } ; <nl> - ChildWidget < PlayerWidget > _player ; <nl> ChildWidget < Window : : TopBarWidget > _topBar ; <nl> - ChildWidget < Media : : Player : : Widget > _mediaPlayer = { nullptr } ; <nl> + ChildWidget < Window : : PlayerWrapWidget > _player = { nullptr } ; <nl> + ChildWidget < Media : : Player : : VolumeWidget > _playerVolume = { nullptr } ; <nl> + ChildWidget < Media : : Player : : Panel > _playerPanel = { nullptr } ; <nl> ConfirmBox * _forwardConfirm = nullptr ; / / for single column layout <nl> ChildWidget < HistoryHider > _hider = { nullptr } ; <nl> std_ : : vector_of_moveable < std_ : : unique_ptr < StackItem > > _stack ; <nl> mmm a / Telegram / SourceFiles / media / media_audio . cpp <nl> ppp b / Telegram / SourceFiles / media / media_audio . cpp <nl> void AudioPlayer : : AudioMsg : : clear ( ) { <nl> videoPlayId = 0 ; <nl> } <nl> <nl> - AudioPlayer : : AudioPlayer ( ) : _audioCurrent ( 0 ) , _songCurrent ( 0 ) , <nl> - _fader ( new AudioPlayerFader ( & _faderThread ) ) , <nl> - _loader ( new AudioPlayerLoaders ( & _loaderThread ) ) { <nl> + AudioPlayer : : AudioPlayer ( ) <nl> + : _fader ( new AudioPlayerFader ( & _faderThread ) ) <nl> + , _loader ( new AudioPlayerLoaders ( & _loaderThread ) ) { <nl> connect ( this , SIGNAL ( faderOnTimer ( ) ) , _fader , SLOT ( onTimer ( ) ) ) ; <nl> connect ( this , SIGNAL ( suppressSong ( ) ) , _fader , SLOT ( onSuppressSong ( ) ) ) ; <nl> connect ( this , SIGNAL ( unsuppressSong ( ) ) , _fader , SLOT ( onUnsuppressSong ( ) ) ) ; <nl> connect ( this , SIGNAL ( suppressAll ( ) ) , _fader , SLOT ( onSuppressAll ( ) ) ) ; <nl> - connect ( this , SIGNAL ( songVolumeChanged ( ) ) , _fader , SLOT ( onSongVolumeChanged ( ) ) ) ; <nl> - connect ( this , SIGNAL ( videoVolumeChanged ( ) ) , _fader , SLOT ( onVideoVolumeChanged ( ) ) ) ; <nl> + subscribe ( Global : : RefSongVolumeChanged ( ) , [ this ] { <nl> + QMetaObject : : invokeMethod ( _fader , " onSongVolumeChanged " ) ; <nl> + } ) ; <nl> + subscribe ( Global : : RefVideoVolumeChanged ( ) , [ this ] { <nl> + QMetaObject : : invokeMethod ( _fader , " onVideoVolumeChanged " ) ; <nl> + } ) ; <nl> connect ( this , SIGNAL ( loaderOnStart ( const AudioMsgId & , qint64 ) ) , _loader , SLOT ( onStart ( const AudioMsgId & , qint64 ) ) ) ; <nl> connect ( this , SIGNAL ( loaderOnCancel ( const AudioMsgId & ) ) , _loader , SLOT ( onCancel ( const AudioMsgId & ) ) ) ; <nl> - connect ( & _faderThread , SIGNAL ( started ( ) ) , _fader , SLOT ( onInit ( ) ) ) ; <nl> - connect ( & _loaderThread , SIGNAL ( started ( ) ) , _loader , SLOT ( onInit ( ) ) ) ; <nl> - connect ( & _faderThread , SIGNAL ( finished ( ) ) , _fader , SLOT ( deleteLater ( ) ) ) ; <nl> - connect ( & _loaderThread , SIGNAL ( finished ( ) ) , _loader , SLOT ( deleteLater ( ) ) ) ; <nl> connect ( _loader , SIGNAL ( needToCheck ( ) ) , _fader , SLOT ( onTimer ( ) ) ) ; <nl> connect ( _loader , SIGNAL ( error ( const AudioMsgId & ) ) , this , SLOT ( onError ( const AudioMsgId & ) ) ) ; <nl> connect ( _fader , SIGNAL ( needToPreload ( const AudioMsgId & ) ) , _loader , SLOT ( onLoad ( const AudioMsgId & ) ) ) ; <nl> _loader ( new AudioPlayerLoaders ( & _loaderThread ) ) { <nl> connect ( _fader , SIGNAL ( error ( const AudioMsgId & ) ) , this , SLOT ( onError ( const AudioMsgId & ) ) ) ; <nl> connect ( this , SIGNAL ( stoppedOnError ( const AudioMsgId & ) ) , this , SIGNAL ( updated ( const AudioMsgId & ) ) , Qt : : QueuedConnection ) ; <nl> connect ( this , SIGNAL ( updated ( const AudioMsgId & ) ) , this , SLOT ( onUpdated ( const AudioMsgId & ) ) ) ; <nl> + <nl> _loaderThread . start ( ) ; <nl> _faderThread . start ( ) ; <nl> } <nl> bool AudioPlayer : : fadedStop ( AudioMsgId : : Type type , bool * fadedStart ) { <nl> void AudioPlayer : : play ( const AudioMsgId & audio , int64 position ) { <nl> auto type = audio . type ( ) ; <nl> AudioMsgId stopped ; <nl> + auto notLoadedYet = false ; <nl> { <nl> QMutexLocker lock ( & playerMutex ) ; <nl> <nl> void AudioPlayer : : play ( const AudioMsgId & audio , int64 position ) { <nl> current - > file = audio . audio ( ) - > location ( true ) ; <nl> current - > data = audio . audio ( ) - > data ( ) ; <nl> if ( current - > file . isEmpty ( ) & & current - > data . isEmpty ( ) ) { <nl> + notLoadedYet = true ; <nl> if ( audio . type ( ) = = AudioMsgId : : Type : : Song ) { <nl> setStoppedState ( current ) ; <nl> - if ( ! audio . audio ( ) - > loading ( ) ) { <nl> - DocumentOpenClickHandler : : doOpen ( audio . audio ( ) ) ; <nl> - } <nl> } else { <nl> setStoppedState ( current , AudioPlayerStoppedAtError ) ; <nl> - onError ( audio ) ; <nl> } <nl> } else { <nl> current - > playbackState . position = position ; <nl> void AudioPlayer : : play ( const AudioMsgId & audio , int64 position ) { <nl> } <nl> } <nl> } <nl> - if ( stopped ) emit updated ( stopped ) ; <nl> + if ( notLoadedYet ) { <nl> + if ( audio . type ( ) = = AudioMsgId : : Type : : Song ) { <nl> + DocumentOpenClickHandler : : doOpen ( audio . audio ( ) , App : : histItemById ( audio . contextId ( ) ) ) ; <nl> + } else { <nl> + onError ( audio ) ; <nl> + } <nl> + } <nl> + if ( stopped ) { <nl> + emit updated ( stopped ) ; <nl> + } <nl> } <nl> <nl> void AudioPlayer : : initFromVideo ( uint64 videoPlayId , std_ : : unique_ptr < VideoSoundData > & & data , int64 position ) { <nl> AudioCapture * audioCapture ( ) { <nl> return capture ; <nl> } <nl> <nl> - AudioPlayerFader : : AudioPlayerFader ( QThread * thread ) : _timer ( this ) , _pauseFlag ( false ) , _paused ( true ) , <nl> - _suppressAll ( false ) , _suppressAllAnim ( false ) , _suppressSong ( false ) , _suppressSongAnim ( false ) , <nl> - _suppressAllGain ( 1 . , 1 . ) , _suppressSongGain ( 1 . , 1 . ) , <nl> - _suppressAllStart ( 0 ) , _suppressSongStart ( 0 ) { <nl> + AudioPlayerFader : : AudioPlayerFader ( QThread * thread ) : QObject ( ) <nl> + , _timer ( this ) <nl> + , _suppressAllGain ( 1 . , 1 . ) <nl> + , _suppressSongGain ( 1 . , 1 . ) { <nl> moveToThread ( thread ) ; <nl> _timer . moveToThread ( thread ) ; <nl> _pauseTimer . moveToThread ( thread ) ; <nl> + connect ( thread , SIGNAL ( started ( ) ) , this , SLOT ( onInit ( ) ) ) ; <nl> + connect ( thread , SIGNAL ( finished ( ) ) , this , SLOT ( deleteLater ( ) ) ) ; <nl> <nl> _timer . setSingleShot ( true ) ; <nl> connect ( & _timer , SIGNAL ( timeout ( ) ) , this , SLOT ( onTimer ( ) ) ) ; <nl> mmm a / Telegram / SourceFiles / media / media_audio . h <nl> ppp b / Telegram / SourceFiles / media / media_audio . h <nl> struct AudioPlaybackState { <nl> int32 frequency = 0 ; <nl> } ; <nl> <nl> - class AudioPlayer : public QObject , public base : : Observable < AudioMsgId > { <nl> + class AudioPlayer : public QObject , public base : : Observable < AudioMsgId > , private base : : Subscriber { <nl> Q_OBJECT <nl> <nl> public : <nl> private slots : <nl> void unsuppressSong ( ) ; <nl> void suppressAll ( ) ; <nl> <nl> - void songVolumeChanged ( ) ; <nl> - void videoVolumeChanged ( ) ; <nl> - <nl> private : <nl> bool fadedStop ( AudioMsgId : : Type type , bool * fadedStart = 0 ) ; <nl> bool updateCurrentStarted ( AudioMsgId : : Type type , int32 pos = - 1 ) ; <nl> private slots : <nl> int * currentIndex ( AudioMsgId : : Type type ) ; <nl> const int * currentIndex ( AudioMsgId : : Type type ) const ; <nl> <nl> - int _audioCurrent ; <nl> + int _audioCurrent = 0 ; <nl> AudioMsg _audioData [ AudioSimultaneousLimit ] ; <nl> <nl> - int _songCurrent ; <nl> + int _songCurrent = 0 ; <nl> AudioMsg _songData [ AudioSimultaneousLimit ] ; <nl> <nl> AudioMsg _videoData ; <nl> public slots : <nl> <nl> QTimer _timer , _pauseTimer ; <nl> QMutex _pauseMutex ; <nl> - bool _pauseFlag , _paused ; <nl> - <nl> - bool _suppressAll , _suppressAllAnim , _suppressSong , _suppressSongAnim , _songVolumeChanged , _videoVolumeChanged ; <nl> + bool _pauseFlag = false ; <nl> + bool _paused = true ; <nl> + <nl> + bool _suppressAll = false ; <nl> + bool _suppressAllAnim = false ; <nl> + bool _suppressSong = false ; <nl> + bool _suppressSongAnim = false ; <nl> + bool _songVolumeChanged , _videoVolumeChanged ; <nl> anim : : fvalue _suppressAllGain , _suppressSongGain ; <nl> - uint64 _suppressAllStart , _suppressSongStart ; <nl> + uint64 _suppressAllStart = 0 ; <nl> + uint64 _suppressSongStart = 0 ; <nl> <nl> } ; <nl> <nl> mmm a / Telegram / SourceFiles / media / media_audio_loaders . cpp <nl> ppp b / Telegram / SourceFiles / media / media_audio_loaders . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> <nl> AudioPlayerLoaders : : AudioPlayerLoaders ( QThread * thread ) : _fromVideoNotify ( this , " onVideoSoundAdded " ) { <nl> moveToThread ( thread ) ; <nl> + connect ( thread , SIGNAL ( started ( ) ) , this , SLOT ( onInit ( ) ) ) ; <nl> + connect ( thread , SIGNAL ( finished ( ) ) , this , SLOT ( deleteLater ( ) ) ) ; <nl> } <nl> <nl> void AudioPlayerLoaders : : feedFromVideo ( VideoSoundPart & & part ) { <nl> mmm a / Telegram / SourceFiles / media / player / media_player . style <nl> ppp b / Telegram / SourceFiles / media / player / media_player . style <nl> MediaPlayerButton { <nl> cancelStroke : pixels ; <nl> } <nl> <nl> - mediaPlayerTitleButtonSize : size ( titleHeight , titleHeight ) ; <nl> - mediaPlayerTitleButtonInner : size ( 25px , 25px ) ; <nl> - mediaPlayerTitleButtonInnerBg : # 49708f ; <nl> - mediaPlayerButtonTransformDuration : 200 ; <nl> + mediaPlayerActiveFg : # 54b5ed ; <nl> + mediaPlayerInactiveFg : # dfebf2 ; <nl> <nl> - mediaPlayerTitleButton : MediaPlayerButton { <nl> - playPosition : point ( 10px , 7px ) ; <nl> - playOuter : size ( 29px , 25px ) ; <nl> - pausePosition : point ( 8px , 8px ) ; <nl> - pauseOuter : size ( 25px , 25px ) ; <nl> - pauseStroke : 3px ; <nl> - cancelPosition : point ( 8px , 8px ) ; <nl> - cancelOuter : size ( 25px , 25px ) ; <nl> - cancelStroke : 2px ; <nl> - } <nl> mediaPlayerButton : MediaPlayerButton { <nl> - playPosition : point ( 3px , 0px ) ; <nl> - playOuter : size ( 22px , 18px ) ; <nl> + playPosition : point ( 2px , 0px ) ; <nl> + playOuter : size ( 17px , 15px ) ; <nl> pausePosition : point ( 1px , 1px ) ; <nl> - pauseOuter : size ( 16px , 18px ) ; <nl> + pauseOuter : size ( 15px , 15px ) ; <nl> pauseStroke : 5px ; <nl> - cancelPosition : point ( 0px , 1px ) ; <nl> - cancelOuter : size ( 16px , 18px ) ; <nl> + cancelPosition : point ( 1px , 1px ) ; <nl> + cancelOuter : size ( 15px , 15px ) ; <nl> cancelStroke : 3px ; <nl> } <nl> + mediaPlayerButtonSize : size ( 25px , 30px ) ; <nl> <nl> - mediaPlayerMarginLeft : 10px ; <nl> - mediaPlayerMarginBottom : 10px ; <nl> - mediaPlayerWidth : 344px ; <nl> - mediaPlayerCoverHeight : 102px ; <nl> + mediaPlayerButtonPosition : point ( 5px , 10px ) ; <nl> + mediaPlayerSkipIconPosition : point ( 5px , 12px ) ; <nl> <nl> - mediaPlayerActiveFg : # 54b5ed ; <nl> - mediaPlayerInactiveFg : # dfebf2 ; <nl> + mediaPlayerHeight : 35px ; <nl> + mediaPlayerPadding : 8px ; <nl> + mediaPlayerNameTop : 22px ; <nl> + mediaPlayerPlayLeft : 7px ; <nl> + mediaPlayerPlaySkip : 1px ; <nl> + mediaPlayerPlayTop : 0px ; <nl> + mediaPlayerCloseRight : 0px ; <nl> <nl> - mediaPlayerButtonSize : size ( 32px , 32px ) ; <nl> - mediaPlayerButtonPosition : point ( 8px , 7px ) ; <nl> + mediaPlayerName : flatLabel ( labelDefFlat ) { <nl> + maxHeight : 20px ; <nl> + textFg : windowTextFg ; <nl> + } <nl> + mediaPlayerTime : LabelSimple ( defaultLabelSimple ) { <nl> + textFg : windowSubTextFg ; <nl> + } <nl> <nl> mediaPlayerRepeatButton : IconButton { <nl> width : 31px ; <nl> - height : 32px ; <nl> + height : 30px ; <nl> <nl> opacity : 1 . ; <nl> overOpacity : 1 . ; <nl> <nl> icon : icon { <nl> - { " player_repeat " , mediaPlayerActiveFg , point ( 9px , 9px ) } <nl> + { " player_repeat " , mediaPlayerActiveFg , point ( 9px , 11px ) } <nl> } ; <nl> iconPosition : point ( 0px , 0px ) ; <nl> downIconPosition : point ( 0px , 0px ) ; <nl> mediaPlayerRepeatButton : IconButton { <nl> duration : 0 ; <nl> } <nl> mediaPlayerRepeatDisabledIcon : icon { <nl> - { " player_repeat " , mediaPlayerInactiveFg , point ( 9px , 9px ) } <nl> - } ; <nl> - mediaPlayerPreviousButton : IconButton ( mediaPlayerRepeatButton ) { <nl> - width : 37px ; <nl> - icon : icon { <nl> - { " player_previous " , mediaPlayerActiveFg , point ( 10px , 10px ) } , <nl> - } ; <nl> - } <nl> - mediaPlayerPreviousDisabledIcon : icon { <nl> - { " player_previous " , mediaPlayerInactiveFg , point ( 10px , 10px ) } , <nl> + { " player_repeat " , # c8c8c8 , point ( 9px , 11px ) } <nl> } ; <nl> - mediaPlayerNextButton : IconButton ( mediaPlayerPreviousButton ) { <nl> - icon : icon { <nl> - { " player_next " , mediaPlayerActiveFg , point ( 10px , 10px ) } , <nl> - } ; <nl> - } <nl> - mediaPlayerNextDisabledIcon : icon { <nl> - { " player_next " , mediaPlayerInactiveFg , point ( 10px , 10px ) } , <nl> + mediaPlayerRepeatInactiveIcon : icon { <nl> + { " player_repeat " , mediaPlayerInactiveFg , point ( 9px , 11px ) } <nl> } ; <nl> <nl> - mediaPlayerPadding : 18px ; <nl> - mediaPlayerNameTop : 24px ; <nl> - mediaPlayerPlayLeft : 9px ; <nl> - mediaPlayerPlaySkip : 7px ; <nl> - mediaPlayerPlayTop : 58px ; <nl> - mediaPlayerPlaybackTop : 32px ; <nl> - mediaPlayerPlaybackPadding : 8px ; <nl> - mediaPlayerPlayback : MediaSlider { <nl> - width : 3px ; <nl> - activeFg : mediaPlayerActiveFg ; <nl> - inactiveFg : mediaPlayerInactiveFg ; <nl> - activeOpacity : 1 . ; <nl> - inactiveOpacity : 1 . ; <nl> - seekSize : size ( 9px , 9px ) ; <nl> - duration : 150 ; <nl> - } <nl> - <nl> - mediaPlayerName : flatLabel ( labelDefFlat ) { <nl> - maxHeight : 20px ; <nl> - textFg : windowTextFg ; <nl> - } <nl> - mediaPlayerTime : LabelSimple ( defaultLabelSimple ) { <nl> - textFg : windowSubTextFg ; <nl> - } <nl> - <nl> - mediaPlayerVolumeTop : 65px ; <nl> - mediaPlayerVolumeRight : 51px ; <nl> - mediaPlayerVolumeWidth : 86px ; <nl> - mediaPlayerVolumeLength : 64px ; <nl> - <nl> mediaPlayerVolumeIcon0 : icon { <nl> { " player_volume0 " , mediaPlayerActiveFg } , <nl> } ; <nl> mediaPlayerVolumeIcon3 : icon { <nl> { " player_volume3 " , mediaPlayerActiveFg } , <nl> } ; <nl> mediaPlayerVolumeToggle : IconButton { <nl> - width : 18px ; <nl> - height : 17px ; <nl> + width : 31px ; <nl> + height : 30px ; <nl> <nl> opacity : 1 . ; <nl> overOpacity : 1 . ; <nl> <nl> icon : mediaPlayerVolumeIcon0 ; <nl> - iconPosition : point ( 0px , 2px ) ; <nl> - downIconPosition : point ( 0px , 2px ) ; <nl> + iconPosition : point ( 8px , 11px ) ; <nl> + downIconPosition : point ( 8px , 11px ) ; <nl> <nl> duration : 0 ; <nl> } <nl> + mediaPlayerVolumeMargin : 10px ; <nl> + mediaPlayerVolumeSize : size ( 27px , 100px ) ; <nl> + <nl> + mediaPlayerPanelPinButton : IconButton ( mediaPlayerRepeatButton ) { <nl> + icon : icon { <nl> + { " player_panel_pin " , mediaPlayerActiveFg , point ( 9px , 11px ) } <nl> + } ; <nl> + } <nl> + <nl> + mediaPlayerNextButton : IconButton ( mediaPlayerRepeatButton ) { <nl> + width : 25px ; <nl> + icon : icon { <nl> + { " player_next " , mediaPlayerActiveFg , mediaPlayerSkipIconPosition } , <nl> + } ; <nl> + } <nl> + mediaPlayerNextDisabledIcon : icon { <nl> + { " player_next " , mediaPlayerInactiveFg , mediaPlayerSkipIconPosition } , <nl> + } ; <nl> + mediaPlayerPreviousButton : IconButton ( mediaPlayerNextButton ) { <nl> + icon : icon { <nl> + { " player_previous " , mediaPlayerActiveFg , mediaPlayerSkipIconPosition } , <nl> + } ; <nl> + } <nl> + mediaPlayerPreviousDisabledIcon : icon { <nl> + { " player_previous " , mediaPlayerInactiveFg , mediaPlayerSkipIconPosition } , <nl> + } ; <nl> + mediaPlayerClose : IconButton ( mediaPlayerRepeatButton ) { <nl> + width : 37px ; <nl> + icon : icon { <nl> + { " player_close " , # c8c8c8 , point ( 10px , 12px ) } , <nl> + } ; <nl> + } <nl> + mediaPlayerPlayback : FilledSlider { <nl> + fullWidth : 6px ; <nl> + lineWidth : 2px ; <nl> + activeFg : mediaPlayerActiveFg ; <nl> + inactiveFg : mediaPlayerInactiveFg ; <nl> + duration : 150 ; <nl> + } <nl> + <nl> + mediaPlayerTitleButtonSize : size ( titleHeight , titleHeight ) ; <nl> + mediaPlayerTitleButtonInner : size ( 25px , 25px ) ; <nl> + mediaPlayerTitleButtonInnerBg : # 49708f ; <nl> + mediaPlayerButtonTransformDuration : 200 ; <nl> + <nl> + mediaPlayerTitleButton : MediaPlayerButton { <nl> + playPosition : point ( 10px , 7px ) ; <nl> + playOuter : size ( 29px , 25px ) ; <nl> + pausePosition : point ( 8px , 8px ) ; <nl> + pauseOuter : size ( 25px , 25px ) ; <nl> + pauseStroke : 3px ; <nl> + cancelPosition : point ( 8px , 8px ) ; <nl> + cancelOuter : size ( 25px , 25px ) ; <nl> + cancelStroke : 2px ; <nl> + } <nl> + <nl> + mediaPlayerPanelButton : MediaPlayerButton { <nl> + playPosition : point ( 3px , 0px ) ; <nl> + playOuter : size ( 22px , 18px ) ; <nl> + pausePosition : point ( 1px , 1px ) ; <nl> + pauseOuter : size ( 16px , 18px ) ; <nl> + pauseStroke : 5px ; <nl> + cancelPosition : point ( 0px , 1px ) ; <nl> + cancelOuter : size ( 16px , 18px ) ; <nl> + cancelStroke : 3px ; <nl> + } <nl> + mediaPlayerPanelButtonSize : size ( 32px , 32px ) ; <nl> + mediaPlayerPanelButtonPosition : point ( 8px , 7px ) ; <nl> + <nl> + mediaPlayerPanelMarginLeft : 10px ; <nl> + mediaPlayerPanelMarginBottom : 10px ; <nl> + mediaPlayerPanelWidth : 344px ; <nl> + mediaPlayerCoverHeight : 102px ; <nl> + <nl> + mediaPlayerPanelNextButton : IconButton ( mediaPlayerRepeatButton ) { <nl> + width : 37px ; <nl> + icon : icon { <nl> + { " player_panel_next " , mediaPlayerActiveFg , point ( 10px , 10px ) } , <nl> + } ; <nl> + } <nl> + mediaPlayerPanelNextDisabledIcon : icon { <nl> + { " player_panel_next " , mediaPlayerInactiveFg , point ( 10px , 10px ) } , <nl> + } ; <nl> + mediaPlayerPanelPreviousButton : IconButton ( mediaPlayerPanelNextButton ) { <nl> + icon : icon { <nl> + { " player_panel_previous " , mediaPlayerActiveFg , point ( 10px , 10px ) } , <nl> + } ; <nl> + } <nl> + mediaPlayerPanelPreviousDisabledIcon : icon { <nl> + { " player_panel_previous " , mediaPlayerInactiveFg , point ( 10px , 10px ) } , <nl> + } ; <nl> + <nl> + mediaPlayerPanelPadding : 18px ; <nl> + mediaPlayerPanelNameTop : 24px ; <nl> + mediaPlayerPanelPlayLeft : 9px ; <nl> + mediaPlayerPanelPlaySkip : 7px ; <nl> + mediaPlayerPanelPlayTop : 58px ; <nl> + mediaPlayerPanelPlaybackTop : 32px ; <nl> + mediaPlayerPanelPlaybackPadding : 8px ; <nl> + mediaPlayerPanelPlayback : MediaSlider { <nl> + width : 3px ; <nl> + activeFg : mediaPlayerActiveFg ; <nl> + inactiveFg : mediaPlayerInactiveFg ; <nl> + activeOpacity : 1 . ; <nl> + inactiveOpacity : 1 . ; <nl> + seekSize : size ( 9px , 9px ) ; <nl> + duration : 150 ; <nl> + } <nl> + <nl> + mediaPlayerPanelVolumeTop : 65px ; <nl> + mediaPlayerPanelVolumeSkip : 3px ; <nl> + mediaPlayerPanelVolumeWidth : 64px ; <nl> + mediaPlayerPanelVolumeToggleSkip : 0px ; <nl> + mediaPlayerPanelVolumeToggleTop : 57px ; <nl> mmm a / Telegram / SourceFiles / media / player / media_player_cover . cpp <nl> ppp b / Telegram / SourceFiles / media / player / media_player_cover . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> <nl> # include " ui / flatlabel . h " <nl> # include " ui / widgets / label_simple . h " <nl> + # include " ui / widgets / media_slider . h " <nl> # include " ui / buttons / icon_button . h " <nl> # include " media / media_audio . h " <nl> # include " media / view / media_clip_playback . h " <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " media / player / media_player_volume_controller . h " <nl> # include " styles / style_media_player . h " <nl> # include " styles / style_mediaview . h " <nl> - # include " shortcuts . h " <nl> <nl> namespace Media { <nl> namespace Player { <nl> class CoverWidget : : PlayButton : public Button { <nl> public : <nl> PlayButton ( QWidget * parent ) ; <nl> <nl> - void setState ( State state ) { <nl> + void setState ( PlayButtonLayout : : State state ) { <nl> _layout . setState ( state ) ; <nl> } <nl> void finishTransform ( ) { <nl> class CoverWidget : : PlayButton : public Button { <nl> } ; <nl> <nl> CoverWidget : : PlayButton : : PlayButton ( QWidget * parent ) : Button ( parent ) <nl> - , _layout ( st : : mediaPlayerButton , [ this ] { update ( ) ; } ) { <nl> - resize ( st : : mediaPlayerButtonSize ) ; <nl> + , _layout ( st : : mediaPlayerPanelButton , [ this ] { update ( ) ; } ) { <nl> + resize ( st : : mediaPlayerPanelButtonSize ) ; <nl> setCursor ( style : : cur_pointer ) ; <nl> } <nl> <nl> void CoverWidget : : PlayButton : : paintEvent ( QPaintEvent * e ) { <nl> Painter p ( this ) ; <nl> <nl> - p . translate ( st : : mediaPlayerButtonPosition . x ( ) , st : : mediaPlayerButtonPosition . y ( ) ) ; <nl> + p . translate ( st : : mediaPlayerPanelButtonPosition . x ( ) , st : : mediaPlayerPanelButtonPosition . y ( ) ) ; <nl> _layout . paint ( p , st : : mediaPlayerActiveFg ) ; <nl> } <nl> <nl> CoverWidget : : CoverWidget ( QWidget * parent ) : TWidget ( parent ) <nl> , _nameLabel ( this , st : : mediaPlayerName ) <nl> , _timeLabel ( this , st : : mediaPlayerTime ) <nl> - , _playback ( this , st : : mediaPlayerPlayback ) <nl> + , _playback ( new Ui : : MediaSlider ( this , st : : mediaPlayerPanelPlayback ) ) <nl> , _playPause ( this ) <nl> + , _volumeToggle ( this , st : : mediaPlayerVolumeToggle ) <nl> , _volumeController ( this ) <nl> + , _pinPlayer ( this , st : : mediaPlayerPanelPinButton ) <nl> , _repeatTrack ( this , st : : mediaPlayerRepeatButton ) { <nl> setAttribute ( Qt : : WA_OpaquePaintEvent ) ; <nl> <nl> CoverWidget : : CoverWidget ( QWidget * parent ) : TWidget ( parent ) <nl> _playback - > setChangeFinishedCallback ( [ this ] ( float64 value ) { <nl> handleSeekFinished ( value ) ; <nl> } ) ; <nl> - _playPause - > setClickedCallback ( [ this ] ( ) { <nl> + _playPause - > setClickedCallback ( [ this ] { <nl> if ( exists ( ) ) { <nl> instance ( ) - > playPauseCancelClicked ( ) ; <nl> } <nl> } ) ; <nl> <nl> updateRepeatTrackIcon ( ) ; <nl> - _repeatTrack - > setClickedCallback ( [ this ] ( ) { <nl> + _repeatTrack - > setClickedCallback ( [ this ] { <nl> instance ( ) - > toggleRepeat ( ) ; <nl> - updateRepeatTrackIcon ( ) ; <nl> } ) ; <nl> <nl> + updateVolumeToggleIcon ( ) ; <nl> + _volumeToggle - > setClickedCallback ( [ this ] ( ) { <nl> + Global : : SetSongVolume ( ( Global : : SongVolume ( ) > 0 ) ? 0 . : Global : : RememberedSongVolume ( ) ) ; <nl> + Global : : RefSongVolumeChanged ( ) . notify ( ) ; <nl> + } ) ; <nl> + subscribe ( Global : : RefSongVolumeChanged ( ) , [ this ] { updateVolumeToggleIcon ( ) ; } ) ; <nl> if ( exists ( ) ) { <nl> - subscribe ( instance ( ) - > playlistChangedNotifier ( ) , [ this ] ( ) { <nl> + subscribe ( instance ( ) - > repeatChangedNotifier ( ) , [ this ] { <nl> + updateRepeatTrackIcon ( ) ; <nl> + } ) ; <nl> + subscribe ( instance ( ) - > playlistChangedNotifier ( ) , [ this ] { <nl> handlePlaylistUpdate ( ) ; <nl> } ) ; <nl> subscribe ( instance ( ) - > updatedNotifier ( ) , [ this ] ( const UpdatedEvent & e ) { <nl> handleSongUpdate ( e ) ; <nl> } ) ; <nl> - subscribe ( instance ( ) - > songChangedNotifier ( ) , [ this ] ( ) { <nl> + subscribe ( instance ( ) - > songChangedNotifier ( ) , [ this ] { <nl> handleSongChange ( ) ; <nl> } ) ; <nl> handleSongChange ( ) ; <nl> CoverWidget : : CoverWidget ( QWidget * parent ) : TWidget ( parent ) <nl> } <nl> } <nl> <nl> + void CoverWidget : : setPinCallback ( PinCallback & & callback ) { <nl> + _pinPlayer - > setClickedCallback ( std_ : : move ( callback ) ) ; <nl> + } <nl> + <nl> void CoverWidget : : handleSeekProgress ( float64 progress ) { <nl> if ( ! _lastDurationMs ) return ; <nl> <nl> void CoverWidget : : handleSeekFinished ( float64 progress ) { <nl> } <nl> <nl> void CoverWidget : : resizeEvent ( QResizeEvent * e ) { <nl> - _nameLabel - > resizeToWidth ( width ( ) - 2 * ( st : : mediaPlayerPadding ) - _timeLabel - > width ( ) - st : : normalFont - > spacew ) ; <nl> + auto widthForName = width ( ) - 2 * ( st : : mediaPlayerPanelPadding ) ; <nl> + widthForName - = _timeLabel - > width ( ) + 2 * st : : normalFont - > spacew ; <nl> + _nameLabel - > resizeToWidth ( widthForName ) ; <nl> updateLabelPositions ( ) ; <nl> <nl> - int skip = ( st : : mediaPlayerPlayback . seekSize . width ( ) / 2 ) ; <nl> - int length = ( width ( ) - 2 * st : : mediaPlayerPadding + st : : mediaPlayerPlayback . seekSize . width ( ) ) ; <nl> - _playback - > setGeometry ( st : : mediaPlayerPadding - skip , st : : mediaPlayerPlaybackTop , length , 2 * st : : mediaPlayerPlaybackPadding + st : : mediaPlayerPlayback . width ) ; <nl> + int skip = ( st : : mediaPlayerPanelPlayback . seekSize . width ( ) / 2 ) ; <nl> + int length = ( width ( ) - 2 * st : : mediaPlayerPanelPadding + st : : mediaPlayerPanelPlayback . seekSize . width ( ) ) ; <nl> + _playback - > setGeometry ( st : : mediaPlayerPanelPadding - skip , st : : mediaPlayerPanelPlaybackTop , length , 2 * st : : mediaPlayerPanelPlaybackPadding + st : : mediaPlayerPanelPlayback . width ) ; <nl> + <nl> + auto top = st : : mediaPlayerPanelVolumeToggleTop ; <nl> + auto right = st : : mediaPlayerPanelPlayLeft ; <nl> + _repeatTrack - > moveToRight ( right , top ) ; right + = _repeatTrack - > width ( ) ; <nl> + _pinPlayer - > moveToRight ( right , top ) ; right + = _pinPlayer - > width ( ) + st : : mediaPlayerPanelVolumeSkip ; <nl> + _volumeController - > moveToRight ( right , st : : mediaPlayerPanelVolumeTop ) ; right + = _volumeController - > width ( ) + st : : mediaPlayerPanelVolumeToggleSkip ; <nl> + _volumeToggle - > moveToRight ( right , top ) ; <nl> <nl> - _repeatTrack - > moveToRight ( st : : mediaPlayerPlayLeft , st : : mediaPlayerPlayTop ) ; <nl> - _volumeController - > moveToRight ( st : : mediaPlayerVolumeRight , st : : mediaPlayerVolumeTop ) ; <nl> updatePlayPrevNextPositions ( ) ; <nl> } <nl> <nl> void CoverWidget : : paintEvent ( QPaintEvent * e ) { <nl> } <nl> <nl> void CoverWidget : : updatePlayPrevNextPositions ( ) { <nl> + auto left = st : : mediaPlayerPanelPlayLeft ; <nl> + auto top = st : : mediaPlayerPanelPlayTop ; <nl> if ( _previousTrack ) { <nl> - auto left = st : : mediaPlayerPlayLeft ; <nl> - _previousTrack - > moveToLeft ( left , st : : mediaPlayerPlayTop ) ; left + = _previousTrack - > width ( ) + st : : mediaPlayerPlaySkip ; <nl> - _playPause - > moveToLeft ( left , st : : mediaPlayerPlayTop ) ; left + = _playPause - > width ( ) + st : : mediaPlayerPlaySkip ; <nl> - _nextTrack - > moveToLeft ( left , st : : mediaPlayerPlayTop ) ; <nl> + _previousTrack - > moveToLeft ( left , top ) ; left + = _previousTrack - > width ( ) + st : : mediaPlayerPanelPlaySkip ; <nl> + _playPause - > moveToLeft ( left , top ) ; left + = _playPause - > width ( ) + st : : mediaPlayerPanelPlaySkip ; <nl> + _nextTrack - > moveToLeft ( left , top ) ; <nl> } else { <nl> - _playPause - > moveToLeft ( st : : mediaPlayerPlayLeft , st : : mediaPlayerPlayTop ) ; <nl> + _playPause - > moveToLeft ( left , top ) ; <nl> } <nl> } <nl> <nl> void CoverWidget : : updateLabelPositions ( ) { <nl> - _nameLabel - > moveToLeft ( st : : mediaPlayerPadding , st : : mediaPlayerNameTop - st : : mediaPlayerName . font - > ascent ) ; <nl> - _timeLabel - > moveToRight ( st : : mediaPlayerPadding , st : : mediaPlayerNameTop - st : : mediaPlayerTime . font - > ascent ) ; <nl> + _nameLabel - > moveToLeft ( st : : mediaPlayerPanelPadding , st : : mediaPlayerPanelNameTop - st : : mediaPlayerName . font - > ascent ) ; <nl> + _timeLabel - > moveToRight ( st : : mediaPlayerPanelPadding , st : : mediaPlayerPanelNameTop - st : : mediaPlayerTime . font - > ascent ) ; <nl> } <nl> <nl> void CoverWidget : : updateRepeatTrackIcon ( ) { <nl> - _repeatTrack - > setIcon ( instance ( ) - > repeatEnabled ( ) ? nullptr : & st : : mediaPlayerRepeatDisabledIcon ) ; <nl> + _repeatTrack - > setIcon ( instance ( ) - > repeatEnabled ( ) ? nullptr : & st : : mediaPlayerRepeatInactiveIcon ) ; <nl> } <nl> <nl> void CoverWidget : : handleSongUpdate ( const UpdatedEvent & e ) { <nl> void CoverWidget : : updateTimeLabel ( ) { <nl> _timeLabel - > setText ( _time ) ; <nl> } <nl> if ( timeLabelWidth ! = _timeLabel - > width ( ) ) { <nl> - _nameLabel - > resizeToWidth ( width ( ) - 2 * ( st : : mediaPlayerPadding ) - _timeLabel - > width ( ) - st : : normalFont - > spacew ) ; <nl> + _nameLabel - > resizeToWidth ( width ( ) - 2 * ( st : : mediaPlayerPanelPadding ) - _timeLabel - > width ( ) - st : : normalFont - > spacew ) ; <nl> updateLabelPositions ( ) ; <nl> } <nl> } <nl> void CoverWidget : : handlePlaylistUpdate ( ) { <nl> createPrevNextButtons ( ) ; <nl> auto previousEnabled = ( index > 0 ) ; <nl> auto nextEnabled = ( index + 1 < playlist . size ( ) ) ; <nl> - _previousTrack - > setIcon ( previousEnabled ? nullptr : & st : : mediaPlayerPreviousDisabledIcon ) ; <nl> + _previousTrack - > setIcon ( previousEnabled ? nullptr : & st : : mediaPlayerPanelPreviousDisabledIcon ) ; <nl> _previousTrack - > setCursor ( previousEnabled ? style : : cur_pointer : style : : cur_default ) ; <nl> - _nextTrack - > setIcon ( nextEnabled ? nullptr : & st : : mediaPlayerNextDisabledIcon ) ; <nl> + _nextTrack - > setIcon ( nextEnabled ? nullptr : & st : : mediaPlayerPanelNextDisabledIcon ) ; <nl> _nextTrack - > setCursor ( nextEnabled ? style : : cur_pointer : style : : cur_default ) ; <nl> } <nl> } <nl> <nl> void CoverWidget : : createPrevNextButtons ( ) { <nl> if ( ! _previousTrack ) { <nl> - _previousTrack . create ( this , st : : mediaPlayerPreviousButton ) ; <nl> - _nextTrack . create ( this , st : : mediaPlayerNextButton ) ; <nl> + _previousTrack . create ( this , st : : mediaPlayerPanelPreviousButton ) ; <nl> + _nextTrack . create ( this , st : : mediaPlayerPanelNextButton ) ; <nl> _previousTrack - > setClickedCallback ( [ this ] ( ) { <nl> if ( exists ( ) ) { <nl> instance ( ) - > previous ( ) ; <nl> void CoverWidget : : destroyPrevNextButtons ( ) { <nl> } <nl> } <nl> <nl> + void CoverWidget : : updateVolumeToggleIcon ( ) { <nl> + auto icon = [ ] ( ) - > const style : : icon * { <nl> + auto volume = Global : : SongVolume ( ) ; <nl> + if ( volume > 0 ) { <nl> + if ( volume < 1 / 3 . ) { <nl> + return & st : : mediaPlayerVolumeIcon1 ; <nl> + } else if ( volume < 2 / 3 . ) { <nl> + return & st : : mediaPlayerVolumeIcon2 ; <nl> + } <nl> + return & st : : mediaPlayerVolumeIcon3 ; <nl> + } <nl> + return nullptr ; <nl> + } ; <nl> + _volumeToggle - > setIcon ( icon ( ) ) ; <nl> + } <nl> + <nl> } / / namespace Player <nl> } / / namespace Media <nl> mmm a / Telegram / SourceFiles / media / player / media_player_cover . h <nl> ppp b / Telegram / SourceFiles / media / player / media_player_cover . h <nl> class Playback ; <nl> <nl> namespace Player { <nl> <nl> - class PlaybackWidget ; <nl> class VolumeController ; <nl> struct UpdatedEvent ; <nl> <nl> class CoverWidget : public TWidget , private base : : Subscriber { <nl> public : <nl> CoverWidget ( QWidget * parent ) ; <nl> <nl> + using PinCallback = base : : lambda_unique < void ( ) > ; <nl> + void setPinCallback ( PinCallback & & callback ) ; <nl> + <nl> protected : <nl> void resizeEvent ( QResizeEvent * e ) override ; <nl> void paintEvent ( QPaintEvent * e ) override ; <nl> class CoverWidget : public TWidget , private base : : Subscriber { <nl> void createPrevNextButtons ( ) ; <nl> void destroyPrevNextButtons ( ) ; <nl> <nl> + void updateVolumeToggleIcon ( ) ; <nl> + <nl> void handleSongUpdate ( const UpdatedEvent & e ) ; <nl> void handleSongChange ( ) ; <nl> void handlePlaylistUpdate ( ) ; <nl> class CoverWidget : public TWidget , private base : : Subscriber { <nl> ChildWidget < Ui : : IconButton > _previousTrack = { nullptr } ; <nl> ChildWidget < PlayButton > _playPause ; <nl> ChildWidget < Ui : : IconButton > _nextTrack = { nullptr } ; <nl> + ChildWidget < Ui : : IconButton > _volumeToggle ; <nl> ChildWidget < VolumeController > _volumeController ; <nl> + ChildWidget < Ui : : IconButton > _pinPlayer ; <nl> ChildWidget < Ui : : IconButton > _repeatTrack ; <nl> <nl> } ; <nl> mmm a / Telegram / SourceFiles / media / player / media_player_instance . cpp <nl> ppp b / Telegram / SourceFiles / media / player / media_player_instance . cpp <nl> void Instance : : handleSongUpdate ( const AudioMsgId & audioId ) { <nl> void Instance : : setCurrent ( const AudioMsgId & audioId ) { <nl> if ( _current ! = audioId ) { <nl> _current = audioId ; <nl> + _isPlaying = false ; <nl> + <nl> auto history = _history , migrated = _migrated ; <nl> auto item = _current ? App : : histItemById ( _current . contextId ( ) ) : nullptr ; <nl> if ( item ) { <nl> void Instance : : emitUpdate ( CheckCallback check ) { <nl> next ( ) ; <nl> } <nl> } <nl> - _isPlaying = ! ( playbackState . state & AudioPlayerStoppedMask ) ; <nl> + auto isPlaying = ! ( playbackState . state & AudioPlayerStoppedMask ) ; <nl> + if ( _isPlaying ! = isPlaying ) { <nl> + _isPlaying = isPlaying ; <nl> + if ( _isPlaying ) { <nl> + preloadNext ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void Instance : : preloadNext ( ) { <nl> + if ( ! _current ) { <nl> + return ; <nl> + } <nl> + auto index = _playlist . indexOf ( _current . contextId ( ) ) ; <nl> + if ( index < 0 ) { <nl> + return ; <nl> + } <nl> + auto nextIndex = index + 1 ; <nl> + if ( nextIndex > = _playlist . size ( ) ) { <nl> + return ; <nl> + } <nl> + if ( auto item = App : : histItemById ( _playlist [ nextIndex ] ) ) { <nl> + if ( auto media = item - > getMedia ( ) ) { <nl> + if ( auto document = media - > getDocument ( ) ) { <nl> + if ( ! document - > loaded ( DocumentData : : FilePathResolveSaveFromDataSilent ) ) { <nl> + DocumentOpenClickHandler : : doOpen ( document , nullptr , ActionOnLoadNone ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> } <nl> <nl> } / / namespace Player <nl> mmm a / Telegram / SourceFiles / media / player / media_player_instance . h <nl> ppp b / Telegram / SourceFiles / media / player / media_player_instance . h <nl> bool exists ( ) ; <nl> class Instance ; <nl> Instance * instance ( ) ; <nl> <nl> - class Widget ; <nl> - struct CreatedEvent { <nl> - explicit CreatedEvent ( Widget * widget ) : widget ( widget ) { <nl> + class Panel ; <nl> + struct PanelEvent { <nl> + explicit PanelEvent ( Panel * panel ) : panel ( panel ) { <nl> } <nl> - Widget * widget ; <nl> + Panel * panel ; <nl> } ; <nl> struct UpdatedEvent { <nl> UpdatedEvent ( const AudioMsgId * audioId , const AudioPlaybackState * playbackState ) : audioId ( audioId ) , playbackState ( playbackState ) { <nl> class Instance : private base : : Subscriber { <nl> } <nl> void toggleRepeat ( ) { <nl> _repeatEnabled = ! _repeatEnabled ; <nl> + _repeatChangedNotifier . notify ( ) ; <nl> } <nl> <nl> bool isSeeking ( ) const { <nl> class Instance : private base : : Subscriber { <nl> return _playlist ; <nl> } <nl> <nl> - base : : Observable < CreatedEvent > & createdNotifier ( ) { <nl> + base : : Observable < PanelEvent > & createdNotifier ( ) { <nl> return _createdNotifier ; <nl> } <nl> + base : : Observable < PanelEvent > & destroyedNotifier ( ) { <nl> + return _destroyedNotifier ; <nl> + } <nl> base : : Observable < UpdatedEvent > & updatedNotifier ( ) { <nl> return _updatedNotifier ; <nl> } <nl> class Instance : private base : : Subscriber { <nl> base : : Observable < void > & songChangedNotifier ( ) { <nl> return _songChangedNotifier ; <nl> } <nl> + base : : Observable < void > & repeatChangedNotifier ( ) { <nl> + return _repeatChangedNotifier ; <nl> + } <nl> <nl> void documentLoadProgress ( DocumentData * document ) ; <nl> <nl> class Instance : private base : : Subscriber { <nl> void setCurrent ( const AudioMsgId & audioId ) ; <nl> void rebuildPlaylist ( ) ; <nl> void moveInPlaylist ( int delta ) ; <nl> + void preloadNext ( ) ; <nl> <nl> template < typename CheckCallback > <nl> void emitUpdate ( CheckCallback check ) ; <nl> class Instance : private base : : Subscriber { <nl> QList < FullMsgId > _playlist ; <nl> bool _isPlaying = false ; <nl> <nl> - base : : Observable < CreatedEvent > _createdNotifier ; <nl> + base : : Observable < PanelEvent > _createdNotifier ; <nl> + base : : Observable < PanelEvent > _destroyedNotifier ; <nl> base : : Observable < UpdatedEvent > _updatedNotifier ; <nl> base : : Observable < void > _playlistChangedNotifier ; <nl> base : : Observable < void > _songChangedNotifier ; <nl> + base : : Observable < void > _repeatChangedNotifier ; <nl> <nl> } ; <nl> <nl> new file mode 100644 <nl> index 00000000000 . . 0bbb247e142 <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / media / player / media_player_panel . cpp <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> + <nl> + Telegram Desktop is free software : you can redistribute it and / or modify <nl> + it under the terms of the GNU General Public License as published by <nl> + the Free Software Foundation , either version 3 of the License , or <nl> + ( at your option ) any later version . <nl> + <nl> + It is distributed in the hope that it will be useful , <nl> + but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + GNU General Public License for more details . <nl> + <nl> + In addition , as a special exception , the copyright holders give permission <nl> + to link the code of portions of this program with the OpenSSL library . <nl> + <nl> + Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> + Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> + * / <nl> + # include " stdafx . h " <nl> + # include " media / player / media_player_panel . h " <nl> + <nl> + # include " media / player / media_player_cover . h " <nl> + # include " media / player / media_player_list . h " <nl> + # include " media / player / media_player_instance . h " <nl> + # include " styles / style_media_player . h " <nl> + # include " mainwindow . h " <nl> + <nl> + namespace Media { <nl> + namespace Player { <nl> + <nl> + Panel : : Panel ( QWidget * parent , Layout layout ) : TWidget ( parent ) <nl> + , _shadow ( st : : defaultInnerDropdown . shadow ) { <nl> + if ( layout = = Layout : : Full ) { <nl> + _cover . create ( this ) ; <nl> + } <nl> + _hideTimer . setSingleShot ( true ) ; <nl> + connect ( & _hideTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( onHideStart ( ) ) ) ; <nl> + <nl> + _showTimer . setSingleShot ( true ) ; <nl> + connect ( & _showTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( onShowStart ( ) ) ) ; <nl> + <nl> + if ( _scroll ) { <nl> + connect ( _scroll , SIGNAL ( scrolled ( ) ) , this , SLOT ( onScroll ( ) ) ) ; <nl> + } <nl> + <nl> + if ( cPlatform ( ) = = dbipMac | | cPlatform ( ) = = dbipMacOld ) { <nl> + connect ( App : : wnd ( ) - > windowHandle ( ) , SIGNAL ( activeChanged ( ) ) , this , SLOT ( onWindowActiveChanged ( ) ) ) ; <nl> + } <nl> + <nl> + hide ( ) ; <nl> + resize ( contentLeft ( ) + st : : mediaPlayerPanelWidth , st : : mediaPlayerCoverHeight + st : : mediaPlayerPanelMarginBottom ) ; <nl> + } <nl> + <nl> + bool Panel : : overlaps ( const QRect & globalRect ) { <nl> + if ( isHidden ( ) | | _a_appearance . animating ( ) ) return false ; <nl> + <nl> + auto marginLeft = rtl ( ) ? 0 : contentLeft ( ) ; <nl> + auto marginRight = rtl ( ) ? contentLeft ( ) : 0 ; <nl> + return rect ( ) . marginsRemoved ( QMargins ( marginLeft , 0 , marginRight , st : : mediaPlayerPanelMarginBottom ) ) . contains ( QRect ( mapFromGlobal ( globalRect . topLeft ( ) ) , globalRect . size ( ) ) ) ; <nl> + } <nl> + <nl> + void Panel : : onWindowActiveChanged ( ) { <nl> + if ( ! App : : wnd ( ) - > windowHandle ( ) - > isActive ( ) & & ! isHidden ( ) ) { <nl> + leaveEvent ( nullptr ) ; <nl> + } <nl> + } <nl> + <nl> + void Panel : : resizeEvent ( QResizeEvent * e ) { <nl> + _cover - > resize ( width ( ) - contentLeft ( ) , st : : mediaPlayerCoverHeight ) ; <nl> + _cover - > moveToRight ( 0 , 0 ) ; <nl> + if ( _scroll ) { <nl> + _scroll - > resize ( width ( ) , height ( ) - _cover - > height ( ) ) ; <nl> + _scroll - > moveToRight ( 0 , _cover - > height ( ) ) ; <nl> + _list - > resizeToWidth ( width ( ) ) ; <nl> + } <nl> + / / _scroll - > setGeometry ( rect ( ) . marginsRemoved ( _st . padding ) . marginsRemoved ( _st . scrollMargin ) ) ; <nl> + / / if ( auto widget = static_cast < ScrolledWidget * > ( _scroll - > widget ( ) ) ) { <nl> + / / widget - > resizeToWidth ( _scroll - > width ( ) ) ; <nl> + / / onScroll ( ) ; <nl> + / / } <nl> + } <nl> + <nl> + void Panel : : onScroll ( ) { <nl> + / / if ( auto widget = static_cast < ScrolledWidget * > ( _scroll - > widget ( ) ) ) { <nl> + / / int visibleTop = _scroll - > scrollTop ( ) ; <nl> + / / int visibleBottom = visibleTop + _scroll - > height ( ) ; <nl> + / / widget - > setVisibleTopBottom ( visibleTop , visibleBottom ) ; <nl> + / / } <nl> + } <nl> + <nl> + void Panel : : paintEvent ( QPaintEvent * e ) { <nl> + Painter p ( this ) ; <nl> + <nl> + if ( ! _cache . isNull ( ) ) { <nl> + bool animating = _a_appearance . animating ( getms ( ) ) ; <nl> + if ( animating ) { <nl> + p . setOpacity ( _a_appearance . current ( _hiding ) ) ; <nl> + } else if ( _hiding ) { <nl> + hidingFinished ( ) ; <nl> + return ; <nl> + } <nl> + p . drawPixmap ( 0 , 0 , _cache ) ; <nl> + if ( ! animating ) { <nl> + showChildren ( ) ; <nl> + _cache = QPixmap ( ) ; <nl> + } <nl> + return ; <nl> + } <nl> + <nl> + / / draw shadow <nl> + auto shadowedRect = myrtlrect ( contentLeft ( ) , 0 , contentWidth ( ) , height ( ) - st : : mediaPlayerPanelMarginBottom ) ; <nl> + auto shadowedSides = ( rtl ( ) ? Ui : : RectShadow : : Side : : Right : Ui : : RectShadow : : Side : : Left ) | Ui : : RectShadow : : Side : : Bottom ; <nl> + _shadow . paint ( p , shadowedRect , st : : defaultInnerDropdown . shadowShift , shadowedSides ) ; <nl> + p . fillRect ( shadowedRect , st : : windowBg ) ; <nl> + } <nl> + <nl> + void Panel : : enterEvent ( QEvent * e ) { <nl> + _hideTimer . stop ( ) ; <nl> + if ( _a_appearance . animating ( getms ( ) ) ) { <nl> + onShowStart ( ) ; <nl> + } else { <nl> + _showTimer . start ( 0 ) ; <nl> + } <nl> + return TWidget : : enterEvent ( e ) ; <nl> + } <nl> + <nl> + void Panel : : leaveEvent ( QEvent * e ) { <nl> + _showTimer . stop ( ) ; <nl> + if ( _a_appearance . animating ( getms ( ) ) ) { <nl> + onHideStart ( ) ; <nl> + } else { <nl> + _hideTimer . start ( 300 ) ; <nl> + } <nl> + return TWidget : : leaveEvent ( e ) ; <nl> + } <nl> + <nl> + void Panel : : otherEnter ( ) { <nl> + _hideTimer . stop ( ) ; <nl> + if ( _a_appearance . animating ( getms ( ) ) ) { <nl> + onShowStart ( ) ; <nl> + } else { <nl> + _showTimer . start ( 300 ) ; <nl> + } <nl> + } <nl> + <nl> + void Panel : : otherLeave ( ) { <nl> + _showTimer . stop ( ) ; <nl> + if ( _a_appearance . animating ( getms ( ) ) ) { <nl> + onHideStart ( ) ; <nl> + } else { <nl> + _hideTimer . start ( 0 ) ; <nl> + } <nl> + } <nl> + <nl> + void Panel : : setPinCallback ( PinCallback & & callback ) { <nl> + if ( _cover ) { <nl> + _cover - > setPinCallback ( std_ : : move ( callback ) ) ; <nl> + } <nl> + } <nl> + <nl> + Panel : : ~ Panel ( ) { <nl> + if ( exists ( ) ) { <nl> + instance ( ) - > destroyedNotifier ( ) . notify ( Media : : Player : : PanelEvent ( this ) , true ) ; <nl> + } <nl> + } <nl> + <nl> + void Panel : : onShowStart ( ) { <nl> + if ( isHidden ( ) ) { <nl> + show ( ) ; <nl> + } else if ( ! _hiding ) { <nl> + return ; <nl> + } <nl> + _hiding = false ; <nl> + startAnimation ( ) ; <nl> + } <nl> + <nl> + void Panel : : onHideStart ( ) { <nl> + if ( _hiding ) return ; <nl> + <nl> + _hiding = true ; <nl> + startAnimation ( ) ; <nl> + } <nl> + <nl> + void Panel : : startAnimation ( ) { <nl> + auto from = _hiding ? 1 . : 0 . ; <nl> + auto to = _hiding ? 0 . : 1 . ; <nl> + if ( ! _a_appearance . animating ( ) ) { <nl> + showChildren ( ) ; <nl> + _cache = myGrab ( this ) ; <nl> + } <nl> + hideChildren ( ) ; <nl> + _a_appearance . start ( [ this ] { appearanceCallback ( ) ; } , from , to , st : : defaultInnerDropdown . duration ) ; <nl> + } <nl> + <nl> + void Panel : : appearanceCallback ( ) { <nl> + if ( ! _a_appearance . animating ( ) & & _hiding ) { <nl> + _hiding = false ; <nl> + hidingFinished ( ) ; <nl> + } else { <nl> + update ( ) ; <nl> + } <nl> + } <nl> + <nl> + void Panel : : hidingFinished ( ) { <nl> + hide ( ) ; <nl> + showChildren ( ) ; <nl> + } <nl> + <nl> + int Panel : : contentLeft ( ) const { <nl> + return st : : mediaPlayerPanelMarginLeft ; <nl> + } <nl> + <nl> + bool Panel : : eventFilter ( QObject * obj , QEvent * e ) { <nl> + if ( e - > type ( ) = = QEvent : : Enter ) { <nl> + otherEnter ( ) ; <nl> + } else if ( e - > type ( ) = = QEvent : : Leave ) { <nl> + otherLeave ( ) ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + } / / namespace Player <nl> + } / / namespace Media <nl> new file mode 100644 <nl> index 00000000000 . . 179a4a3ac1a <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / media / player / media_player_panel . h <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> + <nl> + Telegram Desktop is free software : you can redistribute it and / or modify <nl> + it under the terms of the GNU General Public License as published by <nl> + the Free Software Foundation , either version 3 of the License , or <nl> + ( at your option ) any later version . <nl> + <nl> + It is distributed in the hope that it will be useful , <nl> + but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + GNU General Public License for more details . <nl> + <nl> + In addition , as a special exception , the copyright holders give permission <nl> + to link the code of portions of this program with the OpenSSL library . <nl> + <nl> + Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> + Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> + * / <nl> + # pragma once <nl> + <nl> + # include " ui / effects / rect_shadow . h " <nl> + <nl> + class ScrollArea ; <nl> + <nl> + namespace Media { <nl> + namespace Player { <nl> + <nl> + class CoverWidget ; <nl> + class ListWidget ; <nl> + <nl> + class Panel : public TWidget , private base : : Subscriber { <nl> + Q_OBJECT <nl> + <nl> + public : <nl> + enum class Layout { <nl> + Full , <nl> + OnlyPlaylist , <nl> + } ; <nl> + Panel ( QWidget * parent , Layout layout ) ; <nl> + <nl> + void setLayout ( Layout layout ) ; <nl> + bool overlaps ( const QRect & globalRect ) ; <nl> + <nl> + void otherEnter ( ) ; <nl> + void otherLeave ( ) ; <nl> + <nl> + using PinCallback = base : : lambda_unique < void ( ) > ; <nl> + void setPinCallback ( PinCallback & & callback ) ; <nl> + <nl> + ~ Panel ( ) ; <nl> + <nl> + protected : <nl> + void resizeEvent ( QResizeEvent * e ) override ; <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + void enterEvent ( QEvent * e ) override ; <nl> + void leaveEvent ( QEvent * e ) override ; <nl> + <nl> + bool eventFilter ( QObject * obj , QEvent * e ) override ; <nl> + <nl> + private slots : <nl> + void onShowStart ( ) ; <nl> + void onHideStart ( ) ; <nl> + void onScroll ( ) ; <nl> + <nl> + void onWindowActiveChanged ( ) ; <nl> + <nl> + private : <nl> + void appearanceCallback ( ) ; <nl> + void hidingFinished ( ) ; <nl> + int contentLeft ( ) const ; <nl> + int contentWidth ( ) const { <nl> + return width ( ) - contentLeft ( ) ; <nl> + } <nl> + <nl> + void startAnimation ( ) ; <nl> + <nl> + bool _hiding = false ; <nl> + <nl> + QPixmap _cache ; <nl> + FloatAnimation _a_appearance ; <nl> + <nl> + QTimer _hideTimer , _showTimer ; <nl> + <nl> + Ui : : RectShadow _shadow ; <nl> + ChildWidget < CoverWidget > _cover = { nullptr } ; <nl> + ChildWidget < ListWidget > _list = { nullptr } ; <nl> + ChildWidget < ScrollArea > _scroll = { nullptr } ; <nl> + <nl> + } ; <nl> + <nl> + } / / namespace Clip <nl> + } / / namespace Media <nl> mmm a / Telegram / SourceFiles / media / player / media_player_volume_controller . cpp <nl> ppp b / Telegram / SourceFiles / media / player / media_player_volume_controller . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " ui / widgets / media_slider . h " <nl> # include " styles / style_media_player . h " <nl> # include " styles / style_widgets . h " <nl> + # include " mainwindow . h " <nl> <nl> namespace Media { <nl> namespace Player { <nl> <nl> VolumeController : : VolumeController ( QWidget * parent ) : TWidget ( parent ) <nl> - , _toggle ( this , st : : mediaPlayerVolumeToggle ) <nl> - , _slider ( this , st : : mediaPlayerPlayback ) { <nl> - _toggle - > setClickedCallback ( [ this ] ( ) { <nl> - setVolume ( _slider - > value ( ) ? 0 . : _rememberedVolume ) ; <nl> - } ) ; <nl> + , _slider ( this , st : : mediaPlayerPanelPlayback ) { <nl> _slider - > setChangeProgressCallback ( [ this ] ( float64 volume ) { <nl> applyVolumeChange ( volume ) ; <nl> } ) ; <nl> _slider - > setChangeFinishedCallback ( [ this ] ( float64 volume ) { <nl> if ( volume > 0 ) { <nl> - _rememberedVolume = volume ; <nl> + Global : : SetRememberedSongVolume ( volume ) ; <nl> } <nl> applyVolumeChange ( volume ) ; <nl> } ) ; <nl> + subscribe ( Global : : RefSongVolumeChanged ( ) , [ this ] { <nl> + if ( ! _slider - > isChanging ( ) ) { <nl> + _slider - > setValue ( Global : : SongVolume ( ) , true ) ; <nl> + } <nl> + } ) ; <nl> <nl> auto animated = false ; <nl> setVolume ( Global : : SongVolume ( ) , animated ) ; <nl> <nl> - resize ( st : : mediaPlayerVolumeWidth , 2 * st : : mediaPlayerPlaybackPadding + st : : mediaPlayerPlayback . width ) ; <nl> + resize ( st : : mediaPlayerPanelVolumeWidth , 2 * st : : mediaPlayerPanelPlaybackPadding + st : : mediaPlayerPanelPlayback . width ) ; <nl> + } <nl> + <nl> + void VolumeController : : setIsVertical ( bool vertical ) { <nl> + using Direction = Ui : : MediaSlider : : Direction ; <nl> + _slider - > setDirection ( vertical ? Direction : : Vertical : Direction : : Horizontal ) ; <nl> + _slider - > setAlwaysDisplayMarker ( vertical ) ; <nl> } <nl> <nl> void VolumeController : : resizeEvent ( QResizeEvent * e ) { <nl> - _slider - > resize ( st : : mediaPlayerVolumeLength , height ( ) ) ; <nl> - _slider - > moveToRight ( 0 , 0 ) ; <nl> - _toggle - > moveToLeft ( 0 , ( height ( ) - _toggle - > height ( ) ) / 2 ) ; <nl> + _slider - > setGeometry ( rect ( ) ) ; <nl> } <nl> <nl> void VolumeController : : setVolume ( float64 volume , bool animated ) { <nl> _slider - > setValue ( volume , animated ) ; <nl> if ( volume > 0 ) { <nl> - _rememberedVolume = volume ; <nl> + Global : : SetRememberedSongVolume ( volume ) ; <nl> } <nl> applyVolumeChange ( volume ) ; <nl> } <nl> <nl> void VolumeController : : applyVolumeChange ( float64 volume ) { <nl> - if ( volume > 0 ) { <nl> - if ( volume < 1 / 3 . ) { <nl> - _toggle - > setIcon ( & st : : mediaPlayerVolumeIcon1 ) ; <nl> - } else if ( volume < 2 / 3 . ) { <nl> - _toggle - > setIcon ( & st : : mediaPlayerVolumeIcon2 ) ; <nl> - } else { <nl> - _toggle - > setIcon ( & st : : mediaPlayerVolumeIcon3 ) ; <nl> - } <nl> - } else { <nl> - _toggle - > setIcon ( nullptr ) ; <nl> - } <nl> if ( volume ! = Global : : SongVolume ( ) ) { <nl> Global : : SetSongVolume ( volume ) ; <nl> - if ( auto player = audioPlayer ( ) ) { <nl> - emit player - > songVolumeChanged ( ) ; <nl> + Global : : RefSongVolumeChanged ( ) . notify ( ) ; <nl> + } <nl> + } <nl> + <nl> + VolumeWidget : : VolumeWidget ( QWidget * parent ) : TWidget ( parent ) <nl> + , _shadow ( st : : defaultInnerDropdown . shadow ) <nl> + , _controller ( this ) { <nl> + hide ( ) ; <nl> + _controller - > setIsVertical ( true ) ; <nl> + <nl> + _hideTimer . setSingleShot ( true ) ; <nl> + connect ( & _hideTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( onHideStart ( ) ) ) ; <nl> + <nl> + _showTimer . setSingleShot ( true ) ; <nl> + connect ( & _showTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( onShowStart ( ) ) ) ; <nl> + <nl> + if ( cPlatform ( ) = = dbipMac | | cPlatform ( ) = = dbipMacOld ) { <nl> + connect ( App : : wnd ( ) - > windowHandle ( ) , SIGNAL ( activeChanged ( ) ) , this , SLOT ( onWindowActiveChanged ( ) ) ) ; <nl> + } <nl> + <nl> + hide ( ) ; <nl> + auto margin = getMargin ( ) ; <nl> + resize ( margin . left ( ) + st : : mediaPlayerVolumeSize . width ( ) + margin . right ( ) , margin . top ( ) + st : : mediaPlayerVolumeSize . height ( ) + margin . bottom ( ) ) ; <nl> + } <nl> + <nl> + QMargins VolumeWidget : : getMargin ( ) const { <nl> + return QMargins ( st : : mediaPlayerVolumeMargin , st : : mediaPlayerPlayback . fullWidth , st : : mediaPlayerVolumeMargin , st : : mediaPlayerVolumeMargin ) ; <nl> + } <nl> + <nl> + bool VolumeWidget : : overlaps ( const QRect & globalRect ) { <nl> + if ( isHidden ( ) | | _a_appearance . animating ( ) ) return false ; <nl> + <nl> + return rect ( ) . marginsRemoved ( getMargin ( ) ) . contains ( QRect ( mapFromGlobal ( globalRect . topLeft ( ) ) , globalRect . size ( ) ) ) ; <nl> + } <nl> + <nl> + void VolumeWidget : : onWindowActiveChanged ( ) { <nl> + if ( ! App : : wnd ( ) - > windowHandle ( ) - > isActive ( ) & & ! isHidden ( ) ) { <nl> + leaveEvent ( nullptr ) ; <nl> + } <nl> + } <nl> + <nl> + void VolumeWidget : : resizeEvent ( QResizeEvent * e ) { <nl> + auto inner = rect ( ) . marginsRemoved ( getMargin ( ) ) ; <nl> + _controller - > setGeometry ( inner . x ( ) , inner . y ( ) - st : : lineWidth , inner . width ( ) , inner . height ( ) + st : : lineWidth - ( ( st : : mediaPlayerVolumeSize . width ( ) - st : : mediaPlayerPanelPlayback . width ) / 2 ) ) ; <nl> + } <nl> + <nl> + void VolumeWidget : : paintEvent ( QPaintEvent * e ) { <nl> + Painter p ( this ) ; <nl> + <nl> + if ( ! _cache . isNull ( ) ) { <nl> + bool animating = _a_appearance . animating ( getms ( ) ) ; <nl> + if ( animating ) { <nl> + p . setOpacity ( _a_appearance . current ( _hiding ) ) ; <nl> + } else if ( _hiding ) { <nl> + hidingFinished ( ) ; <nl> + return ; <nl> + } <nl> + p . drawPixmap ( 0 , 0 , _cache ) ; <nl> + if ( ! animating ) { <nl> + showChildren ( ) ; <nl> + _cache = QPixmap ( ) ; <nl> } <nl> + return ; <nl> + } <nl> + <nl> + / / draw shadow <nl> + auto shadowedRect = rect ( ) . marginsRemoved ( getMargin ( ) ) ; <nl> + using ShadowSide = Ui : : RectShadow : : Side ; <nl> + auto shadowedSides = ShadowSide : : Left | ShadowSide : : Right | ShadowSide : : Bottom ; <nl> + _shadow . paint ( p , shadowedRect , st : : defaultInnerDropdown . shadowShift , shadowedSides ) ; <nl> + p . fillRect ( shadowedRect . x ( ) , 0 , shadowedRect . width ( ) , shadowedRect . y ( ) + shadowedRect . height ( ) , st : : windowBg ) ; <nl> + } <nl> + <nl> + void VolumeWidget : : enterEvent ( QEvent * e ) { <nl> + _hideTimer . stop ( ) ; <nl> + if ( _a_appearance . animating ( getms ( ) ) ) { <nl> + onShowStart ( ) ; <nl> + } else { <nl> + _showTimer . start ( 0 ) ; <nl> + } <nl> + return TWidget : : enterEvent ( e ) ; <nl> + } <nl> + <nl> + void VolumeWidget : : leaveEvent ( QEvent * e ) { <nl> + _showTimer . stop ( ) ; <nl> + if ( _a_appearance . animating ( getms ( ) ) ) { <nl> + onHideStart ( ) ; <nl> + } else { <nl> + _hideTimer . start ( 300 ) ; <nl> + } <nl> + return TWidget : : leaveEvent ( e ) ; <nl> + } <nl> + <nl> + void VolumeWidget : : otherEnter ( ) { <nl> + _hideTimer . stop ( ) ; <nl> + if ( _a_appearance . animating ( getms ( ) ) ) { <nl> + onShowStart ( ) ; <nl> + } else { <nl> + _showTimer . start ( 0 ) ; <nl> + } <nl> + } <nl> + <nl> + void VolumeWidget : : otherLeave ( ) { <nl> + _showTimer . stop ( ) ; <nl> + if ( _a_appearance . animating ( getms ( ) ) ) { <nl> + onHideStart ( ) ; <nl> + } else { <nl> + _hideTimer . start ( 0 ) ; <nl> + } <nl> + } <nl> + <nl> + void VolumeWidget : : onShowStart ( ) { <nl> + if ( isHidden ( ) ) { <nl> + show ( ) ; <nl> + } else if ( ! _hiding ) { <nl> + return ; <nl> + } <nl> + _hiding = false ; <nl> + startAnimation ( ) ; <nl> + } <nl> + <nl> + void VolumeWidget : : onHideStart ( ) { <nl> + if ( _hiding ) return ; <nl> + <nl> + _hiding = true ; <nl> + startAnimation ( ) ; <nl> + } <nl> + <nl> + void VolumeWidget : : startAnimation ( ) { <nl> + auto from = _hiding ? 1 . : 0 . ; <nl> + auto to = _hiding ? 0 . : 1 . ; <nl> + if ( _cache . isNull ( ) ) { <nl> + showChildren ( ) ; <nl> + _cache = myGrab ( this ) ; <nl> + } <nl> + hideChildren ( ) ; <nl> + _a_appearance . start ( [ this ] { appearanceCallback ( ) ; } , from , to , st : : defaultInnerDropdown . duration ) ; <nl> + } <nl> + <nl> + void VolumeWidget : : appearanceCallback ( ) { <nl> + if ( ! _a_appearance . animating ( ) & & _hiding ) { <nl> + _hiding = false ; <nl> + hidingFinished ( ) ; <nl> + } else { <nl> + update ( ) ; <nl> + } <nl> + } <nl> + <nl> + void VolumeWidget : : hidingFinished ( ) { <nl> + hide ( ) ; <nl> + showChildren ( ) ; <nl> + _cache = QPixmap ( ) ; <nl> + } <nl> + <nl> + bool VolumeWidget : : eventFilter ( QObject * obj , QEvent * e ) { <nl> + if ( e - > type ( ) = = QEvent : : Enter ) { <nl> + otherEnter ( ) ; <nl> + } else if ( e - > type ( ) = = QEvent : : Leave ) { <nl> + otherLeave ( ) ; <nl> } <nl> + return false ; <nl> } <nl> <nl> } / / namespace Player <nl> mmm a / Telegram / SourceFiles / media / player / media_player_volume_controller . h <nl> ppp b / Telegram / SourceFiles / media / player / media_player_volume_controller . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> * / <nl> # pragma once <nl> <nl> + # include " ui / effects / rect_shadow . h " <nl> + <nl> namespace Ui { <nl> class IconButton ; <nl> class MediaSlider ; <nl> + class RectShadow ; <nl> } / / namespace Ui <nl> <nl> namespace Media { <nl> namespace Player { <nl> <nl> - class VolumeController : public TWidget { <nl> + class VolumeController : public TWidget , private base : : Subscriber { <nl> public : <nl> VolumeController ( QWidget * parent ) ; <nl> <nl> + void setIsVertical ( bool vertical ) ; <nl> + <nl> protected : <nl> void resizeEvent ( QResizeEvent * e ) override ; <nl> <nl> class VolumeController : public TWidget { <nl> void setVolume ( float64 volume , bool animated = true ) ; <nl> void applyVolumeChange ( float64 volume ) ; <nl> <nl> - ChildWidget < Ui : : IconButton > _toggle ; <nl> ChildWidget < Ui : : MediaSlider > _slider ; <nl> - float64 _rememberedVolume = Global : : kDefaultVolume ; <nl> + <nl> + } ; <nl> + <nl> + class VolumeWidget : public TWidget { <nl> + Q_OBJECT <nl> + <nl> + public : <nl> + VolumeWidget ( QWidget * parent ) ; <nl> + <nl> + bool overlaps ( const QRect & globalRect ) ; <nl> + <nl> + void otherEnter ( ) ; <nl> + void otherLeave ( ) ; <nl> + <nl> + QMargins getMargin ( ) const ; <nl> + <nl> + protected : <nl> + void resizeEvent ( QResizeEvent * e ) override ; <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + void enterEvent ( QEvent * e ) override ; <nl> + void leaveEvent ( QEvent * e ) override ; <nl> + <nl> + bool eventFilter ( QObject * obj , QEvent * e ) override ; <nl> + <nl> + private slots : <nl> + void onShowStart ( ) ; <nl> + void onHideStart ( ) ; <nl> + void onWindowActiveChanged ( ) ; <nl> + <nl> + private : <nl> + void appearanceCallback ( ) ; <nl> + void hidingFinished ( ) ; <nl> + void startAnimation ( ) ; <nl> + <nl> + bool _hiding = false ; <nl> + <nl> + QPixmap _cache ; <nl> + FloatAnimation _a_appearance ; <nl> + <nl> + QTimer _hideTimer , _showTimer ; <nl> + <nl> + Ui : : RectShadow _shadow ; <nl> + ChildWidget < VolumeController > _controller ; <nl> <nl> } ; <nl> <nl> mmm a / Telegram / SourceFiles / media / player / media_player_widget . cpp <nl> ppp b / Telegram / SourceFiles / media / player / media_player_widget . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " stdafx . h " <nl> # include " media / player / media_player_widget . h " <nl> <nl> - # include " media / player / media_player_cover . h " <nl> - # include " media / player / media_player_list . h " <nl> + # include " ui / flatlabel . h " <nl> + # include " ui / widgets / label_simple . h " <nl> + # include " ui / widgets / filled_slider . h " <nl> + # include " ui / widgets / shadow . h " <nl> + # include " ui / buttons / icon_button . h " <nl> + # include " media / media_audio . h " <nl> + # include " media / view / media_clip_playback . h " <nl> + # include " media / player / media_player_button . h " <nl> + # include " media / player / media_player_instance . h " <nl> + # include " media / player / media_player_volume_controller . h " <nl> # include " styles / style_media_player . h " <nl> - # include " mainwindow . h " <nl> + # include " styles / style_mediaview . h " <nl> <nl> namespace Media { <nl> namespace Player { <nl> <nl> - Widget : : Widget ( QWidget * parent ) : TWidget ( parent ) <nl> - , _shadow ( st : : defaultInnerDropdown . shadow ) <nl> - , _cover ( this ) { <nl> - _hideTimer . setSingleShot ( true ) ; <nl> - connect ( & _hideTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( onHideStart ( ) ) ) ; <nl> + using State = PlayButtonLayout : : State ; <nl> <nl> - _showTimer . setSingleShot ( true ) ; <nl> - connect ( & _showTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( onShowStart ( ) ) ) ; <nl> + class Widget : : PlayButton : public Button { <nl> + public : <nl> + PlayButton ( QWidget * parent ) ; <nl> <nl> - if ( _scroll ) { <nl> - connect ( _scroll , SIGNAL ( scrolled ( ) ) , this , SLOT ( onScroll ( ) ) ) ; <nl> + void setState ( PlayButtonLayout : : State state ) { <nl> + _layout . setState ( state ) ; <nl> } <nl> - <nl> - if ( cPlatform ( ) = = dbipMac | | cPlatform ( ) = = dbipMacOld ) { <nl> - connect ( App : : wnd ( ) - > windowHandle ( ) , SIGNAL ( activeChanged ( ) ) , this , SLOT ( onWindowActiveChanged ( ) ) ) ; <nl> + void finishTransform ( ) { <nl> + _layout . finishTransform ( ) ; <nl> } <nl> <nl> - hide ( ) ; <nl> - resize ( contentLeft ( ) + st : : mediaPlayerWidth , st : : mediaPlayerCoverHeight + st : : mediaPlayerMarginBottom ) ; <nl> + protected : <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + <nl> + private : <nl> + PlayButtonLayout _layout ; <nl> + <nl> + } ; <nl> + <nl> + Widget : : PlayButton : : PlayButton ( QWidget * parent ) : Button ( parent ) <nl> + , _layout ( st : : mediaPlayerButton , [ this ] { update ( ) ; } ) { <nl> + resize ( st : : mediaPlayerButtonSize ) ; <nl> + setCursor ( style : : cur_pointer ) ; <nl> } <nl> <nl> - bool Widget : : overlaps ( const QRect & globalRect ) { <nl> - if ( isHidden ( ) | | _a_appearance . animating ( ) ) return false ; <nl> + void Widget : : PlayButton : : paintEvent ( QPaintEvent * e ) { <nl> + Painter p ( this ) ; <nl> <nl> - auto marginLeft = rtl ( ) ? 0 : contentLeft ( ) ; <nl> - auto marginRight = rtl ( ) ? contentLeft ( ) : 0 ; <nl> - return rect ( ) . marginsRemoved ( QMargins ( marginLeft , 0 , marginRight , st : : mediaPlayerMarginBottom ) ) . contains ( QRect ( mapFromGlobal ( globalRect . topLeft ( ) ) , globalRect . size ( ) ) ) ; <nl> + p . translate ( st : : mediaPlayerButtonPosition . x ( ) , st : : mediaPlayerButtonPosition . y ( ) ) ; <nl> + _layout . paint ( p , st : : mediaPlayerActiveFg ) ; <nl> } <nl> <nl> - void Widget : : onWindowActiveChanged ( ) { <nl> - if ( ! App : : wnd ( ) - > windowHandle ( ) - > isActive ( ) & & ! isHidden ( ) ) { <nl> - leaveEvent ( nullptr ) ; <nl> + Widget : : Widget ( QWidget * parent ) : TWidget ( parent ) <nl> + , _nameLabel ( this , st : : mediaPlayerName ) <nl> + , _timeLabel ( this , st : : mediaPlayerTime ) <nl> + , _playPause ( this ) <nl> + , _volumeToggle ( this , st : : mediaPlayerVolumeToggle ) <nl> + , _repeatTrack ( this , st : : mediaPlayerRepeatButton ) <nl> + , _close ( this , st : : mediaPlayerClose ) <nl> + , _shadow ( this , st : : shadowColor ) <nl> + , _playback ( new Ui : : FilledSlider ( this , st : : mediaPlayerPlayback ) ) { <nl> + setAttribute ( Qt : : WA_OpaquePaintEvent ) ; <nl> + resize ( st : : wndMinWidth , st : : mediaPlayerHeight + st : : lineWidth ) ; <nl> + <nl> + _playback - > setChangeProgressCallback ( [ this ] ( float64 value ) { <nl> + handleSeekProgress ( value ) ; <nl> + } ) ; <nl> + _playback - > setChangeFinishedCallback ( [ this ] ( float64 value ) { <nl> + handleSeekFinished ( value ) ; <nl> + } ) ; <nl> + _playPause - > setClickedCallback ( [ this ] { <nl> + if ( exists ( ) ) { <nl> + instance ( ) - > playPauseCancelClicked ( ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + updateVolumeToggleIcon ( ) ; <nl> + _volumeToggle - > setClickedCallback ( [ this ] { <nl> + Global : : SetSongVolume ( ( Global : : SongVolume ( ) > 0 ) ? 0 . : Global : : RememberedSongVolume ( ) ) ; <nl> + Global : : RefSongVolumeChanged ( ) . notify ( ) ; <nl> + } ) ; <nl> + subscribe ( Global : : RefSongVolumeChanged ( ) , [ this ] { updateVolumeToggleIcon ( ) ; } ) ; <nl> + <nl> + updateRepeatTrackIcon ( ) ; <nl> + _repeatTrack - > setClickedCallback ( [ this ] { <nl> + instance ( ) - > toggleRepeat ( ) ; <nl> + } ) ; <nl> + <nl> + if ( exists ( ) ) { <nl> + subscribe ( instance ( ) - > repeatChangedNotifier ( ) , [ this ] { <nl> + updateRepeatTrackIcon ( ) ; <nl> + } ) ; <nl> + subscribe ( instance ( ) - > playlistChangedNotifier ( ) , [ this ] { <nl> + handlePlaylistUpdate ( ) ; <nl> + } ) ; <nl> + subscribe ( instance ( ) - > updatedNotifier ( ) , [ this ] ( const UpdatedEvent & e ) { <nl> + handleSongUpdate ( e ) ; <nl> + } ) ; <nl> + subscribe ( instance ( ) - > songChangedNotifier ( ) , [ this ] { <nl> + handleSongChange ( ) ; <nl> + } ) ; <nl> + handleSongChange ( ) ; <nl> + if ( auto player = audioPlayer ( ) ) { <nl> + AudioMsgId playing ; <nl> + auto playbackState = player - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> + handleSongUpdate ( UpdatedEvent ( & playing , & playbackState ) ) ; <nl> + _playPause - > finishTransform ( ) ; <nl> + } <nl> } <nl> } <nl> <nl> - void Widget : : resizeEvent ( QResizeEvent * e ) { <nl> - _cover - > resize ( width ( ) - contentLeft ( ) , st : : mediaPlayerCoverHeight ) ; <nl> - _cover - > moveToRight ( 0 , 0 ) ; <nl> - if ( _scroll ) { <nl> - _scroll - > resize ( width ( ) , height ( ) - _cover - > height ( ) ) ; <nl> - _scroll - > moveToRight ( 0 , _cover - > height ( ) ) ; <nl> - _list - > resizeToWidth ( width ( ) ) ; <nl> - } <nl> - / / _scroll - > setGeometry ( rect ( ) . marginsRemoved ( _st . padding ) . marginsRemoved ( _st . scrollMargin ) ) ; <nl> - / / if ( auto widget = static_cast < ScrolledWidget * > ( _scroll - > widget ( ) ) ) { <nl> - / / widget - > resizeToWidth ( _scroll - > width ( ) ) ; <nl> - / / onScroll ( ) ; <nl> - / / } <nl> + void Widget : : updateVolumeToggleIcon ( ) { <nl> + auto icon = [ ] ( ) - > const style : : icon * { <nl> + auto volume = Global : : SongVolume ( ) ; <nl> + if ( volume > 0 ) { <nl> + if ( volume < 1 / 3 . ) { <nl> + return & st : : mediaPlayerVolumeIcon1 ; <nl> + } else if ( volume < 2 / 3 . ) { <nl> + return & st : : mediaPlayerVolumeIcon2 ; <nl> + } <nl> + return & st : : mediaPlayerVolumeIcon3 ; <nl> + } <nl> + return nullptr ; <nl> + } ; <nl> + _volumeToggle - > setIcon ( icon ( ) ) ; <nl> } <nl> <nl> - void Widget : : onScroll ( ) { <nl> - / / if ( auto widget = static_cast < ScrolledWidget * > ( _scroll - > widget ( ) ) ) { <nl> - / / int visibleTop = _scroll - > scrollTop ( ) ; <nl> - / / int visibleBottom = visibleTop + _scroll - > height ( ) ; <nl> - / / widget - > setVisibleTopBottom ( visibleTop , visibleBottom ) ; <nl> - / / } <nl> + void Widget : : setCloseCallback ( CloseCallback & & callback ) { <nl> + _close - > setClickedCallback ( std_ : : move ( callback ) ) ; <nl> } <nl> <nl> - void Widget : : paintEvent ( QPaintEvent * e ) { <nl> - Painter p ( this ) ; <nl> + void Widget : : setShadowGeometryToLeft ( int x , int y , int w , int h ) { <nl> + _shadow - > setGeometryToLeft ( x , y , w , h ) ; <nl> + } <nl> <nl> - if ( ! _cache . isNull ( ) ) { <nl> - bool animating = _a_appearance . animating ( getms ( ) ) ; <nl> - if ( animating ) { <nl> - p . setOpacity ( _a_appearance . current ( _hiding ) ) ; <nl> - } else if ( _hiding ) { <nl> - hidingFinished ( ) ; <nl> - return ; <nl> - } <nl> - p . drawPixmap ( 0 , 0 , _cache ) ; <nl> - if ( ! animating ) { <nl> - showChildren ( ) ; <nl> - _cache = QPixmap ( ) ; <nl> + void Widget : : showShadow ( ) { <nl> + _shadow - > show ( ) ; <nl> + _playback - > show ( ) ; <nl> + } <nl> + <nl> + void Widget : : hideShadow ( ) { <nl> + _shadow - > hide ( ) ; <nl> + _playback - > hide ( ) ; <nl> + } <nl> + <nl> + QPoint Widget : : getPositionForVolumeWidget ( ) const { <nl> + auto x = _volumeToggle - > x ( ) ; <nl> + x + = ( _volumeToggle - > width ( ) - st : : mediaPlayerVolumeSize . width ( ) ) / 2 ; <nl> + if ( rtl ( ) ) x = width ( ) - x - st : : mediaPlayerVolumeSize . width ( ) ; <nl> + return QPoint ( x , height ( ) ) ; <nl> + } <nl> + <nl> + void Widget : : volumeWidgetCreated ( VolumeWidget * widget ) { <nl> + _volumeToggle - > installEventFilter ( widget ) ; <nl> + } <nl> + <nl> + void Widget : : handleSeekProgress ( float64 progress ) { <nl> + if ( ! _lastDurationMs ) return ; <nl> + <nl> + auto positionMs = snap ( static_cast < int64 > ( progress * _lastDurationMs ) , 0LL , _lastDurationMs ) ; <nl> + if ( _seekPositionMs ! = positionMs ) { <nl> + _seekPositionMs = positionMs ; <nl> + updateTimeLabel ( ) ; <nl> + if ( exists ( ) ) { <nl> + instance ( ) - > startSeeking ( ) ; <nl> } <nl> - return ; <nl> } <nl> - <nl> - / / draw shadow <nl> - auto shadowedRect = myrtlrect ( contentLeft ( ) , 0 , contentWidth ( ) , height ( ) - st : : mediaPlayerMarginBottom ) ; <nl> - auto shadowedSides = ( rtl ( ) ? Ui : : RectShadow : : Side : : Right : Ui : : RectShadow : : Side : : Left ) | Ui : : RectShadow : : Side : : Bottom ; <nl> - _shadow . paint ( p , shadowedRect , st : : defaultInnerDropdown . shadowShift , shadowedSides ) ; <nl> - p . fillRect ( shadowedRect , st : : windowBg ) ; <nl> } <nl> <nl> - void Widget : : enterEvent ( QEvent * e ) { <nl> - _hideTimer . stop ( ) ; <nl> - if ( _a_appearance . animating ( getms ( ) ) ) { <nl> - onShowStart ( ) ; <nl> - } else { <nl> - _showTimer . start ( 0 ) ; <nl> + void Widget : : handleSeekFinished ( float64 progress ) { <nl> + if ( ! _lastDurationMs ) return ; <nl> + <nl> + auto positionMs = snap ( static_cast < int64 > ( progress * _lastDurationMs ) , 0LL , _lastDurationMs ) ; <nl> + _seekPositionMs = - 1 ; <nl> + <nl> + AudioMsgId playing ; <nl> + auto playbackState = audioPlayer ( ) - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> + if ( playing & & playbackState . duration ) { <nl> + audioPlayer ( ) - > seek ( qRound ( progress * playbackState . duration ) ) ; <nl> + } <nl> + <nl> + if ( exists ( ) ) { <nl> + instance ( ) - > stopSeeking ( ) ; <nl> } <nl> - return TWidget : : enterEvent ( e ) ; <nl> } <nl> <nl> - void Widget : : leaveEvent ( QEvent * e ) { <nl> - _showTimer . stop ( ) ; <nl> - if ( _a_appearance . animating ( getms ( ) ) ) { <nl> - onHideStart ( ) ; <nl> - } else { <nl> - _hideTimer . start ( 300 ) ; <nl> + void Widget : : resizeEvent ( QResizeEvent * e ) { <nl> + updatePlayPrevNextPositions ( ) ; <nl> + <nl> + auto right = st : : mediaPlayerCloseRight ; <nl> + _close - > moveToRight ( right , st : : mediaPlayerPlayTop ) ; right + = _close - > width ( ) ; <nl> + _repeatTrack - > moveToRight ( right , st : : mediaPlayerPlayTop ) ; right + = _repeatTrack - > width ( ) ; <nl> + _volumeToggle - > moveToRight ( right , st : : mediaPlayerPlayTop ) ; right + = _volumeToggle - > width ( ) ; <nl> + <nl> + updateLabelsGeometry ( ) ; <nl> + <nl> + _playback - > setGeometry ( 0 , height ( ) - st : : mediaPlayerPlayback . fullWidth , width ( ) , st : : mediaPlayerPlayback . fullWidth ) ; <nl> + } <nl> + <nl> + void Widget : : paintEvent ( QPaintEvent * e ) { <nl> + Painter p ( this ) ; <nl> + auto fill = e - > rect ( ) . intersected ( QRect ( 0 , 0 , width ( ) , st : : mediaPlayerHeight ) ) ; <nl> + if ( ! fill . isEmpty ( ) ) { <nl> + p . fillRect ( fill , st : : windowBg ) ; <nl> } <nl> - return TWidget : : leaveEvent ( e ) ; <nl> } <nl> <nl> - void Widget : : otherEnter ( ) { <nl> - _hideTimer . stop ( ) ; <nl> - if ( _a_appearance . animating ( getms ( ) ) ) { <nl> - onShowStart ( ) ; <nl> + void Widget : : updatePlayPrevNextPositions ( ) { <nl> + auto left = st : : mediaPlayerPlayLeft ; <nl> + auto top = st : : mediaPlayerPlayTop ; <nl> + if ( _previousTrack ) { <nl> + _previousTrack - > moveToLeft ( left , top ) ; left + = _previousTrack - > width ( ) + st : : mediaPlayerPlaySkip ; <nl> + _playPause - > moveToLeft ( left , top ) ; left + = _playPause - > width ( ) + st : : mediaPlayerPlaySkip ; <nl> + _nextTrack - > moveToLeft ( left , top ) ; <nl> } else { <nl> - _showTimer . start ( 300 ) ; <nl> + _playPause - > moveToLeft ( left , top ) ; <nl> } <nl> } <nl> <nl> - void Widget : : otherLeave ( ) { <nl> - _showTimer . stop ( ) ; <nl> - if ( _a_appearance . animating ( getms ( ) ) ) { <nl> - onHideStart ( ) ; <nl> - } else { <nl> - _hideTimer . start ( 0 ) ; <nl> + void Widget : : updateLabelsGeometry ( ) { <nl> + auto left = st : : mediaPlayerPlayLeft + _playPause - > width ( ) ; <nl> + if ( _previousTrack ) { <nl> + left + = _previousTrack - > width ( ) + st : : mediaPlayerPlaySkip + _nextTrack - > width ( ) + st : : mediaPlayerPlaySkip ; <nl> } <nl> + left + = st : : mediaPlayerPadding ; <nl> + <nl> + auto right = st : : mediaPlayerCloseRight + _close - > width ( ) + _repeatTrack - > width ( ) + _volumeToggle - > width ( ) ; <nl> + right + = st : : mediaPlayerPadding ; <nl> + <nl> + auto widthForName = width ( ) - left - right ; <nl> + widthForName - = _timeLabel - > width ( ) + 2 * st : : normalFont - > spacew ; <nl> + _nameLabel - > resizeToWidth ( widthForName ) ; <nl> + <nl> + _nameLabel - > moveToLeft ( left , st : : mediaPlayerNameTop - st : : mediaPlayerName . font - > ascent ) ; <nl> + _timeLabel - > moveToRight ( right , st : : mediaPlayerNameTop - st : : mediaPlayerTime . font - > ascent ) ; <nl> + } <nl> + <nl> + void Widget : : updateRepeatTrackIcon ( ) { <nl> + _repeatTrack - > setIcon ( instance ( ) - > repeatEnabled ( ) ? nullptr : & st : : mediaPlayerRepeatDisabledIcon ) ; <nl> } <nl> <nl> - void Widget : : onShowStart ( ) { <nl> - if ( isHidden ( ) ) { <nl> - show ( ) ; <nl> - } else if ( ! _hiding ) { <nl> + void Widget : : handleSongUpdate ( const UpdatedEvent & e ) { <nl> + auto & audioId = * e . audioId ; <nl> + auto & playbackState = * e . playbackState ; <nl> + if ( ! audioId | | ! audioId . audio ( ) - > song ( ) ) { <nl> return ; <nl> } <nl> - _hiding = false ; <nl> - startAnimation ( ) ; <nl> + <nl> + _playback - > updateState ( * e . playbackState ) ; <nl> + <nl> + auto stopped = ( ( playbackState . state & AudioPlayerStoppedMask ) | | playbackState . state = = AudioPlayerFinishing ) ; <nl> + auto showPause = ! stopped & & ( playbackState . state = = AudioPlayerPlaying | | playbackState . state = = AudioPlayerResuming | | playbackState . state = = AudioPlayerStarting ) ; <nl> + if ( exists ( ) & & instance ( ) - > isSeeking ( ) ) { <nl> + showPause = true ; <nl> + } <nl> + auto state = [ audio = audioId . audio ( ) , showPause ] { <nl> + if ( audio - > loading ( ) ) { <nl> + return State : : Cancel ; <nl> + } else if ( showPause ) { <nl> + return State : : Pause ; <nl> + } <nl> + return State : : Play ; <nl> + } ; <nl> + _playPause - > setState ( state ( ) ) ; <nl> + <nl> + updateTimeText ( audioId , playbackState ) ; <nl> } <nl> <nl> - void Widget : : onHideStart ( ) { <nl> - if ( _hiding ) return ; <nl> + void Widget : : updateTimeText ( const AudioMsgId & audioId , const AudioPlaybackState & playbackState ) { <nl> + QString time ; <nl> + qint64 position = 0 , duration = 0 , display = 0 ; <nl> + auto frequency = ( playbackState . frequency ? playbackState . frequency : AudioVoiceMsgFrequency ) ; <nl> + if ( ! ( playbackState . state & AudioPlayerStoppedMask ) & & playbackState . state ! = AudioPlayerFinishing ) { <nl> + display = position = playbackState . position ; <nl> + duration = playbackState . duration ; <nl> + } else { <nl> + display = playbackState . duration ? playbackState . duration : ( audioId . audio ( ) - > song ( ) - > duration * frequency ) ; <nl> + } <nl> + <nl> + _lastDurationMs = ( playbackState . duration * 1000LL ) / frequency ; <nl> <nl> - _hiding = true ; <nl> - startAnimation ( ) ; <nl> + if ( audioId . audio ( ) - > loading ( ) ) { <nl> + auto loaded = audioId . audio ( ) - > loadOffset ( ) ; <nl> + auto loadProgress = snap ( float64 ( loaded ) / qMax ( audioId . audio ( ) - > size , 1 ) , 0 . , 1 . ) ; <nl> + _time = QString : : number ( qRound ( loadProgress * 100 ) ) + ' % ' ; <nl> + _playback - > setDisabled ( true ) ; <nl> + } else { <nl> + display = display / frequency ; <nl> + _time = formatDurationText ( display ) ; <nl> + _playback - > setDisabled ( false ) ; <nl> + } <nl> + if ( _seekPositionMs < 0 ) { <nl> + updateTimeLabel ( ) ; <nl> + } <nl> } <nl> <nl> - void Widget : : startAnimation ( ) { <nl> - auto from = _hiding ? 1 . : 0 . ; <nl> - auto to = _hiding ? 0 . : 1 . ; <nl> - if ( ! _a_appearance . animating ( ) ) { <nl> - showChildren ( ) ; <nl> - _cache = myGrab ( this ) ; <nl> + void Widget : : updateTimeLabel ( ) { <nl> + auto timeLabelWidth = _timeLabel - > width ( ) ; <nl> + if ( _seekPositionMs > = 0 ) { <nl> + auto playAlready = _seekPositionMs / 1000LL ; <nl> + _timeLabel - > setText ( formatDurationText ( playAlready ) ) ; <nl> + } else { <nl> + _timeLabel - > setText ( _time ) ; <nl> } <nl> - hideChildren ( ) ; <nl> - _a_appearance . start ( [ this ] { <nl> - update ( ) ; <nl> + if ( timeLabelWidth ! = _timeLabel - > width ( ) ) { <nl> + updateLabelsGeometry ( ) ; <nl> + } <nl> + } <nl> <nl> - / / hack , animating ( ) call destroys lambda : ( <nl> - auto that = this ; <nl> - if ( ! _a_appearance . animating ( ) & & that - > _hiding ) { <nl> - that - > _hiding = false ; <nl> - that - > hidingFinished ( ) ; <nl> - } <nl> - } , from , to , st : : defaultInnerDropdown . duration ) ; <nl> + void Widget : : handleSongChange ( ) { <nl> + auto & current = instance ( ) - > current ( ) ; <nl> + auto song = current . audio ( ) - > song ( ) ; <nl> + <nl> + TextWithEntities textWithEntities ; <nl> + if ( song - > performer . isEmpty ( ) ) { <nl> + textWithEntities . text = song - > title . isEmpty ( ) ? ( current . audio ( ) - > name . isEmpty ( ) ? qsl ( " Unknown Track " ) : current . audio ( ) - > name ) : song - > title ; <nl> + } else { <nl> + auto title = song - > title . isEmpty ( ) ? qsl ( " Unknown Track " ) : textClean ( song - > title ) ; <nl> + textWithEntities . text = song - > performer + QString : : fromUtf8 ( " \ xe2 \ x80 \ x93 " ) + title ; <nl> + textWithEntities . entities . append ( { EntityInTextBold , 0 , song - > performer . size ( ) , QString ( ) } ) ; <nl> + } <nl> + _nameLabel - > setMarkedText ( textWithEntities ) ; <nl> + <nl> + handlePlaylistUpdate ( ) ; <nl> } <nl> <nl> - void Widget : : hidingFinished ( ) { <nl> - hide ( ) ; <nl> - showChildren ( ) ; <nl> + void Widget : : handlePlaylistUpdate ( ) { <nl> + auto & current = instance ( ) - > current ( ) ; <nl> + auto & playlist = instance ( ) - > playlist ( ) ; <nl> + auto index = playlist . indexOf ( current . contextId ( ) ) ; <nl> + if ( ! current | | index < 0 ) { <nl> + destroyPrevNextButtons ( ) ; <nl> + } else { <nl> + createPrevNextButtons ( ) ; <nl> + auto previousEnabled = ( index > 0 ) ; <nl> + auto nextEnabled = ( index + 1 < playlist . size ( ) ) ; <nl> + _previousTrack - > setIcon ( previousEnabled ? nullptr : & st : : mediaPlayerPreviousDisabledIcon ) ; <nl> + _previousTrack - > setCursor ( previousEnabled ? style : : cur_pointer : style : : cur_default ) ; <nl> + _nextTrack - > setIcon ( nextEnabled ? nullptr : & st : : mediaPlayerNextDisabledIcon ) ; <nl> + _nextTrack - > setCursor ( nextEnabled ? style : : cur_pointer : style : : cur_default ) ; <nl> + } <nl> } <nl> <nl> - int Widget : : contentLeft ( ) const { <nl> - return st : : mediaPlayerMarginLeft ; <nl> + void Widget : : createPrevNextButtons ( ) { <nl> + if ( ! _previousTrack ) { <nl> + _previousTrack . create ( this , st : : mediaPlayerPreviousButton ) ; <nl> + _nextTrack . create ( this , st : : mediaPlayerNextButton ) ; <nl> + _previousTrack - > setClickedCallback ( [ this ] ( ) { <nl> + if ( exists ( ) ) { <nl> + instance ( ) - > previous ( ) ; <nl> + } <nl> + } ) ; <nl> + _nextTrack - > setClickedCallback ( [ this ] ( ) { <nl> + if ( exists ( ) ) { <nl> + instance ( ) - > next ( ) ; <nl> + } <nl> + } ) ; <nl> + updatePlayPrevNextPositions ( ) ; <nl> + } <nl> } <nl> <nl> - bool Widget : : eventFilter ( QObject * obj , QEvent * e ) { <nl> - if ( e - > type ( ) = = QEvent : : Enter ) { <nl> - otherEnter ( ) ; <nl> - } else if ( e - > type ( ) = = QEvent : : Leave ) { <nl> - otherLeave ( ) ; <nl> + void Widget : : destroyPrevNextButtons ( ) { <nl> + if ( _previousTrack ) { <nl> + _previousTrack . destroy ( ) ; <nl> + _nextTrack . destroy ( ) ; <nl> + updatePlayPrevNextPositions ( ) ; <nl> } <nl> - return false ; <nl> } <nl> <nl> } / / namespace Player <nl> mmm a / Telegram / SourceFiles / media / player / media_player_widget . h <nl> ppp b / Telegram / SourceFiles / media / player / media_player_widget . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> * / <nl> # pragma once <nl> <nl> - # include " ui / effects / rect_shadow . h " <nl> + class AudioMsgId ; <nl> + struct AudioPlaybackState ; <nl> + class FlatLabel ; <nl> <nl> - class ScrollArea ; <nl> + namespace Ui { <nl> + class LabelSimple ; <nl> + class IconButton ; <nl> + class PlainShadow ; <nl> + } / / namespace Ui <nl> <nl> namespace Media { <nl> + namespace Clip { <nl> + class Playback ; <nl> + } / / namespace Clip <nl> + <nl> namespace Player { <nl> <nl> - class CoverWidget ; <nl> - class ListWidget ; <nl> + class PlayButton ; <nl> + class VolumeWidget ; <nl> + struct UpdatedEvent ; <nl> <nl> class Widget : public TWidget , private base : : Subscriber { <nl> - Q_OBJECT <nl> - <nl> public : <nl> Widget ( QWidget * parent ) ; <nl> <nl> - bool overlaps ( const QRect & globalRect ) ; <nl> + using CloseCallback = base : : lambda_unique < void ( ) > ; <nl> + void setCloseCallback ( CloseCallback & & callback ) ; <nl> + <nl> + void setShadowGeometryToLeft ( int x , int y , int w , int h ) ; <nl> + void showShadow ( ) ; <nl> + void hideShadow ( ) ; <nl> <nl> - void otherEnter ( ) ; <nl> - void otherLeave ( ) ; <nl> + QPoint getPositionForVolumeWidget ( ) const ; <nl> + void volumeWidgetCreated ( VolumeWidget * widget ) ; <nl> <nl> protected : <nl> void resizeEvent ( QResizeEvent * e ) override ; <nl> void paintEvent ( QPaintEvent * e ) override ; <nl> - void enterEvent ( QEvent * e ) override ; <nl> - void leaveEvent ( QEvent * e ) override ; <nl> - <nl> - bool eventFilter ( QObject * obj , QEvent * e ) override ; <nl> - <nl> - private slots : <nl> - void onShowStart ( ) ; <nl> - void onHideStart ( ) ; <nl> - void onScroll ( ) ; <nl> - <nl> - void onWindowActiveChanged ( ) ; <nl> <nl> private : <nl> - void hidingFinished ( ) ; <nl> - int contentLeft ( ) const ; <nl> - int contentWidth ( ) const { <nl> - return width ( ) - contentLeft ( ) ; <nl> - } <nl> - <nl> - void startAnimation ( ) ; <nl> - <nl> - bool _hiding = false ; <nl> - <nl> - QPixmap _cache ; <nl> - FloatAnimation _a_appearance ; <nl> - <nl> - QTimer _hideTimer , _showTimer ; <nl> - <nl> - Ui : : RectShadow _shadow ; <nl> - ChildWidget < CoverWidget > _cover ; <nl> - ChildWidget < ListWidget > _list = { nullptr } ; <nl> - ChildWidget < ScrollArea > _scroll = { nullptr } ; <nl> - <nl> + void handleSeekProgress ( float64 progress ) ; <nl> + void handleSeekFinished ( float64 progress ) ; <nl> + <nl> + void updatePlayPrevNextPositions ( ) ; <nl> + void updateLabelsGeometry ( ) ; <nl> + void updateRepeatTrackIcon ( ) ; <nl> + void createPrevNextButtons ( ) ; <nl> + void destroyPrevNextButtons ( ) ; <nl> + <nl> + void updateVolumeToggleIcon ( ) ; <nl> + <nl> + void handleSongUpdate ( const UpdatedEvent & e ) ; <nl> + void handleSongChange ( ) ; <nl> + void handlePlaylistUpdate ( ) ; <nl> + <nl> + void updateTimeText ( const AudioMsgId & audioId , const AudioPlaybackState & playbackState ) ; <nl> + void updateTimeLabel ( ) ; <nl> + <nl> + int64 _seekPositionMs = - 1 ; <nl> + int64 _lastDurationMs = 0 ; <nl> + QString _time ; <nl> + <nl> + class PlayButton ; <nl> + ChildWidget < FlatLabel > _nameLabel ; <nl> + ChildWidget < Ui : : LabelSimple > _timeLabel ; <nl> + ChildWidget < Ui : : IconButton > _previousTrack = { nullptr } ; <nl> + ChildWidget < PlayButton > _playPause ; <nl> + ChildWidget < Ui : : IconButton > _nextTrack = { nullptr } ; <nl> + ChildWidget < Ui : : IconButton > _volumeToggle ; <nl> + ChildWidget < Ui : : IconButton > _repeatTrack ; <nl> + ChildWidget < Ui : : IconButton > _close ; <nl> + ChildWidget < Ui : : PlainShadow > _shadow = { nullptr } ; <nl> + ChildWidget < Clip : : Playback > _playback ; <nl> <nl> } ; <nl> <nl> mmm a / Telegram / SourceFiles / media / view / media_clip_controller . cpp <nl> ppp b / Telegram / SourceFiles / media / view / media_clip_controller . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " media / view / media_clip_volume_controller . h " <nl> # include " styles / style_mediaview . h " <nl> # include " ui / widgets / label_simple . h " <nl> + # include " ui / widgets / media_slider . h " <nl> # include " ui / effects / fade_animation . h " <nl> # include " ui / buttons / icon_button . h " <nl> # include " media / media_audio . h " <nl> namespace Clip { <nl> <nl> Controller : : Controller ( QWidget * parent ) : TWidget ( parent ) <nl> , _playPauseResume ( this , st : : mediaviewPlayButton ) <nl> - , _playback ( this , st : : mediaviewPlayback ) <nl> + , _playback ( new Ui : : MediaSlider ( this , st : : mediaviewPlayback ) ) <nl> , _volumeController ( this ) <nl> , _fullScreenToggle ( this , st : : mediaviewFullScreenButton ) <nl> , _playedAlready ( this , st : : mediaviewPlayProgressLabel ) <nl> mmm a / Telegram / SourceFiles / media / view / media_clip_playback . cpp <nl> ppp b / Telegram / SourceFiles / media / view / media_clip_playback . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " media / view / media_clip_playback . h " <nl> <nl> # include " styles / style_mediaview . h " <nl> - # include " ui / widgets / media_slider . h " <nl> # include " media / media_audio . h " <nl> <nl> namespace Media { <nl> namespace Clip { <nl> <nl> - Playback : : Playback ( QWidget * parent , const style : : MediaSlider & st ) : _slider ( new Ui : : MediaSlider ( parent , st ) ) { <nl> + Playback : : Playback ( Ui : : ContinuousSlider * slider ) : _slider ( slider ) { <nl> } <nl> <nl> void Playback : : updateState ( const AudioPlaybackState & playbackState ) { <nl> mmm a / Telegram / SourceFiles / media / view / media_clip_playback . h <nl> ppp b / Telegram / SourceFiles / media / view / media_clip_playback . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> * / <nl> # pragma once <nl> <nl> - # include " ui / widgets / media_slider . h " <nl> + # include " ui / widgets / continuous_slider . h " <nl> <nl> struct AudioPlaybackState ; <nl> - namespace style { <nl> - struct MediaSlider ; <nl> - } / / namespace style <nl> - namespace Ui { <nl> - class MediaSlider ; <nl> - } / / namespace Ui <nl> <nl> namespace Media { <nl> namespace Clip { <nl> <nl> class Playback { <nl> public : <nl> - Playback ( QWidget * parent , const style : : MediaSlider & st ) ; <nl> + Playback ( Ui : : ContinuousSlider * slider ) ; <nl> <nl> void updateState ( const AudioPlaybackState & playbackState ) ; <nl> <nl> void setFadeOpacity ( float64 opacity ) { <nl> _slider - > setFadeOpacity ( opacity ) ; <nl> } <nl> - void setChangeProgressCallback ( Ui : : MediaSlider : : Callback & & callback ) { <nl> + void setChangeProgressCallback ( Ui : : ContinuousSlider : : Callback & & callback ) { <nl> _slider - > setChangeProgressCallback ( std_ : : move ( callback ) ) ; <nl> } <nl> - void setChangeFinishedCallback ( Ui : : MediaSlider : : Callback & & callback ) { <nl> + void setChangeFinishedCallback ( Ui : : ContinuousSlider : : Callback & & callback ) { <nl> _slider - > setChangeFinishedCallback ( std_ : : move ( callback ) ) ; <nl> } <nl> void setGeometry ( int x , int y , int w , int h ) { <nl> class Playback { <nl> } <nl> <nl> private : <nl> - Ui : : MediaSlider * _slider ; <nl> + Ui : : ContinuousSlider * _slider ; <nl> <nl> int64 _position = 0 ; <nl> int64 _duration = 0 ; <nl> mmm a / Telegram / SourceFiles / mediaview . cpp <nl> ppp b / Telegram / SourceFiles / mediaview . cpp <nl> void MediaView : : onDocClick ( ) { <nl> if ( _doc - > loading ( ) ) { <nl> onSaveCancel ( ) ; <nl> } else { <nl> - DocumentOpenClickHandler : : doOpen ( _doc , ActionOnLoadNone ) ; <nl> + DocumentOpenClickHandler : : doOpen ( _doc , nullptr , ActionOnLoadNone ) ; <nl> if ( _doc - > loading ( ) & & ! _radial . animating ( ) ) { <nl> _radial . start ( _doc - > progress ( ) ) ; <nl> } <nl> void MediaView : : onVideoSeekFinished ( int64 positionMs ) { <nl> <nl> void MediaView : : onVideoVolumeChanged ( float64 volume ) { <nl> Global : : SetVideoVolume ( volume ) ; <nl> - emit audioPlayer ( ) - > videoVolumeChanged ( ) ; <nl> + Global : : RefVideoVolumeChanged ( ) . notify ( ) ; <nl> } <nl> <nl> void MediaView : : onVideoToggleFullScreen ( ) { <nl> mmm a / Telegram / SourceFiles / mtproto / file_download . cpp <nl> ppp b / Telegram / SourceFiles / mtproto / file_download . cpp <nl> namespace { <nl> } <nl> <nl> FileLoader : : FileLoader ( const QString & toFile , int32 size , LocationType locationType , LoadToCacheSetting toCache , LoadFromCloudSetting fromCloud , bool autoLoading ) <nl> - : _prev ( 0 ) <nl> - , _next ( 0 ) <nl> - , _priority ( 0 ) <nl> - , _paused ( false ) <nl> - , _autoLoading ( autoLoading ) <nl> - , _inQueue ( false ) <nl> - , _complete ( false ) <nl> - , _localStatus ( LocalNotTried ) <nl> + : _autoLoading ( autoLoading ) <nl> , _file ( toFile ) <nl> , _fname ( toFile ) <nl> - , _fileIsOpen ( false ) <nl> , _toCache ( toCache ) <nl> , _fromCloud ( fromCloud ) <nl> , _size ( size ) <nl> , _type ( mtpc_storage_fileUnknown ) <nl> - , _locationType ( locationType ) <nl> - , _localTaskId ( 0 ) { <nl> + , _locationType ( locationType ) { <nl> } <nl> <nl> QByteArray FileLoader : : imageFormat ( const QSize & shrinkBox ) const { <nl> int32 FileLoader : : fullSize ( ) const { <nl> } <nl> <nl> bool FileLoader : : setFileName ( const QString & fileName ) { <nl> - if ( _toCache ! = LoadToCacheAsWell | | ! _fname . isEmpty ( ) ) return fileName . isEmpty ( ) ; <nl> + if ( _toCache ! = LoadToCacheAsWell | | ! _fname . isEmpty ( ) ) { <nl> + return fileName . isEmpty ( ) | | ( fileName = = _fname ) ; <nl> + } <nl> _fname = fileName ; <nl> _file . setFileName ( _fname ) ; <nl> return true ; <nl> bool mtpFileLoader : : tryLoadLocal ( ) { <nl> } <nl> } <nl> } <nl> + emit progress ( this ) ; <nl> <nl> if ( _localStatus ! = LocalNotTried ) { <nl> return _complete ; <nl> mmm a / Telegram / SourceFiles / mtproto / file_download . h <nl> ppp b / Telegram / SourceFiles / mtproto / file_download . h <nl> class FileLoader : public QObject { <nl> protected : <nl> void readImage ( const QSize & shrinkBox ) const ; <nl> <nl> - FileLoader * _prev , * _next ; <nl> - int32 _priority ; <nl> + FileLoader * _prev = nullptr ; <nl> + FileLoader * _next = nullptr ; <nl> + int _priority = 0 ; <nl> FileLoaderQueue * _queue ; <nl> <nl> - bool _paused , _autoLoading , _inQueue , _complete ; <nl> - mutable LocalLoadStatus _localStatus ; <nl> + bool _paused = false ; <nl> + bool _autoLoading = false ; <nl> + bool _inQueue = false ; <nl> + bool _complete = false ; <nl> + mutable LocalLoadStatus _localStatus = LocalNotTried ; <nl> <nl> virtual bool tryLoadLocal ( ) = 0 ; <nl> virtual void cancelRequests ( ) = 0 ; <nl> class FileLoader : public QObject { <nl> <nl> QFile _file ; <nl> QString _fname ; <nl> - bool _fileIsOpen ; <nl> + bool _fileIsOpen = false ; <nl> <nl> LoadToCacheSetting _toCache ; <nl> LoadFromCloudSetting _fromCloud ; <nl> class FileLoader : public QObject { <nl> mtpTypeId _type ; <nl> LocationType _locationType ; <nl> <nl> - TaskId _localTaskId ; <nl> + TaskId _localTaskId = 0 ; <nl> mutable QByteArray _imageFormat ; <nl> mutable QPixmap _imagePixmap ; <nl> <nl> mmm a / Telegram / SourceFiles / observer_peer . cpp <nl> ppp b / Telegram / SourceFiles / observer_peer . cpp <nl> using AllUpdatesList = QMap < PeerData * , PeerUpdate > ; <nl> NeverFreedPointer < AllUpdatesList > AllUpdates ; <nl> <nl> void StartCallback ( ) { <nl> - SmallUpdates . makeIfNull ( ) ; <nl> - AllUpdates . makeIfNull ( ) ; <nl> + SmallUpdates . createIfNull ( ) ; <nl> + AllUpdates . createIfNull ( ) ; <nl> } <nl> void FinishCallback ( ) { <nl> SmallUpdates . clear ( ) ; <nl> void mergePeerUpdate ( PeerUpdate & mergeTo , const PeerUpdate & mergeFrom ) { <nl> } <nl> <nl> void peerUpdatedDelayed ( const PeerUpdate & update ) { <nl> - SmallUpdates . makeIfNull ( ) ; <nl> - AllUpdates . makeIfNull ( ) ; <nl> + SmallUpdates . createIfNull ( ) ; <nl> + AllUpdates . createIfNull ( ) ; <nl> <nl> Global : : RefHandleDelayedPeerUpdates ( ) . call ( ) ; <nl> <nl> mmm a / Telegram / SourceFiles / overview / overview_layout . cpp <nl> ppp b / Telegram / SourceFiles / overview / overview_layout . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " application . h " <nl> # include " fileuploader . h " <nl> # include " mainwindow . h " <nl> - # include " playerwidget . h " <nl> # include " media / media_audio . h " <nl> # include " media / player / media_player_instance . h " <nl> # include " localstorage . h " <nl> mmm a / Telegram / SourceFiles / overviewwidget . cpp <nl> ppp b / Telegram / SourceFiles / overviewwidget . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " mainwidget . h " <nl> # include " overviewwidget . h " <nl> # include " application . h " <nl> - # include " playerwidget . h " <nl> # include " overview / overview_layout . h " <nl> # include " history / history_media_types . h " <nl> + # include " media / media_audio . h " <nl> <nl> / / flick scroll taken from http : / / qt - project . org / doc / qt - 4 . 8 / demos - embedded - anomaly - src - flickcharm - cpp . html <nl> <nl> OverviewInner : : ~ OverviewInner ( ) { <nl> OverviewWidget : : OverviewWidget ( QWidget * parent , PeerData * peer , MediaOverviewType type ) : TWidget ( parent ) <nl> , _scroll ( this , st : : historyScroll , false ) <nl> , _inner ( this , & _scroll , peer , type ) <nl> - , _noDropResizeIndex ( false ) <nl> , _a_show ( animation ( this , & OverviewWidget : : step_show ) ) <nl> - , _scrollSetAfterShow ( 0 ) <nl> - , _scrollDelta ( 0 ) <nl> - , _selCount ( 0 ) <nl> - , _topShadow ( this , st : : shadowColor ) <nl> - , _inGrab ( false ) { <nl> + , _topShadow ( this , st : : shadowColor ) { <nl> _scroll . setFocusPolicy ( Qt : : NoFocus ) ; <nl> _scroll . setWidget ( & _inner ) ; <nl> _scroll . move ( 0 , 0 ) ; <nl> OverviewWidget : : OverviewWidget ( QWidget * parent , PeerData * peer , MediaOverviewTyp <nl> connect ( & _scrollTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( onScrollTimer ( ) ) ) ; <nl> _scrollTimer . setSingleShot ( false ) ; <nl> <nl> - / / connect ( App : : main ( ) - > player ( ) , SIGNAL ( playerSongChanged ( const FullMsgId & ) ) , this , SLOT ( onPlayerSongChanged ( const FullMsgId & ) ) ) ; <nl> - <nl> switchType ( type ) ; <nl> } <nl> <nl> void OverviewWidget : : resizeEvent ( QResizeEvent * e ) { <nl> } <nl> _noDropResizeIndex = false ; <nl> <nl> - _topShadow . resize ( width ( ) - ( ( ! Adaptive : : OneColumn ( ) & & ! _inGrab ) ? st : : lineWidth : 0 ) , st : : lineWidth ) ; <nl> - _topShadow . moveToLeft ( ( ! Adaptive : : OneColumn ( ) & & ! _inGrab ) ? st : : lineWidth : 0 , 0 ) ; <nl> + _topShadow - > resize ( width ( ) - ( ( ! Adaptive : : OneColumn ( ) & & ! _inGrab ) ? st : : lineWidth : 0 ) , st : : lineWidth ) ; <nl> + _topShadow - > moveToLeft ( ( ! Adaptive : : OneColumn ( ) & & ! _inGrab ) ? st : : lineWidth : 0 , 0 ) ; <nl> } <nl> <nl> void OverviewWidget : : paintEvent ( QPaintEvent * e ) { <nl> void OverviewWidget : : showAnimated ( Window : : SlideDirection direction , const Window <nl> <nl> _cacheUnder = params . oldContentCache ; <nl> show ( ) ; <nl> - _topShadow . setVisible ( params . withTopBarShadow ? false : true ) ; <nl> + _topShadow - > setVisible ( params . withTopBarShadow ? false : true ) ; <nl> _cacheOver = App : : main ( ) - > grabForShowAnimation ( params ) ; <nl> - _topShadow . setVisible ( params . withTopBarShadow ? true : false ) ; <nl> + _topShadow - > setVisible ( params . withTopBarShadow ? true : false ) ; <nl> App : : main ( ) - > topBar ( ) - > startAnim ( ) ; <nl> <nl> _scrollSetAfterShow = _scroll . scrollTop ( ) ; <nl> void OverviewWidget : : step_show ( float64 ms , bool timer ) { <nl> float64 dt = ms / st : : slideDuration ; <nl> if ( dt > = 1 ) { <nl> _a_show . stop ( ) ; <nl> - _topShadow . show ( ) ; <nl> + _topShadow - > show ( ) ; <nl> <nl> a_coordUnder . finish ( ) ; <nl> a_coordOver . finish ( ) ; <nl> void OverviewWidget : : changingMsgId ( HistoryItem * row , MsgId newId ) { <nl> } <nl> } <nl> <nl> + void OverviewWidget : : grapWithoutTopBarShadow ( ) { <nl> + grabStart ( ) ; <nl> + _topShadow - > hide ( ) ; <nl> + } <nl> + <nl> + void OverviewWidget : : grabFinish ( ) { <nl> + _inGrab = false ; <nl> + resizeEvent ( 0 ) ; <nl> + _topShadow - > show ( ) ; <nl> + } <nl> + <nl> void OverviewWidget : : ui_repaintHistoryItem ( const HistoryItem * item ) { <nl> if ( peer ( ) = = item - > history ( ) - > peer | | migratePeer ( ) = = item - > history ( ) - > peer ) { <nl> _inner . repaintItem ( item ) ; <nl> void OverviewWidget : : onScrollTimer ( ) { <nl> _scroll . scrollToY ( _scroll . scrollTop ( ) + d ) ; <nl> } <nl> <nl> - / / void OverviewWidget : : onPlayerSongChanged ( const FullMsgId & msgId ) { <nl> - / / if ( type ( ) = = OverviewMusicFiles ) { <nl> - / / int32 top = _inner . itemTop ( msgId ) ; <nl> - / / if ( top > 0 ) { <nl> - / / _scroll . scrollToY ( snap ( top - int ( _scroll . height ( ) - ( st : : msgPadding . top ( ) + st : : mediaThumbSize + st : : msgPadding . bottom ( ) ) ) / 2 , 0 , _scroll . scrollTopMax ( ) ) ) ; <nl> - / / } <nl> - / / } <nl> - / / } <nl> - <nl> void OverviewWidget : : checkSelectingScroll ( QPoint point ) { <nl> if ( point . y ( ) < _scroll . scrollTop ( ) ) { <nl> _scrollDelta = point . y ( ) - _scroll . scrollTop ( ) ; <nl> mmm a / Telegram / SourceFiles / overviewwidget . h <nl> ppp b / Telegram / SourceFiles / overviewwidget . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> <nl> namespace Overview { <nl> namespace Layout { <nl> - <nl> class AbstractItem ; <nl> class ItemBase ; <nl> class Date ; <nl> - <nl> } / / namespace Layout <nl> } / / namespace Overview <nl> <nl> + namespace Ui { <nl> + class PlainShadow ; <nl> + } / / namespace Ui <nl> + <nl> class OverviewWidget ; <nl> class OverviewInner : public QWidget , public AbstractTooltipShower , public RPCSender , private base : : Subscriber { <nl> Q_OBJECT <nl> <nl> public : <nl> - <nl> OverviewInner ( OverviewWidget * overview , ScrollArea * scroll , PeerData * peer , MediaOverviewType type ) ; <nl> <nl> void activate ( ) ; <nl> class OverviewInner : public QWidget , public AbstractTooltipShower , public RPCSe <nl> ~ OverviewInner ( ) ; <nl> <nl> public slots : <nl> - <nl> void onUpdateSelected ( ) ; <nl> <nl> void copyContextUrl ( ) ; <nl> public slots : <nl> void onNeedSearchMessages ( ) ; <nl> <nl> private : <nl> - <nl> MsgId complexMsgId ( const HistoryItem * item ) const ; <nl> <nl> bool itemMigrated ( MsgId msgId ) const ; <nl> class OverviewWidget : public TWidget , public RPCSender { <nl> Q_OBJECT <nl> <nl> public : <nl> - <nl> OverviewWidget ( QWidget * parent , PeerData * peer , MediaOverviewType type ) ; <nl> <nl> void clear ( ) ; <nl> class OverviewWidget : public TWidget , public RPCSender { <nl> _inGrab = true ; <nl> resizeEvent ( 0 ) ; <nl> } <nl> - void grapWithoutTopBarShadow ( ) { <nl> - grabStart ( ) ; <nl> - _topShadow . hide ( ) ; <nl> - } <nl> - void grabFinish ( ) override { <nl> - _inGrab = false ; <nl> - resizeEvent ( 0 ) ; <nl> - _topShadow . show ( ) ; <nl> - } <nl> + void grapWithoutTopBarShadow ( ) ; <nl> + void grabFinish ( ) override ; <nl> void rpcClear ( ) override { <nl> _inner . rpcClear ( ) ; <nl> RPCSender : : rpcClear ( ) ; <nl> class OverviewWidget : public TWidget , public RPCSender { <nl> ~ OverviewWidget ( ) ; <nl> <nl> public slots : <nl> - <nl> void activate ( ) ; <nl> void onScroll ( ) ; <nl> <nl> void onScrollTimer ( ) ; <nl> - / / void onPlayerSongChanged ( const FullMsgId & msgId ) ; <nl> <nl> void onForwardSelected ( ) ; <nl> void onDeleteSelected ( ) ; <nl> public slots : <nl> void onClearSelected ( ) ; <nl> <nl> private : <nl> - <nl> ScrollArea _scroll ; <nl> OverviewInner _inner ; <nl> - bool _noDropResizeIndex ; <nl> + bool _noDropResizeIndex = false ; <nl> <nl> QString _header ; <nl> <nl> public slots : <nl> anim : : ivalue a_coordUnder , a_coordOver ; <nl> anim : : fvalue a_progress ; <nl> <nl> - int32 _scrollSetAfterShow ; <nl> + int32 _scrollSetAfterShow = 0 ; <nl> <nl> QTimer _scrollTimer ; <nl> - int32 _scrollDelta ; <nl> + int32 _scrollDelta = 0 ; <nl> <nl> - int32 _selCount ; <nl> + int32 _selCount = 0 ; <nl> <nl> - PlainShadow _topShadow ; <nl> - bool _inGrab ; <nl> + ChildWidget < Ui : : PlainShadow > _topShadow ; <nl> + bool _inGrab = false ; <nl> <nl> } ; <nl> <nl> mmm a / Telegram / SourceFiles / platform / linux / notifications_manager_linux . cpp <nl> ppp b / Telegram / SourceFiles / platform / linux / notifications_manager_linux . cpp <nl> using Notification = QSharedPointer < NotificationData > ; <nl> void start ( ) { <nl> if ( LibNotifyLoaded ( ) ) { <nl> if ( Libs : : notify_is_initted ( ) | | Libs : : notify_init ( " Telegram Desktop " ) ) { <nl> - ManagerInstance . makeIfNull ( ) ; <nl> + ManagerInstance . createIfNull ( ) ; <nl> if ( ! ManagerInstance - > init ( ) ) { <nl> ManagerInstance . clear ( ) ; <nl> LOG ( ( " LibNotify Error : manager failed to init ! " ) ) ; <nl> mmm a / Telegram / SourceFiles / platform / mac / main_window_mac . mm <nl> ppp b / Telegram / SourceFiles / platform / mac / main_window_mac . mm <nl> <nl> # include " mainwindow . h " <nl> # include " mainwidget . h " <nl> # include " application . h " <nl> - # include " playerwidget . h " <nl> # include " historywidget . h " <nl> # include " localstorage . h " <nl> # include " window / notifications_manager_default . h " <nl> mmm a / Telegram / SourceFiles / platform / mac / notifications_manager_mac . mm <nl> ppp b / Telegram / SourceFiles / platform / mac / notifications_manager_mac . mm <nl> - ( BOOL ) userNotificationCenter : ( NSUserNotificationCenter * ) center shouldPresentN <nl> <nl> void start ( ) { <nl> if ( cPlatform ( ) ! = dbipMacOld ) { <nl> - ManagerInstance . makeIfNull ( ) ; <nl> + ManagerInstance . createIfNull ( ) ; <nl> } <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / platform / win / notifications_manager_win . cpp <nl> ppp b / Telegram / SourceFiles / platform / win / notifications_manager_win . cpp <nl> class ToastEventHandler : public Implements < DesktopToastActivatedEventHandler , D <nl> <nl> void start ( ) { <nl> if ( init ( ) ) { <nl> - ManagerInstance . makeIfNull ( ) ; <nl> + ManagerInstance . createIfNull ( ) ; <nl> } <nl> } <nl> <nl> deleted file mode 100644 <nl> index a434bd82aad . . 00000000000 <nl> mmm a / Telegram / SourceFiles / playerwidget . cpp <nl> ppp / dev / null <nl> <nl> - / * <nl> - This file is part of Telegram Desktop , <nl> - the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> - <nl> - Telegram Desktop is free software : you can redistribute it and / or modify <nl> - it under the terms of the GNU General Public License as published by <nl> - the Free Software Foundation , either version 3 of the License , or <nl> - ( at your option ) any later version . <nl> - <nl> - It is distributed in the hope that it will be useful , <nl> - but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - GNU General Public License for more details . <nl> - <nl> - In addition , as a special exception , the copyright holders give permission <nl> - to link the code of portions of this program with the OpenSSL library . <nl> - <nl> - Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> - Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> - * / <nl> - # include " stdafx . h " <nl> - # include " playerwidget . h " <nl> - <nl> - # include " shortcuts . h " <nl> - # include " lang . h " <nl> - # include " boxes / addcontactbox . h " <nl> - # include " application . h " <nl> - # include " mainwindow . h " <nl> - # include " playerwidget . h " <nl> - # include " mainwidget . h " <nl> - # include " localstorage . h " <nl> - # include " media / media_audio . h " <nl> - # include " history / history_media_types . h " <nl> - <nl> - PlayerWidget : : PlayerWidget ( QWidget * parent ) : TWidget ( parent ) <nl> - , _a_state ( animation ( this , & PlayerWidget : : step_state ) ) <nl> - , _a_progress ( animation ( this , & PlayerWidget : : step_progress ) ) { <nl> - resize ( st : : wndMinWidth , st : : playerHeight ) ; <nl> - setMouseTracking ( true ) ; <nl> - memset ( _stateHovers , 0 , sizeof ( _stateHovers ) ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : paintEvent ( QPaintEvent * e ) { <nl> - Painter p ( this ) ; <nl> - <nl> - QRect r ( e - > rect ( ) ) , checkr ( myrtlrect ( r ) ) ; <nl> - p . fillRect ( r , st : : playerBg - > b ) ; <nl> - <nl> - if ( ! _playbackRect . contains ( checkr ) ) { <nl> - if ( _fullAvailable & & checkr . intersects ( _prevRect ) ) { <nl> - if ( _prevAvailable ) { <nl> - float64 o = _stateHovers [ OverPrev ] ; <nl> - p . setOpacity ( o * 1 . + ( 1 . - o ) * st : : playerInactiveOpacity ) ; <nl> - } else { <nl> - p . setOpacity ( st : : playerUnavailableOpacity ) ; <nl> - } <nl> - p . drawSpriteCenterLeft ( _prevRect , width ( ) , st : : playerPrev ) ; <nl> - } <nl> - if ( checkr . intersects ( _playRect ) ) { <nl> - float64 o = _stateHovers [ OverPlay ] ; <nl> - p . setOpacity ( o * 1 . + ( 1 . - o ) * st : : playerInactiveOpacity ) ; <nl> - p . drawSpriteCenterLeft ( _playRect , width ( ) , ( _showPause | | _down = = OverPlayback ) ? st : : playerPause : st : : playerPlay ) ; <nl> - } <nl> - if ( _fullAvailable & & checkr . intersects ( _nextRect ) ) { <nl> - if ( _nextAvailable ) { <nl> - float64 o = _stateHovers [ OverNext ] ; <nl> - p . setOpacity ( o * 1 . + ( 1 . - o ) * st : : playerInactiveOpacity ) ; <nl> - } else { <nl> - p . setOpacity ( st : : playerUnavailableOpacity ) ; <nl> - } <nl> - p . drawSpriteCenterLeft ( _nextRect , width ( ) , st : : playerNext ) ; <nl> - } <nl> - if ( checkr . intersects ( _closeRect ) ) { <nl> - float64 o = _stateHovers [ OverClose ] ; <nl> - p . setOpacity ( o * 1 . + ( 1 . - o ) * st : : playerInactiveOpacity ) ; <nl> - p . drawSpriteCenterLeft ( _closeRect , width ( ) , st : : playerClose ) ; <nl> - } <nl> - if ( checkr . intersects ( _volumeRect ) ) { <nl> - float64 o = _stateHovers [ OverVolume ] ; <nl> - p . setOpacity ( o * 1 . + ( 1 . - o ) * st : : playerInactiveOpacity ) ; <nl> - int32 top = _volumeRect . y ( ) + ( _volumeRect . height ( ) - st : : playerVolume . pxHeight ( ) ) / 2 ; <nl> - int32 left = _volumeRect . x ( ) + ( _volumeRect . width ( ) - st : : playerVolume . pxWidth ( ) ) / 2 ; <nl> - int32 mid = left + qRound ( st : : playerVolume . pxWidth ( ) * Global : : SongVolume ( ) ) ; <nl> - int32 right = left + st : : playerVolume . pxWidth ( ) ; <nl> - if ( rtl ( ) ) { <nl> - left = width ( ) - left ; <nl> - mid = width ( ) - mid ; <nl> - right = width ( ) - right ; <nl> - if ( mid < left ) { <nl> - p . drawPixmap ( QRect ( mid , top , left - mid , st : : playerVolume . pxHeight ( ) ) , App : : sprite ( ) , QRect ( st : : playerVolume . rect ( ) . x ( ) + ( mid - right ) * cIntRetinaFactor ( ) , st : : playerVolume . rect ( ) . y ( ) , ( left - mid ) * cIntRetinaFactor ( ) , st : : playerVolume . pxHeight ( ) * cIntRetinaFactor ( ) ) ) ; <nl> - } <nl> - if ( right < mid ) { <nl> - p . setOpacity ( st : : playerUnavailableOpacity ) ; <nl> - p . drawPixmap ( QRect ( right , top , mid - right , st : : playerVolume . pxHeight ( ) ) , App : : sprite ( ) , QRect ( st : : playerVolume . rect ( ) . x ( ) , st : : playerVolume . rect ( ) . y ( ) , ( mid - right ) * cIntRetinaFactor ( ) , st : : playerVolume . pxHeight ( ) * cIntRetinaFactor ( ) ) ) ; <nl> - } <nl> - } else { <nl> - if ( mid > left ) { <nl> - p . drawPixmap ( QRect ( left , top , mid - left , st : : playerVolume . pxHeight ( ) ) , App : : sprite ( ) , QRect ( st : : playerVolume . rect ( ) . x ( ) , st : : playerVolume . rect ( ) . y ( ) , ( mid - left ) * cIntRetinaFactor ( ) , st : : playerVolume . pxHeight ( ) * cIntRetinaFactor ( ) ) ) ; <nl> - } <nl> - if ( right > mid ) { <nl> - p . setOpacity ( st : : playerUnavailableOpacity ) ; <nl> - p . drawPixmap ( QRect ( mid , top , right - mid , st : : playerVolume . pxHeight ( ) ) , App : : sprite ( ) , QRect ( st : : playerVolume . rect ( ) . x ( ) + ( mid - left ) * cIntRetinaFactor ( ) , st : : playerVolume . rect ( ) . y ( ) , ( right - mid ) * cIntRetinaFactor ( ) , st : : playerVolume . pxHeight ( ) * cIntRetinaFactor ( ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - if ( _fullAvailable & & checkr . intersects ( _fullRect ) ) { <nl> - float64 o = _stateHovers [ OverFull ] ; <nl> - p . setOpacity ( o * 1 . + ( 1 . - o ) * st : : playerInactiveOpacity ) ; <nl> - p . drawSpriteCenterLeft ( _fullRect , width ( ) , st : : playerFull ) ; <nl> - } <nl> - if ( checkr . intersects ( _repeatRect ) ) { <nl> - float64 o = _stateHovers [ OverRepeat ] ; <nl> - p . setOpacity ( _repeat ? 1 . : ( o * st : : playerInactiveOpacity + ( 1 . - o ) * st : : playerUnavailableOpacity ) ) ; <nl> - p . drawSpriteCenterLeft ( _repeatRect , width ( ) , st : : playerRepeat ) ; <nl> - } <nl> - p . setOpacity ( 1 . ) ; <nl> - <nl> - p . setPen ( st : : playerTimeFg - > p ) ; <nl> - p . setFont ( st : : linkFont - > f ) ; <nl> - p . drawTextLeft ( _infoRect . x ( ) + _infoRect . width ( ) - _timeWidth , _infoRect . y ( ) + ( _infoRect . height ( ) - st : : linkFont - > height ) / 2 , width ( ) , _time , _timeWidth ) ; <nl> - <nl> - textstyleSet ( & st : : playerNameStyle ) ; <nl> - p . setPen ( st : : playerFg - > p ) ; <nl> - _name . drawElided ( p , _infoRect . x ( ) + ( rtl ( ) ? ( _timeWidth + st : : playerSkip ) : 0 ) , _infoRect . y ( ) + ( _infoRect . height ( ) - st : : linkFont - > height ) / 2 , _infoRect . width ( ) - _timeWidth - st : : playerSkip ) ; <nl> - textstyleRestore ( ) ; <nl> - } <nl> - <nl> - if ( _duration ) { <nl> - float64 prg = ( _down = = OverPlayback ) ? _downProgress : a_progress . current ( ) ; <nl> - int32 from = _playbackRect . x ( ) , mid = qRound ( _playbackRect . x ( ) + prg * _playbackRect . width ( ) ) , end = _playbackRect . x ( ) + _playbackRect . width ( ) ; <nl> - if ( mid > from ) { <nl> - p . fillRect ( rtl ( ) ? ( width ( ) - mid ) : from , height ( ) - st : : playerLineHeight , mid - from , _playbackRect . height ( ) , st : : playerLineActive - > b ) ; <nl> - } <nl> - if ( end > mid ) { <nl> - p . fillRect ( rtl ( ) ? ( width ( ) - end ) : mid , height ( ) - st : : playerLineHeight , end - mid , st : : playerLineHeight , st : : playerLineInactive - > b ) ; <nl> - } <nl> - if ( _stateHovers [ OverPlayback ] > 0 ) { <nl> - p . setOpacity ( _stateHovers [ OverPlayback ] ) ; <nl> - <nl> - int32 x = mid - ( st : : playerMoverSize . width ( ) / 2 ) ; <nl> - p . fillRect ( rtl ( ) ? ( width ( ) - x - st : : playerMoverSize . width ( ) ) : x , height ( ) - st : : playerMoverSize . height ( ) , st : : playerMoverSize . width ( ) , st : : playerMoverSize . height ( ) , st : : playerLineActive - > b ) ; <nl> - } <nl> - } else if ( a_loadProgress . current ( ) > 0 ) { <nl> - int32 from = _playbackRect . x ( ) , mid = qRound ( _playbackRect . x ( ) + a_loadProgress . current ( ) * _playbackRect . width ( ) ) ; <nl> - if ( mid > from ) { <nl> - p . fillRect ( rtl ( ) ? ( width ( ) - mid ) : from , height ( ) - st : : playerLineHeight , mid - from , _playbackRect . height ( ) , st : : playerLineInactive - > b ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : mousePressEvent ( QMouseEvent * e ) { <nl> - QPoint pos ( myrtlpoint ( e - > pos ( ) ) ) ; <nl> - <nl> - if ( e - > button ( ) = = Qt : : LeftButton ) { <nl> - _down = OverNone ; <nl> - if ( _song & & _over = = OverPlay ) { <nl> - playPausePressed ( ) ; <nl> - return ; <nl> - } else if ( _over = = OverPrev ) { <nl> - prevPressed ( ) ; <nl> - } else if ( _over = = OverNext ) { <nl> - nextPressed ( ) ; <nl> - } else if ( _over = = OverClose ) { <nl> - _down = OverClose ; <nl> - } else if ( _over = = OverVolume ) { <nl> - _down = OverVolume ; <nl> - _downCoord = pos . x ( ) - _volumeRect . x ( ) ; <nl> - Global : : SetSongVolume ( snap ( ( _downCoord - ( ( _volumeRect . width ( ) - st : : playerVolume . pxWidth ( ) ) / 2 ) ) / float64 ( st : : playerVolume . pxWidth ( ) ) , 0 . , 1 . ) ) ; <nl> - emit audioPlayer ( ) - > songVolumeChanged ( ) ; <nl> - rtlupdate ( _volumeRect ) ; <nl> - } else if ( _over = = OverPlayback ) { <nl> - AudioMsgId playing ; <nl> - auto playbackState = audioPlayer ( ) - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> - if ( playing = = _song & & playbackState . duration ) { <nl> - if ( playbackState . state = = AudioPlayerPlaying | | playbackState . state = = AudioPlayerStarting | | playbackState . state = = AudioPlayerResuming ) { <nl> - audioPlayer ( ) - > pauseresume ( AudioMsgId : : Type : : Song ) ; <nl> - } <nl> - _down = OverPlayback ; <nl> - _downProgress = snap ( ( pos . x ( ) - _playbackRect . x ( ) ) / float64 ( _playbackRect . width ( ) ) , 0 . , 1 . ) ; <nl> - _downDuration = playbackState . duration ; <nl> - _downFrequency = ( playbackState . frequency ? playbackState . frequency : AudioVoiceMsgFrequency ) ; <nl> - <nl> - rtlupdate ( _playbackRect ) ; <nl> - updateDownTime ( ) ; <nl> - } <nl> - } else if ( _over = = OverFull & & _song ) { <nl> - if ( HistoryItem * item = App : : histItemById ( _song . contextId ( ) ) ) { <nl> - App : : main ( ) - > showMediaOverview ( item - > history ( ) - > peer , OverviewMusicFiles ) ; <nl> - } <nl> - } else if ( _over = = OverRepeat ) { <nl> - _repeat = ! _repeat ; <nl> - updateOverRect ( OverRepeat ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : updateDownTime ( ) { <nl> - QString time = formatDurationText ( qRound ( _downDuration * _downProgress ) / _downFrequency ) ; <nl> - if ( time ! = _time ) { <nl> - _time = time ; <nl> - _timeWidth = st : : linkFont - > width ( _time ) ; <nl> - rtlupdate ( _infoRect ) ; <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : updateOverState ( OverState newState ) { <nl> - bool result = true ; <nl> - if ( _over ! = newState ) { <nl> - updateOverRect ( _over ) ; <nl> - updateOverRect ( newState ) ; <nl> - if ( _over ! = OverNone ) { <nl> - _stateAnimations . remove ( _over ) ; <nl> - _stateAnimations [ - _over ] = getms ( ) - ( ( 1 . - _stateHovers [ _over ] ) * st : : playerDuration ) ; <nl> - if ( ! _a_state . animating ( ) ) _a_state . start ( ) ; <nl> - } else { <nl> - result = false ; <nl> - } <nl> - _over = newState ; <nl> - if ( newState ! = OverNone ) { <nl> - _stateAnimations . remove ( - _over ) ; <nl> - _stateAnimations [ _over ] = getms ( ) - ( _stateHovers [ _over ] * st : : playerDuration ) ; <nl> - if ( ! _a_state . animating ( ) ) _a_state . start ( ) ; <nl> - setCursor ( style : : cur_pointer ) ; <nl> - } else { <nl> - setCursor ( style : : cur_default ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : updateOverRect ( OverState state ) { <nl> - switch ( state ) { <nl> - case OverPrev : rtlupdate ( _prevRect ) ; break ; <nl> - case OverPlay : rtlupdate ( _playRect ) ; break ; <nl> - case OverNext : rtlupdate ( _nextRect ) ; break ; <nl> - case OverClose : rtlupdate ( _closeRect ) ; break ; <nl> - case OverVolume : rtlupdate ( _volumeRect ) ; break ; <nl> - case OverFull : rtlupdate ( _fullRect ) ; break ; <nl> - case OverRepeat : rtlupdate ( _repeatRect ) ; break ; <nl> - case OverPlayback : rtlupdate ( _playbackRect ) ; break ; <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : updateControls ( ) { <nl> - _fullAvailable = ( _index > = 0 ) ; <nl> - <nl> - History * history = _msgmigrated ? _migrated : _history ; <nl> - _prevAvailable = _fullAvailable & & ( ( _index > 0 ) | | ( _index = = 0 & & _migrated & & ! _msgmigrated & & ! _migrated - > overview [ OverviewMusicFiles ] . isEmpty ( ) ) ) ; <nl> - _nextAvailable = _fullAvailable & & ( ( _index < history - > overview [ OverviewMusicFiles ] . size ( ) - 1 ) | | ( _msgmigrated & & _index = = _migrated - > overview [ OverviewMusicFiles ] . size ( ) - 1 & & _history - > overviewLoaded ( OverviewMusicFiles ) & & _history - > overviewCount ( OverviewMusicFiles ) > 0 ) ) ; <nl> - resizeEvent ( 0 ) ; <nl> - update ( ) ; <nl> - if ( _index > = 0 & & _index < MediaOverviewStartPerPage ) { <nl> - if ( ! _history - > overviewLoaded ( OverviewMusicFiles ) | | ( _migrated & & ! _migrated - > overviewLoaded ( OverviewMusicFiles ) ) ) { <nl> - if ( App : : main ( ) ) { <nl> - if ( _msgmigrated | | ( _migrated & & _index = = 0 & & _history - > overviewLoaded ( OverviewMusicFiles ) ) ) { <nl> - App : : main ( ) - > loadMediaBack ( _migrated - > peer , OverviewMusicFiles ) ; <nl> - } else { <nl> - App : : main ( ) - > loadMediaBack ( _history - > peer , OverviewMusicFiles ) ; <nl> - if ( _migrated & & _index = = 0 & & _migrated - > overview [ OverviewMusicFiles ] . isEmpty ( ) & & ! _migrated - > overviewLoaded ( OverviewMusicFiles ) ) { <nl> - App : : main ( ) - > loadMediaBack ( _migrated - > peer , OverviewMusicFiles ) ; <nl> - } <nl> - } <nl> - if ( _msgmigrated & & ! _history - > overviewCountLoaded ( OverviewMusicFiles ) ) { <nl> - App : : main ( ) - > preloadOverview ( _history - > peer , OverviewMusicFiles ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : findCurrent ( ) { <nl> - _index = - 1 ; <nl> - if ( ! _history | | ! _song . contextId ( ) . msg ) return ; <nl> - <nl> - const History : : MediaOverview * o = & ( _msgmigrated ? _migrated : _history ) - > overview [ OverviewMusicFiles ] ; <nl> - if ( ( _msgmigrated ? _migrated : _history ) - > channelId ( ) = = _song . contextId ( ) . channel ) { <nl> - for ( int i = 0 , l = o - > size ( ) ; i < l ; + + i ) { <nl> - if ( o - > at ( i ) = = _song . contextId ( ) . msg ) { <nl> - _index = i ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - preloadNext ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : preloadNext ( ) { <nl> - if ( _index < 0 ) return ; <nl> - <nl> - History * history = _msgmigrated ? _migrated : _history ; <nl> - const History : : MediaOverview * o = & history - > overview [ OverviewMusicFiles ] ; <nl> - HistoryItem * next = 0 ; <nl> - if ( _index < o - > size ( ) - 1 ) { <nl> - next = App : : histItemById ( history - > channelId ( ) , o - > at ( _index + 1 ) ) ; <nl> - } else if ( _msgmigrated & & _index = = o - > size ( ) - 1 & & _history - > overviewLoaded ( OverviewMusicFiles ) & & _history - > overviewCount ( OverviewMusicFiles ) > 0 ) { <nl> - next = App : : histItemById ( _history - > channelId ( ) , _history - > overview [ OverviewMusicFiles ] . at ( 0 ) ) ; <nl> - } else if ( _msgmigrated & & _index = = o - > size ( ) - 1 & & ! _history - > overviewCountLoaded ( OverviewMusicFiles ) ) { <nl> - if ( App : : main ( ) ) App : : main ( ) - > preloadOverview ( _history - > peer , OverviewMusicFiles ) ; <nl> - } <nl> - if ( next ) { <nl> - if ( HistoryDocument * document = static_cast < HistoryDocument * > ( next - > getMedia ( ) ) ) { <nl> - DocumentData * d = document - > getDocument ( ) ; <nl> - if ( ! d - > loaded ( DocumentData : : FilePathResolveSaveFromDataSilent ) ) { <nl> - DocumentOpenClickHandler : : doOpen ( d , ActionOnLoadNone ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : startPlay ( const FullMsgId & msgId ) { <nl> - if ( HistoryItem * item = App : : histItemById ( msgId ) ) { <nl> - if ( HistoryDocument * doc = static_cast < HistoryDocument * > ( item - > getMedia ( ) ) ) { <nl> - audioPlayer ( ) - > play ( AudioMsgId ( doc - > getDocument ( ) , item - > fullId ( ) ) ) ; <nl> - updateState ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : clearSelection ( ) { <nl> - for ( StateAnimations : : const_iterator i = _stateAnimations . cbegin ( ) ; i ! = _stateAnimations . cend ( ) ; + + i ) { <nl> - _stateHovers [ qAbs ( i . key ( ) ) ] = 0 ; <nl> - } <nl> - _stateAnimations . clear ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : mediaOverviewUpdated ( PeerData * peer , MediaOverviewType type ) { <nl> - if ( _history & & ( _history - > peer = = peer | | ( _migrated & & _migrated - > peer = = peer ) ) & & type = = OverviewMusicFiles ) { <nl> - _index = - 1 ; <nl> - History * history = _msgmigrated ? _migrated : _history ; <nl> - if ( history - > channelId ( ) = = _song . contextId ( ) . channel & & _song . contextId ( ) . msg ) { <nl> - for ( int i = 0 , l = history - > overview [ OverviewMusicFiles ] . size ( ) ; i < l ; + + i ) { <nl> - if ( history - > overview [ OverviewMusicFiles ] . at ( i ) = = _song . contextId ( ) . msg ) { <nl> - _index = i ; <nl> - preloadNext ( ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - updateControls ( ) ; <nl> - } <nl> - } <nl> - <nl> - bool PlayerWidget : : seekingSong ( const AudioMsgId & song ) const { <nl> - return ( _down = = OverPlayback ) & & ( song = = _song ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : openPlayer ( ) { <nl> - _playerOpened = true ; <nl> - Shortcuts : : enableMediaShortcuts ( ) ; <nl> - } <nl> - <nl> - bool PlayerWidget : : isOpened ( ) const { <nl> - return _playerOpened ; <nl> - } <nl> - <nl> - void PlayerWidget : : closePlayer ( ) { <nl> - _playerOpened = false ; <nl> - Shortcuts : : disableMediaShortcuts ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : showPlayer ( ) { <nl> - TWidget : : show ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : hidePlayer ( ) { <nl> - clearSelection ( ) ; <nl> - TWidget : : hide ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : step_state ( uint64 ms , bool timer ) { <nl> - for ( StateAnimations : : iterator i = _stateAnimations . begin ( ) ; i ! = _stateAnimations . cend ( ) ; ) { <nl> - int32 over = qAbs ( i . key ( ) ) ; <nl> - updateOverRect ( OverState ( over ) ) ; <nl> - <nl> - float64 dt = float64 ( ms - i . value ( ) ) / st : : playerDuration ; <nl> - if ( dt > = 1 ) { <nl> - _stateHovers [ over ] = ( i . key ( ) > 0 ) ? 1 : 0 ; <nl> - i = _stateAnimations . erase ( i ) ; <nl> - } else { <nl> - _stateHovers [ over ] = ( i . key ( ) > 0 ) ? dt : ( 1 - dt ) ; <nl> - + + i ; <nl> - } <nl> - } <nl> - if ( _stateAnimations . isEmpty ( ) ) { <nl> - _a_state . stop ( ) ; <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : mouseMoveEvent ( QMouseEvent * e ) { <nl> - _lastMousePos = e - > globalPos ( ) ; <nl> - updateSelected ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : leaveEvent ( QEvent * e ) { <nl> - _lastMousePos = QCursor : : pos ( ) ; <nl> - updateSelected ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : updateSelected ( ) { <nl> - QPoint pos ( myrtlpoint ( mapFromGlobal ( _lastMousePos ) ) ) ; <nl> - <nl> - if ( _down = = OverVolume ) { <nl> - int32 delta = ( pos . x ( ) - _volumeRect . x ( ) ) - _downCoord ; <nl> - float64 startFrom = snap ( ( _downCoord - ( ( _volumeRect . width ( ) - st : : playerVolume . pxWidth ( ) ) / 2 ) ) / float64 ( st : : playerVolume . pxWidth ( ) ) , 0 . , 1 . ) ; <nl> - float64 add = delta / float64 ( 4 * st : : playerVolume . pxWidth ( ) ) , result = snap ( startFrom + add , 0 . , 1 . ) ; <nl> - if ( result ! = Global : : SongVolume ( ) ) { <nl> - Global : : SetSongVolume ( result ) ; <nl> - emit audioPlayer ( ) - > songVolumeChanged ( ) ; <nl> - rtlupdate ( _volumeRect ) ; <nl> - } <nl> - } else if ( _down = = OverPlayback ) { <nl> - _downProgress = snap ( ( pos . x ( ) - _playbackRect . x ( ) ) / float64 ( _playbackRect . width ( ) ) , 0 . , 1 . ) ; <nl> - rtlupdate ( _playbackRect ) ; <nl> - updateDownTime ( ) ; <nl> - } else if ( _down = = OverNone ) { <nl> - bool inInfo = ( ( pos . x ( ) > = _infoRect . x ( ) ) & & ( pos . x ( ) < _fullRect . x ( ) + _fullRect . width ( ) ) & & ( pos . y ( ) > = _playRect . y ( ) ) & & ( pos . y ( ) < = _playRect . y ( ) + _playRect . height ( ) ) ) ; <nl> - if ( _prevAvailable & & _prevRect . contains ( pos ) ) { <nl> - updateOverState ( OverPrev ) ; <nl> - } else if ( _nextAvailable & & _nextRect . contains ( pos ) ) { <nl> - updateOverState ( OverNext ) ; <nl> - } else if ( _playRect . contains ( pos ) ) { <nl> - updateOverState ( OverPlay ) ; <nl> - } else if ( _closeRect . contains ( pos ) ) { <nl> - updateOverState ( OverClose ) ; <nl> - } else if ( _volumeRect . contains ( pos ) ) { <nl> - updateOverState ( OverVolume ) ; <nl> - } else if ( _repeatRect . contains ( pos ) ) { <nl> - updateOverState ( OverRepeat ) ; <nl> - } else if ( _duration & & _playbackRect . contains ( pos ) ) { <nl> - updateOverState ( OverPlayback ) ; <nl> - } else if ( _fullAvailable & & inInfo ) { <nl> - updateOverState ( OverFull ) ; <nl> - } else if ( _over ! = OverNone ) { <nl> - updateOverState ( OverNone ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : mouseReleaseEvent ( QMouseEvent * e ) { <nl> - if ( _down = = OverVolume ) { <nl> - mouseMoveEvent ( e ) ; <nl> - Local : : writeUserSettings ( ) ; <nl> - } else if ( _down = = OverPlayback ) { <nl> - mouseMoveEvent ( e ) ; <nl> - AudioMsgId playing ; <nl> - auto playbackState = audioPlayer ( ) - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> - if ( playing = = _song & & playbackState . duration ) { <nl> - _downDuration = playbackState . duration ; <nl> - audioPlayer ( ) - > seek ( qRound ( _downProgress * _downDuration ) ) ; <nl> - <nl> - _showPause = true ; <nl> - <nl> - a_progress = anim : : fvalue ( _downProgress , _downProgress ) ; <nl> - _a_progress . stop ( ) ; <nl> - } <nl> - update ( ) ; <nl> - } else if ( _down = = OverClose & & _over = = OverClose ) { <nl> - closePressed ( ) ; <nl> - } <nl> - _down = OverNone ; <nl> - } <nl> - <nl> - void PlayerWidget : : playPressed ( ) { <nl> - if ( ! _song | | isHidden ( ) ) return ; <nl> - <nl> - AudioMsgId playing ; <nl> - auto playbackState = audioPlayer ( ) - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> - if ( playing = = _song & & ! ( playbackState . state & AudioPlayerStoppedMask ) ) { <nl> - if ( playbackState . state = = AudioPlayerPausing | | playbackState . state = = AudioPlayerPaused | | playbackState . state = = AudioPlayerPausedAtEnd ) { <nl> - audioPlayer ( ) - > pauseresume ( AudioMsgId : : Type : : Song ) ; <nl> - } <nl> - } else { <nl> - audioPlayer ( ) - > play ( _song ) ; <nl> - audioPlayer ( ) - > notify ( _song ) ; <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : pausePressed ( ) { <nl> - if ( ! _song | | isHidden ( ) ) return ; <nl> - <nl> - AudioMsgId playing ; <nl> - auto playbackState = audioPlayer ( ) - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> - if ( playing = = _song & & ! ( playbackState . state & AudioPlayerStoppedMask ) ) { <nl> - if ( playbackState . state = = AudioPlayerStarting | | playbackState . state = = AudioPlayerResuming | | playbackState . state = = AudioPlayerPlaying | | playbackState . state = = AudioPlayerFinishing ) { <nl> - audioPlayer ( ) - > pauseresume ( AudioMsgId : : Type : : Song ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : playPausePressed ( ) { <nl> - if ( ! _song | | isHidden ( ) ) return ; <nl> - <nl> - AudioMsgId playing ; <nl> - auto playbackState = audioPlayer ( ) - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> - if ( playing = = _song & & ! ( playbackState . state & AudioPlayerStoppedMask ) ) { <nl> - audioPlayer ( ) - > pauseresume ( AudioMsgId : : Type : : Song ) ; <nl> - } else { <nl> - audioPlayer ( ) - > play ( _song ) ; <nl> - audioPlayer ( ) - > notify ( _song ) ; <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : prevPressed ( ) { <nl> - if ( isHidden ( ) ) return ; <nl> - <nl> - auto history = _msgmigrated ? _migrated : _history ; <nl> - auto o = history ? & history - > overview [ OverviewMusicFiles ] : nullptr ; <nl> - if ( audioPlayer ( ) & & o & & _index > 0 & & _index < = o - > size ( ) & & ! o - > isEmpty ( ) ) { <nl> - startPlay ( FullMsgId ( history - > channelId ( ) , o - > at ( _index - 1 ) ) ) ; <nl> - } else if ( ! _index & & _history & & _migrated & & ! _msgmigrated ) { <nl> - o = & _migrated - > overview [ OverviewMusicFiles ] ; <nl> - if ( ! o - > isEmpty ( ) ) { <nl> - startPlay ( FullMsgId ( _migrated - > channelId ( ) , o - > at ( o - > size ( ) - 1 ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : nextPressed ( ) { <nl> - if ( isHidden ( ) ) return ; <nl> - <nl> - auto history = _msgmigrated ? _migrated : _history ; <nl> - auto o = history ? & history - > overview [ OverviewMusicFiles ] : nullptr ; <nl> - if ( audioPlayer ( ) & & o & & _index > = 0 & & _index < o - > size ( ) - 1 ) { <nl> - startPlay ( FullMsgId ( history - > channelId ( ) , o - > at ( _index + 1 ) ) ) ; <nl> - } else if ( o & & ( _index = = o - > size ( ) - 1 ) & & _msgmigrated & & _history - > overviewLoaded ( OverviewMusicFiles ) ) { <nl> - o = & _history - > overview [ OverviewMusicFiles ] ; <nl> - if ( ! o - > isEmpty ( ) ) { <nl> - startPlay ( FullMsgId ( _history - > channelId ( ) , o - > at ( 0 ) ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void PlayerWidget : : stopPressed ( ) { <nl> - if ( ! _song | | isHidden ( ) ) return ; <nl> - <nl> - audioPlayer ( ) - > stop ( AudioMsgId : : Type : : Song ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : closePressed ( ) { <nl> - stopPressed ( ) ; <nl> - if ( App : : main ( ) ) App : : main ( ) - > closePlayer ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : resizeEvent ( QResizeEvent * e ) { <nl> - int32 availh = ( height ( ) - st : : playerLineHeight ) ; <nl> - int32 ch = st : : playerPlay . pxHeight ( ) + st : : playerSkip , ct = ( availh - ch ) / 2 ; <nl> - _playbackRect = QRect ( Adaptive : : OneColumn ( ) ? 0 : st : : lineWidth , height ( ) - st : : playerMoverSize . height ( ) , width ( ) - ( Adaptive : : OneColumn ( ) ? 0 : st : : lineWidth ) , st : : playerMoverSize . height ( ) ) ; <nl> - _prevRect = _fullAvailable ? QRect ( st : : playerSkip / 2 , ct , st : : playerPrev . pxWidth ( ) + st : : playerSkip , ch ) : QRect ( ) ; <nl> - _playRect = QRect ( _fullAvailable ? ( _prevRect . x ( ) + _prevRect . width ( ) ) : ( st : : playerSkip / 2 ) , ct , st : : playerPlay . pxWidth ( ) + st : : playerSkip , ch ) ; <nl> - _nextRect = _fullAvailable ? QRect ( _playRect . x ( ) + _playRect . width ( ) , ct , st : : playerNext . pxWidth ( ) + st : : playerSkip , ch ) : QRect ( ) ; <nl> - <nl> - _closeRect = QRect ( width ( ) - st : : playerSkip / 2 - st : : playerClose . pxWidth ( ) - st : : playerSkip , ct , st : : playerClose . pxWidth ( ) + st : : playerSkip , ch ) ; <nl> - _volumeRect = QRect ( _closeRect . x ( ) - st : : playerVolume . pxWidth ( ) - st : : playerSkip , ct , st : : playerVolume . pxWidth ( ) + st : : playerSkip , ch ) ; <nl> - _repeatRect = QRect ( _volumeRect . x ( ) - st : : playerRepeat . pxWidth ( ) - st : : playerSkip , ct , st : : playerRepeat . pxWidth ( ) + st : : playerSkip , ch ) ; <nl> - _fullRect = _fullAvailable ? QRect ( _repeatRect . x ( ) - st : : playerFull . pxWidth ( ) - st : : playerSkip , ct , st : : playerFull . pxWidth ( ) + st : : playerSkip , ch ) : QRect ( ) ; <nl> - <nl> - int32 infoLeft = ( _fullAvailable ? ( _nextRect . x ( ) + _nextRect . width ( ) ) : ( _playRect . x ( ) + _playRect . width ( ) ) ) ; <nl> - _infoRect = QRect ( infoLeft + st : : playerSkip / 2 , 0 , ( _fullAvailable ? _fullRect . x ( ) : _repeatRect . x ( ) ) - infoLeft - st : : playerSkip , availh ) ; <nl> - <nl> - update ( ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : step_progress ( float64 ms , bool timer ) { <nl> - float64 dt = ms / ( 2 * AudioVoiceMsgUpdateView ) ; <nl> - if ( _duration & & dt > = 1 ) { <nl> - _a_progress . stop ( ) ; <nl> - a_progress . finish ( ) ; <nl> - a_loadProgress . finish ( ) ; <nl> - } else { <nl> - a_progress . update ( qMin ( dt , 1 . ) , anim : : linear ) ; <nl> - a_loadProgress . update ( 1 . - ( st : : radialDuration / ( st : : radialDuration + ms ) ) , anim : : linear ) ; <nl> - } <nl> - if ( timer ) rtlupdate ( _playbackRect ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : updateState ( ) { <nl> - updateState ( AudioMsgId ( ) , AudioPlaybackState ( ) ) ; <nl> - } <nl> - <nl> - void PlayerWidget : : updateState ( AudioMsgId playing , AudioPlaybackState playbackState ) { <nl> - if ( ! playing ) { <nl> - playbackState = audioPlayer ( ) - > currentState ( & playing , AudioMsgId : : Type : : Song ) ; <nl> - } <nl> - <nl> - bool songChanged = false ; <nl> - if ( playing & & _song ! = playing ) { <nl> - songChanged = true ; <nl> - _song = playing ; <nl> - if ( HistoryItem * item = App : : histItemById ( _song . contextId ( ) ) ) { <nl> - _history = item - > history ( ) ; <nl> - if ( _history - > peer - > migrateFrom ( ) ) { <nl> - _migrated = App : : history ( _history - > peer - > migrateFrom ( ) - > id ) ; <nl> - _msgmigrated = false ; <nl> - } else if ( _history - > peer - > migrateTo ( ) ) { <nl> - _migrated = _history ; <nl> - _history = App : : history ( _migrated - > peer - > migrateTo ( ) - > id ) ; <nl> - _msgmigrated = true ; <nl> - } <nl> - findCurrent ( ) ; <nl> - } else { <nl> - _history = nullptr ; <nl> - _msgmigrated = false ; <nl> - _index = - 1 ; <nl> - } <nl> - auto song = _song . audio ( ) - > song ( ) ; <nl> - if ( song - > performer . isEmpty ( ) ) { <nl> - _name . setText ( st : : linkFont , song - > title . isEmpty ( ) ? ( _song . audio ( ) - > name . isEmpty ( ) ? qsl ( " Unknown Track " ) : _song . audio ( ) - > name ) : song - > title , _textNameOptions ) ; <nl> - } else { <nl> - TextCustomTagsMap custom ; <nl> - custom . insert ( QChar ( ' c ' ) , qMakePair ( textcmdStartLink ( 1 ) , textcmdStopLink ( ) ) ) ; <nl> - _name . setRichText ( st : : linkFont , QString : : fromUtf8 ( " [ c ] % 1 [ / c ] \ xe2 \ x80 \ x93 % 2 " ) . arg ( textRichPrepare ( song - > performer ) ) . arg ( song - > title . isEmpty ( ) ? qsl ( " Unknown Track " ) : textRichPrepare ( song - > title ) ) , _textNameOptions , custom ) ; <nl> - } <nl> - updateControls ( ) ; <nl> - } <nl> - <nl> - qint64 position = 0 , duration = 0 , display = 0 ; <nl> - if ( playing = = _song ) { <nl> - if ( ! ( playbackState . state & AudioPlayerStoppedMask ) & & playbackState . state ! = AudioPlayerFinishing ) { <nl> - display = position = playbackState . position ; <nl> - duration = playbackState . duration ; <nl> - } else { <nl> - display = playbackState . duration ; <nl> - } <nl> - display = display / ( playbackState . frequency ? playbackState . frequency : AudioVoiceMsgFrequency ) ; <nl> - } else if ( _song ) { <nl> - display = _song . audio ( ) - > song ( ) - > duration ; <nl> - } <nl> - bool showPause = false , stopped = ( ( playbackState . state & AudioPlayerStoppedMask ) | | playbackState . state = = AudioPlayerFinishing ) ; <nl> - bool wasPlaying = ( _duration ! = 0 ) ; <nl> - if ( ! stopped ) { <nl> - showPause = ( playbackState . state = = AudioPlayerPlaying | | playbackState . state = = AudioPlayerResuming | | playbackState . state = = AudioPlayerStarting ) ; <nl> - } <nl> - QString time ; <nl> - float64 progress = 0 . ; <nl> - int32 loaded ; <nl> - float64 loadProgress = 1 . ; <nl> - if ( duration | | ! _song | | ! _song . audio ( ) | | ! _song . audio ( ) - > loading ( ) ) { <nl> - time = ( _down = = OverPlayback ) ? _time : formatDurationText ( display ) ; <nl> - progress = duration ? snap ( float64 ( position ) / duration , 0 . , 1 . ) : 0 . ; <nl> - loaded = duration ? _song . audio ( ) - > size : 0 ; <nl> - } else { <nl> - loaded = _song . audio ( ) - > loading ( ) ? _song . audio ( ) - > loadOffset ( ) : 0 ; <nl> - time = formatDownloadText ( loaded , _song . audio ( ) - > size ) ; <nl> - loadProgress = snap ( float64 ( loaded ) / qMax ( _song . audio ( ) - > size , 1 ) , 0 . , 1 . ) ; <nl> - } <nl> - if ( time ! = _time | | showPause ! = _showPause ) { <nl> - if ( _time ! = time ) { <nl> - _time = time ; <nl> - _timeWidth = st : : linkFont - > width ( _time ) ; <nl> - } <nl> - _showPause = showPause ; <nl> - if ( duration ! = _duration | | position ! = _position | | loaded ! = _loaded ) { <nl> - if ( ! songChanged & & ( ( ! stopped & & duration & & _duration ) | | ( ! duration & & _loaded ! = loaded ) ) ) { <nl> - a_progress . start ( progress ) ; <nl> - a_loadProgress . start ( loadProgress ) ; <nl> - _a_progress . start ( ) ; <nl> - } else { <nl> - a_progress = anim : : fvalue ( progress , progress ) ; <nl> - a_loadProgress = anim : : fvalue ( loadProgress , loadProgress ) ; <nl> - _a_progress . stop ( ) ; <nl> - } <nl> - _position = position ; <nl> - _duration = duration ; <nl> - _loaded = loaded ; <nl> - } <nl> - update ( ) ; <nl> - } else if ( duration ! = _duration | | position ! = _position | | loaded ! = _loaded ) { <nl> - if ( ! songChanged & & ( ( ! stopped & & duration & & _duration ) | | ( ! duration & & _loaded ! = loaded ) ) ) { <nl> - a_progress . start ( progress ) ; <nl> - a_loadProgress . start ( loadProgress ) ; <nl> - _a_progress . start ( ) ; <nl> - } else { <nl> - a_progress = anim : : fvalue ( progress , progress ) ; <nl> - a_loadProgress = anim : : fvalue ( loadProgress , loadProgress ) ; <nl> - _a_progress . stop ( ) ; <nl> - } <nl> - _position = position ; <nl> - _duration = duration ; <nl> - _loaded = loaded ; <nl> - } <nl> - <nl> - if ( wasPlaying & & playbackState . state = = AudioPlayerStoppedAtEnd ) { <nl> - if ( _repeat ) { <nl> - if ( _song . audio ( ) ) { <nl> - / / audioPlayer ( ) - > play ( _song ) ; <nl> - / / updateState ( ) ; <nl> - } <nl> - } else { <nl> - / / nextPressed ( ) ; <nl> - } <nl> - } <nl> - <nl> - if ( songChanged ) { <nl> - emit playerSongChanged ( _song . contextId ( ) ) ; <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index f93a91dcf16 . . 00000000000 <nl> mmm a / Telegram / SourceFiles / playerwidget . h <nl> ppp / dev / null <nl> <nl> - / * <nl> - This file is part of Telegram Desktop , <nl> - the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> - <nl> - Telegram Desktop is free software : you can redistribute it and / or modify <nl> - it under the terms of the GNU General Public License as published by <nl> - the Free Software Foundation , either version 3 of the License , or <nl> - ( at your option ) any later version . <nl> - <nl> - It is distributed in the hope that it will be useful , <nl> - but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - GNU General Public License for more details . <nl> - <nl> - In addition , as a special exception , the copyright holders give permission <nl> - to link the code of portions of this program with the OpenSSL library . <nl> - <nl> - Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> - Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> - * / <nl> - # pragma once <nl> - <nl> - # include " media / media_audio . h " <nl> - <nl> - class PlayerWidget : public TWidget { <nl> - Q_OBJECT <nl> - <nl> - public : <nl> - <nl> - PlayerWidget ( QWidget * parent ) ; <nl> - <nl> - void paintEvent ( QPaintEvent * e ) ; <nl> - void mousePressEvent ( QMouseEvent * e ) ; <nl> - void mouseMoveEvent ( QMouseEvent * e ) ; <nl> - void leaveEvent ( QEvent * e ) ; <nl> - void mouseReleaseEvent ( QMouseEvent * e ) ; <nl> - void resizeEvent ( QResizeEvent * e ) ; <nl> - <nl> - void playPressed ( ) ; <nl> - void pausePressed ( ) ; <nl> - void playPausePressed ( ) ; <nl> - void prevPressed ( ) ; <nl> - void nextPressed ( ) ; <nl> - void stopPressed ( ) ; <nl> - void closePressed ( ) ; <nl> - <nl> - void step_progress ( float64 ms , bool timer ) ; <nl> - void step_state ( uint64 ms , bool timer ) ; <nl> - <nl> - void updateState ( AudioMsgId playing , AudioPlaybackState playbackState ) ; <nl> - void updateState ( ) ; <nl> - void clearSelection ( ) ; <nl> - <nl> - void mediaOverviewUpdated ( PeerData * peer , MediaOverviewType type ) ; <nl> - <nl> - bool seekingSong ( const AudioMsgId & song ) const ; <nl> - <nl> - void openPlayer ( ) ; <nl> - bool isOpened ( ) const ; <nl> - void closePlayer ( ) ; <nl> - <nl> - void showPlayer ( ) ; <nl> - void hidePlayer ( ) ; <nl> - <nl> - signals : <nl> - <nl> - void playerSongChanged ( const FullMsgId & msgId ) ; <nl> - <nl> - private : <nl> - <nl> - / / Use startPlayer ( ) / stopPlayer ( ) or showPlayer ( ) / hidePlayer ( ) instead . <nl> - void show ( ) ; <nl> - void hide ( ) ; <nl> - <nl> - enum OverState { <nl> - OverNone = 0 , <nl> - OverPrev , <nl> - OverPlay , <nl> - OverNext , <nl> - OverClose , <nl> - OverVolume , <nl> - OverFull , <nl> - OverRepeat , <nl> - OverPlayback , <nl> - <nl> - OverStateCount <nl> - } ; <nl> - void updateDownTime ( ) ; <nl> - void updateOverState ( OverState newState ) ; <nl> - void updateOverRect ( OverState state ) ; <nl> - <nl> - void updateControls ( ) ; <nl> - void findCurrent ( ) ; <nl> - void preloadNext ( ) ; <nl> - <nl> - void startPlay ( const FullMsgId & msgId ) ; <nl> - <nl> - QPoint _lastMousePos ; <nl> - void updateSelected ( ) ; <nl> - <nl> - bool _playerOpened = false ; <nl> - <nl> - bool _prevAvailable = false ; <nl> - bool _nextAvailable = false ; <nl> - bool _fullAvailable = false ; <nl> - OverState _over = OverNone ; <nl> - OverState _down = OverNone ; <nl> - int32 _downCoord = 0 ; <nl> - int64 _downDuration ; <nl> - int32 _downFrequency = AudioVoiceMsgFrequency ; <nl> - float64 _downProgress = 0 . ; <nl> - <nl> - float64 _stateHovers [ OverStateCount ] ; <nl> - typedef QMap < int32 , uint64 > StateAnimations ; <nl> - StateAnimations _stateAnimations ; <nl> - Animation _a_state ; <nl> - <nl> - AudioMsgId _song ; <nl> - bool _msgmigrated = false ; <nl> - int32 _index = - 1 ; <nl> - History * _migrated = nullptr ; <nl> - History * _history = nullptr ; <nl> - QRect _playRect , _prevRect , _nextRect , _playbackRect ; <nl> - QRect _closeRect , _volumeRect , _fullRect , _repeatRect , _infoRect ; <nl> - int32 _timeWidth = 0 ; <nl> - bool _repeat = false ; <nl> - QString _time ; <nl> - Text _name ; <nl> - bool _showPause = false ; <nl> - int64 _position = 0 ; <nl> - int64 _duration = 0 ; <nl> - int32 _loaded = 0 ; <nl> - <nl> - anim : : fvalue a_progress = { 0 . , 0 . } ; <nl> - anim : : fvalue a_loadProgress = { 0 . , 0 . } ; <nl> - Animation _a_progress ; <nl> - <nl> - } ; <nl> mmm a / Telegram / SourceFiles / profile / profile_widget . cpp <nl> ppp b / Telegram / SourceFiles / profile / profile_widget . cpp <nl> Widget : : Widget ( QWidget * parent , PeerData * peer ) : Window : : SectionWidget ( parent ) <nl> _fixedBar - > resizeToWidth ( width ( ) ) ; <nl> _fixedBar - > show ( ) ; <nl> <nl> - _fixedBarShadow - > setMode ( ToggleableShadow : : Mode : : HiddenFast ) ; <nl> + _fixedBarShadow - > setMode ( Ui : : ToggleableShadow : : Mode : : HiddenFast ) ; <nl> _fixedBarShadow - > raise ( ) ; <nl> updateAdaptiveLayout ( ) ; <nl> subscribe ( Adaptive : : Changed ( ) , [ this ] ( ) { updateAdaptiveLayout ( ) ; } ) ; <nl> bool Widget : : showInternal ( const Window : : SectionMemento * memento ) { <nl> void Widget : : setInternalState ( const SectionMemento * memento ) { <nl> myEnsureResized ( this ) ; <nl> _scroll - > scrollToY ( memento - > _scrollTop ) ; <nl> - _fixedBarShadow - > setMode ( memento - > _scrollTop > 0 ? ToggleableShadow : : Mode : : ShownFast : ToggleableShadow : : Mode : : HiddenFast ) ; <nl> + _fixedBarShadow - > setMode ( memento - > _scrollTop > 0 ? Ui : : ToggleableShadow : : Mode : : ShownFast : Ui : : ToggleableShadow : : Mode : : HiddenFast ) ; <nl> } <nl> <nl> std_ : : unique_ptr < Window : : SectionMemento > Widget : : createMemento ( ) const { <nl> void Widget : : resizeEvent ( QResizeEvent * e ) { <nl> } <nl> int scrollTop = _scroll - > scrollTop ( ) ; <nl> _inner - > setVisibleTopBottom ( scrollTop , scrollTop + _scroll - > height ( ) ) ; <nl> - _fixedBarShadow - > setMode ( ( scrollTop > 0 ) ? ToggleableShadow : : Mode : : Shown : ToggleableShadow : : Mode : : Hidden ) ; <nl> + _fixedBarShadow - > setMode ( ( scrollTop > 0 ) ? Ui : : ToggleableShadow : : Mode : : Shown : Ui : : ToggleableShadow : : Mode : : Hidden ) ; <nl> } <nl> } <nl> <nl> void Widget : : onScroll ( ) { <nl> int scrollTop = _scroll - > scrollTop ( ) ; <nl> _inner - > setVisibleTopBottom ( scrollTop , scrollTop + _scroll - > height ( ) ) ; <nl> - _fixedBarShadow - > setMode ( ( scrollTop > 0 ) ? ToggleableShadow : : Mode : : Shown : ToggleableShadow : : Mode : : Hidden ) ; <nl> + _fixedBarShadow - > setMode ( ( scrollTop > 0 ) ? Ui : : ToggleableShadow : : Mode : : Shown : Ui : : ToggleableShadow : : Mode : : Hidden ) ; <nl> } <nl> <nl> void Widget : : showAnimatedHook ( ) { <nl> mmm a / Telegram / SourceFiles / profile / profile_widget . h <nl> ppp b / Telegram / SourceFiles / profile / profile_widget . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # pragma once <nl> <nl> # include " window / section_widget . h " <nl> + # include " ui / widgets / shadow . h " <nl> <nl> class ScrollArea ; <nl> <nl> private slots : <nl> ChildWidget < ScrollArea > _scroll ; <nl> ChildWidget < InnerWidget > _inner ; <nl> ChildWidget < FixedBar > _fixedBar ; <nl> - ChildWidget < ToggleableShadow > _fixedBarShadow ; <nl> + ChildWidget < Ui : : ToggleableShadow > _fixedBarShadow ; <nl> <nl> } ; <nl> <nl> mmm a / Telegram / SourceFiles / pspecific_mac_p . mm <nl> ppp b / Telegram / SourceFiles / pspecific_mac_p . mm <nl> <nl> # include " mainwindow . h " <nl> # include " mainwidget . h " <nl> # include " application . h " <nl> - # include " playerwidget . h " <nl> # include " localstorage . h " <nl> # include " media / player / media_player_instance . h " <nl> # include " platform / mac / mac_utilities . h " <nl> mmm a / Telegram / SourceFiles / settings / settings_widget . cpp <nl> ppp b / Telegram / SourceFiles / settings / settings_widget . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " settings / settings_inner_widget . h " <nl> # include " settings / settings_fixed_bar . h " <nl> # include " styles / style_settings . h " <nl> + # include " ui / widgets / shadow . h " <nl> # include " ui / scrollarea . h " <nl> # include " mainwindow . h " <nl> # include " mainwidget . h " <nl> mmm a / Telegram / SourceFiles / settings / settings_widget . h <nl> ppp b / Telegram / SourceFiles / settings / settings_widget . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> <nl> # include " layerwidget . h " <nl> <nl> + namespace Ui { <nl> + class PlainShadow ; <nl> + } / / namespace Ui <nl> + <nl> namespace Settings { <nl> <nl> class InnerWidget ; <nl> private slots : <nl> ChildWidget < ScrollArea > _scroll ; <nl> ChildWidget < InnerWidget > _inner ; <nl> ChildWidget < FixedBar > _fixedBar ; <nl> - ChildWidget < PlainShadow > _fixedBarShadow1 , _fixedBarShadow2 ; <nl> + ChildWidget < Ui : : PlainShadow > _fixedBarShadow1 , _fixedBarShadow2 ; <nl> <nl> int _contentLeft = 0 ; <nl> <nl> mmm a / Telegram / SourceFiles / stickers / emoji_pan . cpp <nl> ppp b / Telegram / SourceFiles / stickers / emoji_pan . cpp <nl> void StickerPanInner : : selectInlineResult ( int row , int column ) { <nl> } else if ( document - > loading ( ) ) { <nl> document - > cancel ( ) ; <nl> } else { <nl> - DocumentOpenClickHandler : : doOpen ( document , ActionOnLoadNone ) ; <nl> + DocumentOpenClickHandler : : doOpen ( document , nullptr , ActionOnLoadNone ) ; <nl> } <nl> } else if ( auto inlineResult = item - > getResult ( ) ) { <nl> if ( inlineResult - > onChoose ( item ) ) { <nl> mmm a / Telegram / SourceFiles / structs . cpp <nl> ppp b / Telegram / SourceFiles / structs . cpp <nl> bool StickerData : : setInstalled ( ) const { <nl> } <nl> <nl> QString documentSaveFilename ( const DocumentData * data , bool forceSavingAs = false , const QString already = QString ( ) , const QDir & dir = QDir ( ) ) { <nl> + auto alreadySavingFilename = data - > loadingFilePath ( ) ; <nl> + if ( ! alreadySavingFilename . isEmpty ( ) ) { <nl> + return alreadySavingFilename ; <nl> + } <nl> + <nl> QString name , filter , caption , prefix ; <nl> MimeType mimeType = mimeTypeForName ( data - > mime ) ; <nl> QStringList p = mimeType . globPatterns ( ) ; <nl> QString documentSaveFilename ( const DocumentData * data , bool forceSavingAs = fals <nl> return saveFileName ( caption , filter , prefix , name , forceSavingAs , dir ) ; <nl> } <nl> <nl> - void DocumentOpenClickHandler : : doOpen ( DocumentData * data , ActionOnLoad action ) { <nl> + void DocumentOpenClickHandler : : doOpen ( DocumentData * data , HistoryItem * context , ActionOnLoad action ) { <nl> if ( ! data - > date ) return ; <nl> <nl> - HistoryItem * item = App : : hoveredLinkItem ( ) ? App : : hoveredLinkItem ( ) : ( App : : contextItem ( ) ? App : : contextItem ( ) : nullptr ) ; <nl> - FullMsgId msgId ; <nl> - if ( item ) { <nl> - msgId = item - > fullId ( ) ; <nl> - } <nl> + auto msgId = context ? context - > fullId ( ) : FullMsgId ( ) ; <nl> bool playVoice = data - > voice ( ) & & audioPlayer ( ) ; <nl> bool playMusic = data - > song ( ) & & audioPlayer ( ) ; <nl> bool playVideo = data - > isVideo ( ) & & audioPlayer ( ) ; <nl> - bool playAnimation = data - > isAnimation ( ) & & item & & item - > getMedia ( ) ; <nl> - const FileLocation & location ( data - > location ( true ) ) ; <nl> + bool playAnimation = data - > isAnimation ( ) ; <nl> + auto & location = data - > location ( true ) ; <nl> if ( ! location . isEmpty ( ) | | ( ! data - > data ( ) . isEmpty ( ) & & ( playVoice | | playMusic | | playVideo | | playAnimation ) ) ) { <nl> if ( playVoice ) { <nl> AudioMsgId playing ; <nl> void DocumentOpenClickHandler : : doOpen ( DocumentData * data , ActionOnLoad action ) { <nl> } <nl> } else if ( playVideo ) { <nl> if ( ! data - > data ( ) . isEmpty ( ) ) { <nl> - App : : wnd ( ) - > showDocument ( data , item ) ; <nl> + App : : wnd ( ) - > showDocument ( data , context ) ; <nl> } else if ( location . accessEnable ( ) ) { <nl> - App : : wnd ( ) - > showDocument ( data , item ) ; <nl> + App : : wnd ( ) - > showDocument ( data , context ) ; <nl> location . accessDisable ( ) ; <nl> } else { <nl> auto filepath = location . name ( ) ; <nl> void DocumentOpenClickHandler : : doOpen ( DocumentData * data , ActionOnLoad action ) { <nl> if ( App : : main ( ) ) App : : main ( ) - > mediaMarkRead ( data ) ; <nl> } else if ( data - > size < MediaViewImageSizeLimit ) { <nl> if ( ! data - > data ( ) . isEmpty ( ) & & playAnimation ) { <nl> - if ( action = = ActionOnLoadPlayInline & & item - > getMedia ( ) ) { <nl> - item - > getMedia ( ) - > playInline ( item ) ; <nl> + if ( action = = ActionOnLoadPlayInline & & context & & context - > getMedia ( ) ) { <nl> + context - > getMedia ( ) - > playInline ( context ) ; <nl> } else { <nl> - App : : wnd ( ) - > showDocument ( data , item ) ; <nl> + App : : wnd ( ) - > showDocument ( data , context ) ; <nl> } <nl> } else if ( location . accessEnable ( ) ) { <nl> if ( data - > isAnimation ( ) | | QImageReader ( location . name ( ) ) . canRead ( ) ) { <nl> - if ( action = = ActionOnLoadPlayInline & & item & & item - > getMedia ( ) ) { <nl> - item - > getMedia ( ) - > playInline ( item ) ; <nl> + if ( action = = ActionOnLoadPlayInline & & context & & context - > getMedia ( ) ) { <nl> + context - > getMedia ( ) - > playInline ( context ) ; <nl> } else { <nl> - App : : wnd ( ) - > showDocument ( data , item ) ; <nl> + App : : wnd ( ) - > showDocument ( data , context ) ; <nl> } <nl> } else { <nl> psOpenFile ( location . name ( ) ) ; <nl> void DocumentOpenClickHandler : : doOpen ( DocumentData * data , ActionOnLoad action ) { <nl> } <nl> <nl> void DocumentOpenClickHandler : : onClickImpl ( ) const { <nl> - doOpen ( document ( ) , document ( ) - > voice ( ) ? ActionOnLoadNone : ActionOnLoadOpen ) ; <nl> + auto item = App : : hoveredLinkItem ( ) ? App : : hoveredLinkItem ( ) : ( App : : contextItem ( ) ? App : : contextItem ( ) : nullptr ) ; <nl> + doOpen ( document ( ) , item , document ( ) - > voice ( ) ? ActionOnLoadNone : ActionOnLoadOpen ) ; <nl> } <nl> <nl> void GifOpenClickHandler : : onClickImpl ( ) const { <nl> - doOpen ( document ( ) , ActionOnLoadPlayInline ) ; <nl> + auto item = App : : hoveredLinkItem ( ) ? App : : hoveredLinkItem ( ) : ( App : : contextItem ( ) ? App : : contextItem ( ) : nullptr ) ; <nl> + doOpen ( document ( ) , item , ActionOnLoadPlayInline ) ; <nl> } <nl> <nl> void DocumentSaveClickHandler : : doSave ( DocumentData * data , bool forceSavingAs ) { <nl> bool DocumentData : : loading ( ) const { <nl> return _loader & & _loader ! = CancelledMtpFileLoader ; <nl> } <nl> <nl> + QString DocumentData : : loadingFilePath ( ) const { <nl> + return loading ( ) ? _loader - > fileName ( ) : QString ( ) ; <nl> + } <nl> + <nl> bool DocumentData : : displayLoading ( ) const { <nl> return loading ( ) ? ( ! _loader - > loadingLocal ( ) | | ! _loader - > autoLoading ( ) ) : uploading ( ) ; <nl> } <nl> bool DocumentData : : uploading ( ) const { <nl> } <nl> <nl> void DocumentData : : save ( const QString & toFile , ActionOnLoad action , const FullMsgId & actionMsgId , LoadFromCloudSetting fromCloud , bool autoLoading ) { <nl> - _actionOnLoad = action ; <nl> - _actionOnLoadMsgId = actionMsgId ; <nl> - <nl> if ( loaded ( FilePathResolveChecked ) ) { <nl> - const FileLocation & l ( location ( true ) ) ; <nl> + auto & l = location ( true ) ; <nl> if ( ! toFile . isEmpty ( ) ) { <nl> if ( ! _data . isEmpty ( ) ) { <nl> QFile f ( toFile ) ; <nl> void DocumentData : : save ( const QString & toFile , ActionOnLoad action , const FullMs <nl> setLocation ( FileLocation ( StorageFilePartial , toFile ) ) ; <nl> Local : : writeFileLocation ( mediaKey ( ) , FileLocation ( mtpToStorageType ( mtpc_storage_filePartial ) , toFile ) ) ; <nl> } else if ( l . accessEnable ( ) ) { <nl> - QFile ( l . name ( ) ) . copy ( toFile ) ; <nl> + auto alreadyName = l . name ( ) ; <nl> + if ( alreadyName ! = toFile ) { <nl> + QFile ( alreadyName ) . copy ( toFile ) ; <nl> + } <nl> l . accessDisable ( ) ; <nl> } <nl> } <nl> + _actionOnLoad = action ; <nl> + _actionOnLoadMsgId = actionMsgId ; <nl> performActionOnLoad ( ) ; <nl> return ; <nl> } <nl> <nl> - if ( _loader = = CancelledMtpFileLoader ) _loader = 0 ; <nl> + if ( _loader = = CancelledMtpFileLoader ) _loader = nullptr ; <nl> if ( _loader ) { <nl> if ( ! _loader - > setFileName ( toFile ) ) { <nl> - cancel ( ) ; <nl> - _loader = 0 ; <nl> + cancel ( ) ; / / changes _actionOnLoad <nl> + _loader = nullptr ; <nl> } <nl> } <nl> <nl> + _actionOnLoad = action ; <nl> + _actionOnLoadMsgId = actionMsgId ; <nl> if ( _loader ) { <nl> if ( fromCloud = = LoadFromCloudOrLocal ) _loader - > permitLoadFromCloud ( ) ; <nl> } else { <nl> mmm a / Telegram / SourceFiles / structs . h <nl> ppp b / Telegram / SourceFiles / structs . h <nl> class DocumentData { <nl> } ; <nl> bool loaded ( FilePathResolveType type = FilePathResolveCached ) const ; <nl> bool loading ( ) const ; <nl> + QString loadingFilePath ( ) const ; <nl> bool displayLoading ( ) const ; <nl> void save ( const QString & toFile , ActionOnLoad action = ActionOnLoadNone , const FullMsgId & actionMsgId = FullMsgId ( ) , LoadFromCloudSetting fromCloud = LoadFromCloudOrLocal , bool autoLoading = false ) ; <nl> void cancel ( ) ; <nl> class DocumentSaveClickHandler : public DocumentClickHandler { <nl> class DocumentOpenClickHandler : public DocumentClickHandler { <nl> public : <nl> using DocumentClickHandler : : DocumentClickHandler ; <nl> - static void doOpen ( DocumentData * document , ActionOnLoad action = ActionOnLoadOpen ) ; <nl> + static void doOpen ( DocumentData * document , HistoryItem * context , ActionOnLoad action = ActionOnLoadOpen ) ; <nl> protected : <nl> void onClickImpl ( ) const override ; <nl> } ; <nl> mmm a / Telegram / SourceFiles / title . cpp <nl> ppp b / Telegram / SourceFiles / title . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> # include " boxes / aboutbox . h " <nl> # include " media / media_audio . h " <nl> # include " media / player / media_player_title_button . h " <nl> - # include " media / player / media_player_widget . h " <nl> + # include " media / player / media_player_panel . h " <nl> # include " media / player / media_player_instance . h " <nl> <nl> class TitleWidget : : Hider : public TWidget { <nl> TitleWidget : : TitleWidget ( QWidget * parent ) : TWidget ( parent ) <nl> <nl> subscribe ( Adaptive : : Changed ( ) , [ this ] ( ) { updateAdaptiveLayout ( ) ; } ) ; <nl> if ( Media : : Player : : exists ( ) ) { <nl> - subscribe ( Media : : Player : : instance ( ) - > createdNotifier ( ) , [ this ] ( const Media : : Player : : CreatedEvent & e ) { <nl> + subscribe ( Media : : Player : : instance ( ) - > createdNotifier ( ) , [ this ] ( const Media : : Player : : PanelEvent & e ) { <nl> if ( ! _player ) { <nl> _player . create ( this ) ; <nl> - _player - > installEventFilter ( e . widget ) ; <nl> + updateControlsVisibility ( ) ; <nl> + } <nl> + _player - > installEventFilter ( e . panel ) ; <nl> + } ) ; <nl> + subscribe ( Media : : Player : : instance ( ) - > destroyedNotifier ( ) , [ this ] ( const Media : : Player : : PanelEvent & e ) { <nl> + if ( _player ) { <nl> + _player . destroyDelayed ( ) ; <nl> updateControlsVisibility ( ) ; <nl> } <nl> } ) ; <nl> mmm a / Telegram / SourceFiles / title . h <nl> ppp b / Telegram / SourceFiles / title . h <nl> class MainWindow ; <nl> namespace Media { <nl> namespace Player { <nl> class TitleButton ; <nl> - class CreatedEvent ; <nl> + class PanelEvent ; <nl> } / / namespace Player <nl> } / / namespace Media <nl> class AudioMsgId ; <nl> public slots : <nl> void updateSystemButtonsVisibility ( ) ; <nl> void updateControlsPosition ( ) ; <nl> <nl> - void handleMediaPlayerCreated ( const Media : : Player : : CreatedEvent & e ) ; <nl> - <nl> style : : color statusColor ; <nl> <nl> class Hider ; <nl> mmm a / Telegram / SourceFiles / ui / effects / rect_shadow . cpp <nl> ppp b / Telegram / SourceFiles / ui / effects / rect_shadow . cpp <nl> void RectShadow : : paint ( Painter & p , const QRect & box , int shifty , Sides sides ) { <nl> <nl> bool wasSmooth = p . renderHints ( ) . testFlag ( QPainter : : SmoothPixmapTransform ) ; <nl> if ( wasSmooth ) p . setRenderHint ( QPainter : : SmoothPixmapTransform , false ) ; <nl> - if ( left ) p . drawPixmap ( box . left ( ) - countsize + shifty , box . top ( ) + ( top ? minus : 0 ) + shifty , countsize - shifty , box . height ( ) - ( bottom ? minus : 0 ) - ( top ? minus : 0 ) , _left , 0 , 0 , count - rshifty , 1 ) ; <nl> + if ( left ) p . drawPixmap ( box . left ( ) - countsize + shifty , box . top ( ) + ( top ? ( minus + shifty ) : 0 ) , countsize - shifty , box . height ( ) - ( bottom ? ( minus - shifty ) : 0 ) - ( top ? ( minus + shifty ) : 0 ) , _left , 0 , 0 , count - rshifty , 1 ) ; <nl> if ( top ) p . drawPixmap ( box . left ( ) + ( left ? minus : 0 ) , box . top ( ) - countsize + 2 * shifty , box . width ( ) - ( right ? minus : 0 ) - ( left ? minus : 0 ) , countsize - 2 * shifty , _top , 0 , 0 , 1 , count - 2 * rshifty ) ; <nl> - if ( right ) p . drawPixmap ( box . left ( ) + box . width ( ) , box . top ( ) + ( top ? minus : 0 ) + shifty , countsize - shifty , box . height ( ) - ( bottom ? minus : 0 ) - ( top ? minus : 0 ) , _right , rshifty , 0 , count - rshifty , 1 ) ; <nl> + if ( right ) p . drawPixmap ( box . left ( ) + box . width ( ) , box . top ( ) + ( top ? ( minus + shifty ) : 0 ) , countsize - shifty , box . height ( ) - ( bottom ? ( minus - shifty ) : 0 ) - ( top ? ( minus + shifty ) : 0 ) , _right , rshifty , 0 , count - rshifty , 1 ) ; <nl> if ( bottom ) p . drawPixmap ( box . left ( ) + ( left ? minus : 0 ) , box . top ( ) + box . height ( ) , box . width ( ) - ( right ? minus : 0 ) - ( left ? minus : 0 ) , countsize , _bottom , 0 , 0 , 1 , count ) ; <nl> if ( wasSmooth ) p . setRenderHint ( QPainter : : SmoothPixmapTransform ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / ui / filedialog . cpp <nl> ppp b / Telegram / SourceFiles / ui / filedialog . cpp <nl> using QueryList = QList < Query > ; <nl> NeverFreedPointer < QueryList > Queries ; <nl> <nl> void StartCallback ( ) { <nl> - Queries . makeIfNull ( ) ; <nl> + Queries . createIfNull ( ) ; <nl> } <nl> <nl> } / / namespace <nl> <nl> QueryId queryReadFile ( const QString & caption , const QString & filter ) { <nl> - Queries . makeIfNull ( ) ; <nl> + Queries . createIfNull ( ) ; <nl> <nl> Queries - > push_back ( Query ( Query : : Type : : ReadFile , caption , filter ) ) ; <nl> Global : : RefHandleFileDialogQueue ( ) . call ( ) ; <nl> QueryId queryReadFile ( const QString & caption , const QString & filter ) { <nl> } <nl> <nl> QueryId queryReadFiles ( const QString & caption , const QString & filter ) { <nl> - Queries . makeIfNull ( ) ; <nl> + Queries . createIfNull ( ) ; <nl> <nl> Queries - > push_back ( Query ( Query : : Type : : ReadFiles , caption , filter ) ) ; <nl> Global : : RefHandleFileDialogQueue ( ) . call ( ) ; <nl> QueryId queryReadFiles ( const QString & caption , const QString & filter ) { <nl> } <nl> <nl> QueryId queryWriteFile ( const QString & caption , const QString & filter , const QString & filePath ) { <nl> - Queries . makeIfNull ( ) ; <nl> + Queries . createIfNull ( ) ; <nl> <nl> Queries - > push_back ( Query ( Query : : Type : : WriteFile , caption , filter , filePath ) ) ; <nl> Global : : RefHandleFileDialogQueue ( ) . call ( ) ; <nl> QueryId queryWriteFile ( const QString & caption , const QString & filter , const QStr <nl> } <nl> <nl> QueryId queryReadFolder ( const QString & caption ) { <nl> - Queries . makeIfNull ( ) ; <nl> + Queries . createIfNull ( ) ; <nl> <nl> Queries - > push_back ( Query ( Query : : Type : : ReadFolder , caption ) ) ; <nl> Global : : RefHandleFileDialogQueue ( ) . call ( ) ; <nl> mmm a / Telegram / SourceFiles / ui / style / style_core . cpp <nl> ppp b / Telegram / SourceFiles / ui / style / style_core . cpp <nl> void stopModules ( ) { <nl> } / / namespace <nl> <nl> void registerModule ( ModuleBase * module ) { <nl> - styleModules . makeIfNull ( ) ; <nl> + styleModules . createIfNull ( ) ; <nl> styleModules - > push_back ( module ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / ui / style / style_core_icon . cpp <nl> ppp b / Telegram / SourceFiles / ui / style / style_core_icon . cpp <nl> void MonoIcon : : ensureLoaded ( ) const { <nl> if ( _owningPixmap ) { <nl> _pixmap = createIconPixmap ( _mask , _color ) ; <nl> } else { <nl> - iconPixmaps . makeIfNull ( ) ; <nl> + iconPixmaps . createIfNull ( ) ; <nl> auto key = qMakePair ( _mask , colorKey ( _color - > c ) ) ; <nl> auto i = iconPixmaps - > constFind ( key ) ; <nl> if ( i = = iconPixmaps - > cend ( ) ) { <nl> mmm a / Telegram / SourceFiles / ui / toast / toast_manager . cpp <nl> ppp b / Telegram / SourceFiles / ui / toast / toast_manager . cpp <nl> Manager : : Manager ( QWidget * parent ) : QObject ( parent ) { <nl> } <nl> <nl> Manager * Manager : : instance ( QWidget * parent ) { <nl> - _managers . makeIfNull ( ) ; <nl> + _managers . createIfNull ( ) ; <nl> auto i = _managers - > constFind ( parent ) ; <nl> if ( i = = _managers - > cend ( ) ) { <nl> i = _managers - > insert ( parent , new Manager ( parent ) ) ; <nl> mmm a / Telegram / SourceFiles / ui / twidget . cpp <nl> ppp b / Telegram / SourceFiles / ui / twidget . cpp <nl> QPixmap myGrab ( TWidget * target , QRect rect ) { <nl> return result ; <nl> } <nl> <nl> - enum class Mode { <nl> - Shown , <nl> - ShownFast , <nl> - Hidden , <nl> - HiddenFast <nl> - } ; <nl> - void ToggleableShadow : : setMode ( Mode mode ) { <nl> - if ( mode = = Mode : : ShownFast | | mode = = Mode : : HiddenFast ) { <nl> - if ( ! _a_opacity . animating ( ) ) { <nl> - _a_opacity . finish ( ) ; <nl> - update ( ) ; <nl> - } <nl> - } <nl> - if ( _shown & & ( mode = = Mode : : Hidden | | mode = = Mode : : HiddenFast ) ) { <nl> - _shown = false ; <nl> - if ( mode = = Mode : : Hidden ) { <nl> - _a_opacity . start ( [ this ] { update ( ) ; } , 1 . , 0 . , st : : shadowToggleDuration ) ; <nl> - } <nl> - } else if ( ! _shown & & ( mode = = Mode : : Shown | | mode = = Mode : : ShownFast ) ) { <nl> - _shown = true ; <nl> - if ( mode = = Mode : : Shown ) { <nl> - _a_opacity . start ( [ this ] { update ( ) ; } , 0 . , 1 . , st : : shadowToggleDuration ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void ToggleableShadow : : paintEvent ( QPaintEvent * e ) { <nl> - Painter p ( this ) ; <nl> - if ( _a_opacity . animating ( getms ( ) ) ) { <nl> - p . setOpacity ( _a_opacity . current ( ) ) ; <nl> - } else if ( ! _shown ) { <nl> - return ; <nl> - } <nl> - p . fillRect ( e - > rect ( ) , _color ) ; <nl> - } <nl> - <nl> void sendSynteticMouseEvent ( QWidget * widget , QEvent : : Type type , Qt : : MouseButton button , const QPoint & globalPoint ) { <nl> if ( auto windowHandle = widget - > window ( ) - > windowHandle ( ) ) { <nl> auto localPoint = windowHandle - > mapFromGlobal ( globalPoint ) ; <nl> mmm a / Telegram / SourceFiles / ui / twidget . h <nl> ppp b / Telegram / SourceFiles / ui / twidget . h <nl> class Painter : public QPainter { <nl> } <nl> } ; <nl> <nl> - # define T_WIDGET public : \ <nl> - TWidget * tparent ( ) { \ <nl> - return qobject_cast < TWidget * > ( parentWidget ( ) ) ; \ <nl> - } \ <nl> - const TWidget * tparent ( ) const { \ <nl> - return qobject_cast < const TWidget * > ( parentWidget ( ) ) ; \ <nl> - } \ <nl> - virtual void leaveToChildEvent ( QEvent * e , QWidget * child ) { / * e - - from enterEvent ( ) of child TWidget * / \ <nl> - } \ <nl> - virtual void enterFromChildEvent ( QEvent * e , QWidget * child ) { / * e - - from leaveEvent ( ) of child TWidget * / \ <nl> - } \ <nl> - void moveToLeft ( int x , int y , int outerw = 0 ) { \ <nl> - move ( rtl ( ) ? ( ( outerw > 0 ? outerw : parentWidget ( ) - > width ( ) ) - x - width ( ) ) : x , y ) ; \ <nl> - } \ <nl> - void moveToRight ( int x , int y , int outerw = 0 ) { \ <nl> - move ( rtl ( ) ? x : ( ( outerw > 0 ? outerw : parentWidget ( ) - > width ( ) ) - x - width ( ) ) , y ) ; \ <nl> - } \ <nl> - QPoint myrtlpoint ( int x , int y ) const { \ <nl> - return rtlpoint ( x , y , width ( ) ) ; \ <nl> - } \ <nl> - QPoint myrtlpoint ( const QPoint p ) const { \ <nl> - return rtlpoint ( p , width ( ) ) ; \ <nl> - } \ <nl> - QRect myrtlrect ( int x , int y , int w , int h ) const { \ <nl> - return rtlrect ( x , y , w , h , width ( ) ) ; \ <nl> - } \ <nl> - QRect myrtlrect ( const QRect & r ) { \ <nl> - return rtlrect ( r , width ( ) ) ; \ <nl> - } \ <nl> - void rtlupdate ( const QRect & r ) { \ <nl> - update ( myrtlrect ( r ) ) ; \ <nl> - } \ <nl> - void rtlupdate ( int x , int y , int w , int h ) { \ <nl> - update ( myrtlrect ( x , y , w , h ) ) ; \ <nl> - } \ <nl> + # define T_WIDGET \ <nl> + public : \ <nl> + TWidget * tparent ( ) { \ <nl> + return qobject_cast < TWidget * > ( parentWidget ( ) ) ; \ <nl> + } \ <nl> + const TWidget * tparent ( ) const { \ <nl> + return qobject_cast < const TWidget * > ( parentWidget ( ) ) ; \ <nl> + } \ <nl> + virtual void leaveToChildEvent ( QEvent * e , QWidget * child ) { / * e - - from enterEvent ( ) of child TWidget * / \ <nl> + } \ <nl> + virtual void enterFromChildEvent ( QEvent * e , QWidget * child ) { / * e - - from leaveEvent ( ) of child TWidget * / \ <nl> + } \ <nl> + void moveToLeft ( int x , int y , int outerw = 0 ) { \ <nl> + move ( rtl ( ) ? ( ( outerw > 0 ? outerw : parentWidget ( ) - > width ( ) ) - x - width ( ) ) : x , y ) ; \ <nl> + } \ <nl> + void moveToRight ( int x , int y , int outerw = 0 ) { \ <nl> + move ( rtl ( ) ? x : ( ( outerw > 0 ? outerw : parentWidget ( ) - > width ( ) ) - x - width ( ) ) , y ) ; \ <nl> + } \ <nl> + void setGeometryToLeft ( int x , int y , int w , int h , int outerw = 0 ) { \ <nl> + setGeometry ( rtl ( ) ? ( ( outerw > 0 ? outerw : parentWidget ( ) - > width ( ) ) - x - w ) : x , y , w , h ) ; \ <nl> + } \ <nl> + void setGeometryToRight ( int x , int y , int w , int h , int outerw = 0 ) { \ <nl> + setGeometry ( rtl ( ) ? x : ( ( outerw > 0 ? outerw : parentWidget ( ) - > width ( ) ) - x - w ) , y , w , h ) ; \ <nl> + } \ <nl> + QPoint myrtlpoint ( int x , int y ) const { \ <nl> + return rtlpoint ( x , y , width ( ) ) ; \ <nl> + } \ <nl> + QPoint myrtlpoint ( const QPoint p ) const { \ <nl> + return rtlpoint ( p , width ( ) ) ; \ <nl> + } \ <nl> + QRect myrtlrect ( int x , int y , int w , int h ) const { \ <nl> + return rtlrect ( x , y , w , h , width ( ) ) ; \ <nl> + } \ <nl> + QRect myrtlrect ( const QRect & r ) const { \ <nl> + return rtlrect ( r , width ( ) ) ; \ <nl> + } \ <nl> + void rtlupdate ( const QRect & r ) { \ <nl> + update ( myrtlrect ( r ) ) ; \ <nl> + } \ <nl> + void rtlupdate ( int x , int y , int w , int h ) { \ <nl> + update ( myrtlrect ( x , y , w , h ) ) ; \ <nl> + } \ <nl> protected : \ <nl> - void enterEvent ( QEvent * e ) override { \ <nl> - TWidget * p ( tparent ( ) ) ; \ <nl> - if ( p ) p - > leaveToChildEvent ( e , this ) ; \ <nl> - return enterEventHook ( e ) ; \ <nl> - } \ <nl> - void leaveEvent ( QEvent * e ) override { \ <nl> - TWidget * p ( tparent ( ) ) ; \ <nl> - if ( p ) p - > enterFromChildEvent ( e , this ) ; \ <nl> - return leaveEventHook ( e ) ; \ <nl> - } <nl> + void enterEvent ( QEvent * e ) override { \ <nl> + TWidget * p ( tparent ( ) ) ; \ <nl> + if ( p ) p - > leaveToChildEvent ( e , this ) ; \ <nl> + return enterEventHook ( e ) ; \ <nl> + } \ <nl> + void leaveEvent ( QEvent * e ) override { \ <nl> + TWidget * p ( tparent ( ) ) ; \ <nl> + if ( p ) p - > enterFromChildEvent ( e , this ) ; \ <nl> + return leaveEventHook ( e ) ; \ <nl> + } <nl> <nl> class TWidget : public QWidget { <nl> Q_OBJECT <nl> class TWidget : public QWidget { <nl> void myEnsureResized ( QWidget * target ) ; <nl> QPixmap myGrab ( TWidget * target , QRect rect = QRect ( ) ) ; <nl> <nl> - class PlainShadow : public TWidget { <nl> - public : <nl> - PlainShadow ( QWidget * parent , const style : : color & color ) : TWidget ( parent ) , _color ( color ) { <nl> - } <nl> - <nl> - protected : <nl> - void paintEvent ( QPaintEvent * e ) override { <nl> - Painter ( this ) . fillRect ( e - > rect ( ) , _color - > b ) ; <nl> - } <nl> - <nl> - private : <nl> - const style : : color & _color ; <nl> - <nl> - } ; <nl> - <nl> - class ToggleableShadow : public TWidget { <nl> - public : <nl> - ToggleableShadow ( QWidget * parent , const style : : color & color ) : TWidget ( parent ) , _color ( color ) { <nl> - } <nl> - <nl> - enum class Mode { <nl> - Shown , <nl> - ShownFast , <nl> - Hidden , <nl> - HiddenFast <nl> - } ; <nl> - void setMode ( Mode mode ) ; <nl> - <nl> - bool isFullyShown ( ) const { <nl> - return _shown & & ! _a_opacity . animating ( ) ; <nl> - } <nl> - <nl> - protected : <nl> - void paintEvent ( QPaintEvent * e ) override ; <nl> - <nl> - private : <nl> - const style : : color & _color ; <nl> - FloatAnimation _a_opacity ; <nl> - bool _shown = true ; <nl> - <nl> - } ; <nl> - <nl> class SingleDelayedCall : public QObject { <nl> Q_OBJECT <nl> <nl> new file mode 100644 <nl> index 00000000000 . . 2863855b2b5 <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / ui / widgets / continuous_slider . cpp <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> + <nl> + Telegram Desktop is free software : you can redistribute it and / or modify <nl> + it under the terms of the GNU General Public License as published by <nl> + the Free Software Foundation , either version 3 of the License , or <nl> + ( at your option ) any later version . <nl> + <nl> + It is distributed in the hope that it will be useful , <nl> + but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + GNU General Public License for more details . <nl> + <nl> + In addition , as a special exception , the copyright holders give permission <nl> + to link the code of portions of this program with the OpenSSL library . <nl> + <nl> + Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> + Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> + * / <nl> + # include " stdafx . h " <nl> + # include " ui / widgets / continuous_slider . h " <nl> + <nl> + namespace Ui { <nl> + <nl> + ContinuousSlider : : ContinuousSlider ( QWidget * parent ) : TWidget ( parent ) <nl> + , _a_value ( animation ( this , & ContinuousSlider : : step_value ) ) { <nl> + setCursor ( style : : cur_pointer ) ; <nl> + } <nl> + <nl> + float64 ContinuousSlider : : value ( ) const { <nl> + return a_value . current ( ) ; <nl> + } <nl> + <nl> + void ContinuousSlider : : setDisabled ( bool disabled ) { <nl> + if ( _disabled ! = disabled ) { <nl> + _disabled = disabled ; <nl> + setCursor ( _disabled ? style : : cur_default : style : : cur_pointer ) ; <nl> + update ( ) ; <nl> + } <nl> + } <nl> + <nl> + void ContinuousSlider : : setValue ( float64 value , bool animated ) { <nl> + if ( animated ) { <nl> + a_value . start ( value ) ; <nl> + _a_value . start ( ) ; <nl> + } else { <nl> + a_value = anim : : fvalue ( value , value ) ; <nl> + _a_value . stop ( ) ; <nl> + } <nl> + update ( ) ; <nl> + } <nl> + <nl> + void ContinuousSlider : : setFadeOpacity ( float64 opacity ) { <nl> + _fadeOpacity = opacity ; <nl> + update ( ) ; <nl> + } <nl> + <nl> + void ContinuousSlider : : step_value ( float64 ms , bool timer ) { <nl> + float64 dt = ms / ( 2 * AudioVoiceMsgUpdateView ) ; <nl> + if ( dt > = 1 ) { <nl> + _a_value . stop ( ) ; <nl> + a_value . finish ( ) ; <nl> + } else { <nl> + a_value . update ( qMin ( dt , 1 . ) , anim : : linear ) ; <nl> + } <nl> + if ( timer ) update ( ) ; <nl> + } <nl> + <nl> + void ContinuousSlider : : mouseMoveEvent ( QMouseEvent * e ) { <nl> + if ( _mouseDown ) { <nl> + updateDownValueFromPos ( e - > pos ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + float64 ContinuousSlider : : computeValue ( const QPoint & pos ) const { <nl> + auto seekRect = myrtlrect ( getSeekRect ( ) ) ; <nl> + auto result = isHorizontal ( ) ? <nl> + ( pos . x ( ) - seekRect . x ( ) ) / float64 ( seekRect . width ( ) ) : <nl> + ( 1 . - ( pos . y ( ) - seekRect . y ( ) ) / float64 ( seekRect . height ( ) ) ) ; <nl> + return snap ( result , 0 . , 1 . ) ; <nl> + } <nl> + <nl> + void ContinuousSlider : : mousePressEvent ( QMouseEvent * e ) { <nl> + _mouseDown = true ; <nl> + _downValue = computeValue ( e - > pos ( ) ) ; <nl> + update ( ) ; <nl> + if ( _changeProgressCallback ) { <nl> + _changeProgressCallback ( _downValue ) ; <nl> + } <nl> + } <nl> + <nl> + void ContinuousSlider : : mouseReleaseEvent ( QMouseEvent * e ) { <nl> + if ( _mouseDown ) { <nl> + _mouseDown = false ; <nl> + if ( _changeFinishedCallback ) { <nl> + _changeFinishedCallback ( _downValue ) ; <nl> + } <nl> + a_value = anim : : fvalue ( _downValue , _downValue ) ; <nl> + _a_value . stop ( ) ; <nl> + update ( ) ; <nl> + } <nl> + } <nl> + <nl> + void ContinuousSlider : : updateDownValueFromPos ( const QPoint & pos ) { <nl> + _downValue = computeValue ( pos ) ; <nl> + update ( ) ; <nl> + if ( _changeProgressCallback ) { <nl> + _changeProgressCallback ( _downValue ) ; <nl> + } <nl> + } <nl> + <nl> + void ContinuousSlider : : enterEvent ( QEvent * e ) { <nl> + setOver ( true ) ; <nl> + } <nl> + <nl> + void ContinuousSlider : : leaveEvent ( QEvent * e ) { <nl> + setOver ( false ) ; <nl> + } <nl> + <nl> + void ContinuousSlider : : setOver ( bool over ) { <nl> + if ( _over = = over ) return ; <nl> + <nl> + _over = over ; <nl> + auto from = _over ? 0 . : 1 . , to = _over ? 1 . : 0 . ; <nl> + _a_over . start ( [ this ] { update ( ) ; } , from , to , getOverDuration ( ) ) ; <nl> + } <nl> + <nl> + } / / namespace Ui <nl> new file mode 100644 <nl> index 00000000000 . . 1d063fa65c2 <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / ui / widgets / continuous_slider . h <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> + <nl> + Telegram Desktop is free software : you can redistribute it and / or modify <nl> + it under the terms of the GNU General Public License as published by <nl> + the Free Software Foundation , either version 3 of the License , or <nl> + ( at your option ) any later version . <nl> + <nl> + It is distributed in the hope that it will be useful , <nl> + but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + GNU General Public License for more details . <nl> + <nl> + In addition , as a special exception , the copyright holders give permission <nl> + to link the code of portions of this program with the OpenSSL library . <nl> + <nl> + Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> + Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> + * / <nl> + # pragma once <nl> + <nl> + namespace Ui { <nl> + <nl> + class ContinuousSlider : public TWidget { <nl> + public : <nl> + ContinuousSlider ( QWidget * parent ) ; <nl> + <nl> + enum class Direction { <nl> + Horizontal , <nl> + Vertical , <nl> + } ; <nl> + void setDirection ( Direction direction ) { <nl> + _direction = direction ; <nl> + update ( ) ; <nl> + } <nl> + <nl> + float64 value ( ) const ; <nl> + void setValue ( float64 value , bool animated ) ; <nl> + void setFadeOpacity ( float64 opacity ) ; <nl> + void setDisabled ( bool disabled ) ; <nl> + <nl> + using Callback = base : : lambda_unique < void ( float64 ) > ; <nl> + void setChangeProgressCallback ( Callback & & callback ) { <nl> + _changeProgressCallback = std_ : : move ( callback ) ; <nl> + } <nl> + void setChangeFinishedCallback ( Callback & & callback ) { <nl> + _changeFinishedCallback = std_ : : move ( callback ) ; <nl> + } <nl> + bool isChanging ( ) const { <nl> + return _mouseDown ; <nl> + } <nl> + <nl> + protected : <nl> + void mouseMoveEvent ( QMouseEvent * e ) override ; <nl> + void mousePressEvent ( QMouseEvent * e ) override ; <nl> + void mouseReleaseEvent ( QMouseEvent * e ) override ; <nl> + void enterEvent ( QEvent * e ) override ; <nl> + void leaveEvent ( QEvent * e ) override ; <nl> + <nl> + float64 fadeOpacity ( ) const { <nl> + return _fadeOpacity ; <nl> + } <nl> + float64 getCurrentValue ( uint64 ms ) { <nl> + _a_value . step ( ms ) ; <nl> + return _mouseDown ? _downValue : a_value . current ( ) ; <nl> + } <nl> + float64 getCurrentOverFactor ( uint64 ms ) { <nl> + return _a_over . current ( ms , _over ? 1 . : 0 . ) ; <nl> + } <nl> + bool isDisabled ( ) const { <nl> + return _disabled ; <nl> + } <nl> + Direction getDirection ( ) const { <nl> + return _direction ; <nl> + } <nl> + bool isHorizontal ( ) const { <nl> + return ( _direction = = Direction : : Horizontal ) ; <nl> + } <nl> + <nl> + private : <nl> + virtual QRect getSeekRect ( ) const = 0 ; <nl> + virtual float64 getOverDuration ( ) const = 0 ; <nl> + <nl> + void step_value ( float64 ms , bool timer ) ; <nl> + void setOver ( bool over ) ; <nl> + float64 computeValue ( const QPoint & pos ) const ; <nl> + void updateDownValueFromPos ( const QPoint & pos ) ; <nl> + <nl> + Direction _direction = Direction : : Horizontal ; <nl> + bool _disabled = false ; <nl> + <nl> + Callback _changeProgressCallback ; <nl> + Callback _changeFinishedCallback ; <nl> + <nl> + bool _over = false ; <nl> + FloatAnimation _a_over ; <nl> + <nl> + anim : : fvalue a_value = { 0 . , 0 . } ; <nl> + Animation _a_value ; <nl> + <nl> + bool _mouseDown = false ; <nl> + float64 _downValue = 0 . ; <nl> + <nl> + float64 _fadeOpacity = 1 . ; <nl> + <nl> + } ; <nl> + <nl> + } / / namespace Ui <nl> new file mode 100644 <nl> index 00000000000 . . 83dedadec30 <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / ui / widgets / filled_slider . cpp <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> + <nl> + Telegram Desktop is free software : you can redistribute it and / or modify <nl> + it under the terms of the GNU General Public License as published by <nl> + the Free Software Foundation , either version 3 of the License , or <nl> + ( at your option ) any later version . <nl> + <nl> + It is distributed in the hope that it will be useful , <nl> + but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + GNU General Public License for more details . <nl> + <nl> + In addition , as a special exception , the copyright holders give permission <nl> + to link the code of portions of this program with the OpenSSL library . <nl> + <nl> + Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> + Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> + * / <nl> + # include " stdafx . h " <nl> + # include " ui / widgets / filled_slider . h " <nl> + <nl> + # include " styles / style_widgets . h " <nl> + <nl> + namespace Ui { <nl> + <nl> + FilledSlider : : FilledSlider ( QWidget * parent , const style : : FilledSlider & st ) : ContinuousSlider ( parent ) <nl> + , _st ( st ) { <nl> + } <nl> + <nl> + QRect FilledSlider : : getSeekRect ( ) const { <nl> + return QRect ( 0 , 0 , width ( ) , height ( ) ) ; <nl> + } <nl> + <nl> + float64 FilledSlider : : getOverDuration ( ) const { <nl> + return _st . duration ; <nl> + } <nl> + <nl> + void FilledSlider : : paintEvent ( QPaintEvent * e ) { <nl> + Painter p ( this ) ; <nl> + p . setPen ( Qt : : NoPen ) ; <nl> + p . setRenderHint ( QPainter : : HighQualityAntialiasing ) ; <nl> + <nl> + auto masterOpacity = fadeOpacity ( ) ; <nl> + auto ms = getms ( ) ; <nl> + auto disabled = isDisabled ( ) ; <nl> + auto over = getCurrentOverFactor ( ms ) ; <nl> + auto lineWidth = _st . lineWidth + ( ( _st . fullWidth - _st . lineWidth ) * over ) ; <nl> + auto lineWidthRounded = qFloor ( lineWidth ) ; <nl> + auto lineWidthPartial = lineWidth - lineWidthRounded ; <nl> + auto seekRect = getSeekRect ( ) ; <nl> + auto value = getCurrentValue ( ms ) ; <nl> + auto from = seekRect . x ( ) , mid = disabled ? from : qRound ( from + value * seekRect . width ( ) ) , end = from + seekRect . width ( ) ; <nl> + if ( mid > from ) { <nl> + p . setOpacity ( masterOpacity ) ; <nl> + p . fillRect ( from , height ( ) - lineWidthRounded , ( mid - from ) , lineWidthRounded , _st . activeFg ) ; <nl> + if ( lineWidthPartial > 0 . 01 ) { <nl> + p . setOpacity ( masterOpacity * lineWidthPartial ) ; <nl> + p . fillRect ( from , height ( ) - lineWidthRounded - 1 , ( mid - from ) , 1 , _st . activeFg ) ; <nl> + } <nl> + } <nl> + if ( end > mid & & over > 0 ) { <nl> + p . setOpacity ( masterOpacity * over ) ; <nl> + p . fillRect ( mid , height ( ) - lineWidthRounded , ( end - mid ) , lineWidthRounded , _st . inactiveFg ) ; <nl> + if ( lineWidthPartial > 0 . 01 ) { <nl> + p . setOpacity ( masterOpacity * over * lineWidthPartial ) ; <nl> + p . fillRect ( mid , height ( ) - lineWidthRounded - 1 , ( end - mid ) , 1 , _st . inactiveFg ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + } / / namespace Ui <nl> new file mode 100644 <nl> index 00000000000 . . 7037b954485 <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / ui / widgets / filled_slider . h <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> + <nl> + Telegram Desktop is free software : you can redistribute it and / or modify <nl> + it under the terms of the GNU General Public License as published by <nl> + the Free Software Foundation , either version 3 of the License , or <nl> + ( at your option ) any later version . <nl> + <nl> + It is distributed in the hope that it will be useful , <nl> + but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + GNU General Public License for more details . <nl> + <nl> + In addition , as a special exception , the copyright holders give permission <nl> + to link the code of portions of this program with the OpenSSL library . <nl> + <nl> + Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> + Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> + * / <nl> + # pragma once <nl> + <nl> + # include " ui / widgets / continuous_slider . h " <nl> + <nl> + namespace style { <nl> + struct FilledSlider ; <nl> + } / / namespace style <nl> + <nl> + namespace Ui { <nl> + <nl> + class FilledSlider : public ContinuousSlider { <nl> + public : <nl> + FilledSlider ( QWidget * parent , const style : : FilledSlider & st ) ; <nl> + <nl> + protected : <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + <nl> + private : <nl> + QRect getSeekRect ( ) const override ; <nl> + float64 getOverDuration ( ) const override ; <nl> + <nl> + const style : : FilledSlider & _st ; <nl> + <nl> + } ; <nl> + <nl> + } / / namespace Ui <nl> mmm a / Telegram / SourceFiles / ui / widgets / media_slider . cpp <nl> ppp b / Telegram / SourceFiles / ui / widgets / media_slider . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> <nl> namespace Ui { <nl> <nl> - MediaSlider : : MediaSlider ( QWidget * parent , const style : : MediaSlider & st ) : TWidget ( parent ) <nl> - , _st ( st ) <nl> - , _a_value ( animation ( this , & MediaSlider : : step_value ) ) { <nl> - setCursor ( style : : cur_pointer ) ; <nl> + MediaSlider : : MediaSlider ( QWidget * parent , const style : : MediaSlider & st ) : ContinuousSlider ( parent ) <nl> + , _st ( st ) { <nl> } <nl> <nl> - float64 MediaSlider : : value ( ) const { <nl> - return a_value . current ( ) ; <nl> + QRect MediaSlider : : getSeekRect ( ) const { <nl> + return isHorizontal ( ) <nl> + ? QRect ( _st . seekSize . width ( ) / 2 , 0 , width ( ) - _st . seekSize . width ( ) , height ( ) ) <nl> + : QRect ( 0 , _st . seekSize . height ( ) / 2 , width ( ) , height ( ) - _st . seekSize . width ( ) ) ; <nl> } <nl> <nl> - void MediaSlider : : setDisabled ( bool disabled ) { <nl> - if ( _disabled ! = disabled ) { <nl> - _disabled = disabled ; <nl> - setCursor ( _disabled ? style : : cur_default : style : : cur_pointer ) ; <nl> - update ( ) ; <nl> - } <nl> - } <nl> - <nl> - void MediaSlider : : setValue ( float64 value , bool animated ) { <nl> - if ( animated ) { <nl> - a_value . start ( value ) ; <nl> - _a_value . start ( ) ; <nl> - } else { <nl> - a_value = anim : : fvalue ( value , value ) ; <nl> - _a_value . stop ( ) ; <nl> - } <nl> - update ( ) ; <nl> - } <nl> - <nl> - void MediaSlider : : setFadeOpacity ( float64 opacity ) { <nl> - _fadeOpacity = opacity ; <nl> - update ( ) ; <nl> - } <nl> - <nl> - void MediaSlider : : step_value ( float64 ms , bool timer ) { <nl> - float64 dt = ms / ( 2 * AudioVoiceMsgUpdateView ) ; <nl> - if ( dt > = 1 ) { <nl> - _a_value . stop ( ) ; <nl> - a_value . finish ( ) ; <nl> - } else { <nl> - a_value . update ( qMin ( dt , 1 . ) , anim : : linear ) ; <nl> - } <nl> - if ( timer ) update ( ) ; <nl> - } <nl> - <nl> - int MediaSlider : : lineLeft ( ) const { <nl> - return ( _st . seekSize . width ( ) / 2 ) ; <nl> - } <nl> - <nl> - int MediaSlider : : lineWidth ( ) const { <nl> - return ( width ( ) - _st . seekSize . width ( ) ) ; <nl> + float64 MediaSlider : : getOverDuration ( ) const { <nl> + return _st . duration ; <nl> } <nl> <nl> void MediaSlider : : paintEvent ( QPaintEvent * e ) { <nl> Painter p ( this ) ; <nl> - <nl> - int radius = _st . width / 2 ; <nl> - p . setOpacity ( _fadeOpacity ) ; <nl> p . setPen ( Qt : : NoPen ) ; <nl> p . setRenderHint ( QPainter : : HighQualityAntialiasing ) ; <nl> <nl> + auto horizontal = isHorizontal ( ) ; <nl> auto ms = getms ( ) ; <nl> - _a_value . step ( ms ) ; <nl> - auto over = _a_over . current ( ms , _over ? 1 . : 0 . ) ; <nl> - int skip = lineLeft ( ) ; <nl> - int length = lineWidth ( ) ; <nl> - float64 prg = _mouseDown ? _downValue : a_value . current ( ) ; <nl> - int32 from = skip , mid = _disabled ? 0 : qRound ( from + prg * length ) , end = from + length ; <nl> + auto masterOpacity = fadeOpacity ( ) ; <nl> + auto radius = _st . width / 2 ; <nl> + auto disabled = isDisabled ( ) ; <nl> + auto over = getCurrentOverFactor ( ms ) ; <nl> + auto seekRect = getSeekRect ( ) ; <nl> + auto value = getCurrentValue ( ms ) ; <nl> + <nl> + / / invert colors and value for vertical <nl> + if ( ! horizontal ) value = 1 . - value ; <nl> + <nl> + auto markerFrom = ( horizontal ? seekRect . x ( ) : seekRect . y ( ) ) ; <nl> + auto markerLength = ( horizontal ? seekRect . width ( ) : seekRect . height ( ) ) ; <nl> + auto from = _alwaysDisplayMarker ? 0 : markerFrom ; <nl> + auto length = _alwaysDisplayMarker ? ( horizontal ? width ( ) : height ( ) ) : markerLength ; <nl> + auto mid = disabled ? from : qRound ( from + value * length ) ; <nl> + auto end = from + length ; <nl> if ( mid > from ) { <nl> - p . setClipRect ( 0 , 0 , mid , height ( ) ) ; <nl> - p . setOpacity ( _fadeOpacity * ( over * _st . activeOpacity + ( 1 . - over ) * _st . inactiveOpacity ) ) ; <nl> - p . setBrush ( _st . activeFg ) ; <nl> - p . drawRoundedRect ( from , ( height ( ) - _st . width ) / 2 , mid + radius - from , _st . width , radius , radius ) ; <nl> + auto fromClipRect = horizontal ? QRect ( 0 , 0 , mid , height ( ) ) : QRect ( 0 , 0 , width ( ) , mid ) ; <nl> + auto fromRect = horizontal <nl> + ? QRect ( from , ( height ( ) - _st . width ) / 2 , mid + radius - from , _st . width ) <nl> + : QRect ( ( width ( ) - _st . width ) / 2 , from , _st . width , mid + radius - from ) ; <nl> + p . setClipRect ( fromClipRect ) ; <nl> + p . setOpacity ( masterOpacity * ( over * _st . activeOpacity + ( 1 . - over ) * _st . inactiveOpacity ) ) ; <nl> + p . setBrush ( horizontal ? _st . activeFg : _st . inactiveFg ) ; <nl> + p . drawRoundedRect ( fromRect , radius , radius ) ; <nl> } <nl> if ( end > mid ) { <nl> - p . setClipRect ( mid , 0 , width ( ) - mid , height ( ) ) ; <nl> - p . setOpacity ( _fadeOpacity ) ; <nl> - p . setBrush ( _st . inactiveFg ) ; <nl> - p . drawRoundedRect ( mid - radius , ( height ( ) - _st . width ) / 2 , end - ( mid - radius ) , _st . width , radius , radius ) ; <nl> + auto endClipRect = horizontal ? QRect ( mid , 0 , width ( ) - mid , height ( ) ) : QRect ( 0 , mid , width ( ) , height ( ) - mid ) ; <nl> + auto endRect = horizontal <nl> + ? QRect ( mid - radius , ( height ( ) - _st . width ) / 2 , end - ( mid - radius ) , _st . width ) <nl> + : QRect ( ( width ( ) - _st . width ) / 2 , mid - radius , _st . width , end - ( mid - radius ) ) ; <nl> + p . setClipRect ( endClipRect ) ; <nl> + p . setOpacity ( masterOpacity ) ; <nl> + p . setBrush ( horizontal ? _st . inactiveFg : _st . activeFg ) ; <nl> + p . drawRoundedRect ( endRect , radius , radius ) ; <nl> } <nl> - if ( ! _disabled & & over > 0 ) { <nl> - int x = mid - skip ; <nl> - p . setClipRect ( rect ( ) ) ; <nl> - p . setOpacity ( _fadeOpacity * _st . activeOpacity ) ; <nl> - auto seekButton = QRect ( x , ( height ( ) - _st . seekSize . height ( ) ) / 2 , _st . seekSize . width ( ) , _st . seekSize . height ( ) ) ; <nl> - int remove = ( ( 1 . - over ) * _st . seekSize . width ( ) ) / 2 . ; <nl> - if ( remove * 2 < _st . seekSize . width ( ) ) { <nl> + auto markerSizeRatio = disabled ? 0 . : ( _alwaysDisplayMarker ? 1 . : over ) ; <nl> + if ( markerSizeRatio > 0 ) { <nl> + auto position = qRound ( markerFrom + value * markerLength ) - ( horizontal ? seekRect . x ( ) : seekRect . y ( ) ) ; <nl> + auto seekButton = horizontal <nl> + ? QRect ( position , ( height ( ) - _st . seekSize . height ( ) ) / 2 , _st . seekSize . width ( ) , _st . seekSize . height ( ) ) <nl> + : QRect ( ( width ( ) - _st . seekSize . width ( ) ) / 2 , position , _st . seekSize . width ( ) , _st . seekSize . height ( ) ) ; <nl> + auto size = horizontal ? _st . seekSize . width ( ) : _st . seekSize . height ( ) ; <nl> + auto remove = static_cast < int > ( ( ( 1 . - markerSizeRatio ) * size ) / 2 . ) ; <nl> + if ( remove * 2 < size ) { <nl> + p . setClipRect ( rect ( ) ) ; <nl> + p . setOpacity ( masterOpacity * _st . activeOpacity ) ; <nl> p . setBrush ( _st . activeFg ) ; <nl> p . drawEllipse ( seekButton . marginsRemoved ( QMargins ( remove , remove , remove , remove ) ) ) ; <nl> } <nl> } <nl> } <nl> <nl> - void MediaSlider : : mouseMoveEvent ( QMouseEvent * e ) { <nl> - if ( _mouseDown ) { <nl> - updateDownValueFromPos ( e - > pos ( ) . x ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - void MediaSlider : : mousePressEvent ( QMouseEvent * e ) { <nl> - _mouseDown = true ; <nl> - _downValue = snap ( ( e - > pos ( ) . x ( ) - lineLeft ( ) ) / float64 ( lineWidth ( ) ) , 0 . , 1 . ) ; <nl> - update ( ) ; <nl> - if ( _changeProgressCallback ) { <nl> - _changeProgressCallback ( _downValue ) ; <nl> - } <nl> - } <nl> - <nl> - void MediaSlider : : mouseReleaseEvent ( QMouseEvent * e ) { <nl> - if ( _mouseDown ) { <nl> - _mouseDown = false ; <nl> - if ( _changeFinishedCallback ) { <nl> - _changeFinishedCallback ( _downValue ) ; <nl> - } <nl> - a_value = anim : : fvalue ( _downValue , _downValue ) ; <nl> - _a_value . stop ( ) ; <nl> - update ( ) ; <nl> - } <nl> - } <nl> - <nl> - void MediaSlider : : updateDownValueFromPos ( int pos ) { <nl> - _downValue = snap ( ( pos - lineLeft ( ) ) / float64 ( lineWidth ( ) ) , 0 . , 1 . ) ; <nl> - update ( ) ; <nl> - if ( _changeProgressCallback ) { <nl> - _changeProgressCallback ( _downValue ) ; <nl> - } <nl> - } <nl> - <nl> - void MediaSlider : : enterEvent ( QEvent * e ) { <nl> - setOver ( true ) ; <nl> - } <nl> - <nl> - void MediaSlider : : leaveEvent ( QEvent * e ) { <nl> - setOver ( false ) ; <nl> - } <nl> - <nl> - void MediaSlider : : setOver ( bool over ) { <nl> - if ( _over = = over ) return ; <nl> - <nl> - _over = over ; <nl> - auto from = _over ? 0 . : 1 . , to = _over ? 1 . : 0 . ; <nl> - _a_over . start ( [ this ] { update ( ) ; } , from , to , _st . duration ) ; <nl> - } <nl> - <nl> } / / namespace Ui <nl> mmm a / Telegram / SourceFiles / ui / widgets / media_slider . h <nl> ppp b / Telegram / SourceFiles / ui / widgets / media_slider . h <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> * / <nl> # pragma once <nl> <nl> + # include " ui / widgets / continuous_slider . h " <nl> + <nl> namespace style { <nl> struct MediaSlider ; <nl> } / / namespace style <nl> <nl> namespace Ui { <nl> <nl> - class MediaSlider : public TWidget { <nl> + class MediaSlider : public ContinuousSlider { <nl> public : <nl> MediaSlider ( QWidget * parent , const style : : MediaSlider & st ) ; <nl> <nl> - float64 value ( ) const ; <nl> - void setValue ( float64 value , bool animated ) ; <nl> - void setFadeOpacity ( float64 opacity ) ; <nl> - void setDisabled ( bool disabled ) ; <nl> - <nl> - using Callback = base : : lambda_unique < void ( float64 ) > ; <nl> - void setChangeProgressCallback ( Callback & & callback ) { <nl> - _changeProgressCallback = std_ : : move ( callback ) ; <nl> - } <nl> - void setChangeFinishedCallback ( Callback & & callback ) { <nl> - _changeFinishedCallback = std_ : : move ( callback ) ; <nl> + void setAlwaysDisplayMarker ( bool alwaysDisplayMarker ) { <nl> + _alwaysDisplayMarker = alwaysDisplayMarker ; <nl> + update ( ) ; <nl> } <nl> <nl> protected : <nl> void paintEvent ( QPaintEvent * e ) override ; <nl> - void mouseMoveEvent ( QMouseEvent * e ) override ; <nl> - void mousePressEvent ( QMouseEvent * e ) override ; <nl> - void mouseReleaseEvent ( QMouseEvent * e ) override ; <nl> - void enterEvent ( QEvent * e ) override ; <nl> - void leaveEvent ( QEvent * e ) override ; <nl> <nl> private : <nl> - void step_value ( float64 ms , bool timer ) ; <nl> - void setOver ( bool over ) ; <nl> - void updateDownValueFromPos ( int pos ) ; <nl> - <nl> - int lineLeft ( ) const ; <nl> - int lineWidth ( ) const ; <nl> + QRect getSeekRect ( ) const override ; <nl> + float64 getOverDuration ( ) const override ; <nl> <nl> const style : : MediaSlider & _st ; <nl> - <nl> - bool _disabled = false ; <nl> - <nl> - Callback _changeProgressCallback ; <nl> - Callback _changeFinishedCallback ; <nl> - <nl> - bool _over = false ; <nl> - FloatAnimation _a_over ; <nl> - <nl> - anim : : fvalue a_value = { 0 . , 0 . } ; <nl> - Animation _a_value ; <nl> - <nl> - bool _mouseDown = false ; <nl> - float64 _downValue = 0 . ; <nl> - <nl> - float64 _fadeOpacity = 1 . ; <nl> + bool _alwaysDisplayMarker = false ; <nl> <nl> } ; <nl> <nl> new file mode 100644 <nl> index 00000000000 . . c6bbf0df94c <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / ui / widgets / shadow . cpp <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> + <nl> + Telegram Desktop is free software : you can redistribute it and / or modify <nl> + it under the terms of the GNU General Public License as published by <nl> + the Free Software Foundation , either version 3 of the License , or <nl> + ( at your option ) any later version . <nl> + <nl> + It is distributed in the hope that it will be useful , <nl> + but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + GNU General Public License for more details . <nl> + <nl> + In addition , as a special exception , the copyright holders give permission <nl> + to link the code of portions of this program with the OpenSSL library . <nl> + <nl> + Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> + Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> + * / <nl> + # include " stdafx . h " <nl> + # include " ui / widgets / shadow . h " <nl> + <nl> + namespace Ui { <nl> + <nl> + void ToggleableShadow : : setMode ( Mode mode ) { <nl> + if ( mode = = Mode : : ShownFast | | mode = = Mode : : HiddenFast ) { <nl> + if ( ! _a_opacity . animating ( ) ) { <nl> + _a_opacity . finish ( ) ; <nl> + update ( ) ; <nl> + } <nl> + } <nl> + if ( _shown & & ( mode = = Mode : : Hidden | | mode = = Mode : : HiddenFast ) ) { <nl> + _shown = false ; <nl> + if ( mode = = Mode : : Hidden ) { <nl> + _a_opacity . start ( [ this ] { update ( ) ; } , 1 . , 0 . , st : : shadowToggleDuration ) ; <nl> + } <nl> + } else if ( ! _shown & & ( mode = = Mode : : Shown | | mode = = Mode : : ShownFast ) ) { <nl> + _shown = true ; <nl> + if ( mode = = Mode : : Shown ) { <nl> + _a_opacity . start ( [ this ] { update ( ) ; } , 0 . , 1 . , st : : shadowToggleDuration ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void ToggleableShadow : : paintEvent ( QPaintEvent * e ) { <nl> + Painter p ( this ) ; <nl> + if ( _a_opacity . animating ( getms ( ) ) ) { <nl> + p . setOpacity ( _a_opacity . current ( ) ) ; <nl> + } else if ( ! _shown ) { <nl> + return ; <nl> + } <nl> + p . fillRect ( e - > rect ( ) , _color ) ; <nl> + } <nl> + <nl> + } / / namespace Ui <nl> new file mode 100644 <nl> index 00000000000 . . 92e1f3443d3 <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / ui / widgets / shadow . h <nl> <nl> + # pragma once <nl> + <nl> + namespace Ui { <nl> + <nl> + class PlainShadow : public TWidget { <nl> + public : <nl> + PlainShadow ( QWidget * parent , const style : : color & color ) : TWidget ( parent ) , _color ( color ) { <nl> + } <nl> + <nl> + protected : <nl> + void paintEvent ( QPaintEvent * e ) override { <nl> + Painter ( this ) . fillRect ( e - > rect ( ) , _color - > b ) ; <nl> + } <nl> + <nl> + private : <nl> + const style : : color & _color ; <nl> + <nl> + } ; <nl> + <nl> + class ToggleableShadow : public TWidget { <nl> + public : <nl> + ToggleableShadow ( QWidget * parent , const style : : color & color ) : TWidget ( parent ) , _color ( color ) { <nl> + } <nl> + <nl> + enum class Mode { <nl> + Shown , <nl> + ShownFast , <nl> + Hidden , <nl> + HiddenFast <nl> + } ; <nl> + void setMode ( Mode mode ) ; <nl> + <nl> + bool isFullyShown ( ) const { <nl> + return _shown & & ! _a_opacity . animating ( ) ; <nl> + } <nl> + <nl> + protected : <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + <nl> + private : <nl> + const style : : color & _color ; <nl> + FloatAnimation _a_opacity ; <nl> + bool _shown = true ; <nl> + <nl> + } ; <nl> + <nl> + } / / namespace Ui <nl> mmm a / Telegram / SourceFiles / ui / widgets / widget_slide_wrap . h <nl> ppp b / Telegram / SourceFiles / ui / widgets / widget_slide_wrap . h <nl> namespace Ui { <nl> template < typename Widget > <nl> class WidgetSlideWrap : public TWidget { <nl> public : <nl> + using UpdateCallback = base : : lambda_unique < void ( ) > ; <nl> WidgetSlideWrap ( QWidget * parent , Widget * entity <nl> , style : : margins entityPadding <nl> - , base : : lambda_unique < void ( ) > & & updateCallback <nl> + , UpdateCallback & & updateCallback <nl> , int duration = st : : widgetSlideDuration ) : TWidget ( parent ) <nl> - , _entity ( entity ) <nl> - , _padding ( entityPadding ) <nl> - , _duration ( duration ) <nl> - , _updateCallback ( std_ : : move ( updateCallback ) ) <nl> - , _a_height ( animation ( this , & WidgetSlideWrap < Widget > : : step_height ) ) { <nl> - entity - > setParent ( this ) ; <nl> - entity - > moveToLeft ( _padding . left ( ) , _padding . top ( ) ) ; <nl> - _realSize = entity - > rect ( ) . marginsAdded ( _padding ) . size ( ) ; <nl> - entity - > installEventFilter ( this ) ; <nl> + , _entity ( entity ) <nl> + , _padding ( entityPadding ) <nl> + , _duration ( duration ) <nl> + , _updateCallback ( std_ : : move ( updateCallback ) ) <nl> + , _a_height ( animation ( this , & WidgetSlideWrap < Widget > : : step_height ) ) { <nl> + _entity - > setParent ( this ) ; <nl> + _entity - > moveToLeft ( _padding . left ( ) , _padding . top ( ) ) ; <nl> + _realSize = _entity - > rect ( ) . marginsAdded ( _padding ) . size ( ) ; <nl> + _entity - > installEventFilter ( this ) ; <nl> resize ( _realSize ) ; <nl> } <nl> <nl> class WidgetSlideWrap : public TWidget { <nl> } <nl> <nl> void showFast ( ) { <nl> + show ( ) ; <nl> _a_height . stop ( ) ; <nl> resize ( _realSize ) ; <nl> if ( _updateCallback ) { <nl> class WidgetSlideWrap : public TWidget { <nl> bool _inResizeToWidth = false ; <nl> style : : margins _padding ; <nl> int _duration ; <nl> - base : : lambda_unique < void ( ) > _updateCallback ; <nl> + UpdateCallback _updateCallback ; <nl> <nl> style : : size _realSize ; <nl> int _forceHeight = - 1 ; <nl> mmm a / Telegram / SourceFiles / ui / widgets / widgets . style <nl> ppp b / Telegram / SourceFiles / ui / widgets / widgets . style <nl> MediaSlider { <nl> duration : int ; <nl> } <nl> <nl> + FilledSlider { <nl> + fullWidth : pixels ; <nl> + lineWidth : pixels ; <nl> + activeFg : color ; <nl> + inactiveFg : color ; <nl> + duration : int ; <nl> + } <nl> + <nl> widgetSlideDuration : 200 ; <nl> <nl> discreteSliderHeight : 39px ; <nl> mmm a / Telegram / SourceFiles / window / chat_background . cpp <nl> ppp b / Telegram / SourceFiles / window / chat_background . cpp <nl> void ChatBackground : : setTile ( bool tile ) { <nl> } <nl> <nl> ChatBackground * chatBackground ( ) { <nl> - instance . makeIfNull ( ) ; <nl> + instance . createIfNull ( ) ; <nl> return instance . data ( ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / window / notifications_manager_default . cpp <nl> ppp b / Telegram / SourceFiles / window / notifications_manager_default . cpp <nl> internal : : Widget : : Direction notificationShiftDirection ( ) { <nl> } / / namespace <nl> <nl> void start ( ) { <nl> - ManagerInstance . makeIfNull ( ) ; <nl> + ManagerInstance . createIfNull ( ) ; <nl> } <nl> <nl> Manager * manager ( ) { <nl> new file mode 100644 <nl> index 00000000000 . . 7bd1f8ab64b <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / window / player_wrap_widget . cpp <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop version of Telegram messaging app , see https : / / telegram . org <nl> + <nl> + Telegram Desktop is free software : you can redistribute it and / or modify <nl> + it under the terms of the GNU General Public License as published by <nl> + the Free Software Foundation , either version 3 of the License , or <nl> + ( at your option ) any later version . <nl> + <nl> + It is distributed in the hope that it will be useful , <nl> + but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + GNU General Public License for more details . <nl> + <nl> + In addition , as a special exception , the copyright holders give permission <nl> + to link the code of portions of this program with the OpenSSL library . <nl> + <nl> + Full license : https : / / github . com / telegramdesktop / tdesktop / blob / master / LICENSE <nl> + Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> + * / <nl> + # include " stdafx . h " <nl> + # include " window / player_wrap_widget . h " <nl> + <nl> + # include " ui / widgets / shadow . h " <nl> + <nl> + namespace Window { <nl> + <nl> + PlayerWrapWidget : : PlayerWrapWidget ( QWidget * parent , UpdateCallback & & updateCallback ) : Parent ( parent <nl> + , new Media : : Player : : Widget ( parent ) <nl> + , style : : margins ( 0 , 0 , 0 , 0 ) <nl> + , std_ : : move ( updateCallback ) ) { <nl> + } <nl> + <nl> + void PlayerWrapWidget : : resizeEvent ( QResizeEvent * e ) { <nl> + updateShadowGeometry ( ) ; <nl> + Parent : : resizeEvent ( e ) ; <nl> + } <nl> + <nl> + void PlayerWrapWidget : : updateShadowGeometry ( ) { <nl> + auto skip = Adaptive : : OneColumn ( ) ? 0 : st : : lineWidth ; <nl> + entity ( ) - > setShadowGeometryToLeft ( skip , height ( ) - st : : lineWidth , width ( ) - skip , st : : lineWidth ) ; <nl> + } <nl> + <nl> + } / / namespace Window <nl> new file mode 100644 <nl> index 00000000000 . . 7427950030a <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / window / player_wrap_widget . h <nl> <nl> + # pragma once <nl> + <nl> + # include " ui / widgets / widget_slide_wrap . h " <nl> + # include " media / player / media_player_widget . h " <nl> + <nl> + namespace Ui { <nl> + class PlainShadow ; <nl> + } / / namespace Ui <nl> + <nl> + namespace Window { <nl> + <nl> + class PlayerWrapWidget : public Ui : : WidgetSlideWrap < Media : : Player : : Widget > { <nl> + using Parent = Ui : : WidgetSlideWrap < Media : : Player : : Widget > ; <nl> + <nl> + public : <nl> + using UpdateCallback = Parent : : UpdateCallback ; <nl> + PlayerWrapWidget ( QWidget * parent , UpdateCallback & & updateCallback ) ; <nl> + <nl> + void updateAdaptiveLayout ( ) { <nl> + updateShadowGeometry ( ) ; <nl> + } <nl> + void showShadow ( ) { <nl> + entity ( ) - > showShadow ( ) ; <nl> + } <nl> + void hideShadow ( ) { <nl> + entity ( ) - > hideShadow ( ) ; <nl> + } <nl> + int contentHeight ( ) const { <nl> + return height ( ) - st : : lineWidth ; <nl> + } <nl> + <nl> + protected : <nl> + void resizeEvent ( QResizeEvent * e ) override ; <nl> + <nl> + private : <nl> + void updateShadowGeometry ( ) ; <nl> + <nl> + } ; <nl> + <nl> + } / / namespace Window <nl> mmm a / Telegram / gyp / Telegram . gyp <nl> ppp b / Telegram / gyp / Telegram . gyp <nl> <nl> ' < ( src_loc ) / overviewwidget . h ' , <nl> ' < ( src_loc ) / passcodewidget . cpp ' , <nl> ' < ( src_loc ) / passcodewidget . h ' , <nl> - ' < ( src_loc ) / playerwidget . cpp ' , <nl> - ' < ( src_loc ) / playerwidget . h ' , <nl> ' < ( src_loc ) / localimageloader . cpp ' , <nl> ' < ( src_loc ) / localimageloader . h ' , <nl> ' < ( src_loc ) / localstorage . cpp ' , <nl> <nl> ' < ( src_loc ) / media / player / media_player_instance . h ' , <nl> ' < ( src_loc ) / media / player / media_player_list . cpp ' , <nl> ' < ( src_loc ) / media / player / media_player_list . h ' , <nl> + ' < ( src_loc ) / media / player / media_player_panel . cpp ' , <nl> + ' < ( src_loc ) / media / player / media_player_panel . h ' , <nl> ' < ( src_loc ) / media / player / media_player_title_button . cpp ' , <nl> ' < ( src_loc ) / media / player / media_player_title_button . h ' , <nl> ' < ( src_loc ) / media / player / media_player_volume_controller . cpp ' , <nl> <nl> ' < ( src_loc ) / ui / toast / toast_manager . h ' , <nl> ' < ( src_loc ) / ui / toast / toast_widget . cpp ' , <nl> ' < ( src_loc ) / ui / toast / toast_widget . h ' , <nl> + ' < ( src_loc ) / ui / widgets / continuous_slider . cpp ' , <nl> + ' < ( src_loc ) / ui / widgets / continuous_slider . h ' , <nl> + ' < ( src_loc ) / ui / widgets / discrete_slider . cpp ' , <nl> + ' < ( src_loc ) / ui / widgets / discrete_slider . h ' , <nl> + ' < ( src_loc ) / ui / widgets / filled_slider . cpp ' , <nl> + ' < ( src_loc ) / ui / widgets / filled_slider . h ' , <nl> ' < ( src_loc ) / ui / widgets / label_simple . cpp ' , <nl> ' < ( src_loc ) / ui / widgets / label_simple . h ' , <nl> ' < ( src_loc ) / ui / widgets / media_slider . cpp ' , <nl> ' < ( src_loc ) / ui / widgets / media_slider . h ' , <nl> + ' < ( src_loc ) / ui / widgets / shadow . cpp ' , <nl> + ' < ( src_loc ) / ui / widgets / shadow . h ' , <nl> ' < ( src_loc ) / ui / widgets / widget_slide_wrap . h ' , <nl> - ' < ( src_loc ) / ui / widgets / discrete_slider . cpp ' , <nl> - ' < ( src_loc ) / ui / widgets / discrete_slider . h ' , <nl> ' < ( src_loc ) / ui / animation . cpp ' , <nl> ' < ( src_loc ) / ui / animation . h ' , <nl> ' < ( src_loc ) / ui / button . cpp ' , <nl> <nl> ' < ( src_loc ) / window / notifications_manager_default . h ' , <nl> ' < ( src_loc ) / window / notifications_utilities . cpp ' , <nl> ' < ( src_loc ) / window / notifications_utilities . h ' , <nl> + ' < ( src_loc ) / window / player_wrap_widget . cpp ' , <nl> + ' < ( src_loc ) / window / player_wrap_widget . h ' , <nl> ' < ( src_loc ) / window / section_widget . cpp ' , <nl> ' < ( src_loc ) / window / section_widget . h ' , <nl> ' < ( src_loc ) / window / slide_animation . cpp ' , <nl> | Media : : Player : : Widget added instead of PlayerWidget . | telegramdesktop/tdesktop | 9eb8a9371995b430003ebd5885e83cc4a2ab892c | 2016-10-12T19:36:48Z |
mmm a / ci / docker / runtime_functions . sh <nl> ppp b / ci / docker / runtime_functions . sh <nl> integrationtest_ubuntu_gpu_dist_kvstore ( ) { <nl> . . / . . / tools / launch . py - n 7 - - launcher local python dist_sync_kvstore . py <nl> . . / . . / tools / launch . py - n 7 - - launcher local python dist_sync_kvstore . py - - no - multiprecision <nl> . . / . . / tools / launch . py - n 7 - - launcher local python dist_device_sync_kvstore . py <nl> + . . / . . / tools / launch . py - n 7 - - launcher local python dist_sync_kvstore . py - - type = invalid <nl> . . / . . / tools / launch . py - n 7 - - launcher local python dist_sync_kvstore . py - - type = gluon <nl> } <nl> <nl> mmm a / include / mxnet / c_api . h <nl> ppp b / include / mxnet / c_api . h <nl> MXNET_DLL int MXKVStorePushEx ( KVStoreHandle handle , <nl> const char * * keys , <nl> NDArrayHandle * vals , <nl> int priority ) ; <nl> + / * ! <nl> + * \ brief pull a list of ( key , value ) pairs from the kvstore <nl> + * \ param handle handle to the kvstore <nl> + * \ param num the number of key - value pairs <nl> + * \ param keys the list of keys <nl> + * \ param vals the list of values <nl> + * \ param priority the priority of the action <nl> + * \ param ignore_sparse whether to ignore sparse arrays in the request <nl> + * \ return 0 when success , - 1 when failure happens <nl> + * / <nl> + MXNET_DLL int MXKVStorePullWithSparse ( KVStoreHandle handle , <nl> + mx_uint num , <nl> + const int * keys , <nl> + NDArrayHandle * vals , <nl> + int priority , <nl> + bool ignore_sparse ) ; <nl> + / * ! <nl> + * \ brief pull a list of ( key , value ) pairs from the kvstore , where each key is a string <nl> + * \ param handle handle to the kvstore <nl> + * \ param num the number of key - value pairs <nl> + * \ param keys the list of keys <nl> + * \ param vals the list of values <nl> + * \ param priority the priority of the action <nl> + * \ param ignore_sparse whether to ignore sparse arrays in the request <nl> + * \ return 0 when success , - 1 when failure happens <nl> + * / <nl> + MXNET_DLL int MXKVStorePullWithSparseEx ( KVStoreHandle handle , <nl> + mx_uint num , <nl> + const char * * keys , <nl> + NDArrayHandle * vals , <nl> + int priority , <nl> + bool ignore_sparse ) ; <nl> / * ! <nl> * \ brief pull a list of ( key , value ) pairs from the kvstore <nl> * \ param handle handle to the kvstore <nl> mmm a / include / mxnet / engine . h <nl> ppp b / include / mxnet / engine . h <nl> enum class FnProperty { <nl> / * ! \ brief Asynchronous function call * / <nl> kAsync , <nl> / * ! \ brief Delete variable call * / <nl> - kDeleteVar <nl> + kDeleteVar , <nl> + / * ! \ brief Prioritized sync operation on GPU * / <nl> + kGPUPrioritized <nl> } ; / / enum class FnProperty <nl> <nl> / * ! <nl> mmm a / include / mxnet / kvstore . h <nl> ppp b / include / mxnet / kvstore . h <nl> class KVStore { <nl> * \ param keys the list of keys <nl> * \ param values the list of buffers for the pulled data , they should be preallocated <nl> * \ param priority Priority of the action . <nl> + * \ param ignore_sparse whether to ignore sparse arrays in the request <nl> * / <nl> virtual void Pull ( const std : : vector < int > & keys , <nl> const std : : vector < NDArray * > & values , <nl> - int priority = 0 ) = 0 ; <nl> + int priority = 0 , bool ignore_sparse = true ) = 0 ; <nl> / * ! <nl> * \ brief pull a list of key - value pairs from the store <nl> * \ param keys the list of keys in string format <nl> * \ param values the list of buffers for the pulled data , they should be preallocated <nl> * \ param priority Priority of the action . <nl> + * \ param ignore_sparse whether to ignore sparse arrays in the request <nl> * / <nl> virtual void Pull ( const std : : vector < std : : string > & str_keys , <nl> const std : : vector < NDArray * > & values , <nl> - int priority = 0 ) = 0 ; <nl> + int priority = 0 , bool ignore_sparse = true ) = 0 ; <nl> <nl> / * ! <nl> * \ brief pull a list of key - value pairs from the store . <nl> mmm a / include / mxnet / ndarray . h <nl> ppp b / include / mxnet / ndarray . h <nl> void CopyFromTo ( const NDArray & from , const NDArray * to , int priority = 0 ) ; <nl> * \ param from the ndarray we want to copy data from <nl> * \ param to the target ndarray <nl> * \ param priority Priority of the action . <nl> + * \ param is_opr whether it is invoked by an operator . For example , false if invoked from <nl> + KVStore , true if invoked from ` _copyto ` operator . <nl> * \ note The function name explicitly marks the order of from and to <nl> * due to different possible convention carried by copy function . <nl> * / <nl> - void CopyFromTo ( const NDArray & from , const NDArray & to , int priority = 0 ) ; <nl> + void CopyFromTo ( const NDArray & from , const NDArray & to , int priority = 0 , bool is_opr = false ) ; <nl> <nl> / * ! <nl> * \ brief Perform elementwise sum over each data from source , store result into out . <nl> mmm a / python / mxnet / gluon / trainer . py <nl> ppp b / python / mxnet / gluon / trainer . py <nl> def __init__ ( self , params , optimizer , optimizer_params = None , kvstore = ' device ' , <nl> " got % s . " % ( type ( params ) ) ) <nl> self . _params = [ ] <nl> # parameters to initialize on the kvstore <nl> - self . _contains_sparse = False <nl> + self . _contains_sparse_weight = False <nl> + self . _contains_sparse_grad = False <nl> self . _param2idx = { } <nl> for i , param in enumerate ( params ) : <nl> if not isinstance ( param , Parameter ) : <nl> def __init__ ( self , params , optimizer , optimizer_params = None , kvstore = ' device ' , <nl> self . _params . append ( param ) <nl> param . _set_trainer ( self ) <nl> if param . _stype ! = ' default ' : <nl> - self . _contains_sparse = True <nl> + self . _contains_sparse_weight = True <nl> + if param . _grad_stype ! = ' default ' : <nl> + self . _contains_sparse_grad = True <nl> self . _compression_params = compression_params <nl> optimizer_params = optimizer_params if optimizer_params else { } <nl> self . _scale = float ( optimizer_params . get ( ' rescale_grad ' , 1 . 0 ) ) <nl> def _reset_kvstore ( self ) : <nl> def _init_kvstore ( self ) : <nl> " " " Create kvstore . " " " <nl> config = self . _kvstore_params <nl> - if self . _contains_sparse : <nl> + # if weight is sparse , the weight must be updated on KVStore . <nl> + # training loop contains : <nl> + # - row_sparse_pull ( sparse_weight ) <nl> + # - forward ( ) <nl> + # - backward ( ) <nl> + # - push ( sparse_grad ) , push ( dense_grad ) <nl> + # - pull ( dense_weight ) <nl> + if self . _contains_sparse_weight : <nl> kvstore , update_on_kvstore = _create_sparse_kvstore ( config [ ' kvstore ' ] ) <nl> - # update_on_kvstore is set to False by the user <nl> + # raise Error if update_on_kvstore is set to False by the user <nl> if config [ ' update_on_kvstore ' ] is False : <nl> - raise RuntimeError ( " Cannot set update_on_kvstore to False when sparse " <nl> - " gradients and / or sparse weights are present for " <nl> - " Parameter ' % s ' . " % param . name ) <nl> + raise RuntimeError ( " Cannot set update_on_kvstore to False when sparse weights " <nl> + " are present . " ) <nl> + # if weight is dense and grad is sparse , the weight better not be updated on KVStore . <nl> + # training loop contains : <nl> + # - forward ( ) <nl> + # - backward ( ) <nl> + # - push ( grad ) <nl> + # - pull ( grad ) <nl> + # - update ( grad , weight ) <nl> + elif self . _contains_sparse_grad : <nl> + arg_arrays = { param . name : param . data ( self . _contexts [ 0 ] ) for param in self . _params } <nl> + kvstore , _ = _create_kvstore ( config [ ' kvstore ' ] , len ( self . _contexts ) , arg_arrays ) <nl> + update_on_kvstore = False <nl> + # normal case <nl> else : <nl> arg_arrays = { param . name : param . data ( self . _contexts [ 0 ] ) for param in self . _params } <nl> kvstore , update_on_kvstore = _create_kvstore ( config [ ' kvstore ' ] , len ( self . _contexts ) , <nl> def _init_kvstore ( self ) : <nl> if kvstore : <nl> if self . _compression_params : <nl> kvstore . set_gradient_compression ( self . _compression_params ) <nl> - # kv . pull ( row_sparse_grad ) is not supported <nl> - if ' dist ' in kvstore . type and not self . _contains_sparse : <nl> - update_on_kvstore = False <nl> + if ' dist ' in kvstore . type : <nl> + # kv . pull ( row_sparse_grad ) is not supported for dist kvstore <nl> + update_on_kvstore = self . _contains_sparse_weight or self . _contains_sparse_grad <nl> if update_on_kvstore : <nl> # optimizer preferably needs to be set before init for multiprecision <nl> kvstore . set_optimizer ( self . _optimizer ) <nl> def _row_sparse_pull ( self , parameter , out , row_id ) : <nl> self . _init_kvstore ( ) <nl> if self . _params_to_init : <nl> self . _init_params ( ) <nl> - self . _kvstore . row_sparse_pull ( self . _param2idx [ parameter . name ] , \ <nl> - out = out , row_ids = row_id ) <nl> + idx = self . _param2idx [ parameter . name ] <nl> + self . _kvstore . row_sparse_pull ( idx , out = out , row_ids = row_id , priority = - idx ) <nl> <nl> def step ( self , batch_size , ignore_stale_grad = False ) : <nl> " " " Makes one step of parameter update . Should be called after <nl> def _allreduce_grads ( self ) : <nl> self . _kvstore . push ( i , param . list_grad ( ) , priority = - i ) <nl> <nl> if not self . _update_on_kvstore : <nl> - self . _kvstore . pull ( i , param . list_grad ( ) , priority = - i ) <nl> + self . _kvstore . pull ( i , param . list_grad ( ) , priority = - i , ignore_sparse = False ) <nl> <nl> def update ( self , batch_size , ignore_stale_grad = False ) : <nl> " " " Makes one step of parameter update . <nl> def _update ( self , ignore_stale_grad = False ) : <nl> if self . _kvstore and self . _update_on_kvstore : <nl> if param . _stype = = ' default ' : <nl> # ' row_sparse ' parameters are not pulled immediately - they ' re pulled <nl> - # in ` SparseBlock . sparse_forward ` <nl> + # in ` Block . forward ` <nl> self . _kvstore . pull ( i , param . list_data ( ) , priority = - i ) <nl> continue <nl> <nl> mmm a / python / mxnet / kvstore . py <nl> ppp b / python / mxnet / kvstore . py <nl> def push ( self , key , value , priority = 0 ) : <nl> self . handle , mx_uint ( len ( ckeys ) ) , ckeys , cvals , ctypes . c_int ( priority ) ) ) <nl> <nl> <nl> - def pull ( self , key , out = None , priority = 0 ) : <nl> + def pull ( self , key , out = None , priority = 0 , ignore_sparse = True ) : <nl> " " " Pulls a single value or a sequence of values from the store . <nl> <nl> This function returns immediately after adding an operator to the engine . <nl> def pull ( self , key , out = None , priority = 0 ) : <nl> <nl> The returned values are guaranteed to be the latest values in the store . <nl> <nl> - For ` RowSparseNDArray ` values , this call is ignored , <nl> - please use ` ` row_sparse_pull ` ` instead . <nl> + pull with ` RowSparseNDArray ` is not supported for dist kvstore . <nl> + Please use ` ` row_sparse_pull ` ` instead . <nl> <nl> Parameters <nl> mmmmmmmmm - <nl> def pull ( self , key , out = None , priority = 0 ) : <nl> Higher priority pull operations are likely to be executed before <nl> other pull actions . <nl> <nl> + ignore_sparse : bool , optional , default True <nl> + Whether to ignore sparse arrays in the request . <nl> + <nl> Examples <nl> mmmmmm - - <nl> > > > # pull a single key - value pair <nl> def pull ( self , key , out = None , priority = 0 ) : <nl> assert ( out is not None ) <nl> ckeys , cvals , use_str_keys = _ctype_key_value ( key , out ) <nl> if use_str_keys : <nl> - check_call ( _LIB . MXKVStorePullEx ( <nl> - self . handle , mx_uint ( len ( ckeys ) ) , ckeys , cvals , ctypes . c_int ( priority ) ) ) <nl> + check_call ( _LIB . MXKVStorePullWithSparseEx ( self . handle , mx_uint ( len ( ckeys ) ) , ckeys , <nl> + cvals , ctypes . c_int ( priority ) , <nl> + ctypes . c_bool ( ignore_sparse ) ) ) <nl> else : <nl> - check_call ( _LIB . MXKVStorePull ( <nl> - self . handle , mx_uint ( len ( ckeys ) ) , ckeys , cvals , ctypes . c_int ( priority ) ) ) <nl> + check_call ( _LIB . MXKVStorePullWithSparse ( self . handle , mx_uint ( len ( ckeys ) ) , ckeys , <nl> + cvals , ctypes . c_int ( priority ) , <nl> + ctypes . c_bool ( ignore_sparse ) ) ) <nl> <nl> def row_sparse_pull ( self , key , out = None , priority = 0 , row_ids = None ) : <nl> " " " Pulls a single RowSparseNDArray value or a sequence of RowSparseNDArray values \ <nl> mmm a / src / c_api / c_api . cc <nl> ppp b / src / c_api / c_api . cc <nl> int MXKVStorePull ( KVStoreHandle handle , <nl> v_keys [ i ] = keys [ i ] ; <nl> v_vals [ i ] = static_cast < NDArray * > ( vals [ i ] ) ; <nl> } <nl> - static_cast < KVStore * > ( handle ) - > Pull ( v_keys , v_vals , priority ) ; <nl> + static_cast < KVStore * > ( handle ) - > Pull ( v_keys , v_vals , priority , true ) ; <nl> API_END ( ) ; <nl> } <nl> <nl> int MXKVStorePullEx ( KVStoreHandle handle , <nl> - mx_uint num , <nl> - const char * * keys , <nl> - NDArrayHandle * vals , <nl> - int priority ) { <nl> + mx_uint num , <nl> + const char * * keys , <nl> + NDArrayHandle * vals , <nl> + int priority ) { <nl> + API_BEGIN ( ) ; <nl> + std : : vector < std : : string > v_keys ( num ) ; <nl> + std : : vector < NDArray * > v_vals ( num ) ; <nl> + for ( mx_uint i = 0 ; i < num ; + + i ) { <nl> + v_keys [ i ] = keys [ i ] ; <nl> + v_vals [ i ] = static_cast < NDArray * > ( vals [ i ] ) ; <nl> + } <nl> + static_cast < KVStore * > ( handle ) - > Pull ( v_keys , v_vals , priority , true ) ; <nl> + API_END ( ) ; <nl> + } <nl> + <nl> + int MXKVStorePullWithSparse ( KVStoreHandle handle , <nl> + mx_uint num , <nl> + const int * keys , <nl> + NDArrayHandle * vals , <nl> + int priority , <nl> + bool ignore_sparse ) { <nl> + API_BEGIN ( ) ; <nl> + std : : vector < int > v_keys ( num ) ; <nl> + std : : vector < NDArray * > v_vals ( num ) ; <nl> + for ( mx_uint i = 0 ; i < num ; + + i ) { <nl> + v_keys [ i ] = keys [ i ] ; <nl> + v_vals [ i ] = static_cast < NDArray * > ( vals [ i ] ) ; <nl> + } <nl> + static_cast < KVStore * > ( handle ) - > Pull ( v_keys , v_vals , priority , ignore_sparse ) ; <nl> + API_END ( ) ; <nl> + } <nl> + <nl> + int MXKVStorePullWithSparseEx ( KVStoreHandle handle , <nl> + mx_uint num , <nl> + const char * * keys , <nl> + NDArrayHandle * vals , <nl> + int priority , <nl> + bool ignore_sparse ) { <nl> API_BEGIN ( ) ; <nl> std : : vector < std : : string > v_keys ( num ) ; <nl> std : : vector < NDArray * > v_vals ( num ) ; <nl> int MXKVStorePullEx ( KVStoreHandle handle , <nl> v_keys [ i ] = keys [ i ] ; <nl> v_vals [ i ] = static_cast < NDArray * > ( vals [ i ] ) ; <nl> } <nl> - static_cast < KVStore * > ( handle ) - > Pull ( v_keys , v_vals , priority ) ; <nl> + static_cast < KVStore * > ( handle ) - > Pull ( v_keys , v_vals , priority , ignore_sparse ) ; <nl> API_END ( ) ; <nl> } <nl> <nl> mmm a / src / engine / threaded_engine_perdevice . cc <nl> ppp b / src / engine / threaded_engine_perdevice . cc <nl> class ThreadedEnginePerDevice : public ThreadedEngine { <nl> void StopNoWait ( ) { <nl> SignalQueuesForKill ( ) ; <nl> gpu_normal_workers_ . Clear ( ) ; <nl> + gpu_priority_workers_ . Clear ( ) ; <nl> gpu_copy_workers_ . Clear ( ) ; <nl> cpu_normal_workers_ . Clear ( ) ; <nl> cpu_priority_worker_ . reset ( nullptr ) ; <nl> class ThreadedEnginePerDevice : public ThreadedEngine { <nl> this - > ExecuteOprBlock ( RunContext { ctx , nullptr } , opr_block ) ; <nl> } else { <nl> if ( ctx . dev_mask ( ) = = Context : : kCPU ) { <nl> + / / CPU execution . <nl> if ( opr_block - > opr - > prop = = FnProperty : : kCPUPrioritized ) { <nl> cpu_priority_worker_ - > task_queue . Push ( opr_block , opr_block - > priority ) ; <nl> } else { <nl> class ThreadedEnginePerDevice : public ThreadedEngine { <nl> } <nl> } else { <nl> const size_t nthread = gpu_worker_nthreads_ ; <nl> - auto ptr = gpu_normal_workers_ . Get ( ctx . dev_id , [ this , ctx , is_copy , nthread ] ( ) { <nl> - / / Signify to kernel that GPU is being used , so reserve cores as necessary <nl> - OpenMP : : Get ( ) - > set_reserve_cores ( GetReserveCoreCount ( true ) ) ; <nl> - auto blk = new ThreadWorkerBlock < kWorkerQueue > ( ) ; <nl> - blk - > pool . reset ( new ThreadPool ( <nl> - nthread , <nl> - [ this , ctx , is_copy , blk ] <nl> - ( std : : shared_ptr < dmlc : : ManualEvent > ready_event ) { <nl> - this - > GPUWorker ( ctx , is_copy , blk , ready_event ) ; <nl> - } , true ) ) ; <nl> - return blk ; <nl> - } ) ; <nl> - if ( ptr ) { <nl> - if ( opr_block - > opr - > prop = = FnProperty : : kDeleteVar ) { <nl> - ptr - > task_queue . PushFront ( opr_block , opr_block - > priority ) ; <nl> - } else { <nl> + / / GPU priority task <nl> + if ( opr_block - > opr - > prop = = FnProperty : : kGPUPrioritized ) { <nl> + auto ptr = gpu_priority_workers_ . Get ( ctx . dev_id , [ this , ctx , is_copy , nthread ] ( ) { <nl> + / / Signify to kernel that GPU is being used , so reserve cores as necessary <nl> + OpenMP : : Get ( ) - > set_reserve_cores ( GetReserveCoreCount ( true ) ) ; <nl> + auto blk = new ThreadWorkerBlock < kPriorityQueue > ( ) ; <nl> + blk - > pool . reset ( new ThreadPool ( <nl> + nthread , <nl> + [ this , ctx , is_copy , blk ] <nl> + ( std : : shared_ptr < dmlc : : ManualEvent > ready_event ) { <nl> + this - > GPUWorker ( ctx , is_copy , blk , ready_event ) ; <nl> + } , true ) ) ; <nl> + return blk ; <nl> + } ) ; <nl> + if ( ptr ) { <nl> ptr - > task_queue . Push ( opr_block , opr_block - > priority ) ; <nl> } <nl> + } else { <nl> + / / GPU normal task <nl> + auto ptr = gpu_normal_workers_ . Get ( ctx . dev_id , [ this , ctx , is_copy , nthread ] ( ) { <nl> + / / Signify to kernel that GPU is being used , so reserve cores as necessary <nl> + OpenMP : : Get ( ) - > set_reserve_cores ( GetReserveCoreCount ( true ) ) ; <nl> + auto blk = new ThreadWorkerBlock < kWorkerQueue > ( ) ; <nl> + blk - > pool . reset ( new ThreadPool ( <nl> + nthread , <nl> + [ this , ctx , is_copy , blk ] <nl> + ( std : : shared_ptr < dmlc : : ManualEvent > ready_event ) { <nl> + this - > GPUWorker ( ctx , is_copy , blk , ready_event ) ; <nl> + } , true ) ) ; <nl> + return blk ; <nl> + } ) ; <nl> + if ( ptr ) { <nl> + if ( opr_block - > opr - > prop = = FnProperty : : kDeleteVar ) { <nl> + ptr - > task_queue . PushFront ( opr_block , opr_block - > priority ) ; <nl> + } else { <nl> + ptr - > task_queue . Push ( opr_block , opr_block - > priority ) ; <nl> + } <nl> + } <nl> } <nl> } <nl> } <nl> class ThreadedEnginePerDevice : public ThreadedEngine { <nl> common : : LazyAllocArray < ThreadWorkerBlock < kWorkerQueue > > gpu_normal_workers_ ; <nl> / / workers doing copy works from / to GPU <nl> common : : LazyAllocArray < ThreadWorkerBlock < kCopyQueue > > gpu_copy_workers_ ; <nl> + / / gpu priority workers <nl> + common : : LazyAllocArray < ThreadWorkerBlock < kPriorityQueue > > gpu_priority_workers_ ; <nl> / * ! <nl> * \ brief GPU worker that performs operations on a certain device . <nl> * \ param dev_id The device id of the worker . <nl> class ThreadedEnginePerDevice : public ThreadedEngine { <nl> <nl> / * ! Signal all queues for shutdown * / <nl> void SignalQueuesForKill ( ) { <nl> + SignalQueueForKill ( & gpu_priority_workers_ ) ; <nl> SignalQueueForKill ( & gpu_normal_workers_ ) ; <nl> SignalQueueForKill ( & gpu_copy_workers_ ) ; <nl> SignalQueueForKill ( & cpu_normal_workers_ ) ; <nl> mmm a / src / kvstore / comm . h <nl> ppp b / src / kvstore / comm . h <nl> class CommDevice : public Comm { <nl> " next time row_sparse_pull ( ) is called . To avoid such an issue , " <nl> " consider create a new NDArray buffer to store the output . " ) ; <nl> } <nl> - <nl> + bool is_gpu = retained_gpu . ctx ( ) . dev_mask ( ) = = gpu : : kDevMask ; <nl> Engine : : Get ( ) - > PushAsync ( [ = ] ( RunContext rctx , Engine : : CallbackOnComplete on_complete ) { <nl> const TBlob & indices = row_id . data ( ) ; <nl> using namespace mxnet : : common ; <nl> class CommDevice : public Comm { <nl> } <nl> on_complete ( ) ; <nl> } , retained_gpu . ctx ( ) , { src . var ( ) , row_id . var ( ) } , { retained_gpu . var ( ) } , <nl> - FnProperty : : kNormal , priority , " KVStoreSparseRetain " ) ; <nl> + is_gpu ? FnProperty : : kGPUPrioritized : FnProperty : : kCPUPrioritized , <nl> + priority , " KVStoreSparseRetain " ) ; <nl> CopyFromTo ( retained_gpu , out , priority ) ; <nl> } <nl> } <nl> mmm a / src / kvstore / kvstore_dist . h <nl> ppp b / src / kvstore / kvstore_dist . h <nl> class KVStoreDist : public KVStoreLocal { <nl> <nl> void PullImpl ( const std : : vector < int > & keys , <nl> const std : : vector < NDArray * > & values , <nl> - int priority ) override { <nl> + int priority , bool ignore_sparse ) override { <nl> + CHECK ( ignore_sparse ) < < " dist kvstore pull doesn ' t support ignore_sparse = False " ; <nl> std : : vector < int > uniq_keys ; <nl> std : : vector < std : : vector < NDArray * > > grouped_vals ; <nl> - GroupKVPairsPull ( keys , values , & uniq_keys , & grouped_vals ) ; <nl> + GroupKVPairsPull ( keys , values , & uniq_keys , & grouped_vals , true ) ; <nl> <nl> for ( size_t i = 0 ; i < uniq_keys . size ( ) ; + + i ) { <nl> int key = uniq_keys [ i ] ; <nl> class KVStoreDist : public KVStoreLocal { <nl> int priority = 0 ) override { <nl> std : : vector < int > uniq_keys ; <nl> std : : vector < std : : vector < std : : pair < NDArray * , NDArray > > > grouped_val_rowids ; <nl> - GroupKVPairsPullRsp ( keys , val_rowids , & uniq_keys , & grouped_val_rowids ) ; <nl> + GroupKVPairsPullRsp ( keys , val_rowids , & uniq_keys , & grouped_val_rowids , false ) ; <nl> <nl> for ( size_t i = 0 ; i < uniq_keys . size ( ) ; + + i ) { <nl> int key = uniq_keys [ i ] ; <nl> class KVStoreDist : public KVStoreLocal { <nl> / / first aggregate the values over keys <nl> std : : vector < int > uniq_keys ; <nl> std : : vector < std : : vector < NDArray > > grouped_vals ; <nl> - GroupKVPairsPush ( keys , values , & uniq_keys , & grouped_vals ) ; <nl> + GroupKVPairsPush ( keys , values , & uniq_keys , & grouped_vals , false ) ; <nl> <nl> for ( size_t i = 0 ; i < uniq_keys . size ( ) ; + + i ) { <nl> / / merge over devices <nl> mmm a / src / kvstore / kvstore_local . h <nl> ppp b / src / kvstore / kvstore_local . h <nl> class KVStoreLocal : public KVStore { <nl> <nl> void Pull ( const std : : vector < int > & keys , <nl> const std : : vector < NDArray * > & values , <nl> - int priority ) override { <nl> + int priority , <nl> + bool ignore_sparse ) override { <nl> SetKeyType ( kIntKey ) ; <nl> - PullImpl ( keys , values , priority ) ; <nl> + PullImpl ( keys , values , priority , ignore_sparse ) ; <nl> } <nl> <nl> void PullRowSparse ( const std : : vector < int > & keys , <nl> class KVStoreLocal : public KVStore { <nl> <nl> void Pull ( const std : : vector < std : : string > & str_keys , <nl> const std : : vector < NDArray * > & values , <nl> - int priority ) override { <nl> + int priority , <nl> + bool ignore_sparse ) override { <nl> SetKeyType ( kStringKey ) ; <nl> std : : vector < int > keys ( str_keys . size ( ) ) ; <nl> LookupKeys ( str_keys , & keys ) ; <nl> - PullImpl ( keys , values , priority ) ; <nl> + PullImpl ( keys , values , priority , ignore_sparse ) ; <nl> } <nl> <nl> void PullRowSparse ( const std : : vector < std : : string > & str_keys , <nl> class KVStoreLocal : public KVStore { <nl> int priority ) { <nl> std : : vector < int > uniq_keys ; <nl> std : : vector < std : : vector < NDArray > > grouped_vals ; <nl> - GroupKVPairsPush ( keys , values , & uniq_keys , & grouped_vals ) ; <nl> + GroupKVPairsPush ( keys , values , & uniq_keys , & grouped_vals , false ) ; <nl> for ( size_t i = 0 ; i < uniq_keys . size ( ) ; + + i ) { <nl> int key = uniq_keys [ i ] ; <nl> const NDArray & merged = comm_ - > Reduce ( key , grouped_vals [ i ] , priority ) ; <nl> class KVStoreLocal : public KVStore { <nl> <nl> virtual void PullImpl ( const std : : vector < int > & keys , <nl> const std : : vector < NDArray * > & values , <nl> - int priority ) { <nl> + int priority , <nl> + bool ignore_sparse ) { <nl> std : : vector < int > uniq_keys ; <nl> std : : vector < std : : vector < NDArray * > > grouped_vals ; <nl> - GroupKVPairsPull ( keys , values , & uniq_keys , & grouped_vals ) ; <nl> + GroupKVPairsPull ( keys , values , & uniq_keys , & grouped_vals , ignore_sparse ) ; <nl> <nl> for ( size_t i = 0 ; i < uniq_keys . size ( ) ; + + i ) { <nl> int key = uniq_keys [ i ] ; <nl> class KVStoreLocal : public KVStore { <nl> int priority = 0 ) { <nl> std : : vector < int > uniq_keys ; <nl> std : : vector < std : : vector < std : : pair < NDArray * , NDArray > > > grouped_val_rowids ; <nl> - GroupKVPairsPullRsp ( keys , val_rowids , & uniq_keys , & grouped_val_rowids ) ; <nl> + GroupKVPairsPullRsp ( keys , val_rowids , & uniq_keys , & grouped_val_rowids , false ) ; <nl> for ( size_t i = 0 ; i < uniq_keys . size ( ) ; + + i ) { <nl> int key = uniq_keys [ i ] ; <nl> const NDArray & local = local_ [ key ] ; <nl> class KVStoreLocal : public KVStore { <nl> virtual void GroupKVPairsPush ( const std : : vector < int > & keys , <nl> const std : : vector < NDArray > & values , <nl> std : : vector < int > * uniq_keys , <nl> - std : : vector < std : : vector < NDArray > > * grouped_vals ) { <nl> + std : : vector < std : : vector < NDArray > > * grouped_vals , <nl> + bool ignore_sparse ) { <nl> / / check if the storage type of a value is valid <nl> - auto validator = [ this ] ( const int key , const NDArray & nd ) - > bool { <nl> + auto validator = [ this ] ( const int key , const NDArray & nd , bool ignore_sparse ) - > bool { <nl> + CHECK ( ! ignore_sparse ) < < " Cannot ignore sparse arrays for push " ; <nl> auto stype = nd . storage_type ( ) ; <nl> / / valid NDArray <nl> if ( stype = = kDefaultStorage | | stype = = kRowSparseStorage ) return true ; <nl> class KVStoreLocal : public KVStore { <nl> LOG ( FATAL ) < < " Unexpected storage type detected during kvstore push : " < < stype ; <nl> return false ; <nl> } ; <nl> - GroupKVPairs ( keys , values , uniq_keys , grouped_vals , validator ) ; <nl> + GroupKVPairs ( keys , values , uniq_keys , grouped_vals , validator , ignore_sparse ) ; <nl> } <nl> / * * <nl> * \ brief group values on keys for pull <nl> class KVStoreLocal : public KVStore { <nl> virtual void GroupKVPairsPull ( const std : : vector < int > & keys , <nl> const std : : vector < NDArray * > & values , <nl> std : : vector < int > * uniq_keys , <nl> - std : : vector < std : : vector < NDArray * > > * grouped_vals ) { <nl> + std : : vector < std : : vector < NDArray * > > * grouped_vals , <nl> + bool ignore_sparse ) { <nl> / / check if the storage type of a value is valid <nl> - auto validator = [ this ] ( const int key , const NDArray * nd ) - > bool { <nl> + auto validator = [ this ] ( const int key , const NDArray * nd , bool ignore_sparse ) - > bool { <nl> / / valid <nl> - if ( nd - > storage_type ( ) = = kDefaultStorage ) return true ; <nl> + if ( nd - > storage_type ( ) = = kDefaultStorage | | ! ignore_sparse ) return true ; <nl> / / invalid , print warning messages once <nl> if ( this - > warnings_printed_ . find ( key ) = = this - > warnings_printed_ . end ( ) ) { <nl> LOG ( INFO ) < < " Warning : non - default weights detected during kvstore pull . " <nl> class KVStoreLocal : public KVStore { <nl> } <nl> return false ; <nl> } ; <nl> - GroupKVPairs ( keys , values , uniq_keys , grouped_vals , validator ) ; <nl> + GroupKVPairs ( keys , values , uniq_keys , grouped_vals , validator , ignore_sparse ) ; <nl> } <nl> <nl> typedef std : : pair < NDArray * , NDArray > RSPVal ; <nl> class KVStoreLocal : public KVStore { <nl> virtual void GroupKVPairsPullRsp ( const std : : vector < int > & keys , <nl> const std : : vector < RSPVal > & values , <nl> std : : vector < int > * uniq_keys , <nl> - std : : vector < std : : vector < RSPVal > > * grouped_vals ) { <nl> + std : : vector < std : : vector < RSPVal > > * grouped_vals , <nl> + bool ignore_sparse ) { <nl> / / check if the storage type of a value is valid <nl> - auto validator = [ this ] ( const int key , const RSPVal & val_rowid ) - > bool { <nl> + auto validator = [ this ] ( const int key , const RSPVal & val_rowid , bool ignore_sparse ) - > bool { <nl> + CHECK ( ! ignore_sparse ) < < " Cannot ignore sparse arrays in row_sparse_pull " ; <nl> auto val_stype = val_rowid . first - > storage_type ( ) ; <nl> auto rowid_stype = val_rowid . second . storage_type ( ) ; <nl> / / check storage types <nl> class KVStoreLocal : public KVStore { <nl> < < " row_sparse_pull rowids , but detected storage type " < < rowid_stype ; <nl> return true ; <nl> } ; <nl> - GroupKVPairs ( keys , values , uniq_keys , grouped_vals , validator ) ; <nl> + GroupKVPairs ( keys , values , uniq_keys , grouped_vals , validator , ignore_sparse ) ; <nl> } <nl> <nl> / * * <nl> class KVStoreLocal : public KVStore { <nl> const std : : vector < V > & values , <nl> std : : vector < int > * uniq_keys , <nl> std : : vector < std : : vector < V > > * grouped_vals , <nl> - const FValidate & is_valid ) { <nl> + const FValidate & is_valid , <nl> + bool ignore_sparse ) { <nl> CHECK_EQ ( keys . size ( ) , values . size ( ) ) ; <nl> / / TODO ( mli ) check if already sorted as an optimization <nl> using Idx = std : : pair < int , int > ; <nl> class KVStoreLocal : public KVStore { <nl> <nl> int pre_key = idx [ 0 ] . first - 1 ; <nl> for ( auto i : idx ) { <nl> - if ( is_valid ( i . first , values [ i . second ] ) ) { <nl> + if ( is_valid ( i . first , values [ i . second ] , ignore_sparse ) ) { <nl> if ( i . first ! = pre_key ) { <nl> uniq_keys - > push_back ( i . first ) ; <nl> grouped_vals - > push_back ( { values [ i . second ] } ) ; <nl> class KVStoreLocal : public KVStore { <nl> NDArray data_in_ctx = diff_ctx ? NDArray ( data . shape ( ) , ctx , true , data . dtype ( ) ) : data ; <nl> / / if data = = data_in_ctx , CopyFromTo is smart enough to skip the copy <nl> CopyFromTo ( data , & data_in_ctx , priority ) ; <nl> - Resource rsc = ResourceManager : : Get ( ) - > Request ( out . ctx ( ) , <nl> - ResourceRequest ( ResourceRequest : : kTempSpace ) ) ; <nl> / / GPU requires temp resources <nl> - std : : vector < Engine : : VarHandle > mutate_vars { out . var ( ) } ; <nl> - if ( out . ctx ( ) . dev_mask ( ) = = gpu : : kDevMask ) mutate_vars . emplace_back ( rsc . var ) ; <nl> + bool is_gpu = out . ctx ( ) . dev_mask ( ) = = gpu : : kDevMask ; <nl> Engine : : Get ( ) - > PushAsync ( <nl> [ = ] ( RunContext rctx , Engine : : CallbackOnComplete on_complete ) { <nl> / / copy data . data ( ) to out . data ( ) <nl> out . CheckAndAlloc ( { mshadow : : Shape1 ( num_elements ) } ) ; <nl> TBlob out_data = out . data ( ) ; <nl> + NDArray workspace ; <nl> switch ( out . ctx ( ) . dev_mask ( ) ) { <nl> case cpu : : kDevMask : { <nl> mshadow : : Stream < cpu > * s = rctx . get_stream < cpu > ( ) ; <nl> ndarray : : Copy < cpu , cpu > ( data_in_ctx . data ( ) , & out_data , <nl> ctx , ctx , rctx ) ; <nl> - UniqueImpl ( rsc , s , out ) ; <nl> + UniqueImpl ( & workspace , s , out ) ; <nl> break ; <nl> } <nl> # if MXNET_USE_CUDA <nl> class KVStoreLocal : public KVStore { <nl> mshadow : : Stream < gpu > * s = rctx . get_stream < gpu > ( ) ; <nl> ndarray : : Copy < gpu , gpu > ( data_in_ctx . data ( ) , & out_data , <nl> ctx , ctx , rctx ) ; <nl> - UniqueImpl ( rsc , s , out ) ; <nl> + UniqueImpl ( & workspace , s , out ) ; <nl> / / wait for GPU operations to complete <nl> s - > Wait ( ) ; <nl> break ; <nl> class KVStoreLocal : public KVStore { <nl> LOG ( FATAL ) < < MXNET_GPU_NOT_ENABLED_ERROR ; <nl> } <nl> on_complete ( ) ; <nl> - } , out . ctx ( ) , { data_in_ctx . var ( ) } , mutate_vars , <nl> - FnProperty : : kNormal , priority , " KVStoreUnique " ) ; <nl> + } , out . ctx ( ) , { data_in_ctx . var ( ) } , { out . var ( ) } , <nl> + is_gpu ? FnProperty : : kGPUPrioritized : FnProperty : : kCPUPrioritized , <nl> + priority , " KVStoreUnique " ) ; <nl> return out ; <nl> } <nl> <nl> mmm a / src / kvstore / kvstore_utils . cc <nl> ppp b / src / kvstore / kvstore_utils . cc <nl> namespace mxnet { <nl> namespace kvstore { <nl> <nl> template < > <nl> - void UniqueImpl < cpu > ( const Resource & rsc , mshadow : : Stream < cpu > * s , <nl> - const NDArray & out ) { <nl> + void UniqueImpl < cpu > ( NDArray * workspace , mshadow : : Stream < cpu > * s , <nl> + const NDArray & out ) { <nl> const size_t num_elements = out . shape ( ) . Size ( ) ; <nl> CHECK_EQ ( out . storage_type ( ) , kRowSparseStorage ) < < " row_sparse NDArray is expected " ; <nl> MSHADOW_IDX_TYPE_SWITCH ( out . dtype ( ) , IType , { <nl> mmm a / src / kvstore / kvstore_utils . cu <nl> ppp b / src / kvstore / kvstore_utils . cu <nl> namespace mxnet { <nl> namespace kvstore { <nl> <nl> template < typename IType > <nl> - size_t UniqueImplGPU ( const Resource & rsc , mshadow : : Stream < gpu > * s , <nl> - IType * dptr , const size_t size ) { <nl> + size_t UniqueImplGPU ( NDArray * workspace , mshadow : : Stream < gpu > * s , <nl> + IType * dptr , const size_t size , Context ctx ) { <nl> / / estimate unique temp space . The first byte is reserved to store the number <nl> / / of unique values selected <nl> const size_t num_selected_bytes = sizeof ( size_t ) ; <nl> size_t UniqueImplGPU ( const Resource & rsc , mshadow : : Stream < gpu > * s , <nl> / / request temp storage <nl> const size_t total_workspace = num_selected_bytes + sort_output_bytes + <nl> std : : max ( sort_temp_bytes , unique_temp_bytes ) ; <nl> - mshadow : : Tensor < gpu , 1 , char > workspace = rsc <nl> - . get_space_typed < gpu , 1 , char > ( mshadow : : Shape1 ( total_workspace ) , s ) ; <nl> + * workspace = NDArray ( mshadow : : Shape1 ( ( total_workspace + 3 ) / 4 ) , ctx , false ) ; <nl> + char * workspace_dptr = reinterpret_cast < char * > ( workspace - > data ( ) . dptr_ ) ; <nl> / / temp space layout : num_selected_ptr , sort_output_bytes , unique / sort_temp_storage <nl> - size_t * num_selected_ptr = reinterpret_cast < size_t * > ( workspace . dptr_ ) ; <nl> - IType * sort_output_ptr = reinterpret_cast < IType * > ( workspace . dptr_ + num_selected_bytes ) ; <nl> - void * temp_storage = static_cast < void * > ( workspace . dptr_ + <nl> + size_t * num_selected_ptr = reinterpret_cast < size_t * > ( workspace_dptr ) ; <nl> + IType * sort_output_ptr = reinterpret_cast < IType * > ( workspace_dptr + num_selected_bytes ) ; <nl> + void * temp_storage = static_cast < void * > ( workspace_dptr + <nl> num_selected_bytes + sort_output_bytes ) ; <nl> / / execute the sort kernel <nl> # ifndef SORT_WITH_THRUST <nl> size_t UniqueImplGPU ( const Resource & rsc , mshadow : : Stream < gpu > * s , <nl> } <nl> <nl> template < > <nl> - void UniqueImpl < gpu > ( const Resource & rsc , mshadow : : Stream < gpu > * s , <nl> - const NDArray & out ) { <nl> + void UniqueImpl < gpu > ( NDArray * workspace , mshadow : : Stream < gpu > * s , const NDArray & out ) { <nl> const size_t num_elements = out . shape ( ) . Size ( ) ; <nl> CHECK_EQ ( out . storage_type ( ) , kRowSparseStorage ) < < " row_sparse NDArray is expected " ; <nl> MSHADOW_IDX_TYPE_SWITCH ( out . dtype ( ) , IType , { <nl> IType * dptr = out . data ( ) . dptr < IType > ( ) ; <nl> - size_t num_selected_out = UniqueImplGPU ( rsc , s , dptr , num_elements ) ; <nl> + size_t num_selected_out = UniqueImplGPU ( workspace , s , dptr , num_elements , out . ctx ( ) ) ; <nl> / / set the shape of data / aux_data according to the number of unique values <nl> out . set_aux_shape ( rowsparse : : kIdx , mshadow : : Shape1 ( num_selected_out ) ) ; <nl> } ) ; <nl> mmm a / src / kvstore / kvstore_utils . h <nl> ppp b / src / kvstore / kvstore_utils . h <nl> namespace kvstore { <nl> <nl> / * ! <nl> * \ brief compute unique and sorted values in a row_sparse ndarray . <nl> - * \ param rsc Temp resource for computation <nl> + * \ param workspace Temp workspace for computation . Its a pointer to a <nl> + NDArray placeholder to make sure the NDArray is not free ' d <nl> + during execution . <nl> * \ param s Stream <nl> * \ param out Input and output ndarray . The ndarray stores the <nl> * unique elements in out . data ( ) . <nl> * / <nl> template < typename xpu > <nl> - void UniqueImpl ( const Resource & rsc , mshadow : : Stream < xpu > * s , <nl> - const NDArray & out ) ; <nl> + void UniqueImpl ( NDArray * workspace , mshadow : : Stream < xpu > * s , const NDArray & out ) ; <nl> } / / namespace kvstore <nl> } / / namespace mxnet <nl> <nl> mmm a / src / ndarray / ndarray . cc <nl> ppp b / src / ndarray / ndarray . cc <nl> void CopyFromToImpl ( const NDArray & from , const NDArray & to , <nl> } <nl> } <nl> <nl> - void CopyFromTo ( const NDArray & from , const NDArray & to , int priority ) { <nl> + void CopyFromTo ( const NDArray & from , const NDArray & to , int priority , bool is_opr ) { <nl> if ( from . var ( ) = = to . var ( ) & & from . byte_offset ( ) = = to . byte_offset ( ) ) { <nl> / / skip to copy to itself <nl> return ; <nl> void CopyFromTo ( const NDArray & from , const NDArray & to , int priority ) { <nl> on_complete ( ) ; <nl> } , from . ctx ( ) , const_vars , mutable_vars , <nl> from . dtype ( ) ! = to . dtype ( ) ? FnProperty : : kNormal : FnProperty : : kCopyFromGPU , <nl> - priority , " CopyGPU2GPU " ) ; <nl> + priority , is_opr ? " _copyto_GPU2GPU " : " CopyGPU2GPU " ) ; <nl> } else { <nl> LOG ( FATAL ) < < " unknown device mask " ; <nl> } <nl> void CopyFromToSimple ( <nl> const std : : vector < NDArray > & inputs , <nl> const std : : vector < OpReqType > & req , <nl> const std : : vector < NDArray > & outputs ) { <nl> - CopyFromTo ( inputs [ 0 ] , outputs [ 0 ] , 0 ) ; <nl> + CopyFromTo ( inputs [ 0 ] , outputs [ 0 ] , 0 , true ) ; <nl> } <nl> <nl> / / copy function is special <nl> mmm a / tests / nightly / dist_sync_kvstore . py <nl> ppp b / tests / nightly / dist_sync_kvstore . py <nl> def check_diff ( A , x , rank = None ) : <nl> irregular_shape = ( 1211 , 1211 ) <nl> big_shape = ( 1200 , 1200 ) # bigger than MXNET_KVSTORE_BIGARRAY_BOUND <nl> <nl> + keys_invalid = [ 999 ] <nl> keys_shape = [ ' 3 ' , ' 5 ' , ' 7 ' ] <nl> keys_big_shape = [ ' 99 ' ] <nl> fp16_keys_shape = [ ' 4 ' , ' 6 ' , ' 8 ' ] <nl> def check_init ( kv , cur_keys , cur_shape , device = False ) : <nl> check_init ( kv , init_test_keys_device_big , big_shape , device = True ) <nl> print ( ' worker ' + str ( kv . rank ) + ' is initialized ' ) <nl> <nl> - def test_gluon_trainer_reset ( ) : <nl> - params = mx . gluon . ParameterDict ( ) <nl> - x = params . get ( ' x ' , shape = ( 4 , 2 ) , lr_mult = 1 . 0 , stype = ' row_sparse ' ) <nl> - params . initialize ( ctx = mx . cpu ( 0 ) , init = ' zeros ' ) <nl> - trainer = mx . gluon . Trainer ( params , ' sgd ' , { ' learning_rate ' : 0 . 1 } , kvstore = kv ) <nl> - params . save ( ' test_gluon_trainer_reset_ ' + str ( my_rank ) + ' . params ' ) <nl> - row_id = mx . nd . arange ( 0 , 4 ) <nl> - w = x . row_sparse_data ( row_id ) <nl> - assert trainer . _kv_initialized and trainer . _update_on_kvstore <nl> - # load would fail to reset kvstore since update_on_kvstore is True <nl> - assert_exception ( params . load , RuntimeError , ' test_gluon_trainer_reset_ ' + str ( my_rank ) + ' . params ' ) <nl> - print ( ' worker ' + str ( my_rank ) + ' passed test_gluon_trainer_reset ' ) <nl> + def test_invalid_operations ( ) : <nl> + def check_invalid_gluon_trainer_reset ( ) : <nl> + params = mx . gluon . ParameterDict ( ) <nl> + x = params . get ( ' x ' , shape = ( 4 , 2 ) , lr_mult = 1 . 0 , stype = ' row_sparse ' ) <nl> + params . initialize ( ctx = mx . cpu ( 0 ) , init = ' zeros ' ) <nl> + trainer = mx . gluon . Trainer ( params , ' sgd ' , { ' learning_rate ' : 0 . 1 } , kvstore = kv ) <nl> + params . save ( ' test_gluon_trainer_reset_ ' + str ( my_rank ) + ' . params ' ) <nl> + row_id = mx . nd . arange ( 0 , 4 ) <nl> + w = x . row_sparse_data ( row_id ) <nl> + assert trainer . _kv_initialized and trainer . _update_on_kvstore <nl> + mx . nd . waitall ( ) <nl> + # load would fail to reset kvstore since update_on_kvstore is True <nl> + assert_exception ( params . load , RuntimeError , ' test_gluon_trainer_reset_ ' + str ( my_rank ) + ' . params ' ) <nl> + print ( ' worker ' + str ( my_rank ) + ' passed check_invalid_gluon_trainer_reset ' ) <nl> + <nl> + def check_invalid_pull ( ) : <nl> + kv . init ( keys_invalid [ 0 ] , mx . nd . ones ( ( 2 , 2 ) ) . tostype ( ' row_sparse ' ) ) <nl> + out = mx . nd . ones ( ( 2 , 2 ) ) . tostype ( ' row_sparse ' ) <nl> + assert_exception ( kv . pull , mx . MXNetError , ' invalid_key ' , out = out , ignore_sparse = False ) <nl> + print ( ' worker ' + str ( my_rank ) + ' passed check_invalid_pull ' ) <nl> + <nl> + check_invalid_gluon_trainer_reset ( ) <nl> + check_invalid_pull ( ) <nl> + <nl> + def test_gluon_trainer ( ) : <nl> + def check_trainer_kv_type ( stype , grad_stype , update_on_kv ) : <nl> + params = mx . gluon . ParameterDict ( ) <nl> + x = params . get ( ' x ' , shape = ( 10 , 1 ) , lr_mult = 1 . 0 , stype = stype , grad_stype = grad_stype ) <nl> + params . initialize ( ctx = [ mx . cpu ( 0 ) , mx . cpu ( 1 ) ] , init = ' zeros ' ) <nl> + trainer = mx . gluon . Trainer ( params , ' sgd ' , { ' learning_rate ' : 0 . 1 } , kvstore = kv ) <nl> + trainer . _init_kvstore ( ) <nl> + assert trainer . _kv_initialized <nl> + assert trainer . _update_on_kvstore is update_on_kv <nl> + <nl> + check_trainer_kv_type ( ' default ' , ' default ' , False ) <nl> + check_trainer_kv_type ( ' default ' , ' row_sparse ' , True ) <nl> + check_trainer_kv_type ( ' row_sparse ' , ' row_sparse ' , True ) <nl> + print ( ' worker ' + str ( my_rank ) + ' passed test_gluon_trainer ' ) <nl> <nl> <nl> if __name__ = = " __main__ " : <nl> def test_gluon_trainer_reset ( ) : <nl> parser . add_argument ( ' - - no - multiprecision ' , dest = ' multiprecision ' , action = ' store_false ' ) <nl> opt = parser . parse_args ( ) <nl> if opt . type = = ' gluon ' : <nl> - test_gluon_trainer_reset ( ) <nl> + test_gluon_trainer ( ) <nl> + if opt . type = = ' invalid ' : <nl> + test_invalid_operations ( ) <nl> if opt . type = = ' all ' or opt . type = = ' init ' : <nl> test_sync_init ( opt . gpu ) <nl> if opt . type = = ' all ' or opt . type = = ' default ' : <nl> mmm a / tests / python / gpu / test_kvstore_gpu . py <nl> ppp b / tests / python / gpu / test_kvstore_gpu . py <nl> def check_rsp_pull ( kv , count , ctxs , is_same_rowid = False , use_slice = False ) : <nl> expected_val + = 0 if row in excluded_row_ids else 2 <nl> assert_almost_equal ( retained [ row ] , expected_val ) <nl> <nl> + kv . pull ( ' e ' , out = vals_to_pull , ignore_sparse = False ) <nl> + for val in vals : <nl> + retained = val . asnumpy ( ) <nl> + expected_val = np . zeros_like ( retained ) <nl> + expected_val [ : ] = 2 <nl> + assert_almost_equal ( retained , expected_val ) <nl> + <nl> check_rsp_pull ( kv , 1 , [ mx . gpu ( 0 ) ] ) <nl> check_rsp_pull ( kv , 1 , [ mx . cpu ( 0 ) ] ) <nl> check_rsp_pull ( kv , 4 , [ mx . gpu ( i / / 2 ) for i in range ( 4 ) ] ) <nl> mmm a / tests / python / unittest / test_gluon_trainer . py <nl> ppp b / tests / python / unittest / test_gluon_trainer . py <nl> def check_trainer_reset_kv ( kv ) : <nl> kvs = [ ' local ' , ' device ' ] <nl> for kv in kvs : <nl> check_trainer_reset_kv ( kv ) <nl> + <nl> + @ with_seed ( ) <nl> + def test_trainer_sparse_kv ( ) : <nl> + def check_trainer_sparse_kv ( kv , stype , grad_stype , update_on_kv ) : <nl> + params = gluon . ParameterDict ( ) <nl> + x = params . get ( ' x ' , shape = ( 10 , 1 ) , lr_mult = 1 . 0 , stype = stype , grad_stype = grad_stype ) <nl> + params . initialize ( ctx = [ mx . cpu ( 0 ) , mx . cpu ( 1 ) ] , init = ' zeros ' ) <nl> + trainer = gluon . Trainer ( params , ' sgd ' , { ' learning_rate ' : 0 . 1 } , kvstore = kv ) <nl> + all_rows = mx . nd . arange ( 0 , 10 , ctx = mx . cpu ( 0 ) ) <nl> + ws = x . list_data ( ) if stype = = ' default ' else x . list_row_sparse_data ( all_rows ) <nl> + with mx . autograd . record ( ) : <nl> + for w in ws : <nl> + y = w + 1 <nl> + y . backward ( ) <nl> + trainer . step ( 1 ) <nl> + assert trainer . _kvstore . type = = kv <nl> + assert trainer . _kv_initialized <nl> + assert trainer . _update_on_kvstore is update_on_kv <nl> + # the updated parameter should be based on the loaded checkpoint <nl> + mx . nd . waitall ( ) <nl> + updated_w = x . data ( mx . cpu ( 0 ) ) if stype = = ' default ' else x . row_sparse_data ( all_rows ) <nl> + assert ( updated_w = = - 0 . 2 ) . asnumpy ( ) . all ( ) <nl> + <nl> + kvs = [ ' local ' , ' device ' ] <nl> + for kv in kvs : <nl> + check_trainer_sparse_kv ( kv , ' default ' , ' default ' , True ) <nl> + check_trainer_sparse_kv ( kv , ' default ' , ' row_sparse ' , False ) <nl> + check_trainer_sparse_kv ( kv , ' row_sparse ' , ' row_sparse ' , True ) <nl> mmm a / tests / python / unittest / test_kvstore . py <nl> ppp b / tests / python / unittest / test_kvstore . py <nl> def check_aggregator ( kv , key , key_list , stype ) : <nl> @ with_seed ( ) <nl> def test_sparse_aggregator ( ) : <nl> " " " aggregate sparse ndarray on muliple devices " " " <nl> + def check_sparse_aggregator ( sparse_pull ) : <nl> + stype = ' row_sparse ' <nl> + kv = init_kv_with_str ( stype ) <nl> <nl> - stype = ' row_sparse ' <nl> - kv = init_kv_with_str ( stype ) <nl> - <nl> - # devices <nl> - num_devs = 4 <nl> - devs = [ mx . Context ( ' cpu ' , i ) for i in range ( num_devs ) ] <nl> - <nl> - # single <nl> - vals = [ rand_ndarray ( shape , stype ) . copyto ( devs [ i ] ) for i in range ( num_devs ) ] <nl> - expected_sum = np . zeros ( shape ) <nl> - for v in vals : <nl> - expected_sum + = v . asnumpy ( ) <nl> - <nl> - # prepare row_ids <nl> - all_rows = mx . nd . array ( np . arange ( shape [ 0 ] ) ) <nl> - kv . push ( ' a ' , vals ) <nl> - kv . row_sparse_pull ( ' a ' , out = vals , row_ids = [ all_rows ] * len ( vals ) ) <nl> - result_sum = np . zeros ( shape ) <nl> - for v in vals : <nl> - result_sum + = v . asnumpy ( ) <nl> - assert_almost_equal ( result_sum , expected_sum * num_devs ) <nl> + # devices <nl> + num_devs = 4 <nl> + devs = [ mx . Context ( ' cpu ' , i ) for i in range ( num_devs ) ] <nl> <nl> - # list <nl> - vals = [ [ rand_ndarray ( shape , stype ) . copyto ( devs [ i ] ) for i in range ( num_devs ) ] ] * len ( keys ) <nl> - expected_sum = np . zeros ( shape ) <nl> - for v in vals [ 0 ] : <nl> - expected_sum + = v . asnumpy ( ) <nl> - <nl> - kv . push ( str_keys , vals ) <nl> - kv . row_sparse_pull ( str_keys , out = vals , row_ids = [ [ all_rows ] * num_devs ] * len ( vals ) ) <nl> - for vv in vals : <nl> + # single <nl> + vals = [ rand_ndarray ( shape , stype ) . copyto ( devs [ i ] ) for i in range ( num_devs ) ] <nl> + expected_sum = np . zeros ( shape ) <nl> + for v in vals : <nl> + expected_sum + = v . asnumpy ( ) <nl> + <nl> + # prepare row_ids <nl> + kv . push ( ' a ' , vals ) <nl> + if sparse_pull : <nl> + all_rows = mx . nd . array ( np . arange ( shape [ 0 ] ) ) <nl> + kv . row_sparse_pull ( ' a ' , out = vals , row_ids = [ all_rows ] * len ( vals ) ) <nl> + else : <nl> + kv . pull ( ' a ' , out = vals , ignore_sparse = False ) <nl> result_sum = np . zeros ( shape ) <nl> - for v in vv : <nl> + for v in vals : <nl> result_sum + = v . asnumpy ( ) <nl> assert_almost_equal ( result_sum , expected_sum * num_devs ) <nl> <nl> + # list <nl> + vals = [ [ rand_ndarray ( shape , stype ) . copyto ( devs [ i ] ) for i in range ( num_devs ) ] ] * len ( keys ) <nl> + expected_sum = np . zeros ( shape ) <nl> + for v in vals [ 0 ] : <nl> + expected_sum + = v . asnumpy ( ) <nl> + <nl> + kv . push ( str_keys , vals ) <nl> + if sparse_pull : <nl> + kv . row_sparse_pull ( str_keys , out = vals , row_ids = [ [ all_rows ] * num_devs ] * len ( vals ) ) <nl> + else : <nl> + kv . pull ( str_keys , out = vals , ignore_sparse = False ) <nl> + for vv in vals : <nl> + result_sum = np . zeros ( shape ) <nl> + for v in vv : <nl> + result_sum + = v . asnumpy ( ) <nl> + assert_almost_equal ( result_sum , expected_sum * num_devs ) <nl> + <nl> + check_sparse_aggregator ( False ) <nl> + check_sparse_aggregator ( True ) <nl> + <nl> def updater ( key , recv , local ) : <nl> " " " use updater : + = with int keys " " " <nl> assert ( isinstance ( key , int ) ) <nl> | Improve sparse pull performance for gluon trainer ( ) | apache/incubator-mxnet | 266de6bef4da5769431557288d41fab2a02e52ca | 2018-07-09T17:06:40Z |
new file mode 100644 <nl> index 0000000000000 . . 0b87a8263053b <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / mlir / tensorflow / tests / graphdef2mlir / device - arg - attr . pbtxt <nl> <nl> + # RUN : tf - mlir - translate - graphdef - to - mlir % s - tf - graph - as - function - o - | FileCheck % s - - dump - input = fail <nl> + <nl> + # Verify arg devices are added as arg attributes . <nl> + <nl> + # CHECK - LABEL : func @ main <nl> + # CHECK - SAME : ( % [ [ ARG_0 : [ a - z0 - 9 ] + ] ] : tensor < * xf32 > { tf . device = " / CPU : 0 " } , % [ [ ARG_1 : [ a - z0 - 9 ] + ] ] : tensor < 2x4x6x8xi32 > ) - > ( tensor < * xf32 > , tensor < 2x4x6x8xi32 > ) <nl> + <nl> + node { <nl> + name : " args_0 " <nl> + op : " _Arg " <nl> + device : " / CPU : 0 " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " index " <nl> + value { <nl> + i : 0 <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " args_1 " <nl> + op : " _Arg " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_INT32 <nl> + } <nl> + } <nl> + attr { <nl> + key : " _output_shapes " <nl> + value { <nl> + list { <nl> + shape { <nl> + dim { <nl> + size : 2 <nl> + } <nl> + dim { <nl> + size : 4 <nl> + } <nl> + dim { <nl> + size : 6 <nl> + } <nl> + dim { <nl> + size : 8 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + attr { <nl> + key : " index " <nl> + value { <nl> + i : 1 <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " identity " <nl> + op : " IdentityN " <nl> + input : " args_0 " <nl> + input : " args_1 " <nl> + attr : { <nl> + key : " T " <nl> + value : { <nl> + list : { <nl> + type : DT_FLOAT <nl> + type : DT_INT32 <nl> + } <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " rets_0 " <nl> + op : " _Retval " <nl> + input : " identity : 0 " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_FLOAT <nl> + } <nl> + } <nl> + attr { <nl> + key : " index " <nl> + value { <nl> + i : 0 <nl> + } <nl> + } <nl> + } <nl> + node { <nl> + name : " rets_1 " <nl> + op : " _Retval " <nl> + input : " identity : 1 " <nl> + attr { <nl> + key : " T " <nl> + value { <nl> + type : DT_INT32 <nl> + } <nl> + } <nl> + attr { <nl> + key : " index " <nl> + value { <nl> + i : 1 <nl> + } <nl> + } <nl> + } <nl> + versions { <nl> + producer : 121 <nl> + } <nl> mmm a / tensorflow / compiler / mlir / tensorflow / tests / graphdef2mlir / graph - scalar - input . pbtxt <nl> ppp b / tensorflow / compiler / mlir / tensorflow / tests / graphdef2mlir / graph - scalar - input . pbtxt <nl> <nl> <nl> # Verify that we match correctly the input / output when they are scalar . <nl> <nl> - # CHECK : func @ main ( % arg0 : tensor < f32 > ) - > ( tensor < f32 > , tensor < f32 > ) <nl> + # CHECK : func @ main ( % arg0 : tensor < f32 > { tf . device = " / device : CPU : 0 " } ) - > ( tensor < f32 > , tensor < f32 > ) <nl> # CHECK - NEXT : attributes { tf . entry_function = { inputs = " input " , outputs = " out : 1 , out " } } { <nl> <nl> # CHECK : tf . Relu <nl> mmm a / tensorflow / compiler / mlir / tensorflow / translate / import_model . cc <nl> ppp b / tensorflow / compiler / mlir / tensorflow / translate / import_model . cc <nl> class ImporterBase { <nl> / / arguments are added as basic block argument . Also the argument types and <nl> / / the id of the nodes from the input graph needs to be specified . <nl> Status ConvertFunctionArgAndRets ( <nl> - mlir : : Block * bb , mlir : : tf_executor : : GraphOp graph_op , <nl> + mlir : : FuncOp func , mlir : : tf_executor : : GraphOp graph_op , <nl> llvm : : ArrayRef < mlir : : Type > arg_types , <nl> const absl : : InlinedVector < OutputTensor , 4 > & arg_nodes , <nl> const absl : : InlinedVector < OutputTensor , 4 > & ret_nodes , <nl> Status ImporterBase : : Convert ( <nl> / / Seeds the builder with an initial block . <nl> function . addEntryBlock ( ) ; <nl> builder_ = mlir : : OpBuilder ( function . getBody ( ) ) ; <nl> - auto * bb = & function . front ( ) ; <nl> <nl> / / Create the graph operation in which we will convert the individual nodes . <nl> auto graph = builder_ . create < mlir : : tf_executor : : GraphOp > ( <nl> Status ImporterBase : : Convert ( <nl> / / pairs . <nl> TF_RETURN_IF_ERROR ( AddBackedges ( ) ) ; <nl> <nl> - return ConvertFunctionArgAndRets ( bb , graph , func_type . getInputs ( ) , arg_nodes , <nl> - ret_nodes , control_ret_nodes , <nl> + return ConvertFunctionArgAndRets ( function , graph , func_type . getInputs ( ) , <nl> + arg_nodes , ret_nodes , control_ret_nodes , <nl> add_pseudo_input_nodes ) ; <nl> } <nl> <nl> Status ImporterBase : : ConvertFunctionArgAndRets ( <nl> - mlir : : Block * bb , mlir : : tf_executor : : GraphOp graph_op , <nl> + mlir : : FuncOp func , mlir : : tf_executor : : GraphOp graph_op , <nl> llvm : : ArrayRef < mlir : : Type > arg_types , <nl> const absl : : InlinedVector < OutputTensor , 4 > & arg_nodes , <nl> const absl : : InlinedVector < OutputTensor , 4 > & ret_nodes , <nl> const absl : : InlinedVector < Node * , 4 > & control_ret_nodes , <nl> bool add_pseudo_input_nodes ) { <nl> + auto * bb = & func . front ( ) ; <nl> llvm : : SmallDenseMap < std : : pair < Node * , int > , mlir : : Value * , 4 > <nl> arg_nodes_to_values ; <nl> for ( int i = 0 , e = arg_types . size ( ) ; i < e ; + + i ) { <nl> Status ImporterBase : : ConvertFunctionArgAndRets ( <nl> for ( auto & control_use : llvm : : make_early_inc_range ( control_uses ) ) <nl> control_use . getOwner ( ) - > eraseOperand ( control_use . getOperandNumber ( ) ) ; <nl> <nl> + if ( ! arg_node . node - > requested_device ( ) . empty ( ) ) <nl> + func . setArgAttr ( <nl> + i , " tf . device " , <nl> + builder_ . getStringAttr ( arg_node . node - > requested_device ( ) ) ) ; <nl> + <nl> island - > dropAllReferences ( ) ; <nl> island - > erase ( ) ; <nl> continue ; <nl> | Add device of arg nodes as a function arg attribute when importing . | tensorflow/tensorflow | 914d3acbe7e34cbf4683d17da0a2d047348681b4 | 2019-11-07T19:21:09Z |
mmm a / tensorflow / lite / micro / benchmarks / BUILD <nl> ppp b / tensorflow / lite / micro / benchmarks / BUILD <nl> cc_binary ( <nl> " / / tensorflow / lite / micro / testing : micro_benchmark " , <nl> ] , <nl> ) <nl> + <nl> + cc_binary ( <nl> + name = " person_detection_benchmark " , <nl> + srcs = [ " person_detection_benchmark . cc " ] , <nl> + deps = [ <nl> + " / / tensorflow / lite : schema_fbs_version " , <nl> + " / / tensorflow / lite / c : common " , <nl> + " / / tensorflow / lite / micro : micro_framework " , <nl> + " / / tensorflow / lite / micro : micro_utils " , <nl> + " / / tensorflow / lite / micro / examples / person_detection : model_settings " , <nl> + " / / tensorflow / lite / micro / examples / person_detection : person_detect_model_data " , <nl> + " / / tensorflow / lite / micro / examples / person_detection : simple_images_test_data " , <nl> + " / / tensorflow / lite / micro / kernels : micro_ops " , <nl> + " / / tensorflow / lite / micro / testing : micro_benchmark " , <nl> + " / / tensorflow / lite / schema : schema_fbs " , <nl> + ] , <nl> + ) <nl> mmm a / tensorflow / lite / micro / benchmarks / Makefile . inc <nl> ppp b / tensorflow / lite / micro / benchmarks / Makefile . inc <nl> <nl> + $ ( eval $ ( call add_third_party_download , $ ( PERSON_MODEL_URL ) , $ ( PERSON_MODEL_MD5 ) , person_model_grayscale , ) ) <nl> + <nl> KEYWORD_BENCHMARK_SRCS : = \ <nl> tensorflow / lite / micro / benchmarks / keyword_benchmark . cc \ <nl> tensorflow / lite / micro / benchmarks / keyword_scrambled_model_data . cc <nl> tensorflow / lite / micro / benchmarks / keyword_scrambled_model_data . cc <nl> KEYWORD_BENCHMARK_HDRS : = \ <nl> tensorflow / lite / micro / benchmarks / keyword_scrambled_model_data . h <nl> <nl> + PERSON_DETECTION_BENCHMARK_SRCS : = \ <nl> + tensorflow / lite / micro / benchmarks / person_detection_benchmark . cc \ <nl> + $ ( MAKEFILE_DIR ) / downloads / person_model_grayscale / no_person_image_data . cc \ <nl> + $ ( MAKEFILE_DIR ) / downloads / person_model_grayscale / person_detect_model_data . cc \ <nl> + $ ( MAKEFILE_DIR ) / downloads / person_model_grayscale / person_image_data . cc <nl> + <nl> + PERSON_DETECTION_BENCHMARK_HDRS : = \ <nl> + tensorflow / lite / micro / examples / person_detection / person_detect_model_data . h <nl> + <nl> # Builds a standalone binary . <nl> $ ( eval $ ( call microlite_test , keyword_benchmark , \ <nl> $ ( KEYWORD_BENCHMARK_SRCS ) , $ ( KEYWORD_BENCHMARK_HDRS ) ) ) <nl> + <nl> + $ ( eval $ ( call microlite_test , person_detection_benchmark , \ <nl> + $ ( PERSON_DETECTION_BENCHMARK_SRCS ) , $ ( PERSON_DETECTION_BENCHMARK_HDRS ) ) ) <nl> mmm a / tensorflow / lite / micro / benchmarks / README . md <nl> ppp b / tensorflow / lite / micro / benchmarks / README . md <nl> platform . <nl> # # Table of contents <nl> <nl> - [ Keyword Benchmark ] ( # keyword - benchmark ) <nl> + - [ Person Detection Benchmark ] ( # person - detection - benchmark ) <nl> - [ Run on x86 ] ( # run - on - x86 ) <nl> - [ Run on Xtensa XPG Simulator ] ( # run - on - xtensa - xpg - simulator ) <nl> + - [ Run on Sparkfun Edge ] ( # run - on - sparkfun - edge ) <nl> <nl> # # Keyword benchmark <nl> <nl> weights and biases . This model is meant to test performance on a platform only . <nl> Since the weights are scrambled , the output is meaningless . In order to validate <nl> the accuracy of optimized kernels , please run the kernel tests . <nl> <nl> + # # Person detection benchmark <nl> + <nl> + The keyword benchmark provides a way to evaluate the performance of the 250KB <nl> + visual wakewords model . <nl> + <nl> # # Run on x86 <nl> <nl> To run the keyword benchmark on x86 , run <nl> + <nl> ` ` ` <nl> make - f tensorflow / lite / micro / tools / make / Makefile TAGS = posix test_keyword_benchmark <nl> ` ` ` <nl> <nl> + To run the person detection benchmark on x86 , run <nl> + <nl> + ` ` ` <nl> + make - f tensorflow / lite / micro / tools / make / Makefile TAGS = posix test_person_detection_benchmark <nl> + ` ` ` <nl> + <nl> # # Run on Xtensa XPG Simulator <nl> <nl> To run the keyword benchmark on the Xtensa XPG simulator , you will need a valid <nl> Xtensa toolchain and license . With these set up , run : <nl> + <nl> ` ` ` <nl> make - f tensorflow / lite / micro / tools / make / Makefile TARGET = xtensa - xpg XTENSA_CORE = < xtensa core > TAGS = xtensa_hifimini test_keyword_benchmark - j18 <nl> ` ` ` <nl> + <nl> + # # Run on Sparkfun Edge <nl> + The following instructions will help you build and deploy this benchmark on the <nl> + [ SparkFun Edge development board ] ( https : / / sparkfun . com / products / 15170 ) . <nl> + <nl> + <nl> + If you ' re new to using this board , we recommend walking through the <nl> + [ AI on a microcontroller with TensorFlow Lite and SparkFun Edge ] ( https : / / codelabs . developers . google . com / codelabs / sparkfun - tensorflow ) <nl> + codelab to get an understanding of the workflow . <nl> + <nl> + Build binary using <nl> + <nl> + ` ` ` <nl> + make - f tensorflow / lite / micro / tools / make / Makefile TARGET = sparkfun_edge person_detection_benchmark_bin <nl> + ` ` ` <nl> + <nl> + Refer to flashing instructions in the [ Person Detection Example ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / lite / micro / examples / person_detection / README . md # running - on - sparkfun - edge ) . <nl> + <nl> new file mode 100644 <nl> index 0000000000000 . . 5287a9c1e23a3 <nl> mmm / dev / null <nl> ppp b / tensorflow / lite / micro / benchmarks / person_detection_benchmark . cc <nl> <nl> + / * Copyright 2019 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / lite / c / common . h " <nl> + # include " tensorflow / lite / micro / examples / person_detection / model_settings . h " <nl> + # include " tensorflow / lite / micro / examples / person_detection / no_person_image_data . h " <nl> + # include " tensorflow / lite / micro / examples / person_detection / person_detect_model_data . h " <nl> + # include " tensorflow / lite / micro / examples / person_detection / person_image_data . h " <nl> + # include " tensorflow / lite / micro / kernels / micro_ops . h " <nl> + # include " tensorflow / lite / micro / micro_error_reporter . h " <nl> + # include " tensorflow / lite / micro / micro_interpreter . h " <nl> + # include " tensorflow / lite / micro / micro_mutable_op_resolver . h " <nl> + # include " tensorflow / lite / micro / micro_utils . h " <nl> + # include " tensorflow / lite / micro / testing / micro_benchmark . h " <nl> + # include " tensorflow / lite / schema / schema_generated . h " <nl> + # include " tensorflow / lite / version . h " <nl> + <nl> + / / Create an area of memory to use for input , output , and intermediate arrays . <nl> + constexpr int tensor_arena_size = 73 * 1024 ; <nl> + uint8_t tensor_arena [ tensor_arena_size ] ; <nl> + <nl> + / * <nl> + * Person Detection benchmark . Evaluates runtime performance of the visual <nl> + * wakewords person detection model . This is the same model found in <nl> + * exmaples / person_detection . <nl> + * / <nl> + <nl> + namespace { <nl> + <nl> + / / Create an area of memory to use for input , output , and intermediate arrays . <nl> + constexpr int tensor_arena_size = 73 * 1024 ; <nl> + uint8_t tensor_arena [ tensor_arena_size ] ; <nl> + <nl> + class PersonDetectionRunner { <nl> + public : <nl> + PersonDetectionRunner ( ) <nl> + : person_detection_model_ ( tflite : : GetModel ( g_person_detect_model_data ) ) , <nl> + reporter_ ( & micro_reporter_ ) , <nl> + interpreter_ ( person_detection_model_ , resolver_ , tensor_arena , <nl> + tensor_arena_size , reporter_ ) { <nl> + resolver_ . AddBuiltin ( tflite : : BuiltinOperator_DEPTHWISE_CONV_2D , <nl> + tflite : : ops : : micro : : Register_DEPTHWISE_CONV_2D ( ) ) ; <nl> + resolver_ . AddBuiltin ( tflite : : BuiltinOperator_CONV_2D , <nl> + tflite : : ops : : micro : : Register_CONV_2D ( ) ) ; <nl> + resolver_ . AddBuiltin ( tflite : : BuiltinOperator_AVERAGE_POOL_2D , <nl> + tflite : : ops : : micro : : Register_AVERAGE_POOL_2D ( ) ) ; <nl> + interpreter_ . AllocateTensors ( ) ; <nl> + <nl> + TfLiteTensor * input = interpreter_ . input ( 0 ) ; <nl> + TFLITE_CHECK_EQ ( input - > type , kTfLiteUInt8 ) ; <nl> + } <nl> + <nl> + void RunSingleIterationWithPerson ( ) { <nl> + / / Populate input tensor with an image with a person <nl> + TfLiteTensor * input = interpreter_ . input ( 0 ) ; <nl> + int8_t * input_buffer = tflite : : GetTensorData < int8_t > ( input ) ; <nl> + int input_length = tflite : : ElementCount ( * input - > dims ) ; <nl> + for ( int i = 0 ; i < input_length ; i + + ) { <nl> + input_buffer [ i ] = g_person_data [ i ] ; <nl> + } <nl> + <nl> + / / Run the model on this input and make sure it succeeds . <nl> + TfLiteStatus invoke_status = interpreter_ . Invoke ( ) ; <nl> + if ( invoke_status ! = kTfLiteOk ) { <nl> + TF_LITE_REPORT_ERROR ( reporter_ , " Invoke failed . " ) ; <nl> + } <nl> + } <nl> + <nl> + void RunSingleIterationWithoutPerson ( ) { <nl> + / / Populate input tensor with an image with no person . <nl> + TfLiteTensor * input = interpreter_ . input ( 0 ) ; <nl> + int8_t * input_buffer = tflite : : GetTensorData < int8_t > ( input ) ; <nl> + int input_length = tflite : : ElementCount ( * input - > dims ) ; <nl> + for ( int i = 0 ; i < input_length ; i + + ) { <nl> + input_buffer [ i ] = g_no_person_data [ i ] ; <nl> + } <nl> + <nl> + / / Run the model on this input and make sure it succeeds . <nl> + TfLiteStatus invoke_status = interpreter_ . Invoke ( ) ; <nl> + if ( invoke_status ! = kTfLiteOk ) { <nl> + TF_LITE_REPORT_ERROR ( reporter_ , " Invoke failed . " ) ; <nl> + } <nl> + } <nl> + <nl> + private : <nl> + const tflite : : Model * person_detection_model_ ; <nl> + tflite : : MicroErrorReporter micro_reporter_ ; <nl> + tflite : : ErrorReporter * reporter_ ; <nl> + tflite : : MicroOpResolver < 6 > resolver_ ; <nl> + tflite : : MicroInterpreter interpreter_ ; <nl> + } ; <nl> + <nl> + / / NOLINTNEXTLINE <nl> + PersonDetectionRunner runner ; <nl> + <nl> + void PersonDetectionFirstIteration ( ) { runner . RunSingleIterationWithPerson ( ) ; } <nl> + <nl> + void PersonDetectionTenIerationsWithPerson ( ) { <nl> + / / TODO ( b / 152644476 ) : Add a way to run more than a single deterministic input . <nl> + for ( int i = 0 ; i < 10 ; i + + ) { <nl> + runner . RunSingleIterationWithPerson ( ) ; <nl> + } <nl> + } <nl> + <nl> + void PersonDetectionTenIerationsWithoutPerson ( ) { <nl> + / / TODO ( b / 152644476 ) : Add a way to run more than a single deterministic input . <nl> + for ( int i = 0 ; i < 10 ; i + + ) { <nl> + runner . RunSingleIterationWithoutPerson ( ) ; <nl> + } <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + TF_LITE_MICRO_BENCHMARKS_BEGIN <nl> + <nl> + TF_LITE_MICRO_BENCHMARK ( PersonDetectionFirstIteration ) ; <nl> + TF_LITE_MICRO_BENCHMARK ( PersonDetectionTenIerationsWithPerson ) ; <nl> + TF_LITE_MICRO_BENCHMARK ( PersonDetectionTenIerationsWithoutPerson ) ; <nl> + <nl> + TF_LITE_MICRO_BENCHMARKS_END <nl> mmm a / tensorflow / lite / micro / testing / micro_benchmark . h <nl> ppp b / tensorflow / lite / micro / testing / micro_benchmark . h <nl> limitations under the License . <nl> # ifndef TENSORFLOW_LITE_MICRO_TESTING_MICRO_BENCHMARK_H_ <nl> # define TENSORFLOW_LITE_MICRO_TESTING_MICRO_BENCHMARK_H_ <nl> <nl> + # include < climits > <nl> + <nl> # include " tensorflow / lite / micro / micro_error_reporter . h " <nl> # include " tensorflow / lite / micro / micro_time . h " <nl> <nl> extern tflite : : ErrorReporter * reporter ; <nl> int32_t duration_ticks ; \ <nl> int32_t duration_ms ; <nl> <nl> - # define TF_LITE_MICRO_BENCHMARKS_END } <nl> + # define TF_LITE_MICRO_BENCHMARKS_END \ <nl> + return 0 ; \ <nl> + } <nl> <nl> # define TF_LITE_MICRO_BENCHMARK ( func ) \ <nl> if ( tflite : : ticks_per_second ( ) = = 0 ) { \ <nl> extern tflite : : ErrorReporter * reporter ; <nl> start_ticks = tflite : : GetCurrentTimeTicks ( ) ; \ <nl> func ( ) ; \ <nl> duration_ticks = tflite : : GetCurrentTimeTicks ( ) - start_ticks ; \ <nl> - duration_ms = ( duration_ticks * 1000 ) / tflite : : ticks_per_second ( ) ; \ <nl> + if ( duration_ticks > INT_MAX / 1000 ) { \ <nl> + duration_ms = duration_ticks / ( tflite : : ticks_per_second ( ) / 1000 ) ; \ <nl> + } else { \ <nl> + duration_ms = ( duration_ticks * 1000 ) / tflite : : ticks_per_second ( ) ; \ <nl> + } \ <nl> TF_LITE_REPORT_ERROR ( micro_benchmark : : reporter , " % s took % d ticks ( % d ms ) " , \ <nl> # func , duration_ticks , duration_ms ) ; <nl> <nl> mmm a / tensorflow / lite / micro / tools / make / helper_functions . inc <nl> ppp b / tensorflow / lite / micro / tools / make / helper_functions . inc <nl> $ ( call generate_project , make , $ ( MAKE_PROJECT_FILES ) , $ ( 1 ) , $ ( MICROLITE_CC_SRCS ) $ ( T <nl> $ ( call generate_arc_project , make , $ ( MAKE_PROJECT_FILES ) , $ ( 1 ) , $ ( MICROLITE_CC_SRCS ) $ ( THIRD_PARTY_CC_SRCS ) $ ( 2 ) , $ ( MICROLITE_CC_HDRS ) $ ( THIRD_PARTY_CC_HDRS ) $ ( MICROLITE_TEST_HDRS ) $ ( 3 ) , $ ( LDFLAGS ) $ ( GENERATED_PROJECT_LIBS ) , $ ( CXXFLAGS ) $ ( GENERATED_PROJECT_INCLUDES ) , $ ( CCFLAGS ) $ ( GENERATED_PROJECT_INCLUDES ) ) <nl> $ ( call generate_project , mbed , $ ( MBED_PROJECT_FILES ) , $ ( 1 ) , $ ( MICROLITE_CC_SRCS ) $ ( THIRD_PARTY_CC_SRCS ) $ ( 2 ) , $ ( MICROLITE_CC_HDRS ) $ ( THIRD_PARTY_CC_HDRS ) $ ( MICROLITE_TEST_HDRS ) $ ( 3 ) , $ ( MICROLITE_LIBS ) , $ ( CXXFLAGS ) , $ ( CCFLAGS ) , $ ( TARGET_TOOLCHAIN_ROOT ) , $ ( TARGET_TOOLCHAIN_PREFIX ) ) <nl> $ ( call generate_project , keil , $ ( KEIL_PROJECT_FILES ) , $ ( 1 ) , $ ( MICROLITE_CC_SRCS ) $ ( THIRD_PARTY_CC_SRCS ) $ ( 2 ) , $ ( MICROLITE_CC_HDRS ) $ ( THIRD_PARTY_CC_HDRS ) $ ( MICROLITE_TEST_HDRS ) $ ( 3 ) , $ ( MICROLITE_LIBS ) , $ ( CXXFLAGS ) , $ ( CCFLAGS ) , $ ( TARGET_TOOLCHAIN_ROOT ) , $ ( TARGET_TOOLCHAIN_PREFIX ) ) <nl> - $ ( call generate_arduino_project , $ ( ARDUINO_PROJECT_FILES ) , $ ( 1 ) , $ ( MICROLITE_CC_SRCS ) $ ( THIRD_PARTY_CC_SRCS ) $ ( 2 ) , $ ( MICROLITE_CC_HDRS ) $ ( THIRD_PARTY_CC_HDRS ) $ ( MICROLITE_TEST_HDRS ) $ ( 3 ) , $ ( MICROLITE_LIBS ) , $ ( CXXFLAGS ) , $ ( CCFLAGS ) ) <nl> + ifeq ( , $ ( findstring _benchmark , $ ( 1 ) ) ) <nl> + $ ( call generate_arduino_project , $ ( ARDUINO_PROJECT_FILES ) , $ ( 1 ) , $ ( MICROLITE_CC_SRCS ) $ ( THIRD_PARTY_CC_SRCS ) $ ( 2 ) , $ ( MICROLITE_CC_HDRS ) $ ( THIRD_PARTY_CC_HDRS ) $ ( MICROLITE_TEST_HDRS ) $ ( 3 ) , $ ( MICROLITE_LIBS ) , $ ( CXXFLAGS ) , $ ( CCFLAGS ) ) <nl> + endif <nl> $ ( call generate_esp_project , $ ( ESP_PROJECT_FILES ) , $ ( 1 ) , $ ( MICROLITE_CC_SRCS ) $ ( THIRD_PARTY_CC_SRCS ) , $ ( MICROLITE_CC_HDRS ) $ ( THIRD_PARTY_CC_HDRS ) $ ( MICROLITE_TEST_HDRS ) , $ ( 2 ) , $ ( 3 ) , $ ( MICROLITE_LIBS ) , $ ( CXXFLAGS ) , $ ( CCFLAGS ) , $ ( PROJECT_INCLUDES ) ) <nl> endef <nl> <nl> | Create a benchmark for the person detection model . | tensorflow/tensorflow | e225b8c8ca654549dbeb29db0a8410ef84178101 | 2020-04-21T19:46:03Z |
mmm a / system / lib / dlmalloc . c <nl> ppp b / system / lib / dlmalloc . c <nl> <nl> # define HAVE_MMAP 0 <nl> / * we can only grow the heap up anyhow , so don ' t try to trim * / <nl> # define MORECORE_CANNOT_TRIM 1 <nl> + / * XXX Emscripten Tracing API . This defines away the code if tracing is disabled . * / <nl> + # include < emscripten / trace . h > <nl> # endif <nl> <nl> <nl> void * dlmalloc ( size_t bytes ) { <nl> <nl> postaction : <nl> POSTACTION ( gm ) ; <nl> + # if __EMSCRIPTEN__ <nl> + / * XXX Emscripten Tracing API . * / <nl> + emscripten_trace_record_allocation ( mem , bytes ) ; <nl> + # endif <nl> return mem ; <nl> } <nl> <nl> void dlfree ( void * mem ) { <nl> * / <nl> <nl> if ( mem ! = 0 ) { <nl> + # if __EMSCRIPTEN__ <nl> + / * XXX Emscripten Tracing API . * / <nl> + emscripten_trace_record_free ( mem ) ; <nl> + # endif <nl> mchunkptr p = mem2chunk ( mem ) ; <nl> # if FOOTERS <nl> mstate fm = get_mstate_for ( p ) ; <nl> void * dlrealloc ( void * oldmem , size_t bytes ) { <nl> } <nl> } <nl> } <nl> + # if __EMSCRIPTEN__ <nl> + / * XXX Emscripten Tracing API . * / <nl> + emscripten_trace_record_reallocation ( oldmem , mem , bytes ) ; <nl> + # endif <nl> } <nl> return mem ; <nl> } <nl> | [ tracing ] Instrument dlmalloc . c | emscripten-core/emscripten | 06606f99b3479d55c001d536a439fa50ef0f2731 | 2014-09-05T19:44:21Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.