diff
stringlengths
41
2.03M
msg
stringlengths
1
1.5k
repo
stringlengths
5
40
sha
stringlengths
40
40
time
stringlengths
20
20
mmm a / stdlib / public / core / StringInterpolation . swift . gyb <nl> ppp b / stdlib / public / core / StringInterpolation . swift . gyb <nl> extension String : _ExpressibleByStringInterpolation { <nl> self = String ( describing : expr ) <nl> } <nl> <nl> + % for Type in StreamableTypes : <nl> / / / Creates a string containing the given value ' s textual representation . <nl> / / / <nl> / / / Do not call this initializer directly . It is used by the compiler when <nl> / / / interpreting string interpolations . <nl> / / / <nl> / / / - SeeAlso : ` ExpressibleByStringInterpolation ` <nl> - public init < T : TextOutputStreamable > ( stringInterpolationSegment expr : T ) { <nl> + public init ( stringInterpolationSegment expr : $ { Type } ) { <nl> self = _toStringReadOnlyStreamable ( expr ) <nl> } <nl> + % end <nl> <nl> + % for Type in PrintableTypes : <nl> / / / Creates a string containing the given value ' s textual representation . <nl> / / / <nl> / / / Do not call this initializer directly . It is used by the compiler when <nl> / / / interpreting string interpolations . <nl> / / / <nl> / / / - SeeAlso : ` ExpressibleByStringInterpolation ` <nl> - public init < T : CustomStringConvertible > ( stringInterpolationSegment expr : T ) { <nl> + public init ( stringInterpolationSegment expr : $ { Type } ) { <nl> self = _toStringReadOnlyPrintable ( expr ) <nl> } <nl> - <nl> - / / / Creates a string containing the given value ' s textual representation . <nl> - / / / <nl> - / / / Do not call this initializer directly . It is used by the compiler when <nl> - / / / interpreting string interpolations . <nl> - / / / <nl> - / / / - SeeAlso : ` ExpressibleByStringInterpolation ` <nl> - public init < T : TextOutputStreamable & CustomStringConvertible > ( stringInterpolationSegment expr : T ) { <nl> - self = _toStringReadOnlyStreamable ( expr ) <nl> - } <nl> + % end <nl> } <nl> <nl> / / $ { ' Local Variables ' } : <nl> mmm a / test / api - digester / source - stability . swift . expected <nl> ppp b / test / api - digester / source - stability . swift . expected <nl> Protocol IndexableBase has been removed ( deprecated ) <nl> Protocol MutableIndexable has been removed ( deprecated ) <nl> Protocol RandomAccessIndexable has been removed ( deprecated ) <nl> Protocol RangeReplaceableIndexable has been removed ( deprecated ) <nl> - Constructor String . init ( stringInterpolationSegment : ) has been removed <nl> Func Array . append ( contentsOf : ) has been removed <nl> Func ArraySlice . append ( contentsOf : ) has been removed <nl> Func ContiguousArray . append ( contentsOf : ) has been removed <nl> Constructor RangeReplaceableBidirectionalSlice . init ( base : bounds : ) has 2nd parame <nl> Constructor RangeReplaceableRandomAccessSlice . init ( base : bounds : ) has 2nd parameter type change from Range < Base . Index > to Range < RangeReplaceableRandomAccessSlice . Index > <nl> Constructor RangeReplaceableSlice . init ( base : bounds : ) has 2nd parameter type change from Range < Base . Index > to Range < RangeReplaceableSlice . Index > <nl> Constructor Slice . init ( base : bounds : ) has 2nd parameter type change from Range < Base . Index > to Range < Slice . Index > <nl> - Constructor String . init ( stringInterpolationSegment : ) has 1st parameter type change from String to T <nl> Func AnyBidirectionalCollection . makeIterator ( ) has return type change from AnyIterator < Element > to AnyBidirectionalCollection . Iterator <nl> Func AnyCollection . makeIterator ( ) has return type change from AnyIterator < Element > to AnyCollection . Iterator <nl> Func AnyRandomAccessCollection . makeIterator ( ) has return type change from AnyIterator < Element > to AnyRandomAccessCollection . Iterator <nl> deleted file mode 100644 <nl> index 519d3cbe3af3 . . 000000000000 <nl> mmm a / validation - test / Sema / interpolation_placeholders . swift <nl> ppp / dev / null <nl> <nl> - / / RUN : not % target - swift - frontend - typecheck % s <nl> - <nl> - let query = " < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) & < # . . . # > = \ ( < # . . . # > ) " <nl> - <nl>
Revert " Replace concrete init ( stringInterpolationSegment : ) ' s with generic ones "
apple/swift
e387361194c3d127d7ba0cf79d7df44871f7af86
2017-02-08T21:38:11Z
mmm a / src / compiler / typer . cc <nl> ppp b / src / compiler / typer . cc <nl> Type * Typer : : Visitor : : TypeConstant ( Handle < Object > value ) { <nl> int const arity = <nl> JSFunction : : cast ( * value ) - > shared ( ) - > internal_formal_parameter_count ( ) ; <nl> switch ( arity ) { <nl> + case SharedFunctionInfo : : kDontAdaptArgumentsSentinel : <nl> + / / Some smart optimization at work . . . & % $ ! & @ + $ ! <nl> + return Type : : Any ( zone ( ) ) ; <nl> case 0 : <nl> return typer_ - > cache_ - > Get ( kAnyFunc0 ) ; <nl> case 1 : <nl> Type * Typer : : Visitor : : TypeConstant ( Handle < Object > value ) { <nl> case 3 : <nl> return typer_ - > cache_ - > Get ( kAnyFunc3 ) ; <nl> default : { <nl> + DCHECK_LT ( 3 , arity ) ; <nl> Type * * const params = zone ( ) - > NewArray < Type * > ( arity ) ; <nl> std : : fill ( & params [ 0 ] , & params [ arity ] , Type : : Any ( zone ( ) ) ) ; <nl> return Type : : Function ( Type : : Any ( zone ( ) ) , arity , params , zone ( ) ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 08d0d107cad <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - crbug - 500824 . js <nl> <nl> + / / Copyright 2015 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + / / Flags : - - allow - natives - syntax <nl> + <nl> + function get_thrower ( ) { <nl> + " use strict " ; <nl> + return Object . getOwnPropertyDescriptor ( arguments , " callee " ) . get ; <nl> + } <nl> + <nl> + var f = ( function ( v ) { <nl> + " use asm " ; <nl> + function fun ( ) { <nl> + switch ( v ) { } <nl> + } <nl> + return { <nl> + fun : fun <nl> + } ; <nl> + } ) ( get_thrower ( ) ) . fun ; <nl> + <nl> + % OptimizeFunctionOnNextCall ( f ) ; <nl> + f ( ) ; <nl>
[ turbofan ] Work around negative parameter count .
v8/v8
21a1975542e7abd46db7d2074514eb67a6f525a1
2015-06-16T09:44:28Z
new file mode 100644 <nl> index 000000000000 . . 16c6814c6343 <nl> mmm / dev / null <nl> ppp b / validation - test / IDE / crashers / 100 - swift - mangle - mangler - mangledeclname . swift <nl> <nl> + / / RUN : not - - crash % target - swift - ide - test - code - completion - code - completion - token = A - source - filename = % s <nl> + / / REQUIRES : asserts <nl> + { let : { class S ( } # ^ A ^ # <nl> \ No newline at end of file <nl>
Merge pull request from practicalswift / sourcekit - 100 - swift - mangle - mangler - mangledeclname
apple/swift
fd0d4b796ae0be00611f29ea21c8998e2d2dad76
2016-10-10T12:12:30Z
mmm a / src / compiler / node - origin - table . cc <nl> ppp b / src / compiler / node - origin - table . cc <nl> namespace internal { <nl> namespace compiler { <nl> <nl> void NodeOrigin : : PrintJson ( std : : ostream & out ) const { <nl> - out < < " { " <nl> - < < " \ " nodeId \ " : " < < created_from ( ) < < " , \ " reducer \ " : \ " " <nl> - < < reducer_name ( ) < < " \ " " <nl> - < < " } " ; <nl> + out < < " { " ; <nl> + out < < " \ " nodeId \ " : " < < created_from ( ) ; <nl> + out < < " , \ " reducer \ " : \ " " < < reducer_name ( ) < < " \ " " ; <nl> + out < < " , \ " phase \ " : \ " " < < phase_name ( ) < < " \ " " ; <nl> + out < < " } " ; <nl> } <nl> <nl> class NodeOriginTable : : Decorator final : public GraphDecorator { <nl> NodeOriginTable : : NodeOriginTable ( Graph * graph ) <nl> : graph_ ( graph ) , <nl> decorator_ ( nullptr ) , <nl> current_origin_ ( NodeOrigin : : Unknown ( ) ) , <nl> + current_phase_name_ ( " unknown " ) , <nl> table_ ( graph - > zone ( ) ) { } <nl> <nl> void NodeOriginTable : : AddDecorator ( ) { <nl> mmm a / src / compiler / node - origin - table . h <nl> ppp b / src / compiler / node - origin - table . h <nl> namespace compiler { <nl> <nl> class NodeOrigin { <nl> public : <nl> - NodeOrigin ( const char * reducer_name , NodeId created_from ) <nl> - : reducer_name_ ( reducer_name ) , created_from_ ( created_from ) { } <nl> + NodeOrigin ( const char * phase_name , const char * reducer_name , <nl> + NodeId created_from ) <nl> + : phase_name_ ( phase_name ) , <nl> + reducer_name_ ( reducer_name ) , <nl> + created_from_ ( created_from ) { } <nl> NodeOrigin ( const NodeOrigin & other ) = default ; <nl> static NodeOrigin Unknown ( ) { return NodeOrigin ( ) ; } <nl> <nl> bool IsKnown ( ) { return created_from_ > = 0 ; } <nl> int64_t created_from ( ) const { return created_from_ ; } <nl> const char * reducer_name ( ) const { return reducer_name_ ; } <nl> + const char * phase_name ( ) const { return phase_name_ ; } <nl> <nl> bool operator = = ( const NodeOrigin & o ) const { <nl> return reducer_name_ = = o . reducer_name_ & & created_from_ = = o . created_from_ ; <nl> class NodeOrigin { <nl> <nl> private : <nl> NodeOrigin ( ) <nl> - : reducer_name_ ( " " ) , created_from_ ( std : : numeric_limits < int64_t > : : min ( ) ) { } <nl> + : phase_name_ ( " " ) , <nl> + reducer_name_ ( " " ) , <nl> + created_from_ ( std : : numeric_limits < int64_t > : : min ( ) ) { } <nl> + const char * phase_name_ ; <nl> const char * reducer_name_ ; <nl> int64_t created_from_ ; <nl> } ; <nl> class V8_EXPORT_PRIVATE NodeOriginTable final <nl> : origins_ ( origins ) , prev_origin_ ( NodeOrigin : : Unknown ( ) ) { <nl> if ( origins ) { <nl> prev_origin_ = origins - > current_origin_ ; <nl> - origins - > current_origin_ = NodeOrigin ( reducer_name , node - > id ( ) ) ; <nl> + origins - > current_origin_ = <nl> + NodeOrigin ( origins - > current_phase_name_ , reducer_name , node - > id ( ) ) ; <nl> } <nl> } <nl> <nl> class V8_EXPORT_PRIVATE NodeOriginTable final <nl> DISALLOW_COPY_AND_ASSIGN ( Scope ) ; <nl> } ; <nl> <nl> + class PhaseScope final { <nl> + public : <nl> + PhaseScope ( NodeOriginTable * origins , const char * phase_name ) <nl> + : origins_ ( origins ) { <nl> + if ( origins ! = nullptr ) { <nl> + prev_phase_name_ = origins - > current_phase_name_ ; <nl> + origins - > current_phase_name_ = <nl> + phase_name = = nullptr ? " unnamed " : phase_name ; <nl> + } <nl> + } <nl> + <nl> + ~ PhaseScope ( ) { <nl> + if ( origins_ ) origins_ - > current_phase_name_ = prev_phase_name_ ; <nl> + } <nl> + <nl> + private : <nl> + NodeOriginTable * const origins_ ; <nl> + const char * prev_phase_name_ ; <nl> + DISALLOW_COPY_AND_ASSIGN ( PhaseScope ) ; <nl> + } ; <nl> + <nl> explicit NodeOriginTable ( Graph * graph ) ; <nl> <nl> void AddDecorator ( ) ; <nl> class V8_EXPORT_PRIVATE NodeOriginTable final <nl> Graph * const graph_ ; <nl> Decorator * decorator_ ; <nl> NodeOrigin current_origin_ ; <nl> + <nl> + const char * current_phase_name_ ; <nl> NodeAuxData < NodeOrigin , NodeOrigin : : Unknown > table_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( NodeOriginTable ) ; <nl> mmm a / src / compiler / pipeline . cc <nl> ppp b / src / compiler / pipeline . cc <nl> class PipelineRunScope { <nl> : phase_scope_ ( <nl> phase_name = = nullptr ? nullptr : data - > pipeline_statistics ( ) , <nl> phase_name ) , <nl> - zone_scope_ ( data - > zone_stats ( ) , ZONE_NAME ) { } <nl> + zone_scope_ ( data - > zone_stats ( ) , ZONE_NAME ) , <nl> + origin_scope_ ( data - > node_origins ( ) , phase_name ) { } <nl> <nl> Zone * zone ( ) { return zone_scope_ . zone ( ) ; } <nl> <nl> private : <nl> PhaseScope phase_scope_ ; <nl> ZoneStats : : Scope zone_scope_ ; <nl> + NodeOriginTable : : PhaseScope origin_scope_ ; <nl> } ; <nl> <nl> PipelineStatistics * CreatePipelineStatistics ( Handle < Script > script , <nl> mmm a / tools / turbolizer / graph - view . js <nl> ppp b / tools / turbolizer / graph - view . js <nl> class GraphView extends View { <nl> return pane ; <nl> } <nl> <nl> - constructor ( d3 , id , broker ) { <nl> + constructor ( d3 , id , broker , showPhaseByName ) { <nl> super ( id , broker ) ; <nl> var graph = this ; <nl> + this . showPhaseByName = showPhaseByName <nl> <nl> var svg = this . divElement . append ( " svg " ) . attr ( ' version ' , ' 1 . 1 ' ) <nl> . attr ( " width " , " 100 % " ) <nl> class GraphView extends View { <nl> var filterFunction = function ( n ) { <nl> return ( reg . exec ( n . getDisplayLabel ( ) ) ! = null | | <nl> ( graph . state . showTypes & & reg . exec ( n . getDisplayType ( ) ) ) | | <nl> + ( reg . exec ( n . getTitle ( ) ) ) | | <nl> reg . exec ( n . opcode ) ! = null ) ; <nl> } ; <nl> <nl> class GraphView extends View { <nl> selectOrigins ( ) { <nl> const state = this . state ; <nl> const origins = [ ] ; <nl> + let phase = null ; <nl> for ( const n of state . selection ) { <nl> if ( n . origin ) { <nl> const node = this . nodeMap [ n . origin . nodeId ] ; <nl> origins . push ( node ) ; <nl> + phase = n . origin . phase ; <nl> } <nl> } <nl> if ( origins . length ) { <nl> state . selection . clear ( ) ; <nl> state . selection . select ( origins , true ) ; <nl> - this . updateGraphVisibility ( ) ; <nl> + if ( phase ) { <nl> + this . showPhaseByName ( phase ) ; <nl> + } <nl> } <nl> } <nl> <nl> mmm a / tools / turbolizer / node . js <nl> ppp b / tools / turbolizer / node . js <nl> var Node = { <nl> } <nl> let title = this . title + " \ n " + propsString + " \ n " + this . opinfo ; <nl> if ( this . origin ) { <nl> - title + = ` \ nOrigin : $ { this . origin . reducer } from # $ { this . origin . nodeId } ` ; <nl> + title + = ` \ nOrigin : # $ { this . origin . nodeId } in phase $ { this . origin . phase } / $ { this . origin . reducer } ` ; <nl> } <nl> return title ; <nl> } , <nl> mmm a / tools / turbolizer / source - resolver . js <nl> ppp b / tools / turbolizer / source - resolver . js <nl> class SourceResolver { <nl> this . positionToNodes = new Map ( ) ; <nl> / / Maps phase ids to phases . <nl> this . phases = [ ] ; <nl> + / / Maps phase names to phaseIds . <nl> + this . phaseNames = new Map ( ) ; <nl> / / The disassembly phase is stored separately . <nl> this . disassemblyPhase = undefined ; <nl> } <nl> class SourceResolver { <nl> this . disassemblyPhase = phase ; <nl> } else if ( phase . type = = ' schedule ' ) { <nl> this . phases . push ( this . parseSchedule ( phase ) ) <nl> + this . phaseNames . set ( phase . name , this . phases . length ) ; <nl> } else { <nl> this . phases . push ( phase ) ; <nl> + this . phaseNames . set ( phase . name , this . phases . length ) ; <nl> } <nl> } <nl> } <nl> class SourceResolver { <nl> return this . phases [ phaseId ] ; <nl> } <nl> <nl> + getPhaseIdByName ( phaseName ) { <nl> + return this . phaseNames . get ( phaseName ) ; <nl> + } <nl> + <nl> forEachPhase ( f ) { <nl> this . phases . forEach ( f ) ; <nl> } <nl> mmm a / tools / turbolizer / turbo - visualizer . js <nl> ppp b / tools / turbolizer / turbo - visualizer . js <nl> document . onload = ( function ( d3 ) { <nl> const initialPhaseIndex = sourceResolver . repairPhaseId ( + window . sessionStorage . getItem ( " lastSelectedPhase " ) ) ; <nl> selectMenu . selectedIndex = initialPhaseIndex ; <nl> <nl> - graph = new GraphView ( d3 , INTERMEDIATE_PANE_ID , selectionBroker ) ; <nl> + function displayPhaseByName ( phaseName ) { <nl> + const phaseId = sourceResolver . getPhaseIdByName ( phaseName ) ; <nl> + selectMenu . selectedIndex = phaseId - 1 ; <nl> + displayPhase ( sourceResolver . getPhase ( phaseId ) ) ; <nl> + } <nl> + <nl> + graph = new GraphView ( d3 , INTERMEDIATE_PANE_ID , selectionBroker , displayPhaseByName ) ; <nl> schedule = new ScheduleView ( INTERMEDIATE_PANE_ID , selectionBroker ) ; <nl> <nl> displayPhase ( sourceResolver . getPhase ( initialPhaseIndex ) ) ; <nl>
[ turbolizer ] Add reducer phase to node origin
v8/v8
2cd48c74e016057153a950bc85d7e3dc8a446718
2018-05-22T12:13:41Z
mmm a / tests / cpp - tests / Classes / NewAudioEngineTest / NewAudioEngineTest . cpp <nl> ppp b / tests / cpp - tests / Classes / NewAudioEngineTest / NewAudioEngineTest . cpp <nl> bool LargeAudioFileTest : : init ( ) <nl> auto ret = AudioEngineTestDemo : : init ( ) ; <nl> <nl> auto playItem = TextButton : : create ( " play large audio file " , [ & ] ( TextButton * button ) { <nl> - AudioEngine : : play2d ( " audio / Chee Lai ( Arise ) . mp3 " ) ; <nl> + AudioEngine : : play2d ( " audio / LuckyDay . mp3 " ) ; <nl> } ) ; <nl> playItem - > setNormalizedPosition ( Vec2 : : ANCHOR_MIDDLE ) ; <nl> this - > addChild ( playItem ) ; <nl> new file mode 100644 <nl> index 000000000000 . . be00674fb987 <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / LuckyDay . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . e9913ef89c90 <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX081 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 198438b66a2e <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX082 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 0108d518d531 <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX083 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 45290473d3a3 <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX084 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 760623fdc498 <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX085 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 78509a73e609 <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX086 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 37f1200bfddf <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX087 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 4c2f0beede94 <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX088 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 5397a72cdb52 <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX089 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . 521c162d6a1f <nl> Binary files / dev / null and b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / FX090 . mp3 differ <nl> new file mode 100644 <nl> index 000000000000 . . bffb6e502bbb <nl> mmm / dev / null <nl> ppp b / tests / cpp - tests / Resources / audio / SoundEffectsFX009 / README . txt <nl> <nl> + These files in the ' SoundEffectsFX009 ' directory is <nl> + copyright 2014 by jalastram and is licensed under a <nl> + Creative Commons Attribution 3 . 0 Unported License : <nl> + http : / / creativecommons . org / licenses / by / 3 . 0 / <nl>
Merge pull request from Dhilan007 / v3 - res
cocos2d/cocos2d-x
a51254decf38bf935e9b66e1fcad049f8af2d99c
2014-09-23T09:10:50Z
mmm a / src / third_party / wiredtiger / dist / s_all <nl> ppp b / src / third_party / wiredtiger / dist / s_all <nl> errchk ( ) <nl> <nl> # Some tests shouldn ' t return an error , we exclude them here . <nl> case " $ 1 " in <nl> - * s_export * ) <nl> + * s_export | * s_tags ) <nl> break ; ; <nl> * ) <nl> errfound = 1 ; ; <nl> echo ' dist / s_all run finished ' <nl> if test $ errmode - ne 0 ; then <nl> exit $ errfound ; <nl> fi <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_c_test_create <nl> ppp b / src / third_party / wiredtiger / dist / s_c_test_create <nl> <nl> # script in the main C suite directory . <nl> # <nl> tmp = __a <nl> - trap ' rm - f $ tmp ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ tmp ' 0 1 2 3 13 15 <nl> <nl> if [ " x $ 1 " = " x " ] ; then <nl> echo " Usage : $ 0 test_name " <nl> mmm a / src / third_party / wiredtiger / dist / s_copyright <nl> ppp b / src / third_party / wiredtiger / dist / s_copyright <nl> if [ $ # - ne 0 ] ; then <nl> exit 0 <nl> fi <nl> <nl> - trap ' rm - f $ c1 $ c2 $ c3 $ c4 ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ c1 $ c2 $ c3 $ c4 ' 0 1 2 3 13 15 <nl> <nl> year = ` date + % Y ` <nl> <nl> special_copyright LICENSE 1 " $ string1 " <nl> special_copyright src / docs / build - javadoc . sh 1 " $ string2 " <nl> special_copyright src / docs / style / footer . html 2 " $ string2 " <nl> special_copyright src / utilities / util_cpyright . c 1 " $ string3 " <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_define <nl> ppp b / src / third_party / wiredtiger / dist / s_define <nl> <nl> <nl> # Complain about unused # defines . <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # List of source files to search . <nl> l = ` sed - e ' / ^ [ a - z ] / ! d ' - e ' s / [ ] . * $ / / ' - e ' s , ^ , . . / , ' filelist ` <nl> mmm a / src / third_party / wiredtiger / dist / s_docs <nl> ppp b / src / third_party / wiredtiger / dist / s_docs <nl> <nl> # ! / bin / sh <nl> <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t / tmp / __doxy ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t / tmp / __doxy ' 0 1 2 3 13 15 <nl> <nl> # Skip this when building release packages : docs are built separately <nl> test - n " $ WT_RELEASE_BUILD " & & exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_export <nl> ppp b / src / third_party / wiredtiger / dist / s_export <nl> <nl> <nl> # Check for illegal external symbols . <nl> # <nl> - t = __a . c <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + t = __wt . $ $ <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> case ` uname ` in <nl> Darwin ) <nl> check ( ) <nl> } <nl> <nl> # This check would normally be done after the library is built , but this way <nl> - # we don ' t forget about a symbol during development . Check the previously <nl> - # built library , if it exists . <nl> + # we don ' t forget about a symbol during development . We usually build in the <nl> + # top - level or build_posix directories , check the previously built library , <nl> + # if it exists . And , allow this script to be run from the top - level directory <nl> + # as well as locally . <nl> for d in . libs build_posix / . libs ; do <nl> f = " $ d / libwiredtiger . a " <nl> test - f $ f & & check $ f <nl> mmm a / src / third_party / wiredtiger / dist / s_funcs <nl> ppp b / src / third_party / wiredtiger / dist / s_funcs <nl> <nl> <nl> # Complain about unused functions <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # List of files to search . <nl> l = ` sed - e ' / ^ [ a - z ] / ! d ' - e ' s / [ ] . * $ / / ' - e ' s , ^ , . . / , ' filelist ` <nl> mmm a / src / third_party / wiredtiger / dist / s_label <nl> ppp b / src / third_party / wiredtiger / dist / s_label <nl> <nl> <nl> # Check WiredTiger error / return macros . <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> cd . . <nl> <nl> for f in ` find bench examples ext src test - name ' * . [ ci ] ' ` ; do <nl> sed - e " s , ^ , $ f : , " - e ' s / $ / [ return skips API_END call ] / ' <nl> <nl> done <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_lang <nl> ppp b / src / third_party / wiredtiger / dist / s_lang <nl> <nl> <nl> # Check lang directories for potential name conflicts <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> cd . . / lang <nl> <nl> for d in * ; do <nl> echo " $ l : potential SWIG naming conflict " <nl> echo " = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = " <nl> cat $ t <nl> + exit 1 <nl> } <nl> done <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_longlines <nl> ppp b / src / third_party / wiredtiger / dist / s_longlines <nl> <nl> <nl> # Check for long lines <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> l = ` ( cd . . & & <nl> find bench / wtperf examples ext src test - name ' * . [ chisy ] ' & & <nl> for f in $ l ; do <nl> expand - t8 < . . / $ f | awk - - \ <nl> " { if ( length ( \ $ 0 ) > 80 ) printf ( \ " % s : % d \ \ n \ " , \ " $ f \ " , NR ) } " <nl> done <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_prototypes <nl> ppp b / src / third_party / wiredtiger / dist / s_prototypes <nl> <nl> <nl> # Build a list of internal function and variable prototypes . <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # proto - - <nl> # extract public functions . <nl> l = ` sed \ <nl> - e ' / os_win / d ' \ <nl> - e ' s / [ ] . * $ / / ' filelist ` <nl> externs <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_python <nl> ppp b / src / third_party / wiredtiger / dist / s_python <nl> <nl> <nl> # Python style checks . <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> cd . . <nl> <nl> test - s $ t & & { <nl> echo ' trailing semi - colons in selected Python code : ' <nl> cat $ t <nl> } <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_readme <nl> ppp b / src / third_party / wiredtiger / dist / s_readme <nl> <nl> # ! / bin / sh <nl> <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> f = . . / README <nl> <nl> . . . / RELEASE_INFO <nl> END_TEXT <nl> <nl> cmp $ t $ f > / dev / null 2 > & 1 | | <nl> ( echo " Building $ f " & & rm - f $ f & & cp $ t $ f ) <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_stat <nl> ppp b / src / third_party / wiredtiger / dist / s_stat <nl> <nl> <nl> # Complain about unused statistics fields . <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # List of files to search : skip stat . c , it lists all of the fields by <nl> # definition . <nl> mmm a / src / third_party / wiredtiger / dist / s_string <nl> ppp b / src / third_party / wiredtiger / dist / s_string <nl> <nl> # Check spelling in comments and quoted strings from the source files . <nl> <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # Insulate against locale - specific sort order <nl> LC_ALL = C <nl> mmm a / src / third_party / wiredtiger / dist / s_style <nl> ppp b / src / third_party / wiredtiger / dist / s_style <nl> <nl> <nl> # General style correction and cleanup . <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # Parallelize if possible . <nl> xp = " " <nl> else <nl> <nl> cmp $ t $ f > / dev / null 2 > & 1 | | ( echo " modifying $ f " & & cp $ t $ f ) <nl> fi <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_tags <nl> ppp b / src / third_party / wiredtiger / dist / s_tags <nl> <nl> # ! / bin / sh <nl> <nl> - # Build tags file . <nl> - # <nl> - t = __a . c <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + # Build tags files . <nl> + trap ' rm - f tags ' 0 1 2 3 13 15 <nl> <nl> # Skip this when building release packages <nl> test - n " $ WT_RELEASE_BUILD " & & exit 0 <nl> <nl> + # We have to be in the dist directory to run . <nl> + test - f s_tags | | { <nl> + echo " s_tags requires dist be the current working directory " <nl> + exit 1 <nl> + } <nl> + <nl> # We require ctags which may not be installed . <nl> type ctags > / dev / null 2 > & 1 | | { <nl> - echo ' skipped : ctags not found ' > $ t <nl> + echo ' skipped : ctags not found ' <nl> exit 0 <nl> } <nl> <nl> # Test to see what flags this ctags binary supports . <nl> - # Use the - d , - t and - w flags to ctags if available . <nl> flags = " " <nl> - echo " f ( ) { int a ; } " > $ t <nl> for i in - d - t - w - - language - force = C ; do <nl> - if ctags $ i $ t 2 > / dev / null ; then <nl> + if ctags $ i . . / src / conn / api_strerror . c 2 > / dev / null ; then <nl> flags = " $ i $ flags " <nl> fi <nl> done <nl> <nl> - # Generate a tags file for the build directory <nl> - ( cd . . / build_posix <nl> - rm - f tags <nl> - ctags $ flags . . / src / include / * . in . . / src / * / * . [ chi ] 2 > / dev / null ) <nl> + # Generate a tags file for the standard build directory . <nl> + ( cd . . / build_posix & & <nl> + rm - f tags & & <nl> + ctags $ flags . . / src / include / * . in ` find . . / src - name ' * . [ chi ] ' ` 2 > / dev / null ) <nl> <nl> - # Put the shared tags file in the include directory , it ' s at the same level in <nl> - # the tree as the other source files . <nl> - ( cd . . / src / include <nl> - rm - f tags <nl> - ctags $ flags . . / include / * . in . . / * / * . [ chi ] 2 > / dev / null ) <nl> + # Generate a tags file for the src / include directory . <nl> + ( cd . . / src / include & & <nl> + rm - f tags & & <nl> + ctags $ flags . . / include / * . in ` find . . - name ' * . [ chi ] ' ` 2 > / dev / null ) <nl> <nl> - # Link the tags file into place if we ' re at the right level . <nl> + # Link the tags file into place in the standard source directories , if we ' re <nl> + # at the right level . <nl> link_tag ( ) <nl> { <nl> if test - e . . / include / tags ; then <nl> link_tag ( ) <nl> # Link to the tags file from standard build and source directories . <nl> dirs = " ` python - c ' import dist ; dist . print_source_dirs ( ) ' ` . . / src / os_win " <nl> for i in $ dirs ; do <nl> - if expr " $ i " : " . * / include " > / dev / null ; then <nl> - continue <nl> - fi <nl> + expr " $ i " : " . * / include " > / dev / null & & continue <nl> + <nl> ( cd $ i & & link_tag ) <nl> done <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_typedef <nl> ppp b / src / third_party / wiredtiger / dist / s_typedef <nl> <nl> # ! / bin / sh <nl> <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # Insulate against locale - specific sort order and IFS from the user ' s env <nl> LC_ALL = C <nl> mmm a / src / third_party / wiredtiger / dist / s_void <nl> ppp b / src / third_party / wiredtiger / dist / s_void <nl> <nl> # ! / bin / sh <nl> <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> cd . . <nl> <nl> for f in ` find bench ext src test - name ' * . [ ci ] ' ` ; do <nl> cat $ t <nl> } <nl> done <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_whitespace <nl> ppp b / src / third_party / wiredtiger / dist / s_whitespace <nl> <nl> <nl> # Single space and remove trailing whitespace from source files . <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # Clear lines that only contain whitespace , compress multiple empty lines <nl> # into a single line , discard trailing empty lines . <nl> find bench dist examples ext src test \ <nl> | while read f ; do <nl> whitespace $ f <nl> done <nl> + <nl> + exit 0 <nl> mmm a / src / third_party / wiredtiger / dist / s_wtstats <nl> ppp b / src / third_party / wiredtiger / dist / s_wtstats <nl> <nl> # Create wtstats . template . html file <nl> <nl> t = __wt . $ $ <nl> - trap ' rm - f $ t ; exit 0 ' 0 1 2 3 13 15 <nl> + trap ' rm - f $ t ' 0 1 2 3 13 15 <nl> <nl> # We require npm which may not be installed . <nl> type npm > / dev / null 2 > & 1 | | { <nl> mmm a / src / third_party / wiredtiger / src / btree / bt_compact . c <nl> ppp b / src / third_party / wiredtiger / src / btree / bt_compact . c <nl> int <nl> __wt_compact_page_skip ( WT_SESSION_IMPL * session , WT_REF * ref , bool * skipp ) <nl> { <nl> WT_BM * bm ; <nl> + WT_DECL_RET ; <nl> size_t addr_size ; <nl> u_int type ; <nl> const uint8_t * addr ; <nl> <nl> - * skipp = false ; / * Default to reading . * / <nl> - type = 0 ; / * Keep compiler quiet . * / <nl> + / * <nl> + * Skip deleted pages , rewriting them doesn ' t seem useful ; in a better <nl> + * world we ' d write the parent to delete the page . <nl> + * / <nl> + if ( ref - > state = = WT_REF_DELETED ) { <nl> + * skipp = true ; <nl> + return ( 0 ) ; <nl> + } <nl> <nl> - bm = S2BT ( session ) - > bm ; <nl> + * skipp = false ; / * Default to reading * / <nl> <nl> / * <nl> - * We aren ' t holding a hazard pointer , so we can ' t look at the page <nl> - * itself , all we can look at is the WT_REF information . If there ' s no <nl> - * address , the page isn ' t on disk , but we have to read internal pages <nl> - * to walk the tree regardless ; throw up our hands and read it . <nl> + * If the page is in - memory , we want to look at it ( it may have been <nl> + * modified and written , and the current location is the interesting <nl> + * one in terms of compaction , not the original location ) . <nl> + * <nl> + * This test could be combined with the next one , but this is a cheap <nl> + * test and the next one is expensive . <nl> * / <nl> - __wt_ref_info ( ref , & addr , & addr_size , & type ) ; <nl> - if ( addr = = NULL ) <nl> + if ( ref - > state ! = WT_REF_DISK ) <nl> + return ( 0 ) ; <nl> + <nl> + / * <nl> + * There ' s nothing to prevent the WT_REF state from changing underfoot , <nl> + * which can change its address . For example , the WT_REF address might <nl> + * reference an on - page cell , and page eviction can free that memory . <nl> + * Lock the WT_REF so we can look at its address . <nl> + * / <nl> + if ( ! __wt_atomic_casv32 ( & ref - > state , WT_REF_DISK , WT_REF_LOCKED ) ) <nl> return ( 0 ) ; <nl> <nl> / * <nl> + * The page is on disk , so there had better be an address ; assert that <nl> + * fact , test at run - time to avoid the core dump . <nl> + * <nl> * Internal pages must be read to walk the tree ; ask the block - manager <nl> * if it ' s useful to rewrite leaf pages , don ' t do the I / O if a rewrite <nl> * won ' t help . <nl> * / <nl> - return ( type = = WT_CELL_ADDR_INT ? 0 : <nl> - bm - > compact_page_skip ( bm , session , addr , addr_size , skipp ) ) ; <nl> + __wt_ref_info ( ref , & addr , & addr_size , & type ) ; <nl> + WT_ASSERT ( session , addr ! = NULL ) ; <nl> + if ( addr ! = NULL & & type ! = WT_CELL_ADDR_INT ) { <nl> + bm = S2BT ( session ) - > bm ; <nl> + ret = bm - > compact_page_skip ( <nl> + bm , session , addr , addr_size , skipp ) ; <nl> + } <nl> + <nl> + / * <nl> + * Reset the WT_REF state and push the change . The full - barrier isn ' t <nl> + * necessary , but it ' s better to keep pages in circulation than not . <nl> + * / <nl> + ref - > state = WT_REF_DISK ; <nl> + WT_FULL_BARRIER ( ) ; <nl> + <nl> + return ( ret ) ; <nl> } <nl> mmm a / src / third_party / wiredtiger / src / btree / bt_walk . c <nl> ppp b / src / third_party / wiredtiger / src / btree / bt_walk . c <nl> __tree_walk_internal ( WT_SESSION_IMPL * session , <nl> empty_internal = false ; <nl> } else if ( LF_ISSET ( WT_READ_COMPACT ) ) { <nl> / * <nl> - * Skip deleted pages , rewriting them doesn ' t <nl> - * seem useful . <nl> + * Compaction has relatively complex tests to <nl> + * decide if a page can be skipped , call out <nl> + * to a helper function . <nl> * / <nl> - if ( ref - > state = = WT_REF_DELETED ) <nl> + WT_ERR ( __wt_compact_page_skip ( <nl> + session , ref , & skip ) ) ; <nl> + if ( skip ) <nl> break ; <nl> - <nl> - / * <nl> - * If the page is in - memory , we want to look at <nl> - * it ( it may have been modified and written , <nl> - * and the current location is the interesting <nl> - * one in terms of compaction , not the original <nl> - * location ) . If the page isn ' t in - memory , test <nl> - * if the page will help with compaction , don ' t <nl> - * read it if we don ' t have to . <nl> - * / <nl> - if ( ref - > state = = WT_REF_DISK ) { <nl> - WT_ERR ( __wt_compact_page_skip ( <nl> - session , ref , & skip ) ) ; <nl> - if ( skip ) <nl> - break ; <nl> - } <nl> } else { <nl> / * <nl> * Try to skip deleted pages visible to us . <nl> mmm a / src / third_party / wiredtiger / src / conn / conn_api . c <nl> ppp b / src / third_party / wiredtiger / src / conn / conn_api . c <nl> __conn_reconfigure ( WT_CONNECTION * wt_conn , const char * config ) <nl> WT_DECL_RET ; <nl> WT_SESSION_IMPL * session ; <nl> const char * p ; <nl> + bool locked ; <nl> <nl> conn = ( WT_CONNECTION_IMPL * ) wt_conn ; <nl> + locked = false ; <nl> <nl> CONNECTION_API_CALL ( conn , session , reconfigure , config , cfg ) ; <nl> <nl> / * Serialize reconfiguration . * / <nl> __wt_spin_lock ( session , & conn - > reconfig_lock ) ; <nl> + locked = true ; <nl> <nl> / * <nl> * The configuration argument has been checked for validity , update the <nl> __conn_reconfigure ( WT_CONNECTION * wt_conn , const char * config ) <nl> __wt_free ( session , conn - > cfg ) ; <nl> conn - > cfg = p ; <nl> <nl> - err : __wt_spin_unlock ( session , & conn - > reconfig_lock ) ; <nl> + err : if ( locked ) <nl> + __wt_spin_unlock ( session , & conn - > reconfig_lock ) ; <nl> <nl> API_END_RET ( session , ret ) ; <nl> } <nl> __conn_open_session ( WT_CONNECTION * wt_conn , <nl> * wt_sessionp = NULL ; <nl> <nl> conn = ( WT_CONNECTION_IMPL * ) wt_conn ; <nl> - session_ret = NULL ; <nl> <nl> CONNECTION_API_CALL ( conn , session , open_session , config , cfg ) ; <nl> WT_UNUSED ( cfg ) ; <nl> <nl> + session_ret = NULL ; <nl> WT_ERR ( __wt_open_session ( <nl> conn , event_handler , config , true , & session_ret ) ) ; <nl> * wt_sessionp = & session_ret - > iface ; <nl> mmm a / src / third_party / wiredtiger / src / evict / evict_lru . c <nl> ppp b / src / third_party / wiredtiger / src / evict / evict_lru . c <nl> __wt_evict_list_clear_page ( WT_SESSION_IMPL * session , WT_REF * ref ) <nl> / * <nl> * __evict_queue_empty - - <nl> * Is the queue empty ? <nl> + * <nl> + * Note that the eviction server is pessimistic and treats a half full <nl> + * queue as empty . <nl> * / <nl> static inline bool <nl> - __evict_queue_empty ( WT_EVICT_QUEUE * queue ) <nl> + __evict_queue_empty ( WT_EVICT_QUEUE * queue , bool server_check ) <nl> { <nl> - return ( queue - > evict_current = = NULL | | <nl> - queue - > evict_candidates = = 0 ) ; <nl> + uint32_t candidates , used ; <nl> + <nl> + if ( queue - > evict_current = = NULL ) <nl> + return ( true ) ; <nl> + <nl> + / * The eviction server only considers half of the candidates . * / <nl> + candidates = queue - > evict_candidates ; <nl> + if ( server_check & & candidates > 1 ) <nl> + candidates / = 2 ; <nl> + used = ( uint32_t ) ( queue - > evict_current - queue - > evict_queue ) ; <nl> + return ( used > = candidates ) ; <nl> } <nl> <nl> / * <nl> __evict_update_work ( WT_SESSION_IMPL * session ) <nl> { <nl> WT_CACHE * cache ; <nl> WT_CONNECTION_IMPL * conn ; <nl> - double dirty_trigger ; <nl> uint64_t bytes_inuse , bytes_max , dirty_inuse ; <nl> <nl> conn = S2C ( session ) ; <nl> __evict_update_work ( WT_SESSION_IMPL * session ) <nl> if ( ! F_ISSET ( conn , WT_CONN_EVICTION_RUN ) ) <nl> return ( false ) ; <nl> <nl> - if ( ! __evict_queue_empty ( cache - > evict_urgent_queue ) ) <nl> + if ( ! __evict_queue_empty ( cache - > evict_urgent_queue , false ) ) <nl> F_SET ( cache , WT_CACHE_EVICT_URGENT ) ; <nl> <nl> / * <nl> __evict_update_work ( WT_SESSION_IMPL * session ) <nl> bytes_inuse = __wt_cache_bytes_inuse ( cache ) ; <nl> if ( bytes_inuse > ( cache - > eviction_target * bytes_max ) / 100 ) <nl> F_SET ( cache , WT_CACHE_EVICT_CLEAN ) ; <nl> - if ( bytes_inuse > ( cache - > eviction_trigger * bytes_max ) / 100 ) <nl> - F_SET ( cache , WT_CACHE_EVICT_CLEAN_HARD ) ; <nl> + if ( __wt_eviction_clean_needed ( session , NULL ) ) <nl> + F_SET ( cache , WT_CACHE_EVICT_CLEAN | WT_CACHE_EVICT_CLEAN_HARD ) ; <nl> <nl> dirty_inuse = __wt_cache_dirty_leaf_inuse ( cache ) ; <nl> if ( dirty_inuse > ( cache - > eviction_dirty_target * bytes_max ) / 100 ) <nl> F_SET ( cache , WT_CACHE_EVICT_DIRTY ) ; <nl> - if ( ( dirty_trigger = cache - > eviction_scrub_limit ) < 1 . 0 ) <nl> - dirty_trigger = ( double ) cache - > eviction_dirty_trigger ; <nl> - if ( dirty_inuse > ( uint64_t ) ( dirty_trigger * bytes_max ) / 100 ) <nl> - F_SET ( cache , WT_CACHE_EVICT_DIRTY_HARD ) ; <nl> + if ( __wt_eviction_dirty_needed ( session , NULL ) ) <nl> + F_SET ( cache , WT_CACHE_EVICT_DIRTY | WT_CACHE_EVICT_DIRTY_HARD ) ; <nl> <nl> / * <nl> * If application threads are blocked by the total volume of data in <nl> __evict_update_work ( WT_SESSION_IMPL * session ) <nl> F_CLR ( cache , WT_CACHE_EVICT_CLEAN | WT_CACHE_EVICT_CLEAN_HARD ) ; <nl> } <nl> <nl> + / * If threads are blocked by eviction we should be looking for pages . * / <nl> + WT_ASSERT ( session , ! F_ISSET ( cache , WT_CACHE_EVICT_CLEAN_HARD ) | | <nl> + F_ISSET ( cache , WT_CACHE_EVICT_CLEAN ) ) ; <nl> + WT_ASSERT ( session , ! F_ISSET ( cache , WT_CACHE_EVICT_DIRTY_HARD ) | | <nl> + F_ISSET ( cache , WT_CACHE_EVICT_DIRTY ) ) ; <nl> + <nl> WT_STAT_CONN_SET ( session , cache_eviction_state , <nl> F_MASK ( cache , WT_CACHE_EVICT_MASK ) ) ; <nl> <nl> __evict_pass ( WT_SESSION_IMPL * session ) <nl> * / <nl> if ( cache - > evict_empty_score < WT_EVICT_SCORE_CUTOFF | | <nl> ( ! WT_EVICT_HAS_WORKERS ( session ) & & <nl> - ! __evict_queue_empty ( cache - > evict_urgent_queue ) ) ) <nl> + ! __evict_queue_empty ( cache - > evict_urgent_queue , false ) ) ) <nl> WT_RET ( __evict_lru_pages ( session , true ) ) ; <nl> <nl> if ( cache - > pass_intr ! = 0 ) <nl> __evict_lru_walk ( WT_SESSION_IMPL * session ) <nl> * If the queue we are filling is empty , pages are being requested <nl> * faster than they are being queued . <nl> * / <nl> - if ( __evict_queue_empty ( queue ) ) { <nl> + if ( __evict_queue_empty ( queue , false ) ) { <nl> if ( F_ISSET ( cache , <nl> WT_CACHE_EVICT_CLEAN_HARD | WT_CACHE_EVICT_DIRTY_HARD ) ) { <nl> cache - > evict_empty_score = WT_MIN ( <nl> __evict_get_ref ( <nl> WT_CACHE * cache ; <nl> WT_DECL_RET ; <nl> WT_EVICT_ENTRY * evict ; <nl> - WT_EVICT_QUEUE * other_queue , * queue , * urgent_queue ; <nl> + WT_EVICT_QUEUE * queue , * other_queue , * urgent_queue ; <nl> uint32_t candidates ; <nl> bool is_app , urgent_ok ; <nl> <nl> __evict_get_ref ( <nl> WT_STAT_CONN_INCR ( session , cache_eviction_get_ref ) ; <nl> <nl> / * Avoid the LRU lock if no pages are available . * / <nl> - if ( __evict_queue_empty ( cache - > evict_current_queue ) & & <nl> - __evict_queue_empty ( cache - > evict_other_queue ) & & <nl> - __evict_queue_empty ( urgent_queue ) ) { <nl> + if ( __evict_queue_empty ( cache - > evict_current_queue , is_server ) & & <nl> + __evict_queue_empty ( cache - > evict_other_queue , is_server ) & & <nl> + ( ! urgent_ok | | __evict_queue_empty ( urgent_queue , false ) ) ) { <nl> WT_STAT_CONN_INCR ( session , cache_eviction_get_ref_empty ) ; <nl> return ( WT_NOTFOUND ) ; <nl> } <nl> __evict_get_ref ( <nl> * Such cases are extremely rare in real applications . <nl> * / <nl> if ( is_server & & <nl> - ( cache - > evict_empty_score > WT_EVICT_SCORE_CUTOFF | | <nl> - __evict_queue_empty ( cache - > evict_fill_queue ) ) ) { <nl> - do { <nl> + ( cache - > evict_empty_score > WT_EVICT_SCORE_CUTOFF | | <nl> + __evict_queue_empty ( cache - > evict_fill_queue , false ) ) ) { <nl> + while ( ( ret = __wt_spin_trylock ( <nl> + session , & cache - > evict_queue_lock ) ) = = EBUSY ) <nl> if ( ( ! urgent_ok | | <nl> - __evict_queue_empty ( urgent_queue ) ) & & <nl> + __evict_queue_empty ( urgent_queue , false ) ) & & <nl> ! __evict_queue_full ( cache - > evict_fill_queue ) ) <nl> return ( WT_NOTFOUND ) ; <nl> - } while ( ( ret = __wt_spin_trylock ( <nl> - session , & cache - > evict_queue_lock ) ) = = EBUSY ) ; <nl> <nl> WT_RET ( ret ) ; <nl> } else <nl> __wt_spin_lock ( session , & cache - > evict_queue_lock ) ; <nl> <nl> - / * <nl> - * Check if the current queue needs to change . <nl> - * The current queue could have changed while we waited for the lock . <nl> - * / <nl> - queue = cache - > evict_current_queue ; <nl> - other_queue = cache - > evict_other_queue ; <nl> - if ( __evict_queue_empty ( queue ) & & ! __evict_queue_empty ( other_queue ) ) { <nl> - cache - > evict_current_queue = other_queue ; <nl> - cache - > evict_other_queue = queue ; <nl> - } <nl> - <nl> / * Check the urgent queue first . * / <nl> - queue = urgent_ok & & ! __evict_queue_empty ( urgent_queue ) ? <nl> - urgent_queue : cache - > evict_current_queue ; <nl> + if ( urgent_ok & & ! __evict_queue_empty ( urgent_queue , false ) ) <nl> + queue = urgent_queue ; <nl> + else { <nl> + / * <nl> + * Check if the current queue needs to change . <nl> + * The current queue could have changed while we waited for <nl> + * the lock . <nl> + * <nl> + * The server will only evict half of the pages before looking <nl> + * for more . The remainder are left to eviction workers ( if any <nl> + * configured ) , or application threads if necessary . <nl> + * / <nl> + queue = cache - > evict_current_queue ; <nl> + other_queue = cache - > evict_other_queue ; <nl> + if ( __evict_queue_empty ( queue , is_server ) & & <nl> + ! __evict_queue_empty ( other_queue , is_server ) ) { <nl> + cache - > evict_current_queue = other_queue ; <nl> + cache - > evict_other_queue = queue ; <nl> + } <nl> + } <nl> <nl> __wt_spin_unlock ( session , & cache - > evict_queue_lock ) ; <nl> <nl> - / * <nl> - * Only evict half of the pages before looking for more . The remainder <nl> - * are left to eviction workers ( if configured ) , or application threads <nl> - * if necessary . <nl> - * / <nl> - candidates = queue - > evict_candidates ; <nl> - if ( is_server & & queue ! = urgent_queue & & candidates > 1 ) <nl> - candidates / = 2 ; <nl> - <nl> / * <nl> * We got the queue lock , which should be fast , and chose a queue . <nl> * Now we want to get the lock on the individual queue . <nl> * / <nl> for ( ; ; ) { <nl> / * Verify there are still pages available . * / <nl> - if ( __evict_queue_empty ( queue ) | | ( uint32_t ) <nl> - ( queue - > evict_current - queue - > evict_queue ) > = candidates ) { <nl> + if ( __evict_queue_empty ( <nl> + queue , is_server & & queue ! = urgent_queue ) ) { <nl> WT_STAT_CONN_INCR ( <nl> session , cache_eviction_get_ref_empty2 ) ; <nl> return ( WT_NOTFOUND ) ; <nl> __evict_get_ref ( <nl> break ; <nl> } <nl> <nl> + / * <nl> + * Only evict half of the pages before looking for more . The remainder <nl> + * are left to eviction workers ( if configured ) , or application thread <nl> + * if necessary . <nl> + * / <nl> + candidates = queue - > evict_candidates ; <nl> + if ( is_server & & queue ! = urgent_queue & & candidates > 1 ) <nl> + candidates / = 2 ; <nl> + <nl> / * Get the next page queued for eviction . * / <nl> for ( evict = queue - > evict_current ; <nl> evict > = queue - > evict_queue & & <nl> __evict_get_ref ( <nl> } <nl> <nl> / * Move to the next item . * / <nl> - if ( evict ! = NULL & & evict + 1 < <nl> - queue - > evict_queue + queue - > evict_candidates ) <nl> + if ( evict ! = NULL & & <nl> + evict + 1 < queue - > evict_queue + queue - > evict_candidates ) <nl> queue - > evict_current = evict + 1 ; <nl> else / * Clear the current pointer if there are no more candidates . * / <nl> queue - > evict_current = NULL ; <nl> __wt_cache_eviction_worker ( WT_SESSION_IMPL * session , bool busy , u_int pct_full ) <nl> / * Wake the eviction server if we need to do work . * / <nl> __wt_evict_server_wake ( session ) ; <nl> <nl> - / * <nl> - * If we ' re busy , either because of the transaction check we just did , <nl> - * or because our caller is waiting on a longer - than - usual event ( such <nl> - * as a page read ) , limit the work to a single eviction and return . If <nl> - * that ' s not the case , we can do more . <nl> - * / <nl> init_evict_count = cache - > pages_evict ; <nl> <nl> for ( ; ; ) { <nl> - / * Check if we have become busy . * / <nl> - if ( ! busy & & txn_state - > snap_min ! = WT_TXN_NONE & & <nl> - txn_global - > current ! = txn_global - > oldest_id ) <nl> - busy = true ; <nl> - <nl> - max_pages_evicted = busy ? 5 : 20 ; <nl> - <nl> / * <nl> * A pathological case : if we ' re the oldest transaction in the <nl> * system and the eviction server is stuck trying to find space , <nl> __wt_cache_eviction_worker ( WT_SESSION_IMPL * session , bool busy , u_int pct_full ) <nl> return ( WT_ROLLBACK ) ; <nl> } <nl> <nl> + / * <nl> + * Check if we have become busy . <nl> + * <nl> + * If we ' re busy ( because of the transaction check we just did <nl> + * or because our caller is waiting on a longer - than - usual event <nl> + * such as a page read ) , and the cache level drops below 100 % , <nl> + * limit the work to 5 evictions and return . If that ' s not the <nl> + * case , we can do more . <nl> + * / <nl> + if ( ! busy & & txn_state - > snap_min ! = WT_TXN_NONE & & <nl> + txn_global - > current ! = txn_global - > oldest_id ) <nl> + busy = true ; <nl> + max_pages_evicted = busy ? 5 : 20 ; <nl> + <nl> / * See if eviction is still needed . * / <nl> if ( ! __wt_eviction_needed ( session , busy , & pct_full ) | | <nl> ( pct_full < 100 & & <nl> __wt_page_evict_urgent ( WT_SESSION_IMPL * session , WT_REF * ref ) <nl> goto done ; <nl> <nl> __wt_spin_lock ( session , & urgent_queue - > evict_lock ) ; <nl> - if ( __evict_queue_empty ( urgent_queue ) ) { <nl> + if ( __evict_queue_empty ( urgent_queue , false ) ) { <nl> urgent_queue - > evict_current = urgent_queue - > evict_queue ; <nl> urgent_queue - > evict_candidates = 0 ; <nl> } <nl> mmm a / src / third_party / wiredtiger / src / include / btree . i <nl> ppp b / src / third_party / wiredtiger / src / include / btree . i <nl> __wt_cache_page_evict ( WT_SESSION_IMPL * session , WT_PAGE * page ) <nl> <nl> / * Update pages and bytes evicted . * / <nl> ( void ) __wt_atomic_add64 ( & cache - > bytes_evict , page - > memory_footprint ) ; <nl> - ( void ) __wt_atomic_add64 ( & cache - > pages_evict , 1 ) ; <nl> + ( void ) __wt_atomic_addv64 ( & cache - > pages_evict , 1 ) ; <nl> } <nl> <nl> / * <nl> mmm a / src / third_party / wiredtiger / src / include / cache . h <nl> ppp b / src / third_party / wiredtiger / src / include / cache . h <nl> struct __wt_cache { <nl> uint64_t bytes_dirty_leaf ; <nl> uint64_t pages_dirty_leaf ; <nl> uint64_t bytes_evict ; / * Bytes / pages discarded by eviction * / <nl> - uint64_t pages_evict ; <nl> + volatile uint64_t pages_evict ; <nl> uint64_t pages_evicted ; / * Pages evicted during a pass * / <nl> uint64_t bytes_image ; / * Bytes of disk images * / <nl> uint64_t bytes_inmem ; / * Bytes / pages in memory * / <nl> struct __wt_cache { <nl> # define WT_CACHE_EVICT_CLEAN_HARD 0x002 / * Clean % blocking app threads * / <nl> # define WT_CACHE_EVICT_DIRTY 0x004 / * Evict dirty pages * / <nl> # define WT_CACHE_EVICT_DIRTY_HARD 0x008 / * Dirty % blocking app threads * / <nl> - # define WT_CACHE_EVICT_SCRUB 0x010 / * Scrub dirty pages pages * / <nl> + # define WT_CACHE_EVICT_SCRUB 0x010 / * Scrub dirty pages * / <nl> # define WT_CACHE_EVICT_URGENT 0x020 / * Pages are in the urgent queue * / <nl> # define WT_CACHE_EVICT_ALL ( WT_CACHE_EVICT_CLEAN | WT_CACHE_EVICT_DIRTY ) <nl> # define WT_CACHE_EVICT_MASK 0x0FF <nl> mmm a / src / third_party / wiredtiger / src / include / cache . i <nl> ppp b / src / third_party / wiredtiger / src / include / cache . i <nl> __wt_cache_bytes_other ( WT_CACHE * cache ) <nl> * __wt_session_can_wait - - <nl> * Return if a session available for a potentially slow operation . <nl> * / <nl> - static inline int <nl> + static inline bool <nl> __wt_session_can_wait ( WT_SESSION_IMPL * session ) <nl> { <nl> / * <nl> __wt_session_can_wait ( WT_SESSION_IMPL * session ) <nl> * the system cache . <nl> * / <nl> if ( ! F_ISSET ( session , WT_SESSION_CAN_WAIT ) ) <nl> - return ( 0 ) ; <nl> + return ( false ) ; <nl> <nl> / * <nl> * LSM sets the no - eviction flag when holding the LSM tree lock , in that <nl> * case , or when holding the schema lock , we don ' t want to highjack the <nl> * thread for eviction . <nl> * / <nl> - if ( F_ISSET ( session , WT_SESSION_NO_EVICTION | WT_SESSION_LOCKED_SCHEMA ) ) <nl> - return ( 0 ) ; <nl> + return ( ! F_ISSET ( <nl> + session , WT_SESSION_NO_EVICTION | WT_SESSION_LOCKED_SCHEMA ) ) ; <nl> + } <nl> + <nl> + / * <nl> + * __wt_eviction_clean_needed - - <nl> + * Return if an application thread should do eviction due to the total <nl> + * volume of dirty data in cache . <nl> + * / <nl> + static inline bool <nl> + __wt_eviction_clean_needed ( WT_SESSION_IMPL * session , u_int * pct_fullp ) <nl> + { <nl> + WT_CACHE * cache ; <nl> + uint64_t bytes_inuse , bytes_max ; <nl> + <nl> + cache = S2C ( session ) - > cache ; <nl> + <nl> + / * <nl> + * Avoid division by zero if the cache size has not yet been set in a <nl> + * shared cache . <nl> + * / <nl> + bytes_max = S2C ( session ) - > cache_size + 1 ; <nl> + bytes_inuse = __wt_cache_bytes_inuse ( cache ) ; <nl> + <nl> + if ( pct_fullp ! = NULL ) <nl> + * pct_fullp = ( u_int ) ( ( 100 * bytes_inuse ) / bytes_max ) ; <nl> + <nl> + return ( bytes_inuse > ( cache - > eviction_trigger * bytes_max ) / 100 ) ; <nl> + } <nl> + <nl> + / * <nl> + * __wt_eviction_dirty_needed - - <nl> + * Return if an application thread should do eviction due to the total <nl> + * volume of dirty data in cache . <nl> + * / <nl> + static inline bool <nl> + __wt_eviction_dirty_needed ( WT_SESSION_IMPL * session , u_int * pct_fullp ) <nl> + { <nl> + WT_CACHE * cache ; <nl> + double dirty_trigger ; <nl> + uint64_t dirty_inuse , bytes_max ; <nl> + <nl> + cache = S2C ( session ) - > cache ; <nl> + <nl> + / * <nl> + * Avoid division by zero if the cache size has not yet been set in a <nl> + * shared cache . <nl> + * / <nl> + bytes_max = S2C ( session ) - > cache_size + 1 ; <nl> + dirty_inuse = __wt_cache_dirty_leaf_inuse ( cache ) ; <nl> + <nl> + if ( pct_fullp ! = NULL ) <nl> + * pct_fullp = ( u_int ) ( ( 100 * dirty_inuse ) / bytes_max ) ; <nl> + <nl> + if ( ( dirty_trigger = cache - > eviction_scrub_limit ) < 1 . 0 ) <nl> + dirty_trigger = ( double ) cache - > eviction_dirty_trigger ; <nl> <nl> - return ( 1 ) ; <nl> + return ( dirty_inuse > ( uint64_t ) ( dirty_trigger * bytes_max ) / 100 ) ; <nl> } <nl> <nl> / * <nl> __wt_session_can_wait ( WT_SESSION_IMPL * session ) <nl> static inline bool <nl> __wt_eviction_needed ( WT_SESSION_IMPL * session , bool busy , u_int * pct_fullp ) <nl> { <nl> - WT_CONNECTION_IMPL * conn ; <nl> WT_CACHE * cache ; <nl> - double dirty_trigger ; <nl> - uint64_t bytes_inuse , bytes_max , dirty_inuse ; <nl> u_int pct_dirty , pct_full ; <nl> + bool clean_needed , dirty_needed ; <nl> <nl> - conn = S2C ( session ) ; <nl> - cache = conn - > cache ; <nl> + cache = S2C ( session ) - > cache ; <nl> <nl> / * <nl> * If the connection is closing we do not need eviction from an <nl> * application thread . The eviction subsystem is already closed . <nl> * / <nl> - if ( F_ISSET ( conn , WT_CONN_CLOSING ) ) <nl> + if ( F_ISSET ( S2C ( session ) , WT_CONN_CLOSING ) ) <nl> return ( false ) ; <nl> <nl> - / * <nl> - * Avoid division by zero if the cache size has not yet been set in a <nl> - * shared cache . <nl> - * / <nl> - bytes_max = conn - > cache_size + 1 ; <nl> - bytes_inuse = __wt_cache_bytes_inuse ( cache ) ; <nl> - dirty_inuse = __wt_cache_dirty_leaf_inuse ( cache ) ; <nl> + clean_needed = __wt_eviction_clean_needed ( session , & pct_full ) ; <nl> + dirty_needed = __wt_eviction_dirty_needed ( session , & pct_dirty ) ; <nl> <nl> / * <nl> * Calculate the cache full percentage ; anything over the trigger means <nl> * we involve the application thread . <nl> * / <nl> - if ( pct_fullp ! = NULL ) { <nl> - pct_full = ( u_int ) ( ( 100 * bytes_inuse ) / bytes_max ) ; <nl> - pct_dirty = ( u_int ) ( ( 100 * dirty_inuse ) / bytes_max ) ; <nl> - <nl> + if ( pct_fullp ! = NULL ) <nl> * pct_fullp = ( u_int ) WT_MAX ( 0 , 100 - WT_MIN ( <nl> ( int ) cache - > eviction_trigger - ( int ) pct_full , <nl> ( int ) cache - > eviction_dirty_trigger - ( int ) pct_dirty ) ) ; <nl> - } <nl> <nl> / * <nl> * Only check the dirty trigger when the session is not busy . <nl> __wt_eviction_needed ( WT_SESSION_IMPL * session , bool busy , u_int * pct_fullp ) <nl> * The next transaction in this session will not be able to start until <nl> * the cache is under the limit . <nl> * / <nl> - if ( ( dirty_trigger = cache - > eviction_scrub_limit ) < 1 . 0 ) <nl> - dirty_trigger = ( double ) cache - > eviction_dirty_trigger ; <nl> - return ( bytes_inuse > ( cache - > eviction_trigger * bytes_max ) / 100 | | <nl> - ( ! busy & & <nl> - dirty_inuse > ( uint64_t ) ( dirty_trigger * bytes_max ) / 100 ) ) ; <nl> + return ( clean_needed | | ( ! busy & & dirty_needed ) ) ; <nl> } <nl> <nl> / * <nl> mmm a / src / third_party / wiredtiger / src / include / thread_group . h <nl> ppp b / src / third_party / wiredtiger / src / include / thread_group . h <nl> struct __wt_thread { <nl> WT_SESSION_IMPL * session ; <nl> u_int id ; <nl> wt_thread_t tid ; <nl> - # define WT_THREAD_RUN 0x01 <nl> + <nl> + / * <nl> + * WT_THREAD and thread - group function flags , merged because <nl> + * WT_THREAD_PANIC_FAIL appears in both groups . <nl> + * / <nl> + # define WT_THREAD_CAN_WAIT 0x01 / * WT_SESSION_CAN_WAIT * / <nl> + # define WT_THREAD_PANIC_FAIL 0x02 / * panic if the thread fails * / <nl> + # define WT_THREAD_RUN 0x04 / * thread is running * / <nl> uint32_t flags ; <nl> <nl> / * The runner function used by all threads . * / <nl> int ( * run_func ) ( WT_SESSION_IMPL * session , WT_THREAD * context ) ; <nl> } ; <nl> <nl> - / * <nl> - * Flags for thread group functions . <nl> - * / <nl> - # define WT_THREAD_CAN_WAIT 0x01 <nl> - # define WT_THREAD_PANIC_FAIL 0x02 <nl> - <nl> / * <nl> * WT_THREAD_GROUP - - <nl> * Encapsulation of a group of utility threads . <nl> mmm a / src / third_party / wiredtiger / src / support / hazard . c <nl> ppp b / src / third_party / wiredtiger / src / support / hazard . c <nl> __wt_hazard_clear ( WT_SESSION_IMPL * session , WT_PAGE * page ) <nl> <nl> / * <nl> * If this was the last hazard pointer in the session , <nl> - * we may need to update our transactional context . <nl> + * reset the size so that checks can skip this session . <nl> * / <nl> - - - session - > nhazard ; <nl> + if ( - - session - > nhazard = = 0 ) <nl> + WT_PUBLISH ( session - > hazard_size , 0 ) ; <nl> return ( 0 ) ; <nl> } <nl> <nl> mmm a / src / third_party / wiredtiger / src / txn / txn_ckpt . c <nl> ppp b / src / third_party / wiredtiger / src / txn / txn_ckpt . c <nl> __checkpoint_reduce_dirty_cache ( WT_SESSION_IMPL * session ) <nl> * level . <nl> * / <nl> __wt_sleep ( 0 , 10 * stepdown_us ) ; <nl> - cache - > eviction_scrub_limit = current_dirty - delta ; <nl> + cache - > eviction_scrub_limit = <nl> + WT_MAX ( cache - > eviction_dirty_target , current_dirty - delta ) ; <nl> WT_STAT_CONN_SET ( session , txn_checkpoint_scrub_target , <nl> cache - > eviction_scrub_limit ) ; <nl> WT_RET ( __wt_epoch ( session , & last ) ) ; <nl> mmm a / src / third_party / wiredtiger / test / csuite / wt2719_reconfig / main . c <nl> ppp b / src / third_party / wiredtiger / test / csuite / wt2719_reconfig / main . c <nl> <nl> * / <nl> # include " test_util . h " <nl> <nl> + # include < signal . h > <nl> + <nl> / * <nl> * JIRA ticket reference : WT - 2719 <nl> * Test case description : Fuzz testing for WiredTiger reconfiguration . <nl> handle_message ( WT_EVENT_HANDLER * handler , <nl> <nl> static WT_EVENT_HANDLER event_handler = { NULL , handle_message , NULL , NULL } ; <nl> <nl> + static const char * current ; / * Current test configuration * / <nl> + <nl> + static void on_alarm ( int ) WT_GCC_FUNC_DECL_ATTRIBUTE ( ( noreturn ) ) ; <nl> + static void <nl> + on_alarm ( int signo ) <nl> + { <nl> + ( void ) signo ; / * Unused parameter * / <nl> + <nl> + fprintf ( stderr , " configuration timed out : % s \ n " , current ) ; <nl> + abort ( ) ; <nl> + <nl> + / * NOTREACHED * / <nl> + } <nl> + <nl> + static void <nl> + reconfig ( TEST_OPTS * opts , WT_SESSION * session , const char * config ) <nl> + { <nl> + int ret ; <nl> + <nl> + current = config ; <nl> + <nl> + / * <nl> + * Reconfiguration starts and stops servers , so hangs are more likely <nl> + * here than in other tests . Don ' t let the test run too long and get <nl> + * a core dump when it happens . <nl> + * / <nl> + ( void ) alarm ( 60 ) ; <nl> + if ( ( ret = opts - > conn - > reconfigure ( opts - > conn , config ) ) ! = 0 ) { <nl> + fprintf ( stderr , " % s : % s \ n " , <nl> + config , session - > strerror ( session , ret ) ) ; <nl> + exit ( EXIT_FAILURE ) ; <nl> + } <nl> + ( void ) alarm ( 0 ) ; <nl> + } <nl> + <nl> int <nl> main ( int argc , char * argv [ ] ) <nl> { <nl> main ( int argc , char * argv [ ] ) <nl> WT_SESSION * session ; <nl> size_t len ; <nl> u_int i , j ; <nl> - int ret ; <nl> const char * p ; <nl> char * config ; <nl> <nl> main ( int argc , char * argv [ ] ) <nl> len = WT_ELEMENTS ( list ) * 64 ; <nl> config = dmalloc ( len ) ; <nl> <nl> + / * Set an alarm so we can debug hangs . * / <nl> + ( void ) signal ( SIGALRM , on_alarm ) ; <nl> + <nl> / * A linear pass through the list . * / <nl> for ( i = 0 ; i < WT_ELEMENTS ( list ) ; + + i ) <nl> - if ( ( ret = opts - > conn - > reconfigure ( opts - > conn , list [ i ] ) ) ! = 0 ) { <nl> - fprintf ( stderr , " % s : % s \ n " , <nl> - list [ i ] , session - > strerror ( session , ret ) ) ; <nl> - return ( EXIT_FAILURE ) ; <nl> - } <nl> + reconfig ( opts , session , list [ i ] ) ; <nl> <nl> / * <nl> * A linear pass through the list , adding random elements . <nl> main ( int argc , char * argv [ ] ) <nl> } <nl> strcat ( config , p ) ; <nl> } <nl> - if ( ( ret = opts - > conn - > reconfigure ( opts - > conn , config ) ) ! = 0 ) { <nl> - fprintf ( stderr , " % s : % s \ n " , <nl> - config , session - > strerror ( session , ret ) ) ; <nl> - return ( EXIT_FAILURE ) ; <nl> - } <nl> + reconfig ( opts , session , config ) ; <nl> } <nl> <nl> / * <nl> mmm a / src / third_party / wiredtiger / test / suite / test_compact01 . py <nl> ppp b / src / third_party / wiredtiger / test / suite / test_compact01 . py <nl> class test_compact ( wttest . WiredTigerTestCase , suite_subprocess ) : <nl> ( ' utility ' , dict ( utility = 1 , reopen = 0 ) ) , <nl> ] <nl> scenarios = make_scenarios ( types , compact ) <nl> - # We want a large cache so that eviction doesn ' t happen <nl> - # ( which could skew our compaction results ) . <nl> - conn_config = ' cache_size = 250MB , statistics = ( all ) ' <nl> + <nl> + # Configure the connection so that eviction doesn ' t happen ( which could <nl> + # skew our compaction results ) . <nl> + conn_config = ' cache_size = 1GB , eviction_checkpoint_target = 80 , ' + \ <nl> + ' eviction_dirty_target = 80 , eviction_dirty_trigger = 95 , statistics = ( all ) ' <nl> <nl> # Test compaction . <nl> def test_compact ( self ) : <nl>
Import wiredtiger : fc0e7abe82595e579573d42448632f7b36a2d154 from branch mongodb - 3 . 4
mongodb/mongo
9dda827a3ae58beef36d53da1b55554cbd8744c4
2016-09-26T12:11:23Z
mmm a / include / api . h <nl> ppp b / include / api . h <nl> static inline int swoole_event_init ( ) <nl> { <nl> swoole_init ( ) ; <nl> SwooleG . main_reactor = ( swReactor * ) sw_malloc ( sizeof ( swReactor ) ) ; <nl> + if ( ! SwooleG . main_reactor ) <nl> + { <nl> + return SW_ERR ; <nl> + } <nl> return swReactor_create ( SwooleG . main_reactor , SW_REACTOR_MAXEVENTS ) ; <nl> } <nl> <nl> mmm a / include / swoole . h <nl> ppp b / include / swoole . h <nl> size_t sw_vsnprintf ( char * buf , size_t size , const char * format , va_list args ) ; <nl> static sw_inline char * swoole_strdup ( const char * s ) <nl> { <nl> size_t l = strlen ( s ) + 1 ; <nl> - char * p = ( char * ) sw_malloc ( l ) ; <nl> + char * p = ( char * ) sw_malloc ( l ) ; <nl> + if ( ! p ) <nl> + { <nl> + return NULL ; <nl> + } <nl> memcpy ( p , s , l ) ; <nl> return p ; <nl> } <nl> <nl> static sw_inline char * swoole_strndup ( const char * s , size_t n ) <nl> { <nl> - char * p = ( char * ) sw_malloc ( n + 1 ) ; <nl> + char * p = ( char * ) sw_malloc ( n + 1 ) ; <nl> + if ( ! p ) <nl> + { <nl> + return NULL ; <nl> + } <nl> strncpy ( p , s , n ) ; <nl> p [ n ] = ' \ 0 ' ; <nl> return p ; <nl> mmm a / src / core / base . c <nl> ppp b / src / core / base . c <nl> int swoole_gethostbyname ( int flags , char * name , char * addr ) <nl> struct hostent * result ; <nl> <nl> char * buf = ( char * ) sw_malloc ( buf_len ) ; <nl> + if ( ! buf ) <nl> + { <nl> + return SW_ERR ; <nl> + } <nl> memset ( buf , 0 , buf_len ) ; <nl> while ( ( rc = gethostbyname2_r ( name , __af , & hbuf , buf , buf_len , & result , & err ) ) = = ERANGE ) <nl> { <nl> int swoole_shell_exec ( const char * command , pid_t * pid , uint8_t get_error_stream ) <nl> char * swoole_string_format ( size_t n , const char * format , . . . ) <nl> { <nl> char * buf = sw_malloc ( n ) ; <nl> - if ( buf ) <nl> - { <nl> - int ret ; <nl> - va_list va_list ; <nl> - va_start ( va_list , format ) ; <nl> - ret = vsnprintf ( buf , n , format , va_list ) ; <nl> - va_end ( va_list ) ; <nl> - if ( ret > = 0 ) <nl> - { <nl> - return buf ; <nl> - } <nl> - sw_free ( buf ) ; <nl> + if ( ! buf ) <nl> + { <nl> + return NULL ; <nl> + } <nl> + <nl> + int ret ; <nl> + va_list va_list ; <nl> + va_start ( va_list , format ) ; <nl> + ret = vsnprintf ( buf , n , format , va_list ) ; <nl> + va_end ( va_list ) ; <nl> + if ( ret > = 0 ) <nl> + { <nl> + return buf ; <nl> } <nl> + sw_free ( buf ) ; <nl> return NULL ; <nl> } <nl> <nl> mmm a / src / coroutine / context . cc <nl> ppp b / src / coroutine / context . cc <nl> Context : : Context ( size_t stack_size , coroutine_func_t fn , void * private_data ) : <nl> swap_ctx_ = nullptr ; <nl> <nl> stack_ = ( char * ) sw_malloc ( stack_size_ ) ; <nl> + if ( ! stack_ ) <nl> + { <nl> + swFatalError ( SW_ERROR_MALLOC_FAIL , " failed to malloc stack memory . " ) ; <nl> + exit ( 254 ) ; <nl> + } <nl> swTraceLog ( SW_TRACE_COROUTINE , " alloc stack : size = % u , ptr = % p " , stack_size_ , stack_ ) ; <nl> <nl> void * sp = ( void * ) ( ( char * ) stack_ + stack_size_ ) ; <nl> mmm a / src / coroutine / hook . cc <nl> ppp b / src / coroutine / hook . cc <nl> swString * Coroutine : : read_file ( const char * file , int lock ) <nl> if ( ev . error = = 0 ) <nl> { <nl> swString * str = ( swString * ) sw_malloc ( sizeof ( swString ) ) ; <nl> + if ( ! str ) <nl> + { <nl> + return NULL ; <nl> + } <nl> str - > str = ( char * ) ev . buf ; <nl> str - > length = ev . nbytes ; <nl> return str ; <nl> mmm a / src / memory / fixed_pool . c <nl> ppp b / src / memory / fixed_pool . c <nl> swMemoryPool * swFixedPool_new ( uint32_t slice_num , uint32_t slice_size , uint8_t s <nl> size_t size = slice_size * slice_num + slice_num * sizeof ( swFixedPool_slice ) ; <nl> size_t alloc_size = size + sizeof ( swFixedPool ) + sizeof ( swMemoryPool ) ; <nl> void * memory = ( shared = = 1 ) ? sw_shm_malloc ( alloc_size ) : sw_malloc ( alloc_size ) ; <nl> + if ( ! memory ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed " , size ) ; <nl> + return NULL ; <nl> + } <nl> <nl> swFixedPool * object = memory ; <nl> memory = ( char * ) memory + sizeof ( swFixedPool ) ; <nl> mmm a / src / network / stream . c <nl> ppp b / src / network / stream . c <nl> static void swStream_free ( swStream * stream ) <nl> swStream * swStream_new ( char * dst_host , int dst_port , int type ) <nl> { <nl> swStream * stream = ( swStream * ) sw_malloc ( sizeof ( swStream ) ) ; <nl> + if ( ! stream ) <nl> + { <nl> + return NULL ; <nl> + } <nl> bzero ( stream , sizeof ( swStream ) ) ; <nl> <nl> swClient * cli = & stream - > client ; <nl> mmm a / src / protocol / redis . c <nl> ppp b / src / protocol / redis . c <nl> int swRedis_recv ( swProtocol * protocol , swConnection * conn , swString * buffer ) <nl> if ( conn - > object = = NULL ) <nl> { <nl> request = sw_malloc ( sizeof ( swRedis_request ) ) ; <nl> + if ( ! request ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed " , sizeof ( swRedis_request ) ) ; <nl> + return SW_ERR ; <nl> + } <nl> bzero ( request , sizeof ( swRedis_request ) ) ; <nl> conn - > object = request ; <nl> } <nl> mmm a / src / server / manager . cc <nl> ppp b / src / server / manager . cc <nl> static void swManager_add_timeout_killer ( swServer * serv , swWorker * workers , int <nl> * separate old workers , free memory in the timer <nl> * / <nl> swWorker * reload_workers = ( swWorker * ) sw_malloc ( sizeof ( swWorker ) * n ) ; <nl> + if ( ! reload_workers ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed " , sizeof ( swWorker ) * n ) ; <nl> + return ; <nl> + } <nl> swReloadWorker * reload_info = ( swReloadWorker * ) sw_malloc ( sizeof ( swReloadWorker ) ) ; <nl> + if ( ! reload_info ) <nl> + { <nl> + sw_free ( reload_workers ) ; <nl> + swWarn ( " malloc ( % ld ) failed " , sizeof ( swReloadWorker ) ) ; <nl> + return ; <nl> + } <nl> memcpy ( reload_workers , workers , sizeof ( swWorker ) * n ) ; <nl> reload_info - > reload_worker_num = n ; <nl> reload_info - > workers = reload_workers ; <nl> mmm a / src / server / port . c <nl> ppp b / src / server / port . c <nl> static int swPort_onRead_http ( swReactor * reactor , swListenPort * port , swEvent * e <nl> if ( conn - > object = = NULL ) <nl> { <nl> request = sw_malloc ( sizeof ( swHttpRequest ) ) ; <nl> + if ( ! request ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed " , sizeof ( swHttpRequest ) ) ; <nl> + return SW_ERR ; <nl> + } <nl> bzero ( request , sizeof ( swHttpRequest ) ) ; <nl> conn - > object = request ; <nl> } <nl> mmm a / src / server / reactor_process . cc <nl> ppp b / src / server / reactor_process . cc <nl> static int swReactorProcess_loop ( swProcessPool * pool , swWorker * worker ) <nl> if ( ! SwooleG . main_reactor ) <nl> { <nl> reactor = ( swReactor * ) sw_malloc ( sizeof ( swReactor ) ) ; <nl> + if ( ! reactor ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed " , sizeof ( swReactor ) ) ; <nl> + return SW_ERR ; <nl> + } <nl> if ( swReactor_create ( reactor , SW_REACTOR_MAXEVENTS ) < 0 ) <nl> { <nl> swReactor_free_output_buffer ( n_buffer ) ; <nl> mmm a / src / server / reactor_thread . c <nl> ppp b / src / server / reactor_thread . c <nl> int swReactorThread_start ( swServer * serv ) <nl> { <nl> int ret ; <nl> swReactor * main_reactor = sw_malloc ( sizeof ( swReactor ) ) ; <nl> + if ( ! main_reactor ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed " , sizeof ( swReactor ) ) ; <nl> + return SW_ERR ; <nl> + } <nl> <nl> ret = swReactor_create ( main_reactor , SW_REACTOR_MAXEVENTS ) ; <nl> if ( ret < 0 ) <nl> { <nl> + sw_free ( main_reactor ) ; <nl> swWarn ( " Reactor create failed " ) ; <nl> return SW_ERR ; <nl> } <nl> mmm a / swoole_server . cc <nl> ppp b / swoole_server . cc <nl> static PHP_METHOD ( swoole_server , __construct ) <nl> } <nl> <nl> swServer * serv = ( swServer * ) sw_malloc ( sizeof ( swServer ) ) ; <nl> + if ( ! serv ) <nl> + { <nl> + swoole_php_fatal_error ( E_ERROR , " malloc ( % ld ) failed " , sizeof ( swServer ) ) ; <nl> + RETURN_FALSE ; <nl> + } <nl> + <nl> swServer_init ( serv ) ; <nl> <nl> if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " s | lll " , & serv_host , & host_len , & serv_port , & serv_mode , & sock_type ) = = FAILURE ) <nl> static PHP_METHOD ( swoole_server , set ) <nl> sw_free ( SwooleG . task_tmpdir ) ; <nl> } <nl> SwooleG . task_tmpdir = ( char * ) sw_malloc ( str_v . len ( ) + sizeof ( SW_TASK_TMP_FILE ) + 1 ) ; <nl> + if ( ! SwooleG . task_tmpdir ) <nl> + { <nl> + swoole_php_fatal_error ( E_ERROR , " malloc ( ) failed " ) ; <nl> + RETURN_FALSE ; <nl> + } <nl> SwooleG . task_tmpdir_len = sw_snprintf ( SwooleG . task_tmpdir , SW_TASK_TMPDIR_SIZE , " % s / swoole . task . XXXXXX " , str_v . val ( ) ) + 1 ; <nl> } <nl> / / task_max_request <nl> static PHP_METHOD ( swoole_server , set ) <nl> } <nl> int available_num = SW_CPU_NUM - ignore_num ; <nl> int * available_cpu = ( int * ) sw_malloc ( sizeof ( int ) * available_num ) ; <nl> + if ( ! available_cpu ) <nl> + { <nl> + swoole_php_fatal_error ( E_WARNING , " malloc ( ) failed " ) ; <nl> + RETURN_FALSE ; <nl> + } <nl> int flag , i , available_i = 0 ; <nl> <nl> zval * zval_core = NULL ; <nl> static PHP_METHOD ( swoole_server , set ) <nl> sw_free ( serv - > document_root ) ; <nl> } <nl> serv - > document_root = ( char * ) sw_malloc ( PATH_MAX ) ; <nl> + if ( ! serv - > document_root ) <nl> + { <nl> + swoole_php_fatal_error ( E_ERROR , " malloc ( ) failed " ) ; <nl> + RETURN_FALSE ; <nl> + } <nl> if ( ! realpath ( str_v . val ( ) , serv - > document_root ) ) <nl> { <nl> swoole_php_fatal_error ( E_ERROR , " document_root [ % s ] does not exist " , serv - > document_root ) ; <nl>
check malloc return value
swoole/swoole-src
b19bebac7b36567789559e7a0793bb18d7266e41
2019-05-06T03:35:31Z
mmm a / tensorflow / python / distribute / cross_device_ops . py <nl> ppp b / tensorflow / python / distribute / cross_device_ops . py <nl> class CollectiveAllReduce ( CrossDeviceOps ) : <nl> all workers and then put results on the right destinations . <nl> " " " <nl> <nl> - # Whether to only use NCCL for batched all - reduce when NCCL is requested . This <nl> - # is because of the lack of mechanism to order NCCL operations <nl> - # deterministically . <nl> - _limited_nccl = True <nl> - <nl> def __init__ ( self , devices , group_size , collective_keys = None ) : <nl> " " " Initializes the object . <nl> <nl> def __init__ ( self , devices , group_size , collective_keys = None ) : <nl> # function building , the executors are not used . <nl> self . _executors = [ ] <nl> self . _launchers = [ ] <nl> + # Whether to only use NCCL for batched all - reduce when NCCL is requested . <nl> + # This is because of the lack of mechanism to order NCCL operations <nl> + # deterministically . <nl> + self . _limited_nccl = False <nl> for device in self . _devices : <nl> executor = executor_lib . new_executor ( enable_async = True ) <nl> self . _executors . append ( executor ) <nl> launcher = cross_device_utils . CollectiveReplicaLauncher ( <nl> group_key , group_size , self . _collective_keys , device , executor ) <nl> self . _launchers . append ( launcher ) <nl> + if not launcher . can_order_nccl ( ) : <nl> + self . _limited_nccl = True <nl> <nl> super ( CollectiveAllReduce , self ) . __init__ ( ) <nl> <nl> mmm a / tensorflow / python / distribute / cross_device_ops_test . py <nl> ppp b / tensorflow / python / distribute / cross_device_ops_test . py <nl> def enable_collective_ops ( ) : <nl> protocol = cluster_resolver . rpc_layer ) <nl> context . context ( ) . enable_collective_ops ( server_def ) <nl> # Recover default flag values . <nl> - cross_device_ops_lib . CollectiveAllReduce . _limited_nccl = True <nl> cross_device_utils . CollectiveReplicaLauncher . _prefer_scoped_allocator = True <nl> cross_device_utils . CollectiveReplicaLauncher . _prefer_collective_v2 = True <nl> cross_device_utils . CollectiveReplicaLauncher . _prefer_ordering_token = False <nl> def batch_reduce_sparse ( ) : <nl> def testNcclOrdering ( self , num_processes , required_gpus ) : <nl> <nl> def replica_fn ( ) : <nl> - cross_device_ops_lib . CollectiveAllReduce . _limited_nccl = False <nl> cross_device_utils . CollectiveReplicaLauncher . _prefer_collective_v2 = True <nl> cross_device_utils . CollectiveReplicaLauncher . _prefer_ordering_token = True <nl> collective , devices , _ = self . make_collective ( num_processes , <nl> mmm a / tensorflow / python / distribute / cross_device_utils . py <nl> ppp b / tensorflow / python / distribute / cross_device_utils . py <nl> def _get_ordering_token ( self , communication_hint ) : <nl> return self . _ordering_token . handle <nl> return None <nl> <nl> + def can_order_nccl ( self ) : <nl> + " " " Whether this launcher can order NCCL operations . " " " <nl> + return self . _use_ordering_token ( ) <nl> + <nl> def all_reduce ( self , <nl> input_tensor , <nl> control_input = None , <nl>
Condition whether to use NCCL for all collectives on the launcher
tensorflow/tensorflow
d938e55c0297cf3084aaffdcdb013032cd7b02e1
2020-11-24T01:31:58Z
mmm a / ISSUE_TEMPLATE . md <nl> ppp b / ISSUE_TEMPLATE . md <nl> <nl> - # # # Prerequisites <nl> - <nl> - * [ ] Did you [ perform a cursory search ] ( https : / / github . com / issues ? q = is % 3Aissue + repo % 3Aatom % 2Felectron ) to see if it is already reported ? <nl> - <nl> - # # # Description <nl> - <nl> - Electron version : <nl> - <nl> - Operating system : <nl> - <nl> - [ Description of the bug or feature , for example , what you were doing when the issue arose and what you expected to happen ] <nl> + * Electron version : <nl> + * Operating system : <nl>
Remove all but prompts for version numbers
electron/electron
cc6ba0fd10e852d17fb46fbf37ad2f62c1238935
2016-02-18T16:57:31Z
mmm a / src / clustering / immediate_consistency / branch / broadcaster . hpp <nl> ppp b / src / clustering / immediate_consistency / branch / broadcaster . hpp <nl> class broadcaster_t : public home_thread_mixin_t { <nl> class incomplete_write_ref_t { <nl> public : <nl> incomplete_write_ref_t ( ) { } <nl> - incomplete_write_ref_t ( const boost : : shared_ptr < incomplete_write_t > & w ) : write ( w ) { <nl> + explicit incomplete_write_ref_t ( const boost : : shared_ptr < incomplete_write_t > & w ) : write ( w ) { <nl> rassert ( w ) ; <nl> w - > incomplete_count + + ; <nl> } <nl> - incomplete_write_ref_t ( const incomplete_write_ref_t & r ) : write ( r . write ) { <nl> + explicit incomplete_write_ref_t ( const incomplete_write_ref_t & r ) : write ( r . write ) { <nl> if ( r . write ) { <nl> r . write - > incomplete_count + + ; <nl> } <nl> mmm a / src / rpc / connectivity / connectivity . hpp <nl> ppp b / src / rpc / connectivity / connectivity . hpp <nl> struct peer_id_t { <nl> friend std : : ostream & operator < < ( std : : ostream & , peer_id_t ) ; <nl> <nl> boost : : uuids : : uuid uuid ; <nl> - peer_id_t ( boost : : uuids : : uuid u ) : uuid ( u ) { } <nl> + explicit peer_id_t ( boost : : uuids : : uuid u ) : uuid ( u ) { } <nl> <nl> friend class boost : : serialization : : access ; <nl> template < class Archive > void serialize ( Archive & ar , UNUSED const unsigned int version ) { <nl> specific peer connecting or disconnecting . * / <nl> struct connectivity_cluster_t ; <nl> <nl> struct event_watcher_t : public intrusive_list_node_t < event_watcher_t > { <nl> - event_watcher_t ( connectivity_cluster_t * ) ; <nl> + explicit event_watcher_t ( connectivity_cluster_t * ) ; <nl> virtual ~ event_watcher_t ( ) ; <nl> virtual void on_connect ( peer_id_t ) = 0 ; <nl> virtual void on_disconnect ( peer_id_t ) = 0 ; <nl> struct connectivity_cluster_t : <nl> protected : <nl> / * Creating a new cluster node , and connecting one cluster to another <nl> cluster * / <nl> - connectivity_cluster_t ( int port ) ; <nl> + explicit connectivity_cluster_t ( int port ) ; <nl> virtual ~ connectivity_cluster_t ( ) ; <nl> <nl> / * TODO : We should have a better mechanism for sending messages to ourself . <nl> mmm a / src / rpc / mailbox / mailbox . hpp <nl> ppp b / src / rpc / mailbox / mailbox . hpp <nl> message routing infrastructure . * / <nl> struct mailbox_cluster_t : public connectivity_cluster_t { <nl> <nl> public : <nl> - mailbox_cluster_t ( int port ) ; <nl> + explicit mailbox_cluster_t ( int port ) ; <nl> ~ mailbox_cluster_t ( ) ; <nl> <nl> protected : <nl> mmm a / src / rpc / metadata / metadata . hpp <nl> ppp b / src / rpc / metadata / metadata . hpp <nl> class metadata_cluster_t : <nl> ` metadata_readwrite_view_t ` for us . * / <nl> class root_view_t : public metadata_readwrite_view_t < metadata_t > { <nl> public : <nl> - root_view_t ( metadata_cluster_t * ) ; <nl> + explicit root_view_t ( metadata_cluster_t * ) ; <nl> metadata_cluster_t * parent ; <nl> metadata_t get ( ) ; <nl> void join ( const metadata_t & ) ; <nl> mmm a / src / unittest / clustering_backfill . cc <nl> ppp b / src / unittest / clustering_backfill . cc <nl> void run_backfill_test ( ) { <nl> <nl> class simple_mailbox_cluster_t : public mailbox_cluster_t { <nl> public : <nl> - simple_mailbox_cluster_t ( int port ) : mailbox_cluster_t ( port ) { } <nl> + explicit simple_mailbox_cluster_t ( int port ) : mailbox_cluster_t ( port ) { } <nl> private : <nl> void on_utility_message ( peer_id_t , std : : istream & , boost : : function < void ( ) > & ) { <nl> ADD_FAILURE ( ) < < " no utility messages should be sent . WTF ? " ; <nl> mmm a / src / unittest / dummy_metadata_controller . hpp <nl> ppp b / src / unittest / dummy_metadata_controller . hpp <nl> template < class metadata_t > <nl> class dummy_metadata_controller_t { <nl> <nl> public : <nl> - dummy_metadata_controller_t ( const metadata_t & m ) : <nl> + explicit dummy_metadata_controller_t ( const metadata_t & m ) : <nl> view ( boost : : make_shared < view_t > ( this ) ) , <nl> metadata ( m ) , <nl> change_publisher ( & change_lock ) { } <nl> class dummy_metadata_controller_t { <nl> private : <nl> class view_t : public metadata_readwrite_view_t < metadata_t > { <nl> public : <nl> - view_t ( dummy_metadata_controller_t * c ) : controller ( c ) { } <nl> + explicit view_t ( dummy_metadata_controller_t * c ) : controller ( c ) { } <nl> metadata_t get ( ) { <nl> rassert ( controller , " accessing a ` dummy_metadata_controller_t ` ' s " <nl> " view after the controller was destroyed . " ) ; <nl> class dummy_metadata_controller_t { <nl> publisher_controller_t < boost : : function < void ( ) > > change_publisher ; <nl> } ; <nl> <nl> - # endif / * __UNITTEST_DUMMY_METADATA_CONTROLLER_HPP__ * / <nl> \ No newline at end of file <nl> + # endif / * __UNITTEST_DUMMY_METADATA_CONTROLLER_HPP__ * / <nl> mmm a / src / unittest / rpc_connectivity . cc <nl> ppp b / src / unittest / rpc_connectivity . cc <nl> struct recording_connectivity_cluster_t : public connectivity_cluster_t { <nl> stream < < i ; <nl> } <nl> public : <nl> - recording_connectivity_cluster_t ( int i ) : connectivity_cluster_t ( i ) , sequence_number ( 0 ) { } <nl> + explicit recording_connectivity_cluster_t ( int i ) : connectivity_cluster_t ( i ) , sequence_number ( 0 ) { } <nl> void send ( int message , peer_id_t peer ) { <nl> send_message ( peer , boost : : bind ( & write , message , _1 ) ) ; <nl> } <nl> void run_event_watcher_ordering_test ( ) { <nl> <nl> struct watcher_t : public event_watcher_t { <nl> <nl> - watcher_t ( recording_connectivity_cluster_t * c ) : <nl> + explicit watcher_t ( recording_connectivity_cluster_t * c ) : <nl> event_watcher_t ( c ) , cluster ( c ) { } <nl> recording_connectivity_cluster_t * cluster ; <nl> <nl> TEST ( RPCConnectivityTest , BlobJoin ) { <nl> void run_binary_data_test ( ) { <nl> <nl> struct binary_cluster_t : public connectivity_cluster_t { <nl> - binary_cluster_t ( int port ) : connectivity_cluster_t ( port ) , got_spectrum ( false ) { } <nl> + explicit binary_cluster_t ( int port ) : connectivity_cluster_t ( port ) , got_spectrum ( false ) { } <nl> bool got_spectrum ; <nl> static void dump_spectrum ( std : : ostream & stream ) { <nl> char spectrum [ CHAR_MAX - CHAR_MIN + 1 ] ; <nl> mmm a / src / unittest / rpc_mailbox . cc <nl> ppp b / src / unittest / rpc_mailbox . cc <nl> struct recording_mailbox_cluster_t : public mailbox_cluster_t { <nl> inbox [ i ] = peer ; <nl> } <nl> public : <nl> - recording_mailbox_cluster_t ( int i ) : mailbox_cluster_t ( i ) { } <nl> + explicit recording_mailbox_cluster_t ( int i ) : mailbox_cluster_t ( i ) { } <nl> void send ( int message , peer_id_t peer ) { <nl> send_utility_message ( peer , boost : : bind ( & write_integer , message , _1 ) ) ; <nl> } <nl> struct dummy_mailbox_t { <nl> inbox . insert ( i ) ; <nl> } <nl> public : <nl> - dummy_mailbox_t ( mailbox_cluster_t * c ) : <nl> + explicit dummy_mailbox_t ( mailbox_cluster_t * c ) : <nl> mailbox ( c , boost : : bind ( & dummy_mailbox_t : : on_message , this , _1 , _2 ) ) <nl> { } <nl> void expect ( int message ) { <nl>
Marked some clustering single - argument constructors explicit .
rethinkdb/rethinkdb
04112bc5980c3462908763ac77f5078261afea0b
2011-11-01T22:14:59Z
mmm a / atom . gyp <nl> ppp b / atom . gyp <nl> <nl> # Defined in Chromium but not exposed in its gyp file . <nl> ' V8_USE_EXTERNAL_STARTUP_DATA ' , <nl> ' ENABLE_PLUGINS ' , <nl> - # Needed by Node . <nl> - ' NODE_WANT_INTERNALS = 1 ' , <nl> ] , <nl> ' sources ' : [ <nl> ' < @ ( lib_sources ) ' , <nl> mmm a / atom / common / native_mate_converters / v8_value_converter . cc <nl> ppp b / atom / common / native_mate_converters / v8_value_converter . cc <nl> <nl> # include " base / logging . h " <nl> # include " base / memory / scoped_ptr . h " <nl> # include " base / values . h " <nl> + # include " vendor / node / src / node_buffer . h " <nl> <nl> namespace atom { <nl> <nl> base : : Value * V8ValueConverter : : FromV8ValueImpl ( <nl> return FromV8Object ( val - > ToObject ( ) , state , isolate ) ; <nl> } <nl> <nl> + if ( node : : Buffer : : HasInstance ( val ) ) { <nl> + return FromNodeBuffer ( val , state , isolate ) ; <nl> + } <nl> + <nl> if ( val - > IsObject ( ) ) { <nl> return FromV8Object ( val - > ToObject ( ) , state , isolate ) ; <nl> } <nl> base : : Value * V8ValueConverter : : FromV8Array ( <nl> return result ; <nl> } <nl> <nl> + base : : Value * V8ValueConverter : : FromNodeBuffer ( <nl> + v8 : : Local < v8 : : Value > value , <nl> + FromV8ValueState * state , <nl> + v8 : : Isolate * isolate ) const { <nl> + return base : : BinaryValue : : CreateWithCopiedBuffer ( <nl> + node : : Buffer : : Data ( value ) , node : : Buffer : : Length ( value ) ) ; <nl> + } <nl> + <nl> base : : Value * V8ValueConverter : : FromV8Object ( <nl> v8 : : Local < v8 : : Object > val , <nl> FromV8ValueState * state , <nl> mmm a / atom / common / native_mate_converters / v8_value_converter . h <nl> ppp b / atom / common / native_mate_converters / v8_value_converter . h <nl> class V8ValueConverter { <nl> base : : Value * FromV8Array ( v8 : : Local < v8 : : Array > array , <nl> FromV8ValueState * state , <nl> v8 : : Isolate * isolate ) const ; <nl> - <nl> + base : : Value * FromNodeBuffer ( v8 : : Local < v8 : : Value > value , <nl> + FromV8ValueState * state , <nl> + v8 : : Isolate * isolate ) const ; <nl> base : : Value * FromV8Object ( v8 : : Local < v8 : : Object > object , <nl> FromV8ValueState * state , <nl> v8 : : Isolate * isolate ) const ; <nl>
Support converting Buffer to Value
electron/electron
ebb1ddc0df116a17aec7fb5e50ab355db6fc7169
2015-08-12T07:39:33Z
mmm a / src / core / hle / service / hid / controllers / keyboard . cpp <nl> ppp b / src / core / hle / service / hid / controllers / keyboard . cpp <nl> <nl> # include " common / common_types . h " <nl> # include " core / core_timing . h " <nl> # include " core / hle / service / hid / controllers / keyboard . h " <nl> + # include " core / settings . h " <nl> <nl> namespace Service : : HID { <nl> constexpr std : : size_t SHARED_MEMORY_OFFSET = 0x3800 ; <nl> void Controller_Keyboard : : OnUpdate ( u8 * data , std : : size_t size ) { <nl> <nl> cur_entry . sampling_number = last_entry . sampling_number + 1 ; <nl> cur_entry . sampling_number2 = cur_entry . sampling_number ; <nl> - / / TODO ( ogniK ) : Update keyboard states <nl> + <nl> + for ( std : : size_t i = 0 ; i < keyboard_keys . size ( ) ; + + i ) { <nl> + for ( std : : size_t k = 0 ; k < 8 ; + + k ) { <nl> + cur_entry . key [ i / 8 ] | = ( keyboard_keys [ i ] - > GetStatus ( ) < < k ) ; <nl> + } <nl> + } <nl> + <nl> + for ( std : : size_t i = 0 ; i < keyboard_mods . size ( ) ; + + i ) { <nl> + cur_entry . modifier | = ( keyboard_mods [ i ] - > GetStatus ( ) < < i ) ; <nl> + } <nl> <nl> std : : memcpy ( data + SHARED_MEMORY_OFFSET , & shared_memory , sizeof ( SharedMemory ) ) ; <nl> } <nl> <nl> - void Controller_Keyboard : : OnLoadInputDevices ( ) { } <nl> + void Controller_Keyboard : : OnLoadInputDevices ( ) { <nl> + std : : transform ( Settings : : values . keyboard_keys . begin ( ) , Settings : : values . keyboard_keys . end ( ) , <nl> + keyboard_keys . begin ( ) , Input : : CreateDevice < Input : : ButtonDevice > ) ; <nl> + std : : transform ( Settings : : values . keyboard_mods . begin ( ) , Settings : : values . keyboard_mods . end ( ) , <nl> + keyboard_mods . begin ( ) , Input : : CreateDevice < Input : : ButtonDevice > ) ; <nl> + } <nl> } / / namespace Service : : HID <nl> mmm a / src / core / hle / service / hid / controllers / keyboard . h <nl> ppp b / src / core / hle / service / hid / controllers / keyboard . h <nl> <nl> # include " common / common_funcs . h " <nl> # include " common / common_types . h " <nl> # include " common / swap . h " <nl> + # include " core / frontend / input . h " <nl> # include " core / hle / service / hid / controllers / controller_base . h " <nl> + # include " core / settings . h " <nl> <nl> namespace Service : : HID { <nl> class Controller_Keyboard final : public ControllerBase { <nl> class Controller_Keyboard final : public ControllerBase { <nl> } ; <nl> static_assert ( sizeof ( SharedMemory ) = = 0x400 , " SharedMemory is an invalid size " ) ; <nl> SharedMemory shared_memory { } ; <nl> + <nl> + std : : array < std : : unique_ptr < Input : : ButtonDevice > , Settings : : NativeKeyboard : : NumKeyboardKeys > <nl> + keyboard_keys ; <nl> + std : : array < std : : unique_ptr < Input : : ButtonDevice > , Settings : : NativeKeyboard : : NumKeyboardMods > <nl> + keyboard_mods ; <nl> } ; <nl> } / / namespace Service : : HID <nl>
hid : Add keyboard bindings for Keyboard controller
yuzu-emu/yuzu
0fd45e78f453c2afad4fe508c2fe181604ff821e
2018-11-19T04:22:36Z
mmm a / include / swift / AST / ProtocolConformanceRef . h <nl> ppp b / include / swift / AST / ProtocolConformanceRef . h <nl> class ProtocolConformanceRef { <nl> <nl> / / / Replace opaque types in the conforming type with their underlying types , <nl> / / / and resolve opaque conformances to their underlying conformances . <nl> - ProtocolConformanceRef substOpaqueTypesWithUnderlyingTypes ( Type origType , <nl> - ResilienceExpansion expansion ) const ; <nl> + ProtocolConformanceRef substOpaqueTypesWithUnderlyingTypes ( Type origType ) const ; <nl> <nl> / / / Given a dependent type ( expressed in terms of this conformance ' s <nl> / / / protocol ) , follow it from the conforming type . <nl> mmm a / include / swift / AST / SubstitutionMap . h <nl> ppp b / include / swift / AST / SubstitutionMap . h <nl> class SubstitutionMap { <nl> <nl> / / / Replace opaque types in the replacement types in the map with their <nl> / / / underlying types . Does not change keys . <nl> - SubstitutionMap substOpaqueTypesWithUnderlyingTypes ( <nl> - ResilienceExpansion expansion ) const ; <nl> + SubstitutionMap substOpaqueTypesWithUnderlyingTypes ( ) const ; <nl> <nl> / / / Create a substitution map for a protocol conformance . <nl> static SubstitutionMap <nl> mmm a / include / swift / AST / Type . h <nl> ppp b / include / swift / AST / Type . h <nl> class Type { <nl> <nl> / / / Replace opaque types with their underlying types when visible at the given <nl> / / / resilience expansion . <nl> - Type substOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion expansion ) const ; <nl> + Type substOpaqueTypesWithUnderlyingTypes ( ) const ; <nl> <nl> bool isPrivateStdlibType ( bool treatNonBuiltinProtocolsAsPublic = true ) const ; <nl> <nl> mmm a / include / swift / AST / Types . h <nl> ppp b / include / swift / AST / Types . h <nl> END_CAN_TYPE_WRAPPER ( OpaqueTypeArchetypeType , ArchetypeType ) <nl> / / / archetypes with underlying types visible at a given resilience expansion <nl> / / / to their underlying types . <nl> class ReplaceOpaqueTypesWithUnderlyingTypes { <nl> - ResilienceExpansion expansion ; <nl> - <nl> public : <nl> - ReplaceOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion expansion ) <nl> - : expansion ( expansion ) { } <nl> + ReplaceOpaqueTypesWithUnderlyingTypes ( ) { } <nl> <nl> / / / TypeSubstitutionFn <nl> Type operator ( ) ( SubstitutableType * maybeOpaqueType ) const ; <nl> mmm a / include / swift / SIL / AbstractionPattern . h <nl> ppp b / include / swift / SIL / AbstractionPattern . h <nl> class AbstractionPattern { <nl> OrigType = origType ; <nl> else <nl> OrigType = origType <nl> - . substOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion : : Minimal ) <nl> + . substOpaqueTypesWithUnderlyingTypes ( ) <nl> - > getCanonicalType ( ) ; <nl> GenericSig = CanGenericSignature ( ) ; <nl> if ( OrigType - > hasTypeParameter ( ) ) <nl> mmm a / lib / AST / ASTContext . cpp <nl> ppp b / lib / AST / ASTContext . cpp <nl> CanSILBoxType SILBoxType : : get ( ASTContext & C , <nl> SubstitutionMap Substitutions ) { <nl> / / TODO : Support resilient opaque types . <nl> Substitutions = Substitutions <nl> - . substOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion : : Minimal ) ; <nl> + . substOpaqueTypesWithUnderlyingTypes ( ) ; <nl> / / Canonicalize substitutions . <nl> Substitutions = Substitutions . getCanonical ( ) ; <nl> <nl> mmm a / lib / AST / ASTMangler . cpp <nl> ppp b / lib / AST / ASTMangler . cpp <nl> void ASTMangler : : appendType ( Type type ) { <nl> return appendType ( ErrorType : : get ( opaqueTy - > getASTContext ( ) ) ) ; <nl> } <nl> auto underlyingType = <nl> - type . substOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion : : Minimal ) ; <nl> + type . substOpaqueTypesWithUnderlyingTypes ( ) ; <nl> assert ( ! underlyingType - > isEqual ( type ) ) ; <nl> return appendType ( underlyingType - > getCanonicalType ( ) ) ; <nl> } <nl> mmm a / lib / AST / ProtocolConformance . cpp <nl> ppp b / lib / AST / ProtocolConformance . cpp <nl> ProtocolConformanceRef : : subst ( Type origType , <nl> } <nl> <nl> ProtocolConformanceRef <nl> - ProtocolConformanceRef : : substOpaqueTypesWithUnderlyingTypes ( Type origType , <nl> - ResilienceExpansion expansion ) const { <nl> - ReplaceOpaqueTypesWithUnderlyingTypes replacer ( expansion ) ; <nl> + ProtocolConformanceRef : : substOpaqueTypesWithUnderlyingTypes ( Type origType ) const { <nl> + ReplaceOpaqueTypesWithUnderlyingTypes replacer ; <nl> return subst ( origType , replacer , replacer , <nl> SubstFlags : : SubstituteOpaqueArchetypes ) ; <nl> } <nl> mmm a / lib / AST / SubstitutionMap . cpp <nl> ppp b / lib / AST / SubstitutionMap . cpp <nl> SubstitutionMap SubstitutionMap : : subst ( TypeSubstitutionFn subs , <nl> } <nl> <nl> SubstitutionMap <nl> - SubstitutionMap : : substOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion exp ) <nl> + SubstitutionMap : : substOpaqueTypesWithUnderlyingTypes ( ) <nl> const { <nl> - ReplaceOpaqueTypesWithUnderlyingTypes replacer ( exp ) ; <nl> + ReplaceOpaqueTypesWithUnderlyingTypes replacer ; <nl> return subst ( replacer , replacer , SubstFlags : : SubstituteOpaqueArchetypes ) ; <nl> } <nl> <nl> mmm a / lib / AST / Type . cpp <nl> ppp b / lib / AST / Type . cpp <nl> Type ReplaceOpaqueTypesWithUnderlyingTypes : : operator ( ) ( <nl> <nl> / / If the type still contains opaque types , recur . <nl> if ( substTy - > hasOpaqueArchetype ( ) ) { <nl> - return substTy . substOpaqueTypesWithUnderlyingTypes ( expansion ) ; <nl> + return substTy . substOpaqueTypesWithUnderlyingTypes ( ) ; <nl> } <nl> return substTy ; <nl> } <nl> ReplaceOpaqueTypesWithUnderlyingTypes : : operator ( ) ( CanType maybeOpaqueType , <nl> <nl> / / If the type still contains opaque types , recur . <nl> if ( substTy - > hasOpaqueArchetype ( ) ) { <nl> - return substRef . substOpaqueTypesWithUnderlyingTypes ( substTy , expansion ) ; <nl> + return substRef . substOpaqueTypesWithUnderlyingTypes ( substTy ) ; <nl> } <nl> return substRef ; <nl> } <nl> <nl> - Type Type : : substOpaqueTypesWithUnderlyingTypes ( <nl> - ResilienceExpansion expansion ) const { <nl> - ReplaceOpaqueTypesWithUnderlyingTypes replacer ( expansion ) ; <nl> + Type Type : : substOpaqueTypesWithUnderlyingTypes ( ) const { <nl> + ReplaceOpaqueTypesWithUnderlyingTypes replacer ; <nl> return subst ( replacer , replacer , <nl> SubstFlags : : SubstituteOpaqueArchetypes <nl> / / TODO ( opaque ) : Currently lowered types always get opaque types <nl> mmm a / lib / IRGen / GenProto . cpp <nl> ppp b / lib / IRGen / GenProto . cpp <nl> void WitnessTableBuilder : : defineAssociatedTypeWitnessTableAccessFunction ( <nl> ProtocolConformanceRef associatedConformance ) { <nl> / / Substitute out opaque types . <nl> auto substAssocType = associatedType <nl> - . substOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion : : Minimal ) <nl> + . substOpaqueTypesWithUnderlyingTypes ( ) <nl> - > getCanonicalType ( ) ; <nl> if ( substAssocType ! = associatedType ) { <nl> auto substAssocConformance = associatedConformance <nl> - . substOpaqueTypesWithUnderlyingTypes ( associatedType , <nl> - ResilienceExpansion : : Minimal ) ; <nl> + . substOpaqueTypesWithUnderlyingTypes ( associatedType ) ; <nl> <nl> associatedType = substAssocType ; <nl> associatedConformance = substAssocConformance ; <nl> mmm a / lib / SIL / SILInstructions . cpp <nl> ppp b / lib / SIL / SILInstructions . cpp <nl> KeyPathPattern : : get ( SILModule & M , CanGenericSignature signature , <nl> <nl> / / TODO : support resilient opaque types <nl> rootType = rootType <nl> - . substOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion : : Minimal ) <nl> + . substOpaqueTypesWithUnderlyingTypes ( ) <nl> - > getCanonicalType ( ) ; <nl> valueType = valueType <nl> - . substOpaqueTypesWithUnderlyingTypes ( ResilienceExpansion : : Minimal ) <nl> + . substOpaqueTypesWithUnderlyingTypes ( ) <nl> - > getCanonicalType ( ) ; <nl> <nl> auto newPattern = KeyPathPattern : : create ( M , signature , rootType , valueType , <nl> mmm a / lib / SIL / TypeLowering . cpp <nl> ppp b / lib / SIL / TypeLowering . cpp <nl> TypeConverter : : getTypeLowering ( AbstractionPattern origType , <nl> Type origSubstType , <nl> ResilienceExpansion forExpansion ) { <nl> CanType substType = origSubstType - > getCanonicalType ( ) <nl> - . substOpaqueTypesWithUnderlyingTypes ( forExpansion ) <nl> + . substOpaqueTypesWithUnderlyingTypes ( ) <nl> - > getCanonicalType ( ) ; <nl> auto key = getTypeKey ( origType , substType ) ; <nl> <nl>
Remove ResilienceExpansion from substOpaqueTypes for now .
apple/swift
e3bbd8ce9ec75439c80b27d6e1410893ee268bcb
2019-04-17T21:43:32Z
mmm a / lib / AST / NameLookup . cpp <nl> ppp b / lib / AST / NameLookup . cpp <nl> static void forAllVisibleModules ( const DeclContext * DC , const Fn & fn ) { <nl> cast < ModuleDecl > ( moduleScope ) - > forAllVisibleModules ( ModuleDecl : : AccessPathTy ( ) , fn ) ; <nl> } <nl> <nl> + / / / Determine whether the given declaration can be an override . <nl> + static bool canBeAnOverride ( ValueDecl * decl ) { <nl> + / / Only declarations within classes can have an overridden declaration . <nl> + if ( ! decl - > getDeclContext ( ) - > getAsClassOrClassExtensionContext ( ) ) <nl> + return false ; <nl> + <nl> + / / FIXME : We could rely on the presence of the ' override ' keyword to <nl> + / / narrow this check . <nl> + return true ; <nl> + } <nl> + <nl> bool swift : : removeOverriddenDecls ( SmallVectorImpl < ValueDecl * > & decls ) { <nl> - if ( decls . empty ( ) ) <nl> + if ( decls . size ( ) < 2 ) <nl> return false ; <nl> <nl> + auto lazyResolver = decls . front ( ) - > getASTContext ( ) . getLazyResolver ( ) ; <nl> llvm : : SmallPtrSet < ValueDecl * , 8 > overridden ; <nl> for ( auto decl : decls ) { <nl> + / / Skip anything that can ' t be an override . <nl> + if ( ! canBeAnOverride ( decl ) ) continue ; <nl> + <nl> + / / Compute enough information to make the overridden - declaration available . <nl> + / / FIXME : Narrow this check ! <nl> + if ( lazyResolver ) <nl> + lazyResolver - > resolveDeclSignature ( decl ) ; <nl> + <nl> while ( auto overrides = decl - > getOverriddenDecl ( ) ) { <nl> overridden . insert ( overrides ) ; <nl> <nl> bool DeclContext : : lookupQualified ( Type type , <nl> / / criteria . <nl> bool onlyCompleteObjectInits = false ; <nl> auto isAcceptableDecl = [ & ] ( NominalTypeDecl * current , ValueDecl * decl ) - > bool { <nl> - / / If the decl is currently being type checked , then we have something <nl> - / / cyclic going on . Instead of poking at parts that are potentially not <nl> - / / set up , just assume it is acceptable . This will make sure we produce an <nl> - / / error later . <nl> - if ( ! decl - > hasValidSignature ( ) ) <nl> - return true ; <nl> - <nl> / / Filter out designated initializers , if requested . <nl> if ( onlyCompleteObjectInits ) { <nl> if ( auto ctor = dyn_cast < ConstructorDecl > ( decl ) ) { <nl> bool DeclContext : : lookupQualified ( Type type , <nl> } <nl> <nl> / / Check access . <nl> - if ( ! ( options & NL_IgnoreAccessControl ) ) <nl> + if ( ! ( options & NL_IgnoreAccessControl ) ) { <nl> + if ( typeResolver ) <nl> + typeResolver - > resolveAccessControl ( decl ) ; <nl> + <nl> return decl - > isAccessibleFrom ( this ) ; <nl> + } <nl> <nl> return true ; <nl> } ; <nl> bool DeclContext : : lookupQualified ( Type type , <nl> if ( ( options & NL_OnlyTypes ) & & ! isa < TypeDecl > ( decl ) ) <nl> continue ; <nl> <nl> - / / Resolve the declaration signature when we find the <nl> - / / declaration . <nl> - if ( typeResolver ) <nl> - typeResolver - > resolveDeclSignature ( decl ) ; <nl> - <nl> if ( isAcceptableDecl ( current , decl ) ) <nl> decls . push_back ( decl ) ; <nl> } <nl>
[ AST ] Eliminate LazyResolver : : resolveDeclSignature ( ) call from the core of name lookup .
apple/swift
c3ed2decc4064d67f1dea62958f03c67d26a8669
2018-06-05T00:34:33Z
mmm a / xbmc / dialogs / GUIDialogFileBrowser . cpp <nl> ppp b / xbmc / dialogs / GUIDialogFileBrowser . cpp <nl> void CGUIDialogFileBrowser : : Update ( const std : : string & strDirectory ) <nl> } <nl> <nl> m_viewControl . SetItems ( * m_vecItems ) ; <nl> - m_viewControl . SetCurrentView ( ( m_browsingForImages & & CAutoSwitch : : ByFileCount ( * m_vecItems ) ) ? DEFAULT_VIEW_ICONS : DEFAULT_VIEW_LIST ) ; <nl> + m_viewControl . SetCurrentView ( ( m_browsingForImages & & CAutoSwitch : : ByFileCount ( * m_vecItems ) ) ? CONTROL_THUMBS : CONTROL_LIST ) ; <nl> <nl> std : : string strPath2 = m_Directory - > GetPath ( ) ; <nl> URIUtils : : RemoveSlashAtEnd ( strPath2 ) ; <nl>
don ' t force skins to use a panel container
xbmc/xbmc
829e9beb0590417f44bb9c10520b567139adb527
2015-01-06T20:15:23Z
mmm a / tensorflow / core / BUILD <nl> ppp b / tensorflow / core / BUILD <nl> tf_cc_tests ( <nl> " : test " , <nl> " : test_main " , <nl> " / / third_party / eigen3 " , <nl> + " @ com_google_absl / / absl / synchronization " , <nl> " @ zlib_archive / / : zlib " , <nl> ] , <nl> ) <nl> mmm a / tensorflow / core / lib / core / threadpool_test . cc <nl> ppp b / tensorflow / core / lib / core / threadpool_test . cc <nl> limitations under the License . <nl> <nl> # include < atomic > <nl> <nl> + # include " absl / synchronization / barrier . h " <nl> + # include " absl / synchronization / blocking_counter . h " <nl> # include " tensorflow / core / platform / context . h " <nl> # include " tensorflow / core / platform / env . h " <nl> # include " tensorflow / core / platform / mutex . h " <nl> TEST ( ThreadPool , ParallelForWithWorkerId ) { <nl> } <nl> } <nl> <nl> + TEST ( ThreadPool , Parallelism ) { <nl> + / / Test that if we have N threads and schedule N tasks , <nl> + / / all tasks will be scheduled at the same time . <nl> + / / Failure mode for this test will be episodic timeouts ( does not terminate ) . <nl> + ThreadPool pool ( Env : : Default ( ) , " test " , kNumThreads ) ; <nl> + for ( int iter = 0 ; iter < 2000 ; iter + + ) { <nl> + absl : : Barrier barrier ( kNumThreads ) ; <nl> + absl : : BlockingCounter counter ( kNumThreads ) ; <nl> + for ( int t = 0 ; t < kNumThreads ; + + t ) { <nl> + pool . Schedule ( [ & ] ( ) { <nl> + barrier . Block ( ) ; <nl> + counter . DecrementCount ( ) ; <nl> + } ) ; <nl> + } <nl> + counter . Wait ( ) ; <nl> + } <nl> + } <nl> + <nl> static void BM_Sequential ( int iters ) { <nl> ThreadPool pool ( Env : : Default ( ) , " test " , kNumThreads ) ; <nl> / / Decrement count sequentially until 0 . <nl>
Add test for ThreadPool parallelism .
tensorflow/tensorflow
48d77c30a4c95c65f01c06284472865cec0f800b
2019-05-21T13:04:59Z
mmm a / modules / tools / record_analyzer / lidar_endtoend_analyzer . py <nl> ppp b / modules / tools / record_analyzer / lidar_endtoend_analyzer . py <nl> class LidarEndToEndAnalyzer : <nl> <nl> def __init__ ( self ) : <nl> " " " init " " " <nl> - self . endtoend_latency = [ ] <nl> - self . unprocessed_point_cloud_timestamps = [ ] <nl> + self . control_endtoend_latency = [ ] <nl> + self . control_unprocessed_lidar_timestamps = [ ] <nl> + <nl> + self . planning_endtoend_latency = [ ] <nl> + self . planning_unprocessed_lidar_timestamps = [ ] <nl> <nl> def put_control ( self , control_cmd ) : <nl> " " " put control data " " " <nl> if control_cmd . header . lidar_timestamp in \ <nl> - self . unprocessed_point_cloud_timestamps : <nl> - ind = self . unprocessed_point_cloud_timestamps . index ( <nl> + self . control_unprocessed_lidar_timestamps : <nl> + ind = self . control_unprocessed_lidar_timestamps . index ( <nl> control_cmd . header . lidar_timestamp ) <nl> - del ( self . unprocessed_point_cloud_timestamps [ ind ] ) <nl> - self . endtoend_latency . append ( <nl> + del ( self . control_unprocessed_lidar_timestamps [ ind ] ) <nl> + self . control_endtoend_latency . append ( <nl> control_cmd . header . lidar_timestamp / 1 . 0e - 9 - <nl> control_cmd . header . timestamp_sec ) <nl> <nl> + def put_planning ( self , planning_cmd ) : <nl> + " " " put control data " " " <nl> + if planning_cmd . header . lidar_timestamp in \ <nl> + self . planning_unprocessed_lidar_timestamps : <nl> + ind = self . planning_unprocessed_lidar_timestamps . index ( <nl> + planning_cmd . header . lidar_timestamp ) <nl> + del ( self . planning_unprocessed_lidar_timestamps [ ind ] ) <nl> + self . planning_endtoend_latency . append ( <nl> + planning_cmd . header . lidar_timestamp / 1 . 0e - 9 - <nl> + planning_cmd . header . timestamp_sec ) <nl> + <nl> def put_lidar ( self , point_cloud ) : <nl> " " " put lidar data " " " <nl> - self . unprocessed_point_cloud_timestamps . append ( <nl> + self . control_unprocessed_lidar_timestamps . append ( <nl> + point_cloud . header . lidar_timestamp ) <nl> + self . planning_unprocessed_lidar_timestamps . append ( <nl> point_cloud . header . lidar_timestamp ) <nl> <nl> def print_endtoend_latency ( self ) : <nl> " " " print_endtoend_latency " " " <nl> print " \ n \ n " <nl> - print PrintColors . HEADER + " mmm End to End Latency ( ms ) mmm " + \ <nl> + print PrintColors . HEADER + " * End to End ( Control ) Latency ( ms ) " + \ <nl> + PrintColors . ENDC <nl> + analyzer = StatisticalAnalyzer ( ) <nl> + analyzer . print_statistical_results ( self . control_endtoend_latency ) <nl> + <nl> + print PrintColors . FAIL + " - MISS # OF LIDAR : " + \ <nl> + str ( len ( self . control_unprocessed_lidar_timestamps ) ) + \ <nl> + PrintColors . ENDC <nl> + <nl> + print PrintColors . HEADER + " * End to End ( Planning ) Latency ( ms ) " + \ <nl> PrintColors . ENDC <nl> analyzer = StatisticalAnalyzer ( ) <nl> - analyzer . print_statistical_results ( self . endtoend_latency ) <nl> + analyzer . print_statistical_results ( self . planning_endtoend_latency ) <nl> <nl> - print PrintColors . FAIL + " MISS # OF LIDAR : " + \ <nl> - str ( len ( self . unprocessed_point_cloud_timestamps ) ) + \ <nl> + print PrintColors . FAIL + " - MISS # OF LIDAR : " + \ <nl> + str ( len ( self . planning_unprocessed_lidar_timestamps ) ) + \ <nl> PrintColors . ENDC <nl> mmm a / modules / tools / record_analyzer / main . py <nl> ppp b / modules / tools / record_analyzer / main . py <nl> def process ( control_analyzer , planning_analyzer , lidar_endtoend_analyzer ) : <nl> adc_trajectory = planning_pb2 . ADCTrajectory ( ) <nl> adc_trajectory . ParseFromString ( msg . message ) <nl> planning_analyzer . put ( adc_trajectory ) <nl> + lidar_endtoend_analyzer . put_planning ( adc_trajectory ) <nl> <nl> if msg . topic = = " / apollo / sensor / velodyne64 / compensator / PointCloud2 " : <nl> if is_auto_drive : <nl>
tools : added planning e2e analysis for record analyzer .
ApolloAuto/apollo
cf6e059430de862f00f266f68a09191d365020a1
2018-10-17T21:06:59Z
mmm a / src / core / memory . h <nl> ppp b / src / core / memory . h <nl> enum : PAddr { <nl> <nl> / / / Main FCRAM <nl> FCRAM_PADDR = 0x20000000 , <nl> - FCRAM_SIZE = 0x08000000 , / / / < FCRAM size ( 128MB ) <nl> + FCRAM_SIZE = 0x08000000 , / / / < FCRAM size on the Old 3DS ( 128MB ) <nl> + FCRAM_N3DS_SIZE = 0x10000000 , / / / < FCRAM size on the New 3DS ( 256MB ) <nl> FCRAM_PADDR_END = FCRAM_PADDR + FCRAM_SIZE , <nl> + FCRAM_N3DS_PADDR_END = FCRAM_PADDR + FCRAM_N3DS_SIZE , <nl> } ; <nl> <nl> / / / Virtual user - space memory regions <nl>
Memory : Add enum definitions for the n3DS FCRAM size
yuzu-emu/yuzu
42b198eb0a5c3caf9dcb2c15fdf5d4d864e8e4fc
2017-06-21T05:03:25Z
new file mode 100644 <nl> index 00000000000 . . 9b7490b544f <nl> mmm / dev / null <nl> ppp b / system / include / sys / statvfs . h <nl> <nl> + <nl> + # ifdef __cplusplus <nl> + extern " C " { <nl> + # endif <nl> + <nl> + struct statvfs { <nl> + int f_bsize ; <nl> + int f_frsize ; <nl> + int f_blocks ; <nl> + int f_bfree ; <nl> + int f_bavail ; <nl> + int f_files ; <nl> + int f_ffree ; <nl> + int f_favail ; <nl> + int f_fsid ; <nl> + int f_flag ; <nl> + int f_namemax ; <nl> + } ; <nl> + <nl> + int statvfs ( char * path , struct statvfs * s ) ; <nl> + <nl> + # ifdef __cplusplus <nl> + } <nl> + # endif <nl> + <nl>
fix test_statvfs
emscripten-core/emscripten
95420a111d0ba2154ce9953b2506f7e402b97d7b
2011-10-03T08:20:14Z
mmm a / scene / 3d / sprite_3d . cpp <nl> ppp b / scene / 3d / sprite_3d . cpp <nl> float SpriteBase3D : : get_opacity ( ) const { <nl> <nl> void SpriteBase3D : : set_axis ( Vector3 : : Axis p_axis ) { <nl> <nl> + ERR_FAIL_INDEX ( p_axis , 3 ) ; <nl> axis = p_axis ; <nl> _queue_update ( ) ; <nl> } <nl> mmm a / scene / resources / texture . cpp <nl> ppp b / scene / resources / texture . cpp <nl> void CubeMap : : set_side ( Side p_side , const Ref < Image > & p_image ) { <nl> <nl> Ref < Image > CubeMap : : get_side ( Side p_side ) const { <nl> <nl> + ERR_FAIL_INDEX_V ( p_side , 6 , Ref < Image > ( ) ) ; <nl> if ( ! valid [ p_side ] ) <nl> return Ref < Image > ( ) ; <nl> return VS : : get_singleton ( ) - > texture_get_data ( cubemap , VS : : CubeMapSide ( p_side ) ) ; <nl>
Set to enum variables , only correct values
godotengine/godot
33c15799c77f2911470b5b9fa16ab73225661ee1
2019-06-24T12:53:26Z
deleted file mode 100644 <nl> index fa46079367d . . 00000000000 <nl> mmm a / lib / Basics / RandomHeap . h <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief random heap <nl> - / / / <nl> - / / / @ file <nl> - / / / This structure allows only conventional access to a heap ( which is <nl> - / / / by means of removing the head element ) . To use it , you must derive <nl> - / / / from it and implement function " static K key ( const T & ) " , to implement <nl> - / / / random access you must derive from it and overload <nl> - / / / " location " / " setLocation " accessor and implement function <nl> - / / / " static K & key ( T & ) " . <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 Richard Bruch <nl> - / / / @ author Copyright 2014 , ArangoDB GmbH , Cologne , Germany <nl> - / / / @ author Copyright 2010 - 2013 , triAGENS GmbH , Cologne , Germany <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifndef ARANGODB_BASICS_RANDOM_HEAP_H <nl> - # define ARANGODB_BASICS_RANDOM_HEAP_H 1 <nl> - <nl> - # include " Basics / Common . h " <nl> - <nl> - # include " Basics / Exceptions . h " <nl> - <nl> - namespace triagens { <nl> - namespace basics { <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - struct HeapTraitsBase <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief random heap traits <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - template < typename T , typename K = T , typename Compare = std : : less < K > > <nl> - struct HeapTraitsBase { <nl> - typedef K KeyType ; <nl> - <nl> - bool operator ( ) ( const K & f , const K & s ) const { <nl> - return _compare ( f , s ) ; <nl> - } <nl> - <nl> - static void setLocation ( T & , size_t ) { / * do nothing * / <nl> - } <nl> - <nl> - / / we only access head of queue <nl> - static size_t location ( const T & item ) { <nl> - return 1 ; <nl> - } <nl> - <nl> - Compare _compare ; <nl> - } ; <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - struct RandomHeap <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief random heap <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - template < typename T , typename TRAITS = HeapTraitsBase < T > > <nl> - struct RandomHeap { <nl> - typedef TRAITS TraitsType ; <nl> - typedef typename TraitsType : : KeyType K ; <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - constructors and destructors <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief constructor <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - RandomHeap ( ) <nl> - : _bufferLen ( 0 ) , _traits ( ) { <nl> - _queue = new T [ 1 ] ; <nl> - _queueLen = _bufferLen = 1 ; <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - public methods <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief referesh <nl> - / / / <nl> - / / TODO find a better name for semantics of ' preserve ' <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool refresh ( T & item , const K & key , bool & preserve ) { <nl> - bool changed = false , inside = TraitsType : : location ( item ) ; <nl> - <nl> - if ( _queueLen > 1 & & item = = _queue [ 1 ] ) { <nl> - changed = true ; <nl> - } <nl> - <nl> - if ( inside ) { <nl> - remove ( item ) ; <nl> - } <nl> - <nl> - TraitsType : : key ( item ) = key ; <nl> - <nl> - if ( preserve ) { <nl> - insert ( item ) ; <nl> - } <nl> - <nl> - if ( _queueLen > 1 & & item = = _queue [ 1 ] ) { <nl> - changed = true ; <nl> - } <nl> - <nl> - preserve = inside ; <nl> - <nl> - return changed ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief compare <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool operator ( ) ( T & f , T & s ) const { <nl> - return _traits ( TraitsType : : key ( f ) , TraitsType : : key ( s ) ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief head <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - T & head ( ) { <nl> - if ( _queueLen = = 1 ) { <nl> - THROW_INTERNAL_ERROR ( " head has size 1 " ) ; <nl> - } <nl> - <nl> - return _queue [ 1 ] ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief remove <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void remove ( T & item ) { <nl> - size_t i = TraitsType : : location ( item ) ; <nl> - <nl> - TRI_ASSERT ( i < _queueLen ) ; <nl> - TRI_ASSERT ( ! ( * this ) ( _queue [ i ] , item ) & & ! ( * this ) ( item , _queue [ i ] ) ) ; <nl> - <nl> - TraitsType : : setLocation ( item , 0 ) ; <nl> - T * iptr = _queue + i , * tail = _queue + - - _queueLen ; <nl> - <nl> - while ( ( i < < = 1 ) < _queueLen ) { <nl> - <nl> - / / select the smaller child of iptr and move it upheap <nl> - T * pptr = _queue + i ; <nl> - <nl> - if ( i < _queueLen & & ( * this ) ( * ( pptr + 1 ) , * pptr ) ) { <nl> - pptr + + , i + + ; <nl> - } <nl> - <nl> - * iptr = * pptr ; <nl> - TraitsType : : setLocation ( * iptr , iptr - _queue ) ; <nl> - iptr = pptr ; <nl> - } <nl> - <nl> - if ( tail ! = iptr ) { <nl> - adjust ( * tail , iptr - _queue ) ; <nl> - } <nl> - <nl> - * tail = T ( ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief insert <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void insert ( T & item ) { <nl> - if ( _bufferLen = = _queueLen ) { / / no place for the new element <nl> - <nl> - / / we use the simple doubling which should be OK in this case <nl> - T * queue = new T [ _bufferLen < < = 1 ] ; for ( size_t i = 1 ; i < _queueLen ; i + + ) queue [ i ] = _queue [ i ] ; <nl> - delete [ ] _queue ; <nl> - _queue = queue ; <nl> - } <nl> - <nl> - adjust ( item , _queueLen + + ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief adjust <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void adjust ( T & item , int i ) { <nl> - T * iptr = _queue + i ; <nl> - <nl> - while ( i > 1 ) { <nl> - T * pptr = _queue + ( i > > = 1 ) ; <nl> - <nl> - if ( ( * this ) ( * pptr , item ) ) { <nl> - break ; <nl> - } <nl> - <nl> - * iptr = * pptr ; <nl> - TraitsType : : setLocation ( * iptr , iptr - _queue ) ; <nl> - iptr = pptr ; <nl> - } <nl> - <nl> - * iptr = item ; <nl> - TraitsType : : setLocation ( item , iptr - _queue ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief validate <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void validate ( ) { <nl> - for ( size_t i = 1 ; i < _queueLen ; i + + ) { <nl> - T child = _queue [ i ] , * former = this - > former ( child ) ; <nl> - <nl> - if ( ! former ) { <nl> - continue ; <nl> - } <nl> - <nl> - if ( ( * this ) ( child , former ) ) { <nl> - TRI_ASSERT ( false ) ; <nl> - THROW_INTERNAL_ERROR ( " cannot validate random head " ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief former <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - T former ( T wt ) { <nl> - size_t index = TraitsType : : location ( wt ) ; <nl> - <nl> - if ( index > 1 ) { <nl> - return _queue [ index > > 1 ] ; <nl> - } <nl> - <nl> - return 0 ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief empty <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool empty ( ) { <nl> - return _queueLen = = 1 ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief size <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - size_t size ( ) { <nl> - return _queueLen - 1 ; <nl> - } <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - private variables <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - private : <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief queue <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - T * _queue ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief buffer length <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - size_t _bufferLen ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief queue length <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - size_t _queueLen ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief traits <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - TraitsType _traits ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - # endif <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - END - OF - FILE <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / Local Variables : <nl> - / / mode : outline - minor <nl> - / / outline - regexp : " / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ page \ \ | / / - - SECTION - - \ \ | / / / @ \ \ } " <nl> - / / End : <nl>
removed unused file
arangodb/arangodb
f6592aabffbb3e080f3b226cc6e729c2514ad8dd
2015-12-22T15:49:39Z
mmm a / ports / libwebp / CONTROL <nl> ppp b / ports / libwebp / CONTROL <nl> Description : Emscripten only build of webp . js . Deactivates all other options . <nl> Build - Depends : sdl1 ( windows ) <nl> <nl> Feature : swap16bitcsp <nl> - Description : Enable byte swap for 16 bit colorspaces . <nl> \ No newline at end of file <nl> + Description : Enable byte swap for 16 bit colorspaces . <nl> + <nl> + Feature : all <nl> + Description : enable all features except for webp_js and swap16bitcsp <nl> + Build - Depends : libwebp [ anim , gif2webp , img2webp , vwebp_sdl , info , mux , extras , nearlossless , simd , cwebp , dwebp ] <nl> \ No newline at end of file <nl>
restore the all feature .
microsoft/vcpkg
8d3ac08ca1b496da2cb45fd5a280dbd42f73e763
2020-01-13T22:48:41Z
mmm a / tensorflow / compiler / xla / service / cpu / runtime_conv2d_mkl . cc <nl> ppp b / tensorflow / compiler / xla / service / cpu / runtime_conv2d_mkl . cc <nl> void MKLConvImpl ( const EigenDevice & device , ScalarType * out , ScalarType * lhs , <nl> if ( need_output_conversion ) { <nl> net . push_back ( reorder ( conv1_dst_memory , user_dst_memory ) ) ; <nl> } <nl> - stream ( stream : : kind : : eager ) . submit ( net ) . wait ( ) ; <nl> + # ifndef ENABLE_MKLDNN_V1 <nl> + stream ( stream : : kind : : eager_nostore ) . submit ( net ) . wait ( ) ; <nl> + # endif <nl> } <nl> } / / namespace <nl> # endif / / INTEL_MKL <nl> mmm a / tensorflow / core / kernels / mkl_aggregate_ops . cc <nl> ppp b / tensorflow / core / kernels / mkl_aggregate_ops . cc <nl> class MklAddNOp : public OpKernel { <nl> sum_stream . submit ( net ) . wait ( ) ; <nl> # endif <nl> } catch ( mkldnn : : error & e ) { <nl> - string error_msg = " Status : " + std : : to_string ( e . status ) + <nl> - " , message : " + string ( e . message ) + " , in file " + <nl> - string ( __FILE__ ) + " : " + std : : to_string ( __LINE__ ) ; <nl> + string error_msg = " Status : " + std : : to_string ( e . status ) + " , message : " + <nl> + string ( e . message ) + " , in file " + string ( __FILE__ ) + <nl> + " : " + std : : to_string ( __LINE__ ) ; <nl> OP_REQUIRES_OK ( <nl> ctx , errors : : Aborted ( " Operation received an exception : " , error_msg ) ) ; <nl> } <nl> mmm a / tensorflow / core / kernels / mkl_fused_batch_norm_op . cc <nl> ppp b / tensorflow / core / kernels / mkl_fused_batch_norm_op . cc <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> # ifdef INTEL_MKL <nl> # include " mkldnn . hpp " <nl> - # include " third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor " <nl> # include " tensorflow / core / framework / op_kernel . h " <nl> # include " tensorflow / core / framework / register_types . h " <nl> # include " tensorflow / core / framework / tensor . h " <nl> # include " tensorflow / core / framework / tensor_types . h " <nl> # include " tensorflow / core / util / mkl_util . h " <nl> # include " tensorflow / core / util / tensor_format . h " <nl> + # include " third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor " <nl> <nl> using mkldnn : : batch_normalization_backward ; <nl> using mkldnn : : batch_normalization_forward ; <nl> class MklFusedBatchNormFwdPrimitive : public MklPrimitive { <nl> public : <nl> explicit MklFusedBatchNormFwdPrimitive ( const MklBatchNormFwdParams & fwdParams ) <nl> : cpu_engine_ ( engine : : cpu , 0 ) { <nl> - context_ . fwd_stream . reset ( new mkldnn : : stream ( mkldnn : : stream : : kind : : eager ) ) ; <nl> + # ifndef ENABLE_MKLDNN_V1 <nl> + context_ . fwd_stream . reset ( <nl> + new mkldnn : : stream ( mkldnn : : stream : : kind : : eager_nostore ) ) ; <nl> + # endif <nl> if ( context_ . bn_fwd = = nullptr ) Setup ( fwdParams ) ; <nl> } <nl> <nl> class MklFusedBatchNormBwdPrimitive : public MklPrimitive { <nl> public : <nl> explicit MklFusedBatchNormBwdPrimitive ( const MklBatchNormBwdParams & bwdParams ) <nl> : cpu_engine_ ( engine : : cpu , 0 ) { <nl> - context_ . bwd_stream . reset ( new mkldnn : : stream ( mkldnn : : stream : : kind : : eager ) ) ; <nl> + # ifndef ENABLE_MKLDNN_V1 <nl> + context_ . bwd_stream . reset ( <nl> + new mkldnn : : stream ( mkldnn : : stream : : kind : : eager_nostore ) ) ; <nl> + # endif <nl> if ( context_ . bn_bwd = = nullptr ) Setup ( bwdParams ) ; <nl> } <nl> <nl> class MklFusedBatchNormOp : public OpKernel { <nl> std : : memcpy ( batch_variance_data , variance_data , depth_ * sizeof ( U ) ) ; <nl> } <nl> } catch ( mkldnn : : error & e ) { <nl> - string error_msg = " Status : " + std : : to_string ( e . status ) + <nl> - " , message : " + string ( e . message ) + " , in file " + <nl> - string ( __FILE__ ) + " : " + std : : to_string ( __LINE__ ) ; <nl> + string error_msg = " Status : " + std : : to_string ( e . status ) + " , message : " + <nl> + string ( e . message ) + " , in file " + string ( __FILE__ ) + <nl> + " : " + std : : to_string ( __LINE__ ) ; <nl> OP_REQUIRES_OK ( <nl> context , <nl> errors : : Aborted ( " Operation received an exception : " , error_msg ) ) ; <nl> class MklFusedBatchNormGradOp : public OpKernel { <nl> reinterpret_cast < char * > ( diff_weights_data + depth_ ) , <nl> depth_ * sizeof ( U ) ) ; <nl> } catch ( mkldnn : : error & e ) { <nl> - string error_msg = " Status : " + std : : to_string ( e . status ) + <nl> - " , message : " + string ( e . message ) + " , in file " + <nl> - string ( __FILE__ ) + " : " + std : : to_string ( __LINE__ ) ; <nl> + string error_msg = " Status : " + std : : to_string ( e . status ) + " , message : " + <nl> + string ( e . message ) + " , in file " + string ( __FILE__ ) + <nl> + " : " + std : : to_string ( __LINE__ ) ; <nl> OP_REQUIRES_OK ( <nl> context , <nl> errors : : Aborted ( " Operation received an exception : " , error_msg ) ) ; <nl> mmm a / tensorflow / core / kernels / mkl_lrn_op . cc <nl> ppp b / tensorflow / core / kernels / mkl_lrn_op . cc <nl> limitations under the License . <nl> # include < vector > <nl> <nl> # include " mkldnn . hpp " <nl> - # include " third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor " <nl> # include " tensorflow / core / framework / bounds_check . h " <nl> # include " tensorflow / core / framework / op_kernel . h " <nl> # include " tensorflow / core / framework / register_types . h " <nl> limitations under the License . <nl> # include " tensorflow / core / lib / core / errors . h " <nl> # include " tensorflow / core / util / mkl_util . h " <nl> # include " tensorflow / core / util / tensor_format . h " <nl> + # include " third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor " <nl> <nl> # if ! defined ( IS_MOBILE_PLATFORM ) <nl> # include " tensorflow / core / util / work_sharder . h " <nl> class MklLRNOp : public OpKernel { <nl> explicit MklLRNOp ( OpKernelConstruction * context ) : OpKernel ( context ) { <nl> int64 depth_radius64 ; <nl> OP_REQUIRES_OK ( context , context - > GetAttr ( " depth_radius " , & depth_radius64 ) ) ; <nl> - OP_REQUIRES ( <nl> - context , <nl> - FastBoundsCheck ( depth_radius64 , std : : numeric_limits < int > : : max ( ) ) , <nl> - errors : : InvalidArgument ( " depth_radius = " , depth_radius64 , <nl> - " larger than int max " ) ) ; <nl> + OP_REQUIRES ( context , FastBoundsCheck ( depth_radius64 , <nl> + std : : numeric_limits < int > : : max ( ) ) , <nl> + errors : : InvalidArgument ( " depth_radius = " , depth_radius64 , <nl> + " larger than int max " ) ) ; <nl> depth_radius_ = static_cast < size_t > ( depth_radius64 ) ; <nl> <nl> OP_REQUIRES_OK ( context , context - > GetAttr ( " bias " , & bias_ ) ) ; <nl> class MklLRNOp : public OpKernel { <nl> PrepareAndExecuteNet ( lrn_prim_desc , & src_dnn_data , & dst_dnn_data , <nl> & workspace_dnn_data ) ; <nl> } catch ( mkldnn : : error & e ) { <nl> - string error_msg = " Status : " + std : : to_string ( e . status ) + <nl> - " , message : " + string ( e . message ) + " , in file " + <nl> - string ( __FILE__ ) + " : " + std : : to_string ( __LINE__ ) ; <nl> + string error_msg = " Status : " + std : : to_string ( e . status ) + " , message : " + <nl> + string ( e . message ) + " , in file " + string ( __FILE__ ) + <nl> + " : " + std : : to_string ( __LINE__ ) ; <nl> OP_REQUIRES_OK ( <nl> context , <nl> errors : : Aborted ( " Operation received an exception : " , error_msg ) ) ; <nl> class MklLRNOp : public OpKernel { <nl> net . push_back ( lrn_forward ( lrn_fwd_desc , src_dnn_data - > GetOpMem ( ) , <nl> dst_dnn_data - > GetOpMem ( ) ) ) ; <nl> } <nl> - stream ( stream : : kind : : eager ) . submit ( net ) . wait ( ) ; <nl> + # ifndef ENABLE_MKLDNN_V1 <nl> + stream ( stream : : kind : : eager_nostore ) . submit ( net ) . wait ( ) ; <nl> + # endif <nl> } <nl> <nl> void AllocateOutputTensor ( <nl> class MklLRNOp : public OpKernel { <nl> if ( src_dnn_shape . IsMklTensor ( ) ) { <nl> OP_REQUIRES ( context , src_dnn_shape . GetDimension ( ) = = 4 , <nl> errors : : InvalidArgument ( " input must be 4 - dimensional " ) ) ; <nl> - OP_REQUIRES ( context , <nl> - FastBoundsCheck ( src_tensor . NumElements ( ) , <nl> - std : : numeric_limits < int > : : max ( ) ) , <nl> + OP_REQUIRES ( context , FastBoundsCheck ( src_tensor . NumElements ( ) , <nl> + std : : numeric_limits < int > : : max ( ) ) , <nl> errors : : InvalidArgument ( " argument to LRN too large " ) ) ; <nl> } else { <nl> OP_REQUIRES ( context , src_tensor . dims ( ) = = 4 , <nl> errors : : InvalidArgument ( " input must be 4 - dimensional " ) ) ; <nl> - OP_REQUIRES ( context , <nl> - FastBoundsCheck ( src_tensor . NumElements ( ) , <nl> - std : : numeric_limits < int > : : max ( ) ) , <nl> + OP_REQUIRES ( context , FastBoundsCheck ( src_tensor . NumElements ( ) , <nl> + std : : numeric_limits < int > : : max ( ) ) , <nl> errors : : InvalidArgument ( " argument to LRN too large " ) ) ; <nl> } <nl> } <nl> class MklLRNGradOp : public OpKernel { <nl> explicit MklLRNGradOp ( OpKernelConstruction * context ) : OpKernel ( context ) { <nl> int64 depth_radius64 ; <nl> OP_REQUIRES_OK ( context , context - > GetAttr ( " depth_radius " , & depth_radius64 ) ) ; <nl> - OP_REQUIRES ( <nl> - context , <nl> - FastBoundsCheck ( depth_radius64 , std : : numeric_limits < int > : : max ( ) ) , <nl> - errors : : InvalidArgument ( " depth_radius = " , depth_radius64 , <nl> - " larger than int max " ) ) ; <nl> + OP_REQUIRES ( context , FastBoundsCheck ( depth_radius64 , <nl> + std : : numeric_limits < int > : : max ( ) ) , <nl> + errors : : InvalidArgument ( " depth_radius = " , depth_radius64 , <nl> + " larger than int max " ) ) ; <nl> depth_radius_ = static_cast < int > ( depth_radius64 ) ; <nl> OP_REQUIRES_OK ( context , context - > GetAttr ( " bias " , & bias_ ) ) ; <nl> OP_REQUIRES_OK ( context , context - > GetAttr ( " alpha " , & alpha_ ) ) ; <nl> class MklLRNGradOp : public OpKernel { <nl> memory : : primitive_desc ( target_diff_dst_md , cpu_engine ) , <nl> & workspace_dnn_data ) ; <nl> } catch ( mkldnn : : error & e ) { <nl> - string error_msg = " Status : " + std : : to_string ( e . status ) + <nl> - " , message : " + string ( e . message ) + " , in file " + <nl> - string ( __FILE__ ) + " : " + std : : to_string ( __LINE__ ) ; <nl> + string error_msg = " Status : " + std : : to_string ( e . status ) + " , message : " + <nl> + string ( e . message ) + " , in file " + string ( __FILE__ ) + <nl> + " : " + std : : to_string ( __LINE__ ) ; <nl> OP_REQUIRES_OK ( <nl> context , <nl> errors : : Aborted ( " Operation received an exception : " , error_msg ) ) ; <nl> class MklLRNGradOp : public OpKernel { <nl> workspace_dnn_data - > GetOpMem ( ) , <nl> output_diff_src - > GetOpMem ( ) ) ) ; <nl> } <nl> - stream ( stream : : kind : : eager ) . submit ( net ) . wait ( ) ; <nl> + # ifndef ENABLE_MKLDNN_V1 <nl> + stream ( stream : : kind : : eager_nostore ) . submit ( net ) . wait ( ) ; <nl> + # endif <nl> } <nl> <nl> void ConfigureWorkspace ( const Tensor & workspace_tensor , <nl> mmm a / tensorflow / core / kernels / mkl_matmul_ops_common . h <nl> ppp b / tensorflow / core / kernels / mkl_matmul_ops_common . h <nl> class MklDnnMatMulFwdPrimitive : public MklPrimitive { <nl> explicit MklDnnMatMulFwdPrimitive ( <nl> const MklDnnMatMulFwdParams & matmulFwdParams ) <nl> : cpu_engine_ ( engine : : cpu , 0 ) { <nl> - context_ . fwd_stream . reset ( new stream ( stream : : kind : : eager ) ) ; <nl> + # ifndef ENABLE_MKLDNN_V1 <nl> + context_ . fwd_stream . reset ( new stream ( stream : : kind : : eager_nostore ) ) ; <nl> + # endif <nl> / / Create matmul primitive <nl> if ( context_ . matmul_fwd = = nullptr ) { <nl> Setup ( matmulFwdParams ) ; <nl> mmm a / tensorflow / core / kernels / mkl_qmatmul_op . cc <nl> ppp b / tensorflow / core / kernels / mkl_qmatmul_op . cc <nl> class MklDnnQuantizedMatMulOp : public MklDnnMatMulOpBase < Toutput > { <nl> scaled_bias_ - > get_primitive_desc ( ) , bias_attr ) ; <nl> net . push_back ( <nl> mkldnn : : reorder ( reorder_desc , * input_bias_ , * scaled_bias_ ) ) ; <nl> - stream ( stream : : kind : : eager ) . submit ( net ) . wait ( ) ; <nl> + # ifndef ENABLE_MKLDNN_V1 <nl> + stream ( stream : : kind : : eager_nostore ) . submit ( net ) . wait ( ) ; <nl> + # endif <nl> return reinterpret_cast < Tbias * > ( scaled_bias_ - > get_data_handle ( ) ) ; <nl> } else { <nl> context - > CtxFailure ( <nl> mmm a / tensorflow / core / kernels / mkl_softmax_op . cc <nl> ppp b / tensorflow / core / kernels / mkl_softmax_op . cc <nl> limitations under the License . <nl> # ifdef INTEL_MKL <nl> <nl> # include " mkldnn . hpp " <nl> - # include " third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor " <nl> # include " tensorflow / core / framework / numeric_op . h " <nl> # include " tensorflow / core / framework / op_kernel . h " <nl> # include " tensorflow / core / framework / register_types . h " <nl> limitations under the License . <nl> # include " tensorflow / core / lib / core / errors . h " <nl> # include " tensorflow / core / util / mkl_util . h " <nl> # include " tensorflow / core / util / tensor_format . h " <nl> + # include " third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor " <nl> <nl> using mkldnn : : prop_kind ; <nl> using mkldnn : : softmax_forward ; <nl> class MklSoftmaxPrimitive : public MklPrimitive { <nl> public : <nl> explicit MklSoftmaxPrimitive ( const MklSoftmaxParams & fwdParams ) <nl> : cpu_engine_ ( engine : : cpu , 0 ) { <nl> - context_ . fwd_stream . reset ( new stream ( stream : : kind : : eager ) ) ; <nl> + # ifndef ENABLE_MKLDNN_V1 <nl> + context_ . fwd_stream . reset ( new stream ( stream : : kind : : eager_nostore ) ) ; <nl> + # endif <nl> Setup ( fwdParams ) ; <nl> } <nl> <nl> class MklSoftmaxOp : public OpKernel { <nl> / / Execute softmax <nl> softmax_fwd - > Execute ( src_data , dst_data ) ; <nl> } catch ( mkldnn : : error & e ) { <nl> - string error_msg = " Status : " + std : : to_string ( e . status ) + <nl> - " , message : " + string ( e . message ) + " , in file " + <nl> - string ( __FILE__ ) + " : " + std : : to_string ( __LINE__ ) ; <nl> + string error_msg = " Status : " + std : : to_string ( e . status ) + " , message : " + <nl> + string ( e . message ) + " , in file " + string ( __FILE__ ) + <nl> + " : " + std : : to_string ( __LINE__ ) ; <nl> OP_REQUIRES_OK ( <nl> context , <nl> errors : : Aborted ( " Operation received an exception : " , error_msg ) ) ; <nl> mmm a / tensorflow / core / util / mkl_types . h <nl> ppp b / tensorflow / core / util / mkl_types . h <nl> namespace tensorflow { <nl> # define ADD_MD add_pd <nl> # define ALGORITHM mkldnn <nl> # define ALGORITHM_UNDEF ALGORITHM : : algorithm_undef <nl> - # define CPU_STREAM ( engine ) stream ( stream : : kind : : eager ) <nl> + # define CPU_STREAM ( engine ) stream ( stream : : kind : : eager_nostore ) <nl> # define DATA_WITH_ENGINE ( data , engine ) data <nl> # define DST_MD dst_pd <nl> # define ENGINE_CPU engine : : cpu <nl> mmm a / tensorflow / core / util / mkl_util . h <nl> ppp b / tensorflow / core / util / mkl_util . h <nl> inline void ExecutePrimitive ( const std : : vector < primitive > & net , <nl> } <nl> cpu_stream . wait ( ) ; <nl> # else <nl> - stream ( stream : : kind : : eager ) . submit ( net ) . wait ( ) ; <nl> + stream ( stream : : kind : : eager_nostore ) . submit ( net ) . wait ( ) ; <nl> # endif / / ENABLE_MKLDNN_V1 <nl> } <nl> <nl> inline Status ConvertMklToTF ( OpKernelContext * context , <nl> } <nl> return Status : : OK ( ) ; <nl> } catch ( mkldnn : : error & e ) { <nl> - string error_msg = " Status : " + std : : to_string ( e . status ) + <nl> - " , message : " + string ( e . message ) + " , in file " + <nl> - string ( __FILE__ ) + " : " + std : : to_string ( __LINE__ ) ; <nl> + string error_msg = " Status : " + std : : to_string ( e . status ) + " , message : " + <nl> + string ( e . message ) + " , in file " + string ( __FILE__ ) + <nl> + " : " + std : : to_string ( __LINE__ ) ; <nl> LOG ( FATAL ) < < " Operation received an exception : " < < error_msg ; <nl> } <nl> } <nl> inline Status CreateBlockedMemDescHelper ( const memory : : dims & dim , <nl> } catch ( mkldnn : : error & e ) { <nl> return Status ( error : : Code : : INTERNAL , <nl> tensorflow : : strings : : StrCat ( <nl> - " Failed to create blocked memory descriptor . " , <nl> - " Status : " , e . status , " , message : " , e . message ) ) ; <nl> + " Failed to create blocked memory descriptor . " , " Status : " , <nl> + e . status , " , message : " , e . message ) ) ; <nl> } <nl> # else <nl> / / We have to construct memory descriptor in a C style . This is not at all <nl> class MklDnnData { <nl> reorder_memory_ = new memory ( op_pd ) ; <nl> std : : vector < primitive > net ; <nl> net . push_back ( FindOrCreateReorder < T > ( user_memory_ , reorder_memory_ ) ) ; <nl> - stream ( stream : : kind : : eager ) . submit ( net ) . wait ( ) ; <nl> + stream ( stream : : kind : : eager_nostore ) . submit ( net ) . wait ( ) ; <nl> # endif / / ENABLE_MKLDNN_V1 <nl> return true ; <nl> } <nl> class MklDnnData { <nl> std : : vector < primitive > net ; <nl> reorder_memory_ = new memory ( op_pd , reorder_data_handle ) ; <nl> net . push_back ( FindOrCreateReorder < T > ( user_memory_ , reorder_memory_ ) ) ; <nl> - stream ( stream : : kind : : eager ) . submit ( net ) . wait ( ) ; <nl> + stream ( stream : : kind : : eager_nostore ) . submit ( net ) . wait ( ) ; <nl> # endif / / ENABLE_MKLDNN_V1 <nl> return true ; <nl> } <nl> mmm a / tensorflow / workspace . bzl <nl> ppp b / tensorflow / workspace . bzl <nl> def tf_repositories ( path_prefix = " " , tf_repo_name = " " ) : <nl> tf_http_archive ( <nl> name = " mkl_dnn " , <nl> build_file = clean_dep ( " / / third_party / mkl_dnn : mkldnn . BUILD " ) , <nl> - sha256 = " ed56652dd237deb86ee9bf102c18de5f2625c059e5ab1d7512c8dc01e316b694 " , <nl> - strip_prefix = " mkl - dnn - 0 . 21 . 2 " , <nl> + sha256 = " 31e78581e59d7e60d4becaba3834fc6a5bf2dccdae3e16b7f70d89ceab38423f " , <nl> + strip_prefix = " mkl - dnn - 0 . 21 . 3 " , <nl> urls = [ <nl> - " https : / / storage . googleapis . com / mirror . tensorflow . org / github . com / intel / mkl - dnn / archive / v0 . 21 . 2 . tar . gz " , <nl> - " https : / / github . com / intel / mkl - dnn / archive / v0 . 21 . 2 . tar . gz " , <nl> + " https : / / storage . googleapis . com / mirror . tensorflow . org / github . com / intel / mkl - dnn / archive / v0 . 21 . 3 . tar . gz " , <nl> + " https : / / github . com / intel / mkl - dnn / archive / v0 . 21 . 3 . tar . gz " , <nl> ] , <nl> ) <nl> <nl> mmm a / third_party / mkl_dnn / mkldnn . BUILD <nl> ppp b / third_party / mkl_dnn / mkldnn . BUILD <nl> template_rule ( <nl> substitutions = { <nl> " @ MKLDNN_VERSION_MAJOR @ " : " 0 " , <nl> " @ MKLDNN_VERSION_MINOR @ " : " 21 " , <nl> - " @ MKLDNN_VERSION_PATCH @ " : " 2 " , <nl> + " @ MKLDNN_VERSION_PATCH @ " : " 3 " , <nl> " @ MKLDNN_VERSION_HASH @ " : " N / A " , <nl> } , <nl> ) <nl>
[ Intel MKL ] Fix memory leak in dnnl 0 . 21 . 2
tensorflow/tensorflow
964066dd2f60fca543fd360b8d2556c9b3a380cf
2020-02-20T06:42:03Z
mmm a / Marlin / src / lcd / menu / menu . cpp <nl> ppp b / Marlin / src / lcd / menu / menu . cpp <nl> <nl> # include " . . / . . / libs / duration_t . h " <nl> # endif <nl> <nl> - # if ENABLED ( BLTOUCH ) <nl> - # include " . . / . . / module / endstops . h " <nl> - # endif <nl> - <nl> # if HAS_LEVELING <nl> # include " . . / . . / feature / bedlevel / bedlevel . h " <nl> # endif <nl> int32_t minEditValue , maxEditValue ; <nl> screenFunc_t callbackFunc ; <nl> bool liveEdit ; <nl> <nl> - # if ENABLED ( PIDTEMP ) <nl> - float raw_Ki , raw_Kd ; / / place - holders for Ki and Kd edits <nl> - # endif <nl> - <nl> bool no_reentry = false ; <nl> <nl> / / Initialized by settings . load ( ) <nl> void menu_action_setting_edit_callback_bool ( PGM_P pstr , bool * ptr , screenFunc_t <nl> / / / / / / / / / / / / / / / / / Menu Tree / / / / / / / / / / / / / / / / <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - # if DISABLED ( NO_VOLUMETRICS ) | | ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> - void menu_advanced_filament ( ) ; <nl> - # endif <nl> - <nl> # if ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> # if E_STEPPERS > 1 | | ENABLED ( FILAMENT_LOAD_UNLOAD_GCODES ) <nl> void menu_change_filament ( ) ; <nl> void watch_temp_callback_bed ( ) { <nl> # if ENABLED ( EEPROM_SETTINGS ) <nl> void lcd_store_settings ( ) { lcd_completion_feedback ( settings . save ( ) ) ; } <nl> void lcd_load_settings ( ) { lcd_completion_feedback ( settings . load ( ) ) ; } <nl> - # if DISABLED ( SLIM_LCD_MENUS ) <nl> - static void lcd_init_eeprom ( ) { <nl> - lcd_completion_feedback ( settings . init_eeprom ( ) ) ; <nl> - lcd_goto_previous_menu ( ) ; <nl> - } <nl> - static void lcd_init_eeprom_confirm ( ) { <nl> - START_MENU ( ) ; <nl> - MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> - MENU_ITEM ( function , MSG_INIT_EEPROM , lcd_init_eeprom ) ; <nl> - END_MENU ( ) ; <nl> - } <nl> - # endif <nl> # endif <nl> <nl> void _lcd_draw_homing ( ) { <nl> void _lcd_draw_homing ( ) { <nl> <nl> # endif / / DELTA_CALIBRATION_MENU | | DELTA_AUTO_CALIBRATION <nl> <nl> - / * * <nl> - * <nl> - * " Temperature " submenu <nl> - * <nl> - * / <nl> - <nl> - # if ENABLED ( PID_AUTOTUNE_MENU ) <nl> - <nl> - # if ENABLED ( PIDTEMP ) <nl> - int16_t autotune_temp [ HOTENDS ] = ARRAY_BY_HOTENDS1 ( 150 ) ; <nl> - # endif <nl> - <nl> - # if ENABLED ( PIDTEMPBED ) <nl> - int16_t autotune_temp_bed = 70 ; <nl> - # endif <nl> - <nl> - void _lcd_autotune ( int16_t e ) { <nl> - char cmd [ 30 ] ; <nl> - sprintf_P ( cmd , PSTR ( " M303 U1 E % i S % i " ) , e , <nl> - # if HAS_PID_FOR_BOTH <nl> - e < 0 ? autotune_temp_bed : autotune_temp [ e ] <nl> - # elif ENABLED ( PIDTEMPBED ) <nl> - autotune_temp_bed <nl> - # else <nl> - autotune_temp [ e ] <nl> - # endif <nl> - ) ; <nl> - lcd_enqueue_command ( cmd ) ; <nl> - } <nl> - <nl> - # endif / / PID_AUTOTUNE_MENU <nl> - <nl> - # if ENABLED ( PIDTEMP ) <nl> - <nl> - / / Helpers for editing PID Ki & Kd values <nl> - / / grab the PID value out of the temp variable ; scale it ; then update the PID driver <nl> - void copy_and_scalePID_i ( int16_t e ) { <nl> - # if DISABLED ( PID_PARAMS_PER_HOTEND ) | | HOTENDS = = 1 <nl> - UNUSED ( e ) ; <nl> - # endif <nl> - PID_PARAM ( Ki , e ) = scalePID_i ( raw_Ki ) ; <nl> - thermalManager . updatePID ( ) ; <nl> - } <nl> - void copy_and_scalePID_d ( int16_t e ) { <nl> - # if DISABLED ( PID_PARAMS_PER_HOTEND ) | | HOTENDS = = 1 <nl> - UNUSED ( e ) ; <nl> - # endif <nl> - PID_PARAM ( Kd , e ) = scalePID_d ( raw_Kd ) ; <nl> - thermalManager . updatePID ( ) ; <nl> - } <nl> - # define _DEFINE_PIDTEMP_BASE_FUNCS ( N ) \ <nl> - void copy_and_scalePID_i_E # # N ( ) { copy_and_scalePID_i ( N ) ; } \ <nl> - void copy_and_scalePID_d_E # # N ( ) { copy_and_scalePID_d ( N ) ; } <nl> - <nl> - # if ENABLED ( PID_AUTOTUNE_MENU ) <nl> - # define DEFINE_PIDTEMP_FUNCS ( N ) \ <nl> - _DEFINE_PIDTEMP_BASE_FUNCS ( N ) ; \ <nl> - void lcd_autotune_callback_E # # N ( ) { _lcd_autotune ( N ) ; } typedef void _pid_ # # N # # _void <nl> - # else <nl> - # define DEFINE_PIDTEMP_FUNCS ( N ) _DEFINE_PIDTEMP_BASE_FUNCS ( N ) typedef void _pid_ # # N # # _void <nl> - # endif <nl> - <nl> - DEFINE_PIDTEMP_FUNCS ( 0 ) ; <nl> - # if ENABLED ( PID_PARAMS_PER_HOTEND ) <nl> - # if HOTENDS > 1 <nl> - DEFINE_PIDTEMP_FUNCS ( 1 ) ; <nl> - # if HOTENDS > 2 <nl> - DEFINE_PIDTEMP_FUNCS ( 2 ) ; <nl> - # if HOTENDS > 3 <nl> - DEFINE_PIDTEMP_FUNCS ( 3 ) ; <nl> - # if HOTENDS > 4 <nl> - DEFINE_PIDTEMP_FUNCS ( 4 ) ; <nl> - # if HOTENDS > 5 <nl> - DEFINE_PIDTEMP_FUNCS ( 5 ) ; <nl> - # endif / / HOTENDS > 5 <nl> - # endif / / HOTENDS > 4 <nl> - # endif / / HOTENDS > 3 <nl> - # endif / / HOTENDS > 2 <nl> - # endif / / HOTENDS > 1 <nl> - # endif / / PID_PARAMS_PER_HOTEND <nl> - <nl> - # endif / / PIDTEMP <nl> - <nl> - / * * <nl> - * <nl> - * " Advanced Settings " - > " Temperature " submenu <nl> - * <nl> - * / <nl> - void menu_advanced_temperature ( ) { <nl> - START_MENU ( ) ; <nl> - MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> - / / <nl> - / / Autotemp , Min , Max , Fact <nl> - / / <nl> - # if ENABLED ( AUTOTEMP ) & & HAS_TEMP_HOTEND <nl> - MENU_ITEM_EDIT ( bool , MSG_AUTOTEMP , & planner . autotemp_enabled ) ; <nl> - MENU_ITEM_EDIT ( float3 , MSG_MIN , & planner . autotemp_min , 0 , float ( HEATER_0_MAXTEMP ) - 15 ) ; <nl> - MENU_ITEM_EDIT ( float3 , MSG_MAX , & planner . autotemp_max , 0 , float ( HEATER_0_MAXTEMP ) - 15 ) ; <nl> - MENU_ITEM_EDIT ( float52 , MSG_FACTOR , & planner . autotemp_factor , 0 , 1 ) ; <nl> - # endif <nl> - <nl> - / / <nl> - / / PID - P , PID - I , PID - D , PID - C , PID Autotune <nl> - / / PID - P E1 , PID - I E1 , PID - D E1 , PID - C E1 , PID Autotune E1 <nl> - / / PID - P E2 , PID - I E2 , PID - D E2 , PID - C E2 , PID Autotune E2 <nl> - / / PID - P E3 , PID - I E3 , PID - D E3 , PID - C E3 , PID Autotune E3 <nl> - / / PID - P E4 , PID - I E4 , PID - D E4 , PID - C E4 , PID Autotune E4 <nl> - / / PID - P E5 , PID - I E5 , PID - D E5 , PID - C E5 , PID Autotune E5 <nl> - / / <nl> - # if ENABLED ( PIDTEMP ) <nl> - <nl> - # define _PID_BASE_MENU_ITEMS ( ELABEL , eindex ) \ <nl> - raw_Ki = unscalePID_i ( PID_PARAM ( Ki , eindex ) ) ; \ <nl> - raw_Kd = unscalePID_d ( PID_PARAM ( Kd , eindex ) ) ; \ <nl> - MENU_ITEM_EDIT ( float52sign , MSG_PID_P ELABEL , & PID_PARAM ( Kp , eindex ) , 1 , 9990 ) ; \ <nl> - MENU_ITEM_EDIT_CALLBACK ( float52sign , MSG_PID_I ELABEL , & raw_Ki , 0 . 01f , 9990 , copy_and_scalePID_i_E # # eindex ) ; \ <nl> - MENU_ITEM_EDIT_CALLBACK ( float52sign , MSG_PID_D ELABEL , & raw_Kd , 1 , 9990 , copy_and_scalePID_d_E # # eindex ) <nl> - <nl> - # if ENABLED ( PID_EXTRUSION_SCALING ) <nl> - # define _PID_MENU_ITEMS ( ELABEL , eindex ) \ <nl> - _PID_BASE_MENU_ITEMS ( ELABEL , eindex ) ; \ <nl> - MENU_ITEM_EDIT ( float3 , MSG_PID_C ELABEL , & PID_PARAM ( Kc , eindex ) , 1 , 9990 ) <nl> - # else <nl> - # define _PID_MENU_ITEMS ( ELABEL , eindex ) _PID_BASE_MENU_ITEMS ( ELABEL , eindex ) <nl> - # endif <nl> - <nl> - # if ENABLED ( PID_AUTOTUNE_MENU ) <nl> - # define PID_MENU_ITEMS ( ELABEL , eindex ) \ <nl> - _PID_MENU_ITEMS ( ELABEL , eindex ) ; \ <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_PID_AUTOTUNE ELABEL , & autotune_temp [ eindex ] , 150 , heater_maxtemp [ eindex ] - 15 , lcd_autotune_callback_E # # eindex ) <nl> - # else <nl> - # define PID_MENU_ITEMS ( ELABEL , eindex ) _PID_MENU_ITEMS ( ELABEL , eindex ) <nl> - # endif <nl> - <nl> - # if ENABLED ( PID_PARAMS_PER_HOTEND ) & & HOTENDS > 1 <nl> - PID_MENU_ITEMS ( " " MSG_E1 , 0 ) ; <nl> - PID_MENU_ITEMS ( " " MSG_E2 , 1 ) ; <nl> - # if HOTENDS > 2 <nl> - PID_MENU_ITEMS ( " " MSG_E3 , 2 ) ; <nl> - # if HOTENDS > 3 <nl> - PID_MENU_ITEMS ( " " MSG_E4 , 3 ) ; <nl> - # if HOTENDS > 4 <nl> - PID_MENU_ITEMS ( " " MSG_E5 , 4 ) ; <nl> - # if HOTENDS > 5 <nl> - PID_MENU_ITEMS ( " " MSG_E6 , 5 ) ; <nl> - # endif / / HOTENDS > 5 <nl> - # endif / / HOTENDS > 4 <nl> - # endif / / HOTENDS > 3 <nl> - # endif / / HOTENDS > 2 <nl> - # else / / ! PID_PARAMS_PER_HOTEND | | HOTENDS = = 1 <nl> - PID_MENU_ITEMS ( " " , 0 ) ; <nl> - # endif / / ! PID_PARAMS_PER_HOTEND | | HOTENDS = = 1 <nl> - <nl> - # endif / / PIDTEMP <nl> - <nl> - END_MENU ( ) ; <nl> - } <nl> - <nl> - # if DISABLED ( SLIM_LCD_MENUS ) <nl> - <nl> - void _reset_acceleration_rates ( ) { planner . reset_acceleration_rates ( ) ; } <nl> - # if ENABLED ( DISTINCT_E_FACTORS ) <nl> - void _reset_e_acceleration_rate ( const uint8_t e ) { if ( e = = active_extruder ) _reset_acceleration_rates ( ) ; } <nl> - void _reset_e0_acceleration_rate ( ) { _reset_e_acceleration_rate ( 0 ) ; } <nl> - void _reset_e1_acceleration_rate ( ) { _reset_e_acceleration_rate ( 1 ) ; } <nl> - # if E_STEPPERS > 2 <nl> - void _reset_e2_acceleration_rate ( ) { _reset_e_acceleration_rate ( 2 ) ; } <nl> - # if E_STEPPERS > 3 <nl> - void _reset_e3_acceleration_rate ( ) { _reset_e_acceleration_rate ( 3 ) ; } <nl> - # if E_STEPPERS > 4 <nl> - void _reset_e4_acceleration_rate ( ) { _reset_e_acceleration_rate ( 4 ) ; } <nl> - # if E_STEPPERS > 5 <nl> - void _reset_e5_acceleration_rate ( ) { _reset_e_acceleration_rate ( 5 ) ; } <nl> - # endif / / E_STEPPERS > 5 <nl> - # endif / / E_STEPPERS > 4 <nl> - # endif / / E_STEPPERS > 3 <nl> - # endif / / E_STEPPERS > 2 <nl> - # endif <nl> - <nl> - void _planner_refresh_positioning ( ) { planner . refresh_positioning ( ) ; } <nl> - # if ENABLED ( DISTINCT_E_FACTORS ) <nl> - void _planner_refresh_e_positioning ( const uint8_t e ) { <nl> - if ( e = = active_extruder ) <nl> - _planner_refresh_positioning ( ) ; <nl> - else <nl> - planner . steps_to_mm [ E_AXIS + e ] = 1 . 0f / planner . settings . axis_steps_per_mm [ E_AXIS + e ] ; <nl> - } <nl> - void _planner_refresh_e0_positioning ( ) { _planner_refresh_e_positioning ( 0 ) ; } <nl> - void _planner_refresh_e1_positioning ( ) { _planner_refresh_e_positioning ( 1 ) ; } <nl> - # if E_STEPPERS > 2 <nl> - void _planner_refresh_e2_positioning ( ) { _planner_refresh_e_positioning ( 2 ) ; } <nl> - # if E_STEPPERS > 3 <nl> - void _planner_refresh_e3_positioning ( ) { _planner_refresh_e_positioning ( 3 ) ; } <nl> - # if E_STEPPERS > 4 <nl> - void _planner_refresh_e4_positioning ( ) { _planner_refresh_e_positioning ( 4 ) ; } <nl> - # if E_STEPPERS > 5 <nl> - void _planner_refresh_e5_positioning ( ) { _planner_refresh_e_positioning ( 5 ) ; } <nl> - # endif / / E_STEPPERS > 5 <nl> - # endif / / E_STEPPERS > 4 <nl> - # endif / / E_STEPPERS > 3 <nl> - # endif / / E_STEPPERS > 2 <nl> - # endif <nl> - <nl> - / / M203 / M205 Velocity options <nl> - void menu_advanced_velocity ( ) { <nl> - START_MENU ( ) ; <nl> - MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> - <nl> - / / M203 Max Feedrate <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_A , & planner . settings . max_feedrate_mm_s [ A_AXIS ] , 1 , 999 ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_B , & planner . settings . max_feedrate_mm_s [ B_AXIS ] , 1 , 999 ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_C , & planner . settings . max_feedrate_mm_s [ C_AXIS ] , 1 , 999 ) ; <nl> - <nl> - # if ENABLED ( DISTINCT_E_FACTORS ) <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E , & planner . settings . max_feedrate_mm_s [ E_AXIS + active_extruder ] , 1 , 999 ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E1 , & planner . settings . max_feedrate_mm_s [ E_AXIS ] , 1 , 999 ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E2 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 1 ] , 1 , 999 ) ; <nl> - # if E_STEPPERS > 2 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E3 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 2 ] , 1 , 999 ) ; <nl> - # if E_STEPPERS > 3 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E4 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 3 ] , 1 , 999 ) ; <nl> - # if E_STEPPERS > 4 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E5 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 4 ] , 1 , 999 ) ; <nl> - # if E_STEPPERS > 5 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E6 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 5 ] , 1 , 999 ) ; <nl> - # endif / / E_STEPPERS > 5 <nl> - # endif / / E_STEPPERS > 4 <nl> - # endif / / E_STEPPERS > 3 <nl> - # endif / / E_STEPPERS > 2 <nl> - # else <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E , & planner . settings . max_feedrate_mm_s [ E_AXIS ] , 1 , 999 ) ; <nl> - # endif <nl> - <nl> - / / M205 S Min Feedrate <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMIN , & planner . settings . min_feedrate_mm_s , 0 , 999 ) ; <nl> - <nl> - / / M205 T Min Travel Feedrate <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VTRAV_MIN , & planner . settings . min_travel_feedrate_mm_s , 0 , 999 ) ; <nl> - <nl> - END_MENU ( ) ; <nl> - } <nl> - <nl> - / / M201 / M204 Accelerations <nl> - void menu_advanced_acceleration ( ) { <nl> - START_MENU ( ) ; <nl> - MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> - <nl> - / / M204 P Acceleration <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float5 , MSG_ACC , & planner . settings . acceleration , 10 , 99000 ) ; <nl> - <nl> - / / M204 R Retract Acceleration <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float5 , MSG_A_RETRACT , & planner . settings . retract_acceleration , 100 , 99000 ) ; <nl> - <nl> - / / M204 T Travel Acceleration <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float5 , MSG_A_TRAVEL , & planner . settings . travel_acceleration , 100 , 99000 ) ; <nl> - <nl> - / / M201 settings <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_A , & planner . settings . max_acceleration_mm_per_s2 [ A_AXIS ] , 100 , 99000 , _reset_acceleration_rates ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_B , & planner . settings . max_acceleration_mm_per_s2 [ B_AXIS ] , 100 , 99000 , _reset_acceleration_rates ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_C , & planner . settings . max_acceleration_mm_per_s2 [ C_AXIS ] , 10 , 99000 , _reset_acceleration_rates ) ; <nl> - <nl> - # if ENABLED ( DISTINCT_E_FACTORS ) <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + active_extruder ] , 100 , 99000 , _reset_acceleration_rates ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E1 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS ] , 100 , 99000 , _reset_e0_acceleration_rate ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E2 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 1 ] , 100 , 99000 , _reset_e1_acceleration_rate ) ; <nl> - # if E_STEPPERS > 2 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E3 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 2 ] , 100 , 99000 , _reset_e2_acceleration_rate ) ; <nl> - # if E_STEPPERS > 3 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E4 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 3 ] , 100 , 99000 , _reset_e3_acceleration_rate ) ; <nl> - # if E_STEPPERS > 4 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E5 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 4 ] , 100 , 99000 , _reset_e4_acceleration_rate ) ; <nl> - # if E_STEPPERS > 5 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E6 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 5 ] , 100 , 99000 , _reset_e5_acceleration_rate ) ; <nl> - # endif / / E_STEPPERS > 5 <nl> - # endif / / E_STEPPERS > 4 <nl> - # endif / / E_STEPPERS > 3 <nl> - # endif / / E_STEPPERS > 2 <nl> - # else <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS ] , 100 , 99000 , _reset_acceleration_rates ) ; <nl> - # endif <nl> - <nl> - END_MENU ( ) ; <nl> - } <nl> - <nl> - / / M205 Jerk <nl> - void menu_advanced_jerk ( ) { <nl> - START_MENU ( ) ; <nl> - MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> - <nl> - # if ENABLED ( JUNCTION_DEVIATION ) <nl> - # if ENABLED ( LIN_ADVANCE ) <nl> - MENU_ITEM_EDIT_CALLBACK ( float43 , MSG_JUNCTION_DEVIATION , & planner . junction_deviation_mm , 0 . 01f , 0 . 3f , planner . recalculate_max_e_jerk ) ; <nl> - # else <nl> - MENU_ITEM_EDIT ( float43 , MSG_JUNCTION_DEVIATION , & planner . junction_deviation_mm , 0 . 01f , 0 . 3f ) ; <nl> - # endif <nl> - # endif <nl> - # if HAS_CLASSIC_JERK <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VA_JERK , & planner . max_jerk [ A_AXIS ] , 1 , 990 ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VB_JERK , & planner . max_jerk [ B_AXIS ] , 1 , 990 ) ; <nl> - # if ENABLED ( DELTA ) <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VC_JERK , & planner . max_jerk [ C_AXIS ] , 1 , 990 ) ; <nl> - # else <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float52sign , MSG_VC_JERK , & planner . max_jerk [ C_AXIS ] , 0 . 1f , 990 ) ; <nl> - # endif <nl> - # if DISABLED ( JUNCTION_DEVIATION ) | | DISABLED ( LIN_ADVANCE ) <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VE_JERK , & planner . max_jerk [ E_AXIS ] , 1 , 990 ) ; <nl> - # endif <nl> - # endif <nl> - <nl> - END_MENU ( ) ; <nl> - } <nl> - <nl> - / / M92 Steps - per - mm <nl> - void menu_advanced_steps_per_mm ( ) { <nl> - START_MENU ( ) ; <nl> - MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> - <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_ASTEPS , & planner . settings . axis_steps_per_mm [ A_AXIS ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_BSTEPS , & planner . settings . axis_steps_per_mm [ B_AXIS ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_CSTEPS , & planner . settings . axis_steps_per_mm [ C_AXIS ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> - <nl> - # if ENABLED ( DISTINCT_E_FACTORS ) <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_ESTEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + active_extruder ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E1STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS ] , 5 , 9999 , _planner_refresh_e0_positioning ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E2STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 1 ] , 5 , 9999 , _planner_refresh_e1_positioning ) ; <nl> - # if E_STEPPERS > 2 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E3STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 2 ] , 5 , 9999 , _planner_refresh_e2_positioning ) ; <nl> - # if E_STEPPERS > 3 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E4STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 3 ] , 5 , 9999 , _planner_refresh_e3_positioning ) ; <nl> - # if E_STEPPERS > 4 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E5STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 4 ] , 5 , 9999 , _planner_refresh_e4_positioning ) ; <nl> - # if E_STEPPERS > 5 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E6STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 5 ] , 5 , 9999 , _planner_refresh_e5_positioning ) ; <nl> - # endif / / E_STEPPERS > 5 <nl> - # endif / / E_STEPPERS > 4 <nl> - # endif / / E_STEPPERS > 3 <nl> - # endif / / E_STEPPERS > 2 <nl> - # else <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_ESTEPS , & planner . settings . axis_steps_per_mm [ E_AXIS ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> - # endif <nl> - <nl> - END_MENU ( ) ; <nl> - } <nl> - <nl> - # endif / / ! SLIM_LCD_MENUS <nl> - <nl> - / * * <nl> - * <nl> - * " Advanced Settings " submenu <nl> - * <nl> - * / <nl> - <nl> - # if HAS_M206_COMMAND <nl> - / * * <nl> - * Set the home offset based on the current_position <nl> - * / <nl> - void lcd_set_home_offsets ( ) { <nl> - / / M428 Command <nl> - enqueue_and_echo_commands_P ( PSTR ( " M428 " ) ) ; <nl> - lcd_return_to_status ( ) ; <nl> - } <nl> - # endif <nl> - <nl> - # if ENABLED ( SD_FIRMWARE_UPDATE ) <nl> - / * * <nl> - * Toggle the SD Firmware Update state in EEPROM <nl> - * / <nl> - static void _lcd_toggle_sd_update ( ) { <nl> - const bool new_state = ! settings . sd_update_status ( ) ; <nl> - lcd_completion_feedback ( settings . set_sd_update_status ( new_state ) ) ; <nl> - lcd_return_to_status ( ) ; <nl> - if ( new_state ) LCD_MESSAGEPGM ( MSG_RESET_PRINTER ) ; else lcd_reset_status ( ) ; <nl> - } <nl> - # endif <nl> - <nl> - void menu_advanced_settings ( ) { <nl> - START_MENU ( ) ; <nl> - MENU_BACK ( MSG_CONFIGURATION ) ; <nl> - <nl> - # if ENABLED ( BABYSTEP_ZPROBE_OFFSET ) <nl> - MENU_ITEM ( submenu , MSG_ZPROBE_ZOFFSET , lcd_babystep_zoffset ) ; <nl> - # elif HAS_BED_PROBE <nl> - MENU_ITEM_EDIT ( float52 , MSG_ZPROBE_ZOFFSET , & zprobe_zoffset , Z_PROBE_OFFSET_RANGE_MIN , Z_PROBE_OFFSET_RANGE_MAX ) ; <nl> - # endif <nl> - <nl> - # if DISABLED ( SLIM_LCD_MENUS ) <nl> - <nl> - # if HAS_M206_COMMAND <nl> - / / <nl> - / / Set Home Offsets <nl> - / / <nl> - MENU_ITEM ( function , MSG_SET_HOME_OFFSETS , lcd_set_home_offsets ) ; <nl> - # endif <nl> - <nl> - / / M203 / M205 - Feedrate items <nl> - MENU_ITEM ( submenu , MSG_VELOCITY , menu_advanced_velocity ) ; <nl> - <nl> - / / M201 - Acceleration items <nl> - MENU_ITEM ( submenu , MSG_ACCELERATION , menu_advanced_acceleration ) ; <nl> - <nl> - / / M205 - Max Jerk <nl> - MENU_ITEM ( submenu , MSG_JERK , menu_advanced_jerk ) ; <nl> - <nl> - if ( ! printer_busy ( ) ) { <nl> - / / M92 - Steps Per mm <nl> - MENU_ITEM ( submenu , MSG_STEPS_PER_MM , menu_advanced_steps_per_mm ) ; <nl> - } <nl> - <nl> - # endif / / ! SLIM_LCD_MENUS <nl> - <nl> - MENU_ITEM ( submenu , MSG_TEMPERATURE , menu_advanced_temperature ) ; <nl> - <nl> - # if DISABLED ( NO_VOLUMETRICS ) | | ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> - MENU_ITEM ( submenu , MSG_FILAMENT , menu_advanced_filament ) ; <nl> - # elif ENABLED ( LIN_ADVANCE ) <nl> - # if EXTRUDERS = = 1 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K , & planner . extruder_advance_K [ 0 ] , 0 , 999 ) ; <nl> - # elif EXTRUDERS > 1 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E1 , & planner . extruder_advance_K [ 0 ] , 0 , 999 ) ; <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E2 , & planner . extruder_advance_K [ 1 ] , 0 , 999 ) ; <nl> - # if EXTRUDERS > 2 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E3 , & planner . extruder_advance_K [ 2 ] , 0 , 999 ) ; <nl> - # if EXTRUDERS > 3 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E4 , & planner . extruder_advance_K [ 3 ] , 0 , 999 ) ; <nl> - # if EXTRUDERS > 4 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E5 , & planner . extruder_advance_K [ 4 ] , 0 , 999 ) ; <nl> - # if EXTRUDERS > 5 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E6 , & planner . extruder_advance_K [ 5 ] , 0 , 999 ) ; <nl> - # endif / / EXTRUDERS > 5 <nl> - # endif / / EXTRUDERS > 4 <nl> - # endif / / EXTRUDERS > 3 <nl> - # endif / / EXTRUDERS > 2 <nl> - # endif / / EXTRUDERS > 1 <nl> - # endif <nl> - <nl> - / / M540 S - Abort on endstop hit when SD printing <nl> - # if ENABLED ( ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ) <nl> - MENU_ITEM_EDIT ( bool , MSG_ENDSTOP_ABORT , & planner . abort_on_endstop_hit ) ; <nl> - # endif <nl> - <nl> - / / <nl> - / / BLTouch Self - Test and Reset <nl> - / / <nl> - # if ENABLED ( BLTOUCH ) <nl> - MENU_ITEM ( gcode , MSG_BLTOUCH_SELFTEST , PSTR ( " M280 P " STRINGIFY ( Z_PROBE_SERVO_NR ) " S " STRINGIFY ( BLTOUCH_SELFTEST ) ) ) ; <nl> - if ( ! endstops . z_probe_enabled & & TEST_BLTOUCH ( ) ) <nl> - MENU_ITEM ( gcode , MSG_BLTOUCH_RESET , PSTR ( " M280 P " STRINGIFY ( Z_PROBE_SERVO_NR ) " S " STRINGIFY ( BLTOUCH_RESET ) ) ) ; <nl> - # endif <nl> - <nl> - # if ENABLED ( SD_FIRMWARE_UPDATE ) <nl> - bool sd_update_state = settings . sd_update_status ( ) ; <nl> - MENU_ITEM_EDIT_CALLBACK ( bool , MSG_SD_UPDATE , & sd_update_state , _lcd_toggle_sd_update ) ; <nl> - # endif <nl> - <nl> - # if ENABLED ( EEPROM_SETTINGS ) & & DISABLED ( SLIM_LCD_MENUS ) <nl> - MENU_ITEM ( submenu , MSG_INIT_EEPROM , lcd_init_eeprom_confirm ) ; <nl> - # endif <nl> - <nl> - END_MENU ( ) ; <nl> - } <nl> - <nl> - # if DISABLED ( NO_VOLUMETRICS ) | | ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> - / * * <nl> - * <nl> - * " Advanced Settings " > " Filament " submenu <nl> - * <nl> - * / <nl> - void menu_advanced_filament ( ) { <nl> - START_MENU ( ) ; <nl> - MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> - <nl> - # if ENABLED ( LIN_ADVANCE ) <nl> - # if EXTRUDERS = = 1 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K , & planner . extruder_advance_K [ 0 ] , 0 , 999 ) ; <nl> - # elif EXTRUDERS > 1 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E1 , & planner . extruder_advance_K [ 0 ] , 0 , 999 ) ; <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E2 , & planner . extruder_advance_K [ 1 ] , 0 , 999 ) ; <nl> - # if EXTRUDERS > 2 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E3 , & planner . extruder_advance_K [ 2 ] , 0 , 999 ) ; <nl> - # if EXTRUDERS > 3 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E4 , & planner . extruder_advance_K [ 3 ] , 0 , 999 ) ; <nl> - # if EXTRUDERS > 4 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E5 , & planner . extruder_advance_K [ 4 ] , 0 , 999 ) ; <nl> - # if EXTRUDERS > 5 <nl> - MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E6 , & planner . extruder_advance_K [ 5 ] , 0 , 999 ) ; <nl> - # endif / / EXTRUDERS > 5 <nl> - # endif / / EXTRUDERS > 4 <nl> - # endif / / EXTRUDERS > 3 <nl> - # endif / / EXTRUDERS > 2 <nl> - # endif / / EXTRUDERS > 1 <nl> - # endif <nl> - <nl> - # if DISABLED ( NO_VOLUMETRICS ) <nl> - MENU_ITEM_EDIT_CALLBACK ( bool , MSG_VOLUMETRIC_ENABLED , & parser . volumetric_enabled , planner . calculate_volumetric_multipliers ) ; <nl> - <nl> - if ( parser . volumetric_enabled ) { <nl> - # if EXTRUDERS = = 1 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM , & planner . filament_size [ 0 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> - # else / / EXTRUDERS > 1 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM , & planner . filament_size [ active_extruder ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E1 , & planner . filament_size [ 0 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E2 , & planner . filament_size [ 1 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> - # if EXTRUDERS > 2 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E3 , & planner . filament_size [ 2 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> - # if EXTRUDERS > 3 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E4 , & planner . filament_size [ 3 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> - # if EXTRUDERS > 4 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E5 , & planner . filament_size [ 4 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> - # if EXTRUDERS > 5 <nl> - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E6 , & planner . filament_size [ 5 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> - # endif / / EXTRUDERS > 5 <nl> - # endif / / EXTRUDERS > 4 <nl> - # endif / / EXTRUDERS > 3 <nl> - # endif / / EXTRUDERS > 2 <nl> - # endif / / EXTRUDERS > 1 <nl> - } <nl> - # endif <nl> - <nl> - # if ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> - constexpr float extrude_maxlength = <nl> - # if ENABLED ( PREVENT_LENGTHY_EXTRUDE ) <nl> - EXTRUDE_MAXLENGTH <nl> - # else <nl> - 999 <nl> - # endif <nl> - ; <nl> - <nl> - # if EXTRUDERS = = 1 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD , & fc_settings [ 0 ] . unload_length , 0 , extrude_maxlength ) ; <nl> - # else / / EXTRUDERS > 1 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD , & fc_settings [ active_extruder ] . unload_length , 0 , extrude_maxlength ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E1 , & fc_settings [ 0 ] . unload_length , 0 , extrude_maxlength ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E2 , & fc_settings [ 1 ] . unload_length , 0 , extrude_maxlength ) ; <nl> - # if EXTRUDERS > 2 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E3 , & fc_settings [ 2 ] . unload_length , 0 , extrude_maxlength ) ; <nl> - # if EXTRUDERS > 3 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E4 , & fc_settings [ 3 ] . unload_length , 0 , extrude_maxlength ) ; <nl> - # if EXTRUDERS > 4 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E5 , & fc_settings [ 4 ] . unload_length , 0 , extrude_maxlength ) ; <nl> - # if EXTRUDERS > 5 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E6 , & fc_settings [ 5 ] . unload_length , 0 , extrude_maxlength ) ; <nl> - # endif / / EXTRUDERS > 5 <nl> - # endif / / EXTRUDERS > 4 <nl> - # endif / / EXTRUDERS > 3 <nl> - # endif / / EXTRUDERS > 2 <nl> - # endif / / EXTRUDERS > 1 <nl> - <nl> - # if EXTRUDERS = = 1 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD , & fc_settings [ 0 ] . load_length , 0 , extrude_maxlength ) ; <nl> - # else / / EXTRUDERS > 1 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD , & fc_settings [ active_extruder ] . load_length , 0 , extrude_maxlength ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E1 , & fc_settings [ 0 ] . load_length , 0 , extrude_maxlength ) ; <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E2 , & fc_settings [ 1 ] . load_length , 0 , extrude_maxlength ) ; <nl> - # if EXTRUDERS > 2 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E3 , & fc_settings [ 2 ] . load_length , 0 , extrude_maxlength ) ; <nl> - # if EXTRUDERS > 3 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E4 , & fc_settings [ 3 ] . load_length , 0 , extrude_maxlength ) ; <nl> - # if EXTRUDERS > 4 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E5 , & fc_settings [ 4 ] . load_length , 0 , extrude_maxlength ) ; <nl> - # if EXTRUDERS > 5 <nl> - MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E6 , & fc_settings [ 5 ] . load_length , 0 , extrude_maxlength ) ; <nl> - # endif / / EXTRUDERS > 5 <nl> - # endif / / EXTRUDERS > 4 <nl> - # endif / / EXTRUDERS > 3 <nl> - # endif / / EXTRUDERS > 2 <nl> - # endif / / EXTRUDERS > 1 <nl> - # endif <nl> - <nl> - END_MENU ( ) ; <nl> - } <nl> - # endif / / ! NO_VOLUMETRICS | | ADVANCED_PAUSE_FEATURE <nl> - <nl> # if ENABLED ( SDSUPPORT ) <nl> <nl> # if ! PIN_EXISTS ( SD_DETECT ) <nl> new file mode 100644 <nl> index 00000000000 . . 849e82f840e <nl> mmm / dev / null <nl> ppp b / Marlin / src / lcd / menu / menu_advanced . cpp <nl> <nl> + / * * <nl> + * Marlin 3D Printer Firmware <nl> + * Copyright ( C ) 2016 MarlinFirmware [ https : / / github . com / MarlinFirmware / Marlin ] <nl> + * <nl> + * Based on Sprinter and grbl . <nl> + * Copyright ( C ) 2011 Camiel Gubbels / Erik van der Zalm <nl> + * <nl> + * This program 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> + * This program 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> + * You should have received a copy of the GNU General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + <nl> + / / <nl> + / / Advanced Settings Menus <nl> + / / <nl> + <nl> + # include " . . / . . / inc / MarlinConfigPre . h " <nl> + <nl> + # if HAS_LCD_MENU <nl> + <nl> + # include " menu . h " <nl> + # include " . . / . . / module / planner . h " <nl> + <nl> + # if DISABLED ( NO_VOLUMETRICS ) <nl> + # include " . . / . . / gcode / parser . h " <nl> + # endif <nl> + <nl> + # if HAS_BED_PROBE <nl> + # include " . . / . . / module / probe . h " <nl> + # if ENABLED ( BLTOUCH ) <nl> + # include " . . / . . / module / endstops . h " <nl> + # endif <nl> + # endif <nl> + <nl> + # if ENABLED ( PIDTEMP ) <nl> + # include " . . / . . / module / temperature . h " <nl> + # endif <nl> + <nl> + # if HAS_M206_COMMAND <nl> + / / <nl> + / / Set the home offset based on the current_position <nl> + / / <nl> + void _lcd_set_home_offsets ( ) { <nl> + enqueue_and_echo_commands_P ( PSTR ( " M428 " ) ) ; <nl> + lcd_return_to_status ( ) ; <nl> + } <nl> + # endif <nl> + <nl> + # if ENABLED ( SD_FIRMWARE_UPDATE ) <nl> + <nl> + # include " . . / . . / module / configuration_store . h " <nl> + <nl> + / / <nl> + / / Toggle the SD Firmware Update state in EEPROM <nl> + / / <nl> + static void _lcd_toggle_sd_update ( ) { <nl> + const bool new_state = ! settings . sd_update_status ( ) ; <nl> + lcd_completion_feedback ( settings . set_sd_update_status ( new_state ) ) ; <nl> + lcd_return_to_status ( ) ; <nl> + if ( new_state ) LCD_MESSAGEPGM ( MSG_RESET_PRINTER ) ; else lcd_reset_status ( ) ; <nl> + } <nl> + # endif <nl> + <nl> + # if DISABLED ( NO_VOLUMETRICS ) | | ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> + / / <nl> + / / Advanced Settings > Filament <nl> + / / <nl> + void menu_advanced_filament ( ) { <nl> + START_MENU ( ) ; <nl> + MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> + <nl> + # if ENABLED ( LIN_ADVANCE ) <nl> + # if EXTRUDERS = = 1 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K , & planner . extruder_advance_K [ 0 ] , 0 , 999 ) ; <nl> + # elif EXTRUDERS > 1 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E1 , & planner . extruder_advance_K [ 0 ] , 0 , 999 ) ; <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E2 , & planner . extruder_advance_K [ 1 ] , 0 , 999 ) ; <nl> + # if EXTRUDERS > 2 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E3 , & planner . extruder_advance_K [ 2 ] , 0 , 999 ) ; <nl> + # if EXTRUDERS > 3 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E4 , & planner . extruder_advance_K [ 3 ] , 0 , 999 ) ; <nl> + # if EXTRUDERS > 4 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E5 , & planner . extruder_advance_K [ 4 ] , 0 , 999 ) ; <nl> + # if EXTRUDERS > 5 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E6 , & planner . extruder_advance_K [ 5 ] , 0 , 999 ) ; <nl> + # endif / / EXTRUDERS > 5 <nl> + # endif / / EXTRUDERS > 4 <nl> + # endif / / EXTRUDERS > 3 <nl> + # endif / / EXTRUDERS > 2 <nl> + # endif / / EXTRUDERS > 1 <nl> + # endif <nl> + <nl> + # if DISABLED ( NO_VOLUMETRICS ) <nl> + MENU_ITEM_EDIT_CALLBACK ( bool , MSG_VOLUMETRIC_ENABLED , & parser . volumetric_enabled , planner . calculate_volumetric_multipliers ) ; <nl> + <nl> + if ( parser . volumetric_enabled ) { <nl> + # if EXTRUDERS = = 1 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM , & planner . filament_size [ 0 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> + # else / / EXTRUDERS > 1 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM , & planner . filament_size [ active_extruder ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E1 , & planner . filament_size [ 0 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E2 , & planner . filament_size [ 1 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> + # if EXTRUDERS > 2 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E3 , & planner . filament_size [ 2 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> + # if EXTRUDERS > 3 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E4 , & planner . filament_size [ 3 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> + # if EXTRUDERS > 4 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E5 , & planner . filament_size [ 4 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> + # if EXTRUDERS > 5 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_DIAM MSG_DIAM_E6 , & planner . filament_size [ 5 ] , 1 . 5f , 3 . 25f , planner . calculate_volumetric_multipliers ) ; <nl> + # endif / / EXTRUDERS > 5 <nl> + # endif / / EXTRUDERS > 4 <nl> + # endif / / EXTRUDERS > 3 <nl> + # endif / / EXTRUDERS > 2 <nl> + # endif / / EXTRUDERS > 1 <nl> + } <nl> + # endif <nl> + <nl> + # if ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> + constexpr float extrude_maxlength = <nl> + # if ENABLED ( PREVENT_LENGTHY_EXTRUDE ) <nl> + EXTRUDE_MAXLENGTH <nl> + # else <nl> + 999 <nl> + # endif <nl> + ; <nl> + <nl> + # if EXTRUDERS = = 1 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD , & fc_settings [ 0 ] . unload_length , 0 , extrude_maxlength ) ; <nl> + # else / / EXTRUDERS > 1 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD , & fc_settings [ active_extruder ] . unload_length , 0 , extrude_maxlength ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E1 , & fc_settings [ 0 ] . unload_length , 0 , extrude_maxlength ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E2 , & fc_settings [ 1 ] . unload_length , 0 , extrude_maxlength ) ; <nl> + # if EXTRUDERS > 2 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E3 , & fc_settings [ 2 ] . unload_length , 0 , extrude_maxlength ) ; <nl> + # if EXTRUDERS > 3 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E4 , & fc_settings [ 3 ] . unload_length , 0 , extrude_maxlength ) ; <nl> + # if EXTRUDERS > 4 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E5 , & fc_settings [ 4 ] . unload_length , 0 , extrude_maxlength ) ; <nl> + # if EXTRUDERS > 5 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_UNLOAD MSG_DIAM_E6 , & fc_settings [ 5 ] . unload_length , 0 , extrude_maxlength ) ; <nl> + # endif / / EXTRUDERS > 5 <nl> + # endif / / EXTRUDERS > 4 <nl> + # endif / / EXTRUDERS > 3 <nl> + # endif / / EXTRUDERS > 2 <nl> + # endif / / EXTRUDERS > 1 <nl> + <nl> + # if EXTRUDERS = = 1 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD , & fc_settings [ 0 ] . load_length , 0 , extrude_maxlength ) ; <nl> + # else / / EXTRUDERS > 1 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD , & fc_settings [ active_extruder ] . load_length , 0 , extrude_maxlength ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E1 , & fc_settings [ 0 ] . load_length , 0 , extrude_maxlength ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E2 , & fc_settings [ 1 ] . load_length , 0 , extrude_maxlength ) ; <nl> + # if EXTRUDERS > 2 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E3 , & fc_settings [ 2 ] . load_length , 0 , extrude_maxlength ) ; <nl> + # if EXTRUDERS > 3 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E4 , & fc_settings [ 3 ] . load_length , 0 , extrude_maxlength ) ; <nl> + # if EXTRUDERS > 4 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E5 , & fc_settings [ 4 ] . load_length , 0 , extrude_maxlength ) ; <nl> + # if EXTRUDERS > 5 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_FILAMENT_LOAD MSG_DIAM_E6 , & fc_settings [ 5 ] . load_length , 0 , extrude_maxlength ) ; <nl> + # endif / / EXTRUDERS > 5 <nl> + # endif / / EXTRUDERS > 4 <nl> + # endif / / EXTRUDERS > 3 <nl> + # endif / / EXTRUDERS > 2 <nl> + # endif / / EXTRUDERS > 1 <nl> + # endif <nl> + <nl> + END_MENU ( ) ; <nl> + } <nl> + <nl> + # endif / / ! NO_VOLUMETRICS | | ADVANCED_PAUSE_FEATURE <nl> + <nl> + / / <nl> + / / Advanced Settings > Temperature helpers <nl> + / / <nl> + <nl> + # if ENABLED ( PID_AUTOTUNE_MENU ) <nl> + <nl> + # if ENABLED ( PIDTEMP ) <nl> + int16_t autotune_temp [ HOTENDS ] = ARRAY_BY_HOTENDS1 ( 150 ) ; <nl> + # endif <nl> + <nl> + # if ENABLED ( PIDTEMPBED ) <nl> + int16_t autotune_temp_bed = 70 ; <nl> + # endif <nl> + <nl> + void _lcd_autotune ( const int16_t e ) { <nl> + char cmd [ 30 ] ; <nl> + sprintf_P ( cmd , PSTR ( " M303 U1 E % i S % i " ) , e , <nl> + # if HAS_PID_FOR_BOTH <nl> + e < 0 ? autotune_temp_bed : autotune_temp [ e ] <nl> + # elif ENABLED ( PIDTEMPBED ) <nl> + autotune_temp_bed <nl> + # else <nl> + autotune_temp [ e ] <nl> + # endif <nl> + ) ; <nl> + lcd_enqueue_command ( cmd ) ; <nl> + } <nl> + <nl> + # endif / / PID_AUTOTUNE_MENU <nl> + <nl> + # if ENABLED ( PIDTEMP ) <nl> + <nl> + float raw_Ki , raw_Kd ; / / place - holders for Ki and Kd edits <nl> + <nl> + / / Helpers for editing PID Ki & Kd values <nl> + / / grab the PID value out of the temp variable ; scale it ; then update the PID driver <nl> + void copy_and_scalePID_i ( int16_t e ) { <nl> + # if DISABLED ( PID_PARAMS_PER_HOTEND ) | | HOTENDS = = 1 <nl> + UNUSED ( e ) ; <nl> + # endif <nl> + PID_PARAM ( Ki , e ) = scalePID_i ( raw_Ki ) ; <nl> + thermalManager . updatePID ( ) ; <nl> + } <nl> + void copy_and_scalePID_d ( int16_t e ) { <nl> + # if DISABLED ( PID_PARAMS_PER_HOTEND ) | | HOTENDS = = 1 <nl> + UNUSED ( e ) ; <nl> + # endif <nl> + PID_PARAM ( Kd , e ) = scalePID_d ( raw_Kd ) ; <nl> + thermalManager . updatePID ( ) ; <nl> + } <nl> + # define _DEFINE_PIDTEMP_BASE_FUNCS ( N ) \ <nl> + void copy_and_scalePID_i_E # # N ( ) { copy_and_scalePID_i ( N ) ; } \ <nl> + void copy_and_scalePID_d_E # # N ( ) { copy_and_scalePID_d ( N ) ; } <nl> + <nl> + # if ENABLED ( PID_AUTOTUNE_MENU ) <nl> + # define DEFINE_PIDTEMP_FUNCS ( N ) \ <nl> + _DEFINE_PIDTEMP_BASE_FUNCS ( N ) ; \ <nl> + void lcd_autotune_callback_E # # N ( ) { _lcd_autotune ( N ) ; } typedef void _pid_ # # N # # _void <nl> + # else <nl> + # define DEFINE_PIDTEMP_FUNCS ( N ) _DEFINE_PIDTEMP_BASE_FUNCS ( N ) typedef void _pid_ # # N # # _void <nl> + # endif <nl> + <nl> + DEFINE_PIDTEMP_FUNCS ( 0 ) ; <nl> + # if ENABLED ( PID_PARAMS_PER_HOTEND ) <nl> + # if HOTENDS > 1 <nl> + DEFINE_PIDTEMP_FUNCS ( 1 ) ; <nl> + # if HOTENDS > 2 <nl> + DEFINE_PIDTEMP_FUNCS ( 2 ) ; <nl> + # if HOTENDS > 3 <nl> + DEFINE_PIDTEMP_FUNCS ( 3 ) ; <nl> + # if HOTENDS > 4 <nl> + DEFINE_PIDTEMP_FUNCS ( 4 ) ; <nl> + # if HOTENDS > 5 <nl> + DEFINE_PIDTEMP_FUNCS ( 5 ) ; <nl> + # endif / / HOTENDS > 5 <nl> + # endif / / HOTENDS > 4 <nl> + # endif / / HOTENDS > 3 <nl> + # endif / / HOTENDS > 2 <nl> + # endif / / HOTENDS > 1 <nl> + # endif / / PID_PARAMS_PER_HOTEND <nl> + <nl> + # endif / / PIDTEMP <nl> + <nl> + / / <nl> + / / Advanced Settings > Temperature <nl> + / / <nl> + void menu_advanced_temperature ( ) { <nl> + START_MENU ( ) ; <nl> + MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> + / / <nl> + / / Autotemp , Min , Max , Fact <nl> + / / <nl> + # if ENABLED ( AUTOTEMP ) & & HAS_TEMP_HOTEND <nl> + MENU_ITEM_EDIT ( bool , MSG_AUTOTEMP , & planner . autotemp_enabled ) ; <nl> + MENU_ITEM_EDIT ( float3 , MSG_MIN , & planner . autotemp_min , 0 , float ( HEATER_0_MAXTEMP ) - 15 ) ; <nl> + MENU_ITEM_EDIT ( float3 , MSG_MAX , & planner . autotemp_max , 0 , float ( HEATER_0_MAXTEMP ) - 15 ) ; <nl> + MENU_ITEM_EDIT ( float52 , MSG_FACTOR , & planner . autotemp_factor , 0 , 1 ) ; <nl> + # endif <nl> + <nl> + / / <nl> + / / PID - P , PID - I , PID - D , PID - C , PID Autotune <nl> + / / PID - P E1 , PID - I E1 , PID - D E1 , PID - C E1 , PID Autotune E1 <nl> + / / PID - P E2 , PID - I E2 , PID - D E2 , PID - C E2 , PID Autotune E2 <nl> + / / PID - P E3 , PID - I E3 , PID - D E3 , PID - C E3 , PID Autotune E3 <nl> + / / PID - P E4 , PID - I E4 , PID - D E4 , PID - C E4 , PID Autotune E4 <nl> + / / PID - P E5 , PID - I E5 , PID - D E5 , PID - C E5 , PID Autotune E5 <nl> + / / <nl> + # if ENABLED ( PIDTEMP ) <nl> + <nl> + # define _PID_BASE_MENU_ITEMS ( ELABEL , eindex ) \ <nl> + raw_Ki = unscalePID_i ( PID_PARAM ( Ki , eindex ) ) ; \ <nl> + raw_Kd = unscalePID_d ( PID_PARAM ( Kd , eindex ) ) ; \ <nl> + MENU_ITEM_EDIT ( float52sign , MSG_PID_P ELABEL , & PID_PARAM ( Kp , eindex ) , 1 , 9990 ) ; \ <nl> + MENU_ITEM_EDIT_CALLBACK ( float52sign , MSG_PID_I ELABEL , & raw_Ki , 0 . 01f , 9990 , copy_and_scalePID_i_E # # eindex ) ; \ <nl> + MENU_ITEM_EDIT_CALLBACK ( float52sign , MSG_PID_D ELABEL , & raw_Kd , 1 , 9990 , copy_and_scalePID_d_E # # eindex ) <nl> + <nl> + # if ENABLED ( PID_EXTRUSION_SCALING ) <nl> + # define _PID_MENU_ITEMS ( ELABEL , eindex ) \ <nl> + _PID_BASE_MENU_ITEMS ( ELABEL , eindex ) ; \ <nl> + MENU_ITEM_EDIT ( float3 , MSG_PID_C ELABEL , & PID_PARAM ( Kc , eindex ) , 1 , 9990 ) <nl> + # else <nl> + # define _PID_MENU_ITEMS ( ELABEL , eindex ) _PID_BASE_MENU_ITEMS ( ELABEL , eindex ) <nl> + # endif <nl> + <nl> + # if ENABLED ( PID_AUTOTUNE_MENU ) <nl> + # define PID_MENU_ITEMS ( ELABEL , eindex ) \ <nl> + _PID_MENU_ITEMS ( ELABEL , eindex ) ; \ <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( int3 , MSG_PID_AUTOTUNE ELABEL , & autotune_temp [ eindex ] , 150 , heater_maxtemp [ eindex ] - 15 , lcd_autotune_callback_E # # eindex ) <nl> + # else <nl> + # define PID_MENU_ITEMS ( ELABEL , eindex ) _PID_MENU_ITEMS ( ELABEL , eindex ) <nl> + # endif <nl> + <nl> + # if ENABLED ( PID_PARAMS_PER_HOTEND ) & & HOTENDS > 1 <nl> + PID_MENU_ITEMS ( " " MSG_E1 , 0 ) ; <nl> + PID_MENU_ITEMS ( " " MSG_E2 , 1 ) ; <nl> + # if HOTENDS > 2 <nl> + PID_MENU_ITEMS ( " " MSG_E3 , 2 ) ; <nl> + # if HOTENDS > 3 <nl> + PID_MENU_ITEMS ( " " MSG_E4 , 3 ) ; <nl> + # if HOTENDS > 4 <nl> + PID_MENU_ITEMS ( " " MSG_E5 , 4 ) ; <nl> + # if HOTENDS > 5 <nl> + PID_MENU_ITEMS ( " " MSG_E6 , 5 ) ; <nl> + # endif / / HOTENDS > 5 <nl> + # endif / / HOTENDS > 4 <nl> + # endif / / HOTENDS > 3 <nl> + # endif / / HOTENDS > 2 <nl> + # else / / ! PID_PARAMS_PER_HOTEND | | HOTENDS = = 1 <nl> + PID_MENU_ITEMS ( " " , 0 ) ; <nl> + # endif / / ! PID_PARAMS_PER_HOTEND | | HOTENDS = = 1 <nl> + <nl> + # endif / / PIDTEMP <nl> + <nl> + END_MENU ( ) ; <nl> + } <nl> + <nl> + # if DISABLED ( SLIM_LCD_MENUS ) <nl> + <nl> + void _reset_acceleration_rates ( ) { planner . reset_acceleration_rates ( ) ; } <nl> + # if ENABLED ( DISTINCT_E_FACTORS ) <nl> + void _reset_e_acceleration_rate ( const uint8_t e ) { if ( e = = active_extruder ) _reset_acceleration_rates ( ) ; } <nl> + void _reset_e0_acceleration_rate ( ) { _reset_e_acceleration_rate ( 0 ) ; } <nl> + void _reset_e1_acceleration_rate ( ) { _reset_e_acceleration_rate ( 1 ) ; } <nl> + # if E_STEPPERS > 2 <nl> + void _reset_e2_acceleration_rate ( ) { _reset_e_acceleration_rate ( 2 ) ; } <nl> + # if E_STEPPERS > 3 <nl> + void _reset_e3_acceleration_rate ( ) { _reset_e_acceleration_rate ( 3 ) ; } <nl> + # if E_STEPPERS > 4 <nl> + void _reset_e4_acceleration_rate ( ) { _reset_e_acceleration_rate ( 4 ) ; } <nl> + # if E_STEPPERS > 5 <nl> + void _reset_e5_acceleration_rate ( ) { _reset_e_acceleration_rate ( 5 ) ; } <nl> + # endif / / E_STEPPERS > 5 <nl> + # endif / / E_STEPPERS > 4 <nl> + # endif / / E_STEPPERS > 3 <nl> + # endif / / E_STEPPERS > 2 <nl> + # endif <nl> + <nl> + void _planner_refresh_positioning ( ) { planner . refresh_positioning ( ) ; } <nl> + # if ENABLED ( DISTINCT_E_FACTORS ) <nl> + void _planner_refresh_e_positioning ( const uint8_t e ) { <nl> + if ( e = = active_extruder ) <nl> + _planner_refresh_positioning ( ) ; <nl> + else <nl> + planner . steps_to_mm [ E_AXIS + e ] = 1 . 0f / planner . settings . axis_steps_per_mm [ E_AXIS + e ] ; <nl> + } <nl> + void _planner_refresh_e0_positioning ( ) { _planner_refresh_e_positioning ( 0 ) ; } <nl> + void _planner_refresh_e1_positioning ( ) { _planner_refresh_e_positioning ( 1 ) ; } <nl> + # if E_STEPPERS > 2 <nl> + void _planner_refresh_e2_positioning ( ) { _planner_refresh_e_positioning ( 2 ) ; } <nl> + # if E_STEPPERS > 3 <nl> + void _planner_refresh_e3_positioning ( ) { _planner_refresh_e_positioning ( 3 ) ; } <nl> + # if E_STEPPERS > 4 <nl> + void _planner_refresh_e4_positioning ( ) { _planner_refresh_e_positioning ( 4 ) ; } <nl> + # if E_STEPPERS > 5 <nl> + void _planner_refresh_e5_positioning ( ) { _planner_refresh_e_positioning ( 5 ) ; } <nl> + # endif / / E_STEPPERS > 5 <nl> + # endif / / E_STEPPERS > 4 <nl> + # endif / / E_STEPPERS > 3 <nl> + # endif / / E_STEPPERS > 2 <nl> + # endif <nl> + <nl> + / / M203 / M205 Velocity options <nl> + void menu_advanced_velocity ( ) { <nl> + START_MENU ( ) ; <nl> + MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> + <nl> + / / M203 Max Feedrate <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_A , & planner . settings . max_feedrate_mm_s [ A_AXIS ] , 1 , 999 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_B , & planner . settings . max_feedrate_mm_s [ B_AXIS ] , 1 , 999 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_C , & planner . settings . max_feedrate_mm_s [ C_AXIS ] , 1 , 999 ) ; <nl> + <nl> + # if ENABLED ( DISTINCT_E_FACTORS ) <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E , & planner . settings . max_feedrate_mm_s [ E_AXIS + active_extruder ] , 1 , 999 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E1 , & planner . settings . max_feedrate_mm_s [ E_AXIS ] , 1 , 999 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E2 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 1 ] , 1 , 999 ) ; <nl> + # if E_STEPPERS > 2 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E3 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 2 ] , 1 , 999 ) ; <nl> + # if E_STEPPERS > 3 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E4 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 3 ] , 1 , 999 ) ; <nl> + # if E_STEPPERS > 4 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E5 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 4 ] , 1 , 999 ) ; <nl> + # if E_STEPPERS > 5 <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E6 , & planner . settings . max_feedrate_mm_s [ E_AXIS + 5 ] , 1 , 999 ) ; <nl> + # endif / / E_STEPPERS > 5 <nl> + # endif / / E_STEPPERS > 4 <nl> + # endif / / E_STEPPERS > 3 <nl> + # endif / / E_STEPPERS > 2 <nl> + # else <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMAX MSG_E , & planner . settings . max_feedrate_mm_s [ E_AXIS ] , 1 , 999 ) ; <nl> + # endif <nl> + <nl> + / / M205 S Min Feedrate <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VMIN , & planner . settings . min_feedrate_mm_s , 0 , 999 ) ; <nl> + <nl> + / / M205 T Min Travel Feedrate <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VTRAV_MIN , & planner . settings . min_travel_feedrate_mm_s , 0 , 999 ) ; <nl> + <nl> + END_MENU ( ) ; <nl> + } <nl> + <nl> + / / M201 / M204 Accelerations <nl> + void menu_advanced_acceleration ( ) { <nl> + START_MENU ( ) ; <nl> + MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> + <nl> + / / M204 P Acceleration <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float5 , MSG_ACC , & planner . settings . acceleration , 10 , 99000 ) ; <nl> + <nl> + / / M204 R Retract Acceleration <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float5 , MSG_A_RETRACT , & planner . settings . retract_acceleration , 100 , 99000 ) ; <nl> + <nl> + / / M204 T Travel Acceleration <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float5 , MSG_A_TRAVEL , & planner . settings . travel_acceleration , 100 , 99000 ) ; <nl> + <nl> + / / M201 settings <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_A , & planner . settings . max_acceleration_mm_per_s2 [ A_AXIS ] , 100 , 99000 , _reset_acceleration_rates ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_B , & planner . settings . max_acceleration_mm_per_s2 [ B_AXIS ] , 100 , 99000 , _reset_acceleration_rates ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_C , & planner . settings . max_acceleration_mm_per_s2 [ C_AXIS ] , 10 , 99000 , _reset_acceleration_rates ) ; <nl> + <nl> + # if ENABLED ( DISTINCT_E_FACTORS ) <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + active_extruder ] , 100 , 99000 , _reset_acceleration_rates ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E1 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS ] , 100 , 99000 , _reset_e0_acceleration_rate ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E2 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 1 ] , 100 , 99000 , _reset_e1_acceleration_rate ) ; <nl> + # if E_STEPPERS > 2 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E3 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 2 ] , 100 , 99000 , _reset_e2_acceleration_rate ) ; <nl> + # if E_STEPPERS > 3 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E4 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 3 ] , 100 , 99000 , _reset_e3_acceleration_rate ) ; <nl> + # if E_STEPPERS > 4 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E5 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 4 ] , 100 , 99000 , _reset_e4_acceleration_rate ) ; <nl> + # if E_STEPPERS > 5 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E6 , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS + 5 ] , 100 , 99000 , _reset_e5_acceleration_rate ) ; <nl> + # endif / / E_STEPPERS > 5 <nl> + # endif / / E_STEPPERS > 4 <nl> + # endif / / E_STEPPERS > 3 <nl> + # endif / / E_STEPPERS > 2 <nl> + # else <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( long5 , MSG_AMAX MSG_E , & planner . settings . max_acceleration_mm_per_s2 [ E_AXIS ] , 100 , 99000 , _reset_acceleration_rates ) ; <nl> + # endif <nl> + <nl> + END_MENU ( ) ; <nl> + } <nl> + <nl> + / / M205 Jerk <nl> + void menu_advanced_jerk ( ) { <nl> + START_MENU ( ) ; <nl> + MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> + <nl> + # if ENABLED ( JUNCTION_DEVIATION ) <nl> + # if ENABLED ( LIN_ADVANCE ) <nl> + MENU_ITEM_EDIT_CALLBACK ( float43 , MSG_JUNCTION_DEVIATION , & planner . junction_deviation_mm , 0 . 01f , 0 . 3f , planner . recalculate_max_e_jerk ) ; <nl> + # else <nl> + MENU_ITEM_EDIT ( float43 , MSG_JUNCTION_DEVIATION , & planner . junction_deviation_mm , 0 . 01f , 0 . 3f ) ; <nl> + # endif <nl> + # endif <nl> + # if HAS_CLASSIC_JERK <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VA_JERK , & planner . max_jerk [ A_AXIS ] , 1 , 990 ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VB_JERK , & planner . max_jerk [ B_AXIS ] , 1 , 990 ) ; <nl> + # if ENABLED ( DELTA ) <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VC_JERK , & planner . max_jerk [ C_AXIS ] , 1 , 990 ) ; <nl> + # else <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float52sign , MSG_VC_JERK , & planner . max_jerk [ C_AXIS ] , 0 . 1f , 990 ) ; <nl> + # endif <nl> + # if DISABLED ( JUNCTION_DEVIATION ) | | DISABLED ( LIN_ADVANCE ) <nl> + MENU_MULTIPLIER_ITEM_EDIT ( float3 , MSG_VE_JERK , & planner . max_jerk [ E_AXIS ] , 1 , 990 ) ; <nl> + # endif <nl> + # endif <nl> + <nl> + END_MENU ( ) ; <nl> + } <nl> + <nl> + / / M92 Steps - per - mm <nl> + void menu_advanced_steps_per_mm ( ) { <nl> + START_MENU ( ) ; <nl> + MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> + <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_ASTEPS , & planner . settings . axis_steps_per_mm [ A_AXIS ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_BSTEPS , & planner . settings . axis_steps_per_mm [ B_AXIS ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_CSTEPS , & planner . settings . axis_steps_per_mm [ C_AXIS ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> + <nl> + # if ENABLED ( DISTINCT_E_FACTORS ) <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_ESTEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + active_extruder ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E1STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS ] , 5 , 9999 , _planner_refresh_e0_positioning ) ; <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E2STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 1 ] , 5 , 9999 , _planner_refresh_e1_positioning ) ; <nl> + # if E_STEPPERS > 2 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E3STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 2 ] , 5 , 9999 , _planner_refresh_e2_positioning ) ; <nl> + # if E_STEPPERS > 3 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E4STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 3 ] , 5 , 9999 , _planner_refresh_e3_positioning ) ; <nl> + # if E_STEPPERS > 4 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E5STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 4 ] , 5 , 9999 , _planner_refresh_e4_positioning ) ; <nl> + # if E_STEPPERS > 5 <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_E6STEPS , & planner . settings . axis_steps_per_mm [ E_AXIS + 5 ] , 5 , 9999 , _planner_refresh_e5_positioning ) ; <nl> + # endif / / E_STEPPERS > 5 <nl> + # endif / / E_STEPPERS > 4 <nl> + # endif / / E_STEPPERS > 3 <nl> + # endif / / E_STEPPERS > 2 <nl> + # else <nl> + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK ( float62 , MSG_ESTEPS , & planner . settings . axis_steps_per_mm [ E_AXIS ] , 5 , 9999 , _planner_refresh_positioning ) ; <nl> + # endif <nl> + <nl> + END_MENU ( ) ; <nl> + } <nl> + <nl> + # if ENABLED ( EEPROM_SETTINGS ) <nl> + <nl> + # include " . . / . . / module / configuration_store . h " <nl> + <nl> + static void lcd_init_eeprom ( ) { <nl> + lcd_completion_feedback ( settings . init_eeprom ( ) ) ; <nl> + lcd_goto_previous_menu ( ) ; <nl> + } <nl> + <nl> + static void lcd_init_eeprom_confirm ( ) { <nl> + START_MENU ( ) ; <nl> + MENU_BACK ( MSG_ADVANCED_SETTINGS ) ; <nl> + MENU_ITEM ( function , MSG_INIT_EEPROM , lcd_init_eeprom ) ; <nl> + END_MENU ( ) ; <nl> + } <nl> + <nl> + # endif <nl> + <nl> + # endif / / ! SLIM_LCD_MENUS <nl> + <nl> + void menu_advanced_settings ( ) { <nl> + START_MENU ( ) ; <nl> + MENU_BACK ( MSG_CONFIGURATION ) ; <nl> + <nl> + # if ENABLED ( BABYSTEP_ZPROBE_OFFSET ) <nl> + MENU_ITEM ( submenu , MSG_ZPROBE_ZOFFSET , lcd_babystep_zoffset ) ; <nl> + # elif HAS_BED_PROBE <nl> + MENU_ITEM_EDIT ( float52 , MSG_ZPROBE_ZOFFSET , & zprobe_zoffset , Z_PROBE_OFFSET_RANGE_MIN , Z_PROBE_OFFSET_RANGE_MAX ) ; <nl> + # endif <nl> + <nl> + # if DISABLED ( SLIM_LCD_MENUS ) <nl> + <nl> + # if HAS_M206_COMMAND <nl> + / / <nl> + / / Set Home Offsets <nl> + / / <nl> + MENU_ITEM ( function , MSG_SET_HOME_OFFSETS , _lcd_set_home_offsets ) ; <nl> + # endif <nl> + <nl> + / / M203 / M205 - Feedrate items <nl> + MENU_ITEM ( submenu , MSG_VELOCITY , menu_advanced_velocity ) ; <nl> + <nl> + / / M201 - Acceleration items <nl> + MENU_ITEM ( submenu , MSG_ACCELERATION , menu_advanced_acceleration ) ; <nl> + <nl> + / / M205 - Max Jerk <nl> + MENU_ITEM ( submenu , MSG_JERK , menu_advanced_jerk ) ; <nl> + <nl> + if ( ! printer_busy ( ) ) { <nl> + / / M92 - Steps Per mm <nl> + MENU_ITEM ( submenu , MSG_STEPS_PER_MM , menu_advanced_steps_per_mm ) ; <nl> + } <nl> + <nl> + # endif / / ! SLIM_LCD_MENUS <nl> + <nl> + MENU_ITEM ( submenu , MSG_TEMPERATURE , menu_advanced_temperature ) ; <nl> + <nl> + # if DISABLED ( NO_VOLUMETRICS ) | | ENABLED ( ADVANCED_PAUSE_FEATURE ) <nl> + MENU_ITEM ( submenu , MSG_FILAMENT , menu_advanced_filament ) ; <nl> + # elif ENABLED ( LIN_ADVANCE ) <nl> + # if EXTRUDERS = = 1 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K , & planner . extruder_advance_K [ 0 ] , 0 , 999 ) ; <nl> + # elif EXTRUDERS > 1 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E1 , & planner . extruder_advance_K [ 0 ] , 0 , 999 ) ; <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E2 , & planner . extruder_advance_K [ 1 ] , 0 , 999 ) ; <nl> + # if EXTRUDERS > 2 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E3 , & planner . extruder_advance_K [ 2 ] , 0 , 999 ) ; <nl> + # if EXTRUDERS > 3 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E4 , & planner . extruder_advance_K [ 3 ] , 0 , 999 ) ; <nl> + # if EXTRUDERS > 4 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E5 , & planner . extruder_advance_K [ 4 ] , 0 , 999 ) ; <nl> + # if EXTRUDERS > 5 <nl> + MENU_ITEM_EDIT ( float52 , MSG_ADVANCE_K MSG_E6 , & planner . extruder_advance_K [ 5 ] , 0 , 999 ) ; <nl> + # endif / / EXTRUDERS > 5 <nl> + # endif / / EXTRUDERS > 4 <nl> + # endif / / EXTRUDERS > 3 <nl> + # endif / / EXTRUDERS > 2 <nl> + # endif / / EXTRUDERS > 1 <nl> + # endif <nl> + <nl> + / / M540 S - Abort on endstop hit when SD printing <nl> + # if ENABLED ( ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ) <nl> + MENU_ITEM_EDIT ( bool , MSG_ENDSTOP_ABORT , & planner . abort_on_endstop_hit ) ; <nl> + # endif <nl> + <nl> + / / <nl> + / / BLTouch Self - Test and Reset <nl> + / / <nl> + # if ENABLED ( BLTOUCH ) <nl> + MENU_ITEM ( gcode , MSG_BLTOUCH_SELFTEST , PSTR ( " M280 P " STRINGIFY ( Z_PROBE_SERVO_NR ) " S " STRINGIFY ( BLTOUCH_SELFTEST ) ) ) ; <nl> + if ( ! endstops . z_probe_enabled & & TEST_BLTOUCH ( ) ) <nl> + MENU_ITEM ( gcode , MSG_BLTOUCH_RESET , PSTR ( " M280 P " STRINGIFY ( Z_PROBE_SERVO_NR ) " S " STRINGIFY ( BLTOUCH_RESET ) ) ) ; <nl> + # endif <nl> + <nl> + # if ENABLED ( SD_FIRMWARE_UPDATE ) <nl> + bool sd_update_state = settings . sd_update_status ( ) ; <nl> + MENU_ITEM_EDIT_CALLBACK ( bool , MSG_SD_UPDATE , & sd_update_state , _lcd_toggle_sd_update ) ; <nl> + # endif <nl> + <nl> + # if ENABLED ( EEPROM_SETTINGS ) & & DISABLED ( SLIM_LCD_MENUS ) <nl> + MENU_ITEM ( submenu , MSG_INIT_EEPROM , lcd_init_eeprom_confirm ) ; <nl> + # endif <nl> + <nl> + END_MENU ( ) ; <nl> + } <nl> + <nl> + # endif / / HAS_LCD_MENU <nl>
Move Advanced Settings Menu to its own file
MarlinFirmware/Marlin
d87ab3ed2052e28bfbf4282c3dc14b071c71ca32
2018-10-28T20:46:45Z
mmm a / caffe2 / mkl / CMakeLists . txt <nl> ppp b / caffe2 / mkl / CMakeLists . txt <nl> if ( BLAS STREQUAL " MKL " ) <nl> message ( STATUS " Including MKL operators " ) <nl> <nl> # mmm [ CPU files . <nl> - file ( GLOB tmp * . cc ) <nl> + file ( GLOB_RECURSE tmp * . cc ) <nl> set ( Caffe2_CPU_SRCS $ { Caffe2_CPU_SRCS } $ { tmp } ) <nl> # exclude test files and gpu files <nl> - file ( GLOB tmp * _test . cc ) <nl> + file ( GLOB_RECURSE tmp * _test . cc ) <nl> exclude ( Caffe2_CPU_SRCS " $ { Caffe2_CPU_SRCS } " $ { tmp } ) <nl> <nl> # mmm [ CPU test files - currently none but just to be safe <nl> - file ( GLOB tmp * _test . cc ) <nl> + file ( GLOB_RECURSE tmp * _test . cc ) <nl> set ( Caffe2_CPU_TEST_SRCS $ { Caffe2_CPU_TEST_SRCS } $ { tmp } ) <nl> <nl> # mmm [ Send the lists to the parent scope . <nl>
mkl : GLOB_RECURSE instead of GLOB
pytorch/pytorch
ccdeede31bded7909c287624cc6362f463da3071
2017-01-04T21:21:35Z
mmm a / PowerEditor / src / WinControls / PluginsAdmin / pluginsAdmin . cpp <nl> ppp b / PowerEditor / src / WinControls / PluginsAdmin / pluginsAdmin . cpp <nl> bool findStrNoCase ( const generic_string & strHaystack , const generic_string & st <nl> return ( it ! = strHaystack . end ( ) ) ; <nl> } <nl> <nl> + bool PluginsAdminDlg : : isFoundInAvailableListFromIndex ( int index , generic_string str2search , bool inWhichPart ) const <nl> + { <nl> + PluginUpdateInfo * pui = _availableList . getPluginInfoFromIndex ( index ) ; <nl> + generic_string searchIn ; <nl> + if ( inWhichPart = = _inNames ) <nl> + searchIn = pui - > _displayName ; <nl> + else / / ( inWhichPart = = inDescs ) <nl> + searchIn = pui - > _description ; <nl> + <nl> + return ( findStrNoCase ( searchIn , str2search ) ) ; <nl> + } <nl> <nl> long PluginsAdminDlg : : searchFromCurrentSel ( generic_string str2search , bool inWhichPart , bool isNextMode ) const <nl> { <nl> / / search from curent selected item or from the beginning <nl> - long currentIndex = _availableListView . getSelectedIndex ( ) ; <nl> - int nbItem = static_cast < int > ( _availableListView . nbItem ( ) ) ; <nl> + long currentIndex = _availableList . getSelectedIndex ( ) ; <nl> + int nbItem = static_cast < int > ( _availableList . nbItem ( ) ) ; <nl> if ( currentIndex = = - 1 ) <nl> { <nl> / / no selection , let ' s search from 0 to the end <nl> for ( int i = 0 ; i < nbItem ; + + i ) <nl> { <nl> - size_t j = _availableListView . getLParamFromIndex ( i ) ; <nl> - generic_string searchIn ; <nl> - if ( inWhichPart = = inNames ) <nl> - searchIn = _availablePluginList [ j ] . _name ; <nl> - else / / ( inWhichPart = = inDescs ) <nl> - searchIn = _availablePluginList [ j ] . _description ; <nl> - <nl> - if ( findStrNoCase ( searchIn , str2search ) ) <nl> + if ( isFoundInAvailableListFromIndex ( i , str2search , inWhichPart ) ) <nl> return i ; <nl> } <nl> } <nl> - else <nl> + else / / with selection , let ' s search from currentIndex <nl> { <nl> - / / with selection , let ' s search from currentIndex <nl> - <nl> / / from current position to the end <nl> for ( int i = currentIndex + ( isNextMode ? 1 : 0 ) ; i < nbItem ; + + i ) <nl> { <nl> - size_t j = _availableListView . getLParamFromIndex ( i ) ; <nl> - generic_string searchIn ; <nl> - if ( inWhichPart = = inNames ) <nl> - searchIn = _availablePluginList [ j ] . _name ; <nl> - else / / ( inWhichPart = = inDescs ) <nl> - searchIn = _availablePluginList [ j ] . _description ; <nl> - <nl> - if ( findStrNoCase ( searchIn , str2search ) ) <nl> + if ( isFoundInAvailableListFromIndex ( i , str2search , inWhichPart ) ) <nl> return i ; <nl> } <nl> <nl> / / from to begining to current position <nl> for ( int i = 0 ; i < currentIndex + ( isNextMode ? 1 : 0 ) ; + + i ) <nl> { <nl> - size_t j = _availableListView . getLParamFromIndex ( i ) ; <nl> - generic_string searchIn ; <nl> - if ( inWhichPart = = inNames ) <nl> - searchIn = _availablePluginList [ j ] . _name ; <nl> - else / / ( inWhichPart = = inDescs ) <nl> - searchIn = _availablePluginList [ j ] . _description ; <nl> - <nl> - if ( findStrNoCase ( searchIn , str2search ) ) <nl> + if ( isFoundInAvailableListFromIndex ( i , str2search , inWhichPart ) ) <nl> return i ; <nl> } <nl> } <nl> void PluginsAdminDlg : : create ( int dialogID , bool isRTL , bool msgDestParent ) <nl> generic_string vesionStr = pNativeSpeaker - > getAttrNameStr ( TEXT ( " Version " ) , " PluginAdmin " , " Version " ) ; <nl> generic_string stabilityStr = pNativeSpeaker - > getAttrNameStr ( TEXT ( " Stability " ) , " PluginAdmin " , " Stability " ) ; <nl> <nl> - _availableListView . addColumn ( columnInfo ( pluginStr , nppParam - > _dpiManager . scaleX ( 200 ) ) ) ; <nl> - _availableListView . addColumn ( columnInfo ( vesionStr , nppParam - > _dpiManager . scaleX ( 100 ) ) ) ; <nl> - _availableListView . addColumn ( columnInfo ( stabilityStr , nppParam - > _dpiManager . scaleX ( 70 ) ) ) ; <nl> - _availableListView . setStyleOption ( LVS_EX_CHECKBOXES ) ; <nl> + _availableList . addColumn ( columnInfo ( pluginStr , nppParam - > _dpiManager . scaleX ( 200 ) ) ) ; <nl> + _availableList . addColumn ( columnInfo ( vesionStr , nppParam - > _dpiManager . scaleX ( 100 ) ) ) ; <nl> + _availableList . addColumn ( columnInfo ( stabilityStr , nppParam - > _dpiManager . scaleX ( 70 ) ) ) ; <nl> + _availableList . setViewStyleOption ( LVS_EX_CHECKBOXES ) ; <nl> <nl> - _availableListView . init ( _hInst , _hSelf ) ; <nl> - _availableListView . reSizeTo ( listRect ) ; <nl> + _availableList . initView ( _hInst , _hSelf ) ; <nl> + _availableList . reSizeView ( listRect ) ; <nl> <nl> - _updateListView . addColumn ( columnInfo ( pluginStr , nppParam - > _dpiManager . scaleX ( 200 ) ) ) ; <nl> - _updateListView . addColumn ( columnInfo ( vesionStr , nppParam - > _dpiManager . scaleX ( 100 ) ) ) ; <nl> - _updateListView . addColumn ( columnInfo ( stabilityStr , nppParam - > _dpiManager . scaleX ( 70 ) ) ) ; <nl> - _updateListView . setStyleOption ( LVS_EX_CHECKBOXES ) ; <nl> + _updateList . addColumn ( columnInfo ( pluginStr , nppParam - > _dpiManager . scaleX ( 200 ) ) ) ; <nl> + _updateList . addColumn ( columnInfo ( vesionStr , nppParam - > _dpiManager . scaleX ( 100 ) ) ) ; <nl> + _updateList . addColumn ( columnInfo ( stabilityStr , nppParam - > _dpiManager . scaleX ( 70 ) ) ) ; <nl> + _updateList . setViewStyleOption ( LVS_EX_CHECKBOXES ) ; <nl> <nl> - _updateListView . init ( _hInst , _hSelf ) ; <nl> - _updateListView . reSizeTo ( listRect ) ; <nl> + _updateList . initView ( _hInst , _hSelf ) ; <nl> + _updateList . reSizeView ( listRect ) ; <nl> <nl> - _installedListView . addColumn ( columnInfo ( pluginStr , nppParam - > _dpiManager . scaleX ( 200 ) ) ) ; <nl> - _installedListView . addColumn ( columnInfo ( vesionStr , nppParam - > _dpiManager . scaleX ( 100 ) ) ) ; <nl> - _installedListView . addColumn ( columnInfo ( stabilityStr , nppParam - > _dpiManager . scaleX ( 70 ) ) ) ; <nl> - _installedListView . setStyleOption ( LVS_EX_CHECKBOXES ) ; <nl> + _installedList . addColumn ( columnInfo ( pluginStr , nppParam - > _dpiManager . scaleX ( 200 ) ) ) ; <nl> + _installedList . addColumn ( columnInfo ( vesionStr , nppParam - > _dpiManager . scaleX ( 100 ) ) ) ; <nl> + _installedList . addColumn ( columnInfo ( stabilityStr , nppParam - > _dpiManager . scaleX ( 70 ) ) ) ; <nl> + _installedList . setViewStyleOption ( LVS_EX_CHECKBOXES ) ; <nl> <nl> - _installedListView . init ( _hInst , _hSelf ) ; <nl> - _installedListView . reSizeTo ( listRect ) ; <nl> + _installedList . initView ( _hInst , _hSelf ) ; <nl> + _installedList . reSizeView ( listRect ) ; <nl> <nl> HWND hDesc = : : GetDlgItem ( _hSelf , IDC_PLUGINADM_EDIT ) ; <nl> : : MoveWindow ( hDesc , descRect . left , descRect . top , descRect . right , descRect . bottom , TRUE ) ; <nl> void PluginsAdminDlg : : collectNppCurrentStatusInfos ( ) <nl> <nl> bool PluginsAdminDlg : : installPlugins ( ) <nl> { <nl> + / * <nl> vector < size_t > indexes = _availableListView . getCheckedIndexes ( ) ; <nl> <nl> NppParameters * pNppParameters = NppParameters : : getInstance ( ) ; <nl> bool PluginsAdminDlg : : installPlugins ( ) <nl> Process updater ( updaterFullPath . c_str ( ) , updaterParams . c_str ( ) , updaterDir . c_str ( ) ) ; <nl> updater . run ( ) ; <nl> } <nl> + * / <nl> return true ; <nl> } <nl> <nl> bool PluginsAdminDlg : : updatePlugins ( ) <nl> { <nl> + / * <nl> vector < size_t > indexes = _updateListView . getCheckedIndexes ( ) ; <nl> <nl> NppParameters * pNppParameters = NppParameters : : getInstance ( ) ; <nl> bool PluginsAdminDlg : : updatePlugins ( ) <nl> Process updater ( updaterFullPath . c_str ( ) , updaterParams . c_str ( ) , updaterDir . c_str ( ) ) ; <nl> updater . run ( ) ; <nl> } <nl> + * / <nl> return true ; <nl> } <nl> <nl> bool PluginsAdminDlg : : removePlugins ( ) <nl> { <nl> + / * <nl> vector < size_t > indexes = _installedListView . getCheckedIndexes ( ) ; <nl> <nl> NppParameters * pNppParameters = NppParameters : : getInstance ( ) ; <nl> bool PluginsAdminDlg : : removePlugins ( ) <nl> Process updater ( updaterFullPath . c_str ( ) , updaterParams . c_str ( ) , updaterDir . c_str ( ) ) ; <nl> updater . run ( ) ; <nl> } <nl> + * / <nl> return true ; <nl> } <nl> <nl> + void PluginViewList : : pushBack ( PluginUpdateInfo * pi ) <nl> + { <nl> + _list . push_back ( pi ) ; <nl> + <nl> + vector < generic_string > values2Add ; <nl> + values2Add . push_back ( pi - > _displayName ) ; <nl> + Version v = pi - > _version ; <nl> + values2Add . push_back ( v . toString ( ) ) ; <nl> + values2Add . push_back ( TEXT ( " Yes " ) ) ; <nl> + _ui . addLine ( values2Add , reinterpret_cast < LPARAM > ( pi ) ) ; <nl> + } <nl> <nl> - bool loadFromJson ( vector < PluginUpdateInfo > & pl , const json & j ) <nl> + bool loadFromJson ( PluginViewList & pl , const json & j ) <nl> { <nl> if ( j . empty ( ) ) <nl> return false ; <nl> bool loadFromJson ( vector < PluginUpdateInfo > & pl , const json & j ) <nl> for ( const auto & i : jArray ) <nl> { <nl> try { <nl> - PluginUpdateInfo pi ; <nl> + / / std : : unique_ptr < PluginUpdateInfo * > pi = make_unique < PluginUpdateInfo * > ( ) ; <nl> + PluginUpdateInfo * pi = new PluginUpdateInfo ( ) ; <nl> <nl> string valStr = i . at ( " folder - name " ) . get < std : : string > ( ) ; <nl> - pi . _name = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> + pi - > _folderName = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> <nl> valStr = i . at ( " display - name " ) . get < std : : string > ( ) ; <nl> - pi . _alias = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> + pi - > _displayName = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> <nl> valStr = i . at ( " author " ) . get < std : : string > ( ) ; <nl> - pi . _author = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> + pi - > _author = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> <nl> valStr = i . at ( " description " ) . get < std : : string > ( ) ; <nl> - pi . _description = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> + pi - > _description = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> <nl> valStr = i . at ( " repository " ) . get < std : : string > ( ) ; <nl> - pi . _repository = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> + pi - > _repository = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> <nl> valStr = i . at ( " homepage " ) . get < std : : string > ( ) ; <nl> - pi . _homepage = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> + pi - > _homepage = wmc - > char2wchar ( valStr . c_str ( ) , CP_ACP ) ; <nl> <nl> <nl> - pl . push_back ( pi ) ; <nl> + pl . pushBack ( pi ) ; <nl> } <nl> catch ( . . . ) / / Every field is mandatory . If one of property is missing , an exception is thrown then this plugin will be ignored <nl> { <nl> bool PluginsAdminDlg : : updateListAndLoadFromJson ( ) <nl> nppPluginListJson > > pluginsJson ; <nl> <nl> / / initialize available list view <nl> - loadFromJson ( _availablePluginList , pluginsJson ) ; <nl> - updateAvailableListView ( ) ; <nl> + loadFromJson ( _availableList , pluginsJson ) ; <nl> <nl> / / initialize update list view <nl> checkUpdates ( ) ; <nl> - updateUpdateListView ( ) ; <nl> <nl> / / initialize installed list view <nl> loadFromPluginInfos ( ) ; <nl> - updateInstalledListView ( ) ; <nl> <nl> return true ; <nl> } <nl> <nl> - void PluginsAdminDlg : : updateAvailableListView ( ) <nl> - { <nl> - size_t i = 0 ; <nl> - / / <nl> - for ( const auto & pui : _availablePluginList ) <nl> - { <nl> - vector < generic_string > values2Add ; <nl> - values2Add . push_back ( pui . _name ) ; <nl> - Version v = pui . _version ; <nl> - values2Add . push_back ( v . toString ( ) ) ; <nl> - values2Add . push_back ( TEXT ( " Yes " ) ) ; <nl> - _availableListView . addLine ( values2Add , i + + ) ; <nl> - } <nl> - } <nl> - <nl> - void PluginsAdminDlg : : updateInstalledListView ( ) <nl> - { <nl> - size_t i = 0 ; <nl> - / / <nl> - for ( const auto & lpi : _installedPluginList ) <nl> - { <nl> - vector < generic_string > values2Add ; <nl> - values2Add . push_back ( lpi . _name ) ; <nl> - Version v = lpi . _version ; <nl> - values2Add . push_back ( v . toString ( ) ) ; <nl> - values2Add . push_back ( TEXT ( " Yes " ) ) ; <nl> - _installedListView . addLine ( values2Add , i + + ) ; <nl> - } <nl> - } <nl> - <nl> - void PluginsAdminDlg : : updateUpdateListView ( ) <nl> - { <nl> - size_t i = 0 ; <nl> - / / <nl> - for ( const auto & pui : _updatePluginList ) <nl> - { <nl> - vector < generic_string > values2Add ; <nl> - values2Add . push_back ( pui . _name ) ; <nl> - Version v = pui . _version ; <nl> - values2Add . push_back ( v . toString ( ) ) ; <nl> - values2Add . push_back ( TEXT ( " Yes " ) ) ; <nl> - _updateListView . addLine ( values2Add , i + + ) ; <nl> - } <nl> - } <nl> <nl> PluginUpdateInfo : : PluginUpdateInfo ( const generic_string & fullFilePath , const generic_string & filename ) <nl> { <nl> - if ( not : : PathFileExists ( fullFilePath . c_str ( ) ) ) <nl> + if ( ! : : PathFileExists ( fullFilePath . c_str ( ) ) ) <nl> return ; <nl> <nl> _fullFilePath = fullFilePath ; <nl> - _name = filename ; <nl> + _displayName = filename ; <nl> <nl> WcharMbcsConvertor * wmc = WcharMbcsConvertor : : getInstance ( ) ; <nl> const char * path = wmc - > wchar2char ( fullFilePath . c_str ( ) , CP_ACP ) ; <nl> bool PluginsAdminDlg : : loadFromPluginInfos ( ) <nl> <nl> for ( const auto & i : _pPluginsManager - > _loadedDlls ) <nl> { <nl> - PluginUpdateInfo pui ( i . _fullFilePath , i . _fileName ) ; <nl> - _installedPluginList . push_back ( pui ) ; <nl> + PluginUpdateInfo * pui = new PluginUpdateInfo ( i . _fullFilePath , i . _fileName ) ; <nl> + _installedList . pushBack ( pui ) ; <nl> } <nl> <nl> return true ; <nl> bool PluginsAdminDlg : : searchInPlugins ( bool isNextMode ) const <nl> if ( foundIndex = = - 1 ) <nl> return false ; <nl> <nl> - _availableListView . setSelection ( foundIndex ) ; <nl> + _availableList . setSelection ( foundIndex ) ; <nl> <nl> return true ; <nl> } <nl> void PluginsAdminDlg : : switchDialog ( int indexToSwitch ) <nl> showUpdate = false ; <nl> showInstalled = false ; <nl> <nl> - long infoIndex = _availableListView . getSelectedIndex ( ) ; <nl> - if ( infoIndex ! = - 1 & & infoIndex < static_cast < long > ( _availablePluginList . size ( ) ) ) <nl> - desc = _availablePluginList . at ( infoIndex ) . describe ( ) ; <nl> + long infoIndex = _availableList . getSelectedIndex ( ) ; <nl> + if ( infoIndex ! = - 1 & & infoIndex < static_cast < long > ( _availableList . nbItem ( ) ) ) <nl> + desc = _availableList . getPluginInfoFromIndex ( infoIndex ) - > describe ( ) ; <nl> } <nl> break ; <nl> <nl> void PluginsAdminDlg : : switchDialog ( int indexToSwitch ) <nl> showUpdate = true ; <nl> showInstalled = false ; <nl> <nl> - long infoIndex = _updateListView . getSelectedIndex ( ) ; <nl> - if ( infoIndex ! = - 1 & & infoIndex < static_cast < long > ( _updatePluginList . size ( ) ) ) <nl> - desc = _updatePluginList . at ( infoIndex ) . describe ( ) ; <nl> + long infoIndex = _updateList . getSelectedIndex ( ) ; <nl> + if ( infoIndex ! = - 1 & & infoIndex < static_cast < long > ( _updateList . nbItem ( ) ) ) <nl> + desc = _updateList . getPluginInfoFromIndex ( infoIndex ) - > describe ( ) ; <nl> } <nl> break ; <nl> <nl> void PluginsAdminDlg : : switchDialog ( int indexToSwitch ) <nl> showUpdate = false ; <nl> showInstalled = true ; <nl> <nl> - long infoIndex = _installedListView . getSelectedIndex ( ) ; <nl> - if ( infoIndex ! = - 1 & & infoIndex < static_cast < long > ( _installedPluginList . size ( ) ) ) <nl> - desc = _installedPluginList . at ( infoIndex ) . describe ( ) ; <nl> + long infoIndex = _installedList . getSelectedIndex ( ) ; <nl> + if ( infoIndex ! = - 1 & & infoIndex < static_cast < long > ( _installedList . nbItem ( ) ) ) <nl> + desc = _installedList . getPluginInfoFromIndex ( infoIndex ) - > describe ( ) ; <nl> } <nl> break ; <nl> <nl> void PluginsAdminDlg : : switchDialog ( int indexToSwitch ) <nl> return ; <nl> } <nl> <nl> - _availableListView . display ( showAvailable ) ; <nl> - _updateListView . display ( showUpdate ) ; <nl> - _installedListView . display ( showInstalled ) ; <nl> + _availableList . displayView ( showAvailable ) ; <nl> + _updateList . displayView ( showUpdate ) ; <nl> + _installedList . displayView ( showInstalled ) ; <nl> <nl> : : SetDlgItemText ( _hSelf , IDC_PLUGINADM_EDIT , desc . c_str ( ) ) ; <nl> <nl> void PluginsAdminDlg : : switchDialog ( int indexToSwitch ) <nl> : : ShowWindow ( hInstallButton , showAvailable ? SW_SHOW : SW_HIDE ) ; <nl> if ( showAvailable ) <nl> { <nl> - vector < size_t > checkedArray = _availableListView . getCheckedIndexes ( ) ; <nl> + vector < size_t > checkedArray = _availableList . getCheckedIndexes ( ) ; <nl> showAvailable = checkedArray . size ( ) > 0 ; <nl> } <nl> : : EnableWindow ( hInstallButton , showAvailable ) ; <nl> void PluginsAdminDlg : : switchDialog ( int indexToSwitch ) <nl> : : ShowWindow ( hUpdateButton , showUpdate ? SW_SHOW : SW_HIDE ) ; <nl> if ( showUpdate ) <nl> { <nl> - vector < size_t > checkedArray = _updateListView . getCheckedIndexes ( ) ; <nl> + vector < size_t > checkedArray = _updateList . getCheckedIndexes ( ) ; <nl> showUpdate = checkedArray . size ( ) > 0 ; <nl> } <nl> : : EnableWindow ( hUpdateButton , showUpdate ) ; <nl> void PluginsAdminDlg : : switchDialog ( int indexToSwitch ) <nl> : : ShowWindow ( hRemoveButton , showInstalled ? SW_SHOW : SW_HIDE ) ; <nl> if ( showInstalled ) <nl> { <nl> - vector < size_t > checkedArray = _installedListView . getCheckedIndexes ( ) ; <nl> + vector < size_t > checkedArray = _installedList . getCheckedIndexes ( ) ; <nl> showInstalled = checkedArray . size ( ) > 0 ; <nl> } <nl> : : EnableWindow ( hRemoveButton , showInstalled ) ; <nl> INT_PTR CALLBACK PluginsAdminDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARA <nl> case IDC_PLUGINADM_REMOVE : <nl> { <nl> removePlugins ( ) ; <nl> - <nl> return true ; <nl> } <nl> <nl> - <nl> default : <nl> break ; <nl> } <nl> INT_PTR CALLBACK PluginsAdminDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARA <nl> switchDialog ( indexClicked ) ; <nl> } <nl> } <nl> - else if ( pnmh - > hwndFrom = = _availableListView . getHSelf ( ) | | <nl> - pnmh - > hwndFrom = = _updateListView . getHSelf ( ) | | <nl> - pnmh - > hwndFrom = = _installedListView . getHSelf ( ) ) <nl> + else if ( pnmh - > hwndFrom = = _availableList . getViewHwnd ( ) | | <nl> + pnmh - > hwndFrom = = _updateList . getViewHwnd ( ) | | <nl> + pnmh - > hwndFrom = = _installedList . getViewHwnd ( ) ) <nl> { <nl> - ListView * pListView ; <nl> - vector < PluginUpdateInfo > * pPluginInfos ; <nl> + PluginViewList * pViewList ; <nl> int buttonID ; <nl> <nl> - if ( pnmh - > hwndFrom = = _availableListView . getHSelf ( ) ) <nl> + if ( pnmh - > hwndFrom = = _availableList . getViewHwnd ( ) ) <nl> { <nl> - pListView = & _availableListView ; <nl> - pPluginInfos = & _availablePluginList ; <nl> + pViewList = & _availableList ; <nl> buttonID = IDC_PLUGINADM_INSTALL ; <nl> } <nl> - else if ( pnmh - > hwndFrom = = _updateListView . getHSelf ( ) ) <nl> + else if ( pnmh - > hwndFrom = = _updateList . getViewHwnd ( ) ) <nl> { <nl> - pListView = & _updateListView ; <nl> - pPluginInfos = & _updatePluginList ; <nl> + pViewList = & _updateList ; <nl> buttonID = IDC_PLUGINADM_UPDATE ; <nl> } <nl> - else / / pnmh - > hwndFrom = = _installedListView . getHSelf ( ) <nl> + else / / pnmh - > hwndFrom = = _installedList . getViewHwnd ( ) <nl> { <nl> - pListView = & _installedListView ; <nl> - pPluginInfos = & _installedPluginList ; <nl> + pViewList = & _installedList ; <nl> buttonID = IDC_PLUGINADM_REMOVE ; <nl> } <nl> <nl> INT_PTR CALLBACK PluginsAdminDlg : : run_dlgProc ( UINT message , WPARAM wParam , LPARA <nl> ( pnmv - > uNewState & LVIS_STATEIMAGEMASK ) = = INDEXTOSTATEIMAGEMASK ( 1 ) ) / / unchecked <nl> { <nl> HWND hButton = : : GetDlgItem ( _hSelf , buttonID ) ; <nl> - vector < size_t > checkedArray = pListView - > getCheckedIndexes ( ) ; <nl> + vector < size_t > checkedArray = pViewList - > getCheckedIndexes ( ) ; <nl> bool showButton = checkedArray . size ( ) > 0 ; <nl> <nl> : : EnableWindow ( hButton , showButton ) ; <nl> } <nl> else if ( pnmv - > uNewState & LVIS_SELECTED ) <nl> { <nl> - size_t infoIndex = pListView - > getLParamFromIndex ( pnmv - > iItem ) ; <nl> - generic_string desc = pPluginInfos - > at ( infoIndex ) . describe ( ) ; <nl> + PluginUpdateInfo * pui = pViewList - > getPluginInfoFromIndex ( pnmv - > iItem ) ; <nl> + generic_string desc = pui - > describe ( ) ; <nl> : : SetDlgItemText ( _hSelf , IDC_PLUGINADM_EDIT , desc . c_str ( ) ) ; <nl> } <nl> } <nl> mmm a / PowerEditor / src / WinControls / PluginsAdmin / pluginsAdmin . h <nl> ppp b / PowerEditor / src / WinControls / PluginsAdmin / pluginsAdmin . h <nl> struct PluginUpdateInfo <nl> { <nl> generic_string _fullFilePath ; <nl> <nl> - generic_string _id ; <nl> - generic_string _name ; <nl> + generic_string _folderName ; <nl> + generic_string _displayName ; <nl> Version _version ; <nl> generic_string _homepage ; <nl> generic_string _sourceUrl ; <nl> generic_string _description ; <nl> generic_string _author ; <nl> generic_string _md5 ; <nl> - generic_string _alias ; <nl> + generic_string _id ; <nl> generic_string _repository ; <nl> <nl> generic_string describe ( ) ; <nl> struct NppCurrentStatus <nl> bool shouldLaunchInAdmMode ( ) { return _isInProgramFiles ; } ; <nl> } ; <nl> <nl> + class PluginViewList <nl> + { <nl> + public : <nl> + PluginViewList ( ) { } ; <nl> + ~ PluginViewList ( ) { <nl> + _ui . destroy ( ) ; <nl> + for ( auto i : _list ) <nl> + { <nl> + delete i ; <nl> + } <nl> + } ; <nl> + <nl> + void pushBack ( PluginUpdateInfo * pi ) ; <nl> + HWND getViewHwnd ( ) { return _ui . getHSelf ( ) ; } ; <nl> + void displayView ( bool doShow ) const { _ui . display ( doShow ) ; } ; <nl> + std : : vector < size_t > getCheckedIndexes ( ) const { return _ui . getCheckedIndexes ( ) ; } ; <nl> + long getSelectedIndex ( ) const { return _ui . getSelectedIndex ( ) ; } ; <nl> + void setSelection ( int index ) const { _ui . setSelection ( index ) ; } ; <nl> + void initView ( HINSTANCE hInst , HWND parent ) { _ui . init ( hInst , parent ) ; } ; <nl> + void addColumn ( const columnInfo & column2Add ) { _ui . addColumn ( column2Add ) ; } ; <nl> + void reSizeView ( RECT & rc ) { _ui . reSizeTo ( rc ) ; } <nl> + void setViewStyleOption ( int32_t extraStyle ) { _ui . setStyleOption ( extraStyle ) ; } ; <nl> + size_t nbItem ( ) const { return _ui . nbItem ( ) ; } ; <nl> + PluginUpdateInfo * getPluginInfoFromIndex ( int index ) const { return reinterpret_cast < PluginUpdateInfo * > ( _ui . getLParamFromIndex ( index ) ) ; } ; <nl> + <nl> + private : <nl> + std : : vector < PluginUpdateInfo * > _list ; <nl> + ListView _ui ; <nl> + } ; <nl> + <nl> class PluginsAdminDlg final : public StaticDialog <nl> { <nl> public : <nl> PluginsAdminDlg ( ) { } ; <nl> - ~ PluginsAdminDlg ( ) { <nl> - _availableListView . destroy ( ) ; <nl> - _updateListView . destroy ( ) ; <nl> - _installedListView . destroy ( ) ; <nl> - } <nl> + ~ PluginsAdminDlg ( ) { } <nl> void init ( HINSTANCE hInst , HWND parent ) { <nl> Window : : init ( hInst , parent ) ; <nl> } ; <nl> public : <nl> } ; <nl> <nl> void switchDialog ( int indexToSwitch ) ; <nl> - <nl> - bool updateListAndLoadFromJson ( ) ; / / call GitUup for the 1st time <nl> - void updateAvailableListView ( ) ; <nl> - void updateInstalledListView ( ) ; <nl> - void updateUpdateListView ( ) ; <nl> - <nl> void setPluginsManager ( PluginsManager * pluginsManager ) { _pPluginsManager = pluginsManager ; } ; <nl> + <nl> + bool updateListAndLoadFromJson ( ) ; <nl> void setAdminMode ( bool isAdm ) { _nppCurrentStatus . _isAdminMode = isAdm ; } ; <nl> <nl> bool installPlugins ( ) ; <nl> public : <nl> private : <nl> TabBar _tab ; <nl> <nl> - ListView _availableListView ; <nl> - ListView _updateListView ; <nl> - ListView _installedListView ; <nl> - std : : vector < PluginUpdateInfo > _availablePluginList ; / / All plugins ( pluginList . json ) - installed plugins <nl> - std : : vector < PluginUpdateInfo > _updatePluginList ; / / A list returned by gitup . exe <nl> - std : : vector < PluginUpdateInfo > _installedPluginList ; / / for each installed plugin , check its json file <nl> + PluginViewList _availableList ; / / All plugins ( pluginList . json ) - installed plugins <nl> + PluginViewList _updateList ; / / A list returned by gitup . exe <nl> + PluginViewList _installedList ; / / for each installed plugin , check its json file <nl> <nl> PluginsManager * _pPluginsManager = nullptr ; <nl> NppCurrentStatus _nppCurrentStatus ; <nl> <nl> void collectNppCurrentStatusInfos ( ) ; <nl> bool searchInPlugins ( bool isNextMode ) const ; <nl> - const bool inNames = true ; <nl> - const bool inDescs = false ; <nl> + const bool _inNames = true ; <nl> + const bool _inDescs = false ; <nl> + bool isFoundInAvailableListFromIndex ( int index , generic_string str2search , bool inWhichPart ) const ; <nl> long searchFromCurrentSel ( generic_string str2search , bool inWhichPart , bool isNextMode ) const ; <nl> long searchInNamesFromCurrentSel ( generic_string str2search , bool isNextMode ) const { <nl> - return searchFromCurrentSel ( str2search , inNames , isNextMode ) ; <nl> + return searchFromCurrentSel ( str2search , _inNames , isNextMode ) ; <nl> } ; <nl> <nl> long searchInDescsFromCurrentSel ( generic_string str2search , bool isNextMode ) const { <nl> - return searchFromCurrentSel ( str2search , inDescs , isNextMode ) ; <nl> + return searchFromCurrentSel ( str2search , _inDescs , isNextMode ) ; <nl> } ; <nl> <nl> bool loadFromPluginInfos ( ) ; <nl>
Refactoring Plugin Admin codes
notepad-plus-plus/notepad-plus-plus
c30c0de0fc58b30552e96168bd066e65a9b9f4c9
2018-06-12T01:20:37Z
mmm a / src / generic / stage2 / numberparsing . h <nl> ppp b / src / generic / stage2 / numberparsing . h <nl> simdjson_really_inline error_code write_float ( const uint8_t * const src , bool neg <nl> / / 10000000000000000000000000000000000000000000e + 308 <nl> / / 3 . 1415926535897932384626433832795028841971693993751 <nl> / / <nl> + / / NOTE : This makes a * copy * of the writer and passes it to slow_float_parsing . This happens <nl> + / / because slow_float_parsing is a non - inlined function . If we passed our writer reference to <nl> + / / it , it would force it to be stored in memory , preventing the compiler from picking it apart <nl> + / / and putting into registers . i . e . if we pass it as reference , it gets slow . <nl> + / / This is what forces the skip_double , as well . <nl> error_code error = slow_float_parsing ( src , writer ) ; <nl> - / / The number was already written , but we made a copy of the writer <nl> - / / when we passed it to the parse_large_integer ( ) function , so <nl> writer . skip_double ( ) ; <nl> return error ; <nl> } <nl> simdjson_really_inline error_code write_float ( const uint8_t * const src , bool neg <nl> if ( simdjson_unlikely ( exponent < FASTFLOAT_SMALLEST_POWER ) | | ( exponent > FASTFLOAT_LARGEST_POWER ) ) { <nl> / / this is almost never going to get called ! ! ! <nl> / / we start anew , going slowly ! ! ! <nl> + / / NOTE : This makes a * copy * of the writer and passes it to slow_float_parsing . This happens <nl> + / / because slow_float_parsing is a non - inlined function . If we passed our writer reference to <nl> + / / it , it would force it to be stored in memory , preventing the compiler from picking it apart <nl> + / / and putting into registers . i . e . if we pass it as reference , it gets slow . <nl> + / / This is what forces the skip_double , as well . <nl> error_code error = slow_float_parsing ( src , writer ) ; <nl> - / / The number was already written , but we made a copy of the writer when we passed it to the <nl> - / / slow_float_parsing ( ) function , so we have to skip those tape spots now that we ' ve returned <nl> writer . skip_double ( ) ; <nl> return error ; <nl> } <nl>
Make skip_double ( ) comment more explicit
simdjson/simdjson
9b11e119d4cf994a762137322186ba4c98009780
2020-08-19T04:25:03Z
mmm a / docker / packager / deb / Dockerfile <nl> ppp b / docker / packager / deb / Dockerfile <nl> <nl> # docker build - t yandex / clickhouse - deb - builder . <nl> FROM ubuntu : 19 . 10 <nl> <nl> - RUN apt - get - - allow - unauthenticated update - y & & apt - get install - - yes wget gnupg <nl> - RUN wget - O - https : / / apt . llvm . org / llvm - snapshot . gpg . key | apt - key add - <nl> - RUN echo " deb [ trusted = yes ] http : / / apt . llvm . org / eoan / llvm - toolchain - eoan - 10 main " > > / etc / apt / sources . list <nl> + ENV DEBIAN_FRONTEND = noninteractive <nl> + <nl> + RUN \ <nl> + apt update & & \ <nl> + apt install ca - certificates lsb - release wget gnupg apt - transport - https - - yes - - no - install - recommends - - verbose - versions & & \ <nl> + wget - O - https : / / apt . llvm . org / llvm - snapshot . gpg . key | apt - key add - & & \ <nl> + export CODENAME = " $ ( lsb_release - - codename - - short | tr ' A - Z ' ' a - z ' ) " & & \ <nl> + echo " deb [ trusted = yes ] http : / / apt . llvm . org / $ { CODENAME } / llvm - toolchain - $ { CODENAME } - 10 main " > > / etc / apt / sources . list & & \ <nl> + wget " https : / / apache . bintray . com / arrow / ubuntu / apache - arrow - archive - keyring - latest - $ { CODENAME } . deb " & & \ <nl> + apt install " . / apache - arrow - archive - keyring - latest - $ { CODENAME } . deb " - - yes - - no - install - recommends - - verbose - versions & & \ <nl> + rm - v " . / apache - arrow - archive - keyring - latest - $ { CODENAME } . deb " <nl> <nl> # initial packages <nl> - RUN apt - get - - allow - unauthenticated update - y \ <nl> - & & env DEBIAN_FRONTEND = noninteractive \ <nl> - apt - get - - allow - unauthenticated install - - yes - - no - install - recommends \ <nl> + RUN apt update & & \ <nl> + apt install - - no - install - recommends \ <nl> bash \ <nl> fakeroot \ <nl> ccache \ <nl> curl \ <nl> software - properties - common \ <nl> - gnupg \ <nl> - apt - transport - https \ <nl> - ca - certificates <nl> + - - yes <nl> <nl> # Special dpkg - deb ( https : / / github . com / ClickHouse - Extras / dpkg ) version which is able <nl> # to compress files using pigz ( https : / / zlib . net / pigz / ) instead of gzip . <nl> # Significantly increase deb packaging speed and compatible with old systems <nl> - RUN curl - O https : / / clickhouse - builds . s3 . yandex . net / utils / 1 / dpkg - deb <nl> - RUN chmod + x dpkg - deb <nl> - RUN cp dpkg - deb / usr / bin <nl> + RUN curl - O https : / / clickhouse - builds . s3 . yandex . net / utils / 1 / dpkg - deb & & \ <nl> + chmod + x dpkg - deb & & \ <nl> + cp dpkg - deb / usr / bin <nl> <nl> <nl> - # Libraries from OS are only needed to test the " unbundled " build ( that is not used in production ) . <nl> - RUN apt - get - - allow - unauthenticated update - y \ <nl> - & & env DEBIAN_FRONTEND = noninteractive \ <nl> - apt - get - - allow - unauthenticated install - - yes - - no - install - recommends \ <nl> + # Libraries from OS are only needed to test the " unbundled " build ( this is not used in production ) . <nl> + RUN apt update & & \ <nl> + apt install - - no - install - recommends \ <nl> gcc - 9 \ <nl> g + + - 9 \ <nl> llvm - 10 \ <nl> + llvm - 10 - dev \ <nl> + llvm - 9 - dev \ <nl> clang - 10 \ <nl> lld - 10 \ <nl> clang - tidy - 10 \ <nl> clang - 9 \ <nl> lld - 9 \ <nl> clang - tidy - 9 \ <nl> + libssl - dev \ <nl> libicu - dev \ <nl> - libreadline - dev \ <nl> gperf \ <nl> ninja - build \ <nl> perl \ <nl> RUN apt - get - - allow - unauthenticated update - y \ <nl> zlib1g - dev \ <nl> liblz4 - dev \ <nl> libdouble - conversion - dev \ <nl> + libxml2 - dev \ <nl> librdkafka - dev \ <nl> - libpoconetssl62 \ <nl> - libpoco - dev \ <nl> libgoogle - perftools - dev \ <nl> libzstd - dev \ <nl> libltdl - dev \ <nl> RUN apt - get - - allow - unauthenticated update - y \ <nl> libcctz - dev \ <nl> libldap2 - dev \ <nl> libsasl2 - dev \ <nl> + libgsasl7 - dev \ <nl> heimdal - multidev \ <nl> - libhyperscan - dev <nl> + libhyperscan - dev \ <nl> + libbrotli - dev \ <nl> + protobuf - compiler \ <nl> + libprotoc - dev \ <nl> + libgrpc + + - dev \ <nl> + rapidjson - dev \ <nl> + libsnappy - dev \ <nl> + libparquet - dev \ <nl> + libthrift - dev \ <nl> + libavro - dev \ <nl> + libfarmhash - dev \ <nl> + libmysqlclient - dev \ <nl> + - - yes <nl> <nl> <nl> # This symlink required by gcc to find lld compiler <nl>
docker / packager / deb : new dependencies for unbundled
ClickHouse/ClickHouse
4e9b5bd31bd3e3f19ff655716b19bfe36b5b04e1
2020-08-25T17:16:40Z
mmm a / src / mongo / db / repl / minvalid . cpp <nl> ppp b / src / mongo / db / repl / minvalid . cpp <nl> <nl> # include " mongo / db / jsobj . h " <nl> # include " mongo / db / operation_context . h " <nl> # include " mongo / db / operation_context_impl . h " <nl> + # include " mongo / platform / compiler . h " <nl> # include " mongo / util / log . h " <nl> <nl> namespace mongo { <nl> namespace { <nl> } <nl> return false ; <nl> } MONGO_WRITE_CONFLICT_RETRY_LOOP_END ( & txn , " getInitialSyncFlags " , minvalidNS ) ; <nl> + <nl> + / / fixes compile errors on GCC - see SERVER - 18219 for details <nl> + MONGO_COMPILER_UNREACHABLE ; <nl> } <nl> <nl> Timestamp getMinValid ( OperationContext * txn ) { <nl> mmm a / src / mongo / db / repl / sync . cpp <nl> ppp b / src / mongo / db / repl / sync . cpp <nl> <nl> # include " mongo / db / catalog / collection . h " <nl> # include " mongo / db / catalog / database . h " <nl> # include " mongo / db / client . h " <nl> + # include " mongo / db / concurrency / write_conflict_exception . h " <nl> # include " mongo / db / curop . h " <nl> # include " mongo / db / db_raii . h " <nl> - # include " mongo / db / concurrency / write_conflict_exception . h " <nl> # include " mongo / db / jsobj . h " <nl> # include " mongo / db / operation_context . h " <nl> # include " mongo / db / record_id . h " <nl> # include " mongo / db / repl / oplogreader . h " <nl> + # include " mongo / platform / compiler . h " <nl> # include " mongo / util / assert_util . h " <nl> # include " mongo / util / log . h " <nl> <nl> namespace repl { <nl> return true ; <nl> } <nl> } MONGO_WRITE_CONFLICT_RETRY_LOOP_END ( txn , " InsertRetry " , nss . ns ( ) ) ; <nl> + <nl> + / / fixes compile errors on GCC - see SERVER - 18219 for details <nl> + MONGO_COMPILER_UNREACHABLE ; <nl> } <nl> <nl> } / / namespace repl <nl> mmm a / src / mongo / platform / compiler . h <nl> ppp b / src / mongo / platform / compiler . h <nl> <nl> * shared libraries . <nl> * <nl> * Same correct / incorrect usage as for MONGO_COMPILER_API_EXPORT . <nl> + * <nl> + * MONGO_COMPILER_UNREACHABLE <nl> + * <nl> + * Instructs the compiler that a line of code will never be reached . <nl> + * <nl> + * <nl> + * Example : <nl> + * / / code above checks that expr can only be FOO or BAR <nl> + * switch ( expr ) { <nl> + * case FOO : { . . . } <nl> + * case BAR : { . . . } <nl> + * default : <nl> + * MONGO_COMPILER_UNREACHABLE ; <nl> + * <nl> * / <nl> <nl> # if defined ( _MSC_VER ) <nl> mmm a / src / mongo / platform / compiler_gcc . h <nl> ppp b / src / mongo / platform / compiler_gcc . h <nl> <nl> <nl> # define MONGO_likely ( x ) static_cast < bool > ( __builtin_expect ( static_cast < bool > ( x ) , 1 ) ) <nl> # define MONGO_unlikely ( x ) static_cast < bool > ( __builtin_expect ( static_cast < bool > ( x ) , 0 ) ) <nl> + <nl> + # define MONGO_COMPILER_UNREACHABLE __builtin_unreachable ( ) <nl> mmm a / src / mongo / platform / compiler_msvc . h <nl> ppp b / src / mongo / platform / compiler_msvc . h <nl> <nl> <nl> # define MONGO_likely ( x ) bool ( x ) <nl> # define MONGO_unlikely ( x ) bool ( x ) <nl> + <nl> + # define MONGO_COMPILER_UNREACHABLE __assume ( 0 ) <nl>
SERVER - 18219 hint to GCC that WCE loops will actually return
mongodb/mongo
549889cef2d424790cdf82c4a4d372137aaa0439
2015-04-28T22:10:43Z
mmm a / cpp / cpptutorial . md <nl> ppp b / cpp / cpptutorial . md <nl> Then change your current directory to ` grpc - common / cpp / route_guide ` : <nl> $ cd grpc - common / cpp / route_guide <nl> ` ` ` <nl> <nl> - Although we ' ve provided the complete example so you don ' t need to generate the gRPC code yourself , if you want to try generating your own server and client interface code you can follow the setup instructions for the C + + gRPC libraries in [ grpc / grpc / INSTALL ] ( https : / / github . com / grpc / grpc / blob / master / INSTALL ) . <nl> + Although we ' ve provided the complete example so you don ' t need to generate the gRPC code yourself , if you want to try generating your own server and client interface code you can follow the setup instructions in [ the C + + quick start guide ] ( https : / / github . com / grpc / grpc - common / tree / master / cpp ) . <nl> <nl> <nl> # # Defining the service <nl> message Point { <nl> <nl> Next we need to generate the gRPC client and server interfaces from our . proto service definition . We do this using the protocol buffer compiler ` protoc ` with a special gRPC C + + plugin . <nl> <nl> - For simplicity , we ' ve provided a [ makefile ] ( https : / / github . com / grpc / grpc - common / blob / master / cpp / route_guide / Makefile ) that runs ` protoc ` for you with the appropriate plugin , input , and output ( if you want to run this yourself , make sure you ' ve followed the [ installation instructions ] ( https : / / github . com / grpc / grpc / blob / master / INSTALL ) first ) : <nl> + For simplicity , we ' ve provided a [ makefile ] ( https : / / github . com / grpc / grpc - common / blob / master / cpp / route_guide / Makefile ) that runs ` protoc ` for you with the appropriate plugin , input , and output ( if you want to run this yourself , make sure you ' ve installed protoc and followed the gRPC code [ installation instructions ] ( https : / / github . com / grpc / grpc / blob / master / INSTALL ) first ) : <nl> <nl> ` ` ` shell <nl> $ make route_guide . pb . cc <nl> Running this command generates the following files : <nl> <nl> These contain : <nl> - All the protocol buffer code to populate , serialize , and retrieve our request and response message types <nl> - - A class called ` RouteGuide ` that contains both a remote interface type ( or * stub * ) for clients to call and an abstract interface for servers to implement , both with the methods defined in the ` RouteGuide ` service . <nl> + - A class called ` RouteGuide ` that contains <nl> + - a remote interface type ( or * stub * ) for clients to call with the methods defined in the ` RouteGuide ` service . <nl> + - two abstract interfaces for servers to implement , also with the methods defined in the ` RouteGuide ` service . <nl> <nl> <nl> + < a name = " server " > < / a > <nl> # # Creating the server <nl> <nl> - First let ' s look at how we create a ` RouteGuide ` server . <nl> + First let ' s look at how we create a ` RouteGuide ` server . If you ' re only interested in creating gRPC clients , you can skip this section and go straight to [ Creating the client ] ( # client ) ( though you might find it interesting anyway ! ) . <nl> <nl> - There are two parts to making our ` RouteGuide ` service work : <nl> + There are two parts to making our ` RouteGuide ` service do its job : <nl> - Implementing the service interface generated from our service definition : doing the actual " work " of our service . <nl> - - Running a gRPC server to listen for requests from clients and return the service responses <nl> + - Running a gRPC server to listen for requests from clients and return the service responses . <nl> <nl> + You can find our example ` RouteGuide ` server in [ grpc - common / cpp / route_guide / route_guide_server . cc ] ( ( https : / / github . com / grpc / grpc - common / blob / master / cpp / route_guide / route_guide_server . cc ) . Let ' s take a closer look at how it works . <nl> <nl> + # # # Implementing RouteGuide <nl> + <nl> + As you can see , our server has a ` RouteGuideImpl ` class that implements the generated ` RouteGuide : : Service ` interface : <nl> + <nl> + ` ` ` cpp <nl> + class RouteGuideImpl final : public RouteGuide : : Service { <nl> + . . . <nl> + } <nl> + ` ` ` <nl> + In this case we ' re implementing the * synchronous * version of ` RouteGuide ` , which provides our default gRPC server behaviour . It ' s also possible to implement an asynchronous interface , ` RouteGuide : : AsyncService ` , which allows you to further customize your server ' s threading behaviour , though we won ' t look at this in this tutorial . <nl> + <nl> + ` RouteGuideImpl ` implements all our service methods . Let ' s look at the simplest type first , ` GetFeature ` , which just gets a ` Point ` from the client and returns the corresponding feature information from its database in a ` Feature ` . <nl> + <nl> + ` ` ` cpp <nl> + Status GetFeature ( ServerContext * context , const Point * point , <nl> + Feature * feature ) override { <nl> + feature - > set_name ( GetFeatureName ( * point , feature_list_ ) ) ; <nl> + feature - > mutable_location ( ) - > CopyFrom ( * point ) ; <nl> + return Status : : OK ; <nl> + } <nl> + ` ` ` <nl> + <nl> + The method is passed a context object for the RPC , the client ' s ` Point ` protocol buffer request , and a ` Feature ` protocol buffer to fill in with the response information . In the method we populate the ` Feature ` with the appropriate information , and then ` return ` with an ` OK ` status to tell gRPC that we ' ve finished dealing with the RPC and that the ` Feature ` can be returned to the client . <nl> + <nl> + Now let ' s look at something a bit more complicated - a streaming RPC . ` ListFeatures ` is a server - side streaming RPC , so we need to send back multiple ` Feature ` s to our client . <nl> + <nl> + ` ` ` cpp <nl> + Status ListFeatures ( ServerContext * context , const Rectangle * rectangle , <nl> + ServerWriter < Feature > * writer ) override { <nl> + auto lo = rectangle - > lo ( ) ; <nl> + auto hi = rectangle - > hi ( ) ; <nl> + long left = std : : min ( lo . longitude ( ) , hi . longitude ( ) ) ; <nl> + long right = std : : max ( lo . longitude ( ) , hi . longitude ( ) ) ; <nl> + long top = std : : max ( lo . latitude ( ) , hi . latitude ( ) ) ; <nl> + long bottom = std : : min ( lo . latitude ( ) , hi . latitude ( ) ) ; <nl> + for ( const Feature & f : feature_list_ ) { <nl> + if ( f . location ( ) . longitude ( ) > = left & & <nl> + f . location ( ) . longitude ( ) < = right & & <nl> + f . location ( ) . latitude ( ) > = bottom & & <nl> + f . location ( ) . latitude ( ) < = top ) { <nl> + writer - > Write ( f ) ; <nl> + } <nl> + } <nl> + return Status : : OK ; <nl> + } <nl> + ` ` ` <nl> + <nl> + As you can see , instead of getting simple request and response objects in our method parameters , this time we get a request object ( the ` Rectangle ` in which our client wants to find ` Feature ` s ) and a special ` ServerWriter ` object . In the method , we populate as many ` Feature ` objects as we need to return , writing them to the ` ServerWriter ` using its ` Write ( ) ` method . Finally , as in our simple RPC , we ` return Status : : OK ` to tell gRPC that we ' ve finished writing responses . <nl> + <nl> + If you look at the client - side streaming method ` RecordRoute ` you ' ll see it ' s quite similar , except this time we get a ` ServerReader ` instead of a request object and a single response . We use the ` ServerReader ` s ` Read ( ) ` method to repeatedly read in our client ' s requests to a request object ( in this case a ` Point ` ) until there are no more messages : the server needs to check the return value of ` Read ( ) ` after each call . If ` true ` , the stream is still good and it can continue reading ; if ` false ` the message stream has ended . <nl> + <nl> + ` ` ` cpp <nl> + while ( stream - > Read ( & point ) ) { <nl> + . . . / / process client input <nl> + } <nl> + ` ` ` <nl> + Finally , let ' s look at our bidirectional streaming RPC ` RouteChat ( ) ` . <nl> + <nl> + ` ` ` cpp <nl> + Status RouteChat ( ServerContext * context , <nl> + ServerReaderWriter < RouteNote , RouteNote > * stream ) override { <nl> + std : : vector < RouteNote > received_notes ; <nl> + RouteNote note ; <nl> + while ( stream - > Read ( & note ) ) { <nl> + for ( const RouteNote & n : received_notes ) { <nl> + if ( n . location ( ) . latitude ( ) = = note . location ( ) . latitude ( ) & & <nl> + n . location ( ) . longitude ( ) = = note . location ( ) . longitude ( ) ) { <nl> + stream - > Write ( n ) ; <nl> + } <nl> + } <nl> + received_notes . push_back ( note ) ; <nl> + } <nl> + <nl> + return Status : : OK ; <nl> + } <nl> + ` ` ` <nl> + <nl> + This time we get a ` ServerReaderWriter ` that can be used to read * and * write messages . The syntax for reading and writing here is exactly the same as for our client - streaming and server - streaming methods . Although each side will always get the other ' s messages in the order they were written , both the client and server can read and write in any order — the streams operate completely independently . <nl> + <nl> + # # # Starting the server <nl> + <nl> + Once we ' ve implemented all our methods , we also need to start up a gRPC server so that clients can actually use our service . The following snippet shows how we do this for our ` RouteGuide ` service : <nl> + <nl> + ` ` ` cpp <nl> + void RunServer ( const std : : string & db_path ) { <nl> + std : : string server_address ( " 0 . 0 . 0 . 0 : 50051 " ) ; <nl> + RouteGuideImpl service ( db_path ) ; <nl> + <nl> + ServerBuilder builder ; <nl> + builder . AddPort ( server_address ) ; <nl> + builder . RegisterService ( & service ) ; <nl> + std : : unique_ptr < Server > server ( builder . BuildAndStart ( ) ) ; <nl> + std : : cout < < " Server listening on " < < server_address < < std : : endl ; <nl> + while ( true ) { <nl> + std : : this_thread : : sleep_for ( std : : chrono : : seconds ( 5 ) ) ; <nl> + } <nl> + } <nl> + ` ` ` <nl> + As you can see , we build and start our server using a ` ServerBuilder ` . To do this , we : <nl> + <nl> + 1 . Create an instance of our service implementation class ` RouteGuideImpl ` . <nl> + 2 . Create an instance of the factory ` ServerBuilder ` class . <nl> + 3 . Specify the address and port we want to use to listen for client requests using the builder ' s ` AddPort ( ) ` method . <nl> + 4 . Register our service implementation with the builder . <nl> + 5 . Call ` BuildAndStart ( ) ` on the builder to create and start an RPC server for our service . <nl> + <nl> + _ [ is there no equivalent of the Stubby4 wait ( ) method , ie do you have to do the while ( true ) loop to keep the server running ? ] _ <nl> + <nl> + < a name = " client " > < / a > <nl> # # Creating the client <nl> <nl> + In this section , we ' ll look at creating a C + + client for our ` RouteGuide ` service . You can see our complete example client code in [ grpc - common / cpp / route_guide / route_guide_client . cc ] ( https : / / github . com / grpc / grpc - common / blob / master / cpp / route_guide / route_guide_client . cc ) . <nl> + <nl> + # # # Creating a stub <nl> + <nl> + To call service methods , we first need to create a * stub * . <nl> + <nl> + First we need to create a gRPC * channel * for our stub , specifying the server address and port we want to connect to and any special channel arguments - in our case we ' ll use the default ` ChannelArguments ` : <nl> + <nl> + ` ` ` cpp <nl> + grpc : : CreateChannelDeprecated ( " localhost : 50051 " , ChannelArguments ( ) ) ; <nl> + ` ` ` <nl> + <nl> + Now we can use the channel to create our stub using the ` NewStub ` method provided in the ` RouteGuide ` class we generated from our . proto . <nl> + <nl> + ` ` ` cpp <nl> + public : <nl> + RouteGuideClient ( std : : shared_ptr < ChannelInterface > channel , <nl> + const std : : string & db ) <nl> + : stub_ ( RouteGuide : : NewStub ( channel ) ) { <nl> + . . . <nl> + } <nl> + ` ` ` <nl> + <nl> + # # # Calling service methods <nl> + <nl> + Now let ' s look at how we call our service methods . Note that in this tutorial we ' re calling the * blocking / synchronous * versions of each method : this means that the RPC call waits for the server to respond , and will either return a response or raise an exception . <nl> + <nl> + # # # # Simple RPC <nl> + <nl> + Calling the simple RPC ` GetFeature ` is nearly as straightforward as calling a local method . <nl> + <nl> + ` ` ` cpp <nl> + Point point ; <nl> + Feature feature ; <nl> + point = MakePoint ( 409146138 , - 746188906 ) ; <nl> + GetOneFeature ( point , & feature ) ; <nl> + <nl> + . . . <nl> + <nl> + bool GetOneFeature ( const Point & point , Feature * feature ) { <nl> + ClientContext context ; <nl> + Status status = stub_ - > GetFeature ( & context , point , feature ) ; <nl> + . . . <nl> + } <nl> + ` ` ` <nl> + <nl> + As you can see , we create and populate a request protocol buffer object ( in our case ` Point ` ) , and create a response protocol buffer object for the server to fill in . We also create a ` ClientContext ` object for our call - you can optionally set RPC configuration values on this object , such as deadlines , though for now we ' ll use the default settings . Note that you cannot reuse this object between calls . Finally , we call the method on the stub , passing it the context , request , and response . If the method returns ` OK ` , then we can read the response information from the server from our response object . <nl> + <nl> + ` ` ` cpp <nl> + std : : cout < < " Found feature called " < < feature - > name ( ) < < " at " <nl> + < < feature - > location ( ) . latitude ( ) / kCoordFactor_ < < " , " <nl> + < < feature - > location ( ) . longitude ( ) / kCoordFactor_ < < std : : endl ; <nl> + ` ` ` <nl> + <nl> + # # # # Streaming RPCs <nl> + <nl> + Now let ' s look at our streaming methods . If you ' ve already read [ Creating the server ] ( # server ) some of this may look very familiar - streaming RPCs are implemented in a similar way on both sides . Here ' s where we call the server - side streaming method ` ListFeatures ` , which returns a stream of geographical ` Feature ` s : <nl> + <nl> + ` ` ` cpp <nl> + std : : unique_ptr < ClientReader < Feature > > reader ( <nl> + stub_ - > ListFeatures ( & context , rect ) ) ; <nl> + while ( reader - > Read ( & feature ) ) { <nl> + std : : cout < < " Found feature called " <nl> + < < feature . name ( ) < < " at " <nl> + < < feature . location ( ) . latitude ( ) / kCoordFactor_ < < " , " <nl> + < < feature . location ( ) . latitude ( ) / kCoordFactor_ < < std : : endl ; <nl> + } <nl> + Status status = reader - > Finish ( ) ; <nl> + ` ` ` <nl> + <nl> + Instead of passing the method a context , request , and response , we pass it a context and request and get a ` ClientReader ` object back . The client can use the ` ClientReader ` to read the server ' s responses . We use the ` ClientReader ` s ` Read ( ) ` method to repeatedly read in the server ' s responses to a response protocol buffer object ( in this case a ` Feature ` ) until there are no more messages : the client needs to check the return value of ` Read ( ) ` after each call . If ` true ` , the stream is still good and it can continue reading ; if ` false ` the message stream has ended . Finally , we call ` Finish ( ) ` on the stream to complete the call and get our RPC status . <nl> + <nl> + The client - side streaming method ` RecordRoute ` is similar , except there we pass the method a context and response object and get back a ` ClientWriter ` . <nl> + <nl> + ` ` ` cpp <nl> + std : : unique_ptr < ClientWriter < Point > > writer ( <nl> + stub_ - > RecordRoute ( & context , & stats ) ) ; <nl> + for ( int i = 0 ; i < kPoints ; i + + ) { <nl> + const Feature & f = feature_list_ [ feature_distribution ( generator ) ] ; <nl> + std : : cout < < " Visiting point " <nl> + < < f . location ( ) . latitude ( ) / kCoordFactor_ < < " , " <nl> + < < f . location ( ) . longitude ( ) / kCoordFactor_ < < std : : endl ; <nl> + if ( ! writer - > Write ( f . location ( ) ) ) { <nl> + / / Broken stream . <nl> + break ; <nl> + } <nl> + std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( <nl> + delay_distribution ( generator ) ) ) ; <nl> + } <nl> + writer - > WritesDone ( ) ; <nl> + Status status = writer - > Finish ( ) ; <nl> + if ( status . IsOk ( ) ) { <nl> + std : : cout < < " Finished trip with " < < stats . point_count ( ) < < " points \ n " <nl> + < < " Passed " < < stats . feature_count ( ) < < " features \ n " <nl> + < < " Travelled " < < stats . distance ( ) < < " meters \ n " <nl> + < < " It took " < < stats . elapsed_time ( ) < < " seconds " <nl> + < < std : : endl ; <nl> + } else { <nl> + std : : cout < < " RecordRoute rpc failed . " < < std : : endl ; <nl> + } <nl> + ` ` ` <nl> + <nl> + Once we ' ve finished writing our client ' s requests to the stream using ` Write ( ) ` , we need to call ` WritesDone ( ) ` on the stream to let gRPC know that we ' ve finished writing , then ` Finish ( ) ` to complete the call and get our RPC status . If the status is ` OK ` , our response object that we initially passed to ` RecordRoute ( ) ` will be populated with the server ' s response . <nl> + <nl> + Finally , let ' s look at our bidirectional streaming RPC ` RouteChat ( ) ` . In this case , we just pass a context to the method and get back a ` ClientReaderWriter ` , which we can use to both write and read messages . <nl> + <nl> + ` ` ` cpp <nl> + std : : shared_ptr < ClientReaderWriter < RouteNote , RouteNote > > stream ( <nl> + stub_ - > RouteChat ( & context ) ) ; <nl> + ` ` ` <nl> + <nl> + The syntax for reading and writing here is exactly the same as for our client - streaming and server - streaming methods . Although each side will always get the other ' s messages in the order they were written , both the client and server can read and write in any order — the streams operate completely independently . <nl> <nl> + # # Try it out ! <nl> <nl> + _ [ need build and run instructions here ] _ <nl> <nl> <nl> <nl>
Merge pull request from LisaFC / master
grpc/grpc
03ae2e5c315bb9b997ed70e77379e340f7660d3d
2015-02-24T21:22:33Z
mmm a / test / cpp / common / BUILD <nl> ppp b / test / cpp / common / BUILD <nl> grpc_cc_test ( <nl> ] , <nl> ) <nl> <nl> + grpc_cc_test ( <nl> + name = " time_jump_test " , <nl> + srcs = [ " time_jump_test . cc " ] , <nl> + external_deps = [ <nl> + " gtest " , <nl> + ] , <nl> + tags = [ " manual " ] , <nl> + deps = [ <nl> + " / / : grpc + + " , <nl> + " / / test / core / util : grpc_test_util " , <nl> + ] , <nl> + ) <nl> + <nl> grpc_cc_test ( <nl> name = " auth_property_iterator_test " , <nl> srcs = [ " auth_property_iterator_test . cc " ] , <nl> new file mode 100644 <nl> index 00000000000 . . 86bf012f7c0 <nl> mmm / dev / null <nl> ppp b / test / cpp / common / time_jump_test . cc <nl> <nl> + / * <nl> + * <nl> + * Copyright 2019 gRPC authors . <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> + # include < spawn . h > <nl> + # include < sstream > <nl> + # include < string > <nl> + # include < thread > <nl> + # include < vector > <nl> + <nl> + # include < grpc / grpc . h > <nl> + # include < grpc / support / log . h > <nl> + # include < gtest / gtest . h > <nl> + <nl> + # include " src / core / lib / gprpp / sync . h " <nl> + # include " src / core / lib / iomgr / closure . h " <nl> + # include " src / core / lib / iomgr / error . h " <nl> + # include " src / core / lib / iomgr / exec_ctx . h " <nl> + # include " src / core / lib / iomgr / timer . h " <nl> + # include " src / core / lib / iomgr / timer_manager . h " <nl> + # include " test / core / util / test_config . h " <nl> + <nl> + extern char * * environ ; <nl> + <nl> + void run_cmd ( const char * cmd ) { <nl> + pid_t pid ; <nl> + const char * argv [ ] = { const_cast < const char * > ( " sh " ) , <nl> + const_cast < const char * > ( " - c " ) , cmd , nullptr } ; <nl> + int status ; <nl> + <nl> + status = posix_spawn ( & pid , const_cast < const char * > ( " / bin / sh " ) , nullptr , <nl> + nullptr , const_cast < char * * > ( argv ) , environ ) ; <nl> + if ( status = = 0 ) { <nl> + if ( waitpid ( pid , & status , 0 ) = = - 1 ) { <nl> + perror ( " waitpid " ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + class TimeJumpTest : public : : testing : : TestWithParam < std : : string > { <nl> + protected : <nl> + void SetUp ( ) override { grpc_init ( ) ; } <nl> + void TearDown ( ) override { <nl> + run_cmd ( " sudo sntp - sS pool . ntp . org " ) ; <nl> + grpc_shutdown_blocking ( ) ; <nl> + } <nl> + <nl> + const int kWaitTimeMs = 1500 ; <nl> + } ; <nl> + <nl> + std : : vector < std : : string > CreateTestScenarios ( ) { <nl> + return { " - 1M " , " + 1M " , " - 1H " , " + 1H " , " - 1d " , " + 1d " , " - 1y " , " + 1y " } ; <nl> + } <nl> + INSTANTIATE_TEST_CASE_P ( TimeJump , TimeJumpTest , <nl> + : : testing : : ValuesIn ( CreateTestScenarios ( ) ) ) ; <nl> + <nl> + TEST_P ( TimeJumpTest , TimerRunning ) { <nl> + grpc_core : : ExecCtx exec_ctx ; <nl> + grpc_timer timer ; <nl> + grpc_timer_init ( & timer , grpc_core : : ExecCtx : : Get ( ) - > Now ( ) + 3000 , <nl> + GRPC_CLOSURE_CREATE ( <nl> + [ ] ( void * , grpc_error * error ) { <nl> + GPR_ASSERT ( error = = GRPC_ERROR_CANCELLED ) ; <nl> + } , <nl> + nullptr , grpc_schedule_on_exec_ctx ) ) ; <nl> + gpr_sleep_until ( grpc_timeout_milliseconds_to_deadline ( 100 ) ) ; <nl> + std : : ostringstream cmd ; <nl> + cmd < < " sudo date ` date - v " < < GetParam ( ) < < " \ " + % m % d % H % M % y \ " ` " ; <nl> + run_cmd ( cmd . str ( ) . c_str ( ) ) ; <nl> + gpr_sleep_until ( grpc_timeout_milliseconds_to_deadline ( kWaitTimeMs ) ) ; <nl> + / / We expect 1 wakeup / sec when there are not timer expiries <nl> + int64_t wakeups = grpc_timer_manager_get_wakeups_testonly ( ) ; <nl> + gpr_log ( GPR_DEBUG , " wakeups : % " PRId64 " " , wakeups ) ; <nl> + GPR_ASSERT ( wakeups < = 3 ) ; <nl> + grpc_timer_cancel ( & timer ) ; <nl> + } <nl> + <nl> + TEST_P ( TimeJumpTest , TimedWait ) { <nl> + grpc_core : : CondVar cond ; <nl> + grpc_core : : Mutex mu ; <nl> + { <nl> + grpc_core : : MutexLock lock ( & mu ) ; <nl> + std : : thread thd = std : : thread ( [ ] ( ) { <nl> + gpr_sleep_until ( grpc_timeout_milliseconds_to_deadline ( 100 ) ) ; <nl> + std : : ostringstream cmd ; <nl> + cmd < < " sudo date ` date - v " < < GetParam ( ) < < " \ " + % m % d % H % M % y \ " ` " ; <nl> + run_cmd ( cmd . str ( ) . c_str ( ) ) ; <nl> + } ) ; <nl> + gpr_timespec before = gpr_now ( GPR_CLOCK_MONOTONIC ) ; <nl> + int timedout = cond . Wait ( <nl> + & mu , grpc_millis_to_timespec ( kWaitTimeMs , GPR_CLOCK_REALTIME ) ) ; <nl> + gpr_timespec after = gpr_now ( GPR_CLOCK_MONOTONIC ) ; <nl> + int32_t elapsed_ms = gpr_time_to_millis ( gpr_time_sub ( after , before ) ) ; <nl> + gpr_log ( GPR_DEBUG , " After wait , timedout = % d elapsed_ms = % d " , timedout , <nl> + elapsed_ms ) ; <nl> + GPR_ASSERT ( 1 = = timedout ) ; <nl> + GPR_ASSERT ( 1 = = <nl> + gpr_time_similar ( gpr_time_sub ( after , before ) , <nl> + gpr_time_from_millis ( kWaitTimeMs , GPR_TIMESPAN ) , <nl> + gpr_time_from_millis ( 10 , GPR_TIMESPAN ) ) ) ; <nl> + <nl> + thd . join ( ) ; <nl> + } <nl> + / / We expect 1 wakeup / sec when there are not timer expiries <nl> + int64_t wakeups = grpc_timer_manager_get_wakeups_testonly ( ) ; <nl> + gpr_log ( GPR_DEBUG , " wakeups : % " PRId64 " " , wakeups ) ; <nl> + GPR_ASSERT ( wakeups < = 3 ) ; <nl> + } <nl> + <nl> + int main ( int argc , char * * argv ) { <nl> + grpc : : testing : : TestEnvironment env ( argc , argv ) ; <nl> + : : testing : : InitGoogleTest ( & argc , argv ) ; <nl> + return RUN_ALL_TESTS ( ) ; <nl> + } <nl> mmm a / tools / internal_ci / macos / grpc_run_bazel_tests . sh <nl> ppp b / tools / internal_ci / macos / grpc_run_bazel_tests . sh <nl> set - ex <nl> # change to grpc repo root <nl> cd $ ( dirname $ 0 ) / . . / . . / . . <nl> <nl> - # Download bazel <nl> - temp_dir = " $ ( mktemp - d ) " <nl> - wget - q https : / / github . com / bazelbuild / bazel / releases / download / 0 . 26 . 0 / bazel - 0 . 26 . 0 - darwin - x86_64 - O " $ { temp_dir } / bazel " <nl> - chmod 755 " $ { temp_dir } / bazel " <nl> - export PATH = " $ { temp_dir } : $ { PATH } " <nl> - # This should show $ { temp_dir } / bazel <nl> - which bazel <nl> - <nl> . / tools / run_tests / start_port_server . py <nl> <nl> # run cfstream_test separately because it messes with the network <nl> - bazel test $ RUN_TESTS_FLAGS - - spawn_strategy = standalone - - genrule_strategy = standalone - - test_output = all / / test / cpp / end2end : cfstream_test <nl> + tools / bazel test $ RUN_TESTS_FLAGS - - spawn_strategy = standalone - - genrule_strategy = standalone - - test_output = all / / test / cpp / end2end : cfstream_test <nl> + <nl> + # run time_jump_test separately because it changes system time <nl> + tools / bazel test $ RUN_TESTS_FLAGS - - spawn_strategy = standalone - - genrule_strategy = standalone - - test_output = all / / test / cpp / common : time_jump_test <nl> <nl> # kill port_server . py to prevent the build from hanging <nl> ps aux | grep port_server \ \ . py | awk ' { print $ 2 } ' | xargs kill - 9 <nl>
Merge pull request from rmstar / timejumptest
grpc/grpc
06f85fc987a513f77a7ce9a59baa552dbe04872d
2019-08-30T07:31:55Z
mmm a / README . md <nl> ppp b / README . md <nl> Alternatively , if you ' re using Linux and have a supported NVIDIA GPU ( See the re <nl> npm install deepspeech - gpu <nl> ` ` ` <nl> <nl> - See [ client . js ] ( native_client / javascript / client . js ) for an example of how to use the bindings . <nl> + See [ client . js ] ( native_client / javascript / client . js ) for an example of how to use the bindings . Or download the [ wav example ] ( examples / nodejs_wav ) . <nl> <nl> Please ensure you have the required [ CUDA dependency ] ( # cuda - dependency ) . <nl> <nl> new file mode 100644 <nl> index 000000000 . . 8dce9a5c2 <nl> mmm / dev / null <nl> ppp b / examples / nodejs_wav / Readme . md <nl> <nl> + # NodeJS voice recognition example using Mozilla DeepSpeech <nl> + <nl> + Download the pre - trained model ( 1 . 8GB ) : <nl> + <nl> + ` ` ` <nl> + wget https : / / github . com / mozilla / DeepSpeech / releases / download / v0 . 4 . 1 / deepspeech - 0 . 4 . 1 - models . tar . gz <nl> + tar xvfz deepspeech - 0 . 4 . 1 - models . tar . gz <nl> + ` ` ` <nl> + <nl> + Edit references to models path if necessary : <nl> + <nl> + ` ` ` <nl> + let modelPath = ' . / models / output_graph . pbmm ' ; <nl> + let alphabetPath = ' . / models / alphabet . txt ' ; <nl> + let lmPath = ' . / models / lm . binary ' ; <nl> + let triePath = ' . / models / trie ' ; <nl> + ` ` ` <nl> + <nl> + Install Sox ( for . wav file loading ) : <nl> + <nl> + ` ` ` <nl> + brew install sox <nl> + ` ` ` <nl> + <nl> + Download test audio files : <nl> + <nl> + ` ` ` <nl> + wget https : / / github . com / mozilla / DeepSpeech / releases / download / v0 . 4 . 1 / audio - 0 . 4 . 1 . tar . gz <nl> + tar xfvz audio - 0 . 4 . 1 . tar . gz <nl> + ` ` ` <nl> + <nl> + Install NPM dependencies : <nl> + <nl> + ` ` ` <nl> + npm install <nl> + ` ` ` <nl> + <nl> + Run : <nl> + <nl> + ` ` ` <nl> + node index . js <nl> + ` ` ` <nl> + <nl> + Result should be something like : <nl> + <nl> + ` ` ` <nl> + audio length 1 . 975 <nl> + result : experience proves this <nl> + <nl> + ` ` ` <nl> + <nl> + Try other wav files with an argument : <nl> + <nl> + ` ` ` <nl> + node index . js audio / 2830 - 3980 - 0043 . wav <nl> + node index . js audio / 8455 - 210777 - 0068 . wav <nl> + node index . js audio / 4507 - 16021 - 0012 . wav <nl> + ` ` ` <nl> + <nl> new file mode 100644 <nl> index 000000000 . . 0b56b35c7 <nl> mmm / dev / null <nl> ppp b / examples / nodejs_wav / index . js <nl> <nl> + const DeepSpeech = require ( ' deepspeech ' ) ; <nl> + const Fs = require ( ' fs ' ) ; <nl> + const Sox = require ( ' sox - stream ' ) ; <nl> + const MemoryStream = require ( ' memory - stream ' ) ; <nl> + const Duplex = require ( ' stream ' ) . Duplex ; <nl> + const Wav = require ( ' node - wav ' ) ; <nl> + <nl> + const BEAM_WIDTH = 1024 ; <nl> + const N_FEATURES = 26 ; <nl> + const N_CONTEXT = 9 ; <nl> + let modelPath = ' . / models / output_graph . pbmm ' ; <nl> + let alphabetPath = ' . / models / alphabet . txt ' ; <nl> + <nl> + let model = new DeepSpeech . Model ( modelPath , N_FEATURES , N_CONTEXT , alphabetPath , BEAM_WIDTH ) ; <nl> + <nl> + const LM_ALPHA = 0 . 75 ; <nl> + const LM_BETA = 1 . 85 ; <nl> + let lmPath = ' . / models / lm . binary ' ; <nl> + let triePath = ' . / models / trie ' ; <nl> + <nl> + model . enableDecoderWithLM ( alphabetPath , lmPath , triePath , LM_ALPHA , LM_BETA ) ; <nl> + <nl> + let audioFile = process . argv [ 2 ] | | ' . / audio / 2830 - 3980 - 0043 . wav ' ; <nl> + <nl> + if ( ! Fs . existsSync ( audioFile ) ) { <nl> + console . log ( ' file missing : ' , audioFile ) ; <nl> + process . exit ( ) ; <nl> + } <nl> + <nl> + const buffer = Fs . readFileSync ( audioFile ) ; <nl> + const result = Wav . decode ( buffer ) ; <nl> + <nl> + if ( result . sampleRate < 16000 ) { <nl> + console . error ( ' Warning : original sample rate ( ' + result . sampleRate + ' ) is lower than 16kHz . Up - sampling might produce erratic speech recognition . ' ) ; <nl> + } <nl> + <nl> + function bufferToStream ( buffer ) { <nl> + let stream = new Duplex ( ) ; <nl> + stream . push ( buffer ) ; <nl> + stream . push ( null ) ; <nl> + return stream ; <nl> + } <nl> + <nl> + let audioStream = new MemoryStream ( ) ; <nl> + bufferToStream ( buffer ) . <nl> + pipe ( Sox ( { <nl> + global : { <nl> + ' no - dither ' : true , <nl> + } , <nl> + output : { <nl> + bits : 16 , <nl> + rate : 16000 , <nl> + channels : 1 , <nl> + encoding : ' signed - integer ' , <nl> + endian : ' little ' , <nl> + compression : 0 . 0 , <nl> + type : ' raw ' <nl> + } <nl> + } ) ) . <nl> + pipe ( audioStream ) ; <nl> + <nl> + audioStream . on ( ' finish ' , ( ) = > { <nl> + <nl> + let audioBuffer = audioStream . toBuffer ( ) ; <nl> + <nl> + const audioLength = ( audioBuffer . length / 2 ) * ( 1 / 16000 ) ; <nl> + console . log ( ' audio length ' , audioLength ) ; <nl> + <nl> + let result = model . stt ( audioBuffer . slice ( 0 , audioBuffer . length / 2 ) , 16000 ) ; <nl> + <nl> + console . log ( ' result : ' , result ) ; <nl> + } ) ; <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000 . . bbf0824fe <nl> mmm / dev / null <nl> ppp b / examples / nodejs_wav / package . json <nl> <nl> + { <nl> + " name " : " deepspeech - nodejs_wav " , <nl> + " version " : " 1 . 0 . 0 " , <nl> + " description " : " Simple audio processing " , <nl> + " main " : " index . js " , <nl> + " scripts " : { <nl> + " start " : " node . / index . js " <nl> + } , <nl> + " dependencies " : { <nl> + " argparse " : " ^ 1 . 0 . 10 " , <nl> + " deepspeech " : " ^ 0 . 4 . 1 " , <nl> + " node - wav " : " 0 . 0 . 2 " , <nl> + " sox - stream " : " ^ 2 . 0 . 3 " , <nl> + " util " : " ^ 0 . 11 . 1 " <nl> + } , <nl> + " license " : " Public domain " <nl> + } <nl>
Merge pull request from dsteinman / nodejs - example
mozilla/DeepSpeech
dca8c40ae972698ee8dfd16b76e21668fa6d9b61
2019-03-04T11:03:19Z
mmm a / apps / sft / CMakeLists . txt <nl> ppp b / apps / sft / CMakeLists . txt <nl> if ( IOS OR ANDROID ) <nl> return ( ) <nl> endif ( ) <nl> <nl> - set ( the_target stf ) <nl> + set ( the_target sft ) <nl> set ( name $ { the_target } ) <nl> <nl> set ( OPENCV_ $ { the_target } _DEPS opencv_core opencv_objdetect opencv_highgui opencv_imgproc opencv_ml ) <nl>
fix typo
opencv/opencv
c0910921748334003e9a15fe3054882d43a751ed
2013-02-01T10:34:39Z
mmm a / src / ast / ast . cc <nl> ppp b / src / ast / ast . cc <nl> IterationStatement * AstNode : : AsIterationStatement ( ) { <nl> } <nl> } <nl> <nl> - BreakableStatement * AstNode : : AsBreakableStatement ( ) { <nl> - switch ( node_type ( ) ) { <nl> - BREAKABLE_NODE_LIST ( RETURN_NODE ) ; <nl> - ITERATION_NODE_LIST ( RETURN_NODE ) ; <nl> - default : <nl> - return nullptr ; <nl> - } <nl> - } <nl> - <nl> MaterializedLiteral * AstNode : : AsMaterializedLiteral ( ) { <nl> switch ( node_type ( ) ) { <nl> LITERAL_NODE_LIST ( RETURN_NODE ) ; <nl> mmm a / src / ast / ast . h <nl> ppp b / src / ast / ast . h <nl> class AstNode : public ZoneObject { <nl> FAILURE_NODE_LIST ( DECLARE_NODE_FUNCTIONS ) <nl> # undef DECLARE_NODE_FUNCTIONS <nl> <nl> - BreakableStatement * AsBreakableStatement ( ) ; <nl> IterationStatement * AsIterationStatement ( ) ; <nl> MaterializedLiteral * AsMaterializedLiteral ( ) ; <nl> <nl>
[ ast ] Remove dead code identified by coverage reports
v8/v8
ceaaaf14a23e8c9583b654f2fa46c0024c90e795
2018-12-21T16:55:08Z
new file mode 100644 <nl> index 00000000000 . . 7330bcdd559 <nl> mmm / dev / null <nl> ppp b / src / Disks / Executor . h <nl> <nl> + # pragma once <nl> + <nl> + # include < future > <nl> + # include < functional > <nl> + <nl> + namespace DB <nl> + { <nl> + <nl> + / / / Interface to run task asynchronously with possibility to wait for execution . <nl> + class Executor <nl> + { <nl> + public : <nl> + virtual ~ Executor ( ) = default ; <nl> + virtual std : : future < void > execute ( std : : function < void ( ) > task ) = 0 ; <nl> + } ; <nl> + <nl> + / / / Executes task synchronously in case when disk doesn ' t support async operations . <nl> + class SyncExecutor : public Executor <nl> + { <nl> + public : <nl> + SyncExecutor ( ) = default ; <nl> + std : : future < void > execute ( std : : function < void ( ) > task ) override <nl> + { <nl> + auto promise = std : : make_shared < std : : promise < void > > ( ) ; <nl> + try <nl> + { <nl> + task ( ) ; <nl> + promise - > set_value ( ) ; <nl> + } <nl> + catch ( . . . ) <nl> + { <nl> + try <nl> + { <nl> + promise - > set_exception ( std : : current_exception ( ) ) ; <nl> + } <nl> + catch ( . . . ) { } <nl> + } <nl> + return promise - > get_future ( ) ; <nl> + } <nl> + } ; <nl> + <nl> + } <nl> mmm a / src / Disks / IDisk . cpp <nl> ppp b / src / Disks / IDisk . cpp <nl> <nl> # include " IDisk . h " <nl> - # include < IO / copyData . h > <nl> + # include " Disks / Executor . h " <nl> # include < IO / ReadBufferFromFileBase . h > <nl> # include < IO / WriteBufferFromFileBase . h > <nl> + # include < IO / copyData . h > <nl> # include < Poco / Logger . h > <nl> # include < common / logger_useful . h > <nl> + # include < Common / setThreadName . h > <nl> <nl> namespace DB <nl> { <nl> void copyFile ( IDisk & from_disk , const String & from_path , IDisk & to_disk , cons <nl> copyData ( * in , * out ) ; <nl> } <nl> <nl> - void IDisk : : copy ( const String & from_path , const std : : shared_ptr < IDisk > & to_disk , const String & to_path ) <nl> + <nl> + using ResultsCollector = std : : vector < std : : future < void > > ; <nl> + <nl> + void asyncCopy ( IDisk & from_disk , String from_path , IDisk & to_disk , String to_path , Executor & exec , ResultsCollector & results ) <nl> { <nl> - if ( isFile ( from_path ) ) <nl> + if ( from_disk . isFile ( from_path ) ) <nl> { <nl> - DB : : copyFile ( * this , from_path , * to_disk , to_path + fileName ( from_path ) ) ; <nl> + auto result = exec . execute ( <nl> + [ & from_disk , from_path , & to_disk , to_path ] ( ) <nl> + { <nl> + setThreadName ( " DiskCopier " ) ; <nl> + DB : : copyFile ( from_disk , from_path , to_disk , to_path + fileName ( from_path ) ) ; <nl> + } ) ; <nl> + <nl> + results . push_back ( std : : move ( result ) ) ; <nl> } <nl> else <nl> { <nl> Poco : : Path path ( from_path ) ; <nl> const String & dir_name = path . directory ( path . depth ( ) - 1 ) ; <nl> const String dest = to_path + dir_name + " / " ; <nl> - to_disk - > createDirectories ( dest ) ; <nl> + to_disk . createDirectories ( dest ) ; <nl> <nl> - for ( auto it = iterateDirectory ( from_path ) ; it - > isValid ( ) ; it - > next ( ) ) <nl> - { <nl> - copy ( it - > path ( ) , to_disk , dest ) ; <nl> - } <nl> + for ( auto it = from_disk . iterateDirectory ( from_path ) ; it - > isValid ( ) ; it - > next ( ) ) <nl> + asyncCopy ( from_disk , it - > path ( ) , to_disk , dest , exec , results ) ; <nl> } <nl> } <nl> <nl> + void IDisk : : copy ( const String & from_path , const std : : shared_ptr < IDisk > & to_disk , const String & to_path ) <nl> + { <nl> + auto & exec = to_disk - > getExecutor ( ) ; <nl> + ResultsCollector results ; <nl> + <nl> + asyncCopy ( * this , from_path , * to_disk , to_path , exec , results ) ; <nl> + <nl> + for ( auto & result : results ) <nl> + result . wait ( ) ; <nl> + for ( auto & result : results ) <nl> + result . get ( ) ; <nl> + } <nl> + <nl> void IDisk : : truncateFile ( const String & , size_t ) <nl> { <nl> throw Exception ( ErrorCodes : : NOT_IMPLEMENTED , " Truncate operation is not implemented for disk of type { } " , getType ( ) ) ; <nl> mmm a / src / Disks / IDisk . h <nl> ppp b / src / Disks / IDisk . h <nl> <nl> # include < Core / Types . h > <nl> # include < Common / CurrentMetrics . h > <nl> # include < Common / Exception . h > <nl> + # include < Disks / Executor . h > <nl> <nl> # include < memory > <nl> # include < mutex > <nl> using SpacePtr = std : : shared_ptr < Space > ; <nl> class IDisk : public Space <nl> { <nl> public : <nl> + / / / Default constructor . <nl> + explicit IDisk ( std : : unique_ptr < Executor > executor_ = std : : make_unique < SyncExecutor > ( ) ) : executor ( std : : move ( executor_ ) ) { } <nl> + <nl> / / / Root path for all files stored on the disk . <nl> / / / It ' s not required to be a local filesystem path . <nl> virtual const String & getPath ( ) const = 0 ; <nl> class IDisk : public Space <nl> <nl> / / / Return disk type - " local " , " s3 " , etc . <nl> virtual const String getType ( ) const = 0 ; <nl> + <nl> + private : <nl> + / / / Returns executor to perform asynchronous operations . <nl> + Executor & getExecutor ( ) { return * executor ; } <nl> + <nl> + std : : unique_ptr < Executor > executor ; <nl> } ; <nl> <nl> using DiskPtr = std : : shared_ptr < IDisk > ; <nl> mmm a / src / Disks / S3 / DiskS3 . cpp <nl> ppp b / src / Disks / S3 / DiskS3 . cpp <nl> class DiskS3Reservation final : public IReservation <nl> CurrentMetrics : : Increment metric_increment ; <nl> } ; <nl> <nl> + / / / Runs tasks asynchronously using global thread pool . <nl> + class AsyncExecutor : public Executor <nl> + { <nl> + public : <nl> + explicit AsyncExecutor ( ) = default ; <nl> + <nl> + std : : future < void > execute ( std : : function < void ( ) > task ) override <nl> + { <nl> + auto promise = std : : make_shared < std : : promise < void > > ( ) ; <nl> + <nl> + GlobalThreadPool : : instance ( ) . scheduleOrThrowOnError ( <nl> + [ promise , task ] ( ) <nl> + { <nl> + try <nl> + { <nl> + task ( ) ; <nl> + promise - > set_value ( ) ; <nl> + } <nl> + catch ( . . . ) <nl> + { <nl> + tryLogCurrentException ( & Poco : : Logger : : get ( " DiskS3 " ) , " Failed to run async task " ) ; <nl> + <nl> + try <nl> + { <nl> + promise - > set_exception ( std : : current_exception ( ) ) ; <nl> + } catch ( . . . ) { } <nl> + } <nl> + } ) ; <nl> + <nl> + return promise - > get_future ( ) ; <nl> + } <nl> + } ; <nl> + <nl> <nl> DiskS3 : : DiskS3 ( <nl> String name_ , <nl> DiskS3 : : DiskS3 ( <nl> size_t min_upload_part_size_ , <nl> size_t min_multi_part_upload_size_ , <nl> size_t min_bytes_for_seek_ ) <nl> - : name ( std : : move ( name_ ) ) <nl> + : IDisk ( std : : make_unique < AsyncExecutor > ( ) ) <nl> + , name ( std : : move ( name_ ) ) <nl> , client ( std : : move ( client_ ) ) <nl> , proxy_configuration ( std : : move ( proxy_configuration_ ) ) <nl> , bucket ( std : : move ( bucket_ ) ) <nl> mmm a / src / Disks / S3 / DiskS3 . h <nl> ppp b / src / Disks / S3 / DiskS3 . h <nl> <nl> # pragma once <nl> <nl> # include " Disks / DiskFactory . h " <nl> + # include " Disks / Executor . h " <nl> # include " ProxyConfiguration . h " <nl> <nl> # include < aws / s3 / S3Client . h > <nl> <nl> <nl> namespace DB <nl> { <nl> + <nl> / * * <nl> * Storage for persisting data in S3 and metadata on the local disk . <nl> * Files are represented by file in local filesystem ( clickhouse_root / disks / disk_name / path / to / file ) <nl> mmm a / tests / integration / test_merge_tree_s3 / test . py <nl> ppp b / tests / integration / test_merge_tree_s3 / test . py <nl> def test_move_partition_to_another_disk ( cluster ) : <nl> assert node . query ( " SELECT count ( * ) FROM s3_test FORMAT Values " ) = = " ( 8192 ) " <nl> assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = FILES_OVERHEAD + FILES_OVERHEAD_PER_PART_WIDE <nl> <nl> + node . query ( " ALTER TABLE s3_test MOVE PARTITION ' 2020 - 01 - 04 ' TO DISK ' s3 ' " ) <nl> + assert node . query ( " SELECT count ( * ) FROM s3_test FORMAT Values " ) = = " ( 8192 ) " <nl> + assert len ( list ( minio . list_objects ( cluster . minio_bucket , ' data / ' ) ) ) = = FILES_OVERHEAD + FILES_OVERHEAD_PER_PART_WIDE * 2 <nl> + <nl> <nl> def test_table_manipulations ( cluster ) : <nl> create_table ( cluster , " s3_test " ) <nl>
Merge pull request from Jokser / s3 - multithreaded - disk - copy
ClickHouse/ClickHouse
ef5882639bd5b5e98ed6e34e6f8a177e64289661
2020-08-12T04:36:03Z
mmm a / doc / files . md <nl> ppp b / doc / files . md <nl> <nl> * blocks / rev000 ? ? . dat ; block undo data ( custom ) ; since 0 . 8 . 0 ( format changed since pre - 0 . 8 ) <nl> * blocks / index / * ; block index ( LevelDB ) ; since 0 . 8 . 0 <nl> * chainstate / * ; block chain state database ( LevelDB ) ; since 0 . 8 . 0 <nl> - * database / * : BDB database environment ; only used for wallet since 0 . 8 . 0 <nl> - * db . log : wallet database log file <nl> + * database / * : BDB database environment ; only used for wallet since 0 . 8 . 0 ; moved to wallets / directory on new installs since 0 . 16 . 0 <nl> + * db . log : wallet database log file ; moved to wallets / directory on new installs since 0 . 16 . 0 <nl> * debug . log : contains debug information and general logging generated by bitcoind or bitcoin - qt <nl> * fee_estimates . dat : stores statistics used to estimate minimum transaction fees and priorities required for confirmation ; since 0 . 10 . 0 <nl> * mempool . dat : dump of the mempool ' s transactions ; since 0 . 14 . 0 . <nl> * peers . dat : peer IP address database ( custom format ) ; since 0 . 7 . 0 <nl> - * wallet . dat : personal wallet ( BDB ) with keys and transactions <nl> + * wallet . dat : personal wallet ( BDB ) with keys and transactions ; moved to wallets / directory on new installs since 0 . 16 . 0 <nl> + * wallets / database / * : BDB database environment ; used for wallets since 0 . 16 . 0 <nl> + * wallets / db . log : wallet database log file ; since 0 . 16 . 0 <nl> + * wallets / wallet . dat : personal wallet ( BDB ) with keys and transactions ; since 0 . 16 . 0 <nl> * . cookie : session RPC authentication cookie ( written at start when cookie authentication is used , deleted on shutdown ) : since 0 . 12 . 0 <nl> * onion_private_key : cached Tor hidden service private key for ` - listenonion ` : since 0 . 12 . 0 <nl> * guisettings . ini . bak : backup of former GUI settings after ` - resetguisettings ` is used <nl>
Update files . md for new wallets / subdirectory
bitcoin/bitcoin
aac6b3f06717626b88cdfd140f2cc1a3f2dde4be
2017-12-13T10:36:43Z
mmm a / osquery / tables / system / linux / pci_devices . cpp <nl> ppp b / osquery / tables / system / linux / pci_devices . cpp <nl> <nl> # include " osquery / database . h " <nl> <nl> namespace osquery { <nl> - namespace tables { <nl> + namespace tables { <nl> <nl> - const char * kSlot = " PCI_SLOT_NAME " ; <nl> - const char * kClass = " ID_PCI_CLASS_FROM_DATABASE " ; <nl> - const char * kVendor = " ID_VENDOR_FROM_DATABASE " ; <nl> - const char * kModel = " ID_MODEL_FROM_DATABASE " ; <nl> + const std : : string kSlot = " PCI_SLOT_NAME " ; <nl> + const std : : string kClass = " ID_PCI_CLASS_FROM_DATABASE " ; <nl> + const std : : string kVendor = " ID_VENDOR_FROM_DATABASE " ; <nl> + const std : : string kModel = " ID_MODEL_FROM_DATABASE " ; <nl> <nl> - struct udev * udev ; <nl> - struct udev_enumerate * enumerate ; <nl> - struct udev_list_entry * devices , * dev_list_entry ; <nl> - struct udev_device * dev ; <nl> + struct udev * udev ; <nl> + struct udev_enumerate * enumerate ; <nl> + struct udev_list_entry * devices , * dev_list_entry ; <nl> + struct udev_device * dev ; <nl> <nl> - QueryData genLspci ( ) { <nl> - QueryData results ; <nl> + QueryData genLspci ( ) { <nl> + QueryData results ; <nl> <nl> - / * Create the udev object * / <nl> - udev = udev_new ( ) ; <nl> - if ( ! udev ) { <nl> - LOG ( ERROR ) < < " Can ' t create udev object " ; <nl> - return results ; <nl> - } <nl> + / / Create the udev object <nl> + udev = udev_new ( ) ; <nl> + if ( ! udev ) { <nl> + LOG ( ERROR ) < < " Can ' t create udev object " ; <nl> + return results ; <nl> + } <nl> <nl> - / * Enumerate the list of all PCI devices * / <nl> - enumerate = udev_enumerate_new ( udev ) ; <nl> - udev_enumerate_add_match_subsystem ( enumerate , " pci " ) ; <nl> - udev_enumerate_scan_devices ( enumerate ) ; <nl> - devices = udev_enumerate_get_list_entry ( enumerate ) ; <nl> + / / Enumerate the list of all PCI devices <nl> + enumerate = udev_enumerate_new ( udev ) ; <nl> + udev_enumerate_add_match_subsystem ( enumerate , " pci " ) ; <nl> + udev_enumerate_scan_devices ( enumerate ) ; <nl> + devices = udev_enumerate_get_list_entry ( enumerate ) ; <nl> <nl> - / * udev_list_entry_foreach is a macro which expands to <nl> - a loop . The loop will be executed for each member in <nl> - devices , setting dev_list_entry to a list entry <nl> - which contains the device ' s path in / sys . * / <nl> + / / udev_list_entry_foreach is a macro which expands to <nl> + / / a loop . The loop will be executed for each member in <nl> + / / devices , setting dev_list_entry to a list entry <nl> + / / which contains the device ' s path in / sys . <nl> <nl> - udev_list_entry_foreach ( dev_list_entry , devices ) { <nl> - const char * path ; <nl> + udev_list_entry_foreach ( dev_list_entry , devices ) { <nl> + const char * path ; <nl> <nl> - / * Get the filename of the / sys entry for the PCI device <nl> - and create a udev_device object ( dev ) representing it * / <nl> - path = udev_list_entry_get_name ( dev_list_entry ) ; <nl> - dev = udev_device_new_from_syspath ( udev , path ) ; <nl> + / / Get the filename of the / sys entry for the PCI device <nl> + / / and create a udev_device object ( dev ) representing it <nl> + path = udev_list_entry_get_name ( dev_list_entry ) ; <nl> + dev = udev_device_new_from_syspath ( udev , path ) ; <nl> <nl> - Row r ; <nl> - r [ " slot " ] = boost : : lexical_cast < std : : string > <nl> - ( udev_device_get_property_value ( dev , kSlot ) ) ; <nl> - r [ " device_class " ] = boost : : lexical_cast < std : : string > <nl> - ( udev_device_get_property_value ( dev , kClass ) ) ; <nl> - r [ " vendor " ] = boost : : lexical_cast < std : : string > <nl> - ( udev_device_get_property_value ( dev , kVendor ) ) ; <nl> - r [ " model " ] = boost : : lexical_cast < std : : string > <nl> - ( udev_device_get_property_value ( dev , kModel ) ) ; <nl> - results . push_back ( r ) ; <nl> - } <nl> - return results ; <nl> - } <nl> - } <nl> + Row r ; <nl> + r [ " slot " ] = boost : : lexical_cast < std : : string > ( <nl> + udev_device_get_property_value ( dev , kSlot . c_str ( ) ) ) ; <nl> + r [ " device_class " ] = boost : : lexical_cast < std : : string > ( <nl> + udev_device_get_property_value ( dev , kClass . c_str ( ) ) ) ; <nl> + r [ " vendor " ] = boost : : lexical_cast < std : : string > ( <nl> + udev_device_get_property_value ( dev , kVendor . c_str ( ) ) ) ; <nl> + r [ " model " ] = boost : : lexical_cast < std : : string > ( <nl> + udev_device_get_property_value ( dev , kModel . c_str ( ) ) ) ; <nl> + results . push_back ( r ) ; <nl> + } <nl> + return results ; <nl> + } <nl> + } <nl> } <nl>
changed comments to / / from / * , char * to std : : string consts , and ran clang - format on the file
osquery/osquery
c99c08c6072e5a0a2d1384b2d8b8fd0152a9fa6c
2014-11-03T04:09:04Z
mmm a / tensorflow / core / api_def / BUILD <nl> ppp b / tensorflow / core / api_def / BUILD <nl> <nl> # The following targets can be used to access ApiDefs : <nl> # : base_api_def <nl> # : python_api_def <nl> + # : java_api_def <nl> <nl> package ( <nl> default_visibility = [ " / / visibility : private " ] , <nl> filegroup ( <nl> visibility = [ " / / tensorflow : internal " ] , <nl> ) <nl> <nl> + filegroup ( <nl> + name = " java_api_def " , <nl> + srcs = glob ( [ " java_api / * " ] ) , <nl> + visibility = [ " / / tensorflow : internal " ] , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " excluded_ops_lib " , <nl> srcs = [ " excluded_ops . cc " ] , <nl> new file mode 100644 <nl> index 0000000000000 . . b1f868897d5b8 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / api_def / java_api / api_def_Assert . pbtxt <nl> <nl> + op { <nl> + graph_op_name : " Assert " # TODO ( karllessard ) escape that reserved name <nl> + visibility : HIDDEN <nl> + } <nl> new file mode 100644 <nl> index 0000000000000 . . 2dbdca34e0072 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / api_def / java_api / api_def_Const . pbtxt <nl> <nl> + op { <nl> + graph_op_name : " Const " # TODO ( karllessard ) escape that reserved name <nl> + visibility : HIDDEN <nl> + } <nl> new file mode 100644 <nl> index 0000000000000 . . 0d3362a91e151 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / api_def / java_api / api_def_Switch . pbtxt <nl> <nl> + op { <nl> + graph_op_name : " Switch " # TODO ( karllessard ) escape that reserved name <nl> + visibility : HIDDEN <nl> + } <nl> mmm a / tensorflow / java / BUILD <nl> ppp b / tensorflow / java / BUILD <nl> java_library ( <nl> srcs = glob ( [ " src / gen / java / org / tensorflow / processor / * * / * . java " ] ) , <nl> javacopts = JAVACOPTS , <nl> resources = glob ( [ " src / gen / resources / META - INF / services / javax . annotation . processing . Processor " ] ) , <nl> + deps = [ <nl> + " @ com_google_guava " , <nl> + " @ com_squareup_javapoet " , <nl> + ] , <nl> ) <nl> <nl> filegroup ( <nl> tf_java_op_gen_srcjar ( <nl> name = " java_op_gen_sources " , <nl> api_def_srcs = [ <nl> " / / tensorflow / core / api_def : base_api_def " , <nl> + " / / tensorflow / core / api_def : java_api_def " , <nl> ] , <nl> base_package = " org . tensorflow . op " , <nl> gen_tool = " : java_op_gen_tool " , <nl> mmm a / tensorflow / java / src / gen / cc / op_generator . cc <nl> ppp b / tensorflow / java / src / gen / cc / op_generator . cc <nl> namespace tensorflow { <nl> namespace java { <nl> namespace { <nl> <nl> - const char * kLicense = <nl> - " / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . \ n " <nl> - " \ n " <nl> - " Licensed under the Apache License , Version 2 . 0 ( the \ " License \ " ) ; \ n " <nl> - " you may not use this file except in compliance with the License . \ n " <nl> - " You may obtain a copy of the License at \ n " <nl> - " \ n " <nl> - " http : / / www . apache . org / licenses / LICENSE - 2 . 0 \ n " <nl> - " \ n " <nl> - " Unless required by applicable law or agreed to in writing , software \ n " <nl> - " distributed under the License is distributed on an \ " AS IS \ " BASIS , \ n " <nl> - " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . \ n " <nl> - " See the License for the specific language governing permissions and \ n " <nl> - " limitations under the License . \ n " <nl> - " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / " <nl> - " \ n " ; <nl> + constexpr const char kLicense [ ] = <nl> + " / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . \ n " <nl> + " \ n " <nl> + " Licensed under the Apache License , Version 2 . 0 ( the \ " License \ " ) ; \ n " <nl> + " you may not use this file except in compliance with the License . \ n " <nl> + " You may obtain a copy of the License at \ n " <nl> + " \ n " <nl> + " http : / / www . apache . org / licenses / LICENSE - 2 . 0 \ n " <nl> + " \ n " <nl> + " Unless required by applicable law or agreed to in writing , software \ n " <nl> + " distributed under the License is distributed on an \ " AS IS \ " BASIS , \ n " <nl> + " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . \ n " <nl> + " See the License for the specific language governing permissions and \ n " <nl> + " limitations under the License . \ n " <nl> + " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / \ n " ; <nl> <nl> / / There is three different modes to render an op class , depending on the <nl> / / number and type of outputs it has : <nl> void GenerateOp ( const OpSpec & op , const EndpointSpec & endpoint , <nl> } <nl> if ( ! op . hidden ( ) ) { <nl> / / expose the op in the Ops Graph API only if it is visible <nl> - op_class . add_annotation ( <nl> - Annotation : : Create ( " Operator " , " org . tensorflow . op . annotation " ) <nl> - . attributes ( " group = \ " " + endpoint . package ( ) + " \ " " ) ) ; <nl> + Annotation oper_annot = <nl> + Annotation : : Create ( " Operator " , " org . tensorflow . op . annotation " ) ; <nl> + if ( endpoint . package ( ) ! = kDefaultEndpointPackage ) { <nl> + oper_annot . attributes ( " group = \ " " + endpoint . package ( ) + " \ " " ) ; <nl> + } <nl> + op_class . add_annotation ( oper_annot ) ; <nl> } <nl> / / create op class file <nl> const string op_dir_name = io : : JoinPath ( <nl> mmm a / tensorflow / java / src / gen / cc / op_specs . cc <nl> ppp b / tensorflow / java / src / gen / cc / op_specs . cc <nl> EndpointSpec CreateEndpoint ( const OpDef & op_def , const ApiDef & api_def , <nl> package = name_tokens . at ( 0 ) ; <nl> name = name_tokens . at ( 1 ) ; <nl> } else { <nl> - package = " core " ; / / generate unclassified ops in the ' core ' package <nl> + package = kDefaultEndpointPackage ; <nl> name = name_tokens . at ( 0 ) ; <nl> } <nl> return EndpointSpec ( package , <nl> mmm a / tensorflow / java / src / gen / cc / op_specs . h <nl> ppp b / tensorflow / java / src / gen / cc / op_specs . h <nl> limitations under the License . <nl> namespace tensorflow { <nl> namespace java { <nl> <nl> + constexpr const char kDefaultEndpointPackage [ ] = " core " ; <nl> + <nl> class EndpointSpec { <nl> public : <nl> / / A specification for an operation endpoint <nl> mmm a / tensorflow / java / src / gen / java / org / tensorflow / processor / OperatorProcessor . java <nl> ppp b / tensorflow / java / src / gen / java / org / tensorflow / processor / OperatorProcessor . java <nl> <nl> package org . tensorflow . processor ; <nl> <nl> import java . io . IOException ; <nl> - import java . io . PrintWriter ; <nl> + import java . util . Collection ; <nl> import java . util . Collections ; <nl> - import java . util . HashSet ; <nl> + import java . util . HashMap ; <nl> + import java . util . Map ; <nl> import java . util . Set ; <nl> + import java . util . regex . Matcher ; <nl> + import java . util . regex . Pattern ; <nl> + <nl> import javax . annotation . processing . AbstractProcessor ; <nl> import javax . annotation . processing . Filer ; <nl> import javax . annotation . processing . Messager ; <nl> import javax . annotation . processing . ProcessingEnvironment ; <nl> import javax . annotation . processing . RoundEnvironment ; <nl> import javax . lang . model . SourceVersion ; <nl> + import javax . lang . model . element . AnnotationMirror ; <nl> + import javax . lang . model . element . AnnotationValue ; <nl> import javax . lang . model . element . Element ; <nl> + import javax . lang . model . element . ExecutableElement ; <nl> + import javax . lang . model . element . Modifier ; <nl> import javax . lang . model . element . TypeElement ; <nl> + import javax . lang . model . element . TypeParameterElement ; <nl> + import javax . lang . model . element . VariableElement ; <nl> + import javax . lang . model . type . TypeMirror ; <nl> + import javax . lang . model . type . TypeVariable ; <nl> + import javax . lang . model . util . ElementFilter ; <nl> + import javax . lang . model . util . Elements ; <nl> import javax . tools . Diagnostic . Kind ; <nl> <nl> + import com . google . common . base . CaseFormat ; <nl> + import com . google . common . base . Strings ; <nl> + import com . google . common . collect . HashMultimap ; <nl> + import com . google . common . collect . Multimap ; <nl> + import com . squareup . javapoet . ClassName ; <nl> + import com . squareup . javapoet . FieldSpec ; <nl> + import com . squareup . javapoet . JavaFile ; <nl> + import com . squareup . javapoet . MethodSpec ; <nl> + import com . squareup . javapoet . ParameterSpec ; <nl> + import com . squareup . javapoet . TypeName ; <nl> + import com . squareup . javapoet . TypeSpec ; <nl> + import com . squareup . javapoet . TypeVariableName ; <nl> + <nl> / * * <nl> * A compile - time Processor that aggregates classes annotated with { @ link <nl> * org . tensorflow . op . annotation . Operator } and generates the { @ code Ops } convenience API . Please <nl> public synchronized void init ( ProcessingEnvironment processingEnv ) { <nl> super . init ( processingEnv ) ; <nl> messager = processingEnv . getMessager ( ) ; <nl> filer = processingEnv . getFiler ( ) ; <nl> + elements = processingEnv . getElementUtils ( ) ; <nl> } <nl> <nl> @ Override <nl> public boolean process ( Set < ? extends TypeElement > annotations , RoundEnvironment <nl> / / generated our code , flag the location of each such class . <nl> if ( hasRun ) { <nl> for ( Element e : annotated ) { <nl> - error ( <nl> - e , <nl> - " The Operator processor has already processed @ Operator annotated sources \ n " <nl> - + " and written out an Ops API . It cannot process additional @ Operator sources . \ n " <nl> - + " One reason this can happen is if other annotation processors generate \ n " <nl> - + " new @ Operator source files . " ) ; <nl> + error ( e , " The Operator processor has already processed @ Operator annotated sources \ n " + <nl> + " and written out an Ops API . It cannot process additional @ Operator sources . \ n " + <nl> + " One reason this can happen is if other annotation processors generate \ n " + <nl> + " new @ Operator source files . " ) ; <nl> } <nl> return true ; <nl> } <nl> <nl> / / Collect all classes tagged with our annotation . <nl> - Set < TypeElement > opClasses = new HashSet < TypeElement > ( ) ; <nl> - if ( ! collectOpClasses ( roundEnv , opClasses , annotation ) ) { <nl> + Multimap < String , MethodSpec > groupedMethods = HashMultimap . create ( ) ; <nl> + if ( ! collectOpsMethods ( roundEnv , groupedMethods , annotation ) ) { <nl> return true ; <nl> } <nl> <nl> / / Nothing to do when there are no tagged classes . <nl> - if ( opClasses . isEmpty ( ) ) { <nl> + if ( groupedMethods . isEmpty ( ) ) { <nl> return true ; <nl> } <nl> <nl> - / / TODO : ( kbsriram ) validate operator classes and generate Op API . <nl> - writeApi ( ) ; <nl> + / / Validate operator classes and generate Op API . <nl> + writeApi ( groupedMethods ) ; <nl> + <nl> hasRun = true ; <nl> return true ; <nl> } <nl> <nl> @ Override <nl> public Set < String > getSupportedAnnotationTypes ( ) { <nl> - return Collections . singleton ( String . format ( " % s . annotation . Operator " , OP_PACKAGE ) ) ; <nl> + return Collections . singleton ( " org . tensorflow . op . annotation . Operator " ) ; <nl> + } <nl> + <nl> + private static final Pattern JAVADOC_TAG_PATTERN = Pattern . compile ( " @ ( ? : param | return | throws | exception | see ) \ \ s + . * " ) ; <nl> + private static final TypeName T_OPS = ClassName . get ( " org . tensorflow . op " , " Ops " ) ; <nl> + private static final TypeName T_OPERATOR = ClassName . get ( " org . tensorflow . op . annotation " , " Operator " ) ; <nl> + private static final TypeName T_SCOPE = ClassName . get ( " org . tensorflow . op " , " Scope " ) ; <nl> + private static final TypeName T_GRAPH = ClassName . get ( " org . tensorflow " , " Graph " ) ; <nl> + private static final TypeName T_STRING = ClassName . get ( String . class ) ; <nl> + <nl> + private Filer filer ; <nl> + private Messager messager ; <nl> + private Elements elements ; <nl> + private boolean hasRun = false ; <nl> + <nl> + private void error ( Element e , String message , Object . . . args ) { <nl> + if ( args ! = null & & args . length > 0 ) { <nl> + message = String . format ( message , args ) ; <nl> + } <nl> + messager . printMessage ( Kind . ERROR , message , e ) ; <nl> } <nl> <nl> - private void writeApi ( ) { <nl> - / / Generate an empty class for now and get the build working correctly . This will be changed to <nl> - / / generate the actual API once we ' ve done with build - related changes . <nl> - / / TODO : ( kbsriram ) <nl> - try ( PrintWriter writer = <nl> - new PrintWriter ( filer . createSourceFile ( String . format ( " % s . Ops " , OP_PACKAGE ) ) . openWriter ( ) ) ) { <nl> - writer . println ( String . format ( " package % s ; " , OP_PACKAGE ) ) ; <nl> - writer . println ( " public class Ops { } " ) ; <nl> + private void write ( TypeSpec spec ) { <nl> + try { <nl> + JavaFile . builder ( " org . tensorflow . op " , spec ) <nl> + . skipJavaLangImports ( true ) <nl> + . build ( ) <nl> + . writeTo ( filer ) ; <nl> } catch ( IOException e ) { <nl> - error ( null , " Unexpected failure generating API : % s " , e . getMessage ( ) ) ; <nl> + throw new AssertionError ( e ) ; <nl> } <nl> } <nl> <nl> - private boolean collectOpClasses ( <nl> - RoundEnvironment roundEnv , Set < TypeElement > opClasses , TypeElement annotation ) { <nl> + private void writeApi ( Multimap < String , MethodSpec > groupedMethods ) { <nl> + Map < String , ClassName > groups = new HashMap < String , ClassName > ( ) ; <nl> + <nl> + / / Generate a API class for each group collected other than the default one ( = empty string ) <nl> + for ( Map . Entry < String , Collection < MethodSpec > > entry : groupedMethods . asMap ( ) . entrySet ( ) ) { <nl> + if ( ! entry . getKey ( ) . isEmpty ( ) ) { <nl> + TypeSpec groupClass = buildGroupClass ( entry . getKey ( ) , entry . getValue ( ) ) ; <nl> + write ( groupClass ) ; <nl> + groups . put ( entry . getKey ( ) , ClassName . get ( " org . tensorflow . op " , groupClass . name ) ) ; <nl> + } <nl> + } <nl> + / / Generate the top API class , adding any methods added to the default group <nl> + TypeSpec topClass = buildTopClass ( groups , groupedMethods . get ( " " ) ) ; <nl> + write ( topClass ) ; <nl> + } <nl> + <nl> + private boolean collectOpsMethods ( <nl> + RoundEnvironment roundEnv , Multimap < String , MethodSpec > groupedMethods , TypeElement annotation ) { <nl> boolean result = true ; <nl> for ( Element e : roundEnv . getElementsAnnotatedWith ( annotation ) ) { <nl> / / @ Operator can only apply to types , so e must be a TypeElement . <nl> if ( ! ( e instanceof TypeElement ) ) { <nl> - error ( <nl> - e , <nl> - " @ Operator can only be applied to classes , but this is a % s " , <nl> - e . getKind ( ) . toString ( ) ) ; <nl> + error ( e , " @ Operator can only be applied to classes , but this is a % s " , e . getKind ( ) . toString ( ) ) ; <nl> result = false ; <nl> continue ; <nl> } <nl> - opClasses . add ( ( TypeElement ) e ) ; <nl> + TypeElement opClass = ( TypeElement ) e ; <nl> + / / Skip deprecated operations for now , as we do not guarantee API stability yet <nl> + if ( opClass . getAnnotation ( Deprecated . class ) = = null ) { <nl> + collectOpMethods ( groupedMethods , opClass , annotation ) ; <nl> + } <nl> } <nl> return result ; <nl> } <nl> + <nl> + private void collectOpMethods ( Multimap < String , MethodSpec > groupedMethods , TypeElement opClass , TypeElement annotation ) { <nl> + AnnotationMirror am = getAnnotationMirror ( opClass , annotation ) ; <nl> + String groupName = getAnnotationElementValueAsString ( " group " , am ) ; <nl> + String methodName = getAnnotationElementValueAsString ( " name " , am ) ; <nl> + ClassName opClassName = ClassName . get ( opClass ) ; <nl> + if ( Strings . isNullOrEmpty ( methodName ) ) { <nl> + methodName = CaseFormat . UPPER_CAMEL . to ( CaseFormat . LOWER_CAMEL , opClassName . simpleName ( ) ) ; <nl> + } <nl> + / / Build a method for each @ Operator found in the class path . There should be one method per operation factory called <nl> + / / " create " , which takes in parameter a scope and , optionally , a list of arguments <nl> + for ( ExecutableElement opMethod : ElementFilter . methodsIn ( opClass . getEnclosedElements ( ) ) ) { <nl> + if ( opMethod . getModifiers ( ) . contains ( Modifier . STATIC ) & & opMethod . getSimpleName ( ) . contentEquals ( " create " ) ) { <nl> + MethodSpec method = buildOpMethod ( methodName , opClassName , opMethod ) ; <nl> + groupedMethods . put ( groupName , method ) ; <nl> + } <nl> + } <nl> + } <nl> <nl> - private void error ( Element e , String message , Object . . . args ) { <nl> - if ( args ! = null & & args . length > 0 ) { <nl> - message = String . format ( message , args ) ; <nl> + private MethodSpec buildOpMethod ( String methodName , ClassName opClassName , ExecutableElement factoryMethod ) { <nl> + MethodSpec . Builder builder = <nl> + MethodSpec . methodBuilder ( methodName ) <nl> + . addModifiers ( Modifier . PUBLIC ) <nl> + . returns ( TypeName . get ( factoryMethod . getReturnType ( ) ) ) <nl> + . varargs ( factoryMethod . isVarArgs ( ) ) <nl> + . addJavadoc ( " $ L " , buildOpMethodJavadoc ( opClassName , factoryMethod ) ) ; <nl> + <nl> + for ( TypeParameterElement tp : factoryMethod . getTypeParameters ( ) ) { <nl> + TypeVariableName tvn = TypeVariableName . get ( ( TypeVariable ) tp . asType ( ) ) ; <nl> + builder . addTypeVariable ( tvn ) ; <nl> } <nl> - messager . printMessage ( Kind . ERROR , message , e ) ; <nl> + for ( TypeMirror thrownType : factoryMethod . getThrownTypes ( ) ) { <nl> + builder . addException ( TypeName . get ( thrownType ) ) ; <nl> + } <nl> + StringBuilder call = new StringBuilder ( " return $ T . create ( scope " ) ; <nl> + boolean first = true ; <nl> + for ( VariableElement param : factoryMethod . getParameters ( ) ) { <nl> + ParameterSpec p = ParameterSpec . get ( param ) ; <nl> + if ( first ) { <nl> + first = false ; <nl> + continue ; <nl> + } <nl> + call . append ( " , " ) ; <nl> + call . append ( p . name ) ; <nl> + builder . addParameter ( p ) ; <nl> + } <nl> + call . append ( " ) " ) ; <nl> + builder . addStatement ( call . toString ( ) , opClassName ) ; <nl> + return builder . build ( ) ; <nl> + } <nl> + <nl> + private String buildOpMethodJavadoc ( ClassName opClassName , ExecutableElement factoryMethod ) { <nl> + StringBuilder javadoc = new StringBuilder ( ) ; <nl> + javadoc . append ( " Adds an { @ link " ) . append ( opClassName . simpleName ( ) ) . append ( " } operation to the graph \ n \ n " ) ; <nl> + <nl> + / / Add all javadoc tags found in the operator factory method but the first one , which should be in all cases the <nl> + / / ' scope ' parameter that is implicitly passed by this API <nl> + Matcher tagMatcher = JAVADOC_TAG_PATTERN . matcher ( elements . getDocComment ( factoryMethod ) ) ; <nl> + boolean firstParam = true ; <nl> + <nl> + while ( tagMatcher . find ( ) ) { <nl> + String tag = tagMatcher . group ( ) ; <nl> + if ( tag . startsWith ( " @ param " ) & & firstParam ) { <nl> + firstParam = false ; <nl> + } else { <nl> + javadoc . append ( tag ) . append ( ' \ n ' ) ; <nl> + } <nl> + } <nl> + javadoc . append ( " @ see { @ link " ) . append ( opClassName ) . append ( " } \ n " ) ; <nl> + <nl> + return javadoc . toString ( ) ; <nl> } <nl> + <nl> + private static TypeSpec buildGroupClass ( String group , Collection < MethodSpec > methods ) { <nl> + MethodSpec . Builder ctorBuilder = <nl> + MethodSpec . constructorBuilder ( ) <nl> + . addParameter ( T_SCOPE , " scope " ) <nl> + . addStatement ( " this . scope = scope " ) ; <nl> + <nl> + TypeSpec . Builder builder = <nl> + TypeSpec . classBuilder ( CaseFormat . LOWER_CAMEL . to ( CaseFormat . UPPER_CAMEL , group ) + " Ops " ) <nl> + . addModifiers ( Modifier . PUBLIC , Modifier . FINAL ) <nl> + . addJavadoc ( " An API for adding { @ code $ L } operations to a { @ link $ T Graph } \ n \ n " + <nl> + " @ see { @ link $ T } \ n " , group , T_GRAPH , T_OPS ) <nl> + . addMethods ( methods ) <nl> + . addMethod ( ctorBuilder . build ( ) ) ; <nl> <nl> - private Filer filer ; <nl> - private Messager messager ; <nl> - private boolean hasRun = false ; <nl> - private static final String OP_PACKAGE = " org . tensorflow . op " ; <nl> + builder . addField ( <nl> + FieldSpec . builder ( T_SCOPE , " scope " ) <nl> + . addModifiers ( Modifier . PRIVATE , Modifier . FINAL ) <nl> + . build ( ) ) ; <nl> + <nl> + return builder . build ( ) ; <nl> + } <nl> + <nl> + private static TypeSpec buildTopClass ( Map < String , ClassName > groupToClass , Collection < MethodSpec > methods ) { <nl> + MethodSpec . Builder ctorBuilder = <nl> + MethodSpec . constructorBuilder ( ) <nl> + . addModifiers ( Modifier . PRIVATE ) <nl> + . addParameter ( T_SCOPE , " scope " ) <nl> + . addStatement ( " this . scope = scope " , T_SCOPE ) ; <nl> + <nl> + for ( Map . Entry < String , ClassName > entry : groupToClass . entrySet ( ) ) { <nl> + ctorBuilder . addStatement ( " $ L = new $ T ( scope ) " , entry . getKey ( ) , entry . getValue ( ) ) ; <nl> + } <nl> + <nl> + TypeSpec . Builder opsBuilder = <nl> + TypeSpec . classBuilder ( " Ops " ) <nl> + . addModifiers ( Modifier . PUBLIC , Modifier . FINAL ) <nl> + . addJavadoc ( " An API for building a { @ link $ T } with operation wrappers \ n < p > \ n " + <nl> + " Any operation wrapper found in the classpath properly annotated as an { @ link $ T @ Operator } is exposed \ n " + <nl> + " by this API or one of its subgroup . \ n < p > Example usage : \ n < pre > { @ code \ n " + <nl> + " try ( Graph g = new Graph ( ) ) { \ n " + <nl> + " Ops ops = new Ops ( g ) ; \ n " + <nl> + " / / Operations are typed classes with convenience \ n " + <nl> + " / / builders in Ops . \ n " + <nl> + " Constant three = ops . constant ( 3 ) ; \ n " + <nl> + " / / Single - result operations implement the Operand \ n " + <nl> + " / / interface , so this works too . \ n " + <nl> + " Operand four = ops . constant ( 4 ) ; \ n " + <nl> + " / / Most builders are found within a group , and accept \ n " + <nl> + " / / Operand types as operands \ n " + <nl> + " Operand nine = ops . math ( ) . add ( four , ops . constant ( 5 ) ) ; \ n " + <nl> + " / / Multi - result operations however offer methods to \ n " + <nl> + " / / select a particular result for use . \ n " + <nl> + " Operand result = \ n " + <nl> + " ops . math ( ) . add ( ops . array ( ) . unique ( s , a ) . y ( ) , b ) ; \ n " + <nl> + " / / Optional attributes \ n " + <nl> + " ops . math ( ) . matMul ( a , b , MatMul . transposeA ( true ) ) ; \ n " + <nl> + " / / Naming operators \ n " + <nl> + " ops . withName ( “ foo ” ) . constant ( 5 ) ; / / name “ foo ” \ n " + <nl> + " / / Names can exist in a hierarchy \ n " + <nl> + " Ops sub = ops . withSubScope ( “ sub ” ) ; \ n " + <nl> + " sub . withName ( “ bar ” ) . constant ( 4 ) ; / / “ sub / bar ” \ n " + <nl> + " } \ n " + <nl> + " } < / pre > \ n " , T_GRAPH , T_OPERATOR ) <nl> + . addMethods ( methods ) <nl> + . addMethod ( ctorBuilder . build ( ) ) ; <nl> + <nl> + opsBuilder . addMethod ( <nl> + MethodSpec . methodBuilder ( " withSubScope " ) <nl> + . addModifiers ( Modifier . PUBLIC ) <nl> + . addParameter ( T_STRING , " childScopeName " ) <nl> + . returns ( T_OPS ) <nl> + . addStatement ( " return new $ T ( scope . withSubScope ( childScopeName ) ) " , T_OPS ) <nl> + . addJavadoc ( <nl> + " Returns an API that adds operations to the graph with the provided name prefix . \ n \ n " + <nl> + " @ see { @ link $ T # withSubScope ( String ) } \ n " , T_SCOPE ) <nl> + . build ( ) ) ; <nl> + <nl> + opsBuilder . addMethod ( <nl> + MethodSpec . methodBuilder ( " withName " ) <nl> + . addModifiers ( Modifier . PUBLIC ) <nl> + . addParameter ( T_STRING , " opName " ) <nl> + . returns ( T_OPS ) <nl> + . addStatement ( " return new Ops ( scope . withName ( opName ) ) " ) <nl> + . addJavadoc ( <nl> + " Returns an API that uses the provided name for an op . \ n \ n " + <nl> + " @ see { @ link $ T # withName ( String ) } \ n " , T_SCOPE ) <nl> + . build ( ) ) ; <nl> + <nl> + opsBuilder . addField ( <nl> + FieldSpec . builder ( T_SCOPE , " scope " ) <nl> + . addModifiers ( Modifier . PRIVATE , Modifier . FINAL ) <nl> + . build ( ) ) ; <nl> + <nl> + opsBuilder . addMethod ( <nl> + MethodSpec . methodBuilder ( " scope " ) <nl> + . addModifiers ( Modifier . PUBLIC , Modifier . FINAL ) <nl> + . returns ( T_SCOPE ) <nl> + . addStatement ( " return scope " ) <nl> + . addJavadoc ( " Returns the current { @ link $ T scope } of this API \ n " , T_SCOPE ) <nl> + . build ( ) ) ; <nl> + <nl> + for ( Map . Entry < String , ClassName > entry : groupToClass . entrySet ( ) ) { <nl> + opsBuilder . addField ( <nl> + FieldSpec . builder ( entry . getValue ( ) , entry . getKey ( ) ) <nl> + . addModifiers ( Modifier . PUBLIC , Modifier . FINAL ) <nl> + . build ( ) ) ; <nl> + <nl> + opsBuilder . addMethod ( <nl> + MethodSpec . methodBuilder ( entry . getKey ( ) ) <nl> + . addModifiers ( Modifier . PUBLIC , Modifier . FINAL ) <nl> + . returns ( entry . getValue ( ) ) <nl> + . addStatement ( " return $ L " , entry . getKey ( ) ) <nl> + . addJavadoc ( " Returns an API for adding { @ code $ L } operations to the graph \ n " , entry . getKey ( ) ) <nl> + . build ( ) ) ; <nl> + } <nl> + <nl> + opsBuilder . addMethod ( <nl> + MethodSpec . methodBuilder ( " create " ) <nl> + . addModifiers ( Modifier . PUBLIC , Modifier . STATIC ) <nl> + . addParameter ( T_GRAPH , " graph " ) <nl> + . returns ( T_OPS ) <nl> + . addStatement ( " return new Ops ( new $ T ( graph ) ) " , T_SCOPE ) <nl> + . addJavadoc ( " Creates an API for adding operations to the provided { @ code graph } \ n " ) <nl> + . build ( ) ) ; <nl> + <nl> + return opsBuilder . build ( ) ; <nl> + } <nl> + <nl> + private static AnnotationMirror getAnnotationMirror ( Element element , TypeElement annotation ) { <nl> + for ( AnnotationMirror am : element . getAnnotationMirrors ( ) ) { <nl> + if ( am . getAnnotationType ( ) . asElement ( ) . equals ( annotation ) ) { <nl> + return am ; <nl> + } <nl> + } <nl> + throw new IllegalArgumentException ( " Annotation " + annotation . getSimpleName ( ) + " not present on element " <nl> + + element . getSimpleName ( ) ) ; <nl> + } <nl> + <nl> + private static String getAnnotationElementValueAsString ( String elementName , AnnotationMirror am ) { <nl> + for ( Map . Entry < ? extends ExecutableElement , ? extends AnnotationValue > entry : am . getElementValues ( ) . entrySet ( ) ) { <nl> + if ( entry . getKey ( ) . getSimpleName ( ) . contentEquals ( elementName ) ) { <nl> + return entry . getValue ( ) . getValue ( ) . toString ( ) ; <nl> + } <nl> + } <nl> + return " " ; <nl> + } <nl> } <nl> mmm a / tensorflow / workspace . bzl <nl> ppp b / tensorflow / workspace . bzl <nl> def tf_workspace ( path_prefix = " " , tf_repo_name = " " ) : <nl> licenses = [ " notice " ] , # Apache 2 . 0 <nl> ) <nl> <nl> + java_import_external ( <nl> + name = " com_squareup_javapoet " , <nl> + jar_sha256 = " 5bb5abdfe4366c15c0da3332c57d484e238bd48260d6f9d6acf2b08fdde1efea " , <nl> + jar_urls = [ <nl> + " http : / / mirror . bazel . build / repo1 . maven . org / maven2 / com / squareup / javapoet / 1 . 9 . 0 / javapoet - 1 . 9 . 0 . jar " , <nl> + " http : / / repo1 . maven . org / maven2 / com / squareup / javapoet / 1 . 9 . 0 / javapoet - 1 . 9 . 0 . jar " , <nl> + ] , <nl> + licenses = [ " notice " ] , # Apache 2 . 0 <nl> + ) <nl> + <nl> tf_http_archive ( <nl> name = " com_google_pprof " , <nl> urls = [ <nl>
Merge pull request from karllessard / java - ops - 3c - api
tensorflow/tensorflow
95945c60a8c7693d41ef633d1fdd91faed4b85bc
2018-06-15T18:54:48Z
mmm a / Code / CryEngine / CryCommon / CryPhysics / physinterface . h <nl> ppp b / Code / CryEngine / CryCommon / CryPhysics / physinterface . h <nl> enum rwi_flags <nl> { <nl> rwi_ignore_terrain_holes = 0x20 , rwi_ignore_noncolliding = 0x40 , rwi_ignore_back_faces = 0x80 , rwi_ignore_solid_back_faces = 0x100 , <nl> rwi_pierceability_mask = 0x0F , rwi_pierceability0 = 0 , rwi_stop_at_pierceable = 0x0F , <nl> + rwi_max_piercing = 0x10 , / / ! < the ray will pierce all surfaces ( including those with pierceability 0 ) <nl> rwi_separate_important_hits = sf_important , / / ! < among pierceble hits , materials with sf_important will have priority <nl> rwi_colltype_bit = 16 , / / ! < used to manually specify collision geometry types ( default is geom_colltype_ray ) <nl> rwi_colltype_any = 0x400 , / / ! < if several colltype flag are specified , switches between requiring all or any of them in a geometry <nl> mmm a / Code / CryEngine / CryPhysics / rwi . cpp <nl> ppp b / Code / CryEngine / CryPhysics / rwi . cpp <nl> struct entity_grid_checker { <nl> for ( j - - ; j > = 0 ; j - - ) <nl> if ( pcontacts [ j ] . t < phits [ 0 ] . dist & & ( flags & rwi_ignore_back_faces ) * ( facing = pcontacts [ j ] . n * aray . m_dirn ) < = 0 ) { <nl> imat = pentFlags - > GetMatId ( pcontacts [ j ] . id [ 0 ] , i ) ; <nl> + int rayPierceability = ( int ) ( ( flags & rwi_pierceability_mask ) - ( flags & rwi_max_piercing ) ) ; <nl> int pierceability = pWorld - > m_SurfaceFlagsTable [ imat & NSURFACETYPES - 1 ] & sf_pierceable_mask ; <nl> ihit = - ( int ) ( flags & rwi_force_pierceable_noncoll ) > > 31 & - iszero ( ( int ) pentFlags - > m_parts [ i ] . flags & ( geom_colltype_solid | geom_colltype_ray ) ) ; <nl> pierceability + = sf_max_pierceable + 1 - pierceability & ihit ; <nl> ihit = 0 ; <nl> - if ( ( int ) ( flags & rwi_pierceability_mask ) < pierceability ) { <nl> + if ( rayPierceability < pierceability ) { <nl> if ( ( pWorld - > m_SurfaceFlagsTable [ imat & NSURFACETYPES - 1 ] | flags ) & sf_important ) { <nl> for ( ihit = 1 ; ihit < = nThroughHits & & phits [ ihit ] . dist < pcontacts [ j ] . t ; ihit + + ) ; <nl> if ( ihit < = nThroughHits ) { <nl>
! FI ( Physics ) added a flag for unconditionally piercing rwi ray
CRYTEK/CRYENGINE
de8d404642518f2092064fd1e4353bc25fa42298
2018-05-02T12:36:50Z
mmm a / android / commons / build . gradle <nl> ppp b / android / commons / build . gradle <nl> dependencies { <nl> compile ' com . facebook . fresco : fresco : 0 . 10 . 0 ' <nl> <nl> provided ' com . taobao . android : weex_analyzer : 0 . 1 . 0 . 5 ' <nl> + provided ' com . squareup . okhttp : okhttp : 2 . 3 . 0 ' <nl> + provided ' com . squareup . okhttp : okhttp - ws : 2 . 3 . 0 ' <nl> <nl> testCompile ' junit : junit : 4 . 12 ' <nl> testCompile ' org . hamcrest : hamcrest - core : 1 . 3 ' <nl> new file mode 100644 <nl> index 0000000000 . . 1fdea98a1b <nl> mmm / dev / null <nl> ppp b / android / commons / src / main / java / com / alibaba / weex / commons / adapter / DefaultWebSocketAdapter . java <nl> <nl> + / * * <nl> + * <nl> + * Apache License <nl> + * Version 2 . 0 , January 2004 <nl> + * http : / / www . apache . org / licenses / <nl> + * <nl> + * TERMS AND CONDITIONS FOR USE , REPRODUCTION , AND DISTRIBUTION <nl> + * <nl> + * 1 . Definitions . <nl> + * <nl> + * " License " shall mean the terms and conditions for use , reproduction , <nl> + * and distribution as defined by Sections 1 through 9 of this document . <nl> + * <nl> + * " Licensor " shall mean the copyright owner or entity authorized by <nl> + * the copyright owner that is granting the License . <nl> + * <nl> + * " Legal Entity " shall mean the union of the acting entity and all <nl> + * other entities that control , are controlled by , or are under common <nl> + * control with that entity . For the purposes of this definition , <nl> + * " control " means ( i ) the power , direct or indirect , to cause the <nl> + * direction or management of such entity , whether by contract or <nl> + * otherwise , or ( ii ) ownership of fifty percent ( 50 % ) or more of the <nl> + * outstanding shares , or ( iii ) beneficial ownership of such entity . <nl> + * <nl> + * " You " ( or " Your " ) shall mean an individual or Legal Entity <nl> + * exercising permissions granted by this License . <nl> + * <nl> + * " Source " form shall mean the preferred form for making modifications , <nl> + * including but not limited to software source code , documentation <nl> + * source , and configuration files . <nl> + * <nl> + * " Object " form shall mean any form resulting from mechanical <nl> + * transformation or translation of a Source form , including but <nl> + * not limited to compiled object code , generated documentation , <nl> + * and conversions to other media types . <nl> + * <nl> + * " Work " shall mean the work of authorship , whether in Source or <nl> + * Object form , made available under the License , as indicated by a <nl> + * copyright notice that is included in or attached to the work <nl> + * ( an example is provided in the Appendix below ) . <nl> + * <nl> + * " Derivative Works " shall mean any work , whether in Source or Object <nl> + * form , that is based on ( or derived from ) the Work and for which the <nl> + * editorial revisions , annotations , elaborations , or other modifications <nl> + * represent , as a whole , an original work of authorship . For the purposes <nl> + * of this License , Derivative Works shall not include works that remain <nl> + * separable from , or merely link ( or bind by name ) to the interfaces of , <nl> + * the Work and Derivative Works thereof . <nl> + * <nl> + * " Contribution " shall mean any work of authorship , including <nl> + * the original version of the Work and any modifications or additions <nl> + * to that Work or Derivative Works thereof , that is intentionally <nl> + * submitted to Licensor for inclusion in the Work by the copyright owner <nl> + * or by an individual or Legal Entity authorized to submit on behalf of <nl> + * the copyright owner . For the purposes of this definition , " submitted " <nl> + * means any form of electronic , verbal , or written communication sent <nl> + * to the Licensor or its representatives , including but not limited to <nl> + * communication on electronic mailing lists , source code control systems , <nl> + * and issue tracking systems that are managed by , or on behalf of , the <nl> + * Licensor for the purpose of discussing and improving the Work , but <nl> + * excluding communication that is conspicuously marked or otherwise <nl> + * designated in writing by the copyright owner as " Not a Contribution . " <nl> + * <nl> + * " Contributor " shall mean Licensor and any individual or Legal Entity <nl> + * on behalf of whom a Contribution has been received by Licensor and <nl> + * subsequently incorporated within the Work . <nl> + * <nl> + * 2 . Grant of Copyright License . Subject to the terms and conditions of <nl> + * this License , each Contributor hereby grants to You a perpetual , <nl> + * worldwide , non - exclusive , no - charge , royalty - free , irrevocable <nl> + * copyright license to reproduce , prepare Derivative Works of , <nl> + * publicly display , publicly perform , sublicense , and distribute the <nl> + * Work and such Derivative Works in Source or Object form . <nl> + * <nl> + * 3 . Grant of Patent License . Subject to the terms and conditions of <nl> + * this License , each Contributor hereby grants to You a perpetual , <nl> + * worldwide , non - exclusive , no - charge , royalty - free , irrevocable <nl> + * ( except as stated in this section ) patent license to make , have made , <nl> + * use , offer to sell , sell , import , and otherwise transfer the Work , <nl> + * where such license applies only to those patent claims licensable <nl> + * by such Contributor that are necessarily infringed by their <nl> + * Contribution ( s ) alone or by combination of their Contribution ( s ) <nl> + * with the Work to which such Contribution ( s ) was submitted . If You <nl> + * institute patent litigation against any entity ( including a <nl> + * cross - claim or counterclaim in a lawsuit ) alleging that the Work <nl> + * or a Contribution incorporated within the Work constitutes direct <nl> + * or contributory patent infringement , then any patent licenses <nl> + * granted to You under this License for that Work shall terminate <nl> + * as of the date such litigation is filed . <nl> + * <nl> + * 4 . Redistribution . You may reproduce and distribute copies of the <nl> + * Work or Derivative Works thereof in any medium , with or without <nl> + * modifications , and in Source or Object form , provided that You <nl> + * meet the following conditions : <nl> + * <nl> + * ( a ) You must give any other recipients of the Work or <nl> + * Derivative Works a copy of this License ; and <nl> + * <nl> + * ( b ) You must cause any modified files to carry prominent notices <nl> + * stating that You changed the files ; and <nl> + * <nl> + * ( c ) You must retain , in the Source form of any Derivative Works <nl> + * that You distribute , all copyright , patent , trademark , and <nl> + * attribution notices from the Source form of the Work , <nl> + * excluding those notices that do not pertain to any part of <nl> + * the Derivative Works ; and <nl> + * <nl> + * ( d ) If the Work includes a " NOTICE " text file as part of its <nl> + * distribution , then any Derivative Works that You distribute must <nl> + * include a readable copy of the attribution notices contained <nl> + * within such NOTICE file , excluding those notices that do not <nl> + * pertain to any part of the Derivative Works , in at least one <nl> + * of the following places : within a NOTICE text file distributed <nl> + * as part of the Derivative Works ; within the Source form or <nl> + * documentation , if provided along with the Derivative Works ; or , <nl> + * within a display generated by the Derivative Works , if and <nl> + * wherever such third - party notices normally appear . The contents <nl> + * of the NOTICE file are for informational purposes only and <nl> + * do not modify the License . You may add Your own attribution <nl> + * notices within Derivative Works that You distribute , alongside <nl> + * or as an addendum to the NOTICE text from the Work , provided <nl> + * that such additional attribution notices cannot be construed <nl> + * as modifying the License . <nl> + * <nl> + * You may add Your own copyright statement to Your modifications and <nl> + * may provide additional or different license terms and conditions <nl> + * for use , reproduction , or distribution of Your modifications , or <nl> + * for any such Derivative Works as a whole , provided Your use , <nl> + * reproduction , and distribution of the Work otherwise complies with <nl> + * the conditions stated in this License . <nl> + * <nl> + * 5 . Submission of Contributions . Unless You explicitly state otherwise , <nl> + * any Contribution intentionally submitted for inclusion in the Work <nl> + * by You to the Licensor shall be under the terms and conditions of <nl> + * this License , without any additional terms or conditions . <nl> + * Notwithstanding the above , nothing herein shall supersede or modify <nl> + * the terms of any separate license agreement you may have executed <nl> + * with Licensor regarding such Contributions . <nl> + * <nl> + * 6 . Trademarks . This License does not grant permission to use the trade <nl> + * names , trademarks , service marks , or product names of the Licensor , <nl> + * except as required for reasonable and customary use in describing the <nl> + * origin of the Work and reproducing the content of the NOTICE file . <nl> + * <nl> + * 7 . Disclaimer of Warranty . Unless required by applicable law or <nl> + * agreed to in writing , Licensor provides the Work ( and each <nl> + * Contributor provides its Contributions ) on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or <nl> + * implied , including , without limitation , any warranties or conditions <nl> + * of TITLE , NON - INFRINGEMENT , MERCHANTABILITY , or FITNESS FOR A <nl> + * PARTICULAR PURPOSE . You are solely responsible for determining the <nl> + * appropriateness of using or redistributing the Work and assume any <nl> + * risks associated with Your exercise of permissions under this License . <nl> + * <nl> + * 8 . Limitation of Liability . In no event and under no legal theory , <nl> + * whether in tort ( including negligence ) , contract , or otherwise , <nl> + * unless required by applicable law ( such as deliberate and grossly <nl> + * negligent acts ) or agreed to in writing , shall any Contributor be <nl> + * liable to You for damages , including any direct , indirect , special , <nl> + * incidental , or consequential damages of any character arising as a <nl> + * result of this License or out of the use or inability to use the <nl> + * Work ( including but not limited to damages for loss of goodwill , <nl> + * work stoppage , computer failure or malfunction , or any and all <nl> + * other commercial damages or losses ) , even if such Contributor <nl> + * has been advised of the possibility of such damages . <nl> + * <nl> + * 9 . Accepting Warranty or Additional Liability . While redistributing <nl> + * the Work or Derivative Works thereof , You may choose to offer , <nl> + * and charge a fee for , acceptance of support , warranty , indemnity , <nl> + * or other liability obligations and / or rights consistent with this <nl> + * License . However , in accepting such obligations , You may act only <nl> + * on Your own behalf and on Your sole responsibility , not on behalf <nl> + * of any other Contributor , and only if You agree to indemnify , <nl> + * defend , and hold each Contributor harmless for any liability <nl> + * incurred by , or claims asserted against , such Contributor by reason <nl> + * of your accepting any such warranty or additional liability . <nl> + * <nl> + * END OF TERMS AND CONDITIONS <nl> + * <nl> + * APPENDIX : How to apply the Apache License to your work . <nl> + * <nl> + * To apply the Apache License to your work , attach the following <nl> + * boilerplate notice , with the fields enclosed by brackets " [ ] " <nl> + * replaced with your own identifying information . ( Don ' t include <nl> + * the brackets ! ) The text should be enclosed in the appropriate <nl> + * comment syntax for the file format . We also recommend that a <nl> + * file or class name and description of purpose be included on the <nl> + * same " printed page " as the copyright notice for easier <nl> + * identification within third - party archives . <nl> + * <nl> + * Copyright 2016 Alibaba Group <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> + package com . alibaba . weex . commons . adapter ; <nl> + <nl> + import android . support . annotation . Nullable ; <nl> + <nl> + import com . squareup . okhttp . OkHttpClient ; <nl> + import com . squareup . okhttp . Request ; <nl> + import com . squareup . okhttp . Response ; <nl> + import com . squareup . okhttp . ws . WebSocket ; <nl> + import com . squareup . okhttp . ws . WebSocketCall ; <nl> + import com . squareup . okhttp . ws . WebSocketListener ; <nl> + import com . taobao . weex . appfram . websocket . IWXWebSocketAdapter ; <nl> + import com . taobao . weex . bridge . JSCallback ; <nl> + <nl> + import java . io . IOException ; <nl> + <nl> + import okio . Buffer ; <nl> + import okio . BufferedSource ; <nl> + <nl> + / * * <nl> + * Created by moxun on 16 / 12 / 27 . <nl> + * / <nl> + <nl> + public class DefaultWebSocketAdapter implements IWXWebSocketAdapter { <nl> + <nl> + private WebSocket ws ; <nl> + private OkHttpClient okHttpClient ; <nl> + private JSCallback onOpen ; <nl> + private JSCallback onMessage ; <nl> + private JSCallback onClose ; <nl> + private JSCallback onError ; <nl> + <nl> + private DefaultWebSocketAdapter ( ) { <nl> + okHttpClient = new OkHttpClient ( ) ; <nl> + } <nl> + <nl> + @ Override <nl> + public void WebSocket ( String url , @ Nullable String protocol ) { <nl> + Request wsRequest = new Request . Builder ( ) <nl> + . url ( url ) <nl> + . build ( ) ; <nl> + <nl> + WebSocketCall . create ( okHttpClient , wsRequest ) . enqueue ( new WebSocketListener ( ) { <nl> + @ Override <nl> + public void onOpen ( WebSocket webSocket , Request request , Response response ) throws IOException { <nl> + ws = webSocket ; <nl> + } <nl> + <nl> + @ Override <nl> + public void onMessage ( BufferedSource payload , WebSocket . PayloadType type ) throws IOException { <nl> + <nl> + } <nl> + <nl> + @ Override <nl> + public void onPong ( Buffer payload ) { <nl> + <nl> + } <nl> + <nl> + @ Override <nl> + public void onClose ( int code , String reason ) { <nl> + <nl> + } <nl> + <nl> + @ Override <nl> + public void onFailure ( IOException e ) { <nl> + <nl> + } <nl> + } ) ; <nl> + } <nl> + <nl> + @ Override <nl> + public void send ( String data ) { <nl> + <nl> + } <nl> + <nl> + @ Override <nl> + public void close ( int code , String reason ) { <nl> + <nl> + } <nl> + <nl> + @ Override <nl> + public void onopen ( JSCallback callback ) { <nl> + this . onOpen = callback ; <nl> + } <nl> + <nl> + @ Override <nl> + public void onmessage ( JSCallback callback ) { <nl> + this . onMessage = callback ; <nl> + } <nl> + <nl> + @ Override <nl> + public void onclose ( JSCallback callback ) { <nl> + this . onClose = callback ; <nl> + } <nl> + <nl> + @ Override <nl> + public void onerror ( JSCallback callback ) { <nl> + <nl> + } <nl> + } <nl> mmm a / android / sdk / src / main / java / com / taobao / weex / InitConfig . java <nl> ppp b / android / sdk / src / main / java / com / taobao / weex / InitConfig . java <nl> <nl> import com . taobao . weex . adapter . IWXUserTrackAdapter ; <nl> import com . taobao . weex . adapter . URIAdapter ; <nl> import com . taobao . weex . appfram . storage . IWXStorageAdapter ; <nl> + import com . taobao . weex . appfram . websocket . IWXWebSocketAdapter ; <nl> <nl> / * * <nl> * Created by sospartan on 5 / 31 / 16 . <nl> <nl> private IWXDebugAdapter debugAdapter ; <nl> private IWXStorageAdapter storageAdapter ; <nl> private URIAdapter mURIAdapter ; <nl> + private IWXWebSocketAdapter webSocketAdapter ; <nl> private String framework ; <nl> <nl> public IWXHttpAdapter getHttpAdapter ( ) { <nl> public URIAdapter getURIAdapter ( ) { <nl> return mURIAdapter ; <nl> } <nl> <nl> + public IWXWebSocketAdapter getWebSocketAdapter ( ) { <nl> + return webSocketAdapter ; <nl> + } <nl> + <nl> private InitConfig ( ) { <nl> } <nl> <nl> private InitConfig ( ) { <nl> IWXStorageAdapter storageAdapter ; <nl> URIAdapter mURIAdapter ; <nl> String framework ; <nl> + IWXWebSocketAdapter webSocketAdapter ; <nl> public Builder ( ) { <nl> <nl> } <nl> public Builder setFramework ( String framework ) { <nl> return this ; <nl> } <nl> <nl> + public Builder setWebSocketAdapter ( IWXWebSocketAdapter adapter ) { <nl> + this . webSocketAdapter = adapter ; <nl> + return this ; <nl> + } <nl> + <nl> public InitConfig build ( ) { <nl> InitConfig config = new InitConfig ( ) ; <nl> config . httpAdapter = this . httpAdapter ; <nl> public InitConfig build ( ) { <nl> config . storageAdapter = this . storageAdapter ; <nl> config . framework = this . framework ; <nl> config . mURIAdapter = this . mURIAdapter ; <nl> + config . webSocketAdapter = this . webSocketAdapter ; <nl> return config ; <nl> } <nl> } <nl> mmm a / android / sdk / src / main / java / com / taobao / weex / WXSDKEngine . java <nl> ppp b / android / sdk / src / main / java / com / taobao / weex / WXSDKEngine . java <nl> <nl> import com . taobao . weex . appfram . pickers . WXPickersModule ; <nl> import com . taobao . weex . appfram . storage . IWXStorageAdapter ; <nl> import com . taobao . weex . appfram . storage . WXStorageModule ; <nl> + import com . taobao . weex . appfram . websocket . IWXWebSocketAdapter ; <nl> import com . taobao . weex . bridge . ModuleFactory ; <nl> import com . taobao . weex . bridge . WXBridgeManager ; <nl> import com . taobao . weex . bridge . WXModuleManager ; <nl> public static IWXStorageAdapter getIWXStorageAdapter ( ) { <nl> return WXSDKManager . getInstance ( ) . getIWXStorageAdapter ( ) ; <nl> } <nl> <nl> + public static IWXWebSocketAdapter getIWXWebSocketAdapter ( ) { <nl> + return WXSDKManager . getInstance ( ) . getIWXWebSocketAdapter ( ) ; <nl> + } <nl> + <nl> <nl> public static IActivityNavBarSetter getActivityNavBarSetter ( ) { <nl> return WXSDKManager . getInstance ( ) . getActivityNavBarSetter ( ) ; <nl> mmm a / android / sdk / src / main / java / com / taobao / weex / WXSDKManager . java <nl> ppp b / android / sdk / src / main / java / com / taobao / weex / WXSDKManager . java <nl> <nl> <nl> import android . os . Looper ; <nl> import android . support . annotation . NonNull ; <nl> + import android . support . annotation . Nullable ; <nl> import android . text . TextUtils ; <nl> <nl> import com . taobao . weex . adapter . DefaultUriAdapter ; <nl> <nl> import com . taobao . weex . appfram . navigator . IActivityNavBarSetter ; <nl> import com . taobao . weex . appfram . storage . DefaultWXStorage ; <nl> import com . taobao . weex . appfram . storage . IWXStorageAdapter ; <nl> + import com . taobao . weex . appfram . websocket . IWXWebSocketAdapter ; <nl> import com . taobao . weex . bridge . WXBridgeManager ; <nl> import com . taobao . weex . bridge . WXModuleManager ; <nl> import com . taobao . weex . common . WXRefreshData ; <nl> <nl> <nl> private IWXStorageAdapter mIWXStorageAdapter ; <nl> private URIAdapter mURIAdapter ; <nl> + private IWXWebSocketAdapter mIWXWebSocketAdapter ; <nl> <nl> private WXSDKManager ( ) { <nl> mWXRenderManager = new WXRenderManager ( ) ; <nl> void setInitConfig ( InitConfig config ) { <nl> this . mIWXStorageAdapter = config . getStorageAdapter ( ) ; <nl> this . mIWXUserTrackAdapter = config . getUtAdapter ( ) ; <nl> this . mURIAdapter = config . getURIAdapter ( ) ; <nl> + this . mIWXWebSocketAdapter = config . getWebSocketAdapter ( ) ; <nl> } <nl> <nl> public IWXDebugAdapter getIWXDebugAdapter ( ) { <nl> public IWXStorageAdapter getIWXStorageAdapter ( ) { <nl> return mIWXStorageAdapter ; <nl> } <nl> <nl> + public @ Nullable IWXWebSocketAdapter getIWXWebSocketAdapter ( ) { <nl> + if ( mIWXWebSocketAdapter = = null ) { <nl> + <nl> + } <nl> + return mIWXWebSocketAdapter ; <nl> + } <nl> <nl> } <nl> new file mode 100644 <nl> index 0000000000 . . a955f5963a <nl> mmm / dev / null <nl> ppp b / android / sdk / src / main / java / com / taobao / weex / appfram / websocket / IWXWebSocketAdapter . java <nl> <nl> + / * * <nl> + * <nl> + * Apache License <nl> + * Version 2 . 0 , January 2004 <nl> + * http : / / www . apache . org / licenses / <nl> + * <nl> + * TERMS AND CONDITIONS FOR USE , REPRODUCTION , AND DISTRIBUTION <nl> + * <nl> + * 1 . Definitions . <nl> + * <nl> + * " License " shall mean the terms and conditions for use , reproduction , <nl> + * and distribution as defined by Sections 1 through 9 of this document . <nl> + * <nl> + * " Licensor " shall mean the copyright owner or entity authorized by <nl> + * the copyright owner that is granting the License . <nl> + * <nl> + * " Legal Entity " shall mean the union of the acting entity and all <nl> + * other entities that control , are controlled by , or are under common <nl> + * control with that entity . For the purposes of this definition , <nl> + * " control " means ( i ) the power , direct or indirect , to cause the <nl> + * direction or management of such entity , whether by contract or <nl> + * otherwise , or ( ii ) ownership of fifty percent ( 50 % ) or more of the <nl> + * outstanding shares , or ( iii ) beneficial ownership of such entity . <nl> + * <nl> + * " You " ( or " Your " ) shall mean an individual or Legal Entity <nl> + * exercising permissions granted by this License . <nl> + * <nl> + * " Source " form shall mean the preferred form for making modifications , <nl> + * including but not limited to software source code , documentation <nl> + * source , and configuration files . <nl> + * <nl> + * " Object " form shall mean any form resulting from mechanical <nl> + * transformation or translation of a Source form , including but <nl> + * not limited to compiled object code , generated documentation , <nl> + * and conversions to other media types . <nl> + * <nl> + * " Work " shall mean the work of authorship , whether in Source or <nl> + * Object form , made available under the License , as indicated by a <nl> + * copyright notice that is included in or attached to the work <nl> + * ( an example is provided in the Appendix below ) . <nl> + * <nl> + * " Derivative Works " shall mean any work , whether in Source or Object <nl> + * form , that is based on ( or derived from ) the Work and for which the <nl> + * editorial revisions , annotations , elaborations , or other modifications <nl> + * represent , as a whole , an original work of authorship . For the purposes <nl> + * of this License , Derivative Works shall not include works that remain <nl> + * separable from , or merely link ( or bind by name ) to the interfaces of , <nl> + * the Work and Derivative Works thereof . <nl> + * <nl> + * " Contribution " shall mean any work of authorship , including <nl> + * the original version of the Work and any modifications or additions <nl> + * to that Work or Derivative Works thereof , that is intentionally <nl> + * submitted to Licensor for inclusion in the Work by the copyright owner <nl> + * or by an individual or Legal Entity authorized to submit on behalf of <nl> + * the copyright owner . For the purposes of this definition , " submitted " <nl> + * means any form of electronic , verbal , or written communication sent <nl> + * to the Licensor or its representatives , including but not limited to <nl> + * communication on electronic mailing lists , source code control systems , <nl> + * and issue tracking systems that are managed by , or on behalf of , the <nl> + * Licensor for the purpose of discussing and improving the Work , but <nl> + * excluding communication that is conspicuously marked or otherwise <nl> + * designated in writing by the copyright owner as " Not a Contribution . " <nl> + * <nl> + * " Contributor " shall mean Licensor and any individual or Legal Entity <nl> + * on behalf of whom a Contribution has been received by Licensor and <nl> + * subsequently incorporated within the Work . <nl> + * <nl> + * 2 . Grant of Copyright License . Subject to the terms and conditions of <nl> + * this License , each Contributor hereby grants to You a perpetual , <nl> + * worldwide , non - exclusive , no - charge , royalty - free , irrevocable <nl> + * copyright license to reproduce , prepare Derivative Works of , <nl> + * publicly display , publicly perform , sublicense , and distribute the <nl> + * Work and such Derivative Works in Source or Object form . <nl> + * <nl> + * 3 . Grant of Patent License . Subject to the terms and conditions of <nl> + * this License , each Contributor hereby grants to You a perpetual , <nl> + * worldwide , non - exclusive , no - charge , royalty - free , irrevocable <nl> + * ( except as stated in this section ) patent license to make , have made , <nl> + * use , offer to sell , sell , import , and otherwise transfer the Work , <nl> + * where such license applies only to those patent claims licensable <nl> + * by such Contributor that are necessarily infringed by their <nl> + * Contribution ( s ) alone or by combination of their Contribution ( s ) <nl> + * with the Work to which such Contribution ( s ) was submitted . If You <nl> + * institute patent litigation against any entity ( including a <nl> + * cross - claim or counterclaim in a lawsuit ) alleging that the Work <nl> + * or a Contribution incorporated within the Work constitutes direct <nl> + * or contributory patent infringement , then any patent licenses <nl> + * granted to You under this License for that Work shall terminate <nl> + * as of the date such litigation is filed . <nl> + * <nl> + * 4 . Redistribution . You may reproduce and distribute copies of the <nl> + * Work or Derivative Works thereof in any medium , with or without <nl> + * modifications , and in Source or Object form , provided that You <nl> + * meet the following conditions : <nl> + * <nl> + * ( a ) You must give any other recipients of the Work or <nl> + * Derivative Works a copy of this License ; and <nl> + * <nl> + * ( b ) You must cause any modified files to carry prominent notices <nl> + * stating that You changed the files ; and <nl> + * <nl> + * ( c ) You must retain , in the Source form of any Derivative Works <nl> + * that You distribute , all copyright , patent , trademark , and <nl> + * attribution notices from the Source form of the Work , <nl> + * excluding those notices that do not pertain to any part of <nl> + * the Derivative Works ; and <nl> + * <nl> + * ( d ) If the Work includes a " NOTICE " text file as part of its <nl> + * distribution , then any Derivative Works that You distribute must <nl> + * include a readable copy of the attribution notices contained <nl> + * within such NOTICE file , excluding those notices that do not <nl> + * pertain to any part of the Derivative Works , in at least one <nl> + * of the following places : within a NOTICE text file distributed <nl> + * as part of the Derivative Works ; within the Source form or <nl> + * documentation , if provided along with the Derivative Works ; or , <nl> + * within a display generated by the Derivative Works , if and <nl> + * wherever such third - party notices normally appear . The contents <nl> + * of the NOTICE file are for informational purposes only and <nl> + * do not modify the License . You may add Your own attribution <nl> + * notices within Derivative Works that You distribute , alongside <nl> + * or as an addendum to the NOTICE text from the Work , provided <nl> + * that such additional attribution notices cannot be construed <nl> + * as modifying the License . <nl> + * <nl> + * You may add Your own copyright statement to Your modifications and <nl> + * may provide additional or different license terms and conditions <nl> + * for use , reproduction , or distribution of Your modifications , or <nl> + * for any such Derivative Works as a whole , provided Your use , <nl> + * reproduction , and distribution of the Work otherwise complies with <nl> + * the conditions stated in this License . <nl> + * <nl> + * 5 . Submission of Contributions . Unless You explicitly state otherwise , <nl> + * any Contribution intentionally submitted for inclusion in the Work <nl> + * by You to the Licensor shall be under the terms and conditions of <nl> + * this License , without any additional terms or conditions . <nl> + * Notwithstanding the above , nothing herein shall supersede or modify <nl> + * the terms of any separate license agreement you may have executed <nl> + * with Licensor regarding such Contributions . <nl> + * <nl> + * 6 . Trademarks . This License does not grant permission to use the trade <nl> + * names , trademarks , service marks , or product names of the Licensor , <nl> + * except as required for reasonable and customary use in describing the <nl> + * origin of the Work and reproducing the content of the NOTICE file . <nl> + * <nl> + * 7 . Disclaimer of Warranty . Unless required by applicable law or <nl> + * agreed to in writing , Licensor provides the Work ( and each <nl> + * Contributor provides its Contributions ) on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or <nl> + * implied , including , without limitation , any warranties or conditions <nl> + * of TITLE , NON - INFRINGEMENT , MERCHANTABILITY , or FITNESS FOR A <nl> + * PARTICULAR PURPOSE . You are solely responsible for determining the <nl> + * appropriateness of using or redistributing the Work and assume any <nl> + * risks associated with Your exercise of permissions under this License . <nl> + * <nl> + * 8 . Limitation of Liability . In no event and under no legal theory , <nl> + * whether in tort ( including negligence ) , contract , or otherwise , <nl> + * unless required by applicable law ( such as deliberate and grossly <nl> + * negligent acts ) or agreed to in writing , shall any Contributor be <nl> + * liable to You for damages , including any direct , indirect , special , <nl> + * incidental , or consequential damages of any character arising as a <nl> + * result of this License or out of the use or inability to use the <nl> + * Work ( including but not limited to damages for loss of goodwill , <nl> + * work stoppage , computer failure or malfunction , or any and all <nl> + * other commercial damages or losses ) , even if such Contributor <nl> + * has been advised of the possibility of such damages . <nl> + * <nl> + * 9 . Accepting Warranty or Additional Liability . While redistributing <nl> + * the Work or Derivative Works thereof , You may choose to offer , <nl> + * and charge a fee for , acceptance of support , warranty , indemnity , <nl> + * or other liability obligations and / or rights consistent with this <nl> + * License . However , in accepting such obligations , You may act only <nl> + * on Your own behalf and on Your sole responsibility , not on behalf <nl> + * of any other Contributor , and only if You agree to indemnify , <nl> + * defend , and hold each Contributor harmless for any liability <nl> + * incurred by , or claims asserted against , such Contributor by reason <nl> + * of your accepting any such warranty or additional liability . <nl> + * <nl> + * END OF TERMS AND CONDITIONS <nl> + * <nl> + * APPENDIX : How to apply the Apache License to your work . <nl> + * <nl> + * To apply the Apache License to your work , attach the following <nl> + * boilerplate notice , with the fields enclosed by brackets " [ ] " <nl> + * replaced with your own identifying information . ( Don ' t include <nl> + * the brackets ! ) The text should be enclosed in the appropriate <nl> + * comment syntax for the file format . We also recommend that a <nl> + * file or class name and description of purpose be included on the <nl> + * same " printed page " as the copyright notice for easier <nl> + * identification within third - party archives . <nl> + * <nl> + * Copyright 2016 Alibaba Group <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> + package com . taobao . weex . appfram . websocket ; <nl> + <nl> + import android . support . annotation . Nullable ; <nl> + <nl> + / * * <nl> + * Created by moxun on 16 / 12 / 27 . <nl> + * / <nl> + <nl> + public interface IWXWebSocketAdapter { <nl> + void connect ( String url , @ Nullable String protocol , EventListener listener ) ; <nl> + void send ( String data ) ; <nl> + void close ( int code , String reason ) ; <nl> + <nl> + interface EventListener { <nl> + <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 0000000000 . . 4b181cced9 <nl> mmm / dev / null <nl> ppp b / android / sdk / src / main / java / com / taobao / weex / appfram / websocket / WXWebSocketModule . java <nl> <nl> + / * * <nl> + * <nl> + * Apache License <nl> + * Version 2 . 0 , January 2004 <nl> + * http : / / www . apache . org / licenses / <nl> + * <nl> + * TERMS AND CONDITIONS FOR USE , REPRODUCTION , AND DISTRIBUTION <nl> + * <nl> + * 1 . Definitions . <nl> + * <nl> + * " License " shall mean the terms and conditions for use , reproduction , <nl> + * and distribution as defined by Sections 1 through 9 of this document . <nl> + * <nl> + * " Licensor " shall mean the copyright owner or entity authorized by <nl> + * the copyright owner that is granting the License . <nl> + * <nl> + * " Legal Entity " shall mean the union of the acting entity and all <nl> + * other entities that control , are controlled by , or are under common <nl> + * control with that entity . For the purposes of this definition , <nl> + * " control " means ( i ) the power , direct or indirect , to cause the <nl> + * direction or management of such entity , whether by contract or <nl> + * otherwise , or ( ii ) ownership of fifty percent ( 50 % ) or more of the <nl> + * outstanding shares , or ( iii ) beneficial ownership of such entity . <nl> + * <nl> + * " You " ( or " Your " ) shall mean an individual or Legal Entity <nl> + * exercising permissions granted by this License . <nl> + * <nl> + * " Source " form shall mean the preferred form for making modifications , <nl> + * including but not limited to software source code , documentation <nl> + * source , and configuration files . <nl> + * <nl> + * " Object " form shall mean any form resulting from mechanical <nl> + * transformation or translation of a Source form , including but <nl> + * not limited to compiled object code , generated documentation , <nl> + * and conversions to other media types . <nl> + * <nl> + * " Work " shall mean the work of authorship , whether in Source or <nl> + * Object form , made available under the License , as indicated by a <nl> + * copyright notice that is included in or attached to the work <nl> + * ( an example is provided in the Appendix below ) . <nl> + * <nl> + * " Derivative Works " shall mean any work , whether in Source or Object <nl> + * form , that is based on ( or derived from ) the Work and for which the <nl> + * editorial revisions , annotations , elaborations , or other modifications <nl> + * represent , as a whole , an original work of authorship . For the purposes <nl> + * of this License , Derivative Works shall not include works that remain <nl> + * separable from , or merely link ( or bind by name ) to the interfaces of , <nl> + * the Work and Derivative Works thereof . <nl> + * <nl> + * " Contribution " shall mean any work of authorship , including <nl> + * the original version of the Work and any modifications or additions <nl> + * to that Work or Derivative Works thereof , that is intentionally <nl> + * submitted to Licensor for inclusion in the Work by the copyright owner <nl> + * or by an individual or Legal Entity authorized to submit on behalf of <nl> + * the copyright owner . For the purposes of this definition , " submitted " <nl> + * means any form of electronic , verbal , or written communication sent <nl> + * to the Licensor or its representatives , including but not limited to <nl> + * communication on electronic mailing lists , source code control systems , <nl> + * and issue tracking systems that are managed by , or on behalf of , the <nl> + * Licensor for the purpose of discussing and improving the Work , but <nl> + * excluding communication that is conspicuously marked or otherwise <nl> + * designated in writing by the copyright owner as " Not a Contribution . " <nl> + * <nl> + * " Contributor " shall mean Licensor and any individual or Legal Entity <nl> + * on behalf of whom a Contribution has been received by Licensor and <nl> + * subsequently incorporated within the Work . <nl> + * <nl> + * 2 . Grant of Copyright License . Subject to the terms and conditions of <nl> + * this License , each Contributor hereby grants to You a perpetual , <nl> + * worldwide , non - exclusive , no - charge , royalty - free , irrevocable <nl> + * copyright license to reproduce , prepare Derivative Works of , <nl> + * publicly display , publicly perform , sublicense , and distribute the <nl> + * Work and such Derivative Works in Source or Object form . <nl> + * <nl> + * 3 . Grant of Patent License . Subject to the terms and conditions of <nl> + * this License , each Contributor hereby grants to You a perpetual , <nl> + * worldwide , non - exclusive , no - charge , royalty - free , irrevocable <nl> + * ( except as stated in this section ) patent license to make , have made , <nl> + * use , offer to sell , sell , import , and otherwise transfer the Work , <nl> + * where such license applies only to those patent claims licensable <nl> + * by such Contributor that are necessarily infringed by their <nl> + * Contribution ( s ) alone or by combination of their Contribution ( s ) <nl> + * with the Work to which such Contribution ( s ) was submitted . If You <nl> + * institute patent litigation against any entity ( including a <nl> + * cross - claim or counterclaim in a lawsuit ) alleging that the Work <nl> + * or a Contribution incorporated within the Work constitutes direct <nl> + * or contributory patent infringement , then any patent licenses <nl> + * granted to You under this License for that Work shall terminate <nl> + * as of the date such litigation is filed . <nl> + * <nl> + * 4 . Redistribution . You may reproduce and distribute copies of the <nl> + * Work or Derivative Works thereof in any medium , with or without <nl> + * modifications , and in Source or Object form , provided that You <nl> + * meet the following conditions : <nl> + * <nl> + * ( a ) You must give any other recipients of the Work or <nl> + * Derivative Works a copy of this License ; and <nl> + * <nl> + * ( b ) You must cause any modified files to carry prominent notices <nl> + * stating that You changed the files ; and <nl> + * <nl> + * ( c ) You must retain , in the Source form of any Derivative Works <nl> + * that You distribute , all copyright , patent , trademark , and <nl> + * attribution notices from the Source form of the Work , <nl> + * excluding those notices that do not pertain to any part of <nl> + * the Derivative Works ; and <nl> + * <nl> + * ( d ) If the Work includes a " NOTICE " text file as part of its <nl> + * distribution , then any Derivative Works that You distribute must <nl> + * include a readable copy of the attribution notices contained <nl> + * within such NOTICE file , excluding those notices that do not <nl> + * pertain to any part of the Derivative Works , in at least one <nl> + * of the following places : within a NOTICE text file distributed <nl> + * as part of the Derivative Works ; within the Source form or <nl> + * documentation , if provided along with the Derivative Works ; or , <nl> + * within a display generated by the Derivative Works , if and <nl> + * wherever such third - party notices normally appear . The contents <nl> + * of the NOTICE file are for informational purposes only and <nl> + * do not modify the License . You may add Your own attribution <nl> + * notices within Derivative Works that You distribute , alongside <nl> + * or as an addendum to the NOTICE text from the Work , provided <nl> + * that such additional attribution notices cannot be construed <nl> + * as modifying the License . <nl> + * <nl> + * You may add Your own copyright statement to Your modifications and <nl> + * may provide additional or different license terms and conditions <nl> + * for use , reproduction , or distribution of Your modifications , or <nl> + * for any such Derivative Works as a whole , provided Your use , <nl> + * reproduction , and distribution of the Work otherwise complies with <nl> + * the conditions stated in this License . <nl> + * <nl> + * 5 . Submission of Contributions . Unless You explicitly state otherwise , <nl> + * any Contribution intentionally submitted for inclusion in the Work <nl> + * by You to the Licensor shall be under the terms and conditions of <nl> + * this License , without any additional terms or conditions . <nl> + * Notwithstanding the above , nothing herein shall supersede or modify <nl> + * the terms of any separate license agreement you may have executed <nl> + * with Licensor regarding such Contributions . <nl> + * <nl> + * 6 . Trademarks . This License does not grant permission to use the trade <nl> + * names , trademarks , service marks , or product names of the Licensor , <nl> + * except as required for reasonable and customary use in describing the <nl> + * origin of the Work and reproducing the content of the NOTICE file . <nl> + * <nl> + * 7 . Disclaimer of Warranty . Unless required by applicable law or <nl> + * agreed to in writing , Licensor provides the Work ( and each <nl> + * Contributor provides its Contributions ) on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or <nl> + * implied , including , without limitation , any warranties or conditions <nl> + * of TITLE , NON - INFRINGEMENT , MERCHANTABILITY , or FITNESS FOR A <nl> + * PARTICULAR PURPOSE . You are solely responsible for determining the <nl> + * appropriateness of using or redistributing the Work and assume any <nl> + * risks associated with Your exercise of permissions under this License . <nl> + * <nl> + * 8 . Limitation of Liability . In no event and under no legal theory , <nl> + * whether in tort ( including negligence ) , contract , or otherwise , <nl> + * unless required by applicable law ( such as deliberate and grossly <nl> + * negligent acts ) or agreed to in writing , shall any Contributor be <nl> + * liable to You for damages , including any direct , indirect , special , <nl> + * incidental , or consequential damages of any character arising as a <nl> + * result of this License or out of the use or inability to use the <nl> + * Work ( including but not limited to damages for loss of goodwill , <nl> + * work stoppage , computer failure or malfunction , or any and all <nl> + * other commercial damages or losses ) , even if such Contributor <nl> + * has been advised of the possibility of such damages . <nl> + * <nl> + * 9 . Accepting Warranty or Additional Liability . While redistributing <nl> + * the Work or Derivative Works thereof , You may choose to offer , <nl> + * and charge a fee for , acceptance of support , warranty , indemnity , <nl> + * or other liability obligations and / or rights consistent with this <nl> + * License . However , in accepting such obligations , You may act only <nl> + * on Your own behalf and on Your sole responsibility , not on behalf <nl> + * of any other Contributor , and only if You agree to indemnify , <nl> + * defend , and hold each Contributor harmless for any liability <nl> + * incurred by , or claims asserted against , such Contributor by reason <nl> + * of your accepting any such warranty or additional liability . <nl> + * <nl> + * END OF TERMS AND CONDITIONS <nl> + * <nl> + * APPENDIX : How to apply the Apache License to your work . <nl> + * <nl> + * To apply the Apache License to your work , attach the following <nl> + * boilerplate notice , with the fields enclosed by brackets " [ ] " <nl> + * replaced with your own identifying information . ( Don ' t include <nl> + * the brackets ! ) The text should be enclosed in the appropriate <nl> + * comment syntax for the file format . We also recommend that a <nl> + * file or class name and description of purpose be included on the <nl> + * same " printed page " as the copyright notice for easier <nl> + * identification within third - party archives . <nl> + * <nl> + * Copyright 2016 Alibaba Group <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> + package com . taobao . weex . appfram . websocket ; <nl> + <nl> + import com . taobao . weex . WXSDKEngine ; <nl> + <nl> + / * * <nl> + * Created by moxun on 16 / 12 / 27 . <nl> + * / <nl> + <nl> + public class WXWebSocketModule extends WXSDKEngine . DestroyableModule { <nl> + <nl> + IWXWebSocketAdapter webSocketAdapter ; <nl> + <nl> + @ Override <nl> + public void destroy ( ) { <nl> + <nl> + } <nl> + } <nl>
* [ android ] stash
apache/incubator-weex
29c7cbbaa4f303c772d30e3af83ca47069c05107
2016-12-28T03:12:41Z
mmm a / selfdrive / car / toyota / values . py <nl> ppp b / selfdrive / car / toyota / values . py <nl> class CAR : <nl> b ' 8965B48271 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 ' , <nl> ] , <nl> ( Ecu . fwdRadar , 0x750 , 0xf ) : [ <nl> - b ' \ x018821F3301400 \ x00 \ x00 \ x00 \ x00 ' , <nl> + b ' \ x018821F3301100 \ x00 \ x00 \ x00 \ x00 ' , <nl> b ' \ x018821F3301300 \ x00 \ x00 \ x00 \ x00 ' , <nl> + b ' \ x018821F3301400 \ x00 \ x00 \ x00 \ x00 ' , <nl> ] , <nl> ( Ecu . fwdCamera , 0x750 , 0x6d ) : [ <nl> b ' \ x028646F4810100 \ x00 \ x00 \ x00 \ x008646G2601200 \ x00 \ x00 \ x00 \ x00 ' , <nl>
Added 2020 RX350 fwdRadar f / w x018821F3301100 ( )
commaai/openpilot
853dfcd59ace1e7ee2f13b45403af94065fd921f
2020-06-18T22:38:19Z
mmm a / src / bittorrent . cpp <nl> ppp b / src / bittorrent . cpp <nl> QTorrentHandle Bittorrent : : addTorrent ( QString path , bool fromScanDir , QString fr <nl> } <nl> return h ; <nl> } <nl> + / / Check number of files <nl> + if ( t - > num_files ( ) < 1 ) { <nl> + addConsoleMessage ( tr ( " Error : The torrent % 1 does not contain any file . " ) . arg ( misc : : toQStringU ( t - > name ( ) ) ) ) ; <nl> + if ( fromScanDir ) { <nl> + / / Delete torrent from scan dir <nl> + QFile : : remove ( file ) ; <nl> + } else { <nl> + if ( ! from_url . isNull ( ) ) { <nl> + / / If download from url , remove temp file <nl> + QFile : : remove ( file ) ; <nl> + } <nl> + } <nl> + return h ; <nl> + } <nl> + / / Actually add the torrent <nl> QString root_folder = misc : : truncateRootFolder ( t ) ; <nl> add_torrent_params p ; <nl> / / Getting fast resume data if existing <nl> mmm a / src / torrentadditiondlg . cpp <nl> ppp b / src / torrentadditiondlg . cpp <nl> <nl> <nl> # include " torrentadditiondlg . h " <nl> <nl> - torrentAdditionDialog : : torrentAdditionDialog ( GUI * parent , Bittorrent * _BTSession ) : QDialog ( ( QWidget * ) parent ) , old_label ( " " ) { <nl> + torrentAdditionDialog : : torrentAdditionDialog ( GUI * parent , Bittorrent * _BTSession ) : QDialog ( ( QWidget * ) parent ) , old_label ( " " ) , hidden_height ( 0 ) { <nl> setupUi ( this ) ; <nl> setAttribute ( Qt : : WA_DeleteOnClose ) ; <nl> connect ( this , SIGNAL ( torrentPaused ( QTorrentHandle & ) ) , parent - > getTransferList ( ) , SLOT ( pauseTorrent ( QTorrentHandle & ) ) ) ; <nl> void torrentAdditionDialog : : readSettings ( ) { <nl> } <nl> <nl> void torrentAdditionDialog : : saveSettings ( ) { <nl> - if ( is_magnet | | t - > num_files ( ) < = 1 ) return ; <nl> QSettings settings ( QString : : fromUtf8 ( " qBittorrent " ) , QString : : fromUtf8 ( " qBittorrent " ) ) ; <nl> - QStringList contentColsWidths ; <nl> - / / - 1 because we hid PROGRESS column <nl> - for ( int i = 0 ; i < PropListModel - > columnCount ( ) - 1 ; + + i ) { <nl> - contentColsWidths < < QString : : number ( torrentContentList - > columnWidth ( i ) ) ; <nl> + if ( ! is_magnet & & t - > num_files ( ) > 1 ) { <nl> + QStringList contentColsWidths ; <nl> + / / - 1 because we hid PROGRESS column <nl> + for ( int i = 0 ; i < PropListModel - > columnCount ( ) - 1 ; + + i ) { <nl> + contentColsWidths < < QString : : number ( torrentContentList - > columnWidth ( i ) ) ; <nl> + } <nl> + settings . setValue ( QString : : fromUtf8 ( " TorrentAdditionDlg / filesColsWidth " ) , contentColsWidths ) ; <nl> } <nl> - settings . setValue ( QString : : fromUtf8 ( " TorrentAdditionDlg / filesColsWidth " ) , contentColsWidths ) ; <nl> - settings . setValue ( " TorrentAdditionDlg / size " , size ( ) ) ; <nl> + settings . setValue ( " TorrentAdditionDlg / size " , size ( ) + QSize ( 0 , hidden_height ) ) ; <nl> + qDebug ( " pos : ( % d , % d ) " , pos ( ) . x ( ) , pos ( ) . y ( ) ) ; <nl> settings . setValue ( " TorrentAdditionDlg / pos " , pos ( ) ) ; <nl> } <nl> <nl> void torrentAdditionDialog : : renameTorrentNameInModel ( QString file_path ) { <nl> } <nl> <nl> void torrentAdditionDialog : : hideTorrentContent ( ) { <nl> - int hidden_height = 0 ; <nl> / / Disable useless widgets <nl> hidden_height + = torrentContentList - > height ( ) ; <nl> torrentContentList - > setVisible ( false ) ; <nl> mmm a / src / torrentadditiondlg . h <nl> ppp b / src / torrentadditiondlg . h <nl> public slots : <nl> boost : : intrusive_ptr < torrent_info > t ; <nl> QStringList files_path ; <nl> bool is_magnet ; <nl> + int hidden_height ; <nl> } ; <nl> <nl> # endif <nl>
Torrent addition dialog size / pos are now remembered correctly
qbittorrent/qBittorrent
cf65e4d77d77badead81d5d80e960cb7b8e24c30
2010-06-23T15:14:38Z
mmm a / src / heap . cc <nl> ppp b / src / heap . cc <nl> Heap : : HeapState Heap : : gc_state_ = NOT_IN_GC ; <nl> <nl> int Heap : : mc_count_ = 0 ; <nl> int Heap : : ms_count_ = 0 ; <nl> - int Heap : : gc_count_ = 0 ; <nl> + unsigned int Heap : : gc_count_ = 0 ; <nl> <nl> GCTracer * Heap : : tracer_ = NULL ; <nl> <nl> bool Heap : : IdleNotification ( ) { <nl> static const int kIdlesBeforeMarkSweep = 7 ; <nl> static const int kIdlesBeforeMarkCompact = 8 ; <nl> static const int kMaxIdleCount = kIdlesBeforeMarkCompact + 1 ; <nl> - static const int kGCsBetweenCleanup = 4 ; <nl> + static const unsigned int kGCsBetweenCleanup = 4 ; <nl> static int number_idle_notifications = 0 ; <nl> - static int last_gc_count = gc_count_ ; <nl> + static unsigned int last_gc_count = gc_count_ ; <nl> <nl> bool uncommit = true ; <nl> bool finished = false ; <nl> bool Heap : : IdleNotification ( ) { <nl> / / GCs have taken place . This allows another round of cleanup based <nl> / / on idle notifications if enough work has been carried out to <nl> / / provoke a number of garbage collections . <nl> - if ( gc_count_ < last_gc_count + kGCsBetweenCleanup ) { <nl> + if ( gc_count_ - last_gc_count < kGCsBetweenCleanup ) { <nl> number_idle_notifications = <nl> Min ( number_idle_notifications + 1 , kMaxIdleCount ) ; <nl> } else { <nl> mmm a / src / heap . h <nl> ppp b / src / heap . h <nl> class Heap : public AllStatic { <nl> <nl> static int mc_count_ ; / / how many mark - compact collections happened <nl> static int ms_count_ ; / / how many mark - sweep collections happened <nl> - static int gc_count_ ; / / how many gc happened <nl> + static unsigned int gc_count_ ; / / how many gc happened <nl> <nl> / / Total length of the strings we failed to flatten since the last GC . <nl> static int unflattened_strings_length_ ; <nl> class GCTracer BASE_EMBEDDED { <nl> void set_collector ( GarbageCollector collector ) { collector_ = collector ; } <nl> <nl> / / Sets the GC count . <nl> - void set_gc_count ( int count ) { gc_count_ = count ; } <nl> + void set_gc_count ( unsigned int count ) { gc_count_ = count ; } <nl> <nl> / / Sets the full GC count . <nl> void set_full_gc_count ( int count ) { full_gc_count_ = count ; } <nl> class GCTracer BASE_EMBEDDED { <nl> <nl> / / A count ( including this one , eg , the first collection is 1 ) of the <nl> / / number of garbage collections . <nl> - int gc_count_ ; <nl> + unsigned int gc_count_ ; <nl> <nl> / / A count ( including this one ) of the number of full garbage collections . <nl> int full_gc_count_ ; <nl>
Heap : : gc_count_ , last_gc_count , and kGCsBetweenCleanup should be unsigned
v8/v8
58600281e830413bc84a59c30ac11665d4be9008
2011-02-21T16:11:46Z
mmm a / torch / nn / _functions / thnn / auto_double_backwards . py <nl> ppp b / torch / nn / _functions / thnn / auto_double_backwards . py <nl> def leakyrelu_double_backwards ( ctx , ggI ) : <nl> <nl> gI = Variable ( ggI . data . new ( ggI . size ( ) ) . zero_ ( ) ) <nl> input_lt_0 = ( input < 0 ) . type_as ( ggI ) <nl> - input_ge_0 = ( input > = 0 ) . type_as ( ggI ) <nl> + input_ge_0 = ( input > = 0 ) . type_as ( ggI ) <nl> ggO = ggI * ( input_lt_0 * negative_slope + input_ge_0 ) <nl> return gI , ggO , None , None , None <nl> <nl>
Fix lint .
pytorch/pytorch
2118400e185ab132628062e6537d31db750c2f9e
2017-07-25T02:07:25Z
new file mode 100644 <nl> index 00000000000 . . 0abff0ff674 <nl> mmm / dev / null <nl> ppp b / lib / Basics / VelocyPackDumper . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2016 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 Jan Steemann <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " VelocyPackDumper . h " <nl> + # include " Basics / Exceptions . h " <nl> + # include " Basics / fpconv . h " <nl> + # include " Logger / Logger . h " <nl> + / / # include " Basics / StringUtils . h " <nl> + / / # include " Basics / Utf8Helper . h " <nl> + / / # include " Basics / VPackStringBufferAdapter . h " <nl> + / / # include " Basics / files . h " <nl> + / / # include " Basics / hashes . h " <nl> + / / # include " Basics / tri - strings . h " <nl> + <nl> + # include < velocypack / velocypack - common . h > <nl> + # include < velocypack / AttributeTranslator . h > <nl> + # include " velocypack / Iterator . h " <nl> + # include < velocypack / Options . h > <nl> + # include < velocypack / Slice . h > <nl> + # include < velocypack / velocypack - aliases . h > <nl> + <nl> + using namespace arangodb : : basics ; <nl> + <nl> + void VelocyPackDumper : : handleUnsupportedType ( VPackSlice const * slice ) { <nl> + if ( options - > unsupportedTypeBehavior = = VPackOptions : : NullifyUnsupportedType ) { <nl> + _buffer - > appendText ( " null " , 4 ) ; <nl> + return ; <nl> + } else if ( options - > unsupportedTypeBehavior = = VPackOptions : : ConvertUnsupportedType ) { <nl> + _buffer - > appendText ( std : : string ( " \ " ( non - representable type " ) + slice - > typeName ( ) + " ) \ " " ) ; <nl> + return ; <nl> + } <nl> + <nl> + throw VPackException ( VPackException : : NoJsonEquivalent ) ; <nl> + } <nl> + <nl> + void VelocyPackDumper : : appendUInt ( uint64_t v ) { <nl> + if ( 10000000000000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000000000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 1000000000000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000000000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 100000000000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000000000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 10000000000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 1000000000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 100000000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 10000000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 1000000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 100000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 10000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 1000000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 100000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 10000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 1000000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000ULL ) % 10 ) ; <nl> + } <nl> + if ( 100000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000ULL ) % 10 ) ; <nl> + } <nl> + if ( 10000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000ULL ) % 10 ) ; <nl> + } <nl> + if ( 1000ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000ULL ) % 10 ) ; <nl> + } <nl> + if ( 100ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100ULL ) % 10 ) ; <nl> + } <nl> + if ( 10ULL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10ULL ) % 10 ) ; <nl> + } <nl> + <nl> + _buffer - > appendChar ( ' 0 ' + ( v % 10 ) ) ; <nl> + } <nl> + <nl> + void VelocyPackDumper : : appendDouble ( double v ) { <nl> + char temp [ 24 ] ; <nl> + int len = fpconv_dtoa ( v , & temp [ 0 ] ) ; <nl> + _buffer - > appendText ( & temp [ 0 ] , static_cast < VPackValueLength > ( len ) ) ; <nl> + } <nl> + <nl> + void VelocyPackDumper : : dumpInteger ( VPackSlice const * slice ) { <nl> + if ( slice - > isType ( VPackValueType : : UInt ) ) { <nl> + uint64_t v = slice - > getUInt ( ) ; <nl> + <nl> + appendUInt ( v ) ; <nl> + } else if ( slice - > isType ( VPackValueType : : Int ) ) { <nl> + int64_t v = slice - > getInt ( ) ; <nl> + if ( v = = INT64_MIN ) { <nl> + _buffer - > appendText ( " - 9223372036854775808 " , 20 ) ; <nl> + return ; <nl> + } <nl> + if ( v < 0 ) { <nl> + _buffer - > appendChar ( ' - ' ) ; <nl> + v = - v ; <nl> + } <nl> + <nl> + if ( 1000000000000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000000000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 100000000000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000000000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 10000000000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 1000000000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 100000000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 10000000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 1000000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 100000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 10000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 1000000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000000LL ) % 10 ) ; <nl> + } <nl> + if ( 100000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000000LL ) % 10 ) ; <nl> + } <nl> + if ( 10000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000000LL ) % 10 ) ; <nl> + } <nl> + if ( 1000000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000000LL ) % 10 ) ; <nl> + } <nl> + if ( 100000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100000LL ) % 10 ) ; <nl> + } <nl> + if ( 10000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10000LL ) % 10 ) ; <nl> + } <nl> + if ( 1000LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 1000LL ) % 10 ) ; <nl> + } <nl> + if ( 100LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 100LL ) % 10 ) ; <nl> + } <nl> + if ( 10LL < = v ) { <nl> + _buffer - > appendChar ( ' 0 ' + ( v / 10LL ) % 10 ) ; <nl> + } <nl> + <nl> + _buffer - > appendChar ( ' 0 ' + ( v % 10 ) ) ; <nl> + } else if ( slice - > isType ( VPackValueType : : SmallInt ) ) { <nl> + int64_t v = slice - > getSmallInt ( ) ; <nl> + if ( v < 0 ) { <nl> + _buffer - > appendChar ( ' - ' ) ; <nl> + v = - v ; <nl> + } <nl> + _buffer - > appendChar ( ' 0 ' + static_cast < char > ( v ) ) ; <nl> + } <nl> + } <nl> + <nl> + void VelocyPackDumper : : dumpString ( char const * src , VPackValueLength len ) { <nl> + static char const EscapeTable [ 256 ] = { <nl> + / / 0 1 2 3 4 5 6 7 8 9 A B C D E <nl> + / / F <nl> + ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' b ' , ' t ' , ' n ' , ' u ' , ' f ' , ' r ' , <nl> + ' u ' , <nl> + ' u ' , / / 00 <nl> + ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , ' u ' , <nl> + ' u ' , <nl> + ' u ' , / / 10 <nl> + 0 , 0 , ' " ' , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , <nl> + ' / ' , / / 20 <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , <nl> + 0 , / / 30 ~ 4F <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + ' \ \ ' , 0 , 0 , 0 , / / 50 <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , <nl> + 0 , / / 60 ~ FF <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 } ; <nl> + <nl> + _buffer - > reserve ( len ) ; <nl> + <nl> + uint8_t const * p = reinterpret_cast < uint8_t const * > ( src ) ; <nl> + uint8_t const * e = p + len ; <nl> + while ( p < e ) { <nl> + uint8_t c = * p ; <nl> + <nl> + if ( ( c & 0x80 ) = = 0 ) { <nl> + / / check for control characters <nl> + char esc = EscapeTable [ c ] ; <nl> + <nl> + if ( esc ) { <nl> + if ( c ! = ' / ' | | options - > escapeForwardSlashes ) { <nl> + / / escape forward slashes only when requested <nl> + _buffer - > appendChar ( ' \ \ ' ) ; <nl> + } <nl> + _buffer - > appendChar ( static_cast < char > ( esc ) ) ; <nl> + <nl> + if ( esc = = ' u ' ) { <nl> + uint16_t i1 = ( ( ( uint16_t ) c ) & 0xf0 ) > > 4 ; <nl> + uint16_t i2 = ( ( ( uint16_t ) c ) & 0x0f ) ; <nl> + <nl> + _buffer - > appendText ( " 00 " , 2 ) ; <nl> + _buffer - > appendChar ( <nl> + static_cast < char > ( ( i1 < 10 ) ? ( ' 0 ' + i1 ) : ( ' A ' + i1 - 10 ) ) ) ; <nl> + _buffer - > appendChar ( <nl> + static_cast < char > ( ( i2 < 10 ) ? ( ' 0 ' + i2 ) : ( ' A ' + i2 - 10 ) ) ) ; <nl> + } <nl> + } else { <nl> + _buffer - > appendChar ( static_cast < char > ( c ) ) ; <nl> + } <nl> + } else if ( ( c & 0xe0 ) = = 0xc0 ) { <nl> + / / two - byte sequence <nl> + if ( p + 1 > = e ) { <nl> + throw VPackException ( VPackException : : InvalidUtf8Sequence ) ; <nl> + } <nl> + <nl> + _buffer - > appendText ( reinterpret_cast < char const * > ( p ) , 2 ) ; <nl> + + + p ; <nl> + } else if ( ( c & 0xf0 ) = = 0xe0 ) { <nl> + / / three - byte sequence <nl> + if ( p + 2 > = e ) { <nl> + throw VPackException ( VPackException : : InvalidUtf8Sequence ) ; <nl> + } <nl> + <nl> + _buffer - > appendText ( reinterpret_cast < char const * > ( p ) , 3 ) ; <nl> + p + = 2 ; <nl> + } else if ( ( c & 0xf8 ) = = 0xf0 ) { <nl> + / / four - byte sequence <nl> + if ( p + 3 > = e ) { <nl> + throw VPackException ( VPackException : : InvalidUtf8Sequence ) ; <nl> + } <nl> + <nl> + _buffer - > appendText ( reinterpret_cast < char const * > ( p ) , 4 ) ; <nl> + p + = 3 ; <nl> + } <nl> + <nl> + + + p ; <nl> + } <nl> + } <nl> + <nl> + void VelocyPackDumper : : dumpValue ( VPackSlice const * slice , VPackSlice const * base ) { <nl> + if ( base = = nullptr ) { <nl> + base = slice ; <nl> + } <nl> + <nl> + switch ( slice - > type ( ) ) { <nl> + case VPackValueType : : Null : { <nl> + _buffer - > appendText ( " null " , 4 ) ; <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : Bool : { <nl> + if ( slice - > getBool ( ) ) { <nl> + _buffer - > appendText ( " true " , 4 ) ; <nl> + } else { <nl> + _buffer - > appendText ( " false " , 5 ) ; <nl> + } <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : Array : { <nl> + VPackArrayIterator it ( * slice , true ) ; <nl> + _buffer - > appendChar ( ' [ ' ) ; <nl> + while ( it . valid ( ) ) { <nl> + if ( ! it . isFirst ( ) ) { <nl> + _buffer - > appendChar ( ' , ' ) ; <nl> + } <nl> + dumpValue ( it . value ( ) , slice ) ; <nl> + it . next ( ) ; <nl> + } <nl> + _buffer - > appendChar ( ' ] ' ) ; <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : Object : { <nl> + VPackObjectIterator it ( * slice ) ; <nl> + _buffer - > appendChar ( ' { ' ) ; <nl> + while ( it . valid ( ) ) { <nl> + if ( ! it . isFirst ( ) ) { <nl> + _buffer - > appendChar ( ' , ' ) ; <nl> + } <nl> + dumpValue ( it . key ( ) . makeKey ( ) , slice ) ; <nl> + _buffer - > appendChar ( ' : ' ) ; <nl> + dumpValue ( it . value ( ) , slice ) ; <nl> + it . next ( ) ; <nl> + } <nl> + _buffer - > appendChar ( ' } ' ) ; <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : Double : { <nl> + double const v = slice - > getDouble ( ) ; <nl> + if ( std : : isnan ( v ) | | ! std : : isfinite ( v ) ) { <nl> + handleUnsupportedType ( slice ) ; <nl> + } else { <nl> + appendDouble ( v ) ; <nl> + } <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : Int : <nl> + case VPackValueType : : UInt : <nl> + case VPackValueType : : SmallInt : { <nl> + dumpInteger ( slice ) ; <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : String : { <nl> + VPackValueLength len ; <nl> + char const * p = slice - > getString ( len ) ; <nl> + _buffer - > reserve ( 2 + len ) ; <nl> + _buffer - > appendChar ( ' " ' ) ; <nl> + dumpString ( p , len ) ; <nl> + _buffer - > appendChar ( ' " ' ) ; <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : External : { <nl> + VPackSlice const external ( slice - > getExternal ( ) ) ; <nl> + dumpValue ( & external , base ) ; <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : Custom : { <nl> + if ( options - > customTypeHandler = = nullptr ) { <nl> + throw VPackException ( VPackException : : NeedCustomTypeHandler ) ; <nl> + } else { <nl> + std : : string v = options - > customTypeHandler - > toString ( * slice , nullptr , * base ) ; <nl> + dumpString ( v . c_str ( ) , v . size ( ) ) ; <nl> + } <nl> + break ; <nl> + } <nl> + <nl> + case VPackValueType : : UTCDate : <nl> + case VPackValueType : : None : <nl> + case VPackValueType : : Binary : <nl> + case VPackValueType : : Illegal : <nl> + case VPackValueType : : MinKey : <nl> + case VPackValueType : : MaxKey : <nl> + case VPackValueType : : BCD : { <nl> + handleUnsupportedType ( slice ) ; <nl> + break ; <nl> + } <nl> + <nl> + } <nl> + } <nl> + <nl> new file mode 100644 <nl> index 00000000000 . . f41b0912ba9 <nl> mmm / dev / null <nl> ppp b / lib / Basics / VelocyPackDumper . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2016 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 Jan Steemann <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_BASICS_VELOCY_PACK_DUMPER_H <nl> + # define ARANGODB_BASICS_VELOCY_PACK_DUMPER_H 1 <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Basics / StringBuffer . h " <nl> + # include " Logger / Logger . h " <nl> + <nl> + # include < velocypack / Exception . h > <nl> + # include < velocypack / Slice . h > <nl> + <nl> + namespace arangodb { <nl> + namespace velocypack { <nl> + struct Options ; <nl> + } <nl> + <nl> + namespace basics { <nl> + <nl> + class VelocyPackDumper { <nl> + public : <nl> + VelocyPackDumper ( VelocyPackDumper const & ) = delete ; <nl> + VelocyPackDumper & operator = ( VelocyPackDumper const & ) = delete ; <nl> + <nl> + public : <nl> + VelocyPackDumper ( StringBuffer * buffer , velocypack : : Options const * options ) <nl> + : options ( options ) , _buffer ( buffer ) { <nl> + TRI_ASSERT ( buffer ! = nullptr ) ; <nl> + TRI_ASSERT ( options ! = nullptr ) ; <nl> + } <nl> + <nl> + ~ VelocyPackDumper ( ) = default ; <nl> + <nl> + void dump ( velocypack : : Slice const & slice ) { <nl> + _buffer - > reserve ( slice . byteSize ( ) ) ; <nl> + dumpValue ( & slice ) ; <nl> + } <nl> + <nl> + void dump ( velocypack : : Slice const * slice ) { dump ( * slice ) ; } <nl> + <nl> + void append ( velocypack : : Slice const & slice ) { dumpValue ( & slice ) ; } <nl> + <nl> + void append ( velocypack : : Slice const * slice ) { dumpValue ( slice ) ; } <nl> + <nl> + void appendUInt ( uint64_t ) ; <nl> + <nl> + void appendDouble ( double ) ; <nl> + <nl> + private : <nl> + void handleUnsupportedType ( velocypack : : Slice const * slice ) ; <nl> + <nl> + void dumpInteger ( velocypack : : Slice const * ) ; <nl> + <nl> + void dumpString ( char const * , velocypack : : ValueLength ) ; <nl> + <nl> + inline void dumpValue ( velocypack : : Slice const & slice , velocypack : : Slice const * base = nullptr ) { <nl> + dumpValue ( & slice , base ) ; <nl> + } <nl> + <nl> + void dumpValue ( velocypack : : Slice const * , velocypack : : Slice const * = nullptr ) ; <nl> + <nl> + public : <nl> + velocypack : : Options const * options ; <nl> + <nl> + private : <nl> + StringBuffer * _buffer ; <nl> + } ; <nl> + <nl> + } <nl> + } <nl> + <nl> + # endif <nl> mmm a / lib / Basics / VelocyPackHelper . h <nl> ppp b / lib / Basics / VelocyPackHelper . h <nl> <nl> # ifndef ARANGODB_BASICS_VELOCY_PACK_HELPER_H <nl> # define ARANGODB_BASICS_VELOCY_PACK_HELPER_H 1 <nl> <nl> + # include " Basics / Common . h " <nl> # include " Basics / JsonHelper . h " <nl> # include " Logger / Logger . h " <nl> <nl> mmm a / lib / CMakeLists . txt <nl> ppp b / lib / CMakeLists . txt <nl> add_library ( $ { LIB_ARANGO } STATIC <nl> Basics / ThreadPool . cpp <nl> Basics / Timers . cpp <nl> Basics / Utf8Helper . cpp <nl> + Basics / VelocyPackDumper . cpp <nl> Basics / VelocyPackHelper . cpp <nl> Basics / WorkMonitor . cpp <nl> Basics / application - exit . cpp <nl>
separate to - JSON dumper , not yet used
arangodb/arangodb
add739a3374da1983202ef6f995bad70d2d17794
2016-05-02T12:33:25Z
mmm a / core / input / SCsub <nl> ppp b / core / input / SCsub <nl> import input_builders <nl> <nl> # Order matters here . Higher index controller database files write on top of lower index database files . <nl> controller_databases = [ <nl> - " # core / input / gamecontrollerdb_204 . txt " , <nl> - " # core / input / gamecontrollerdb_205 . txt " , <nl> " # core / input / gamecontrollerdb . txt " , <nl> " # core / input / godotcontrollerdb . txt " , <nl> ] <nl> deleted file mode 100644 <nl> index 7fbe925b250 . . 00000000000 <nl> mmm a / core / input / gamecontrollerdb_204 . txt <nl> ppp / dev / null <nl> <nl> - # Game Controller DB for SDL in 2 . 0 . 4 format <nl> - # Source : https : / / github . com / gabomdq / SDL_GameControllerDB <nl> - <nl> - # Windows <nl> - 02200090000000000000504944564944 , 8Bitdo NES30 PRO USB , a : b0 , b : b1 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b13 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : b9 , rightx : a3 , righty : a4 , start : b11 , x : b3 , y : b4 , platform : Windows , <nl> - 20380900000000000000504944564944 , 8Bitdo NES30 PRO Wireless , a : b0 , b : b1 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b13 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : b9 , rightx : a3 , righty : a4 , start : b11 , x : b3 , y : b4 , platform : Windows , <nl> - 10280900000000000000504944564944 , 8Bitdo SFC30 GamePad , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Windows , <nl> - 8f0e1200000000000000504944564944 , Acme , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 341a3608000000000000504944564944 , Afterglow PS3 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - c0111352000000000000504944564944 , Battalife Joystick , a : b6 , b : b7 , back : b2 , leftshoulder : b0 , leftx : a0 , lefty : a1 , rightshoulder : b1 , start : b3 , x : b4 , y : b5 , platform : Windows , <nl> - d81d0b00000000000000504944564944 , BUFFALO BSGP1601 Series , a : b5 , b : b3 , back : b12 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b8 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b9 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b13 , x : b4 , y : b2 , platform : Windows , <nl> - e8206058000000000000504944564944 , Cideko AK08b , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 5e048e02000000000000504944564944 , Controller ( XBOX 360 For Windows ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a2 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - 791d0103000000000000504944564944 , Dual Box WII , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b6 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 4f0423b3000000000000504944564944 , Dual Trigger 3 - in - 1 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 341a0108000000000000504944564944 , EXEQ RF USB Gamepad 8206 , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 0d0f8500000000000000504944564944 , Fighting Commander 2016 PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f5e00000000000000504944564944 , Fighting Commander 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , leftstick : b10 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b4 , rightstick : b11 , righttrigger : a3 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f5f00000000000000504944564944 , Fighting Commander 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f8400000000000000504944564944 , Fighting Commander 5 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f8700000000000000504944564944 , Fighting Stick mini 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f8800000000000000504944564944 , Fighting Stick mini 4 , a : b1 , b : b2 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b8 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f2700000000000000504944564944 , FIGHTING STICK V3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 79000600000000000000504944564944 , G - Shark GS - GP702 , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a4 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 28040140000000000000504944564944 , GamePad Pro USB , a : b1 , b : b2 , back : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - ffff0000000000000000504944564944 , GameStop Gamepad , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 6d0416c2000000000000504944564944 , Generic DirectInput Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 45130010000000000000504944564944 , Generic USB Joystick , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 0d0f4900000000000000504944564944 , Hatsune Miku Sho Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - d8140862000000000000504944564944 , HitBox Edition Cthulhu + , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , lefttrigger : b4 , rightshoulder : b7 , righttrigger : b6 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f4000000000000000504944564944 , Hori Fighting Stick Mini 3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , lefttrigger : b4 , rightshoulder : b7 , righttrigger : b6 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f6e00000000000000504944564944 , HORIPAD 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0fee00000000000000504944564944 , HORIPAD mini4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f4d00000000000000504944564944 , HORIPAD3 A , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 25090017000000000000504944564944 , HRAP2 on PS / SS / N64 Joypad to USB BOX , a : b2 , b : b1 , back : b9 , leftshoulder : b5 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b6 , start : b8 , x : b3 , y : b0 , platform : Windows , <nl> - d81d0f00000000000000504944564944 , iBUFFALO BSGP1204 Series , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - d81d1000000000000000504944564944 , iBUFFALO BSGP1204P Series , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 83056020000000000000504944564944 , iBuffalo USB 2 - axis 8 - button Gamepad , a : b1 , b : b0 , back : b6 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b7 , x : b3 , y : b2 , platform : Windows , <nl> - 6f0e2401000000000000504944564944 , INJUSTICE FightStick for PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 49190204000000000000504944564944 , Ipega PG - 9023 , a : b0 , b : b1 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b13 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : b9 , rightx : a3 , righty : a4 , start : b11 , x : b3 , y : b4 , platform : Windows , <nl> - 6d0418c2000000000000504944564944 , Logitech F510 Gamepad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 6d0419c2000000000000504944564944 , Logitech F710 Gamepad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38075032000000000000504944564944 , Mad Catz FightPad PRO PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38075082000000000000504944564944 , Mad Catz FightPad PRO PS4 , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38078433000000000000504944564944 , Mad Catz FightStick TE S + PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38078483000000000000504944564944 , Mad Catz FightStick TE S + PS4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b6 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38078134000000000000504944564944 , Mad Catz FightStick TE2 + PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b7 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b4 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38078184000000000000504944564944 , Mad Catz FightStick TE2 + PS4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , leftstick : b10 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b4 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38078034000000000000504944564944 , Mad Catz TE2 PS3 Fightstick , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38078084000000000000504944564944 , Mad Catz TE2 PS4 Fightstick , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38078532000000000000504944564944 , Madcatz Arcade Fightstick TE S PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38073888000000000000504944564944 , Madcatz Arcade Fightstick TE S + PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 38071888000000000000504944564944 , MadCatz SFIV FightStick PS3 , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , lefttrigger : b7 , leftx : a0 , lefty : a1 , rightshoulder : b4 , righttrigger : b6 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 03000000380700008081000000000000 , MADCATZ SFV Arcade FightStick Alpha PS4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 25090128000000000000504944564944 , Mayflash Arcade Stick , a : b1 , b : b2 , back : b8 , leftshoulder : b0 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b3 , righttrigger : b7 , start : b9 , x : b5 , y : b6 , platform : Windows , <nl> - 79004318000000000000504944564944 , Mayflash GameCube Controller Adapter , a : b1 , b : b2 , back : b0 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b0 , leftshoulder : b4 , leftstick : b0 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b0 , righttrigger : a4 , rightx : a5 , righty : a2 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 8f0e1030000000000000504944564944 , Mayflash USB Adapter for original Sega Saturn controller , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , lefttrigger : b5 , rightshoulder : b2 , righttrigger : b7 , start : b9 , x : b3 , y : b4 , platform : Windows , <nl> - 2509e803000000000000504944564944 , Mayflash Wii Classic Controller , a : b1 , b : b0 , back : b8 , dpdown : b13 , dpleft : b12 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b2 , platform : Windows , <nl> - 79000018000000000000504944564944 , Mayflash WiiU Pro Game Controller Adapter ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 8f0e0d31000000000000504944564944 , Multilaser JS071 USB , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 100801e5000000000000504944564944 , NEXT Classic USB Game Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b6 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - bd1215d0000000000000504944564944 , Nintendo Retrolink USB Super SNES Classic Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 4b12014d000000000000504944564944 , NYKO AIRFLO , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : a3 , leftstick : a0 , lefttrigger : b6 , rightshoulder : b5 , rightstick : a2 , righttrigger : b7 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 36280100000000000000504944564944 , OUYA Controller , a : b0 , b : b3 , dpdown : b9 , dpleft : b10 , dpright : b11 , dpup : b8 , guide : b15 , leftshoulder : b4 , leftstick : b6 , lefttrigger : b12 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : b13 , rightx : a3 , righty : a4 , start : b14 , x : b1 , y : b2 , platform : Windows , <nl> - 4d6963726f736f66742050432d6a6f79 , OUYA Controller , a : b0 , b : b3 , dpdown : b9 , dpleft : b10 , dpright : b11 , dpup : b8 , guide : b14 , leftshoulder : b4 , leftstick : b6 , lefttrigger : b12 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : b13 , rightx : a5 , righty : a4 , x : b1 , y : b2 , platform : Windows , <nl> - 120cf60e000000000000504944564944 , P4 Wired Gamepad , a : b1 , b : b2 , back : b12 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b5 , lefttrigger : b7 , rightshoulder : b4 , righttrigger : b6 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 8f0e0300000000000000504944564944 , Piranha xtreme , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - d6206dca000000000000504944564944 , PowerA Pro Ex , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 10080100000000000000504944564944 , PS1 USB , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 10080300000000000000504944564944 , PS2 USB , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a4 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 4c056802000000000000504944564944 , PS3 Controller , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Windows , <nl> - 88880803000000000000504944564944 , PS3 Controller , a : b2 , b : b1 , back : b8 , dpdown : h0 . 8 , dpleft : h0 . 4 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b9 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b11 , x : b0 , y : b3 , platform : Windows , <nl> - 25090500000000000000504944564944 , PS3 DualShock , a : b2 , b : b1 , back : b9 , dpdown : h0 . 8 , dpleft : h0 . 4 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b0 , y : b3 , platform : Windows , <nl> - 10008200000000000000504944564944 , PS360 + v1 . 66 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : h0 . 4 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 4c05c405000000000000504944564944 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 300f0011000000000000504944564944 , QanBa Arcade JoyStick 1008 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b10 , x : b0 , y : b3 , platform : Windows , <nl> - 300f1611000000000000504944564944 , QanBa Arcade JoyStick 4018 , a : b1 , b : b2 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b9 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b8 , x : b0 , y : b3 , platform : Windows , <nl> - 222c0020000000000000504944564944 , QANBA DRONE ARCADE JOYSTICK , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : a3 , rightshoulder : b5 , righttrigger : a4 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 300f1210000000000000504944564944 , QanBa Joystick Plus , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , rightshoulder : b5 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 341a0104000000000000504944564944 , QanBa Joystick Q4RAF , a : b5 , b : b6 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b0 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b3 , righttrigger : b7 , start : b9 , x : b1 , y : b2 , platform : Windows , <nl> - 222c0223000000000000504944564944 , Qanba Obsidian Arcade Joystick PS3 Mode , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 222c0023000000000000504944564944 , Qanba Obsidian Arcade Joystick PS4 Mode , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f1100000000000000504944564944 , REAL ARCADE PRO . 3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f6a00000000000000504944564944 , Real Arcade Pro . 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f6b00000000000000504944564944 , Real Arcade Pro . 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f8a00000000000000504944564944 , Real Arcade Pro . 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f8b00000000000000504944564944 , Real Arcade Pro . 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f7000000000000000504944564944 , REAL ARCADE PRO . 4 VLX , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0d0f2200000000000000504944564944 , REAL ARCADE Pro . V3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 00f00300000000000000504944564944 , RetroUSB . com RetroPad , a : b1 , b : b5 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b0 , y : b4 , platform : Windows , <nl> - 00f0f100000000000000504944564944 , RetroUSB . com Super RetroPort , a : b1 , b : b5 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b0 , y : b4 , platform : Windows , <nl> - 6f0e1e01000000000000504944564944 , Rock Candy Gamepad for PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 300f1201000000000000504944564944 , Saitek Dual Analog Pad , a : b2 , b : b3 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Windows , <nl> - a3060cff000000000000504944564944 , Saitek P2500 , a : b2 , b : b3 , back : b5 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b6 , leftstick : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b9 , rightx : a2 , righty : a3 , start : b4 , x : b0 , y : b1 , platform : Windows , <nl> - 300f1001000000000000504944564944 , Saitek P480 Rumble Pad , a : b2 , b : b3 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Windows , <nl> - 9b280500000000000000504944564944 , Saturn_Adapter_2 . 0 , a : b1 , b : b2 , leftshoulder : b6 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 79001100000000000000504944564944 , Sega Saturn Gamepad , a : b1 , b : b2 , leftshoulder : b6 , lefttrigger : b3 , leftx : a0 , lefty : a4 , rightshoulder : b7 , righttrigger : b0 , start : b8 , x : b4 , y : b5 , platform : Windows , <nl> - 4c05cc09000000000000504944564944 , Sony DualShock 4 , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 4c05a00b000000000000504944564944 , Sony DualShock 4 Wireless Adaptor , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - ff113133000000000000504944564944 , SVEN X - PAD , a : b2 , b : b3 , back : b4 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b9 , rightx : a2 , righty : a4 , start : b5 , x : b0 , y : b1 , platform : Windows , <nl> - 4f0415b3000000000000504944564944 , Thrustmaster Dual Analog 3 . 2 , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Windows , <nl> - 4f0400b3000000000000504944564944 , Thrustmaster Firestorm Dual Power , a : b0 , b : b2 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b12 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b10 , x : b1 , y : b3 , platform : Windows , <nl> - 66660488000000000000504944564944 , TigerGame PS / PS2 Game Controller Adapter , a : b2 , b : b1 , back : b9 , dpdown : b14 , dpleft : b15 , dpright : b13 , dpup : b12 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b3 , y : b0 , platform : Windows , <nl> - 38076652000000000000504944564944 , UnKnown , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 63252305000000000000504944564944 , USB Vibration Joystick ( BM ) , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 79001b18000000000000504944564944 , Venom Arcade Joystick , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - xinput , XInput Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - <nl> - # Mac OS X <nl> - 10280000000000000900000000000000 , 8Bitdo SFC30 GamePad , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Mac OS X , <nl> - 830500000000000031b0000000000000 , Cideko AK08b , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 79000000000000000600000000000000 , G - Shark GP - 702 , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b0 , platform : Mac OS X , <nl> - AD1B00000000000001F9000000000000 , Gamestop BB - 070 X360 Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 0500000047532047616d657061640000 , GameStop Gamepad , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 0d0f0000000000004d00000000000000 , HORI Gem Pad 3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 0d0f0000000000006600000000000000 , HORIPAD FPS PLUS 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 83050000000000006020000000000000 , iBuffalo USB 2 - axis 8 - button Gamepad , a : b1 , b : b0 , back : b6 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b7 , x : b3 , y : b2 , platform : Mac OS X , <nl> - 6d0400000000000016c2000000000000 , Logitech F310 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 6d0400000000000018c2000000000000 , Logitech F510 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 6d040000000000001fc2000000000000 , Logitech F710 Gamepad ( XInput ) , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 6d0400000000000019c2000000000000 , Logitech Wireless Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 2509000000000000e803000000000000 , Mayflash Wii Classic Controller , a : b1 , b : b0 , back : b8 , dpdown : b13 , dpleft : b12 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b2 , platform : Mac OS X , <nl> - 79000000000000000018000000000000 , Mayflash WiiU Pro Game Controller Adapter ( DInput ) , a : b4 , b : b8 , back : b32 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b16 , leftstick : b40 , lefttrigger : b24 , leftx : a0 , lefty : a4 , rightshoulder : b20 , rightstick : b44 , righttrigger : b28 , rightx : a8 , righty : a12 , start : b36 , x : b0 , y : b12 , platform : Mac OS X , <nl> - d814000000000000cecf000000000000 , MC Cthulhu , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 8f0e0000000000000300000000000000 , Piranha xtreme , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Mac OS X , <nl> - 4c050000000000006802000000000000 , PS3 Controller , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Mac OS X , <nl> - 4c05000000000000c405000000000000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 891600000000000000fd000000000000 , Razer Onza Tournament , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 79000000000000001100000000000000 , Retrolink Classic Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a3 , lefty : a4 , rightshoulder : b5 , start : b9 , x : b3 , y : b0 , platform : Mac OS X , <nl> - 81170000000000007e05000000000000 , Sega Saturn , a : b2 , b : b4 , dpdown : b16 , dpleft : b15 , dpright : b14 , dpup : b17 , leftshoulder : b8 , lefttrigger : a5 , leftx : a0 , lefty : a2 , rightshoulder : b9 , righttrigger : a4 , start : b13 , x : b0 , y : b6 , platform : Mac OS X , <nl> - b4040000000000000a01000000000000 , Sega Saturn USB Gamepad , a : b0 , b : b1 , back : b5 , guide : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b8 , x : b3 , y : b4 , platform : Mac OS X , <nl> - 351200000000000021ab000000000000 , SFC30 Joystick , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Mac OS X , <nl> - 4c05000000000000cc09000000000000 , Sony DualShock 4 V2 , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 4c05000000000000a00b000000000000 , Sony DualShock 4 Wireless Adaptor , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 11010000000000002014000000000000 , SteelSeries Nimbus , a : b0 , b : b1 , dpdown : b9 , dpleft : b11 , dpright : b10 , dpup : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b12 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 11010000000000001714000000000000 , SteelSeries Stratus XL , a : b0 , b : b1 , dpdown : b9 , dpleft : b11 , dpright : b10 , dpup : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b12 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 4f0400000000000015b3000000000000 , Thrustmaster Dual Analog 3 . 2 , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Mac OS X , <nl> - 4f0400000000000000b3000000000000 , Thrustmaster Firestorm Dual Power , a : b0 , b : b2 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b10 , x : b1 , y : b3 , platform : Mac OS X , <nl> - bd1200000000000015d0000000000000 , Tomee SNES USB Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b9 , x : b3 , y : b0 , platform : Mac OS X , <nl> - 10080000000000000100000000000000 , Twin USB Joystick , a : b4 , b : b2 , back : b16 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b12 , leftstick : b20 , lefttrigger : b8 , leftx : a0 , lefty : a2 , rightshoulder : b14 , rightstick : b22 , righttrigger : b10 , rightx : a6 , righty : a4 , start : b18 , x : b6 , y : b0 , platform : Mac OS X , <nl> - 050000005769696d6f74652028303000 , Wii Remote , a : b4 , b : b5 , back : b7 , dpdown : b3 , dpleft : b0 , dpright : b1 , dpup : b2 , guide : b8 , leftshoulder : b11 , lefttrigger : b12 , leftx : a0 , lefty : a1 , start : b6 , x : b10 , y : b9 , platform : Mac OS X , <nl> - 050000005769696d6f74652028313800 , Wii U Pro Controller , a : b16 , b : b15 , back : b7 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b8 , leftshoulder : b19 , leftstick : b23 , lefttrigger : b21 , leftx : a0 , lefty : a1 , rightshoulder : b20 , rightstick : b24 , righttrigger : b22 , rightx : a2 , righty : a3 , start : b6 , x : b18 , y : b17 , platform : Mac OS X , <nl> - 5e040000000000008e02000000000000 , X360 Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 5e04000000000000dd02000000000000 , Xbox One Wired Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 5e04000000000000e002000000000000 , Xbox Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 5e04000000000000ea02000000000000 , Xbox Wireless Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - <nl> - # Linux <nl> - 05000000102800000900000000010000 , 8Bitdo SFC30 GamePad , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Linux , <nl> - 05000000a00500003232000001000000 , 8Bitdo Zero GamePad , a : b0 , b : b1 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b3 , y : b4 , platform : Linux , <nl> - 030000006f0e00003901000020060000 , Afterglow Wired Controller for Xbox One , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000e82000006058000001010000 , Cideko AK08b , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000790000000600000010010000 , DragonRise Inc . Generic USB Joystick , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 030000006f0e00003001000001010000 , EA Sports PS3 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000341a000005f7000010010000 , GameCube { HuiJia USB box } , a : b1 , b : b2 , dpdown : b14 , dpleft : b15 , dpright : b13 , dpup : b12 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : a4 , rightx : a5 , righty : a2 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000260900008888000000010000 , GameCube { WiseGroup USB box } , a : b0 , b : b2 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b6 , righttrigger : a5 , rightx : a2 , righty : a3 , start : b7 , x : b1 , y : b3 , platform : Linux , <nl> - 0500000047532047616d657061640000 , GameStop Gamepad , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006f0e00000104000000010000 , Gamestop Logic3 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006f0e00001304000000010000 , Generic X - Box pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : a0 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : a3 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006f0e00001f01000000010000 , Generic X - Box pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000f0250000c183000010010000 , Goodbetterbest Ltd USB Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000280400000140000000010000 , Gravis GamePad Pro USB , a : b1 , b : b2 , back : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000008f0e00000300000010010000 , GreenAsia Inc . USB Joystick , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 030000008f0e00001200000010010000 , GreenAsia Inc . USB Joystick , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000ff1100004133000010010000 , GreenAsia Inc . USB Joystick , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 06000000adde0000efbe000002010000 , Hidromancer Game Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000d81400000862000011010000 , HitBox ( PS3 / PC ) Analog Mode , a : b1 , b : b2 , back : b8 , guide : b9 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b12 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000c9110000f055000011010000 , HJC Game GAMEPAD , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 030000000d0f00000d00000000010000 , hori , a : b0 , b : b6 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b3 , leftx : b4 , lefty : b5 , rightshoulder : b7 , start : b9 , x : b1 , y : b2 , platform : Linux , <nl> - 030000000d0f00001000000011010000 , HORI CO . LTD . FIGHTING STICK 3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000000d0f00002200000011010000 , HORI CO . LTD . REAL ARCADE Pro . V3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000ad1b000001f5000033050000 , Hori Pad EX Turbo 2 , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000830500006020000010010000 , iBuffalo USB 2 - axis 8 - button Gamepad , a : b1 , b : b0 , back : b6 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b7 , x : b3 , y : b2 , platform : Linux , <nl> - 03000000fd0500000030000000010000 , InterAct GoPad I - 73000 ( Fighting Game Layout ) , a : b3 , b : b4 , back : b6 , leftx : a0 , lefty : a1 , rightshoulder : b2 , righttrigger : b5 , start : b7 , x : b0 , y : b1 , platform : Linux , <nl> - 030000006e0500000320000010010000 , JC - U3613M - DirectInput Mode , a : b2 , b : b3 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b8 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b11 , x : b0 , y : b1 , platform : Linux , <nl> - 03000000300f00001001000010010000 , Jess Tech Dual Analog Rumble Pad , a : b2 , b : b3 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Linux , <nl> - 03000000ba2200002010000001010000 , Jess Technology USB Game Controller , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 030000006f0e00000103000000020000 , Logic3 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006d04000019c2000010010000 , Logitech Cordless RumblePad 2 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d04000016c2000011010000 , Logitech F310 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d0400001dc2000014400000 , Logitech F310 Gamepad ( XInput ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006d0400001ec2000020200000 , Logitech F510 Gamepad ( XInput ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006d04000019c2000011010000 , Logitech F710 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d0400001fc2000005030000 , Logitech F710 Gamepad ( XInput ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006d04000016c2000010010000 , Logitech Logitech Dual Action , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d04000018c2000010010000 , Logitech RumblePad 2 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d04000011c2000010010000 , Logitech WingMan Cordless RumblePad , a : b0 , b : b1 , back : b2 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b5 , leftshoulder : b6 , lefttrigger : b9 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b10 , rightx : a3 , righty : a4 , start : b8 , x : b3 , y : b4 , platform : Linux , <nl> - 05000000380700006652000025010000 , Mad Catz C . T . R . L . R , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000ad1b00002ef0000090040000 , Mad Catz Fightpad SFxT , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , lefttrigger : a2 , rightshoulder : b5 , righttrigger : a5 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000380700001647000010040000 , Mad Catz Wired Xbox 360 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000ad1b000016f0000090040000 , Mad Catz Xbox 360 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000780000000600000010010000 , Microntek USB Joystick , a : b2 , b : b1 , back : b8 , leftshoulder : b6 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b5 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 030000005e0400008e02000004010000 , Microsoft X - Box 360 pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008e02000062230000 , Microsoft X - Box 360 pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e040000dd02000003020000 , Microsoft X - Box One pad v2 , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008502000000010000 , Microsoft X - Box pad ( Japan ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b5 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b2 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b3 , y : b4 , platform : Linux , <nl> - 030000005e0400008902000021010000 , Microsoft X - Box pad v2 ( US ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b5 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b2 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b3 , y : b4 , platform : Linux , <nl> - 05000000d6200000ad0d000001000000 , Moga Pro , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b7 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b8 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b6 , x : b2 , y : b3 , platform : Linux , <nl> - 030000001008000001e5000010010000 , NEXT Classic USB Game Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b6 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 050000007e0500003003000001000000 , Nintendo Wii Remote Pro Controller , a : b1 , b : b0 , back : b8 , dpdown : b14 , dpleft : b15 , dpright : b16 , dpup : b13 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 05000000010000000100000003000000 , Nintendo Wiimote , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000550900001072000011010000 , NVIDIA Controller , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000451300000830000010010000 , NYKO CORE , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 05000000362800000100000002010000 , OUYA Game Controller , a : b0 , b : b3 , dpdown : b9 , dpleft : b10 , dpright : b11 , dpup : b8 , guide : b14 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , x : b1 , y : b2 , platform : Linux , <nl> - 05000000362800000100000003010000 , OUYA Game Controller , a : b0 , b : b3 , dpdown : b9 , dpleft : b10 , dpright : b11 , dpup : b8 , guide : b14 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , x : b1 , y : b2 , platform : Linux , <nl> - 03000000ff1100003133000010010000 , PC Game Controller , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000341a00003608000011010000 , PS3 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004c0500006802000011010000 , PS3 Controller , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Linux , <nl> - 050000004c0500006802000000010000 , PS3 Controller ( Bluetooth ) , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Linux , <nl> - 05000000504c415953544154494f4e00 , PS3 Controller ( Bluetooth ) , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Linux , <nl> - 060000004c0500006802000000010000 , PS3 Controller ( Bluetooth ) , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Linux , <nl> - 030000004c050000c405000011010000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 050000004c050000c405000000010000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000009b2800000300000001010000 , raphnet . net 4nes4snes v1 . 5 , a : b0 , b : b4 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b1 , y : b5 , platform : Linux , <nl> - 030000008916000001fd000024010000 , Razer Onza Classic Edition , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000008916000000fd000024010000 , Razer Onza Tournament , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000c6240000045d000025010000 , Razer Sabertooth , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000321500000009000011010000 , Razer Serval , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 050000003215000000090000163a0000 , Razer Serval , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000790000001100000010010000 , RetroLink Saturn Classic Controller , a : b0 , b : b1 , back : b5 , guide : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b8 , x : b3 , y : b4 , platform : Linux , <nl> - 0300000000f000000300000000010000 , RetroUSB . com RetroPad , a : b1 , b : b5 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b0 , y : b4 , platform : Linux , <nl> - 0300000000f00000f100000000010000 , RetroUSB . com Super RetroPort , a : b1 , b : b5 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b0 , y : b4 , platform : Linux , <nl> - 030000006f0e00001e01000011010000 , Rock Candy Gamepad for PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006f0e00004601000001010000 , Rock Candy Wired Controller for Xbox One , a : b0 , b : b1 , back : b6 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000a306000023f6000011010000 , Saitek Cyborg V . 1 Game Pad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a4 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000a30600000c04000011010000 , Saitek P2900 Wireless Pad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b9 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b12 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000a30600000901000000010000 , Saitek P880 , a : b2 , b : b3 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : b7 , rightx : a3 , righty : a2 , x : b0 , y : b1 , platform : Linux , <nl> - 03000000a306000018f5000010010000 , Saitek PLC Saitek P3200 Rumble Pad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000c01600008704000011010000 , Serial / Keyboard / Mouse / Joystick , a : b12 , b : b10 , back : b4 , dpdown : b2 , dpleft : b3 , dpright : b1 , dpup : b0 , leftshoulder : b9 , leftstick : b14 , lefttrigger : b6 , leftx : a1 , lefty : a0 , rightshoulder : b8 , rightstick : b15 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b5 , x : b13 , y : b11 , platform : Linux , <nl> - 030000004c050000c405000011810000 , Sony DualShock 4 , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 050000004c050000cc09000000810000 , Sony DualShock 4 ( CUH - ZCT2U ) ( Bluetooth ) , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 030000004c050000cc09000011810000 , Sony DualShock 4 ( CUH - ZCT2U ) ( USB ) , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 030000004c050000cc09000011010000 , Sony DualShock 4 V2 , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 050000004c050000cc09000000010000 , Sony DualShock 4 V2 BT , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004c050000a00b000011010000 , Sony DualShock 4 Wireless Adaptor , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000250900000500000000010000 , Sony PS2 pad with SmartJoy adapter , a : b2 , b : b1 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b3 , y : b0 , platform : Linux , <nl> - 030000005e0400008e02000073050000 , Speedlink TORID Wireless Gamepad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008e02000020200000 , SpeedLink XEOX Pro Analog Gamepad pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000de280000fc11000001000000 , Steam Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000666600000488000000010000 , Super Joy Box 5 Pro , a : b2 , b : b1 , back : b9 , dpdown : b14 , dpleft : b15 , dpright : b13 , dpup : b12 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b3 , y : b0 , platform : Linux , <nl> - 030000004f04000020b3000010010000 , Thrustmaster 2 in 1 DT , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Linux , <nl> - 030000004f04000015b3000010010000 , Thrustmaster Dual Analog 4 , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Linux , <nl> - 030000004f04000023b3000000010000 , Thrustmaster Dual Trigger 3 - in - 1 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004f04000000b3000010010000 , Thrustmaster Firestorm Dual Power , a : b0 , b : b2 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b12 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b10 , x : b1 , y : b3 , platform : Linux , <nl> - 030000004f04000008d0000000010000 , Thrustmaster Run N Drive Wireless , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004f04000009d0000000010000 , Thrustmaster Run N Drive Wireless PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000bd12000015d0000010010000 , Tomee SNES USB Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000d814000007cd000011010000 , Toodles 2008 Chimp PC / PS3 , a : b0 , b : b1 , back : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 03000000100800000100000010010000 , Twin USB PS2 Adapter , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000100800000300000010010000 , USB Gamepad , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000de280000ff11000001000000 , Valve Streaming Gamepad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 05000000ac0500003232000001000000 , VR - BOX , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008e02000010010000 , X360 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008e02000014010000 , X360 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400001907000000010000 , X360 Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400009102000007010000 , X360 Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e040000a102000000010000 , X360 Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 0000000058626f782047616d65706100 , Xbox Gamepad ( userspace driver ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e040000d102000001010000 , Xbox One Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 050000005e040000e002000003090000 , Xbox One Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000c0160000e105000001010000 , Xin - Mo Xin - Mo Dual Arcade , a : b4 , b : b3 , back : b6 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b9 , leftshoulder : b2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b7 , x : b1 , y : b0 , platform : Linux , <nl> - xinput , XInput Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - <nl> - # Android <nl> - 4e564944494120436f72706f72617469 , NVIDIA Controller , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b9 , leftstick : b7 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b10 , rightstick : b8 , righttrigger : a5 , rightx : a2 , righty : a3 , start : b6 , x : b2 , y : b3 , platform : Android , <nl> - <nl> - # iOS <nl> - 4d466947616d65706164010000000000 , MFi Extended Gamepad , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b6 , x : b2 , y : b3 , platform : iOS , <nl> - 4d466947616d65706164020000000000 , MFi Gamepad , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , rightshoulder : b5 , start : b6 , x : b2 , y : b3 , platform : iOS , <nl> deleted file mode 100644 <nl> index 55c45eb148e . . 00000000000 <nl> mmm a / core / input / gamecontrollerdb_205 . txt <nl> ppp / dev / null <nl> <nl> - # Game Controller DB for SDL in 2 . 0 . 5 format <nl> - # Source : https : / / github . com / gabomdq / SDL_GameControllerDB <nl> - <nl> - # Windows <nl> - 03000000022000000090000000000000 , 8Bitdo NES30 PRO USB , a : b0 , b : b1 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b13 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : b9 , rightx : a3 , righty : a4 , start : b11 , x : b3 , y : b4 , platform : Windows , <nl> - 03000000203800000900000000000000 , 8Bitdo NES30 PRO Wireless , a : b0 , b : b1 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b13 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : b9 , rightx : a3 , righty : a4 , start : b11 , x : b3 , y : b4 , platform : Windows , <nl> - 03000000102800000900000000000000 , 8Bitdo SFC30 GamePad , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Windows , <nl> - 10280900000000000000504944564944 , 8Bitdo SFC30 GamePad , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Windows , <nl> - 030000008f0e00001200000000000000 , Acme , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 03000000341a00003608000000000000 , Afterglow PS3 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 341a3608000000000000504944564944 , Afterglow PS3 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000c01100001352000000000000 , Battalife Joystick , a : b6 , b : b7 , back : b2 , leftshoulder : b0 , leftx : a0 , lefty : a1 , rightshoulder : b1 , start : b3 , x : b4 , y : b5 , platform : Windows , <nl> - 030000006b1400000055000000000000 , bigben ps3padstreetnew , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 0300000066f700000500000000000000 , BrutalLegendTest , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000d81d00000b00000000000000 , BUFFALO BSGP1601 Series , a : b5 , b : b3 , back : b12 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b8 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b9 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b13 , x : b4 , y : b2 , platform : Windows , <nl> - e8206058000000000000504944564944 , Cideko AK08b , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 030000005e0400008e02000000000000 , Controller ( XBOX 360 For Windows ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a2 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - 030000004f04000023b3000000000000 , Dual Trigger 3 - in - 1 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000341a00000108000000000000 , EXEQ RF USB Gamepad 8206 , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 030000000d0f00008500000000000000 , Fighting Commander 2016 PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00005e00000000000000 , Fighting Commander 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , leftstick : b10 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b4 , rightstick : b11 , righttrigger : a3 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00005f00000000000000 , Fighting Commander 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00008400000000000000 , Fighting Commander 5 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00008700000000000000 , Fighting Stick mini 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00008800000000000000 , Fighting Stick mini 4 , a : b1 , b : b2 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b8 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00002700000000000000 , FIGHTING STICK V3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 78696e70757403000000000000000000 , Fightstick TES , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , lefttrigger : a2 , rightshoulder : b5 , righttrigger : a5 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - 03000000790000000600000000000000 , G - Shark GS - GP702 , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a4 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000260900002625000000000000 , Gamecube Controller , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b6 , lefttrigger : a4 , leftx : a0 , lefty : a1 , righttrigger : a5 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - 030000008f0e00000d31000000000000 , GAMEPAD 3 TURBO , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000280400000140000000000000 , GamePad Pro USB , a : b1 , b : b2 , back : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000ffff00000000000000000000 , GameStop Gamepad , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - ffff0000000000000000504944564944 , GameStop Gamepad , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 030000006d04000016c2000000000000 , Generic DirectInput Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 6d0416c2000000000000504944564944 , Generic DirectInput Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000451300000010000000000000 , Generic USB Joystick , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 03000000341a00000302000000000000 , Hama Scorpad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00004900000000000000 , Hatsune Miku Sho Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000d81400000862000000000000 , HitBox Edition Cthulhu + , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , lefttrigger : b4 , rightshoulder : b7 , righttrigger : b6 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00004000000000000000 , Hori Fighting Stick Mini 3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , lefttrigger : b4 , rightshoulder : b7 , righttrigger : b6 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00006e00000000000000 , HORIPAD 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00004d00000000000000 , HORIPAD3 A , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000250900000017000000000000 , HRAP2 on PS / SS / N64 Joypad to USB BOX , a : b2 , b : b1 , back : b9 , leftshoulder : b5 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b6 , start : b8 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000d81d00000f00000000000000 , iBUFFALO BSGP1204 Series , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000d81d00001000000000000000 , iBUFFALO BSGP1204P Series , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000830500006020000000000000 , iBuffalo USB 2 - axis 8 - button Gamepad , a : b1 , b : b0 , back : b6 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b7 , x : b3 , y : b2 , platform : Windows , <nl> - 03000000b50700001403000000000000 , IMPACT BLACK , a : b2 , b : b3 , back : b8 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Windows , <nl> - 030000006f0e00002401000000000000 , INJUSTICE FightStick for PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000491900000204000000000000 , Ipega PG - 9023 , a : b0 , b : b1 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b13 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : b9 , rightx : a3 , righty : a4 , start : b11 , x : b3 , y : b4 , platform : Windows , <nl> - 030000006d04000019c2000000000000 , Logitech Cordless RumblePad 2 USB , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000006d04000011c2000000000000 , Logitech Cordless Wingman , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b9 , leftstick : b5 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b10 , rightstick : b2 , righttrigger : b7 , rightx : a3 , righty : a4 , x : b4 , platform : Windows , <nl> - 6d0418c2000000000000504944564944 , Logitech F510 Gamepad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 6d0419c2000000000000504944564944 , Logitech F710 Gamepad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000006d04000018c2000000000000 , Logitech RumblePad 2 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700005032000000000000 , Mad Catz FightPad PRO PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700005082000000000000 , Mad Catz FightPad PRO PS4 , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700008433000000000000 , Mad Catz FightStick TE S + PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700008483000000000000 , Mad Catz FightStick TE S + PS4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b6 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700008134000000000000 , Mad Catz FightStick TE2 + PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b7 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b4 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700008184000000000000 , Mad Catz FightStick TE2 + PS4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , leftstick : b10 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b4 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700008034000000000000 , Mad Catz TE2 PS3 Fightstick , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700008084000000000000 , Mad Catz TE2 PS4 Fightstick , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700008532000000000000 , Madcatz Arcade Fightstick TE S PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700003888000000000000 , Madcatz Arcade Fightstick TE S + PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000380700001888000000000000 , MadCatz SFIV FightStick PS3 , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b5 , lefttrigger : b7 , leftx : a0 , lefty : a1 , rightshoulder : b4 , righttrigger : b6 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 03000000380700008081000000000000 , MADCATZ SFV Arcade FightStick Alpha PS4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000008305000031b0000000000000 , MaxfireBlaze3 , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 03000000250900000128000000000000 , Mayflash Arcade Stick , a : b1 , b : b2 , back : b8 , leftshoulder : b0 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b3 , righttrigger : b7 , start : b9 , x : b5 , y : b6 , platform : Windows , <nl> - 03000000790000004318000000000000 , Mayflash GameCube Controller Adapter , a : b1 , b : b2 , back : b0 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b0 , leftshoulder : b4 , leftstick : b0 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b0 , righttrigger : a4 , rightx : a5 , righty : a2 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000008f0e00001030000000000000 , Mayflash USB Adapter for original Sega Saturn controller , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , lefttrigger : b5 , rightshoulder : b2 , righttrigger : b7 , start : b9 , x : b3 , y : b4 , platform : Windows , <nl> - 0300000025090000e803000000000000 , Mayflash Wii Classic Controller , a : b1 , b : b0 , back : b8 , dpdown : b13 , dpleft : b12 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b2 , platform : Windows , <nl> - 03000000790000000018000000000000 , Mayflash WiiU Pro Game Controller Adapter ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000001008000001e5000000000000 , NEXT Classic USB Game Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b6 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000bd12000015d0000000000000 , Nintendo Retrolink USB Super SNES Classic Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 030000004b120000014d000000000000 , NYKO AIRFLO , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : a3 , leftstick : a0 , lefttrigger : b6 , rightshoulder : b5 , rightstick : a2 , righttrigger : b7 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 03000000362800000100000000000000 , OUYA Controller , a : b0 , b : b3 , dpdown : b9 , dpleft : b10 , dpright : b11 , dpup : b8 , guide : b15 , leftshoulder : b4 , leftstick : b6 , lefttrigger : b12 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : b13 , rightx : a3 , righty : a4 , start : b14 , x : b1 , y : b2 , platform : Windows , <nl> - 4d6963726f736f66742050432d6a6f79 , OUYA Controller , a : b0 , b : b3 , dpdown : b9 , dpleft : b10 , dpright : b11 , dpup : b8 , guide : b14 , leftshoulder : b4 , leftstick : b6 , lefttrigger : b12 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : b13 , rightx : a5 , righty : a4 , x : b1 , y : b2 , platform : Windows , <nl> - 03000000120c0000f60e000000000000 , P4 Wired Gamepad , a : b1 , b : b2 , back : b12 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b5 , lefttrigger : b7 , rightshoulder : b4 , righttrigger : b6 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000008f0e00000300000000000000 , Piranha xtreme , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000d62000006dca000000000000 , PowerA Pro Ex , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000008f0e00007530000000000000 , PS ( R ) Gamepad , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b1 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000e30500009605000000000000 , PS to USB convert cable , a : b2 , b : b1 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000100800000100000000000000 , PS1 USB , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000100800000300000000000000 , PS2 USB , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a4 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000888800000803000000000000 , PS3 , a : b2 , b : b1 , back : b8 , dpdown : h0 . 8 , dpleft : h0 . 4 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 030000004c0500006802000000000000 , PS3 Controller , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Windows , <nl> - 4c056802000000000000504944564944 , PS3 Controller , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Windows , <nl> - 88880803000000000000504944564944 , PS3 Controller , a : b2 , b : b1 , back : b8 , dpdown : h0 . 8 , dpleft : h0 . 4 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b9 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b11 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000250900000500000000000000 , PS3 DualShock , a : b2 , b : b1 , back : b9 , dpdown : h0 . 8 , dpleft : h0 . 4 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b0 , y : b3 , platform : Windows , <nl> - 25090500000000000000504944564944 , PS3 DualShock , a : b2 , b : b1 , back : b9 , dpdown : h0 . 8 , dpleft : h0 . 4 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000100000008200000000000000 , PS360 + v1 . 66 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : h0 . 4 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000004c050000c405000000000000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 4c05c405000000000000504944564944 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000300f00000011000000000000 , QanBa Arcade JoyStick 1008 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b10 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000300f00001611000000000000 , QanBa Arcade JoyStick 4018 , a : b1 , b : b2 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b9 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b8 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000222c00000020000000000000 , QANBA DRONE ARCADE JOYSTICK , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : a3 , rightshoulder : b5 , righttrigger : a4 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000300f00001210000000000000 , QanBa Joystick Plus , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , rightshoulder : b5 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - 03000000341a00000104000000000000 , QanBa Joystick Q4RAF , a : b5 , b : b6 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b0 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b3 , righttrigger : b7 , start : b9 , x : b1 , y : b2 , platform : Windows , <nl> - 03000000222c00000223000000000000 , Qanba Obsidian Arcade Joystick PS3 Mode , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000222c00000023000000000000 , Qanba Obsidian Arcade Joystick PS4 Mode , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000321500000003000000000000 , Razer Hydra , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a2 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - 030000000d0f00001100000000000000 , REAL ARCADE PRO . 3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00006a00000000000000 , Real Arcade Pro . 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00006b00000000000000 , Real Arcade Pro . 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00008a00000000000000 , Real Arcade Pro . 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00008b00000000000000 , Real Arcade Pro . 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00007000000000000000 , REAL ARCADE PRO . 4 VLX , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00002200000000000000 , REAL ARCADE Pro . V3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00005b00000000000000 , Real Arcade Pro . V4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000000d0f00005c00000000000000 , Real Arcade Pro . V4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 0300000000f000000300000000000000 , RetroUSB . com RetroPad , a : b1 , b : b5 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b0 , y : b4 , platform : Windows , <nl> - 0300000000f00000f100000000000000 , RetroUSB . com Super RetroPort , a : b1 , b : b5 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b0 , y : b4 , platform : Windows , <nl> - 030000006f0e00001e01000000000000 , Rock Candy Gamepad for PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000004f04000003d0000000000000 , run ' n ' drive , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b7 , leftshoulder : a3 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : a4 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000a30600001af5000000000000 , Saitek Cyborg , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000a306000023f6000000000000 , Saitek Cyborg V . 1 Game pad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a4 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000300f00001201000000000000 , Saitek Dual Analog Pad , a : b2 , b : b3 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Windows , <nl> - 03000000a30600000cff000000000000 , Saitek P2500 , a : b2 , b : b3 , back : b5 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b6 , leftstick : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b9 , rightx : a2 , righty : a3 , start : b4 , x : b0 , y : b1 , platform : Windows , <nl> - 03000000a30600000c04000000000000 , Saitek P2900 , a : b1 , b : b2 , back : b12 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000300f00001001000000000000 , Saitek P480 Rumble Pad , a : b2 , b : b3 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Windows , <nl> - 03000000a30600000b04000000000000 , Saitek P990 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000300f00001101000000000000 , saitek rumble pad , a : b2 , b : b3 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Windows , <nl> - 0300000000050000289b000000000000 , Saturn_Adapter_2 . 0 , a : b1 , b : b2 , leftshoulder : b6 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000009b2800000500000000000000 , Saturn_Adapter_2 . 0 , a : b1 , b : b2 , leftshoulder : b6 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000790000001100000000000000 , Sega Saturn Gamepad , a : b1 , b : b2 , leftshoulder : b6 , lefttrigger : b3 , leftx : a0 , lefty : a4 , rightshoulder : b7 , righttrigger : b0 , start : b8 , x : b4 , y : b5 , platform : Windows , <nl> - 03000000341a00000208000000000000 , SL - 6555 - SBK , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , lefttrigger : - a4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a4 , rightx : a3 , righty : a2 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - 030000004c050000cc09000000000000 , Sony DualShock 4 , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000004c050000a00b000000000000 , Sony DualShock 4 Wireless Adaptor , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 030000008f0e00000800000000000000 , SpeedLink Strike FX Wireless , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000ff1100003133000000000000 , SVEN X - PAD , a : b2 , b : b3 , back : b4 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b9 , rightx : a2 , righty : a4 , start : b5 , x : b0 , y : b1 , platform : Windows , <nl> - 03000000fa1900000706000000000000 , Team 5 , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000b50700001203000000000000 , Techmobility X6 - 38V , a : b2 , b : b3 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Windows , <nl> - 030000004f04000015b3000000000000 , Thrustmaster Dual Analog 2 , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Windows , <nl> - 030000004f04000000b3000000000000 , Thrustmaster Firestorm Dual Power , a : b0 , b : b2 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b12 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b10 , x : b1 , y : b3 , platform : Windows , <nl> - 030000004f04000004b3000000000000 , Thrustmaster Firestorm Dual Power 3 , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Windows , <nl> - 03000000666600000488000000000000 , TigerGame PS / PS2 Game Controller Adapter , a : b2 , b : b1 , back : b9 , dpdown : b14 , dpleft : b15 , dpright : b13 , dpup : b12 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000d90400000200000000000000 , TwinShock PS2 , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000380700006652000000000000 , UnKnown , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000632500002305000000000000 , USB Vibration Joystick ( BM ) , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Windows , <nl> - 03000000790000001b18000000000000 , Venom Arcade Joystick , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Windows , <nl> - 03000000786901006e70000000000000 , XInput Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - xinput , XInput Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Windows , <nl> - <nl> - # Mac OS X <nl> - 03000000102800000900000000000000 , 8Bitdo SFC30 GamePad , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Mac OS X , <nl> - 10280000000000000900000000000000 , 8Bitdo SFC30 GamePad Joystick , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Mac OS X , <nl> - 830500000000000031b0000000000000 , Cideko AK08b , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 03000000790000000600000000000000 , G - Shark GP - 702 , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b0 , platform : Mac OS X , <nl> - 03000000ad1b000001f9000000000000 , Gamestop BB - 070 X360 Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 0500000047532047616d657061640000 , GameStop Gamepad , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 030000000d0f00005f00000000000000 , HORI Fighting Commander 4 PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 030000000d0f00005e00000000000000 , HORI Fighting Commander 4 PS4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 030000000d0f00004d00000000000000 , HORI Gem Pad 3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 030000000d0f00006600000000000000 , HORIPAD FPS PLUS 4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 03000000830500006020000000000000 , iBuffalo USB 2 - axis 8 - button Gamepad , a : b1 , b : b0 , back : b6 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b7 , x : b3 , y : b2 , platform : Mac OS X , <nl> - 030000006d04000016c2000000000000 , Logitech F310 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 6d0400000000000016c2000000000000 , Logitech F310 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 030000006d04000018c2000000000000 , Logitech F510 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 6d0400000000000018c2000000000000 , Logitech F510 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 030000006d0400001fc2000000000000 , Logitech F710 Gamepad ( XInput ) , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 6d040000000000001fc2000000000000 , Logitech F710 Gamepad ( XInput ) , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 030000006d04000019c2000000000000 , Logitech Wireless Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 6d0400000000000019c2000000000000 , Logitech Wireless Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 0300000025090000e803000000000000 , Mayflash Wii Classic Controller , a : b1 , b : b0 , back : b8 , dpdown : b13 , dpleft : b12 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b2 , platform : Mac OS X , <nl> - 03000000790000000018000000000000 , Mayflash WiiU Pro Game Controller Adapter ( DInput ) , a : b4 , b : b8 , back : b32 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b16 , leftstick : b40 , lefttrigger : b24 , leftx : a0 , lefty : a4 , rightshoulder : b20 , rightstick : b44 , righttrigger : b28 , rightx : a8 , righty : a12 , start : b36 , x : b0 , y : b12 , platform : Mac OS X , <nl> - 03000000d8140000cecf000000000000 , MC Cthulhu , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 030000008f0e00000300000000000000 , Piranha xtreme , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Mac OS X , <nl> - 030000004c0500006802000000000000 , PS3 Controller , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Mac OS X , <nl> - 4c050000000000006802000000000000 , PS3 Controller , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Mac OS X , <nl> - 030000004c050000c405000000000000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 4c05000000000000c405000000000000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 030000008916000000fd000000000000 , Razer Onza TE , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 03000000790000001100000000000000 , Retrolink Classic Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a3 , lefty : a4 , rightshoulder : b5 , start : b9 , x : b3 , y : b0 , platform : Mac OS X , <nl> - 03000000811700007e05000000000000 , Sega Saturn , a : b2 , b : b4 , dpdown : b16 , dpleft : b15 , dpright : b14 , dpup : b17 , leftshoulder : b8 , lefttrigger : a5 , leftx : a0 , lefty : a2 , rightshoulder : b9 , righttrigger : a4 , start : b13 , x : b0 , y : b6 , platform : Mac OS X , <nl> - 03000000b40400000a01000000000000 , Sega Saturn USB Gamepad , a : b0 , b : b1 , back : b5 , guide : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b8 , x : b3 , y : b4 , platform : Mac OS X , <nl> - 030000003512000021ab000000000000 , SFC30 Joystick , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Mac OS X , <nl> - 351200000000000021ab000000000000 , SFC30 Joystick , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Mac OS X , <nl> - 030000004c050000cc09000000000000 , Sony DualShock 4 V2 , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 030000004c050000a00b000000000000 , Sony DualShock 4 Wireless Adaptor , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Mac OS X , <nl> - 11010000000000002014000000000000 , SteelSeries Nimbus , a : b0 , b : b1 , dpdown : b9 , dpleft : b11 , dpright : b10 , dpup : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b12 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 11010000000000001714000000000000 , SteelSeries Stratus XL , a : b0 , b : b1 , dpdown : b9 , dpleft : b11 , dpright : b10 , dpup : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b12 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 030000004f04000015b3000000000000 , Thrustmaster Dual Analog 3 . 2 , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Mac OS X , <nl> - 030000004f04000000b3000000000000 , Thrustmaster Firestorm Dual Power , a : b0 , b : b2 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b10 , x : b1 , y : b3 , platform : Mac OS X , <nl> - 03000000bd12000015d0000000000000 , Tomee SNES USB Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b9 , x : b3 , y : b0 , platform : Mac OS X , <nl> - 03000000100800000100000000000000 , Twin USB Joystick , a : b4 , b : b2 , back : b16 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b12 , leftstick : b20 , lefttrigger : b8 , leftx : a0 , lefty : a2 , rightshoulder : b14 , rightstick : b22 , righttrigger : b10 , rightx : a6 , righty : a4 , start : b18 , x : b6 , y : b0 , platform : Mac OS X , <nl> - 050000005769696d6f74652028303000 , Wii Remote , a : b4 , b : b5 , back : b7 , dpdown : b3 , dpleft : b0 , dpright : b1 , dpup : b2 , guide : b8 , leftshoulder : b11 , lefttrigger : b12 , leftx : a0 , lefty : a1 , start : b6 , x : b10 , y : b9 , platform : Mac OS X , <nl> - 050000005769696d6f74652028313800 , Wii U Pro Controller , a : b16 , b : b15 , back : b7 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b8 , leftshoulder : b19 , leftstick : b23 , lefttrigger : b21 , leftx : a0 , lefty : a1 , rightshoulder : b20 , rightstick : b24 , righttrigger : b22 , rightx : a2 , righty : a3 , start : b6 , x : b18 , y : b17 , platform : Mac OS X , <nl> - 030000005e0400008e02000000000000 , X360 Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 5e040000000000008e02000000000000 , X360 Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 030000005e040000dd02000000000000 , Xbox One Wired Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 030000005e040000e002000000000000 , Xbox Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Mac OS X , <nl> - 030000005e040000ea02000000000000 , Xbox Wireless Controller , a : b0 , b : b1 , back : b9 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b10 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b8 , x : b2 , y : b3 , platform : Mac OS X , <nl> - <nl> - # Linux <nl> - 05000000203800000900000000010000 , 8Bitdo NES30 Pro , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftstick : b13 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : a6 , rightx : a2 , righty : a3 , start : b11 , x : b4 , y : b3 , platform : Linux , <nl> - 05000000c82d00002038000000010000 , 8Bitdo NES30 Pro , a : b1 , b : b0 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b2 , leftshoulder : b6 , leftstick : b13 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b11 , x : b4 , y : b3 , platform : Linux , <nl> - 03000000c82d00000190000011010000 , 8Bitdo NES30 Pro 8Bitdo NES30 Pro , a : b1 , b : b0 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b13 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b14 , righttrigger : a5 , rightx : a2 , righty : a3 , start : b11 , x : b4 , y : b3 , platform : Linux , <nl> - 05000000102800000900000000010000 , 8Bitdo SFC30 GamePad , a : b1 , b : b0 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b4 , y : b3 , platform : Linux , <nl> - 05000000a00500003232000001000000 , 8Bitdo Zero GamePad , a : b0 , b : b1 , back : b10 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b11 , x : b3 , y : b4 , platform : Linux , <nl> - 030000006f0e00003901000020060000 , Afterglow Wired Controller for Xbox One , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000100000008200000011010000 , Akishop Customs PS360 + v1 . 66 , a : b1 , b : b2 , back : b12 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000666600006706000000010000 , boom PSX to PC Converter , a : b2 , b : b1 , back : b8 , dpdown : b14 , dpleft : b15 , dpright : b13 , dpup : b12 , leftshoulder : b6 , leftstick : b9 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b10 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b11 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000e82000006058000001010000 , Cideko AK08b , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000b40400000a01000000010000 , CYPRESS USB Gamepad , a : b0 , b : b1 , back : b5 , guide : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b8 , x : b3 , y : b4 , platform : Linux , <nl> - 03000000790000000600000010010000 , DragonRise Inc . Generic USB Joystick , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 030000006f0e00003001000001010000 , EA Sports PS3 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000341a000005f7000010010000 , GameCube { HuiJia USB box } , a : b1 , b : b2 , dpdown : b14 , dpleft : b15 , dpright : b13 , dpup : b12 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : a4 , rightx : a5 , righty : a2 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000260900008888000000010000 , GameCube { WiseGroup USB box } , a : b0 , b : b2 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b6 , righttrigger : a5 , rightx : a2 , righty : a3 , start : b7 , x : b1 , y : b3 , platform : Linux , <nl> - 0500000047532047616d657061640000 , GameStop Gamepad , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006f0e00000104000000010000 , Gamestop Logic3 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006f0e00001304000000010000 , Generic X - Box pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : a0 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : a3 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006f0e00001f01000000010000 , Generic X - Box pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000f0250000c183000010010000 , Goodbetterbest Ltd USB Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000280400000140000000010000 , Gravis GamePad Pro USB , a : b1 , b : b2 , back : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000008f0e00000300000010010000 , GreenAsia Inc . USB Joystick , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 030000008f0e00001200000010010000 , GreenAsia Inc . USB Joystick , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000ff1100004133000010010000 , GreenAsia Inc . USB Joystick , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 0500000047532067616d657061640000 , GS gamepad , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 06000000adde0000efbe000002010000 , Hidromancer Game Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000d81400000862000011010000 , HitBox ( PS3 / PC ) Analog Mode , a : b1 , b : b2 , back : b8 , guide : b9 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b12 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000c9110000f055000011010000 , HJC Game GAMEPAD , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 030000000d0f00000d00000000010000 , hori , a : b0 , b : b6 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b3 , leftx : b4 , lefty : b5 , rightshoulder : b7 , start : b9 , x : b1 , y : b2 , platform : Linux , <nl> - 030000000d0f00001000000011010000 , HORI CO . LTD . FIGHTING STICK 3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000000d0f00002200000011010000 , HORI CO . LTD . REAL ARCADE Pro . V3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000ad1b000001f5000033050000 , Hori Pad EX Turbo 2 , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000000d0f00006700000001010000 , HORIPAD ONE , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000830500006020000010010000 , iBuffalo USB 2 - axis 8 - button Gamepad , a : b1 , b : b0 , back : b6 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b7 , x : b3 , y : b2 , platform : Linux , <nl> - 050000006964726f69643a636f6e0000 , idroid : con , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000fd0500000030000000010000 , InterAct GoPad I - 73000 ( Fighting Game Layout ) , a : b3 , b : b4 , back : b6 , leftx : a0 , lefty : a1 , rightshoulder : b2 , righttrigger : b5 , start : b7 , x : b0 , y : b1 , platform : Linux , <nl> - 030000006e0500000320000010010000 , JC - U3613M - DirectInput Mode , a : b2 , b : b3 , back : b10 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b8 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b11 , x : b0 , y : b1 , platform : Linux , <nl> - 03000000300f00001001000010010000 , Jess Tech Dual Analog Rumble Pad , a : b2 , b : b3 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b0 , y : b1 , platform : Linux , <nl> - 03000000ba2200002010000001010000 , Jess Technology USB Game Controller , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 030000006f0e00000103000000020000 , Logic3 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006d04000019c2000010010000 , Logitech Cordless RumblePad 2 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d04000016c2000011010000 , Logitech F310 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d0400001dc2000014400000 , Logitech F310 Gamepad ( XInput ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006d0400001ec2000020200000 , Logitech F510 Gamepad ( XInput ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006d04000019c2000011010000 , Logitech F710 Gamepad ( DInput ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d0400001fc2000005030000 , Logitech F710 Gamepad ( XInput ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000006d04000016c2000010010000 , Logitech Logitech Dual Action , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d04000018c2000010010000 , Logitech RumblePad 2 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006d04000011c2000010010000 , Logitech WingMan Cordless RumblePad , a : b0 , b : b1 , back : b2 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b5 , leftshoulder : b6 , lefttrigger : b9 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b10 , rightx : a3 , righty : a4 , start : b8 , x : b3 , y : b4 , platform : Linux , <nl> - 05000000380700006652000025010000 , Mad Catz C . T . R . L . R , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000ad1b00002ef0000090040000 , Mad Catz Fightpad SFxT , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , lefttrigger : a2 , rightshoulder : b5 , righttrigger : a5 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000380700008034000011010000 , Mad Catz fightstick ( PS3 ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000380700008084000011010000 , Mad Catz fightstick ( PS4 ) , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000380700008433000011010000 , Mad Catz FightStick TE S + PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000380700008483000011010000 , Mad Catz FightStick TE S + PS4 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000380700001647000010040000 , Mad Catz Wired Xbox 360 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000380700003847000090040000 , Mad Catz Wired Xbox 360 Controller ( SFIV ) , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000ad1b000016f0000090040000 , Mad Catz Xbox 360 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000380700001888000010010000 , MadCatz PC USB Wired Stick 8818 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000380700003888000010010000 , MadCatz PC USB Wired Stick 8838 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : a0 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000780000000600000010010000 , Microntek USB Joystick , a : b2 , b : b1 , back : b8 , leftshoulder : b6 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , righttrigger : b5 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 030000005e0400008e02000004010000 , Microsoft X - Box 360 pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008e02000062230000 , Microsoft X - Box 360 pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e040000dd02000003020000 , Microsoft X - Box One pad v2 , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008502000000010000 , Microsoft X - Box pad ( Japan ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b5 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b2 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b3 , y : b4 , platform : Linux , <nl> - 030000005e0400008902000021010000 , Microsoft X - Box pad v2 ( US ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b5 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b2 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b3 , y : b4 , platform : Linux , <nl> - 05000000d6200000ad0d000001000000 , Moga Pro , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b7 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b8 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b6 , x : b2 , y : b3 , platform : Linux , <nl> - 030000001008000001e5000010010000 , NEXT Classic USB Game Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b6 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 050000007e0500003003000001000000 , Nintendo Wii Remote Pro Controller , a : b1 , b : b0 , back : b8 , dpdown : b14 , dpleft : b15 , dpright : b16 , dpup : b13 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 05000000010000000100000003000000 , Nintendo Wiimote , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000550900001072000011010000 , NVIDIA Controller , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000451300000830000010010000 , NYKO CORE , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000005e0400000202000000010000 , Old Xbox pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b5 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b2 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b3 , y : b4 , platform : Linux , <nl> - 05000000362800000100000002010000 , OUYA Game Controller , a : b0 , b : b3 , dpdown : b9 , dpleft : b10 , dpright : b11 , dpup : b8 , guide : b14 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , x : b1 , y : b2 , platform : Linux , <nl> - 05000000362800000100000003010000 , OUYA Game Controller , a : b0 , b : b3 , dpdown : b9 , dpleft : b10 , dpright : b11 , dpup : b8 , guide : b14 , leftshoulder : b4 , leftstick : b6 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b7 , righttrigger : a5 , rightx : a3 , righty : a4 , x : b1 , y : b2 , platform : Linux , <nl> - 03000000ff1100003133000010010000 , PC Game Controller , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000341a00003608000011010000 , PS3 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004c0500006802000011010000 , PS3 Controller , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Linux , <nl> - 050000004c0500006802000000010000 , PS3 Controller ( Bluetooth ) , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Linux , <nl> - 05000000504c415953544154494f4e00 , PS3 Controller ( Bluetooth ) , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Linux , <nl> - 060000004c0500006802000000010000 , PS3 Controller ( Bluetooth ) , a : b14 , b : b13 , back : b0 , dpdown : b6 , dpleft : b7 , dpright : b5 , dpup : b4 , guide : b16 , leftshoulder : b10 , leftstick : b1 , lefttrigger : b8 , leftx : a0 , lefty : a1 , rightshoulder : b11 , rightstick : b2 , righttrigger : b9 , rightx : a2 , righty : a3 , start : b3 , x : b15 , y : b12 , platform : Linux , <nl> - 030000004c050000c405000011010000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004c050000cc09000011010000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 050000004c050000c405000000010000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 050000004c050000cc09000000010000 , PS4 Controller , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000009b2800000300000001010000 , raphnet . net 4nes4snes v1 . 5 , a : b0 , b : b4 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b1 , y : b5 , platform : Linux , <nl> - 030000008916000001fd000024010000 , Razer Onza Classic Edition , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000008916000000fd000024010000 , Razer Onza Tournament , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000c6240000045d000025010000 , Razer Sabertooth , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000321500000009000011010000 , Razer Serval , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 050000003215000000090000163a0000 , Razer Serval , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000790000001100000010010000 , RetroLink Saturn Classic Controller , a : b0 , b : b1 , back : b5 , guide : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b8 , x : b3 , y : b4 , platform : Linux , <nl> - 0300000000f000000300000000010000 , RetroUSB . com RetroPad , a : b1 , b : b5 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b0 , y : b4 , platform : Linux , <nl> - 0300000000f00000f100000000010000 , RetroUSB . com Super RetroPort , a : b1 , b : b5 , back : b2 , leftshoulder : b6 , leftx : a0 , lefty : a1 , rightshoulder : b7 , start : b3 , x : b0 , y : b4 , platform : Linux , <nl> - 030000006f0e00001e01000011010000 , Rock Candy Gamepad for PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000006f0e00004601000001010000 , Rock Candy Wired Controller for Xbox One , a : b0 , b : b1 , back : b6 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000a306000023f6000011010000 , Saitek Cyborg V . 1 Game Pad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a4 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000a30600000c04000011010000 , Saitek P2900 Wireless Pad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b9 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b12 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000a30600000901000000010000 , Saitek P880 , a : b2 , b : b3 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b8 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : b7 , rightx : a3 , righty : a2 , x : b0 , y : b1 , platform : Linux , <nl> - 03000000a306000018f5000010010000 , Saitek PLC Saitek P3200 Rumble Pad , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a3 , righty : a4 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000c01600008704000011010000 , Serial / Keyboard / Mouse / Joystick , a : b12 , b : b10 , back : b4 , dpdown : b2 , dpleft : b3 , dpright : b1 , dpup : b0 , leftshoulder : b9 , leftstick : b14 , lefttrigger : b6 , leftx : a1 , lefty : a0 , rightshoulder : b8 , rightstick : b15 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b5 , x : b13 , y : b11 , platform : Linux , <nl> - 030000004c050000c405000011810000 , Sony DualShock 4 , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 050000004c050000cc09000000810000 , Sony DualShock 4 ( CUH - ZCT2U ) ( Bluetooth ) , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 030000004c050000cc09000011810000 , Sony DualShock 4 ( CUH - ZCT2U ) ( USB ) , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 030000004c050000a00b000011010000 , Sony DualShock 4 Wireless Adaptor , a : b1 , b : b2 , back : b13 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : a3 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : a4 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004c0500006802000011810000 , Sony PLAYSTATION ( R ) 3 Controller , a : b0 , b : b1 , back : b8 , dpdown : b14 , dpleft : b15 , dpright : b16 , dpup : b13 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 050000004c0500006802000000810000 , Sony PLAYSTATION ( R ) 3 Controller , a : b0 , b : b1 , back : b8 , dpdown : b14 , dpleft : b15 , dpright : b16 , dpup : b13 , guide : b10 , leftshoulder : b4 , leftstick : b11 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b12 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 03000000250900000500000000010000 , Sony PS2 pad with SmartJoy adapter , a : b2 , b : b1 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b3 , y : b0 , platform : Linux , <nl> - 030000005e0400008e02000073050000 , Speedlink TORID Wireless Gamepad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008e02000020200000 , SpeedLink XEOX Pro Analog Gamepad pad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000de280000fc11000001000000 , Steam Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000666600000488000000010000 , Super Joy Box 5 Pro , a : b2 , b : b1 , back : b9 , dpdown : b14 , dpleft : b15 , dpright : b13 , dpup : b12 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a2 , righty : a3 , start : b8 , x : b3 , y : b0 , platform : Linux , <nl> - 030000004f04000020b3000010010000 , Thrustmaster 2 in 1 DT , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Linux , <nl> - 030000004f04000015b3000010010000 , Thrustmaster Dual Analog 4 , a : b0 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b1 , y : b3 , platform : Linux , <nl> - 030000004f04000023b3000000010000 , Thrustmaster Dual Trigger 3 - in - 1 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004f04000000b3000010010000 , Thrustmaster Firestorm Dual Power , a : b0 , b : b2 , back : b9 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b11 , lefttrigger : b5 , leftx : a0 , lefty : a1 , rightshoulder : b6 , rightstick : b12 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b10 , x : b1 , y : b3 , platform : Linux , <nl> - 030000004f04000008d0000000010000 , Thrustmaster Run N Drive Wireless , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a5 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 030000004f04000009d0000000010000 , Thrustmaster Run N Drive Wireless PS3 , a : b1 , b : b2 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b12 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b0 , y : b3 , platform : Linux , <nl> - 03000000bd12000015d0000010010000 , Tomee SNES USB Controller , a : b2 , b : b1 , back : b8 , leftshoulder : b4 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000d814000007cd000011010000 , Toodles 2008 Chimp PC / PS3 , a : b0 , b : b1 , back : b8 , leftshoulder : b4 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : b7 , start : b9 , x : b3 , y : b2 , platform : Linux , <nl> - 03000000100800000100000010010000 , Twin USB PS2 Adapter , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000100800000300000010010000 , USB Gamepad , a : b2 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b3 , y : b0 , platform : Linux , <nl> - 03000000790000001100000000010000 , USB Gamepad1 , a : b2 , b : b1 , back : b8 , dpdown : a0 , dpleft : a1 , dpright : a2 , dpup : a4 , start : b9 , platform : Linux , <nl> - 03000000de280000ff11000001000000 , Valve Streaming Gamepad , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 05000000ac0500003232000001000000 , VR - BOX , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b6 , leftstick : b10 , lefttrigger : b4 , leftx : a0 , lefty : a1 , rightshoulder : b7 , rightstick : b11 , righttrigger : b5 , rightx : a3 , righty : a2 , start : b9 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008e02000010010000 , X360 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400008e02000014010000 , X360 Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400001907000000010000 , X360 Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e0400009102000007010000 , X360 Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e040000a102000000010000 , X360 Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : b14 , dpleft : b11 , dpright : b12 , dpup : b13 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e040000a102000007010000 , X360 Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 0000000058626f782033363020576900 , Xbox 360 Wireless Controller , a : b0 , b : b1 , back : b14 , dpdown : b11 , dpleft : b12 , dpright : b13 , dpup : b10 , guide : b7 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b6 , x : b2 , y : b3 , platform : Linux , <nl> - 0000000058626f782047616d65706100 , Xbox Gamepad ( userspace driver ) , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a5 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a4 , rightx : a2 , righty : a3 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 030000005e040000d102000001010000 , Xbox One Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 050000005e040000e002000003090000 , Xbox One Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b10 , leftshoulder : b4 , leftstick : b8 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b9 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 03000000c0160000e105000001010000 , Xin - Mo Xin - Mo Dual Arcade , a : b4 , b : b3 , back : b6 , dpdown : b12 , dpleft : b13 , dpright : b14 , dpup : b11 , guide : b9 , leftshoulder : b2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , start : b7 , x : b1 , y : b0 , platform : Linux , <nl> - xinput , XInput Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - <nl> - # Android <nl> - 4e564944494120436f72706f72617469 , NVIDIA Controller , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b9 , leftstick : b7 , lefttrigger : a4 , leftx : a0 , lefty : a1 , rightshoulder : b10 , rightstick : b8 , righttrigger : a5 , rightx : a2 , righty : a3 , start : b6 , x : b2 , y : b3 , platform : Android , <nl> - <nl> - # iOS <nl> - 4d466947616d65706164010000000000 , MFi Extended Gamepad , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b6 , x : b2 , y : b3 , platform : iOS , <nl> - 4d466947616d65706164020000000000 , MFi Gamepad , a : b0 , b : b1 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , rightshoulder : b5 , start : b6 , x : b2 , y : b3 , platform : iOS , <nl> mmm a / core / input / godotcontrollerdb . txt <nl> ppp b / core / input / godotcontrollerdb . txt <nl> <nl> - # Game Controller DB for SDL in 2 . 0 . 6 + format <nl> + # Game Controller DB for Godot in SDL 2 . 0 . 10 format <nl> # Source : https : / / github . com / godotengine / godot <nl> <nl> - # Windows <nl> - 9000318000000000000504944564944 , Mayflash Wiimote PC Adapter , a : b2 , b : h0 . 4 , x : b0 , y : b1 , back : b4 , start : b5 , guide : b11 , leftshoulder : b6 , rightshoulder : b3 , leftx : a0 , lefty : a1 , platform : Windows , <nl> - c911f055000000000000504944564944 , GAMEPAD , a : b0 , b : b1 , back : b8 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , leftstick : b10 , lefttrigger : b6 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b11 , righttrigger : b7 , rightx : a2 , righty : a3 , start : b9 , x : b2 , y : b3 , platform : Windows , <nl> - __XINPUT_DEVICE__ , XInput Gamepad , a : b12 , b : b13 , x : b14 , y : b15 , start : b4 , back : b5 , leftstick : b6 , rightstick : b7 , leftshoulder : b8 , rightshoulder : b9 , dpup : b0 , dpdown : b1 , dpleft : b2 , dpright : b3 , leftx : a0 , lefty : a1 , rightx : a2 , righty : a3 , lefttrigger : a4 , righttrigger : a5 , platform : Windows , <nl> - <nl> - # Linux <nl> - 030000006f0e00001302000000010000 , Afterglow Gamepad for Xbox 360 , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - 05000000362800000100000004010000 , OUYA Game Controller , leftx : a0 , lefty : a1 , dpdown : b9 , rightstick : b7 , rightshoulder : b5 , rightx : a3 , start : b16 , righty : a4 , dpleft : b10 , lefttrigger : b12 , x : b1 , dpup : b8 , back : b14 , leftstick : b6 , leftshoulder : b4 , y : b2 , a : b0 , dpright : b11 , righttrigger : b13 , b : b3 , platform : Linux , <nl> - 030000005e0400008e02000001000000 , Microsoft X - Box 360 pad , leftstick : b9 , leftx : a0 , lefty : a1 , dpdown : h0 . 1 , rightstick : b10 , rightshoulder : b5 , rightx : a3 , start : b7 , righty : a4 , dpleft : h0 . 2 , lefttrigger : a2 , x : b2 , dpup : h0 . 4 , back : b6 , leftshoulder : b4 , y : b3 , a : b0 , dpright : h0 . 8 , righttrigger : a5 , b : b1 , platform : Linux , <nl> - 03000000fd0500002a26000000010000 , 3dfx InterAct HammerHead FX , leftx : a0 , lefty : a1 , dpdown : h0 . 4 , rightstick : b5 , rightshoulder : b7 , rightx : a2 , start : b11 , righty : a3 , dpleft : h0 . 8 , lefttrigger : b8 , x : b0 , dpup : h0 . 1 , back : b10 , leftstick : b2 , leftshoulder : b6 , y : b1 , a : b3 , dpright : h0 . 2 , righttrigger : b9 , b : b4 , platform : Linux , <nl> - 030000006f0e00002801000011010000 , PDP Rock Candy Wireless Controller for PS3 , leftx : a0 , lefty : a1 , dpdown : h0 . 4 , rightstick : b11 , rightshoulder : b5 , rightx : a2 , start : b9 , righty : a3 , dpleft : h0 . 8 , lefttrigger : b6 , x : b0 , dpup : h0 . 1 , back : b8 , leftstick : b10 , leftshoulder : b4 , y : b3 , a : b1 , dpright : h0 . 2 , righttrigger : b7 , b : b2 , platform : Linux , <nl> - 030000000d0f00004d00000011010000 , HORI Gem Pad 3 , x : b0 , a : b1 , b : b2 , y : b3 , back : b8 , guide : b12 , start : b9 , dpleft : h0 . 8 , dpdown : h0 . 4 , dpright : h0 . 2 , dpup : h0 . 1 , leftshoulder : b4 , lefttrigger : b6 , rightshoulder : b5 , righttrigger : b7 , leftstick : b10 , rightstick : b11 , leftx : a0 , lefty : a1 , rightx : a2 , righty : a3 , platform : Linux , <nl> - 030000005e040000ea02000001030000 , Xbox One Wireless Controller , a : b0 , b : b1 , back : b6 , dpdown : h0 . 4 , dpleft : h0 . 8 , dpright : h0 . 2 , dpup : h0 . 1 , guide : b8 , leftshoulder : b4 , leftstick : b9 , lefttrigger : a2 , leftx : a0 , lefty : a1 , rightshoulder : b5 , rightstick : b10 , righttrigger : a5 , rightx : a3 , righty : a4 , start : b7 , x : b2 , y : b3 , platform : Linux , <nl> - <nl> - # Android <nl> - 4f5559412047616d6520436f6e74726f , OUYA Game Controller , leftx : a1 , lefty : a3 , dpdown : b12 , rightstick : b8 , rightshoulder : b10 , rightx : a6 , start : b - 86 , righty : a7 , dpleft : b13 , lefttrigger : b15 , x : b2 , dpup : b11 , leftstick : b7 , leftshoulder : b9 , y : b3 , a : b0 , dpright : b14 , righttrigger : b16 , b : b1 , platform : Android , <nl> - Default Android Gamepad , Default Controller , leftx : a0 , lefty : a1 , dpdown : h0 . 4 , rightstick : b8 , rightshoulder : b10 , rightx : a2 , start : b6 , righty : a3 , dpleft : h0 . 8 , lefttrigger : a4 , x : b2 , dpup : h0 . 1 , back : b4 , leftstick : b7 , leftshoulder : b9 , y : b3 , a : b0 , dpright : h0 . 2 , righttrigger : a5 , b : b1 , platform : Android , <nl> - 532e542e442e20496e74657261637420 , 3dfx InterAct HammerHead FX , leftx : a0 , lefty : a1 , dpdown : h0 . 4 , rightstick : b25 , rightshoulder : b27 , rightx : a2 , start : b31 , righty : a3 , dpleft : h0 . 8 , lefttrigger : b28 , x : b20 , dpup : h0 . 1 , back : b30 , leftstick : b22 , leftshoulder : b26 , y : b21 , a : b23 , dpright : h0 . 2 , righttrigger : b29 , b : b24 , platform : Android , <nl> - 506572666f726d616e63652044657369 , PDP Rock Candy Wireless Controller for PS3 , leftx : a0 , lefty : a1 , dpdown : h0 . 4 , rightstick : b6 , rightshoulder : b18 , rightx : a2 , start : b16 , righty : a3 , dpleft : h0 . 8 , lefttrigger : b9 , x : b0 , dpup : h0 . 1 , back : h0 . 2 , leftstick : b4 , leftshoulder : b3 , y : b2 , a : b1 , dpright : h0 . 2 , righttrigger : b10 , b : b17 , platform : Android , <nl> - 4d6963726f736f667420582d426f7820 , Microsoft X - Box 360 pad , leftx : a0 , lefty : a1 , dpdown : h0 . 4 , rightstick : b8 , rightshoulder : b10 , rightx : a2 , start : b6 , righty : a3 , dpleft : h0 . 8 , lefttrigger : a4 , x : b2 , dpup : h0 . 1 , leftstick : b7 , leftshoulder : b9 , y : b3 , a : b0 , dpright : h0 . 2 , righttrigger : a5 , b : b1 , platform : Android , <nl> - 484f524920434f2e2c4c544420205041 , Hori Gem Pad 3 , leftx : a0 , lefty : a1 , dpdown : h0 . 4 , rightstick : b6 , rightshoulder : b18 , rightx : a2 , start : b16 , righty : a3 , dpleft : h0 . 8 , lefttrigger : b9 , x : b0 , dpup : h0 . 1 , back : b15 , leftstick : b4 , leftshoulder : b3 , y : b2 , a : b1 , dpright : h0 . 2 , righttrigger : b10 , b : b17 , platform : Android , <nl> - 47656e6572696320582d426f78207061 , Logitech F - 310 , leftx : a0 , lefty : a1 , dpdown : h0 . 4 , rightstick : b8 , rightshoulder : b10 , rightx : a2 , start : b6 , righty : a3 , dpleft : h0 . 8 , lefttrigger : a5 , x : b2 , dpup : h0 . 1 , leftstick : b7 , leftshoulder : b9 , y : b3 , a : b0 , dpright : h0 . 2 , righttrigger : a4 , b : b1 , platform : Android , <nl> - <nl> # Javascript <nl> Default HTML5 Gamepad , Default Mapping , leftx : a0 , lefty : a1 , dpdown : b13 , rightstick : b11 , rightshoulder : b5 , rightx : a2 , start : b9 , righty : a3 , dpleft : b14 , lefttrigger : a6 , x : b2 , dpup : b12 , back : b8 , leftstick : b10 , leftshoulder : b4 , y : b3 , a : b0 , dpright : b15 , righttrigger : a7 , b : b1 , platform : Javascript , <nl> c2a94d6963726f736f66742058626f78 , Wireless X360 Controller , leftx : a0 , lefty : a1 , dpdown : b14 , rightstick : b10 , rightshoulder : b5 , rightx : a3 , start : b7 , righty : a4 , dpleft : b11 , lefttrigger : a2 , x : b2 , dpup : b13 , back : b6 , leftstick : b9 , leftshoulder : b4 , y : b3 , a : b0 , dpright : b12 , righttrigger : a5 , b : b1 , platform : Javascript , <nl>
Merge pull request from akien - mga / input - drop - obsolete - controllerdbs
godotengine/godot
b9e58ed5b869cf2caf946be9a5e3b9066e1387eb
2020-04-28T13:44:31Z
mmm a / test / onnx / test_pytorch_onnx_onnxruntime . py <nl> ppp b / test / onnx / test_pytorch_onnx_onnxruntime . py <nl> def forward ( self , x ) : <nl> x = torch . randn ( 5 , 3 , 3 ) <nl> self . run_test ( model , x ) <nl> <nl> + @ skipIfUnsupportedMinOpsetVersion ( 11 ) <nl> + def test_loop_multi_dim ( self ) : <nl> + class LoopMultiDimModel ( torch . jit . ScriptModule ) : <nl> + @ torch . jit . script_method <nl> + def forward ( self , x , y ) : <nl> + for x_ in torch . flip ( x . narrow ( 0 , 0 , 7 ) , [ 0 ] ) : <nl> + y = x_ [ 0 ] [ y ] <nl> + return y <nl> + <nl> + model = LoopMultiDimModel ( ) <nl> + x = torch . randint ( 0 , 5 , ( 8 , 1 , 17 ) , dtype = torch . long ) <nl> + y = torch . ones ( 1 , dtype = torch . long ) <nl> + self . run_test ( model , ( x , y ) ) <nl> + <nl> @ skipIfUnsupportedMinOpsetVersion ( 11 ) <nl> def test_list ( self ) : <nl> class ListModel ( torch . jit . ScriptModule ) : <nl> mmm a / torch / onnx / symbolic_opset11 . py <nl> ppp b / torch / onnx / symbolic_opset11 . py <nl> def masked_scatter ( g , self , mask , source ) : <nl> def _len ( g , self ) : <nl> if _is_tensor_list ( self ) or self . node ( ) . kind ( ) = = " onnx : : SplitToSequence " : <nl> return g . op ( " SequenceLength " , self ) <nl> - return g . op ( " Size " , self ) <nl> + sz_0 = size ( g , self , g . op ( " Constant " , value_t = torch . LongTensor ( [ 0 ] ) ) ) <nl> + return g . op ( ' Squeeze ' , sz_0 , axes_i = [ 0 ] ) <nl> <nl> <nl> def __getitem_ ( g , self , i ) : <nl> mmm a / torch / onnx / symbolic_opset9 . py <nl> ppp b / torch / onnx / symbolic_opset9 . py <nl> def floor ( g , input ) : <nl> <nl> <nl> def _len ( g , self ) : <nl> - return g . op ( " Size " , self ) <nl> + sz_0 = size ( g , self , g . op ( " Constant " , value_t = torch . LongTensor ( [ 0 ] ) ) ) <nl> + return g . op ( ' Squeeze ' , sz_0 , axes_i = [ 0 ] ) <nl> <nl> <nl> @ parse_args ( ' v ' , ' t ' , ' t ' ) <nl>
[ ONNX ] Convert _len based on the first dimension length ( )
pytorch/pytorch
85c43c3da15ab9671791e6b7a7eabaccf2eeb459
2020-11-13T04:25:39Z
mmm a / plugins / txn_test_gen_plugin / CMakeLists . txt <nl> ppp b / plugins / txn_test_gen_plugin / CMakeLists . txt <nl> file ( GLOB HEADERS " include / eosio / txn_test_gen_plugin / * . hpp " ) <nl> add_library ( txn_test_gen_plugin <nl> txn_test_gen_plugin . cpp <nl> $ { HEADERS } ) <nl> - <nl> + <nl> target_link_libraries ( txn_test_gen_plugin appbase fc http_plugin chain_plugin eosio_testing ) <nl> target_include_directories ( txn_test_gen_plugin PUBLIC $ { CMAKE_CURRENT_SOURCE_DIR } / include ) <nl> - target_include_directories ( txn_test_gen_plugin PUBLIC $ { CMAKE_BINARY_DIR } / contracts ) <nl> + target_include_directories ( txn_test_gen_plugin PUBLIC $ { CMAKE_BINARY_DIR } / test - contracts ) <nl> target_include_directories ( txn_test_gen_plugin PUBLIC $ { CMAKE_BINARY_DIR } / unittests / include ) <nl> target_include_directories ( txn_test_gen_plugin PUBLIC $ { CMAKE_SOURCE_DIR } / libraries / testing / include ) <nl> mmm a / tests / CMakeLists . txt <nl> ppp b / tests / CMakeLists . txt <nl> set_property ( TEST nodeos_run_bnet_test PROPERTY LABELS nonparallelizable_tests ) <nl> <nl> add_test ( NAME p2p_dawn515_test COMMAND tests / p2p_tests / dawn_515 / test . sh WORKING_DIRECTORY $ { CMAKE_BINARY_DIR } ) <nl> set_property ( TEST p2p_dawn515_test PROPERTY LABELS nonparallelizable_tests ) <nl> - if ( BUILD_MONGO_DB_PLUGIN ) <nl> - add_test ( NAME nodeos_run_test - mongodb COMMAND tests / nodeos_run_test . py - - mongodb - v - - clean - run - - dump - error - detail WORKING_DIRECTORY $ { CMAKE_BINARY_DIR } ) <nl> - set_property ( TEST nodeos_run_test - mongodb PROPERTY LABELS nonparallelizable_tests ) <nl> - endif ( ) <nl> + # if ( BUILD_MONGO_DB_PLUGIN ) <nl> + # add_test ( NAME nodeos_run_test - mongodb COMMAND tests / nodeos_run_test . py - - mongodb - v - - clean - run - - dump - error - detail WORKING_DIRECTORY $ { CMAKE_BINARY_DIR } ) <nl> + # set_property ( TEST nodeos_run_test - mongodb PROPERTY LABELS nonparallelizable_tests ) <nl> + # endif ( ) <nl> <nl> add_test ( NAME distributed - transactions - test COMMAND tests / distributed - transactions - test . py - d 2 - p 4 - n 6 - v - - clean - run - - dump - error - detail WORKING_DIRECTORY $ { CMAKE_BINARY_DIR } ) <nl> set_property ( TEST distributed - transactions - test PROPERTY LABELS nonparallelizable_tests ) <nl> mmm a / unittests / CMakeLists . txt <nl> ppp b / unittests / CMakeLists . txt <nl> <nl> - # file ( GLOB COMMON_SOURCES " common / * . cpp " ) <nl> - <nl> find_package ( Gperftools QUIET ) <nl> if ( GPERFTOOLS_FOUND ) <nl> message ( STATUS " Found gperftools ; compiling tests with TCMalloc " ) <nl>
Clean up
EOSIO/eos
922eb880fa3f1ddf1022ada8756ca3fea26f2ef2
2018-12-17T21:48:06Z
mmm a / cocos / scripting / lua / bindings / LuaBasicConversions . cpp <nl> ppp b / cocos / scripting / lua / bindings / LuaBasicConversions . cpp <nl> bool luaval_is_usertype ( lua_State * L , int lo , const char * type , int def ) <nl> return false ; <nl> } <nl> <nl> + bool luaval_to_ushort ( lua_State * L , int lo , unsigned short * outValue ) <nl> + { <nl> + if ( nullptr = = L | | nullptr = = outValue ) <nl> + return false ; <nl> + <nl> + bool ok = true ; <nl> + <nl> + tolua_Error tolua_err ; <nl> + if ( ! tolua_isnumber ( L , lo , 0 , & tolua_err ) ) <nl> + { <nl> + # if COCOS2D_DEBUG > = 1 <nl> + luaval_to_native_err ( L , " # ferror : " , & tolua_err ) ; <nl> + # endif <nl> + ok = false ; <nl> + } <nl> + <nl> + if ( ok ) <nl> + { <nl> + * outValue = ( unsigned short ) tolua_tonumber ( L , lo , 0 ) ; <nl> + } <nl> + <nl> + return ok ; <nl> + } <nl> + <nl> <nl> bool luaval_to_int32 ( lua_State * L , int lo , int * outValue ) <nl> { <nl> mmm a / cocos / scripting / lua / bindings / LuaBasicConversions . h <nl> ppp b / cocos / scripting / lua / bindings / LuaBasicConversions . h <nl> cocos2d : : log ( __VA_ARGS__ ) ; \ <nl> <nl> extern bool luaval_is_usertype ( lua_State * L , int lo , const char * type , int def ) ; <nl> / / to native <nl> + extern bool luaval_to_ushort ( lua_State * L , int lo , unsigned short * outValue ) ; <nl> extern bool luaval_to_int32 ( lua_State * L , int lo , int * outValue ) ; <nl> extern bool luaval_to_uint32 ( lua_State * L , int lo , unsigned int * outValue ) ; <nl> extern bool luaval_to_uint16 ( lua_State * L , int lo , uint16_t * outValue ) ; <nl> mmm a / tools / bindings - generator <nl> ppp b / tools / bindings - generator <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit ddd06521c6cd99cc19ff8122d31784a6075df3bb <nl> + Subproject commit c98aaef6ec8c805ed22cdabefa044f23e2014394 <nl>
Merge pull request from samuele3hu / LuaConversion
cocos2d/cocos2d-x
7a5074652cd8a57ca21b031bcad728cc40a0015b
2013-12-18T06:43:42Z
new file mode 100644 <nl> index 000000000000 . . afb288ee56bf <nl> mmm / dev / null <nl> ppp b / jstests / core / automation_setparameter . js <nl> <nl> + / / Tests that using setParameter to update the parameter ' automationServiceDescriptor ' causes a <nl> + / / field with that name to be echoed back in isMaster . See SERVER - 18399 for more details . <nl> + <nl> + ( function ( ) { <nl> + <nl> + / / Run isMaster , and if it contains an automation service descriptor , save it , so we can restore <nl> + / / it later . If it wasn ' t set , original will just be undefined . <nl> + var res = assert . commandWorked ( db . runCommand ( { isMaster : 1 } ) ) ; <nl> + var original = res . automationServiceDescriptor ; <nl> + <nl> + / / Try to set the descriptor to an invalid value : only strings are supported . <nl> + assert . commandFailedWithCode ( db . adminCommand ( { setParameter : 1 , automationServiceDescriptor : 0 } ) , <nl> + ErrorCodes . TypeMismatch ) ; <nl> + <nl> + / / Try to set the descriptor to an invalid value : Only 64 characters are allowed . <nl> + assert . commandFailedWithCode ( db . adminCommand ( { <nl> + setParameter : 1 , <nl> + automationServiceDescriptor : <nl> + " 1234567812345678123456781234567812345678123456781234567812345678X " <nl> + } ) , <nl> + ErrorCodes . Overflow ) ; <nl> + <nl> + / / Short strings are okay . <nl> + res = assert . commandWorked ( <nl> + db . adminCommand ( { setParameter : 1 , automationServiceDescriptor : " some_service " } ) ) ; <nl> + <nl> + / / Verify that the setParameter ' was ' field contains what we expected . <nl> + if ( original ) <nl> + assert . eq ( original , res . was ) ; <nl> + <nl> + / / Verify that the ' some_service ' string is now echoed back to us in isMaster <nl> + res = assert . commandWorked ( db . runCommand ( { isMaster : 1 } ) ) ; <nl> + assert . eq ( res . automationServiceDescriptor , " some_service " ) ; <nl> + <nl> + / / Verify that setting the descriptor to the empty string is ok , and prevents it from being <nl> + / / echoed back <nl> + assert . commandWorked ( db . adminCommand ( { setParameter : 1 , automationServiceDescriptor : " " } ) ) ; <nl> + res = assert . commandWorked ( db . runCommand ( { isMaster : 1 } ) ) ; <nl> + assert ( ! res . hasOwnProperty ( ' automationServiceDescriptor ' ) ) ; <nl> + <nl> + / / Restore whatever was there originally . <nl> + if ( ! original ) <nl> + original = " " ; <nl> + assert . commandWorked ( db . adminCommand ( { setParameter : 1 , automationServiceDescriptor : original } ) ) ; <nl> + } ( ) ) ; <nl> mmm a / src / mongo / db / commands / parameters . cpp <nl> ppp b / src / mongo / db / commands / parameters . cpp <nl> ExportedServerParameter < int , ServerParameterType : : kRuntimeOnly > MaxConsecutiveFa <nl> <nl> ExportedServerParameter < bool , ServerParameterType : : kRuntimeOnly > TraceExceptionsSetting ( <nl> ServerParameterSet : : getGlobal ( ) , " traceExceptions " , & DBException : : traceExceptions ) ; <nl> + <nl> + class AutomationServiceDescriptor final : public ServerParameter { <nl> + public : <nl> + static constexpr auto kName = " automationServiceDescriptor " _sd ; <nl> + static constexpr auto kMaxSize = 64U ; <nl> + <nl> + AutomationServiceDescriptor ( ) <nl> + : ServerParameter ( ServerParameterSet : : getGlobal ( ) , kName . toString ( ) , true , true ) { } <nl> + <nl> + virtual void append ( OperationContext * txn , <nl> + BSONObjBuilder & builder , <nl> + const std : : string & name ) override { <nl> + const stdx : : lock_guard < stdx : : mutex > lock ( _mutex ) ; <nl> + if ( ! _value . empty ( ) ) <nl> + builder < < name < < _value ; <nl> + } <nl> + <nl> + virtual Status set ( const BSONElement & newValueElement ) override { <nl> + if ( newValueElement . type ( ) ! = mongo : : String ) <nl> + return { ErrorCodes : : TypeMismatch , <nl> + mongoutils : : str : : stream ( ) < < " Value for parameter " < < kName <nl> + < < " must be of type ' string ' " } ; <nl> + return setFromString ( newValueElement . String ( ) ) ; <nl> + } <nl> + <nl> + virtual Status setFromString ( const std : : string & str ) override { <nl> + if ( str . size ( ) > kMaxSize ) <nl> + return { ErrorCodes : : Overflow , <nl> + mongoutils : : str : : stream ( ) < < " Value for parameter " < < kName <nl> + < < " must be no more than " <nl> + < < kMaxSize <nl> + < < " bytes " } ; <nl> + <nl> + { <nl> + const stdx : : lock_guard < stdx : : mutex > lock ( _mutex ) ; <nl> + _value = str ; <nl> + } <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + private : <nl> + stdx : : mutex _mutex ; <nl> + std : : string _value ; <nl> + } automationServiceDescriptor ; <nl> + <nl> + constexpr decltype ( AutomationServiceDescriptor : : kName ) AutomationServiceDescriptor : : kName ; <nl> } <nl> } <nl> mmm a / src / mongo / db / repl / replication_info . cpp <nl> ppp b / src / mongo / db / repl / replication_info . cpp <nl> <nl> # include " mongo / db / repl / oplog . h " <nl> # include " mongo / db / repl / oplogreader . h " <nl> # include " mongo / db / repl / replication_coordinator_global . h " <nl> + # include " mongo / db / server_options . h " <nl> + # include " mongo / db / server_parameters . h " <nl> # include " mongo / db / storage / storage_options . h " <nl> # include " mongo / db / wire_version . h " <nl> # include " mongo / executor / network_interface . h " <nl> # include " mongo / s / write_ops / batched_command_request . h " <nl> + # include " mongo / util / map_util . h " <nl> <nl> namespace mongo { <nl> <nl> class CmdIsMaster : public Command { <nl> result . append ( " maxWireVersion " , WireSpec : : instance ( ) . maxWireVersionIncoming ) ; <nl> result . append ( " minWireVersion " , WireSpec : : instance ( ) . minWireVersionIncoming ) ; <nl> result . append ( " readOnly " , storageGlobalParams . readOnly ) ; <nl> + <nl> + const auto parameter = mapFindWithDefault ( ServerParameterSet : : getGlobal ( ) - > getMap ( ) , <nl> + " automationServiceDescriptor " ) ; <nl> + if ( parameter ) <nl> + parameter - > append ( txn , result , " automationServiceDescriptor " ) ; <nl> + <nl> return true ; <nl> } <nl> } cmdismaster ; <nl> mmm a / src / mongo / s / commands / cluster_is_master_cmd . cpp <nl> ppp b / src / mongo / s / commands / cluster_is_master_cmd . cpp <nl> <nl> # include " mongo / platform / basic . h " <nl> <nl> # include " mongo / db / commands . h " <nl> + # include " mongo / db / server_options . h " <nl> + # include " mongo / db / server_parameters . h " <nl> # include " mongo / db / wire_version . h " <nl> # include " mongo / s / grid . h " <nl> # include " mongo / s / write_ops / batched_command_request . h " <nl> + # include " mongo / util / map_util . h " <nl> <nl> namespace mongo { <nl> namespace { <nl> class CmdIsMaster : public Command { <nl> result . append ( " maxWireVersion " , WireSpec : : instance ( ) . maxWireVersionIncoming ) ; <nl> result . append ( " minWireVersion " , WireSpec : : instance ( ) . minWireVersionIncoming ) ; <nl> <nl> + const auto parameter = mapFindWithDefault ( ServerParameterSet : : getGlobal ( ) - > getMap ( ) , <nl> + " automationServiceDescriptor " ) ; <nl> + if ( parameter ) <nl> + parameter - > append ( txn , result , " automationServiceDescriptor " ) ; <nl> + <nl> return true ; <nl> } <nl> <nl> mmm a / src / mongo / shell / dbshell . cpp <nl> ppp b / src / mongo / shell / dbshell . cpp <nl> int _main ( int argc , char * argv [ ] , char * * envp ) { <nl> <nl> if ( ! shellGlobalParams . nodb & & ! mongo : : serverGlobalParams . quiet & & isatty ( fileno ( stdin ) ) ) { <nl> scope - > exec ( <nl> - " shellHelper ( ' show ' , ' startupWarnings ' ) " , " ( shellwarnings " , false , true , false ) ; <nl> + " shellHelper ( ' show ' , ' startupWarnings ' ) " , " ( shellwarnings ) " , false , true , false ) ; <nl> + <nl> + scope - > exec ( " shellHelper ( ' show ' , ' automationNotices ' ) " , <nl> + " ( automationnotices ) " , <nl> + false , <nl> + true , <nl> + false ) ; <nl> } <nl> <nl> shellHistoryInit ( ) ; <nl> mmm a / src / mongo / shell / utils . js <nl> ppp b / src / mongo / shell / utils . js <nl> shellHelper . show = function ( what ) { <nl> } <nl> } <nl> <nl> + if ( what = = " automationNotices " ) { <nl> + var dbDeclared , ex ; <nl> + try { <nl> + / / ! ! db essentially casts db to a boolean <nl> + / / Will throw a reference exception if db hasn ' t been declared . <nl> + dbDeclared = ! ! db ; <nl> + } catch ( ex ) { <nl> + dbDeclared = false ; <nl> + } <nl> + <nl> + if ( dbDeclared ) { <nl> + var res = db . runCommand ( { isMaster : 1 , forShell : 1 } ) ; <nl> + if ( ! res . ok ) { <nl> + print ( " Note : Cannot determine if automation is active " ) ; <nl> + return " " ; <nl> + } <nl> + <nl> + if ( res . hasOwnProperty ( " automationServiceDescriptor " ) ) { <nl> + print ( " Note : This server is managed by automation service ' " + <nl> + res . automationServiceDescriptor + " ' . " ) ; <nl> + print ( <nl> + " Note : Many administrative actions are inappropriate , and may be automatically reverted . " ) ; <nl> + return " " ; <nl> + } <nl> + <nl> + return " " ; <nl> + <nl> + } else { <nl> + print ( " Cannot show automationNotices , \ " db \ " is not set " ) ; <nl> + return " " ; <nl> + } <nl> + } <nl> + <nl> throw Error ( " don ' t know how to show [ " + what + " ] " ) ; <nl> <nl> } ; <nl>
SERVER - 18399 Issue a notification in the shell when automation is active
mongodb/mongo
08ef5eefb59b96c6696416144d43cfe2c45d3619
2016-07-15T22:10:22Z
mmm a / dbms / include / DB / Common / SipHash . h <nl> ppp b / dbms / include / DB / Common / SipHash . h <nl> <nl> * ( ~ 700 МБ / сек . , 15 млн . строк в секунду ) <nl> * / <nl> <nl> - # include < stdint . h > <nl> - # include < cstdlib > <nl> - # include < stddef . h > <nl> + # include < cstdint > <nl> + # include < cstddef > <nl> <nl> # define ROTL ( x , b ) ( u64 ) ( ( ( x ) < < ( b ) ) | ( ( x ) > > ( 64 - ( b ) ) ) ) <nl> <nl>
Merge
ClickHouse/ClickHouse
fbff4f503adb0245d83ef223e8e8d942b41d3748
2015-07-03T09:24:50Z
mmm a / test / AutoDiff / SILGen / differentiable_function . swift <nl> ppp b / test / AutoDiff / SILGen / differentiable_function . swift <nl> <nl> / / RUN : % target - swift - frontend - emit - silgen - enable - experimental - differentiable - programming % s | % FileCheck % s <nl> + / / REQUIRES : differentiable_programming <nl> <nl> / / Test SILGen for ` @ differentiable ` function typed values . <nl> <nl>
Merge pull request from davezarzycki / pr29434
apple/swift
8f3d2b27d10fc8390f1d364d2efa17a7e2cace05
2020-01-24T20:40:40Z
similarity index 94 % <nl> rename from Readme . md <nl> rename to README . md <nl> mmm a / Readme . md <nl> ppp b / README . md <nl> So you ' ve experimented with cmder a little and want to give it a shot in a more <nl> # # # Shortcut to open Cmder in a chosen folder <nl> <nl> 1 . Open a terminal as an Administrator <nl> - 1 . Navigate to the directory you have placed Cmder <nl> - 1 . Execute ` . \ cmder . exe / REGISTER ALL * ` <nl> + 2 . Navigate to the directory you have placed Cmder <nl> + 3 . Execute ` . \ cmder . exe / REGISTER ALL ` <nl> + _If you get a message " Access Denied " ensure you are executing the command in an * * Administrator * * prompt . _ <nl> <nl> In a file explorer window right click in or on a directory to see " Cmder Here " in the context menu . <nl> <nl> - * If you get a message " Access Denied " ensure you are executing the command in an Administrator prompt . <nl> - <nl> # # Keyboard shortcuts <nl> <nl> # # # Tab manipulation <nl>
Fixes ambigius about notice and parameter
cmderdev/cmder
5b9166504093f9d6efb3fbbd81f5f3036e1eb3e6
2014-10-23T16:45:54Z
mmm a / src / citra / citra . cpp <nl> ppp b / src / citra / citra . cpp <nl> int main ( int argc , char * * argv ) { <nl> break ; / / Expected case <nl> } <nl> <nl> + Core : : Telemetry ( ) . AddField ( Telemetry : : FieldType : : App , " Frontend " , " SDL " ) ; <nl> + <nl> while ( emu_window - > IsOpen ( ) ) { <nl> system . RunLoop ( ) ; <nl> } <nl> mmm a / src / citra / config . cpp <nl> ppp b / src / citra / config . cpp <nl> void Config : : ReadValues ( ) { <nl> static_cast < u16 > ( sdl2_config - > GetInteger ( " Debugging " , " gdbstub_port " , 24689 ) ) ; <nl> <nl> / / Web Service <nl> + Settings : : values . enable_telemetry = <nl> + sdl2_config - > GetBoolean ( " WebService " , " enable_telemetry " , true ) ; <nl> Settings : : values . telemetry_endpoint_url = sdl2_config - > Get ( <nl> " WebService " , " telemetry_endpoint_url " , " https : / / services . citra - emu . org / api / telemetry " ) ; <nl> + Settings : : values . citra_username = sdl2_config - > Get ( " WebService " , " citra_username " , " " ) ; <nl> + Settings : : values . citra_token = sdl2_config - > Get ( " WebService " , " citra_token " , " " ) ; <nl> } <nl> <nl> void Config : : Reload ( ) { <nl> mmm a / src / citra / default_ini . h <nl> ppp b / src / citra / default_ini . h <nl> use_gdbstub = false <nl> gdbstub_port = 24689 <nl> <nl> [ WebService ] <nl> + # Whether or not to enable telemetry <nl> + # 0 : No , 1 ( default ) : Yes <nl> + enable_telemetry = <nl> # Endpoint URL for submitting telemetry data <nl> - telemetry_endpoint_url = <nl> + telemetry_endpoint_url = https : / / services . citra - emu . org / api / telemetry <nl> + # Username and token for Citra Web Service <nl> + # See https : / / services . citra - emu . org / for more info <nl> + citra_username = <nl> + citra_token = <nl> ) " ; <nl> } <nl> mmm a / src / citra_qt / CMakeLists . txt <nl> ppp b / src / citra_qt / CMakeLists . txt <nl> set ( SRCS <nl> configuration / configure_graphics . cpp <nl> configuration / configure_input . cpp <nl> configuration / configure_system . cpp <nl> + configuration / configure_web . cpp <nl> debugger / graphics / graphics . cpp <nl> debugger / graphics / graphics_breakpoint_observer . cpp <nl> debugger / graphics / graphics_breakpoints . cpp <nl> set ( HEADERS <nl> configuration / configure_graphics . h <nl> configuration / configure_input . h <nl> configuration / configure_system . h <nl> + configuration / configure_web . h <nl> debugger / graphics / graphics . h <nl> debugger / graphics / graphics_breakpoint_observer . h <nl> debugger / graphics / graphics_breakpoints . h <nl> set ( UIS <nl> configuration / configure_graphics . ui <nl> configuration / configure_input . ui <nl> configuration / configure_system . ui <nl> + configuration / configure_web . ui <nl> debugger / registers . ui <nl> hotkeys . ui <nl> main . ui <nl> mmm a / src / citra_qt / configuration / config . cpp <nl> ppp b / src / citra_qt / configuration / config . cpp <nl> void Config : : ReadValues ( ) { <nl> qt_config - > endGroup ( ) ; <nl> <nl> qt_config - > beginGroup ( " WebService " ) ; <nl> + Settings : : values . enable_telemetry = qt_config - > value ( " enable_telemetry " , true ) . toBool ( ) ; <nl> Settings : : values . telemetry_endpoint_url = <nl> qt_config - > value ( " telemetry_endpoint_url " , " https : / / services . citra - emu . org / api / telemetry " ) <nl> . toString ( ) <nl> . toStdString ( ) ; <nl> + Settings : : values . citra_username = qt_config - > value ( " citra_username " ) . toString ( ) . toStdString ( ) ; <nl> + Settings : : values . citra_token = qt_config - > value ( " citra_token " ) . toString ( ) . toStdString ( ) ; <nl> qt_config - > endGroup ( ) ; <nl> <nl> qt_config - > beginGroup ( " UI " ) ; <nl> void Config : : ReadValues ( ) { <nl> UISettings : : values . show_status_bar = qt_config - > value ( " showStatusBar " , true ) . toBool ( ) ; <nl> UISettings : : values . confirm_before_closing = qt_config - > value ( " confirmClose " , true ) . toBool ( ) ; <nl> UISettings : : values . first_start = qt_config - > value ( " firstStart " , true ) . toBool ( ) ; <nl> + UISettings : : values . callout_flags = qt_config - > value ( " calloutFlags " , 0 ) . toUInt ( ) ; <nl> <nl> qt_config - > endGroup ( ) ; <nl> } <nl> void Config : : SaveValues ( ) { <nl> qt_config - > endGroup ( ) ; <nl> <nl> qt_config - > beginGroup ( " WebService " ) ; <nl> + qt_config - > setValue ( " enable_telemetry " , Settings : : values . enable_telemetry ) ; <nl> qt_config - > setValue ( " telemetry_endpoint_url " , <nl> QString : : fromStdString ( Settings : : values . telemetry_endpoint_url ) ) ; <nl> + qt_config - > setValue ( " citra_username " , QString : : fromStdString ( Settings : : values . citra_username ) ) ; <nl> + qt_config - > setValue ( " citra_token " , QString : : fromStdString ( Settings : : values . citra_token ) ) ; <nl> qt_config - > endGroup ( ) ; <nl> <nl> qt_config - > beginGroup ( " UI " ) ; <nl> void Config : : SaveValues ( ) { <nl> qt_config - > setValue ( " showStatusBar " , UISettings : : values . show_status_bar ) ; <nl> qt_config - > setValue ( " confirmClose " , UISettings : : values . confirm_before_closing ) ; <nl> qt_config - > setValue ( " firstStart " , UISettings : : values . first_start ) ; <nl> + qt_config - > setValue ( " calloutFlags " , UISettings : : values . callout_flags ) ; <nl> <nl> qt_config - > endGroup ( ) ; <nl> } <nl> mmm a / src / citra_qt / configuration / configure . ui <nl> ppp b / src / citra_qt / configuration / configure . ui <nl> <nl> < rect > <nl> < x > 0 < / x > <nl> < y > 0 < / y > <nl> - < width > 441 < / width > <nl> - < height > 501 < / height > <nl> + < width > 740 < / width > <nl> + < height > 500 < / height > <nl> < / rect > <nl> < / property > <nl> < property name = " windowTitle " > <nl> <nl> < string > Debug < / string > <nl> < / attribute > <nl> < / widget > <nl> + < widget class = " ConfigureWeb " name = " webTab " > <nl> + < attribute name = " title " > <nl> + < string > Web < / string > <nl> + < / attribute > <nl> + < / widget > <nl> < / widget > <nl> < / item > <nl> < item > <nl> <nl> < header > configuration / configure_graphics . h < / header > <nl> < container > 1 < / container > <nl> < / customwidget > <nl> + < customwidget > <nl> + < class > ConfigureWeb < / class > <nl> + < extends > QWidget < / extends > <nl> + < header > configuration / configure_web . h < / header > <nl> + < container > 1 < / container > <nl> + < / customwidget > <nl> < / customwidgets > <nl> < resources / > <nl> < connections > <nl> mmm a / src / citra_qt / configuration / configure_dialog . cpp <nl> ppp b / src / citra_qt / configuration / configure_dialog . cpp <nl> void ConfigureDialog : : applyConfiguration ( ) { <nl> ui - > graphicsTab - > applyConfiguration ( ) ; <nl> ui - > audioTab - > applyConfiguration ( ) ; <nl> ui - > debugTab - > applyConfiguration ( ) ; <nl> + ui - > webTab - > applyConfiguration ( ) ; <nl> Settings : : Apply ( ) ; <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 8715fb0181e <nl> mmm / dev / null <nl> ppp b / src / citra_qt / configuration / configure_web . cpp <nl> <nl> + / / Copyright 2017 Citra Emulator Project <nl> + / / Licensed under GPLv2 or any later version <nl> + / / Refer to the license . txt file included . <nl> + <nl> + # include " citra_qt / configuration / configure_web . h " <nl> + # include " core / settings . h " <nl> + # include " core / telemetry_session . h " <nl> + # include " ui_configure_web . h " <nl> + <nl> + ConfigureWeb : : ConfigureWeb ( QWidget * parent ) <nl> + : QWidget ( parent ) , ui ( std : : make_unique < Ui : : ConfigureWeb > ( ) ) { <nl> + ui - > setupUi ( this ) ; <nl> + connect ( ui - > button_regenerate_telemetry_id , & QPushButton : : clicked , this , <nl> + & ConfigureWeb : : refreshTelemetryID ) ; <nl> + <nl> + this - > setConfiguration ( ) ; <nl> + } <nl> + <nl> + ConfigureWeb : : ~ ConfigureWeb ( ) { } <nl> + <nl> + void ConfigureWeb : : setConfiguration ( ) { <nl> + ui - > web_credentials_disclaimer - > setWordWrap ( true ) ; <nl> + ui - > telemetry_learn_more - > setOpenExternalLinks ( true ) ; <nl> + ui - > telemetry_learn_more - > setText ( " < a " <nl> + " href = ' https : / / citra - emu . org / entry / " <nl> + " telemetry - and - why - thats - a - good - thing / ' > Learn more < / a > " ) ; <nl> + <nl> + ui - > web_signup_link - > setOpenExternalLinks ( true ) ; <nl> + ui - > web_signup_link - > setText ( " < a href = ' https : / / services . citra - emu . org / ' > Sign up < / a > " ) ; <nl> + ui - > web_token_info_link - > setOpenExternalLinks ( true ) ; <nl> + ui - > web_token_info_link - > setText ( <nl> + " < a href = ' https : / / citra - emu . org / wiki / citra - web - service / ' > What is my token ? < / a > " ) ; <nl> + <nl> + ui - > toggle_telemetry - > setChecked ( Settings : : values . enable_telemetry ) ; <nl> + ui - > edit_username - > setText ( QString : : fromStdString ( Settings : : values . citra_username ) ) ; <nl> + ui - > edit_token - > setText ( QString : : fromStdString ( Settings : : values . citra_token ) ) ; <nl> + ui - > label_telemetry_id - > setText ( " Telemetry ID : 0x " + <nl> + QString : : number ( Core : : GetTelemetryId ( ) , 16 ) . toUpper ( ) ) ; <nl> + } <nl> + <nl> + void ConfigureWeb : : applyConfiguration ( ) { <nl> + Settings : : values . enable_telemetry = ui - > toggle_telemetry - > isChecked ( ) ; <nl> + Settings : : values . citra_username = ui - > edit_username - > text ( ) . toStdString ( ) ; <nl> + Settings : : values . citra_token = ui - > edit_token - > text ( ) . toStdString ( ) ; <nl> + Settings : : Apply ( ) ; <nl> + } <nl> + <nl> + void ConfigureWeb : : refreshTelemetryID ( ) { <nl> + const u64 new_telemetry_id { Core : : RegenerateTelemetryId ( ) } ; <nl> + ui - > label_telemetry_id - > setText ( " Telemetry ID : 0x " + <nl> + QString : : number ( new_telemetry_id , 16 ) . toUpper ( ) ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 20bc254b909 <nl> mmm / dev / null <nl> ppp b / src / citra_qt / configuration / configure_web . h <nl> <nl> + / / Copyright 2017 Citra Emulator Project <nl> + / / Licensed under GPLv2 or any later version <nl> + / / Refer to the license . txt file included . <nl> + <nl> + # pragma once <nl> + <nl> + # include < memory > <nl> + # include < QWidget > <nl> + <nl> + namespace Ui { <nl> + class ConfigureWeb ; <nl> + } <nl> + <nl> + class ConfigureWeb : public QWidget { <nl> + Q_OBJECT <nl> + <nl> + public : <nl> + explicit ConfigureWeb ( QWidget * parent = nullptr ) ; <nl> + ~ ConfigureWeb ( ) ; <nl> + <nl> + void applyConfiguration ( ) ; <nl> + <nl> + public slots : <nl> + void refreshTelemetryID ( ) ; <nl> + <nl> + private : <nl> + void setConfiguration ( ) ; <nl> + <nl> + std : : unique_ptr < Ui : : ConfigureWeb > ui ; <nl> + } ; <nl> new file mode 100644 <nl> index 00000000000 . . d8d283fad4b <nl> mmm / dev / null <nl> ppp b / src / citra_qt / configuration / configure_web . ui <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> + < ui version = " 4 . 0 " > <nl> + < class > ConfigureWeb < / class > <nl> + < widget class = " QWidget " name = " ConfigureWeb " > <nl> + < property name = " geometry " > <nl> + < rect > <nl> + < x > 0 < / x > <nl> + < y > 0 < / y > <nl> + < width > 400 < / width > <nl> + < height > 300 < / height > <nl> + < / rect > <nl> + < / property > <nl> + < property name = " windowTitle " > <nl> + < string > Form < / string > <nl> + < / property > <nl> + < layout class = " QVBoxLayout " name = " verticalLayout " > <nl> + < item > <nl> + < layout class = " QVBoxLayout " name = " verticalLayout_3 " > <nl> + < item > <nl> + < widget class = " QGroupBox " name = " groupBoxWebConfig " > <nl> + < property name = " title " > <nl> + < string > Citra Web Service < / string > <nl> + < / property > <nl> + < layout class = " QVBoxLayout " name = " verticalLayoutCitraWebService " > <nl> + < item > <nl> + < widget class = " QLabel " name = " web_credentials_disclaimer " > <nl> + < property name = " text " > <nl> + < string > By providing your username and token , you agree to allow Citra to collect additional usage data , which may include user identifying information . < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item > <nl> + < layout class = " QGridLayout " name = " gridLayoutCitraUsername " > <nl> + < item row = " 0 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_username " > <nl> + < property name = " text " > <nl> + < string > Username : < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 0 " column = " 1 " > <nl> + < widget class = " QLineEdit " name = " edit_username " > <nl> + < property name = " maxLength " > <nl> + < number > 36 < / number > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 1 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_token " > <nl> + < property name = " text " > <nl> + < string > Token : < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 1 " column = " 1 " > <nl> + < widget class = " QLineEdit " name = " edit_token " > <nl> + < property name = " maxLength " > <nl> + < number > 36 < / number > <nl> + < / property > <nl> + < property name = " echoMode " > <nl> + < enum > QLineEdit : : Password < / enum > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 2 " column = " 0 " > <nl> + < widget class = " QLabel " name = " web_signup_link " > <nl> + < property name = " text " > <nl> + < string > Sign up < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 2 " column = " 1 " > <nl> + < widget class = " QLabel " name = " web_token_info_link " > <nl> + < property name = " text " > <nl> + < string > What is my token ? < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < / layout > <nl> + < / item > <nl> + < / layout > <nl> + < / widget > <nl> + < / item > <nl> + < item > <nl> + < widget class = " QGroupBox " name = " groupBox " > <nl> + < property name = " title " > <nl> + < string > Telemetry < / string > <nl> + < / property > <nl> + < layout class = " QVBoxLayout " name = " verticalLayout_2 " > <nl> + < item > <nl> + < widget class = " QCheckBox " name = " toggle_telemetry " > <nl> + < property name = " text " > <nl> + < string > Share anonymous usage data with the Citra team < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item > <nl> + < widget class = " QLabel " name = " telemetry_learn_more " > <nl> + < property name = " text " > <nl> + < string > Learn more < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item > <nl> + < layout class = " QGridLayout " name = " gridLayoutTelemetryId " > <nl> + < item row = " 0 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_telemetry_id " > <nl> + < property name = " text " > <nl> + < string > Telemetry ID : < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 0 " column = " 1 " > <nl> + < widget class = " QPushButton " name = " button_regenerate_telemetry_id " > <nl> + < property name = " sizePolicy " > <nl> + < sizepolicy hsizetype = " Fixed " vsizetype = " Fixed " > <nl> + < horstretch > 0 < / horstretch > <nl> + < verstretch > 0 < / verstretch > <nl> + < / sizepolicy > <nl> + < / property > <nl> + < property name = " layoutDirection " > <nl> + < enum > Qt : : RightToLeft < / enum > <nl> + < / property > <nl> + < property name = " text " > <nl> + < string > Regenerate < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < / layout > <nl> + < / item > <nl> + < / layout > <nl> + < / widget > <nl> + < / item > <nl> + < / layout > <nl> + < / item > <nl> + < item > <nl> + < spacer name = " verticalSpacer " > <nl> + < property name = " orientation " > <nl> + < enum > Qt : : Vertical < / enum > <nl> + < / property > <nl> + < property name = " sizeHint " stdset = " 0 " > <nl> + < size > <nl> + < width > 20 < / width > <nl> + < height > 40 < / height > <nl> + < / size > <nl> + < / property > <nl> + < / spacer > <nl> + < / item > <nl> + < / layout > <nl> + < / widget > <nl> + < resources / > <nl> + < connections / > <nl> + < / ui > <nl> mmm a / src / citra_qt / main . cpp <nl> ppp b / src / citra_qt / main . cpp <nl> <nl> Q_IMPORT_PLUGIN ( QWindowsIntegrationPlugin ) ; <nl> # endif <nl> <nl> + / * * <nl> + * " Callouts " are one - time instructional messages shown to the user . In the config settings , there <nl> + * is a bitfield " callout_flags " options , used to track if a message has already been shown to the <nl> + * user . This is 32 - bits - if we have more than 32 callouts , we should retire and recyle old ones . <nl> + * / <nl> + enum class CalloutFlag : uint32_t { <nl> + Telemetry = 0x1 , <nl> + } ; <nl> + <nl> + static void ShowCalloutMessage ( const QString & message , CalloutFlag flag ) { <nl> + if ( UISettings : : values . callout_flags & static_cast < uint32_t > ( flag ) ) { <nl> + return ; <nl> + } <nl> + <nl> + UISettings : : values . callout_flags | = static_cast < uint32_t > ( flag ) ; <nl> + <nl> + QMessageBox msg ; <nl> + msg . setText ( message ) ; <nl> + msg . setStandardButtons ( QMessageBox : : Ok ) ; <nl> + msg . setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Expanding ) ; <nl> + msg . setStyleSheet ( " QLabel { min - width : 900px ; } " ) ; <nl> + msg . exec ( ) ; <nl> + } <nl> + <nl> + void GMainWindow : : ShowCallouts ( ) { <nl> + static const QString telemetry_message = <nl> + tr ( " To help improve Citra , the Citra Team collects anonymous usage data . No private or " <nl> + " personally identifying information is collected . This data helps us to understand how " <nl> + " people use Citra and prioritize our efforts . Furthermore , it helps us to more easily " <nl> + " identify emulation bugs and performance issues . This data includes : < ul > < li > Information " <nl> + " about the version of Citra you are using < / li > < li > Performance data about the games you " <nl> + " play < / li > < li > Your configuration settings < / li > < li > Information about your computer " <nl> + " hardware < / li > < li > Emulation errors and crash information < / li > < / ul > By default , this " <nl> + " feature is enabled . To disable this feature , click ' Emulation ' from the menu and then " <nl> + " select ' Configure . . . ' . Then , on the ' Web ' tab , uncheck ' Share anonymous usage data with " <nl> + " the Citra team ' . < br / > < br / > By using this software , you agree to the above terms . < br / > " <nl> + " < br / > < a href = ' https : / / citra - emu . org / entry / telemetry - and - why - thats - a - good - thing / ' > Learn " <nl> + " more < / a > " ) ; <nl> + ShowCalloutMessage ( telemetry_message , CalloutFlag : : Telemetry ) ; <nl> + } <nl> + <nl> GMainWindow : : GMainWindow ( ) : config ( new Config ( ) ) , emu_thread ( nullptr ) { <nl> Pica : : g_debug_context = Pica : : DebugContext : : Construct ( ) ; <nl> setAcceptDrops ( true ) ; <nl> GMainWindow : : GMainWindow ( ) : config ( new Config ( ) ) , emu_thread ( nullptr ) { <nl> <nl> UpdateUITheme ( ) ; <nl> <nl> + / / Show one - time " callout " messages to the user <nl> + ShowCallouts ( ) ; <nl> + <nl> QStringList args = QApplication : : arguments ( ) ; <nl> if ( args . length ( ) > = 2 ) { <nl> BootGame ( args [ 1 ] ) ; <nl> bool GMainWindow : : LoadROM ( const QString & filename ) { <nl> <nl> const Core : : System : : ResultStatus result { system . Load ( render_window , filename . toStdString ( ) ) } ; <nl> <nl> + Core : : Telemetry ( ) . AddField ( Telemetry : : FieldType : : App , " Frontend " , " Qt " ) ; <nl> + <nl> if ( result ! = Core : : System : : ResultStatus : : Success ) { <nl> switch ( result ) { <nl> case Core : : System : : ResultStatus : : ErrorGetLoader : <nl> mmm a / src / citra_qt / main . h <nl> ppp b / src / citra_qt / main . h <nl> class GMainWindow : public QMainWindow { <nl> void BootGame ( const QString & filename ) ; <nl> void ShutdownGame ( ) ; <nl> <nl> + void ShowCallouts ( ) ; <nl> + <nl> / * * <nl> * Stores the filename in the recently loaded files list . <nl> * The new filename is stored at the beginning of the recently loaded files list . <nl> mmm a / src / citra_qt / ui_settings . h <nl> ppp b / src / citra_qt / ui_settings . h <nl> struct Values { <nl> <nl> / / Shortcut name < Shortcut , context > <nl> std : : vector < Shortcut > shortcuts ; <nl> + <nl> + uint32_t callout_flags ; <nl> } ; <nl> <nl> extern Values values ; <nl> mmm a / src / core / settings . h <nl> ppp b / src / core / settings . h <nl> struct Values { <nl> u16 gdbstub_port ; <nl> <nl> / / WebService <nl> + bool enable_telemetry ; <nl> std : : string telemetry_endpoint_url ; <nl> + std : : string citra_username ; <nl> + std : : string citra_token ; <nl> } extern values ; <nl> <nl> / / a special value for Values : : region_value indicating that citra will automatically select a region <nl> mmm a / src / core / telemetry_session . cpp <nl> ppp b / src / core / telemetry_session . cpp <nl> <nl> / / Refer to the license . txt file included . <nl> <nl> # include < cstring > <nl> + # include < cryptopp / osrng . h > <nl> <nl> # include " common / assert . h " <nl> + # include " common / file_util . h " <nl> # include " common / scm_rev . h " <nl> # include " common / x64 / cpu_detect . h " <nl> # include " core / core . h " <nl> static const char * CpuVendorToStr ( Common : : CPUVendor vendor ) { <nl> UNREACHABLE ( ) ; <nl> } <nl> <nl> + static u64 GenerateTelemetryId ( ) { <nl> + u64 telemetry_id { } ; <nl> + CryptoPP : : AutoSeededRandomPool rng ; <nl> + rng . GenerateBlock ( reinterpret_cast < CryptoPP : : byte * > ( & telemetry_id ) , sizeof ( u64 ) ) ; <nl> + return telemetry_id ; <nl> + } <nl> + <nl> + u64 GetTelemetryId ( ) { <nl> + u64 telemetry_id { } ; <nl> + static const std : : string & filename { FileUtil : : GetUserPath ( D_CONFIG_IDX ) + " telemetry_id " } ; <nl> + <nl> + if ( FileUtil : : Exists ( filename ) ) { <nl> + FileUtil : : IOFile file ( filename , " rb " ) ; <nl> + if ( ! file . IsOpen ( ) ) { <nl> + LOG_ERROR ( Core , " failed to open telemetry_id : % s " , filename . c_str ( ) ) ; <nl> + return { } ; <nl> + } <nl> + file . ReadBytes ( & telemetry_id , sizeof ( u64 ) ) ; <nl> + } else { <nl> + FileUtil : : IOFile file ( filename , " wb " ) ; <nl> + if ( ! file . IsOpen ( ) ) { <nl> + LOG_ERROR ( Core , " failed to open telemetry_id : % s " , filename . c_str ( ) ) ; <nl> + return { } ; <nl> + } <nl> + telemetry_id = GenerateTelemetryId ( ) ; <nl> + file . WriteBytes ( & telemetry_id , sizeof ( u64 ) ) ; <nl> + } <nl> + <nl> + return telemetry_id ; <nl> + } <nl> + <nl> + u64 RegenerateTelemetryId ( ) { <nl> + const u64 new_telemetry_id { GenerateTelemetryId ( ) } ; <nl> + static const std : : string & filename { FileUtil : : GetUserPath ( D_CONFIG_IDX ) + " telemetry_id " } ; <nl> + <nl> + FileUtil : : IOFile file ( filename , " wb " ) ; <nl> + if ( ! file . IsOpen ( ) ) { <nl> + LOG_ERROR ( Core , " failed to open telemetry_id : % s " , filename . c_str ( ) ) ; <nl> + return { } ; <nl> + } <nl> + file . WriteBytes ( & new_telemetry_id , sizeof ( u64 ) ) ; <nl> + return new_telemetry_id ; <nl> + } <nl> + <nl> TelemetrySession : : TelemetrySession ( ) { <nl> # ifdef ENABLE_WEB_SERVICE <nl> - backend = std : : make_unique < WebService : : TelemetryJson > ( ) ; <nl> + if ( Settings : : values . enable_telemetry ) { <nl> + backend = std : : make_unique < WebService : : TelemetryJson > ( <nl> + Settings : : values . telemetry_endpoint_url , Settings : : values . citra_username , <nl> + Settings : : values . citra_token ) ; <nl> + } else { <nl> + backend = std : : make_unique < Telemetry : : NullVisitor > ( ) ; <nl> + } <nl> # else <nl> backend = std : : make_unique < Telemetry : : NullVisitor > ( ) ; <nl> # endif <nl> + / / Log one - time top - level information <nl> + AddField ( Telemetry : : FieldType : : None , " TelemetryId " , GetTelemetryId ( ) ) ; <nl> + <nl> / / Log one - time session start information <nl> const s64 init_time { std : : chrono : : duration_cast < std : : chrono : : milliseconds > ( <nl> std : : chrono : : system_clock : : now ( ) . time_since_epoch ( ) ) <nl> mmm a / src / core / telemetry_session . h <nl> ppp b / src / core / telemetry_session . h <nl> class TelemetrySession : NonCopyable { <nl> std : : unique_ptr < Telemetry : : VisitorInterface > backend ; / / / < Backend interface that logs fields <nl> } ; <nl> <nl> + / * * <nl> + * Gets TelemetryId , a unique identifier used for the user ' s telemetry sessions . <nl> + * @ returns The current TelemetryId for the session . <nl> + * / <nl> + u64 GetTelemetryId ( ) ; <nl> + <nl> + / * * <nl> + * Regenerates TelemetryId , a unique identifier used for the user ' s telemetry sessions . <nl> + * @ returns The new TelemetryId that was generated . <nl> + * / <nl> + u64 RegenerateTelemetryId ( ) ; <nl> + <nl> } / / namespace Core <nl> mmm a / src / web_service / telemetry_json . cpp <nl> ppp b / src / web_service / telemetry_json . cpp <nl> <nl> / / Refer to the license . txt file included . <nl> <nl> # include " common / assert . h " <nl> - # include " core / settings . h " <nl> # include " web_service / telemetry_json . h " <nl> # include " web_service / web_backend . h " <nl> <nl> void TelemetryJson : : Complete ( ) { <nl> SerializeSection ( Telemetry : : FieldType : : UserFeedback , " UserFeedback " ) ; <nl> SerializeSection ( Telemetry : : FieldType : : UserConfig , " UserConfig " ) ; <nl> SerializeSection ( Telemetry : : FieldType : : UserSystem , " UserSystem " ) ; <nl> - PostJson ( Settings : : values . telemetry_endpoint_url , TopSection ( ) . dump ( ) ) ; <nl> + PostJson ( endpoint_url , TopSection ( ) . dump ( ) , true , username , token ) ; <nl> } <nl> <nl> } / / namespace WebService <nl> mmm a / src / web_service / telemetry_json . h <nl> ppp b / src / web_service / telemetry_json . h <nl> namespace WebService { <nl> * / <nl> class TelemetryJson : public Telemetry : : VisitorInterface { <nl> public : <nl> - TelemetryJson ( ) = default ; <nl> + TelemetryJson ( const std : : string & endpoint_url , const std : : string & username , <nl> + const std : : string & token ) <nl> + : endpoint_url ( endpoint_url ) , username ( username ) , token ( token ) { } <nl> ~ TelemetryJson ( ) = default ; <nl> <nl> void Visit ( const Telemetry : : Field < bool > & field ) override ; <nl> class TelemetryJson : public Telemetry : : VisitorInterface { <nl> <nl> nlohmann : : json output ; <nl> std : : array < nlohmann : : json , 7 > sections ; <nl> + std : : string endpoint_url ; <nl> + std : : string username ; <nl> + std : : string token ; <nl> } ; <nl> <nl> } / / namespace WebService <nl> mmm a / src / web_service / web_backend . cpp <nl> ppp b / src / web_service / web_backend . cpp <nl> <nl> / / Licensed under GPLv2 or any later version <nl> / / Refer to the license . txt file included . <nl> <nl> + # ifdef _WIN32 <nl> + # include < winsock . h > <nl> + # endif <nl> + <nl> + # include < cstdlib > <nl> + # include < thread > <nl> # include < cpr / cpr . h > <nl> - # include < stdlib . h > <nl> # include " common / logging / log . h " <nl> # include " web_service / web_backend . h " <nl> <nl> namespace WebService { <nl> <nl> static constexpr char API_VERSION [ ] { " 1 " } ; <nl> - static constexpr char ENV_VAR_USERNAME [ ] { " CITRA_WEB_SERVICES_USERNAME " } ; <nl> - static constexpr char ENV_VAR_TOKEN [ ] { " CITRA_WEB_SERVICES_TOKEN " } ; <nl> - <nl> - static std : : string GetEnvironmentVariable ( const char * name ) { <nl> - const char * value { getenv ( name ) } ; <nl> - if ( value ) { <nl> - return value ; <nl> - } <nl> - return { } ; <nl> - } <nl> - <nl> - const std : : string & GetUsername ( ) { <nl> - static const std : : string username { GetEnvironmentVariable ( ENV_VAR_USERNAME ) } ; <nl> - return username ; <nl> - } <nl> <nl> - const std : : string & GetToken ( ) { <nl> - static const std : : string token { GetEnvironmentVariable ( ENV_VAR_TOKEN ) } ; <nl> - return token ; <nl> - } <nl> + static std : : unique_ptr < cpr : : Session > g_session ; <nl> <nl> - void PostJson ( const std : : string & url , const std : : string & data ) { <nl> + void PostJson ( const std : : string & url , const std : : string & data , bool allow_anonymous , <nl> + const std : : string & username , const std : : string & token ) { <nl> if ( url . empty ( ) ) { <nl> LOG_ERROR ( WebService , " URL is invalid " ) ; <nl> return ; <nl> } <nl> <nl> - if ( GetUsername ( ) . empty ( ) | | GetToken ( ) . empty ( ) ) { <nl> - LOG_ERROR ( WebService , " Environment variables % s and % s must be set to POST JSON " , <nl> - ENV_VAR_USERNAME , ENV_VAR_TOKEN ) ; <nl> + const bool are_credentials_provided { ! token . empty ( ) & & ! username . empty ( ) } ; <nl> + if ( ! allow_anonymous & & ! are_credentials_provided ) { <nl> + LOG_ERROR ( WebService , " Credentials must be provided for authenticated requests " ) ; <nl> return ; <nl> } <nl> <nl> - cpr : : PostAsync ( cpr : : Url { url } , cpr : : Body { data } , cpr : : Header { { " Content - Type " , " application / json " } , <nl> - { " x - username " , GetUsername ( ) } , <nl> - { " x - token " , GetToken ( ) } , <nl> - { " api - version " , API_VERSION } } ) ; <nl> + # ifdef _WIN32 <nl> + / / On Windows , CPR / libcurl does not properly initialize Winsock . The below code is used to <nl> + / / initialize Winsock globally , which fixes this problem . Without this , only the first CPR <nl> + / / session will properly be created , and subsequent ones will fail . <nl> + WSADATA wsa_data ; <nl> + const int wsa_result { WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsa_data ) } ; <nl> + if ( wsa_result ) { <nl> + LOG_CRITICAL ( WebService , " WSAStartup failed : % d " , wsa_result ) ; <nl> + } <nl> + # endif <nl> + <nl> + / / Built request header <nl> + cpr : : Header header ; <nl> + if ( are_credentials_provided ) { <nl> + / / Authenticated request if credentials are provided <nl> + header = { { " Content - Type " , " application / json " } , <nl> + { " x - username " , username . c_str ( ) } , <nl> + { " x - token " , token . c_str ( ) } , <nl> + { " api - version " , API_VERSION } } ; <nl> + } else { <nl> + / / Otherwise , anonymous request <nl> + header = cpr : : Header { { " Content - Type " , " application / json " } , { " api - version " , API_VERSION } } ; <nl> + } <nl> + <nl> + / / Post JSON asynchronously <nl> + static cpr : : AsyncResponse future ; <nl> + future = cpr : : PostAsync ( cpr : : Url { url . c_str ( ) } , cpr : : Body { data . c_str ( ) } , header ) ; <nl> } <nl> <nl> } / / namespace WebService <nl> mmm a / src / web_service / web_backend . h <nl> ppp b / src / web_service / web_backend . h <nl> <nl> <nl> namespace WebService { <nl> <nl> - / * * <nl> - * Gets the current username for accessing services . citra - emu . org . <nl> - * @ returns Username as a string , empty if not set . <nl> - * / <nl> - const std : : string & GetUsername ( ) ; <nl> - <nl> - / * * <nl> - * Gets the current token for accessing services . citra - emu . org . <nl> - * @ returns Token as a string , empty if not set . <nl> - * / <nl> - const std : : string & GetToken ( ) ; <nl> - <nl> / * * <nl> * Posts JSON to services . citra - emu . org . <nl> * @ param url URL of the services . citra - emu . org endpoint to post data to . <nl> * @ param data String of JSON data to use for the body of the POST request . <nl> + * @ param allow_anonymous If true , allow anonymous unauthenticated requests . <nl> + * @ param username Citra username to use for authentication . <nl> + * @ param token Citra token to use for authentication . <nl> * / <nl> - void PostJson ( const std : : string & url , const std : : string & data ) ; <nl> + void PostJson ( const std : : string & url , const std : : string & data , bool allow_anonymous , <nl> + const std : : string & username = { } , const std : : string & token = { } ) ; <nl> <nl> } / / namespace WebService <nl>
Merge pull request from bunnei / telemetry - ui
yuzu-emu/yuzu
22fc378fe9f3314b08d81ffaaf57fd8688e9e3cc
2017-08-27T00:15:15Z
mmm a / xbmc / CueDocument . cpp <nl> ppp b / xbmc / CueDocument . cpp <nl> CStdString CCueDocument : : GetMediaTitle ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> bool CCueDocument : : ReadNextLine ( CStdString & szLine ) <nl> { <nl> - char * pos ; <nl> / / Read the next line . <nl> while ( m_file . ReadString ( m_szBuffer , 1023 ) ) / / Bigger than MAX_PATH_SIZE , for usage with relax ! <nl> { <nl> - / / Remove the white space at the beginning of the line . <nl> - pos = m_szBuffer ; <nl> - while ( pos & & ( * pos = = ' ' | | * pos = = ' \ t ' | | * pos = = ' \ r ' | | * pos = = ' \ n ' ) ) pos + + ; <nl> - if ( pos ) <nl> - { <nl> - szLine = pos ; <nl> + / / Remove the white space at the beginning and end of the line . <nl> + szLine = m_szBuffer ; <nl> + szLine . Trim ( ) ; <nl> + if ( ! szLine . empty ( ) ) <nl> return true ; <nl> - } <nl> / / If we are here , we have an empty line so try the next line <nl> } <nl> return false ; <nl>
remove whitespace from the end of lines in . cue sheet documents . fixes issues with Genres popping up with carriage returns at the end of the line .
xbmc/xbmc
3a9e3a5240525544833e8a9d56ee62aa385130bd
2012-11-06T23:13:03Z
mmm a / tensorflow / python / client / tf_session_helper . cc <nl> ppp b / tensorflow / python / client / tf_session_helper . cc <nl> Status TFTensorToPyArray ( Safe_TF_TensorPtr tensor , PyObject * * out_ndarray ) { <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> - / / Converts the given numpy ndarray to a ( safe ) TF_Tensor . If ` ndarray ` contains <nl> - / / a resource handle , ` * resource_handle ` will be set to the deserialized <nl> - / / handle . Otherwise it is set to nullptr . ` resource_handle ` and ` out_tensor ` <nl> - / / must be non - null . Caller retains ownership of ` ndarray ` and becomes owner of <nl> - / / ` * resource_handle ` if it ' s set . <nl> + / / Converts the given numpy ndarray to a ( safe ) TF_Tensor . <nl> + / / <nl> + / / If ` ndarray ` contains a resource handle , ` * resource_handle ` will be set to <nl> + / / the deserialized handle . Otherwise it is set to nullptr . Caller becomes owner <nl> + / / of ` * resource_handle ` if it ' s set , and it must outlive the returned <nl> + / / ` out_tensor ` . <nl> + / / <nl> + / / ` resource_handle ` and ` out_tensor ` must be non - null . Caller retains ownership <nl> + / / of ` ndarray ` . <nl> Status PyArrayToTFTensor ( PyObject * ndarray , Safe_TF_TensorPtr * out_tensor , <nl> ResourceHandle * * resource_handle ) { <nl> DCHECK ( out_tensor ! = nullptr ) ; <nl> void TF_Run_wrapper_helper ( TF_DeprecatedSession * session , const char * handle , <nl> int index = 0 ; <nl> Status s ; <nl> <nl> - gtl : : InlinedVector < std : : shared_ptr < ResourceHandle > , 4 > resource_handles ; <nl> + gtl : : InlinedVector < std : : unique_ptr < ResourceHandle > , 4 > resource_handles ; <nl> while ( PyDict_Next ( feed_dict , & pos , & key , & value ) ) { <nl> char * key_string = PyBytes_AsString ( key ) ; <nl> if ( ! key_string ) { <nl> void TF_Run_wrapper_helper ( TF_DeprecatedSession * session , const char * handle , <nl> inputs_safe . emplace_back ( make_safe ( static_cast < TF_Tensor * > ( nullptr ) ) ) ; <nl> ResourceHandle * resource_handle ; <nl> s = PyArrayToTFTensor ( value , & inputs_safe . back ( ) , & resource_handle ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + Set_TF_Status_from_Status ( out_status , s ) ; <nl> + return ; <nl> + } <nl> inputs_unsafe . push_back ( inputs_safe . back ( ) . get ( ) ) ; <nl> if ( resource_handle ! = nullptr ) { <nl> resource_handles . emplace_back ( resource_handle ) ; <nl>
A few more tf_session_helper . cc tweaks
tensorflow/tensorflow
448c7562f38e36924d40dd1d4dfdf8714d77f146
2017-05-20T01:16:02Z
mmm a / lib / Sema / CSSimplify . cpp <nl> ppp b / lib / Sema / CSSimplify . cpp <nl> <nl> # include " swift / AST / ExistentialLayout . h " <nl> # include " swift / AST / GenericEnvironment . h " <nl> # include " swift / AST / GenericSignature . h " <nl> + # include " swift / AST / Initializer . h " <nl> # include " swift / AST / ParameterList . h " <nl> # include " swift / AST / PropertyWrappers . h " <nl> # include " swift / AST / ProtocolConformance . h " <nl> performMemberLookup ( ConstraintKind constraintKind , DeclName memberName , <nl> / / reasonable choice . <nl> auto addChoice = [ & ] ( OverloadChoice candidate ) { <nl> auto decl = candidate . getDecl ( ) ; <nl> - <nl> + <nl> + / / In a pattern binding initializer , immediately reject all of its bound <nl> + / / variables . These would otherwise allow circular references . <nl> + if ( auto * PBI = dyn_cast < PatternBindingInitializer > ( DC ) ) { <nl> + if ( auto * VD = dyn_cast < VarDecl > ( decl ) ) { <nl> + if ( PBI - > getBinding ( ) = = VD - > getParentPatternBinding ( ) ) { <nl> + result . addUnviable ( candidate , <nl> + MemberLookupResult : : UR_InstanceMemberOnType ) ; <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + <nl> / / If the result is invalid , skip it . <nl> / / FIXME ( InterfaceTypeRequest ) : isInvalid ( ) should be based on the interface type . <nl> ( void ) decl - > getInterfaceType ( ) ; <nl> mmm a / test / NameBinding / name_lookup . swift <nl> ppp b / test / NameBinding / name_lookup . swift <nl> struct PatternBindingWithTwoVars1 { var x = 3 , y = x } <nl> / / expected - error @ - 1 { { cannot use instance member ' x ' within property initializer ; property initializers run before ' self ' is available } } <nl> <nl> struct PatternBindingWithTwoVars2 { var x = y , y = 3 } <nl> - / / expected - error @ - 1 { { type ' PatternBindingWithTwoVars2 ' has no member ' y ' } } <nl> + / / expected - error @ - 1 { { property ' y ' references itself } } <nl> + / / expected - error @ - 2 { { cannot use instance member ' y ' within property initializer ; property initializers run before ' self ' is available } } <nl> <nl> / / This one should be accepted , but for now PatternBindingDecl validation <nl> / / circularity detection is not fine grained enough . <nl> struct PatternBindingWithTwoVars3 { var x = y , y = x } <nl> - / / expected - error @ - 1 { { type ' PatternBindingWithTwoVars3 ' has no member ' y ' } } <nl> + / / expected - error @ - 1 { { cannot use instance member ' x ' within property initializer ; property initializers run before ' self ' is available } } <nl> + / / expected - error @ - 2 { { cannot use instance member ' y ' within property initializer ; property initializers run before ' self ' is available } } <nl> + / / expected - error @ - 3 { { property ' y ' references itself } } <nl> <nl> / / https : / / bugs . swift . org / browse / SR - 9015 <nl> func sr9015 ( ) { <nl> mmm a / test / decl / overload . swift <nl> ppp b / test / decl / overload . swift <nl> enum SR_10084_E_8 { <nl> } <nl> <nl> enum SR_10084_E_9 { <nl> - case A / / expected - note { { found this candidate } } / / expected - note { { ' A ' previously declared here } } <nl> - static let A : SR_10084_E_9 = . A / / expected - note { { found this candidate } } / / expected - error { { invalid redeclaration of ' A ' } } / / expected - error { { ambiguous use of ' A ' } } <nl> + case A / / expected - note { { ' A ' previously declared here } } <nl> + static let A : SR_10084_E_9 = . A / / expected - error { { invalid redeclaration of ' A ' } } <nl> } <nl> <nl> enum SR_10084_E_10 { <nl> - static let A : SR_10084_E_10 = . A / / expected - note { { found this candidate } } / / expected - note { { ' A ' previously declared here } } / / expected - error { { ambiguous use of ' A ' } } <nl> - case A / / expected - note { { found this candidate } } / / expected - error { { invalid redeclaration of ' A ' } } <nl> + static let A : SR_10084_E_10 = . A / / expected - note { { ' A ' previously declared here } } <nl> + case A / / expected - error { { invalid redeclaration of ' A ' } } <nl> } <nl> <nl> enum SR_10084_E_11 { <nl> - case A / / expected - note { { found this candidate } } / / expected - note { { ' A ' previously declared here } } <nl> - static var A : SR_10084_E_11 = . A / / expected - note { { found this candidate } } / / expected - error { { invalid redeclaration of ' A ' } } / / expected - error { { ambiguous use of ' A ' } } <nl> + case A / / expected - note { { ' A ' previously declared here } } <nl> + static var A : SR_10084_E_11 = . A / / expected - error { { invalid redeclaration of ' A ' } } <nl> } <nl> <nl> enum SR_10084_E_12 { <nl> - static var A : SR_10084_E_12 = . A / / expected - note { { found this candidate } } / / expected - note { { ' A ' previously declared here } } / / expected - error { { ambiguous use of ' A ' } } <nl> - case A / / expected - note { { found this candidate } } / / expected - error { { invalid redeclaration of ' A ' } } <nl> + static var A : SR_10084_E_12 = . A / / expected - note { { ' A ' previously declared here } } <nl> + case A / / expected - error { { invalid redeclaration of ' A ' } } <nl> } <nl> <nl> enum SR_10084_E_13 { <nl> enum SR_10084_E_16 { <nl> typealias Z = Int / / expected - note { { ' Z ' previously declared here } } <nl> case Z / / expected - error { { invalid redeclaration of ' Z ' } } <nl> } <nl> + <nl> + / / N . B . Validating the pattern binding initializer for ` raw ` used to cause <nl> + / / recursive validation of the VarDecl . Check that we don ' t regress now that <nl> + / / this isn ' t the case . <nl> + public struct Cyclic { <nl> + static func pickMe ( please : Bool ) - > Int { return 42 } <nl> + public static let pickMe = Cyclic . pickMe ( please : true ) <nl> + } <nl>
Strike VarDecls in Pattern Binding Initializers From Overloads
apple/swift
f15544de0b1cbb9cbcdbb1b5b83fd6fac008db79
2019-10-14T18:54:24Z
mmm a / Code / CryEngine / Cry3DEngine / 3dEngine . cpp <nl> ppp b / Code / CryEngine / Cry3DEngine / 3dEngine . cpp <nl> IRenderNode * C3DEngine : : CreateRenderNode ( EERType type ) <nl> <nl> void C3DEngine : : DeleteRenderNode ( IRenderNode * pRenderNode ) <nl> { <nl> + LOADING_TIME_PROFILE_SECTION_NAMED ( pRenderNode - > GetName ( ) ) ; <nl> UnRegisterEntityDirect ( pRenderNode ) ; <nl> delete pRenderNode ; <nl> } <nl> mmm a / Code / CryEngine / CryEntitySystem / Area . cpp <nl> ppp b / Code / CryEngine / CryEntitySystem / Area . cpp <nl> void CArea : : RemoveEntity ( EntityGUID const entGuid ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CArea : : RemoveEntities ( ) <nl> { <nl> + LOADING_TIME_PROFILE_SECTION <nl> / / Inform all attached entities that they have been disconnected to prevent lost entities . <nl> EntityIdVector const tmpVec ( std : : move ( m_entityIds ) ) ; <nl> EntityIdVector : : const_iterator Iter ( tmpVec . begin ( ) ) ; <nl>
! B ( Sandbox ) Level closing optimizations , in particular do not invalidate matrices when closing as this triggers a lot of unnecessary work ( Approved by samuelk )
CRYTEK/CRYENGINE
005e1b373c8f7175fd86b7cd8d0c29206c66793f
2017-05-11T09:35:49Z
mmm a / jstests / max_time_ms . js <nl> ppp b / jstests / max_time_ms . js <nl> assert . eq ( 0 , t . getDB ( ) . runCommand ( { ping : 1 , maxTimeMS : maxValue + 1 } ) . ok ) ; <nl> assert . eq ( 0 , t . getDB ( ) . runCommand ( { ping : 1 , maxTimeMS : NumberInt ( maxValue + 1 ) } ) . ok ) ; <nl> assert . eq ( 0 , t . getDB ( ) . runCommand ( { ping : 1 , maxTimeMS : NumberLong ( maxValue + 1 ) } ) . ok ) ; <nl> <nl> - / / Verify invalid types are rejected . <nl> + / / Verify invalid values are rejected . <nl> + assert . throws . automsg ( function ( ) { t . find ( ) . maxTimeMS ( 0 . 1 ) . itcount ( ) ; } ) ; <nl> + assert . throws . automsg ( function ( ) { t . find ( ) . maxTimeMS ( - 0 . 1 ) . itcount ( ) ; } ) ; <nl> assert . throws . automsg ( function ( ) { t . find ( ) . maxTimeMS ( ) . itcount ( ) ; } ) ; <nl> assert . throws . automsg ( function ( ) { t . find ( ) . maxTimeMS ( " " ) . itcount ( ) ; } ) ; <nl> assert . throws . automsg ( function ( ) { t . find ( ) . maxTimeMS ( true ) . itcount ( ) ; } ) ; <nl> assert . throws . automsg ( function ( ) { t . find ( ) . maxTimeMS ( { } ) . itcount ( ) ; } ) ; <nl> + assert . eq ( 0 , t . getDB ( ) . runCommand ( { ping : 1 , maxTimeMS : 0 . 1 } ) . ok ) ; <nl> + assert . eq ( 0 , t . getDB ( ) . runCommand ( { ping : 1 , maxTimeMS : - 0 . 1 } ) . ok ) ; <nl> assert . eq ( 0 , t . getDB ( ) . runCommand ( { ping : 1 , maxTimeMS : undefined } ) . ok ) ; <nl> assert . eq ( 0 , t . getDB ( ) . runCommand ( { ping : 1 , maxTimeMS : " " } ) . ok ) ; <nl> assert . eq ( 0 , t . getDB ( ) . runCommand ( { ping : 1 , maxTimeMS : true } ) . ok ) ; <nl> mmm a / src / mongo / db / query / lite_parsed_query . cpp <nl> ppp b / src / mongo / db / query / lite_parsed_query . cpp <nl> <nl> <nl> # include " mongo / db / query / lite_parsed_query . h " <nl> <nl> + # include < cmath > <nl> + <nl> # include " mongo / db / dbmessage . h " <nl> # include " mongo / util / assert_util . h " <nl> <nl> namespace mongo { <nl> < < maxTimeMSElt . fieldNameStringData ( ) <nl> < < " is out of range " ) . str ( ) ) ; <nl> } <nl> + double maxTimeMSDouble = maxTimeMSElt . numberDouble ( ) ; <nl> + if ( maxTimeMSElt . type ( ) = = mongo : : NumberDouble <nl> + & & floor ( maxTimeMSDouble ) ! = maxTimeMSDouble ) { <nl> + return StatusWith < int > ( ErrorCodes : : BadValue , <nl> + ( StringBuilder ( ) <nl> + < < maxTimeMSElt . fieldNameStringData ( ) <nl> + < < " has non - integral value " ) . str ( ) ) ; <nl> + } <nl> return StatusWith < int > ( static_cast < int > ( maxTimeMSLongLong ) ) ; <nl> } <nl> <nl>
SERVER - 11221 Reject non - integral values for max time
mongodb/mongo
c86a094c97b97de8b34f6bba66068df470ff4d10
2013-10-28T16:48:21Z
mmm a / python / pyphantomjs / phantom . py <nl> ppp b / python / pyphantomjs / phantom . py <nl> def exit ( self , code = 0 ) : <nl> self . m_terminated = True <nl> self . m_returnValue = code <nl> <nl> - # stop javascript execution in start script <nl> - # and delete all the pages C + + objects , <nl> - # then delete the Python references <nl> + # stop javascript execution in start script ; <nl> + # delete all the pages C + + objects , then clear <nl> + # the page list , and empty the Phantom page <nl> for page in self . m_pages : <nl> sip . delete ( page ) <nl> - del page <nl> - del self . m_page , self . m_pages <nl> + del self . m_pages [ : ] <nl> + self . m_page = None <nl> <nl> QApplication . instance ( ) . exit ( code ) <nl> <nl>
More efficient handling of exit ( ) deletion of pages
ariya/phantomjs
d12202f0a60769cd4aa6376ce4f951a1eac3657c
2011-07-03T00:26:06Z
mmm a / tests / test_benchmark . py <nl> ppp b / tests / test_benchmark . py <nl> def run ( self , args ) : <nl> return run_js ( self . filename , engine = self . engine , args = args , stderr = PIPE , full_output = True ) <nl> <nl> # Benchmarkers <nl> - benchmarkers = [ <nl> - # NativeBenchmarker ( ' clang ' , CLANG_CC , CLANG ) , <nl> - NativeBenchmarker ( ' clang - 3 . 2 ' , os . path . join ( LLVM_3_2 , ' clang ' ) , os . path . join ( LLVM_3_2 , ' clang + + ' ) ) , <nl> - # NativeBenchmarker ( ' clang - 3 . 3 ' , os . path . join ( LLVM_3_3 , ' clang ' ) , os . path . join ( LLVM_3_3 , ' clang + + ' ) ) , <nl> - # NativeBenchmarker ( ' clang - 3 . 4 ' , os . path . join ( LLVM_3_4 , ' clang ' ) , os . path . join ( LLVM_3_4 , ' clang + + ' ) ) , <nl> - # NativeBenchmarker ( ' gcc ' , ' gcc ' , ' g + + ' ) , <nl> - JSBenchmarker ( ' sm - f32 ' , SPIDERMONKEY_ENGINE , [ ' - s ' , ' PRECISE_F32 = 2 ' ] ) , <nl> - # JSBenchmarker ( ' sm - f32 - 3 . 2 ' , SPIDERMONKEY_ENGINE , [ ' - s ' , ' PRECISE_F32 = 2 ' ] , env = { ' LLVM ' : LLVM_3_2 } ) , <nl> - # JSBenchmarker ( ' sm - f32 - 3 . 3 ' , SPIDERMONKEY_ENGINE , [ ' - s ' , ' PRECISE_F32 = 2 ' ] , env = { ' LLVM ' : LLVM_3_3 } ) , <nl> - # JSBenchmarker ( ' sm - f32 - 3 . 4 ' , SPIDERMONKEY_ENGINE , [ ' - s ' , ' PRECISE_F32 = 2 ' ] , env = { ' LLVM ' : LLVM_3_4 } ) , <nl> - # JSBenchmarker ( ' sm - fc ' , SPIDERMONKEY_ENGINE , env = { ' EMCC_FAST_COMPILER ' : ' 1 ' } ) , <nl> - # JSBenchmarker ( ' sm - noasm ' , SPIDERMONKEY_ENGINE + [ ' - - no - asmjs ' ] ) , <nl> - # JSBenchmarker ( ' sm - noasm - f32 ' , SPIDERMONKEY_ENGINE + [ ' - - no - asmjs ' ] , [ ' - s ' , ' PRECISE_F32 = 2 ' ] ) , <nl> - # JSBenchmarker ( ' v8 ' , V8_ENGINE ) <nl> - ] <nl> + try : <nl> + benchmarkers_error = ' ' <nl> + benchmarkers = [ <nl> + # NativeBenchmarker ( ' clang ' , CLANG_CC , CLANG ) , <nl> + NativeBenchmarker ( ' clang - 3 . 2 ' , os . path . join ( LLVM_3_2 , ' clang ' ) , os . path . join ( LLVM_3_2 , ' clang + + ' ) ) , <nl> + # NativeBenchmarker ( ' clang - 3 . 3 ' , os . path . join ( LLVM_3_3 , ' clang ' ) , os . path . join ( LLVM_3_3 , ' clang + + ' ) ) , <nl> + # NativeBenchmarker ( ' clang - 3 . 4 ' , os . path . join ( LLVM_3_4 , ' clang ' ) , os . path . join ( LLVM_3_4 , ' clang + + ' ) ) , <nl> + # NativeBenchmarker ( ' gcc ' , ' gcc ' , ' g + + ' ) , <nl> + JSBenchmarker ( ' sm - f32 ' , SPIDERMONKEY_ENGINE , [ ' - s ' , ' PRECISE_F32 = 2 ' ] ) , <nl> + # JSBenchmarker ( ' sm - f32 - 3 . 2 ' , SPIDERMONKEY_ENGINE , [ ' - s ' , ' PRECISE_F32 = 2 ' ] , env = { ' LLVM ' : LLVM_3_2 } ) , <nl> + # JSBenchmarker ( ' sm - f32 - 3 . 3 ' , SPIDERMONKEY_ENGINE , [ ' - s ' , ' PRECISE_F32 = 2 ' ] , env = { ' LLVM ' : LLVM_3_3 } ) , <nl> + # JSBenchmarker ( ' sm - f32 - 3 . 4 ' , SPIDERMONKEY_ENGINE , [ ' - s ' , ' PRECISE_F32 = 2 ' ] , env = { ' LLVM ' : LLVM_3_4 } ) , <nl> + # JSBenchmarker ( ' sm - fc ' , SPIDERMONKEY_ENGINE , env = { ' EMCC_FAST_COMPILER ' : ' 1 ' } ) , <nl> + # JSBenchmarker ( ' sm - noasm ' , SPIDERMONKEY_ENGINE + [ ' - - no - asmjs ' ] ) , <nl> + # JSBenchmarker ( ' sm - noasm - f32 ' , SPIDERMONKEY_ENGINE + [ ' - - no - asmjs ' ] , [ ' - s ' , ' PRECISE_F32 = 2 ' ] ) , <nl> + # JSBenchmarker ( ' v8 ' , V8_ENGINE ) <nl> + ] <nl> + except Exception , e : <nl> + benchmarkers_error = str ( e ) <nl> + benchmarkers = [ ] <nl> <nl> class benchmark ( RunnerCore ) : <nl> save_dir = True <nl> def setUpClass ( self ) : <nl> Building . COMPILER_TEST_OPTS = [ ] <nl> <nl> def do_benchmark ( self , name , src , expected_output = ' FAIL ' , args = [ ] , emcc_args = [ ] , native_args = [ ] , shared_args = [ ] , force_c = False , reps = TEST_REPS , native_exec = None , output_parser = None , args_processor = None , lib_builder = None ) : <nl> + if len ( benchmarkers ) = = 0 : raise Exception ( ' error , no benchmarkers : ' + benchmarkers_error ) <nl> + <nl> args = args or [ DEFAULT_ARG ] <nl> if args_processor : args = args_processor ( args ) <nl> <nl>
make benchmark suite more robust to settings changes
emscripten-core/emscripten
6344b5c8d41ee9489ad51b40f9b0bee770b1a22f
2014-01-07T18:46:13Z
mmm a / jstests / noPassthrough / disabled_test_parameters . js <nl> ppp b / jstests / noPassthrough / disabled_test_parameters . js <nl> <nl> assertStarts ( { <nl> ' setParameter ' : { <nl> enableTestCommands : v , <nl> - enableIndexBuildsCoordinatorForCreateIndexesCommand : ' false ' , <nl> + disableIndexSpecNamespaceGeneration : ' false ' , <nl> } , <nl> } ) ; <nl> } ) ; <nl>
SERVER - 41966 update test case in disabled_test_parameters . js to use test - only server parameter
mongodb/mongo
8cb025148fb78311f97454894324419d1442ce08
2019-07-01T18:09:25Z
mmm a / src / wasm / wasm - interpreter . cc <nl> ppp b / src / wasm / wasm - interpreter . cc <nl> class ThreadImpl { <nl> } <nl> <nl> WasmValue GetGlobalValue ( uint32_t index ) { <nl> - const WasmGlobal * global = & module ( ) - > globals [ index ] ; <nl> - switch ( global - > type ) { <nl> - # define CASE_TYPE ( wasm , ctype ) \ <nl> - case kWasm # # wasm : { \ <nl> - byte * ptr = GetGlobalPtr ( global ) ; \ <nl> - return WasmValue ( \ <nl> - ReadLittleEndianValue < ctype > ( reinterpret_cast < Address > ( ptr ) ) ) ; \ <nl> - break ; \ <nl> + auto & global = module ( ) - > globals [ index ] ; <nl> + switch ( global . type ) { <nl> + # define CASE_TYPE ( wasm , ctype ) \ <nl> + case kWasm # # wasm : { \ <nl> + byte * ptr = \ <nl> + WasmInstanceObject : : GetGlobalStorage ( instance_object_ , global ) ; \ <nl> + return WasmValue ( \ <nl> + ReadLittleEndianValue < ctype > ( reinterpret_cast < Address > ( ptr ) ) ) ; \ <nl> + break ; \ <nl> } <nl> WASM_CTYPES ( CASE_TYPE ) <nl> # undef CASE_TYPE <nl> class ThreadImpl { <nl> case kWasmExnRef : { <nl> HandleScope handle_scope ( isolate_ ) ; / / Avoid leaking handles . <nl> Handle < FixedArray > global_buffer ; / / The buffer of the global . <nl> - uint32_t global_index = 0 ; / / The index into the buffer . <nl> - GetGlobalBufferAndIndex ( global , & global_buffer , & global_index ) ; <nl> + uint32_t global_index ; / / The index into the buffer . <nl> + std : : tie ( global_buffer , global_index ) = <nl> + WasmInstanceObject : : GetGlobalBufferAndIndex ( instance_object_ , <nl> + global ) ; <nl> Handle < Object > value ( global_buffer - > get ( global_index ) , isolate_ ) ; <nl> return WasmValue ( handle_scope . CloseAndEscape ( value ) ) ; <nl> } <nl> class ThreadImpl { <nl> return true ; <nl> } <nl> <nl> - byte * GetGlobalPtr ( const WasmGlobal * global ) { <nl> - DCHECK ( ! ValueTypes : : IsReferenceType ( global - > type ) ) ; <nl> - if ( global - > mutability & & global - > imported ) { <nl> - return reinterpret_cast < byte * > ( <nl> - instance_object_ - > imported_mutable_globals ( ) [ global - > index ] ) ; <nl> - } else { <nl> - return instance_object_ - > globals_start ( ) + global - > offset ; <nl> - } <nl> - } <nl> - <nl> - void GetGlobalBufferAndIndex ( const WasmGlobal * global , <nl> - Handle < FixedArray > * buffer , uint32_t * index ) { <nl> - DCHECK ( ValueTypes : : IsReferenceType ( global - > type ) ) ; <nl> - if ( global - > mutability & & global - > imported ) { <nl> - * buffer = <nl> - handle ( FixedArray : : cast ( <nl> - instance_object_ - > imported_mutable_globals_buffers ( ) . get ( <nl> - global - > index ) ) , <nl> - isolate_ ) ; <nl> - Address idx = instance_object_ - > imported_mutable_globals ( ) [ global - > index ] ; <nl> - DCHECK_LE ( idx , std : : numeric_limits < uint32_t > : : max ( ) ) ; <nl> - * index = static_cast < uint32_t > ( idx ) ; <nl> - } else { <nl> - * buffer = handle ( instance_object_ - > tagged_globals_buffer ( ) , isolate_ ) ; <nl> - * index = global - > offset ; <nl> - } <nl> - } <nl> - <nl> bool ExecuteSimdOp ( WasmOpcode opcode , Decoder * decoder , InterpreterCode * code , <nl> pc_t pc , int * const len ) { <nl> switch ( opcode ) { <nl> class ThreadImpl { <nl> case kExprGlobalSet : { <nl> GlobalIndexImmediate < Decoder : : kNoValidate > imm ( & decoder , <nl> code - > at ( pc ) ) ; <nl> - const WasmGlobal * global = & module ( ) - > globals [ imm . index ] ; <nl> - switch ( global - > type ) { <nl> - # define CASE_TYPE ( wasm , ctype ) \ <nl> - case kWasm # # wasm : { \ <nl> - byte * ptr = GetGlobalPtr ( global ) ; \ <nl> - WriteLittleEndianValue < ctype > ( reinterpret_cast < Address > ( ptr ) , \ <nl> - Pop ( ) . to < ctype > ( ) ) ; \ <nl> - break ; \ <nl> + auto & global = module ( ) - > globals [ imm . index ] ; <nl> + switch ( global . type ) { <nl> + # define CASE_TYPE ( wasm , ctype ) \ <nl> + case kWasm # # wasm : { \ <nl> + byte * ptr = \ <nl> + WasmInstanceObject : : GetGlobalStorage ( instance_object_ , global ) ; \ <nl> + WriteLittleEndianValue < ctype > ( reinterpret_cast < Address > ( ptr ) , \ <nl> + Pop ( ) . to < ctype > ( ) ) ; \ <nl> + break ; \ <nl> } <nl> WASM_CTYPES ( CASE_TYPE ) <nl> # undef CASE_TYPE <nl> class ThreadImpl { <nl> case kWasmExnRef : { <nl> HandleScope handle_scope ( isolate_ ) ; / / Avoid leaking handles . <nl> Handle < FixedArray > global_buffer ; / / The buffer of the global . <nl> - uint32_t global_index = 0 ; / / The index into the buffer . <nl> - GetGlobalBufferAndIndex ( global , & global_buffer , & global_index ) ; <nl> + uint32_t global_index ; / / The index into the buffer . <nl> + std : : tie ( global_buffer , global_index ) = <nl> + WasmInstanceObject : : GetGlobalBufferAndIndex ( instance_object_ , <nl> + global ) ; <nl> global_buffer - > set ( global_index , * Pop ( ) . to_anyref ( ) ) ; <nl> break ; <nl> } <nl> mmm a / src / wasm / wasm - objects . cc <nl> ppp b / src / wasm / wasm - objects . cc <nl> void WasmInstanceObject : : ImportWasmJSFunctionIntoTable ( <nl> . Set ( sig_id , call_target , * tuple ) ; <nl> } <nl> <nl> + / / static <nl> + uint8_t * WasmInstanceObject : : GetGlobalStorage ( <nl> + Handle < WasmInstanceObject > instance , const wasm : : WasmGlobal & global ) { <nl> + DCHECK ( ! wasm : : ValueTypes : : IsReferenceType ( global . type ) ) ; <nl> + if ( global . mutability & & global . imported ) { <nl> + return reinterpret_cast < byte * > ( <nl> + instance - > imported_mutable_globals ( ) [ global . index ] ) ; <nl> + } else { <nl> + return instance - > globals_start ( ) + global . offset ; <nl> + } <nl> + } <nl> + <nl> + / / static <nl> + std : : pair < Handle < FixedArray > , uint32_t > <nl> + WasmInstanceObject : : GetGlobalBufferAndIndex ( Handle < WasmInstanceObject > instance , <nl> + const wasm : : WasmGlobal & global ) { <nl> + DCHECK ( wasm : : ValueTypes : : IsReferenceType ( global . type ) ) ; <nl> + Isolate * isolate = instance - > GetIsolate ( ) ; <nl> + if ( global . mutability & & global . imported ) { <nl> + Handle < FixedArray > buffer ( <nl> + FixedArray : : cast ( <nl> + instance - > imported_mutable_globals_buffers ( ) . get ( global . index ) ) , <nl> + isolate ) ; <nl> + Address idx = instance - > imported_mutable_globals ( ) [ global . index ] ; <nl> + DCHECK_LE ( idx , std : : numeric_limits < uint32_t > : : max ( ) ) ; <nl> + return { buffer , static_cast < uint32_t > ( idx ) } ; <nl> + } <nl> + return { handle ( instance - > tagged_globals_buffer ( ) , isolate ) , global . offset } ; <nl> + } <nl> + <nl> / / static <nl> Handle < WasmExceptionObject > WasmExceptionObject : : New ( <nl> Isolate * isolate , const wasm : : FunctionSig * sig , <nl> mmm a / src / wasm / wasm - objects . h <nl> ppp b / src / wasm / wasm - objects . h <nl> class SignatureMap ; <nl> class WasmCode ; <nl> struct WasmException ; <nl> struct WasmFeatures ; <nl> + struct WasmGlobal ; <nl> class WasmInterpreter ; <nl> struct WasmModule ; <nl> class WasmValue ; <nl> class WasmInstanceObject : public JSObject { <nl> int table_index , int entry_index , <nl> Handle < WasmJSFunction > js_function ) ; <nl> <nl> + / / Get a raw pointer to the location where the given global is stored . <nl> + / / { global } must not be a reference type . <nl> + static uint8_t * GetGlobalStorage ( Handle < WasmInstanceObject > , <nl> + const wasm : : WasmGlobal & ) ; <nl> + <nl> + / / Get the FixedArray and the index in that FixedArray for the given global , <nl> + / / which must be a reference type . <nl> + static std : : pair < Handle < FixedArray > , uint32_t > GetGlobalBufferAndIndex ( <nl> + Handle < WasmInstanceObject > , const wasm : : WasmGlobal & ) ; <nl> + <nl> OBJECT_CONSTRUCTORS ( WasmInstanceObject , JSObject ) ; <nl> <nl> private : <nl>
[ wasm ] Move global storage accessors out of interpreter
v8/v8
f30a92e6f216e286bf23d6340e5cbabf4ce69096
2019-10-23T12:39:34Z
mmm a / atom / browser / resources / mac / Info . plist <nl> ppp b / atom / browser / resources / mac / Info . plist <nl> <nl> < key > CFBundleIconFile < / key > <nl> < string > atom . icns < / string > <nl> < key > CFBundleVersion < / key > <nl> - < string > 0 . 13 . 1 < / string > <nl> + < string > 0 . 13 . 2 < / string > <nl> < key > LSMinimumSystemVersion < / key > <nl> < string > 10 . 8 . 0 < / string > <nl> < key > NSMainNibFile < / key > <nl> mmm a / atom / browser / resources / win / atom . rc <nl> ppp b / atom / browser / resources / win / atom . rc <nl> END <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 0 , 13 , 1 , 0 <nl> - PRODUCTVERSION 0 , 13 , 1 , 0 <nl> + FILEVERSION 0 , 13 , 2 , 0 <nl> + PRODUCTVERSION 0 , 13 , 2 , 0 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl> BEGIN <nl> BEGIN <nl> VALUE " CompanyName " , " GitHub , Inc . " <nl> VALUE " FileDescription " , " Atom - Shell " <nl> - VALUE " FileVersion " , " 0 . 13 . 1 " <nl> + VALUE " FileVersion " , " 0 . 13 . 2 " <nl> VALUE " InternalName " , " atom . exe " <nl> VALUE " LegalCopyright " , " Copyright ( C ) 2013 GitHub , Inc . All rights reserved . " <nl> VALUE " OriginalFilename " , " atom . exe " <nl> VALUE " ProductName " , " Atom - Shell " <nl> - VALUE " ProductVersion " , " 0 . 13 . 1 " <nl> + VALUE " ProductVersion " , " 0 . 13 . 2 " <nl> END <nl> END <nl> BLOCK " VarFileInfo " <nl> mmm a / atom / common / atom_version . h <nl> ppp b / atom / common / atom_version . h <nl> <nl> <nl> # define ATOM_MAJOR_VERSION 0 <nl> # define ATOM_MINOR_VERSION 13 <nl> - # define ATOM_PATCH_VERSION 1 <nl> + # define ATOM_PATCH_VERSION 2 <nl> <nl> # define ATOM_VERSION_IS_RELEASE 1 <nl> <nl> mmm a / package . json <nl> ppp b / package . json <nl> <nl> { <nl> " name " : " atom - shell " , <nl> - " version " : " 0 . 13 . 1 " , <nl> + " version " : " 0 . 13 . 2 " , <nl> <nl> " licenses " : [ <nl> { <nl>
Bump v0 . 13 . 2 .
electron/electron
32323a00061546275dd646429ca1269fc313269b
2014-06-18T01:09:04Z
mmm a / tools / depends / target / fribidi / Makefile <nl> ppp b / tools / depends / target / fribidi / Makefile <nl> DEPS = . . / . . / Makefile . include Makefile <nl> <nl> # lib name , version <nl> LIBNAME = fribidi <nl> - VERSION = 0 . 19 . 7 <nl> + VERSION = 1 . 0 . 5 <nl> SOURCE = $ ( LIBNAME ) - $ ( VERSION ) <nl> ARCHIVE = $ ( SOURCE ) . tar . bz2 <nl> - export CFLAGS + = - D__STDC_INT64__ <nl> + <nl> # configuration settings <nl> CONFIGURE = cp - f $ ( CONFIG_SUB ) $ ( CONFIG_GUESS ) . ; \ <nl> . / configure - - prefix = $ ( PREFIX ) - - disable - shared - - with - glib = no <nl> clean : <nl> <nl> distclean : : <nl> rm - rf $ ( PLATFORM ) . installed - $ ( PLATFORM ) <nl> - <nl>
[ depends ] bump fribidi to 1 . 0 . 5
xbmc/xbmc
19318b0e777d669495fac1058fe05b5ca6023819
2019-09-19T06:11:33Z
mmm a / arangod / Cluster / ClusterComm . cpp <nl> ppp b / arangod / Cluster / ClusterComm . cpp <nl> ClusterComm : : getConnection ( ServerID & serverID ) { <nl> if ( ! s - > unused . empty ( ) ) { <nl> c = s - > unused . back ( ) ; <nl> s - > unused . pop_back ( ) ; <nl> - c - > lastUsed = time ( 0 ) ; <nl> return c ; <nl> } <nl> } <nl> void ClusterComm : : closeUnusedConnections ( ) { <nl> } <nl> } <nl> <nl> + ClusterCommResult * ClusterComm : : asyncRequest ( <nl> + ClientTransactionID const & clientTransactionID , <nl> + TransactionID const coordTransactionID , <nl> + ShardID const & shardID , <nl> + rest : : HttpRequest : : HttpRequestType reqtype , <nl> + string const & path , <nl> + char const * body , <nl> + size_t const bodyLength , <nl> + map < string , string > const & headerFields , <nl> + ClusterCommCallback * callback , <nl> + ClusterCommTimeout timeout ) { <nl> + <nl> + OperationID opID = getOperationID ( ) ; <nl> + <nl> + / / Build HTTPRequest <nl> + / / Build ClusterCommOperation object <nl> + / / Put into queue <nl> + / / signal on condition variable <nl> + / / Build ClusterCommResult object <nl> + / / return <nl> + return 0 ; <nl> + } <nl> + <nl> + bool ClusterComm : : match ( ClientTransactionID const & clientTransactionID , <nl> + TransactionID const coordTransactionID , <nl> + OperationID const operationID , <nl> + ShardID const & shardID , <nl> + ClusterCommOperation * op ) { <nl> + / / First check operationID , if given , can return false already <nl> + / / then check other IDs . <nl> + return true ; <nl> + } <nl> + <nl> + ClusterCommResult * enquire ( OperationID const operationID ) { <nl> + / / Find operation by its ID ( fast ) <nl> + / / build ClusterCommResult object and return it . <nl> + return 0 ; <nl> + } <nl> + <nl> + ClusterCommResult * ClusterComm : : wait ( <nl> + ClientTransactionID const & clientTransactionID , <nl> + TransactionID const coordTransactionID , <nl> + OperationID const operationID , <nl> + ShardID const & shardID , <nl> + ClusterCommTimeout timeout ) { <nl> + / / Only look at received queue , match , return the first with CL_COMM_RECEIVED <nl> + / / dequeue it <nl> + / / Initialise remaining time <nl> + / / If nothing found , use condition variable and wait to get more with <nl> + / / possible timeout , if timeout , return empty <nl> + / / otherwise check again , if . . . <nl> + return 0 ; <nl> + } <nl> + <nl> + void ClusterComm : : drop ( ClientTransactionID const & clientTransactionID , <nl> + TransactionID const coordTransactionID , <nl> + OperationID const operationID , <nl> + ShardID const & shardID ) { <nl> + / / Look at both send queue and recv queue , delete everything found <nl> + } <nl> + <nl> + int ClusterComm : : processAnswer ( rest : : HttpRequest * answer ) { <nl> + / / find matching operation , report if found , otherwise drop <nl> + return TRI_ERROR_NO_ERROR ; <nl> + } <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - ClusterCommThread <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> void ClusterCommThread : : run ( ) { <nl> LOG_TRACE ( " starting ClusterComm thread " ) ; <nl> <nl> while ( ! _stop ) { <nl> - usleep ( 2000 ) ; <nl> + usleep ( 2000000 ) ; <nl> / / FIXME : . . . <nl> - LOG_TRACE ( " ClusterComm alive " ) ; <nl> + LOG_DEBUG ( " ClusterComm alive " ) ; <nl> } <nl> <nl> / / another thread is waiting for this value to shut down properly <nl> mmm a / arangod / Cluster / ClusterComm . h <nl> ppp b / arangod / Cluster / ClusterComm . h <nl> namespace triagens { <nl> / / / and not in a DBServer node . <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - int processAnswer ( rest : : HttpRequest & answer ) ; <nl> + int processAnswer ( rest : : HttpRequest * answer ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief send an answer HTTP request to a coordinator , which contains <nl> namespace triagens { <nl> / / Receiving answers : <nl> list < ClusterCommOperation * > received ; <nl> map < OperationID , list < ClusterCommOperation * > : : iterator > receivedByOpID ; <nl> - triagens : : basics : : ReadWriteLock receiveLock ; <nl> + triagens : : basics : : ConditionVariable somethingReceived ; <nl> + <nl> + / / An internal function to match an operation : <nl> + bool match ( ClientTransactionID const & clientTransactionID , <nl> + TransactionID const coordTransactionID , <nl> + OperationID const operationID , <nl> + ShardID const & shardID , <nl> + ClusterCommOperation * op ) ; <nl> <nl> / / Finally , our background communications thread : <nl> ClusterCommThread * _backgroundThread ; <nl>
Add skeletons of new functions .
arangodb/arangodb
fdc664859c4969f294ceab6bda8175a8c42a7647
2013-12-17T12:52:31Z
mmm a / trunk / configure <nl> ppp b / trunk / configure <nl> if [ $ SRS_LIBRTMP = YES ] ; then <nl> fi <nl> # <nl> # utest , the unit - test cases of srs , base on gtest1 . 6 <nl> - MODULE_FILES = ( " srs_utest " " srs_utest_amf0 " " srs_utest_handshake " ) <nl> + MODULE_FILES = ( " srs_utest " " srs_utest_amf0 " " srs_utest_handshake " " srs_utest_buffer " ) <nl> ModuleLibIncs = ( $ { SRS_OBJS } $ { LibSTRoot } ) <nl> ModuleLibFiles = ( $ { LibSTfile } $ { LibHttpParserfile } $ { LibSSLfile } ) <nl> MODULE_DEPENDS = ( " CORE " " KERNEL " " RTMP " " APP " ) <nl> mmm a / trunk / src / app / srs_app_http . cpp <nl> ppp b / trunk / src / app / srs_app_http . cpp <nl> SrsHttpHandler * SrsHttpHandler : : res_body ( stringstream & ss , string body ) <nl> <nl> int SrsHttpHandler : : res_flush ( SrsSocket * skt , stringstream & ss ) <nl> { <nl> - return skt - > write ( ss . str ( ) . c_str ( ) , ss . str ( ) . length ( ) , NULL ) ; <nl> + return skt - > write ( ( void * ) ss . str ( ) . c_str ( ) , ss . str ( ) . length ( ) , NULL ) ; <nl> } <nl> <nl> int SrsHttpHandler : : res_options ( SrsSocket * skt ) <nl> mmm a / trunk / src / app / srs_app_http_client . cpp <nl> ppp b / trunk / src / app / srs_app_http_client . cpp <nl> int SrsHttpClient : : post ( SrsHttpUri * uri , string req , string & res ) <nl> SrsSocket skt ( stfd ) ; <nl> <nl> std : : string data = ss . str ( ) ; <nl> - if ( ( ret = skt . write ( data . c_str ( ) , data . length ( ) , NULL ) ) ! = ERROR_SUCCESS ) { <nl> + if ( ( ret = skt . write ( ( void * ) data . c_str ( ) , data . length ( ) , NULL ) ) ! = ERROR_SUCCESS ) { <nl> / / disconnect when error . <nl> disconnect ( ) ; <nl> <nl> mmm a / trunk / src / app / srs_app_socket . cpp <nl> ppp b / trunk / src / app / srs_app_socket . cpp <nl> int64_t SrsSocket : : get_send_bytes ( ) <nl> return send_bytes ; <nl> } <nl> <nl> - int SrsSocket : : read ( const void * buf , size_t size , ssize_t * nread ) <nl> + int SrsSocket : : read ( void * buf , size_t size , ssize_t * nread ) <nl> { <nl> int ret = ERROR_SUCCESS ; <nl> <nl> - ssize_t nb_read = st_read ( stfd , ( void * ) buf , size , recv_timeout ) ; <nl> + ssize_t nb_read = st_read ( stfd , buf , size , recv_timeout ) ; <nl> if ( nread ) { <nl> * nread = nb_read ; <nl> } <nl> int SrsSocket : : read ( const void * buf , size_t size , ssize_t * nread ) <nl> return ret ; <nl> } <nl> <nl> - int SrsSocket : : read_fully ( const void * buf , size_t size , ssize_t * nread ) <nl> + int SrsSocket : : read_fully ( void * buf , size_t size , ssize_t * nread ) <nl> { <nl> int ret = ERROR_SUCCESS ; <nl> <nl> - ssize_t nb_read = st_read_fully ( stfd , ( void * ) buf , size , recv_timeout ) ; <nl> + ssize_t nb_read = st_read_fully ( stfd , buf , size , recv_timeout ) ; <nl> if ( nread ) { <nl> * nread = nb_read ; <nl> } <nl> int SrsSocket : : read_fully ( const void * buf , size_t size , ssize_t * nread ) <nl> return ret ; <nl> } <nl> <nl> - int SrsSocket : : write ( const void * buf , size_t size , ssize_t * nwrite ) <nl> + int SrsSocket : : write ( void * buf , size_t size , ssize_t * nwrite ) <nl> { <nl> int ret = ERROR_SUCCESS ; <nl> <nl> - ssize_t nb_write = st_write ( stfd , ( void * ) buf , size , send_timeout ) ; <nl> + ssize_t nb_write = st_write ( stfd , buf , size , send_timeout ) ; <nl> if ( nwrite ) { <nl> * nwrite = nb_write ; <nl> } <nl> mmm a / trunk / src / app / srs_app_socket . hpp <nl> ppp b / trunk / src / app / srs_app_socket . hpp <nl> class SrsSocket : public ISrsProtocolReaderWriter <nl> / * * <nl> * @ param nread , the actual read bytes , ignore if NULL . <nl> * / <nl> - virtual int read ( const void * buf , size_t size , ssize_t * nread ) ; <nl> - virtual int read_fully ( const void * buf , size_t size , ssize_t * nread ) ; <nl> + virtual int read ( void * buf , size_t size , ssize_t * nread ) ; <nl> + virtual int read_fully ( void * buf , size_t size , ssize_t * nread ) ; <nl> / * * <nl> * @ param nwrite , the actual write bytes , ignore if NULL . <nl> * / <nl> - virtual int write ( const void * buf , size_t size , ssize_t * nwrite ) ; <nl> + virtual int write ( void * buf , size_t size , ssize_t * nwrite ) ; <nl> virtual int writev ( const iovec * iov , int iov_size , ssize_t * nwrite ) ; <nl> } ; <nl> <nl> mmm a / trunk / src / kernel / srs_kernel_buffer . cpp <nl> ppp b / trunk / src / kernel / srs_kernel_buffer . cpp <nl> void SrsBuffer : : erase ( int size ) <nl> { <nl> srs_assert ( size > 0 ) ; <nl> <nl> - if ( size = = length ( ) ) { <nl> + if ( size > = length ( ) ) { <nl> data . clear ( ) ; <nl> return ; <nl> } <nl> mmm a / trunk / src / kernel / srs_kernel_buffer . hpp <nl> ppp b / trunk / src / kernel / srs_kernel_buffer . hpp <nl> class ISrsBufferReader <nl> virtual ~ ISrsBufferReader ( ) ; <nl> / / for protocol / amf0 / msg - codec <nl> public : <nl> - virtual int read ( const void * buf , size_t size , ssize_t * nread ) = 0 ; <nl> + virtual int read ( void * buf , size_t size , ssize_t * nread ) = 0 ; <nl> } ; <nl> <nl> / * * <nl> * the buffer provices bytes cache for protocol . generally , <nl> * protocol recv data from socket , put into buffer , decode to RTMP message . <nl> - * protocol encode RTMP message to bytes , put into buffer , send to socket . <nl> * / <nl> - class SrsBuffer <nl> + class SrsBuffer <nl> { <nl> private : <nl> std : : vector < char > data ; <nl> class ISrsBufferReader <nl> virtual ~ SrsBuffer ( ) ; <nl> public : <nl> / * * <nl> - * get the length of buffer . <nl> - * never negative , empty if zero . <nl> + * get the length of buffer . empty if zero . <nl> + * @ remark assert length ( ) is not negative . <nl> * / <nl> virtual int length ( ) ; <nl> / * * <nl> class ISrsBufferReader <nl> virtual char * bytes ( ) ; <nl> / * * <nl> * erase size of bytes from begin . <nl> - * if size equals to length ( ) , clear buffer . <nl> - * @ param size <nl> + * @ param size to erase size of bytes . <nl> + * clear if size greater than or equals to length ( ) <nl> + * @ remark assert size is positive . <nl> * / <nl> virtual void erase ( int size ) ; <nl> / * * <nl> * append specified bytes to buffer . <nl> - * @ param size the size of bytes , assert positive . <nl> + * @ param size the size of bytes <nl> + * @ remark assert size is positive . <nl> * / <nl> virtual void append ( const char * bytes , int size ) ; <nl> public : <nl> / * * <nl> * grow buffer to the required size , loop to read from skt to fill . <nl> * @ param reader , read more bytes from reader to fill the buffer to required size . <nl> - * @ param required_size , loop to fill to ensure buffer size to required . <nl> + * @ param required_size , loop to fill to ensure buffer size to required . <nl> + * @ return an int error code , error if required_size negative . <nl> + * @ remark , we actually maybe read more than required_size , maybe 4k for example . <nl> * / <nl> virtual int grow ( ISrsBufferReader * reader , int required_size ) ; <nl> } ; <nl> mmm a / trunk / src / libs / srs_lib_simple_socket . cpp <nl> ppp b / trunk / src / libs / srs_lib_simple_socket . cpp <nl> int SimpleSocketStream : : connect ( const char * server_ip , int port ) <nl> } <nl> <nl> / / ISrsBufferReader <nl> - int SimpleSocketStream : : read ( const void * buf , size_t size , ssize_t * nread ) <nl> + int SimpleSocketStream : : read ( void * buf , size_t size , ssize_t * nread ) <nl> { <nl> int ret = ERROR_SUCCESS ; <nl> <nl> - * nread = : : recv ( fd , ( void * ) buf , size , 0 ) ; <nl> + * nread = : : recv ( fd , buf , size , 0 ) ; <nl> <nl> / / On success a non - negative integer indicating the number of bytes actually read is returned <nl> / / ( a value of 0 means the network connection is closed or end of file is reached ) . <nl> bool SimpleSocketStream : : is_never_timeout ( int64_t timeout_us ) <nl> return timeout_us = = ( int64_t ) ST_UTIME_NO_TIMEOUT ; <nl> } <nl> <nl> - int SimpleSocketStream : : read_fully ( const void * buf , size_t size , ssize_t * nread ) <nl> + int SimpleSocketStream : : read_fully ( void * buf , size_t size , ssize_t * nread ) <nl> { <nl> int ret = ERROR_SUCCESS ; <nl> <nl> int SimpleSocketStream : : read_fully ( const void * buf , size_t size , ssize_t * nread ) <nl> return ret ; <nl> } <nl> <nl> - int SimpleSocketStream : : write ( const void * buf , size_t size , ssize_t * nwrite ) <nl> + int SimpleSocketStream : : write ( void * buf , size_t size , ssize_t * nwrite ) <nl> { <nl> int ret = ERROR_SUCCESS ; <nl> <nl> mmm a / trunk / src / libs / srs_lib_simple_socket . hpp <nl> ppp b / trunk / src / libs / srs_lib_simple_socket . hpp <nl> class SimpleSocketStream : public ISrsProtocolReaderWriter <nl> virtual int connect ( const char * server , int port ) ; <nl> / / ISrsBufferReader <nl> public : <nl> - virtual int read ( const void * buf , size_t size , ssize_t * nread ) ; <nl> + virtual int read ( void * buf , size_t size , ssize_t * nread ) ; <nl> / / ISrsProtocolReader <nl> public : <nl> virtual void set_recv_timeout ( int64_t timeout_us ) ; <nl> class SimpleSocketStream : public ISrsProtocolReaderWriter <nl> / / ISrsProtocolReaderWriter <nl> public : <nl> virtual bool is_never_timeout ( int64_t timeout_us ) ; <nl> - virtual int read_fully ( const void * buf , size_t size , ssize_t * nread ) ; <nl> - virtual int write ( const void * buf , size_t size , ssize_t * nwrite ) ; <nl> + virtual int read_fully ( void * buf , size_t size , ssize_t * nread ) ; <nl> + virtual int write ( void * buf , size_t size , ssize_t * nwrite ) ; <nl> } ; <nl> <nl> # endif <nl> mmm a / trunk / src / rtmp / srs_protocol_io . hpp <nl> ppp b / trunk / src / rtmp / srs_protocol_io . hpp <nl> class ISrsProtocolReaderWriter : public ISrsProtocolReader , public ISrsProtocolW <nl> virtual bool is_never_timeout ( int64_t timeout_us ) = 0 ; <nl> / / for handshake . <nl> public : <nl> - virtual int read_fully ( const void * buf , size_t size , ssize_t * nread ) = 0 ; <nl> - virtual int write ( const void * buf , size_t size , ssize_t * nwrite ) = 0 ; <nl> + virtual int read_fully ( void * buf , size_t size , ssize_t * nread ) = 0 ; <nl> + virtual int write ( void * buf , size_t size , ssize_t * nwrite ) = 0 ; <nl> } ; <nl> <nl> # endif <nl> mmm a / trunk / src / srs / srs . upp <nl> ppp b / trunk / src / srs / srs . upp <nl> file <nl> . . \ utest \ srs_utest . cpp , <nl> . . \ utest \ srs_utest_amf0 . hpp , <nl> . . \ utest \ srs_utest_amf0 . cpp , <nl> + . . \ utest \ srs_utest_buffer . hpp , <nl> + . . \ utest \ srs_utest_buffer . cpp , <nl> . . \ utest \ srs_utest_handshake . hpp , <nl> . . \ utest \ srs_utest_handshake . cpp , <nl> research readonly separator , <nl> mmm a / trunk / src / utest / srs_utest . cpp <nl> ppp b / trunk / src / utest / srs_utest . cpp <nl> bool MockEmptyIO : : is_never_timeout ( int64_t / * timeout_us * / ) <nl> return true ; <nl> } <nl> <nl> - int MockEmptyIO : : read_fully ( const void * / * buf * / , size_t / * size * / , ssize_t * / * nread * / ) <nl> + int MockEmptyIO : : read_fully ( void * / * buf * / , size_t / * size * / , ssize_t * / * nread * / ) <nl> { <nl> return ERROR_SUCCESS ; <nl> } <nl> <nl> - int MockEmptyIO : : write ( const void * / * buf * / , size_t / * size * / , ssize_t * / * nwrite * / ) <nl> + int MockEmptyIO : : write ( void * / * buf * / , size_t / * size * / , ssize_t * / * nwrite * / ) <nl> { <nl> return ERROR_SUCCESS ; <nl> } <nl> int MockEmptyIO : : writev ( const iovec * / * iov * / , int / * iov_size * / , ssize_t * / * nwrit <nl> return ERROR_SUCCESS ; <nl> } <nl> <nl> - int MockEmptyIO : : read ( const void * / * buf * / , size_t / * size * / , ssize_t * / * nread * / ) <nl> + int MockEmptyIO : : read ( void * / * buf * / , size_t / * size * / , ssize_t * / * nread * / ) <nl> { <nl> return ERROR_SUCCESS ; <nl> } <nl> mmm a / trunk / src / utest / srs_utest . hpp <nl> ppp b / trunk / src / utest / srs_utest . hpp <nl> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> / / we add an empty macro for upp to show the smart tips . <nl> # define VOID <nl> <nl> + / / the asserts of gtest : <nl> + / / * { ASSERT | EXPECT } _EQ ( expected , actual ) : Tests that expected = = actual <nl> + / / * { ASSERT | EXPECT } _NE ( v1 , v2 ) : Tests that v1 ! = v2 <nl> + / / * { ASSERT | EXPECT } _LT ( v1 , v2 ) : Tests that v1 < v2 <nl> + / / * { ASSERT | EXPECT } _LE ( v1 , v2 ) : Tests that v1 < = v2 <nl> + / / * { ASSERT | EXPECT } _GT ( v1 , v2 ) : Tests that v1 > v2 <nl> + / / * { ASSERT | EXPECT } _GE ( v1 , v2 ) : Tests that v1 > = v2 <nl> + / / * { ASSERT | EXPECT } _STREQ ( s1 , s2 ) : Tests that s1 = = s2 <nl> + / / * { ASSERT | EXPECT } _STRNE ( s1 , s2 ) : Tests that s1 ! = s2 <nl> + / / * { ASSERT | EXPECT } _STRCASEEQ ( s1 , s2 ) : Tests that s1 = = s2 , ignoring case <nl> + / / * { ASSERT | EXPECT } _STRCASENE ( s1 , s2 ) : Tests that s1 ! = s2 , ignoring case <nl> + / / * { ASSERT | EXPECT } _FLOAT_EQ ( expected , actual ) : Tests that two float values are almost equal . <nl> + / / * { ASSERT | EXPECT } _DOUBLE_EQ ( expected , actual ) : Tests that two double values are almost equal . <nl> + / / * { ASSERT | EXPECT } _NEAR ( v1 , v2 , abs_error ) : Tests that v1 and v2 are within the given distance to each other . <nl> + <nl> # include < srs_protocol_io . hpp > <nl> <nl> class MockEmptyIO : public ISrsProtocolReaderWriter <nl> class MockEmptyIO : public ISrsProtocolReaderWriter <nl> virtual bool is_never_timeout ( int64_t timeout_us ) ; <nl> / / for handshake . <nl> public : <nl> - virtual int read_fully ( const void * buf , size_t size , ssize_t * nread ) ; <nl> - virtual int write ( const void * buf , size_t size , ssize_t * nwrite ) ; <nl> + virtual int read_fully ( void * buf , size_t size , ssize_t * nread ) ; <nl> + virtual int write ( void * buf , size_t size , ssize_t * nwrite ) ; <nl> / / for protocol <nl> public : <nl> virtual void set_recv_timeout ( int64_t timeout_us ) ; <nl> class MockEmptyIO : public ISrsProtocolReaderWriter <nl> virtual int writev ( const iovec * iov , int iov_size , ssize_t * nwrite ) ; <nl> / / for protocol / amf0 / msg - codec <nl> public : <nl> - virtual int read ( const void * buf , size_t size , ssize_t * nread ) ; <nl> + virtual int read ( void * buf , size_t size , ssize_t * nread ) ; <nl> } ; <nl> <nl> # endif <nl> new file mode 100644 <nl> index 000000000 . . 5f07ebb04 <nl> mmm / dev / null <nl> ppp b / trunk / src / utest / srs_utest_buffer . cpp <nl> <nl> + / * <nl> + The MIT License ( MIT ) <nl> + <nl> + Copyright ( c ) 2013 - 2014 winlin <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy of <nl> + this software and associated documentation files ( the " Software " ) , to deal in <nl> + the Software without restriction , including without limitation the rights to <nl> + use , copy , modify , merge , publish , distribute , sublicense , and / or sell copies of <nl> + the Software , and to permit persons to whom the Software is furnished to do so , <nl> + subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in all <nl> + copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , FITNESS <nl> + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR <nl> + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER <nl> + IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN <nl> + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> + * / <nl> + # include < srs_utest_buffer . hpp > <nl> + <nl> + # include < srs_kernel_error . hpp > <nl> + <nl> + MockBufferReader : : MockBufferReader ( const char * data ) <nl> + { <nl> + str = data ; <nl> + } <nl> + <nl> + MockBufferReader : : ~ MockBufferReader ( ) <nl> + { <nl> + } <nl> + <nl> + int MockBufferReader : : read ( void * buf , size_t size , ssize_t * nread ) <nl> + { <nl> + int len = srs_min ( str . length ( ) , size ) ; <nl> + <nl> + memcpy ( buf , str . data ( ) , len ) ; <nl> + <nl> + if ( nread ) { <nl> + * nread = len ; <nl> + } <nl> + <nl> + return ERROR_SUCCESS ; <nl> + } <nl> + <nl> + VOID TEST ( BufferTest , DefaultObject ) <nl> + { <nl> + SrsBuffer b ; <nl> + <nl> + EXPECT_EQ ( 0 , b . length ( ) ) ; <nl> + EXPECT_EQ ( NULL , b . bytes ( ) ) ; <nl> + } <nl> + <nl> + VOID TEST ( BufferTest , AppendBytes ) <nl> + { <nl> + SrsBuffer b ; <nl> + <nl> + char winlin [ ] = " winlin " ; <nl> + b . append ( winlin , strlen ( winlin ) ) ; <nl> + EXPECT_EQ ( ( int ) strlen ( winlin ) , b . length ( ) ) ; <nl> + ASSERT_TRUE ( NULL ! = b . bytes ( ) ) ; <nl> + EXPECT_EQ ( ' w ' , b . bytes ( ) [ 0 ] ) ; <nl> + EXPECT_EQ ( ' n ' , b . bytes ( ) [ 5 ] ) ; <nl> + <nl> + b . append ( winlin , strlen ( winlin ) ) ; <nl> + EXPECT_EQ ( 2 * ( int ) strlen ( winlin ) , b . length ( ) ) ; <nl> + ASSERT_TRUE ( NULL ! = b . bytes ( ) ) ; <nl> + EXPECT_EQ ( ' w ' , b . bytes ( ) [ 0 ] ) ; <nl> + EXPECT_EQ ( ' n ' , b . bytes ( ) [ 5 ] ) ; <nl> + EXPECT_EQ ( ' w ' , b . bytes ( ) [ 6 ] ) ; <nl> + EXPECT_EQ ( ' n ' , b . bytes ( ) [ 11 ] ) ; <nl> + } <nl> + <nl> + VOID TEST ( BufferTest , EraseBytes ) <nl> + { <nl> + SrsBuffer b ; <nl> + <nl> + char winlin [ ] = " winlin " ; <nl> + b . append ( winlin , strlen ( winlin ) ) ; <nl> + b . erase ( b . length ( ) ) ; <nl> + EXPECT_EQ ( 0 , b . length ( ) ) ; <nl> + <nl> + b . append ( winlin , strlen ( winlin ) ) ; <nl> + b . erase ( 1 ) ; <nl> + EXPECT_EQ ( 5 , b . length ( ) ) ; <nl> + EXPECT_EQ ( ' i ' , b . bytes ( ) [ 0 ] ) ; <nl> + EXPECT_EQ ( ' n ' , b . bytes ( ) [ 4 ] ) ; <nl> + b . erase ( 2 ) ; <nl> + EXPECT_EQ ( 3 , b . length ( ) ) ; <nl> + EXPECT_EQ ( ' l ' , b . bytes ( ) [ 0 ] ) ; <nl> + EXPECT_EQ ( ' n ' , b . bytes ( ) [ 2 ] ) ; <nl> + b . erase ( 3 ) ; <nl> + EXPECT_EQ ( 0 , b . length ( ) ) ; <nl> + } <nl> + <nl> + VOID TEST ( BufferTest , Grow ) <nl> + { <nl> + SrsBuffer b ; <nl> + MockBufferReader r ( " winlin " ) ; <nl> + <nl> + b . grow ( & r , 1 ) ; <nl> + EXPECT_EQ ( 6 , b . length ( ) ) ; <nl> + EXPECT_EQ ( ' w ' , b . bytes ( ) [ 0 ] ) ; <nl> + <nl> + b . grow ( & r , 3 ) ; <nl> + EXPECT_EQ ( 6 , b . length ( ) ) ; <nl> + EXPECT_EQ ( ' n ' , b . bytes ( ) [ 2 ] ) ; <nl> + <nl> + b . grow ( & r , 100 ) ; <nl> + EXPECT_EQ ( 102 , b . length ( ) ) ; <nl> + EXPECT_EQ ( ' l ' , b . bytes ( ) [ 99 ] ) ; <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . 6281d0f4b <nl> mmm / dev / null <nl> ppp b / trunk / src / utest / srs_utest_buffer . hpp <nl> <nl> + / * <nl> + The MIT License ( MIT ) <nl> + <nl> + Copyright ( c ) 2013 - 2014 winlin <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy of <nl> + this software and associated documentation files ( the " Software " ) , to deal in <nl> + the Software without restriction , including without limitation the rights to <nl> + use , copy , modify , merge , publish , distribute , sublicense , and / or sell copies of <nl> + the Software , and to permit persons to whom the Software is furnished to do so , <nl> + subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in all <nl> + copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , FITNESS <nl> + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR <nl> + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER <nl> + IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN <nl> + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> + * / <nl> + <nl> + # ifndef SRS_UTEST_BUFFER_HPP <nl> + # define SRS_UTEST_BUFFER_HPP <nl> + <nl> + / * <nl> + # include < srs_utest_buffer . hpp > <nl> + * / <nl> + # include < srs_utest . hpp > <nl> + <nl> + # include < string > <nl> + # include < srs_kernel_buffer . hpp > <nl> + <nl> + class MockBufferReader : public ISrsBufferReader <nl> + { <nl> + private : <nl> + std : : string str ; <nl> + public : <nl> + MockBufferReader ( const char * data ) ; <nl> + virtual ~ MockBufferReader ( ) ; <nl> + public : <nl> + virtual int read ( void * buf , size_t size , ssize_t * nread ) ; <nl> + } ; <nl> + <nl> + # endif <nl>
refine kernel buffer . complete the utest for buffer .
ossrs/srs
94cf0c10696125d5710c6612d5acd23dbf2c5a83
2014-06-07T14:23:17Z
mmm a / amalgamation / amalgamation . py <nl> ppp b / amalgamation / amalgamation . py <nl> def expand ( x , pending , stage ) : <nl> if ( h not in blacklist and <nl> h not in sysheaders and <nl> ' mkl ' not in h and <nl> - ' nnpack ' not in h ) : sysheaders . append ( h ) <nl> + ' nnpack ' not in h and <nl> + not h . endswith ( ' . cuh ' ) ) : sysheaders . append ( h ) <nl> else : <nl> expand ( source , pending + [ x ] , stage ) <nl> print > > out , " / / = = = = = EXPANDED : % s = = = = = \ n " % x <nl>
Update amalgamation . py
apache/incubator-mxnet
23fff3f9a6911db49c70ad60b24b8f1bf26b1e50
2017-02-21T00:38:08Z
mmm a / torch . in <nl> ppp b / torch . in <nl> <nl> - # ! @ Torch_INSTALL_BIN @ / lua <nl> + # ! @ Torch_INSTALL_BIN @ / torch - lua <nl> <nl> - - PREFIX <nl> PREFIX = ' @ Torch_INSTALL_BIN @ ' <nl> require ' paths ' <nl> <nl> - - help / args <nl> help = <nl> - [ = [ Usage : torch [ options ] [ script [ args ] ] <nl> + [ = [ Torch7 Shell <nl> + <nl> + Usage : torch [ options ] [ script [ args ] ] <nl> + <nl> General options : <nl> - b | - bare start a bare environment ( no libs preloaded ) <nl> - e string execute string <nl> General options : <nl> - i enter interactive mode after executing script [ false ] <nl> - v | - version show version information [ false ] <nl> - h | - help this help [ false ] <nl> + <nl> Qt options : <nl> - nographics | - ng disable all the graphical capabilities [ false ] <nl> - ide enable IDE ( graphical console ) [ false ] <nl> - onethread run lua in the main thread ( might be safer ) [ false ] ] = ] <nl> <nl> - - default lua : qlua <nl> - lua = ' qlua ' <nl> + lua = ' torch - qlua ' <nl> <nl> - - preload torch environment <nl> env = ' - e " ' . . " require ' torch ' ; torch . include ( ' torch ' , ' torch . lua ' ) ; " . . ' " ' <nl> interactive = true <nl> for i , a in ipairs ( arg ) do <nl> - - no graphics mode ? <nl> if a = = ' - nographics ' or a = = ' - ng ' then <nl> - lua = ' lua ' <nl> + lua = ' torch - lua ' <nl> arg [ i ] = ' ' <nl> end <nl> - - help ? <nl> end <nl> args = table . concat ( arg , ' ' ) <nl> <nl> - - test qlua existence <nl> - if lua = = ' qlua ' and not paths . filep ( paths . concat ( PREFIX , lua ) ) then <nl> + if lua = = ' torch - qlua ' and not paths . filep ( paths . concat ( PREFIX , lua ) ) then <nl> print ( ' Install Qt4 and rebuild Torch7 for graphics capability ( graphics disabled ) ' ) <nl> - lua = ' lua ' <nl> + lua = ' torch - lua ' <nl> elseif os . getenv ( ' DISPLAY ' ) = = ' ' or os . getenv ( ' DISPLAY ' ) = = nil then <nl> print ( ' Unable to connect X11 server ( disabling graphics ) ' ) <nl> - lua = ' lua ' <nl> + lua = ' torch - lua ' <nl> else <nl> print ( ' Try the IDE : torch - ide ' ) <nl> end <nl>
First basic skeleton for package manager
pytorch/pytorch
ade0d0e1f22811cd42af33dd7c6afe4e3c16ea60
2012-01-30T17:09:02Z
mmm a / tensorflow / contrib / cmake / tf_python . cmake <nl> ppp b / tensorflow / contrib / cmake / tf_python . cmake <nl> add_python_module ( " tensorflow / python / debug / examples " ) <nl> add_python_module ( " tensorflow / python / debug / wrappers " ) <nl> add_python_module ( " tensorflow / python / framework " ) <nl> add_python_module ( " tensorflow / python / kernel_tests " ) <nl> + add_python_module ( " tensorflow / python / layers " ) <nl> add_python_module ( " tensorflow / python / lib " ) <nl> add_python_module ( " tensorflow / python / lib / core " ) <nl> add_python_module ( " tensorflow / python / lib / io " ) <nl>
Add tensorflow / python / layers module to tf_python . cmake
tensorflow/tensorflow
6ec4fdf619cb981ed0ca1d0ca4dad640355fa6da
2016-11-24T16:58:14Z
mmm a / src / ruby / lib / grpc / grpc . rb <nl> ppp b / src / ruby / lib / grpc / grpc . rb <nl> <nl> if File . directory ? ( distrib_lib_dir ) <nl> require_relative " # { distrib_lib_dir } / grpc_c " <nl> else <nl> - require_relative ' grpc_c ' <nl> + require ' grpc / grpc_c ' <nl> end <nl> end <nl>
Merge pull request from ernie / use - arch - extensions - dir
grpc/grpc
35766734e8e7ae9378ea557437b0119711233902
2017-05-19T22:30:07Z
mmm a / stdlib / objc / Darwin / Darwin . swift <nl> ppp b / stdlib / objc / Darwin / Darwin . swift <nl> <nl> @ exported import Darwin / / Clang module <nl> <nl> <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / MacTypes . h <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + public let noErr : OSStatus = 0 <nl> + <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / sys / errno . h <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> mmm a / stdlib / objc / Foundation / Foundation . swift <nl> ppp b / stdlib / objc / Foundation / Foundation . swift <nl> public let NSUTF16LittleEndianStringEncoding : UInt = 0x94000100 <nl> public let NSUTF32StringEncoding : UInt = 0x8c000100 <nl> public let NSUTF32BigEndianStringEncoding : UInt = 0x98000100 <nl> public let NSUTF32LittleEndianStringEncoding : UInt = 0x9c000100 <nl> - public let noErr : Int32 = 0 <nl> <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl>
Move noErr to Darwin with OSStatus as its type .
apple/swift
5197fe0f9d133e016de67fddedd24e2e602de52c
2014-07-21T21:14:27Z
mmm a / docs / WindowsBuild . md <nl> ppp b / docs / WindowsBuild . md <nl> cmake - B " S : \ b \ toolchain " - G Ninja - S S : \ toolchain \ llvm ^ <nl> - DSWIFT_PATH_TO_LIBDISPATCH_SOURCE = S : \ toolchain \ swift - corelibs - libdispatch ^ <nl> - DLLVM_ENABLE_PDB = YES ^ <nl> - DLLVM_ENABLE_LIBEDIT = NO ^ <nl> - - DLLDB_DISABLE_PYTHON = YES ^ <nl> + - DLLDB_ENABLE_PYTHON = NO ^ <nl> - DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE = " S : / Library / icu - 64 / usr / include " ^ <nl> - DSWIFT_WINDOWS_x86_64_ICU_UC = " S : / Library / icu - 64 / usr / lib / icuuc64 . lib " ^ <nl> - DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE = " S : / Library / icu - 64 / usr / include " ^ <nl>
Merge pull request from apple / compnerd - lldb - python - flag
apple/swift
54fd54c21930a9f13746f6dceec2cdf0ef5c50c1
2020-04-22T16:23:44Z
similarity index 100 % <nl> rename from leveldb / AUTHORS <nl> rename to AUTHORS <nl> similarity index 100 % <nl> rename from leveldb / LICENSE <nl> rename to LICENSE <nl> similarity index 95 % <nl> rename from leveldb / Makefile <nl> rename to Makefile <nl> mmm a / leveldb / Makefile <nl> ppp b / Makefile <nl> LIBOBJECTS = \ <nl> . / db / version_set . o \ <nl> . / db / write_batch . o \ <nl> . / port / port_posix . o \ <nl> + . / port / sha1_portable . o \ <nl> . / table / block . o \ <nl> . / table / block_builder . o \ <nl> . / table / format . o \ <nl> TESTS = \ <nl> env_test \ <nl> filename_test \ <nl> log_test \ <nl> + sha1_test \ <nl> skiplist_test \ <nl> table_test \ <nl> version_edit_test \ <nl> log_test : db / log_test . o $ ( LIBOBJECTS ) $ ( TESTHARNESS ) <nl> table_test : table / table_test . o $ ( LIBOBJECTS ) $ ( TESTHARNESS ) <nl> $ ( CC ) $ ( LDFLAGS ) table / table_test . o $ ( LIBOBJECTS ) $ ( TESTHARNESS ) - o $ @ <nl> <nl> + sha1_test : port / sha1_test . o $ ( LIBOBJECTS ) $ ( TESTHARNESS ) <nl> + $ ( CC ) $ ( LDFLAGS ) port / sha1_test . o $ ( LIBOBJECTS ) $ ( TESTHARNESS ) - o $ @ <nl> + <nl> skiplist_test : db / skiplist_test . o $ ( LIBOBJECTS ) $ ( TESTHARNESS ) <nl> $ ( CC ) $ ( LDFLAGS ) db / skiplist_test . o $ ( LIBOBJECTS ) $ ( TESTHARNESS ) - o $ @ <nl> <nl> similarity index 94 % <nl> rename from leveldb / README <nl> rename to README <nl> mmm a / leveldb / README <nl> ppp b / README <nl> leveldb : A key - value store <nl> Authors : Sanjay Ghemawat ( sanjay @ google . com ) and Jeff Dean ( jeff @ google . com ) <nl> <nl> The code under this directory implements a system for maintaining a <nl> - persistent key / value store . <nl> + persistent key / value store . <nl> <nl> See doc / index . html for more explanation . <nl> - See doc / impl . html for a brief overview of the implementation . <nl> + See doc / db_layout . txt for a brief overview of the implementation . <nl> <nl> The public interface is in include / * . h . Callers should not include or <nl> rely on the details of any other header files in this package . Those <nl> similarity index 85 % <nl> rename from leveldb / TODO <nl> rename to TODO <nl> mmm a / leveldb / TODO <nl> ppp b / TODO <nl> db <nl> object stores , etc . can be done in the background anyway , so <nl> probably not that important . <nl> <nl> - api changes : <nl> - - Make it wrappable <nl> + api changes ? <nl> + - Efficient large value reading and writing <nl> <nl> Faster Get implementation <nl> similarity index 85 % <nl> rename from leveldb / db / builder . cc <nl> rename to db / builder . cc <nl> mmm a / leveldb / db / builder . cc <nl> ppp b / db / builder . cc <nl> Status BuildTable ( const std : : string & dbname , <nl> for ( ; iter - > Valid ( ) ; iter - > Next ( ) ) { <nl> Slice key = iter - > key ( ) ; <nl> meta - > largest . DecodeFrom ( key ) ; <nl> + if ( ExtractValueType ( key ) = = kTypeLargeValueRef ) { <nl> + if ( iter - > value ( ) . size ( ) ! = LargeValueRef : : ByteSize ( ) ) { <nl> + s = Status : : Corruption ( " invalid indirect reference hash value ( L0 ) " ) ; <nl> + break ; <nl> + } <nl> + edit - > AddLargeValueRef ( LargeValueRef : : FromRef ( iter - > value ( ) ) , <nl> + meta - > number , <nl> + iter - > key ( ) ) ; <nl> + } <nl> builder - > Add ( key , iter - > value ( ) ) ; <nl> } <nl> <nl> similarity index 84 % <nl> rename from leveldb / db / builder . h <nl> rename to db / builder . h <nl> mmm a / leveldb / db / builder . h <nl> ppp b / db / builder . h <nl> class VersionEdit ; <nl> / / Build a Table file from the contents of * iter . The generated file <nl> / / will be named according to meta - > number . On success , the rest of <nl> / / * meta will be filled with metadata about the generated table , and <nl> - / / the file information will be added to * edit . If no data is present <nl> - / / in * iter , meta - > file_size will be set to zero , and no Table file <nl> - / / will be produced . <nl> + / / large value refs and the added file information will be added to <nl> + / / * edit . If no data is present in * iter , meta - > file_size will be set <nl> + / / to zero , and no Table file will be produced . <nl> extern Status BuildTable ( const std : : string & dbname , <nl> Env * env , <nl> const Options & options , <nl> similarity index 93 % <nl> rename from leveldb / db / corruption_test . cc <nl> rename to db / corruption_test . cc <nl> mmm a / leveldb / db / corruption_test . cc <nl> ppp b / db / corruption_test . cc <nl> class CorruptionTest { <nl> std : : vector < std : : string > filenames ; <nl> ASSERT_OK ( env_ . GetChildren ( dbname_ , & filenames ) ) ; <nl> uint64_t number ; <nl> + LargeValueRef large_ref ; <nl> FileType type ; <nl> std : : vector < std : : string > candidates ; <nl> for ( int i = 0 ; i < filenames . size ( ) ; i + + ) { <nl> - if ( ParseFileName ( filenames [ i ] , & number , & type ) & & <nl> + if ( ParseFileName ( filenames [ i ] , & number , & large_ref , & type ) & & <nl> type = = filetype ) { <nl> candidates . push_back ( dbname_ + " / " + filenames [ i ] ) ; <nl> } <nl> TEST ( CorruptionTest , SequenceNumberRecovery ) { <nl> ASSERT_EQ ( " v6 " , v ) ; <nl> } <nl> <nl> + TEST ( CorruptionTest , LargeValueRecovery ) { <nl> + Options options ; <nl> + options . large_value_threshold = 10000 ; <nl> + Reopen ( & options ) ; <nl> + <nl> + Random rnd ( 301 ) ; <nl> + std : : string big ; <nl> + ASSERT_OK ( db_ - > Put ( WriteOptions ( ) , <nl> + " foo " , test : : RandomString ( & rnd , 100000 , & big ) ) ) ; <nl> + std : : string v ; <nl> + ASSERT_OK ( db_ - > Get ( ReadOptions ( ) , " foo " , & v ) ) ; <nl> + ASSERT_EQ ( big , v ) ; <nl> + <nl> + RepairDB ( ) ; <nl> + Reopen ( ) ; <nl> + ASSERT_OK ( db_ - > Get ( ReadOptions ( ) , " foo " , & v ) ) ; <nl> + ASSERT_EQ ( big , v ) ; <nl> + <nl> + Reopen ( ) ; <nl> + ASSERT_OK ( db_ - > Get ( ReadOptions ( ) , " foo " , & v ) ) ; <nl> + ASSERT_EQ ( big , v ) ; <nl> + } <nl> + <nl> TEST ( CorruptionTest , CorruptedDescriptor ) { <nl> ASSERT_OK ( db_ - > Put ( WriteOptions ( ) , " foo " , " hello " ) ) ; <nl> DBImpl * dbi = reinterpret_cast < DBImpl * > ( db_ ) ; <nl> similarity index 96 % <nl> rename from leveldb / db / db_bench . cc <nl> rename to db / db_bench . cc <nl> mmm a / leveldb / db / db_bench . cc <nl> ppp b / db / db_bench . cc <nl> <nl> / / readreverse - - read N values in reverse order <nl> / / readrandom - - read N values in random order <nl> / / crc32c - - repeated crc32c of 4K of data <nl> + / / sha1 - - repeated SHA1 computation over 4K of data <nl> / / Meta operations : <nl> / / compact - - Compact the entire DB <nl> / / stats - - Print DB stats <nl> static const char * FLAGS_benchmarks = <nl> " readreverse , " <nl> " fill100K , " <nl> " crc32c , " <nl> + " sha1 , " <nl> " snappycomp , " <nl> " snappyuncomp , " <nl> ; <nl> class Benchmark { <nl> Compact ( ) ; <nl> } else if ( name = = Slice ( " crc32c " ) ) { <nl> Crc32c ( 4096 , " ( 4K per op ) " ) ; <nl> + } else if ( name = = Slice ( " sha1 " ) ) { <nl> + SHA1 ( 4096 , " ( 4K per op ) " ) ; <nl> } else if ( name = = Slice ( " snappycomp " ) ) { <nl> SnappyCompress ( ) ; <nl> } else if ( name = = Slice ( " snappyuncomp " ) ) { <nl> class Benchmark { <nl> message_ = label ; <nl> } <nl> <nl> + void SHA1 ( int size , const char * label ) { <nl> + / / SHA1 about 100MB of data total <nl> + std : : string data ( size , ' x ' ) ; <nl> + int64_t bytes = 0 ; <nl> + char sha1 [ 20 ] ; <nl> + while ( bytes < 100 * 1048576 ) { <nl> + port : : SHA1_Hash ( data . data ( ) , size , sha1 ) ; <nl> + FinishedSingleOp ( ) ; <nl> + bytes + = size ; <nl> + } <nl> + <nl> + / / Print so result is not dead <nl> + fprintf ( stderr , " . . . sha1 = % 02x . . . \ r " , static_cast < unsigned int > ( sha1 [ 0 ] ) ) ; <nl> + <nl> + bytes_ = bytes ; <nl> + message_ = label ; <nl> + } <nl> + <nl> void SnappyCompress ( ) { <nl> Slice input = gen_ . Generate ( Options ( ) . block_size ) ; <nl> int64_t bytes = 0 ; <nl> similarity index 83 % <nl> rename from leveldb / db / db_impl . cc <nl> rename to db / db_impl . cc <nl> mmm a / leveldb / db / db_impl . cc <nl> ppp b / db / db_impl . cc <nl> class NullWritableFile : public WritableFile { <nl> / / Fix user - supplied options to be reasonable <nl> template < class T , class V > <nl> static void ClipToRange ( T * ptr , V minvalue , V maxvalue ) { <nl> - if ( static_cast < V > ( * ptr ) > maxvalue ) * ptr = maxvalue ; <nl> - if ( static_cast < V > ( * ptr ) < minvalue ) * ptr = minvalue ; <nl> + if ( * ptr > maxvalue ) * ptr = maxvalue ; <nl> + if ( * ptr < minvalue ) * ptr = minvalue ; <nl> } <nl> Options SanitizeOptions ( const std : : string & dbname , <nl> const InternalKeyComparator * icmp , <nl> Options SanitizeOptions ( const std : : string & dbname , <nl> result . comparator = icmp ; <nl> ClipToRange ( & result . max_open_files , 20 , 50000 ) ; <nl> ClipToRange ( & result . write_buffer_size , 64 < < 10 , 1 < < 30 ) ; <nl> + ClipToRange ( & result . large_value_threshold , 16 < < 10 , 1 < < 30 ) ; <nl> ClipToRange ( & result . block_size , 1 < < 10 , 4 < < 20 ) ; <nl> if ( result . info_log = = NULL ) { <nl> / / Open a log file in the same directory as the db <nl> void DBImpl : : DeleteObsoleteFiles ( ) { <nl> std : : set < uint64_t > live = pending_outputs_ ; <nl> versions_ - > AddLiveFiles ( & live ) ; <nl> <nl> + versions_ - > CleanupLargeValueRefs ( live ) ; <nl> + <nl> std : : vector < std : : string > filenames ; <nl> env_ - > GetChildren ( dbname_ , & filenames ) ; / / Ignoring errors on purpose <nl> uint64_t number ; <nl> + LargeValueRef large_ref ; <nl> FileType type ; <nl> - for ( size_t i = 0 ; i < filenames . size ( ) ; i + + ) { <nl> - if ( ParseFileName ( filenames [ i ] , & number , & type ) ) { <nl> + for ( int i = 0 ; i < filenames . size ( ) ; i + + ) { <nl> + if ( ParseFileName ( filenames [ i ] , & number , & large_ref , & type ) ) { <nl> bool keep = true ; <nl> switch ( type ) { <nl> case kLogFile : <nl> void DBImpl : : DeleteObsoleteFiles ( ) { <nl> / / be recorded in pending_outputs_ , which is inserted into " live " <nl> keep = ( live . find ( number ) ! = live . end ( ) ) ; <nl> break ; <nl> + case kLargeValueFile : <nl> + keep = versions_ - > LargeValueIsLive ( large_ref ) ; <nl> + break ; <nl> case kCurrentFile : <nl> case kDBLockFile : <nl> case kInfoLogFile : <nl> void DBImpl : : CleanupCompaction ( CompactionState * compact ) { <nl> assert ( compact - > outfile = = NULL ) ; <nl> } <nl> delete compact - > outfile ; <nl> - for ( size_t i = 0 ; i < compact - > outputs . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < compact - > outputs . size ( ) ; i + + ) { <nl> const CompactionState : : Output & out = compact - > outputs [ i ] ; <nl> pending_outputs_ . erase ( out . number ) ; <nl> } <nl> Status DBImpl : : InstallCompactionResults ( CompactionState * compact ) { <nl> / / Add compaction outputs <nl> compact - > compaction - > AddInputDeletions ( compact - > compaction - > edit ( ) ) ; <nl> const int level = compact - > compaction - > level ( ) ; <nl> - for ( size_t i = 0 ; i < compact - > outputs . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < compact - > outputs . size ( ) ; i + + ) { <nl> const CompactionState : : Output & out = compact - > outputs [ i ] ; <nl> compact - > compaction - > edit ( ) - > AddFile ( <nl> level + 1 , <nl> Status DBImpl : : InstallCompactionResults ( CompactionState * compact ) { <nl> DeleteObsoleteFiles ( ) ; <nl> } else { <nl> / / Discard any files we may have created during this failed compaction <nl> - for ( size_t i = 0 ; i < compact - > outputs . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < compact - > outputs . size ( ) ; i + + ) { <nl> env_ - > DeleteFile ( TableFileName ( dbname_ , compact - > outputs [ i ] . number ) ) ; <nl> } <nl> } <nl> Status DBImpl : : DoCompactionWork ( CompactionState * compact ) { <nl> " Compact : % s , seq % d , type : % d % d , drop : % d , is_base : % d , " <nl> " % d smallest_snapshot : % d " , <nl> ikey . user_key . ToString ( ) . c_str ( ) , <nl> - ( int ) ikey . sequence , ikey . type , kTypeValue , drop , <nl> + ( int ) ikey . sequence , ikey . type , kTypeLargeValueRef , drop , <nl> compact - > compaction - > IsBaseLevelForKey ( ikey . user_key ) , <nl> ( int ) last_sequence_for_key , ( int ) compact - > smallest_snapshot ) ; <nl> # endif <nl> Status DBImpl : : DoCompactionWork ( CompactionState * compact ) { <nl> compact - > current_output ( ) - > smallest . DecodeFrom ( key ) ; <nl> } <nl> compact - > current_output ( ) - > largest . DecodeFrom ( key ) ; <nl> - compact - > builder - > Add ( key , input - > value ( ) ) ; <nl> + <nl> + if ( ikey . type = = kTypeLargeValueRef ) { <nl> + if ( input - > value ( ) . size ( ) ! = LargeValueRef : : ByteSize ( ) ) { <nl> + if ( options_ . paranoid_checks ) { <nl> + status = Status : : Corruption ( " invalid large value ref " ) ; <nl> + break ; <nl> + } else { <nl> + Log ( env_ , options_ . info_log , <nl> + " compaction found invalid large value ref " ) ; <nl> + } <nl> + } else { <nl> + compact - > compaction - > edit ( ) - > AddLargeValueRef ( <nl> + LargeValueRef : : FromRef ( input - > value ( ) ) , <nl> + compact - > current_output ( ) - > number , <nl> + input - > key ( ) ) ; <nl> + compact - > builder - > Add ( key , input - > value ( ) ) ; <nl> + } <nl> + } else { <nl> + compact - > builder - > Add ( key , input - > value ( ) ) ; <nl> + } <nl> <nl> / / Close output file if it is big enough <nl> if ( compact - > builder - > FileSize ( ) > = <nl> Status DBImpl : : DoCompactionWork ( CompactionState * compact ) { <nl> stats . bytes_read + = compact - > compaction - > input ( which , i ) - > file_size ; <nl> } <nl> } <nl> - for ( size_t i = 0 ; i < compact - > outputs . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < compact - > outputs . size ( ) ; i + + ) { <nl> stats . bytes_written + = compact - > outputs [ i ] . file_size ; <nl> } <nl> <nl> Status DBImpl : : Delete ( const WriteOptions & options , const Slice & key ) { <nl> <nl> Status DBImpl : : Write ( const WriteOptions & options , WriteBatch * updates ) { <nl> Status status ; <nl> - MutexLock l ( & mutex_ ) ; <nl> - status = MakeRoomForWrite ( false ) ; / / May temporarily release lock and wait <nl> - uint64_t last_sequence = versions_ - > LastSequence ( ) ; <nl> - if ( status . ok ( ) ) { <nl> - WriteBatchInternal : : SetSequence ( updates , last_sequence + 1 ) ; <nl> - last_sequence + = WriteBatchInternal : : Count ( updates ) ; <nl> - versions_ - > SetLastSequence ( last_sequence ) ; <nl> - <nl> - / / Add to log and apply to memtable <nl> - status = log_ - > AddRecord ( WriteBatchInternal : : Contents ( updates ) ) ; <nl> - if ( status . ok ( ) & & options . sync ) { <nl> - status = logfile_ - > Sync ( ) ; <nl> + <nl> + WriteBatch * final = NULL ; <nl> + { <nl> + MutexLock l ( & mutex_ ) ; <nl> + status = MakeRoomForWrite ( false ) ; / / May temporarily release lock and wait <nl> + <nl> + uint64_t last_sequence = versions_ - > LastSequence ( ) ; <nl> + if ( status . ok ( ) ) { <nl> + status = HandleLargeValues ( last_sequence + 1 , updates , & final ) ; <nl> } <nl> if ( status . ok ( ) ) { <nl> - status = WriteBatchInternal : : InsertInto ( updates , mem_ ) ; <nl> + WriteBatchInternal : : SetSequence ( final , last_sequence + 1 ) ; <nl> + last_sequence + = WriteBatchInternal : : Count ( final ) ; <nl> + versions_ - > SetLastSequence ( last_sequence ) ; <nl> + <nl> + / / Add to log and apply to memtable <nl> + status = log_ - > AddRecord ( WriteBatchInternal : : Contents ( final ) ) ; <nl> + if ( status . ok ( ) & & options . sync ) { <nl> + status = logfile_ - > Sync ( ) ; <nl> + } <nl> + if ( status . ok ( ) ) { <nl> + status = WriteBatchInternal : : InsertInto ( final , mem_ ) ; <nl> + } <nl> + } <nl> + <nl> + if ( options . post_write_snapshot ! = NULL ) { <nl> + * options . post_write_snapshot = <nl> + status . ok ( ) ? snapshots_ . New ( last_sequence ) : NULL ; <nl> } <nl> } <nl> - if ( options . post_write_snapshot ! = NULL ) { <nl> - * options . post_write_snapshot = <nl> - status . ok ( ) ? snapshots_ . New ( last_sequence ) : NULL ; <nl> + if ( final ! = updates ) { <nl> + delete final ; <nl> } <nl> + <nl> return status ; <nl> } <nl> <nl> Status DBImpl : : MakeRoomForWrite ( bool force ) { <nl> return s ; <nl> } <nl> <nl> + bool DBImpl : : HasLargeValues ( const WriteBatch & batch ) const { <nl> + if ( WriteBatchInternal : : ByteSize ( & batch ) > = options_ . large_value_threshold ) { <nl> + for ( WriteBatchInternal : : Iterator it ( batch ) ; ! it . Done ( ) ; it . Next ( ) ) { <nl> + if ( it . op ( ) = = kTypeValue & & <nl> + it . value ( ) . size ( ) > = options_ . large_value_threshold ) { <nl> + return true ; <nl> + } <nl> + } <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / Given " raw_value " , determines the appropriate compression format to use <nl> + / / and stores the data that should be written to the large value file in <nl> + / / " * file_bytes " , and sets " * ref " to the appropriate large value reference . <nl> + / / May use " * scratch " as backing store for " * file_bytes " . <nl> + void DBImpl : : MaybeCompressLargeValue ( <nl> + const Slice & raw_value , <nl> + Slice * file_bytes , <nl> + std : : string * scratch , <nl> + LargeValueRef * ref ) { <nl> + switch ( options_ . compression ) { <nl> + case kSnappyCompression : { <nl> + if ( port : : Snappy_Compress ( raw_value . data ( ) , raw_value . size ( ) , scratch ) & & <nl> + ( scratch - > size ( ) < ( raw_value . size ( ) / 8 ) * 7 ) ) { <nl> + * file_bytes = * scratch ; <nl> + * ref = LargeValueRef : : Make ( raw_value , kSnappyCompression ) ; <nl> + return ; <nl> + } <nl> + <nl> + / / Less than 12 . 5 % compression : just leave as uncompressed data <nl> + break ; <nl> + } <nl> + case kNoCompression : <nl> + / / Use default code outside of switch <nl> + break ; <nl> + } <nl> + / / Store as uncompressed data <nl> + * file_bytes = raw_value ; <nl> + * ref = LargeValueRef : : Make ( raw_value , kNoCompression ) ; <nl> + } <nl> + <nl> + Status DBImpl : : HandleLargeValues ( SequenceNumber assigned_seq , <nl> + WriteBatch * updates , <nl> + WriteBatch * * final ) { <nl> + if ( ! HasLargeValues ( * updates ) ) { <nl> + / / Fast path : no large values found <nl> + * final = updates ; <nl> + } else { <nl> + / / Copy * updates to a new WriteBatch , replacing the references to <nl> + * final = new WriteBatch ; <nl> + SequenceNumber seq = assigned_seq ; <nl> + for ( WriteBatchInternal : : Iterator it ( * updates ) ; ! it . Done ( ) ; it . Next ( ) ) { <nl> + switch ( it . op ( ) ) { <nl> + case kTypeValue : <nl> + if ( it . value ( ) . size ( ) < options_ . large_value_threshold ) { <nl> + ( * final ) - > Put ( it . key ( ) , it . value ( ) ) ; <nl> + } else { <nl> + std : : string scratch ; <nl> + Slice file_bytes ; <nl> + LargeValueRef large_ref ; <nl> + MaybeCompressLargeValue ( <nl> + it . value ( ) , & file_bytes , & scratch , & large_ref ) ; <nl> + InternalKey ikey ( it . key ( ) , seq , kTypeLargeValueRef ) ; <nl> + if ( versions_ - > RegisterLargeValueRef ( <nl> + large_ref , versions_ - > LogNumber ( ) , ikey ) ) { <nl> + / / TODO ( opt ) : avoid holding the lock here ( but be careful about <nl> + / / another thread doing a Write and switching logs or <nl> + / / having us get a different " assigned_seq " value ) . <nl> + <nl> + uint64_t tmp_number = versions_ - > NewFileNumber ( ) ; <nl> + pending_outputs_ . insert ( tmp_number ) ; <nl> + std : : string tmp = TempFileName ( dbname_ , tmp_number ) ; <nl> + WritableFile * file ; <nl> + Status s = env_ - > NewWritableFile ( tmp , & file ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + return s ; / / Caller will delete * final <nl> + } <nl> + <nl> + file - > Append ( file_bytes ) ; <nl> + <nl> + s = file - > Close ( ) ; <nl> + delete file ; <nl> + <nl> + if ( s . ok ( ) ) { <nl> + const std : : string fname = <nl> + LargeValueFileName ( dbname_ , large_ref ) ; <nl> + s = env_ - > RenameFile ( tmp , fname ) ; <nl> + } else { <nl> + Log ( env_ , options_ . info_log , " Write large value : % s " , <nl> + s . ToString ( ) . c_str ( ) ) ; <nl> + } <nl> + pending_outputs_ . erase ( tmp_number ) ; <nl> + <nl> + if ( ! s . ok ( ) ) { <nl> + env_ - > DeleteFile ( tmp ) ; / / Cleanup ; intentionally ignoring error <nl> + return s ; / / Caller will delete * final <nl> + } <nl> + } <nl> + <nl> + / / Put an indirect reference in the write batch in place <nl> + / / of large value <nl> + WriteBatchInternal : : PutLargeValueRef ( * final , it . key ( ) , large_ref ) ; <nl> + } <nl> + break ; <nl> + case kTypeLargeValueRef : <nl> + return Status : : Corruption ( " Corrupted write batch " ) ; <nl> + break ; <nl> + case kTypeDeletion : <nl> + ( * final ) - > Delete ( it . key ( ) ) ; <nl> + break ; <nl> + } <nl> + seq = seq + 1 ; <nl> + } <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> bool DBImpl : : GetProperty ( const Slice & property , std : : string * value ) { <nl> value - > clear ( ) ; <nl> <nl> bool DBImpl : : GetProperty ( const Slice & property , std : : string * value ) { <nl> return false ; <nl> } else { <nl> char buf [ 100 ] ; <nl> - snprintf ( buf , sizeof ( buf ) , " % d " , <nl> - versions_ - > NumLevelFiles ( static_cast < int > ( level ) ) ) ; <nl> + snprintf ( buf , sizeof ( buf ) , " % d " , versions_ - > NumLevelFiles ( level ) ) ; <nl> * value = buf ; <nl> return true ; <nl> } <nl> Status DestroyDB ( const std : : string & dbname , const Options & options ) { <nl> Status result = env - > LockFile ( LockFileName ( dbname ) , & lock ) ; <nl> if ( result . ok ( ) ) { <nl> uint64_t number ; <nl> + LargeValueRef large_ref ; <nl> FileType type ; <nl> - for ( size_t i = 0 ; i < filenames . size ( ) ; i + + ) { <nl> - if ( ParseFileName ( filenames [ i ] , & number , & type ) ) { <nl> + for ( int i = 0 ; i < filenames . size ( ) ; i + + ) { <nl> + if ( ParseFileName ( filenames [ i ] , & number , & large_ref , & type ) ) { <nl> Status del = env - > DeleteFile ( dbname + " / " + filenames [ i ] ) ; <nl> if ( result . ok ( ) & & ! del . ok ( ) ) { <nl> result = del ; <nl> similarity index 84 % <nl> rename from leveldb / db / db_impl . h <nl> rename to db / db_impl . h <nl> mmm a / leveldb / db / db_impl . h <nl> ppp b / db / db_impl . h <nl> class DBImpl : public DB { <nl> Status WriteLevel0Table ( MemTable * mem , VersionEdit * edit ) ; <nl> <nl> Status MakeRoomForWrite ( bool force / * compact even if there is room ? * / ) ; <nl> + bool HasLargeValues ( const WriteBatch & batch ) const ; <nl> + <nl> + / / Process data in " * updates " and return a status . " assigned_seq " <nl> + / / is the sequence number assigned to the first mod in " * updates " . <nl> + / / If no large values are encountered , " * final " is set to " updates " . <nl> + / / If large values were encountered , registers the references of the <nl> + / / large values with the VersionSet , writes the large values to <nl> + / / files ( if appropriate ) , and allocates a new WriteBatch with the <nl> + / / large values replaced with indirect references and stores a <nl> + / / pointer to the new WriteBatch in * final . If * final ! = updates on <nl> + / / return , then the client should delete * final when no longer <nl> + / / needed . Returns OK on success , and an appropriate error <nl> + / / otherwise . <nl> + Status HandleLargeValues ( SequenceNumber assigned_seq , <nl> + WriteBatch * updates , <nl> + WriteBatch * * final ) ; <nl> + <nl> + / / Helper routine for HandleLargeValues <nl> + void MaybeCompressLargeValue ( <nl> + const Slice & raw_value , <nl> + Slice * file_bytes , <nl> + std : : string * scratch , <nl> + LargeValueRef * ref ) ; <nl> <nl> struct CompactionState ; <nl> <nl> similarity index 72 % <nl> rename from leveldb / db / db_iter . cc <nl> rename to db / db_iter . cc <nl> mmm a / leveldb / db / db_iter . cc <nl> ppp b / db / db_iter . cc <nl> class DBIter : public Iterator { <nl> user_comparator_ ( cmp ) , <nl> iter_ ( iter ) , <nl> sequence_ ( s ) , <nl> + large_ ( NULL ) , <nl> direction_ ( kForward ) , <nl> valid_ ( false ) { <nl> } <nl> virtual ~ DBIter ( ) { <nl> delete iter_ ; <nl> + delete large_ ; <nl> } <nl> virtual bool Valid ( ) const { return valid_ ; } <nl> virtual Slice key ( ) const { <nl> class DBIter : public Iterator { <nl> } <nl> virtual Slice value ( ) const { <nl> assert ( valid_ ) ; <nl> - return ( direction_ = = kForward ) ? iter_ - > value ( ) : saved_value_ ; <nl> + Slice raw_value = ( direction_ = = kForward ) ? iter_ - > value ( ) : saved_value_ ; <nl> + if ( large_ = = NULL ) { <nl> + return raw_value ; <nl> + } else { <nl> + MutexLock l ( & large_ - > mutex ) ; <nl> + if ( ! large_ - > produced ) { <nl> + ReadIndirectValue ( raw_value ) ; <nl> + } <nl> + return large_ - > value ; <nl> + } <nl> } <nl> virtual Status status ( ) const { <nl> if ( status_ . ok ( ) ) { <nl> + if ( large_ ! = NULL & & ! large_ - > status . ok ( ) ) return large_ - > status ; <nl> return iter_ - > status ( ) ; <nl> } else { <nl> return status_ ; <nl> class DBIter : public Iterator { <nl> virtual void SeekToLast ( ) ; <nl> <nl> private : <nl> + struct Large { <nl> + port : : Mutex mutex ; <nl> + std : : string value ; <nl> + bool produced ; <nl> + Status status ; <nl> + } ; <nl> + <nl> void FindNextUserEntry ( bool skipping , std : : string * skip ) ; <nl> void FindPrevUserEntry ( ) ; <nl> bool ParseKey ( ParsedInternalKey * key ) ; <nl> + void ReadIndirectValue ( Slice ref ) const ; <nl> <nl> inline void SaveKey ( const Slice & k , std : : string * dst ) { <nl> dst - > assign ( k . data ( ) , k . size ( ) ) ; <nl> } <nl> <nl> + inline void ForgetLargeValue ( ) { <nl> + if ( large_ ! = NULL ) { <nl> + delete large_ ; <nl> + large_ = NULL ; <nl> + } <nl> + } <nl> + <nl> inline void ClearSavedValue ( ) { <nl> if ( saved_value_ . capacity ( ) > 1048576 ) { <nl> std : : string empty ; <nl> class DBIter : public Iterator { <nl> Status status_ ; <nl> std : : string saved_key_ ; / / = = current key when direction_ = = kReverse <nl> std : : string saved_value_ ; / / = = current raw value when direction_ = = kReverse <nl> + Large * large_ ; / / Non - NULL if value is an indirect reference <nl> Direction direction_ ; <nl> bool valid_ ; <nl> <nl> inline bool DBIter : : ParseKey ( ParsedInternalKey * ikey ) { <nl> <nl> void DBIter : : Next ( ) { <nl> assert ( valid_ ) ; <nl> + ForgetLargeValue ( ) ; <nl> <nl> if ( direction_ = = kReverse ) { / / Switch directions ? <nl> direction_ = kForward ; <nl> void DBIter : : FindNextUserEntry ( bool skipping , std : : string * skip ) { <nl> / / Loop until we hit an acceptable entry to yield <nl> assert ( iter_ - > Valid ( ) ) ; <nl> assert ( direction_ = = kForward ) ; <nl> + assert ( large_ = = NULL ) ; <nl> do { <nl> ParsedInternalKey ikey ; <nl> if ( ParseKey ( & ikey ) & & ikey . sequence < = sequence_ ) { <nl> void DBIter : : FindNextUserEntry ( bool skipping , std : : string * skip ) { <nl> skipping = true ; <nl> break ; <nl> case kTypeValue : <nl> + case kTypeLargeValueRef : <nl> if ( skipping & & <nl> user_comparator_ - > Compare ( ikey . user_key , * skip ) < = 0 ) { <nl> / / Entry hidden <nl> } else { <nl> valid_ = true ; <nl> saved_key_ . clear ( ) ; <nl> + if ( ikey . type = = kTypeLargeValueRef ) { <nl> + large_ = new Large ; <nl> + large_ - > produced = false ; <nl> + } <nl> return ; <nl> } <nl> break ; <nl> void DBIter : : FindNextUserEntry ( bool skipping , std : : string * skip ) { <nl> <nl> void DBIter : : Prev ( ) { <nl> assert ( valid_ ) ; <nl> + ForgetLargeValue ( ) ; <nl> <nl> if ( direction_ = = kForward ) { / / Switch directions ? <nl> / / iter_ is pointing at the current entry . Scan backwards until <nl> void DBIter : : Prev ( ) { <nl> <nl> void DBIter : : FindPrevUserEntry ( ) { <nl> assert ( direction_ = = kReverse ) ; <nl> + assert ( large_ = = NULL ) ; <nl> <nl> ValueType value_type = kTypeDeletion ; <nl> if ( iter_ - > Valid ( ) ) { <nl> void DBIter : : FindPrevUserEntry ( ) { <nl> direction_ = kForward ; <nl> } else { <nl> valid_ = true ; <nl> + if ( value_type = = kTypeLargeValueRef ) { <nl> + large_ = new Large ; <nl> + large_ - > produced = false ; <nl> + } <nl> } <nl> } <nl> <nl> void DBIter : : Seek ( const Slice & target ) { <nl> direction_ = kForward ; <nl> + ForgetLargeValue ( ) ; <nl> ClearSavedValue ( ) ; <nl> saved_key_ . clear ( ) ; <nl> AppendInternalKey ( <nl> void DBIter : : Seek ( const Slice & target ) { <nl> <nl> void DBIter : : SeekToFirst ( ) { <nl> direction_ = kForward ; <nl> + ForgetLargeValue ( ) ; <nl> ClearSavedValue ( ) ; <nl> iter_ - > SeekToFirst ( ) ; <nl> if ( iter_ - > Valid ( ) ) { <nl> void DBIter : : SeekToFirst ( ) { <nl> <nl> void DBIter : : SeekToLast ( ) { <nl> direction_ = kReverse ; <nl> + ForgetLargeValue ( ) ; <nl> ClearSavedValue ( ) ; <nl> iter_ - > SeekToLast ( ) ; <nl> FindPrevUserEntry ( ) ; <nl> } <nl> <nl> + void DBIter : : ReadIndirectValue ( Slice ref ) const { <nl> + assert ( ! large_ - > produced ) ; <nl> + large_ - > produced = true ; <nl> + LargeValueRef large_ref ; <nl> + if ( ref . size ( ) ! = LargeValueRef : : ByteSize ( ) ) { <nl> + large_ - > status = Status : : Corruption ( " malformed large value reference " ) ; <nl> + return ; <nl> + } <nl> + memcpy ( large_ref . data , ref . data ( ) , LargeValueRef : : ByteSize ( ) ) ; <nl> + std : : string fname = LargeValueFileName ( * dbname_ , large_ref ) ; <nl> + RandomAccessFile * file ; <nl> + Status s = env_ - > NewRandomAccessFile ( fname , & file ) ; <nl> + uint64_t file_size = 0 ; <nl> + if ( s . ok ( ) ) { <nl> + s = env_ - > GetFileSize ( fname , & file_size ) ; <nl> + } <nl> + if ( s . ok ( ) ) { <nl> + uint64_t value_size = large_ref . ValueSize ( ) ; <nl> + large_ - > value . resize ( value_size ) ; <nl> + Slice result ; <nl> + s = file - > Read ( 0 , file_size , & result , <nl> + const_cast < char * > ( large_ - > value . data ( ) ) ) ; <nl> + if ( s . ok ( ) ) { <nl> + if ( result . size ( ) = = file_size ) { <nl> + switch ( large_ref . compression_type ( ) ) { <nl> + case kNoCompression : { <nl> + if ( result . data ( ) ! = large_ - > value . data ( ) ) { <nl> + large_ - > value . assign ( result . data ( ) , result . size ( ) ) ; <nl> + } <nl> + break ; <nl> + } <nl> + case kSnappyCompression : { <nl> + std : : string uncompressed ; <nl> + if ( port : : Snappy_Uncompress ( result . data ( ) , result . size ( ) , <nl> + & uncompressed ) & & <nl> + uncompressed . size ( ) = = large_ref . ValueSize ( ) ) { <nl> + swap ( uncompressed , large_ - > value ) ; <nl> + } else { <nl> + s = Status : : Corruption ( <nl> + " Unable to read entire compressed large value file " ) ; <nl> + } <nl> + } <nl> + } <nl> + } else { <nl> + s = Status : : Corruption ( " Unable to read entire large value file " ) ; <nl> + } <nl> + } <nl> + delete file ; / / Ignore errors on closing <nl> + } <nl> + if ( ! s . ok ( ) ) { <nl> + large_ - > value . clear ( ) ; <nl> + large_ - > status = s ; <nl> + } <nl> + } <nl> + <nl> } / / anonymous namespace <nl> <nl> Iterator * NewDBIterator ( <nl> similarity index 100 % <nl> rename from leveldb / db / db_iter . h <nl> rename to db / db_iter . h <nl> similarity index 79 % <nl> rename from leveldb / db / db_test . cc <nl> rename to db / db_test . cc <nl> mmm a / leveldb / db / db_test . cc <nl> ppp b / db / db_test . cc <nl> class DBTest { <nl> case kTypeValue : <nl> result + = iter - > value ( ) . ToString ( ) ; <nl> break ; <nl> + case kTypeLargeValueRef : <nl> + result + = " LARGEVALUE ( " + EscapeString ( iter - > value ( ) ) + " ) " ; <nl> + break ; <nl> case kTypeDeletion : <nl> result + = " DEL " ; <nl> break ; <nl> class DBTest { <nl> return size ; <nl> } <nl> <nl> + std : : set < LargeValueRef > LargeValueFiles ( ) const { <nl> + / / Return the set of large value files that exist in the database <nl> + std : : vector < std : : string > filenames ; <nl> + env_ - > GetChildren ( dbname_ , & filenames ) ; / / Ignoring errors on purpose <nl> + uint64_t number ; <nl> + LargeValueRef large_ref ; <nl> + FileType type ; <nl> + std : : set < LargeValueRef > live ; <nl> + for ( int i = 0 ; i < filenames . size ( ) ; i + + ) { <nl> + if ( ParseFileName ( filenames [ i ] , & number , & large_ref , & type ) & & <nl> + type = = kLargeValueFile ) { <nl> + fprintf ( stderr , " live : % s \ n " , <nl> + LargeValueRefToFilenameString ( large_ref ) . c_str ( ) ) ; <nl> + live . insert ( large_ref ) ; <nl> + } <nl> + } <nl> + fprintf ( stderr , " Found % d live large value files \ n " , ( int ) live . size ( ) ) ; <nl> + return live ; <nl> + } <nl> + <nl> void Compact ( const Slice & start , const Slice & limit ) { <nl> dbfull ( ) - > TEST_CompactMemTable ( ) ; <nl> int max_level_with_files = 1 ; <nl> TEST ( DBTest , MinorCompactionsHappen ) { <nl> TEST ( DBTest , RecoverWithLargeLog ) { <nl> { <nl> Options options ; <nl> + options . large_value_threshold = 1048576 ; <nl> Reopen ( & options ) ; <nl> ASSERT_OK ( Put ( " big1 " , std : : string ( 200000 , ' 1 ' ) ) ) ; <nl> ASSERT_OK ( Put ( " big2 " , std : : string ( 200000 , ' 2 ' ) ) ) ; <nl> TEST ( DBTest , RecoverWithLargeLog ) { <nl> / / we flush table files in the middle of a large log file . <nl> Options options ; <nl> options . write_buffer_size = 100000 ; <nl> + options . large_value_threshold = 1048576 ; <nl> Reopen ( & options ) ; <nl> ASSERT_EQ ( NumTableFilesAtLevel ( 0 ) , 3 ) ; <nl> ASSERT_EQ ( std : : string ( 200000 , ' 1 ' ) , Get ( " big1 " ) ) ; <nl> TEST ( DBTest , RecoverWithLargeLog ) { <nl> TEST ( DBTest , CompactionsGenerateMultipleFiles ) { <nl> Options options ; <nl> options . write_buffer_size = 100000000 ; / / Large write buffer <nl> + options . large_value_threshold = 1048576 ; <nl> Reopen ( & options ) ; <nl> <nl> Random rnd ( 301 ) ; <nl> static bool Between ( uint64_t val , uint64_t low , uint64_t high ) { <nl> } <nl> <nl> TEST ( DBTest , ApproximateSizes ) { <nl> - Options options ; <nl> - options . write_buffer_size = 100000000 ; / / Large write buffer <nl> - options . compression = kNoCompression ; <nl> - DestroyAndReopen ( ) ; <nl> - <nl> - ASSERT_TRUE ( Between ( Size ( " " , " xyz " ) , 0 , 0 ) ) ; <nl> - Reopen ( & options ) ; <nl> - ASSERT_TRUE ( Between ( Size ( " " , " xyz " ) , 0 , 0 ) ) ; <nl> + for ( int test = 0 ; test < 2 ; test + + ) { <nl> + / / test = = 0 : default large_value_threshold <nl> + / / test = = 1 : 1 MB large_value_threshold <nl> + Options options ; <nl> + options . large_value_threshold = ( test = = 0 ) ? 65536 : 1048576 ; <nl> + options . write_buffer_size = 100000000 ; / / Large write buffer <nl> + options . compression = kNoCompression ; <nl> + DestroyAndReopen ( ) ; <nl> <nl> - / / Write 8MB ( 80 values , each 100K ) <nl> - ASSERT_EQ ( NumTableFilesAtLevel ( 0 ) , 0 ) ; <nl> - const int N = 80 ; <nl> - Random rnd ( 301 ) ; <nl> - for ( int i = 0 ; i < N ; i + + ) { <nl> - ASSERT_OK ( Put ( Key ( i ) , RandomString ( & rnd , 100000 ) ) ) ; <nl> - } <nl> + ASSERT_TRUE ( Between ( Size ( " " , " xyz " ) , 0 , 0 ) ) ; <nl> + Reopen ( & options ) ; <nl> + ASSERT_TRUE ( Between ( Size ( " " , " xyz " ) , 0 , 0 ) ) ; <nl> <nl> - / / 0 because GetApproximateSizes ( ) does not account for memtable space <nl> - ASSERT_TRUE ( Between ( Size ( " " , Key ( 50 ) ) , 0 , 0 ) ) ; <nl> + / / Write 8MB ( 80 values , each 100K ) <nl> + ASSERT_EQ ( NumTableFilesAtLevel ( 0 ) , 0 ) ; <nl> + const int N = 80 ; <nl> + Random rnd ( 301 ) ; <nl> + for ( int i = 0 ; i < N ; i + + ) { <nl> + ASSERT_OK ( Put ( Key ( i ) , RandomString ( & rnd , 100000 ) ) ) ; <nl> + } <nl> + if ( test = = 1 ) { <nl> + / / 0 because GetApproximateSizes ( ) does not account for memtable space for <nl> + / / non - large values <nl> + ASSERT_TRUE ( Between ( Size ( " " , Key ( 50 ) ) , 0 , 0 ) ) ; <nl> + } else { <nl> + ASSERT_TRUE ( Between ( Size ( " " , Key ( 50 ) ) , 100000 * 50 , 100000 * 50 + 10000 ) ) ; <nl> + ASSERT_TRUE ( Between ( Size ( Key ( 20 ) , Key ( 30 ) ) , <nl> + 100000 * 10 , 100000 * 10 + 10000 ) ) ; <nl> + } <nl> <nl> - / / Check sizes across recovery by reopening a few times <nl> - for ( int run = 0 ; run < 3 ; run + + ) { <nl> - Reopen ( & options ) ; <nl> + / / Check sizes across recovery by reopening a few times <nl> + for ( int run = 0 ; run < 3 ; run + + ) { <nl> + Reopen ( & options ) ; <nl> + <nl> + for ( int compact_start = 0 ; compact_start < N ; compact_start + = 10 ) { <nl> + for ( int i = 0 ; i < N ; i + = 10 ) { <nl> + ASSERT_TRUE ( Between ( Size ( " " , Key ( i ) ) , 100000 * i , 100000 * i + 10000 ) ) ; <nl> + ASSERT_TRUE ( Between ( Size ( " " , Key ( i ) + " . suffix " ) , <nl> + 100000 * ( i + 1 ) , 100000 * ( i + 1 ) + 10000 ) ) ; <nl> + ASSERT_TRUE ( Between ( Size ( Key ( i ) , Key ( i + 10 ) ) , <nl> + 100000 * 10 , 100000 * 10 + 10000 ) ) ; <nl> + } <nl> + ASSERT_TRUE ( Between ( Size ( " " , Key ( 50 ) ) , 5000000 , 5010000 ) ) ; <nl> + ASSERT_TRUE ( Between ( Size ( " " , Key ( 50 ) + " . suffix " ) , 5100000 , 5110000 ) ) ; <nl> <nl> - for ( int compact_start = 0 ; compact_start < N ; compact_start + = 10 ) { <nl> - for ( int i = 0 ; i < N ; i + = 10 ) { <nl> - ASSERT_TRUE ( Between ( Size ( " " , Key ( i ) ) , 100000 * i , 100000 * i + 10000 ) ) ; <nl> - ASSERT_TRUE ( Between ( Size ( " " , Key ( i ) + " . suffix " ) , <nl> - 100000 * ( i + 1 ) , 100000 * ( i + 1 ) + 10000 ) ) ; <nl> - ASSERT_TRUE ( Between ( Size ( Key ( i ) , Key ( i + 10 ) ) , <nl> - 100000 * 10 , 100000 * 10 + 10000 ) ) ; <nl> + dbfull ( ) - > TEST_CompactRange ( 0 , <nl> + Key ( compact_start ) , <nl> + Key ( compact_start + 9 ) ) ; <nl> } <nl> - ASSERT_TRUE ( Between ( Size ( " " , Key ( 50 ) ) , 5000000 , 5010000 ) ) ; <nl> - ASSERT_TRUE ( Between ( Size ( " " , Key ( 50 ) + " . suffix " ) , 5100000 , 5110000 ) ) ; <nl> <nl> - dbfull ( ) - > TEST_CompactRange ( 0 , <nl> - Key ( compact_start ) , <nl> - Key ( compact_start + 9 ) ) ; <nl> + ASSERT_EQ ( NumTableFilesAtLevel ( 0 ) , 0 ) ; <nl> + ASSERT_GT ( NumTableFilesAtLevel ( 1 ) , 0 ) ; <nl> } <nl> - <nl> - ASSERT_EQ ( NumTableFilesAtLevel ( 0 ) , 0 ) ; <nl> - ASSERT_GT ( NumTableFilesAtLevel ( 1 ) , 0 ) ; <nl> } <nl> } <nl> <nl> TEST ( DBTest , ApproximateSizes_MixOfSmallAndLarge ) { <nl> Options options ; <nl> + options . large_value_threshold = 65536 ; <nl> options . compression = kNoCompression ; <nl> Reopen ( ) ; <nl> <nl> TEST ( DBTest , ComparatorCheck ) { <nl> < < s . ToString ( ) ; <nl> } <nl> <nl> + static bool LargeValuesOK ( DBTest * db , <nl> + const std : : set < LargeValueRef > & expected ) { <nl> + std : : set < LargeValueRef > actual = db - > LargeValueFiles ( ) ; <nl> + if ( actual . size ( ) ! = expected . size ( ) ) { <nl> + fprintf ( stderr , " Sets differ in size : % d vs % d \ n " , <nl> + ( int ) actual . size ( ) , ( int ) expected . size ( ) ) ; <nl> + return false ; <nl> + } <nl> + for ( std : : set < LargeValueRef > : : const_iterator it = expected . begin ( ) ; <nl> + it ! = expected . end ( ) ; <nl> + + + it ) { <nl> + if ( actual . count ( * it ) ! = 1 ) { <nl> + fprintf ( stderr , " key ' % s ' not found in actual set \ n " , <nl> + LargeValueRefToFilenameString ( * it ) . c_str ( ) ) ; <nl> + return false ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + TEST ( DBTest , LargeValues1 ) { <nl> + Options options ; <nl> + options . large_value_threshold = 10000 ; <nl> + Reopen ( & options ) ; <nl> + <nl> + Random rnd ( 301 ) ; <nl> + <nl> + std : : string big1 ; <nl> + test : : CompressibleString ( & rnd , 1 . 0 , 100000 , & big1 ) ; / / Not compressible <nl> + std : : set < LargeValueRef > expected ; <nl> + <nl> + ASSERT_OK ( Put ( " big1 " , big1 ) ) ; <nl> + expected . insert ( LargeValueRef : : Make ( big1 , kNoCompression ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + ASSERT_OK ( Delete ( " big1 " ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + ASSERT_OK ( dbfull ( ) - > TEST_CompactMemTable ( ) ) ; <nl> + / / No handling of deletion markers on memtable compactions , so big1 remains <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + dbfull ( ) - > TEST_CompactRange ( 0 , " " , " z " ) ; <nl> + expected . erase ( LargeValueRef : : Make ( big1 , kNoCompression ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + } <nl> + <nl> + static bool SnappyCompressionSupported ( ) { <nl> + std : : string out ; <nl> + Slice in = " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " ; <nl> + return port : : Snappy_Compress ( in . data ( ) , in . size ( ) , & out ) ; <nl> + } <nl> + <nl> + TEST ( DBTest , LargeValues2 ) { <nl> + Options options ; <nl> + options . large_value_threshold = 10000 ; <nl> + Reopen ( & options ) ; <nl> + <nl> + Random rnd ( 301 ) ; <nl> + <nl> + std : : string big1 , big2 ; <nl> + test : : CompressibleString ( & rnd , 1 . 0 , 20000 , & big1 ) ; / / Not compressible <nl> + test : : CompressibleString ( & rnd , 0 . 6 , 40000 , & big2 ) ; / / Compressible <nl> + std : : set < LargeValueRef > expected ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + ASSERT_OK ( Put ( " big1 " , big1 ) ) ; <nl> + expected . insert ( LargeValueRef : : Make ( big1 , kNoCompression ) ) ; <nl> + ASSERT_EQ ( big1 , Get ( " big1 " ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + ASSERT_OK ( Put ( " big2 " , big2 ) ) ; <nl> + ASSERT_EQ ( big2 , Get ( " big2 " ) ) ; <nl> + if ( SnappyCompressionSupported ( ) ) { <nl> + expected . insert ( LargeValueRef : : Make ( big2 , kSnappyCompression ) ) ; <nl> + } else { <nl> + expected . insert ( LargeValueRef : : Make ( big2 , kNoCompression ) ) ; <nl> + } <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + ASSERT_OK ( dbfull ( ) - > TEST_CompactMemTable ( ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + dbfull ( ) - > TEST_CompactRange ( 0 , " " , " z " ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + ASSERT_OK ( Put ( " big2 " , big2 ) ) ; <nl> + ASSERT_OK ( Put ( " big2_b " , big2 ) ) ; <nl> + ASSERT_EQ ( big1 , Get ( " big1 " ) ) ; <nl> + ASSERT_EQ ( big2 , Get ( " big2 " ) ) ; <nl> + ASSERT_EQ ( big2 , Get ( " big2_b " ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + ASSERT_OK ( Delete ( " big1 " ) ) ; <nl> + ASSERT_EQ ( " NOT_FOUND " , Get ( " big1 " ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + ASSERT_OK ( dbfull ( ) - > TEST_CompactMemTable ( ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + dbfull ( ) - > TEST_CompactRange ( 0 , " " , " z " ) ; <nl> + expected . erase ( LargeValueRef : : Make ( big1 , kNoCompression ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + dbfull ( ) - > TEST_CompactRange ( 1 , " " , " z " ) ; <nl> + <nl> + ASSERT_OK ( Delete ( " big2 " ) ) ; <nl> + ASSERT_EQ ( " NOT_FOUND " , Get ( " big2 " ) ) ; <nl> + ASSERT_EQ ( big2 , Get ( " big2_b " ) ) ; <nl> + ASSERT_OK ( dbfull ( ) - > TEST_CompactMemTable ( ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + dbfull ( ) - > TEST_CompactRange ( 0 , " " , " z " ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + <nl> + / / Make sure the large value refs survive a reload and compactions after <nl> + / / the reload . <nl> + Reopen ( ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + ASSERT_OK ( Put ( " foo " , " bar " ) ) ; <nl> + ASSERT_OK ( dbfull ( ) - > TEST_CompactMemTable ( ) ) ; <nl> + dbfull ( ) - > TEST_CompactRange ( 0 , " " , " z " ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + } <nl> + <nl> + TEST ( DBTest , LargeValues3 ) { <nl> + / / Make sure we don ' t compress values if <nl> + Options options ; <nl> + options . large_value_threshold = 10000 ; <nl> + options . compression = kNoCompression ; <nl> + Reopen ( & options ) ; <nl> + <nl> + Random rnd ( 301 ) ; <nl> + <nl> + std : : string big1 = std : : string ( 100000 , ' x ' ) ; / / Very compressible <nl> + std : : set < LargeValueRef > expected ; <nl> + <nl> + ASSERT_OK ( Put ( " big1 " , big1 ) ) ; <nl> + ASSERT_EQ ( big1 , Get ( " big1 " ) ) ; <nl> + expected . insert ( LargeValueRef : : Make ( big1 , kNoCompression ) ) ; <nl> + ASSERT_TRUE ( LargeValuesOK ( this , expected ) ) ; <nl> + } <nl> + <nl> + <nl> TEST ( DBTest , DBOpen_Options ) { <nl> std : : string dbname = test : : TmpDir ( ) + " / db_options_test " ; <nl> DestroyDB ( dbname , Options ( ) ) ; <nl> class ModelDB : public DB { <nl> case kTypeValue : <nl> map_ [ it . key ( ) . ToString ( ) ] = it . value ( ) . ToString ( ) ; <nl> break ; <nl> + case kTypeLargeValueRef : <nl> + assert ( false ) ; / / Should not occur <nl> + break ; <nl> case kTypeDeletion : <nl> map_ . erase ( it . key ( ) . ToString ( ) ) ; <nl> break ; <nl> similarity index 60 % <nl> rename from leveldb / db / dbformat . cc <nl> rename to db / dbformat . cc <nl> mmm a / leveldb / db / dbformat . cc <nl> ppp b / db / dbformat . cc <nl> void InternalKeyComparator : : FindShortSuccessor ( std : : string * key ) const { <nl> } <nl> } <nl> <nl> + LargeValueRef LargeValueRef : : Make ( const Slice & value , CompressionType ctype ) { <nl> + LargeValueRef result ; <nl> + port : : SHA1_Hash ( value . data ( ) , value . size ( ) , & result . data [ 0 ] ) ; <nl> + EncodeFixed64 ( & result . data [ 20 ] , value . size ( ) ) ; <nl> + result . data [ 28 ] = static_cast < unsigned char > ( ctype ) ; <nl> + return result ; <nl> + } <nl> + <nl> + std : : string LargeValueRefToFilenameString ( const LargeValueRef & h ) { <nl> + assert ( sizeof ( h . data ) = = LargeValueRef : : ByteSize ( ) ) ; <nl> + assert ( sizeof ( h . data ) = = 29 ) ; / / So we can hardcode the array size of buf <nl> + static const char tohex [ ] = " 0123456789abcdef " ; <nl> + char buf [ 20 * 2 ] ; <nl> + for ( int i = 0 ; i < 20 ; i + + ) { <nl> + buf [ 2 * i ] = tohex [ ( h . data [ i ] > > 4 ) & 0xf ] ; <nl> + buf [ 2 * i + 1 ] = tohex [ h . data [ i ] & 0xf ] ; <nl> + } <nl> + std : : string result = std : : string ( buf , sizeof ( buf ) ) ; <nl> + result + = " - " ; <nl> + result + = NumberToString ( h . ValueSize ( ) ) ; <nl> + result + = " - " ; <nl> + result + = NumberToString ( static_cast < uint64_t > ( h . compression_type ( ) ) ) ; <nl> + return result ; <nl> + } <nl> + <nl> + static uint32_t hexvalue ( char c ) { <nl> + if ( c > = ' 0 ' & & c < = ' 9 ' ) { <nl> + return c - ' 0 ' ; <nl> + } else if ( c > = ' A ' & & c < = ' F ' ) { <nl> + return 10 + c - ' A ' ; <nl> + } else { <nl> + assert ( c > = ' a ' & & c < = ' f ' ) ; <nl> + return 10 + c - ' a ' ; <nl> + } <nl> + } <nl> + <nl> + bool FilenameStringToLargeValueRef ( const Slice & s , LargeValueRef * h ) { <nl> + Slice in = s ; <nl> + if ( in . size ( ) < 40 ) { <nl> + return false ; <nl> + } <nl> + for ( int i = 0 ; i < 20 ; i + + ) { <nl> + if ( ! isxdigit ( in [ i * 2 ] ) | | ! isxdigit ( in [ i * 2 + 1 ] ) ) { <nl> + return false ; <nl> + } <nl> + unsigned char c = ( hexvalue ( in [ i * 2 ] ) < < 4 ) | hexvalue ( in [ i * 2 + 1 ] ) ; <nl> + h - > data [ i ] = c ; <nl> + } <nl> + in . remove_prefix ( 40 ) ; <nl> + uint64_t value_size , ctype ; <nl> + <nl> + if ( ConsumeChar ( & in , ' - ' ) & & <nl> + ConsumeDecimalNumber ( & in , & value_size ) & & <nl> + ConsumeChar ( & in , ' - ' ) & & <nl> + ConsumeDecimalNumber ( & in , & ctype ) & & <nl> + in . empty ( ) & & <nl> + ( ctype < = kSnappyCompression ) ) { <nl> + EncodeFixed64 ( & h - > data [ 20 ] , value_size ) ; <nl> + h - > data [ 28 ] = static_cast < unsigned char > ( ctype ) ; <nl> + return true ; <nl> + } else { <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> } <nl> similarity index 71 % <nl> rename from leveldb / db / dbformat . h <nl> rename to db / dbformat . h <nl> mmm a / leveldb / db / dbformat . h <nl> ppp b / db / dbformat . h <nl> class InternalKey ; <nl> enum ValueType { <nl> kTypeDeletion = 0x0 , <nl> kTypeValue = 0x1 , <nl> + kTypeLargeValueRef = 0x2 , <nl> } ; <nl> / / kValueTypeForSeek defines the ValueType that should be passed when <nl> / / constructing a ParsedInternalKey object for seeking to a particular <nl> enum ValueType { <nl> / / and the value type is embedded as the low 8 bits in the sequence <nl> / / number in internal keys , we need to use the highest - numbered <nl> / / ValueType , not the lowest ) . <nl> - static const ValueType kValueTypeForSeek = kTypeValue ; <nl> + static const ValueType kValueTypeForSeek = kTypeLargeValueRef ; <nl> <nl> typedef uint64_t SequenceNumber ; <nl> <nl> inline int InternalKeyComparator : : Compare ( <nl> return Compare ( a . Encode ( ) , b . Encode ( ) ) ; <nl> } <nl> <nl> + / / LargeValueRef is a 160 - bit hash value ( 20 bytes ) , plus an 8 byte <nl> + / / uncompressed size , and a 1 byte CompressionType code . An <nl> + / / encoded form of it is embedded in the filenames of large value <nl> + / / files stored in the database , and the raw binary form is stored as <nl> + / / the iter - > value ( ) result for values of type kTypeLargeValueRef in <nl> + / / the table and log files that make up the database . <nl> + struct LargeValueRef { <nl> + char data [ 29 ] ; <nl> + <nl> + / / Initialize a large value ref for the given data <nl> + static LargeValueRef Make ( const Slice & data , <nl> + CompressionType compression_type ) ; <nl> + <nl> + / / Initialize a large value ref from a serialized , 29 - byte reference value <nl> + static LargeValueRef FromRef ( const Slice & ref ) { <nl> + LargeValueRef result ; <nl> + assert ( ref . size ( ) = = sizeof ( result . data ) ) ; <nl> + memcpy ( result . data , ref . data ( ) , sizeof ( result . data ) ) ; <nl> + return result ; <nl> + } <nl> + <nl> + / / Return the number of bytes in a LargeValueRef ( not the <nl> + / / number of bytes in the value referenced ) . <nl> + static size_t ByteSize ( ) { return sizeof ( LargeValueRef ( ) . data ) ; } <nl> + <nl> + / / Return the number of bytes in the value referenced by " * this " . <nl> + uint64_t ValueSize ( ) const { return DecodeFixed64 ( & data [ 20 ] ) ; } <nl> + <nl> + CompressionType compression_type ( ) const { <nl> + return static_cast < CompressionType > ( data [ 28 ] ) ; <nl> + } <nl> + <nl> + bool operator = = ( const LargeValueRef & b ) const { <nl> + return memcmp ( data , b . data , sizeof ( data ) ) = = 0 ; <nl> + } <nl> + bool operator < ( const LargeValueRef & b ) const { <nl> + return memcmp ( data , b . data , sizeof ( data ) ) < 0 ; <nl> + } <nl> + } ; <nl> + <nl> + / / Convert the large value ref to a human - readable string suitable <nl> + / / for embedding in a large value filename . <nl> + extern std : : string LargeValueRefToFilenameString ( const LargeValueRef & h ) ; <nl> + <nl> + / / Parse the large value filename string in " input " and store it in <nl> + / / " * h " . If successful , returns true . Otherwise returns false . <nl> + extern bool FilenameStringToLargeValueRef ( const Slice & in , LargeValueRef * ref ) ; <nl> + <nl> inline bool ParseInternalKey ( const Slice & internal_key , <nl> ParsedInternalKey * result ) { <nl> const size_t n = internal_key . size ( ) ; <nl> inline bool ParseInternalKey ( const Slice & internal_key , <nl> result - > sequence = num > > 8 ; <nl> result - > type = static_cast < ValueType > ( c ) ; <nl> result - > user_key = Slice ( internal_key . data ( ) , n - 8 ) ; <nl> - return ( c < = static_cast < unsigned char > ( kTypeValue ) ) ; <nl> + return ( c < = static_cast < unsigned char > ( kTypeLargeValueRef ) ) ; <nl> } <nl> <nl> } <nl> similarity index 84 % <nl> rename from leveldb / db / dbformat_test . cc <nl> rename to db / dbformat_test . cc <nl> mmm a / leveldb / db / dbformat_test . cc <nl> ppp b / db / dbformat_test . cc <nl> TEST ( FormatTest , InternalKeyShortSeparator ) { <nl> ASSERT_EQ ( IKey ( " foo " , 100 , kTypeValue ) , <nl> Shorten ( IKey ( " foo " , 100 , kTypeValue ) , <nl> IKey ( " foo " , 100 , kTypeDeletion ) ) ) ; <nl> + ASSERT_EQ ( IKey ( " foo " , 100 , kTypeValue ) , <nl> + Shorten ( IKey ( " foo " , 100 , kTypeValue ) , <nl> + IKey ( " foo " , 100 , kTypeLargeValueRef ) ) ) ; <nl> <nl> / / When user keys are misordered <nl> ASSERT_EQ ( IKey ( " foo " , 100 , kTypeValue ) , <nl> TEST ( FormatTest , InternalKeyShortestSuccessor ) { <nl> ShortSuccessor ( IKey ( " \ xff \ xff " , 100 , kTypeValue ) ) ) ; <nl> } <nl> <nl> + TEST ( FormatTest , SHA1 ) { <nl> + / / Check that we are computing the same value as sha1 . <nl> + / / Note that the last two numbers are the length of the input and the <nl> + / / compression type . <nl> + ASSERT_EQ ( " aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d - 5 - 0 " , / / SHA1 , uncompr <nl> + LargeValueRefToFilenameString ( <nl> + LargeValueRef : : Make ( " hello " , kNoCompression ) ) ) ; <nl> + ASSERT_EQ ( " aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d - 5 - 1 " , / / SHA1 , lwcompr <nl> + LargeValueRefToFilenameString ( <nl> + LargeValueRef : : Make ( " hello " , kSnappyCompression ) ) ) ; <nl> + } <nl> + <nl> } <nl> <nl> int main ( int argc , char * * argv ) { <nl> similarity index 85 % <nl> rename from leveldb / db / filename . cc <nl> rename to db / filename . cc <nl> mmm a / leveldb / db / filename . cc <nl> ppp b / db / filename . cc <nl> std : : string TableFileName ( const std : : string & name , uint64_t number ) { <nl> return MakeFileName ( name , number , " sst " ) ; <nl> } <nl> <nl> + std : : string LargeValueFileName ( const std : : string & name , <nl> + const LargeValueRef & large_ref ) { <nl> + std : : string result = name + " / " ; <nl> + result + = LargeValueRefToFilenameString ( large_ref ) ; <nl> + result + = " . val " ; <nl> + return result ; <nl> + } <nl> + <nl> std : : string DescriptorFileName ( const std : : string & dbname , uint64_t number ) { <nl> assert ( number > 0 ) ; <nl> char buf [ 100 ] ; <nl> std : : string OldInfoLogFileName ( const std : : string & dbname ) { <nl> / / dbname / LOG <nl> / / dbname / LOG . old <nl> / / dbname / MANIFEST - [ 0 - 9 ] + <nl> + / / dbname / [ 0 - 9a - f ] { 20 } - [ 0 - 9 ] + - [ 0 - 9 ] + . val <nl> / / dbname / [ 0 - 9 ] + . ( log | sst ) <nl> bool ParseFileName ( const std : : string & fname , <nl> uint64_t * number , <nl> + LargeValueRef * large_ref , <nl> FileType * type ) { <nl> Slice rest ( fname ) ; <nl> if ( rest = = " CURRENT " ) { <nl> bool ParseFileName ( const std : : string & fname , <nl> } else if ( rest = = " LOG " | | rest = = " LOG . old " ) { <nl> * number = 0 ; <nl> * type = kInfoLogFile ; <nl> + } else if ( rest . size ( ) > = 4 & & <nl> + Slice ( rest . data ( ) + rest . size ( ) - 4 , 4 ) = = " . val " ) { <nl> + LargeValueRef h ; <nl> + if ( ! FilenameStringToLargeValueRef ( Slice ( rest . data ( ) , rest . size ( ) - 4 ) , <nl> + & h ) ) { <nl> + return false ; <nl> + } <nl> + * large_ref = h ; <nl> + * type = kLargeValueFile ; <nl> } else if ( rest . starts_with ( " MANIFEST - " ) ) { <nl> rest . remove_prefix ( strlen ( " MANIFEST - " ) ) ; <nl> uint64_t num ; <nl> similarity index 79 % <nl> rename from leveldb / db / filename . h <nl> rename to db / filename . h <nl> mmm a / leveldb / db / filename . h <nl> ppp b / db / filename . h <nl> <nl> namespace leveldb { <nl> <nl> class Env ; <nl> + struct LargeValueRef ; <nl> <nl> enum FileType { <nl> kLogFile , <nl> kDBLockFile , <nl> kTableFile , <nl> + kLargeValueFile , <nl> kDescriptorFile , <nl> kCurrentFile , <nl> kTempFile , <nl> extern std : : string LogFileName ( const std : : string & dbname , uint64_t number ) ; <nl> / / " dbname " . <nl> extern std : : string TableFileName ( const std : : string & dbname , uint64_t number ) ; <nl> <nl> + / / Return the name of the large value file with the specified large <nl> + / / value reference in the db named by " dbname " . The result will be <nl> + / / prefixed with " dbname " . <nl> + extern std : : string LargeValueFileName ( const std : : string & dbname , <nl> + const LargeValueRef & large_ref ) ; <nl> + <nl> / / Return the name of the descriptor file for the db named by <nl> / / " dbname " and the specified incarnation number . The result will be <nl> / / prefixed with " dbname " . <nl> extern std : : string InfoLogFileName ( const std : : string & dbname ) ; <nl> extern std : : string OldInfoLogFileName ( const std : : string & dbname ) ; <nl> <nl> / / If filename is a leveldb file , store the type of the file in * type . <nl> - / / The number encoded in the filename is stored in * number . If the <nl> - / / filename was successfully parsed , returns true . Else return false . <nl> + / / If * type is kLargeValueFile , then the large value reference data <nl> + / / from the filename is stored in " * large_ref . For all other types of <nl> + / / files , the number encoded in the filename is stored in * number . If <nl> + / / the filename was successfully parsed , returns true . Else return <nl> + / / false . <nl> extern bool ParseFileName ( const std : : string & filename , <nl> uint64_t * number , <nl> + LargeValueRef * large_ref , <nl> FileType * type ) ; <nl> <nl> / / Make the CURRENT file point to the descriptor file with the <nl> new file mode 100644 <nl> index 000000000 . . 4d2a91ef1 <nl> mmm / dev / null <nl> ppp b / db / filename_test . cc <nl> <nl> + / / Copyright ( c ) 2011 The LevelDB Authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . See the AUTHORS file for names of contributors . <nl> + <nl> + # include " db / filename . h " <nl> + <nl> + # include " db / dbformat . h " <nl> + # include " port / port . h " <nl> + # include " util / logging . h " <nl> + # include " util / testharness . h " <nl> + <nl> + namespace leveldb { <nl> + <nl> + class FileNameTest { } ; <nl> + <nl> + TEST ( FileNameTest , Parse ) { <nl> + Slice db ; <nl> + FileType type ; <nl> + uint64_t number ; <nl> + LargeValueRef large_ref ; <nl> + <nl> + / / Successful parses <nl> + static struct { <nl> + const char * fname ; <nl> + uint64_t number ; <nl> + const char * large_ref ; <nl> + FileType type ; <nl> + } cases [ ] = { <nl> + { " 100 . log " , 100 , " " , kLogFile } , <nl> + { " 0 . log " , 0 , " " , kLogFile } , <nl> + { " 0 . sst " , 0 , " " , kTableFile } , <nl> + { " CURRENT " , 0 , " " , kCurrentFile } , <nl> + { " LOCK " , 0 , " " , kDBLockFile } , <nl> + { " MANIFEST - 2 " , 2 , " " , kDescriptorFile } , <nl> + { " MANIFEST - 7 " , 7 , " " , kDescriptorFile } , <nl> + { " LOG " , 0 , " " , kInfoLogFile } , <nl> + { " LOG . old " , 0 , " " , kInfoLogFile } , <nl> + { " 18446744073709551615 . log " , 18446744073709551615ull , " " , <nl> + kLogFile } , <nl> + { " 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2323 - 1234 - 0 . val " , 0 , <nl> + " 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2323 - 1234 - 0 " , kLargeValueFile } , <nl> + { " 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2323 - 10000000000 - 0 . val " , 0 , <nl> + " 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2323 - 10000000000 - 0 " , <nl> + kLargeValueFile } , <nl> + } ; <nl> + for ( int i = 0 ; i < sizeof ( cases ) / sizeof ( cases [ 0 ] ) ; i + + ) { <nl> + std : : string f = cases [ i ] . fname ; <nl> + ASSERT_TRUE ( ParseFileName ( f , & number , & large_ref , & type ) ) < < f ; <nl> + ASSERT_EQ ( cases [ i ] . type , type ) < < f ; <nl> + if ( type = = kLargeValueFile ) { <nl> + ASSERT_EQ ( cases [ i ] . large_ref , LargeValueRefToFilenameString ( large_ref ) ) <nl> + < < f ; <nl> + } else { <nl> + ASSERT_EQ ( cases [ i ] . number , number ) < < f ; <nl> + } <nl> + } <nl> + <nl> + / / Errors <nl> + static const char * errors [ ] = { <nl> + " " , <nl> + " foo " , <nl> + " foo - dx - 100 . log " , <nl> + " . log " , <nl> + " " , <nl> + " manifest " , <nl> + " CURREN " , <nl> + " CURRENTX " , <nl> + " MANIFES " , <nl> + " MANIFEST " , <nl> + " MANIFEST - " , <nl> + " XMANIFEST - 3 " , <nl> + " MANIFEST - 3x " , <nl> + " LOC " , <nl> + " LOCKx " , <nl> + " LO " , <nl> + " LOGx " , <nl> + " 18446744073709551616 . log " , <nl> + " 184467440737095516150 . log " , <nl> + " 100 " , <nl> + " 100 . " , <nl> + " 100 . lop " , <nl> + " 100 . val " , <nl> + " . val " , <nl> + " 123456789012345678901234567890123456789 - 12340 . val " , <nl> + " 1234567890123456789012345678901234567 - 123 - 0 . val " , <nl> + " 12345678901234567890123456789012345678902 - 100 - 1 - . val " , <nl> + / / Overflow on value size <nl> + " 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2323 - 100000000000000000000 - 1 . val " , <nl> + / / ' 03 . val ' is a bad compression type <nl> + " 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2323 - 100000 - 3 . val " } ; <nl> + for ( int i = 0 ; i < sizeof ( errors ) / sizeof ( errors [ 0 ] ) ; i + + ) { <nl> + std : : string f = errors [ i ] ; <nl> + ASSERT_TRUE ( ! ParseFileName ( f , & number , & large_ref , & type ) ) < < f ; <nl> + } ; <nl> + } <nl> + <nl> + TEST ( FileNameTest , Construction ) { <nl> + uint64_t number ; <nl> + FileType type ; <nl> + LargeValueRef large_ref ; <nl> + std : : string fname ; <nl> + <nl> + fname = CurrentFileName ( " foo " ) ; <nl> + ASSERT_EQ ( " foo / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> + ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & large_ref , & type ) ) ; <nl> + ASSERT_EQ ( 0 , number ) ; <nl> + ASSERT_EQ ( kCurrentFile , type ) ; <nl> + <nl> + fname = LockFileName ( " foo " ) ; <nl> + ASSERT_EQ ( " foo / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> + ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & large_ref , & type ) ) ; <nl> + ASSERT_EQ ( 0 , number ) ; <nl> + ASSERT_EQ ( kDBLockFile , type ) ; <nl> + <nl> + fname = LogFileName ( " foo " , 192 ) ; <nl> + ASSERT_EQ ( " foo / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> + ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & large_ref , & type ) ) ; <nl> + ASSERT_EQ ( 192 , number ) ; <nl> + ASSERT_EQ ( kLogFile , type ) ; <nl> + <nl> + fname = TableFileName ( " bar " , 200 ) ; <nl> + ASSERT_EQ ( " bar / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> + ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & large_ref , & type ) ) ; <nl> + ASSERT_EQ ( 200 , number ) ; <nl> + ASSERT_EQ ( kTableFile , type ) ; <nl> + <nl> + fname = DescriptorFileName ( " bar " , 100 ) ; <nl> + ASSERT_EQ ( " bar / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> + ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & large_ref , & type ) ) ; <nl> + ASSERT_EQ ( 100 , number ) ; <nl> + ASSERT_EQ ( kDescriptorFile , type ) ; <nl> + <nl> + fname = TempFileName ( " tmp " , 999 ) ; <nl> + ASSERT_EQ ( " tmp / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> + ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & large_ref , & type ) ) ; <nl> + ASSERT_EQ ( 999 , number ) ; <nl> + ASSERT_EQ ( kTempFile , type ) ; <nl> + <nl> + for ( int i = 0 ; i < = kSnappyCompression ; i + + ) { <nl> + CompressionType ctype = static_cast < CompressionType > ( i ) ; <nl> + std : : string value = " abcdef " ; <nl> + LargeValueRef real_large_ref = LargeValueRef : : Make ( Slice ( value ) , ctype ) ; <nl> + fname = LargeValueFileName ( " tmp " , real_large_ref ) ; <nl> + ASSERT_EQ ( " tmp / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> + ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & large_ref , & type ) ) ; <nl> + ASSERT_TRUE ( real_large_ref = = large_ref ) ; <nl> + ASSERT_EQ ( kLargeValueFile , type ) ; <nl> + ASSERT_EQ ( large_ref . compression_type ( ) , ctype ) ; <nl> + } <nl> + } <nl> + <nl> + } <nl> + <nl> + int main ( int argc , char * * argv ) { <nl> + return leveldb : : test : : RunAllTests ( ) ; <nl> + } <nl> similarity index 100 % <nl> rename from leveldb / db / log_format . h <nl> rename to db / log_format . h <nl> similarity index 100 % <nl> rename from leveldb / db / log_reader . cc <nl> rename to db / log_reader . cc <nl> similarity index 100 % <nl> rename from leveldb / db / log_reader . h <nl> rename to db / log_reader . h <nl> similarity index 100 % <nl> rename from leveldb / db / log_test . cc <nl> rename to db / log_test . cc <nl> similarity index 95 % <nl> rename from leveldb / db / log_writer . cc <nl> rename to db / log_writer . cc <nl> mmm a / leveldb / db / log_writer . cc <nl> ppp b / db / log_writer . cc <nl> Status Writer : : AddRecord ( const Slice & slice ) { <nl> } <nl> <nl> / / Invariant : we never leave < kHeaderSize bytes in a block . <nl> - assert ( kBlockSize - block_offset_ - kHeaderSize > = 0 ) ; <nl> + const int avail = kBlockSize - block_offset_ - kHeaderSize ; <nl> + assert ( avail > = 0 ) ; <nl> <nl> - const size_t avail = kBlockSize - block_offset_ - kHeaderSize ; <nl> const size_t fragment_length = ( left < avail ) ? left : avail ; <nl> <nl> RecordType type ; <nl> similarity index 100 % <nl> rename from leveldb / db / log_writer . h <nl> rename to db / log_writer . h <nl> similarity index 100 % <nl> rename from leveldb / db / memtable . cc <nl> rename to db / memtable . cc <nl> similarity index 100 % <nl> rename from leveldb / db / memtable . h <nl> rename to db / memtable . h <nl> similarity index 89 % <nl> rename from leveldb / db / repair . cc <nl> rename to db / repair . cc <nl> mmm a / leveldb / db / repair . cc <nl> ppp b / db / repair . cc <nl> <nl> / / ( 1 ) Any log files are first converted to tables <nl> / / ( 2 ) We scan every table to compute <nl> / / ( a ) smallest / largest for the table <nl> - / / ( b ) largest sequence number in the table <nl> + / / ( b ) large value refs from the table <nl> + / / ( c ) largest sequence number in the table <nl> / / ( 3 ) We generate descriptor contents : <nl> / / - log number is set to zero <nl> / / - next - file - number is set to 1 + largest file number we found <nl> <nl> / / ( c ) For each table : if it overlaps earlier table , place in level - 0 , <nl> / / else place in level - M . <nl> / / Possible optimization 2 : <nl> - / / Store per - table metadata ( smallest , largest , largest - seq # , . . . ) <nl> - / / in the table ' s meta section to speed up ScanTable . <nl> + / / Store per - table metadata ( smallest , largest , largest - seq # , <nl> + / / large - value - refs , . . . ) in the table ' s meta section to speed up <nl> + / / ScanTable . <nl> <nl> # include " db / builder . h " <nl> # include " db / db_impl . h " <nl> class Repairer { <nl> } <nl> if ( status . ok ( ) ) { <nl> unsigned long long bytes = 0 ; <nl> - for ( size_t i = 0 ; i < tables_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < tables_ . size ( ) ; i + + ) { <nl> bytes + = tables_ [ i ] . meta . file_size ; <nl> } <nl> Log ( env_ , options_ . info_log , <nl> class Repairer { <nl> } <nl> <nl> uint64_t number ; <nl> + LargeValueRef large_ref ; <nl> FileType type ; <nl> - for ( size_t i = 0 ; i < filenames . size ( ) ; i + + ) { <nl> - if ( ParseFileName ( filenames [ i ] , & number , & type ) ) { <nl> - if ( type = = kDescriptorFile ) { <nl> + for ( int i = 0 ; i < filenames . size ( ) ; i + + ) { <nl> + if ( ParseFileName ( filenames [ i ] , & number , & large_ref , & type ) ) { <nl> + if ( type = = kLargeValueFile ) { <nl> + / / Will be picked up when we process a Table that points to it <nl> + } else if ( type = = kDescriptorFile ) { <nl> manifests_ . push_back ( filenames [ i ] ) ; <nl> } else { <nl> if ( number + 1 > next_file_number_ ) { <nl> class Repairer { <nl> } <nl> <nl> void ConvertLogFilesToTables ( ) { <nl> - for ( size_t i = 0 ; i < logs_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < logs_ . size ( ) ; i + + ) { <nl> std : : string logname = LogFileName ( dbname_ , logs_ [ i ] ) ; <nl> Status status = ConvertLogToTable ( logs_ [ i ] ) ; <nl> if ( ! status . ok ( ) ) { <nl> class Repairer { <nl> <nl> void ExtractMetaData ( ) { <nl> std : : vector < TableInfo > kept ; <nl> - for ( size_t i = 0 ; i < table_numbers_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < table_numbers_ . size ( ) ; i + + ) { <nl> TableInfo t ; <nl> t . meta . number = table_numbers_ [ i ] ; <nl> Status status = ScanTable ( & t ) ; <nl> class Repairer { <nl> if ( parsed . sequence > t - > max_sequence ) { <nl> t - > max_sequence = parsed . sequence ; <nl> } <nl> + <nl> + if ( ExtractValueType ( key ) = = kTypeLargeValueRef ) { <nl> + if ( iter - > value ( ) . size ( ) ! = LargeValueRef : : ByteSize ( ) ) { <nl> + Log ( env_ , options_ . info_log , " Table # % llu : bad large value ref " , <nl> + ( unsigned long long ) t - > meta . number ) ; <nl> + } else { <nl> + edit_ . AddLargeValueRef ( LargeValueRef : : FromRef ( iter - > value ( ) ) , <nl> + t - > meta . number , <nl> + key ) ; <nl> + } <nl> + } <nl> } <nl> if ( ! iter - > status ( ) . ok ( ) ) { <nl> status = iter - > status ( ) ; <nl> class Repairer { <nl> } <nl> <nl> SequenceNumber max_sequence = 0 ; <nl> - for ( size_t i = 0 ; i < tables_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < tables_ . size ( ) ; i + + ) { <nl> if ( max_sequence < tables_ [ i ] . max_sequence ) { <nl> max_sequence = tables_ [ i ] . max_sequence ; <nl> } <nl> class Repairer { <nl> edit_ . SetNextFile ( next_file_number_ ) ; <nl> edit_ . SetLastSequence ( max_sequence ) ; <nl> <nl> - for ( size_t i = 0 ; i < tables_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < tables_ . size ( ) ; i + + ) { <nl> / / TODO ( opt ) : separate out into multiple levels <nl> const TableInfo & t = tables_ [ i ] ; <nl> edit_ . AddFile ( 0 , t . meta . number , t . meta . file_size , <nl> class Repairer { <nl> env_ - > DeleteFile ( tmp ) ; <nl> } else { <nl> / / Discard older manifests <nl> - for ( size_t i = 0 ; i < manifests_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < manifests_ . size ( ) ; i + + ) { <nl> ArchiveFile ( dbname_ + " / " + manifests_ [ i ] ) ; <nl> } <nl> <nl> similarity index 100 % <nl> rename from leveldb / db / skiplist . h <nl> rename to db / skiplist . h <nl> similarity index 100 % <nl> rename from leveldb / db / skiplist_test . cc <nl> rename to db / skiplist_test . cc <nl> similarity index 100 % <nl> rename from leveldb / db / snapshot . h <nl> rename to db / snapshot . h <nl> similarity index 100 % <nl> rename from leveldb / db / table_cache . cc <nl> rename to db / table_cache . cc <nl> similarity index 100 % <nl> rename from leveldb / db / table_cache . h <nl> rename to db / table_cache . h <nl> similarity index 82 % <nl> rename from leveldb / db / version_edit . cc <nl> rename to db / version_edit . cc <nl> mmm a / leveldb / db / version_edit . cc <nl> ppp b / db / version_edit . cc <nl> enum Tag { <nl> kCompactPointer = 5 , <nl> kDeletedFile = 6 , <nl> kNewFile = 7 , <nl> - / / 8 was used for large value refs <nl> + kLargeValueRef = 8 , <nl> kPrevLogNumber = 9 , <nl> } ; <nl> <nl> void VersionEdit : : Clear ( ) { <nl> has_last_sequence_ = false ; <nl> deleted_files_ . clear ( ) ; <nl> new_files_ . clear ( ) ; <nl> + large_refs_added_ . clear ( ) ; <nl> } <nl> <nl> void VersionEdit : : EncodeTo ( std : : string * dst ) const { <nl> void VersionEdit : : EncodeTo ( std : : string * dst ) const { <nl> PutVarint64 ( dst , last_sequence_ ) ; <nl> } <nl> <nl> - for ( size_t i = 0 ; i < compact_pointers_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < compact_pointers_ . size ( ) ; i + + ) { <nl> PutVarint32 ( dst , kCompactPointer ) ; <nl> PutVarint32 ( dst , compact_pointers_ [ i ] . first ) ; / / level <nl> PutLengthPrefixedSlice ( dst , compact_pointers_ [ i ] . second . Encode ( ) ) ; <nl> void VersionEdit : : EncodeTo ( std : : string * dst ) const { <nl> PutVarint64 ( dst , iter - > second ) ; / / file number <nl> } <nl> <nl> - for ( size_t i = 0 ; i < new_files_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < new_files_ . size ( ) ; i + + ) { <nl> const FileMetaData & f = new_files_ [ i ] . second ; <nl> PutVarint32 ( dst , kNewFile ) ; <nl> PutVarint32 ( dst , new_files_ [ i ] . first ) ; / / level <nl> void VersionEdit : : EncodeTo ( std : : string * dst ) const { <nl> PutLengthPrefixedSlice ( dst , f . smallest . Encode ( ) ) ; <nl> PutLengthPrefixedSlice ( dst , f . largest . Encode ( ) ) ; <nl> } <nl> + <nl> + for ( int i = 0 ; i < large_refs_added_ . size ( ) ; i + + ) { <nl> + const VersionEdit : : Large & l = large_refs_added_ [ i ] ; <nl> + PutVarint32 ( dst , kLargeValueRef ) ; <nl> + PutLengthPrefixedSlice ( dst , <nl> + Slice ( l . large_ref . data , LargeValueRef : : ByteSize ( ) ) ) ; <nl> + PutVarint64 ( dst , l . fnum ) ; <nl> + PutLengthPrefixedSlice ( dst , l . internal_key . Encode ( ) ) ; <nl> + } <nl> } <nl> <nl> static bool GetInternalKey ( Slice * input , InternalKey * dst ) { <nl> Status VersionEdit : : DecodeFrom ( const Slice & src ) { <nl> uint64_t number ; <nl> FileMetaData f ; <nl> Slice str ; <nl> + Large large ; <nl> InternalKey key ; <nl> <nl> while ( msg = = NULL & & GetVarint32 ( & input , & tag ) ) { <nl> Status VersionEdit : : DecodeFrom ( const Slice & src ) { <nl> } <nl> break ; <nl> <nl> + case kLargeValueRef : <nl> + if ( GetLengthPrefixedSlice ( & input , & str ) & & <nl> + ( str . size ( ) = = LargeValueRef : : ByteSize ( ) ) & & <nl> + GetVarint64 ( & input , & large . fnum ) & & <nl> + GetInternalKey ( & input , & large . internal_key ) ) { <nl> + large . large_ref = LargeValueRef : : FromRef ( str ) ; <nl> + large_refs_added_ . push_back ( large ) ; <nl> + } else { <nl> + msg = " large ref " ; <nl> + } <nl> + break ; <nl> + <nl> default : <nl> msg = " unknown tag " ; <nl> break ; <nl> std : : string VersionEdit : : DebugString ( ) const { <nl> r . append ( " \ n LastSeq : " ) ; <nl> AppendNumberTo ( & r , last_sequence_ ) ; <nl> } <nl> - for ( size_t i = 0 ; i < compact_pointers_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < compact_pointers_ . size ( ) ; i + + ) { <nl> r . append ( " \ n CompactPointer : " ) ; <nl> AppendNumberTo ( & r , compact_pointers_ [ i ] . first ) ; <nl> r . append ( " ' " ) ; <nl> std : : string VersionEdit : : DebugString ( ) const { <nl> r . append ( " " ) ; <nl> AppendNumberTo ( & r , iter - > second ) ; <nl> } <nl> - for ( size_t i = 0 ; i < new_files_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < new_files_ . size ( ) ; i + + ) { <nl> const FileMetaData & f = new_files_ [ i ] . second ; <nl> r . append ( " \ n AddFile : " ) ; <nl> AppendNumberTo ( & r , new_files_ [ i ] . first ) ; <nl> std : : string VersionEdit : : DebugString ( ) const { <nl> AppendEscapedStringTo ( & r , f . largest . Encode ( ) ) ; <nl> r . append ( " ' " ) ; <nl> } <nl> + for ( int i = 0 ; i < large_refs_added_ . size ( ) ; i + + ) { <nl> + const VersionEdit : : Large & l = large_refs_added_ [ i ] ; <nl> + r . append ( " \ n LargeRef : " ) ; <nl> + AppendNumberTo ( & r , l . fnum ) ; <nl> + r . append ( " " ) ; <nl> + r . append ( LargeValueRefToFilenameString ( l . large_ref ) ) ; <nl> + r . append ( " ' " ) ; <nl> + AppendEscapedStringTo ( & r , l . internal_key . Encode ( ) ) ; <nl> + r . append ( " ' " ) ; <nl> + } <nl> r . append ( " \ n } \ n " ) ; <nl> return r ; <nl> } <nl> similarity index 82 % <nl> rename from leveldb / db / version_edit . h <nl> rename to db / version_edit . h <nl> mmm a / leveldb / db / version_edit . h <nl> ppp b / db / version_edit . h <nl> class VersionEdit { <nl> deleted_files_ . insert ( std : : make_pair ( level , file ) ) ; <nl> } <nl> <nl> + / / Record that a large value with the specified large_ref was <nl> + / / written to the output file numbered " fnum " <nl> + void AddLargeValueRef ( const LargeValueRef & large_ref , <nl> + uint64_t fnum , <nl> + const Slice & internal_key ) { <nl> + large_refs_added_ . resize ( large_refs_added_ . size ( ) + 1 ) ; <nl> + Large * large = & ( large_refs_added_ . back ( ) ) ; <nl> + large - > large_ref = large_ref ; <nl> + large - > fnum = fnum ; <nl> + large - > internal_key . DecodeFrom ( internal_key ) ; <nl> + } <nl> + <nl> void EncodeTo ( std : : string * dst ) const ; <nl> Status DecodeFrom ( const Slice & src ) ; <nl> <nl> class VersionEdit { <nl> std : : vector < std : : pair < int , InternalKey > > compact_pointers_ ; <nl> DeletedFileSet deleted_files_ ; <nl> std : : vector < std : : pair < int , FileMetaData > > new_files_ ; <nl> + struct Large { <nl> + LargeValueRef large_ref ; <nl> + uint64_t fnum ; <nl> + InternalKey internal_key ; <nl> + } ; <nl> + std : : vector < Large > large_refs_added_ ; <nl> } ; <nl> <nl> } <nl> similarity index 79 % <nl> rename from leveldb / db / version_edit_test . cc <nl> rename to db / version_edit_test . cc <nl> mmm a / leveldb / db / version_edit_test . cc <nl> ppp b / db / version_edit_test . cc <nl> TEST ( VersionEditTest , EncodeDecode ) { <nl> for ( int i = 0 ; i < 4 ; i + + ) { <nl> TestEncodeDecode ( edit ) ; <nl> edit . AddFile ( 3 , kBig + 300 + i , kBig + 400 + i , <nl> - InternalKey ( " foo " , kBig + 500 + i , kTypeValue ) , <nl> + InternalKey ( " foo " , kBig + 500 + i , kTypeLargeValueRef ) , <nl> InternalKey ( " zoo " , kBig + 600 + i , kTypeDeletion ) ) ; <nl> edit . DeleteFile ( 4 , kBig + 700 + i ) ; <nl> + edit . AddLargeValueRef ( LargeValueRef : : Make ( " big " , kNoCompression ) , <nl> + kBig + 800 + i , " foobar " ) ; <nl> + edit . AddLargeValueRef ( LargeValueRef : : Make ( " big2 " , kSnappyCompression ) , <nl> + kBig + 801 + i , " baz " ) ; <nl> edit . SetCompactPointer ( i , InternalKey ( " x " , kBig + 900 + i , kTypeValue ) ) ; <nl> } <nl> <nl> similarity index 88 % <nl> rename from leveldb / db / version_set . cc <nl> rename to db / version_set . cc <nl> mmm a / leveldb / db / version_set . cc <nl> ppp b / db / version_set . cc <nl> std : : string IntSetToString ( const std : : set < uint64_t > & s ) { <nl> Version : : ~ Version ( ) { <nl> assert ( refs_ = = 0 ) ; <nl> for ( int level = 0 ; level < config : : kNumLevels ; level + + ) { <nl> - for ( size_t i = 0 ; i < files_ [ level ] . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files_ [ level ] . size ( ) ; i + + ) { <nl> FileMetaData * f = files_ [ level ] [ i ] ; <nl> assert ( f - > refs > = 0 ) ; <nl> f - > refs - - ; <nl> class Version : : LevelFileNumIterator : public Iterator { <nl> private : <nl> const InternalKeyComparator icmp_ ; <nl> const std : : vector < FileMetaData * > * const flist_ ; <nl> - uint32_t index_ ; <nl> + int index_ ; <nl> <nl> / / Backing store for value ( ) . Holds the file number and size . <nl> mutable char value_buf_ [ 16 ] ; <nl> Iterator * Version : : NewConcatenatingIterator ( const ReadOptions & options , <nl> void Version : : AddIterators ( const ReadOptions & options , <nl> std : : vector < Iterator * > * iters ) { <nl> / / Merge all level zero files together since they may overlap <nl> - for ( size_t i = 0 ; i < files_ [ 0 ] . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files_ [ 0 ] . size ( ) ; i + + ) { <nl> iters - > push_back ( <nl> vset_ - > table_cache_ - > NewIterator ( <nl> options , files_ [ 0 ] [ i ] - > number , files_ [ 0 ] [ i ] - > file_size ) ) ; <nl> std : : string Version : : DebugString ( ) const { <nl> AppendNumberTo ( & r , level ) ; <nl> r . push_back ( ' : ' ) ; <nl> const std : : vector < FileMetaData * > & files = files_ [ level ] ; <nl> - for ( size_t i = 0 ; i < files . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files . size ( ) ; i + + ) { <nl> r . push_back ( ' ' ) ; <nl> AppendNumberTo ( & r , files [ i ] - > number ) ; <nl> r . push_back ( ' : ' ) ; <nl> class VersionSet : : Builder { <nl> : vset_ ( vset ) { <nl> for ( int level = 0 ; level < config : : kNumLevels ; level + + ) { <nl> const std : : vector < FileMetaData * > & files = base - > files_ [ level ] ; <nl> - for ( size_t i = 0 ; i < files . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files . size ( ) ; i + + ) { <nl> FileMetaData * f = files [ i ] ; <nl> f - > refs + + ; <nl> files_ [ level ] . insert ( std : : make_pair ( f - > number , f ) ) ; <nl> class VersionSet : : Builder { <nl> / / Apply all of the edits in * edit to the current state . <nl> void Apply ( VersionEdit * edit ) { <nl> / / Update compaction pointers <nl> - for ( size_t i = 0 ; i < edit - > compact_pointers_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < edit - > compact_pointers_ . size ( ) ; i + + ) { <nl> const int level = edit - > compact_pointers_ [ i ] . first ; <nl> vset_ - > compact_pointer_ [ level ] = <nl> edit - > compact_pointers_ [ i ] . second . Encode ( ) . ToString ( ) ; <nl> class VersionSet : : Builder { <nl> } <nl> <nl> / / Add new files <nl> - for ( size_t i = 0 ; i < edit - > new_files_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < edit - > new_files_ . size ( ) ; i + + ) { <nl> const int level = edit - > new_files_ [ i ] . first ; <nl> FileMetaData * f = new FileMetaData ( edit - > new_files_ [ i ] . second ) ; <nl> f - > refs = 1 ; <nl> assert ( files_ [ level ] . count ( f - > number ) = = 0 ) ; <nl> files_ [ level ] . insert ( std : : make_pair ( f - > number , f ) ) ; <nl> } <nl> + <nl> + / / Add large value refs <nl> + for ( int i = 0 ; i < edit - > large_refs_added_ . size ( ) ; i + + ) { <nl> + const VersionEdit : : Large & l = edit - > large_refs_added_ [ i ] ; <nl> + vset_ - > RegisterLargeValueRef ( l . large_ref , l . fnum , l . internal_key ) ; <nl> + } <nl> } <nl> <nl> / / Save the current state in * v . <nl> Status VersionSet : : Recover ( ) { <nl> <nl> static int64_t TotalFileSize ( const std : : vector < FileMetaData * > & files ) { <nl> int64_t sum = 0 ; <nl> - for ( size_t i = 0 ; i < files . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files . size ( ) ; i + + ) { <nl> sum + = files [ i ] - > file_size ; <nl> } <nl> return sum ; <nl> Status VersionSet : : WriteSnapshot ( log : : Writer * log ) { <nl> / / Save files <nl> for ( int level = 0 ; level < config : : kNumLevels ; level + + ) { <nl> const std : : vector < FileMetaData * > & files = current_ - > files_ [ level ] ; <nl> - for ( size_t i = 0 ; i < files . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files . size ( ) ; i + + ) { <nl> const FileMetaData * f = files [ i ] ; <nl> edit . AddFile ( level , f - > number , f - > file_size , f - > smallest , f - > largest ) ; <nl> } <nl> } <nl> <nl> + / / Save large value refs <nl> + for ( LargeValueMap : : const_iterator it = large_value_refs_ . begin ( ) ; <nl> + it ! = large_value_refs_ . end ( ) ; <nl> + + + it ) { <nl> + const LargeValueRef & ref = it - > first ; <nl> + const LargeReferencesSet & pointers = it - > second ; <nl> + for ( LargeReferencesSet : : const_iterator j = pointers . begin ( ) ; <nl> + j ! = pointers . end ( ) ; <nl> + + + j ) { <nl> + edit . AddLargeValueRef ( ref , j - > first , j - > second ) ; <nl> + } <nl> + } <nl> + <nl> std : : string record ; <nl> edit . EncodeTo ( & record ) ; <nl> return log - > AddRecord ( record ) ; <nl> Status VersionSet : : SortLevel ( Version * v , uint64_t level ) { <nl> <nl> if ( result . ok ( ) & & level > 0 ) { <nl> / / There should be no overlap <nl> - for ( size_t i = 1 ; i < v - > files_ [ level ] . size ( ) ; i + + ) { <nl> + for ( int i = 1 ; i < v - > files_ [ level ] . size ( ) ; i + + ) { <nl> const InternalKey & prev_end = v - > files_ [ level ] [ i - 1 ] - > largest ; <nl> const InternalKey & this_begin = v - > files_ [ level ] [ i ] - > smallest ; <nl> if ( icmp_ . Compare ( prev_end , this_begin ) > = 0 ) { <nl> uint64_t VersionSet : : ApproximateOffsetOf ( Version * v , const InternalKey & ikey ) { <nl> uint64_t result = 0 ; <nl> for ( int level = 0 ; level < config : : kNumLevels ; level + + ) { <nl> const std : : vector < FileMetaData * > & files = v - > files_ [ level ] ; <nl> - for ( size_t i = 0 ; i < files . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files . size ( ) ; i + + ) { <nl> if ( icmp_ . Compare ( files [ i ] - > largest , ikey ) < = 0 ) { <nl> / / Entire file is before " ikey " , so just add the file size <nl> result + = files [ i ] - > file_size ; <nl> uint64_t VersionSet : : ApproximateOffsetOf ( Version * v , const InternalKey & ikey ) { <nl> } <nl> } <nl> } <nl> + <nl> + / / Add in large value files which are references from internal keys <nl> + / / stored in the table files <nl> + / / <nl> + / / TODO ( opt ) : this is O ( # large values in db ) . If this becomes too slow , <nl> + / / we could store an auxiliary data structure indexed by internal key <nl> + for ( LargeValueMap : : const_iterator it = large_value_refs_ . begin ( ) ; <nl> + it ! = large_value_refs_ . end ( ) ; <nl> + + + it ) { <nl> + const LargeValueRef & lref = it - > first ; <nl> + for ( LargeReferencesSet : : const_iterator it2 = it - > second . begin ( ) ; <nl> + it2 ! = it - > second . end ( ) ; <nl> + + + it2 ) { <nl> + if ( icmp_ . Compare ( it2 - > second , ikey . Encode ( ) ) < = 0 ) { <nl> + / / Internal key for large value is before our key of interest <nl> + result + = lref . ValueSize ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + <nl> return result ; <nl> } <nl> <nl> + bool VersionSet : : RegisterLargeValueRef ( const LargeValueRef & large_ref , <nl> + uint64_t fnum , <nl> + const InternalKey & internal_key ) { <nl> + LargeReferencesSet * refs = & large_value_refs_ [ large_ref ] ; <nl> + bool is_first = refs - > empty ( ) ; <nl> + refs - > insert ( make_pair ( fnum , internal_key . Encode ( ) . ToString ( ) ) ) ; <nl> + return is_first ; <nl> + } <nl> + <nl> + void VersionSet : : CleanupLargeValueRefs ( const std : : set < uint64_t > & live_tables ) { <nl> + for ( LargeValueMap : : iterator it = large_value_refs_ . begin ( ) ; <nl> + it ! = large_value_refs_ . end ( ) ; <nl> + ) { <nl> + LargeReferencesSet * refs = & it - > second ; <nl> + for ( LargeReferencesSet : : iterator ref_it = refs - > begin ( ) ; <nl> + ref_it ! = refs - > end ( ) ; <nl> + ) { <nl> + if ( ref_it - > first ! = log_number_ & & / / Not in log file <nl> + ref_it - > first ! = prev_log_number_ & & / / Not in prev log <nl> + live_tables . count ( ref_it - > first ) = = 0 ) { / / Not in a live table <nl> + / / No longer live : erase <nl> + LargeReferencesSet : : iterator to_erase = ref_it ; <nl> + + + ref_it ; <nl> + refs - > erase ( to_erase ) ; <nl> + } else { <nl> + / / Still live : leave this reference alone <nl> + + + ref_it ; <nl> + } <nl> + } <nl> + if ( refs - > empty ( ) ) { <nl> + / / No longer any live references to this large value : remove from <nl> + / / large_value_refs <nl> + Log ( env_ , options_ - > info_log , " large value is dead : ' % s ' " , <nl> + LargeValueRefToFilenameString ( it - > first ) . c_str ( ) ) ; <nl> + LargeValueMap : : iterator to_erase = it ; <nl> + + + it ; <nl> + large_value_refs_ . erase ( to_erase ) ; <nl> + } else { <nl> + + + it ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool VersionSet : : LargeValueIsLive ( const LargeValueRef & large_ref ) { <nl> + LargeValueMap : : iterator it = large_value_refs_ . find ( large_ref ) ; <nl> + if ( it = = large_value_refs_ . end ( ) ) { <nl> + return false ; <nl> + } else { <nl> + assert ( ! it - > second . empty ( ) ) ; <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> void VersionSet : : MaybeDeleteOldVersions ( ) { <nl> / / Note : it is important to delete versions in order since a newer <nl> / / version with zero refs may be holding a pointer to a memtable <nl> void VersionSet : : AddLiveFiles ( std : : set < uint64_t > * live ) { <nl> for ( Version * v = oldest_ ; v ! = NULL ; v = v - > next_ ) { <nl> for ( int level = 0 ; level < config : : kNumLevels ; level + + ) { <nl> const std : : vector < FileMetaData * > & files = v - > files_ [ level ] ; <nl> - for ( size_t i = 0 ; i < files . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files . size ( ) ; i + + ) { <nl> live - > insert ( files [ i ] - > number ) ; <nl> } <nl> } <nl> int64_t VersionSet : : MaxNextLevelOverlappingBytes ( ) { <nl> int64_t result = 0 ; <nl> std : : vector < FileMetaData * > overlaps ; <nl> for ( int level = 0 ; level < config : : kNumLevels - 1 ; level + + ) { <nl> - for ( size_t i = 0 ; i < current_ - > files_ [ level ] . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < current_ - > files_ [ level ] . size ( ) ; i + + ) { <nl> const FileMetaData * f = current_ - > files_ [ level ] [ i ] ; <nl> GetOverlappingInputs ( level + 1 , f - > smallest , f - > largest , & overlaps ) ; <nl> const int64_t sum = TotalFileSize ( overlaps ) ; <nl> void VersionSet : : GetOverlappingInputs ( <nl> Slice user_begin = begin . user_key ( ) ; <nl> Slice user_end = end . user_key ( ) ; <nl> const Comparator * user_cmp = icmp_ . user_comparator ( ) ; <nl> - for ( size_t i = 0 ; i < current_ - > files_ [ level ] . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < current_ - > files_ [ level ] . size ( ) ; i + + ) { <nl> FileMetaData * f = current_ - > files_ [ level ] [ i ] ; <nl> if ( user_cmp - > Compare ( f - > largest . user_key ( ) , user_begin ) < 0 | | <nl> user_cmp - > Compare ( f - > smallest . user_key ( ) , user_end ) > 0 ) { <nl> void VersionSet : : GetRange ( const std : : vector < FileMetaData * > & inputs , <nl> assert ( ! inputs . empty ( ) ) ; <nl> smallest - > Clear ( ) ; <nl> largest - > Clear ( ) ; <nl> - for ( size_t i = 0 ; i < inputs . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < inputs . size ( ) ; i + + ) { <nl> FileMetaData * f = inputs [ i ] ; <nl> if ( i = = 0 ) { <nl> * smallest = f - > smallest ; <nl> Iterator * VersionSet : : MakeInputIterator ( Compaction * c ) { <nl> if ( ! c - > inputs_ [ which ] . empty ( ) ) { <nl> if ( c - > level ( ) + which = = 0 ) { <nl> const std : : vector < FileMetaData * > & files = c - > inputs_ [ which ] ; <nl> - for ( size_t i = 0 ; i < files . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < files . size ( ) ; i + + ) { <nl> list [ num + + ] = table_cache_ - > NewIterator ( <nl> options , files [ i ] - > number , files [ i ] - > file_size ) ; <nl> } <nl> Compaction * VersionSet : : PickCompaction ( ) { <nl> c - > input_version_ - > Ref ( ) ; <nl> <nl> / / Pick the first file that comes after compact_pointer_ [ level ] <nl> - for ( size_t i = 0 ; i < current_ - > files_ [ level ] . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < current_ - > files_ [ level ] . size ( ) ; i + + ) { <nl> FileMetaData * f = current_ - > files_ [ level ] [ i ] ; <nl> if ( compact_pointer_ [ level ] . empty ( ) | | <nl> icmp_ . Compare ( f - > largest . Encode ( ) , compact_pointer_ [ level ] ) > 0 ) { <nl> bool Compaction : : IsTrivialMove ( ) const { <nl> <nl> void Compaction : : AddInputDeletions ( VersionEdit * edit ) { <nl> for ( int which = 0 ; which < 2 ; which + + ) { <nl> - for ( size_t i = 0 ; i < inputs_ [ which ] . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < inputs_ [ which ] . size ( ) ; i + + ) { <nl> edit - > DeleteFile ( level_ + which , inputs_ [ which ] [ i ] - > number ) ; <nl> } <nl> } <nl> similarity index 88 % <nl> rename from leveldb / db / version_set . h <nl> rename to db / version_set . h <nl> mmm a / leveldb / db / version_set . h <nl> ppp b / db / version_set . h <nl> class VersionSet { <nl> / / " key " as of version " v " . <nl> uint64_t ApproximateOffsetOf ( Version * v , const InternalKey & key ) ; <nl> <nl> + / / Register a reference to a large value with the specified <nl> + / / large_ref from the specified file number . Returns " true " if this <nl> + / / is the first recorded reference to the " large_ref " value in the <nl> + / / database , and false otherwise . <nl> + bool RegisterLargeValueRef ( const LargeValueRef & large_ref , <nl> + uint64_t filenum , <nl> + const InternalKey & internal_key ) ; <nl> + <nl> + / / Cleanup the large value reference state by eliminating any <nl> + / / references from files that are not includes in either " live_tables " <nl> + / / or the current log . <nl> + void CleanupLargeValueRefs ( const std : : set < uint64_t > & live_tables ) ; <nl> + <nl> + / / Returns true if a large value with the given reference is live . <nl> + bool LargeValueIsLive ( const LargeValueRef & large_ref ) ; <nl> + <nl> private : <nl> class Builder ; <nl> <nl> class VersionSet { <nl> Version * current_ ; / / Pointer to the last ( newest ) list entry <nl> Version * oldest_ ; / / Pointer to the first ( oldest ) list entry <nl> <nl> + / / Map from large value reference to the set of < file numbers , internal_key > <nl> + / / values containing references to the value . We keep the <nl> + / / internal key as a std : : string rather than as an InternalKey because <nl> + / / we want to be able to easily use a set . <nl> + typedef std : : set < std : : pair < uint64_t , std : : string > > LargeReferencesSet ; <nl> + typedef std : : map < LargeValueRef , LargeReferencesSet > LargeValueMap ; <nl> + LargeValueMap large_value_refs_ ; <nl> + <nl> / / Per - level key at which the next compaction at that level should start . <nl> / / Either an empty string , or a valid InternalKey . <nl> std : : string compact_pointer_ [ config : : kNumLevels ] ; <nl> class Compaction { <nl> / / State used to check for number of of overlapping grandparent files <nl> / / ( parent = = level_ + 1 , grandparent = = level_ + 2 ) <nl> std : : vector < FileMetaData * > grandparents_ ; <nl> - size_t grandparent_index_ ; / / Index in grandparent_starts_ <nl> + int grandparent_index_ ; / / Index in grandparent_starts_ <nl> bool seen_key_ ; / / Some output key has been seen <nl> int64_t overlapped_bytes_ ; / / Bytes of overlap between current output <nl> / / and grandparent files <nl> class Compaction { <nl> / / is that we are positioned at one of the file ranges for each <nl> / / higher level than the ones involved in this compaction ( i . e . for <nl> / / all L > = level_ + 2 ) . <nl> - size_t level_ptrs_ [ config : : kNumLevels ] ; <nl> + int level_ptrs_ [ config : : kNumLevels ] ; <nl> } ; <nl> <nl> } <nl> similarity index 84 % <nl> rename from leveldb / db / write_batch . cc <nl> rename to db / write_batch . cc <nl> mmm a / leveldb / db / write_batch . cc <nl> ppp b / db / write_batch . cc <nl> <nl> / / data : record [ count ] <nl> / / record : = <nl> / / kTypeValue varstring varstring | <nl> + / / kTypeLargeValueRef varstring varstring | <nl> / / kTypeDeletion varstring <nl> / / varstring : = <nl> / / len : varint32 <nl> void WriteBatch : : Put ( const Slice & key , const Slice & value ) { <nl> PutLengthPrefixedSlice ( & rep_ , value ) ; <nl> } <nl> <nl> + void WriteBatchInternal : : PutLargeValueRef ( WriteBatch * b , <nl> + const Slice & key , <nl> + const LargeValueRef & large_ref ) { <nl> + WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ; <nl> + b - > rep_ . push_back ( static_cast < char > ( kTypeLargeValueRef ) ) ; <nl> + PutLengthPrefixedSlice ( & b - > rep_ , key ) ; <nl> + PutLengthPrefixedSlice ( & b - > rep_ , <nl> + Slice ( large_ref . data , sizeof ( large_ref . data ) ) ) ; <nl> + } <nl> + <nl> void WriteBatch : : Delete ( const Slice & key ) { <nl> WriteBatchInternal : : SetCount ( this , WriteBatchInternal : : Count ( this ) + 1 ) ; <nl> rep_ . push_back ( static_cast < char > ( kTypeDeletion ) ) ; <nl> Status WriteBatchInternal : : InsertInto ( const WriteBatch * b , <nl> case kTypeValue : <nl> memtable - > Add ( it . sequence_number ( ) , kTypeValue , it . key ( ) , it . value ( ) ) ; <nl> break ; <nl> + case kTypeLargeValueRef : <nl> + memtable - > Add ( it . sequence_number ( ) , kTypeLargeValueRef , <nl> + it . key ( ) , it . value ( ) ) ; <nl> + break ; <nl> } <nl> found + + ; <nl> } <nl> void WriteBatchInternal : : Iterator : : GetNextEntry ( ) { <nl> input_ . remove_prefix ( 1 ) ; <nl> switch ( tag ) { <nl> case kTypeValue : <nl> + case kTypeLargeValueRef : <nl> if ( GetLengthPrefixedSlice ( & input_ , & key_ ) & & <nl> GetLengthPrefixedSlice ( & input_ , & value_ ) ) { <nl> op_ = static_cast < ValueType > ( tag ) ; <nl> similarity index 92 % <nl> rename from leveldb / db / write_batch_internal . h <nl> rename to db / write_batch_internal . h <nl> mmm a / leveldb / db / write_batch_internal . h <nl> ppp b / db / write_batch_internal . h <nl> namespace leveldb { <nl> / / WriteBatch that we don ' t want in the public WriteBatch interface . <nl> class WriteBatchInternal { <nl> public : <nl> + static void PutLargeValueRef ( WriteBatch * batch , <nl> + const Slice & key , <nl> + const LargeValueRef & large_ref ) ; <nl> + <nl> / / Return the number of entries in the batch . <nl> static int Count ( const WriteBatch * batch ) ; <nl> <nl> similarity index 75 % <nl> rename from leveldb / db / write_batch_test . cc <nl> rename to db / write_batch_test . cc <nl> mmm a / leveldb / db / write_batch_test . cc <nl> ppp b / db / write_batch_test . cc <nl> static std : : string PrintContents ( WriteBatch * b ) { <nl> state . append ( iter - > value ( ) . ToString ( ) ) ; <nl> state . append ( " ) " ) ; <nl> break ; <nl> + case kTypeLargeValueRef : <nl> + state . append ( " PutRef ( " ) ; <nl> + state . append ( ikey . user_key . ToString ( ) ) ; <nl> + state . append ( " , " ) ; <nl> + state . append ( iter - > value ( ) . ToString ( ) ) ; <nl> + state . append ( " ) " ) ; <nl> + break ; <nl> case kTypeDeletion : <nl> state . append ( " Delete ( " ) ; <nl> state . append ( ikey . user_key . ToString ( ) ) ; <nl> TEST ( WriteBatchTest , Multiple ) { <nl> PrintContents ( & batch ) ) ; <nl> } <nl> <nl> + TEST ( WriteBatchTest , PutIndirect ) { <nl> + WriteBatch batch ; <nl> + batch . Put ( Slice ( " baz " ) , Slice ( " boo " ) ) ; <nl> + LargeValueRef h ; <nl> + for ( int i = 0 ; i < LargeValueRef : : ByteSize ( ) ; i + + ) { <nl> + h . data [ i ] = ( i < 20 ) ? ' a ' : ' b ' ; <nl> + } <nl> + WriteBatchInternal : : PutLargeValueRef ( & batch , Slice ( " foo " ) , h ) ; <nl> + WriteBatchInternal : : SetSequence ( & batch , 100 ) ; <nl> + ASSERT_EQ ( 100 , WriteBatchInternal : : Sequence ( & batch ) ) ; <nl> + ASSERT_EQ ( 2 , WriteBatchInternal : : Count ( & batch ) ) ; <nl> + ASSERT_EQ ( " Put ( baz , boo ) @ 100 " <nl> + " PutRef ( foo , aaaaaaaaaaaaaaaaaaaabbbbbbbbb ) @ 101 " , <nl> + PrintContents ( & batch ) ) ; <nl> + } <nl> + <nl> TEST ( WriteBatchTest , Corruption ) { <nl> WriteBatch batch ; <nl> batch . Put ( Slice ( " foo " ) , Slice ( " bar " ) ) ; <nl> similarity index 100 % <nl> rename from leveldb / doc / doc . css <nl> rename to doc / doc . css <nl> similarity index 93 % <nl> rename from leveldb / doc / impl . html <nl> rename to doc / impl . html <nl> mmm a / leveldb / doc / impl . html <nl> ppp b / doc / impl . html <nl> < h2 > Sorted tables < / h2 > <nl> the young level to the largest level using only bulk reads and writes <nl> ( i . e . , minimizing expensive seeks ) . <nl> <nl> + < h2 > Large value files < / h2 > <nl> + < p > <nl> + Each large value ( greater than 64KB by default ) is placed in a large <nl> + value file ( * . val ) of its own . An entry is maintained in the log <nl> + and / or sorted tables that maps from the corresponding key to the <nl> + name of this large value file . The name of the large value file <nl> + is derived from a SHA1 hash of the value and its length so that <nl> + identical values share the same file . <nl> + < p > <nl> < h2 > Manifest < / h2 > <nl> < p > <nl> A MANIFEST file lists the set of sorted tables that make up each <nl> < h1 > Garbage collection of files < / h1 > <nl> compaction and at the end of recovery . It finds the names of all <nl> files in the database . It deletes all log files that are not the <nl> current log file . It deletes all table files that are not referenced <nl> - from some level and are not the output of an active compaction . <nl> + from some level and are not the output of an active compaction . It <nl> + deletes all large value files that are not referenced from any live <nl> + table or log file . <nl> <nl> < / body > <nl> < / html > <nl> similarity index 97 % <nl> rename from leveldb / doc / index . html <nl> rename to doc / index . html <nl> mmm a / leveldb / doc / index . html <nl> ppp b / doc / index . html <nl> < h2 > Key Layout < / h2 > <nl> over just the metadata do not force us to fetch and cache bulky file <nl> contents . <nl> < p > <nl> + < h2 > Large Values < / h2 > <nl> + < p > <nl> + < code > leveldb < / code > has special treatment of large values ( by default , a value <nl> + of length greater than or equal to 64K is considered large , though a <nl> + field in Options can be used to adjust this threshold ) . Each such <nl> + large value is placed in a separate operating system file , and the <nl> + normal database blocks just contain pointers to such files . <nl> + < p > <nl> + Furthermore , if the same large value occurs multiple times in a single <nl> + database , it will be stored just once . <nl> + < p > <nl> < h1 > Checksums < / h1 > <nl> < p > <nl> < code > leveldb < / code > associates checksums with all data it stores in the file system . <nl> similarity index 100 % <nl> rename from leveldb / doc / log_format . txt <nl> rename to doc / log_format . txt <nl> similarity index 100 % <nl> rename from leveldb / doc / table_format . txt <nl> rename to doc / table_format . txt <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / cache . h <nl> rename to include / leveldb / cache . h <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / comparator . h <nl> rename to include / leveldb / comparator . h <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / db . h <nl> rename to include / leveldb / db . h <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / env . h <nl> rename to include / leveldb / env . h <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / iterator . h <nl> rename to include / leveldb / iterator . h <nl> similarity index 95 % <nl> rename from leveldb / include / leveldb / options . h <nl> rename to include / leveldb / options . h <nl> mmm a / leveldb / include / leveldb / options . h <nl> ppp b / include / leveldb / options . h <nl> struct Options { <nl> / / Default : 1000 <nl> int max_open_files ; <nl> <nl> + / / Handle values larger than " large_value_threshold " bytes <nl> + / / specially , by writing them into their own files ( to avoid <nl> + / / compaction overhead ) and doing content - based elimination of <nl> + / / duplicate values to save space . <nl> + / / <nl> + / / We recommend against changing this value . <nl> + / / <nl> + / / Default : 64K <nl> + size_t large_value_threshold ; <nl> + <nl> / / Control over blocks ( user data is stored in a set of blocks , and <nl> / / a block is the unit of reading from disk ) . <nl> <nl> struct Options { <nl> / / compression is enabled . This parameter can be changed dynamically . <nl> / / <nl> / / Default : 4K <nl> - size_t block_size ; <nl> + int block_size ; <nl> <nl> / / Number of keys between restart points for delta encoding of keys . <nl> / / This parameter can be changed dynamically . Most clients should <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / slice . h <nl> rename to include / leveldb / slice . h <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / status . h <nl> rename to include / leveldb / status . h <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / table . h <nl> rename to include / leveldb / table . h <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / table_builder . h <nl> rename to include / leveldb / table_builder . h <nl> similarity index 100 % <nl> rename from leveldb / include / leveldb / write_batch . h <nl> rename to include / leveldb / write_batch . h <nl> similarity index 96 % <nl> rename from leveldb / leveldb . gyp <nl> rename to leveldb . gyp <nl> mmm a / leveldb / leveldb . gyp <nl> ppp b / leveldb . gyp <nl> <nl> ' port / port_example . h ' , <nl> ' port / port_posix . cc ' , <nl> ' port / port_posix . h ' , <nl> + ' port / sha1_portable . cc ' , <nl> + ' port / sha1_portable . h ' , <nl> ' table / block . cc ' , <nl> ' table / block . h ' , <nl> ' table / block_builder . cc ' , <nl> <nl> ' db / log_test . cc ' , <nl> ] , <nl> } , <nl> + { <nl> + ' target_name ' : ' leveldb_sha1_test ' , <nl> + ' type ' : ' executable ' , <nl> + ' dependencies ' : [ <nl> + ' leveldb_testutil ' , <nl> + ] , <nl> + ' sources ' : [ <nl> + ' port / sha1_test . cc ' , <nl> + ] , <nl> + } , <nl> { <nl> ' target_name ' : ' leveldb_skiplist_test ' , <nl> ' type ' : ' executable ' , <nl> deleted file mode 100644 <nl> index 2f61e8d42 . . 000000000 <nl> mmm a / leveldb / db / filename_test . cc <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2011 The LevelDB Authors . All rights reserved . <nl> - / / Use of this source code is governed by a BSD - style license that can be <nl> - / / found in the LICENSE file . See the AUTHORS file for names of contributors . <nl> - <nl> - # include " db / filename . h " <nl> - <nl> - # include " db / dbformat . h " <nl> - # include " port / port . h " <nl> - # include " util / logging . h " <nl> - # include " util / testharness . h " <nl> - <nl> - namespace leveldb { <nl> - <nl> - class FileNameTest { } ; <nl> - <nl> - TEST ( FileNameTest , Parse ) { <nl> - Slice db ; <nl> - FileType type ; <nl> - uint64_t number ; <nl> - <nl> - / / Successful parses <nl> - static struct { <nl> - const char * fname ; <nl> - uint64_t number ; <nl> - FileType type ; <nl> - } cases [ ] = { <nl> - { " 100 . log " , 100 , kLogFile } , <nl> - { " 0 . log " , 0 , kLogFile } , <nl> - { " 0 . sst " , 0 , kTableFile } , <nl> - { " CURRENT " , 0 , kCurrentFile } , <nl> - { " LOCK " , 0 , kDBLockFile } , <nl> - { " MANIFEST - 2 " , 2 , kDescriptorFile } , <nl> - { " MANIFEST - 7 " , 7 , kDescriptorFile } , <nl> - { " LOG " , 0 , kInfoLogFile } , <nl> - { " LOG . old " , 0 , kInfoLogFile } , <nl> - { " 18446744073709551615 . log " , 18446744073709551615ull , kLogFile } , <nl> - } ; <nl> - for ( int i = 0 ; i < sizeof ( cases ) / sizeof ( cases [ 0 ] ) ; i + + ) { <nl> - std : : string f = cases [ i ] . fname ; <nl> - ASSERT_TRUE ( ParseFileName ( f , & number , & type ) ) < < f ; <nl> - ASSERT_EQ ( cases [ i ] . type , type ) < < f ; <nl> - ASSERT_EQ ( cases [ i ] . number , number ) < < f ; <nl> - } <nl> - <nl> - / / Errors <nl> - static const char * errors [ ] = { <nl> - " " , <nl> - " foo " , <nl> - " foo - dx - 100 . log " , <nl> - " . log " , <nl> - " " , <nl> - " manifest " , <nl> - " CURREN " , <nl> - " CURRENTX " , <nl> - " MANIFES " , <nl> - " MANIFEST " , <nl> - " MANIFEST - " , <nl> - " XMANIFEST - 3 " , <nl> - " MANIFEST - 3x " , <nl> - " LOC " , <nl> - " LOCKx " , <nl> - " LO " , <nl> - " LOGx " , <nl> - " 18446744073709551616 . log " , <nl> - " 184467440737095516150 . log " , <nl> - " 100 " , <nl> - " 100 . " , <nl> - " 100 . lop " <nl> - } ; <nl> - for ( int i = 0 ; i < sizeof ( errors ) / sizeof ( errors [ 0 ] ) ; i + + ) { <nl> - std : : string f = errors [ i ] ; <nl> - ASSERT_TRUE ( ! ParseFileName ( f , & number , & type ) ) < < f ; <nl> - } ; <nl> - } <nl> - <nl> - TEST ( FileNameTest , Construction ) { <nl> - uint64_t number ; <nl> - FileType type ; <nl> - std : : string fname ; <nl> - <nl> - fname = CurrentFileName ( " foo " ) ; <nl> - ASSERT_EQ ( " foo / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> - ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & type ) ) ; <nl> - ASSERT_EQ ( 0 , number ) ; <nl> - ASSERT_EQ ( kCurrentFile , type ) ; <nl> - <nl> - fname = LockFileName ( " foo " ) ; <nl> - ASSERT_EQ ( " foo / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> - ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & type ) ) ; <nl> - ASSERT_EQ ( 0 , number ) ; <nl> - ASSERT_EQ ( kDBLockFile , type ) ; <nl> - <nl> - fname = LogFileName ( " foo " , 192 ) ; <nl> - ASSERT_EQ ( " foo / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> - ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & type ) ) ; <nl> - ASSERT_EQ ( 192 , number ) ; <nl> - ASSERT_EQ ( kLogFile , type ) ; <nl> - <nl> - fname = TableFileName ( " bar " , 200 ) ; <nl> - ASSERT_EQ ( " bar / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> - ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & type ) ) ; <nl> - ASSERT_EQ ( 200 , number ) ; <nl> - ASSERT_EQ ( kTableFile , type ) ; <nl> - <nl> - fname = DescriptorFileName ( " bar " , 100 ) ; <nl> - ASSERT_EQ ( " bar / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> - ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & type ) ) ; <nl> - ASSERT_EQ ( 100 , number ) ; <nl> - ASSERT_EQ ( kDescriptorFile , type ) ; <nl> - <nl> - fname = TempFileName ( " tmp " , 999 ) ; <nl> - ASSERT_EQ ( " tmp / " , std : : string ( fname . data ( ) , 4 ) ) ; <nl> - ASSERT_TRUE ( ParseFileName ( fname . c_str ( ) + 4 , & number , & type ) ) ; <nl> - ASSERT_EQ ( 999 , number ) ; <nl> - ASSERT_EQ ( kTempFile , type ) ; <nl> - } <nl> - <nl> - } <nl> - <nl> - int main ( int argc , char * * argv ) { <nl> - return leveldb : : test : : RunAllTests ( ) ; <nl> - } <nl> similarity index 100 % <nl> rename from leveldb / port / README <nl> rename to port / README <nl> similarity index 100 % <nl> rename from leveldb / port / port . h <nl> rename to port / port . h <nl> similarity index 100 % <nl> rename from leveldb / port / port_android . cc <nl> rename to port / port_android . cc <nl> similarity index 93 % <nl> rename from leveldb / port / port_android . h <nl> rename to port / port_android . h <nl> mmm a / leveldb / port / port_android . h <nl> ppp b / port / port_android . h <nl> <nl> # include < endian . h > <nl> # include < pthread . h > <nl> # include < stdint . h > <nl> + # include < sha1 . h > <nl> # include < cstdatomic > <nl> # include < string > <nl> # include < cctype > <nl> inline bool Snappy_Uncompress ( <nl> return false ; <nl> } <nl> <nl> + inline void SHA1_Hash ( const char * data , size_t len , char * hash_array ) { <nl> + SHA1_CTX sha1_ctx ; <nl> + SHA1Init ( & sha1_ctx ) ; <nl> + SHA1Update ( & sha1_ctx , ( const u_char * ) data , len ) ; <nl> + SHA1Final ( ( u_char * ) hash_array , & sha1_ctx ) ; <nl> + } <nl> + <nl> inline uint64_t ThreadIdentifier ( ) { <nl> pthread_t tid = pthread_self ( ) ; <nl> uint64_t r = 0 ; <nl> similarity index 100 % <nl> rename from leveldb / port / port_chromium . cc <nl> rename to port / port_chromium . cc <nl> similarity index 89 % <nl> rename from leveldb / port / port_chromium . h <nl> rename to port / port_chromium . h <nl> mmm a / leveldb / port / port_chromium . h <nl> ppp b / port / port_chromium . h <nl> <nl> # include " base / atomicops . h " <nl> # include " base / basictypes . h " <nl> # include " base / logging . h " <nl> + # include " base / sha1 . h " <nl> # include " base / synchronization / condition_variable . h " <nl> # include " base / synchronization / lock . h " <nl> <nl> class AtomicPointer { <nl> } <nl> } ; <nl> <nl> + inline void SHA1_Hash ( const char * data , size_t len , char * hash_array ) { <nl> + return : : base : : SHA1HashBytes ( reinterpret_cast < const unsigned char * > ( data ) , <nl> + len , <nl> + reinterpret_cast < unsigned char * > ( hash_array ) ) ; <nl> + } <nl> + <nl> bool Snappy_Compress ( const char * input , size_t input_length , <nl> std : : string * output ) ; <nl> bool Snappy_Uncompress ( const char * input_data , size_t input_length , <nl> similarity index 94 % <nl> rename from leveldb / port / port_example . h <nl> rename to port / port_example . h <nl> mmm a / leveldb / port / port_example . h <nl> ppp b / port / port_example . h <nl> class AtomicPointer { <nl> void NoBarrier_Store ( void * v ) ; <nl> } ; <nl> <nl> + / / mmmmmmmmmmmmmmmmmm Checksumming mmmmmmmmmmmmmmmmmm - <nl> + <nl> + / / Store a 160 - bit hash of " data [ 0 . . len - 1 ] " in " hash_array [ 0 ] . . hash_array [ 19 ] " <nl> + extern void SHA1_Hash ( const char * data , size_t len , char * hash_array ) ; <nl> + <nl> / / mmmmmmmmmmmmmmmmmm Compression mmmmmmmmmmmmmmmmmm - <nl> <nl> / / Store the snappy compression of " input [ 0 , input_length - 1 ] " in * output . <nl> similarity index 100 % <nl> rename from leveldb / port / port_posix . cc <nl> rename to port / port_posix . cc <nl> similarity index 93 % <nl> rename from leveldb / port / port_posix . h <nl> rename to port / port_posix . h <nl> mmm a / leveldb / port / port_posix . h <nl> ppp b / port / port_posix . h <nl> <nl> # include < string > <nl> # include < cstdatomic > <nl> # include < cstring > <nl> + # include " port / sha1_portable . h " <nl> <nl> namespace leveldb { <nl> namespace port { <nl> class AtomicPointer { <nl> } <nl> } ; <nl> <nl> + inline void SHA1_Hash ( const char * data , size_t len , char * hash_array ) { <nl> + SHA1_Hash_Portable ( data , len , hash_array ) ; <nl> + } <nl> + <nl> / / TODO ( gabor ) : Implement actual compress <nl> inline bool Snappy_Compress ( const char * input , size_t input_length , <nl> std : : string * output ) { <nl> new file mode 100644 <nl> index 000000000 . . 8fa727744 <nl> mmm / dev / null <nl> ppp b / port / sha1_portable . cc <nl> <nl> + / / Portions copyright ( c ) 2011 The LevelDB Authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . See the AUTHORS file for names of contributors . <nl> + / / <nl> + / / This module provides a slow but portable implementation of <nl> + / / the SHA1 hash function . <nl> + / / <nl> + / / It is adapted from free code written by Paul E . Jones <nl> + / / < paulej @ packetizer . com > . See http : / / www . packetizer . com / security / sha1 / <nl> + / / <nl> + / / The license for the original code is : <nl> + / * <nl> + Copyright ( C ) 1998 , 2009 <nl> + Paul E . Jones < paulej @ packetizer . com > <nl> + <nl> + Freeware Public License ( FPL ) <nl> + <nl> + This software is licensed as " freeware . " Permission to distribute <nl> + this software in source and binary forms , including incorporation <nl> + into other products , is hereby granted without a fee . THIS SOFTWARE <nl> + IS PROVIDED ' AS IS ' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES , <nl> + INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY <nl> + AND FITNESS FOR A PARTICULAR PURPOSE . THE AUTHOR SHALL NOT BE HELD <nl> + LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE , EITHER <nl> + DIRECTLY OR INDIRECTLY , INCLUDING , BUT NOT LIMITED TO , LOSS OF DATA <nl> + OR DATA BEING RENDERED INACCURATE . <nl> + * / <nl> + <nl> + # include " port / sha1_portable . h " <nl> + # include < stdio . h > <nl> + # include < stdlib . h > <nl> + # include < stdint . h > <nl> + <nl> + namespace leveldb { <nl> + namespace port { <nl> + <nl> + / * <nl> + * Description : <nl> + * This class implements the Secure Hashing Standard as defined <nl> + * in FIPS PUB 180 - 1 published April 17 , 1995 . <nl> + * / <nl> + <nl> + / * <nl> + * This structure will hold context information for the hashing <nl> + * operation <nl> + * / <nl> + typedef struct SHA1Context { <nl> + unsigned Message_Digest [ 5 ] ; / * Message Digest ( output ) * / <nl> + <nl> + unsigned Length_Low ; / * Message length in bits * / <nl> + unsigned Length_High ; / * Message length in bits * / <nl> + <nl> + unsigned char Message_Block [ 64 ] ; / * 512 - bit message blocks * / <nl> + int Message_Block_Index ; / * Index into message block array * / <nl> + <nl> + bool Computed ; / * Is the digest computed ? * / <nl> + bool Corrupted ; / * Is the message digest corruped ? * / <nl> + } SHA1Context ; <nl> + <nl> + / * <nl> + * Portability Issues : <nl> + * SHA - 1 is defined in terms of 32 - bit " words " . This code was <nl> + * written with the expectation that the processor has at least <nl> + * a 32 - bit machine word size . If the machine word size is larger , <nl> + * the code should still function properly . One caveat to that <nl> + * is that the input functions taking characters and character <nl> + * arrays assume that only 8 bits of information are stored in each <nl> + * character . <nl> + * / <nl> + <nl> + / * <nl> + * Define the circular shift macro <nl> + * / <nl> + # define SHA1CircularShift ( bits , word ) \ <nl> + ( ( ( ( word ) < < ( bits ) ) & 0xFFFFFFFF ) | \ <nl> + ( ( word ) > > ( 32 - ( bits ) ) ) ) <nl> + <nl> + / * Function prototypes * / <nl> + static void SHA1ProcessMessageBlock ( SHA1Context * ) ; <nl> + static void SHA1PadMessage ( SHA1Context * ) ; <nl> + <nl> + / / Initialize the SHA1Context in preparation for computing a new <nl> + / / message digest . <nl> + static void SHA1Reset ( SHA1Context * context ) { <nl> + context - > Length_Low = 0 ; <nl> + context - > Length_High = 0 ; <nl> + context - > Message_Block_Index = 0 ; <nl> + <nl> + context - > Message_Digest [ 0 ] = 0x67452301 ; <nl> + context - > Message_Digest [ 1 ] = 0xEFCDAB89 ; <nl> + context - > Message_Digest [ 2 ] = 0x98BADCFE ; <nl> + context - > Message_Digest [ 3 ] = 0x10325476 ; <nl> + context - > Message_Digest [ 4 ] = 0xC3D2E1F0 ; <nl> + <nl> + context - > Computed = false ; <nl> + context - > Corrupted = false ; <nl> + } <nl> + <nl> + / / This function will return the 160 - bit message digest into the <nl> + / / Message_Digest array within the SHA1Context provided <nl> + static bool SHA1Result ( SHA1Context * context ) { <nl> + if ( context - > Corrupted ) { <nl> + return false ; <nl> + } <nl> + <nl> + if ( ! context - > Computed ) { <nl> + SHA1PadMessage ( context ) ; <nl> + context - > Computed = true ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + / / This function accepts an array of bytes as the next portion of <nl> + / / the message . <nl> + static void SHA1Input ( SHA1Context * context , <nl> + const unsigned char * message_array , <nl> + unsigned length ) { <nl> + if ( ! length ) return ; <nl> + <nl> + if ( context - > Computed | | context - > Corrupted ) { <nl> + context - > Corrupted = true ; <nl> + return ; <nl> + } <nl> + <nl> + while ( length - - & & ! context - > Corrupted ) { <nl> + context - > Message_Block [ context - > Message_Block_Index + + ] = <nl> + ( * message_array & 0xFF ) ; <nl> + <nl> + context - > Length_Low + = 8 ; <nl> + / * Force it to 32 bits * / <nl> + context - > Length_Low & = 0xFFFFFFFF ; <nl> + if ( context - > Length_Low = = 0 ) { <nl> + context - > Length_High + + ; <nl> + / * Force it to 32 bits * / <nl> + context - > Length_High & = 0xFFFFFFFF ; <nl> + if ( context - > Length_High = = 0 ) <nl> + { <nl> + / * Message is too long * / <nl> + context - > Corrupted = true ; <nl> + } <nl> + } <nl> + <nl> + if ( context - > Message_Block_Index = = 64 ) <nl> + { <nl> + SHA1ProcessMessageBlock ( context ) ; <nl> + } <nl> + <nl> + message_array + + ; <nl> + } <nl> + } <nl> + <nl> + / / This function will process the next 512 bits of the message stored <nl> + / / in the Message_Block array . <nl> + static void SHA1ProcessMessageBlock ( SHA1Context * context ) { <nl> + const unsigned K [ ] = / / Constants defined in SHA - 1 <nl> + { <nl> + 0x5A827999 , <nl> + 0x6ED9EBA1 , <nl> + 0x8F1BBCDC , <nl> + 0xCA62C1D6 <nl> + } ; <nl> + int t ; / / Loop counter <nl> + unsigned temp ; / / Temporary word value <nl> + unsigned W [ 80 ] ; / / Word sequence <nl> + unsigned A , B , C , D , E ; / / Word buffers <nl> + <nl> + / / Initialize the first 16 words in the array W <nl> + for ( t = 0 ; t < 16 ; t + + ) { <nl> + W [ t ] = ( ( unsigned ) context - > Message_Block [ t * 4 ] ) < < 24 ; <nl> + W [ t ] | = ( ( unsigned ) context - > Message_Block [ t * 4 + 1 ] ) < < 16 ; <nl> + W [ t ] | = ( ( unsigned ) context - > Message_Block [ t * 4 + 2 ] ) < < 8 ; <nl> + W [ t ] | = ( ( unsigned ) context - > Message_Block [ t * 4 + 3 ] ) ; <nl> + } <nl> + <nl> + for ( t = 16 ; t < 80 ; t + + ) { <nl> + W [ t ] = SHA1CircularShift ( 1 , W [ t - 3 ] ^ W [ t - 8 ] ^ W [ t - 14 ] ^ W [ t - 16 ] ) ; <nl> + } <nl> + <nl> + A = context - > Message_Digest [ 0 ] ; <nl> + B = context - > Message_Digest [ 1 ] ; <nl> + C = context - > Message_Digest [ 2 ] ; <nl> + D = context - > Message_Digest [ 3 ] ; <nl> + E = context - > Message_Digest [ 4 ] ; <nl> + <nl> + for ( t = 0 ; t < 20 ; t + + ) { <nl> + temp = SHA1CircularShift ( 5 , A ) + <nl> + ( ( B & C ) | ( ( ~ B ) & D ) ) + E + W [ t ] + K [ 0 ] ; <nl> + temp & = 0xFFFFFFFF ; <nl> + E = D ; <nl> + D = C ; <nl> + C = SHA1CircularShift ( 30 , B ) ; <nl> + B = A ; <nl> + A = temp ; <nl> + } <nl> + <nl> + for ( t = 20 ; t < 40 ; t + + ) { <nl> + temp = SHA1CircularShift ( 5 , A ) + ( B ^ C ^ D ) + E + W [ t ] + K [ 1 ] ; <nl> + temp & = 0xFFFFFFFF ; <nl> + E = D ; <nl> + D = C ; <nl> + C = SHA1CircularShift ( 30 , B ) ; <nl> + B = A ; <nl> + A = temp ; <nl> + } <nl> + <nl> + for ( t = 40 ; t < 60 ; t + + ) { <nl> + temp = SHA1CircularShift ( 5 , A ) + <nl> + ( ( B & C ) | ( B & D ) | ( C & D ) ) + E + W [ t ] + K [ 2 ] ; <nl> + temp & = 0xFFFFFFFF ; <nl> + E = D ; <nl> + D = C ; <nl> + C = SHA1CircularShift ( 30 , B ) ; <nl> + B = A ; <nl> + A = temp ; <nl> + } <nl> + <nl> + for ( t = 60 ; t < 80 ; t + + ) { <nl> + temp = SHA1CircularShift ( 5 , A ) + ( B ^ C ^ D ) + E + W [ t ] + K [ 3 ] ; <nl> + temp & = 0xFFFFFFFF ; <nl> + E = D ; <nl> + D = C ; <nl> + C = SHA1CircularShift ( 30 , B ) ; <nl> + B = A ; <nl> + A = temp ; <nl> + } <nl> + <nl> + context - > Message_Digest [ 0 ] = ( context - > Message_Digest [ 0 ] + A ) & 0xFFFFFFFF ; <nl> + context - > Message_Digest [ 1 ] = ( context - > Message_Digest [ 1 ] + B ) & 0xFFFFFFFF ; <nl> + context - > Message_Digest [ 2 ] = ( context - > Message_Digest [ 2 ] + C ) & 0xFFFFFFFF ; <nl> + context - > Message_Digest [ 3 ] = ( context - > Message_Digest [ 3 ] + D ) & 0xFFFFFFFF ; <nl> + context - > Message_Digest [ 4 ] = ( context - > Message_Digest [ 4 ] + E ) & 0xFFFFFFFF ; <nl> + <nl> + context - > Message_Block_Index = 0 ; <nl> + } <nl> + <nl> + / / According to the standard , the message must be padded to an even <nl> + / / 512 bits . The first padding bit must be a ' 1 ' . The last 64 bits <nl> + / / represent the length of the original message . All bits in between <nl> + / / should be 0 . This function will pad the message according to those <nl> + / / rules by filling the Message_Block array accordingly . It will also <nl> + / / call SHA1ProcessMessageBlock ( ) appropriately . When it returns , it <nl> + / / can be assumed that the message digest has been computed . <nl> + static void SHA1PadMessage ( SHA1Context * context ) { <nl> + / / Check to see if the current message block is too small to hold <nl> + / / the initial padding bits and length . If so , we will pad the <nl> + / / block , process it , and then continue padding into a second block . <nl> + if ( context - > Message_Block_Index > 55 ) { <nl> + context - > Message_Block [ context - > Message_Block_Index + + ] = 0x80 ; <nl> + while ( context - > Message_Block_Index < 64 ) { <nl> + context - > Message_Block [ context - > Message_Block_Index + + ] = 0 ; <nl> + } <nl> + <nl> + SHA1ProcessMessageBlock ( context ) ; <nl> + <nl> + while ( context - > Message_Block_Index < 56 ) { <nl> + context - > Message_Block [ context - > Message_Block_Index + + ] = 0 ; <nl> + } <nl> + } else { <nl> + context - > Message_Block [ context - > Message_Block_Index + + ] = 0x80 ; <nl> + while ( context - > Message_Block_Index < 56 ) { <nl> + context - > Message_Block [ context - > Message_Block_Index + + ] = 0 ; <nl> + } <nl> + } <nl> + <nl> + / / Store the message length as the last 8 octets <nl> + context - > Message_Block [ 56 ] = ( context - > Length_High > > 24 ) & 0xFF ; <nl> + context - > Message_Block [ 57 ] = ( context - > Length_High > > 16 ) & 0xFF ; <nl> + context - > Message_Block [ 58 ] = ( context - > Length_High > > 8 ) & 0xFF ; <nl> + context - > Message_Block [ 59 ] = ( context - > Length_High ) & 0xFF ; <nl> + context - > Message_Block [ 60 ] = ( context - > Length_Low > > 24 ) & 0xFF ; <nl> + context - > Message_Block [ 61 ] = ( context - > Length_Low > > 16 ) & 0xFF ; <nl> + context - > Message_Block [ 62 ] = ( context - > Length_Low > > 8 ) & 0xFF ; <nl> + context - > Message_Block [ 63 ] = ( context - > Length_Low ) & 0xFF ; <nl> + <nl> + SHA1ProcessMessageBlock ( context ) ; <nl> + } <nl> + <nl> + <nl> + void SHA1_Hash_Portable ( const char * data , size_t len , char * hash_array ) { <nl> + SHA1Context context ; <nl> + SHA1Reset ( & context ) ; <nl> + SHA1Input ( & context , reinterpret_cast < const unsigned char * > ( data ) , len ) ; <nl> + bool ok = SHA1Result ( & context ) ; <nl> + if ( ! ok ) { <nl> + fprintf ( stderr , " Unexpected error in SHA1_Hash_Portable code \ n " ) ; <nl> + exit ( 1 ) ; <nl> + } <nl> + for ( int i = 0 ; i < 5 ; i + + ) { <nl> + uint32_t value = context . Message_Digest [ i ] ; <nl> + hash_array [ i * 4 + 0 ] = ( value > > 24 ) & 0xff ; <nl> + hash_array [ i * 4 + 1 ] = ( value > > 16 ) & 0xff ; <nl> + hash_array [ i * 4 + 2 ] = ( value > > 8 ) & 0xff ; <nl> + hash_array [ i * 4 + 3 ] = value & 0xff ; <nl> + } <nl> + } <nl> + <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000 . . 31db30528 <nl> mmm / dev / null <nl> ppp b / port / sha1_portable . h <nl> <nl> + / / Copyright ( c ) 2011 The LevelDB Authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . See the AUTHORS file for names of contributors . <nl> + <nl> + # ifndef STORAGE_LEVELDB_PORT_SHA1_PORTABLE_H_ <nl> + # define STORAGE_LEVELDB_PORT_SHA1_PORTABLE_H_ <nl> + <nl> + # include < stddef . h > <nl> + <nl> + namespace leveldb { <nl> + namespace port { <nl> + <nl> + / / Compute the SHA1 hash value of " data [ 0 . . len - 1 ] " and store it in <nl> + / / " hash_array [ 0 . . 19 ] " . hash_array must have 20 bytes of space available . <nl> + / / <nl> + / / This function is portable but may not be as fast as a version <nl> + / / optimized for your platform . It is provided as a default method <nl> + / / that can be used when porting leveldb to a new platform if no <nl> + / / better SHA1 hash implementation is available . <nl> + void SHA1_Hash_Portable ( const char * data , size_t len , char * hash_array ) ; <nl> + <nl> + } <nl> + } <nl> + <nl> + # endif / / STORAGE_LEVELDB_PORT_SHA1_PORTABLE_H_ <nl> new file mode 100644 <nl> index 000000000 . . b182e6757 <nl> mmm / dev / null <nl> ppp b / port / sha1_test . cc <nl> <nl> + / / Copyright ( c ) 2011 The LevelDB Authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . See the AUTHORS file for names of contributors . <nl> + <nl> + # include " port / port . h " <nl> + # include " util / testharness . h " <nl> + <nl> + namespace leveldb { <nl> + namespace port { <nl> + <nl> + class SHA1 { } ; <nl> + <nl> + static std : : string TestSHA1 ( const char * data , size_t len ) { <nl> + char hash_val [ 20 ] ; <nl> + SHA1_Hash ( data , len , hash_val ) ; <nl> + char buf [ 41 ] ; <nl> + for ( int i = 0 ; i < 20 ; i + + ) { <nl> + snprintf ( buf + i * 2 , 41 - i * 2 , <nl> + " % 02x " , <nl> + static_cast < unsigned int > ( static_cast < unsigned char > ( <nl> + hash_val [ i ] ) ) ) ; <nl> + } <nl> + return std : : string ( buf , 40 ) ; <nl> + } <nl> + <nl> + TEST ( SHA1 , Simple ) { <nl> + ASSERT_EQ ( " da39a3ee5e6b4b0d3255bfef95601890afd80709 " , TestSHA1 ( " " , 0 ) ) ; <nl> + ASSERT_EQ ( " aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d " , TestSHA1 ( " hello " , 5 ) ) ; <nl> + std : : string x ( 10000 , ' x ' ) ; <nl> + ASSERT_EQ ( " f8c5cde791c5056cf515881e701c8a9ecb439a75 " , <nl> + TestSHA1 ( x . data ( ) , x . size ( ) ) ) ; <nl> + } <nl> + <nl> + } <nl> + } <nl> + <nl> + int main ( int argc , char * * argv ) { <nl> + return leveldb : : test : : RunAllTests ( ) ; <nl> + } <nl> similarity index 100 % <nl> rename from leveldb / port / win / stdint . h <nl> rename to port / win / stdint . h <nl> similarity index 98 % <nl> rename from leveldb / table / block . cc <nl> rename to table / block . cc <nl> mmm a / leveldb / table / block . cc <nl> ppp b / table / block . cc <nl> static inline const char * DecodeEntry ( const char * p , const char * limit , <nl> if ( ( p = GetVarint32Ptr ( p , limit , value_length ) ) = = NULL ) return NULL ; <nl> } <nl> <nl> - if ( static_cast < uint32 > ( limit - p ) < ( * non_shared + * value_length ) ) { <nl> - return NULL ; <nl> - } <nl> + if ( limit - p < ( * non_shared + * value_length ) ) return NULL ; <nl> return p ; <nl> } <nl> <nl> similarity index 100 % <nl> rename from leveldb / table / block . h <nl> rename to table / block . h <nl> similarity index 98 % <nl> rename from leveldb / table / block_builder . cc <nl> rename to table / block_builder . cc <nl> mmm a / leveldb / table / block_builder . cc <nl> ppp b / table / block_builder . cc <nl> size_t BlockBuilder : : CurrentSizeEstimate ( ) const { <nl> <nl> Slice BlockBuilder : : Finish ( ) { <nl> / / Append restart array <nl> - for ( size_t i = 0 ; i < restarts_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < restarts_ . size ( ) ; i + + ) { <nl> PutFixed32 ( & buffer_ , restarts_ [ i ] ) ; <nl> } <nl> PutFixed32 ( & buffer_ , restarts_ . size ( ) ) ; <nl> similarity index 100 % <nl> rename from leveldb / table / block_builder . h <nl> rename to table / block_builder . h <nl> similarity index 96 % <nl> rename from leveldb / table / format . cc <nl> rename to table / format . cc <nl> mmm a / leveldb / table / format . cc <nl> ppp b / table / format . cc <nl> void Footer : : EncodeTo ( std : : string * dst ) const { <nl> metaindex_handle_ . EncodeTo ( dst ) ; <nl> index_handle_ . EncodeTo ( dst ) ; <nl> dst - > resize ( 2 * BlockHandle : : kMaxEncodedLength ) ; / / Padding <nl> - PutFixed32 ( dst , static_cast < uint32_t > ( kTableMagicNumber & 0xffffffffu ) ) ; <nl> + PutFixed32 ( dst , static_cast < uint32_t > ( kTableMagicNumber ) ) ; <nl> PutFixed32 ( dst , static_cast < uint32_t > ( kTableMagicNumber > > 32 ) ) ; <nl> assert ( dst - > size ( ) = = original_size + kEncodedLength ) ; <nl> } <nl> Status ReadBlock ( RandomAccessFile * file , <nl> <nl> / / Read the block contents as well as the type / crc footer . <nl> / / See table_builder . cc for the code that built this structure . <nl> - size_t n = static_cast < size_t > ( handle . size ( ) ) ; <nl> + size_t n = handle . size ( ) ; <nl> char * buf = new char [ n + kBlockTrailerSize ] ; <nl> Slice contents ; <nl> Status s = file - > Read ( handle . offset ( ) , n + kBlockTrailerSize , & contents , buf ) ; <nl> similarity index 100 % <nl> rename from leveldb / table / format . h <nl> rename to table / format . h <nl> similarity index 100 % <nl> rename from leveldb / table / iterator . cc <nl> rename to table / iterator . cc <nl> similarity index 100 % <nl> rename from leveldb / table / iterator_wrapper . h <nl> rename to table / iterator_wrapper . h <nl> similarity index 100 % <nl> rename from leveldb / table / merger . cc <nl> rename to table / merger . cc <nl> similarity index 100 % <nl> rename from leveldb / table / merger . h <nl> rename to table / merger . h <nl> similarity index 100 % <nl> rename from leveldb / table / table . cc <nl> rename to table / table . cc <nl> similarity index 100 % <nl> rename from leveldb / table / table_builder . cc <nl> rename to table / table_builder . cc <nl> similarity index 100 % <nl> rename from leveldb / table / table_test . cc <nl> rename to table / table_test . cc <nl> similarity index 100 % <nl> rename from leveldb / table / two_level_iterator . cc <nl> rename to table / two_level_iterator . cc <nl> similarity index 100 % <nl> rename from leveldb / table / two_level_iterator . h <nl> rename to table / two_level_iterator . h <nl> similarity index 97 % <nl> rename from leveldb / util / arena . cc <nl> rename to util / arena . cc <nl> mmm a / leveldb / util / arena . cc <nl> ppp b / util / arena . cc <nl> Arena : : Arena ( ) { <nl> } <nl> <nl> Arena : : ~ Arena ( ) { <nl> - for ( size_t i = 0 ; i < blocks_ . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < blocks_ . size ( ) ; i + + ) { <nl> delete [ ] blocks_ [ i ] ; <nl> } <nl> } <nl> similarity index 100 % <nl> rename from leveldb / util / arena . h <nl> rename to util / arena . h <nl> similarity index 100 % <nl> rename from leveldb / util / arena_test . cc <nl> rename to util / arena_test . cc <nl> similarity index 100 % <nl> rename from leveldb / util / cache . cc <nl> rename to util / cache . cc <nl> similarity index 100 % <nl> rename from leveldb / util / cache_test . cc <nl> rename to util / cache_test . cc <nl> similarity index 99 % <nl> rename from leveldb / util / coding . cc <nl> rename to util / coding . cc <nl> mmm a / leveldb / util / coding . cc <nl> ppp b / util / coding . cc <nl> char * EncodeVarint64 ( char * dst , uint64_t v ) { <nl> * ( ptr + + ) = ( v & ( B - 1 ) ) | B ; <nl> v > > = 7 ; <nl> } <nl> - * ( ptr + + ) = static_cast < unsigned char > ( v ) ; <nl> + * ( ptr + + ) = v ; <nl> return reinterpret_cast < char * > ( ptr ) ; <nl> } <nl> <nl> similarity index 100 % <nl> rename from leveldb / util / coding . h <nl> rename to util / coding . h <nl> similarity index 100 % <nl> rename from leveldb / util / coding_test . cc <nl> rename to util / coding_test . cc <nl> similarity index 98 % <nl> rename from leveldb / util / comparator . cc <nl> rename to util / comparator . cc <nl> mmm a / leveldb / util / comparator . cc <nl> ppp b / util / comparator . cc <nl> class BytewiseComparatorImpl : public Comparator { <nl> virtual void FindShortSuccessor ( std : : string * key ) const { <nl> / / Find first character that can be incremented <nl> size_t n = key - > size ( ) ; <nl> - for ( size_t i = 0 ; i < n ; i + + ) { <nl> + for ( int i = 0 ; i < n ; i + + ) { <nl> const uint8_t byte = ( * key ) [ i ] ; <nl> if ( byte ! = static_cast < uint8_t > ( 0xff ) ) { <nl> ( * key ) [ i ] = byte + 1 ; <nl> similarity index 100 % <nl> rename from leveldb / util / crc32c . cc <nl> rename to util / crc32c . cc <nl> similarity index 100 % <nl> rename from leveldb / util / crc32c . h <nl> rename to util / crc32c . h <nl> similarity index 100 % <nl> rename from leveldb / util / crc32c_test . cc <nl> rename to util / crc32c_test . cc <nl> similarity index 100 % <nl> rename from leveldb / util / env . cc <nl> rename to util / env . cc <nl> similarity index 100 % <nl> rename from leveldb / util / env_chromium . cc <nl> rename to util / env_chromium . cc <nl> similarity index 100 % <nl> rename from leveldb / util / env_posix . cc <nl> rename to util / env_posix . cc <nl> similarity index 100 % <nl> rename from leveldb / util / env_test . cc <nl> rename to util / env_test . cc <nl> similarity index 100 % <nl> rename from leveldb / util / hash . cc <nl> rename to util / hash . cc <nl> similarity index 100 % <nl> rename from leveldb / util / hash . h <nl> rename to util / hash . h <nl> similarity index 100 % <nl> rename from leveldb / util / histogram . cc <nl> rename to util / histogram . cc <nl> similarity index 100 % <nl> rename from leveldb / util / histogram . h <nl> rename to util / histogram . h <nl> similarity index 97 % <nl> rename from leveldb / util / logging . cc <nl> rename to util / logging . cc <nl> mmm a / leveldb / util / logging . cc <nl> ppp b / util / logging . cc <nl> void AppendNumberTo ( std : : string * str , uint64_t num ) { <nl> } <nl> <nl> void AppendEscapedStringTo ( std : : string * str , const Slice & value ) { <nl> - for ( size_t i = 0 ; i < value . size ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < value . size ( ) ; i + + ) { <nl> char c = value [ i ] ; <nl> if ( c > = ' ' & & c < = ' ~ ' ) { <nl> str - > push_back ( c ) ; <nl> similarity index 100 % <nl> rename from leveldb / util / logging . h <nl> rename to util / logging . h <nl> similarity index 100 % <nl> rename from leveldb / util / mutexlock . h <nl> rename to util / mutexlock . h <nl> similarity index 95 % <nl> rename from leveldb / util / options . cc <nl> rename to util / options . cc <nl> mmm a / leveldb / util / options . cc <nl> ppp b / util / options . cc <nl> Options : : Options ( ) <nl> info_log ( NULL ) , <nl> write_buffer_size ( 4 < < 20 ) , <nl> max_open_files ( 1000 ) , <nl> + large_value_threshold ( 65536 ) , <nl> block_cache ( NULL ) , <nl> block_size ( 4096 ) , <nl> block_restart_interval ( 16 ) , <nl> similarity index 96 % <nl> rename from leveldb / util / random . h <nl> rename to util / random . h <nl> mmm a / leveldb / util / random . h <nl> ppp b / util / random . h <nl> class Random { <nl> uint64_t product = seed_ * A ; <nl> <nl> / / Compute ( product % M ) using the fact that ( ( x < < 31 ) % M ) = = x . <nl> - seed_ = static_cast < uint32_t > ( ( product > > 31 ) + ( product & M ) ) ; <nl> + seed_ = ( product > > 31 ) + ( product & M ) ; <nl> / / The first reduction may overflow by 1 bit , so we may need to <nl> / / repeat . mod = = M is not possible ; using > allows the faster <nl> / / sign - bit - based test . <nl> similarity index 100 % <nl> rename from leveldb / util / status . cc <nl> rename to util / status . cc <nl> similarity index 100 % <nl> rename from leveldb / util / testharness . cc <nl> rename to util / testharness . cc <nl> similarity index 100 % <nl> rename from leveldb / util / testharness . h <nl> rename to util / testharness . h <nl> similarity index 100 % <nl> rename from leveldb / util / testutil . cc <nl> rename to util / testutil . cc <nl> similarity index 100 % <nl> rename from leveldb / util / testutil . h <nl> rename to util / testutil . h <nl>
reverting disastrous MOE commit , returning to r21
facebook/rocksdb
69c6d38342a1fab5f7f2921aa2e9c0e60ba90e35
2011-04-19T23:11:15Z
mmm a / src / qml / app . qml <nl> ppp b / src / qml / app . qml <nl> ApplicationWindow { <nl> <nl> toolBar : AppToolBar { } <nl> <nl> - SplitView { <nl> + BetterSplitView { <nl> anchors . fill : parent <nl> - orientation : Qt . Horizontal <nl> + orientation : Qt . Horizontal <nl> <nl> BetterTreeView { <nl> id : connectionsTree <nl> ApplicationWindow { <nl> Layout . minimumWidth : 350 <nl> } <nl> <nl> - SplitView { <nl> + BetterSplitView { <nl> orientation : Qt . Vertical <nl> <nl> BetterTabView { <nl> new file mode 100644 <nl> index 00000000 . . 4fcd61ab <nl> mmm / dev / null <nl> ppp b / src / qml / common / BetterSplitView . qml <nl> <nl> + import QtQuick 2 . 0 <nl> + import QtQuick . Controls 1 . 4 <nl> + import QtQuick . Controls . Styles 1 . 1 <nl> + <nl> + SplitView { <nl> + handleDelegate : Rectangle { color : " # e2e2e2 " } <nl> + } <nl> mmm a / src / qml / common / BetterTabView . qml <nl> ppp b / src / qml / common / BetterTabView . qml <nl> import QtQuick 2 . 3 <nl> import QtQuick . Layouts 1 . 1 <nl> import QtQuick . Controls 1 . 4 <nl> import QtQuick . Controls . Styles 1 . 1 <nl> - <nl> + import " . " <nl> <nl> TabView { <nl> id : root <nl> TabView { <nl> Layout . preferredWidth : 3 <nl> } <nl> <nl> - ToolButton { <nl> + ImageButton { <nl> visible : root . getTab ( styleData . index ) & & root . getTab ( styleData . index ) . closable <nl> + <nl> Layout . preferredWidth : 18 <nl> Layout . preferredHeight : 18 <nl> <nl> - iconSource : " qrc : / images / clear . png " <nl> + imgSource : " qrc : / images / clear . png " <nl> onClicked : root . getTab ( styleData . index ) . closeTab ( styleData . index ) <nl> } <nl> } <nl> new file mode 100644 <nl> index 00000000 . . 164ced55 <nl> mmm / dev / null <nl> ppp b / src / qml / common / ImageButton . qml <nl> <nl> + import QtQuick 2 . 0 <nl> + <nl> + Item { <nl> + id : root <nl> + property alias imgWidth : img . width <nl> + property alias imgHeight : img . height <nl> + property alias imgSource : img . source <nl> + <nl> + signal clicked <nl> + <nl> + Image { <nl> + id : img <nl> + anchors . centerIn : parent <nl> + source : " qrc : / images / clear . png " <nl> + width : 18 <nl> + height : 18 <nl> + } <nl> + <nl> + MouseArea { <nl> + anchors . fill : parent <nl> + onClicked : root . clicked ( ) <nl> + } <nl> + } <nl> + <nl> mmm a / src / qml / connections - tree / menu / InlineMenu . qml <nl> ppp b / src / qml / connections - tree / menu / InlineMenu . qml <nl> <nl> import QtQuick 2 . 3 <nl> import QtQuick . Layouts 1 . 1 <nl> import QtQuick . Controls 1 . 4 <nl> + import " . / . . / . . / " <nl> <nl> RowLayout { <nl> property alias model : repeater . model <nl> RowLayout { <nl> ToolButton { <nl> iconSource : modelData [ ' icon ' ] <nl> <nl> + Layout . preferredWidth : 25 <nl> + Layout . preferredHeight : 25 <nl> + <nl> onClicked : { <nl> if ( ! connectionsManager ) <nl> return <nl> mmm a / src / qml / qml . qrc <nl> ppp b / src / qml / qml . qrc <nl> <nl> < qresource prefix = " / " > <nl> < file > app . qml < / file > <nl> < file > WelcomeTab . qml < / file > <nl> - < file > QuickStartDialog . qml < / file > <nl> + < file > QuickStartDialog . qml < / file > <nl> < file > ConnectionSettignsDialog . qml < / file > <nl> < file > common / RichTextWithLinks . qml < / file > <nl> < file > common / PasswordInput . qml < / file > <nl> <nl> < file > console / Consoles . qml < / file > <nl> < file > connections - tree / BetterTreeView . qml < / file > <nl> < file > AppToolBar . qml < / file > <nl> + < file > common / BetterSplitView . qml < / file > <nl> + < file > common / ImageButton . qml < / file > <nl> < / qresource > <nl> < / RCC > <nl>
Fix layout issues on OSX
uglide/RedisDesktopManager
a2e5358be59240fc269a9282d14f10d8679fed5e
2016-01-31T11:01:03Z
mmm a / modules / common / util / string_util . cc <nl> ppp b / modules / common / util / string_util . cc <nl> namespace { <nl> static const char kBase64Array [ ] = <nl> " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 + / " ; <nl> <nl> - / / A table which maps a char to its value in Base64 mode . <nl> - std : : vector < int > Base64CodeTable ( ) { <nl> - std : : vector < int > table ( 256 , - 1 ) ; <nl> - const size_t base64_array_length = strlen ( kBase64Array ) ; <nl> - for ( size_t i = 0 ; i < base64_array_length ; + + i ) { <nl> - table [ kBase64Array [ i ] ] = static_cast < int > ( i ) ; <nl> - } <nl> - return table ; <nl> - } <nl> - <nl> const char * tripletBase64 ( const int triplet ) { <nl> static char result [ 4 ] ; <nl> result [ 0 ] = kBase64Array [ ( triplet > > 18 ) & 0x3f ] ; <nl> const char * tripletBase64 ( const int triplet ) { <nl> <nl> } / / namespace <nl> <nl> - std : : string DecodeBase64 ( const std : : string & base64_str ) { <nl> - static const std : : vector < int > kBase64CodeTable = Base64CodeTable ( ) ; <nl> - <nl> - std : : string bytes ; <nl> - / / Binary string is generally 3 / 4 the length of base64 string <nl> - bytes . reserve ( base64_str . length ( ) * 3 / 4 + 3 ) ; <nl> - unsigned int sum = 0 , sum_bits = 0 ; <nl> - for ( const char c : base64_str ) { <nl> - if ( kBase64CodeTable [ c ] = = - 1 ) { <nl> - break ; <nl> - } <nl> - <nl> - / / Convert 6 - bits Base64 chars to 8 - bits general bytes . <nl> - sum = ( sum < < 6 ) + kBase64CodeTable [ c ] ; <nl> - sum_bits + = 6 ; <nl> - if ( sum_bits > = 8 ) { <nl> - bytes . push_back ( static_cast < char > ( ( sum > > ( sum_bits - 8 ) ) & 0xFF ) ) ; <nl> - sum_bits - = 8 ; <nl> - } <nl> - } <nl> - return bytes ; <nl> - } <nl> - <nl> std : : string EncodeBase64 ( const std : : string & in ) { <nl> std : : string out ; <nl> if ( in . empty ( ) ) { <nl> mmm a / modules / common / util / string_util . h <nl> ppp b / modules / common / util / string_util . h <nl> struct DebugStringFormatter { <nl> } <nl> } ; <nl> <nl> - std : : string DecodeBase64 ( const std : : string & base64_str ) ; <nl> - <nl> std : : string EncodeBase64 ( const std : : string & in ) ; <nl> <nl> } / / namespace util <nl> mmm a / modules / common / util / string_util_test . cc <nl> ppp b / modules / common / util / string_util_test . cc <nl> namespace apollo { <nl> namespace common { <nl> namespace util { <nl> <nl> - TEST ( StringUtilTest , DecodeBase64 ) { <nl> - EXPECT_EQ ( " " , DecodeBase64 ( " " ) ) ; <nl> - EXPECT_EQ ( " f " , DecodeBase64 ( " Zg = = " ) ) ; <nl> - EXPECT_EQ ( " fo " , DecodeBase64 ( " Zm8 = " ) ) ; <nl> - EXPECT_EQ ( " foo " , DecodeBase64 ( " Zm9v " ) ) ; <nl> - EXPECT_EQ ( " foob " , DecodeBase64 ( " Zm9vYg = = " ) ) ; <nl> - EXPECT_EQ ( " fooba " , DecodeBase64 ( " Zm9vYmE = " ) ) ; <nl> - EXPECT_EQ ( " foobar " , DecodeBase64 ( " Zm9vYmFy " ) ) ; <nl> - } <nl> - <nl> TEST ( StringUtilTest , EncodeBase64 ) { <nl> EXPECT_EQ ( " " , EncodeBase64 ( " " ) ) ; <nl> EXPECT_EQ ( " Zg = = " , EncodeBase64 ( " f " ) ) ; <nl>
Common : Retire unused DecodeBase64 .
ApolloAuto/apollo
c692005bb0d344b7554ea0f44a8ee0e1a9b82417
2019-11-19T01:10:00Z
mmm a / test / 1_stdlib / Optional . swift <nl> ppp b / test / 1_stdlib / Optional . swift <nl> <nl> protocol TestProtocol1 { } <nl> <nl> / / Check that the generic parameter is called ' Memory ' . <nl> - extension Optional where Wrapped : TestProtocol1 { <nl> + extension Optional where Wrapped : TestProtocol1 { <nl> var _wrappedIsTestProtocol1 : Bool { <nl> fatalError ( " not implemented " ) <nl> } <nl> } <nl> <nl> - extension ImplicitlyUnwrappedOptional where Wrapped : TestProtocol1 { <nl> + extension ImplicitlyUnwrappedOptional where Wrapped : TestProtocol1 { <nl> var _wrappedIsTestProtocol1 : Bool { <nl> fatalError ( " not implemented " ) <nl> } <nl> } <nl> <nl> - var x : Optional < Int > = nil <nl> + var x : Optional < Int > = nil <nl> if x ! = nil { <nl> print ( " x is non - empty ! " ) <nl> } else { <nl> if x = = nil { <nl> / / CHECK : logical negation works 0 <nl> <nl> if true { <nl> - var y1 : Optional < Int > = . None <nl> + var y1 : Optional < Int > = . None <nl> if y1 = = nil { <nl> print ( " y1 is . None " ) <nl> } <nl> / / CHECK : y1 is . None <nl> <nl> - var y2 : Optional < Int > = . None <nl> + var y2 : Optional < Int > = . None <nl> if y2 = = nil { <nl> print ( " y2 is . None " ) <nl> } <nl> let OptionalTests = TestSuite ( " Optional " ) <nl> struct X { } <nl> class C { } <nl> <nl> - class E : Equatable { } <nl> + class E : Equatable { } <nl> func = = ( _ : E , _ : E ) - > Bool { return true } <nl> <nl> OptionalTests . test ( " nil comparison " ) { <nl> OptionalTests . test ( " flatMap " ) { <nl> } <nl> <nl> @ inline ( never ) <nl> - func anyToAny < T , U > ( a : T , _ : U . Type ) - > U { <nl> + func anyToAny < T , U > ( a : T , _ : U . Type ) - > U { <nl> return a as ! U <nl> } <nl> @ inline ( never ) <nl> - func anyToAnyOrNil < T , U > ( a : T , _ : U . Type ) - > U ? { <nl> + func anyToAnyOrNil < T , U > ( a : T , _ : U . Type ) - > U ? { <nl> return a as ? U <nl> } <nl> - func canGenericCast < T , U > ( a : T , _ ty : U . Type ) - > Bool { <nl> + func canGenericCast < T , U > ( a : T , _ ty : U . Type ) - > Bool { <nl> return anyToAnyOrNil ( a , ty ) ! = nil <nl> } <nl> <nl> OptionalTests . test ( " Casting Optional " ) { <nl> let x = C ( ) <nl> - let sx : C ? = x <nl> - let nx : C ? = nil <nl> + let sx : C ? = x <nl> + let nx : C ? = nil <nl> expectTrue ( anyToAny ( x , Optional < C > . self ) ! = = = x ) <nl> expectTrue ( anyToAny ( sx , C . self ) = = = x ) <nl> expectTrue ( anyToAny ( sx , Optional < C > . self ) ! = = = x ) <nl> OptionalTests . test ( " Casting Optional " ) { <nl> expectTrue ( anyToAnyOrNil ( nx , C . self ) = = nil ) <nl> <nl> let i = Int . max <nl> - let si : Int ? = Int . max <nl> - let ni : Int ? = nil <nl> + let si : Int ? = Int . max <nl> + let ni : Int ? = nil <nl> expectEqual ( anyToAny ( i , Optional < Int > . self ) ! , Int . max ) <nl> expectEqual ( anyToAny ( si , Int . self ) , Int . max ) <nl> expectEqual ( anyToAny ( si , Optional < Int > . self ) ! , Int . max ) <nl> OptionalTests . test ( " Casting Optional " ) { <nl> expectTrue ( anyToAny ( ni , Optional < Int > . self ) = = nil ) <nl> expectTrue ( anyToAnyOrNil ( ni , Int . self ) = = nil ) <nl> <nl> - let ssx : C ? ? = sx <nl> + let ssx : C ? ? = sx <nl> expectTrue ( anyToAny ( ssx , Optional < C > . self ) ! = = = x ) <nl> expectTrue ( anyToAny ( x , Optional < Optional < C > > . self ) ! ! = = = x ) <nl> expectTrue ( anyToAnyOrNil ( ni , Int . self ) = = nil ) <nl> } <nl> <nl> OptionalTests . test ( " Casting Optional Traps " ) { <nl> - let nx : C ? = nil <nl> + let nx : C ? = nil <nl> expectCrashLater ( ) <nl> anyToAny ( nx , Int . self ) <nl> } <nl> <nl> class TestNoString { } <nl> - class TestString : CustomStringConvertible , CustomDebugStringConvertible { <nl> + class TestString : CustomStringConvertible , CustomDebugStringConvertible { <nl> var description : String { <nl> return " AString " <nl> } <nl> class TestString : CustomStringConvertible , CustomDebugStringConvertible { <nl> return " XString " <nl> } <nl> } <nl> - class TestStream : Streamable { <nl> - func writeTo < Target : OutputStreamType > ( inout target : Target ) { <nl> + class TestStream : Streamable { <nl> + func writeTo < Target : OutputStreamType > ( inout target : Target ) { <nl> target . write ( " AStream " ) <nl> } <nl> } <nl> func debugPrintStr < T > ( a : T ) - > String { <nl> / / description regardless of whether the wrapper type conforms to an <nl> / / output stream protocol . <nl> OptionalTests . test ( " Optional OutputStream " ) { <nl> - let optNoString : TestNoString ? = TestNoString ( ) <nl> + let optNoString : TestNoString ? = TestNoString ( ) <nl> expectFalse ( optNoString is CustomStringConvertible ) <nl> expectFalse ( canGenericCast ( optNoString , CustomStringConvertible . self ) ) <nl> expectFalse ( optNoString is Streamable ) <nl> OptionalTests . test ( " Optional OutputStream " ) { <nl> expectEqual ( String ( optNoString ) , " Optional ( main . TestNoString ) " ) <nl> expectEqual ( debugPrintStr ( optNoString ) , " Optional ( main . TestNoString ) " ) <nl> <nl> - let iouNoString : TestNoString ! = TestNoString ( ) <nl> + let iouNoString : TestNoString ! = TestNoString ( ) <nl> / / IOU directly conforms to CustomStringConvertible . <nl> / / Disabled pending SR - 164 <nl> / / expectTrue ( iouNoString is CustomStringConvertible ) <nl> OptionalTests . test ( " Optional OutputStream " ) { <nl> expectEqual ( String ( iouNoString ) , " main . TestNoString " ) <nl> expectEqual ( debugPrintStr ( iouNoString ) , " main . TestNoString " ) <nl> <nl> - let optString : TestString ? = TestString ( ) <nl> + let optString : TestString ? = TestString ( ) <nl> expectTrue ( optString is CustomStringConvertible ) <nl> expectTrue ( canGenericCast ( optString , CustomStringConvertible . self ) ) <nl> expectTrue ( optString is CustomDebugStringConvertible ) <nl> OptionalTests . test ( " Optional OutputStream " ) { <nl> expectEqual ( String ( optString ) , " Optional ( XString ) " ) <nl> expectEqual ( debugPrintStr ( optString ) , " Optional ( XString ) " ) <nl> <nl> - let iouString : TestString ! = TestString ( ) <nl> + let iouString : TestString ! = TestString ( ) <nl> expectTrue ( iouString is CustomStringConvertible ) <nl> expectTrue ( canGenericCast ( iouString , CustomStringConvertible . self ) ) <nl> / / CustomDebugStringConvertible conformance is a temporary hack . <nl> OptionalTests . test ( " Optional OutputStream " ) { <nl> / / ( directly invoking debugPrint ( Any ) already works correctly ) . <nl> expectEqual ( debugPrintStr ( iouString ) , " AString " ) <nl> <nl> - let optStream : TestStream ? = TestStream ( ) <nl> + let optStream : TestStream ? = TestStream ( ) <nl> expectTrue ( optStream is Streamable ) <nl> expectTrue ( canGenericCast ( optStream , Streamable . self ) ) <nl> expectTrue ( optStream is CustomDebugStringConvertible ) <nl>
Improving code style
apple/swift
da1cdf2f47a59b521c46be590ae208a17e814ea5
2015-12-11T17:05:05Z
mmm a / templates / tools / dockerfile / test / sanity / Dockerfile . template <nl> ppp b / templates / tools / dockerfile / test / sanity / Dockerfile . template <nl> <nl> automake $ { " \ \ " } <nl> libtool $ { " \ \ " } <nl> curl $ { " \ \ " } <nl> - python - virtualenv <nl> + python - virtualenv $ { " \ \ " } <nl> + python - lxml <nl> RUN pip install simplejson mako <nl> <nl> # = = = = = = = = = = = = = = = = = = = <nl> new file mode 100755 <nl> index 00000000000 . . 96dd2e4487d <nl> mmm / dev / null <nl> ppp b / tools / distrib / check_vsprojects . py <nl> <nl> + # ! / usr / bin / env python2 . 7 <nl> + <nl> + # Copyright 2016 , Google Inc . <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 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> + import os <nl> + import re <nl> + import sys <nl> + <nl> + from lxml import etree <nl> + <nl> + <nl> + def main ( ) : <nl> + root_dir = os . path . abspath ( <nl> + os . path . join ( os . path . dirname ( sys . argv [ 0 ] ) , ' . . / . . ' ) ) <nl> + os . chdir ( root_dir ) <nl> + <nl> + project_re = re . compile ( ' Project \ ( . * \ ) = " . + " , " ( . + ) " , " ( . + ) " ' ) <nl> + <nl> + known_projects = { } <nl> + with open ( os . path . join ( ' vsprojects ' , ' grpc . sln ' ) ) as f : <nl> + for line in f . readlines ( ) : <nl> + m = project_re . match ( line ) <nl> + if not m : <nl> + continue <nl> + <nl> + vcxproj_path , project_guid = m . groups ( ) <nl> + if os . name ! = ' nt ' : <nl> + vcxproj_path = vcxproj_path . replace ( ' \ \ ' , ' / ' ) <nl> + <nl> + known_projects [ project_guid ] = vcxproj_path <nl> + <nl> + ok = True <nl> + for vcxproj_path in known_projects . values ( ) : <nl> + with open ( os . path . join ( root_dir , ' vsprojects ' , vcxproj_path ) ) as f : <nl> + tree = etree . parse ( f ) <nl> + <nl> + namespaces = { ' ns ' : ' http : / / schemas . microsoft . com / developer / msbuild / 2003 ' } <nl> + referenced_projects = tree . getroot ( ) . xpath ( ' / ns : Project / ns : ItemGroup ' <nl> + ' / ns : ProjectReference ' <nl> + ' / ns : Project ' , <nl> + namespaces = namespaces ) <nl> + for referenced_project in referenced_projects : <nl> + # Project tag under ProjectReference is a GUID reference . <nl> + if referenced_project . text not in known_projects : <nl> + target_vcxproj = referenced_project . getparent ( ) . attrib [ ' Include ' ] <nl> + guid = referenced_project . text <nl> + print ( ' In project " % s " , dependency " % s " ( with GUID " % s " ) is not in ' <nl> + ' grpc . sln ' % ( vcxproj_path , target_vcxproj , guid ) ) <nl> + ok = False <nl> + <nl> + if not ok : <nl> + exit ( 1 ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + main ( ) <nl> + <nl> mmm a / tools / dockerfile / test / sanity / Dockerfile <nl> ppp b / tools / dockerfile / test / sanity / Dockerfile <nl> RUN apt - get update & & apt - get install - y \ <nl> automake \ <nl> libtool \ <nl> curl \ <nl> - python - virtualenv <nl> + python - virtualenv \ <nl> + python - lxml <nl> RUN pip install simplejson mako <nl> <nl> # = = = = = = = = = = = = = = = = = = = <nl> mmm a / tools / run_tests / sanity / sanity_tests . yaml <nl> ppp b / tools / run_tests / sanity / sanity_tests . yaml <nl> <nl> - script : tools / buildgen / generate_projects . sh - j 3 <nl> cpu_cost : 3 <nl> - script : tools / distrib / check_copyright . py <nl> + - script : tools / distrib / check_vsprojects . py <nl> - script : tools / distrib / clang_format_code . sh <nl> - script : tools / distrib / check_trailing_newlines . sh <nl> - script : tools / distrib / check_nanopb_output . sh <nl>
Add a sanity check to make sure vsprojects stays usable .
grpc/grpc
50df82ffe4c77985bfa9856575ee8a8ca453b0f3
2016-04-07T16:33:08Z
mmm a / tensorflow / python / keras / mixed_precision / experimental / policy . py <nl> ppp b / tensorflow / python / keras / mixed_precision / experimental / policy . py <nl> class Policy ( object ) : <nl> computation dtype to avoid type errors . <nl> <nl> Policies also have a ` tf . train . experimental . LossScale ` instance , which is used <nl> - by Models to performance loss scaling . Layers which are not Models ignore <nl> - the loss scale . <nl> + by ` tf . keras . Model ` s to performance loss scaling . Loss scaling is only done by <nl> + Models in ` Model . fit ` and ` Model . train_on_batch ` . Layers which are not Models <nl> + ignore the loss scale . <nl> <nl> Policies are constructed by passing a string to the constructor , e . g . <nl> ` tf . keras . mixed_precision . experimental . Policy ( ' float32 ' ) ` . The string <nl> - determines the compute and variable dtypes . Currently , it can be one of <nl> - in one of the following forms : <nl> + determines the compute and variable dtypes . It can be one of the following : <nl> <nl> * Any dtype name , such as ' float32 ' or ' float64 ' . Both the variable and <nl> - compute dtypes will be that dtype . <nl> - * ' < dtype > _with_float32_vars ' , where < dtype > is any dtype . The compute dtype <nl> - will be < dtype > , while the variable dtype is float32 . This can be used for <nl> - mixed precision , which uses float16 or bfloat16 for most computations , and <nl> - float32 for variables , but it is recommended to use the ' mixed_float16 ' or <nl> - ' mixed_bfloat16 ' policies instead . <nl> - * ' mixed_float16 ' or ' mixed_bfloat16 ' : Similar to <nl> - ' float16_with_float32_vars ' or ' bfloat16_with_float32_vars ' respectively . <nl> - ' mixed_float16 ' is identical to ' float16_with_float32_vars ' except the <nl> - loss_scale is dynamic by default . ' mixed_bfloat16 ' is currently identical <nl> - to ' bfloat16_with_float32_vars ' . More changes may be added to these mixed <nl> - policies in the future , to further differentiate them from <nl> - [ b ] float16_with_float32_vars . <nl> + compute dtypes will be that dtype . No loss scaling is done by default . <nl> + * ' mixed_float16 ' or ' mixed_bfloat16 ' : The compute dtype is float16 or <nl> + bfloat16 , while the variable dtype is float32 . These policies are used for <nl> + mixed precision training . With ' mixed_float16 ' , a dynamic loss scale is <nl> + used by default . ' mixed_bfloat16 ' does no loss scaling by default , as loss <nl> + scaling is unnecessary with bfloat16 . <nl> <nl> # # # How to use mixed precision in layers with Policies <nl> <nl> class Policy ( object ) : <nl> constructors in the ` dtype ` argument instead of policies , but only if the <nl> string is convertible to a dtype . <nl> <nl> + Note the ' mixed_float16 ' policy will apply loss scaling by default in <nl> + ` Model . fit ` and ` Model . train_on_batch ` . If neither method is used ( e . g . , a <nl> + custom training loop is used ) and ' mixed_float16 ' is used , the loss scale must <nl> + be manually applied . See <nl> + ` tf . keras . mixed_precision . experimental . LossScaleOptimizer ` for details . For <nl> + ' mixed_bfloat16 ' , no loss scaling is done and loss scaling never needs to be <nl> + manually applied . <nl> + <nl> # # # The deprecated " infer " policy <nl> <nl> In addition to a dtype or " < dtype > _with_float32_vars " , a policy can also be <nl> class Policy ( object ) : <nl> the dtype of the first input . <nl> <nl> Similarly to " infer " , there is a deprecated " infer_with_float32_vars " policy <nl> - that infers the compute dtype , but not the variable dtype . <nl> + that infers the compute dtype , but not the variable dtype . Once a layer with <nl> + an " infer_with_float32_vars " policy is called for the first time , the layer ' s <nl> + policy will change to " < dtype > _with_float32_vars " , where < dtype > is the dtype <nl> + of the first input . These policies force variables in float32 . <nl> + <nl> + Warning : Policies ending in " _with_float32_vars " will be removed in TensorFlow <nl> + 2 . 1 . Please use " mixed_float16 " or " mixed_bfloat16 " instead . <nl> <nl> In TensorFlow 1 , only the " infer " and " infer_with_float32_vars " policies are <nl> available . <nl> class Policy ( object ) : <nl> # TODO ( reedwm ) : Replace link in above docstring with a version that is more <nl> # TensorFlow - specific , and that also mentions bfloat16 . <nl> <nl> + # If True , warn when a policy is created whose name ends in <nl> + # " _with_float32_vars " . We always want to warn when a user creates such a <nl> + # policy , but when the TensorFlow creates a policy , it suppresses the warning <nl> + # by setting this to False when creating the policy . <nl> + _warn_about_float32_vars = True <nl> + <nl> def __init__ ( self , name , loss_scale = USE_DEFAULT ) : <nl> " " " Constructs the policy . <nl> <nl> def __init__ ( self , name , loss_scale = USE_DEFAULT ) : <nl> name : A string . Can be one of the following values : <nl> * Any dtype name , such as ' float32 ' or ' float64 ' . Both the variable and <nl> compute dtypes will be that dtype . <nl> - * ' < dtype > _with_float32_vars ' , where < dtype > is any dtype . The compute <nl> - dtype will be < dtype > , while the variable dtype is float32 . This can <nl> - be used for mixed precision , which uses float16 or bfloat16 for most <nl> - computations , and float32 for variables , but it is recommended to use <nl> - the ' mixed_float16 ' or ' mixed_bfloat16 ' policies instead . <nl> - * ' mixed_float16 ' or ' mixed_bfloat16 ' : Similar to <nl> - ' float16_with_float32_vars ' or ' bfloat16_with_float32_vars ' <nl> - respectively . ' mixed_float16 ' is identical to <nl> - ' float16_with_float32_vars ' except the loss_scale is dynamic by <nl> - default . ' mixed_bfloat16 ' is currently identical to <nl> - ' bfloat16_with_float32_vars ' . More changes may be added to these mixed <nl> - policies in the future , to further differentiate them from <nl> - [ b ] float16_with_float32_vars . <nl> - * ' infer ' or ' infer_with_float32_vars ' ( deprecated ) : Infer the <nl> - computation dtype from the input dtype . <nl> + * ' mixed_float16 ' or ' mixed_bfloat16 ' : The compute dtype is float16 or <nl> + bfloat16 , while the variable dtype is float32 . With ' mixed_float16 ' , <nl> + a dynamic loss scale is used . These policies are used for mixed <nl> + precision training . <nl> + * ' infer ' ( deprecated ) : Infer the compute and variable dtype from the <nl> + input dtype . <nl> loss_scale : A ` tf . train . experimental . LossScale ` , or a value convertible to <nl> one such as " dynamic " . Defaults to using no loss scaling unless ` name ` <nl> is " mixed_float16 " , in which case this defaults to " dynamic " . Only <nl> def __init__ ( self , name , loss_scale = USE_DEFAULT ) : <nl> self . _name = name <nl> self . _compute_dtype , self . _variable_dtype = self . _parse_name ( name ) <nl> <nl> + if name . endswith ( ' _with_float32_vars ' ) and self . _warn_about_float32_vars : <nl> + warning = ( " WARNING : The ' % s ' policy is deprecated and will be removed " <nl> + " in TensorFlow 2 . 1 . " % name ) <nl> + if name = = ' infer_with_float32_vars ' : <nl> + warning + = ( " Please use the ' mixed_float16 ' or ' mixed_bfloat16 ' " <nl> + " policy instead . " ) <nl> + elif name = = ' float16_with_float32_vars ' : <nl> + warning + = " Please use the ' mixed_float16 ' policy instead . " <nl> + elif name = = ' bfloat16_with_float32_vars ' : <nl> + warning + = " Please use the ' mixed_bfloat16 ' policy instead . " <nl> + tf_logging . warn ( warning ) <nl> + <nl> if loss_scale = = USE_DEFAULT : <nl> loss_scale = ' dynamic ' if name = = ' mixed_float16 ' else None <nl> if loss_scale and self . _compute_dtype not in ( None , ' float16 ' ) : <nl> def _parse_name ( self , name ) : <nl> try : <nl> base_dtype = dtypes . as_dtype ( base_name ) . name <nl> except TypeError : <nl> - error = ( ' Cannot convert value % s to a mixed precision Policy . ' <nl> - ' Valid policies include include those in the form " < dtype > " ' <nl> - ' and " < dtype > _with_float32_vars " , where < dtype > is the name ' <nl> - ' of a dtype . ' % ( name , ) ) <nl> + error = ( " Cannot convert value % s to a mixed precision Policy . " <nl> + " Valid policies include include ' mixed_float16 ' , " <nl> + " ' mixed_bfloat16 ' , and the name of any dtype such as " <nl> + " ' float32 ' . " % ( name , ) ) <nl> if float32_vars : <nl> error + = ( ' The value % s ends with _with_float32_vars , but % s cannot ' <nl> ' be converted to a DType ' % ( name , base_name ) ) <nl> def with_input_dtype ( policy , dtype ) : <nl> # Policies without a compute dtype are either " infer " or <nl> # " infer_with_float32_vars " , so the variable_dtype must be float32 here . <nl> assert policy . variable_dtype = = ' float32 ' <nl> - return Policy ( dtype + ' _with_float32_vars ' ) <nl> + try : <nl> + Policy . _warn_about_float32_vars = False # pylint : disable = protected - access <nl> + return Policy ( dtype + ' _with_float32_vars ' ) <nl> + finally : <nl> + Policy . _warn_about_float32_vars = True # pylint : disable = protected - access <nl> <nl> <nl> # The current global policy in effect . If None , it means the current value of <nl> mmm a / tensorflow / python / keras / mixed_precision / experimental / policy_test . py <nl> ppp b / tensorflow / python / keras / mixed_precision / experimental / policy_test . py <nl> def test_loss_scale_warning ( self ) : <nl> ' policies . You passed loss_scale = 2 . 0 for policy float32 . Consider ' <nl> ' not passing any loss_scale instead . ' ) <nl> <nl> - for policy_name in ' float16 ' , ' float16_with_float32_vars ' , ' mixed_float16 ' : <nl> + for policy_name in ' float16 ' , ' mixed_float16 ' : <nl> with test . mock . patch . object ( tf_logging , ' warn ' ) as mock_warn : <nl> mp_policy . Policy ( policy_name , loss_scale = 2 . ) <nl> mock_warn . assert_not_called ( ) <nl> <nl> + @ testing_utils . enable_v2_dtype_behavior <nl> + def test_float32_vars_warning ( self ) : <nl> + with test . mock . patch . object ( tf_logging , ' warn ' ) as mock_warn : <nl> + mp_policy . Policy ( ' infer_with_float32_vars ' ) <nl> + self . assertEqual ( <nl> + mock_warn . call_args [ 0 ] [ 0 ] , <nl> + " WARNING : The ' infer_with_float32_vars ' policy is deprecated and " <nl> + " will be removed in TensorFlow 2 . 1 . Please use the ' mixed_float16 ' " <nl> + " or ' mixed_bfloat16 ' policy instead . " ) <nl> + <nl> + with test . mock . patch . object ( tf_logging , ' warn ' ) as mock_warn : <nl> + mp_policy . Policy ( ' float16_with_float32_vars ' ) <nl> + self . assertEqual ( <nl> + mock_warn . call_args [ 0 ] [ 0 ] , <nl> + " WARNING : The ' float16_with_float32_vars ' policy is deprecated and " <nl> + " will be removed in TensorFlow 2 . 1 . Please use the ' mixed_float16 ' " <nl> + " policy instead . " ) <nl> + <nl> + with test . mock . patch . object ( tf_logging , ' warn ' ) as mock_warn : <nl> + mp_policy . Policy ( ' bfloat16_with_float32_vars ' ) <nl> + self . assertEqual ( <nl> + mock_warn . call_args [ 0 ] [ 0 ] , <nl> + " WARNING : The ' bfloat16_with_float32_vars ' policy is deprecated and " <nl> + " will be removed in TensorFlow 2 . 1 . Please use the ' mixed_bfloat16 ' " <nl> + " policy instead . " ) <nl> + <nl> + with test . mock . patch . object ( tf_logging , ' warn ' ) as mock_warn : <nl> + mp_policy . Policy ( ' float64_with_float32_vars ' ) <nl> + self . assertEqual ( <nl> + mock_warn . call_args [ 0 ] [ 0 ] , <nl> + " WARNING : The ' float64_with_float32_vars ' policy is deprecated and " <nl> + " will be removed in TensorFlow 2 . 1 . " ) <nl> + <nl> + for policy_name in ' float16 ' , ' float32 ' , ' mixed_float16 ' , ' mixed_bfloat16 ' : <nl> + with test . mock . patch . object ( tf_logging , ' warn ' ) as mock_warn : <nl> + mp_policy . Policy ( policy_name ) <nl> + mock_warn . assert_not_called ( ) <nl> + <nl> @ testing_utils . enable_v2_dtype_behavior <nl> def test_policy_scope ( self ) : <nl> if base_layer_utils . v2_dtype_behavior_enabled ( ) : <nl>
Deprecate " _with_float32_vars " policies .
tensorflow/tensorflow
03fc776b0431b19b7ee4b11a2b7806f4423ef3f6
2019-09-05T19:45:40Z
mmm a / editor / editor_node . cpp <nl> ppp b / editor / editor_node . cpp <nl> <nl> # include " plugins / curve_editor_plugin . h " <nl> # include " plugins / gi_probe_editor_plugin . h " <nl> # include " plugins / gradient_editor_plugin . h " <nl> - # include " plugins / gradient_texture_editor_plugin . h " <nl> # include " plugins / item_list_editor_plugin . h " <nl> # include " plugins / light_occluder_2d_editor_plugin . h " <nl> # include " plugins / line_2d_editor_plugin . h " <nl> EditorNode : : EditorNode ( ) { <nl> add_editor_plugin ( memnew ( LightOccluder2DEditorPlugin ( this ) ) ) ; <nl> add_editor_plugin ( memnew ( NavigationPolygonEditorPlugin ( this ) ) ) ; <nl> add_editor_plugin ( memnew ( GradientEditorPlugin ( this ) ) ) ; <nl> - add_editor_plugin ( memnew ( GradientTextureEditorPlugin ( this ) ) ) ; <nl> add_editor_plugin ( memnew ( CollisionShape2DEditorPlugin ( this ) ) ) ; <nl> add_editor_plugin ( memnew ( CurveEditorPlugin ( this ) ) ) ; <nl> add_editor_plugin ( memnew ( TextureEditorPlugin ( this ) ) ) ; <nl> mmm a / editor / plugins / gradient_editor_plugin . cpp <nl> ppp b / editor / plugins / gradient_editor_plugin . cpp <nl> void GradientEditorPlugin : : _ramp_changed ( ) { <nl> } <nl> } <nl> <nl> - void GradientEditorPlugin : : _undo_redo_gradient ( const Vector < float > & offsets , <nl> - const Vector < Color > & colors ) { <nl> + void GradientEditorPlugin : : _undo_redo_gradient ( const Vector < float > & offsets , const Vector < Color > & colors ) { <nl> <nl> gradient_ref - > set_offsets ( offsets ) ; <nl> gradient_ref - > set_colors ( colors ) ; <nl> mmm a / editor / plugins / gradient_editor_plugin . h <nl> ppp b / editor / plugins / gradient_editor_plugin . h <nl> class GradientEditorPlugin : public EditorPlugin { <nl> <nl> GDCLASS ( GradientEditorPlugin , EditorPlugin ) ; <nl> <nl> - bool _2d ; <nl> Ref < Gradient > gradient_ref ; <nl> GradientEdit * ramp_editor ; <nl> EditorNode * editor ; <nl> deleted file mode 100644 <nl> index bc985dcdf71 . . 00000000000 <nl> mmm a / editor / plugins / gradient_texture_editor_plugin . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * gradient_texture_editor_plugin . cpp * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * http : / / www . godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2017 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2017 Godot Engine contributors ( cf . AUTHORS . md ) * / <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 NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # include " gradient_texture_editor_plugin . h " <nl> - <nl> - # include " canvas_item_editor_plugin . h " <nl> - # include " os / keyboard . h " <nl> - # include " scene / resources / default_theme / theme_data . h " <nl> - # include " spatial_editor_plugin . h " <nl> - <nl> - # define POINT_WIDTH 8 <nl> - <nl> - GradientTextureEdit : : GradientTextureEdit ( ) { <nl> - grabbed = - 1 ; <nl> - grabbing = false ; <nl> - set_focus_mode ( FOCUS_ALL ) ; <nl> - <nl> - popup = memnew ( PopupPanel ) ; <nl> - picker = memnew ( ColorPicker ) ; <nl> - popup - > add_child ( picker ) ; <nl> - <nl> - add_child ( popup ) ; <nl> - <nl> - checker = Ref < ImageTexture > ( memnew ( ImageTexture ) ) ; <nl> - Ref < Image > checker_bg = memnew ( Image ( checker_bg_png ) ) ; <nl> - checker - > create_from_image ( checker_bg , ImageTexture : : FLAG_REPEAT ) ; <nl> - } <nl> - <nl> - int GradientTextureEdit : : _get_point_from_pos ( int x ) { <nl> - int result = - 1 ; <nl> - int total_w = get_size ( ) . width - get_size ( ) . height - 3 ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - / / Check if we clicked at point <nl> - if ( ABS ( x - points [ i ] . offset * total_w + 1 ) < ( POINT_WIDTH / 2 + 1 ) ) { <nl> - result = i ; <nl> - } <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - void GradientTextureEdit : : _show_color_picker ( ) { <nl> - if ( grabbed = = - 1 ) <nl> - return ; <nl> - Size2 ms = Size2 ( 350 , picker - > get_combined_minimum_size ( ) . height + 10 ) ; <nl> - picker - > set_pick_color ( points [ grabbed ] . color ) ; <nl> - popup - > set_position ( get_global_position ( ) - Vector2 ( ms . width - get_size ( ) . width , ms . height ) ) ; <nl> - popup - > set_size ( ms ) ; <nl> - popup - > popup ( ) ; <nl> - } <nl> - <nl> - GradientTextureEdit : : ~ GradientTextureEdit ( ) { <nl> - } <nl> - <nl> - void GradientTextureEdit : : _gui_input ( const Ref < InputEvent > & p_event ) { <nl> - <nl> - Ref < InputEventKey > k = p_event ; <nl> - <nl> - if ( k . is_valid ( ) & & k - > is_pressed ( ) & & k - > get_scancode ( ) = = KEY_DELETE & & grabbed ! = - 1 ) { <nl> - <nl> - points . remove ( grabbed ) ; <nl> - grabbed = - 1 ; <nl> - grabbing = false ; <nl> - update ( ) ; <nl> - emit_signal ( " ramp_changed " ) ; <nl> - accept_event ( ) ; <nl> - } <nl> - <nl> - Ref < InputEventMouseButton > mb = p_event ; <nl> - / / Show color picker on double click . <nl> - if ( mb . is_valid ( ) & & mb - > get_button_index ( ) = = 1 & & mb - > is_doubleclick ( ) & & mb - > is_pressed ( ) ) { <nl> - grabbed = _get_point_from_pos ( mb - > get_position ( ) . x ) ; <nl> - _show_color_picker ( ) ; <nl> - accept_event ( ) ; <nl> - } <nl> - <nl> - / / Delete point on right click <nl> - if ( mb . is_valid ( ) & & mb - > get_button_index ( ) = = 2 & & mb - > is_pressed ( ) ) { <nl> - grabbed = _get_point_from_pos ( mb - > get_position ( ) . x ) ; <nl> - if ( grabbed ! = - 1 ) { <nl> - points . remove ( grabbed ) ; <nl> - grabbed = - 1 ; <nl> - grabbing = false ; <nl> - update ( ) ; <nl> - emit_signal ( " ramp_changed " ) ; <nl> - accept_event ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / Hold alt key to duplicate selected color <nl> - if ( mb . is_valid ( ) & & mb - > get_button_index ( ) = = 1 & & mb - > is_pressed ( ) & & mb - > get_alt ( ) ) { <nl> - <nl> - int x = mb - > get_position ( ) . x ; <nl> - grabbed = _get_point_from_pos ( x ) ; <nl> - <nl> - if ( grabbed ! = - 1 ) { <nl> - int total_w = get_size ( ) . width - get_size ( ) . height - 3 ; <nl> - GradientTexture : : Point newPoint = points [ grabbed ] ; <nl> - newPoint . offset = CLAMP ( x / float ( total_w ) , 0 , 1 ) ; <nl> - <nl> - points . push_back ( newPoint ) ; <nl> - points . sort ( ) ; <nl> - for ( int i = 0 ; i < points . size ( ) ; + + i ) { <nl> - if ( points [ i ] . offset = = newPoint . offset ) { <nl> - grabbed = i ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - emit_signal ( " ramp_changed " ) ; <nl> - update ( ) ; <nl> - } <nl> - } <nl> - <nl> - if ( mb . is_valid ( ) & & mb - > get_button_index ( ) = = 1 & & mb - > is_pressed ( ) ) { <nl> - <nl> - update ( ) ; <nl> - int x = mb - > get_position ( ) . x ; <nl> - int total_w = get_size ( ) . width - get_size ( ) . height - 3 ; <nl> - <nl> - / / Check if color selector was clicked . <nl> - if ( x > total_w + 3 ) { <nl> - _show_color_picker ( ) ; <nl> - return ; <nl> - } <nl> - <nl> - grabbing = true ; <nl> - <nl> - grabbed = _get_point_from_pos ( x ) ; <nl> - / / grab or select <nl> - if ( grabbed ! = - 1 ) { <nl> - return ; <nl> - } <nl> - <nl> - / / insert <nl> - GradientTexture : : Point newPoint ; <nl> - newPoint . offset = CLAMP ( x / float ( total_w ) , 0 , 1 ) ; <nl> - <nl> - GradientTexture : : Point prev ; <nl> - GradientTexture : : Point next ; <nl> - <nl> - int pos = - 1 ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - if ( points [ i ] . offset < newPoint . offset ) <nl> - pos = i ; <nl> - } <nl> - <nl> - if ( pos = = - 1 ) { <nl> - <nl> - prev . color = Color ( 0 , 0 , 0 ) ; <nl> - prev . offset = 0 ; <nl> - if ( points . size ( ) ) { <nl> - next = points [ 0 ] ; <nl> - } else { <nl> - next . color = Color ( 1 , 1 , 1 ) ; <nl> - next . offset = 1 . 0 ; <nl> - } <nl> - } else { <nl> - <nl> - if ( pos = = points . size ( ) - 1 ) { <nl> - next . color = Color ( 1 , 1 , 1 ) ; <nl> - next . offset = 1 . 0 ; <nl> - } else { <nl> - next = points [ pos + 1 ] ; <nl> - } <nl> - prev = points [ pos ] ; <nl> - } <nl> - <nl> - newPoint . color = prev . color . linear_interpolate ( next . color , ( newPoint . offset - prev . offset ) / ( next . offset - prev . offset ) ) ; <nl> - <nl> - points . push_back ( newPoint ) ; <nl> - points . sort ( ) ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - if ( points [ i ] . offset = = newPoint . offset ) { <nl> - grabbed = i ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - emit_signal ( " ramp_changed " ) ; <nl> - } <nl> - <nl> - if ( mb . is_valid ( ) & & mb - > get_button_index ( ) = = 1 & & ! mb - > is_pressed ( ) ) { <nl> - <nl> - if ( grabbing ) { <nl> - grabbing = false ; <nl> - emit_signal ( " ramp_changed " ) ; <nl> - } <nl> - update ( ) ; <nl> - } <nl> - <nl> - Ref < InputEventMouseMotion > mm = p_event ; <nl> - <nl> - if ( mm . is_valid ( ) & & grabbing ) { <nl> - <nl> - int total_w = get_size ( ) . width - get_size ( ) . height - 3 ; <nl> - <nl> - int x = mm - > get_position ( ) . x ; <nl> - float newofs = CLAMP ( x / float ( total_w ) , 0 , 1 ) ; <nl> - <nl> - / / Snap to nearest point if holding shift <nl> - if ( mm - > get_shift ( ) ) { <nl> - float snap_treshhold = 0 . 03 ; <nl> - float smallest_ofs = snap_treshhold ; <nl> - bool founded = false ; <nl> - int nearest_point ; <nl> - for ( int i = 0 ; i < points . size ( ) ; + + i ) { <nl> - if ( i ! = grabbed ) { <nl> - float temp_ofs = ABS ( points [ i ] . offset - newofs ) ; <nl> - if ( temp_ofs < smallest_ofs ) { <nl> - smallest_ofs = temp_ofs ; <nl> - nearest_point = i ; <nl> - if ( founded ) <nl> - break ; <nl> - founded = true ; <nl> - } <nl> - } <nl> - } <nl> - if ( founded ) { <nl> - if ( points [ nearest_point ] . offset < newofs ) <nl> - newofs = points [ nearest_point ] . offset + 0 . 00001 ; <nl> - else <nl> - newofs = points [ nearest_point ] . offset - 0 . 00001 ; <nl> - newofs = CLAMP ( newofs , 0 , 1 ) ; <nl> - } <nl> - } <nl> - <nl> - bool valid = true ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - <nl> - if ( points [ i ] . offset = = newofs & & i ! = grabbed ) { <nl> - valid = false ; <nl> - } <nl> - } <nl> - <nl> - if ( ! valid ) <nl> - return ; <nl> - <nl> - points [ grabbed ] . offset = newofs ; <nl> - <nl> - points . sort ( ) ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - if ( points [ i ] . offset = = newofs ) { <nl> - grabbed = i ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - emit_signal ( " ramp_changed " ) ; <nl> - <nl> - update ( ) ; <nl> - } <nl> - } <nl> - <nl> - void GradientTextureEdit : : _notification ( int p_what ) { <nl> - <nl> - if ( p_what = = NOTIFICATION_ENTER_TREE ) { <nl> - if ( ! picker - > is_connected ( " color_changed " , this , " _color_changed " ) ) { <nl> - picker - > connect ( " color_changed " , this , " _color_changed " ) ; <nl> - } <nl> - } <nl> - if ( p_what = = NOTIFICATION_DRAW ) { <nl> - <nl> - int w = get_size ( ) . x ; <nl> - int h = get_size ( ) . y ; <nl> - <nl> - if ( w = = 0 | | h = = 0 ) <nl> - return ; / / Safety check . We have division by ' h ' . And in any case there is nothing to draw with such size <nl> - <nl> - int total_w = get_size ( ) . width - get_size ( ) . height - 3 ; <nl> - <nl> - / / Draw checker pattern for ramp <nl> - _draw_checker ( 0 , 0 , total_w , h ) ; <nl> - <nl> - / / Draw color ramp <nl> - GradientTexture : : Point prev ; <nl> - prev . offset = 0 ; <nl> - if ( points . size ( ) = = 0 ) <nl> - prev . color = Color ( 0 , 0 , 0 ) ; / / Draw black rectangle if we have no points <nl> - else <nl> - prev . color = points [ 0 ] . color ; / / Extend color of first point to the beginning . <nl> - <nl> - for ( int i = - 1 ; i < points . size ( ) ; i + + ) { <nl> - <nl> - GradientTexture : : Point next ; <nl> - / / If there is no next point <nl> - if ( i + 1 = = points . size ( ) ) { <nl> - if ( points . size ( ) = = 0 ) <nl> - next . color = Color ( 0 , 0 , 0 ) ; / / Draw black rectangle if we have no points <nl> - else <nl> - next . color = points [ i ] . color ; / / Extend color of last point to the end . <nl> - next . offset = 1 ; <nl> - } else { <nl> - next = points [ i + 1 ] ; <nl> - } <nl> - <nl> - if ( prev . offset = = next . offset ) { <nl> - prev = next ; <nl> - continue ; <nl> - } <nl> - <nl> - Vector < Vector2 > points ; <nl> - Vector < Color > colors ; <nl> - points . push_back ( Vector2 ( prev . offset * total_w , h ) ) ; <nl> - points . push_back ( Vector2 ( prev . offset * total_w , 0 ) ) ; <nl> - points . push_back ( Vector2 ( next . offset * total_w , 0 ) ) ; <nl> - points . push_back ( Vector2 ( next . offset * total_w , h ) ) ; <nl> - colors . push_back ( prev . color ) ; <nl> - colors . push_back ( prev . color ) ; <nl> - colors . push_back ( next . color ) ; <nl> - colors . push_back ( next . color ) ; <nl> - draw_primitive ( points , colors , Vector < Point2 > ( ) ) ; <nl> - prev = next ; <nl> - } <nl> - <nl> - / / Draw point markers <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - <nl> - Color col = i = = grabbed ? Color ( 1 , 0 . 0 , 0 . 0 , 0 . 9 ) : points [ i ] . color . contrasted ( ) ; <nl> - col . a = 0 . 9 ; <nl> - <nl> - draw_line ( Vector2 ( points [ i ] . offset * total_w , 0 ) , Vector2 ( points [ i ] . offset * total_w , h / 2 ) , col ) ; <nl> - draw_rect ( Rect2 ( points [ i ] . offset * total_w - POINT_WIDTH / 2 , h / 2 , POINT_WIDTH , h / 2 ) , Color ( 0 . 6 , 0 . 6 , 0 . 6 , i = = grabbed ? 0 . 9 : 0 . 4 ) ) ; <nl> - draw_line ( Vector2 ( points [ i ] . offset * total_w - POINT_WIDTH / 2 , h / 2 ) , Vector2 ( points [ i ] . offset * total_w - POINT_WIDTH / 2 , h - 1 ) , col ) ; <nl> - draw_line ( Vector2 ( points [ i ] . offset * total_w + POINT_WIDTH / 2 , h / 2 ) , Vector2 ( points [ i ] . offset * total_w + POINT_WIDTH / 2 , h - 1 ) , col ) ; <nl> - draw_line ( Vector2 ( points [ i ] . offset * total_w - POINT_WIDTH / 2 , h / 2 ) , Vector2 ( points [ i ] . offset * total_w + POINT_WIDTH / 2 , h / 2 ) , col ) ; <nl> - draw_line ( Vector2 ( points [ i ] . offset * total_w - POINT_WIDTH / 2 , h - 1 ) , Vector2 ( points [ i ] . offset * total_w + POINT_WIDTH / 2 , h - 1 ) , col ) ; <nl> - } <nl> - <nl> - / / Draw " button " for color selector <nl> - _draw_checker ( total_w + 3 , 0 , h , h ) ; <nl> - if ( grabbed ! = - 1 ) { <nl> - / / Draw with selection color <nl> - draw_rect ( Rect2 ( total_w + 3 , 0 , h , h ) , points [ grabbed ] . color ) ; <nl> - } else { <nl> - / / if no color selected draw grey color with ' X ' on top . <nl> - draw_rect ( Rect2 ( total_w + 3 , 0 , h , h ) , Color ( 0 . 5 , 0 . 5 , 0 . 5 , 1 ) ) ; <nl> - draw_line ( Vector2 ( total_w + 3 , 0 ) , Vector2 ( total_w + 3 + h , h ) , Color ( 1 , 1 , 1 , 0 . 6 ) ) ; <nl> - draw_line ( Vector2 ( total_w + 3 , h ) , Vector2 ( total_w + 3 + h , 0 ) , Color ( 1 , 1 , 1 , 0 . 6 ) ) ; <nl> - } <nl> - <nl> - / / Draw borders around color ramp if in focus <nl> - if ( has_focus ( ) ) { <nl> - <nl> - draw_line ( Vector2 ( - 1 , - 1 ) , Vector2 ( total_w + 1 , - 1 ) , Color ( 1 , 1 , 1 , 0 . 6 ) ) ; <nl> - draw_line ( Vector2 ( total_w + 1 , - 1 ) , Vector2 ( total_w + 1 , h + 1 ) , Color ( 1 , 1 , 1 , 0 . 6 ) ) ; <nl> - draw_line ( Vector2 ( total_w + 1 , h + 1 ) , Vector2 ( - 1 , h + 1 ) , Color ( 1 , 1 , 1 , 0 . 6 ) ) ; <nl> - draw_line ( Vector2 ( - 1 , - 1 ) , Vector2 ( - 1 , h + 1 ) , Color ( 1 , 1 , 1 , 0 . 6 ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void GradientTextureEdit : : _draw_checker ( int x , int y , int w , int h ) { <nl> - / / Draw it with polygon to insert UVs for scale <nl> - Vector < Vector2 > backPoints ; <nl> - backPoints . push_back ( Vector2 ( x , y ) ) ; <nl> - backPoints . push_back ( Vector2 ( x , y + h ) ) ; <nl> - backPoints . push_back ( Vector2 ( x + w , y + h ) ) ; <nl> - backPoints . push_back ( Vector2 ( x + w , y ) ) ; <nl> - Vector < Color > colorPoints ; <nl> - colorPoints . push_back ( Color ( 1 , 1 , 1 , 1 ) ) ; <nl> - colorPoints . push_back ( Color ( 1 , 1 , 1 , 1 ) ) ; <nl> - colorPoints . push_back ( Color ( 1 , 1 , 1 , 1 ) ) ; <nl> - colorPoints . push_back ( Color ( 1 , 1 , 1 , 1 ) ) ; <nl> - Vector < Vector2 > uvPoints ; <nl> - / / Draw checker pattern pixel - perfect and scale it by 2 . <nl> - uvPoints . push_back ( Vector2 ( x , y ) ) ; <nl> - uvPoints . push_back ( Vector2 ( x , y + h * . 5f / checker - > get_height ( ) ) ) ; <nl> - uvPoints . push_back ( Vector2 ( x + w * . 5f / checker - > get_width ( ) , y + h * . 5f / checker - > get_height ( ) ) ) ; <nl> - uvPoints . push_back ( Vector2 ( x + w * . 5f / checker - > get_width ( ) , y ) ) ; <nl> - draw_polygon ( backPoints , colorPoints , uvPoints , checker ) ; <nl> - } <nl> - <nl> - Size2 GradientTextureEdit : : get_minimum_size ( ) const { <nl> - <nl> - return Vector2 ( 0 , 16 ) ; <nl> - } <nl> - <nl> - void GradientTextureEdit : : _color_changed ( const Color & p_color ) { <nl> - <nl> - if ( grabbed = = - 1 ) <nl> - return ; <nl> - points [ grabbed ] . color = p_color ; <nl> - update ( ) ; <nl> - emit_signal ( " ramp_changed " ) ; <nl> - } <nl> - <nl> - void GradientTextureEdit : : set_ramp ( const Vector < float > & p_offsets , const Vector < Color > & p_colors ) { <nl> - <nl> - ERR_FAIL_COND ( p_offsets . size ( ) ! = p_colors . size ( ) ) ; <nl> - points . clear ( ) ; <nl> - for ( int i = 0 ; i < p_offsets . size ( ) ; i + + ) { <nl> - GradientTexture : : Point p ; <nl> - p . offset = p_offsets [ i ] ; <nl> - p . color = p_colors [ i ] ; <nl> - points . push_back ( p ) ; <nl> - } <nl> - <nl> - points . sort ( ) ; <nl> - update ( ) ; <nl> - } <nl> - <nl> - Vector < float > GradientTextureEdit : : get_offsets ( ) const { <nl> - Vector < float > ret ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) <nl> - ret . push_back ( points [ i ] . offset ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - Vector < Color > GradientTextureEdit : : get_colors ( ) const { <nl> - Vector < Color > ret ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) <nl> - ret . push_back ( points [ i ] . color ) ; <nl> - return ret ; <nl> - } <nl> - <nl> - void GradientTextureEdit : : set_points ( Vector < GradientTexture : : Point > & p_points ) { <nl> - if ( points . size ( ) ! = p_points . size ( ) ) <nl> - grabbed = - 1 ; <nl> - points . clear ( ) ; <nl> - points = p_points ; <nl> - } <nl> - <nl> - Vector < GradientTexture : : Point > & GradientTextureEdit : : get_points ( ) { <nl> - return points ; <nl> - } <nl> - <nl> - void GradientTextureEdit : : _bind_methods ( ) { <nl> - ClassDB : : bind_method ( D_METHOD ( " _gui_input " ) , & GradientTextureEdit : : _gui_input ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " _color_changed " ) , & GradientTextureEdit : : _color_changed ) ; <nl> - ADD_SIGNAL ( MethodInfo ( " ramp_changed " ) ) ; <nl> - } <nl> - <nl> - GradientTextureEditorPlugin : : GradientTextureEditorPlugin ( EditorNode * p_node ) { <nl> - <nl> - editor = p_node ; <nl> - ramp_editor = memnew ( GradientTextureEdit ) ; <nl> - <nl> - gradient_button = editor - > add_bottom_panel_item ( " GradientTexture " , ramp_editor ) ; <nl> - <nl> - gradient_button - > hide ( ) ; <nl> - ramp_editor - > set_custom_minimum_size ( Size2 ( 100 , 100 * EDSCALE ) ) ; <nl> - ramp_editor - > hide ( ) ; <nl> - ramp_editor - > connect ( " ramp_changed " , this , " ramp_changed " ) ; <nl> - } <nl> - <nl> - void GradientTextureEditorPlugin : : edit ( Object * p_object ) { <nl> - <nl> - GradientTexture * gradient_texture = p_object - > cast_to < GradientTexture > ( ) ; <nl> - if ( ! gradient_texture ) <nl> - return ; <nl> - gradient_texture_ref = Ref < GradientTexture > ( gradient_texture ) ; <nl> - ramp_editor - > set_points ( gradient_texture_ref - > get_points ( ) ) ; <nl> - } <nl> - <nl> - bool GradientTextureEditorPlugin : : handles ( Object * p_object ) const { <nl> - <nl> - return p_object - > is_class ( " GradientTexture " ) ; <nl> - } <nl> - <nl> - void GradientTextureEditorPlugin : : make_visible ( bool p_visible ) { <nl> - <nl> - if ( p_visible ) { <nl> - gradient_button - > show ( ) ; <nl> - editor - > make_bottom_panel_item_visible ( ramp_editor ) ; <nl> - <nl> - } else { <nl> - <nl> - gradient_button - > hide ( ) ; <nl> - if ( ramp_editor - > is_visible_in_tree ( ) ) <nl> - editor - > hide_bottom_panel ( ) ; <nl> - } <nl> - } <nl> - <nl> - void GradientTextureEditorPlugin : : _ramp_changed ( ) { <nl> - <nl> - if ( gradient_texture_ref . is_valid ( ) ) { <nl> - <nl> - UndoRedo * ur = EditorNode : : get_singleton ( ) - > get_undo_redo ( ) ; <nl> - <nl> - / / Not sure if I should convert this data to PoolVector <nl> - Vector < float > new_offsets = ramp_editor - > get_offsets ( ) ; <nl> - Vector < Color > new_colors = ramp_editor - > get_colors ( ) ; <nl> - Vector < float > old_offsets = gradient_texture_ref - > get_offsets ( ) ; <nl> - Vector < Color > old_colors = gradient_texture_ref - > get_colors ( ) ; <nl> - <nl> - if ( old_offsets . size ( ) ! = new_offsets . size ( ) ) <nl> - ur - > create_action ( TTR ( " Add / Remove Color Ramp Point " ) ) ; <nl> - else <nl> - ur - > create_action ( TTR ( " Modify Color Ramp " ) , UndoRedo : : MERGE_ENDS ) ; <nl> - ur - > add_do_method ( this , " undo_redo_gradient_texture " , new_offsets , new_colors ) ; <nl> - ur - > add_undo_method ( this , " undo_redo_gradient_texture " , old_offsets , old_colors ) ; <nl> - ur - > commit_action ( ) ; <nl> - <nl> - / / gradient_texture_ref - > set_points ( ramp_editor - > get_points ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - void GradientTextureEditorPlugin : : _undo_redo_gradient_texture ( const Vector < float > & offsets , <nl> - const Vector < Color > & colors ) { <nl> - <nl> - gradient_texture_ref - > set_offsets ( offsets ) ; <nl> - gradient_texture_ref - > set_colors ( colors ) ; <nl> - ramp_editor - > set_points ( gradient_texture_ref - > get_points ( ) ) ; <nl> - ramp_editor - > update ( ) ; <nl> - } <nl> - <nl> - GradientTextureEditorPlugin : : ~ GradientTextureEditorPlugin ( ) { <nl> - } <nl> - <nl> - void GradientTextureEditorPlugin : : _bind_methods ( ) { <nl> - ClassDB : : bind_method ( D_METHOD ( " ramp_changed " ) , & GradientTextureEditorPlugin : : _ramp_changed ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " undo_redo_gradient_texture " , " offsets " , " colors " ) , & GradientTextureEditorPlugin : : _undo_redo_gradient_texture ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 842d586541b . . 00000000000 <nl> mmm a / editor / plugins / gradient_texture_editor_plugin . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * gradient_texture_editor_plugin . h * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * This file is part of : * / <nl> - / * GODOT ENGINE * / <nl> - / * http : / / www . godotengine . org * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - / * Copyright ( c ) 2007 - 2017 Juan Linietsky , Ariel Manzur . * / <nl> - / * Copyright ( c ) 2014 - 2017 Godot Engine contributors ( cf . AUTHORS . md ) * / <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 NONINFRINGEMENT . * / <nl> - / * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * / <nl> - / * CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , * / <nl> - / * TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE * / <nl> - / * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * / <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - # ifndef GRADIENT_TEXTURE_EDITOR_PLUGIN_H <nl> - # define GRADIENT_TEXTURE_EDITOR_PLUGIN_H <nl> - <nl> - # include " editor / editor_node . h " <nl> - # include " editor / editor_plugin . h " <nl> - # include " scene / resources / texture . h " <nl> - <nl> - class GradientTextureEdit : public Control { <nl> - <nl> - GDCLASS ( GradientTextureEdit , Control ) ; <nl> - <nl> - PopupPanel * popup ; <nl> - ColorPicker * picker ; <nl> - <nl> - Ref < ImageTexture > checker ; <nl> - <nl> - bool grabbing ; <nl> - int grabbed ; <nl> - Vector < GradientTexture : : Point > points ; <nl> - <nl> - void _draw_checker ( int x , int y , int w , int h ) ; <nl> - void _color_changed ( const Color & p_color ) ; <nl> - int _get_point_from_pos ( int x ) ; <nl> - void _show_color_picker ( ) ; <nl> - <nl> - protected : <nl> - void _gui_input ( const Ref < InputEvent > & p_event ) ; <nl> - void _notification ( int p_what ) ; <nl> - static void _bind_methods ( ) ; <nl> - <nl> - public : <nl> - void set_ramp ( const Vector < float > & p_offsets , const Vector < Color > & p_colors ) ; <nl> - Vector < float > get_offsets ( ) const ; <nl> - Vector < Color > get_colors ( ) const ; <nl> - void set_points ( Vector < GradientTexture : : Point > & p_points ) ; <nl> - Vector < GradientTexture : : Point > & get_points ( ) ; <nl> - virtual Size2 get_minimum_size ( ) const ; <nl> - <nl> - GradientTextureEdit ( ) ; <nl> - virtual ~ GradientTextureEdit ( ) ; <nl> - } ; <nl> - <nl> - class GradientTextureEditorPlugin : public EditorPlugin { <nl> - <nl> - GDCLASS ( GradientTextureEditorPlugin , EditorPlugin ) ; <nl> - <nl> - bool _2d ; <nl> - Ref < GradientTexture > gradient_texture_ref ; <nl> - GradientTextureEdit * ramp_editor ; <nl> - EditorNode * editor ; <nl> - ToolButton * gradient_button ; <nl> - <nl> - protected : <nl> - static void _bind_methods ( ) ; <nl> - void _ramp_changed ( ) ; <nl> - void _undo_redo_gradient_texture ( const Vector < float > & offsets , const Vector < Color > & colors ) ; <nl> - <nl> - public : <nl> - virtual String get_name ( ) const { return " GradientTexture " ; } <nl> - bool has_main_screen ( ) const { return false ; } <nl> - virtual void edit ( Object * p_node ) ; <nl> - virtual bool handles ( Object * p_node ) const ; <nl> - virtual void make_visible ( bool p_visible ) ; <nl> - <nl> - GradientTextureEditorPlugin ( EditorNode * p_node ) ; <nl> - ~ GradientTextureEditorPlugin ( ) ; <nl> - } ; <nl> - <nl> - # endif / / GRADIENT_TEXTURE_EDITOR_PLUGIN_H <nl> mmm a / scene / resources / texture . cpp <nl> ppp b / scene / resources / texture . cpp <nl> CurveTexture : : ~ CurveTexture ( ) { <nl> # define COLOR_RAMP_SET_COLORS " set_colors " <nl> <nl> GradientTexture : : GradientTexture ( ) { <nl> - / / Set initial color ramp transition from black to white <nl> - points . resize ( 2 ) ; <nl> - points [ 0 ] . color = Color ( 0 , 0 , 0 , 1 ) ; <nl> - points [ 0 ] . offset = 0 ; <nl> - points [ 1 ] . color = Color ( 1 , 1 , 1 , 1 ) ; <nl> - points [ 1 ] . offset = 1 ; <nl> - is_sorted = true ; <nl> update_pending = false ; <nl> width = 2048 ; <nl> <nl> GradientTexture : : ~ GradientTexture ( ) { <nl> <nl> void GradientTexture : : _bind_methods ( ) { <nl> <nl> - ClassDB : : bind_method ( D_METHOD ( " add_point " , " offset " , " color " ) , & GradientTexture : : add_point ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " remove_point " , " offset " , " color " ) , & GradientTexture : : remove_point ) ; <nl> - <nl> - ClassDB : : bind_method ( D_METHOD ( " set_offset " , " point " , " offset " ) , & GradientTexture : : set_offset ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_offset " , " point " ) , & GradientTexture : : get_offset ) ; <nl> - <nl> - ClassDB : : bind_method ( D_METHOD ( " set_color " , " point " , " color " ) , & GradientTexture : : set_color ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_color " , " point " ) , & GradientTexture : : get_color ) ; <nl> + ClassDB : : bind_method ( D_METHOD ( " set_gradient " , " gradient : Gradient " ) , & GradientTexture : : set_gradient ) ; <nl> + ClassDB : : bind_method ( D_METHOD ( " get_gradient : Gradient " ) , & GradientTexture : : get_gradient ) ; <nl> <nl> ClassDB : : bind_method ( D_METHOD ( " set_width " , " width " ) , & GradientTexture : : set_width ) ; <nl> <nl> - ClassDB : : bind_method ( D_METHOD ( " interpolate " , " offset " ) , & GradientTexture : : get_color_at_offset ) ; <nl> - <nl> - ClassDB : : bind_method ( D_METHOD ( " get_point_count " ) , & GradientTexture : : get_points_count ) ; <nl> - <nl> ClassDB : : bind_method ( D_METHOD ( " _update " ) , & GradientTexture : : _update ) ; <nl> <nl> - ClassDB : : bind_method ( D_METHOD ( COLOR_RAMP_SET_OFFSETS , " offsets " ) , & GradientTexture : : set_offsets ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( COLOR_RAMP_GET_OFFSETS ) , & GradientTexture : : get_offsets ) ; <nl> + ADD_PROPERTY ( PropertyInfo ( Variant : : OBJECT , " gradient " , PROPERTY_HINT_RESOURCE_TYPE , " Gradient " ) , " set_gradient " , " get_gradient " ) ; <nl> + ADD_PROPERTY ( PropertyInfo ( Variant : : INT , " width " ) , " set_width " , " get_width " ) ; <nl> + } <nl> <nl> - ClassDB : : bind_method ( D_METHOD ( COLOR_RAMP_SET_COLORS , " colors " ) , & GradientTexture : : set_colors ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( COLOR_RAMP_GET_COLORS ) , & GradientTexture : : get_colors ) ; <nl> + void GradientTexture : : set_gradient ( Ref < Gradient > p_gradient ) { <nl> + if ( p_gradient = = gradient ) <nl> + return ; <nl> + if ( gradient . is_valid ( ) ) { <nl> + gradient - > disconnect ( CoreStringNames : : get_singleton ( ) - > changed , this , " _update " ) ; <nl> + } <nl> + gradient = p_gradient ; <nl> + if ( gradient . is_valid ( ) ) { <nl> + gradient - > connect ( CoreStringNames : : get_singleton ( ) - > changed , this , " _update " ) ; <nl> + } <nl> + _update ( ) ; <nl> + emit_changed ( ) ; <nl> + } <nl> <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : INT , " width " ) , " set_width " , " get_width " ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " offsets " ) , COLOR_RAMP_SET_OFFSETS , COLOR_RAMP_GET_OFFSETS ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " colors " ) , COLOR_RAMP_SET_COLORS , COLOR_RAMP_GET_COLORS ) ; <nl> + Ref < Gradient > GradientTexture : : get_gradient ( ) const { <nl> + return gradient ; <nl> } <nl> <nl> void GradientTexture : : _queue_update ( ) { <nl> void GradientTexture : : _queue_update ( ) { <nl> <nl> void GradientTexture : : _update ( ) { <nl> <nl> + if ( gradient . is_null ( ) ) <nl> + return ; <nl> + <nl> update_pending = false ; <nl> <nl> PoolVector < uint8_t > data ; <nl> data . resize ( width * 4 ) ; <nl> { <nl> PoolVector < uint8_t > : : Write wd8 = data . write ( ) ; <nl> + Gradient & g = * * gradient ; <nl> + <nl> for ( int i = 0 ; i < width ; i + + ) { <nl> + <nl> float ofs = float ( i ) / ( width - 1 ) ; <nl> + Color color = g . get_color_at_offset ( ofs ) ; <nl> <nl> - Color color = get_color_at_offset ( ofs ) ; <nl> wd8 [ i * 4 + 0 ] = uint8_t ( CLAMP ( color . r * 255 . 0 , 0 , 255 ) ) ; <nl> wd8 [ i * 4 + 1 ] = uint8_t ( CLAMP ( color . g * 255 . 0 , 0 , 255 ) ) ; <nl> wd8 [ i * 4 + 2 ] = uint8_t ( CLAMP ( color . b * 255 . 0 , 0 , 255 ) ) ; <nl> int GradientTexture : : get_width ( ) const { <nl> return width ; <nl> } <nl> <nl> - Vector < float > GradientTexture : : get_offsets ( ) const { <nl> - Vector < float > offsets ; <nl> - offsets . resize ( points . size ( ) ) ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - offsets [ i ] = points [ i ] . offset ; <nl> - } <nl> - return offsets ; <nl> - } <nl> - <nl> - Vector < Color > GradientTexture : : get_colors ( ) const { <nl> - Vector < Color > colors ; <nl> - colors . resize ( points . size ( ) ) ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - colors [ i ] = points [ i ] . color ; <nl> - } <nl> - return colors ; <nl> - } <nl> - <nl> - void GradientTexture : : set_offsets ( const Vector < float > & p_offsets ) { <nl> - points . resize ( p_offsets . size ( ) ) ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - points [ i ] . offset = p_offsets [ i ] ; <nl> - } <nl> - is_sorted = false ; <nl> - emit_changed ( ) ; <nl> - _queue_update ( ) ; <nl> - } <nl> - <nl> - void GradientTexture : : set_colors ( const Vector < Color > & p_colors ) { <nl> - if ( points . size ( ) < p_colors . size ( ) ) <nl> - is_sorted = false ; <nl> - points . resize ( p_colors . size ( ) ) ; <nl> - for ( int i = 0 ; i < points . size ( ) ; i + + ) { <nl> - points [ i ] . color = p_colors [ i ] ; <nl> - } <nl> - emit_changed ( ) ; <nl> - _queue_update ( ) ; <nl> - } <nl> - <nl> - Vector < GradientTexture : : Point > & GradientTexture : : get_points ( ) { <nl> - return points ; <nl> - } <nl> - <nl> - void GradientTexture : : add_point ( float p_offset , const Color & p_color ) { <nl> - <nl> - Point p ; <nl> - p . offset = p_offset ; <nl> - p . color = p_color ; <nl> - is_sorted = false ; <nl> - points . push_back ( p ) ; <nl> - <nl> - emit_changed ( ) ; <nl> - _queue_update ( ) ; <nl> - } <nl> - <nl> - void GradientTexture : : remove_point ( int p_index ) { <nl> - <nl> - ERR_FAIL_INDEX ( p_index , points . size ( ) ) ; <nl> - ERR_FAIL_COND ( points . size ( ) < = 2 ) ; <nl> - points . remove ( p_index ) ; <nl> - emit_changed ( ) ; <nl> - _queue_update ( ) ; <nl> - } <nl> - <nl> - void GradientTexture : : set_points ( Vector < GradientTexture : : Point > & p_points ) { <nl> - points = p_points ; <nl> - is_sorted = false ; <nl> - emit_changed ( ) ; <nl> - _queue_update ( ) ; <nl> - } <nl> - <nl> - void GradientTexture : : set_offset ( int pos , const float offset ) { <nl> - if ( points . size ( ) < = pos ) <nl> - points . resize ( pos + 1 ) ; <nl> - points [ pos ] . offset = offset ; <nl> - is_sorted = false ; <nl> - emit_changed ( ) ; <nl> - _queue_update ( ) ; <nl> - } <nl> - <nl> - float GradientTexture : : get_offset ( int pos ) const { <nl> - if ( points . size ( ) > pos ) <nl> - return points [ pos ] . offset ; <nl> - return 0 ; / / TODO : Maybe throw some error instead ? <nl> - } <nl> - <nl> Ref < Image > GradientTexture : : get_data ( ) const { <nl> return VisualServer : : get_singleton ( ) - > texture_get_data ( texture ) ; <nl> } <nl> - <nl> - void GradientTexture : : set_color ( int pos , const Color & color ) { <nl> - if ( points . size ( ) < = pos ) { <nl> - points . resize ( pos + 1 ) ; <nl> - is_sorted = false ; <nl> - } <nl> - points [ pos ] . color = color ; <nl> - emit_changed ( ) ; <nl> - _queue_update ( ) ; <nl> - } <nl> - <nl> - Color GradientTexture : : get_color ( int pos ) const { <nl> - if ( points . size ( ) > pos ) <nl> - return points [ pos ] . color ; <nl> - return Color ( 0 , 0 , 0 , 1 ) ; / / TODO : Maybe throw some error instead ? <nl> - } <nl> - <nl> - int GradientTexture : : get_points_count ( ) const { <nl> - return points . size ( ) ; <nl> - } <nl> mmm a / scene / resources / texture . h <nl> ppp b / scene / resources / texture . h <nl> <nl> # include " io / resource_loader . h " <nl> # include " math_2d . h " <nl> # include " resource . h " <nl> + # include " scene / resources / color_ramp . h " <nl> # include " servers / visual_server . h " <nl> <nl> / * * <nl> class CurveTexture : public Texture { <nl> / / VARIANT_ENUM_CAST ( Texture : : CubeMapSide ) ; <nl> <nl> class GradientTexture : public Texture { <nl> - GDCLASS ( GradientTexture , Texture ) ; <nl> + GDCLASS ( GradientTexture , Texture ) <nl> <nl> public : <nl> struct Point { <nl> class GradientTexture : public Texture { <nl> } ; <nl> <nl> private : <nl> - Vector < Point > points ; <nl> - bool is_sorted ; <nl> + Ref < Gradient > gradient ; <nl> bool update_pending ; <nl> RID texture ; <nl> int width ; <nl> class GradientTexture : public Texture { <nl> static void _bind_methods ( ) ; <nl> <nl> public : <nl> - void add_point ( float p_offset , const Color & p_color ) ; <nl> - void remove_point ( int p_index ) ; <nl> - <nl> - void set_points ( Vector < Point > & points ) ; <nl> - Vector < Point > & get_points ( ) ; <nl> - <nl> - void set_offset ( int pos , const float offset ) ; <nl> - float get_offset ( int pos ) const ; <nl> - <nl> - void set_color ( int pos , const Color & color ) ; <nl> - Color get_color ( int pos ) const ; <nl> - <nl> - void set_offsets ( const Vector < float > & offsets ) ; <nl> - Vector < float > get_offsets ( ) const ; <nl> - <nl> - void set_colors ( const Vector < Color > & colors ) ; <nl> - Vector < Color > get_colors ( ) const ; <nl> + void set_gradient ( Ref < Gradient > p_gradient ) ; <nl> + Ref < Gradient > get_gradient ( ) const ; <nl> <nl> void set_width ( int p_width ) ; <nl> int get_width ( ) const ; <nl> class GradientTexture : public Texture { <nl> virtual void set_flags ( uint32_t p_flags ) { } <nl> virtual uint32_t get_flags ( ) const { return FLAG_FILTER ; } <nl> <nl> - _FORCE_INLINE_ Color get_color_at_offset ( float p_offset ) { <nl> - <nl> - if ( points . empty ( ) ) <nl> - return Color ( 0 , 0 , 0 , 1 ) ; <nl> - <nl> - if ( ! is_sorted ) { <nl> - points . sort ( ) ; <nl> - is_sorted = true ; <nl> - } <nl> - <nl> - / / binary search <nl> - int low = 0 ; <nl> - int high = points . size ( ) - 1 ; <nl> - int middle ; <nl> - <nl> - while ( low < = high ) { <nl> - middle = ( low + high ) / 2 ; <nl> - Point & point = points [ middle ] ; <nl> - if ( point . offset > p_offset ) { <nl> - high = middle - 1 ; / / search low end of array <nl> - } else if ( point . offset < p_offset ) { <nl> - low = middle + 1 ; / / search high end of array <nl> - } else { <nl> - return point . color ; <nl> - } <nl> - } <nl> - <nl> - / / return interpolated value <nl> - if ( points [ middle ] . offset > p_offset ) { <nl> - middle - - ; <nl> - } <nl> - int first = middle ; <nl> - int second = middle + 1 ; <nl> - if ( second > = points . size ( ) ) <nl> - return points [ points . size ( ) - 1 ] . color ; <nl> - if ( first < 0 ) <nl> - return points [ 0 ] . color ; <nl> - Point & pointFirst = points [ first ] ; <nl> - Point & pointSecond = points [ second ] ; <nl> - return pointFirst . color . linear_interpolate ( pointSecond . color , ( p_offset - pointFirst . offset ) / ( pointSecond . offset - pointFirst . offset ) ) ; <nl> - } <nl> - <nl> virtual Ref < Image > get_data ( ) const ; <nl> <nl> - int get_points_count ( ) const ; <nl> - <nl> GradientTexture ( ) ; <nl> virtual ~ GradientTexture ( ) ; <nl> } ; <nl>
Merge pull request from Zylann / gradient_refactor
godotengine/godot
898d8fd55735354783d131bc55c5f822ddabf60c
2017-06-24T21:13:56Z
mmm a / stdlib / public / core / StringComparison . swift <nl> ppp b / stdlib / public / core / StringComparison . swift <nl> import SwiftShims <nl> / / memcmp fast path for comparing ascii strings . rdar : / / problem / 37473470 <nl> @ inline ( never ) / / @ outlined <nl> @ effects ( readonly ) <nl> - @ _versioned internal <nl> + @ _versioned / / @ opaque <nl> + internal <nl> func _compareUnicode ( <nl> _ lhs : _StringGuts . _RawBitPattern , _ rhs : _StringGuts . _RawBitPattern <nl> ) - > Int { <nl> let left = _StringGuts ( rawBits : lhs ) <nl> let right = _StringGuts ( rawBits : rhs ) <nl> - return left . _compare ( right ) <nl> + <nl> + if _slowPath ( ! left . _isContiguous | | ! right . _isContiguous ) { <nl> + if ! left . _isContiguous { <nl> + return left . _asOpaque ( ) . _compareOpaque ( right ) . rawValue <nl> + } else { <nl> + return right . _asOpaque ( ) . _compareOpaque ( left ) . flipped . rawValue <nl> + } <nl> + } <nl> + <nl> + return left . _compareContiguous ( right ) <nl> } <nl> <nl> @ inline ( never ) / / @ outlined <nl> @ effects ( readonly ) <nl> - @ _versioned internal <nl> + @ _versioned / / @ opaque <nl> + internal <nl> func _compareUnicode ( <nl> _ lhs : _StringGuts . _RawBitPattern , _ leftRange : Range < Int > , <nl> _ rhs : _StringGuts . _RawBitPattern , _ rightRange : Range < Int > <nl> ) - > Int { <nl> let left = _StringGuts ( rawBits : lhs ) <nl> let right = _StringGuts ( rawBits : rhs ) <nl> - return left . _compare ( leftRange , right , rightRange ) <nl> + <nl> + if _slowPath ( ! left . _isContiguous | | ! right . _isContiguous ) { <nl> + if ! left . _isContiguous { <nl> + return left . _asOpaque ( ) [ leftRange ] . _compareOpaque ( <nl> + right , rightRange <nl> + ) . rawValue <nl> + } else { <nl> + return right . _asOpaque ( ) [ rightRange ] . _compareOpaque ( <nl> + left , leftRange <nl> + ) . flipped . rawValue <nl> + } <nl> + } <nl> + <nl> + return left . _compareContiguous ( leftRange , right , rightRange ) <nl> } <nl> <nl> / / <nl> extension _UnmanagedString where CodeUnit = = UInt8 { <nl> public extension _StringGuts { <nl> @ inline ( __always ) <nl> public <nl> - func _compare ( _ other : _StringGuts ) - > Int { <nl> - let selfRange = Range < Int > ( uncheckedBounds : ( 0 , self . count ) ) <nl> - let otherRange = Range < Int > ( uncheckedBounds : ( 0 , other . count ) ) <nl> - return _compare ( selfRange , other , otherRange ) <nl> + func _compareContiguous ( _ other : _StringGuts ) - > Int { <nl> + _sanityCheck ( self . _isContiguous & & other . _isContiguous ) <nl> + switch ( self . isASCII , other . isASCII ) { <nl> + case ( true , true ) : <nl> + fatalError ( " Should have hit the ascii comp in StringComparable . compare ( ) " ) <nl> + case ( true , false ) : <nl> + return self . _unmanagedASCIIView . _compareStringsPreLoop ( <nl> + other : other . _unmanagedUTF16View <nl> + ) . rawValue <nl> + case ( false , true ) : <nl> + / / Same compare , just invert result <nl> + return other . _unmanagedASCIIView . _compareStringsPreLoop ( <nl> + other : self . _unmanagedUTF16View <nl> + ) . flipped . rawValue <nl> + case ( false , false ) : <nl> + return self . _unmanagedUTF16View . _compareStringsPreLoop ( <nl> + other : other . _unmanagedUTF16View <nl> + ) . rawValue <nl> + } <nl> } <nl> <nl> @ inline ( __always ) <nl> public <nl> - func _compare ( <nl> + func _compareContiguous ( <nl> _ selfRange : Range < Int > , <nl> _ other : _StringGuts , <nl> _ otherRange : Range < Int > <nl> ) - > Int { <nl> - if _slowPath ( <nl> - ! self . _isContiguous | | ! other . _isContiguous <nl> - ) { <nl> - if ! self . _isContiguous { <nl> - return self . _asOpaque ( ) . _compareOpaque ( <nl> - selfRange , other , otherRange <nl> - ) . rawValue <nl> - } else { <nl> - return other . _asOpaque ( ) . _compareOpaque ( <nl> - otherRange , self , selfRange <nl> - ) . flipped . rawValue <nl> - } <nl> - } <nl> - <nl> - switch ( self . isASCII , other . isASCII ) { <nl> - case ( true , true ) : <nl> - fatalError ( " Should have hit the ascii comp in StringComparable . compare ( ) " ) <nl> - case ( true , false ) : <nl> - return self . _unmanagedASCIIView [ selfRange ] . _compareStringsPreLoop ( <nl> - other : other . _unmanagedUTF16View [ otherRange ] <nl> - ) . rawValue <nl> - case ( false , true ) : <nl> - / / Same compare , just invert result <nl> - return other . _unmanagedASCIIView [ otherRange ] . _compareStringsPreLoop ( <nl> - other : self . _unmanagedUTF16View [ selfRange ] <nl> - ) . flipped . rawValue <nl> - case ( false , false ) : <nl> - return self . _unmanagedUTF16View [ selfRange ] . _compareStringsPreLoop ( <nl> - other : other . _unmanagedUTF16View [ otherRange ] <nl> - ) . rawValue <nl> - } <nl> + _sanityCheck ( self . _isContiguous & & other . _isContiguous ) <nl> + switch ( self . isASCII , other . isASCII ) { <nl> + case ( true , true ) : <nl> + fatalError ( " Should have hit the ascii comp in StringComparable . compare ( ) " ) <nl> + case ( true , false ) : <nl> + return self . _unmanagedASCIIView [ selfRange ] . _compareStringsPreLoop ( <nl> + other : other . _unmanagedUTF16View [ otherRange ] <nl> + ) . rawValue <nl> + case ( false , true ) : <nl> + / / Same compare , just invert result <nl> + return other . _unmanagedASCIIView [ otherRange ] . _compareStringsPreLoop ( <nl> + other : self . _unmanagedUTF16View [ selfRange ] <nl> + ) . flipped . rawValue <nl> + case ( false , false ) : <nl> + return self . _unmanagedUTF16View [ selfRange ] . _compareStringsPreLoop ( <nl> + other : other . _unmanagedUTF16View [ otherRange ] <nl> + ) . rawValue <nl> + } <nl> } <nl> } <nl> <nl> extension _UnmanagedOpaqueString { <nl> - @ inline ( never ) <nl> + @ inline ( never ) / / @ outlined <nl> + @ _versioned <nl> + internal <nl> + func _compareOpaque ( _ other : _StringGuts ) - > _Ordering { <nl> + return self . _compareOpaque ( other , 0 . . < other . count ) <nl> + } <nl> + <nl> + @ inline ( never ) / / @ outlined <nl> @ _versioned <nl> internal <nl> func _compareOpaque ( <nl> - _ selfRange : Range < Int > , <nl> - _ other : _StringGuts , <nl> - _ otherRange : Range < Int > <nl> + _ other : _StringGuts , _ otherRange : Range < Int > <nl> ) - > _Ordering { <nl> / / <nl> / / Do a fast Latiny comparison loop ; bail if that proves insufficient . <nl> extension _UnmanagedOpaqueString { <nl> / / termination of an all - ASCII file loaded by String . init ( contentsOfFile : ) . <nl> / / <nl> <nl> - <nl> - let selfCount = selfRange . count <nl> + let selfCount = self . count <nl> let otherCount = otherRange . count <nl> let count = Swift . min ( selfCount , otherCount ) <nl> - let idx = self [ selfRange ] . _findDiffIdx ( other , otherRange ) <nl> + let idx = self . _findDiffIdx ( other , otherRange ) <nl> if idx = = count { <nl> return _lexicographicalCompare ( selfCount , otherCount ) <nl> } <nl> mmm a / validation - test / stdlib / String . swift <nl> ppp b / validation - test / stdlib / String . swift <nl> struct ComparisonTestCase { <nl> } <nl> } <nl> <nl> - let simpleComparisonTestCases = [ <nl> + let comparisonTestCases = [ <nl> ComparisonTestCase ( [ " a " , " a " ] , . equal ) , <nl> ComparisonTestCase ( [ " abcdefg " , " abcdefg " ] , . equal ) , <nl> ComparisonTestCase ( [ " " , " Z " , " a " , " b " , " c " , " \ u { 00c5 } " , " á " ] , . less ) , <nl> <nl> ComparisonTestCase ( [ " ábcdefg " , " ábcdefgh " , " ábcdefghi " ] , . less ) , <nl> ComparisonTestCase ( [ " abcdefg " , " abcdefgh " , " abcdefghi " ] , . less ) , <nl> - ] <nl> <nl> - let complexComparisonTestCases = [ <nl> ComparisonTestCase ( [ " á " , " \ u { 0061 } \ u { 0301 } " ] , . equal ) , <nl> ComparisonTestCase ( [ " à " , " \ u { 0061 } \ u { 0301 } " , " â " , " \ u { e3 } " , " a \ u { 0308 } " ] , . less ) , <nl> <nl> let complexComparisonTestCases = [ <nl> ComparisonTestCase ( [ " i ̀ ́ ̂ ̃ ̄ ̉ ̊ ̋ ̌ ̍ ̎ ̏ ̐ ̑ ̒ ̓ ̝ ̞ ̟ ̠ ̡ ̢ ̣ ̤ ̥ ̦ ̧ ̨ ̩ ̪ ̫ ̬ ̭ ̮ ̯ ̰ ̹ ̺ ̻ ̼ ̽ ̾ ̿ ̀ ́ ͂ ̓ ̈́ ͅ ͆ ͇ ͈ ͉ ͊ ͋ ͌ ͍ ͎ ͏ ͐ ͑ ͒ ͓ ͔ ͕ ͖ ͗ ͘ ͙ ͬ ͭ ͮ " , " i ̀ ́ ̂ ̃ ̄ ̉ ̊ ̋ ̌ ̍ ̎ ̏ ̐ ̑ ̒ ̓ ̝ ̞ ̟ ̠ ̡ ̢ ̣ ̤ ̥ ̦ ̧ ̨ ̩ ̪ ̫ ̬ ̭ ̮ ̯ ̰ ̹ ̺ ̻ ̼ ̽ ̾ ̿ ̀ ́ ͂ ̓ ̈́ ͅ ͆ ͇ ͈ ͉ ͊ ͋ ͌ ͍ ͎ ͏ ͐ ͑ ͒ ͓ ͔ ͕ ͖ ͗ ͘ ͙ ͬ ͭ ͮ " ] , . equal ) <nl> ] <nl> <nl> - let comparisonTestCases = simpleComparisonTestCases + complexComparisonTestCases <nl> - <nl> for test in comparisonTestCases { <nl> StringTests . test ( " Comparison . \ ( test . strings ) " ) { <nl> test . test ( ) <nl> for test in comparisonTestCases { <nl> . code { <nl> test . testOpaqueStrings ( ) <nl> } <nl> - } <nl> <nl> - for test in simpleComparisonTestCases { <nl> StringTests . test ( " Comparison . OpaqueSubstring . \ ( test . strings ) " ) <nl> . skip ( . linuxAny ( reason : " NSSlowString requires ObjC interop " ) ) <nl> . code { <nl>
Merge pull request from milseman / comparison_finance_reform
apple/swift
149ad71040fbbd4deccb568679ba701cf16bf9b3
2018-02-19T21:00:50Z
mmm a / . jenkins / caffe2 / test . sh <nl> ppp b / . jenkins / caffe2 / test . sh <nl> if [ [ " $ BUILD_ENVIRONMENT " = = * onnx * ] ] ; then <nl> # default pip version is too old ( 9 . 0 . 2 ) , unable to support tag ` manylinux2010 ` . <nl> # Fix the pip error : Couldn ' t find a version that satisfies the requirement <nl> sudo pip install - - upgrade pip <nl> - pip install - q - - user - i https : / / test . pypi . org / simple / ort - nightly = = 1 . 3 . 0 . dev202005121 <nl> + pip install - q - - user - i https : / / test . pypi . org / simple / ort - nightly = = 1 . 3 . 0 . dev202005123 <nl> fi <nl> " $ ROOT_DIR / scripts / onnx / test . sh " <nl> fi <nl> mmm a / test / onnx / test_pytorch_onnx_onnxruntime . py <nl> ppp b / test / onnx / test_pytorch_onnx_onnxruntime . py <nl> def forward ( self , x ) : <nl> x = torch . rand ( 5 , 5 , 5 ) <nl> self . run_test ( DynamicSliceExportMod ( ) , x , <nl> dynamic_axes = { ' input_1 ' : [ 0 , 1 , 2 ] , <nl> - ' output_1 ' : [ 0 , 1 , 2 ] } ) <nl> + ' output_1 ' : [ 0 , 1 , 2 ] } ) <nl> <nl> @ skipIfUnsupportedMinOpsetVersion ( 9 ) <nl> def test_arange_dynamic ( self ) : <nl> def get_LstmNet_model_and_inputs ( input_size , hidden_size , num_layers , batch_size <nl> model2 , input2 = get_LstmNet_model_and_inputs ( 5 , 4 , 3 , batch_size2 , 7 , False ) <nl> self . run_test ( model2 , input2 , do_constant_folding = True ) <nl> <nl> + @ skipIfUnsupportedMinOpsetVersion ( 9 ) <nl> + def test_lstm_no_bias ( self ) : <nl> + class LstmNet ( torch . nn . Module ) : <nl> + def __init__ ( self , num_layers , bidirectional ) : <nl> + super ( LstmNet , self ) . __init__ ( ) <nl> + self . lstm = torch . nn . LSTM ( RNN_INPUT_SIZE , RNN_HIDDEN_SIZE , num_layers , bias = False , bidirectional = bidirectional ) <nl> + <nl> + def forward ( self , input , initial_state ) : <nl> + return self . lstm ( input , initial_state ) <nl> + <nl> + def get_LstmNet_model_and_inputs ( num_layers , bidirectional ) : <nl> + input = torch . randn ( RNN_SEQUENCE_LENGTH , BATCH_SIZE , RNN_INPUT_SIZE ) <nl> + num_directions = 2 if bidirectional else 1 <nl> + model = LstmNet ( num_layers , bidirectional ) <nl> + h0 = torch . randn ( num_layers * num_directions , BATCH_SIZE , RNN_HIDDEN_SIZE ) <nl> + c0 = torch . randn ( num_layers * num_directions , BATCH_SIZE , RNN_HIDDEN_SIZE ) <nl> + return model , ( input , ( h0 , c0 ) ) <nl> + <nl> + num_layers = [ 1 , 1 , 2 , 3 ] <nl> + bidirectional = [ True , False , True , False ] <nl> + models_and_inputs = [ get_LstmNet_model_and_inputs ( n , b ) for n , b in zip ( num_layers , bidirectional ) ] <nl> + for model , input in models_and_inputs : <nl> + self . run_test ( model , input ) <nl> + <nl> + def test_rnn_no_bias ( self ) : <nl> + def make_model ( layers , packed_sequence ) : <nl> + batch_first = True if packed_sequence = = 2 else False <nl> + model = torch . nn . RNN ( RNN_INPUT_SIZE , RNN_HIDDEN_SIZE , layers , bidirectional = False , <nl> + batch_first = batch_first , bias = False ) <nl> + <nl> + if packed_sequence = = 1 : <nl> + model = RnnModelWithPackedSequence ( model , False ) <nl> + if packed_sequence = = 2 : <nl> + model = RnnModelWithPackedSequence ( model , True ) <nl> + return model <nl> + <nl> + def make_input ( batch_size , layers , packed_sequence ) : <nl> + batch_first = True if packed_sequence = = 2 else False <nl> + seq_lengths = np . random . randint ( 1 , RNN_SEQUENCE_LENGTH + 1 , size = batch_size ) <nl> + seq_lengths = list ( reversed ( sorted ( map ( int , seq_lengths ) ) ) ) <nl> + inputs = [ torch . randn ( l , RNN_INPUT_SIZE ) for l in seq_lengths ] <nl> + inputs = rnn_utils . pad_sequence ( inputs , batch_first = batch_first ) <nl> + inputs = [ inputs ] <nl> + <nl> + h0 = torch . randn ( layers , batch_size , RNN_HIDDEN_SIZE ) <nl> + inputs . append ( h0 ) <nl> + if packed_sequence ! = 0 : <nl> + inputs . append ( torch . IntTensor ( seq_lengths ) ) <nl> + if len ( inputs ) = = 1 : <nl> + input = inputs [ 0 ] <nl> + else : <nl> + input = tuple ( inputs ) <nl> + return input <nl> + <nl> + layers = [ 1 , 3 , 1 , 3 , 1 , 3 ] <nl> + packed_sequence = [ 0 , 0 , 1 , 1 , 2 , 2 ] <nl> + models = [ make_model ( l , p ) for l , p in zip ( layers , packed_sequence ) ] <nl> + inputs = [ make_input ( RNN_BATCH_SIZE , l , p ) for l , p in zip ( layers , packed_sequence ) ] <nl> + <nl> + for model , input in zip ( models , inputs ) : <nl> + self . run_test ( model , input , batch_size = RNN_BATCH_SIZE ) <nl> + <nl> + def test_gru_no_bias ( self ) : <nl> + class GruNet ( torch . nn . Module ) : <nl> + def __init__ ( self , input_size , hidden_size , num_layers , bidirectional ) : <nl> + super ( GruNet , self ) . __init__ ( ) <nl> + self . mygru = torch . nn . GRU ( input_size , hidden_size , num_layers , bidirectional = bidirectional , bias = False ) <nl> + <nl> + def forward ( self , input , initial_state ) : <nl> + out = self . mygru ( input , initial_state ) <nl> + return out <nl> + <nl> + def get_GruNet_model_and_inputs ( input_size , hidden_size , num_layers , batch_size , <nl> + seq_len , bidirectional ) : <nl> + num_directions = 2 if bidirectional else 1 <nl> + model = GruNet ( input_size , hidden_size , num_layers , bidirectional ) <nl> + input = torch . randn ( seq_len , batch_size , input_size ) <nl> + h0 = torch . randn ( num_layers * num_directions , batch_size , hidden_size ) <nl> + return model , ( input , h0 ) <nl> + <nl> + input_size = [ 7 , 5 ] <nl> + hidden_size = [ 3 , 4 ] <nl> + num_layers = [ 2 , 3 ] <nl> + batch_size = [ 3 , 4 ] <nl> + seq_len = [ 5 , 7 ] <nl> + bidirectional = [ True , False ] <nl> + models_and_inputs = [ get_GruNet_model_and_inputs ( i , h , n , b , s , bi ) <nl> + for i , h , n , b , s , bi in zip ( input_size , hidden_size , num_layers , batch_size , seq_len , bidirectional ) ] <nl> + for model , input in models_and_inputs : <nl> + self . run_test ( model , input , do_constant_folding = True ) <nl> + <nl> def test_gru_constant_folding ( self ) : <nl> class GruNet ( torch . nn . Module ) : <nl> def __init__ ( self , input_size , hidden_size , num_layers , bidirectional ) : <nl> def setup_rnn_tests ( ) : <nl> TestONNXRuntime_opset9_IRv4 = type ( str ( " TestONNXRuntime_opset9_IRv4 " ) , <nl> ( unittest . TestCase , ) , <nl> dict ( TestONNXRuntime . __dict__ , <nl> - keep_initializers_as_inputs = False ) ) <nl> + keep_initializers_as_inputs = False ) ) <nl> <nl> <nl> # opset 10 tests , with keep_initializers_as_inputs = False for <nl> def setup_rnn_tests ( ) : <nl> TestONNXRuntime_opset10_IRv4 = type ( str ( " TestONNXRuntime_opset10_IRv4 " ) , <nl> ( unittest . TestCase , ) , <nl> dict ( TestONNXRuntime . __dict__ , opset_version = 10 , <nl> - keep_initializers_as_inputs = False ) ) <nl> + keep_initializers_as_inputs = False ) ) <nl> <nl> <nl> # opset 11 tests , with keep_initializers_as_inputs = False for <nl> def setup_rnn_tests ( ) : <nl> TestONNXRuntime_opset11_IRv4 = type ( str ( " TestONNXRuntime_opset11_IRv4 " ) , <nl> ( unittest . TestCase , ) , <nl> dict ( TestONNXRuntime . __dict__ , opset_version = 11 , <nl> - keep_initializers_as_inputs = False ) ) <nl> + keep_initializers_as_inputs = False ) ) <nl> <nl> # opset 12 tests , with keep_initializers_as_inputs = False for <nl> # IR version 4 style export . <nl> TestONNXRuntime_opset12_IRv4 = type ( str ( " TestONNXRuntime_opset12_IRv4 " ) , <nl> ( unittest . TestCase , ) , <nl> dict ( TestONNXRuntime . __dict__ , opset_version = 12 , <nl> - keep_initializers_as_inputs = False ) ) <nl> + keep_initializers_as_inputs = False ) ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / torch / onnx / symbolic_opset9 . py <nl> ppp b / torch / onnx / symbolic_opset9 . py <nl> def reform_weights ( g , w , n , intervals ) : <nl> slices = [ sym_help . _slice_helper ( g , w , axes = [ 0 ] , starts = [ x * n ] , ends = [ y * n ] ) for x , y in intervals ] <nl> return g . op ( ' Concat ' , * slices , axis_i = 0 ) <nl> <nl> + def transform_weights_no_bias ( layer_index ) : <nl> + weights = layer_weights [ layer_index ] <nl> + if variant = = ' RNN ' : <nl> + weight_ih , weight_hh = weights <nl> + elif variant = = ' GRU ' or variant = = ' LSTM ' : <nl> + weight_ih , weight_hh = \ <nl> + [ reform_weights ( g , w , hidden_size , reform_permutation ) for w in weights ] <nl> + return tuple ( g . op ( ' Unsqueeze ' , x , axes_i = [ 0 ] ) for x in ( weight_ih , weight_hh ) ) <nl> + <nl> def transform_weights ( layer_index ) : <nl> + weights = layer_weights [ layer_index ] <nl> if variant = = ' RNN ' : <nl> - weight_ih , weight_hh , bias_ih , bias_hh = layer_weights [ layer_index ] <nl> + weight_ih , weight_hh , bias_ih , bias_hh = weights <nl> elif variant = = ' GRU ' or variant = = ' LSTM ' : <nl> weight_ih , weight_hh , bias_ih , bias_hh = \ <nl> - [ reform_weights ( g , w , hidden_size , reform_permutation ) for w in layer_weights [ layer_index ] ] <nl> + [ reform_weights ( g , w , hidden_size , reform_permutation ) for w in weights ] <nl> bias_concat = g . op ( ' Concat ' , bias_ih , bias_hh , axis_i = 0 ) <nl> - <nl> return tuple ( g . op ( ' Unsqueeze ' , x , axes_i = [ 0 ] ) for x in ( weight_ih , weight_hh , bias_concat ) ) <nl> <nl> def retrieve_state ( x , start , end ) : <nl> def retrieve_state ( x , start , end ) : <nl> <nl> for i in range ( num_layers ) : <nl> if unidirectional : <nl> - weight_ih , weight_hh , bias_concat = transform_weights ( i ) <nl> + if weights_per_layer = = 4 : <nl> + weight_ih , weight_hh , bias_concat = transform_weights ( i ) <nl> + else : <nl> + weight_ih , weight_hh = transform_weights_no_bias ( i ) <nl> + bias_concat = unused ( g ) <nl> + <nl> state_indices = i , i + 1 <nl> else : <nl> - weight_ih_f , weight_hh_f , bias_f = transform_weights ( 2 * i ) <nl> - weight_ih_b , weight_hh_b , bias_b = transform_weights ( 2 * i + 1 ) <nl> + if weights_per_layer = = 4 : <nl> + weight_ih_f , weight_hh_f , bias_f = transform_weights ( 2 * i ) <nl> + weight_ih_b , weight_hh_b , bias_b = transform_weights ( 2 * i + 1 ) <nl> + bias_concat = g . op ( ' Concat ' , bias_f , bias_b , axis_i = 0 ) <nl> + else : <nl> + weight_ih_f , weight_hh_f = transform_weights_no_bias ( 2 * i ) <nl> + weight_ih_b , weight_hh_b = transform_weights_no_bias ( 2 * i + 1 ) <nl> + bias_concat = unused ( g ) <nl> <nl> weight_ih = g . op ( ' Concat ' , weight_ih_f , weight_ih_b , axis_i = 0 ) <nl> weight_hh = g . op ( ' Concat ' , weight_hh_f , weight_hh_b , axis_i = 0 ) <nl> - bias_concat = g . op ( ' Concat ' , bias_f , bias_b , axis_i = 0 ) <nl> <nl> state_indices = 2 * i , 2 * i + 2 <nl> <nl>
Fix ONNX export of RNNs with no bias ( )
pytorch/pytorch
0251ba61089795a7a27c0473e4bb022805432c1f
2020-06-09T03:36:22Z
mmm a / src / python / grpcio / grpc / _cython / _cygrpc / aio / completion_queue . pxd . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / aio / completion_queue . pxd . pxi <nl> cdef extern from " < queue > " namespace " std " nogil : <nl> size_t size ( ) <nl> <nl> <nl> + cdef extern from " < mutex > " namespace " std " nogil : <nl> + cdef cppclass mutex : <nl> + mutex ( ) <nl> + void lock ( ) <nl> + void unlock ( ) <nl> + <nl> + <nl> ctypedef queue [ grpc_event ] cpp_event_queue <nl> <nl> <nl> cdef class BaseCompletionQueue : <nl> cdef class PollerCompletionQueue ( BaseCompletionQueue ) : <nl> cdef bint _shutdown <nl> cdef cpp_event_queue _queue <nl> + cdef mutex _queue_mutex <nl> cdef object _poller_thread <nl> cdef int _write_fd <nl> cdef object _read_socket <nl> mmm a / src / python / grpcio / grpc / _cython / _cygrpc / aio / completion_queue . pyx . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / aio / completion_queue . pyx . pxi <nl> cdef class PollerCompletionQueue ( BaseCompletionQueue ) : <nl> elif event . type = = GRPC_QUEUE_SHUTDOWN : <nl> self . _shutdown = True <nl> else : <nl> + self . _queue_mutex . lock ( ) <nl> self . _queue . push ( event ) <nl> + self . _queue_mutex . unlock ( ) <nl> _unified_socket_write ( self . _write_fd ) <nl> <nl> def _poll_wrapper ( self ) : <nl> cdef class PollerCompletionQueue ( BaseCompletionQueue ) : <nl> cdef grpc_event event <nl> cdef CallbackContext * context <nl> <nl> - while not self . _queue . empty ( ) : <nl> - event = self . _queue . front ( ) <nl> - self . _queue . pop ( ) <nl> + while True : <nl> + self . _queue_mutex . lock ( ) <nl> + if self . _queue . empty ( ) : <nl> + self . _queue_mutex . unlock ( ) <nl> + break <nl> + else : <nl> + event = self . _queue . front ( ) <nl> + self . _queue . pop ( ) <nl> + self . _queue_mutex . unlock ( ) <nl> <nl> context = < CallbackContext * > event . tag <nl> loop = < object > context . loop <nl>
Use mutex to protect queue operations
grpc/grpc
d6bd3c37b287cb10d0783b281544a1720fdebf8b
2020-03-17T22:32:38Z
mmm a / lib / IRGen / IRGenModule . h <nl> ppp b / lib / IRGen / IRGenModule . h <nl> class IRGenModule { <nl> const llvm : : DataLayout & DataLayout ; <nl> SILModule * SILMod ; <nl> / / / Order dependency - - TargetInfo must be initialized after Opts . <nl> - SwiftTargetInfo TargetInfo ; <nl> + const SwiftTargetInfo TargetInfo ; <nl> / / / Holds lexical scope info , etc . Is a nullptr if we compile without - g . <nl> IRGenDebugInfo * DebugInfo ; <nl> / / / A Clang - to - IR - type converter for types appearing in function <nl>
Remove some boilerplate from SwiftTargetInfo construction ,
apple/swift
a3bf2619e97b90c1dcd43e60225f0976cac739cf
2014-01-24T02:32:35Z
mmm a / swoole_process . c <nl> ppp b / swoole_process . c <nl> PHP_METHOD ( swoole_process , start ) <nl> { <nl> swWorker * process ; <nl> SWOOLE_GET_WORKER ( getThis ( ) , process ) ; <nl> - zval * zpipe ; <nl> <nl> pid_t pid = fork ( ) ; <nl> <nl> PHP_METHOD ( swoole_process , start ) <nl> <nl> close ( process - > pipe_worker ) ; <nl> <nl> - MAKE_STD_ZVAL ( zpipe ) ; <nl> - ZVAL_LONG ( zpipe , process - > pipe ) ; <nl> - <nl> - zend_update_property ( swoole_process_class_entry_ptr , getThis ( ) , ZEND_STRL ( " pipe " ) , zpipe TSRMLS_CC ) ; <nl> - zval_ptr_dtor ( & zpipe ) ; <nl> + zend_update_property_long ( swoole_server_class_entry_ptr , getThis ( ) , ZEND_STRL ( " pid " ) , process - > pid TSRMLS_CC ) ; <nl> + zend_update_property_long ( swoole_process_class_entry_ptr , getThis ( ) , ZEND_STRL ( " pipe " ) , process - > pipe TSRMLS_CC ) ; <nl> <nl> RETURN_LONG ( pid ) ; <nl> } <nl> PHP_METHOD ( swoole_process , start ) <nl> php_sw_reactor_ok = 0 ; <nl> } <nl> <nl> - zval * zpid ; <nl> - MAKE_STD_ZVAL ( zpid ) ; <nl> - ZVAL_LONG ( zpid , process - > pid ) ; <nl> - <nl> - zend_update_property ( swoole_server_class_entry_ptr , getThis ( ) , ZEND_STRL ( " pid " ) , zpid TSRMLS_CC ) ; <nl> - zval_ptr_dtor ( & zpid ) ; <nl> - <nl> - MAKE_STD_ZVAL ( zpipe ) ; <nl> - ZVAL_LONG ( zpipe , process - > pipe ) ; <nl> - <nl> - zend_update_property ( swoole_process_class_entry_ptr , getThis ( ) , ZEND_STRL ( " pipe " ) , zpipe TSRMLS_CC ) ; <nl> - zval_ptr_dtor ( & zpipe ) ; <nl> + zend_update_property_long ( swoole_server_class_entry_ptr , getThis ( ) , ZEND_STRL ( " pid " ) , process - > pid TSRMLS_CC ) ; <nl> + zend_update_property_long ( swoole_process_class_entry_ptr , getThis ( ) , ZEND_STRL ( " pipe " ) , process - > pipe TSRMLS_CC ) ; <nl> <nl> zval * zcallback = zend_read_property ( swoole_process_class_entry_ptr , getThis ( ) , ZEND_STRL ( " callback " ) , 0 TSRMLS_CC ) ; <nl> zval * * args [ 1 ] ; <nl>
Added swoole_process - > pid
swoole/swoole-src
582d9981329ce9f2f7b32c756bb37f406df349b2
2014-08-29T04:23:51Z
mmm a / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioAE . cpp <nl> ppp b / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioAE . cpp <nl> void CCoreAudioAE : : SetVolume ( float volume ) <nl> / / we need this because m_volume is init ' ed via <nl> / / SetVolume and need to also init m_volumeBeforeMute . <nl> if ( ! m_muted ) <nl> - m_volumeBeforeMute = volume ; <nl> + m_volumeBeforeMute = volume ; <nl> <nl> HAL - > SetVolume ( m_volume ) ; <nl> } <nl> void CCoreAudioAE : : SetMute ( const bool enabled ) <nl> m_muted = enabled ; <nl> if ( m_muted ) <nl> { <nl> - m_volumeBeforeMute = m_volume ; <nl> + m_volumeBeforeMute = m_volume ; <nl> SetVolume ( VOLUME_MINIMUM ) ; <nl> } <nl> else <nl> bool CCoreAudioAE : : IsMuted ( ) <nl> void CCoreAudioAE : : SetSoundMode ( const int mode ) <nl> { <nl> m_soundMode = mode ; <nl> - <nl> + <nl> / * stop all currently playing sounds if they are being turned off * / <nl> if ( mode = = AE_SOUND_OFF | | ( mode = = AE_SOUND_IDLE & & m_streamsPlaying ) ) <nl> - StopAllSounds ( ) ; <nl> + StopAllSounds ( ) ; <nl> } <nl> <nl> bool CCoreAudioAE : : SupportsRaw ( ) <nl> IAEStream * CCoreAudioAE : : MakeStream ( enum AEDataFormat dataFormat , <nl> <nl> Start ( ) ; <nl> <nl> - m_streamsPlaying = true ; <nl> + m_streamsPlaying = true ; <nl> <nl> return stream ; <nl> } <nl> IAEStream * CCoreAudioAE : : FreeStream ( IAEStream * stream ) <nl> m_streamsPlaying = ! m_streams . empty ( ) ; <nl> <nl> streamLock . Leave ( ) ; <nl> - <nl> + <nl> / / When we have been in passthrough mode , reinit the hardware to come back to anlog out <nl> if ( / * m_streams . empty ( ) | | * / m_rawPassthrough ) <nl> { <nl> OSStatus CCoreAudioAE : : OnRender ( AudioUnitRenderActionFlags * actionFlags , <nl> / / int size = frames * HAL - > m_BytesPerFrame ; <nl> <nl> for ( UInt32 i = 0 ; i < ioData - > mNumberBuffers ; i + + ) <nl> - bzero ( ioData - > mBuffers [ i ] . mData , ioData - > mBuffers [ i ] . mDataByteSize ) ; <nl> + bzero ( ioData - > mBuffers [ i ] . mData , ioData - > mBuffers [ i ] . mDataByteSize ) ; <nl> <nl> if ( ! m_Initialized ) <nl> { <nl> mmm a / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioAE . h <nl> ppp b / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioAE . h <nl> class CCoreAudioAE : public IAE , public ICoreAudioSource <nl> / / Give the HAL access to the engine <nl> friend class CCoreAudioAEHAL ; <nl> CCoreAudioAEHAL * HAL ; <nl> - <nl> + <nl> public : <nl> virtual void Shutdown ( ) ; <nl> <nl> class CCoreAudioAE : public IAE , public ICoreAudioSource <nl> virtual void SetMute ( const bool enabled ) ; <nl> virtual bool IsMuted ( ) ; <nl> virtual void SetSoundMode ( const int mode ) ; <nl> - <nl> + <nl> <nl> virtual bool SupportsRaw ( ) ; <nl> - <nl> + <nl> CCoreAudioAEHAL * GetHAL ( ) ; <nl> - <nl> + <nl> / / returns a new stream for data in the specified format <nl> - virtual IAEStream * MakeStream ( enum AEDataFormat dataFormat , <nl> + virtual IAEStream * MakeStream ( enum AEDataFormat dataFormat , <nl> unsigned int sampleRate , unsigned int encodedSamplerate , <nl> CAEChannelInfo channelLayout , unsigned int options = 0 ) ; <nl> - <nl> + <nl> virtual IAEStream * FreeStream ( IAEStream * stream ) ; <nl> - <nl> + <nl> / / returns a new sound object <nl> virtual IAESound * MakeSound ( const std : : string & file ) ; <nl> void StopAllSounds ( ) ; <nl> class CCoreAudioAE : public IAE , public ICoreAudioSource <nl> <nl> virtual void EnumerateOutputDevices ( AEDeviceList & devices , bool passthrough ) ; <nl> <nl> - virtual OSStatus Render ( AudioUnitRenderActionFlags * actionFlags , <nl> - const AudioTimeStamp * pTimeStamp , UInt32 busNumber , <nl> + virtual OSStatus Render ( AudioUnitRenderActionFlags * actionFlags , <nl> + const AudioTimeStamp * pTimeStamp , UInt32 busNumber , <nl> UInt32 frameCount , AudioBufferList * pBufList ) ; <nl> - <nl> + <nl> <nl> private : <nl> CCriticalSection m_callbackLock ; <nl> CCriticalSection m_streamLock ; <nl> CCriticalSection m_soundLock ; <nl> CCriticalSection m_soundSampleLock ; <nl> - <nl> + <nl> / / currently playing sounds <nl> typedef struct { <nl> CCoreAudioAESound * owner ; <nl> class CCoreAudioAE : public IAE , public ICoreAudioSource <nl> StreamList m_streams ; <nl> SoundList m_sounds ; <nl> SoundStateList m_playing_sounds ; <nl> - <nl> + <nl> / / Prevent multiple init / deinit <nl> bool m_Initialized ; <nl> bool m_callbackRunning ; <nl> - <nl> + <nl> AEAudioFormat m_format ; <nl> unsigned int m_chLayoutCount ; <nl> bool m_rawPassthrough ; <nl> <nl> enum AEStdChLayout m_stdChLayout ; <nl> - <nl> + <nl> bool OpenCoreAudio ( unsigned int sampleRate , bool forceRaw , enum AEDataFormat rawDataFormat ) ; <nl> void Deinitialize ( ) ; <nl> void Start ( ) ; <nl> void Stop ( ) ; <nl> <nl> - OSStatus OnRender ( AudioUnitRenderActionFlags * actionFlags , <nl> - const AudioTimeStamp * inTimeStamp , UInt32 inBusNumber , <nl> + OSStatus OnRender ( AudioUnitRenderActionFlags * actionFlags , <nl> + const AudioTimeStamp * inTimeStamp , UInt32 inBusNumber , <nl> UInt32 inNumberFrames , AudioBufferList * ioData ) ; <nl> <nl> float m_volume ; <nl> - float m_volumeBeforeMute ; <nl> + float m_volumeBeforeMute ; <nl> bool m_muted ; <nl> int m_soundMode ; <nl> - bool m_streamsPlaying ; <nl> + bool m_streamsPlaying ; <nl> } ; <nl> mmm a / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioAEHALIOS . h <nl> ppp b / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioAEHALIOS . h <nl> class CCoreAudioUnit <nl> public : <nl> CCoreAudioUnit ( ) ; <nl> virtual ~ CCoreAudioUnit ( ) ; <nl> - <nl> + <nl> virtual bool Open ( AUGraph audioGraph , AudioComponentDescription desc ) ; <nl> virtual bool Open ( AUGraph audioGraph , OSType type , OSType subType , OSType manufacturer ) ; <nl> virtual void Close ( ) ; <nl> virtual bool SetInputSource ( ICoreAudioSource * pSource ) ; <nl> virtual bool IsInitialized ( ) { return m_Initialized ; } <nl> - virtual bool GetFormat ( AudioStreamBasicDescription * pDesc , AudioUnitScope scope , AudioUnitElement bus ) ; <nl> + virtual bool GetFormat ( AudioStreamBasicDescription * pDesc , AudioUnitScope scope , AudioUnitElement bus ) ; <nl> virtual bool SetFormat ( AudioStreamBasicDescription * pDesc , AudioUnitScope scope , AudioUnitElement bus ) ; <nl> virtual bool SetMaxFramesPerSlice ( UInt32 maxFrames ) ; <nl> virtual void GetFormatDesc ( AEAudioFormat format , AudioStreamBasicDescription * streamDesc ) ; <nl> class CCoreAudioUnit <nl> protected : <nl> bool SetRenderProc ( ) ; <nl> bool RemoveRenderProc ( ) ; <nl> - static OSStatus RenderCallback ( void * inRefCon , <nl> - AudioUnitRenderActionFlags * ioActionFlags , <nl> - const AudioTimeStamp * inTimeStamp , <nl> - UInt32 inBusNumber , <nl> - UInt32 inNumberFrames , <nl> + static OSStatus RenderCallback ( void * inRefCon , <nl> + AudioUnitRenderActionFlags * ioActionFlags , <nl> + const AudioTimeStamp * inTimeStamp , <nl> + UInt32 inBusNumber , <nl> + UInt32 inNumberFrames , <nl> AudioBufferList * ioData ) ; <nl> ICoreAudioSource * m_pSource ; <nl> AudioUnit m_audioUnit ; <nl> class CAUOutputDevice : public CCoreAudioUnit <nl> CAUOutputDevice ( ) ; <nl> virtual ~ CAUOutputDevice ( ) ; <nl> UInt32 GetBufferFrameSize ( ) ; <nl> - <nl> + <nl> / * <nl> Float32 GetCurrentVolume ( ) ; <nl> bool SetCurrentVolume ( Float32 vol ) ; <nl> class CAUMultiChannelMixer : public CAUOutputDevice <nl> public : <nl> CAUMultiChannelMixer ( ) ; <nl> virtual ~ CAUMultiChannelMixer ( ) ; <nl> - <nl> + <nl> UInt32 GetInputBusCount ( ) ; <nl> bool SetInputBusFormat ( UInt32 busCount , AudioStreamBasicDescription * pFormat ) ; <nl> bool SetInputBusCount ( UInt32 busCount ) ; <nl> UInt32 GetOutputBusCount ( ) ; <nl> bool SetOutputBusCount ( UInt32 busCount ) ; <nl> - <nl> + <nl> Float32 GetCurrentVolume ( ) ; <nl> bool SetCurrentVolume ( Float32 vol ) ; <nl> } ; <nl> class CCoreAudioGraph <nl> { <nl> private : <nl> AUGraph m_audioGraph ; <nl> - <nl> + <nl> CAUOutputDevice * m_audioUnit ; <nl> CAUMultiChannelMixer * m_mixerUnit ; <nl> CAUOutputDevice * m_inputUnit ; <nl> - <nl> + <nl> int m_reservedBusNumber [ MAX_CONNECTION_LIMIT ] ; <nl> bool m_initialized ; <nl> bool m_allowMixing ; <nl> - <nl> + <nl> typedef std : : list < CAUOutputDevice * > AUUnitList ; <nl> AUUnitList m_auUnitList ; <nl> - <nl> + <nl> public : <nl> CCoreAudioGraph ( ) ; <nl> ~ CCoreAudioGraph ( ) ; <nl> - <nl> + <nl> bool Open ( ICoreAudioSource * pSource , AEAudioFormat & format , bool allowMixing ) ; <nl> bool Close ( ) ; <nl> bool Start ( ) ; <nl> class CCoreAudioAEHALIOS : public ICoreAudioAEHAL <nl> unsigned int m_NumLatencyFrames ; <nl> unsigned int m_OutputBufferIndex ; <nl> CCoreAudioAE * m_ae ; <nl> - <nl> + <nl> CCoreAudioAEHALIOS ( ) ; <nl> virtual ~ CCoreAudioAEHALIOS ( ) ; <nl> - <nl> + <nl> virtual bool InitializePCM ( ICoreAudioSource * pSource , AEAudioFormat & format , bool allowMixing ) ; <nl> virtual bool InitializePCMEncoded ( ICoreAudioSource * pSource , AEAudioFormat & format ) ; <nl> virtual bool Initialize ( ICoreAudioSource * ae , bool passThrough , AEAudioFormat & format , AEDataFormat rawDataFormat , std : : string & device ) ; <nl> mmm a / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioAEHALOSX . cpp <nl> ppp b / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioAEHALOSX . cpp <nl> bool CCoreAudioAEHALOSX : : InitializeEncoded ( AudioDeviceID outputDevice , AEAudioFo <nl> { <nl> / / check pcm output formats <nl> unsigned int bps = CAEUtil : : DataFormatToBits ( AE_FMT_S16NE ) ; <nl> - if ( desc . mFormat . mChannelsPerFrame = = m_initformat . m_channelLayout . Count ( ) & & <nl> + if ( desc . mFormat . mChannelsPerFrame = = m_initformat . m_channelLayout . Count ( ) & & <nl> desc . mFormat . mBitsPerChannel = = bps & & <nl> desc . mFormat . mSampleRate = = m_initformat . m_sampleRate ) <nl> { <nl> bool CCoreAudioAEHALOSX : : InitializeEncoded ( AudioDeviceID outputDevice , AEAudioFo <nl> / / check encoded formats <nl> if ( desc . mFormat . mFormatID = = kAudioFormat60958AC3 | | desc . mFormat . mFormatID = = ' IAC3 ' ) <nl> { <nl> - if ( desc . mFormat . mChannelsPerFrame = = m_initformat . m_channelLayout . Count ( ) & & <nl> + if ( desc . mFormat . mChannelsPerFrame = = m_initformat . m_channelLayout . Count ( ) & & <nl> desc . mFormat . mSampleRate = = m_initformat . m_sampleRate ) <nl> { <nl> outputFormat = desc . mFormat ; / / Select this format <nl> bool CCoreAudioAEHALOSX : : InitializeEncoded ( AudioDeviceID outputDevice , AEAudioFo <nl> } <nl> <nl> CLog : : Log ( LOGDEBUG , " CCoreAudioAEHALOSX : : InitializeEncoded : " <nl> - " Selected stream [ % u ] - id : 0x % 04X , Physical Format : % s " , <nl> + " Selected stream [ % u ] - id : 0x % 04X , Physical Format : % s " , <nl> m_OutputBufferIndex , ( uint ) outputStream , StreamDescriptionToString ( outputFormat , formatString ) ) ; <nl> <nl> / / TODO : Auto hogging sets this for us . Figure out how / when to turn it off or use it <nl> mmm a / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioGraph . h <nl> ppp b / xbmc / cores / AudioEngine / Engines / CoreAudio / CoreAudioGraph . h <nl> class CCoreAudioGraph <nl> public : <nl> CCoreAudioGraph ( ) ; <nl> ~ CCoreAudioGraph ( ) ; <nl> - <nl> + <nl> bool Open ( ICoreAudioSource * pSource , AEAudioFormat & format , AudioDeviceID deviceId , <nl> bool allowMixing , AudioChannelLayoutTag layoutTag ) ; <nl> bool Close ( ) ; <nl> class CCoreAudioGraph <nl> <nl> private : <nl> AUGraph m_audioGraph ; <nl> - <nl> + <nl> CAUOutputDevice * m_inputUnit ; <nl> CAUOutputDevice * m_audioUnit ; <nl> CAUMatrixMixer * m_mixerUnit ; <nl> - <nl> + <nl> int m_reservedBusNumber [ MAX_CONNECTION_LIMIT ] ; <nl> bool m_initialized ; <nl> AudioDeviceID m_deviceId ; <nl> mmm a / xbmc / cores / AudioEngine / Engines / CoreAudio / ICoreAudioAEHAL . h <nl> ppp b / xbmc / cores / AudioEngine / Engines / CoreAudio / ICoreAudioAEHAL . h <nl> class CAUOutputDevice ; <nl> * / <nl> class ICoreAudioAEHAL <nl> { <nl> - protected : <nl> + protected : <nl> ICoreAudioAEHAL ( ) { } <nl> virtual ~ ICoreAudioAEHAL ( ) { } <nl> <nl>
[ cosmetics ] - whitespaces
xbmc/xbmc
688eaf2662c9c06083f69e4a315fe9864834feb1
2012-08-14T20:53:12Z
new file mode 100644 <nl> index 0000000000 . . bb1d01ca88 <nl> mmm / dev / null <nl> ppp b / osquery / tables / system / darwin / ca_certs . h <nl> <nl> + / * <nl> + * Copyright ( c ) 2014 , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * <nl> + * / <nl> + <nl> + # include < map > <nl> + # include < vector > <nl> + <nl> + # include < CoreFoundation / CoreFoundation . h > <nl> + # include < Security / Security . h > <nl> + <nl> + # include " osquery / core / conversions . h " <nl> + <nl> + namespace osquery { <nl> + namespace tables { <nl> + <nl> + std : : string genKIDProperty ( const CFDataRef & ) ; <nl> + std : : string genCommonNameProperty ( const CFDataRef & ) ; <nl> + std : : string genAlgorithmProperty ( const CFDataRef & ) ; <nl> + <nl> + typedef std : : string ( * PropGenerator ) ( const CFDataRef & ) ; <nl> + typedef std : : pair < CFTypeRef , PropGenerator > Property ; <nl> + <nl> + extern const std : : vector < std : : string > kSystemKeychainPaths ; <nl> + extern const std : : vector < std : : string > kUserKeychainPaths ; <nl> + extern const std : : map < std : : string , Property > kCertificateProperties ; <nl> + <nl> + std : : string genKIDProperty ( const CFDataRef & kid ) ; <nl> + std : : string genCommonNameProperty ( const CFDataRef & ca ) ; <nl> + std : : string genAlgorithmProperty ( const CFDataRef & alg ) ; <nl> + std : : string genSHA1ForCertificate ( const SecCertificateRef & ca ) ; <nl> + <nl> + CFNumberRef CFNumberCreateCopy ( const CFNumberRef & number ) ; <nl> + CFDataRef CreatePropertyFromCertificate ( const SecCertificateRef & cert , <nl> + const CFTypeRef & oid ) ; <nl> + bool CertificateIsCA ( const SecCertificateRef & cert ) ; <nl> + <nl> + / / From SecCertificatePriv . h <nl> + typedef uint32_t SecKeyUsage ; <nl> + enum { <nl> + kSecKeyUsageUnspecified = 0 , <nl> + kSecKeyUsageDigitalSignature = 1 < < 0 , <nl> + kSecKeyUsageNonRepudiation = 1 < < 1 , <nl> + kSecKeyUsageContentCommitment = 1 < < 1 , <nl> + kSecKeyUsageKeyEncipherment = 1 < < 2 , <nl> + kSecKeyUsageDataEncipherment = 1 < < 3 , <nl> + kSecKeyUsageKeyAgreement = 1 < < 4 , <nl> + kSecKeyUsageKeyCertSign = 1 < < 5 , <nl> + kSecKeyUsageCRLSign = 1 < < 6 , <nl> + kSecKeyUsageEncipherOnly = 1 < < 7 , <nl> + kSecKeyUsageDecipherOnly = 1 < < 8 , <nl> + kSecKeyUsageCritical = 1 < < 31 , <nl> + kSecKeyUsageAll = 0x7FFFFFFF <nl> + } ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 0000000000 . . fee0a2811f <nl> mmm / dev / null <nl> ppp b / osquery / tables / system / darwin / ca_certs . mm <nl> <nl> + / * <nl> + * Copyright ( c ) 2014 , Facebook , Inc . <nl> + * All rights reserved . <nl> + * <nl> + * This source code is licensed under the BSD - style license found in the <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> + * of patent rights can be found in the PATENTS file in the same directory . <nl> + * <nl> + * / <nl> + <nl> + # include < osquery / core . h > <nl> + / / # include < osquery / logger . h > <nl> + # include < osquery / tables . h > <nl> + <nl> + # include " osquery / tables / system / darwin / ca_certs . h " <nl> + <nl> + namespace osquery { <nl> + namespace tables { <nl> + <nl> + bool genOSXAuthorities ( CFArrayRef & reference ) { <nl> + CFArrayRef keychain_certs ; <nl> + CFMutableDictionaryRef query ; <nl> + OSStatus status = errSecSuccess ; <nl> + <nl> + query = CFDictionaryCreateMutable ( NULL , <nl> + 0 , <nl> + & kCFTypeDictionaryKeyCallBacks , <nl> + & kCFTypeDictionaryValueCallBacks ) ; <nl> + CFDictionaryAddValue ( query , kSecClass , kSecClassCertificate ) ; <nl> + CFDictionaryAddValue ( query , kSecReturnRef , kCFBooleanTrue ) ; <nl> + / / This can be added to restrict results to x509v3 <nl> + / / CFDictionaryAddValue ( query , kSecAttrCertificateType , 0x03 ) ; <nl> + CFDictionaryAddValue ( query , kSecAttrCanVerify , kCFBooleanTrue ) ; <nl> + CFDictionaryAddValue ( query , kSecMatchLimit , kSecMatchLimitAll ) ; <nl> + <nl> + status = SecItemCopyMatching ( query , ( CFTypeRef * ) & keychain_certs ) ; <nl> + CFRelease ( query ) ; <nl> + <nl> + if ( status ! = errSecSuccess ) { <nl> + reference = NULL ; <nl> + return false ; <nl> + } <nl> + <nl> + / / Limit certificates to authorities ( kSecOIDBasicConstraints ) . <nl> + CFMutableArrayRef authorities ; <nl> + SecCertificateRef cert ; <nl> + <nl> + / / Store just the authority certificates . <nl> + authorities = CFArrayCreateMutable ( NULL , 0 , & kCFTypeArrayCallBacks ) ; <nl> + <nl> + / / For each certificate returned from the search , get the constraints prop . <nl> + for ( CFIndex i = 0 ; i < CFArrayGetCount ( keychain_certs ) ; i + + ) { <nl> + cert = ( SecCertificateRef ) CFArrayGetValueAtIndex ( keychain_certs , i ) ; <nl> + if ( CertificateIsCA ( cert ) ) { <nl> + CFArrayAppendValue ( authorities , cert ) ; <nl> + } <nl> + } <nl> + <nl> + reference = ( CFArrayRef ) authorities ; <nl> + CFRelease ( keychain_certs ) ; <nl> + return ( status = = errSecSuccess ) ; <nl> + } <nl> + <nl> + QueryData genCerts ( QueryContext & context ) { <nl> + QueryData results ; <nl> + CFArrayRef authorities = NULL ; <nl> + / / Keychains / certificate stores belonging to the OS . <nl> + if ( ! genOSXAuthorities ( authorities ) ) { <nl> + / / LOG ( ERROR ) < < " Could not find OSX Keychain Certificate Authorities . " ; <nl> + return results ; <nl> + } <nl> + <nl> + / / Must have returned an array of matching certificates . <nl> + if ( CFGetTypeID ( authorities ) ! = CFArrayGetTypeID ( ) ) { <nl> + / / LOG ( ERROR ) < < " Unknown certificate authorities type . " ; <nl> + return results ; <nl> + } <nl> + <nl> + / / Evaluate the certificate data , check for CA in Basic constraints . <nl> + unsigned int certificate_count = 0 ; <nl> + SecCertificateRef ca = NULL ; <nl> + CFDataRef property = NULL ; <nl> + <nl> + certificate_count = CFArrayGetCount ( ( CFArrayRef ) authorities ) ; <nl> + for ( CFIndex i = 0 ; i < certificate_count ; i + + ) { <nl> + Row r ; <nl> + ca = ( SecCertificateRef ) CFArrayGetValueAtIndex ( authorities , i ) ; <nl> + <nl> + / / Iterate through each selected certificate property . <nl> + for ( const auto & property_iterator : kCertificateProperties ) { <nl> + property = <nl> + CreatePropertyFromCertificate ( ca , property_iterator . second . first ) ; <nl> + if ( property = = NULL ) { <nl> + continue ; <nl> + } <nl> + / / Each property may be stored differently , apply a generator function . <nl> + r [ property_iterator . first ] = property_iterator . second . second ( property ) ; <nl> + CFRelease ( property ) ; <nl> + } <nl> + <nl> + r [ " sha1 " ] = genSHA1ForCertificate ( ca ) ; <nl> + results . push_back ( r ) ; <nl> + } <nl> + <nl> + CFRelease ( authorities ) ; <nl> + return results ; <nl> + } <nl> + } <nl> + } <nl> similarity index 62 % <nl> rename from osquery / tables / system / darwin / ca_certs . cpp <nl> rename to osquery / tables / system / darwin / ca_certs_utils . cpp <nl> mmm a / osquery / tables / system / darwin / ca_certs . cpp <nl> ppp b / osquery / tables / system / darwin / ca_certs_utils . cpp <nl> <nl> * All rights reserved . <nl> * <nl> * This source code is licensed under the BSD - style license found in the <nl> - * LICENSE file in the root directory of this source tree . An additional grant <nl> + * LICENSE file in the root directory of this source tree . An additional grant <nl> * of patent rights can be found in the PATENTS file in the same directory . <nl> * <nl> * / <nl> <nl> # include < string > <nl> # include < iomanip > <nl> <nl> - # include < stdio . h > <nl> - # include < stdlib . h > <nl> - <nl> # include < boost / lexical_cast . hpp > <nl> # include < boost / uuid / sha1 . hpp > <nl> <nl> - # include < CoreFoundation / CoreFoundation . h > <nl> - # include < Security / Security . h > <nl> - <nl> - # include < osquery / core . h > <nl> - # include < osquery / logger . h > <nl> - # include < osquery / tables . h > <nl> - <nl> - # include " osquery / core / conversions . h " <nl> + # include " osquery / tables / system / darwin / ca_certs . h " <nl> <nl> namespace osquery { <nl> namespace tables { <nl> <nl> - std : : string genKIDProperty ( const CFDataRef & ) ; <nl> - std : : string genCommonNameProperty ( const CFDataRef & ) ; <nl> - std : : string genAlgorithmProperty ( const CFDataRef & ) ; <nl> - <nl> - typedef std : : string ( * PropGenerator ) ( const CFDataRef & ) ; <nl> - typedef std : : pair < CFTypeRef , PropGenerator > Property ; <nl> - <nl> const std : : vector < std : : string > kSystemKeychainPaths = { <nl> " / System / Library / Keychains " , " / Library / Keychains " , <nl> } ; <nl> const std : : map < std : : string , Property > kCertificateProperties = { <nl> std : : make_pair ( kSecOIDAuthorityKeyIdentifier , genKIDProperty ) } , <nl> } ; <nl> <nl> - / / From SecCertificatePriv . h <nl> - typedef uint32_t SecKeyUsage ; <nl> - enum { <nl> - kSecKeyUsageUnspecified = 0 , <nl> - kSecKeyUsageDigitalSignature = 1 < < 0 , <nl> - kSecKeyUsageNonRepudiation = 1 < < 1 , <nl> - kSecKeyUsageContentCommitment = 1 < < 1 , <nl> - kSecKeyUsageKeyEncipherment = 1 < < 2 , <nl> - kSecKeyUsageDataEncipherment = 1 < < 3 , <nl> - kSecKeyUsageKeyAgreement = 1 < < 4 , <nl> - kSecKeyUsageKeyCertSign = 1 < < 5 , <nl> - kSecKeyUsageCRLSign = 1 < < 6 , <nl> - kSecKeyUsageEncipherOnly = 1 < < 7 , <nl> - kSecKeyUsageDecipherOnly = 1 < < 8 , <nl> - kSecKeyUsageCritical = 1 < < 31 , <nl> - kSecKeyUsageAll = 0x7FFFFFFF <nl> - } ; <nl> - <nl> std : : string genKIDProperty ( const CFDataRef & kid ) { <nl> CFDataRef kid_data = NULL ; <nl> CFDictionaryRef kid_dict = NULL ; <nl> - const char * kid_value = 0 ; <nl> + const char * kid_value = 0 ; <nl> <nl> / / Find the key identifier data within the property mess . <nl> for ( CFIndex i = 0 ; i < CFArrayGetCount ( ( CFArrayRef ) kid ) ; i + + ) { <nl> kid_dict = ( CFDictionaryRef ) CFArrayGetValueAtIndex ( ( CFArrayRef ) kid , i ) ; <nl> kid_value = <nl> - ( const char * ) CFDictionaryGetValue ( kid_dict , kSecPropertyKeyValue ) ; <nl> + ( const char * ) CFDictionaryGetValue ( kid_dict , kSecPropertyKeyValue ) ; <nl> <nl> if ( CFGetTypeID ( kid_value ) = = CFDataGetTypeID ( ) ) { <nl> kid_data = ( CFDataRef ) kid_value ; <nl> CFNumberRef CFNumberCreateCopy ( const CFNumberRef & number ) { <nl> return copy ; <nl> } <nl> <nl> - CFDataRef CreatePropertyFromCertificate ( const SecCertificateRef & cert , <nl> - const CFTypeRef & oid ) { <nl> + CFDataRef CreatePropertyFromCertificate ( const SecCertificateRef & cert , <nl> + const CFTypeRef & oid ) { <nl> CFDictionaryRef certificate_values ; <nl> CFDictionaryRef property_values ; <nl> CFDataRef property ; <nl> CFDataRef CreatePropertyFromCertificate ( const SecCertificateRef & cert , <nl> } else if ( CFGetTypeID ( property ) = = CFNumberGetTypeID ( ) ) { <nl> property = ( CFDataRef ) CFNumberCreateCopy ( ( CFNumberRef ) property ) ; <nl> } else { <nl> - LOG ( ERROR ) < < " This property type is unknown . . . " ; <nl> + / / LOG ( ERROR ) < < " This property type is unknown . . . " ; <nl> property = NULL ; <nl> } <nl> <nl> bool CertificateIsCA ( const SecCertificateRef & cert ) { <nl> CFRelease ( constraints ) ; <nl> return isCA ; <nl> } <nl> - <nl> - bool genOSXAuthorities ( CFArrayRef & reference ) { <nl> - CFArrayRef keychain_certs ; <nl> - CFMutableDictionaryRef query ; <nl> - OSStatus status = errSecSuccess ; <nl> - <nl> - query = CFDictionaryCreateMutable ( NULL , <nl> - 0 , <nl> - & kCFTypeDictionaryKeyCallBacks , <nl> - & kCFTypeDictionaryValueCallBacks ) ; <nl> - CFDictionaryAddValue ( query , kSecClass , kSecClassCertificate ) ; <nl> - CFDictionaryAddValue ( query , kSecReturnRef , kCFBooleanTrue ) ; <nl> - / / This can be added to restrict results to x509v3 <nl> - / / CFDictionaryAddValue ( query , kSecAttrCertificateType , 0x03 ) ; <nl> - CFDictionaryAddValue ( query , kSecAttrCanVerify , kCFBooleanTrue ) ; <nl> - CFDictionaryAddValue ( query , kSecMatchLimit , kSecMatchLimitAll ) ; <nl> - <nl> - status = SecItemCopyMatching ( query , ( CFTypeRef * ) & keychain_certs ) ; <nl> - CFRelease ( query ) ; <nl> - <nl> - if ( status ! = errSecSuccess ) { <nl> - reference = NULL ; <nl> - return false ; <nl> - } <nl> - <nl> - / / Limit certificates to authorities ( kSecOIDBasicConstraints ) . <nl> - CFMutableArrayRef authorities ; <nl> - SecCertificateRef cert ; <nl> - <nl> - / / Store just the authority certificates . <nl> - authorities = CFArrayCreateMutable ( NULL , 0 , & kCFTypeArrayCallBacks ) ; <nl> - <nl> - / / For each certificate returned from the search , get the constraints prop . <nl> - for ( CFIndex i = 0 ; i < CFArrayGetCount ( keychain_certs ) ; i + + ) { <nl> - cert = ( SecCertificateRef ) CFArrayGetValueAtIndex ( keychain_certs , i ) ; <nl> - if ( CertificateIsCA ( cert ) ) { <nl> - CFArrayAppendValue ( authorities , cert ) ; <nl> - } <nl> - } <nl> - <nl> - reference = ( CFArrayRef ) authorities ; <nl> - CFRelease ( keychain_certs ) ; <nl> - return ( status = = errSecSuccess ) ; <nl> - } <nl> - <nl> - QueryData genCerts ( QueryContext & context ) { <nl> - QueryData results ; <nl> - CFArrayRef authorities = NULL ; <nl> - / / Keychains / certificate stores belonging to the OS . <nl> - if ( ! genOSXAuthorities ( authorities ) ) { <nl> - LOG ( ERROR ) < < " Could not find OSX Keychain Certificate Authorities . " ; <nl> - return results ; <nl> - } <nl> - <nl> - / / Must have returned an array of matching certificates . <nl> - if ( CFGetTypeID ( authorities ) ! = CFArrayGetTypeID ( ) ) { <nl> - LOG ( ERROR ) < < " Unknown certificate authorities type . " ; <nl> - return results ; <nl> - } <nl> - <nl> - / / Evaluate the certificate data , check for CA in Basic constraints . <nl> - unsigned int certificate_count = 0 ; <nl> - SecCertificateRef ca = NULL ; <nl> - CFDataRef property = NULL ; <nl> - <nl> - certificate_count = CFArrayGetCount ( ( CFArrayRef ) authorities ) ; <nl> - for ( CFIndex i = 0 ; i < certificate_count ; i + + ) { <nl> - Row r ; <nl> - ca = ( SecCertificateRef ) CFArrayGetValueAtIndex ( authorities , i ) ; <nl> - <nl> - / / Iterate through each selected certificate property . <nl> - for ( const auto & property_iterator : kCertificateProperties ) { <nl> - property = <nl> - CreatePropertyFromCertificate ( ca , property_iterator . second . first ) ; <nl> - if ( property = = NULL ) { <nl> - continue ; <nl> - } <nl> - / / Each property may be stored differently , apply a generator function . <nl> - r [ property_iterator . first ] = property_iterator . second . second ( property ) ; <nl> - CFRelease ( property ) ; <nl> - } <nl> - <nl> - r [ " sha1 " ] = genSHA1ForCertificate ( ca ) ; <nl> - results . push_back ( r ) ; <nl> - } <nl> - <nl> - CFRelease ( authorities ) ; <nl> - return results ; <nl> - } <nl> } <nl> } <nl>
Fix ca_certs memory leak
osquery/osquery
8c6e45e9b587e881380cdceb9ec578e994ba7b3b
2014-12-25T20:49:45Z
mmm a / xbmc / filesystem / File . cpp <nl> ppp b / xbmc / filesystem / File . cpp <nl> CFileStreamBuffer : : pos_type CFileStreamBuffer : : seekoff ( <nl> std : : ios_base : : openmode mode ) <nl> { <nl> / / calculate relative offset <nl> - off_type pos = m_file - > GetPosition ( ) - ( egptr ( ) - gptr ( ) ) ; <nl> + off_type aheadbytes = ( egptr ( ) - gptr ( ) ) ; <nl> + off_type pos = m_file - > GetPosition ( ) - aheadbytes ; <nl> off_type offset2 ; <nl> if ( way = = std : : ios_base : : cur ) <nl> offset2 = offset ; <nl> CFileStreamBuffer : : pos_type CFileStreamBuffer : : seekoff ( <nl> <nl> int64_t position = - 1 ; <nl> if ( way = = std : : ios_base : : cur ) <nl> - position = m_file - > Seek ( offset , SEEK_CUR ) ; <nl> + position = m_file - > Seek ( offset - aheadbytes , SEEK_CUR ) ; <nl> else if ( way = = std : : ios_base : : end ) <nl> position = m_file - > Seek ( offset , SEEK_END ) ; <nl> else <nl>
Subtract readahead when seeking ( SEEK_CUR ) outside of buffer area
xbmc/xbmc
c1e80ea2a54e2abf82fb3b1049f0d9bf597247b6
2015-09-23T14:14:24Z
mmm a / Telegram / SourceFiles / apiwrap . cpp <nl> ppp b / Telegram / SourceFiles / apiwrap . cpp <nl> void ApiWrap : : requestContacts ( ) { <nl> <nl> const auto userId = contact . c_contact ( ) . vuser_id . v ; <nl> if ( userId = = _session - > userId ( ) ) { <nl> - Auth ( ) . user ( ) - > setContactStatus ( <nl> + _session - > user ( ) - > setContactStatus ( <nl> UserData : : ContactStatus : : Contact ) ; <nl> } <nl> } <nl> void ApiWrap : : gotChatFull ( PeerData * peer , const MTPmessages_ChatFull & result , mt <nl> channel - > setKickedCount ( f . has_kicked_count ( ) ? f . vkicked_count . v : 0 ) ; <nl> channel - > setInviteLink ( ( f . vexported_invite . type ( ) = = mtpc_chatInviteExported ) ? qs ( f . vexported_invite . c_chatInviteExported ( ) . vlink ) : QString ( ) ) ; <nl> if ( const auto history = App : : historyLoaded ( channel - > id ) ) { <nl> + history - > clearUpTill ( f . vavailable_min_id . v ) ; <nl> history - > applyDialogFields ( <nl> f . vunread_count . v , <nl> f . vread_inbox_max_id . v , <nl> void ApiWrap : : requestSelfParticipant ( ChannelData * channel ) { <nl> channel - > inviter = _session - > userId ( ) ; <nl> channel - > inviteDate = channel - > date ; <nl> if ( channel - > mgInfo ) { <nl> - channel - > mgInfo - > creator = Auth ( ) . user ( ) ; <nl> + channel - > mgInfo - > creator = _session - > user ( ) ; <nl> } <nl> } break ; <nl> case mtpc_channelParticipantAdmin : { <nl> void ApiWrap : : updatePrivacyLastSeens ( const QVector < MTPPrivacyRule > & rules ) { <nl> } <nl> <nl> auto now = unixtime ( ) ; <nl> - App : : enumerateUsers ( [ & ] ( UserData * user ) { <nl> + _session - > data ( ) . enumerateUsers ( [ & ] ( UserData * user ) { <nl> if ( user - > isSelf ( ) | | user - > loadedStatus ! = PeerData : : FullLoaded ) { <nl> return ; <nl> } <nl> void ApiWrap : : saveDraftsToCloud ( ) { <nl> if ( cloudDraft & & cloudDraft - > saveRequestId ) { <nl> request ( base : : take ( cloudDraft - > saveRequestId ) ) . cancel ( ) ; <nl> } <nl> - if ( ! Auth ( ) . supportMode ( ) ) { <nl> + if ( ! _session - > supportMode ( ) ) { <nl> cloudDraft = history - > createCloudDraft ( localDraft ) ; <nl> } else if ( ! cloudDraft ) { <nl> cloudDraft = history - > createCloudDraft ( nullptr ) ; <nl> void ApiWrap : : gotWebPages ( ChannelData * channel , const MTPmessages_Messages & msgs <nl> } <nl> <nl> for ( const auto [ position , index ] : indices ) { <nl> - const auto item = App : : histories ( ) . addNewMessage ( <nl> + const auto item = _session - > data ( ) . addNewMessage ( <nl> v - > at ( index ) , <nl> NewMessageExisting ) ; <nl> if ( item ) { <nl> void ApiWrap : : applyUpdatesNoPtsCheck ( const MTPUpdates & updates ) { <nl> const auto peerUserId = d . is_out ( ) <nl> ? d . vuser_id <nl> : MTP_int ( _session - > userId ( ) ) ; <nl> - App : : histories ( ) . addNewMessage ( <nl> + _session - > data ( ) . addNewMessage ( <nl> MTP_message ( <nl> MTP_flags ( flags ) , <nl> d . vid , <nl> void ApiWrap : : applyUpdatesNoPtsCheck ( const MTPUpdates & updates ) { <nl> case mtpc_updateShortChatMessage : { <nl> auto & d = updates . c_updateShortChatMessage ( ) ; <nl> auto flags = mtpCastFlags ( d . vflags . v ) | MTPDmessage : : Flag : : f_from_id ; <nl> - App : : histories ( ) . addNewMessage ( <nl> + _session - > data ( ) . addNewMessage ( <nl> MTP_message ( <nl> MTP_flags ( flags ) , <nl> d . vid , <nl> void ApiWrap : : applyUpdateNoPtsCheck ( const MTPUpdate & update ) { <nl> } <nl> } <nl> if ( needToAdd ) { <nl> - App : : histories ( ) . addNewMessage ( d . vmessage , NewMessageUnread ) ; <nl> + _session - > data ( ) . addNewMessage ( d . vmessage , NewMessageUnread ) ; <nl> } <nl> } break ; <nl> <nl> void ApiWrap : : applyUpdateNoPtsCheck ( const MTPUpdate & update ) { <nl> } <nl> } <nl> if ( needToAdd ) { <nl> - App : : histories ( ) . addNewMessage ( d . vmessage , NewMessageUnread ) ; <nl> + _session - > data ( ) . addNewMessage ( d . vmessage , NewMessageUnread ) ; <nl> } <nl> } break ; <nl> <nl> void ApiWrap : : requestMessageAfterDate ( <nl> / / App : : feedUsers ( data . vusers ) ; <nl> / / App : : feedChats ( data . vchats ) ; <nl> / / for ( const auto & msg : messages ) { <nl> - / / if ( const auto item = App : : histories ( ) . addNewMessage ( msg , type ) ) { <nl> + / / if ( const auto item = _session - > data ( ) . addNewMessage ( msg , type ) ) { <nl> / / if ( item - > date ( ) > = offsetDate | | true ) { <nl> / / callback ( item - > position ( ) ) ; <nl> / / return ; <nl> void ApiWrap : : userPhotosDone ( <nl> / / if ( ! messages . empty ( ) ) { <nl> / / ids . reserve ( messages . size ( ) ) ; <nl> / / for ( const auto & msg : messages ) { <nl> - / / if ( const auto item = App : : histories ( ) . addNewMessage ( msg , type ) ) { <nl> + / / if ( const auto item = _session - > data ( ) . addNewMessage ( msg , type ) ) { <nl> / / const auto position = item - > position ( ) ; <nl> / / if ( tooLargePosition ( position ) ) { <nl> / / accumulateTill ( noSkipRange . till , position ) ; <nl> void ApiWrap : : photoUploadReady ( <nl> } <nl> <nl> void ApiWrap : : clearPeerPhoto ( not_null < PhotoData * > photo ) { <nl> - const auto self = Auth ( ) . user ( ) ; <nl> + const auto self = _session - > user ( ) ; <nl> if ( self - > userpicPhotoId ( ) = = photo - > id ) { <nl> request ( MTPphotos_UpdateProfilePhoto ( <nl> MTP_inputPhotoEmpty ( ) <nl> void ApiWrap : : saveSelfBio ( const QString & text , FnMut < void ( ) > done ) { <nl> _saveBioRequestId = 0 ; <nl> <nl> App : : feedUsers ( MTP_vector < MTPUser > ( 1 , result ) ) ; <nl> - Auth ( ) . user ( ) - > setAbout ( _saveBioText ) ; <nl> + _session - > user ( ) - > setAbout ( _saveBioText ) ; <nl> if ( _saveBioDone ) { <nl> _saveBioDone ( ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / app . cpp <nl> ppp b / Telegram / SourceFiles / app . cpp <nl> For license and copyright information please follow this link : <nl> namespace { <nl> App : : LaunchState _launchState = App : : Launched ; <nl> <nl> - std : : unordered_map < PeerId , std : : unique_ptr < PeerData > > peersData ; <nl> - <nl> using DependentItemsSet = OrderedSet < HistoryItem * > ; <nl> using DependentItems = QMap < HistoryItem * , DependentItemsSet > ; <nl> DependentItems dependentItems ; <nl> <nl> - Histories histories ; <nl> - <nl> using MsgsData = QHash < MsgId , HistoryItem * > ; <nl> MsgsData msgsData ; <nl> using ChannelMsgsData = QMap < ChannelId , MsgsData > ; <nl> namespace App { <nl> return nullptr ; <nl> } <nl> <nl> - namespace { <nl> - / / we should get a full restriction in " { fulltype } : { reason } " format and we <nl> - / / need to find a " - all " tag in { fulltype } , otherwise ignore this restriction <nl> - QString extractRestrictionReason ( const QString & fullRestriction ) { <nl> - int fullTypeEnd = fullRestriction . indexOf ( ' : ' ) ; <nl> - if ( fullTypeEnd < = 0 ) { <nl> - return QString ( ) ; <nl> - } <nl> - <nl> - / / { fulltype } is in " { type } - { tag } - { tag } - { tag } " format <nl> - / / if we find " all " tag we return the restriction string <nl> - auto typeTags = fullRestriction . mid ( 0 , fullTypeEnd ) . split ( ' - ' ) . mid ( 1 ) ; <nl> - # ifndef OS_MAC_STORE <nl> - auto restrictionApplies = typeTags . contains ( qsl ( " all " ) ) ; <nl> - # else / / OS_MAC_STORE <nl> - auto restrictionApplies = typeTags . contains ( qsl ( " all " ) ) | | typeTags . contains ( qsl ( " ios " ) ) ; <nl> - # endif / / OS_MAC_STORE <nl> - if ( restrictionApplies ) { <nl> - return fullRestriction . midRef ( fullTypeEnd + 1 ) . trimmed ( ) . toString ( ) ; <nl> - } <nl> - return QString ( ) ; <nl> - } <nl> - } <nl> - <nl> UserData * feedUser ( const MTPUser & user ) { <nl> - UserData * data = nullptr ; <nl> - bool minimal = false ; <nl> - const MTPUserStatus * status = 0 , emptyStatus = MTP_userStatusEmpty ( ) ; <nl> - <nl> - Notify : : PeerUpdate update ; <nl> - using UpdateFlag = Notify : : PeerUpdate : : Flag ; <nl> - <nl> - switch ( user . type ( ) ) { <nl> - case mtpc_userEmpty : { <nl> - auto & d = user . c_userEmpty ( ) ; <nl> - <nl> - auto peer = peerFromUser ( d . vid . v ) ; <nl> - data = App : : user ( peer ) ; <nl> - auto canShareThisContact = data - > canShareThisContactFast ( ) ; <nl> - <nl> - data - > input = MTP_inputPeerUser ( d . vid , MTP_long ( 0 ) ) ; <nl> - data - > inputUser = MTP_inputUser ( d . vid , MTP_long ( 0 ) ) ; <nl> - data - > setName ( lang ( lng_deleted ) , QString ( ) , QString ( ) , QString ( ) ) ; <nl> - data - > setPhoto ( MTP_userProfilePhotoEmpty ( ) ) ; <nl> - / / data - > setFlags ( MTPDuser_ClientFlag : : f_inaccessible | 0 ) ; <nl> - data - > setFlags ( MTPDuser : : Flag : : f_deleted ) ; <nl> - if ( ! data - > phone ( ) . isEmpty ( ) ) { <nl> - data - > setPhone ( QString ( ) ) ; <nl> - update . flags | = UpdateFlag : : UserPhoneChanged ; <nl> - } <nl> - data - > setBotInfoVersion ( - 1 ) ; <nl> - status = & emptyStatus ; <nl> - data - > setContactStatus ( UserData : : ContactStatus : : PhoneUnknown ) ; <nl> - <nl> - if ( canShareThisContact ! = data - > canShareThisContactFast ( ) ) { <nl> - update . flags | = UpdateFlag : : UserCanShareContact ; <nl> - } <nl> - } break ; <nl> - case mtpc_user : { <nl> - auto & d = user . c_user ( ) ; <nl> - minimal = d . is_min ( ) ; <nl> - <nl> - auto peer = peerFromUser ( d . vid . v ) ; <nl> - data = App : : user ( peer ) ; <nl> - auto canShareThisContact = data - > canShareThisContactFast ( ) ; <nl> - if ( minimal ) { <nl> - auto mask = 0 <nl> - / / | MTPDuser_ClientFlag : : f_inaccessible <nl> - | MTPDuser : : Flag : : f_deleted ; <nl> - data - > setFlags ( ( data - > flags ( ) & ~ mask ) | ( d . vflags . v & mask ) ) ; <nl> - } else { <nl> - data - > setFlags ( d . vflags . v ) ; <nl> - if ( d . is_self ( ) ) { <nl> - data - > input = MTP_inputPeerSelf ( ) ; <nl> - data - > inputUser = MTP_inputUserSelf ( ) ; <nl> - } else if ( ! d . has_access_hash ( ) ) { <nl> - data - > input = MTP_inputPeerUser ( d . vid , MTP_long ( data - > accessHash ( ) ) ) ; <nl> - data - > inputUser = MTP_inputUser ( d . vid , MTP_long ( data - > accessHash ( ) ) ) ; <nl> - } else { <nl> - data - > input = MTP_inputPeerUser ( d . vid , d . vaccess_hash ) ; <nl> - data - > inputUser = MTP_inputUser ( d . vid , d . vaccess_hash ) ; <nl> - } <nl> - if ( d . is_restricted ( ) ) { <nl> - data - > setRestrictionReason ( extractRestrictionReason ( qs ( d . vrestriction_reason ) ) ) ; <nl> - } else { <nl> - data - > setRestrictionReason ( QString ( ) ) ; <nl> - } <nl> - } <nl> - if ( d . is_deleted ( ) ) { <nl> - if ( ! data - > phone ( ) . isEmpty ( ) ) { <nl> - data - > setPhone ( QString ( ) ) ; <nl> - update . flags | = UpdateFlag : : UserPhoneChanged ; <nl> - } <nl> - data - > setName ( lang ( lng_deleted ) , QString ( ) , QString ( ) , QString ( ) ) ; <nl> - data - > setPhoto ( MTP_userProfilePhotoEmpty ( ) ) ; <nl> - status = & emptyStatus ; <nl> - } else { <nl> - / / apply first_name and last_name from minimal user only if we don ' t have <nl> - / / local values for first name and last name already , otherwise skip <nl> - bool noLocalName = data - > firstName . isEmpty ( ) & & data - > lastName . isEmpty ( ) ; <nl> - QString fname = ( ! minimal | | noLocalName ) ? ( d . has_first_name ( ) ? TextUtilities : : SingleLine ( qs ( d . vfirst_name ) ) : QString ( ) ) : data - > firstName ; <nl> - QString lname = ( ! minimal | | noLocalName ) ? ( d . has_last_name ( ) ? TextUtilities : : SingleLine ( qs ( d . vlast_name ) ) : QString ( ) ) : data - > lastName ; <nl> - <nl> - QString phone = minimal ? data - > phone ( ) : ( d . has_phone ( ) ? qs ( d . vphone ) : QString ( ) ) ; <nl> - QString uname = minimal ? data - > username : ( d . has_username ( ) ? TextUtilities : : SingleLine ( qs ( d . vusername ) ) : QString ( ) ) ; <nl> - <nl> - bool phoneChanged = ( data - > phone ( ) ! = phone ) ; <nl> - if ( phoneChanged ) { <nl> - data - > setPhone ( phone ) ; <nl> - update . flags | = UpdateFlag : : UserPhoneChanged ; <nl> - } <nl> - bool nameChanged = ( data - > firstName ! = fname ) | | ( data - > lastName ! = lname ) ; <nl> - <nl> - bool showPhone = ! isServiceUser ( data - > id ) <nl> - & & ! d . is_self ( ) <nl> - & & ! d . is_contact ( ) <nl> - & & ! d . is_mutual_contact ( ) ; <nl> - bool showPhoneChanged = ! isServiceUser ( data - > id ) <nl> - & & ! d . is_self ( ) <nl> - & & ( ( showPhone <nl> - & & data - > contactStatus ( ) = = UserData : : ContactStatus : : Contact ) <nl> - | | ( ! showPhone <nl> - & & data - > contactStatus ( ) = = UserData : : ContactStatus : : CanAdd ) ) ; <nl> - if ( minimal ) { <nl> - showPhoneChanged = false ; <nl> - showPhone = ! isServiceUser ( data - > id ) <nl> - & & ( data - > id ! = Auth ( ) . userPeerId ( ) ) <nl> - & & ( data - > contactStatus ( ) = = UserData : : ContactStatus : : CanAdd ) ; <nl> - } <nl> - <nl> - / / see also Local : : readPeer <nl> - <nl> - const auto pname = ( showPhoneChanged | | phoneChanged | | nameChanged ) <nl> - ? ( ( showPhone & & ! phone . isEmpty ( ) ) <nl> - ? formatPhone ( phone ) <nl> - : QString ( ) ) <nl> - : data - > nameOrPhone ; <nl> - <nl> - if ( ! minimal & & d . is_self ( ) & & uname ! = data - > username ) { <nl> - CrashReports : : SetAnnotation ( " Username " , uname ) ; <nl> - } <nl> - data - > setName ( fname , lname , pname , uname ) ; <nl> - if ( d . has_photo ( ) ) { <nl> - data - > setPhoto ( d . vphoto ) ; <nl> - } else { <nl> - data - > setPhoto ( MTP_userProfilePhotoEmpty ( ) ) ; <nl> - } <nl> - if ( d . has_access_hash ( ) ) { <nl> - data - > setAccessHash ( d . vaccess_hash . v ) ; <nl> - } <nl> - status = d . has_status ( ) ? & d . vstatus : & emptyStatus ; <nl> - } <nl> - if ( ! minimal ) { <nl> - if ( d . has_bot_info_version ( ) ) { <nl> - data - > setBotInfoVersion ( d . vbot_info_version . v ) ; <nl> - data - > botInfo - > readsAllHistory = d . is_bot_chat_history ( ) ; <nl> - if ( data - > botInfo - > cantJoinGroups ! = d . is_bot_nochats ( ) ) { <nl> - data - > botInfo - > cantJoinGroups = d . is_bot_nochats ( ) ; <nl> - update . flags | = UpdateFlag : : BotCanAddToGroups ; <nl> - } <nl> - data - > botInfo - > inlinePlaceholder = d . has_bot_inline_placeholder ( ) ? ' _ ' + qs ( d . vbot_inline_placeholder ) : QString ( ) ; <nl> - } else { <nl> - data - > setBotInfoVersion ( - 1 ) ; <nl> - } <nl> - data - > setContactStatus ( ( d . is_contact ( ) | | d . is_mutual_contact ( ) ) <nl> - ? UserData : : ContactStatus : : Contact <nl> - : data - > phone ( ) . isEmpty ( ) <nl> - ? UserData : : ContactStatus : : PhoneUnknown <nl> - : UserData : : ContactStatus : : CanAdd ) ; <nl> - } <nl> - <nl> - if ( canShareThisContact ! = data - > canShareThisContactFast ( ) ) { <nl> - update . flags | = UpdateFlag : : UserCanShareContact ; <nl> - } <nl> - } break ; <nl> - } <nl> - <nl> - if ( ! data ) { <nl> - return nullptr ; <nl> - } <nl> - <nl> - if ( minimal ) { <nl> - if ( data - > loadedStatus = = PeerData : : NotLoaded ) { <nl> - data - > loadedStatus = PeerData : : MinimalLoaded ; <nl> - } <nl> - } else if ( data - > loadedStatus ! = PeerData : : FullLoaded <nl> - & & ( ! data - > isSelf ( ) | | ! data - > phone ( ) . isEmpty ( ) ) ) { <nl> - data - > loadedStatus = PeerData : : FullLoaded ; <nl> - } <nl> - <nl> - if ( status & & ! minimal ) { <nl> - const auto oldOnlineTill = data - > onlineTill ; <nl> - const auto newOnlineTill = ApiWrap : : OnlineTillFromStatus ( <nl> - * status , <nl> - oldOnlineTill ) ; <nl> - if ( oldOnlineTill ! = newOnlineTill ) { <nl> - data - > onlineTill = newOnlineTill ; <nl> - update . flags | = UpdateFlag : : UserOnlineChanged ; <nl> - } <nl> - } <nl> - <nl> - if ( data - > contactStatus ( ) = = UserData : : ContactStatus : : PhoneUnknown <nl> - & & ! data - > phone ( ) . isEmpty ( ) <nl> - & & ! data - > isSelf ( ) ) { <nl> - data - > setContactStatus ( UserData : : ContactStatus : : CanAdd ) ; <nl> - } <nl> - if ( App : : main ( ) ) { <nl> - if ( update . flags ) { <nl> - update . peer = data ; <nl> - Notify : : peerUpdatedDelayed ( update ) ; <nl> - } <nl> - } <nl> - return data ; <nl> + return Auth ( ) . data ( ) . user ( user ) ; <nl> } <nl> <nl> UserData * feedUsers ( const MTPVector < MTPUser > & users ) { <nl> - UserData * result = nullptr ; <nl> - for_const ( auto & user , users . v ) { <nl> - if ( auto feededUser = feedUser ( user ) ) { <nl> - result = feededUser ; <nl> - } <nl> - } <nl> - <nl> - return result ; <nl> + return Auth ( ) . data ( ) . processUsers ( users ) ; <nl> } <nl> <nl> PeerData * feedChat ( const MTPChat & chat ) { <nl> - PeerData * data = nullptr ; <nl> - bool minimal = false ; <nl> - <nl> - Notify : : PeerUpdate update ; <nl> - using UpdateFlag = Notify : : PeerUpdate : : Flag ; <nl> - <nl> - switch ( chat . type ( ) ) { <nl> - case mtpc_chat : { <nl> - auto & d ( chat . c_chat ( ) ) ; <nl> - <nl> - data = App : : chat ( peerFromChat ( d . vid . v ) ) ; <nl> - auto cdata = data - > asChat ( ) ; <nl> - auto canEdit = cdata - > canEdit ( ) ; <nl> - <nl> - if ( cdata - > version < d . vversion . v ) { <nl> - cdata - > version = d . vversion . v ; <nl> - cdata - > invalidateParticipants ( ) ; <nl> - } <nl> - <nl> - data - > input = MTP_inputPeerChat ( d . vid ) ; <nl> - cdata - > setName ( qs ( d . vtitle ) ) ; <nl> - cdata - > setPhoto ( d . vphoto ) ; <nl> - cdata - > date = d . vdate . v ; <nl> - <nl> - if ( d . has_migrated_to ( ) & & d . vmigrated_to . type ( ) = = mtpc_inputChannel ) { <nl> - auto & c = d . vmigrated_to . c_inputChannel ( ) ; <nl> - auto channel = App : : channel ( peerFromChannel ( c . vchannel_id ) ) ; <nl> - channel - > addFlags ( MTPDchannel : : Flag : : f_megagroup ) ; <nl> - if ( ! channel - > access ) { <nl> - channel - > input = MTP_inputPeerChannel ( c . vchannel_id , c . vaccess_hash ) ; <nl> - channel - > inputChannel = d . vmigrated_to ; <nl> - channel - > access = d . vmigrated_to . c_inputChannel ( ) . vaccess_hash . v ; <nl> - } <nl> - bool updatedTo = ( cdata - > migrateToPtr ! = channel ) , updatedFrom = ( channel - > mgInfo - > migrateFromPtr ! = cdata ) ; <nl> - if ( updatedTo ) { <nl> - cdata - > migrateToPtr = channel ; <nl> - } <nl> - if ( updatedFrom ) { <nl> - channel - > mgInfo - > migrateFromPtr = cdata ; <nl> - if ( auto h = App : : historyLoaded ( cdata - > id ) ) { <nl> - if ( auto hto = App : : historyLoaded ( channel - > id ) ) { <nl> - if ( ! h - > isEmpty ( ) ) { <nl> - h - > unloadBlocks ( ) ; <nl> - } <nl> - if ( hto - > inChatList ( Dialogs : : Mode : : All ) & & h - > inChatList ( Dialogs : : Mode : : All ) ) { <nl> - App : : main ( ) - > removeDialog ( h ) ; <nl> - } <nl> - } <nl> - } <nl> - Notify : : migrateUpdated ( channel ) ; <nl> - update . flags | = UpdateFlag : : MigrationChanged ; <nl> - } <nl> - if ( updatedTo ) { <nl> - Notify : : migrateUpdated ( cdata ) ; <nl> - update . flags | = UpdateFlag : : MigrationChanged ; <nl> - } <nl> - } <nl> - <nl> - if ( ! ( cdata - > flags ( ) & MTPDchat : : Flag : : f_admins_enabled ) & & ( d . vflags . v & MTPDchat : : Flag : : f_admins_enabled ) ) { <nl> - cdata - > invalidateParticipants ( ) ; <nl> - } <nl> - cdata - > setFlags ( d . vflags . v ) ; <nl> - <nl> - cdata - > count = d . vparticipants_count . v ; <nl> - if ( canEdit ! = cdata - > canEdit ( ) ) { <nl> - update . flags | = UpdateFlag : : ChatCanEdit ; <nl> - } <nl> - } break ; <nl> - case mtpc_chatForbidden : { <nl> - auto & d ( chat . c_chatForbidden ( ) ) ; <nl> - <nl> - data = App : : chat ( peerFromChat ( d . vid . v ) ) ; <nl> - auto cdata = data - > asChat ( ) ; <nl> - auto canEdit = cdata - > canEdit ( ) ; <nl> - <nl> - data - > input = MTP_inputPeerChat ( d . vid ) ; <nl> - cdata - > setName ( qs ( d . vtitle ) ) ; <nl> - cdata - > setPhoto ( MTP_chatPhotoEmpty ( ) ) ; <nl> - cdata - > date = 0 ; <nl> - cdata - > count = - 1 ; <nl> - cdata - > invalidateParticipants ( ) ; <nl> - cdata - > setFlags ( MTPDchat_ClientFlag : : f_forbidden | 0 ) ; <nl> - if ( canEdit ! = cdata - > canEdit ( ) ) { <nl> - update . flags | = UpdateFlag : : ChatCanEdit ; <nl> - } <nl> - } break ; <nl> - case mtpc_channel : { <nl> - const auto & d = chat . c_channel ( ) ; <nl> - <nl> - const auto peerId = peerFromChannel ( d . vid . v ) ; <nl> - minimal = d . is_min ( ) ; <nl> - if ( minimal ) { <nl> - data = App : : channelLoaded ( peerId ) ; <nl> - if ( ! data ) { <nl> - / / Can ' t apply minimal to a not loaded channel . <nl> - / / Need to make getDifference . <nl> - return nullptr ; <nl> - } <nl> - } else { <nl> - data = App : : channel ( peerId ) ; <nl> - const auto accessHash = d . has_access_hash ( ) <nl> - ? d . vaccess_hash <nl> - : MTP_long ( 0 ) ; <nl> - data - > input = MTP_inputPeerChannel ( d . vid , accessHash ) ; <nl> - } <nl> - <nl> - const auto cdata = data - > asChannel ( ) ; <nl> - const auto wasInChannel = cdata - > amIn ( ) ; <nl> - const auto canViewAdmins = cdata - > canViewAdmins ( ) ; <nl> - const auto canViewMembers = cdata - > canViewMembers ( ) ; <nl> - const auto canAddMembers = cdata - > canAddMembers ( ) ; <nl> - <nl> - if ( d . has_participants_count ( ) ) { <nl> - cdata - > setMembersCount ( d . vparticipants_count . v ) ; <nl> - } <nl> - if ( minimal ) { <nl> - auto mask = 0 <nl> - | MTPDchannel : : Flag : : f_broadcast <nl> - | MTPDchannel : : Flag : : f_verified <nl> - | MTPDchannel : : Flag : : f_megagroup <nl> - | MTPDchannel : : Flag : : f_democracy <nl> - | MTPDchannel_ClientFlag : : f_forbidden ; <nl> - cdata - > setFlags ( ( cdata - > flags ( ) & ~ mask ) | ( d . vflags . v & mask ) ) ; <nl> - } else { <nl> - if ( d . has_admin_rights ( ) ) { <nl> - cdata - > setAdminRights ( d . vadmin_rights ) ; <nl> - } else if ( cdata - > hasAdminRights ( ) ) { <nl> - cdata - > setAdminRights ( MTP_channelAdminRights ( MTP_flags ( 0 ) ) ) ; <nl> - } <nl> - if ( d . has_banned_rights ( ) ) { <nl> - cdata - > setRestrictedRights ( d . vbanned_rights ) ; <nl> - } else if ( cdata - > hasRestrictions ( ) ) { <nl> - cdata - > setRestrictedRights ( MTP_channelBannedRights ( MTP_flags ( 0 ) , MTP_int ( 0 ) ) ) ; <nl> - } <nl> - cdata - > inputChannel = MTP_inputChannel ( d . vid , d . vaccess_hash ) ; <nl> - cdata - > access = d . vaccess_hash . v ; <nl> - cdata - > date = d . vdate . v ; <nl> - if ( cdata - > version < d . vversion . v ) { <nl> - cdata - > version = d . vversion . v ; <nl> - } <nl> - if ( d . is_restricted ( ) ) { <nl> - cdata - > setRestrictionReason ( extractRestrictionReason ( qs ( d . vrestriction_reason ) ) ) ; <nl> - } else { <nl> - cdata - > setRestrictionReason ( QString ( ) ) ; <nl> - } <nl> - cdata - > setFlags ( d . vflags . v ) ; <nl> - / / if ( d . has_feed_id ( ) ) { / / # feed <nl> - / / cdata - > setFeed ( Auth ( ) . data ( ) . feed ( d . vfeed_id . v ) ) ; <nl> - / / } else { <nl> - / / cdata - > clearFeed ( ) ; <nl> - / / } <nl> - } <nl> - <nl> - QString uname = d . has_username ( ) ? TextUtilities : : SingleLine ( qs ( d . vusername ) ) : QString ( ) ; <nl> - cdata - > setName ( qs ( d . vtitle ) , uname ) ; <nl> - <nl> - cdata - > setPhoto ( d . vphoto ) ; <nl> - <nl> - if ( wasInChannel ! = cdata - > amIn ( ) ) { <nl> - update . flags | = UpdateFlag : : ChannelAmIn ; <nl> - } <nl> - if ( canViewAdmins ! = cdata - > canViewAdmins ( ) <nl> - | | canViewMembers ! = cdata - > canViewMembers ( ) <nl> - | | canAddMembers ! = cdata - > canAddMembers ( ) ) { <nl> - update . flags | = UpdateFlag : : ChannelRightsChanged ; <nl> - } <nl> - } break ; <nl> - case mtpc_channelForbidden : { <nl> - auto & d ( chat . c_channelForbidden ( ) ) ; <nl> - <nl> - auto peerId = peerFromChannel ( d . vid . v ) ; <nl> - data = App : : channel ( peerId ) ; <nl> - data - > input = MTP_inputPeerChannel ( d . vid , d . vaccess_hash ) ; <nl> - <nl> - auto cdata = data - > asChannel ( ) ; <nl> - auto wasInChannel = cdata - > amIn ( ) ; <nl> - auto canViewAdmins = cdata - > canViewAdmins ( ) ; <nl> - auto canViewMembers = cdata - > canViewMembers ( ) ; <nl> - auto canAddMembers = cdata - > canAddMembers ( ) ; <nl> - <nl> - cdata - > inputChannel = MTP_inputChannel ( d . vid , d . vaccess_hash ) ; <nl> - <nl> - auto mask = mtpCastFlags ( MTPDchannelForbidden : : Flag : : f_broadcast | MTPDchannelForbidden : : Flag : : f_megagroup ) ; <nl> - cdata - > setFlags ( ( cdata - > flags ( ) & ~ mask ) | ( mtpCastFlags ( d . vflags ) & mask ) | MTPDchannel_ClientFlag : : f_forbidden ) ; <nl> - <nl> - if ( cdata - > hasAdminRights ( ) ) { <nl> - cdata - > setAdminRights ( MTP_channelAdminRights ( MTP_flags ( 0 ) ) ) ; <nl> - } <nl> - if ( cdata - > hasRestrictions ( ) ) { <nl> - cdata - > setRestrictedRights ( MTP_channelBannedRights ( MTP_flags ( 0 ) , MTP_int ( 0 ) ) ) ; <nl> - } <nl> - <nl> - cdata - > setName ( qs ( d . vtitle ) , QString ( ) ) ; <nl> - <nl> - cdata - > access = d . vaccess_hash . v ; <nl> - cdata - > setPhoto ( MTP_chatPhotoEmpty ( ) ) ; <nl> - cdata - > date = 0 ; <nl> - cdata - > setMembersCount ( 0 ) ; <nl> - <nl> - if ( wasInChannel ! = cdata - > amIn ( ) ) { <nl> - update . flags | = UpdateFlag : : ChannelAmIn ; <nl> - } <nl> - if ( canViewAdmins ! = cdata - > canViewAdmins ( ) <nl> - | | canViewMembers ! = cdata - > canViewMembers ( ) <nl> - | | canAddMembers ! = cdata - > canAddMembers ( ) ) { <nl> - update . flags | = UpdateFlag : : ChannelRightsChanged ; <nl> - } <nl> - } break ; <nl> - } <nl> - if ( ! data ) { <nl> - return nullptr ; <nl> - } <nl> - <nl> - if ( minimal ) { <nl> - if ( data - > loadedStatus = = PeerData : : NotLoaded ) { <nl> - data - > loadedStatus = PeerData : : MinimalLoaded ; <nl> - } <nl> - } else if ( data - > loadedStatus ! = PeerData : : FullLoaded ) { <nl> - data - > loadedStatus = PeerData : : FullLoaded ; <nl> - } <nl> - if ( update . flags ) { <nl> - update . peer = data ; <nl> - Notify : : peerUpdatedDelayed ( update ) ; <nl> - } <nl> - return data ; <nl> + return Auth ( ) . data ( ) . chat ( chat ) ; <nl> } <nl> <nl> PeerData * feedChats ( const MTPVector < MTPChat > & chats ) { <nl> - PeerData * result = nullptr ; <nl> - for_const ( auto & chat , chats . v ) { <nl> - if ( auto feededChat = feedChat ( chat ) ) { <nl> - result = feededChat ; <nl> - } <nl> - } <nl> - return result ; <nl> + return Auth ( ) . data ( ) . processChats ( chats ) ; <nl> } <nl> <nl> void feedParticipants ( const MTPChatParticipants & p , bool requestBotInfos ) { <nl> namespace App { <nl> indices . emplace ( ( uint64 ( uint32 ( msgId ) ) < < 32 ) | uint64 ( i ) , i ) ; <nl> } <nl> for ( const auto [ position , index ] : indices ) { <nl> - histories ( ) . addNewMessage ( msgs [ index ] , type ) ; <nl> + Auth ( ) . data ( ) . addNewMessage ( msgs [ index ] , type ) ; <nl> } <nl> } <nl> <nl> namespace App { <nl> } <nl> } <nl> <nl> - PeerData * peer ( const PeerId & id , PeerData : : LoadedStatus restriction ) { <nl> - if ( ! id ) { <nl> - return nullptr ; <nl> - } <nl> - <nl> - auto i = peersData . find ( id ) ; <nl> - if ( i = = peersData . cend ( ) ) { <nl> - auto newData = [ & ] ( ) - > std : : unique_ptr < PeerData > { <nl> - if ( peerIsUser ( id ) ) { <nl> - return std : : make_unique < UserData > ( id ) ; <nl> - } else if ( peerIsChat ( id ) ) { <nl> - return std : : make_unique < ChatData > ( id ) ; <nl> - } else if ( peerIsChannel ( id ) ) { <nl> - return std : : make_unique < ChannelData > ( id ) ; <nl> - } <nl> - Unexpected ( " Peer id type . " ) ; <nl> - } ( ) ; <nl> - <nl> - newData - > input = MTPinputPeer ( MTP_inputPeerEmpty ( ) ) ; <nl> - i = peersData . emplace ( id , std : : move ( newData ) ) . first ; <nl> - } <nl> - switch ( restriction ) { <nl> - case PeerData : : MinimalLoaded : { <nl> - if ( i - > second - > loadedStatus = = PeerData : : NotLoaded ) { <nl> - return nullptr ; <nl> - } <nl> - } break ; <nl> - case PeerData : : FullLoaded : { <nl> - if ( i - > second - > loadedStatus ! = PeerData : : FullLoaded ) { <nl> - return nullptr ; <nl> - } <nl> - } break ; <nl> - } <nl> - return i - > second . get ( ) ; <nl> + not_null < PeerData * > peer ( PeerId id ) { <nl> + return Auth ( ) . data ( ) . peer ( id ) ; <nl> } <nl> - <nl> - void enumerateUsers ( Fn < void ( not_null < UserData * > ) > action ) { <nl> - for ( const auto & [ peerId , peer ] : peersData ) { <nl> - if ( const auto user = peer - > asUser ( ) ) { <nl> - action ( user ) ; <nl> - } <nl> - } <nl> + not_null < UserData * > user ( UserId id ) { <nl> + return Auth ( ) . data ( ) . user ( id ) ; <nl> } <nl> - <nl> - void enumerateGroups ( Fn < void ( not_null < PeerData * > ) > action ) { <nl> - for ( const auto & [ peerId , peer ] : peersData ) { <nl> - if ( peer - > isChat ( ) | | peer - > isMegagroup ( ) ) { <nl> - action ( peer . get ( ) ) ; <nl> - } <nl> - } <nl> + not_null < ChatData * > chat ( ChatId id ) { <nl> + return Auth ( ) . data ( ) . chat ( id ) ; <nl> } <nl> - <nl> - void enumerateChannels ( Fn < void ( not_null < ChannelData * > ) > action ) { <nl> - for ( const auto & [ peerId , peer ] : peersData ) { <nl> - if ( const auto channel = peer - > asChannel ( ) ) { <nl> - if ( ! channel - > isMegagroup ( ) ) { <nl> - action ( channel ) ; <nl> - } <nl> - } <nl> - } <nl> + not_null < ChannelData * > channel ( ChannelId id ) { <nl> + return Auth ( ) . data ( ) . channel ( id ) ; <nl> } <nl> - <nl> - PeerData * peerByName ( const QString & username ) { <nl> - const auto uname = username . trimmed ( ) ; <nl> - for ( const auto & [ peerId , peer ] : peersData ) { <nl> - if ( ! peer - > userName ( ) . compare ( uname , Qt : : CaseInsensitive ) ) { <nl> - return peer . get ( ) ; <nl> - } <nl> - } <nl> - return nullptr ; <nl> + PeerData * peerLoaded ( PeerId id ) { <nl> + return Auth ( ) . data ( ) . peerLoaded ( id ) ; <nl> + } <nl> + UserData * userLoaded ( UserId id ) { <nl> + return Auth ( ) . data ( ) . userLoaded ( id ) ; <nl> + } <nl> + ChatData * chatLoaded ( ChatId id ) { <nl> + return Auth ( ) . data ( ) . chatLoaded ( id ) ; <nl> + } <nl> + ChannelData * channelLoaded ( ChannelId id ) { <nl> + return Auth ( ) . data ( ) . channelLoaded ( id ) ; <nl> } <nl> <nl> QString peerName ( const PeerData * peer , bool forDialogs ) { <nl> return peer ? ( ( forDialogs & & peer - > isUser ( ) & & ! peer - > asUser ( ) - > nameOrPhone . isEmpty ( ) ) ? peer - > asUser ( ) - > nameOrPhone : peer - > name ) : lang ( lng_deleted ) ; <nl> } <nl> <nl> - Histories & histories ( ) { <nl> - return : : histories ; <nl> + not_null < History * > history ( PeerId peer ) { <nl> + return Auth ( ) . data ( ) . history ( peer ) ; <nl> } <nl> <nl> - not_null < History * > history ( const PeerId & peer ) { <nl> - return : : histories . findOrInsert ( peer ) ; <nl> - } <nl> - <nl> - History * historyLoaded ( const PeerId & peer ) { <nl> - if ( ! peer ) { <nl> - return nullptr ; <nl> - } <nl> - return : : histories . find ( peer ) ; <nl> + History * historyLoaded ( PeerId peer ) { <nl> + return Auth ( ) . data ( ) . historyLoaded ( peer ) ; <nl> } <nl> <nl> HistoryItem * histItemById ( ChannelId channelId , MsgId itemId ) { <nl> namespace App { <nl> dependent - > dependencyItemRemoved ( item ) ; <nl> } <nl> } <nl> - Auth ( ) . notifications ( ) . clearFromItem ( item ) ; <nl> + item - > history ( ) - > session ( ) . notifications ( ) . clearFromItem ( item ) ; <nl> } <nl> <nl> void historyUpdateDependent ( not_null < HistoryItem * > item ) { <nl> namespace App { <nl> cSetSavedPeers ( SavedPeers ( ) ) ; <nl> cSetSavedPeersByTime ( SavedPeersByTime ( ) ) ; <nl> cSetRecentInlineBots ( RecentInlineBots ( ) ) ; <nl> - <nl> - peersData . clear ( ) ; <nl> - <nl> - if ( AuthSession : : Exists ( ) ) { <nl> - Auth ( ) . api ( ) . clearWebPageRequests ( ) ; <nl> - } <nl> cSetRecentStickers ( RecentStickerPack ( ) ) ; <nl> cSetReportSpamStatuses ( ReportSpamStatuses ( ) ) ; <nl> } <nl> namespace App { <nl> } ) ; <nl> } <nl> <nl> - void clearHistories ( ) { <nl> - ClickHandler : : clearActive ( ) ; <nl> - ClickHandler : : unpressed ( ) ; <nl> - <nl> - if ( AuthSession : : Exists ( ) ) { <nl> - / / Clear notifications to prevent any showNotification ( ) calls while destroying items . <nl> - Auth ( ) . notifications ( ) . clearAllFast ( ) ; <nl> - } <nl> - <nl> - histories ( ) . clear ( ) ; <nl> - <nl> - Images : : ClearRemote ( ) ; <nl> - cSetServerBackgrounds ( WallPapers ( ) ) ; <nl> - } <nl> - <nl> void deinitMedia ( ) { <nl> clearCorners ( ) ; <nl> <nl> namespace App { <nl> roundRect ( p , x , y , w , h , bg , i . value ( ) , nullptr , parts ) ; <nl> } <nl> <nl> - WallPapers gServerBackgrounds ; <nl> - <nl> } <nl> mmm a / Telegram / SourceFiles / app . h <nl> ppp b / Telegram / SourceFiles / app . h <nl> class MainWindow ; <nl> class MainWidget ; <nl> class HistoryItem ; <nl> class History ; <nl> - class Histories ; <nl> namespace HistoryView { <nl> class Element ; <nl> } / / namespace HistoryView <nl> namespace App { <nl> <nl> ImagePtr image ( const MTPPhotoSize & size ) ; <nl> <nl> - PeerData * peer ( const PeerId & id , PeerData : : LoadedStatus restriction = PeerData : : NotLoaded ) ; <nl> - inline UserData * user ( const PeerId & id , PeerData : : LoadedStatus restriction = PeerData : : NotLoaded ) { <nl> - return asUser ( peer ( id , restriction ) ) ; <nl> - } <nl> - inline ChatData * chat ( const PeerId & id , PeerData : : LoadedStatus restriction = PeerData : : NotLoaded ) { <nl> - return asChat ( peer ( id , restriction ) ) ; <nl> - } <nl> - inline ChannelData * channel ( const PeerId & id , PeerData : : LoadedStatus restriction = PeerData : : NotLoaded ) { <nl> - return asChannel ( peer ( id , restriction ) ) ; <nl> - } <nl> - inline UserData * user ( UserId userId , PeerData : : LoadedStatus restriction = PeerData : : NotLoaded ) { <nl> - return asUser ( peer ( peerFromUser ( userId ) , restriction ) ) ; <nl> - } <nl> - inline ChatData * chat ( ChatId chatId , PeerData : : LoadedStatus restriction = PeerData : : NotLoaded ) { <nl> - return asChat ( peer ( peerFromChat ( chatId ) , restriction ) ) ; <nl> - } <nl> - inline ChannelData * channel ( ChannelId channelId , PeerData : : LoadedStatus restriction = PeerData : : NotLoaded ) { <nl> - return asChannel ( peer ( peerFromChannel ( channelId ) , restriction ) ) ; <nl> - } <nl> - inline PeerData * peerLoaded ( const PeerId & id ) { <nl> - return peer ( id , PeerData : : FullLoaded ) ; <nl> - } <nl> - inline UserData * userLoaded ( const PeerId & id ) { <nl> - return user ( id , PeerData : : FullLoaded ) ; <nl> - } <nl> - inline ChatData * chatLoaded ( const PeerId & id ) { <nl> - return chat ( id , PeerData : : FullLoaded ) ; <nl> - } <nl> - inline ChannelData * channelLoaded ( const PeerId & id ) { <nl> - return channel ( id , PeerData : : FullLoaded ) ; <nl> - } <nl> - inline UserData * userLoaded ( UserId userId ) { <nl> - return user ( userId , PeerData : : FullLoaded ) ; <nl> - } <nl> - inline ChatData * chatLoaded ( ChatId chatId ) { <nl> - return chat ( chatId , PeerData : : FullLoaded ) ; <nl> - } <nl> - inline ChannelData * channelLoaded ( ChannelId channelId ) { <nl> - return channel ( channelId , PeerData : : FullLoaded ) ; <nl> - } <nl> - void enumerateUsers ( Fn < void ( not_null < UserData * > ) > action ) ; <nl> - void enumerateGroups ( Fn < void ( not_null < PeerData * > ) > action ) ; <nl> - void enumerateChannels ( Fn < void ( not_null < ChannelData * > ) > action ) ; <nl> - <nl> - PeerData * peerByName ( const QString & username ) ; <nl> - QString peerName ( const PeerData * peer , bool forDialogs = false ) ; <nl> - <nl> - Histories & histories ( ) ; <nl> - not_null < History * > history ( const PeerId & peer ) ; <nl> - History * historyLoaded ( const PeerId & peer ) ; <nl> - HistoryItem * histItemById ( ChannelId channelId , MsgId itemId ) ; <nl> - inline not_null < History * > history ( const PeerData * peer ) { <nl> + [ [ nodiscard ] ] not_null < PeerData * > peer ( PeerId id ) ; <nl> + [ [ nodiscard ] ] not_null < UserData * > user ( UserId userId ) ; <nl> + [ [ nodiscard ] ] not_null < ChatData * > chat ( ChatId chatId ) ; <nl> + [ [ nodiscard ] ] not_null < ChannelData * > channel ( ChannelId channelId ) ; <nl> + [ [ nodiscard ] ] PeerData * peerLoaded ( PeerId id ) ; <nl> + [ [ nodiscard ] ] UserData * userLoaded ( UserId userId ) ; <nl> + [ [ nodiscard ] ] ChatData * chatLoaded ( ChatId chatId ) ; <nl> + [ [ nodiscard ] ] ChannelData * channelLoaded ( ChannelId channelId ) ; <nl> + <nl> + [ [ nodiscard ] ] QString peerName ( const PeerData * peer , bool forDialogs = false ) ; <nl> + <nl> + [ [ nodiscard ] ] not_null < History * > history ( PeerId peer ) ; <nl> + [ [ nodiscard ] ] History * historyLoaded ( PeerId peer ) ; <nl> + [ [ nodiscard ] ] HistoryItem * histItemById ( ChannelId channelId , MsgId itemId ) ; <nl> + [ [ nodiscard ] ] inline not_null < History * > history ( const PeerData * peer ) { <nl> Assert ( peer ! = nullptr ) ; <nl> return history ( peer - > id ) ; <nl> } <nl> - inline History * historyLoaded ( const PeerData * peer ) { <nl> + [ [ nodiscard ] ] inline History * historyLoaded ( const PeerData * peer ) { <nl> return peer ? historyLoaded ( peer - > id ) : nullptr ; <nl> } <nl> - inline HistoryItem * histItemById ( const ChannelData * channel , MsgId itemId ) { <nl> + [ [ nodiscard ] ] inline HistoryItem * histItemById ( const ChannelData * channel , MsgId itemId ) { <nl> return histItemById ( channel ? peerToChannel ( channel - > id ) : 0 , itemId ) ; <nl> } <nl> - inline HistoryItem * histItemById ( const FullMsgId & msgId ) { <nl> + [ [ nodiscard ] ] inline HistoryItem * histItemById ( const FullMsgId & msgId ) { <nl> return histItemById ( msgId . channel , msgId . msg ) ; <nl> } <nl> void historyRegItem ( not_null < HistoryItem * > item ) ; <nl> namespace App { <nl> <nl> const style : : font & monofont ( ) ; <nl> <nl> - void clearHistories ( ) ; <nl> - <nl> void initMedia ( ) ; <nl> void deinitMedia ( ) ; <nl> <nl> namespace App { <nl> return roundRect ( p , rect . x ( ) , rect . y ( ) , rect . width ( ) , rect . height ( ) , bg , radius , parts ) ; <nl> } <nl> <nl> - struct WallPaper { <nl> - WallPaper ( int32 id , ImagePtr thumb , ImagePtr full ) : id ( id ) , thumb ( thumb ) , full ( full ) { <nl> - } <nl> - int32 id ; <nl> - ImagePtr thumb ; <nl> - ImagePtr full ; <nl> - } ; <nl> - typedef QList < WallPaper > WallPapers ; <nl> - DeclareSetting ( WallPapers , ServerBackgrounds ) ; <nl> - <nl> } ; <nl> mmm a / Telegram / SourceFiles / auth_session . cpp <nl> ppp b / Telegram / SourceFiles / auth_session . cpp <nl> AuthSession & Auth ( ) { <nl> } <nl> <nl> AuthSession : : AuthSession ( const MTPUser & user ) <nl> - : _user ( App : : user ( user . match ( [ ] ( const auto & data ) { return data . vid . v ; } ) ) ) <nl> - , _autoLockTimer ( [ this ] { checkAutoLock ( ) ; } ) <nl> + : _autoLockTimer ( [ this ] { checkAutoLock ( ) ; } ) <nl> , _api ( std : : make_unique < ApiWrap > ( this ) ) <nl> , _calls ( std : : make_unique < Calls : : Instance > ( ) ) <nl> , _downloader ( std : : make_unique < Storage : : Downloader > ( ) ) <nl> AuthSession : : AuthSession ( const MTPUser & user ) <nl> , _storage ( std : : make_unique < Storage : : Facade > ( ) ) <nl> , _notifications ( std : : make_unique < Window : : Notifications : : System > ( this ) ) <nl> , _data ( std : : make_unique < Data : : Session > ( this ) ) <nl> + , _user ( _data - > user ( user ) ) <nl> , _changelogs ( Core : : Changelogs : : Create ( this ) ) <nl> - , _supportHelper ( <nl> - ( Support : : ValidateAccount ( user ) <nl> - ? std : : make_unique < Support : : Helper > ( this ) <nl> - : nullptr ) ) { <nl> - App : : feedUser ( user ) ; <nl> - <nl> + , _supportHelper ( Support : : Helper : : Create ( this ) ) { <nl> _saveDataTimer . setCallback ( [ = ] { <nl> Local : : writeUserSettings ( ) ; <nl> } ) ; <nl> Support : : Templates & AuthSession : : supportTemplates ( ) const { <nl> return supportHelper ( ) . templates ( ) ; <nl> } <nl> <nl> - AuthSession : : ~ AuthSession ( ) = default ; <nl> + AuthSession : : ~ AuthSession ( ) { <nl> + ClickHandler : : clearActive ( ) ; <nl> + ClickHandler : : unpressed ( ) ; <nl> + } <nl> mmm a / Telegram / SourceFiles / auth_session . h <nl> ppp b / Telegram / SourceFiles / auth_session . h <nl> class AuthSession final <nl> private : <nl> static constexpr auto kDefaultSaveDelay = TimeMs ( 1000 ) ; <nl> <nl> - const not_null < UserData * > _user ; <nl> AuthSessionSettings _settings ; <nl> base : : Timer _saveDataTimer ; <nl> <nl> class AuthSession final <nl> const std : : unique_ptr < Storage : : Facade > _storage ; <nl> const std : : unique_ptr < Window : : Notifications : : System > _notifications ; <nl> <nl> - / / _data depends on _downloader / _uploader , including destructor . <nl> + / / _data depends on _downloader / _uploader / _notifications . <nl> const std : : unique_ptr < Data : : Session > _data ; <nl> + const not_null < UserData * > _user ; <nl> <nl> / / _changelogs depends on _data , subscribes on chats loading event . <nl> const std : : unique_ptr < Core : : Changelogs > _changelogs ; <nl> mmm a / Telegram / SourceFiles / boxes / background_box . cpp <nl> ppp b / Telegram / SourceFiles / boxes / background_box . cpp <nl> For license and copyright information please follow this link : <nl> # include " ui / effects / round_checkbox . h " <nl> # include " ui / image / image . h " <nl> # include " auth_session . h " <nl> + # include " data / data_session . h " <nl> # include " styles / style_overview . h " <nl> # include " styles / style_boxes . h " <nl> <nl> BackgroundBox : : BackgroundBox ( QWidget * ) { <nl> void BackgroundBox : : prepare ( ) { <nl> setTitle ( langFactory ( lng_backgrounds_header ) ) ; <nl> <nl> - addButton ( langFactory ( lng_close ) , [ this ] { closeBox ( ) ; } ) ; <nl> + addButton ( langFactory ( lng_close ) , [ = ] { closeBox ( ) ; } ) ; <nl> <nl> setDimensions ( st : : boxWideWidth , st : : boxMaxListHeight ) ; <nl> <nl> _inner = setInnerWidget ( object_ptr < Inner > ( this ) , st : : backgroundScroll ) ; <nl> - _inner - > setBackgroundChosenCallback ( [ this ] ( int index ) { backgroundChosen ( index ) ; } ) ; <nl> + _inner - > setBackgroundChosenCallback ( [ = ] ( int index ) { <nl> + backgroundChosen ( index ) ; <nl> + } ) ; <nl> } <nl> <nl> void BackgroundBox : : backgroundChosen ( int index ) { <nl> - if ( index > = 0 & & index < App : : cServerBackgrounds ( ) . size ( ) ) { <nl> - auto & paper = App : : cServerBackgrounds ( ) [ index ] ; <nl> - if ( App : : main ( ) ) App : : main ( ) - > setChatBackground ( paper ) ; <nl> + if ( index > = 0 & & index < Auth ( ) . data ( ) . wallpapersCount ( ) ) { <nl> + const auto & paper = Auth ( ) . data ( ) . wallpaper ( index ) ; <nl> + App : : main ( ) - > setChatBackground ( paper ) ; <nl> <nl> using Update = Window : : Theme : : BackgroundUpdate ; <nl> Window : : Theme : : Background ( ) - > notify ( Update ( Update : : Type : : Start , ! paper . id ) ) ; <nl> void BackgroundBox : : backgroundChosen ( int index ) { <nl> BackgroundBox : : Inner : : Inner ( QWidget * parent ) : TWidget ( parent ) <nl> , _check ( std : : make_unique < Ui : : RoundCheckbox > ( st : : overviewCheck , [ this ] { update ( ) ; } ) ) { <nl> _check - > setChecked ( true , Ui : : RoundCheckbox : : SetStyle : : Fast ) ; <nl> - if ( App : : cServerBackgrounds ( ) . isEmpty ( ) ) { <nl> + if ( ! Auth ( ) . data ( ) . wallpapersCount ( ) ) { <nl> resize ( BackgroundsInRow * ( st : : backgroundSize . width ( ) + st : : backgroundPadding ) + st : : backgroundPadding , 2 * ( st : : backgroundSize . height ( ) + st : : backgroundPadding ) + st : : backgroundPadding ) ; <nl> MTP : : send ( MTPaccount_GetWallPapers ( ) , rpcDone ( & Inner : : gotWallpapers ) ) ; <nl> } else { <nl> BackgroundBox : : Inner : : Inner ( QWidget * parent ) : TWidget ( parent ) <nl> } <nl> <nl> void BackgroundBox : : Inner : : gotWallpapers ( const MTPVector < MTPWallPaper > & result ) { <nl> - App : : WallPapers wallpapers ; <nl> - <nl> - auto oldBackground = Images : : Create ( qsl ( " : / gui / art / bg_initial . jpg " ) , " JPG " ) ; <nl> - wallpapers . push_back ( App : : WallPaper ( Window : : Theme : : kInitialBackground , oldBackground , oldBackground ) ) ; <nl> - auto & v = result . v ; <nl> - for_const ( auto & w , v ) { <nl> - switch ( w . type ( ) ) { <nl> - case mtpc_wallPaper : { <nl> - auto & d = w . c_wallPaper ( ) ; <nl> - auto & sizes = d . vsizes . v ; <nl> - const MTPPhotoSize * thumb = 0 , * full = 0 ; <nl> - int32 thumbLevel = - 1 , fullLevel = - 1 ; <nl> - for ( QVector < MTPPhotoSize > : : const_iterator j = sizes . cbegin ( ) , e = sizes . cend ( ) ; j ! = e ; + + j ) { <nl> - char size = 0 ; <nl> - int32 w = 0 , h = 0 ; <nl> - switch ( j - > type ( ) ) { <nl> - case mtpc_photoSize : { <nl> - auto & s = j - > c_photoSize ( ) . vtype . v ; <nl> - if ( s . size ( ) ) size = s [ 0 ] ; <nl> - w = j - > c_photoSize ( ) . vw . v ; <nl> - h = j - > c_photoSize ( ) . vh . v ; <nl> - } break ; <nl> - <nl> - case mtpc_photoCachedSize : { <nl> - auto & s = j - > c_photoCachedSize ( ) . vtype . v ; <nl> - if ( s . size ( ) ) size = s [ 0 ] ; <nl> - w = j - > c_photoCachedSize ( ) . vw . v ; <nl> - h = j - > c_photoCachedSize ( ) . vh . v ; <nl> - } break ; <nl> - } <nl> - if ( ! size | | ! w | | ! h ) continue ; <nl> - <nl> - int32 newThumbLevel = qAbs ( ( st : : backgroundSize . width ( ) * cIntRetinaFactor ( ) ) - w ) , newFullLevel = qAbs ( 2560 - w ) ; <nl> - if ( thumbLevel < 0 | | newThumbLevel < thumbLevel ) { <nl> - thumbLevel = newThumbLevel ; <nl> - thumb = & ( * j ) ; <nl> - } <nl> - if ( fullLevel < 0 | | newFullLevel < fullLevel ) { <nl> - fullLevel = newFullLevel ; <nl> - full = & ( * j ) ; <nl> - } <nl> - } <nl> - if ( thumb & & full & & full - > type ( ) ! = mtpc_photoSizeEmpty ) { <nl> - wallpapers . push_back ( App : : WallPaper ( d . vid . v ? d . vid . v : INT_MAX , App : : image ( * thumb ) , App : : image ( * full ) ) ) ; <nl> - } <nl> - } break ; <nl> - <nl> - case mtpc_wallPaperSolid : { <nl> - auto & d = w . c_wallPaperSolid ( ) ; <nl> - } break ; <nl> - } <nl> - } <nl> - <nl> - App : : cSetServerBackgrounds ( wallpapers ) ; <nl> + Auth ( ) . data ( ) . setWallpapers ( result . v ) ; <nl> updateWallpapers ( ) ; <nl> } <nl> <nl> void BackgroundBox : : Inner : : updateWallpapers ( ) { <nl> - _bgCount = App : : cServerBackgrounds ( ) . size ( ) ; <nl> + _bgCount = Auth ( ) . data ( ) . wallpapersCount ( ) ; <nl> _rows = _bgCount / BackgroundsInRow ; <nl> if ( _bgCount % BackgroundsInRow ) + + _rows ; <nl> <nl> void BackgroundBox : : Inner : : updateWallpapers ( ) { <nl> for ( int i = 0 ; i < BackgroundsInRow * 3 ; + + i ) { <nl> if ( i > = _bgCount ) break ; <nl> <nl> - App : : cServerBackgrounds ( ) [ i ] . thumb - > load ( Data : : FileOrigin ( ) ) ; <nl> + Auth ( ) . data ( ) . wallpaper ( i ) . thumb - > load ( Data : : FileOrigin ( ) ) ; <nl> } <nl> } <nl> <nl> void BackgroundBox : : Inner : : paintEvent ( QPaintEvent * e ) { <nl> int index = i * BackgroundsInRow + j ; <nl> if ( index > = _bgCount ) break ; <nl> <nl> - const auto & paper = App : : cServerBackgrounds ( ) [ index ] ; <nl> + const auto & paper = Auth ( ) . data ( ) . wallpaper ( index ) ; <nl> paper . thumb - > load ( Data : : FileOrigin ( ) ) ; <nl> <nl> int x = st : : backgroundPadding + j * ( st : : backgroundSize . width ( ) + st : : backgroundPadding ) ; <nl> mmm a / Telegram / SourceFiles / calls / calls_box_controller . cpp <nl> ppp b / Telegram / SourceFiles / calls / calls_box_controller . cpp <nl> void BoxController : : receivedCalls ( const QVector < MTPMessage > & result ) { <nl> _allLoaded = true ; <nl> } <nl> <nl> - for_const ( auto & message , result ) { <nl> + for ( const auto & message : result ) { <nl> auto msgId = IdFromMessage ( message ) ; <nl> auto peerId = PeerFromMessage ( message ) ; <nl> if ( auto peer = App : : peerLoaded ( peerId ) ) { <nl> - auto item = App : : histories ( ) . addNewMessage ( message , NewMessageExisting ) ; <nl> + auto item = Auth ( ) . data ( ) . addNewMessage ( message , NewMessageExisting ) ; <nl> insertRow ( item , InsertWay : : Append ) ; <nl> } else { <nl> LOG ( ( " API Error : a search results with not loaded peer % 1 " ) . arg ( peerId ) ) ; <nl> mmm a / Telegram / SourceFiles / chat_helpers / message_field . cpp <nl> ppp b / Telegram / SourceFiles / chat_helpers / message_field . cpp <nl> For license and copyright information please follow this link : <nl> # include " base / qthelp_url . h " <nl> # include " boxes / abstract_box . h " <nl> # include " ui / wrap / vertical_layout . h " <nl> + # include " data / data_session . h " <nl> # include " chat_helpers / emoji_suggestions_widget . h " <nl> # include " window / window_controller . h " <nl> # include " lang / lang_keys . h " <nl> InlineBotQuery ParseInlineBotQuery ( not_null < const Ui : : InputField * > field ) { <nl> auto username = text . midRef ( inlineUsernameStart , inlineUsernameLength ) ; <nl> if ( username ! = result . username ) { <nl> result . username = username . toString ( ) ; <nl> - if ( const auto peer = App : : peerByName ( result . username ) ) { <nl> + if ( const auto peer = Auth ( ) . data ( ) . peerByUsername ( result . username ) ) { <nl> if ( const auto user = peer - > asUser ( ) ) { <nl> result . bot = peer - > asUser ( ) ; <nl> } else { <nl> mmm a / Telegram / SourceFiles / data / data_feed . cpp <nl> ppp b / Telegram / SourceFiles / data / data_feed . cpp <nl> void Feed : : changedInChatListHook ( Dialogs : : Mode list , bool added ) { <nl> const auto nonMutedCount = count - mutedCount ; <nl> const auto mutedDelta = added ? mutedCount : - mutedCount ; <nl> const auto nonMutedDelta = added ? nonMutedCount : - nonMutedCount ; <nl> - App : : histories ( ) . unreadIncrement ( nonMutedDelta , false ) ; <nl> - App : : histories ( ) . unreadIncrement ( mutedDelta , true ) ; <nl> + Auth ( ) . data ( ) . unreadIncrement ( nonMutedDelta , false ) ; <nl> + Auth ( ) . data ( ) . unreadIncrement ( mutedDelta , true ) ; <nl> <nl> const auto fullMuted = ( nonMutedCount = = 0 ) ; <nl> const auto entriesWithUnreadDelta = added ? 1 : - 1 ; <nl> const auto mutedEntriesWithUnreadDelta = fullMuted <nl> ? entriesWithUnreadDelta <nl> : 0 ; <nl> - App : : histories ( ) . unreadEntriesChanged ( <nl> + Auth ( ) . data ( ) . unreadEntriesChanged ( <nl> entriesWithUnreadDelta , <nl> mutedEntriesWithUnreadDelta ) ; <nl> } <nl> void Feed : : updateUnreadCounts ( PerformUpdate & & performUpdate ) { <nl> const auto nowFullMuted = ( nowUnreadMutedCount > 0 ) <nl> & & ( nowUnreadCount = = nowUnreadMutedCount ) ; <nl> <nl> - App : : histories ( ) . unreadIncrement ( <nl> + Auth ( ) . data ( ) . unreadIncrement ( <nl> ( nowUnreadCount - nowUnreadMutedCount ) <nl> - ( wasUnreadCount - wasUnreadMutedCount ) , <nl> false ) ; <nl> - App : : histories ( ) . unreadIncrement ( <nl> + Auth ( ) . data ( ) . unreadIncrement ( <nl> nowUnreadMutedCount - wasUnreadMutedCount , <nl> true ) ; <nl> <nl> void Feed : : updateUnreadCounts ( PerformUpdate & & performUpdate ) { <nl> : ( wasFullMuted & & ! nowFullMuted ) <nl> ? - 1 <nl> : 0 ; <nl> - App : : histories ( ) . unreadEntriesChanged ( <nl> + Auth ( ) . data ( ) . unreadEntriesChanged ( <nl> entriesDelta , <nl> mutedEntriesDelta ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / data / data_media_types . cpp <nl> ppp b / Telegram / SourceFiles / data / data_media_types . cpp <nl> For license and copyright information please follow this link : <nl> * / <nl> # include " data / data_media_types . h " <nl> <nl> + # include " history / history . h " <nl> # include " history / history_item . h " <nl> # include " history / history_location_manager . h " <nl> # include " history / view / history_view_element . h " <nl> For license and copyright information please follow this link : <nl> # include " data / data_web_page . h " <nl> # include " data / data_poll . h " <nl> # include " lang / lang_keys . h " <nl> - # include " auth_session . h " <nl> # include " layout . h " <nl> <nl> namespace Data { <nl> Call ComputeCallData ( const MTPDmessageActionPhoneCall & call ) { <nl> return result ; <nl> } <nl> <nl> - Invoice ComputeInvoiceData ( const MTPDmessageMediaInvoice & data ) { <nl> + Invoice ComputeInvoiceData ( <nl> + not_null < HistoryItem * > item , <nl> + const MTPDmessageMediaInvoice & data ) { <nl> auto result = Invoice ( ) ; <nl> result . isTest = data . is_test ( ) ; <nl> result . amount = data . vtotal_amount . v ; <nl> Invoice ComputeInvoiceData ( const MTPDmessageMediaInvoice & data ) { <nl> result . receiptMsgId = data . vreceipt_msg_id . v ; <nl> } <nl> if ( data . has_photo ( ) ) { <nl> - result . photo = Auth ( ) . data ( ) . photoFromWeb ( data . vphoto ) ; <nl> + result . photo = item - > history ( ) - > owner ( ) . photoFromWeb ( data . vphoto ) ; <nl> } <nl> return result ; <nl> } <nl> MediaPhoto : : MediaPhoto ( <nl> not_null < PhotoData * > photo ) <nl> : Media ( parent ) <nl> , _photo ( photo ) { <nl> - Auth ( ) . data ( ) . registerPhotoItem ( _photo , parent ) ; <nl> + parent - > history ( ) - > owner ( ) . registerPhotoItem ( _photo , parent ) ; <nl> } <nl> <nl> MediaPhoto : : MediaPhoto ( <nl> MediaPhoto : : MediaPhoto ( <nl> : Media ( parent ) <nl> , _photo ( photo ) <nl> , _chat ( chat ) { <nl> - Auth ( ) . data ( ) . registerPhotoItem ( _photo , parent ) ; <nl> + parent - > history ( ) - > owner ( ) . registerPhotoItem ( _photo , parent ) ; <nl> } <nl> <nl> MediaPhoto : : ~ MediaPhoto ( ) { <nl> - Auth ( ) . data ( ) . unregisterPhotoItem ( _photo , parent ( ) ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . unregisterPhotoItem ( _photo , parent ( ) ) ; <nl> } <nl> <nl> std : : unique_ptr < Media > MediaPhoto : : clone ( not_null < HistoryItem * > parent ) { <nl> bool MediaPhoto : : updateInlineResultMedia ( const MTPMessageMedia & media ) { <nl> } <nl> auto & data = media . c_messageMediaPhoto ( ) ; <nl> if ( data . has_photo ( ) & & ! data . has_ttl_seconds ( ) ) { <nl> - const auto photo = Auth ( ) . data ( ) . photo ( data . vphoto ) ; <nl> + const auto photo = parent ( ) - > history ( ) - > owner ( ) . photo ( data . vphoto ) ; <nl> if ( photo = = _photo ) { <nl> return true ; <nl> } else { <nl> bool MediaPhoto : : updateSentMedia ( const MTPMessageMedia & media ) { <nl> return false ; <nl> } <nl> const auto & photo = mediaPhoto . vphoto ; <nl> - Auth ( ) . data ( ) . photoConvert ( _photo , photo ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . photoConvert ( _photo , photo ) ; <nl> <nl> if ( photo . type ( ) ! = mtpc_photo ) { <nl> return false ; <nl> bool MediaPhoto : : updateSentMedia ( const MTPMessageMedia & media ) { <nl> const MTPFileLocation * location = nullptr ; <nl> QByteArray bytes ; <nl> } ; <nl> - const auto saveImageToCache = [ ] ( <nl> + const auto saveImageToCache = [ & ] ( <nl> const ImagePtr & image , <nl> SizeData size ) { <nl> Expects ( size . location ! = nullptr ) ; <nl> bool MediaPhoto : : updateSentMedia ( const MTPMessageMedia & media ) { <nl> LOG ( ( " App Error : Bad photo data for saving to cache . " ) ) ; <nl> return ; <nl> } <nl> - Auth ( ) . data ( ) . cache ( ) . putIfEmpty ( <nl> + parent ( ) - > history ( ) - > owner ( ) . cache ( ) . putIfEmpty ( <nl> Data : : StorageCacheKey ( key ) , <nl> Storage : : Cache : : Database : : TaggedValue ( <nl> std : : move ( size . bytes ) , <nl> MediaFile : : MediaFile ( <nl> : Media ( parent ) <nl> , _document ( document ) <nl> , _emoji ( document - > sticker ( ) ? document - > sticker ( ) - > alt : QString ( ) ) { <nl> - Auth ( ) . data ( ) . registerDocumentItem ( _document , parent ) ; <nl> + parent - > history ( ) - > owner ( ) . registerDocumentItem ( _document , parent ) ; <nl> <nl> if ( ! _emoji . isEmpty ( ) ) { <nl> if ( const auto emoji = Ui : : Emoji : : Find ( _emoji ) ) { <nl> MediaFile : : MediaFile ( <nl> } <nl> <nl> MediaFile : : ~ MediaFile ( ) { <nl> - Auth ( ) . data ( ) . unregisterDocumentItem ( _document , parent ( ) ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . unregisterDocumentItem ( <nl> + _document , <nl> + parent ( ) ) ; <nl> } <nl> <nl> std : : unique_ptr < Media > MediaFile : : clone ( not_null < HistoryItem * > parent ) { <nl> bool MediaFile : : updateInlineResultMedia ( const MTPMessageMedia & media ) { <nl> } <nl> auto & data = media . c_messageMediaDocument ( ) ; <nl> if ( data . has_document ( ) & & ! data . has_ttl_seconds ( ) ) { <nl> - const auto document = Auth ( ) . data ( ) . document ( data . vdocument ) ; <nl> + const auto document = parent ( ) - > history ( ) - > owner ( ) . document ( <nl> + data . vdocument ) ; <nl> if ( document = = _document ) { <nl> return false ; <nl> } else { <nl> bool MediaFile : : updateSentMedia ( const MTPMessageMedia & media ) { <nl> " or with ttl_seconds in updateSentMedia ( ) " ) ) ; <nl> return false ; <nl> } <nl> - Auth ( ) . data ( ) . documentConvert ( _document , data . vdocument ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . documentConvert ( _document , data . vdocument ) ; <nl> <nl> if ( const auto good = _document - > goodThumbnail ( ) ) { <nl> auto bytes = good - > bytesForCache ( ) ; <nl> bool MediaFile : : updateSentMedia ( const MTPMessageMedia & media ) { <nl> if ( length > Storage : : kMaxFileInMemory ) { <nl> LOG ( ( " App Error : Bad thumbnail data for saving to cache . " ) ) ; <nl> } else { <nl> - Auth ( ) . data ( ) . cache ( ) . putIfEmpty ( <nl> + parent ( ) - > history ( ) - > owner ( ) . cache ( ) . putIfEmpty ( <nl> _document - > goodThumbnailCacheKey ( ) , <nl> Storage : : Cache : : Database : : TaggedValue ( <nl> std : : move ( bytes ) , <nl> MediaContact : : MediaContact ( <nl> const QString & lastName , <nl> const QString & phoneNumber ) <nl> : Media ( parent ) { <nl> - Auth ( ) . data ( ) . registerContactItem ( userId , parent ) ; <nl> + parent - > history ( ) - > owner ( ) . registerContactItem ( userId , parent ) ; <nl> <nl> _contact . userId = userId ; <nl> _contact . firstName = firstName ; <nl> MediaContact : : MediaContact ( <nl> } <nl> <nl> MediaContact : : ~ MediaContact ( ) { <nl> - Auth ( ) . data ( ) . unregisterContactItem ( _contact . userId , parent ( ) ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . unregisterContactItem ( <nl> + _contact . userId , <nl> + parent ( ) ) ; <nl> } <nl> <nl> std : : unique_ptr < Media > MediaContact : : clone ( not_null < HistoryItem * > parent ) { <nl> bool MediaContact : : updateSentMedia ( const MTPMessageMedia & media ) { <nl> return false ; <nl> } <nl> if ( _contact . userId ! = media . c_messageMediaContact ( ) . vuser_id . v ) { <nl> - Auth ( ) . data ( ) . unregisterContactItem ( _contact . userId , parent ( ) ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . unregisterContactItem ( <nl> + _contact . userId , <nl> + parent ( ) ) ; <nl> _contact . userId = media . c_messageMediaContact ( ) . vuser_id . v ; <nl> - Auth ( ) . data ( ) . registerContactItem ( _contact . userId , parent ( ) ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . registerContactItem ( <nl> + _contact . userId , <nl> + parent ( ) ) ; <nl> } <nl> return true ; <nl> } <nl> MediaLocation : : MediaLocation ( <nl> const QString & title , <nl> const QString & description ) <nl> : Media ( parent ) <nl> - , _location ( Auth ( ) . data ( ) . location ( coords ) ) <nl> + , _location ( parent - > history ( ) - > owner ( ) . location ( coords ) ) <nl> , _title ( title ) <nl> , _description ( description ) { <nl> } <nl> MediaWebPage : : MediaWebPage ( <nl> not_null < WebPageData * > page ) <nl> : Media ( parent ) <nl> , _page ( page ) { <nl> - Auth ( ) . data ( ) . registerWebPageItem ( _page , parent ) ; <nl> + parent - > history ( ) - > owner ( ) . registerWebPageItem ( _page , parent ) ; <nl> } <nl> <nl> MediaWebPage : : ~ MediaWebPage ( ) { <nl> - Auth ( ) . data ( ) . unregisterWebPageItem ( _page , parent ( ) ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . unregisterWebPageItem ( _page , parent ( ) ) ; <nl> } <nl> <nl> std : : unique_ptr < Media > MediaWebPage : : clone ( not_null < HistoryItem * > parent ) { <nl> bool MediaGame : : updateSentMedia ( const MTPMessageMedia & media ) { <nl> if ( media . type ( ) ! = mtpc_messageMediaGame ) { <nl> return false ; <nl> } <nl> - Auth ( ) . data ( ) . gameConvert ( _game , media . c_messageMediaGame ( ) . vgame ) ; <nl> + parent ( ) - > history ( ) - > owner ( ) . gameConvert ( <nl> + _game , media . c_messageMediaGame ( ) . vgame ) ; <nl> return true ; <nl> } <nl> <nl> MediaInvoice : : MediaInvoice ( <nl> not_null < HistoryItem * > parent , <nl> const MTPDmessageMediaInvoice & data ) <nl> : Media ( parent ) <nl> - , _invoice ( ComputeInvoiceData ( data ) ) { <nl> + , _invoice ( ComputeInvoiceData ( parent , data ) ) { <nl> } <nl> <nl> MediaInvoice : : MediaInvoice ( <nl> TextWithEntities MediaPoll : : clipboardText ( ) const { <nl> + ranges : : accumulate ( <nl> ranges : : view : : all ( <nl> _poll - > answers <nl> - ) | ranges : : view : : transform ( <nl> - [ ] ( const PollAnswer & answer ) { return " \ n - " + answer . text ; } <nl> - ) , <nl> + ) | ranges : : view : : transform ( [ ] ( const PollAnswer & answer ) { <nl> + return " \ n - " + answer . text ; <nl> + } ) , <nl> QString ( ) ) ; <nl> return { text , EntitiesInText ( ) } ; <nl> } <nl> mmm a / Telegram / SourceFiles / data / data_peer . cpp <nl> ppp b / Telegram / SourceFiles / data / data_peer . cpp <nl> void PeerClickHandler : : onClick ( ClickContext context ) const { <nl> } <nl> } <nl> <nl> - PeerData : : PeerData ( const PeerId & id ) <nl> + PeerData : : PeerData ( not_null < Data : : Session * > owner , PeerId id ) <nl> : id ( id ) <nl> + , _owner ( owner ) <nl> , _userpicEmpty ( createEmptyUserpic ( ) ) { <nl> nameText . setText ( st : : msgNameStyle , QString ( ) , Ui : : NameTextOptions ( ) ) ; <nl> } <nl> <nl> + Data : : Session & PeerData : : owner ( ) const { <nl> + return * _owner ; <nl> + } <nl> + <nl> + AuthSession & PeerData : : session ( ) const { <nl> + return _owner - > session ( ) ; <nl> + } <nl> + <nl> void PeerData : : updateNameDelayed ( <nl> const QString & newName , <nl> const QString & newNameOrPhone , <nl> void PeerData : : setUserpic ( <nl> <nl> void PeerData : : setUserpicPhoto ( const MTPPhoto & data ) { <nl> const auto photoId = data . match ( [ & ] ( const MTPDphoto & data ) { <nl> - const auto photo = Auth ( ) . data ( ) . photo ( data ) ; <nl> + const auto photo = owner ( ) . photo ( data ) ; <nl> photo - > peer = this ; <nl> return photo - > id ; <nl> } , [ ] ( const MTPDphotoEmpty & data ) { <nl> void PeerData : : setUserpicChecked ( <nl> Notify : : peerUpdatedDelayed ( this , UpdateFlag : : PhotoChanged ) ; <nl> if ( const auto channel = asChannel ( ) ) { <nl> if ( const auto feed = channel - > feed ( ) ) { <nl> - Auth ( ) . data ( ) . notifyFeedUpdated ( <nl> + owner ( ) . notifyFeedUpdated ( <nl> feed , <nl> Data : : FeedUpdateFlag : : ChannelPhoto ) ; <nl> } <nl> const Text & BotCommand : : descriptionText ( ) const { <nl> return _descriptionText ; <nl> } <nl> <nl> + UserData : : UserData ( not_null < Data : : Session * > owner , PeerId id ) <nl> + : PeerData ( owner , id ) { <nl> + } <nl> + <nl> bool UserData : : canShareThisContact ( ) const { <nl> return canShareThisContactFast ( ) <nl> - | | ! Auth ( ) . data ( ) . findContactPhone ( peerToUser ( id ) ) . isEmpty ( ) ; <nl> + | | ! owner ( ) . findContactPhone ( peerToUser ( id ) ) . isEmpty ( ) ; <nl> } <nl> <nl> void UserData : : setContactStatus ( ContactStatus status ) { <nl> bool UserData : : hasCalls ( ) const { <nl> & & ( callsStatus ( ) ! = CallsStatus : : Unknown ) ; <nl> } <nl> <nl> + ChatData : : ChatData ( not_null < Data : : Session * > owner , PeerId id ) <nl> + : PeerData ( owner , id ) <nl> + , inputChat ( MTP_int ( bareId ( ) ) ) { <nl> + } <nl> + <nl> void ChatData : : setPhoto ( const MTPChatPhoto & photo ) { <nl> setPhoto ( userpicPhotoId ( ) , photo ) ; <nl> } <nl> void ChatData : : setInviteLink ( const QString & newInviteLink ) { <nl> } <nl> } <nl> <nl> - ChannelData : : ChannelData ( const PeerId & id ) <nl> - : PeerData ( id ) <nl> + ChannelData : : ChannelData ( not_null < Data : : Session * > owner , PeerId id ) <nl> + : PeerData ( owner , id ) <nl> , inputChannel ( MTP_inputChannel ( MTP_int ( bareId ( ) ) , MTP_long ( 0 ) ) ) { <nl> Data : : PeerFlagValue ( <nl> this , <nl> void PeerData : : updateFull ( ) { <nl> } <nl> <nl> void PeerData : : updateFullForced ( ) { <nl> - Auth ( ) . api ( ) . requestFullPeer ( this ) ; <nl> + session ( ) . api ( ) . requestFullPeer ( this ) ; <nl> if ( auto channel = asChannel ( ) ) { <nl> if ( ! channel - > amCreator ( ) & & ! channel - > inviter ) { <nl> - Auth ( ) . api ( ) . requestSelfParticipant ( channel ) ; <nl> + session ( ) . api ( ) . requestSelfParticipant ( channel ) ; <nl> } <nl> } <nl> } <nl> void ChannelData : : applyEditBanned ( not_null < UserData * > user , const MTPChannelBann <nl> } <nl> } <nl> flags | = Notify : : PeerUpdate : : Flag : : MembersChanged ; <nl> - Auth ( ) . data ( ) . removeMegagroupParticipant ( this , user ) ; <nl> + owner ( ) . removeMegagroupParticipant ( this , user ) ; <nl> } <nl> } <nl> Data : : ChannelAdminChanges ( this ) . feed ( peerToUser ( user - > id ) , false ) ; <nl> void ChannelData : : setRestrictionReason ( const QString & text ) { <nl> void ChannelData : : setAvailableMinId ( MsgId availableMinId ) { <nl> if ( _availableMinId ! = availableMinId ) { <nl> _availableMinId = availableMinId ; <nl> - if ( auto history = App : : historyLoaded ( this ) ) { <nl> - history - > clearUpTill ( availableMinId ) ; <nl> - } <nl> if ( pinnedMessageId ( ) < = _availableMinId ) { <nl> clearPinnedMessage ( ) ; <nl> } <nl> void ChannelData : : setAdminRights ( const MTPChannelAdminRights & rights ) { <nl> } <nl> _adminRights . set ( rights . c_channelAdminRights ( ) . vflags . v ) ; <nl> if ( isMegagroup ( ) ) { <nl> - const auto self = Auth ( ) . user ( ) ; <nl> + const auto self = session ( ) . user ( ) ; <nl> if ( hasAdminRights ( ) ) { <nl> if ( ! amCreator ( ) ) { <nl> auto me = MegagroupInfo : : Admin { rights } ; <nl> void ChannelData : : setAdminRights ( const MTPChannelAdminRights & rights ) { <nl> } <nl> <nl> auto amAdmin = hasAdminRights ( ) | | amCreator ( ) ; <nl> - Data : : ChannelAdminChanges ( this ) . feed ( Auth ( ) . userId ( ) , amAdmin ) ; <nl> + Data : : ChannelAdminChanges ( this ) . feed ( session ( ) . userId ( ) , amAdmin ) ; <nl> } <nl> Notify : : peerUpdatedDelayed ( this , UpdateFlag : : ChannelRightsChanged | UpdateFlag : : AdminsChanged | UpdateFlag : : BannedUsersChanged ) ; <nl> } <nl> void ChannelData : : setRestrictedRights ( const MTPChannelBannedRights & rights ) { <nl> _restrictedUntill = rights . c_channelBannedRights ( ) . vuntil_date . v ; <nl> _restrictions . set ( rights . c_channelBannedRights ( ) . vflags . v ) ; <nl> if ( isMegagroup ( ) ) { <nl> - const auto self = Auth ( ) . user ( ) ; <nl> + const auto self = session ( ) . user ( ) ; <nl> if ( hasRestrictions ( ) ) { <nl> if ( ! amCreator ( ) ) { <nl> auto me = MegagroupInfo : : Restricted { rights } ; <nl> mgInfo - > lastRestricted . emplace ( self , me ) ; <nl> } <nl> mgInfo - > lastAdmins . remove ( self ) ; <nl> - Data : : ChannelAdminChanges ( this ) . feed ( Auth ( ) . userId ( ) , false ) ; <nl> + Data : : ChannelAdminChanges ( this ) . feed ( session ( ) . userId ( ) , false ) ; <nl> } else { <nl> mgInfo - > lastRestricted . remove ( self ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / data / data_peer . h <nl> ppp b / Telegram / SourceFiles / data / data_peer . h <nl> namespace Ui { <nl> class EmptyUserpic ; <nl> } / / namespace Ui <nl> <nl> + class AuthSession ; <nl> class PeerData ; <nl> class UserData ; <nl> class ChatData ; <nl> class ChannelData ; <nl> namespace Data { <nl> <nl> class Feed ; <nl> + class Session ; <nl> <nl> int PeerColorIndex ( PeerId peerId ) ; <nl> int PeerColorIndex ( int32 bareId ) ; <nl> class PeerClickHandler : public ClickHandler { <nl> <nl> class PeerData { <nl> protected : <nl> - PeerData ( const PeerId & id ) ; <nl> + PeerData ( not_null < Data : : Session * > owner , PeerId id ) ; <nl> PeerData ( const PeerData & other ) = delete ; <nl> PeerData & operator = ( const PeerData & other ) = delete ; <nl> <nl> public : <nl> virtual ~ PeerData ( ) ; <nl> <nl> + Data : : Session & owner ( ) const ; <nl> + AuthSession & session ( ) const ; <nl> + <nl> bool isUser ( ) const { <nl> return peerIsUser ( id ) ; <nl> } <nl> class PeerData { <nl> <nl> static constexpr auto kUnknownPhotoId = PhotoId ( 0xFFFFFFFFFFFFFFFFULL ) ; <nl> <nl> + not_null < Data : : Session * > _owner ; <nl> + <nl> ImagePtr _userpic ; <nl> PhotoId _userpicPhotoId = kUnknownPhotoId ; <nl> mutable std : : unique_ptr < Ui : : EmptyUserpic > _userpicEmpty ; <nl> class UserData : public PeerData { <nl> MTPDuserFull : : Flags , <nl> kEssentialFullFlags . value ( ) > ; <nl> <nl> - UserData ( const PeerId & id ) : PeerData ( id ) { <nl> - } <nl> + UserData ( not_null < Data : : Session * > owner , PeerId id ) ; <nl> void setPhoto ( const MTPUserProfilePhoto & photo ) ; <nl> <nl> void setName ( <nl> class ChatData : public PeerData { <nl> MTPDchat : : Flags , <nl> kEssentialFlags > ; <nl> <nl> - ChatData ( const PeerId & id ) <nl> - : PeerData ( id ) <nl> - , inputChat ( MTP_int ( bareId ( ) ) ) { <nl> - } <nl> + ChatData ( not_null < Data : : Session * > owner , PeerId id ) ; <nl> + <nl> void setPhoto ( const MTPChatPhoto & photo ) ; <nl> void setPhoto ( PhotoId photoId , const MTPChatPhoto & photo ) ; <nl> <nl> class ChannelData : public PeerData { <nl> MTPDchannelFull : : Flags , <nl> kEssentialFullFlags > ; <nl> <nl> - ChannelData ( const PeerId & id ) ; <nl> + ChannelData ( not_null < Data : : Session * > owner , PeerId id ) ; <nl> <nl> void setPhoto ( const MTPChatPhoto & photo ) ; <nl> void setPhoto ( PhotoId photoId , const MTPChatPhoto & photo ) ; <nl> mmm a / Telegram / SourceFiles / data / data_search_controller . cpp <nl> ppp b / Telegram / SourceFiles / data / data_search_controller . cpp <nl> SearchResult ParseSearchResult ( <nl> <nl> auto addType = NewMessageExisting ; <nl> result . messageIds . reserve ( messages - > size ( ) ) ; <nl> - for ( auto & message : * messages ) { <nl> - if ( auto item = App : : histories ( ) . addNewMessage ( message , addType ) ) { <nl> + for ( const auto & message : * messages ) { <nl> + if ( auto item = Auth ( ) . data ( ) . addNewMessage ( message , addType ) ) { <nl> auto itemId = item - > id ; <nl> if ( ( type = = Storage : : SharedMediaType : : kCount ) <nl> | | item - > sharedMediaTypes ( ) . test ( type ) ) { <nl> mmm a / Telegram / SourceFiles / data / data_session . cpp <nl> ppp b / Telegram / SourceFiles / data / data_session . cpp <nl> For license and copyright information please follow this link : <nl> # include " auth_session . h " <nl> # include " apiwrap . h " <nl> # include " messenger . h " <nl> + # include " mainwidget . h " / / for main ( ) - > removeDialog <nl> + # include " core / crash_reports . h " / / for CrashReports : : SetAnnotation <nl> # include " ui / image / image . h " <nl> # include " export / export_controller . h " <nl> # include " export / view / export_view_panel_controller . h " <nl> For license and copyright information please follow this link : <nl> # include " storage / storage_encrypted_file . h " <nl> # include " boxes / abstract_box . h " <nl> # include " passport / passport_form_controller . h " <nl> + # include " window / themes / window_theme . h " <nl> + # include " lang / lang_keys . h " / / for lang ( lng_deleted ) in user name . <nl> # include " data / data_media_types . h " <nl> # include " data / data_feed . h " <nl> # include " data / data_photo . h " <nl> For license and copyright information please follow this link : <nl> # include " data / data_web_page . h " <nl> # include " data / data_game . h " <nl> # include " data / data_poll . h " <nl> + # include " styles / style_boxes . h " / / for st : : backgroundSize <nl> <nl> namespace Data { <nl> namespace { <nl> void UpdateImage ( ImagePtr & old , ImagePtr now ) { <nl> } <nl> } <nl> <nl> + void CheckForSwitchInlineButton ( not_null < HistoryItem * > item ) { <nl> + if ( item - > out ( ) | | ! item - > hasSwitchInlineButton ( ) ) { <nl> + return ; <nl> + } <nl> + if ( const auto user = item - > history ( ) - > peer - > asUser ( ) ) { <nl> + if ( ! user - > botInfo | | ! user - > botInfo - > inlineReturnPeerId ) { <nl> + return ; <nl> + } <nl> + if ( const auto markup = item - > Get < HistoryMessageReplyMarkup > ( ) ) { <nl> + for ( const auto & row : markup - > rows ) { <nl> + for ( const auto & button : row ) { <nl> + using ButtonType = HistoryMessageMarkupButton : : Type ; <nl> + if ( button . type = = ButtonType : : SwitchInline ) { <nl> + Notify : : switchInlineBotButtonReceived ( <nl> + QString : : fromUtf8 ( button . data ) ) ; <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / We should get a full restriction in " { full } : { reason } " format and we <nl> + / / need to find an " - all " tag in { full } , otherwise ignore this restriction . <nl> + QString ExtractRestrictionReason ( const QString & restriction ) { <nl> + const auto fullEnd = restriction . indexOf ( ' : ' ) ; <nl> + if ( fullEnd < = 0 ) { <nl> + return QString ( ) ; <nl> + } <nl> + <nl> + / / { full } is in " { type } - { tag } - { tag } - { tag } " format <nl> + / / if we find " all " tag we return the restriction string <nl> + const auto typeTags = restriction . mid ( 0 , fullEnd ) . split ( ' - ' ) . mid ( 1 ) ; <nl> + # ifndef OS_MAC_STORE <nl> + const auto restrictionApplies = typeTags . contains ( qsl ( " all " ) ) ; <nl> + # else / / OS_MAC_STORE <nl> + const auto restrictionApplies = typeTags . contains ( qsl ( " all " ) ) <nl> + | | typeTags . contains ( qsl ( " ios " ) ) ; <nl> + # endif / / OS_MAC_STORE <nl> + if ( restrictionApplies ) { <nl> + return restriction . midRef ( fullEnd + 1 ) . trimmed ( ) . toString ( ) ; <nl> + } <nl> + return QString ( ) ; <nl> + } <nl> + <nl> } / / namespace <nl> <nl> Session : : Session ( not_null < AuthSession * > session ) <nl> Session : : Session ( not_null < AuthSession * > session ) <nl> , _cache ( Messenger : : Instance ( ) . databases ( ) . get ( <nl> Local : : cachePath ( ) , <nl> Local : : cacheSettings ( ) ) ) <nl> + , _selfDestructTimer ( [ = ] { checkSelfDestructItems ( ) ; } ) <nl> + , _a_sendActions ( animation ( this , & Session : : step_typings ) ) <nl> , _groups ( this ) <nl> , _unmuteByFinishedTimer ( [ = ] { unmuteByFinished ( ) ; } ) { <nl> _cache - > open ( Local : : cacheKey ( ) ) ; <nl> Session : : Session ( not_null < AuthSession * > session ) <nl> setupChannelLeavingViewer ( ) ; <nl> } <nl> <nl> + void Session : : clear ( ) { <nl> + _sendActions . clear ( ) ; <nl> + <nl> + for ( const auto & [ peerId , history ] : _histories ) { <nl> + history - > unloadBlocks ( ) ; <nl> + } <nl> + App : : historyClearMsgs ( ) ; <nl> + _histories . clear ( ) ; <nl> + <nl> + App : : historyClearItems ( ) ; <nl> + } <nl> + <nl> + not_null < PeerData * > Session : : peer ( PeerId id ) { <nl> + const auto i = _peers . find ( id ) ; <nl> + if ( i ! = _peers . cend ( ) ) { <nl> + return i - > second . get ( ) ; <nl> + } <nl> + auto result = [ & ] ( ) - > std : : unique_ptr < PeerData > { <nl> + if ( peerIsUser ( id ) ) { <nl> + return std : : make_unique < UserData > ( this , id ) ; <nl> + } else if ( peerIsChat ( id ) ) { <nl> + return std : : make_unique < ChatData > ( this , id ) ; <nl> + } else if ( peerIsChannel ( id ) ) { <nl> + return std : : make_unique < ChannelData > ( this , id ) ; <nl> + } <nl> + Unexpected ( " Peer id type . " ) ; <nl> + } ( ) ; <nl> + <nl> + result - > input = MTPinputPeer ( MTP_inputPeerEmpty ( ) ) ; <nl> + return _peers . emplace ( id , std : : move ( result ) ) . first - > second . get ( ) ; <nl> + } <nl> + <nl> + not_null < UserData * > Session : : user ( UserId id ) { <nl> + return peer ( peerFromUser ( id ) ) - > asUser ( ) ; <nl> + } <nl> + <nl> + not_null < ChatData * > Session : : chat ( ChatId id ) { <nl> + return peer ( peerFromChat ( id ) ) - > asChat ( ) ; <nl> + } <nl> + <nl> + not_null < ChannelData * > Session : : channel ( ChannelId id ) { <nl> + return peer ( peerFromChannel ( id ) ) - > asChannel ( ) ; <nl> + } <nl> + <nl> + PeerData * Session : : peerLoaded ( PeerId id ) const { <nl> + const auto i = _peers . find ( id ) ; <nl> + if ( i = = end ( _peers ) ) { <nl> + return nullptr ; <nl> + } else if ( i - > second - > loadedStatus ! = PeerData : : FullLoaded ) { <nl> + return nullptr ; <nl> + } <nl> + return i - > second . get ( ) ; <nl> + } <nl> + <nl> + UserData * Session : : userLoaded ( UserId id ) const { <nl> + if ( const auto peer = peerLoaded ( peerFromUser ( id ) ) ) { <nl> + return peer - > asUser ( ) ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + ChatData * Session : : chatLoaded ( ChatId id ) const { <nl> + if ( const auto peer = peerLoaded ( peerFromChat ( id ) ) ) { <nl> + return peer - > asChat ( ) ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + ChannelData * Session : : channelLoaded ( ChannelId id ) const { <nl> + if ( const auto peer = peerLoaded ( peerFromChannel ( id ) ) ) { <nl> + return peer - > asChannel ( ) ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + not_null < UserData * > Session : : user ( const MTPUser & data ) { <nl> + const auto result = user ( data . match ( [ ] ( const auto & data ) { <nl> + return data . vid . v ; <nl> + } ) ) ; <nl> + auto minimal = false ; <nl> + const MTPUserStatus * status = 0 , emptyStatus = MTP_userStatusEmpty ( ) ; <nl> + <nl> + Notify : : PeerUpdate update ; <nl> + using UpdateFlag = Notify : : PeerUpdate : : Flag ; <nl> + data . match ( [ & ] ( const MTPDuserEmpty & data ) { <nl> + const auto canShareThisContact = result - > canShareThisContactFast ( ) ; <nl> + <nl> + result - > input = MTP_inputPeerUser ( data . vid , MTP_long ( 0 ) ) ; <nl> + result - > inputUser = MTP_inputUser ( data . vid , MTP_long ( 0 ) ) ; <nl> + result - > setName ( lang ( lng_deleted ) , QString ( ) , QString ( ) , QString ( ) ) ; <nl> + result - > setPhoto ( MTP_userProfilePhotoEmpty ( ) ) ; <nl> + / / result - > setFlags ( MTPDuser_ClientFlag : : f_inaccessible | 0 ) ; <nl> + result - > setFlags ( MTPDuser : : Flag : : f_deleted ) ; <nl> + if ( ! result - > phone ( ) . isEmpty ( ) ) { <nl> + result - > setPhone ( QString ( ) ) ; <nl> + update . flags | = UpdateFlag : : UserPhoneChanged ; <nl> + } <nl> + result - > setBotInfoVersion ( - 1 ) ; <nl> + status = & emptyStatus ; <nl> + result - > setContactStatus ( UserData : : ContactStatus : : PhoneUnknown ) ; <nl> + if ( canShareThisContact ! = result - > canShareThisContactFast ( ) ) { <nl> + update . flags | = UpdateFlag : : UserCanShareContact ; <nl> + } <nl> + } , [ & ] ( const MTPDuser & data ) { <nl> + minimal = data . is_min ( ) ; <nl> + <nl> + const auto canShareThisContact = result - > canShareThisContactFast ( ) ; <nl> + if ( minimal ) { <nl> + const auto mask = 0 <nl> + / / | MTPDuser_ClientFlag : : f_inaccessible <nl> + | MTPDuser : : Flag : : f_deleted ; <nl> + result - > setFlags ( ( result - > flags ( ) & ~ mask ) | ( data . vflags . v & mask ) ) ; <nl> + } else { <nl> + result - > setFlags ( data . vflags . v ) ; <nl> + if ( data . is_self ( ) ) { <nl> + result - > input = MTP_inputPeerSelf ( ) ; <nl> + result - > inputUser = MTP_inputUserSelf ( ) ; <nl> + } else if ( ! data . has_access_hash ( ) ) { <nl> + result - > input = MTP_inputPeerUser ( data . vid , MTP_long ( result - > accessHash ( ) ) ) ; <nl> + result - > inputUser = MTP_inputUser ( data . vid , MTP_long ( result - > accessHash ( ) ) ) ; <nl> + } else { <nl> + result - > input = MTP_inputPeerUser ( data . vid , data . vaccess_hash ) ; <nl> + result - > inputUser = MTP_inputUser ( data . vid , data . vaccess_hash ) ; <nl> + } <nl> + if ( data . is_restricted ( ) ) { <nl> + result - > setRestrictionReason ( <nl> + ExtractRestrictionReason ( qs ( data . vrestriction_reason ) ) ) ; <nl> + } else { <nl> + result - > setRestrictionReason ( QString ( ) ) ; <nl> + } <nl> + } <nl> + if ( data . is_deleted ( ) ) { <nl> + if ( ! result - > phone ( ) . isEmpty ( ) ) { <nl> + result - > setPhone ( QString ( ) ) ; <nl> + update . flags | = UpdateFlag : : UserPhoneChanged ; <nl> + } <nl> + result - > setName ( lang ( lng_deleted ) , QString ( ) , QString ( ) , QString ( ) ) ; <nl> + result - > setPhoto ( MTP_userProfilePhotoEmpty ( ) ) ; <nl> + status = & emptyStatus ; <nl> + } else { <nl> + / / apply first_name and last_name from minimal user only if we don ' t have <nl> + / / local values for first name and last name already , otherwise skip <nl> + bool noLocalName = result - > firstName . isEmpty ( ) & & result - > lastName . isEmpty ( ) ; <nl> + QString fname = ( ! minimal | | noLocalName ) ? ( data . has_first_name ( ) ? TextUtilities : : SingleLine ( qs ( data . vfirst_name ) ) : QString ( ) ) : result - > firstName ; <nl> + QString lname = ( ! minimal | | noLocalName ) ? ( data . has_last_name ( ) ? TextUtilities : : SingleLine ( qs ( data . vlast_name ) ) : QString ( ) ) : result - > lastName ; <nl> + <nl> + QString phone = minimal ? result - > phone ( ) : ( data . has_phone ( ) ? qs ( data . vphone ) : QString ( ) ) ; <nl> + QString uname = minimal ? result - > username : ( data . has_username ( ) ? TextUtilities : : SingleLine ( qs ( data . vusername ) ) : QString ( ) ) ; <nl> + <nl> + const auto phoneChanged = ( result - > phone ( ) ! = phone ) ; <nl> + if ( phoneChanged ) { <nl> + result - > setPhone ( phone ) ; <nl> + update . flags | = UpdateFlag : : UserPhoneChanged ; <nl> + } <nl> + const auto nameChanged = ( result - > firstName ! = fname ) <nl> + | | ( result - > lastName ! = lname ) ; <nl> + <nl> + auto showPhone = ! isServiceUser ( result - > id ) <nl> + & & ! data . is_self ( ) <nl> + & & ! data . is_contact ( ) <nl> + & & ! data . is_mutual_contact ( ) ; <nl> + auto showPhoneChanged = ! isServiceUser ( result - > id ) <nl> + & & ! data . is_self ( ) <nl> + & & ( ( showPhone <nl> + & & result - > contactStatus ( ) = = UserData : : ContactStatus : : Contact ) <nl> + | | ( ! showPhone <nl> + & & result - > contactStatus ( ) = = UserData : : ContactStatus : : CanAdd ) ) ; <nl> + if ( minimal ) { <nl> + showPhoneChanged = false ; <nl> + showPhone = ! isServiceUser ( result - > id ) <nl> + & & ( result - > id ! = _session - > userPeerId ( ) ) <nl> + & & ( result - > contactStatus ( ) = = UserData : : ContactStatus : : CanAdd ) ; <nl> + } <nl> + <nl> + / / see also Local : : readPeer <nl> + <nl> + const auto pname = ( showPhoneChanged | | phoneChanged | | nameChanged ) <nl> + ? ( ( showPhone & & ! phone . isEmpty ( ) ) <nl> + ? App : : formatPhone ( phone ) <nl> + : QString ( ) ) <nl> + : result - > nameOrPhone ; <nl> + <nl> + if ( ! minimal & & data . is_self ( ) & & uname ! = result - > username ) { <nl> + CrashReports : : SetAnnotation ( " Username " , uname ) ; <nl> + } <nl> + result - > setName ( fname , lname , pname , uname ) ; <nl> + if ( data . has_photo ( ) ) { <nl> + result - > setPhoto ( data . vphoto ) ; <nl> + } else { <nl> + result - > setPhoto ( MTP_userProfilePhotoEmpty ( ) ) ; <nl> + } <nl> + if ( data . has_access_hash ( ) ) { <nl> + result - > setAccessHash ( data . vaccess_hash . v ) ; <nl> + } <nl> + status = data . has_status ( ) ? & data . vstatus : & emptyStatus ; <nl> + } <nl> + if ( ! minimal ) { <nl> + if ( data . has_bot_info_version ( ) ) { <nl> + result - > setBotInfoVersion ( data . vbot_info_version . v ) ; <nl> + result - > botInfo - > readsAllHistory = data . is_bot_chat_history ( ) ; <nl> + if ( result - > botInfo - > cantJoinGroups ! = data . is_bot_nochats ( ) ) { <nl> + result - > botInfo - > cantJoinGroups = data . is_bot_nochats ( ) ; <nl> + update . flags | = UpdateFlag : : BotCanAddToGroups ; <nl> + } <nl> + result - > botInfo - > inlinePlaceholder = data . has_bot_inline_placeholder ( ) ? ' _ ' + qs ( data . vbot_inline_placeholder ) : QString ( ) ; <nl> + } else { <nl> + result - > setBotInfoVersion ( - 1 ) ; <nl> + } <nl> + result - > setContactStatus ( ( data . is_contact ( ) | | data . is_mutual_contact ( ) ) <nl> + ? UserData : : ContactStatus : : Contact <nl> + : result - > phone ( ) . isEmpty ( ) <nl> + ? UserData : : ContactStatus : : PhoneUnknown <nl> + : UserData : : ContactStatus : : CanAdd ) ; <nl> + } <nl> + <nl> + if ( canShareThisContact ! = result - > canShareThisContactFast ( ) ) { <nl> + update . flags | = UpdateFlag : : UserCanShareContact ; <nl> + } <nl> + } ) ; <nl> + <nl> + if ( minimal ) { <nl> + if ( result - > loadedStatus = = PeerData : : NotLoaded ) { <nl> + result - > loadedStatus = PeerData : : MinimalLoaded ; <nl> + } <nl> + } else if ( result - > loadedStatus ! = PeerData : : FullLoaded <nl> + & & ( ! result - > isSelf ( ) | | ! result - > phone ( ) . isEmpty ( ) ) ) { <nl> + result - > loadedStatus = PeerData : : FullLoaded ; <nl> + } <nl> + <nl> + if ( status & & ! minimal ) { <nl> + const auto oldOnlineTill = result - > onlineTill ; <nl> + const auto newOnlineTill = ApiWrap : : OnlineTillFromStatus ( <nl> + * status , <nl> + oldOnlineTill ) ; <nl> + if ( oldOnlineTill ! = newOnlineTill ) { <nl> + result - > onlineTill = newOnlineTill ; <nl> + update . flags | = UpdateFlag : : UserOnlineChanged ; <nl> + } <nl> + } <nl> + <nl> + if ( result - > contactStatus ( ) = = UserData : : ContactStatus : : PhoneUnknown <nl> + & & ! result - > phone ( ) . isEmpty ( ) <nl> + & & ! result - > isSelf ( ) ) { <nl> + result - > setContactStatus ( UserData : : ContactStatus : : CanAdd ) ; <nl> + } <nl> + if ( App : : main ( ) ) { <nl> + if ( update . flags ) { <nl> + update . peer = result ; <nl> + Notify : : peerUpdatedDelayed ( update ) ; <nl> + } <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + not_null < PeerData * > Session : : chat ( const MTPChat & data ) { <nl> + const auto result = data . match ( [ & ] ( const MTPDchat & data ) { <nl> + return peer ( peerFromChat ( data . vid . v ) ) ; <nl> + } , [ & ] ( const MTPDchatForbidden & data ) { <nl> + return peer ( peerFromChat ( data . vid . v ) ) ; <nl> + } , [ & ] ( const MTPDchatEmpty & data ) { <nl> + return peer ( peerFromChat ( data . vid . v ) ) ; <nl> + } , [ & ] ( const MTPDchannel & data ) { <nl> + return peer ( peerFromChannel ( data . vid . v ) ) ; <nl> + } , [ & ] ( const MTPDchannelForbidden & data ) { <nl> + return peer ( peerFromChannel ( data . vid . v ) ) ; <nl> + } ) ; <nl> + auto minimal = false ; <nl> + <nl> + Notify : : PeerUpdate update ; <nl> + using UpdateFlag = Notify : : PeerUpdate : : Flag ; <nl> + <nl> + data . match ( [ & ] ( const MTPDchat & data ) { <nl> + const auto chat = result - > asChat ( ) ; <nl> + const auto canEdit = chat - > canEdit ( ) ; <nl> + <nl> + if ( chat - > version < data . vversion . v ) { <nl> + chat - > version = data . vversion . v ; <nl> + chat - > invalidateParticipants ( ) ; <nl> + } <nl> + <nl> + chat - > input = MTP_inputPeerChat ( data . vid ) ; <nl> + chat - > setName ( qs ( data . vtitle ) ) ; <nl> + chat - > setPhoto ( data . vphoto ) ; <nl> + chat - > date = data . vdate . v ; <nl> + <nl> + const auto & migratedTo = data . has_migrated_to ( ) <nl> + ? data . vmigrated_to <nl> + : MTPInputChannel ( MTP_inputChannelEmpty ( ) ) ; <nl> + migratedTo . match ( [ & ] ( const MTPDinputChannel & input ) { <nl> + const auto channel = this - > channel ( input . vchannel_id . v ) ; <nl> + channel - > addFlags ( MTPDchannel : : Flag : : f_megagroup ) ; <nl> + if ( ! channel - > access ) { <nl> + channel - > input = MTP_inputPeerChannel ( input . vchannel_id , input . vaccess_hash ) ; <nl> + channel - > inputChannel = data . vmigrated_to ; <nl> + channel - > access = input . vaccess_hash . v ; <nl> + } <nl> + const auto updatedTo = ( chat - > migrateToPtr ! = channel ) ; <nl> + const auto updatedFrom = ( channel - > mgInfo - > migrateFromPtr ! = chat ) ; <nl> + if ( updatedTo ) { <nl> + chat - > migrateToPtr = channel ; <nl> + } <nl> + if ( updatedFrom ) { <nl> + channel - > mgInfo - > migrateFromPtr = chat ; <nl> + if ( const auto h = historyLoaded ( chat - > id ) ) { <nl> + if ( const auto hto = historyLoaded ( channel - > id ) ) { <nl> + if ( ! h - > isEmpty ( ) ) { <nl> + h - > unloadBlocks ( ) ; <nl> + } <nl> + if ( hto - > inChatList ( Dialogs : : Mode : : All ) <nl> + & & h - > inChatList ( Dialogs : : Mode : : All ) ) { <nl> + App : : main ( ) - > removeDialog ( h ) ; <nl> + } <nl> + } <nl> + } <nl> + Notify : : migrateUpdated ( channel ) ; <nl> + update . flags | = UpdateFlag : : MigrationChanged ; <nl> + } <nl> + if ( updatedTo ) { <nl> + Notify : : migrateUpdated ( chat ) ; <nl> + update . flags | = UpdateFlag : : MigrationChanged ; <nl> + } <nl> + } , [ ] ( const MTPDinputChannelEmpty & ) { <nl> + } ) ; <nl> + <nl> + if ( ! ( chat - > flags ( ) & MTPDchat : : Flag : : f_admins_enabled ) <nl> + & & ( data . vflags . v & MTPDchat : : Flag : : f_admins_enabled ) ) { <nl> + chat - > invalidateParticipants ( ) ; <nl> + } <nl> + chat - > setFlags ( data . vflags . v ) ; <nl> + <nl> + chat - > count = data . vparticipants_count . v ; <nl> + if ( canEdit ! = chat - > canEdit ( ) ) { <nl> + update . flags | = UpdateFlag : : ChatCanEdit ; <nl> + } <nl> + } , [ & ] ( const MTPDchatForbidden & data ) { <nl> + const auto chat = result - > asChat ( ) ; <nl> + const auto canEdit = chat - > canEdit ( ) ; <nl> + <nl> + chat - > input = MTP_inputPeerChat ( data . vid ) ; <nl> + chat - > setName ( qs ( data . vtitle ) ) ; <nl> + chat - > setPhoto ( MTP_chatPhotoEmpty ( ) ) ; <nl> + chat - > date = 0 ; <nl> + chat - > count = - 1 ; <nl> + chat - > invalidateParticipants ( ) ; <nl> + chat - > setFlags ( MTPDchat_ClientFlag : : f_forbidden | 0 ) ; <nl> + if ( canEdit ! = chat - > canEdit ( ) ) { <nl> + update . flags | = UpdateFlag : : ChatCanEdit ; <nl> + } <nl> + } , [ & ] ( const MTPDchannel & data ) { <nl> + const auto channel = result - > asChannel ( ) ; <nl> + <nl> + minimal = data . is_min ( ) ; <nl> + if ( minimal ) { <nl> + if ( result - > loadedStatus ! = PeerData : : FullLoaded ) { <nl> + LOG ( ( " API Warning : not loaded minimal channel applied . " ) ) ; <nl> + } <nl> + } else { <nl> + const auto accessHash = data . has_access_hash ( ) <nl> + ? data . vaccess_hash <nl> + : MTP_long ( 0 ) ; <nl> + channel - > input = MTP_inputPeerChannel ( data . vid , accessHash ) ; <nl> + } <nl> + <nl> + const auto wasInChannel = channel - > amIn ( ) ; <nl> + const auto canViewAdmins = channel - > canViewAdmins ( ) ; <nl> + const auto canViewMembers = channel - > canViewMembers ( ) ; <nl> + const auto canAddMembers = channel - > canAddMembers ( ) ; <nl> + <nl> + if ( data . has_participants_count ( ) ) { <nl> + channel - > setMembersCount ( data . vparticipants_count . v ) ; <nl> + } <nl> + if ( minimal ) { <nl> + auto mask = 0 <nl> + | MTPDchannel : : Flag : : f_broadcast <nl> + | MTPDchannel : : Flag : : f_verified <nl> + | MTPDchannel : : Flag : : f_megagroup <nl> + | MTPDchannel : : Flag : : f_democracy <nl> + | MTPDchannel_ClientFlag : : f_forbidden ; <nl> + channel - > setFlags ( ( channel - > flags ( ) & ~ mask ) | ( data . vflags . v & mask ) ) ; <nl> + } else { <nl> + if ( data . has_admin_rights ( ) ) { <nl> + channel - > setAdminRights ( data . vadmin_rights ) ; <nl> + } else if ( channel - > hasAdminRights ( ) ) { <nl> + channel - > setAdminRights ( MTP_channelAdminRights ( MTP_flags ( 0 ) ) ) ; <nl> + } <nl> + if ( data . has_banned_rights ( ) ) { <nl> + channel - > setRestrictedRights ( data . vbanned_rights ) ; <nl> + } else if ( channel - > hasRestrictions ( ) ) { <nl> + channel - > setRestrictedRights ( MTP_channelBannedRights ( MTP_flags ( 0 ) , MTP_int ( 0 ) ) ) ; <nl> + } <nl> + channel - > inputChannel = MTP_inputChannel ( data . vid , data . vaccess_hash ) ; <nl> + channel - > access = data . vaccess_hash . v ; <nl> + channel - > date = data . vdate . v ; <nl> + if ( channel - > version < data . vversion . v ) { <nl> + channel - > version = data . vversion . v ; <nl> + } <nl> + if ( data . is_restricted ( ) ) { <nl> + channel - > setRestrictionReason ( <nl> + ExtractRestrictionReason ( qs ( data . vrestriction_reason ) ) ) ; <nl> + } else { <nl> + channel - > setRestrictionReason ( QString ( ) ) ; <nl> + } <nl> + channel - > setFlags ( data . vflags . v ) ; <nl> + / / if ( data . has_feed_id ( ) ) { / / # feed <nl> + / / channel - > setFeed ( feed ( data . vfeed_id . v ) ) ; <nl> + / / } else { <nl> + / / channel - > clearFeed ( ) ; <nl> + / / } <nl> + } <nl> + <nl> + QString uname = data . has_username ( ) ? TextUtilities : : SingleLine ( qs ( data . vusername ) ) : QString ( ) ; <nl> + channel - > setName ( qs ( data . vtitle ) , uname ) ; <nl> + <nl> + channel - > setPhoto ( data . vphoto ) ; <nl> + <nl> + if ( wasInChannel ! = channel - > amIn ( ) ) { <nl> + update . flags | = UpdateFlag : : ChannelAmIn ; <nl> + } <nl> + if ( canViewAdmins ! = channel - > canViewAdmins ( ) <nl> + | | canViewMembers ! = channel - > canViewMembers ( ) <nl> + | | canAddMembers ! = channel - > canAddMembers ( ) ) { <nl> + update . flags | = UpdateFlag : : ChannelRightsChanged ; <nl> + } <nl> + } , [ & ] ( const MTPDchannelForbidden & data ) { <nl> + const auto channel = result - > asChannel ( ) ; <nl> + channel - > input = MTP_inputPeerChannel ( data . vid , data . vaccess_hash ) ; <nl> + <nl> + auto wasInChannel = channel - > amIn ( ) ; <nl> + auto canViewAdmins = channel - > canViewAdmins ( ) ; <nl> + auto canViewMembers = channel - > canViewMembers ( ) ; <nl> + auto canAddMembers = channel - > canAddMembers ( ) ; <nl> + <nl> + channel - > inputChannel = MTP_inputChannel ( data . vid , data . vaccess_hash ) ; <nl> + <nl> + auto mask = mtpCastFlags ( MTPDchannelForbidden : : Flag : : f_broadcast | MTPDchannelForbidden : : Flag : : f_megagroup ) ; <nl> + channel - > setFlags ( ( channel - > flags ( ) & ~ mask ) | ( mtpCastFlags ( data . vflags ) & mask ) | MTPDchannel_ClientFlag : : f_forbidden ) ; <nl> + <nl> + if ( channel - > hasAdminRights ( ) ) { <nl> + channel - > setAdminRights ( MTP_channelAdminRights ( MTP_flags ( 0 ) ) ) ; <nl> + } <nl> + if ( channel - > hasRestrictions ( ) ) { <nl> + channel - > setRestrictedRights ( MTP_channelBannedRights ( MTP_flags ( 0 ) , MTP_int ( 0 ) ) ) ; <nl> + } <nl> + <nl> + channel - > setName ( qs ( data . vtitle ) , QString ( ) ) ; <nl> + <nl> + channel - > access = data . vaccess_hash . v ; <nl> + channel - > setPhoto ( MTP_chatPhotoEmpty ( ) ) ; <nl> + channel - > date = 0 ; <nl> + channel - > setMembersCount ( 0 ) ; <nl> + <nl> + if ( wasInChannel ! = channel - > amIn ( ) ) { <nl> + update . flags | = UpdateFlag : : ChannelAmIn ; <nl> + } <nl> + if ( canViewAdmins ! = channel - > canViewAdmins ( ) <nl> + | | canViewMembers ! = channel - > canViewMembers ( ) <nl> + | | canAddMembers ! = channel - > canAddMembers ( ) ) { <nl> + update . flags | = UpdateFlag : : ChannelRightsChanged ; <nl> + } <nl> + } , [ ] ( const MTPDchatEmpty & ) { <nl> + } ) ; <nl> + <nl> + if ( minimal ) { <nl> + if ( result - > loadedStatus = = PeerData : : NotLoaded ) { <nl> + result - > loadedStatus = PeerData : : MinimalLoaded ; <nl> + } <nl> + } else if ( result - > loadedStatus ! = PeerData : : FullLoaded ) { <nl> + result - > loadedStatus = PeerData : : FullLoaded ; <nl> + } <nl> + if ( update . flags ) { <nl> + update . peer = result ; <nl> + Notify : : peerUpdatedDelayed ( update ) ; <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + UserData * Session : : processUsers ( const MTPVector < MTPUser > & data ) { <nl> + auto result = ( UserData * ) nullptr ; <nl> + for ( const auto & user : data . v ) { <nl> + result = this - > user ( user ) ; <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + PeerData * Session : : processChats ( const MTPVector < MTPChat > & data ) { <nl> + auto result = ( PeerData * ) nullptr ; <nl> + for ( const auto & chat : data . v ) { <nl> + result = this - > chat ( chat ) ; <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + PeerData * Session : : peerByUsername ( const QString & username ) const { <nl> + const auto uname = username . trimmed ( ) ; <nl> + for ( const auto & [ peerId , peer ] : _peers ) { <nl> + if ( ! peer - > userName ( ) . compare ( uname , Qt : : CaseInsensitive ) ) { <nl> + return peer . get ( ) ; <nl> + } <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + void Session : : enumerateUsers ( Fn < void ( not_null < UserData * > ) > action ) const { <nl> + for ( const auto & [ peerId , peer ] : _peers ) { <nl> + if ( const auto user = peer - > asUser ( ) ) { <nl> + action ( user ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void Session : : enumerateGroups ( Fn < void ( not_null < PeerData * > ) > action ) const { <nl> + for ( const auto & [ peerId , peer ] : _peers ) { <nl> + if ( peer - > isChat ( ) | | peer - > isMegagroup ( ) ) { <nl> + action ( peer . get ( ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void Session : : enumerateChannels ( <nl> + Fn < void ( not_null < ChannelData * > ) > action ) const { <nl> + for ( const auto & [ peerId , peer ] : _peers ) { <nl> + if ( const auto channel = peer - > asChannel ( ) ) { <nl> + if ( ! channel - > isMegagroup ( ) ) { <nl> + action ( channel ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + not_null < History * > Session : : history ( PeerId peerId ) { <nl> + Expects ( peerId ! = 0 ) ; <nl> + <nl> + if ( const auto result = historyLoaded ( peerId ) ) { <nl> + return result ; <nl> + } <nl> + const auto [ i , ok ] = _histories . emplace ( <nl> + peerId , <nl> + std : : make_unique < History > ( this , peerId ) ) ; <nl> + return i - > second . get ( ) ; <nl> + } <nl> + <nl> + History * Session : : historyLoaded ( PeerId peerId ) const { <nl> + const auto i = peerId ? _histories . find ( peerId ) : end ( _histories ) ; <nl> + return ( i ! = end ( _histories ) ) ? i - > second . get ( ) : nullptr ; <nl> + } <nl> + <nl> + not_null < History * > Session : : history ( not_null < const PeerData * > peer ) { <nl> + return history ( peer - > id ) ; <nl> + } <nl> + <nl> + History * Session : : historyLoaded ( const PeerData * peer ) { <nl> + return peer ? historyLoaded ( peer - > id ) : nullptr ; <nl> + } <nl> + <nl> + void Session : : registerSendAction ( <nl> + not_null < History * > history , <nl> + not_null < UserData * > user , <nl> + const MTPSendMessageAction & action , <nl> + TimeId when ) { <nl> + if ( history - > updateSendActionNeedsAnimating ( user , action ) ) { <nl> + user - > madeAction ( when ) ; <nl> + <nl> + const auto i = _sendActions . find ( history ) ; <nl> + if ( ! _sendActions . contains ( history ) ) { <nl> + _sendActions . emplace ( history , getms ( ) ) ; <nl> + _a_sendActions . start ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void Session : : step_typings ( TimeMs ms , bool timer ) { <nl> + for ( auto i = begin ( _sendActions ) ; i ! = end ( _sendActions ) ; ) { <nl> + if ( i - > first - > updateSendActionNeedsAnimating ( ms ) ) { <nl> + + + i ; <nl> + } else { <nl> + i = _sendActions . erase ( i ) ; <nl> + } <nl> + } <nl> + if ( _sendActions . empty ( ) ) { <nl> + _a_sendActions . stop ( ) ; <nl> + } <nl> + } <nl> + <nl> Storage : : Cache : : Database & Session : : cache ( ) { <nl> return * _cache ; <nl> } <nl> void Session : : setupChannelLeavingViewer ( ) { <nl> & & ! ( channel - > amIn ( ) ) ; <nl> } ) | rpl : : start_with_next ( [ = ] ( not_null < ChannelData * > channel ) { <nl> channel - > clearFeed ( ) ; <nl> - if ( const auto history = App : : historyLoaded ( channel - > id ) ) { <nl> + if ( const auto history = historyLoaded ( channel - > id ) ) { <nl> history - > removeJoinedMessage ( ) ; <nl> history - > updateChatListExistence ( ) ; <nl> history - > updateChatListSortPosition ( ) ; <nl> void Session : : setupChannelLeavingViewer ( ) { <nl> } , _lifetime ) ; <nl> } <nl> <nl> - Session : : ~ Session ( ) = default ; <nl> + Session : : ~ Session ( ) { <nl> + / / Optimization : clear notifications before destroying items . <nl> + _session - > notifications ( ) . clearAllFast ( ) ; <nl> + <nl> + clear ( ) ; <nl> + Images : : ClearRemote ( ) ; <nl> + } <nl> <nl> template < typename Method > <nl> void Session : : enumerateItemViews ( <nl> void Session : : applyPinnedDialogs ( const QVector < MTPDialog > & list ) { <nl> case mtpc_dialog : { <nl> const auto & dialogData = dialog . c_dialog ( ) ; <nl> if ( const auto peer = peerFromMTP ( dialogData . vpeer ) ) { <nl> - setPinnedDialog ( App : : history ( peer ) , true ) ; <nl> + setPinnedDialog ( history ( peer ) , true ) ; <nl> } <nl> } break ; <nl> <nl> void Session : : applyPinnedDialogs ( const QVector < MTPDialogPeer > & list ) { <nl> case mtpc_dialogPeer : { <nl> const auto & peerData = dialogPeer . c_dialogPeer ( ) ; <nl> if ( const auto peerId = peerFromMTP ( peerData . vpeer ) ) { <nl> - setPinnedDialog ( App : : history ( peerId ) , true ) ; <nl> + setPinnedDialog ( history ( peerId ) , true ) ; <nl> } <nl> } break ; <nl> / / case mtpc_dialogPeerFeed : { / / # feed <nl> const NotifySettings & Session : : defaultNotifySettings ( <nl> } <nl> <nl> void Session : : updateNotifySettingsLocal ( not_null < PeerData * > peer ) { <nl> - const auto history = App : : historyLoaded ( peer - > id ) ; <nl> + const auto history = historyLoaded ( peer - > id ) ; <nl> auto changesIn = TimeMs ( 0 ) ; <nl> const auto muted = notifyIsMuted ( peer , & changesIn ) ; <nl> if ( history & & history - > changeMute ( muted ) ) { <nl> void Session : : unmuteByFinishedDelayed ( TimeMs delay ) { <nl> void Session : : unmuteByFinished ( ) { <nl> auto changesInMin = TimeMs ( 0 ) ; <nl> for ( auto i = begin ( _mutedPeers ) ; i ! = end ( _mutedPeers ) ; ) { <nl> - const auto history = App : : historyLoaded ( ( * i ) - > id ) ; <nl> + const auto history = historyLoaded ( ( * i ) - > id ) ; <nl> auto changesIn = TimeMs ( 0 ) ; <nl> const auto muted = notifyIsMuted ( * i , & changesIn ) ; <nl> if ( muted ) { <nl> void Session : : unmuteByFinished ( ) { <nl> } <nl> } <nl> <nl> + HistoryItem * Session : : addNewMessage ( <nl> + const MTPMessage & data , <nl> + NewMessageType type ) { <nl> + const auto peerId = PeerFromMessage ( data ) ; <nl> + if ( ! peerId ) { <nl> + return nullptr ; <nl> + } <nl> + <nl> + const auto result = history ( peerId ) - > addNewMessage ( data , type ) ; <nl> + if ( result & & type = = NewMessageUnread ) { <nl> + CheckForSwitchInlineButton ( result ) ; <nl> + } <nl> + return result ; <nl> + } <nl> + <nl> + auto Session : : sendActionAnimationUpdated ( ) const <nl> + - > rpl : : producer < SendActionAnimationUpdate > { <nl> + return _sendActionAnimationUpdate . events ( ) ; <nl> + } <nl> + <nl> + void Session : : updateSendActionAnimation ( <nl> + SendActionAnimationUpdate & & update ) { <nl> + _sendActionAnimationUpdate . fire ( std : : move ( update ) ) ; <nl> + } <nl> + <nl> + int Session : : unreadBadge ( ) const { <nl> + return computeUnreadBadge ( <nl> + _unreadFull , <nl> + _unreadMuted , <nl> + _unreadEntriesFull , <nl> + _unreadEntriesMuted ) ; <nl> + } <nl> + <nl> + bool Session : : unreadBadgeMuted ( ) const { <nl> + return computeUnreadBadgeMuted ( <nl> + _unreadFull , <nl> + _unreadMuted , <nl> + _unreadEntriesFull , <nl> + _unreadEntriesMuted ) ; <nl> + } <nl> + <nl> + int Session : : unreadBadgeIgnoreOne ( History * history ) const { <nl> + const auto removeCount = ( history <nl> + & & history - > inChatList ( Dialogs : : Mode : : All ) ) <nl> + ? history - > unreadCount ( ) <nl> + : 0 ; <nl> + if ( ! removeCount ) { <nl> + return unreadBadge ( ) ; <nl> + } <nl> + const auto removeMuted = history - > mute ( ) ; <nl> + return computeUnreadBadge ( <nl> + _unreadFull - removeCount , <nl> + _unreadMuted - ( removeMuted ? removeCount : 0 ) , <nl> + _unreadEntriesFull - 1 , <nl> + _unreadEntriesMuted - ( removeMuted ? 1 : 0 ) ) ; <nl> + } <nl> + <nl> + bool Session : : unreadBadgeMutedIgnoreOne ( History * history ) const { <nl> + const auto removeCount = ( history <nl> + & & history - > inChatList ( Dialogs : : Mode : : All ) ) <nl> + ? history - > unreadCount ( ) <nl> + : 0 ; <nl> + if ( ! removeCount ) { <nl> + return unreadBadgeMuted ( ) ; <nl> + } <nl> + const auto removeMuted = history - > mute ( ) ; <nl> + return computeUnreadBadgeMuted ( <nl> + _unreadFull - removeCount , <nl> + _unreadMuted - ( removeMuted ? removeCount : 0 ) , <nl> + _unreadEntriesFull - 1 , <nl> + _unreadEntriesMuted - ( removeMuted ? 1 : 0 ) ) ; <nl> + } <nl> + <nl> + int Session : : unreadOnlyMutedBadge ( ) const { <nl> + return _session - > settings ( ) . countUnreadMessages ( ) <nl> + ? _unreadMuted <nl> + : _unreadEntriesMuted ; <nl> + } <nl> + <nl> + int Session : : computeUnreadBadge ( <nl> + int full , <nl> + int muted , <nl> + int entriesFull , <nl> + int entriesMuted ) const { <nl> + const auto withMuted = _session - > settings ( ) . includeMutedCounter ( ) ; <nl> + return _session - > settings ( ) . countUnreadMessages ( ) <nl> + ? ( full - ( withMuted ? 0 : muted ) ) <nl> + : ( entriesFull - ( withMuted ? 0 : entriesMuted ) ) ; <nl> + } <nl> + <nl> + bool Session : : computeUnreadBadgeMuted ( <nl> + int full , <nl> + int muted , <nl> + int entriesFull , <nl> + int entriesMuted ) const { <nl> + if ( ! _session - > settings ( ) . includeMutedCounter ( ) ) { <nl> + return false ; <nl> + } <nl> + return _session - > settings ( ) . countUnreadMessages ( ) <nl> + ? ( muted > = full ) <nl> + : ( entriesMuted > = entriesFull ) ; <nl> + } <nl> + <nl> + void Session : : unreadIncrement ( int count , bool muted ) { <nl> + if ( ! count ) { <nl> + return ; <nl> + } <nl> + _unreadFull + = count ; <nl> + if ( muted ) { <nl> + _unreadMuted + = count ; <nl> + } <nl> + if ( _session - > settings ( ) . countUnreadMessages ( ) ) { <nl> + if ( ! muted | | _session - > settings ( ) . includeMutedCounter ( ) ) { <nl> + Notify : : unreadCounterUpdated ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void Session : : unreadMuteChanged ( int count , bool muted ) { <nl> + const auto wasAll = ( _unreadMuted = = _unreadFull ) ; <nl> + if ( muted ) { <nl> + _unreadMuted + = count ; <nl> + } else { <nl> + _unreadMuted - = count ; <nl> + } <nl> + if ( _session - > settings ( ) . countUnreadMessages ( ) ) { <nl> + const auto nowAll = ( _unreadMuted = = _unreadFull ) ; <nl> + const auto changed = ! _session - > settings ( ) . includeMutedCounter ( ) <nl> + | | ( wasAll ! = nowAll ) ; <nl> + if ( changed ) { <nl> + Notify : : unreadCounterUpdated ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void Session : : unreadEntriesChanged ( <nl> + int withUnreadDelta , <nl> + int mutedWithUnreadDelta ) { <nl> + if ( ! withUnreadDelta & & ! mutedWithUnreadDelta ) { <nl> + return ; <nl> + } <nl> + const auto wasAll = ( _unreadEntriesMuted = = _unreadEntriesFull ) ; <nl> + _unreadEntriesFull + = withUnreadDelta ; <nl> + _unreadEntriesMuted + = mutedWithUnreadDelta ; <nl> + if ( ! _session - > settings ( ) . countUnreadMessages ( ) ) { <nl> + const auto nowAll = ( _unreadEntriesMuted = = _unreadEntriesFull ) ; <nl> + const auto withMuted = _session - > settings ( ) . includeMutedCounter ( ) ; <nl> + const auto withMutedChanged = withMuted <nl> + & & ( withUnreadDelta ! = 0 | | wasAll ! = nowAll ) ; <nl> + const auto withoutMutedChanged = ! withMuted <nl> + & & ( withUnreadDelta ! = mutedWithUnreadDelta ) ; <nl> + if ( withMutedChanged | | withoutMutedChanged ) { <nl> + Notify : : unreadCounterUpdated ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void Session : : selfDestructIn ( not_null < HistoryItem * > item , TimeMs delay ) { <nl> + _selfDestructItems . push_back ( item - > fullId ( ) ) ; <nl> + if ( ! _selfDestructTimer . isActive ( ) <nl> + | | _selfDestructTimer . remainingTime ( ) > delay ) { <nl> + _selfDestructTimer . callOnce ( delay ) ; <nl> + } <nl> + } <nl> + <nl> + void Session : : checkSelfDestructItems ( ) { <nl> + auto now = getms ( true ) ; <nl> + auto nextDestructIn = TimeMs ( 0 ) ; <nl> + for ( auto i = _selfDestructItems . begin ( ) ; i ! = _selfDestructItems . cend ( ) ; ) { <nl> + if ( auto item = App : : histItemById ( * i ) ) { <nl> + if ( auto destructIn = item - > getSelfDestructIn ( now ) ) { <nl> + if ( nextDestructIn > 0 ) { <nl> + accumulate_min ( nextDestructIn , destructIn ) ; <nl> + } else { <nl> + nextDestructIn = destructIn ; <nl> + } <nl> + + + i ; <nl> + } else { <nl> + i = _selfDestructItems . erase ( i ) ; <nl> + } <nl> + } else { <nl> + i = _selfDestructItems . erase ( i ) ; <nl> + } <nl> + } <nl> + if ( nextDestructIn > 0 ) { <nl> + _selfDestructTimer . callOnce ( nextDestructIn ) ; <nl> + } <nl> + } <nl> + <nl> not_null < PhotoData * > Session : : photo ( PhotoId id ) { <nl> auto i = _photos . find ( id ) ; <nl> if ( i = = _photos . end ( ) ) { <nl> void Session : : registerContactItem ( <nl> if ( ! contactId ) { <nl> return ; <nl> } <nl> - const auto contact = App : : userLoaded ( contactId ) ; <nl> + const auto contact = userLoaded ( contactId ) ; <nl> const auto canShare = contact ? contact - > canShareThisContact ( ) : false ; <nl> <nl> _contactItems [ contactId ] . insert ( item ) ; <nl> void Session : : unregisterContactItem ( <nl> if ( ! contactId ) { <nl> return ; <nl> } <nl> - const auto contact = App : : userLoaded ( contactId ) ; <nl> + const auto contact = userLoaded ( contactId ) ; <nl> const auto canShare = contact ? contact - > canShareThisContact ( ) : false ; <nl> <nl> const auto i = _contactItems . find ( contactId ) ; <nl> void Session : : applyNotifySetting ( <nl> if ( _defaultUserNotifySettings . change ( settings ) ) { <nl> _defaultUserNotifyUpdates . fire ( { } ) ; <nl> <nl> - App : : enumerateUsers ( [ & ] ( not_null < UserData * > user ) { <nl> + enumerateUsers ( [ & ] ( not_null < UserData * > user ) { <nl> if ( ! user - > notifySettingsUnknown ( ) <nl> & & ( ( ! user - > notifyMuteUntil ( ) <nl> & & _defaultUserNotifySettings . muteUntil ( ) ) <nl> void Session : : applyNotifySetting ( <nl> if ( _defaultChatNotifySettings . change ( settings ) ) { <nl> _defaultChatNotifyUpdates . fire ( { } ) ; <nl> <nl> - App : : enumerateGroups ( [ & ] ( not_null < PeerData * > peer ) { <nl> + enumerateGroups ( [ & ] ( not_null < PeerData * > peer ) { <nl> if ( ! peer - > notifySettingsUnknown ( ) <nl> & & ( ( ! peer - > notifyMuteUntil ( ) <nl> & & _defaultChatNotifySettings . muteUntil ( ) ) <nl> void Session : : applyNotifySetting ( <nl> if ( _defaultBroadcastNotifySettings . change ( settings ) ) { <nl> _defaultBroadcastNotifyUpdates . fire ( { } ) ; <nl> <nl> - App : : enumerateChannels ( [ & ] ( not_null < ChannelData * > channel ) { <nl> + enumerateChannels ( [ & ] ( not_null < ChannelData * > channel ) { <nl> if ( ! channel - > notifySettingsUnknown ( ) <nl> & & ( ( ! channel - > notifyMuteUntil ( ) <nl> & & _defaultBroadcastNotifySettings . muteUntil ( ) ) <nl> void Session : : applyNotifySetting ( <nl> } break ; <nl> case mtpc_notifyPeer : { <nl> const auto & data = notifyPeer . c_notifyPeer ( ) ; <nl> - if ( const auto peer = App : : peerLoaded ( peerFromMTP ( data . vpeer ) ) ) { <nl> + if ( const auto peer = peerLoaded ( peerFromMTP ( data . vpeer ) ) ) { <nl> if ( peer - > notifyChange ( settings ) ) { <nl> updateNotifySettingsLocal ( peer ) ; <nl> } <nl> void Session : : serviceNotification ( <nl> const TextWithEntities & message , <nl> const MTPMessageMedia & media ) { <nl> const auto date = unixtime ( ) ; <nl> - if ( ! App : : userLoaded ( ServiceUserId ) ) { <nl> - App : : feedUsers ( MTP_vector < MTPUser > ( 1 , MTP_user ( <nl> + if ( ! userLoaded ( ServiceUserId ) ) { <nl> + user ( MTP_user ( <nl> MTP_flags ( <nl> MTPDuser : : Flag : : f_first_name <nl> | MTPDuser : : Flag : : f_phone <nl> void Session : : serviceNotification ( <nl> MTPint ( ) , <nl> MTPstring ( ) , <nl> MTPstring ( ) , <nl> - MTPstring ( ) ) ) ) ; <nl> + MTPstring ( ) ) ) ; <nl> } <nl> - const auto history = App : : history ( peerFromUser ( ServiceUserId ) ) ; <nl> + const auto history = this - > history ( peerFromUser ( ServiceUserId ) ) ; <nl> if ( ! history - > lastMessageKnown ( ) ) { <nl> _session - > api ( ) . requestDialogEntry ( history , [ = ] { <nl> insertCheckedServiceNotification ( message , media , date ) ; <nl> void Session : : insertCheckedServiceNotification ( <nl> const TextWithEntities & message , <nl> const MTPMessageMedia & media , <nl> TimeId date ) { <nl> - const auto history = App : : history ( peerFromUser ( ServiceUserId ) ) ; <nl> + const auto history = this - > history ( peerFromUser ( ServiceUserId ) ) ; <nl> if ( ! history - > isReadyFor ( ShowAtUnreadMsgId ) ) { <nl> history - > setUnreadCount ( 0 ) ; <nl> history - > getReadyFor ( ShowAtTheEndMsgId ) ; <nl> void Session : : insertCheckedServiceNotification ( <nl> | MTPDmessage_ClientFlag : : f_clientside_unread ; <nl> auto sending = TextWithEntities ( ) , left = message ; <nl> while ( TextUtilities : : CutPart ( sending , left , MaxMessageSize ) ) { <nl> - App : : histories ( ) . addNewMessage ( <nl> + addNewMessage ( <nl> MTP_message ( <nl> MTP_flags ( flags ) , <nl> MTP_int ( clientMsgId ( ) ) , <nl> MessageIdsList Session : : takeMimeForwardIds ( ) { <nl> <nl> void Session : : setProxyPromoted ( PeerData * promoted ) { <nl> if ( _proxyPromoted ! = promoted ) { <nl> - if ( const auto history = App : : historyLoaded ( _proxyPromoted ) ) { <nl> + if ( const auto history = historyLoaded ( _proxyPromoted ) ) { <nl> history - > cacheProxyPromoted ( false ) ; <nl> } <nl> const auto old = std : : exchange ( _proxyPromoted , promoted ) ; <nl> if ( _proxyPromoted ) { <nl> - const auto history = App : : history ( _proxyPromoted ) ; <nl> + const auto history = this - > history ( _proxyPromoted ) ; <nl> history - > cacheProxyPromoted ( true ) ; <nl> if ( ! history - > lastMessageKnown ( ) ) { <nl> _session - > api ( ) . requestDialogEntry ( history ) ; <nl> PeerData * Session : : proxyPromoted ( ) const { <nl> return _proxyPromoted ; <nl> } <nl> <nl> + int Session : : wallpapersCount ( ) const { <nl> + return _wallpapers . size ( ) ; <nl> + } <nl> + <nl> + const WallPaper & Session : : wallpaper ( int index ) const { <nl> + Expects ( index > = 0 & & index < _wallpapers . size ( ) ) ; <nl> + <nl> + return _wallpapers [ index ] ; <nl> + } <nl> + <nl> + void Session : : setWallpapers ( const QVector < MTPWallPaper > & data ) { <nl> + _wallpapers . clear ( ) ; <nl> + _wallpapers . reserve ( data . size ( ) + 1 ) ; <nl> + <nl> + auto oldBackground = Images : : Create ( qsl ( " : / gui / art / bg_initial . jpg " ) , " JPG " ) ; <nl> + _wallpapers . push_back ( { <nl> + Window : : Theme : : kInitialBackground , <nl> + oldBackground , <nl> + oldBackground <nl> + } ) ; <nl> + for ( const auto & paper : data ) { <nl> + paper . match ( [ & ] ( const MTPDwallPaper & paper ) { <nl> + const auto & sizes = paper . vsizes . v ; <nl> + const MTPPhotoSize * thumb = 0 , * full = 0 ; <nl> + int32 thumbLevel = - 1 , fullLevel = - 1 ; <nl> + for ( auto j = sizes . cbegin ( ) , e = sizes . cend ( ) ; j ! = e ; + + j ) { <nl> + char size = 0 ; <nl> + int32 w = 0 , h = 0 ; <nl> + switch ( j - > type ( ) ) { <nl> + case mtpc_photoSize : { <nl> + auto & s = j - > c_photoSize ( ) . vtype . v ; <nl> + if ( s . size ( ) ) size = s [ 0 ] ; <nl> + w = j - > c_photoSize ( ) . vw . v ; <nl> + h = j - > c_photoSize ( ) . vh . v ; <nl> + } break ; <nl> + <nl> + case mtpc_photoCachedSize : { <nl> + auto & s = j - > c_photoCachedSize ( ) . vtype . v ; <nl> + if ( s . size ( ) ) size = s [ 0 ] ; <nl> + w = j - > c_photoCachedSize ( ) . vw . v ; <nl> + h = j - > c_photoCachedSize ( ) . vh . v ; <nl> + } break ; <nl> + } <nl> + if ( ! size | | ! w | | ! h ) continue ; <nl> + <nl> + const auto newThumbLevel = qAbs ( <nl> + ( st : : backgroundSize . width ( ) * cIntRetinaFactor ( ) ) - w ) ; <nl> + const auto newFullLevel = qAbs ( 2560 - w ) ; <nl> + if ( thumbLevel < 0 | | newThumbLevel < thumbLevel ) { <nl> + thumbLevel = newThumbLevel ; <nl> + thumb = & ( * j ) ; <nl> + } <nl> + if ( fullLevel < 0 | | newFullLevel < fullLevel ) { <nl> + fullLevel = newFullLevel ; <nl> + full = & ( * j ) ; <nl> + } <nl> + } <nl> + if ( thumb & & full & & full - > type ( ) ! = mtpc_photoSizeEmpty ) { <nl> + _wallpapers . push_back ( { <nl> + paper . vid . v ? paper . vid . v : INT_MAX , <nl> + App : : image ( * thumb ) , <nl> + App : : image ( * full ) <nl> + } ) ; <nl> + } <nl> + } , [ ] ( const MTPDwallPaperSolid & ) { <nl> + } ) ; <nl> + } <nl> + } <nl> + <nl> + void Session : : clearLocalStorage ( ) { <nl> + clear ( ) ; <nl> + <nl> + _cache - > close ( ) ; <nl> + _cache - > clear ( ) ; <nl> + } <nl> + <nl> } / / namespace Data <nl> mmm a / Telegram / SourceFiles / data / data_session . h <nl> ppp b / Telegram / SourceFiles / data / data_session . h <nl> class Feed ; <nl> enum class FeedUpdateFlag ; <nl> struct FeedUpdate ; <nl> <nl> + struct WallPaper { <nl> + int32 id = 0 ; <nl> + ImagePtr thumb ; <nl> + ImagePtr full ; <nl> + } ; <nl> + <nl> class Session final { <nl> public : <nl> using ViewElement = HistoryView : : Element ; <nl> class Session final { <nl> return * _session ; <nl> } <nl> <nl> + void clear ( ) ; <nl> + <nl> void startExport ( PeerData * peer = nullptr ) ; <nl> void startExport ( const MTPInputPeer & singlePeer ) ; <nl> void suggestStartExport ( TimeId availableAt ) ; <nl> class Session final { <nl> <nl> Storage : : Cache : : Database & cache ( ) ; <nl> <nl> + [ [ nodiscard ] ] not_null < PeerData * > peer ( PeerId id ) ; <nl> + [ [ nodiscard ] ] not_null < UserData * > user ( UserId id ) ; <nl> + [ [ nodiscard ] ] not_null < ChatData * > chat ( ChatId id ) ; <nl> + [ [ nodiscard ] ] not_null < ChannelData * > channel ( ChannelId id ) ; <nl> + <nl> + [ [ nodiscard ] ] PeerData * peerLoaded ( PeerId id ) const ; <nl> + [ [ nodiscard ] ] UserData * userLoaded ( UserId id ) const ; <nl> + [ [ nodiscard ] ] ChatData * chatLoaded ( ChatId id ) const ; <nl> + [ [ nodiscard ] ] ChannelData * channelLoaded ( ChannelId id ) const ; <nl> + <nl> + not_null < UserData * > user ( const MTPUser & data ) ; <nl> + not_null < PeerData * > chat ( const MTPChat & data ) ; <nl> + <nl> + / / Returns last user , if there were any . <nl> + UserData * processUsers ( const MTPVector < MTPUser > & data ) ; <nl> + PeerData * processChats ( const MTPVector < MTPChat > & data ) ; <nl> + <nl> + void enumerateUsers ( Fn < void ( not_null < UserData * > ) > action ) const ; <nl> + void enumerateGroups ( Fn < void ( not_null < PeerData * > ) > action ) const ; <nl> + void enumerateChannels ( Fn < void ( not_null < ChannelData * > ) > action ) const ; <nl> + [ [ nodiscard ] ] PeerData * peerByUsername ( const QString & username ) const ; <nl> + <nl> + not_null < History * > history ( PeerId peerId ) ; <nl> + History * historyLoaded ( PeerId peerId ) const ; <nl> + not_null < History * > history ( not_null < const PeerData * > peer ) ; <nl> + History * historyLoaded ( const PeerData * peer ) ; <nl> + <nl> + void registerSendAction ( <nl> + not_null < History * > history , <nl> + not_null < UserData * > user , <nl> + const MTPSendMessageAction & action , <nl> + TimeId when ) ; <nl> + <nl> [ [ nodiscard ] ] base : : Variable < bool > & contactsLoaded ( ) { <nl> return _contactsLoaded ; <nl> } <nl> class Session final { <nl> void markMediaRead ( not_null < const DocumentData * > document ) ; <nl> void requestPollViewRepaint ( not_null < const PollData * > poll ) ; <nl> <nl> + HistoryItem * addNewMessage ( const MTPMessage & data , NewMessageType type ) ; <nl> + <nl> + struct SendActionAnimationUpdate { <nl> + not_null < History * > history ; <nl> + int width = 0 ; <nl> + int height = 0 ; <nl> + bool textUpdated = false ; <nl> + } ; <nl> + [ [ nodiscard ] ] auto sendActionAnimationUpdated ( ) const <nl> + - > rpl : : producer < SendActionAnimationUpdate > ; <nl> + void updateSendActionAnimation ( SendActionAnimationUpdate & & update ) ; <nl> + <nl> + void updateSendActionAnimation ( ) ; <nl> + <nl> + int unreadBadge ( ) const ; <nl> + bool unreadBadgeMuted ( ) const ; <nl> + int unreadBadgeIgnoreOne ( History * history ) const ; <nl> + bool unreadBadgeMutedIgnoreOne ( History * history ) const ; <nl> + int unreadOnlyMutedBadge ( ) const ; <nl> + <nl> + void unreadIncrement ( int count , bool muted ) ; <nl> + void unreadMuteChanged ( int count , bool muted ) ; <nl> + void unreadEntriesChanged ( <nl> + int withUnreadDelta , <nl> + int mutedWithUnreadDelta ) ; <nl> + <nl> + void selfDestructIn ( not_null < HistoryItem * > item , TimeMs delay ) ; <nl> + <nl> not_null < PhotoData * > photo ( PhotoId id ) ; <nl> not_null < PhotoData * > photo ( const MTPPhoto & data ) ; <nl> not_null < PhotoData * > photo ( const MTPDphoto & data ) ; <nl> class Session final { <nl> return _groups ; <nl> } <nl> <nl> + int wallpapersCount ( ) const ; <nl> + const WallPaper & wallpaper ( int index ) const ; <nl> + void setWallpapers ( const QVector < MTPWallPaper > & data ) ; <nl> + <nl> + void clearLocalStorage ( ) ; <nl> + <nl> private : <nl> void suggestStartExport ( ) ; <nl> <nl> void setupContactViewsViewer ( ) ; <nl> void setupChannelLeavingViewer ( ) ; <nl> + <nl> + void checkSelfDestructItems ( ) ; <nl> + int computeUnreadBadge ( <nl> + int full , <nl> + int muted , <nl> + int entriesFull , <nl> + int entriesMuted ) const ; <nl> + bool computeUnreadBadgeMuted ( <nl> + int full , <nl> + int muted , <nl> + int entriesFull , <nl> + int entriesMuted ) const ; <nl> + <nl> void photoApplyFields ( <nl> not_null < PhotoData * > photo , <nl> const MTPPhoto & data ) ; <nl> class Session final { <nl> const MTPMessageMedia & media , <nl> TimeId date ) ; <nl> <nl> + void step_typings ( TimeMs ms , bool timer ) ; <nl> + <nl> not_null < AuthSession * > _session ; <nl> <nl> Storage : : DatabasePointer _cache ; <nl> class Session final { <nl> Stickers : : Order _archivedStickerSetsOrder ; <nl> Stickers : : SavedGifs _savedGifs ; <nl> <nl> + int _unreadFull = 0 ; <nl> + int _unreadMuted = 0 ; <nl> + int _unreadEntriesFull = 0 ; <nl> + int _unreadEntriesMuted = 0 ; <nl> + <nl> + base : : Timer _selfDestructTimer ; <nl> + std : : vector < FullMsgId > _selfDestructItems ; <nl> + <nl> + / / When typing in this history started . <nl> + base : : flat_map < not_null < History * > , TimeMs > _sendActions ; <nl> + BasicAnimation _a_sendActions ; <nl> + <nl> std : : unordered_map < <nl> PhotoId , <nl> std : : unique_ptr < PhotoData > > _photos ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> not_null < const PhotoData * > , <nl> base : : flat_set < not_null < HistoryItem * > > > _photoItems ; <nl> std : : unordered_map < <nl> DocumentId , <nl> std : : unique_ptr < DocumentData > > _documents ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> not_null < const DocumentData * > , <nl> base : : flat_set < not_null < HistoryItem * > > > _documentItems ; <nl> std : : unordered_map < <nl> WebPageId , <nl> std : : unique_ptr < WebPageData > > _webpages ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> not_null < const WebPageData * > , <nl> base : : flat_set < not_null < HistoryItem * > > > _webpageItems ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> not_null < const WebPageData * > , <nl> base : : flat_set < not_null < ViewElement * > > > _webpageViews ; <nl> std : : unordered_map < <nl> class Session final { <nl> std : : unordered_map < <nl> GameId , <nl> std : : unique_ptr < GameData > > _games ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> not_null < const GameData * > , <nl> base : : flat_set < not_null < ViewElement * > > > _gameViews ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> not_null < const PollData * > , <nl> base : : flat_set < not_null < ViewElement * > > > _pollViews ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> UserId , <nl> base : : flat_set < not_null < HistoryItem * > > > _contactItems ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> UserId , <nl> base : : flat_set < not_null < ViewElement * > > > _contactViews ; <nl> base : : flat_map < <nl> class Session final { <nl> base : : flat_map < FeedId , std : : unique_ptr < Feed > > _feeds ; <nl> rpl : : variable < FeedId > _defaultFeedId = FeedId ( ) ; <nl> Groups _groups ; <nl> - std : : map < <nl> + std : : unordered_map < <nl> not_null < const HistoryItem * > , <nl> std : : vector < not_null < ViewElement * > > > _views ; <nl> <nl> class Session final { <nl> std : : unordered_set < not_null < const PeerData * > > _mutedPeers ; <nl> base : : Timer _unmuteByFinishedTimer ; <nl> <nl> + std : : unordered_map < PeerId , std : : unique_ptr < PeerData > > _peers ; <nl> + std : : unordered_map < PeerId , std : : unique_ptr < History > > _histories ; <nl> + <nl> MessageIdsList _mimeForwardIds ; <nl> <nl> using CredentialsWithGeneration = std : : pair < <nl> class Session final { <nl> <nl> rpl : : event_stream < > _newAuthorizationChecks ; <nl> <nl> + rpl : : event_stream < SendActionAnimationUpdate > _sendActionAnimationUpdate ; <nl> + <nl> + std : : vector < WallPaper > _wallpapers ; <nl> + <nl> rpl : : lifetime _lifetime ; <nl> <nl> } ; <nl> mmm a / Telegram / SourceFiles / dialogs / dialogs_inner_widget . cpp <nl> ppp b / Telegram / SourceFiles / dialogs / dialogs_inner_widget . cpp <nl> DialogsInner : : DialogsInner ( QWidget * parent , not_null < Window : : Controller * > contro <nl> <nl> subscribe ( Auth ( ) . downloaderTaskFinished ( ) , [ this ] { update ( ) ; } ) ; <nl> subscribe ( Auth ( ) . data ( ) . contactsLoaded ( ) , [ this ] ( bool ) { refresh ( ) ; } ) ; <nl> + <nl> Auth ( ) . data ( ) . itemRemoved ( <nl> ) | rpl : : start_with_next ( <nl> [ this ] ( auto item ) { itemRemoved ( item ) ; } , <nl> lifetime ( ) ) ; <nl> + <nl> Auth ( ) . data ( ) . itemRepaintRequest ( <nl> ) | rpl : : start_with_next ( [ = ] ( auto item ) { <nl> const auto history = item - > history ( ) ; <nl> DialogsInner : : DialogsInner ( QWidget * parent , not_null < Window : : Controller * > contro <nl> } <nl> } <nl> } , lifetime ( ) ) ; <nl> - subscribe ( App : : histories ( ) . sendActionAnimationUpdated ( ) , [ this ] ( const Histories : : SendActionAnimationUpdate & update ) { <nl> - auto updateRect = Dialogs : : Layout : : RowPainter : : sendActionAnimationRect ( update . width , update . height , getFullWidth ( ) , update . textUpdated ) ; <nl> + <nl> + Auth ( ) . data ( ) . sendActionAnimationUpdated ( <nl> + ) | rpl : : start_with_next ( [ = ] ( <nl> + const Data : : Session : : SendActionAnimationUpdate & update ) { <nl> + using RowPainter = Dialogs : : Layout : : RowPainter ; <nl> + const auto updateRect = RowPainter : : sendActionAnimationRect ( <nl> + update . width , <nl> + update . height , <nl> + getFullWidth ( ) , <nl> + update . textUpdated ) ; <nl> updateDialogRow ( <nl> Dialogs : : RowDescriptor ( update . history , FullMsgId ( ) ) , <nl> updateRect , <nl> UpdateRowSection : : Default | UpdateRowSection : : Filtered ) ; <nl> - } ) ; <nl> + } , lifetime ( ) ) ; <nl> <nl> subscribe ( Window : : Theme : : Background ( ) , [ = ] ( const Window : : Theme : : BackgroundUpdate & data ) { <nl> if ( data . paletteChanged ( ) ) { <nl> bool DialogsInner : : searchReceived ( <nl> <nl> auto unknownUnreadCounts = std : : vector < not_null < History * > > ( ) ; <nl> TimeId lastDateFound = 0 ; <nl> - for_const ( auto message , messages ) { <nl> + for ( const auto & message : messages ) { <nl> auto msgId = IdFromMessage ( message ) ; <nl> auto peerId = PeerFromMessage ( message ) ; <nl> auto lastDate = DateFromMessage ( message ) ; <nl> if ( const auto peer = App : : peerLoaded ( peerId ) ) { <nl> if ( lastDate ) { <nl> - const auto item = App : : histories ( ) . addNewMessage ( <nl> + const auto item = Auth ( ) . data ( ) . addNewMessage ( <nl> message , <nl> NewMessageExisting ) ; <nl> const auto history = item - > history ( ) ; <nl> mmm a / Telegram / SourceFiles / dialogs / dialogs_layout . cpp <nl> ppp b / Telegram / SourceFiles / dialogs / dialogs_layout . cpp <nl> For license and copyright information please follow this link : <nl> <nl> # include " data / data_abstract_structure . h " <nl> # include " data / data_drafts . h " <nl> + # include " data / data_session . h " <nl> # include " dialogs / dialogs_list . h " <nl> # include " styles / style_dialogs . h " <nl> # include " storage / localstorage . h " <nl> void paintImportantSwitch ( Painter & p , Mode current , int fullWidth , bool selected <nl> if ( ! mutedHidden ) { <nl> return ; <nl> } <nl> - if ( const auto unread = App : : histories ( ) . unreadOnlyMutedBadge ( ) ) { <nl> + if ( const auto unread = Auth ( ) . data ( ) . unreadOnlyMutedBadge ( ) ) { <nl> const auto unreadRight = fullWidth - st : : dialogsPadding . x ( ) ; <nl> UnreadBadgeStyle st ; <nl> st . muted = true ; <nl> mmm a / Telegram / SourceFiles / history / history . cpp <nl> ppp b / Telegram / SourceFiles / history / history . cpp <nl> constexpr auto kSetMyActionForMs = 10000 ; <nl> constexpr auto kNewBlockEachMessage = 50 ; <nl> constexpr auto kSkipCloudDraftsFor = TimeId ( 3 ) ; <nl> <nl> - void checkForSwitchInlineButton ( HistoryItem * item ) { <nl> - if ( item - > out ( ) | | ! item - > hasSwitchInlineButton ( ) ) { <nl> - return ; <nl> - } <nl> - if ( const auto user = item - > history ( ) - > peer - > asUser ( ) ) { <nl> - if ( ! user - > botInfo | | ! user - > botInfo - > inlineReturnPeerId ) { <nl> - return ; <nl> - } <nl> - if ( const auto markup = item - > Get < HistoryMessageReplyMarkup > ( ) ) { <nl> - for_const ( auto & row , markup - > rows ) { <nl> - for_const ( auto & button , row ) { <nl> - if ( button . type = = HistoryMessageMarkupButton : : Type : : SwitchInline ) { <nl> - Notify : : switchInlineBotButtonReceived ( QString : : fromUtf8 ( button . data ) ) ; <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> } / / namespace <nl> <nl> - Histories : : Histories ( ) <nl> - : _a_typings ( animation ( this , & Histories : : step_typings ) ) <nl> - , _selfDestructTimer ( [ this ] { checkSelfDestructItems ( ) ; } ) { <nl> - } <nl> - <nl> - History * Histories : : find ( PeerId peerId ) const { <nl> - if ( const auto i = _map . find ( peerId ) ; i ! = _map . end ( ) ) { <nl> - return i - > second . get ( ) ; <nl> - } <nl> - return nullptr ; <nl> - } <nl> - <nl> - not_null < History * > Histories : : findOrInsert ( PeerId peerId ) { <nl> - if ( const auto result = find ( peerId ) ) { <nl> - return result ; <nl> - } <nl> - const auto [ i , ok ] = _map . emplace ( <nl> - peerId , <nl> - std : : make_unique < History > ( peerId ) ) ; <nl> - return i - > second . get ( ) ; <nl> - } <nl> - <nl> - void Histories : : clear ( ) { <nl> - for ( const auto & [ peerId , history ] : _map ) { <nl> - history - > unloadBlocks ( ) ; <nl> - } <nl> - App : : historyClearMsgs ( ) ; <nl> - _map . clear ( ) ; <nl> - <nl> - _unreadFull = _unreadMuted = 0 ; <nl> - _unreadEntriesFull = _unreadEntriesMuted = 0 ; <nl> - Notify : : unreadCounterUpdated ( ) ; <nl> - App : : historyClearItems ( ) ; <nl> - typing . clear ( ) ; <nl> - } <nl> - <nl> - void Histories : : registerSendAction ( <nl> - not_null < History * > history , <nl> - not_null < UserData * > user , <nl> - const MTPSendMessageAction & action , <nl> - TimeId when ) { <nl> - if ( history - > updateSendActionNeedsAnimating ( user , action ) ) { <nl> - user - > madeAction ( when ) ; <nl> - <nl> - auto i = typing . find ( history ) ; <nl> - if ( i = = typing . cend ( ) ) { <nl> - typing . insert ( history , getms ( ) ) ; <nl> - _a_typings . start ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void Histories : : step_typings ( TimeMs ms , bool timer ) { <nl> - for ( auto i = typing . begin ( ) , e = typing . end ( ) ; i ! = e ; ) { <nl> - if ( i . key ( ) - > updateSendActionNeedsAnimating ( ms ) ) { <nl> - + + i ; <nl> - } else { <nl> - i = typing . erase ( i ) ; <nl> - } <nl> - } <nl> - if ( typing . isEmpty ( ) ) { <nl> - _a_typings . stop ( ) ; <nl> - } <nl> - } <nl> - <nl> - void Histories : : remove ( const PeerId & peer ) { <nl> - const auto i = _map . find ( peer ) ; <nl> - if ( i ! = _map . cend ( ) ) { <nl> - typing . remove ( i - > second . get ( ) ) ; <nl> - _map . erase ( i ) ; <nl> - } <nl> - } <nl> - <nl> - HistoryItem * Histories : : addNewMessage ( <nl> - const MTPMessage & msg , <nl> - NewMessageType type ) { <nl> - auto peer = PeerFromMessage ( msg ) ; <nl> - if ( ! peer ) return nullptr ; <nl> - <nl> - auto result = App : : history ( peer ) - > addNewMessage ( msg , type ) ; <nl> - if ( result & & type = = NewMessageUnread ) { <nl> - checkForSwitchInlineButton ( result ) ; <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - int Histories : : unreadBadge ( ) const { <nl> - return computeUnreadBadge ( <nl> - _unreadFull , <nl> - _unreadMuted , <nl> - _unreadEntriesFull , <nl> - _unreadEntriesMuted ) ; <nl> - } <nl> - <nl> - bool Histories : : unreadBadgeMuted ( ) const { <nl> - return computeUnreadBadgeMuted ( <nl> - _unreadFull , <nl> - _unreadMuted , <nl> - _unreadEntriesFull , <nl> - _unreadEntriesMuted ) ; <nl> - } <nl> - <nl> - int Histories : : unreadBadgeIgnoreOne ( History * history ) const { <nl> - const auto removeCount = ( history <nl> - & & history - > inChatList ( Dialogs : : Mode : : All ) ) <nl> - ? history - > unreadCount ( ) <nl> - : 0 ; <nl> - if ( ! removeCount ) { <nl> - return unreadBadge ( ) ; <nl> - } <nl> - const auto removeMuted = history - > mute ( ) ; <nl> - return computeUnreadBadge ( <nl> - _unreadFull - removeCount , <nl> - _unreadMuted - ( removeMuted ? removeCount : 0 ) , <nl> - _unreadEntriesFull - 1 , <nl> - _unreadEntriesMuted - ( removeMuted ? 1 : 0 ) ) ; <nl> - } <nl> - <nl> - bool Histories : : unreadBadgeMutedIgnoreOne ( History * history ) const { <nl> - const auto removeCount = ( history <nl> - & & history - > inChatList ( Dialogs : : Mode : : All ) ) <nl> - ? history - > unreadCount ( ) <nl> - : 0 ; <nl> - if ( ! removeCount ) { <nl> - return unreadBadgeMuted ( ) ; <nl> - } <nl> - const auto removeMuted = history - > mute ( ) ; <nl> - return computeUnreadBadgeMuted ( <nl> - _unreadFull - removeCount , <nl> - _unreadMuted - ( removeMuted ? removeCount : 0 ) , <nl> - _unreadEntriesFull - 1 , <nl> - _unreadEntriesMuted - ( removeMuted ? 1 : 0 ) ) ; <nl> - } <nl> - <nl> - int Histories : : unreadOnlyMutedBadge ( ) const { <nl> - return Auth ( ) . settings ( ) . countUnreadMessages ( ) <nl> - ? _unreadMuted <nl> - : _unreadEntriesMuted ; <nl> - } <nl> - <nl> - int Histories : : computeUnreadBadge ( <nl> - int full , <nl> - int muted , <nl> - int entriesFull , <nl> - int entriesMuted ) const { <nl> - const auto withMuted = Auth ( ) . settings ( ) . includeMutedCounter ( ) ; <nl> - return Auth ( ) . settings ( ) . countUnreadMessages ( ) <nl> - ? ( full - ( withMuted ? 0 : muted ) ) <nl> - : ( entriesFull - ( withMuted ? 0 : entriesMuted ) ) ; <nl> - } <nl> - <nl> - bool Histories : : computeUnreadBadgeMuted ( <nl> - int full , <nl> - int muted , <nl> - int entriesFull , <nl> - int entriesMuted ) const { <nl> - if ( ! Auth ( ) . settings ( ) . includeMutedCounter ( ) ) { <nl> - return false ; <nl> - } <nl> - return Auth ( ) . settings ( ) . countUnreadMessages ( ) <nl> - ? ( muted > = full ) <nl> - : ( entriesMuted > = entriesFull ) ; <nl> - } <nl> - <nl> - void Histories : : unreadIncrement ( int count , bool muted ) { <nl> - if ( ! count ) { <nl> - return ; <nl> - } <nl> - _unreadFull + = count ; <nl> - if ( muted ) { <nl> - _unreadMuted + = count ; <nl> - } <nl> - if ( Auth ( ) . settings ( ) . countUnreadMessages ( ) ) { <nl> - if ( ! muted | | Auth ( ) . settings ( ) . includeMutedCounter ( ) ) { <nl> - Notify : : unreadCounterUpdated ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void Histories : : unreadMuteChanged ( int count , bool muted ) { <nl> - const auto wasAll = ( _unreadMuted = = _unreadFull ) ; <nl> - if ( muted ) { <nl> - _unreadMuted + = count ; <nl> - } else { <nl> - _unreadMuted - = count ; <nl> - } <nl> - if ( Auth ( ) . settings ( ) . countUnreadMessages ( ) ) { <nl> - const auto nowAll = ( _unreadMuted = = _unreadFull ) ; <nl> - const auto changed = ! Auth ( ) . settings ( ) . includeMutedCounter ( ) <nl> - | | ( wasAll ! = nowAll ) ; <nl> - if ( changed ) { <nl> - Notify : : unreadCounterUpdated ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void Histories : : unreadEntriesChanged ( <nl> - int withUnreadDelta , <nl> - int mutedWithUnreadDelta ) { <nl> - if ( ! withUnreadDelta & & ! mutedWithUnreadDelta ) { <nl> - return ; <nl> - } <nl> - const auto wasAll = ( _unreadEntriesMuted = = _unreadEntriesFull ) ; <nl> - _unreadEntriesFull + = withUnreadDelta ; <nl> - _unreadEntriesMuted + = mutedWithUnreadDelta ; <nl> - if ( ! Auth ( ) . settings ( ) . countUnreadMessages ( ) ) { <nl> - const auto nowAll = ( _unreadEntriesMuted = = _unreadEntriesFull ) ; <nl> - const auto withMuted = Auth ( ) . settings ( ) . includeMutedCounter ( ) ; <nl> - const auto withMutedChanged = withMuted <nl> - & & ( withUnreadDelta ! = 0 | | wasAll ! = nowAll ) ; <nl> - const auto withoutMutedChanged = ! withMuted <nl> - & & ( withUnreadDelta ! = mutedWithUnreadDelta ) ; <nl> - if ( withMutedChanged | | withoutMutedChanged ) { <nl> - Notify : : unreadCounterUpdated ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void Histories : : selfDestructIn ( not_null < HistoryItem * > item , TimeMs delay ) { <nl> - _selfDestructItems . push_back ( item - > fullId ( ) ) ; <nl> - if ( ! _selfDestructTimer . isActive ( ) | | _selfDestructTimer . remainingTime ( ) > delay ) { <nl> - _selfDestructTimer . callOnce ( delay ) ; <nl> - } <nl> - } <nl> - <nl> - void Histories : : checkSelfDestructItems ( ) { <nl> - auto now = getms ( true ) ; <nl> - auto nextDestructIn = TimeMs ( 0 ) ; <nl> - for ( auto i = _selfDestructItems . begin ( ) ; i ! = _selfDestructItems . cend ( ) ; ) { <nl> - if ( auto item = App : : histItemById ( * i ) ) { <nl> - if ( auto destructIn = item - > getSelfDestructIn ( now ) ) { <nl> - if ( nextDestructIn > 0 ) { <nl> - accumulate_min ( nextDestructIn , destructIn ) ; <nl> - } else { <nl> - nextDestructIn = destructIn ; <nl> - } <nl> - + + i ; <nl> - } else { <nl> - i = _selfDestructItems . erase ( i ) ; <nl> - } <nl> - } else { <nl> - i = _selfDestructItems . erase ( i ) ; <nl> - } <nl> - } <nl> - if ( nextDestructIn > 0 ) { <nl> - _selfDestructTimer . callOnce ( nextDestructIn ) ; <nl> - } <nl> - } <nl> - <nl> - History : : History ( const PeerId & peerId ) <nl> + History : : History ( not_null < Data : : Session * > owner , const PeerId & peerId ) <nl> : Entry ( this ) <nl> , peer ( App : : peer ( peerId ) ) <nl> , cloudDraftTextCache ( st : : dialogsTextWidthMin ) <nl> - , _mute ( Auth ( ) . data ( ) . notifyIsMuted ( peer ) ) <nl> + , _owner ( owner ) <nl> + , _mute ( _owner - > notifyIsMuted ( peer ) ) <nl> , _sendActionText ( st : : dialogsTextWidthMin ) { <nl> if ( const auto user = peer - > asUser ( ) ) { <nl> if ( user - > botInfo ) { <nl> void History : : takeLocalDraft ( History * from ) { <nl> _localDraft - > msgId = 0 ; <nl> } <nl> from - > clearLocalDraft ( ) ; <nl> - Auth ( ) . api ( ) . saveDraftToCloudDelayed ( from ) ; <nl> + session ( ) . api ( ) . saveDraftToCloudDelayed ( from ) ; <nl> } <nl> } <nl> <nl> void History : : createLocalDraftFromCloud ( ) { <nl> auto draft = cloudDraft ( ) ; <nl> - if ( Data : : draftIsNull ( draft ) | | ! draft - > date | | Auth ( ) . supportMode ( ) ) { <nl> + if ( Data : : draftIsNull ( draft ) <nl> + | | ! draft - > date <nl> + | | session ( ) . supportMode ( ) ) { <nl> return ; <nl> } <nl> <nl> void History : : draftSavedToCloud ( ) { <nl> } <nl> <nl> HistoryItemsList History : : validateForwardDraft ( ) { <nl> - auto result = Auth ( ) . data ( ) . idsToItems ( _forwardDraft ) ; <nl> + auto result = _owner - > idsToItems ( _forwardDraft ) ; <nl> if ( result . size ( ) ! = _forwardDraft . size ( ) ) { <nl> - setForwardDraft ( Auth ( ) . data ( ) . itemsToIds ( result ) ) ; <nl> + setForwardDraft ( _owner - > itemsToIds ( result ) ) ; <nl> } <nl> return result ; <nl> } <nl> bool History : : updateSendActionNeedsAnimating ( TimeMs ms , bool force ) { <nl> } <nl> auto result = ( ! _typing . isEmpty ( ) | | ! _sendActions . isEmpty ( ) ) ; <nl> if ( changed | | ( result & & ! anim : : Disabled ( ) ) ) { <nl> - App : : histories ( ) . sendActionAnimationUpdated ( ) . notify ( { <nl> + _owner - > updateSendActionAnimation ( { <nl> this , <nl> _sendActionAnimation . width ( ) , <nl> st : : normalFont - > height , <nl> not_null < HistoryItem * > History : : addNewItem ( <nl> if ( const auto sharedMediaTypes = item - > sharedMediaTypes ( ) ) { <nl> auto from = loadedAtTop ( ) ? 0 : minMsgId ( ) ; <nl> auto till = loadedAtBottom ( ) ? ServerMaxMsgId : maxMsgId ( ) ; <nl> - Auth ( ) . storage ( ) . add ( Storage : : SharedMediaAddExisting ( <nl> + session ( ) . storage ( ) . add ( Storage : : SharedMediaAddExisting ( <nl> peer - > id , <nl> sharedMediaTypes , <nl> item - > id , <nl> not_null < HistoryItem * > History : : addNewItem ( <nl> } <nl> if ( auto megagroup = peer - > asMegagroup ( ) ) { <nl> Notify : : peerUpdatedDelayed ( peer , Notify : : PeerUpdate : : Flag : : MembersChanged ) ; <nl> - Auth ( ) . data ( ) . addNewMegagroupParticipant ( megagroup , user ) ; <nl> + _owner - > addNewMegagroupParticipant ( megagroup , user ) ; <nl> } <nl> } <nl> } <nl> not_null < HistoryItem * > History : : addNewItem ( <nl> newItemAdded ( item ) ; <nl> } <nl> <nl> - Auth ( ) . data ( ) . notifyHistoryChangeDelayed ( this ) ; <nl> + _owner - > notifyHistoryChangeDelayed ( this ) ; <nl> return item ; <nl> } <nl> <nl> void History : : applyServiceChanges ( <nl> if ( ! base : : contains ( mgInfo - > lastParticipants , user ) ) { <nl> mgInfo - > lastParticipants . push_front ( user ) ; <nl> Notify : : peerUpdatedDelayed ( peer , Notify : : PeerUpdate : : Flag : : MembersChanged ) ; <nl> - Auth ( ) . data ( ) . addNewMegagroupParticipant ( megagroup , user ) ; <nl> + _owner - > addNewMegagroupParticipant ( megagroup , user ) ; <nl> } <nl> if ( user - > botInfo ) { <nl> peer - > asChannel ( ) - > mgInfo - > bots . insert ( user ) ; <nl> void History : : applyServiceChanges ( <nl> if ( ! base : : contains ( mgInfo - > lastParticipants , user ) ) { <nl> mgInfo - > lastParticipants . push_front ( user ) ; <nl> Notify : : peerUpdatedDelayed ( peer , Notify : : PeerUpdate : : Flag : : MembersChanged ) ; <nl> - Auth ( ) . data ( ) . addNewMegagroupParticipant ( megagroup , user ) ; <nl> + _owner - > addNewMegagroupParticipant ( megagroup , user ) ; <nl> } <nl> if ( user - > botInfo ) { <nl> mgInfo - > bots . insert ( user ) ; <nl> void History : : applyServiceChanges ( <nl> mgInfo - > lastParticipants . erase ( i ) ; <nl> Notify : : peerUpdatedDelayed ( peer , Notify : : PeerUpdate : : Flag : : MembersChanged ) ; <nl> } <nl> - Auth ( ) . data ( ) . removeMegagroupParticipant ( megagroup , user ) ; <nl> + _owner - > removeMegagroupParticipant ( megagroup , user ) ; <nl> if ( megagroup - > membersCount ( ) > 1 ) { <nl> megagroup - > setMembersCount ( megagroup - > membersCount ( ) - 1 ) ; <nl> } else { <nl> void History : : applyServiceChanges ( <nl> if ( d . vphoto . type ( ) = = mtpc_photo ) { <nl> auto & sizes = d . vphoto . c_photo ( ) . vsizes . v ; <nl> if ( ! sizes . isEmpty ( ) ) { <nl> - auto photo = Auth ( ) . data ( ) . photo ( d . vphoto . c_photo ( ) ) ; <nl> + auto photo = _owner - > photo ( d . vphoto . c_photo ( ) ) ; <nl> if ( photo ) photo - > peer = peer ; <nl> auto & smallSize = sizes . front ( ) ; <nl> auto & bigSize = sizes . back ( ) ; <nl> void History : : addEdgesToSharedMedia ( ) { <nl> auto till = loadedAtBottom ( ) ? ServerMaxMsgId : maxMsgId ( ) ; <nl> for ( auto i = 0 ; i ! = Storage : : kSharedMediaTypeCount ; + + i ) { <nl> const auto type = static_cast < Storage : : SharedMediaType > ( i ) ; <nl> - Auth ( ) . storage ( ) . add ( Storage : : SharedMediaAddSlice ( <nl> + session ( ) . storage ( ) . add ( Storage : : SharedMediaAddSlice ( <nl> peer - > id , <nl> type , <nl> { } , <nl> void History : : addToSharedMedia ( <nl> for ( auto i = 0 ; i ! = Storage : : kSharedMediaTypeCount ; + + i ) { <nl> if ( ! medias [ i ] . empty ( ) ) { <nl> const auto type = static_cast < Storage : : SharedMediaType > ( i ) ; <nl> - Auth ( ) . storage ( ) . add ( Storage : : SharedMediaAddSlice ( <nl> + session ( ) . storage ( ) . add ( Storage : : SharedMediaAddSlice ( <nl> peer - > id , <nl> type , <nl> std : : move ( medias [ i ] ) , <nl> void History : : inboxRead ( MsgId upTo ) { <nl> } <nl> <nl> _firstUnreadView = nullptr ; <nl> - Auth ( ) . notifications ( ) . clearFromHistory ( this ) ; <nl> + session ( ) . notifications ( ) . clearFromHistory ( this ) ; <nl> } <nl> <nl> void History : : inboxRead ( not_null < const HistoryItem * > wasRead ) { <nl> void History : : setUnreadCount ( int newUnreadCount ) { <nl> const auto delta = unreadMarkDelta + ( unreadCountDelta <nl> ? * unreadCountDelta <nl> : newUnreadCount ) ; <nl> - App : : histories ( ) . unreadIncrement ( delta , mute ( ) ) ; <nl> + _owner - > unreadIncrement ( delta , mute ( ) ) ; <nl> <nl> const auto nowUnread = ( * _unreadCount > 0 ) | | _unreadMark ; <nl> const auto entriesDelta = ( wasUnread & & ! nowUnread ) <nl> void History : : setUnreadCount ( int newUnreadCount ) { <nl> : ( nowUnread & & ! wasUnread ) <nl> ? 1 <nl> : 0 ; <nl> - App : : histories ( ) . unreadEntriesChanged ( <nl> + _owner - > unreadEntriesChanged ( <nl> entriesDelta , <nl> mute ( ) ? entriesDelta : 0 ) ; <nl> } <nl> void History : : setUnreadMark ( bool unread ) { <nl> if ( ! _unreadCount | | ! * _unreadCount ) { <nl> if ( inChatList ( Dialogs : : Mode : : All ) ) { <nl> const auto delta = _unreadMark ? 1 : - 1 ; <nl> - App : : histories ( ) . unreadIncrement ( delta , mute ( ) ) ; <nl> - App : : histories ( ) . unreadEntriesChanged ( <nl> + _owner - > unreadIncrement ( delta , mute ( ) ) ; <nl> + _owner - > unreadEntriesChanged ( <nl> delta , <nl> mute ( ) ? delta : 0 ) ; <nl> <nl> bool History : : changeMute ( bool newMute ) { <nl> feed - > unreadCountChanged ( unreadCountDelta , mutedCountDelta ) ; <nl> } <nl> } else { <nl> - Auth ( ) . api ( ) . requestDialogEntry ( this ) ; <nl> - Auth ( ) . api ( ) . requestDialogEntry ( feed ) ; <nl> + session ( ) . api ( ) . requestDialogEntry ( this ) ; <nl> + session ( ) . api ( ) . requestDialogEntry ( feed ) ; <nl> } <nl> } <nl> if ( inChatList ( Dialogs : : Mode : : All ) ) { <nl> if ( const auto count = historiesUnreadCount ( ) ) { <nl> - App : : histories ( ) . unreadMuteChanged ( count , _mute ) ; <nl> + _owner - > unreadMuteChanged ( count , _mute ) ; <nl> <nl> const auto entriesWithUnreadDelta = 0 ; <nl> const auto mutedEntriesWithUnreadDelta = _mute ? 1 : - 1 ; <nl> - App : : histories ( ) . unreadEntriesChanged ( <nl> + _owner - > unreadEntriesChanged ( <nl> entriesWithUnreadDelta , <nl> mutedEntriesWithUnreadDelta ) ; <nl> <nl> std : : shared_ptr < AdminLog : : LocalIdManager > History : : adminLogIdManager ( ) { <nl> TimeId History : : adjustChatListTimeId ( ) const { <nl> const auto result = chatsListTimeId ( ) ; <nl> if ( const auto draft = cloudDraft ( ) ) { <nl> - if ( ! Data : : draftIsNull ( draft ) & & ! Auth ( ) . supportMode ( ) ) { <nl> + if ( ! Data : : draftIsNull ( draft ) & & ! session ( ) . supportMode ( ) ) { <nl> return std : : max ( result , draft - > date ) ; <nl> } <nl> } <nl> void History : : getReadyFor ( MsgId msgId ) { <nl> void History : : setNotLoadedAtBottom ( ) { <nl> _loadedAtBottom = false ; <nl> <nl> - Auth ( ) . storage ( ) . invalidate ( <nl> + session ( ) . storage ( ) . invalidate ( <nl> Storage : : SharedMediaInvalidateBottom ( peer - > id ) ) ; <nl> if ( const auto channel = peer - > asChannel ( ) ) { <nl> if ( const auto feed = channel - > feed ( ) ) { <nl> - Auth ( ) . storage ( ) . invalidate ( <nl> + session ( ) . storage ( ) . invalidate ( <nl> Storage : : FeedMessagesInvalidateBottom ( <nl> feed - > id ( ) ) ) ; <nl> } <nl> void History : : setNotLoadedAtBottom ( ) { <nl> void History : : markFullyLoaded ( ) { <nl> _loadedAtTop = _loadedAtBottom = true ; <nl> if ( isEmpty ( ) ) { <nl> - Auth ( ) . storage ( ) . remove ( Storage : : SharedMediaRemoveAll ( peer - > id ) ) ; <nl> + session ( ) . storage ( ) . remove ( <nl> + Storage : : SharedMediaRemoveAll ( peer - > id ) ) ; <nl> if ( const auto channel = peer - > asChannel ( ) ) { <nl> if ( const auto feed = channel - > feed ( ) ) { <nl> - Auth ( ) . storage ( ) . remove ( Storage : : FeedMessagesRemoveAll ( <nl> - feed - > id ( ) , <nl> - channel - > bareId ( ) ) ) ; <nl> + session ( ) . storage ( ) . remove ( <nl> + Storage : : FeedMessagesRemoveAll ( <nl> + feed - > id ( ) , <nl> + channel - > bareId ( ) ) ) ; <nl> } <nl> } <nl> } <nl> void History : : updateChatListExistence ( ) { <nl> if ( const auto channel = peer - > asChannel ( ) ) { <nl> if ( ! channel - > feed ( ) ) { <nl> / / After ungrouping from a feed we need to load dialog . <nl> - Auth ( ) . api ( ) . requestDialogEntry ( this ) ; <nl> + session ( ) . api ( ) . requestDialogEntry ( this ) ; <nl> } <nl> } <nl> } <nl> void History : : applyDialog ( const MTPDdialog & data ) { <nl> data . vtop_message . v ) ; <nl> if ( const auto item = App : : histItemById ( topMessageId ) ) { <nl> if ( item - > date ( ) < = channel - > date ) { <nl> - Auth ( ) . api ( ) . requestSelfParticipant ( channel ) ; <nl> + session ( ) . api ( ) . requestSelfParticipant ( channel ) ; <nl> } <nl> } <nl> } <nl> } <nl> - Auth ( ) . data ( ) . applyNotifySetting ( <nl> + _owner - > applyNotifySetting ( <nl> MTP_notifyPeer ( data . vpeer ) , <nl> data . vnotify_settings ) ; <nl> <nl> void History : : applyDialog ( const MTPDdialog & data ) { <nl> } <nl> <nl> bool History : : clearUnreadOnClientSide ( ) const { <nl> - if ( ! Auth ( ) . supportMode ( ) ) { <nl> + if ( ! session ( ) . supportMode ( ) ) { <nl> return false ; <nl> } <nl> if ( const auto user = peer - > asUser ( ) ) { <nl> void History : : resizeToWidth ( int newWidth ) { <nl> _height = y ; <nl> } <nl> <nl> + Data : : Session & History : : owner ( ) const { <nl> + return * _owner ; <nl> + } <nl> + <nl> + AuthSession & History : : session ( ) const { <nl> + return _owner - > session ( ) ; <nl> + } <nl> + <nl> ChannelId History : : channelId ( ) const { <nl> return peerToChannel ( peer - > id ) ; <nl> } <nl> HistoryService * History : : insertJoinedMessage ( bool unread ) { <nl> } <nl> <nl> MTPDmessage : : Flags flags = 0 ; <nl> - if ( inviter - > id = = Auth ( ) . userPeerId ( ) ) { <nl> + if ( inviter - > id = = session ( ) . userPeerId ( ) ) { <nl> unread = false ; <nl> / / } else if ( unread ) { <nl> / / flags | = MTPDmessage : : Flag : : f_unread ; <nl> void History : : clearBlocks ( bool leaveItems ) { <nl> forgetScrollState ( ) ; <nl> } <nl> if ( leaveItems ) { <nl> - Auth ( ) . data ( ) . notifyHistoryUnloaded ( this ) ; <nl> + _owner - > notifyHistoryUnloaded ( this ) ; <nl> } else { <nl> setLastMessage ( nullptr ) ; <nl> notifies . clear ( ) ; <nl> - Auth ( ) . data ( ) . notifyHistoryCleared ( this ) ; <nl> + _owner - > notifyHistoryCleared ( this ) ; <nl> } <nl> blocks . clear ( ) ; <nl> if ( leaveItems ) { <nl> void History : : clearBlocks ( bool leaveItems ) { <nl> } <nl> clearLastKeyboard ( ) ; <nl> } <nl> - Auth ( ) . data ( ) . notifyHistoryChangeDelayed ( this ) ; <nl> + _owner - > notifyHistoryChangeDelayed ( this ) ; <nl> <nl> _loadedAtTop = false ; <nl> _loadedAtBottom = ! leaveItems ; <nl> void History : : clearUpTill ( MsgId availableMinId ) { <nl> } while ( ! isEmpty ( ) ) ; <nl> <nl> if ( ! lastMessageKnown ( ) ) { <nl> - Auth ( ) . api ( ) . requestDialogEntry ( this ) ; <nl> + session ( ) . api ( ) . requestDialogEntry ( this ) ; <nl> } <nl> - Auth ( ) . data ( ) . sendHistoryChangeNotifications ( ) ; <nl> + _owner - > sendHistoryChangeNotifications ( ) ; <nl> } <nl> <nl> void History : : applyGroupAdminChanges ( <nl> void History : : applyGroupAdminChanges ( <nl> void History : : changedInChatListHook ( Dialogs : : Mode list , bool added ) { <nl> if ( list = = Dialogs : : Mode : : All ) { <nl> if ( const auto delta = historiesUnreadCount ( ) * ( added ? 1 : - 1 ) ) { <nl> - App : : histories ( ) . unreadIncrement ( delta , mute ( ) ) ; <nl> + _owner - > unreadIncrement ( delta , mute ( ) ) ; <nl> <nl> const auto entriesDelta = added ? 1 : - 1 ; <nl> - App : : histories ( ) . unreadEntriesChanged ( <nl> + _owner - > unreadEntriesChanged ( <nl> entriesDelta , <nl> mute ( ) ? entriesDelta : 0 ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / history . h <nl> ppp b / Telegram / SourceFiles / history / history . h <nl> class AuthSession ; <nl> <nl> namespace Data { <nl> struct Draft ; <nl> + class Session ; <nl> } / / namespace Data <nl> <nl> namespace Dialogs { <nl> enum NewMessageType : char { <nl> NewMessageExisting , <nl> } ; <nl> <nl> - class Histories { <nl> - public : <nl> - Histories ( ) ; <nl> - <nl> - void registerSendAction ( <nl> - not_null < History * > history , <nl> - not_null < UserData * > user , <nl> - const MTPSendMessageAction & action , <nl> - TimeId when ) ; <nl> - void step_typings ( TimeMs ms , bool timer ) ; <nl> - <nl> - History * find ( PeerId peerId ) const ; <nl> - not_null < History * > findOrInsert ( PeerId peerId ) ; <nl> - <nl> - void clear ( ) ; <nl> - void remove ( const PeerId & peer ) ; <nl> - <nl> - HistoryItem * addNewMessage ( const MTPMessage & msg , NewMessageType type ) ; <nl> - <nl> - / / When typing in this history started . <nl> - typedef QMap < History * , TimeMs > TypingHistories ; <nl> - TypingHistories typing ; <nl> - BasicAnimation _a_typings ; <nl> - <nl> - int unreadBadge ( ) const ; <nl> - bool unreadBadgeMuted ( ) const ; <nl> - int unreadBadgeIgnoreOne ( History * history ) const ; <nl> - bool unreadBadgeMutedIgnoreOne ( History * history ) const ; <nl> - int unreadOnlyMutedBadge ( ) const ; <nl> - <nl> - void unreadIncrement ( int count , bool muted ) ; <nl> - void unreadMuteChanged ( int count , bool muted ) ; <nl> - void unreadEntriesChanged ( <nl> - int withUnreadDelta , <nl> - int mutedWithUnreadDelta ) ; <nl> - <nl> - struct SendActionAnimationUpdate { <nl> - History * history ; <nl> - int width ; <nl> - int height ; <nl> - bool textUpdated ; <nl> - } ; <nl> - base : : Observable < SendActionAnimationUpdate > & sendActionAnimationUpdated ( ) { <nl> - return _sendActionAnimationUpdated ; <nl> - } <nl> - void selfDestructIn ( not_null < HistoryItem * > item , TimeMs delay ) ; <nl> - <nl> - private : <nl> - void checkSelfDestructItems ( ) ; <nl> - int computeUnreadBadge ( <nl> - int full , <nl> - int muted , <nl> - int entriesFull , <nl> - int entriesMuted ) const ; <nl> - bool computeUnreadBadgeMuted ( <nl> - int full , <nl> - int muted , <nl> - int entriesFull , <nl> - int entriesMuted ) const ; <nl> - <nl> - std : : unordered_map < PeerId , std : : unique_ptr < History > > _map ; <nl> - <nl> - int _unreadFull = 0 ; <nl> - int _unreadMuted = 0 ; <nl> - int _unreadEntriesFull = 0 ; <nl> - int _unreadEntriesMuted = 0 ; <nl> - base : : Observable < SendActionAnimationUpdate > _sendActionAnimationUpdated ; <nl> - <nl> - base : : Timer _selfDestructTimer ; <nl> - std : : vector < FullMsgId > _selfDestructItems ; <nl> - <nl> - } ; <nl> - <nl> enum class UnreadMentionType { <nl> New , / / when new message is added to history <nl> Existing , / / when some messages slice was received <nl> } ; <nl> <nl> - class History : public Dialogs : : Entry { <nl> + class History final : public Dialogs : : Entry { <nl> public : <nl> using Element = HistoryView : : Element ; <nl> <nl> - History ( const PeerId & peerId ) ; <nl> + History ( not_null < Data : : Session * > owner , const PeerId & peerId ) ; <nl> History ( const History & ) = delete ; <nl> History & operator = ( const History & ) = delete ; <nl> <nl> + Data : : Session & owner ( ) const ; <nl> + AuthSession & session ( ) const ; <nl> + <nl> ChannelId channelId ( ) const ; <nl> bool isChannel ( ) const ; <nl> bool isMegagroup ( ) const ; <nl> class History : public Dialogs : : Entry { <nl> <nl> void viewReplaced ( not_null < const Element * > was , Element * now ) ; <nl> <nl> + not_null < Data : : Session * > _owner ; <nl> Flags _flags = 0 ; <nl> bool _mute = false ; <nl> int _width = 0 ; <nl> mmm a / Telegram / SourceFiles / history / history_item . cpp <nl> ppp b / Telegram / SourceFiles / history / history_item . cpp <nl> TimeId HistoryItem : : date ( ) const { <nl> } <nl> <nl> void HistoryItem : : finishEdition ( int oldKeyboardTop ) { <nl> - Auth ( ) . data ( ) . requestItemViewRefresh ( this ) ; <nl> + _history - > owner ( ) . requestItemViewRefresh ( this ) ; <nl> invalidateChatsListEntry ( ) ; <nl> - if ( const auto group = Auth ( ) . data ( ) . groups ( ) . find ( this ) ) { <nl> + if ( const auto group = _history - > owner ( ) . groups ( ) . find ( this ) ) { <nl> const auto leader = group - > items . back ( ) ; <nl> if ( leader ! = this ) { <nl> - Auth ( ) . data ( ) . requestItemViewRefresh ( leader ) ; <nl> + _history - > owner ( ) . requestItemViewRefresh ( leader ) ; <nl> leader - > invalidateChatsListEntry ( ) ; <nl> } <nl> } <nl> void HistoryItem : : setGroupId ( MessageGroupId groupId ) { <nl> Expects ( ! _groupId ) ; <nl> <nl> _groupId = groupId ; <nl> - Auth ( ) . data ( ) . groups ( ) . registerMessage ( this ) ; <nl> + _history - > owner ( ) . groups ( ) . registerMessage ( this ) ; <nl> } <nl> <nl> HistoryMessageReplyMarkup * HistoryItem : : inlineReplyMarkup ( ) { <nl> void HistoryItem : : addLogEntryOriginal ( <nl> Expects ( isLogEntry ( ) ) ; <nl> <nl> AddComponents ( HistoryMessageLogEntryOriginal : : Bit ( ) ) ; <nl> - Get < HistoryMessageLogEntryOriginal > ( ) - > page = Auth ( ) . data ( ) . webpage ( <nl> + Get < HistoryMessageLogEntryOriginal > ( ) - > page = _history - > owner ( ) . webpage ( <nl> localId , <nl> label , <nl> content ) ; <nl> UserData * HistoryItem : : getMessageBot ( ) const { <nl> } ; <nl> <nl> void HistoryItem : : destroy ( ) { <nl> - const auto history = this - > history ( ) ; <nl> if ( isLogEntry ( ) ) { <nl> Assert ( ! mainView ( ) ) ; <nl> } else { <nl> void HistoryItem : : destroy ( ) { <nl> eraseFromUnreadMentions ( ) ; <nl> if ( IsServerMsgId ( id ) ) { <nl> if ( const auto types = sharedMediaTypes ( ) ) { <nl> - Auth ( ) . storage ( ) . remove ( Storage : : SharedMediaRemoveOne ( <nl> - history - > peer - > id , <nl> + _history - > session ( ) . storage ( ) . remove ( Storage : : SharedMediaRemoveOne ( <nl> + _history - > peer - > id , <nl> types , <nl> id ) ) ; <nl> } <nl> } else { <nl> - Auth ( ) . api ( ) . cancelLocalItem ( this ) ; <nl> + _history - > session ( ) . api ( ) . cancelLocalItem ( this ) ; <nl> } <nl> _history - > itemRemoved ( this ) ; <nl> } <nl> void HistoryItem : : destroy ( ) { <nl> <nl> void HistoryItem : : refreshMainView ( ) { <nl> if ( const auto view = mainView ( ) ) { <nl> - Auth ( ) . data ( ) . notifyHistoryChangeDelayed ( _history ) ; <nl> + _history - > owner ( ) . notifyHistoryChangeDelayed ( _history ) ; <nl> view - > refreshInBlock ( ) ; <nl> } <nl> } <nl> <nl> void HistoryItem : : removeMainView ( ) { <nl> if ( const auto view = mainView ( ) ) { <nl> - Auth ( ) . data ( ) . notifyHistoryChangeDelayed ( _history ) ; <nl> + _history - > owner ( ) . notifyHistoryChangeDelayed ( _history ) ; <nl> view - > removeFromBlock ( ) ; <nl> } <nl> } <nl> void HistoryItem : : indexAsNewItem ( ) { <nl> addToUnreadMentions ( UnreadMentionType : : New ) ; <nl> CrashReports : : ClearAnnotation ( " addToUnreadMentions " ) ; <nl> if ( const auto types = sharedMediaTypes ( ) ) { <nl> - Auth ( ) . storage ( ) . add ( Storage : : SharedMediaAddNew ( <nl> + _history - > session ( ) . storage ( ) . add ( Storage : : SharedMediaAddNew ( <nl> history ( ) - > peer - > id , <nl> types , <nl> id ) ) ; <nl> } <nl> if ( const auto channel = history ( ) - > peer - > asChannel ( ) ) { <nl> if ( const auto feed = channel - > feed ( ) ) { <nl> - Auth ( ) . storage ( ) . add ( Storage : : FeedMessagesAddNew ( <nl> + _history - > session ( ) . storage ( ) . add ( Storage : : FeedMessagesAddNew ( <nl> feed - > id ( ) , <nl> position ( ) ) ) ; <nl> } <nl> void HistoryItem : : setRealId ( MsgId newId ) { <nl> } <nl> } <nl> <nl> - Auth ( ) . data ( ) . notifyItemIdChange ( { this , oldId } ) ; <nl> - Auth ( ) . data ( ) . requestItemRepaint ( this ) ; <nl> + _history - > owner ( ) . notifyItemIdChange ( { this , oldId } ) ; <nl> + _history - > owner ( ) . requestItemRepaint ( this ) ; <nl> } <nl> <nl> bool HistoryItem : : isPinned ( ) const { <nl> void HistoryItem : : drawInDialog ( <nl> } <nl> <nl> HistoryItem : : ~ HistoryItem ( ) { <nl> - Auth ( ) . data ( ) . notifyItemRemoved ( this ) ; <nl> + _history - > owner ( ) . notifyItemRemoved ( this ) ; <nl> App : : historyUnregItem ( this ) ; <nl> if ( id < 0 & & ! App : : quitting ( ) ) { <nl> - Auth ( ) . uploader ( ) . cancel ( fullId ( ) ) ; <nl> + _history - > session ( ) . uploader ( ) . cancel ( fullId ( ) ) ; <nl> } <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / history / history_item_components . cpp <nl> ppp b / Telegram / SourceFiles / history / history_item_components . cpp <nl> For license and copyright information please follow this link : <nl> # include " ui / effects / ripple_animation . h " <nl> # include " ui / image / image . h " <nl> # include " ui / text_options . h " <nl> + # include " history / history . h " <nl> # include " history / history_message . h " <nl> # include " history / view / history_view_service_message . h " <nl> # include " history / media / history_media_document . h " <nl> # include " media / media_audio . h " <nl> # include " media / player / media_player_instance . h " <nl> - # include " auth_session . h " <nl> # include " data / data_media_types . h " <nl> # include " data / data_session . h " <nl> # include " styles / style_widgets . h " <nl> bool HistoryMessageReply : : updateData ( <nl> replyToMsgId = 0 ; <nl> } <nl> if ( force ) { <nl> - Auth ( ) . data ( ) . requestItemResize ( holder ) ; <nl> + holder - > history ( ) - > owner ( ) . requestItemResize ( holder ) ; <nl> } <nl> return ( replyToMsg | | ! replyToMsgId ) ; <nl> } <nl> void HistoryMessageReply : : itemRemoved ( <nl> HistoryItem * removed ) { <nl> if ( replyToMsg = = removed ) { <nl> clearData ( holder ) ; <nl> - Auth ( ) . data ( ) . requestItemResize ( holder ) ; <nl> + holder - > history ( ) - > owner ( ) . requestItemResize ( holder ) ; <nl> } <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / history / history_message . cpp <nl> ppp b / Telegram / SourceFiles / history / history_message . cpp <nl> void FastShareMessage ( not_null < HistoryItem * > item ) { <nl> MessageIdsList msgIds ; <nl> base : : flat_set < mtpRequestId > requests ; <nl> } ; <nl> + const auto history = item - > history ( ) ; <nl> const auto data = std : : make_shared < ShareData > ( <nl> - item - > history ( ) - > peer , <nl> - Auth ( ) . data ( ) . itemOrItsGroup ( item ) ) ; <nl> - const auto isGroup = ( Auth ( ) . data ( ) . groups ( ) . find ( item ) ! = nullptr ) ; <nl> + history - > peer , <nl> + history - > owner ( ) . itemOrItsGroup ( item ) ) ; <nl> + const auto isGroup = ( history - > owner ( ) . groups ( ) . find ( item ) ! = nullptr ) ; <nl> const auto isGame = item - > getMessageBot ( ) <nl> & & item - > media ( ) <nl> & & ( item - > media ( ) - > game ( ) ! = nullptr ) ; <nl> void FastShareMessage ( not_null < HistoryItem * > item ) { <nl> if ( ! data - > requests . empty ( ) ) { <nl> return ; / / Share clicked already . <nl> } <nl> - auto items = Auth ( ) . data ( ) . idsToItems ( data - > msgIds ) ; <nl> + auto items = history - > owner ( ) . idsToItems ( data - > msgIds ) ; <nl> if ( items . empty ( ) | | result . empty ( ) ) { <nl> return ; <nl> } <nl> void FastShareMessage ( not_null < HistoryItem * > item ) { <nl> return ; <nl> } <nl> <nl> - auto doneCallback = [ data ] ( const MTPUpdates & updates , mtpRequestId requestId ) { <nl> - Auth ( ) . api ( ) . applyUpdates ( updates ) ; <nl> + auto doneCallback = [ = ] ( const MTPUpdates & updates , mtpRequestId requestId ) { <nl> + history - > session ( ) . api ( ) . applyUpdates ( updates ) ; <nl> data - > requests . remove ( requestId ) ; <nl> if ( data - > requests . empty ( ) ) { <nl> Ui : : Toast : : Show ( lang ( lng_share_done ) ) ; <nl> void FastShareMessage ( not_null < HistoryItem * > item ) { <nl> auto message = ApiWrap : : MessageToSend ( history ) ; <nl> message . textWithTags = comment ; <nl> message . clearDraft = false ; <nl> - Auth ( ) . api ( ) . sendMessage ( std : : move ( message ) ) ; <nl> + history - > session ( ) . api ( ) . sendMessage ( std : : move ( message ) ) ; <nl> } <nl> auto request = MTPmessages_ForwardMessages ( <nl> MTP_flags ( sendFlags ) , <nl> void HistoryMessage : : applyGroupAdminChanges ( <nl> } else { <nl> _flags & = ~ MTPDmessage_ClientFlag : : f_has_admin_badge ; <nl> } <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> } <nl> } <nl> <nl> void HistoryMessage : : createComponents ( const CreateConfig & config ) { <nl> if ( const auto reply = Get < HistoryMessageReply > ( ) ) { <nl> reply - > replyToMsgId = config . replyTo ; <nl> if ( ! reply - > updateData ( this ) ) { <nl> - Auth ( ) . api ( ) . requestMessageData ( <nl> + history ( ) - > session ( ) . api ( ) . requestMessageData ( <nl> history ( ) - > peer - > asChannel ( ) , <nl> reply - > replyToMsgId , <nl> HistoryDependentItemCallback ( fullId ( ) ) ) ; <nl> void HistoryMessage : : refreshMedia ( const MTPMessageMedia * media ) { <nl> } <nl> <nl> void HistoryMessage : : refreshSentMedia ( const MTPMessageMedia * media ) { <nl> - const auto wasGrouped = Auth ( ) . data ( ) . groups ( ) . isGrouped ( this ) ; <nl> + const auto wasGrouped = history ( ) - > owner ( ) . groups ( ) . isGrouped ( this ) ; <nl> refreshMedia ( media ) ; <nl> if ( wasGrouped ) { <nl> - Auth ( ) . data ( ) . groups ( ) . refreshMessage ( this ) ; <nl> + history ( ) - > owner ( ) . groups ( ) . refreshMessage ( this ) ; <nl> } else { <nl> - Auth ( ) . data ( ) . requestItemViewRefresh ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemViewRefresh ( this ) ; <nl> } <nl> } <nl> <nl> std : : unique_ptr < Data : : Media > HistoryMessage : : CreateMedia ( <nl> return media . vphoto . match ( [ & ] ( const MTPDphoto & photo ) - > Result { <nl> return std : : make_unique < Data : : MediaPhoto > ( <nl> item , <nl> - Auth ( ) . data ( ) . photo ( photo ) ) ; <nl> + item - > history ( ) - > owner ( ) . photo ( photo ) ) ; <nl> } , [ ] ( const MTPDphotoEmpty & ) - > Result { <nl> return nullptr ; <nl> } ) ; <nl> std : : unique_ptr < Data : : Media > HistoryMessage : : CreateMedia ( <nl> return document . match ( [ & ] ( const MTPDdocument & document ) - > Result { <nl> return std : : make_unique < Data : : MediaFile > ( <nl> item , <nl> - Auth ( ) . data ( ) . document ( document ) ) ; <nl> + item - > history ( ) - > owner ( ) . document ( document ) ) ; <nl> } , [ ] ( const MTPDdocumentEmpty & ) - > Result { <nl> return nullptr ; <nl> } ) ; <nl> std : : unique_ptr < Data : : Media > HistoryMessage : : CreateMedia ( <nl> } , [ & ] ( const MTPDwebPagePending & webpage ) - > Result { <nl> return std : : make_unique < Data : : MediaWebPage > ( <nl> item , <nl> - Auth ( ) . data ( ) . webpage ( webpage ) ) ; <nl> + item - > history ( ) - > owner ( ) . webpage ( webpage ) ) ; <nl> } , [ & ] ( const MTPDwebPage & webpage ) - > Result { <nl> return std : : make_unique < Data : : MediaWebPage > ( <nl> item , <nl> - Auth ( ) . data ( ) . webpage ( webpage ) ) ; <nl> + item - > history ( ) - > owner ( ) . webpage ( webpage ) ) ; <nl> } , [ ] ( const MTPDwebPageNotModified & ) - > Result { <nl> LOG ( ( " API Error : " <nl> " webPageNotModified is unexpected in message media . " ) ) ; <nl> std : : unique_ptr < Data : : Media > HistoryMessage : : CreateMedia ( <nl> return media . vgame . match ( [ & ] ( const MTPDgame & game ) { <nl> return std : : make_unique < Data : : MediaGame > ( <nl> item , <nl> - Auth ( ) . data ( ) . game ( game ) ) ; <nl> + item - > history ( ) - > owner ( ) . game ( game ) ) ; <nl> } ) ; <nl> } , [ & ] ( const MTPDmessageMediaInvoice & media ) - > Result { <nl> return std : : make_unique < Data : : MediaInvoice > ( item , media ) ; <nl> } , [ & ] ( const MTPDmessageMediaPoll & media ) - > Result { <nl> return std : : make_unique < Data : : MediaPoll > ( <nl> item , <nl> - Auth ( ) . data ( ) . poll ( media ) ) ; <nl> + item - > history ( ) - > owner ( ) . poll ( media ) ) ; <nl> } , [ ] ( const MTPDmessageMediaEmpty & ) - > Result { <nl> return nullptr ; <nl> } , [ ] ( const MTPDmessageMediaUnsupported & ) - > Result { <nl> void HistoryMessage : : updateSentMedia ( const MTPMessageMedia * media ) { <nl> refreshSentMedia ( media ) ; <nl> } <nl> } <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> } <nl> <nl> void HistoryMessage : : addToUnreadMentions ( UnreadMentionType type ) { <nl> void HistoryMessage : : setReplyMarkup ( const MTPReplyMarkup * markup ) { <nl> if ( Has < HistoryMessageReplyMarkup > ( ) ) { <nl> RemoveComponents ( HistoryMessageReplyMarkup : : Bit ( ) ) ; <nl> } <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> Notify : : replyMarkupUpdated ( this ) ; <nl> } <nl> return ; <nl> void HistoryMessage : : setReplyMarkup ( const MTPReplyMarkup * markup ) { <nl> changed = true ; <nl> } <nl> if ( changed ) { <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> Notify : : replyMarkupUpdated ( this ) ; <nl> } <nl> } else { <nl> void HistoryMessage : : setReplyMarkup ( const MTPReplyMarkup * markup ) { <nl> AddComponents ( HistoryMessageReplyMarkup : : Bit ( ) ) ; <nl> } <nl> Get < HistoryMessageReplyMarkup > ( ) - > create ( * markup ) ; <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> Notify : : replyMarkupUpdated ( this ) ; <nl> } <nl> } <nl> void HistoryMessage : : setViewsCount ( int32 count ) { <nl> ? 0 <nl> : st : : msgDateFont - > width ( views - > _viewsText ) ; <nl> if ( was = = views - > _viewsWidth ) { <nl> - Auth ( ) . data ( ) . requestItemRepaint ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemRepaint ( this ) ; <nl> } else { <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> } <nl> } <nl> <nl> void HistoryMessage : : setRealId ( MsgId newId ) { <nl> HistoryItem : : setRealId ( newId ) ; <nl> <nl> - Auth ( ) . data ( ) . groups ( ) . refreshMessage ( this ) ; <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . groups ( ) . refreshMessage ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> if ( const auto reply = Get < HistoryMessageReply > ( ) ) { <nl> if ( reply - > replyToLink ( ) ) { <nl> reply - > setReplyToLinkFrom ( this ) ; <nl> mmm a / Telegram / SourceFiles / history / history_service . cpp <nl> ppp b / Telegram / SourceFiles / history / history_service . cpp <nl> void HistoryService : : setMessageByAction ( const MTPmessageAction & action ) { <nl> if ( auto channel = history ( ) - > peer - > asMegagroup ( ) ) { <nl> auto & users = action . c_messageActionChatAddUser ( ) . vusers ; <nl> for_const ( auto & item , users . v ) { <nl> - if ( item . v = = Auth ( ) . userId ( ) ) { <nl> + if ( item . v = = history ( ) - > session ( ) . userId ( ) ) { <nl> channel - > mgInfo - > joinedMessageFound = true ; <nl> break ; <nl> } <nl> void HistoryService : : setMessageByAction ( const MTPmessageAction & action ) { <nl> _media = std : : make_unique < Data : : MediaPhoto > ( <nl> this , <nl> history ( ) - > peer , <nl> - Auth ( ) . data ( ) . photo ( photo . c_photo ( ) ) ) ; <nl> + history ( ) - > owner ( ) . photo ( photo . c_photo ( ) ) ) ; <nl> } <nl> } break ; <nl> <nl> bool HistoryService : : updateDependent ( bool force ) { <nl> updateDependentText ( ) ; <nl> } <nl> if ( force & & gotDependencyItem ) { <nl> - Auth ( ) . notifications ( ) . checkDelayed ( ) ; <nl> + history ( ) - > session ( ) . notifications ( ) . checkDelayed ( ) ; <nl> } <nl> return ( dependent - > msg | | ! dependent - > msgId ) ; <nl> } <nl> void HistoryService : : setServiceText ( const PreparedText & prepared ) { <nl> } <nl> <nl> void HistoryService : : markMediaAsReadHook ( ) { <nl> - if ( auto selfdestruct = Get < HistoryServiceSelfDestruct > ( ) ) { <nl> + if ( const auto selfdestruct = Get < HistoryServiceSelfDestruct > ( ) ) { <nl> if ( ! selfdestruct - > destructAt ) { <nl> selfdestruct - > destructAt = getms ( true ) + selfdestruct - > timeToLive ; <nl> - App : : histories ( ) . selfDestructIn ( this , selfdestruct - > timeToLive ) ; <nl> + history ( ) - > owner ( ) . selfDestructIn ( this , selfdestruct - > timeToLive ) ; <nl> } <nl> } <nl> } <nl> void HistoryService : : createFromMtp ( const MTPDmessageService & message ) { <nl> if ( auto dependent = GetDependentData ( ) ) { <nl> dependent - > msgId = message . vreply_to_msg_id . v ; <nl> if ( ! updateDependent ( ) ) { <nl> - Auth ( ) . api ( ) . requestMessageData ( <nl> + history ( ) - > session ( ) . api ( ) . requestMessageData ( <nl> history ( ) - > peer - > asChannel ( ) , <nl> dependent - > msgId , <nl> HistoryDependentItemCallback ( fullId ( ) ) ) ; <nl> void HistoryService : : removeMedia ( ) { <nl> _media . reset ( ) ; <nl> _textWidth = - 1 ; <nl> _textHeight = 0 ; <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> } <nl> <nl> Storage : : SharedMediaTypesMask HistoryService : : sharedMediaTypes ( ) const { <nl> void HistoryService : : updateDependentText ( ) { <nl> } <nl> <nl> setServiceText ( text ) ; <nl> - Auth ( ) . data ( ) . requestItemResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestItemResize ( this ) ; <nl> if ( history ( ) - > textCachedFor = = this ) { <nl> history ( ) - > textCachedFor = nullptr ; <nl> } <nl> HistoryService : : ~ HistoryService ( ) { <nl> HistoryService : : PreparedText GenerateJoinedText ( <nl> not_null < History * > history , <nl> not_null < UserData * > inviter ) { <nl> - if ( inviter - > id ! = Auth ( ) . userPeerId ( ) ) { <nl> + if ( inviter - > id ! = history - > session ( ) . userPeerId ( ) ) { <nl> auto result = HistoryService : : PreparedText { } ; <nl> result . links . push_back ( inviter - > createOpenLink ( ) ) ; <nl> result . text = ( history - > isMegagroup ( ) <nl> HistoryService : : PreparedText GenerateJoinedText ( <nl> : lng_action_add_you ) ( lt_from , textcmdLink ( 1 , inviter - > name ) ) ; <nl> return result ; <nl> } else if ( history - > isMegagroup ( ) ) { <nl> - auto self = App : : user ( Auth ( ) . userPeerId ( ) ) ; <nl> + auto self = history - > session ( ) . user ( ) ; <nl> auto result = HistoryService : : PreparedText { } ; <nl> result . links . push_back ( self - > createOpenLink ( ) ) ; <nl> result . text = lng_action_user_joined ( <nl> mmm a / Telegram / SourceFiles / history / media / history_media . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media . cpp <nl> Storage : : SharedMediaTypesMask HistoryMedia : : sharedMediaTypes ( ) const { <nl> return { } ; <nl> } <nl> <nl> + not_null < History * > HistoryMedia : : history ( ) const { <nl> + return _parent - > history ( ) ; <nl> + } <nl> + <nl> bool HistoryMedia : : isDisplayed ( ) const { <nl> return true ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / media / history_media . h <nl> ppp b / Telegram / SourceFiles / history / media / history_media . h <nl> class HistoryMedia : public HistoryView : : Object { <nl> HistoryMedia ( not_null < Element * > parent ) : _parent ( parent ) { <nl> } <nl> <nl> + not_null < History * > history ( ) const ; <nl> + <nl> virtual TextWithEntities selectedText ( TextSelection selection ) const { <nl> return TextWithEntities ( ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / media / history_media_contact . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_contact . cpp <nl> For license and copyright information please follow this link : <nl> # include " lang / lang_keys . h " <nl> # include " layout . h " <nl> # include " mainwindow . h " <nl> - # include " auth_session . h " <nl> # include " boxes / add_contact_box . h " <nl> # include " history / history_item_components . h " <nl> # include " history / history_item . h " <nl> + # include " history / history . h " <nl> # include " history / view / history_view_element . h " <nl> # include " history / view / history_view_cursor_state . h " <nl> # include " window / window_controller . h " <nl> HistoryContact : : HistoryContact ( <nl> , _fname ( first ) <nl> , _lname ( last ) <nl> , _phone ( App : : formatPhone ( phone ) ) { <nl> - Auth ( ) . data ( ) . registerContactView ( userId , parent ) ; <nl> + history ( ) - > owner ( ) . registerContactView ( userId , parent ) ; <nl> <nl> _name . setText ( <nl> st : : semiboldTextStyle , <nl> HistoryContact : : HistoryContact ( <nl> } <nl> <nl> HistoryContact : : ~ HistoryContact ( ) { <nl> - Auth ( ) . data ( ) . unregisterContactView ( _userId , _parent ) ; <nl> + history ( ) - > owner ( ) . unregisterContactView ( _userId , _parent ) ; <nl> } <nl> <nl> void HistoryContact : : updateSharedContactUserId ( UserId userId ) { <nl> if ( _userId ! = userId ) { <nl> - Auth ( ) . data ( ) . unregisterContactView ( _userId , _parent ) ; <nl> + history ( ) - > owner ( ) . unregisterContactView ( _userId , _parent ) ; <nl> _userId = userId ; <nl> - Auth ( ) . data ( ) . registerContactView ( _userId , _parent ) ; <nl> + history ( ) - > owner ( ) . registerContactView ( _userId , _parent ) ; <nl> } <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / history / media / history_media_document . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_document . cpp <nl> For license and copyright information please follow this link : <nl> <nl> # include " lang / lang_keys . h " <nl> # include " layout . h " <nl> - # include " auth_session . h " <nl> # include " storage / localstorage . h " <nl> # include " media / media_audio . h " <nl> # include " media / player / media_player_instance . h " <nl> # include " history / history_item_components . h " <nl> + # include " history / history . h " <nl> # include " history / view / history_view_element . h " <nl> # include " history / view / history_view_cursor_state . h " <nl> # include " history / media / history_media_common . h " <nl> void HistoryDocument : : updatePressed ( QPoint point ) { <nl> nameright = st : : msgFilePadding . left ( ) ; <nl> } <nl> voice - > setSeekingCurrent ( snap ( ( point . x ( ) - nameleft ) / float64 ( width ( ) - nameleft - nameright ) , 0 . , 1 . ) ) ; <nl> - Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; <nl> } <nl> } <nl> } <nl> void HistoryDocument : : step_voiceProgress ( float64 ms , bool timer ) { <nl> voice - > _playback - > a_progress . update ( qMin ( dt , 1 . ) , anim : : linear ) ; <nl> } <nl> if ( timer ) { <nl> - Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; <nl> } <nl> } <nl> } <nl> void HistoryDocument : : parentTextUpdated ( ) { <nl> } else { <nl> RemoveComponents ( HistoryDocumentCaptioned : : Bit ( ) ) ; <nl> } <nl> - Auth ( ) . data ( ) . requestViewResize ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( _parent ) ; <nl> } <nl> <nl> TextWithEntities HistoryDocument : : getCaption ( ) const { <nl> mmm a / Telegram / SourceFiles / history / media / history_media_file . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_file . cpp <nl> For license and copyright information please follow this link : <nl> <nl> # include " lang / lang_keys . h " <nl> # include " layout . h " <nl> - # include " auth_session . h " <nl> # include " history / history_item . h " <nl> + # include " history / history . h " <nl> # include " data / data_document . h " <nl> # include " data / data_session . h " <nl> # include " styles / style_history . h " <nl> void HistoryFileMedia : : clickHandlerActiveChanged ( const ClickHandlerPtr & p , bool <nl> } <nl> <nl> void HistoryFileMedia : : thumbAnimationCallback ( ) { <nl> - Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; <nl> } <nl> <nl> void HistoryFileMedia : : clickHandlerPressedChanged ( <nl> const ClickHandlerPtr & handler , <nl> bool pressed ) { <nl> - Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; <nl> } <nl> <nl> void HistoryFileMedia : : setLinks ( <nl> void HistoryFileMedia : : step_radial ( TimeMs ms , bool timer ) { <nl> } ; <nl> if ( timer ) { <nl> if ( ! anim : : Disabled ( ) | | updateRadial ( ) ) { <nl> - Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; <nl> } <nl> } else { <nl> updateRadial ( ) ; <nl> mmm a / Telegram / SourceFiles / history / media / history_media_game . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_game . cpp <nl> For license and copyright information please follow this link : <nl> <nl> # include " lang / lang_keys . h " <nl> # include " layout . h " <nl> - # include " auth_session . h " <nl> # include " history / history_item_components . h " <nl> + # include " history / history . h " <nl> # include " history / view / history_view_element . h " <nl> # include " history / view / history_view_cursor_state . h " <nl> # include " history / media / history_media_common . h " <nl> HistoryGame : : HistoryGame ( <nl> consumed , <nl> Ui : : ItemTextOptions ( parent - > data ( ) ) ) ; <nl> } <nl> - Auth ( ) . data ( ) . registerGameView ( _data , _parent ) ; <nl> + history ( ) - > owner ( ) . registerGameView ( _data , _parent ) ; <nl> } <nl> <nl> QSize HistoryGame : : countOptimalSize ( ) { <nl> void HistoryGame : : parentTextUpdated ( ) { <nl> } else { <nl> _description = Text ( st : : msgMinWidth - st : : webPageLeft ) ; <nl> } <nl> - Auth ( ) . data ( ) . requestViewResize ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( _parent ) ; <nl> } <nl> } <nl> <nl> HistoryGame : : ~ HistoryGame ( ) { <nl> - Auth ( ) . data ( ) . unregisterGameView ( _data , _parent ) ; <nl> + history ( ) - > owner ( ) . unregisterGameView ( _data , _parent ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / media / history_media_gif . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_gif . cpp <nl> For license and copyright information please follow this link : <nl> # include " lang / lang_keys . h " <nl> # include " layout . h " <nl> # include " mainwindow . h " <nl> - # include " auth_session . h " <nl> # include " media / media_audio . h " <nl> # include " media / media_clip_reader . h " <nl> # include " media / player / media_player_round_controller . h " <nl> For license and copyright information please follow this link : <nl> # include " boxes / confirm_box . h " <nl> # include " history / history_item_components . h " <nl> # include " history / history_item . h " <nl> + # include " history / history . h " <nl> # include " history / view / history_view_element . h " <nl> # include " history / view / history_view_cursor_state . h " <nl> # include " window / window_controller . h " <nl> void HistoryGif : : parentTextUpdated ( ) { <nl> _caption = ( _parent - > media ( ) = = this ) <nl> ? createCaption ( _parent - > data ( ) ) <nl> : Text ( ) ; <nl> - Auth ( ) . data ( ) . requestViewResize ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( _parent ) ; <nl> } <nl> <nl> int HistoryGif : : additionalWidth ( const HistoryMessageVia * via , const HistoryMessageReply * reply , const HistoryMessageForwarded * forwarded ) const { <nl> void HistoryGif : : clipCallback ( Media : : Clip : : Notification notification ) { <nl> auto stopped = false ; <nl> if ( reader - > autoPausedGif ( ) ) { <nl> auto amVisible = false ; <nl> - Auth ( ) . data ( ) . queryItemVisibility ( ) . notify ( <nl> + history ( ) - > owner ( ) . queryItemVisibility ( ) . notify ( <nl> { _parent - > data ( ) , & amVisible } , <nl> true ) ; <nl> if ( ! amVisible ) { / / Stop animation if it is not visible . <nl> void HistoryGif : : clipCallback ( Media : : Clip : : Notification notification ) { <nl> } <nl> } <nl> if ( ! stopped ) { <nl> - Auth ( ) . data ( ) . requestViewResize ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( _parent ) ; <nl> } <nl> } break ; <nl> <nl> case NotificationRepaint : { <nl> if ( ! reader - > currentDisplayed ( ) ) { <nl> - Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; <nl> } <nl> } break ; <nl> } <nl> void HistoryGif : : playAnimation ( bool autoplay ) { <nl> stopAnimation ( ) ; <nl> } else if ( _data - > loaded ( DocumentData : : FilePathResolveChecked ) ) { <nl> if ( ! cAutoPlayGif ( ) ) { <nl> - Auth ( ) . data ( ) . stopAutoplayAnimations ( ) ; <nl> + history ( ) - > owner ( ) . stopAutoplayAnimations ( ) ; <nl> } <nl> setClipReader ( Media : : Clip : : MakeReader ( <nl> _data , <nl> void HistoryGif : : playAnimation ( bool autoplay ) { <nl> void HistoryGif : : stopAnimation ( ) { <nl> if ( _gif ) { <nl> clearClipReader ( ) ; <nl> - Auth ( ) . data ( ) . requestViewResize ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( _parent ) ; <nl> _data - > unload ( ) ; <nl> } <nl> } <nl> <nl> void HistoryGif : : setClipReader ( Media : : Clip : : ReaderPointer gif ) { <nl> if ( _gif ) { <nl> - Auth ( ) . data ( ) . unregisterAutoplayAnimation ( _gif . get ( ) ) ; <nl> + history ( ) - > owner ( ) . unregisterAutoplayAnimation ( _gif . get ( ) ) ; <nl> } <nl> _gif = std : : move ( gif ) ; <nl> if ( _gif ) { <nl> - Auth ( ) . data ( ) . registerAutoplayAnimation ( _gif . get ( ) , _parent ) ; <nl> + history ( ) - > owner ( ) . registerAutoplayAnimation ( _gif . get ( ) , _parent ) ; <nl> } <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / history / media / history_media_grouped . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_grouped . cpp <nl> For license and copyright information please follow this link : <nl> <nl> # include " history / history_item_components . h " <nl> # include " history / history_message . h " <nl> + # include " history / history . h " <nl> # include " history / view / history_view_element . h " <nl> # include " history / view / history_view_cursor_state . h " <nl> # include " data / data_media_types . h " <nl> For license and copyright information please follow this link : <nl> # include " lang / lang_keys . h " <nl> # include " ui / grouped_layout . h " <nl> # include " ui / text_options . h " <nl> - # include " auth_session . h " <nl> # include " layout . h " <nl> # include " styles / style_history . h " <nl> <nl> void HistoryGroupedMedia : : updateNeedBubbleState ( ) { <nl> } <nl> <nl> void HistoryGroupedMedia : : parentTextUpdated ( ) { <nl> - Auth ( ) . data ( ) . requestViewResize ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( _parent ) ; <nl> } <nl> <nl> bool HistoryGroupedMedia : : needsBubble ( ) const { <nl> mmm a / Telegram / SourceFiles / history / media / history_media_photo . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_photo . cpp <nl> For license and copyright information please follow this link : <nl> # include " history / media / history_media_photo . h " <nl> <nl> # include " layout . h " <nl> - # include " auth_session . h " <nl> # include " history / history_item_components . h " <nl> # include " history / history_item . h " <nl> + # include " history / history . h " <nl> # include " history / view / history_view_element . h " <nl> # include " history / view / history_view_cursor_state . h " <nl> # include " history / media / history_media_common . h " <nl> void HistoryPhoto : : parentTextUpdated ( ) { <nl> _caption = ( _parent - > media ( ) = = this ) <nl> ? createCaption ( _parent - > data ( ) ) <nl> : Text ( ) ; <nl> - Auth ( ) . data ( ) . requestViewResize ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( _parent ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / media / history_media_poll . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_poll . cpp <nl> HistoryPoll : : HistoryPoll ( <nl> : HistoryMedia ( parent ) <nl> , _poll ( poll ) <nl> , _question ( st : : msgMinWidth / 2 ) { <nl> - Auth ( ) . data ( ) . registerPollView ( _poll , _parent ) ; <nl> + history ( ) - > owner ( ) . registerPollView ( _poll , _parent ) ; <nl> } <nl> <nl> QSize HistoryPoll : : countOptimalSize ( ) { <nl> ClickHandlerPtr HistoryPoll : : createAnswerClickHandler ( <nl> const auto option = answer . option ; <nl> const auto itemId = _parent - > data ( ) - > fullId ( ) ; <nl> return std : : make_shared < LambdaClickHandler > ( [ = ] { <nl> - Auth ( ) . api ( ) . sendPollVotes ( itemId , { option } ) ; <nl> + history ( ) - > session ( ) . api ( ) . sendPollVotes ( itemId , { option } ) ; <nl> } ) ; <nl> } <nl> <nl> void HistoryPoll : : resetAnswersAnimation ( ) const { <nl> <nl> void HistoryPoll : : step_radial ( TimeMs ms , bool timer ) { <nl> if ( timer & & ! anim : : Disabled ( ) ) { <nl> - Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; <nl> } <nl> } <nl> <nl> void HistoryPoll : : startAnswersAnimation ( ) const { <nl> data . opacity . start ( can ? 0 . : 1 . ) ; <nl> } <nl> _answersAnimation - > progress . start ( <nl> - [ = ] { Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; } , <nl> + [ = ] { history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; } , <nl> 0 . , <nl> 1 . , <nl> st : : historyPollDuration ) ; <nl> void HistoryPoll : : toggleRipple ( Answer & answer , bool pressed ) { <nl> ? st : : historyPollRippleOut <nl> : st : : historyPollRippleIn ) , <nl> std : : move ( mask ) , <nl> - [ = ] { Auth ( ) . data ( ) . requestViewRepaint ( _parent ) ; } ) ; <nl> + [ = ] { history ( ) - > owner ( ) . requestViewRepaint ( _parent ) ; } ) ; <nl> } <nl> const auto top = countAnswerTop ( answer , innerWidth ) ; <nl> answer . ripple - > add ( _lastLinkPoint - QPoint ( 0 , top ) ) ; <nl> void HistoryPoll : : toggleRipple ( Answer & answer , bool pressed ) { <nl> } <nl> <nl> HistoryPoll : : ~ HistoryPoll ( ) { <nl> - Auth ( ) . data ( ) . unregisterPollView ( _poll , _parent ) ; <nl> + history ( ) - > owner ( ) . unregisterPollView ( _poll , _parent ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / media / history_media_video . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_video . cpp <nl> For license and copyright information please follow this link : <nl> <nl> # include " history / media / history_media_common . h " <nl> # include " layout . h " <nl> - # include " auth_session . h " <nl> # include " history / history_item_components . h " <nl> # include " history / history_item . h " <nl> + # include " history / history . h " <nl> # include " history / view / history_view_element . h " <nl> # include " history / view / history_view_cursor_state . h " <nl> # include " ui / image / image . h " <nl> void HistoryVideo : : parentTextUpdated ( ) { <nl> _caption = ( _parent - > media ( ) = = this ) <nl> ? createCaption ( _parent - > data ( ) ) <nl> : Text ( ) ; <nl> - Auth ( ) . data ( ) . requestViewResize ( _parent ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( _parent ) ; <nl> } <nl> <nl> void HistoryVideo : : updateStatusText ( ) const { <nl> mmm a / Telegram / SourceFiles / history / media / history_media_web_page . cpp <nl> ppp b / Telegram / SourceFiles / history / media / history_media_web_page . cpp <nl> For license and copyright information please follow this link : <nl> # include " history / media / history_media_web_page . h " <nl> <nl> # include " layout . h " <nl> - # include " auth_session . h " <nl> # include " core / click_handler_types . h " <nl> # include " history / history_item_components . h " <nl> # include " history / history_item . h " <nl> + # include " history / history . h " <nl> # include " history / view / history_view_element . h " <nl> # include " history / view / history_view_cursor_state . h " <nl> # include " history / media / history_media_common . h " <nl> HistoryWebPage : : HistoryWebPage ( <nl> , _data ( data ) <nl> , _title ( st : : msgMinWidth - st : : webPageLeft ) <nl> , _description ( st : : msgMinWidth - st : : webPageLeft ) { <nl> - Auth ( ) . data ( ) . registerWebPageView ( _data , _parent ) ; <nl> + history ( ) - > owner ( ) . registerWebPageView ( _data , _parent ) ; <nl> } <nl> <nl> QSize HistoryWebPage : : countOptimalSize ( ) { <nl> int HistoryWebPage : : bottomInfoPadding ( ) const { <nl> } <nl> <nl> HistoryWebPage : : ~ HistoryWebPage ( ) { <nl> - Auth ( ) . data ( ) . unregisterWebPageView ( _data , _parent ) ; <nl> + history ( ) - > owner ( ) . unregisterWebPageView ( _data , _parent ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / view / history_view_element . cpp <nl> ppp b / Telegram / SourceFiles / history / view / history_view_element . cpp <nl> For license and copyright information please follow this link : <nl> # include " data / data_groups . h " <nl> # include " data / data_media_types . h " <nl> # include " lang / lang_keys . h " <nl> - # include " auth_session . h " <nl> # include " layout . h " <nl> # include " styles / style_history . h " <nl> <nl> Element : : Element ( <nl> , _data ( data ) <nl> , _dateTime ( ItemDateTime ( data ) ) <nl> , _context ( delegate - > elementContext ( ) ) { <nl> - Auth ( ) . data ( ) . registerItemView ( this ) ; <nl> + history ( ) - > owner ( ) . registerItemView ( this ) ; <nl> refreshMedia ( ) ; <nl> if ( _context = = Context : : History ) { <nl> - _data - > _history - > setHasPendingResizedItems ( ) ; <nl> + history ( ) - > setHasPendingResizedItems ( ) ; <nl> } <nl> } <nl> <nl> not_null < HistoryItem * > Element : : data ( ) const { <nl> return _data ; <nl> } <nl> <nl> + not_null < History * > Element : : history ( ) const { <nl> + return _data - > history ( ) ; <nl> + } <nl> + <nl> QDateTime Element : : dateTime ( ) const { <nl> return _dateTime ; <nl> } <nl> void Element : : refreshMedia ( ) { <nl> const auto item = data ( ) ; <nl> const auto media = item - > media ( ) ; <nl> if ( media & & media - > canBeGrouped ( ) ) { <nl> - if ( const auto group = Auth ( ) . data ( ) . groups ( ) . find ( item ) ) { <nl> + if ( const auto group = history ( ) - > owner ( ) . groups ( ) . find ( item ) ) { <nl> if ( group - > items . back ( ) ! = item ) { <nl> _media = nullptr ; <nl> _flags | = Flag : : HiddenByGroup ; <nl> void Element : : refreshMedia ( ) { <nl> this , <nl> group - > items ) ; <nl> if ( ! pendingResize ( ) ) { <nl> - Auth ( ) . data ( ) . requestViewResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( this ) ; <nl> } <nl> } <nl> return ; <nl> void Element : : destroyUnreadBar ( ) { <nl> return ; <nl> } <nl> RemoveComponents ( UnreadBar : : Bit ( ) ) ; <nl> - Auth ( ) . data ( ) . requestViewResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( this ) ; <nl> if ( data ( ) - > mainView ( ) = = this ) { <nl> recountAttachToPreviousInBlocks ( ) ; <nl> } <nl> void Element : : setUnreadBarCount ( int count ) { <nl> if ( data ( ) - > mainView ( ) = = this ) { <nl> recountAttachToPreviousInBlocks ( ) ; <nl> } <nl> - Auth ( ) . data ( ) . requestViewResize ( this ) ; <nl> + history ( ) - > owner ( ) . requestViewResize ( this ) ; <nl> } else { <nl> - Auth ( ) . data ( ) . requestViewRepaint ( this ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( this ) ; <nl> } <nl> } <nl> <nl> void Element : : clickHandlerActiveChanged ( <nl> } <nl> } <nl> App : : hoveredLinkItem ( active ? this : nullptr ) ; <nl> - Auth ( ) . data ( ) . requestViewRepaint ( this ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( this ) ; <nl> if ( const auto media = this - > media ( ) ) { <nl> media - > clickHandlerActiveChanged ( handler , active ) ; <nl> } <nl> void Element : : clickHandlerPressedChanged ( <nl> } <nl> } <nl> App : : pressedLinkItem ( pressed ? this : nullptr ) ; <nl> - Auth ( ) . data ( ) . requestViewRepaint ( this ) ; <nl> + history ( ) - > owner ( ) . requestViewRepaint ( this ) ; <nl> if ( const auto media = this - > media ( ) ) { <nl> media - > clickHandlerPressedChanged ( handler , pressed ) ; <nl> } <nl> Element : : ~ Element ( ) { <nl> _data - > clearMainView ( ) ; <nl> } <nl> if ( _context = = Context : : History ) { <nl> - Auth ( ) . data ( ) . notifyViewRemoved ( this ) ; <nl> + history ( ) - > owner ( ) . notifyViewRemoved ( this ) ; <nl> } <nl> - Auth ( ) . data ( ) . unregisterItemView ( this ) ; <nl> + history ( ) - > owner ( ) . unregisterItemView ( this ) ; <nl> } <nl> <nl> } / / namespace HistoryView <nl> mmm a / Telegram / SourceFiles / history / view / history_view_element . h <nl> ppp b / Telegram / SourceFiles / history / view / history_view_element . h <nl> class Element <nl> <nl> not_null < ElementDelegate * > delegate ( ) const ; <nl> not_null < HistoryItem * > data ( ) const ; <nl> + not_null < History * > history ( ) const ; <nl> HistoryMedia * media ( ) const ; <nl> Context context ( ) const ; <nl> void refreshDataId ( ) ; <nl> mmm a / Telegram / SourceFiles / history / view / history_view_message . cpp <nl> ppp b / Telegram / SourceFiles / history / view / history_view_message . cpp <nl> For license and copyright information please follow this link : <nl> # include " mainwidget . h " <nl> # include " mainwindow . h " <nl> # include " window / window_controller . h " <nl> - # include " auth_session . h " <nl> # include " layout . h " <nl> # include " styles / style_widgets . h " <nl> # include " styles / style_history . h " <nl> const style : : TextStyle & KeyboardStyle : : textStyle ( ) const { <nl> } <nl> <nl> void KeyboardStyle : : repaint ( not_null < const HistoryItem * > item ) const { <nl> - Auth ( ) . data ( ) . requestItemRepaint ( item ) ; <nl> + item - > history ( ) - > owner ( ) . requestItemRepaint ( item ) ; <nl> } <nl> <nl> int KeyboardStyle : : buttonRadius ( ) const { <nl> mmm a / Telegram / SourceFiles / history / view / history_view_top_bar_widget . cpp <nl> ppp b / Telegram / SourceFiles / history / view / history_view_top_bar_widget . cpp <nl> For license and copyright information please follow this link : <nl> # include " calls / calls_instance . h " <nl> # include " data / data_peer_values . h " <nl> # include " data / data_feed . h " <nl> + # include " data / data_session . h " <nl> # include " support / support_helper . h " <nl> # include " observer_peer . h " <nl> # include " apiwrap . h " <nl> TopBarWidget : : TopBarWidget ( <nl> if ( Adaptive : : OneColumn ( ) ) { <nl> createUnreadBadge ( ) ; <nl> } <nl> - subscribe ( <nl> - App : : histories ( ) . sendActionAnimationUpdated ( ) , <nl> - [ this ] ( const Histories : : SendActionAnimationUpdate & update ) { <nl> - if ( update . history = = _activeChat . history ( ) ) { <nl> - this - > update ( ) ; <nl> - } <nl> - } ) ; <nl> + Auth ( ) . data ( ) . sendActionAnimationUpdated ( <nl> + ) | rpl : : start_with_next ( [ = ] ( <nl> + const Data : : Session : : SendActionAnimationUpdate & update ) { <nl> + if ( update . history = = _activeChat . history ( ) ) { <nl> + this - > update ( ) ; <nl> + } <nl> + } , lifetime ( ) ) ; <nl> + <nl> using UpdateFlag = Notify : : PeerUpdate : : Flag ; <nl> auto flags = UpdateFlag : : UserHasCalls <nl> | UpdateFlag : : UserOnlineChanged <nl> void TopBarWidget : : updateUnreadBadge ( ) { <nl> if ( ! _unreadBadge ) return ; <nl> <nl> const auto history = _activeChat . history ( ) ; <nl> - const auto active = ! App : : histories ( ) . unreadBadgeMutedIgnoreOne ( history ) ; <nl> - const auto counter = App : : histories ( ) . unreadBadgeIgnoreOne ( history ) ; <nl> + const auto active = ! Auth ( ) . data ( ) . unreadBadgeMutedIgnoreOne ( history ) ; <nl> + const auto counter = Auth ( ) . data ( ) . unreadBadgeIgnoreOne ( history ) ; <nl> const auto text = [ & ] { <nl> if ( ! counter ) { <nl> return QString ( ) ; <nl> mmm a / Telegram / SourceFiles / info / info_controller . cpp <nl> ppp b / Telegram / SourceFiles / info / info_controller . cpp <nl> Controller : : Controller ( <nl> , _widget ( widget ) <nl> , _key ( memento - > key ( ) ) <nl> , _migrated ( memento - > migratedPeerId ( ) <nl> - ? App : : peer ( memento - > migratedPeerId ( ) ) <nl> + ? App : : peer ( memento - > migratedPeerId ( ) ) . get ( ) <nl> : nullptr ) <nl> , _section ( memento - > section ( ) ) { <nl> updateSearchControllers ( memento ) ; <nl> mmm a / Telegram / SourceFiles / mainwidget . cpp <nl> ppp b / Telegram / SourceFiles / mainwidget . cpp <nl> void MainWidget : : updateScrollColors ( ) { <nl> _history - > updateScrollColors ( ) ; <nl> } <nl> <nl> - void MainWidget : : setChatBackground ( const App : : WallPaper & wp ) { <nl> - _background = std : : make_unique < App : : WallPaper > ( wp ) ; <nl> + void MainWidget : : setChatBackground ( const Data : : WallPaper & background ) { <nl> + _background = std : : make_unique < Data : : WallPaper > ( background ) ; <nl> _background - > full - > loadEvenCancelled ( Data : : FileOrigin ( ) ) ; <nl> checkChatBackground ( ) ; <nl> } <nl> void MainWidget : : checkChatBackground ( ) { <nl> Window : : Theme : : Background ( ) - > setImage ( _background - > id , _background - > full - > pix ( Data : : FileOrigin ( ) ) . toImage ( ) ) ; <nl> } <nl> _background = nullptr ; <nl> - QTimer : : singleShot ( 0 , this , SLOT ( update ( ) ) ) ; <nl> + crl : : on_main ( this , [ = ] { update ( ) ; } ) ; <nl> } <nl> } <nl> } <nl> void MainWidget : : ui_showPeerHistory ( <nl> animationParams ) ; <nl> } else { <nl> _history - > show ( ) ; <nl> - if ( App : : wnd ( ) ) { <nl> - QTimer : : singleShot ( 0 , App : : wnd ( ) , SLOT ( setInnerFocus ( ) ) ) ; <nl> - } <nl> + crl : : on_main ( App : : wnd ( ) , [ ] { <nl> + App : : wnd ( ) - > setInnerFocus ( ) ; <nl> + } ) ; <nl> } <nl> } <nl> } <nl> void MainWidget : : showBackFromStack ( <nl> if ( selectingPeer ( ) ) return ; <nl> if ( _stack . empty ( ) ) { <nl> _controller - > clearSectionStack ( params ) ; <nl> - if ( App : : wnd ( ) ) { <nl> - QTimer : : singleShot ( 0 , App : : wnd ( ) , SLOT ( setInnerFocus ( ) ) ) ; <nl> - } <nl> + crl : : on_main ( App : : wnd ( ) , [ ] { <nl> + App : : wnd ( ) - > setInnerFocus ( ) ; <nl> + } ) ; <nl> return ; <nl> } <nl> auto item = std : : move ( _stack . back ( ) ) ; <nl> void MainWidget : : openPeerByName ( <nl> FullMsgId clickFromMessageId ) { <nl> Messenger : : Instance ( ) . hideMediaView ( ) ; <nl> <nl> - PeerData * peer = App : : peerByName ( username ) ; <nl> - if ( peer ) { <nl> + if ( const auto peer = Auth ( ) . data ( ) . peerByUsername ( username ) ) { <nl> if ( msgId = = ShowAtGameShareMsgId ) { <nl> if ( peer - > isUser ( ) & & peer - > asUser ( ) - > botInfo & & ! startToken . isEmpty ( ) ) { <nl> peer - > asUser ( ) - > botInfo - > shareGameShortName = startToken ; <nl> bool fwdInfoDataLoaded ( const MTPMessageFwdHeader & header ) { <nl> if ( ! App : : channelLoaded ( peerFromChannel ( info . vchannel_id ) ) ) { <nl> return false ; <nl> } <nl> - if ( info . has_from_id ( ) & & ! App : : user ( peerFromUser ( info . vfrom_id ) , PeerData : : MinimalLoaded ) ) { <nl> - return false ; <nl> + if ( info . has_from_id ( ) ) { <nl> + const auto from = App : : user ( peerFromUser ( info . vfrom_id ) ) ; <nl> + if ( from - > loadedStatus = = PeerData : : NotLoaded ) { <nl> + return false ; <nl> + } <nl> } <nl> } else { <nl> if ( info . has_from_id ( ) & & ! App : : userLoaded ( peerFromUser ( info . vfrom_id ) ) ) { <nl> void MainWidget : : feedUpdate ( const MTPUpdate & update ) { <nl> const auto user = App : : userLoaded ( d . vuser_id . v ) ; <nl> if ( history & & user ) { <nl> const auto when = requestingDifference ( ) ? 0 : unixtime ( ) ; <nl> - App : : histories ( ) . registerSendAction ( history , user , d . vaction , when ) ; <nl> + Auth ( ) . data ( ) . registerSendAction ( history , user , d . vaction , when ) ; <nl> } <nl> } break ; <nl> <nl> void MainWidget : : feedUpdate ( const MTPUpdate & update ) { <nl> : App : : userLoaded ( d . vuser_id . v ) ; <nl> if ( history & & user ) { <nl> const auto when = requestingDifference ( ) ? 0 : unixtime ( ) ; <nl> - App : : histories ( ) . registerSendAction ( history , user , d . vaction , when ) ; <nl> + Auth ( ) . data ( ) . registerSendAction ( history , user , d . vaction , when ) ; <nl> } <nl> } break ; <nl> <nl> void MainWidget : : feedUpdate ( const MTPUpdate & update ) { <nl> <nl> case mtpc_updateChannelAvailableMessages : { <nl> auto & d = update . c_updateChannelAvailableMessages ( ) ; <nl> - if ( auto channel = App : : channelLoaded ( d . vchannel_id . v ) ) { <nl> + if ( const auto channel = App : : channelLoaded ( d . vchannel_id . v ) ) { <nl> channel - > setAvailableMinId ( d . vavailable_min_id . v ) ; <nl> + if ( const auto history = App : : historyLoaded ( channel ) ) { <nl> + history - > clearUpTill ( d . vavailable_min_id . v ) ; <nl> + } <nl> } <nl> } break ; <nl> <nl> mmm a / Telegram / SourceFiles / mainwidget . h <nl> ppp b / Telegram / SourceFiles / mainwidget . h <nl> namespace Notify { <nl> struct PeerUpdate ; <nl> } / / namespace Notify <nl> <nl> + namespace Data { <nl> + struct WallPaper ; <nl> + } / / namespace Data <nl> + <nl> namespace Dialogs { <nl> struct RowDescriptor ; <nl> class Row ; <nl> class MainWidget <nl> QPixmap cachedBackground ( const QRect & forRect , int & x , int & y ) ; <nl> void updateScrollColors ( ) ; <nl> <nl> - void setChatBackground ( const App : : WallPaper & wp ) ; <nl> + void setChatBackground ( const Data : : WallPaper & background ) ; <nl> bool chatBackgroundLoading ( ) ; <nl> float64 chatBackgroundProgress ( ) const ; <nl> void checkChatBackground ( ) ; <nl> public slots : <nl> ViewsIncrementByRequest _viewsIncrementByRequest ; <nl> SingleTimer _viewsIncrementTimer ; <nl> <nl> - std : : unique_ptr < App : : WallPaper > _background ; <nl> + std : : unique_ptr < Data : : WallPaper > _background ; <nl> <nl> bool _firstColumnResizing = false ; <nl> int _firstColumnResizingShift = 0 ; <nl> mmm a / Telegram / SourceFiles / mainwindow . cpp <nl> ppp b / Telegram / SourceFiles / mainwindow . cpp <nl> void MainWindow : : firstShow ( ) { <nl> void MainWindow : : clearWidgetsHook ( ) { <nl> Expects ( _passcodeLock = = nullptr | | ! Global : : LocalPasscode ( ) ) ; <nl> <nl> - auto wasMain = ( _main ! = nullptr ) ; <nl> _main . destroy ( ) ; <nl> _passcodeLock . destroy ( ) ; <nl> _intro . destroy ( ) ; <nl> - if ( wasMain ) { <nl> - App : : clearHistories ( ) ; <nl> - } <nl> } <nl> <nl> QPixmap MainWindow : : grabInner ( ) { <nl> mmm a / Telegram / SourceFiles / messenger . cpp <nl> ppp b / Telegram / SourceFiles / messenger . cpp <nl> void Messenger : : authSessionCreate ( const MTPUser & user ) { <nl> void Messenger : : authSessionDestroy ( ) { <nl> unlockTerms ( ) ; <nl> <nl> - _authSession . reset ( ) ; <nl> + _authSession = nullptr ; <nl> _private - > storedAuthSession . reset ( ) ; <nl> _private - > authSessionUserId = 0 ; <nl> _private - > authSessionUserSerialized = { } ; <nl> authSessionChanged ( ) . notify ( true ) ; <nl> + Notify : : unreadCounterUpdated ( ) ; <nl> } <nl> <nl> int Messenger : : unreadBadge ( ) const { <nl> - return _authSession ? App : : histories ( ) . unreadBadge ( ) : 0 ; <nl> + return _authSession ? _authSession - > data ( ) . unreadBadge ( ) : 0 ; <nl> } <nl> <nl> bool Messenger : : unreadBadgeMuted ( ) const { <nl> - return _authSession ? App : : histories ( ) . unreadBadgeMuted ( ) : false ; <nl> + return _authSession ? _authSession - > data ( ) . unreadBadgeMuted ( ) : false ; <nl> } <nl> <nl> void Messenger : : setInternalLinkDomain ( const QString & domain ) const { <nl> Messenger : : ~ Messenger ( ) { <nl> _mediaView . reset ( ) ; <nl> <nl> / / Some MTP requests can be cancelled from data clearing . <nl> - App : : clearHistories ( ) ; <nl> authSessionDestroy ( ) ; <nl> <nl> / / The langpack manager should be destroyed before MTProto instance , <nl> void Messenger : : loggedOut ( ) { <nl> Media : : Player : : mixer ( ) - > stopAndClear ( ) ; <nl> Global : : SetVoiceMsgPlaybackDoubled ( false ) ; <nl> Media : : Player : : mixer ( ) - > setVoicePlaybackDoubled ( false ) ; <nl> - if ( const auto w = getActiveWindow ( ) ) { <nl> - w - > tempDirDelete ( Local : : ClearManagerAll ) ; <nl> - w - > setupIntro ( ) ; <nl> + if ( const auto window = getActiveWindow ( ) ) { <nl> + window - > tempDirDelete ( Local : : ClearManagerAll ) ; <nl> + window - > setupIntro ( ) ; <nl> } <nl> - App : : histories ( ) . clear ( ) ; <nl> if ( const auto session = authSession ( ) ) { <nl> - session - > data ( ) . cache ( ) . close ( ) ; <nl> - session - > data ( ) . cache ( ) . clear ( ) ; <nl> + session - > data ( ) . clearLocalStorage ( ) ; <nl> + authSessionDestroy ( ) ; <nl> } <nl> - authSessionDestroy ( ) ; <nl> if ( _mediaView ) { <nl> hideMediaView ( ) ; <nl> _mediaView - > clearData ( ) ; <nl> mmm a / Telegram / SourceFiles / support / support_common . cpp <nl> ppp b / Telegram / SourceFiles / support / support_common . cpp <nl> For license and copyright information please follow this link : <nl> <nl> namespace Support { <nl> <nl> - bool ValidateAccount ( const MTPUser & self ) { <nl> - / / return true ; AssertIsDebug ( ) ; <nl> - return self . match ( [ ] ( const MTPDuser & data ) { <nl> - DEBUG_LOG ( ( " ValidateAccount : % 1 % 2 " <nl> - ) . arg ( Logs : : b ( data . has_phone ( ) ) <nl> - ) . arg ( data . has_phone ( ) ? qs ( data . vphone ) : QString ( ) ) ) ; <nl> - return data . has_phone ( ) & & qs ( data . vphone ) . startsWith ( qstr ( " 424 " ) ) ; <nl> - } , [ ] ( const MTPDuserEmpty & data ) { <nl> - return false ; <nl> - } ) ; <nl> - } <nl> - <nl> bool HandleSwitch ( Qt : : KeyboardModifiers modifiers ) { <nl> return ! ( modifiers & Qt : : ShiftModifier ) <nl> | | ( ! ( modifiers & Qt : : ControlModifier ) <nl> mmm a / Telegram / SourceFiles / support / support_common . h <nl> ppp b / Telegram / SourceFiles / support / support_common . h <nl> For license and copyright information please follow this link : <nl> <nl> namespace Support { <nl> <nl> - bool ValidateAccount ( const MTPUser & self ) ; <nl> - <nl> enum class SwitchSettings { <nl> None , <nl> Next , <nl> mmm a / Telegram / SourceFiles / support / support_helper . cpp <nl> ppp b / Telegram / SourceFiles / support / support_helper . cpp <nl> Helper : : Helper ( not_null < AuthSession * > session ) <nl> } ) . send ( ) ; <nl> } <nl> <nl> + std : : unique_ptr < Helper > Helper : : Create ( not_null < AuthSession * > session ) { <nl> + / / return std : : make_unique < Helper > ( session ) ; AssertIsDebug ( ) ; <nl> + const auto valid = session - > user ( ) - > phone ( ) . startsWith ( qstr ( " 424 " ) ) ; <nl> + return valid ? std : : make_unique < Helper > ( session ) : nullptr ; <nl> + } <nl> + <nl> void Helper : : registerWindow ( not_null < Window : : Controller * > controller ) { <nl> controller - > activeChatValue ( <nl> ) | rpl : : map ( [ ] ( Dialogs : : Key key ) { <nl> mmm a / Telegram / SourceFiles / support / support_helper . h <nl> ppp b / Telegram / SourceFiles / support / support_helper . h <nl> class Helper : private MTP : : Sender { <nl> public : <nl> explicit Helper ( not_null < AuthSession * > session ) ; <nl> <nl> + static std : : unique_ptr < Helper > Create ( not_null < AuthSession * > session ) ; <nl> + <nl> void registerWindow ( not_null < Window : : Controller * > controller ) ; <nl> void cloudDraftChanged ( not_null < History * > history ) ; <nl> <nl> mmm a / Telegram / SourceFiles / window / main_window . cpp <nl> ppp b / Telegram / SourceFiles / window / main_window . cpp <nl> For license and copyright information please follow this link : <nl> # include " boxes / confirm_box . h " <nl> # include " core / click_handler_types . h " <nl> # include " lang / lang_keys . h " <nl> + # include " data / data_session . h " <nl> # include " mediaview . h " <nl> # include " auth_session . h " <nl> # include " apiwrap . h " <nl> void MainWindow : : updateUnreadCounter ( ) { <nl> if ( ! Global : : started ( ) | | App : : quitting ( ) ) return ; <nl> <nl> const auto counter = AuthSession : : Exists ( ) <nl> - ? App : : histories ( ) . unreadBadge ( ) <nl> + ? Auth ( ) . data ( ) . unreadBadge ( ) <nl> : 0 ; <nl> _titleText = ( counter > 0 ) ? qsl ( " Telegram ( % 1 ) " ) . arg ( counter ) : qsl ( " Telegram " ) ; <nl> <nl>
Move App : : histories to Data : : Session .
telegramdesktop/tdesktop
1f8626b3837a70309b7ec93f6189d340ae791d90
2019-01-17T08:21:28Z
mmm a / tensorflow / core / data / service / BUILD <nl> ppp b / tensorflow / core / data / service / BUILD <nl> cc_library ( <nl> " : credentials_factory " , <nl> " : data_service " , <nl> " : dispatcher_proto_cc " , <nl> + " : dispatcher_state " , <nl> " : grpc_util " , <nl> " : worker_cc_grpc_proto " , <nl> " : worker_proto_cc " , <nl> mmm a / tensorflow / core / data / service / dispatcher_impl . cc <nl> ppp b / tensorflow / core / data / service / dispatcher_impl . cc <nl> namespace tensorflow { <nl> namespace data { <nl> <nl> namespace { <nl> + using Dataset = DispatcherState : : Dataset ; <nl> + using NamedJobKey = DispatcherState : : NamedJobKey ; <nl> + using Job = DispatcherState : : Job ; <nl> + <nl> Status CreateWorkerStub ( const std : : string & address , const std : : string & protocol , <nl> std : : unique_ptr < WorkerService : : Stub > * stub ) { <nl> : : grpc : : ChannelArguments args ; <nl> Status DataServiceDispatcherImpl : : RegisterWorker ( <nl> const RegisterWorkerRequest * request , RegisterWorkerResponse * response ) { <nl> VLOG ( 3 ) < < " Received register worker request " ; <nl> mutex_lock l ( mu_ ) ; <nl> - int64 worker_id = next_worker_id_ + + ; <nl> - workers_ . push_back ( <nl> - std : : make_shared < Worker > ( worker_id , request - > worker_address ( ) ) ) ; <nl> + std : : string worker_address = request - > worker_address ( ) ; <nl> + if ( ! workers_ . contains ( worker_address ) ) { <nl> + workers_ [ worker_address ] = <nl> + std : : make_shared < Worker > ( next_worker_id_ + + , worker_address ) ; <nl> + } <nl> + int64 worker_id = workers_ [ worker_address ] - > worker_id ; <nl> response - > set_worker_id ( worker_id ) ; <nl> - <nl> + std : : vector < std : : shared_ptr < const Job > > jobs = state_ . ListJobs ( ) ; <nl> / / Allocate tasks to the worker . <nl> - for ( auto & entry : jobs_ ) { <nl> - std : : shared_ptr < Job > job = entry . second ; <nl> - if ( job - > finished ( ) ) { <nl> + for ( const auto & job : jobs ) { <nl> + if ( job - > finished ) { <nl> continue ; <nl> } <nl> - const Task & task = CreateTaskLocked ( job . get ( ) , request - > worker_address ( ) ) ; <nl> + std : : shared_ptr < Task > task = CreateTask ( job , worker_address ) ; <nl> <nl> TaskDef * task_def = response - > add_tasks ( ) ; <nl> - * task_def - > mutable_dataset ( ) = <nl> - datasets_by_id_ [ job - > dataset_id ( ) ] - > dataset_def ( ) ; <nl> - task_def - > set_dataset_id ( job - > dataset_id ( ) ) ; <nl> - task_def - > set_job_id ( job - > job_id ( ) ) ; <nl> - task_def - > set_task_id ( task . task_id ( ) ) ; <nl> + std : : shared_ptr < const Dataset > dataset ; <nl> + TF_RETURN_IF_ERROR ( state_ . DatasetFromId ( job - > dataset_id , & dataset ) ) ; <nl> + * ( task_def - > mutable_dataset ( ) ) = dataset - > dataset_def ; <nl> + task_def - > set_dataset_id ( job - > dataset_id ) ; <nl> + task_def - > set_job_id ( job - > job_id ) ; <nl> + task_def - > set_task_id ( task - > task_id ) ; <nl> } <nl> <nl> VLOG ( 1 ) < < " Registered worker at address " < < request - > worker_address ( ) <nl> Status DataServiceDispatcherImpl : : WorkerUpdate ( <nl> int64 worker_id = request - > worker_id ( ) ; <nl> for ( auto & update : request - > updates ( ) ) { <nl> int64 task_id = update . task_id ( ) ; <nl> - if ( ! tasks_ . contains ( task_id ) ) { <nl> + const auto it = tasks_ . find ( task_id ) ; <nl> + if ( it = = tasks_ . end ( ) ) { <nl> return errors : : NotFound ( " WorkerUpdate called for worker " , worker_id , <nl> " with unknown task id " , task_id ) ; <nl> } <nl> + std : : shared_ptr < Task > task = it - > second ; <nl> if ( update . completed ( ) ) { <nl> - int64 job_id = tasks_ . at ( task_id ) . job_id ( ) ; <nl> - DCHECK ( jobs_ . contains ( job_id ) ) ; <nl> - jobs_ . at ( job_id ) - > task_finished ( task_id ) ; <nl> - VLOG ( 3 ) < < " Task " < < task_id < < " from job " < < job_id < < " completed " ; <nl> + if ( task - > finished ) { <nl> + VLOG ( 1 ) < < " Received completion update for already - finished task " <nl> + < < task - > task_id < < " on worker " < < task - > worker_address ; <nl> + continue ; <nl> + } <nl> + task - > finished = true ; <nl> + bool finished = true ; <nl> + for ( const auto & task : tasks_by_job_ [ task - > job_id ] ) { <nl> + if ( ! task - > finished ) { <nl> + finished = false ; <nl> + break ; <nl> + } <nl> + } <nl> + if ( finished ) { <nl> + Update update ; <nl> + FinishJobUpdate * finish_job = update . mutable_finish_job ( ) ; <nl> + finish_job - > set_job_id ( task - > job_id ) ; <nl> + TF_RETURN_IF_ERROR ( state_ . Apply ( update ) ) ; <nl> + } <nl> + VLOG ( 3 ) < < " Task " < < task_id < < " from job " < < task - > job_id <nl> + < < " completed " ; <nl> } <nl> } <nl> return Status : : OK ( ) ; <nl> Status DataServiceDispatcherImpl : : GetOrRegisterDataset ( <nl> uint64 fingerprint ; <nl> TF_RETURN_IF_ERROR ( HashGraph ( request - > dataset ( ) . graph ( ) , & fingerprint ) ) ; <nl> mutex_lock l ( mu_ ) ; <nl> - VLOG ( 3 ) < < " Registering dataset graph : " <nl> + VLOG ( 4 ) < < " Registering dataset graph : " <nl> < < request - > dataset ( ) . graph ( ) . DebugString ( ) ; <nl> - if ( datasets_by_fingerprint_ . contains ( fingerprint ) ) { <nl> - int64 id = datasets_by_fingerprint_ [ fingerprint ] - > dataset_id ( ) ; <nl> + std : : shared_ptr < const Dataset > dataset ; <nl> + Status s = state_ . DatasetFromFingerprint ( fingerprint , & dataset ) ; <nl> + if ( s . ok ( ) ) { <nl> + int64 id = dataset - > dataset_id ; <nl> VLOG ( 3 ) < < " Received duplicate RegisterDataset request with fingerprint " <nl> < < fingerprint < < " . Returning id " < < id ; <nl> response - > set_dataset_id ( id ) ; <nl> return Status : : OK ( ) ; <nl> + } else if ( ! errors : : IsNotFound ( s ) ) { <nl> + return s ; <nl> } <nl> - int64 id = RegisterDataset ( fingerprint , request - > dataset ( ) ) ; <nl> <nl> + int64 id ; <nl> + TF_RETURN_IF_ERROR ( RegisterDataset ( fingerprint , request - > dataset ( ) , & id ) ) ; <nl> response - > set_dataset_id ( id ) ; <nl> VLOG ( 3 ) < < " Registered new dataset with id " < < id ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> - int64 DataServiceDispatcherImpl : : RegisterDataset ( uint64 fingerprint , <nl> - const DatasetDef & dataset ) <nl> + Status DataServiceDispatcherImpl : : RegisterDataset ( uint64 fingerprint , <nl> + const DatasetDef & dataset , <nl> + int64 * dataset_id ) <nl> EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) { <nl> - int64 dataset_id = next_dataset_id_ + + ; <nl> - auto new_dataset = <nl> - std : : make_shared < Dataset > ( dataset_id , fingerprint , dataset ) ; <nl> - <nl> - DCHECK ( ! datasets_by_id_ . contains ( dataset_id ) ) ; <nl> - datasets_by_id_ [ dataset_id ] = new_dataset ; <nl> - DCHECK ( ! datasets_by_fingerprint_ . contains ( fingerprint ) ) ; <nl> - datasets_by_fingerprint_ [ fingerprint ] = new_dataset ; <nl> - return dataset_id ; <nl> + * dataset_id = state_ . NextAvailableDatasetId ( ) ; <nl> + Update update ; <nl> + RegisterDatasetUpdate * register_dataset = update . mutable_register_dataset ( ) ; <nl> + register_dataset - > set_dataset_id ( * dataset_id ) ; <nl> + register_dataset - > set_fingerprint ( fingerprint ) ; <nl> + * register_dataset - > mutable_dataset_def ( ) = dataset ; <nl> + return state_ . Apply ( update ) ; <nl> } <nl> <nl> Status DataServiceDispatcherImpl : : CreateJob ( const CreateJobRequest * request , <nl> Status DataServiceDispatcherImpl : : CreateJob ( const CreateJobRequest * request , <nl> VLOG ( 3 ) < < " Received create job request for dataset id " <nl> < < request - > dataset_id ( ) ; <nl> ProcessingMode processing_mode = ProcessingMode ( request - > processing_mode ( ) ) ; <nl> - int64 job_id ; <nl> - TF_RETURN_IF_ERROR ( CreateJob ( request - > dataset_id ( ) , processing_mode , <nl> - absl : : optional < std : : string > ( ) , & job_id ) ) ; <nl> - response - > set_job_id ( job_id ) ; <nl> + std : : shared_ptr < const Job > job ; <nl> + std : : vector < std : : shared_ptr < const Task > > tasks ; <nl> + { <nl> + mutex_lock l ( mu_ ) ; <nl> + TF_RETURN_IF_ERROR ( CreateJob ( request - > dataset_id ( ) , processing_mode , <nl> + absl : : optional < NamedJobKey > ( ) , & job ) ) ; <nl> + tasks = CreateTasksForJob ( job ) ; <nl> + } <nl> + response - > set_job_id ( job - > job_id ) ; <nl> + TF_RETURN_IF_ERROR ( AssignTasks ( tasks ) ) ; <nl> <nl> - VLOG ( 3 ) < < " Creating job " < < job_id < < " for dataset " <nl> + VLOG ( 3 ) < < " Creating job " < < job - > job_id < < " for dataset " <nl> < < request - > dataset_id ( ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> Status DataServiceDispatcherImpl : : GetOrCreateJob ( <nl> NamedJobKey key ( request - > job_name ( ) , request - > job_name_index ( ) ) ; <nl> ProcessingMode requested_processing_mode = <nl> ProcessingMode ( request - > processing_mode ( ) ) ; <nl> + std : : shared_ptr < const Job > job ; <nl> + std : : vector < std : : shared_ptr < const Task > > tasks ; <nl> { <nl> mutex_lock l ( mu_ ) ; <nl> - std : : shared_ptr < Job > * job = gtl : : FindOrNull ( named_jobs_ , key ) ; <nl> - if ( job ! = nullptr ) { <nl> - TF_RETURN_IF_ERROR ( ValidateMatchingJob ( * * job , requested_processing_mode , <nl> + Status s = state_ . NamedJobByKey ( key , & job ) ; <nl> + if ( s . ok ( ) ) { <nl> + TF_RETURN_IF_ERROR ( ValidateMatchingJob ( job , requested_processing_mode , <nl> request - > dataset_id ( ) ) ) ; <nl> - int64 job_id = ( * job ) - > job_id ( ) ; <nl> - response - > set_job_id ( job_id ) ; <nl> - VLOG ( 3 ) < < " Found existing job for name = " < < request - > job_name ( ) <nl> - < < " , index = " < < request - > job_name_index ( ) <nl> - < < " . job_id : " < < job_id ; <nl> + response - > set_job_id ( job - > job_id ) ; <nl> + VLOG ( 3 ) < < " Found existing job for name = " < < key . name <nl> + < < " , index = " < < key . index < < " . job_id : " < < job - > job_id ; <nl> return Status : : OK ( ) ; <nl> + } else if ( ! errors : : IsNotFound ( s ) ) { <nl> + return s ; <nl> } <nl> + TF_RETURN_IF_ERROR ( <nl> + CreateJob ( request - > dataset_id ( ) , requested_processing_mode , key , & job ) ) ; <nl> + tasks = CreateTasksForJob ( job ) ; <nl> } <nl> - int64 job_id ; <nl> - TF_RETURN_IF_ERROR ( CreateJob ( request - > dataset_id ( ) , requested_processing_mode , <nl> - request - > job_name ( ) , & job_id ) ) ; <nl> - { <nl> - mutex_lock l ( mu_ ) ; <nl> - named_jobs_ [ key ] = jobs_ [ job_id ] ; <nl> - } <nl> - response - > set_job_id ( job_id ) ; <nl> - VLOG ( 3 ) < < " Created job " < < job_id < < " for dataset " <nl> + TF_RETURN_IF_ERROR ( AssignTasks ( tasks ) ) ; <nl> + response - > set_job_id ( job - > job_id ) ; <nl> + VLOG ( 3 ) < < " Created job " < < job - > job_id < < " for dataset " <nl> < < request - > dataset_id ( ) < < " and name " < < request - > job_name ( ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> / / Validates that the job matches the given processing_mode and dataset_id . <nl> Status DataServiceDispatcherImpl : : ValidateMatchingJob ( <nl> - const Job & job , ProcessingMode processing_mode , int64 dataset_id ) { <nl> - DCHECK ( job . name ( ) . has_value ( ) ) ; <nl> - std : : string job_name = job . name ( ) . value ( ) ; <nl> - if ( job . processing_mode ( ) ! = processing_mode ) { <nl> + std : : shared_ptr < const Job > job , ProcessingMode processing_mode , <nl> + int64 dataset_id ) EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) { <nl> + DCHECK ( job - > named_job_key . has_value ( ) ) ; <nl> + std : : string job_name = job - > named_job_key - > name ; <nl> + if ( job - > processing_mode ! = processing_mode ) { <nl> std : : string requested = ProcessingModeToString ( processing_mode ) ; <nl> - std : : string actual = ProcessingModeToString ( job . processing_mode ( ) ) ; <nl> + std : : string actual = ProcessingModeToString ( job - > processing_mode ) ; <nl> return errors : : FailedPrecondition ( <nl> " Found a job with name " , job_name , " , but the processing mode < " , <nl> actual , " > doesn ' t match the requested processing mode < " , requested , <nl> " > . " ) ; <nl> } <nl> - if ( job . dataset_id ( ) ! = dataset_id ) { <nl> + if ( job - > dataset_id ! = dataset_id ) { <nl> return errors : : FailedPrecondition ( <nl> " Found a job with name " , job_name , " , but the dataset id < " , <nl> - job . dataset_id ( ) , " > doesn ' t match the requested dataset id < " , <nl> + job - > dataset_id , " > doesn ' t match the requested dataset id < " , <nl> dataset_id , " > . " ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> Status DataServiceDispatcherImpl : : ValidateMatchingJob ( <nl> <nl> Status DataServiceDispatcherImpl : : CreateJob ( <nl> int64 dataset_id , ProcessingMode processing_mode , <nl> - absl : : optional < std : : string > job_name , int64 * out_job_id ) <nl> - LOCKS_EXCLUDED ( mu_ ) { <nl> + absl : : optional < NamedJobKey > named_job_key , std : : shared_ptr < const Job > * job ) <nl> + EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) { <nl> switch ( processing_mode ) { <nl> case ProcessingMode : : PARALLEL_EPOCHS : <nl> break ; <nl> Status DataServiceDispatcherImpl : : CreateJob ( <nl> ProcessingModeToString ( processing_mode ) , <nl> " not recognized " ) ; <nl> } <nl> - std : : shared_ptr < Job > job ; <nl> - std : : vector < std : : shared_ptr < Worker > > workers ; <nl> - { <nl> - mutex_lock l ( mu_ ) ; <nl> - if ( ! datasets_by_id_ . contains ( dataset_id ) ) { <nl> - return errors : : NotFound ( " Dataset id : < " , dataset_id , " > not found . " ) ; <nl> - } <nl> - <nl> - int64 job_id = next_job_id_ + + ; <nl> - DCHECK ( ! jobs_ . contains ( job_id ) ) ; <nl> - job = std : : make_shared < Job > ( job_id , dataset_id , processing_mode , job_name ) ; <nl> - jobs_ [ job_id ] = job ; <nl> - <nl> - / / Copy workers_ so that we can iterate through the workers without holding <nl> - / / the lock . When a new worker is added in ` RegisterWorker ` , we iterate <nl> - / / through the jobs in ` jobs_ ` and give it a task for each job . So even if a <nl> - / / new worker is registered after we release the lock , because this job has <nl> - / / been added to ` jobs_ ` , it will still receive a task for this job . <nl> - workers = workers_ ; <nl> - const Dataset & dataset = * datasets_by_id_ [ dataset_id ] ; <nl> - if ( VLOG_IS_ON ( 1 ) ) { <nl> - VLOG ( 1 ) < < " Sending tasks to workers for job " < < job - > job_id ( ) <nl> - < < " . Dataset id : " < < dataset_id <nl> - < < " . Dataset fingerprint : " < < dataset . fingerprint ( ) <nl> - < < " . Dataset definition size : " <nl> - < < datasets_by_id_ [ dataset_id ] - > dataset_def ( ) . ByteSizeLong ( ) ; <nl> - } <nl> - } <nl> - <nl> - for ( auto & worker : workers ) { <nl> - const Task & task = CreateTask ( job . get ( ) , worker - > address ( ) ) ; <nl> - Status s = AllocateTaskToWorker ( task , worker . get ( ) ) ; <nl> - if ( ! s . ok ( ) ) { <nl> - LOG ( WARNING ) < < " Failed to allocate task with id " < < task . task_id ( ) <nl> - < < " to worker at address " < < worker - > address ( ) < < " : " <nl> - < < s . error_message ( ) ; <nl> - } <nl> + int64 job_id = state_ . NextAvailableJobId ( ) ; <nl> + Update update ; <nl> + CreateJobUpdate * create_job = update . mutable_create_job ( ) ; <nl> + create_job - > set_job_id ( job_id ) ; <nl> + create_job - > set_dataset_id ( dataset_id ) ; <nl> + create_job - > set_processing_mode ( ProcessingModeDef ( processing_mode ) ) ; <nl> + if ( named_job_key . has_value ( ) ) { <nl> + NamedJobKeyDef * key = create_job - > mutable_named_job_key ( ) ; <nl> + key - > set_name ( named_job_key - > name ) ; <nl> + key - > set_index ( named_job_key - > index ) ; <nl> } <nl> - VLOG ( 1 ) < < " Done sending tasks to workers for job " < < job - > job_id ( ) ; <nl> - <nl> - * out_job_id = job - > job_id ( ) ; <nl> + TF_RETURN_IF_ERROR ( state_ . Apply ( update ) ) ; <nl> + TF_RETURN_IF_ERROR ( state_ . JobFromId ( job_id , job ) ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> - const DataServiceDispatcherImpl : : Task & DataServiceDispatcherImpl : : CreateTask ( <nl> - Job * job , const std : : string & worker_address ) LOCKS_EXCLUDED ( mu_ ) { <nl> - mutex_lock l ( mu_ ) ; <nl> - return CreateTaskLocked ( job , worker_address ) ; <nl> + std : : vector < std : : shared_ptr < const DataServiceDispatcherImpl : : Task > > <nl> + DataServiceDispatcherImpl : : CreateTasksForJob ( std : : shared_ptr < const Job > job ) <nl> + EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) { <nl> + std : : vector < std : : shared_ptr < const Task > > tasks ; <nl> + tasks . reserve ( workers_ . size ( ) ) ; <nl> + for ( const auto & it : workers_ ) { <nl> + std : : shared_ptr < Worker > worker = it . second ; <nl> + tasks . push_back ( CreateTask ( job , worker - > address ) ) ; <nl> + } <nl> + return tasks ; <nl> } <nl> <nl> - const DataServiceDispatcherImpl : : Task & <nl> - DataServiceDispatcherImpl : : CreateTaskLocked ( Job * job , <nl> - const std : : string & worker_address ) <nl> + std : : shared_ptr < DataServiceDispatcherImpl : : Task > <nl> + DataServiceDispatcherImpl : : CreateTask ( std : : shared_ptr < const Job > job , <nl> + const std : : string & worker_address ) <nl> EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) { <nl> int64 task_id = next_task_id_ + + ; <nl> DCHECK ( ! tasks_ . contains ( task_id ) ) ; <nl> - tasks_ . insert ( { task_id , Task ( task_id , job - > job_id ( ) , job - > dataset_id ( ) , <nl> - worker_address ) } ) ; <nl> - job - > add_task_id ( task_id ) ; <nl> - return tasks_ . at ( task_id ) ; <nl> + tasks_ [ task_id ] = std : : make_shared < Task > ( task_id , job - > job_id , <nl> + job - > dataset_id , worker_address ) ; <nl> + tasks_by_job_ [ job - > job_id ] . push_back ( tasks_ [ task_id ] ) ; <nl> + return tasks_ [ task_id ] ; <nl> + } <nl> + <nl> + Status DataServiceDispatcherImpl : : AssignTasks ( <nl> + std : : vector < std : : shared_ptr < const Task > > tasks ) LOCKS_EXCLUDED ( mu_ ) { <nl> + for ( const auto & task : tasks ) { <nl> + TF_RETURN_IF_ERROR ( AssignTask ( task ) ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> } <nl> <nl> Status DataServiceDispatcherImpl : : EnsureWorkerStubInitialized ( Worker * worker ) { <nl> - if ( ! worker - > stub ( ) ) { <nl> - std : : unique_ptr < WorkerService : : Stub > stub ; <nl> + if ( ! worker - > stub ) { <nl> TF_RETURN_IF_ERROR ( <nl> - CreateWorkerStub ( worker - > address ( ) , config_ . protocol ( ) , & stub ) ) ; <nl> - worker - > set_stub ( std : : move ( stub ) ) ; <nl> + CreateWorkerStub ( worker - > address , config_ . protocol ( ) , & worker - > stub ) ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> - Status DataServiceDispatcherImpl : : AllocateTaskToWorker ( const Task & task , <nl> - Worker * worker ) <nl> + Status DataServiceDispatcherImpl : : AssignTask ( std : : shared_ptr < const Task > task ) <nl> LOCKS_EXCLUDED ( mu_ ) { <nl> - TF_RETURN_IF_ERROR ( EnsureWorkerStubInitialized ( worker ) ) ; <nl> grpc : : ClientContext client_ctx ; <nl> ProcessTaskRequest req ; <nl> - req . mutable_task ( ) - > set_dataset_id ( task . dataset_id ( ) ) ; <nl> + TaskDef * task_def = req . mutable_task ( ) ; <nl> + task_def - > set_dataset_id ( task - > dataset_id ) ; <nl> + std : : shared_ptr < Worker > worker ; <nl> { <nl> mutex_lock l ( mu_ ) ; <nl> - DCHECK ( datasets_by_id_ . contains ( task . dataset_id ( ) ) ) ; <nl> - * req . mutable_task ( ) - > mutable_dataset ( ) = <nl> - datasets_by_id_ . at ( task . dataset_id ( ) ) - > dataset_def ( ) ; <nl> + worker = workers_ [ task - > worker_address ] ; <nl> + std : : shared_ptr < const Dataset > dataset ; <nl> + TF_RETURN_IF_ERROR ( state_ . DatasetFromId ( task - > dataset_id , & dataset ) ) ; <nl> + * task_def - > mutable_dataset ( ) = dataset - > dataset_def ; <nl> + } <nl> + if ( ! worker ) { <nl> + return errors : : NotFound ( " No worker found for address " , <nl> + task - > worker_address ) ; <nl> } <nl> - req . mutable_task ( ) - > set_task_id ( task . task_id ( ) ) ; <nl> + task_def - > set_task_id ( task - > task_id ) ; <nl> ProcessTaskResponse resp ; <nl> - grpc : : Status s = worker - > stub ( ) - > ProcessTask ( & client_ctx , req , & resp ) ; <nl> + TF_RETURN_IF_ERROR ( EnsureWorkerStubInitialized ( worker . get ( ) ) ) ; <nl> + grpc : : Status s = worker - > stub - > ProcessTask ( & client_ctx , req , & resp ) ; <nl> if ( ! s . ok ( ) ) { <nl> return grpc_util : : WrapError ( <nl> - absl : : StrCat ( " Failed to submit task to worker " , worker - > address ( ) ) , s ) ; <nl> + absl : : StrCat ( " Failed to submit task to worker " , worker - > address ) , s ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> } <nl> Status DataServiceDispatcherImpl : : GetTasks ( const GetTasksRequest * request , <nl> GetTasksResponse * response ) { <nl> mutex_lock l ( mu_ ) ; <nl> VLOG ( 3 ) < < " Looking up tasks for job id " < < request - > job_id ( ) ; <nl> - auto it = jobs_ . find ( request - > job_id ( ) ) ; <nl> - if ( it = = jobs_ . end ( ) ) { <nl> + auto it = tasks_by_job_ . find ( request - > job_id ( ) ) ; <nl> + if ( it = = tasks_by_job_ . end ( ) ) { <nl> return errors : : NotFound ( " GetTasks failed . Job id < " , request - > job_id ( ) , <nl> " > not found . " ) ; <nl> } <nl> - std : : shared_ptr < Job > job = it - > second ; <nl> - for ( const auto & task_id : job - > task_ids ( ) ) { <nl> - auto task_iter = tasks_ . find ( task_id ) ; <nl> - DCHECK ( task_iter ! = tasks_ . end ( ) ) ; <nl> - Task & task = task_iter - > second ; <nl> + std : : vector < std : : shared_ptr < Task > > & tasks = it - > second ; <nl> + bool has_finished_tasks = false ; <nl> + for ( const auto & task : tasks ) { <nl> + if ( task - > finished ) { <nl> + has_finished_tasks = true ; <nl> + continue ; <nl> + } <nl> TaskInfo * task_info = response - > mutable_task_info ( ) - > Add ( ) ; <nl> - task_info - > set_worker_address ( task . worker_address ( ) ) ; <nl> - task_info - > set_id ( task . task_id ( ) ) ; <nl> + task_info - > set_worker_address ( task - > worker_address ) ; <nl> + task_info - > set_id ( task - > task_id ) ; <nl> } <nl> - response - > set_job_finished ( job - > finished ( ) ) ; <nl> + response - > set_job_finished ( has_finished_tasks & & <nl> + response - > task_info_size ( ) = = 0 ) ; <nl> VLOG ( 3 ) < < " Found " < < response - > task_info_size ( ) < < " tasks for job id " <nl> < < request - > job_id ( ) ; <nl> return Status : : OK ( ) ; <nl> Status DataServiceDispatcherImpl : : GetWorkers ( const GetWorkersRequest * request , <nl> GetWorkersResponse * response ) { <nl> mutex_lock l ( mu_ ) ; <nl> VLOG ( 3 ) < < " Enter GetWorkers " ; <nl> - for ( auto & worker : workers_ ) { <nl> + for ( const auto & it : workers_ ) { <nl> + std : : shared_ptr < Worker > worker = it . second ; <nl> WorkerInfo * info = response - > add_workers ( ) ; <nl> - info - > set_address ( worker - > address ( ) ) ; <nl> - info - > set_id ( worker - > worker_id ( ) ) ; <nl> + info - > set_address ( worker - > address ) ; <nl> + info - > set_id ( worker - > worker_id ) ; <nl> } <nl> VLOG ( 3 ) < < " Returning list of " < < workers_ . size ( ) <nl> < < " workers from GetWorkers " ; <nl> mmm a / tensorflow / core / data / service / dispatcher_impl . h <nl> ppp b / tensorflow / core / data / service / dispatcher_impl . h <nl> limitations under the License . <nl> # include " tensorflow / core / data / service / common . pb . h " <nl> # include " tensorflow / core / data / service / data_service . h " <nl> # include " tensorflow / core / data / service / dispatcher . pb . h " <nl> + # include " tensorflow / core / data / service / dispatcher_state . h " <nl> # include " tensorflow / core / data / service / worker . grpc . pb . h " <nl> # include " tensorflow / core / lib / core / status . h " <nl> # include " tensorflow / core / platform / mutex . h " <nl> class DataServiceDispatcherImpl { <nl> GetWorkersResponse * response ) ; <nl> <nl> private : <nl> - class Worker { <nl> - public : <nl> - Worker ( int64 worker_id , const std : : string address ) <nl> - : worker_id_ ( worker_id ) , address_ ( address ) { } <nl> - <nl> - int64 worker_id ( ) { return worker_id_ ; } <nl> - std : : string address ( ) { return address_ ; } <nl> - WorkerService : : Stub * stub ( ) { return stub_ . get ( ) ; } <nl> - void set_stub ( std : : unique_ptr < WorkerService : : Stub > stub ) { <nl> - stub_ = std : : move ( stub ) ; <nl> - } <nl> - <nl> - std : : string DebugString ( ) { <nl> - return absl : : StrCat ( " id : " , worker_id_ , " address : " , address_ ) ; <nl> - } <nl> - <nl> - private : <nl> - const int64 worker_id_ ; <nl> - const std : : string address_ ; <nl> - std : : unique_ptr < WorkerService : : Stub > stub_ ; <nl> - } ; <nl> - <nl> - class Dataset { <nl> - public : <nl> - Dataset ( int64 dataset_id , int64 fingerprint , const DatasetDef & dataset_def ) <nl> - : dataset_id_ ( dataset_id ) , <nl> - fingerprint_ ( fingerprint ) , <nl> - dataset_def_ ( dataset_def ) { } <nl> - <nl> - int64 dataset_id ( ) const { return dataset_id_ ; } <nl> - int64 fingerprint ( ) const { return fingerprint_ ; } <nl> - const DatasetDef & dataset_def ( ) { return dataset_def_ ; } <nl> - <nl> - private : <nl> - const int64 dataset_id_ ; <nl> - const int64 fingerprint_ ; <nl> - const DatasetDef dataset_def_ ; <nl> - } ; <nl> + struct Worker { <nl> + Worker ( int64 worker_id , const std : : string & address ) <nl> + : worker_id ( worker_id ) , address ( address ) { } <nl> <nl> - class Job { <nl> - public : <nl> - Job ( int64 job_id , int64 dataset_id , ProcessingMode processing_mode , <nl> - absl : : optional < absl : : string_view > job_name ) <nl> - : job_id_ ( job_id ) , <nl> - dataset_id_ ( dataset_id ) , <nl> - processing_mode_ ( processing_mode ) , <nl> - job_name_ ( job_name ) { } <nl> - <nl> - int64 job_id ( ) const { return job_id_ ; } <nl> - int64 dataset_id ( ) const { return dataset_id_ ; } <nl> - ProcessingMode processing_mode ( ) const { return processing_mode_ ; } <nl> - absl : : optional < std : : string > name ( ) const { return job_name_ ; } <nl> - const std : : vector < int64 > & task_ids ( ) const { return task_ids_ ; } <nl> - void add_task_id ( int64 task_id ) { task_ids_ . push_back ( task_id ) ; } <nl> - void task_finished ( int64 task_id ) { <nl> - finished_tasks_ . push_back ( task_id ) ; <nl> - if ( finished_tasks_ . size ( ) = = task_ids_ . size ( ) ) { <nl> - finished_ = true ; <nl> - } <nl> - } <nl> - bool finished ( ) const { return finished_ ; } <nl> - <nl> - private : <nl> - const int64 job_id_ ; <nl> - const int64 dataset_id_ ; <nl> - const ProcessingMode processing_mode_ ; <nl> - const absl : : optional < std : : string > job_name_ ; <nl> - std : : vector < int64 > task_ids_ ; <nl> - std : : vector < int64 > finished_tasks_ ; <nl> - bool finished_ = false ; <nl> + const int64 worker_id ; <nl> + const std : : string address ; <nl> + std : : unique_ptr < WorkerService : : Stub > stub ; <nl> } ; <nl> <nl> - class NamedJobKey { <nl> - public : <nl> - NamedJobKey ( absl : : string_view name , int64 index ) <nl> - : name_ ( name ) , index_ ( index ) { } <nl> - <nl> - friend bool operator = = ( const NamedJobKey & lhs , const NamedJobKey & rhs ) { <nl> - return lhs . name_ = = rhs . name_ & & lhs . index_ = = rhs . index_ ; <nl> - } <nl> - <nl> - template < typename H > <nl> - friend H AbslHashValue ( H h , const NamedJobKey & k ) { <nl> - return H : : combine ( std : : move ( h ) , k . name_ , k . index_ ) ; <nl> - } <nl> - <nl> - private : <nl> - const std : : string name_ ; <nl> - const int64 index_ ; <nl> - } ; <nl> - <nl> - class Task { <nl> - public : <nl> + struct Task { <nl> Task ( int64 task_id , int64 job_id , int64 dataset_id , <nl> const std : : string & worker_address ) <nl> - : task_id_ ( task_id ) , <nl> - job_id_ ( job_id ) , <nl> - dataset_id_ ( dataset_id ) , <nl> - worker_address_ ( worker_address ) { } <nl> - <nl> - int64 task_id ( ) const { return task_id_ ; } <nl> - int64 job_id ( ) const { return job_id_ ; } <nl> - int64 dataset_id ( ) const { return dataset_id_ ; } <nl> - std : : string worker_address ( ) const { return worker_address_ ; } <nl> - <nl> - private : <nl> - const int64 task_id_ ; <nl> - const int64 job_id_ ; <nl> - const int64 dataset_id_ ; <nl> - const std : : string worker_address_ ; <nl> + : task_id ( task_id ) , <nl> + job_id ( job_id ) , <nl> + dataset_id ( dataset_id ) , <nl> + worker_address ( worker_address ) { } <nl> + <nl> + const int64 task_id ; <nl> + const int64 job_id ; <nl> + const int64 dataset_id ; <nl> + const std : : string worker_address ; <nl> + bool finished = false ; <nl> } ; <nl> <nl> - / / Registers a dataset with the given fingerprint , returning a new dataset id . <nl> - int64 RegisterDataset ( uint64 fingerprint , const DatasetDef & dataset ) <nl> - EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> + / / Registers a dataset with the given fingerprint , storing the new dataset ' s <nl> + / / id in ` * dataset - id ` . <nl> + Status RegisterDataset ( uint64 fingerprint , const DatasetDef & dataset , <nl> + int64 * dataset_id ) EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> / / Initializes a workers stub , if it hasn ' t been initialized already . <nl> Status EnsureWorkerStubInitialized ( Worker * worker ) ; <nl> - / / Instructs a worker to begin processing a task . <nl> - Status AllocateTaskToWorker ( const Task & task_id , Worker * worker ) <nl> - LOCKS_EXCLUDED ( mu_ ) ; <nl> - / / Creates a job and stores its job_id in ` * job_id ` . <nl> + / / Creates a job and stores it in ` * job ` . This method updates the <nl> + / / dispatcher state with the new job , but does not assign tasks to workers . <nl> Status CreateJob ( int64 dataset_id , ProcessingMode processing_mode , <nl> - absl : : optional < std : : string > job_name , int64 * out_job_id ) <nl> - LOCKS_EXCLUDED ( mu_ ) ; <nl> - / / Creates a new task for a job , returning a reference to the task . <nl> - const Task & CreateTask ( Job * job , const std : : string & worker_address ) <nl> - LOCKS_EXCLUDED ( mu_ ) ; <nl> - / / Same as ` CreateTask ` , but expects that the dispatcher lock is already held . <nl> - const Task & CreateTaskLocked ( Job * job , const std : : string & worker_address ) <nl> + absl : : optional < DispatcherState : : NamedJobKey > named_job_key , <nl> + std : : shared_ptr < const DispatcherState : : Job > * job ) <nl> + EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> + / / Creates one task for each worker , for the given job . This method only <nl> + / / updates dispatcher metadata with the new tasks , but doesn ' t assign the <nl> + / / tasks to the workers . <nl> + std : : vector < std : : shared_ptr < const Task > > CreateTasksForJob ( <nl> + std : : shared_ptr < const DispatcherState : : Job > job ) <nl> EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> + / / Creates a new task for a job , returning a pointer to the created task . <nl> + std : : shared_ptr < Task > CreateTask ( <nl> + std : : shared_ptr < const DispatcherState : : Job > job , <nl> + const std : : string & worker_address ) EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> + / / Assigns the list of tasks to the workers indicated by their <nl> + / / ` worker_address ` fields . <nl> + Status AssignTasks ( std : : vector < std : : shared_ptr < const Task > > tasks ) <nl> + LOCKS_EXCLUDED ( mu_ ) ; <nl> + / / Assigns a task to the worker indicated by its ` worker_address ` field . <nl> + Status AssignTask ( std : : shared_ptr < const Task > task ) LOCKS_EXCLUDED ( mu_ ) ; <nl> / / Validates that an existing job matches the given processing_mode and <nl> / / dataset_id , returning an error status describing any difference . <nl> - Status ValidateMatchingJob ( const Job & job , ProcessingMode processing_mode , <nl> - int64 dataset_id ) ; <nl> + Status ValidateMatchingJob ( std : : shared_ptr < const DispatcherState : : Job > job , <nl> + ProcessingMode processing_mode , int64 dataset_id ) <nl> + EXCLUSIVE_LOCKS_REQUIRED ( mu_ ) ; <nl> <nl> const experimental : : DispatcherConfig & config_ ; <nl> <nl> mutex mu_ ; <nl> <nl> int64 next_worker_id_ TF_GUARDED_BY ( mu_ ) = 0 ; <nl> - int64 next_dataset_id_ TF_GUARDED_BY ( mu_ ) = 0 ; <nl> - int64 next_job_id_ TF_GUARDED_BY ( mu_ ) = 0 ; <nl> int64 next_task_id_ TF_GUARDED_BY ( mu_ ) = 0 ; <nl> <nl> - / / Registered workers . <nl> - std : : vector < std : : shared_ptr < Worker > > workers_ TF_GUARDED_BY ( mu_ ) ; <nl> - / / Registered datasets , keyed by dataset ids . <nl> - absl : : flat_hash_map < int64 , std : : shared_ptr < Dataset > > datasets_by_id_ <nl> + / / Registered workers , keyed by their addresses . <nl> + absl : : flat_hash_map < std : : string , std : : shared_ptr < Worker > > workers_ <nl> TF_GUARDED_BY ( mu_ ) ; <nl> - / / Registered datasets , keyed by dataset fingerprints . <nl> - absl : : flat_hash_map < uint64 , std : : shared_ptr < Dataset > > datasets_by_fingerprint_ <nl> - TF_GUARDED_BY ( mu_ ) ; <nl> - / / Information about jobs , keyed by job ids . <nl> - absl : : flat_hash_map < int64 , std : : shared_ptr < Job > > jobs_ TF_GUARDED_BY ( mu_ ) ; <nl> - / / Information about tasks , keyed by task ids . <nl> - absl : : flat_hash_map < int64 , Task > tasks_ TF_GUARDED_BY ( mu_ ) ; <nl> - / / Named jobs , keyed by their names and indices . Not all jobs have names , so <nl> - / / this is a subset of the jobs stored in ` jobs_ ` . <nl> - absl : : flat_hash_map < NamedJobKey , std : : shared_ptr < Job > > named_jobs_ <nl> + / / Tasks , keyed by task ids . <nl> + absl : : flat_hash_map < int64 , std : : shared_ptr < Task > > tasks_ TF_GUARDED_BY ( mu_ ) ; <nl> + / / Mapping from job id to the tasks for that job . <nl> + absl : : flat_hash_map < int64 , std : : vector < std : : shared_ptr < Task > > > tasks_by_job_ <nl> TF_GUARDED_BY ( mu_ ) ; <nl> <nl> + DispatcherState state_ TF_GUARDED_BY ( mu_ ) ; <nl> + <nl> TF_DISALLOW_COPY_AND_ASSIGN ( DataServiceDispatcherImpl ) ; <nl> } ; <nl> <nl> mmm a / tensorflow / core / data / service / dispatcher_state . cc <nl> ppp b / tensorflow / core / data / service / dispatcher_state . cc <nl> void DispatcherState : : CreateJob ( const CreateJobUpdate & create_job ) { <nl> named_job_key ) ; <nl> DCHECK ( ! jobs_ . contains ( job_id ) ) ; <nl> jobs_ [ job_id ] = job ; <nl> + LOG ( INFO ) < < " Created a new job with id " < < job_id ; <nl> if ( named_job_key . has_value ( ) ) { <nl> DCHECK ( ! named_jobs_ . contains ( named_job_key . value ( ) ) ) ; <nl> named_jobs_ [ named_job_key . value ( ) ] = job ; <nl> Status DispatcherState : : DatasetFromFingerprint ( <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + std : : vector < std : : shared_ptr < const DispatcherState : : Job > > <nl> + DispatcherState : : ListJobs ( ) { <nl> + std : : vector < std : : shared_ptr < const DispatcherState : : Job > > jobs ; <nl> + jobs . reserve ( jobs_ . size ( ) ) ; <nl> + for ( const auto & it : jobs_ ) { <nl> + jobs . push_back ( it . second ) ; <nl> + } <nl> + return jobs ; <nl> + } <nl> + <nl> Status DispatcherState : : JobFromId ( int64 id , <nl> std : : shared_ptr < const Job > * job ) const { <nl> auto it = jobs_ . find ( id ) ; <nl> mmm a / tensorflow / core / data / service / dispatcher_state . h <nl> ppp b / tensorflow / core / data / service / dispatcher_state . h <nl> class DispatcherState { <nl> <nl> / / A dataset registered with the dispatcher . <nl> struct Dataset { <nl> - public : <nl> Dataset ( int64 dataset_id , int64 fingerprint , const DatasetDef & dataset_def ) <nl> : dataset_id ( dataset_id ) , <nl> fingerprint ( fingerprint ) , <nl> class DispatcherState { <nl> / / A key for identifying a named job . The key contains a user - specified name , <nl> / / as well as an index describing which iteration of the job we are on . <nl> struct NamedJobKey { <nl> - public : <nl> NamedJobKey ( absl : : string_view name , int64 index ) <nl> : name ( name ) , index ( index ) { } <nl> <nl> class DispatcherState { <nl> <nl> / / A job for processing a dataset . <nl> struct Job { <nl> - public : <nl> Job ( int64 job_id , int64 dataset_id , ProcessingMode processing_mode , <nl> absl : : optional < NamedJobKey > named_job_key ) <nl> : job_id ( job_id ) , <nl> class DispatcherState { <nl> <nl> / / Returns the next available job id . <nl> int64 NextAvailableJobId ( ) const ; <nl> + / / Returns a list of all jobs . <nl> + std : : vector < std : : shared_ptr < const Job > > ListJobs ( ) ; <nl> / / Gets a job by id . Returns NOT_FOUND if there is no such job . <nl> Status JobFromId ( int64 id , std : : shared_ptr < const Job > * job ) const ; <nl> / / Gets a named job by key . Returns NOT_FOUND if there is no such job . <nl> mmm a / tensorflow / core / data / service / dispatcher_state_test . cc <nl> ppp b / tensorflow / core / data / service / dispatcher_state_test . cc <nl> Status CreateNamedJob ( int64 job_id , int64 dataset_id , <nl> create_job - > set_job_id ( job_id ) ; <nl> create_job - > set_dataset_id ( dataset_id ) ; <nl> create_job - > set_processing_mode ( ProcessingModeDef : : PARALLEL_EPOCHS ) ; <nl> - NamedJobKey * key = create_job - > mutable_named_job_key ( ) ; <nl> + NamedJobKeyDef * key = create_job - > mutable_named_job_key ( ) ; <nl> key - > set_name ( named_job_key . name ) ; <nl> key - > set_index ( named_job_key . index ) ; <nl> TF_RETURN_IF_ERROR ( state - > Apply ( update ) ) ; <nl> mmm a / tensorflow / core / data / service / journal . proto <nl> ppp b / tensorflow / core / data / service / journal . proto <nl> message RegisterDatasetUpdate { <nl> uint64 fingerprint = 3 ; <nl> } <nl> <nl> - message NamedJobKey { <nl> + message NamedJobKeyDef { <nl> string name = 1 ; <nl> int64 index = 2 ; <nl> } <nl> message CreateJobUpdate { <nl> int64 dataset_id = 2 ; <nl> ProcessingModeDef processing_mode = 3 ; <nl> / / Only some jobs have names , so this may be unset . <nl> - NamedJobKey named_job_key = 4 ; <nl> + NamedJobKeyDef named_job_key = 4 ; <nl> } <nl> <nl> message FinishJobUpdate { <nl>
[ tf . data service ] Update dispatcher_impl to use dispatcher_state .
tensorflow/tensorflow
ee38b3e2f9ca7ba785e74ea4803c4dc4e2593bda
2020-07-31T00:17:13Z
mmm a / tensorflow / contrib / distributions / python / ops / bernoulli . py <nl> ppp b / tensorflow / contrib / distributions / python / ops / bernoulli . py <nl> def _log_prob ( self , event ) : <nl> distribution_util . same_dynamic_shape ( logits , event ) , <nl> lambda : ( logits , event ) , <nl> lambda : broadcast ( logits , event ) ) <nl> - return - nn . sigmoid_cross_entropy_with_logits ( logits , event ) <nl> + return - nn . sigmoid_cross_entropy_with_logits ( labels = event , logits = logits ) <nl> <nl> def _prob ( self , event ) : <nl> return math_ops . exp ( self . _log_prob ( event ) ) <nl> mmm a / tensorflow / contrib / distributions / python / ops / categorical . py <nl> ppp b / tensorflow / contrib / distributions / python / ops / categorical . py <nl> def _log_prob ( self , k ) : <nl> logits_shape = array_ops . shape ( logits ) [ : - 1 ] <nl> k * = array_ops . ones ( logits_shape , dtype = k . dtype ) <nl> k . set_shape ( tensor_shape . TensorShape ( logits . get_shape ( ) [ : - 1 ] ) ) <nl> - return - nn_ops . sparse_softmax_cross_entropy_with_logits ( logits , k ) <nl> + return - nn_ops . sparse_softmax_cross_entropy_with_logits ( labels = k , <nl> + logits = logits ) <nl> <nl> def _prob ( self , k ) : <nl> return math_ops . exp ( self . _log_prob ( k ) ) <nl> def _entropy ( self ) : <nl> logits_2d = array_ops . reshape ( self . logits , [ - 1 , self . num_classes ] ) <nl> histogram_2d = nn_ops . softmax ( logits_2d ) <nl> ret = array_ops . reshape ( <nl> - nn_ops . softmax_cross_entropy_with_logits ( logits_2d , histogram_2d ) , <nl> + nn_ops . softmax_cross_entropy_with_logits ( labels = histogram_2d , <nl> + logits = logits_2d ) , <nl> self . batch_shape ( ) ) <nl> ret . set_shape ( self . get_batch_shape ( ) ) <nl> return ret <nl> mmm a / tensorflow / contrib / distributions / python / ops / onehot_categorical . py <nl> ppp b / tensorflow / contrib / distributions / python / ops / onehot_categorical . py <nl> def _log_prob ( self , x ) : <nl> else : <nl> logits_2d = array_ops . reshape ( logits , [ - 1 , self . num_classes ] ) <nl> x_2d = array_ops . reshape ( x , [ - 1 , self . num_classes ] ) <nl> - ret = - nn_ops . softmax_cross_entropy_with_logits ( logits_2d , x_2d ) <nl> + ret = - nn_ops . softmax_cross_entropy_with_logits ( labels = x_2d , <nl> + logits = logits_2d ) <nl> ret = array_ops . reshape ( ret , logits_shape ) <nl> return ret <nl> <nl> def _entropy ( self ) : <nl> logits_2d = array_ops . reshape ( self . logits , [ - 1 , self . num_classes ] ) <nl> histogram_2d = nn_ops . softmax ( logits_2d ) <nl> ret = array_ops . reshape ( <nl> - nn_ops . softmax_cross_entropy_with_logits ( logits_2d , histogram_2d ) , <nl> + nn_ops . softmax_cross_entropy_with_logits ( labels = histogram_2d , <nl> + logits = logits_2d ) , <nl> self . batch_shape ( ) ) <nl> ret . set_shape ( self . get_batch_shape ( ) ) <nl> return ret <nl> mmm a / tensorflow / contrib / layers / python / layers / feature_column_ops . py <nl> ppp b / tensorflow / contrib / layers / python / layers / feature_column_ops . py <nl> def weighted_sum_from_feature_columns ( columns_to_tensors , <nl> columns_to_tensors = columns_to_tensor , <nl> feature_columns = feature_columns , <nl> num_outputs = 1 ) <nl> - loss = tf . nn . sigmoid_cross_entropy_with_logits ( logits , labels ) <nl> + loss = tf . nn . sigmoid_cross_entropy_with_logits ( labels = labels , <nl> + logits = logits ) <nl> ` ` ` <nl> <nl> Args : <nl> mmm a / tensorflow / contrib / layers / python / layers / target_column . py <nl> ppp b / tensorflow / contrib / layers / python / layers / target_column . py <nl> def _log_loss_with_two_classes ( logits , target ) : <nl> # sigmoid_cross_entropy_with_logits requires [ batch_size , 1 ] target . <nl> if len ( target . get_shape ( ) ) = = 1 : <nl> target = array_ops . expand_dims ( target , dim = [ 1 ] ) <nl> - loss_vec = nn . sigmoid_cross_entropy_with_logits ( logits , <nl> - math_ops . to_float ( target ) ) <nl> + loss_vec = nn . sigmoid_cross_entropy_with_logits ( <nl> + labels = math_ops . to_float ( target ) , logits = logits ) <nl> return loss_vec <nl> <nl> <nl> def _softmax_cross_entropy_loss ( logits , target ) : <nl> # sparse_softmax_cross_entropy_with_logits requires [ batch_size ] target . <nl> if len ( target . get_shape ( ) ) = = 2 : <nl> target = array_ops . squeeze ( target , squeeze_dims = [ 1 ] ) <nl> - loss_vec = nn . sparse_softmax_cross_entropy_with_logits ( logits , target ) <nl> + loss_vec = nn . sparse_softmax_cross_entropy_with_logits ( <nl> + labels = target , logits = logits ) <nl> return loss_vec <nl> <nl> <nl> mmm a / tensorflow / contrib / learn / python / learn / estimators / head . py <nl> ppp b / tensorflow / contrib / learn / python / learn / estimators / head . py <nl> def _log_loss_with_two_classes ( logits , labels ) : <nl> if len ( labels . get_shape ( ) ) = = 1 : <nl> labels = array_ops . expand_dims ( labels , dim = ( 1 , ) ) <nl> return nn . sigmoid_cross_entropy_with_logits ( <nl> - logits , math_ops . to_float ( labels ) , name = name ) <nl> + labels = math_ops . to_float ( labels ) , logits = logits , name = name ) <nl> <nl> <nl> def _one_class_to_two_class_logits ( logits ) : <nl> def _softmax_cross_entropy_loss ( logits , labels ) : <nl> if len ( labels . get_shape ( ) ) = = 2 : <nl> labels = array_ops . squeeze ( labels , squeeze_dims = ( 1 , ) ) <nl> return nn . sparse_softmax_cross_entropy_with_logits ( <nl> - logits , labels , name = name ) <nl> + labels = labels , logits = logits , name = name ) <nl> <nl> <nl> class _MultiClassHead ( _Head ) : <nl> def _sigmoid_cross_entropy_loss ( logits , labels ) : <nl> ( logits , labels ) ) as name : <nl> # sigmoid_cross_entropy_with_logits requires [ batch_size , n_classes ] labels . <nl> return nn . sigmoid_cross_entropy_with_logits ( <nl> - logits , math_ops . to_float ( labels ) , name = name ) <nl> + labels = math_ops . to_float ( labels ) , logits = logits , name = name ) <nl> <nl> <nl> def _float_weights_or_none ( weights ) : <nl> mmm a / tensorflow / contrib / learn / python / learn / ops / seq2seq_ops . py <nl> ppp b / tensorflow / contrib / learn / python / learn / ops / seq2seq_ops . py <nl> def sequence_classifier ( decoding , labels , sampling_decoding = None , name = None ) : <nl> predictions , xent_list = [ ] , [ ] <nl> for i , pred in enumerate ( decoding ) : <nl> xent_list . append ( nn . softmax_cross_entropy_with_logits ( <nl> - pred , labels [ i ] , <nl> + labels = labels [ i ] , logits = pred , <nl> name = " sequence_loss / xent_raw { 0 } " . format ( i ) ) ) <nl> if sampling_decoding : <nl> predictions . append ( nn . softmax ( sampling_decoding [ i ] ) ) <nl> mmm a / tensorflow / contrib / legacy_seq2seq / python / ops / seq2seq . py <nl> ppp b / tensorflow / contrib / legacy_seq2seq / python / ops / seq2seq . py <nl> def sequence_loss_by_example ( logits , <nl> # violates our general scalar strictness policy . <nl> target = array_ops . reshape ( target , [ - 1 ] ) <nl> crossent = nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> - logits = logit , labels = target ) <nl> + labels = target , logits = logit ) <nl> else : <nl> crossent = softmax_loss_function ( target , logit ) <nl> log_perp_list . append ( crossent * weight ) <nl> mmm a / tensorflow / contrib / linear_optimizer / python / ops / sdca_ops . py <nl> ppp b / tensorflow / contrib / linear_optimizer / python / ops / sdca_ops . py <nl> def unregularized_loss ( self , examples ) : <nl> dtypes . float64 ) <nl> <nl> if self . _options [ ' loss_type ' ] = = ' logistic_loss ' : <nl> - return math_ops . reduce_sum ( <nl> - math_ops . multiply ( <nl> - sigmoid_cross_entropy_with_logits ( predictions , labels ) , <nl> - weights ) ) / math_ops . reduce_sum ( weights ) <nl> + return math_ops . reduce_sum ( math_ops . multiply ( <nl> + sigmoid_cross_entropy_with_logits ( labels = labels , <nl> + logits = predictions ) , <nl> + weights ) ) / math_ops . reduce_sum ( weights ) <nl> <nl> if self . _options [ ' loss_type ' ] in [ ' hinge_loss ' , ' smooth_hinge_loss ' ] : <nl> # hinge_loss = max { 0 , 1 - y_i w * x } where y_i \ in { - 1 , 1 } . So , we need to <nl> mmm a / tensorflow / contrib / losses / python / losses / loss_ops . py <nl> ppp b / tensorflow / contrib / losses / python / losses / loss_ops . py <nl> def sigmoid_cross_entropy ( <nl> multi_class_labels = ( multi_class_labels * ( 1 - label_smoothing ) + <nl> 0 . 5 * label_smoothing ) <nl> <nl> - losses = nn . sigmoid_cross_entropy_with_logits ( logits , multi_class_labels , <nl> + losses = nn . sigmoid_cross_entropy_with_logits ( labels = multi_class_labels , <nl> + logits = logits , <nl> name = " xentropy " ) <nl> return compute_weighted_loss ( losses , weights , scope = scope ) <nl> <nl> def softmax_cross_entropy ( <nl> smooth_negatives = label_smoothing / num_classes <nl> onehot_labels = onehot_labels * smooth_positives + smooth_negatives <nl> <nl> - losses = nn . softmax_cross_entropy_with_logits ( logits , onehot_labels , <nl> + losses = nn . softmax_cross_entropy_with_logits ( labels = onehot_labels , <nl> + logits = logits , <nl> name = " xentropy " ) <nl> return compute_weighted_loss ( losses , weights , scope = scope ) <nl> <nl> def sparse_softmax_cross_entropy ( logits , labels , weights = 1 . 0 , scope = None ) : <nl> labels = array_ops . reshape ( labels , shape = [ array_ops . shape ( labels ) [ 0 ] ] ) <nl> weights = array_ops . squeeze ( weights ) <nl> <nl> - losses = nn . sparse_softmax_cross_entropy_with_logits ( logits , labels , <nl> + losses = nn . sparse_softmax_cross_entropy_with_logits ( labels = labels , <nl> + logits = logits , <nl> name = " xentropy " ) <nl> return compute_weighted_loss ( losses , weights , scope = scope ) <nl> <nl> mmm a / tensorflow / contrib / nn / python / ops / cross_entropy . py <nl> ppp b / tensorflow / contrib / nn / python / ops / cross_entropy . py <nl> def deprecated_flipped_softmax_cross_entropy_with_logits ( logits , <nl> softmax cross entropy loss . <nl> " " " <nl> return nn . softmax_cross_entropy_with_logits ( <nl> - logits = logits , labels = labels , dim = dim , name = name ) <nl> + labels = labels , logits = logits , dim = dim , name = name ) <nl> <nl> <nl> # TODO ( b / 33392402 ) : Formally deprecate this API . <nl> def deprecated_flipped_sparse_softmax_cross_entropy_with_logits ( logits , <nl> of the labels is not equal to the rank of the labels minus one . <nl> " " " <nl> return nn . sparse_softmax_cross_entropy_with_logits ( <nl> - logits = logits , labels = labels , name = name ) <nl> + labels = labels , logits = logits , name = name ) <nl> <nl> <nl> # TODO ( b / 33392402 ) : Formally deprecate this API . <nl> class is independent and not mutually exclusive . For instance , one could <nl> ValueError : If ` logits ` and ` targets ` do not have the same shape . <nl> " " " <nl> return nn . sigmoid_cross_entropy_with_logits ( <nl> - logits = logits , targets = targets , name = name ) <nl> + labels = targets , logits = logits , name = name ) <nl> mmm a / tensorflow / contrib / tensor_forest / hybrid / python / hybrid_model . py <nl> ppp b / tensorflow / contrib / tensor_forest / hybrid / python / hybrid_model . py <nl> def loss ( self , data , labels ) : <nl> else : <nl> loss = math_ops . reduce_mean ( <nl> nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> - self . training_inference_graph ( data ) , <nl> - array_ops . squeeze ( math_ops . to_int32 ( labels ) ) ) , <nl> + labels = array_ops . squeeze ( math_ops . to_int32 ( labels ) ) , <nl> + logits = self . training_inference_graph ( data ) ) , <nl> name = " loss " ) <nl> if self . regularizer : <nl> loss + = layers . apply_regularization ( self . regularizer , <nl> mmm a / tensorflow / examples / image_retraining / retrain . py <nl> ppp b / tensorflow / examples / image_retraining / retrain . py <nl> def add_final_training_ops ( class_count , final_tensor_name , bottleneck_tensor ) : <nl> <nl> with tf . name_scope ( ' cross_entropy ' ) : <nl> cross_entropy = tf . nn . softmax_cross_entropy_with_logits ( <nl> - logits , ground_truth_input ) <nl> + labels = ground_truth_input , logits = logits ) <nl> with tf . name_scope ( ' total ' ) : <nl> cross_entropy_mean = tf . reduce_mean ( cross_entropy ) <nl> tf . summary . scalar ( ' cross_entropy ' , cross_entropy_mean ) <nl> mmm a / tensorflow / examples / tutorials / mnist / mnist . py <nl> ppp b / tensorflow / examples / tutorials / mnist / mnist . py <nl> def loss ( logits , labels ) : <nl> " " " <nl> labels = tf . to_int64 ( labels ) <nl> cross_entropy = tf . nn . sparse_softmax_cross_entropy_with_logits ( <nl> - logits , labels , name = ' xentropy ' ) <nl> - loss = tf . reduce_mean ( cross_entropy , name = ' xentropy_mean ' ) <nl> - return loss <nl> + labels = labels , logits = logits , name = ' xentropy ' ) <nl> + return tf . reduce_mean ( cross_entropy , name = ' xentropy_mean ' ) <nl> <nl> <nl> def training ( loss , learning_rate ) : <nl> mmm a / tensorflow / examples / tutorials / mnist / mnist_softmax . py <nl> ppp b / tensorflow / examples / tutorials / mnist / mnist_softmax . py <nl> def main ( _ ) : <nl> # <nl> # So here we use tf . nn . softmax_cross_entropy_with_logits on the raw <nl> # outputs of ' y ' , and then average across the batch . <nl> - cross_entropy = tf . reduce_mean ( tf . nn . softmax_cross_entropy_with_logits ( y , y_ ) ) <nl> + cross_entropy = tf . reduce_mean ( <nl> + tf . nn . softmax_cross_entropy_with_logits ( labels = y_ , logits = y ) ) <nl> train_step = tf . train . GradientDescentOptimizer ( 0 . 5 ) . minimize ( cross_entropy ) <nl> <nl> sess = tf . InteractiveSession ( ) <nl> mmm a / tensorflow / examples / tutorials / mnist / mnist_with_summaries . py <nl> ppp b / tensorflow / examples / tutorials / mnist / mnist_with_summaries . py <nl> def nn_layer ( input_tensor , input_dim , output_dim , layer_name , act = tf . nn . relu ) : <nl> # So here we use tf . nn . softmax_cross_entropy_with_logits on the <nl> # raw outputs of the nn_layer above , and then average across <nl> # the batch . <nl> - diff = tf . nn . softmax_cross_entropy_with_logits ( y , y_ ) <nl> + diff = tf . nn . softmax_cross_entropy_with_logits ( labels = y_ , logits = y ) <nl> with tf . name_scope ( ' total ' ) : <nl> cross_entropy = tf . reduce_mean ( diff ) <nl> tf . summary . scalar ( ' cross_entropy ' , cross_entropy ) <nl> mmm a / tensorflow / examples / udacity / 2_fullyconnected . ipynb <nl> ppp b / tensorflow / examples / udacity / 2_fullyconnected . ipynb <nl> <nl> " # cross - entropy across all training examples : that ' s our loss . \ n " , <nl> " logits = tf . matmul ( tf_train_dataset , weights ) + biases \ n " , <nl> " loss = tf . reduce_mean ( \ n " , <nl> - " tf . nn . softmax_cross_entropy_with_logits ( logits , tf_train_labels ) ) \ n " , <nl> + " tf . nn . softmax_cross_entropy_with_logits ( labels = tf_train_labels , logits = logits ) ) \ n " , <nl> " \ n " , <nl> " # Optimizer . \ n " , <nl> " # We are going to find the minimum of this loss using gradient descent . \ n " , <nl> <nl> " # Training computation . \ n " , <nl> " logits = tf . matmul ( tf_train_dataset , weights ) + biases \ n " , <nl> " loss = tf . reduce_mean ( \ n " , <nl> - " tf . nn . softmax_cross_entropy_with_logits ( logits , tf_train_labels ) ) \ n " , <nl> + " tf . nn . softmax_cross_entropy_with_logits ( labels = tf_train_labels , logits = logits ) ) \ n " , <nl> " \ n " , <nl> " # Optimizer . \ n " , <nl> " optimizer = tf . train . GradientDescentOptimizer ( 0 . 5 ) . minimize ( loss ) \ n " , <nl> mmm a / tensorflow / examples / udacity / 4_convolutions . ipynb <nl> ppp b / tensorflow / examples / udacity / 4_convolutions . ipynb <nl> <nl> " # Training computation . \ n " , <nl> " logits = model ( tf_train_dataset ) \ n " , <nl> " loss = tf . reduce_mean ( \ n " , <nl> - " tf . nn . softmax_cross_entropy_with_logits ( logits , tf_train_labels ) ) \ n " , <nl> + " tf . nn . softmax_cross_entropy_with_logits ( labels = tf_train_labels , logits = logits ) ) \ n " , <nl> " \ n " , <nl> " # Optimizer . \ n " , <nl> " optimizer = tf . train . GradientDescentOptimizer ( 0 . 05 ) . minimize ( loss ) \ n " , <nl> mmm a / tensorflow / examples / udacity / 6_lstm . ipynb <nl> ppp b / tensorflow / examples / udacity / 6_lstm . ipynb <nl> <nl> " logits = tf . nn . xw_plus_b ( tf . concat_v2 ( outputs , 0 ) , w , b ) \ n " , <nl> " loss = tf . reduce_mean ( \ n " , <nl> " tf . nn . softmax_cross_entropy_with_logits ( \ n " , <nl> - " logits , tf . concat_v2 ( train_labels , 0 ) ) ) \ n " , <nl> + " labels = tf . concat_v2 ( train_labels , 0 ) , logits = logits ) ) \ n " , <nl> " \ n " , <nl> " # Optimizer . \ n " , <nl> " global_step = tf . Variable ( 0 ) \ n " , <nl> mmm a / tensorflow / g3doc / api_docs / python / contrib . layers . md <nl> ppp b / tensorflow / g3doc / api_docs / python / contrib . layers . md <nl> Example : <nl> columns_to_tensors = columns_to_tensor , <nl> feature_columns = feature_columns , <nl> num_outputs = 1 ) <nl> - loss = tf . nn . sigmoid_cross_entropy_with_logits ( logits , labels ) <nl> + loss = tf . nn . sigmoid_cross_entropy_with_logits ( labels = labels , <nl> + logits = logits ) <nl> ` ` ` <nl> <nl> # # # # # Args : <nl> mmm a / tensorflow / g3doc / api_docs / python / functions_and_classes / shard2 / tf . contrib . layers . weighted_sum_from_feature_columns . md <nl> ppp b / tensorflow / g3doc / api_docs / python / functions_and_classes / shard2 / tf . contrib . layers . weighted_sum_from_feature_columns . md <nl> Example : <nl> columns_to_tensors = columns_to_tensor , <nl> feature_columns = feature_columns , <nl> num_outputs = 1 ) <nl> - loss = tf . nn . sigmoid_cross_entropy_with_logits ( logits , labels ) <nl> + loss = tf . nn . sigmoid_cross_entropy_with_logits ( labels = labels , <nl> + logits = logits ) <nl> ` ` ` <nl> <nl> # # # # # Args : <nl> mmm a / tensorflow / g3doc / how_tos / meta_graph / index . md <nl> ppp b / tensorflow / g3doc / how_tos / meta_graph / index . md <nl> Here are some of the typical usage models : <nl> onehot_labels = tf . sparse_to_dense ( <nl> concated , tf . pack ( [ batch_size , 10 ] ) , 1 . 0 , 0 . 0 ) <nl> logits = tf . get_collection ( " logits " ) [ 0 ] <nl> - cross_entropy = tf . nn . softmax_cross_entropy_with_logits ( logits , <nl> - onehot_labels , <nl> - name = " xentropy " ) <nl> + cross_entropy = tf . nn . softmax_cross_entropy_with_logits ( <nl> + labels = onehot_labels , logits = logits , name = " xentropy " ) <nl> loss = tf . reduce_mean ( cross_entropy , name = " xentropy_mean " ) <nl> <nl> tf . summary . scalar ( ' loss ' , loss ) <nl> mmm a / tensorflow / g3doc / how_tos / summaries_and_tensorboard / index . md <nl> ppp b / tensorflow / g3doc / how_tos / summaries_and_tensorboard / index . md <nl> with tf . name_scope ( ' cross_entropy ' ) : <nl> # So here we use tf . nn . softmax_cross_entropy_with_logits on the <nl> # raw outputs of the nn_layer above , and then average across <nl> # the batch . <nl> - diff = tf . nn . softmax_cross_entropy_with_logits ( y , y_ ) <nl> + diff = tf . nn . softmax_cross_entropy_with_logits ( targets = y_ , logits = y ) <nl> with tf . name_scope ( ' total ' ) : <nl> cross_entropy = tf . reduce_mean ( diff ) <nl> tf . summary . scalar ( ' cross_entropy ' , cross_entropy ) <nl> mmm a / tensorflow / g3doc / tutorials / mnist / pros / index . md <nl> ppp b / tensorflow / g3doc / tutorials / mnist / pros / index . md <nl> between the target and the softmax activation function applied to the model ' s <nl> prediction . As in the beginners tutorial , we use the stable formulation : <nl> <nl> ` ` ` python <nl> - cross_entropy = tf . reduce_mean ( tf . nn . softmax_cross_entropy_with_logits ( y , y_ ) ) <nl> + cross_entropy = tf . reduce_mean ( <nl> + tf . nn . softmax_cross_entropy_with_logits ( labels = y_ , logits = y ) ) <nl> ` ` ` <nl> <nl> Note that ` tf . nn . softmax_cross_entropy_with_logits ` internally applies the <nl> Feel free to go ahead and run this code , but it does 20 , 000 training iterations <nl> and may take a while ( possibly up to half an hour ) , depending on your processor . <nl> <nl> ` ` ` python <nl> - cross_entropy = tf . reduce_mean ( tf . nn . softmax_cross_entropy_with_logits ( y_conv , y_ ) ) <nl> + cross_entropy = tf . reduce_mean ( <nl> + tf . nn . softmax_cross_entropy_with_logits ( labels = y_ , logits = y_conv ) ) <nl> train_step = tf . train . AdamOptimizer ( 1e - 4 ) . minimize ( cross_entropy ) <nl> correct_prediction = tf . equal ( tf . argmax ( y_conv , 1 ) , tf . argmax ( y_ , 1 ) ) <nl> accuracy = tf . reduce_mean ( tf . cast ( correct_prediction , tf . float32 ) ) <nl> mmm a / tensorflow / g3doc / tutorials / mnist / tf / index . md <nl> ppp b / tensorflow / g3doc / tutorials / mnist / tf / index . md <nl> First , the values from the ` labels_placeholder ` are converted to 64 - bit integers <nl> ` ` ` python <nl> labels = tf . to_int64 ( labels ) <nl> cross_entropy = tf . nn . sparse_softmax_cross_entropy_with_logits ( <nl> - logits , labels , name = ' xentropy ' ) <nl> + labels = labels , logits = logits , name = ' xentropy ' ) <nl> ` ` ` <nl> <nl> It then uses [ ` tf . reduce_mean ` ] ( . . / . . / . . / api_docs / python / math_ops . md # reduce_mean ) <nl> mmm a / tensorflow / python / kernel_tests / sparse_xent_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / sparse_xent_op_test . py <nl> def testShapeMismatch ( self ) : <nl> with self . test_session ( use_gpu = True ) : <nl> with self . assertRaisesRegexp ( ValueError , " . * Rank mismatch : * " ) : <nl> nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> - [ [ 0 . , 1 . ] , [ 2 . , 3 . ] , [ 2 . , 3 . ] ] , [ [ 0 , 2 ] ] ) <nl> + labels = [ [ 0 , 2 ] ] , logits = [ [ 0 . , 1 . ] , [ 2 . , 3 . ] , [ 2 . , 3 . ] ] ) <nl> <nl> def testScalar ( self ) : <nl> with self . test_session ( use_gpu = True ) : <nl> with self . assertRaisesRegexp ( ValueError , " . * Logits cannot be scalars * " ) : <nl> nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> - constant_op . constant ( 1 . 0 ) , constant_op . constant ( 0 ) ) <nl> + labels = constant_op . constant ( 0 ) , logits = constant_op . constant ( 1 . 0 ) ) <nl> <nl> def testLabelsPlaceholderScalar ( self ) : <nl> with self . test_session ( use_gpu = True ) : <nl> labels = array_ops . placeholder ( np . int32 ) <nl> - y = nn_ops . sparse_softmax_cross_entropy_with_logits ( [ [ 7 . ] ] , labels ) <nl> + y = nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> + labels = labels , logits = [ [ 7 . ] ] ) <nl> with self . assertRaisesOpError ( " labels must be 1 - D " ) : <nl> y . eval ( feed_dict = { labels : 0 } ) <nl> <nl> def testVector ( self ) : <nl> with self . test_session ( use_gpu = True ) : <nl> loss = nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> - constant_op . constant ( [ 1 . 0 ] ) , constant_op . constant ( 0 ) ) <nl> + labels = constant_op . constant ( 0 ) , logits = constant_op . constant ( [ 1 . 0 ] ) ) <nl> self . assertAllClose ( 0 . 0 , loss . eval ( ) ) <nl> <nl> def testFloat ( self ) : <nl> def testGradient ( self ) : <nl> shape = [ 3 , 4 ] , <nl> dtype = dtypes . float64 , <nl> name = " f " ) <nl> - x = nn_ops . sparse_softmax_cross_entropy_with_logits ( f , l , name = " xent " ) <nl> + x = nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> + labels = l , logits = f , name = " xent " ) <nl> err = gradient_checker . compute_gradient_error ( f , [ 3 , 4 ] , x , [ 3 ] ) <nl> print ( " cross entropy gradient err = " , err ) <nl> self . assertLess ( err , 5e - 8 ) <nl> def _testHighDim ( self , features , labels ) : <nl> # manually reshape loss <nl> np_loss = np . reshape ( np_loss , np . array ( labels ) . shape ) <nl> with self . test_session ( use_gpu = True ) as sess : <nl> - loss = nn_ops . sparse_softmax_cross_entropy_with_logits ( features , labels ) <nl> + loss = nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> + labels = labels , logits = features ) <nl> backprop = loss . op . inputs [ 0 ] . op . outputs [ 1 ] <nl> tf_loss , tf_backprop = sess . run ( [ loss , backprop ] ) <nl> self . assertAllCloseAccordingToType ( np_loss , tf_loss ) <nl> def testScalarHandling ( self ) : <nl> labels = array_ops . placeholder ( dtypes . int32 , shape = [ None , 1 ] ) <nl> logits = array_ops . placeholder ( dtypes . float32 , shape = [ None , 3 ] ) <nl> ce = nn_ops . sparse_softmax_cross_entropy_with_logits ( <nl> - logits , array_ops . squeeze ( labels ) ) <nl> + labels = array_ops . squeeze ( labels ) , logits = logits ) <nl> labels_v2 = np . zeros ( ( 1 , 1 ) , dtype = np . int32 ) <nl> logits_v2 = np . random . randn ( 1 , 3 ) <nl> sess . run ( [ ce ] , feed_dict = { labels : labels_v2 , logits : logits_v2 } ) <nl> def _sparse_vs_dense_xent_benchmark_dense ( labels , logits ) : <nl> array_ops . stack ( [ length ] ) , 1 . 0 , 0 . 0 ) <nl> target = array_ops . reshape ( target , array_ops . stack ( [ - 1 , num_entries ] ) ) <nl> crossent = nn_ops . softmax_cross_entropy_with_logits ( <nl> - logits , target , name = " SequenceLoss / CrossEntropy " ) <nl> + labels = target , logits = logits , name = " SequenceLoss / CrossEntropy " ) <nl> crossent_sum = math_ops . reduce_sum ( crossent ) <nl> grads = gradients_impl . gradients ( [ crossent_sum ] , [ logits ] ) [ 0 ] <nl> <nl> mmm a / tensorflow / python / kernel_tests / xent_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / xent_op_test . py <nl> def _testXentWrapper ( self , np_features , np_labels , dim = - 1 , use_gpu = False ) : <nl> np_loss , _ = self . _npXent ( np_features , np_labels , dim = dim ) <nl> with self . test_session ( use_gpu = use_gpu ) as sess : <nl> loss = nn_ops . softmax_cross_entropy_with_logits ( <nl> - np_features , np_labels , dim = dim ) <nl> + labels = np_labels , logits = np_features , dim = dim ) <nl> tf_loss = sess . run ( loss ) <nl> print ( " np_loss : " , np_loss ) <nl> print ( " tf_loss : " , tf_loss ) <nl> def testGradient ( self ) : <nl> shape = [ 3 , 4 ] , <nl> dtype = dtypes . float64 , <nl> name = " f " ) <nl> - x = nn_ops . softmax_cross_entropy_with_logits ( f , l , name = " xent " ) <nl> + x = nn_ops . softmax_cross_entropy_with_logits ( labels = l , logits = f , <nl> + name = " xent " ) <nl> err = gradient_checker . compute_gradient_error ( f , [ 3 , 4 ] , x , [ 3 ] ) <nl> print ( " cross entropy gradient err = " , err ) <nl> self . assertLess ( err , 5e - 8 ) <nl> mmm a / tensorflow / python / ops / gradient_checker_test . py <nl> ppp b / tensorflow / python / ops / gradient_checker_test . py <nl> def _BuildAndTestMiniMNIST ( self , param_index , tag ) : <nl> dtype = dtypes . float64 , <nl> name = " labels " ) <nl> cost = nn_ops . softmax_cross_entropy_with_logits ( <nl> - logits , labels , name = " cost " ) <nl> + labels = labels , logits = logits , name = " cost " ) <nl> <nl> # Test the gradients . <nl> err = gradient_checker . compute_gradient_error ( <nl> mmm a / tensorflow / python / ops / losses / losses_impl . py <nl> ppp b / tensorflow / python / ops / losses / losses_impl . py <nl> def sigmoid_cross_entropy ( <nl> multi_class_labels = ( multi_class_labels * ( 1 - label_smoothing ) + <nl> 0 . 5 * label_smoothing ) <nl> <nl> - losses = nn . sigmoid_cross_entropy_with_logits ( logits , multi_class_labels , <nl> + losses = nn . sigmoid_cross_entropy_with_logits ( labels = multi_class_labels , <nl> + logits = logits , <nl> name = " xentropy " ) <nl> return compute_weighted_loss ( losses , weights , scope , loss_collection ) <nl> <nl> def softmax_cross_entropy ( <nl> smooth_negatives = label_smoothing / num_classes <nl> onehot_labels = onehot_labels * smooth_positives + smooth_negatives <nl> <nl> - losses = nn . softmax_cross_entropy_with_logits ( logits , onehot_labels , <nl> + losses = nn . softmax_cross_entropy_with_logits ( labels = onehot_labels , <nl> + logits = logits , <nl> name = " xentropy " ) <nl> return compute_weighted_loss ( losses , weights , scope , loss_collection ) <nl> <nl> def sparse_softmax_cross_entropy ( labels , logits , weights = 1 . 0 , scope = None , <nl> [ logits , labels , weights ] ) as scope : <nl> labels = array_ops . reshape ( labels , shape = [ array_ops . shape ( labels ) [ 0 ] ] ) <nl> <nl> - losses = nn . sparse_softmax_cross_entropy_with_logits ( logits , labels , <nl> + losses = nn . sparse_softmax_cross_entropy_with_logits ( labels = labels , <nl> + logits = logits , <nl> name = " xentropy " ) <nl> # Reshape losses to [ batch_size , 1 ] to be consistent with weights . <nl> losses = array_ops . reshape ( losses , shape = [ array_ops . shape ( losses ) [ 0 ] , 1 ] ) <nl> mmm a / tensorflow / python / ops / nn_impl . py <nl> ppp b / tensorflow / python / ops / nn_impl . py <nl> def log_poisson_loss ( targets , log_input , compute_full_loss = False , name = None ) : <nl> return result <nl> <nl> <nl> - def sigmoid_cross_entropy_with_logits ( logits , targets , name = None ) : <nl> + def sigmoid_cross_entropy_with_logits ( _sentinel = None , # pylint : disable = invalid - name <nl> + labels = None , logits = None , <nl> + name = None ) : <nl> " " " Computes sigmoid cross entropy given ` logits ` . <nl> <nl> Measures the probability error in discrete classification tasks in which each <nl> class is independent and not mutually exclusive . For instance , one could <nl> perform multilabel classification where a picture can contain both an elephant <nl> and a dog at the same time . <nl> <nl> - For brevity , let ` x = logits ` , ` z = targets ` . The logistic loss is <nl> + For brevity , let ` x = logits ` , ` z = labels ` . The logistic loss is <nl> <nl> z * - log ( sigmoid ( x ) ) + ( 1 - z ) * - log ( 1 - sigmoid ( x ) ) <nl> = z * - log ( 1 / ( 1 + exp ( - x ) ) ) + ( 1 - z ) * - log ( exp ( - x ) / ( 1 + exp ( - x ) ) ) <nl> class is independent and not mutually exclusive . For instance , one could <nl> <nl> max ( x , 0 ) - x * z + log ( 1 + exp ( - abs ( x ) ) ) <nl> <nl> - ` logits ` and ` targets ` must have the same type and shape . <nl> + ` logits ` and ` labels ` must have the same type and shape . <nl> <nl> Args : <nl> + _sentinel : Used to prevent positional parameters . Internal , do not use . <nl> + labels : A ` Tensor ` of the same type and shape as ` logits ` . <nl> logits : A ` Tensor ` of type ` float32 ` or ` float64 ` . <nl> - targets : A ` Tensor ` of the same type and shape as ` logits ` . <nl> name : A name for the operation ( optional ) . <nl> <nl> Returns : <nl> class is independent and not mutually exclusive . For instance , one could <nl> logistic losses . <nl> <nl> Raises : <nl> - ValueError : If ` logits ` and ` targets ` do not have the same shape . <nl> + ValueError : If ` logits ` and ` labels ` do not have the same shape . <nl> " " " <nl> - with ops . name_scope ( name , " logistic_loss " , [ logits , targets ] ) as name : <nl> + # pylint : disable = protected - access <nl> + nn_ops . _ensure_xent_args ( " sigmoid_cross_entropy_with_logits " , <nl> + _sentinel , labels , logits ) <nl> + # pylint : enable = protected - access <nl> + <nl> + with ops . name_scope ( name , " logistic_loss " , [ logits , labels ] ) as name : <nl> logits = ops . convert_to_tensor ( logits , name = " logits " ) <nl> - targets = ops . convert_to_tensor ( targets , name = " targets " ) <nl> + labels = ops . convert_to_tensor ( labels , name = " labels " ) <nl> try : <nl> - targets . get_shape ( ) . merge_with ( logits . get_shape ( ) ) <nl> + labels . get_shape ( ) . merge_with ( logits . get_shape ( ) ) <nl> except ValueError : <nl> - raise ValueError ( " logits and targets must have the same shape ( % s vs % s ) " <nl> - % ( logits . get_shape ( ) , targets . get_shape ( ) ) ) <nl> + raise ValueError ( " logits and labels must have the same shape ( % s vs % s ) " <nl> + % ( logits . get_shape ( ) , labels . get_shape ( ) ) ) <nl> <nl> # The logistic loss formula from above is <nl> # x - x * z + log ( 1 + exp ( - x ) ) <nl> class is independent and not mutually exclusive . For instance , one could <nl> cond = ( logits > = zeros ) <nl> relu_logits = array_ops . where ( cond , logits , zeros ) <nl> neg_abs_logits = array_ops . where ( cond , - logits , logits ) <nl> - return math_ops . add ( relu_logits - logits * targets , <nl> + return math_ops . add ( relu_logits - logits * labels , <nl> math_ops . log1p ( math_ops . exp ( neg_abs_logits ) ) , <nl> name = name ) <nl> <nl> def nce_loss ( weights , <nl> partition_strategy = partition_strategy , <nl> name = name ) <nl> sampled_losses = sigmoid_cross_entropy_with_logits ( <nl> - logits , labels , name = " sampled_losses " ) <nl> + labels = labels , logits = logits , name = " sampled_losses " ) <nl> # sampled_losses is batch_size x { true_loss , sampled_losses . . . } <nl> # We sum out true and sampled losses . <nl> return _sum_rows ( sampled_losses ) <nl> def sampled_softmax_loss ( weights , <nl> remove_accidental_hits = remove_accidental_hits , <nl> partition_strategy = partition_strategy , <nl> name = name ) <nl> - sampled_losses = nn_ops . softmax_cross_entropy_with_logits ( logits , labels ) <nl> + sampled_losses = nn_ops . softmax_cross_entropy_with_logits ( labels = labels , <nl> + logits = logits ) <nl> # sampled_losses is a [ batch_size ] tensor . <nl> return sampled_losses <nl> mmm a / tensorflow / python / ops / nn_ops . py <nl> ppp b / tensorflow / python / ops / nn_ops . py <nl> <nl> # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> " " " Wrappers for primitive Neural Net ( NN ) Operations . " " " <nl> <nl> - # pylint : disable = invalid - name <nl> from __future__ import absolute_import <nl> from __future__ import division <nl> from __future__ import print_function <nl> def conv2d_transpose ( value , <nl> raise ValueError ( " data_format has to be either NCHW or NHWC . " ) <nl> value = ops . convert_to_tensor ( value , name = " value " ) <nl> filter = ops . convert_to_tensor ( filter , name = " filter " ) <nl> - axis = 3 if data_format = = " NHWC " else 1 <nl> + axis = 3 if data_format = = " NHWC " else 1 <nl> if not value . get_shape ( ) [ axis ] . is_compatible_with ( filter . get_shape ( ) [ 3 ] ) : <nl> raise ValueError ( " input channels does not match filter ' s input channels , " <nl> " { } ! = { } " . format ( value . get_shape ( ) [ 3 ] , filter . get_shape ( <nl> def log_softmax ( logits , dim = - 1 , name = None ) : <nl> return _softmax ( logits , gen_nn_ops . _log_softmax , dim , name ) <nl> <nl> <nl> - def softmax_cross_entropy_with_logits ( logits , labels , dim = - 1 , name = None ) : <nl> + def _ensure_xent_args ( name , sentinel , labels , logits ) : <nl> + # Make sure that all arguments were passed as named arguments . <nl> + if sentinel is not None : <nl> + raise ValueError ( " Only call ` % s ` with " <nl> + " named arguments ( labels = . . . , logits = . . . , . . . ) " % name ) <nl> + if labels is None or logits is None : <nl> + raise ValueError ( " Both labels and logits must be provided . " ) <nl> + <nl> + <nl> + def softmax_cross_entropy_with_logits ( _sentinel = None , # pylint : disable = invalid - name <nl> + labels = None , logits = None , <nl> + dim = - 1 , name = None ) : <nl> " " " Computes softmax cross entropy between ` logits ` and ` labels ` . <nl> <nl> Measures the probability error in discrete classification tasks in which the <nl> def softmax_cross_entropy_with_logits ( logits , labels , dim = - 1 , name = None ) : <nl> ` logits ` and ` labels ` must have the same shape ` [ batch_size , num_classes ] ` <nl> and the same dtype ( either ` float16 ` , ` float32 ` , or ` float64 ` ) . <nl> <nl> + * * Note that to avoid confusion , it is required to pass only named arguments to <nl> + this function . * * <nl> + <nl> Args : <nl> - logits : Unscaled log probabilities . <nl> + _sentinel : Used to prevent positional parameters . Internal , do not use . <nl> labels : Each row ` labels [ i ] ` must be a valid probability distribution . <nl> + logits : Unscaled log probabilities . <nl> dim : The class dimension . Defaulted to - 1 which is the last dimension . <nl> name : A name for the operation ( optional ) . <nl> <nl> def softmax_cross_entropy_with_logits ( logits , labels , dim = - 1 , name = None ) : <nl> A 1 - D ` Tensor ` of length ` batch_size ` of the same type as ` logits ` with the <nl> softmax cross entropy loss . <nl> " " " <nl> + _ensure_xent_args ( " softmax_cross_entropy_with_logits " , _sentinel , <nl> + labels , logits ) <nl> + <nl> # TODO ( pcmurray ) Raise an error when the labels do not sum to 1 . Note : This <nl> # could break users who call this with bad labels , but disregard the bad <nl> # results . <nl> def softmax_cross_entropy_with_logits ( logits , labels , dim = - 1 , name = None ) : <nl> labels = ops . convert_to_tensor ( labels ) <nl> precise_logits = math_ops . cast ( logits , dtypes . float32 ) if ( <nl> logits . dtype = = dtypes . float16 ) else logits <nl> - # Labels and logits must be of the same type <nl> + # labels and logits must be of the same type <nl> labels = math_ops . cast ( labels , precise_logits . dtype ) <nl> input_rank = array_ops . rank ( precise_logits ) <nl> # For shape inference . <nl> def _move_dim_to_end ( tensor , dim_index , rank ) : <nl> return cost <nl> <nl> <nl> - def sparse_softmax_cross_entropy_with_logits ( logits , labels , name = None ) : <nl> + def sparse_softmax_cross_entropy_with_logits ( _sentinel = None , # pylint : disable = invalid - name <nl> + labels = None , logits = None , <nl> + name = None ) : <nl> " " " Computes sparse softmax cross entropy between ` logits ` and ` labels ` . <nl> <nl> Measures the probability error in discrete classification tasks in which the <nl> def sparse_softmax_cross_entropy_with_logits ( logits , labels , name = None ) : <nl> A common use case is to have logits of shape ` [ batch_size , num_classes ] ` and <nl> labels of shape ` [ batch_size ] ` . But higher dimensions are supported . <nl> <nl> + * * Note that to avoid confusion , it is required to pass only named arguments to <nl> + this function . * * <nl> + <nl> Args : <nl> - logits : Unscaled log probabilities of rank ` r ` and shape <nl> - ` [ d_0 , d_1 , . . . , d_ { r - 2 } , num_classes ] ` and dtype ` float32 ` or ` float64 ` . <nl> + _sentinel : Used to prevent positional parameters . Internal , do not use . <nl> labels : ` Tensor ` of shape ` [ d_0 , d_1 , . . . , d_ { r - 2 } ] ` and dtype ` int32 ` or <nl> ` int64 ` . Each entry in ` labels ` must be an index in ` [ 0 , num_classes ) ` . <nl> Other values will raise an exception when this op is run on CPU , and <nl> return ` NaN ` for corresponding corresponding loss and gradient rows <nl> on GPU . <nl> + logits : Unscaled log probabilities of rank ` r ` and shape <nl> + ` [ d_0 , d_1 , . . . , d_ { r - 2 } , num_classes ] ` and dtype ` float32 ` or ` float64 ` . <nl> name : A name for the operation ( optional ) . <nl> <nl> Returns : <nl> def sparse_softmax_cross_entropy_with_logits ( logits , labels , name = None ) : <nl> ValueError : If logits are scalars ( need to have rank > = 1 ) or if the rank <nl> of the labels is not equal to the rank of the labels minus one . <nl> " " " <nl> + _ensure_xent_args ( " sparse_softmax_cross_entropy_with_logits " , _sentinel , <nl> + labels , logits ) <nl> + <nl> # TODO ( pcmurray ) Raise an error when the label is not an index in <nl> # [ 0 , num_classes ) . Note : This could break users who call this with bad <nl> # labels , but disregard the bad results . <nl> def sparse_softmax_cross_entropy_with_logits ( logits , labels , name = None ) : <nl> if logits . get_shape ( ) . ndims is not None and ( <nl> labels_static_shape . ndims is not None and <nl> labels_static_shape . ndims ! = logits . get_shape ( ) . ndims - 1 ) : <nl> - raise ValueError ( " Rank mismatch : Rank of labels ( received % s ) should equal " <nl> - " rank of logits minus 1 ( received % s ) . " % <nl> + raise ValueError ( " Rank mismatch : Rank of labels ( received % s ) should " <nl> + " equal rank of logits minus 1 ( received % s ) . " % <nl> ( labels_static_shape . ndims , logits . get_shape ( ) . ndims ) ) <nl> # Check if no reshapes are required . <nl> if logits . get_shape ( ) . ndims = = 2 : <nl> def xw_plus_b_v1 ( x , weights , biases , name = None ) : # pylint : disable = invalid - name <nl> return bias_add_v1 ( mm , biases , name = name ) <nl> <nl> <nl> - # pylint : disable = invalid - name <nl> - def dropout ( x , keep_prob , noise_shape = None , seed = None , name = None ) : <nl> + def dropout ( x , keep_prob , noise_shape = None , seed = None , name = None ) : # pylint : disable = invalid - name <nl> " " " Computes dropout . <nl> <nl> With probability ` keep_prob ` , outputs the input element scaled up by <nl> def erosion2d ( value , kernel , strides , rates , padding , name = None ) : <nl> rates = rates , <nl> padding = padding , <nl> name = name ) ) <nl> - <nl> - # pylint : enable = invalid - name <nl> mmm a / tensorflow / python / ops / nn_xent_test . py <nl> ppp b / tensorflow / python / ops / nn_xent_test . py <nl> def testConstructionNamed ( self ) : <nl> with self . test_session ( ) : <nl> logits , targets , _ = self . _Inputs ( ) <nl> loss = nn_impl . sigmoid_cross_entropy_with_logits ( <nl> - logits , targets , name = " mylogistic " ) <nl> + labels = targets , logits = logits , name = " mylogistic " ) <nl> self . assertEqual ( " mylogistic " , loss . op . name ) <nl> <nl> def testLogisticOutput ( self ) : <nl> def testLogisticOutput ( self ) : <nl> for dtype in [ dtypes . float32 , dtypes . float16 ] : <nl> with self . test_session ( use_gpu = use_gpu ) : <nl> logits , targets , losses = self . _Inputs ( dtype = dtype ) <nl> - loss = nn_impl . sigmoid_cross_entropy_with_logits ( logits , targets ) <nl> + loss = nn_impl . sigmoid_cross_entropy_with_logits ( <nl> + labels = targets , logits = logits ) <nl> np_loss = np . array ( losses ) . astype ( np . float32 ) <nl> tf_loss = loss . eval ( ) <nl> self . assertAllClose ( np_loss , tf_loss , atol = 0 . 001 ) <nl> def testLogisticOutputMultiDim ( self ) : <nl> for dtype in [ dtypes . float32 , dtypes . float16 ] : <nl> with self . test_session ( use_gpu = use_gpu ) : <nl> logits , targets , losses = self . _Inputs ( dtype = dtype , sizes = [ 2 , 2 , 2 ] ) <nl> - loss = nn_impl . sigmoid_cross_entropy_with_logits ( logits , targets ) <nl> + loss = nn_impl . sigmoid_cross_entropy_with_logits ( <nl> + labels = targets , logits = logits ) <nl> np_loss = np . array ( losses ) . astype ( np . float32 ) <nl> tf_loss = loss . eval ( ) <nl> self . assertAllClose ( np_loss , tf_loss , atol = 0 . 001 ) <nl> def testGradient ( self ) : <nl> sizes = [ 4 , 2 ] <nl> with self . test_session ( ) : <nl> logits , targets , _ = self . _Inputs ( sizes = sizes ) <nl> - loss = nn_impl . sigmoid_cross_entropy_with_logits ( logits , targets ) <nl> + loss = nn_impl . sigmoid_cross_entropy_with_logits ( <nl> + labels = targets , logits = logits ) <nl> err = gradient_checker . compute_gradient_error ( logits , sizes , loss , sizes ) <nl> print ( " logistic loss gradient err = " , err ) <nl> self . assertLess ( err , 1e - 7 ) <nl> def testGradientAtZero ( self ) : <nl> with self . test_session ( ) : <nl> logits = constant_op . constant ( [ 0 . 0 , 0 . 0 ] , dtype = dtypes . float64 ) <nl> targets = constant_op . constant ( [ 0 . 0 , 1 . 0 ] , dtype = dtypes . float64 ) <nl> - loss = nn_impl . sigmoid_cross_entropy_with_logits ( logits , targets ) <nl> + loss = nn_impl . sigmoid_cross_entropy_with_logits ( <nl> + labels = targets , logits = logits ) <nl> grads = gradients_impl . gradients ( loss , logits ) [ 0 ] . eval ( ) <nl> self . assertAllClose ( grads , [ 0 . 5 , - 0 . 5 ] ) <nl> <nl> def testShapeError ( self ) : <nl> with self . assertRaisesRegexp ( ValueError , " must have the same shape " ) : <nl> - nn_impl . sigmoid_cross_entropy_with_logits ( [ [ 2 , 1 ] ] , [ 1 , 2 , 3 ] ) <nl> + nn_impl . sigmoid_cross_entropy_with_logits ( labels = [ 1 , 2 , 3 ] , <nl> + logits = [ [ 2 , 1 ] ] ) <nl> <nl> <nl> class WeightedCrossEntropyTest ( test . TestCase ) : <nl> def testConstructionNamed ( self ) : <nl> with self . test_session ( ) : <nl> logits , targets , pos_weight , _ = self . _Inputs ( ) <nl> loss = nn_impl . weighted_cross_entropy_with_logits ( <nl> - targets , logits , pos_weight , name = " mybce " ) <nl> + targets = targets , logits = logits , pos_weight = pos_weight , name = " mybce " ) <nl> self . assertEqual ( " mybce " , loss . op . name ) <nl> <nl> def testOutput ( self ) : <nl> for use_gpu in [ True , False ] : <nl> with self . test_session ( use_gpu = use_gpu ) : <nl> logits , targets , pos_weight , losses = self . _Inputs ( dtype = dtypes . float32 ) <nl> - loss = nn_impl . weighted_cross_entropy_with_logits ( targets , logits , <nl> - pos_weight ) <nl> + loss = nn_impl . weighted_cross_entropy_with_logits ( <nl> + targets = targets , logits = logits , pos_weight = pos_weight ) <nl> np_loss = np . array ( losses ) . astype ( np . float32 ) <nl> tf_loss = loss . eval ( ) <nl> self . assertAllClose ( np_loss , tf_loss , atol = 0 . 001 ) <nl> def testOutputMultiDim ( self ) : <nl> with self . test_session ( use_gpu = use_gpu ) : <nl> logits , targets , pos_weight , losses = self . _Inputs ( <nl> dtype = dtypes . float32 , sizes = [ 2 , 2 , 2 ] ) <nl> - loss = nn_impl . weighted_cross_entropy_with_logits ( targets , logits , <nl> - pos_weight ) <nl> + loss = nn_impl . weighted_cross_entropy_with_logits ( <nl> + targets = targets , logits = logits , pos_weight = pos_weight ) <nl> np_loss = np . array ( losses ) . astype ( np . float32 ) <nl> tf_loss = loss . eval ( ) <nl> self . assertAllClose ( np_loss , tf_loss , atol = 0 . 001 ) <nl> def testGradient ( self ) : <nl> sizes = [ 4 , 2 ] <nl> with self . test_session ( ) : <nl> logits , targets , pos_weight , _ = self . _Inputs ( sizes = sizes ) <nl> - loss = nn_impl . weighted_cross_entropy_with_logits ( targets , logits , <nl> - pos_weight ) <nl> + loss = nn_impl . weighted_cross_entropy_with_logits ( <nl> + targets = targets , logits = logits , pos_weight = pos_weight ) <nl> err = gradient_checker . compute_gradient_error ( logits , sizes , loss , sizes ) <nl> print ( " logistic loss gradient err = " , err ) <nl> self . assertLess ( err , 1e - 7 ) <nl> <nl> def testShapeError ( self ) : <nl> with self . assertRaisesRegexp ( ValueError , " must have the same shape " ) : <nl> - nn_impl . weighted_cross_entropy_with_logits ( [ 1 , 2 , 3 ] , [ [ 2 , 1 ] ] , 2 . 0 ) <nl> + nn_impl . weighted_cross_entropy_with_logits ( <nl> + targets = [ 1 , 2 , 3 ] , logits = [ [ 2 , 1 ] ] , pos_weight = 2 . 0 ) <nl> <nl> <nl> if __name__ = = " __main__ " : <nl> mmm a / tensorflow / python / training / saver_test . py <nl> ppp b / tensorflow / python / training / saver_test . py <nl> def _testGraphExtensionRestore ( self , test_dir ) : <nl> concated , array_ops . stack ( [ batch_size , 10 ] ) , 1 . 0 , 0 . 0 ) <nl> logits = ops_lib . get_collection ( " logits " ) [ 0 ] <nl> cross_entropy = nn_ops . softmax_cross_entropy_with_logits ( <nl> - logits , onehot_labels , name = " xentropy " ) <nl> + labels = onehot_labels , logits = logits , name = " xentropy " ) <nl> loss = math_ops . reduce_mean ( cross_entropy , name = " xentropy_mean " ) <nl> <nl> summary . scalar ( " loss " , loss ) <nl> def testImportIntoNamescope ( self ) : <nl> bias = variables . Variable ( array_ops . zeros ( [ 10 ] ) , name = " bias " ) <nl> logit = nn_ops . relu ( math_ops . matmul ( image , weights ) + bias , name = " logits " ) <nl> nn_ops . softmax ( logit , name = " prediction " ) <nl> - cost = nn_ops . softmax_cross_entropy_with_logits ( logit , label , name = " cost " ) <nl> + cost = nn_ops . softmax_cross_entropy_with_logits ( labels = label , <nl> + logits = logit , name = " cost " ) <nl> adam . AdamOptimizer ( ) . minimize ( cost , name = " optimize " ) <nl> saver = saver_module . Saver ( ) <nl> sess . run ( variables . global_variables_initializer ( ) ) <nl> def testClearDevicesOnImport ( self ) : <nl> bias = variables . Variable ( array_ops . zeros ( [ 10 ] ) , name = " bias " ) <nl> logit = nn_ops . relu ( math_ops . matmul ( image , weights ) + bias ) <nl> nn_ops . softmax ( logit , name = " prediction " ) <nl> - cost = nn_ops . softmax_cross_entropy_with_logits ( logit , label ) <nl> + cost = nn_ops . softmax_cross_entropy_with_logits ( labels = label , <nl> + logits = logit ) <nl> adam . AdamOptimizer ( ) . minimize ( cost , name = " optimize " ) <nl> meta_graph_def = saver_module . export_meta_graph ( ) <nl> <nl> def testClearDevicesOnExport ( self ) : <nl> bias = variables . Variable ( array_ops . zeros ( [ 10 ] ) , name = " bias " ) <nl> logit = nn_ops . relu ( math_ops . matmul ( image , weights ) + bias ) <nl> nn_ops . softmax ( logit , name = " prediction " ) <nl> - cost = nn_ops . softmax_cross_entropy_with_logits ( logit , label ) <nl> + cost = nn_ops . softmax_cross_entropy_with_logits ( labels = label , <nl> + logits = logit ) <nl> adam . AdamOptimizer ( ) . minimize ( cost , name = " optimize " ) <nl> meta_graph_def = saver_module . export_meta_graph ( clear_devices = True ) <nl> graph_io . write_graph ( meta_graph_def , " / tmp " , " meta_graph . pbtxt " ) <nl> mmm a / tensorflow / tools / docker / notebooks / 3_mnist_from_scratch . ipynb <nl> ppp b / tensorflow / tools / docker / notebooks / 3_mnist_from_scratch . ipynb <nl> <nl> " # Training computation : logits + cross - entropy loss . \ n " , <nl> " logits = model ( train_data_node , True ) \ n " , <nl> " loss = tf . reduce_mean ( tf . nn . softmax_cross_entropy_with_logits ( \ n " , <nl> - " logits , train_labels_node ) ) \ n " , <nl> + " labels = train_labels_node , logits = logits ) ) \ n " , <nl> " \ n " , <nl> " # L2 regularization for the fully connected parameters . \ n " , <nl> " regularizers = ( tf . nn . l2_loss ( fc1_weights ) + tf . nn . l2_loss ( fc1_biases ) + \ n " , <nl>
Change arg order for { softmax , sparse_softmax , sigmoid } _cross_entropy_with_logits to be ( labels , predictions ) , and force use of named args to avoid accidents .
tensorflow/tensorflow
333dc32ff79af21484695157f3d141dc776f7c02
2017-01-05T05:46:08Z
mmm a / modules / imgcodecs / src / grfmt_tiff . cpp <nl> ppp b / modules / imgcodecs / src / grfmt_tiff . cpp <nl> bool TiffDecoder : : readHeader ( ) <nl> & TiffDecoderBufHelper : : write , & TiffDecoderBufHelper : : seek , <nl> & TiffDecoderBufHelper : : close , & TiffDecoderBufHelper : : size , <nl> & TiffDecoderBufHelper : : map , / * unmap = * / 0 ) ; <nl> + if ( ! tif ) <nl> + delete buf_helper ; <nl> } <nl> else <nl> { <nl>
imgcodecs ( tiff ) : avoid leak of helper struct on malformed inputs
opencv/opencv
2ece029fe03d0507b4b86d665a937573771cc121
2019-04-01T14:08:40Z
mmm a / data / lm / README . rst <nl> ppp b / data / lm / README . rst <nl> <nl> + | Generate vocab - 500000 . txt and lm . binary files <nl> + | Add ' - - download_librispeech ' to download the librispeech text corpus ( will be downloaded to ' - - input_txt ' ) <nl> + | Optional change the path of the kenlm binaries with ' - - kenlm_bins path / to / bins / ' <nl> + | Optional change the number of most frequent words with ' - - top_k 300000 ' <nl> <nl> - The LM binary was generated from the LibriSpeech normalized LM training text , available ` here < http : / / www . openslr . org / 11 > ` _ \ , using the ` generate_lm . py ` script ( will generate ` lm . binary ` and ` librispeech - vocab - 500k . txt ` in the folder it is run from ) . ` KenLM < https : / / github . com / kpu / kenlm > ` _ ' s built binaries must be in your PATH ( lmplz , build_binary , filter ) . <nl> <nl> - The scorer package was then built using the ` generate_package . py ` script : <nl> + . . code - block : : bash <nl> + <nl> + python3 data / lm / generate_lm . py - - input_txt path / to / vocab_sentences . txt - - output_dir path / lm / <nl> + <nl> + <nl> + | Generate scorer package with the above vocab - 500000 . txt and lm . binary files <nl> <nl> . . code - block : : bash <nl> - python generate_lm . py # this will create lm . binary and librispeech - vocab - 500k . txt <nl> + <nl> python generate_package . py - - alphabet . . / alphabet . txt - - lm lm . binary - - vocab librispeech - vocab - 500k . txt - - default_alpha 0 . 75 - - default_beta 1 . 85 - - package kenlm . scorer <nl> mmm a / data / lm / generate_lm . py <nl> ppp b / data / lm / generate_lm . py <nl> <nl> + import argparse <nl> import gzip <nl> import io <nl> import os <nl> import subprocess <nl> - import tempfile <nl> - <nl> from collections import Counter <nl> from urllib import request <nl> <nl> - def main ( ) : <nl> - # Grab corpus . <nl> - url = ' http : / / www . openslr . org / resources / 11 / librispeech - lm - norm . txt . gz ' <nl> + import tqdm <nl> + <nl> <nl> - with tempfile . TemporaryDirectory ( ) as tmp : <nl> - data_upper = os . path . join ( tmp , ' upper . txt . gz ' ) <nl> - print ( ' Downloading { } into { } . . . ' . format ( url , data_upper ) ) <nl> - request . urlretrieve ( url , data_upper ) <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + def convert_and_filter_topk ( args ) : <nl> + " " " Convert to lowercase , count word occurrences and save top - k words to a file " " " <nl> <nl> - # Convert to lowercase and count word occurences . <nl> counter = Counter ( ) <nl> - data_lower = os . path . join ( tmp , ' lower . txt . gz ' ) <nl> - print ( ' Converting to lower case and counting word frequencies . . . ' ) <nl> - with io . TextIOWrapper ( io . BufferedWriter ( gzip . open ( data_lower , ' w ' ) ) , encoding = ' utf - 8 ' ) as lower : <nl> - with io . TextIOWrapper ( io . BufferedReader ( gzip . open ( data_upper ) ) , encoding = ' utf8 ' ) as upper : <nl> - for line in upper : <nl> - line_lower = line . lower ( ) <nl> - counter . update ( line_lower . split ( ) ) <nl> - lower . write ( line_lower ) <nl> - <nl> - # Build pruned LM . <nl> - lm_path = os . path . join ( tmp , ' lm . arpa ' ) <nl> - print ( ' Creating ARPA file . . . ' ) <nl> + data_lower = os . path . join ( args . output_dir , ' lower . txt . gz ' ) <nl> + <nl> + print ( ' \ nConverting to lowercase and counting word occurrences . . . ' ) <nl> + with io . TextIOWrapper ( io . BufferedWriter ( gzip . open ( data_lower , ' w + ' ) ) , encoding = ' utf - 8 ' ) as lower : <nl> + with open ( args . input_txt , encoding = ' utf8 ' ) as upper : <nl> + for line in tqdm . tqdm ( upper ) : <nl> + line_lower = line . lower ( ) <nl> + counter . update ( line_lower . split ( ) ) <nl> + lower . write ( line_lower ) <nl> + <nl> + # Save top - k words <nl> + print ( ' \ nSaving top { } words ' . format ( args . top_k ) ) <nl> + vocab_str = ' \ n ' . join ( word for word , count in counter . most_common ( args . top_k ) ) <nl> + vocab_path = ' vocab - { } . txt ' . format ( args . top_k ) <nl> + vocab_path = os . path . join ( args . output_dir , vocab_path ) <nl> + with open ( vocab_path , ' w + ' ) as file : <nl> + file . write ( vocab_str ) <nl> + <nl> + return data_lower , vocab_str <nl> + <nl> + <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + def build_lm ( args , data_lower , vocab_str ) : <nl> + print ( ' \ nCreating ARPA file . . . ' ) <nl> + lm_path = os . path . join ( args . output_dir , ' lm . arpa ' ) <nl> subprocess . check_call ( [ <nl> - ' lmplz ' , ' - - order ' , ' 5 ' , <nl> - ' - - temp_prefix ' , tmp , <nl> - ' - - memory ' , ' 50 % ' , <nl> - ' - - text ' , data_lower , <nl> - ' - - arpa ' , lm_path , <nl> - ' - - prune ' , ' 0 ' , ' 0 ' , ' 1 ' <nl> + args . kenlm_bins + ' lmplz ' , ' - - order ' , ' 5 ' , <nl> + ' - - temp_prefix ' , args . output_dir , <nl> + ' - - memory ' , ' 75 % ' , <nl> + ' - - text ' , data_lower , <nl> + ' - - arpa ' , lm_path , <nl> + ' - - prune ' , ' 0 ' , ' 0 ' , ' 1 ' <nl> ] ) <nl> <nl> - vocab_str = ' \ n ' . join ( word for word , count in counter . most_common ( 500000 ) ) <nl> - with open ( ' librispeech - vocab - 500k . txt ' , ' w ' ) as fout : <nl> - fout . write ( vocab_str ) <nl> - <nl> # Filter LM using vocabulary of top 500k words <nl> - print ( ' Filtering ARPA file . . . ' ) <nl> - filtered_path = os . path . join ( tmp , ' lm_filtered . arpa ' ) <nl> - subprocess . run ( [ ' filter ' , ' single ' , ' model : { } ' . format ( lm_path ) , filtered_path ] , input = vocab_str . encode ( ' utf - 8 ' ) , check = True ) <nl> + print ( ' \ nFiltering ARPA file using vocabulary of top - k words . . . ' ) <nl> + filtered_path = os . path . join ( args . output_dir , ' lm_filtered . arpa ' ) <nl> + subprocess . run ( [ args . kenlm_bins + ' filter ' , ' single ' , ' model : { } ' . format ( lm_path ) , filtered_path ] , <nl> + input = vocab_str . encode ( ' utf - 8 ' ) , <nl> + check = True ) <nl> <nl> # Quantize and produce trie binary . <nl> - print ( ' Building lm . binary . . . ' ) <nl> + print ( ' \ nBuilding lm . binary . . . ' ) <nl> + binary_path = os . path . join ( args . output_dir , ' lm . binary ' ) <nl> subprocess . check_call ( [ <nl> - ' build_binary ' , ' - a ' , ' 255 ' , <nl> - ' - q ' , ' 8 ' , <nl> - ' - v ' , <nl> - ' trie ' , <nl> - filtered_path , <nl> - ' lm . binary ' <nl> + args . kenlm_bins + ' build_binary ' , ' - a ' , ' 255 ' , <nl> + ' - q ' , ' 8 ' , <nl> + ' - v ' , <nl> + ' trie ' , <nl> + filtered_path , <nl> + binary_path <nl> ] ) <nl> <nl> + <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + def main ( ) : <nl> + parser = argparse . ArgumentParser ( <nl> + description = ' Generate an lm . binary and top - k vocab for DeepSpeech . ' <nl> + ) <nl> + parser . add_argument ( <nl> + ' - - input_txt ' , <nl> + help = ' File path to a . txt with sample sentences ' , <nl> + type = str , <nl> + required = True <nl> + ) <nl> + parser . add_argument ( <nl> + ' - - output_dir ' , <nl> + help = ' Directory path for the output ' , <nl> + type = str , <nl> + required = True <nl> + ) <nl> + parser . add_argument ( <nl> + ' - - top_k ' , <nl> + help = ' Use top_k most frequent words for the vocab . txt file ' , <nl> + type = int , <nl> + default = 500000 <nl> + ) <nl> + parser . add_argument ( <nl> + ' - - download_librispeech ' , <nl> + action = ' store_true ' <nl> + ) <nl> + parser . add_argument ( <nl> + ' - - kenlm_bins ' , <nl> + help = ' File path to the kenlm binaries lmplz , filter and build_binary ' , <nl> + type = str , <nl> + default = ' / DeepSpeech / native_client / kenlm / build / bin / ' <nl> + ) <nl> + args = parser . parse_args ( ) <nl> + <nl> + if args . download_librispeech : <nl> + # Grab corpus <nl> + url = ' http : / / www . openslr . org / resources / 11 / librispeech - lm - norm . txt . gz ' <nl> + print ( ' Downloading { } into { } . . . ' . format ( url , args . input_txt + ' . gz ' ) ) <nl> + request . urlretrieve ( url , args . input_txt + ' . gz ' ) <nl> + print ( ' Unzipping . . . ' ) <nl> + subprocess . check_call ( [ ' gunzip ' , args . input_txt + ' . gz ' ] ) <nl> + <nl> + data_lower , vocab_str = convert_and_filter_topk ( args ) <nl> + build_lm ( args , data_lower , vocab_str ) <nl> + <nl> + # Delete intermediate files <nl> + if args . download_librispeech : <nl> + os . remove ( args . input_txt ) <nl> + os . remove ( os . path . join ( args . output_dir , ' lower . txt . gz ' ) ) <nl> + os . remove ( os . path . join ( args . output_dir , ' lm . arpa ' ) ) <nl> + os . remove ( os . path . join ( args . output_dir , ' lm_filtered . arpa ' ) ) <nl> + <nl> + <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> if __name__ = = ' __main__ ' : <nl> - main ( ) <nl> + main ( ) <nl>
Rewrite generate_lm . py to allow usage with other languages .
mozilla/DeepSpeech
15a75c77ff125ed466b3df06b9a99aa3819ded89
2020-02-27T16:18:19Z
mmm a / Examples / SequenceToSequence / CMUDict / Python / Sequence2Sequence . py <nl> ppp b / Examples / SequenceToSequence / CMUDict / Python / Sequence2Sequence . py <nl> <nl> use_attention = False # True - - BUGBUG ( layers ) : not working for now due to has_aux <nl> use_embedding = True <nl> embedding_dim = 200 <nl> - vocab = enumerate ( [ w . strip ( ) for w in open ( os . path . join ( DATA_DIR , VOCAB_FILE ) ) . readlines ( ) ] ) <nl> + vocab = ( [ w . strip ( ) for w in open ( os . path . join ( DATA_DIR , VOCAB_FILE ) ) . readlines ( ) ] ) <nl> length_increase = 1 . 5 <nl> <nl> + # sentence - start symbol as a constant <nl> + sentence_start = Constant ( np . array ( [ w = = ' < s > ' for w in vocab ] , dtype = np . float32 ) ) <nl> + sentence_end_index = vocab . index ( ' < / s > ' ) <nl> + # TODO : move these where they belong <nl> + <nl> # # # # # # # # # # # # # # # # # # # # # # # # <nl> # define the reader # <nl> # # # # # # # # # # # # # # # # # # # # # # # # <nl> def create_model ( ) : <nl> # Right now assumes shared embedding and shared vocab size . <nl> embed = Embedding ( embedding_dim ) if use_embedding else identity <nl> <nl> - # sentence - start symbol as a constant <nl> - sentence_start = Constant ( np . array ( [ w = = ' < s > ' for w in vocab ] , dtype = np . float32 ) ) <nl> - sentence_end_index = vocab . index ( ' < / s > ' ) <nl> - <nl> # Encoder : ( embedded_input * ) - - > ( h0 , c0 ) <nl> # Create multiple layers of LSTMs by passing the output of the i - th layer <nl> # to the ( i + 1 ) th layer as its input <nl> def create_model ( ) : <nl> def decoder ( history , input ) : <nl> encoder_output = encoder ( input ) <nl> r = history <nl> + r = embed ( r ) <nl> r = Stabilizer ( ) ( r ) <nl> for i in range ( num_layers ) : <nl> r = RecurrenceFrom ( LSTM ( hidden_dim ) ) ( r , * encoder_output . outputs ) # : : r , h0 , c0 - > h <nl> def decoder ( history , input ) : <nl> r = Dense ( label_vocab_dim ) ( r ) <nl> return r <nl> <nl> + return decoder <nl> + <nl> + def old_code ( ) : <nl> + # OLD CODE which I may still need later : <nl> + # Parameters to the decoder stack depend on the model type ( use attention or not ) <nl> + if use_attention : <nl> + label_embedded = embed ( label_sequence ) <nl> + augment_input_hook = create_attention_augment_hook ( attention_dim , attention_span , <nl> + label_embedded , encoder_output_h ) <nl> + recurrence_hook_h = past_value <nl> + recurrence_hook_c = past_value <nl> + decoder_output_h , _ = LSTM_stack ( decoder_input , num_layers , hidden_dim , recurrence_hook_h , recurrence_hook_c , augment_input_hook ) <nl> + else : <nl> + if False : <nl> + # William ' s original <nl> + thought_vector_h , thought_vector_c = encoder_output . outputs <nl> + # Here we broadcast the single - time - step thought vector along the dynamic axis of the decoder <nl> + label_embedded = embed ( label_sequence ) <nl> + thought_vector_broadcast_h = broadcast_as ( thought_vector_h , label_embedded ) <nl> + thought_vector_broadcast_c = broadcast_as ( thought_vector_c , label_embedded ) <nl> + augment_input_hook = None <nl> + is_first_label = sequence . is_first ( label_sequence ) # 1 0 0 0 . . . <nl> + def recurrence_hook_h ( operand ) : <nl> + return element_select ( is_first_label , thought_vector_broadcast_h , past_value ( operand ) ) <nl> + def recurrence_hook_c ( operand ) : <nl> + return element_select ( is_first_label , thought_vector_broadcast_c , past_value ( operand ) ) <nl> + decoder_output_h , _ = LSTM_stack ( decoder_input , num_layers , hidden_dim , recurrence_hook_h , recurrence_hook_c , augment_input_hook ) <nl> + z = Dense ( label_vocab_dim ) ( Stabilizer ( ) ( decoder_output_h ) ) <nl> + else : <nl> + z = decoder ( decoder_input , * encoder_output . outputs ) <nl> + <nl> + return z <nl> + <nl> + # # # # # # # # # # # # # # # # # # # # # # # # <nl> + # train action # <nl> + # # # # # # # # # # # # # # # # # # # # # # # # <nl> + <nl> + def train ( train_reader , valid_reader , vocab , i2w , decoder , max_epochs , epoch_size ) : <nl> + <nl> + from cntk . blocks import Constant , Type <nl> + <nl> # note : the labels must not contain the initial < s > <nl> @ Function <nl> def model_train ( input , labels ) : # ( input , labels ) - - > ( word_sequence ) <nl> <nl> # The input to the decoder always starts with the special label sequence start token . <nl> # Then , use the previous value of the label sequence ( for training ) or the output ( for execution ) . <nl> - decoder_input = delayed_value ( embed ( labels ) , initial_state = embed ( sentence_start ) ) <nl> + decoder_input = delayed_value ( labels , initial_state = sentence_start ) <nl> z = decoder ( decoder_input , input ) <nl> return z <nl> + model = model_train <nl> <nl> @ Function <nl> # def model_greedy ( input , raw_labels ) : # ( input_sequence , decoder_history_sequence ) - - > ( word_sequence ) <nl> def unfold_from ( input , dynamic_axes_like ) : <nl> input1 = Placeholder ( name = ' input1 ' ) <nl> <nl> history_fwd = Placeholder ( name = ' hook ' ) <nl> - prev_history = delayed_value ( embed ( history_fwd ) , initial_state = initial_state , dynamic_axes_like = out_axis ) <nl> + prev_history = delayed_value ( history_fwd , initial_state = initial_state , dynamic_axes_like = out_axis ) <nl> z = over ( prev_history , input1 ) <nl> z . replace_placeholders ( { history_fwd : hardmax ( z ) . output } ) <nl> <nl> def unfold_from ( input , dynamic_axes_like ) : <nl> # z . dump_signature ( ' z ' ) <nl> return z <nl> return unfold_from <nl> - z = UnfoldFrom ( decoder , length_increase = length_increase , initial_state = embed ( sentence_start ) ) ( input , dynamic_axes_like = input ) <nl> + z = UnfoldFrom ( decoder , length_increase = length_increase , initial_state = sentence_start ) ( input , dynamic_axes_like = input ) <nl> <nl> # add another loop to cut at < s / > <nl> # TODO : change to Python slicing syntax <nl> def unfold_from ( input , dynamic_axes_like ) : <nl> <nl> return z <nl> <nl> - return ( model_train , model_greedy ) <nl> - <nl> - def old_code ( ) : <nl> - # OLD CODE which I may still need later : <nl> - # Parameters to the decoder stack depend on the model type ( use attention or not ) <nl> - if use_attention : <nl> - label_embedded = embed ( label_sequence ) <nl> - augment_input_hook = create_attention_augment_hook ( attention_dim , attention_span , <nl> - label_embedded , encoder_output_h ) <nl> - recurrence_hook_h = past_value <nl> - recurrence_hook_c = past_value <nl> - decoder_output_h , _ = LSTM_stack ( decoder_input , num_layers , hidden_dim , recurrence_hook_h , recurrence_hook_c , augment_input_hook ) <nl> - else : <nl> - if False : <nl> - # William ' s original <nl> - thought_vector_h , thought_vector_c = encoder_output . outputs <nl> - # Here we broadcast the single - time - step thought vector along the dynamic axis of the decoder <nl> - label_embedded = embed ( label_sequence ) <nl> - thought_vector_broadcast_h = broadcast_as ( thought_vector_h , label_embedded ) <nl> - thought_vector_broadcast_c = broadcast_as ( thought_vector_c , label_embedded ) <nl> - augment_input_hook = None <nl> - is_first_label = sequence . is_first ( label_sequence ) # 1 0 0 0 . . . <nl> - def recurrence_hook_h ( operand ) : <nl> - return element_select ( is_first_label , thought_vector_broadcast_h , past_value ( operand ) ) <nl> - def recurrence_hook_c ( operand ) : <nl> - return element_select ( is_first_label , thought_vector_broadcast_c , past_value ( operand ) ) <nl> - decoder_output_h , _ = LSTM_stack ( decoder_input , num_layers , hidden_dim , recurrence_hook_h , recurrence_hook_c , augment_input_hook ) <nl> - z = Dense ( label_vocab_dim ) ( Stabilizer ( ) ( decoder_output_h ) ) <nl> - else : <nl> - z = decoder ( decoder_input , * encoder_output . outputs ) <nl> - <nl> - return z <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # train action # <nl> - # # # # # # # # # # # # # # # # # # # # # # # # <nl> - <nl> - def train ( train_reader , valid_reader , vocab , i2w , model , model_greedy , max_epochs , epoch_size ) : <nl> - <nl> - from cntk . blocks import Constant , Type <nl> - <nl> # decoder_history_hook = find_by_name ( model , ' decoder_history_hook ' ) <nl> # # network output for decoder history <nl> # net_output = hardmax ( model ) <nl> def debug_attention ( model , mb , reader ) : <nl> <nl> # create inputs and create model <nl> # inputs = create_inputs ( ) <nl> - model_train , model_greedy = create_model ( ) <nl> + model = create_model ( ) <nl> <nl> # train <nl> # try : <nl> - train ( train_reader , valid_reader , vocab , i2w , model_train , model_greedy , max_epochs = 10 , epoch_size = 908241 ) <nl> + train ( train_reader , valid_reader , vocab , i2w , model , max_epochs = 10 , epoch_size = 908241 ) <nl> # except : <nl> # x = input ( " hit enter " ) <nl> <nl>
moved final trainer / decoder model into train ( ) function ( will separate it out further )
microsoft/CNTK
14b48a6ee0d51c73191523331759cbe5ea33edd3
2017-01-16T19:48:49Z
mmm a / BUILD <nl> ppp b / BUILD <nl> grpc_cc_library ( <nl> name = " grpc_resolver_dns_ares " , <nl> srcs = [ <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc " , <nl> - " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc " , <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc " , <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc " , <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc " , <nl> mmm a / BUILD . gn <nl> ppp b / BUILD . gn <nl> config ( " grpc_config " ) { <nl> " src / core / ext / filters / client_channel / resolver . cc " , <nl> " src / core / ext / filters / client_channel / resolver . h " , <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc " , <nl> - " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc " , <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h " , <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc " , <nl> " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc " , <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> add_library ( grpc <nl> src / core / ext / filters / client_channel / proxy_mapper_registry . cc <nl> src / core / ext / filters / client_channel / resolver . cc <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc <nl> add_library ( grpc_unsecure <nl> src / core / ext / filters / client_channel / proxy_mapper_registry . cc <nl> src / core / ext / filters / client_channel / resolver . cc <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> LIBGRPC_SRC = \ <nl> src / core / ext / filters / client_channel / proxy_mapper_registry . cc \ <nl> src / core / ext / filters / client_channel / resolver . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc \ <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc \ <nl> LIBGRPC_UNSECURE_SRC = \ <nl> src / core / ext / filters / client_channel / proxy_mapper_registry . cc \ <nl> src / core / ext / filters / client_channel / resolver . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc \ <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc \ <nl> mmm a / build_autogenerated . yaml <nl> ppp b / build_autogenerated . yaml <nl> libs : <nl> - src / core / ext / filters / client_channel / proxy_mapper_registry . cc <nl> - src / core / ext / filters / client_channel / resolver . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc <nl> - - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc <nl> libs : <nl> - src / core / ext / filters / client_channel / proxy_mapper_registry . cc <nl> - src / core / ext / filters / client_channel / resolver . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc <nl> - - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc <nl> mmm a / config . m4 <nl> ppp b / config . m4 <nl> if test " $ PHP_GRPC " ! = " no " ; then <nl> src / core / ext / filters / client_channel / proxy_mapper_registry . cc \ <nl> src / core / ext / filters / client_channel / resolver . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc \ <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc \ <nl> mmm a / config . w32 <nl> ppp b / config . w32 <nl> if ( PHP_GRPC ! = " no " ) { <nl> " src \ \ core \ \ ext \ \ filters \ \ client_channel \ \ proxy_mapper_registry . cc " + <nl> " src \ \ core \ \ ext \ \ filters \ \ client_channel \ \ resolver . cc " + <nl> " src \ \ core \ \ ext \ \ filters \ \ client_channel \ \ resolver \ \ dns \ \ c_ares \ \ dns_resolver_ares . cc " + <nl> - " src \ \ core \ \ ext \ \ filters \ \ client_channel \ \ resolver \ \ dns \ \ c_ares \ \ grpc_ares_ev_driver . cc " + <nl> " src \ \ core \ \ ext \ \ filters \ \ client_channel \ \ resolver \ \ dns \ \ c_ares \ \ grpc_ares_ev_driver_libuv . cc " + <nl> " src \ \ core \ \ ext \ \ filters \ \ client_channel \ \ resolver \ \ dns \ \ c_ares \ \ grpc_ares_ev_driver_posix . cc " + <nl> " src \ \ core \ \ ext \ \ filters \ \ client_channel \ \ resolver \ \ dns \ \ c_ares \ \ grpc_ares_ev_driver_windows . cc " + <nl> mmm a / gRPC - Core . podspec <nl> ppp b / gRPC - Core . podspec <nl> Pod : : Spec . new do | s | <nl> ' src / core / ext / filters / client_channel / resolver . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver . h ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc ' , <nl> - ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc ' , <nl> mmm a / grpc . gemspec <nl> ppp b / grpc . gemspec <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / ext / filters / client_channel / resolver . cc ) <nl> s . files + = % w ( src / core / ext / filters / client_channel / resolver . h ) <nl> s . files + = % w ( src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc ) <nl> - s . files + = % w ( src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc ) <nl> s . files + = % w ( src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h ) <nl> s . files + = % w ( src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc ) <nl> s . files + = % w ( src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc ) <nl> mmm a / grpc . gyp <nl> ppp b / grpc . gyp <nl> <nl> ' src / core / ext / filters / client_channel / proxy_mapper_registry . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc ' , <nl> - ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc ' , <nl> <nl> ' src / core / ext / filters / client_channel / proxy_mapper_registry . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc ' , <nl> - ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc ' , <nl> mmm a / package . xml <nl> ppp b / package . xml <nl> <nl> < file baseinstalldir = " / " name = " src / core / ext / filters / client_channel / resolver . cc " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / filters / client_channel / resolver . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc " role = " src " / > <nl> - < file baseinstalldir = " / " name = " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc " role = " src " / > <nl> < file baseinstalldir = " / " name = " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc " role = " src " / > <nl> deleted file mode 100644 <nl> index 905ceef7256 . . 00000000000 <nl> mmm a / src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc <nl> ppp / dev / null <nl> <nl> - / * <nl> - * <nl> - * Copyright 2016 gRPC authors . <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 < grpc / support / port_platform . h > <nl> - <nl> - # include " src / core / lib / iomgr / port . h " <nl> - # if GRPC_ARES = = 1 <nl> - <nl> - # include < ares . h > <nl> - # include < string . h > <nl> - <nl> - # include " absl / strings / str_cat . h " <nl> - <nl> - # include " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h " <nl> - <nl> - # include < grpc / support / alloc . h > <nl> - # include < grpc / support / log . h > <nl> - # include < grpc / support / string_util . h > <nl> - # include < grpc / support / time . h > <nl> - # include " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_wrapper . h " <nl> - # include " src / core / lib / gpr / string . h " <nl> - # include " src / core / lib / iomgr / iomgr_internal . h " <nl> - # include " src / core / lib / iomgr / sockaddr_utils . h " <nl> - # include " src / core / lib / iomgr / timer . h " <nl> - <nl> - typedef struct fd_node { <nl> - / * * the owner of this fd node * / <nl> - grpc_ares_ev_driver * ev_driver ; <nl> - / * * a closure wrapping on_readable_locked , which should be <nl> - invoked when the grpc_fd in this node becomes readable . * / <nl> - grpc_closure read_closure ; <nl> - / * * a closure wrapping on_writable_locked , which should be <nl> - invoked when the grpc_fd in this node becomes writable . * / <nl> - grpc_closure write_closure ; <nl> - / * * next fd node in the list * / <nl> - struct fd_node * next ; <nl> - <nl> - / * * wrapped fd that ' s polled by grpc ' s poller for the current platform * / <nl> - grpc_core : : GrpcPolledFd * grpc_polled_fd ; <nl> - / * * if the readable closure has been registered * / <nl> - bool readable_registered ; <nl> - / * * if the writable closure has been registered * / <nl> - bool writable_registered ; <nl> - / * * if the fd has been shutdown yet from grpc iomgr perspective * / <nl> - bool already_shutdown ; <nl> - } fd_node ; <nl> - <nl> - struct grpc_ares_ev_driver { <nl> - / * * the ares_channel owned by this event driver * / <nl> - ares_channel channel ; <nl> - / * * pollset set for driving the IO events of the channel * / <nl> - grpc_pollset_set * pollset_set ; <nl> - / * * refcount of the event driver * / <nl> - gpr_refcount refs ; <nl> - <nl> - / * * work_serializer to synchronize c - ares and I / O callbacks on * / <nl> - std : : shared_ptr < grpc_core : : WorkSerializer > work_serializer ; <nl> - / * * a list of grpc_fd that this event driver is currently using . * / <nl> - fd_node * fds ; <nl> - / * * is this event driver currently working ? * / <nl> - bool working ; <nl> - / * * is this event driver being shut down * / <nl> - bool shutting_down ; <nl> - / * * request object that ' s using this ev driver * / <nl> - grpc_ares_request * request ; <nl> - / * * Owned by the ev_driver . Creates new GrpcPolledFd ' s * / <nl> - std : : unique_ptr < grpc_core : : GrpcPolledFdFactory > polled_fd_factory ; <nl> - / * * query timeout in milliseconds * / <nl> - int query_timeout_ms ; <nl> - / * * alarm to cancel active queries * / <nl> - grpc_timer query_timeout ; <nl> - / * * cancels queries on a timeout * / <nl> - grpc_closure on_timeout_locked ; <nl> - / * * alarm to poll ares_process on in case fd events don ' t happen * / <nl> - grpc_timer ares_backup_poll_alarm ; <nl> - / * * polls ares_process on a periodic timer * / <nl> - grpc_closure on_ares_backup_poll_alarm_locked ; <nl> - } ; <nl> - <nl> - static void grpc_ares_notify_on_event_locked ( grpc_ares_ev_driver * ev_driver ) ; <nl> - <nl> - static grpc_ares_ev_driver * grpc_ares_ev_driver_ref ( <nl> - grpc_ares_ev_driver * ev_driver ) { <nl> - GRPC_CARES_TRACE_LOG ( " request : % p Ref ev_driver % p " , ev_driver - > request , <nl> - ev_driver ) ; <nl> - gpr_ref ( & ev_driver - > refs ) ; <nl> - return ev_driver ; <nl> - } <nl> - <nl> - static void grpc_ares_ev_driver_unref ( grpc_ares_ev_driver * ev_driver ) { <nl> - GRPC_CARES_TRACE_LOG ( " request : % p Unref ev_driver % p " , ev_driver - > request , <nl> - ev_driver ) ; <nl> - if ( gpr_unref ( & ev_driver - > refs ) ) { <nl> - GRPC_CARES_TRACE_LOG ( " request : % p destroy ev_driver % p " , ev_driver - > request , <nl> - ev_driver ) ; <nl> - GPR_ASSERT ( ev_driver - > fds = = nullptr ) ; <nl> - ares_destroy ( ev_driver - > channel ) ; <nl> - grpc_ares_complete_request_locked ( ev_driver - > request ) ; <nl> - delete ev_driver ; <nl> - } <nl> - } <nl> - <nl> - static void fd_node_destroy_locked ( fd_node * fdn ) { <nl> - GRPC_CARES_TRACE_LOG ( " request : % p delete fd : % s " , fdn - > ev_driver - > request , <nl> - fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> - GPR_ASSERT ( ! fdn - > readable_registered ) ; <nl> - GPR_ASSERT ( ! fdn - > writable_registered ) ; <nl> - GPR_ASSERT ( fdn - > already_shutdown ) ; <nl> - delete fdn - > grpc_polled_fd ; <nl> - gpr_free ( fdn ) ; <nl> - } <nl> - <nl> - static void fd_node_shutdown_locked ( fd_node * fdn , const char * reason ) { <nl> - if ( ! fdn - > already_shutdown ) { <nl> - fdn - > already_shutdown = true ; <nl> - fdn - > grpc_polled_fd - > ShutdownLocked ( <nl> - GRPC_ERROR_CREATE_FROM_STATIC_STRING ( reason ) ) ; <nl> - } <nl> - } <nl> - <nl> - static void on_timeout ( void * arg , grpc_error * error ) ; <nl> - static void on_timeout_locked ( grpc_ares_ev_driver * driver , grpc_error * error ) ; <nl> - <nl> - static void on_ares_backup_poll_alarm ( void * arg , grpc_error * error ) ; <nl> - static void on_ares_backup_poll_alarm_locked ( grpc_ares_ev_driver * driver , <nl> - grpc_error * error ) ; <nl> - <nl> - static void noop_inject_channel_config ( ares_channel / * channel * / ) { } <nl> - <nl> - void ( * grpc_ares_test_only_inject_config ) ( ares_channel channel ) = <nl> - noop_inject_channel_config ; <nl> - <nl> - grpc_error * grpc_ares_ev_driver_create_locked ( <nl> - grpc_ares_ev_driver * * ev_driver , grpc_pollset_set * pollset_set , <nl> - int query_timeout_ms , <nl> - std : : shared_ptr < grpc_core : : WorkSerializer > work_serializer , <nl> - grpc_ares_request * request ) { <nl> - * ev_driver = new grpc_ares_ev_driver ( ) ; <nl> - ares_options opts ; <nl> - memset ( & opts , 0 , sizeof ( opts ) ) ; <nl> - opts . flags | = ARES_FLAG_STAYOPEN ; <nl> - int status = ares_init_options ( & ( * ev_driver ) - > channel , & opts , ARES_OPT_FLAGS ) ; <nl> - grpc_ares_test_only_inject_config ( ( * ev_driver ) - > channel ) ; <nl> - GRPC_CARES_TRACE_LOG ( " request : % p grpc_ares_ev_driver_create_locked " , request ) ; <nl> - if ( status ! = ARES_SUCCESS ) { <nl> - grpc_error * err = GRPC_ERROR_CREATE_FROM_COPIED_STRING ( <nl> - absl : : StrCat ( " Failed to init ares channel . C - ares error : " , <nl> - ares_strerror ( status ) ) <nl> - . c_str ( ) ) ; <nl> - gpr_free ( * ev_driver ) ; <nl> - return err ; <nl> - } <nl> - ( * ev_driver ) - > work_serializer = std : : move ( work_serializer ) ; <nl> - gpr_ref_init ( & ( * ev_driver ) - > refs , 1 ) ; <nl> - ( * ev_driver ) - > pollset_set = pollset_set ; <nl> - ( * ev_driver ) - > fds = nullptr ; <nl> - ( * ev_driver ) - > working = false ; <nl> - ( * ev_driver ) - > shutting_down = false ; <nl> - ( * ev_driver ) - > request = request ; <nl> - ( * ev_driver ) - > polled_fd_factory = <nl> - grpc_core : : NewGrpcPolledFdFactory ( ( * ev_driver ) - > work_serializer ) ; <nl> - ( * ev_driver ) <nl> - - > polled_fd_factory - > ConfigureAresChannelLocked ( ( * ev_driver ) - > channel ) ; <nl> - ( * ev_driver ) - > query_timeout_ms = query_timeout_ms ; <nl> - return GRPC_ERROR_NONE ; <nl> - } <nl> - <nl> - void grpc_ares_ev_driver_on_queries_complete_locked ( <nl> - grpc_ares_ev_driver * ev_driver ) { <nl> - / / We mark the event driver as being shut down . If the event driver <nl> - / / is working , grpc_ares_notify_on_event_locked will shut down the <nl> - / / fds ; if it ' s not working , there are no fds to shut down . <nl> - ev_driver - > shutting_down = true ; <nl> - grpc_timer_cancel ( & ev_driver - > query_timeout ) ; <nl> - grpc_timer_cancel ( & ev_driver - > ares_backup_poll_alarm ) ; <nl> - grpc_ares_ev_driver_unref ( ev_driver ) ; <nl> - } <nl> - <nl> - void grpc_ares_ev_driver_shutdown_locked ( grpc_ares_ev_driver * ev_driver ) { <nl> - ev_driver - > shutting_down = true ; <nl> - fd_node * fn = ev_driver - > fds ; <nl> - while ( fn ! = nullptr ) { <nl> - fd_node_shutdown_locked ( fn , " grpc_ares_ev_driver_shutdown " ) ; <nl> - fn = fn - > next ; <nl> - } <nl> - } <nl> - <nl> - / / Search fd in the fd_node list head . This is an O ( n ) search , the max possible <nl> - / / value of n is ARES_GETSOCK_MAXNUM ( 16 ) . n is typically 1 - 2 in our tests . <nl> - static fd_node * pop_fd_node_locked ( fd_node * * head , ares_socket_t as ) { <nl> - fd_node dummy_head ; <nl> - dummy_head . next = * head ; <nl> - fd_node * node = & dummy_head ; <nl> - while ( node - > next ! = nullptr ) { <nl> - if ( node - > next - > grpc_polled_fd - > GetWrappedAresSocketLocked ( ) = = as ) { <nl> - fd_node * ret = node - > next ; <nl> - node - > next = node - > next - > next ; <nl> - * head = dummy_head . next ; <nl> - return ret ; <nl> - } <nl> - node = node - > next ; <nl> - } <nl> - return nullptr ; <nl> - } <nl> - <nl> - static grpc_millis calculate_next_ares_backup_poll_alarm_ms ( <nl> - grpc_ares_ev_driver * driver ) { <nl> - / / An alternative here could be to use ares_timeout to try to be more <nl> - / / accurate , but that would require using " struct timeval " ' s , which just makes <nl> - / / things a bit more complicated . So just poll every second , as suggested <nl> - / / by the c - ares code comments . <nl> - grpc_millis ms_until_next_ares_backup_poll_alarm = 1000 ; <nl> - GRPC_CARES_TRACE_LOG ( <nl> - " request : % p ev_driver = % p . next ares process poll time in " <nl> - " % " PRId64 " ms " , <nl> - driver - > request , driver , ms_until_next_ares_backup_poll_alarm ) ; <nl> - return ms_until_next_ares_backup_poll_alarm + <nl> - grpc_core : : ExecCtx : : Get ( ) - > Now ( ) ; <nl> - } <nl> - <nl> - static void on_timeout ( void * arg , grpc_error * error ) { <nl> - grpc_ares_ev_driver * driver = static_cast < grpc_ares_ev_driver * > ( arg ) ; <nl> - GRPC_ERROR_REF ( error ) ; / / ref owned by lambda <nl> - driver - > work_serializer - > Run ( <nl> - [ driver , error ] ( ) { on_timeout_locked ( driver , error ) ; } , DEBUG_LOCATION ) ; <nl> - } <nl> - <nl> - static void on_timeout_locked ( grpc_ares_ev_driver * driver , grpc_error * error ) { <nl> - GRPC_CARES_TRACE_LOG ( <nl> - " request : % p ev_driver = % p on_timeout_locked . driver - > shutting_down = % d . " <nl> - " err = % s " , <nl> - driver - > request , driver , driver - > shutting_down , grpc_error_string ( error ) ) ; <nl> - if ( ! driver - > shutting_down & & error = = GRPC_ERROR_NONE ) { <nl> - grpc_ares_ev_driver_shutdown_locked ( driver ) ; <nl> - } <nl> - grpc_ares_ev_driver_unref ( driver ) ; <nl> - GRPC_ERROR_UNREF ( error ) ; <nl> - } <nl> - <nl> - static void on_ares_backup_poll_alarm ( void * arg , grpc_error * error ) { <nl> - grpc_ares_ev_driver * driver = static_cast < grpc_ares_ev_driver * > ( arg ) ; <nl> - GRPC_ERROR_REF ( error ) ; <nl> - driver - > work_serializer - > Run ( <nl> - [ driver , error ] ( ) { on_ares_backup_poll_alarm_locked ( driver , error ) ; } , <nl> - DEBUG_LOCATION ) ; <nl> - } <nl> - <nl> - / * In case of non - responsive DNS servers , dropped packets , etc . , c - ares has <nl> - * intelligent timeout and retry logic , which we can take advantage of by <nl> - * polling ares_process_fd on time intervals . Overall , the c - ares library is <nl> - * meant to be called into and given a chance to proceed name resolution : <nl> - * a ) when fd events happen <nl> - * b ) when some time has passed without fd events having happened <nl> - * For the latter , we use this backup poller . Also see <nl> - * https : / / github . com / grpc / grpc / pull / 17688 description for more details . * / <nl> - static void on_ares_backup_poll_alarm_locked ( grpc_ares_ev_driver * driver , <nl> - grpc_error * error ) { <nl> - GRPC_CARES_TRACE_LOG ( <nl> - " request : % p ev_driver = % p on_ares_backup_poll_alarm_locked . " <nl> - " driver - > shutting_down = % d . " <nl> - " err = % s " , <nl> - driver - > request , driver , driver - > shutting_down , grpc_error_string ( error ) ) ; <nl> - if ( ! driver - > shutting_down & & error = = GRPC_ERROR_NONE ) { <nl> - fd_node * fdn = driver - > fds ; <nl> - while ( fdn ! = nullptr ) { <nl> - if ( ! fdn - > already_shutdown ) { <nl> - GRPC_CARES_TRACE_LOG ( <nl> - " request : % p ev_driver = % p on_ares_backup_poll_alarm_locked ; " <nl> - " ares_process_fd . fd = % s " , <nl> - driver - > request , driver , fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> - ares_socket_t as = fdn - > grpc_polled_fd - > GetWrappedAresSocketLocked ( ) ; <nl> - ares_process_fd ( driver - > channel , as , as ) ; <nl> - } <nl> - fdn = fdn - > next ; <nl> - } <nl> - if ( ! driver - > shutting_down ) { <nl> - grpc_millis next_ares_backup_poll_alarm = <nl> - calculate_next_ares_backup_poll_alarm_ms ( driver ) ; <nl> - grpc_ares_ev_driver_ref ( driver ) ; <nl> - GRPC_CLOSURE_INIT ( & driver - > on_ares_backup_poll_alarm_locked , <nl> - on_ares_backup_poll_alarm , driver , <nl> - grpc_schedule_on_exec_ctx ) ; <nl> - grpc_timer_init ( & driver - > ares_backup_poll_alarm , <nl> - next_ares_backup_poll_alarm , <nl> - & driver - > on_ares_backup_poll_alarm_locked ) ; <nl> - } <nl> - grpc_ares_notify_on_event_locked ( driver ) ; <nl> - } <nl> - grpc_ares_ev_driver_unref ( driver ) ; <nl> - GRPC_ERROR_UNREF ( error ) ; <nl> - } <nl> - <nl> - static void on_readable_locked ( fd_node * fdn , grpc_error * error ) { <nl> - GPR_ASSERT ( fdn - > readable_registered ) ; <nl> - grpc_ares_ev_driver * ev_driver = fdn - > ev_driver ; <nl> - const ares_socket_t as = fdn - > grpc_polled_fd - > GetWrappedAresSocketLocked ( ) ; <nl> - fdn - > readable_registered = false ; <nl> - GRPC_CARES_TRACE_LOG ( " request : % p readable on % s " , fdn - > ev_driver - > request , <nl> - fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> - if ( error = = GRPC_ERROR_NONE ) { <nl> - do { <nl> - ares_process_fd ( ev_driver - > channel , as , ARES_SOCKET_BAD ) ; <nl> - } while ( fdn - > grpc_polled_fd - > IsFdStillReadableLocked ( ) ) ; <nl> - } else { <nl> - / / If error is not GRPC_ERROR_NONE , it means the fd has been shutdown or <nl> - / / timed out . The pending lookups made on this ev_driver will be cancelled <nl> - / / by the following ares_cancel ( ) and the on_done callbacks will be invoked <nl> - / / with a status of ARES_ECANCELLED . The remaining file descriptors in this <nl> - / / ev_driver will be cleaned up in the follwing <nl> - / / grpc_ares_notify_on_event_locked ( ) . <nl> - ares_cancel ( ev_driver - > channel ) ; <nl> - } <nl> - grpc_ares_notify_on_event_locked ( ev_driver ) ; <nl> - grpc_ares_ev_driver_unref ( ev_driver ) ; <nl> - GRPC_ERROR_UNREF ( error ) ; <nl> - } <nl> - <nl> - static void on_readable ( void * arg , grpc_error * error ) { <nl> - fd_node * fdn = static_cast < fd_node * > ( arg ) ; <nl> - GRPC_ERROR_REF ( error ) ; / * ref owned by lambda * / <nl> - fdn - > ev_driver - > work_serializer - > Run ( <nl> - [ fdn , error ] ( ) { on_readable_locked ( fdn , error ) ; } , DEBUG_LOCATION ) ; <nl> - } <nl> - <nl> - static void on_writable_locked ( fd_node * fdn , grpc_error * error ) { <nl> - GPR_ASSERT ( fdn - > writable_registered ) ; <nl> - grpc_ares_ev_driver * ev_driver = fdn - > ev_driver ; <nl> - const ares_socket_t as = fdn - > grpc_polled_fd - > GetWrappedAresSocketLocked ( ) ; <nl> - fdn - > writable_registered = false ; <nl> - GRPC_CARES_TRACE_LOG ( " request : % p writable on % s " , ev_driver - > request , <nl> - fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> - if ( error = = GRPC_ERROR_NONE ) { <nl> - ares_process_fd ( ev_driver - > channel , ARES_SOCKET_BAD , as ) ; <nl> - } else { <nl> - / / If error is not GRPC_ERROR_NONE , it means the fd has been shutdown or <nl> - / / timed out . The pending lookups made on this ev_driver will be cancelled <nl> - / / by the following ares_cancel ( ) and the on_done callbacks will be invoked <nl> - / / with a status of ARES_ECANCELLED . The remaining file descriptors in this <nl> - / / ev_driver will be cleaned up in the follwing <nl> - / / grpc_ares_notify_on_event_locked ( ) . <nl> - ares_cancel ( ev_driver - > channel ) ; <nl> - } <nl> - grpc_ares_notify_on_event_locked ( ev_driver ) ; <nl> - grpc_ares_ev_driver_unref ( ev_driver ) ; <nl> - GRPC_ERROR_UNREF ( error ) ; <nl> - } <nl> - <nl> - static void on_writable ( void * arg , grpc_error * error ) { <nl> - fd_node * fdn = static_cast < fd_node * > ( arg ) ; <nl> - GRPC_ERROR_REF ( error ) ; / * ref owned by lambda * / <nl> - fdn - > ev_driver - > work_serializer - > Run ( <nl> - [ fdn , error ] ( ) { on_writable_locked ( fdn , error ) ; } , DEBUG_LOCATION ) ; <nl> - } <nl> - <nl> - ares_channel * grpc_ares_ev_driver_get_channel_locked ( <nl> - grpc_ares_ev_driver * ev_driver ) { <nl> - return & ev_driver - > channel ; <nl> - } <nl> - <nl> - / / Get the file descriptors used by the ev_driver ' s ares channel , register <nl> - / / driver_closure with these filedescriptors . <nl> - static void grpc_ares_notify_on_event_locked ( grpc_ares_ev_driver * ev_driver ) { <nl> - fd_node * new_list = nullptr ; <nl> - if ( ! ev_driver - > shutting_down ) { <nl> - ares_socket_t socks [ ARES_GETSOCK_MAXNUM ] ; <nl> - int socks_bitmask = <nl> - ares_getsock ( ev_driver - > channel , socks , ARES_GETSOCK_MAXNUM ) ; <nl> - for ( size_t i = 0 ; i < ARES_GETSOCK_MAXNUM ; i + + ) { <nl> - if ( ARES_GETSOCK_READABLE ( socks_bitmask , i ) | | <nl> - ARES_GETSOCK_WRITABLE ( socks_bitmask , i ) ) { <nl> - fd_node * fdn = pop_fd_node_locked ( & ev_driver - > fds , socks [ i ] ) ; <nl> - / / Create a new fd_node if sock [ i ] is not in the fd_node list . <nl> - if ( fdn = = nullptr ) { <nl> - fdn = static_cast < fd_node * > ( gpr_malloc ( sizeof ( fd_node ) ) ) ; <nl> - fdn - > grpc_polled_fd = <nl> - ev_driver - > polled_fd_factory - > NewGrpcPolledFdLocked ( <nl> - socks [ i ] , ev_driver - > pollset_set , ev_driver - > work_serializer ) ; <nl> - GRPC_CARES_TRACE_LOG ( " request : % p new fd : % s " , ev_driver - > request , <nl> - fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> - fdn - > ev_driver = ev_driver ; <nl> - fdn - > readable_registered = false ; <nl> - fdn - > writable_registered = false ; <nl> - fdn - > already_shutdown = false ; <nl> - } <nl> - fdn - > next = new_list ; <nl> - new_list = fdn ; <nl> - / / Register read_closure if the socket is readable and read_closure has <nl> - / / not been registered with this socket . <nl> - if ( ARES_GETSOCK_READABLE ( socks_bitmask , i ) & & <nl> - ! fdn - > readable_registered ) { <nl> - grpc_ares_ev_driver_ref ( ev_driver ) ; <nl> - GRPC_CARES_TRACE_LOG ( " request : % p notify read on : % s " , <nl> - ev_driver - > request , <nl> - fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> - GRPC_CLOSURE_INIT ( & fdn - > read_closure , on_readable , fdn , <nl> - grpc_schedule_on_exec_ctx ) ; <nl> - fdn - > grpc_polled_fd - > RegisterForOnReadableLocked ( & fdn - > read_closure ) ; <nl> - fdn - > readable_registered = true ; <nl> - } <nl> - / / Register write_closure if the socket is writable and write_closure <nl> - / / has not been registered with this socket . <nl> - if ( ARES_GETSOCK_WRITABLE ( socks_bitmask , i ) & & <nl> - ! fdn - > writable_registered ) { <nl> - GRPC_CARES_TRACE_LOG ( " request : % p notify write on : % s " , <nl> - ev_driver - > request , <nl> - fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> - grpc_ares_ev_driver_ref ( ev_driver ) ; <nl> - GRPC_CLOSURE_INIT ( & fdn - > write_closure , on_writable , fdn , <nl> - grpc_schedule_on_exec_ctx ) ; <nl> - fdn - > grpc_polled_fd - > RegisterForOnWriteableLocked ( <nl> - & fdn - > write_closure ) ; <nl> - fdn - > writable_registered = true ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - / / Any remaining fds in ev_driver - > fds were not returned by ares_getsock ( ) and <nl> - / / are therefore no longer in use , so they can be shut down and removed from <nl> - / / the list . <nl> - while ( ev_driver - > fds ! = nullptr ) { <nl> - fd_node * cur = ev_driver - > fds ; <nl> - ev_driver - > fds = ev_driver - > fds - > next ; <nl> - fd_node_shutdown_locked ( cur , " c - ares fd shutdown " ) ; <nl> - if ( ! cur - > readable_registered & & ! cur - > writable_registered ) { <nl> - fd_node_destroy_locked ( cur ) ; <nl> - } else { <nl> - cur - > next = new_list ; <nl> - new_list = cur ; <nl> - } <nl> - } <nl> - ev_driver - > fds = new_list ; <nl> - / / If the ev driver has no working fd , all the tasks are done . <nl> - if ( new_list = = nullptr ) { <nl> - ev_driver - > working = false ; <nl> - GRPC_CARES_TRACE_LOG ( " request : % p ev driver stop working " , <nl> - ev_driver - > request ) ; <nl> - } <nl> - } <nl> - <nl> - void grpc_ares_ev_driver_start_locked ( grpc_ares_ev_driver * ev_driver ) { <nl> - if ( ! ev_driver - > working ) { <nl> - ev_driver - > working = true ; <nl> - grpc_ares_notify_on_event_locked ( ev_driver ) ; <nl> - / / Initialize overall DNS resolution timeout alarm <nl> - grpc_millis timeout = <nl> - ev_driver - > query_timeout_ms = = 0 <nl> - ? GRPC_MILLIS_INF_FUTURE <nl> - : ev_driver - > query_timeout_ms + grpc_core : : ExecCtx : : Get ( ) - > Now ( ) ; <nl> - GRPC_CARES_TRACE_LOG ( <nl> - " request : % p ev_driver = % p grpc_ares_ev_driver_start_locked . timeout in " <nl> - " % " PRId64 " ms " , <nl> - ev_driver - > request , ev_driver , timeout ) ; <nl> - grpc_ares_ev_driver_ref ( ev_driver ) ; <nl> - GRPC_CLOSURE_INIT ( & ev_driver - > on_timeout_locked , on_timeout , ev_driver , <nl> - grpc_schedule_on_exec_ctx ) ; <nl> - grpc_timer_init ( & ev_driver - > query_timeout , timeout , <nl> - & ev_driver - > on_timeout_locked ) ; <nl> - / / Initialize the backup poll alarm <nl> - grpc_millis next_ares_backup_poll_alarm = <nl> - calculate_next_ares_backup_poll_alarm_ms ( ev_driver ) ; <nl> - grpc_ares_ev_driver_ref ( ev_driver ) ; <nl> - GRPC_CLOSURE_INIT ( & ev_driver - > on_ares_backup_poll_alarm_locked , <nl> - on_ares_backup_poll_alarm , ev_driver , <nl> - grpc_schedule_on_exec_ctx ) ; <nl> - grpc_timer_init ( & ev_driver - > ares_backup_poll_alarm , <nl> - next_ares_backup_poll_alarm , <nl> - & ev_driver - > on_ares_backup_poll_alarm_locked ) ; <nl> - } <nl> - } <nl> - <nl> - # endif / * GRPC_ARES = = 1 * / <nl> mmm a / src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h <nl> ppp b / src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h <nl> <nl> # include < grpc / support / port_platform . h > <nl> <nl> # include < ares . h > <nl> - # include " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_wrapper . h " <nl> # include " src / core / lib / iomgr / pollset_set . h " <nl> - <nl> - typedef struct grpc_ares_ev_driver grpc_ares_ev_driver ; <nl> - <nl> - / * Start \ a ev_driver . It will keep working until all IO on its ares_channel is <nl> - done , or grpc_ares_ev_driver_destroy ( ) is called . It may notify the callbacks <nl> - bound to its ares_channel when necessary . * / <nl> - void grpc_ares_ev_driver_start_locked ( grpc_ares_ev_driver * ev_driver ) ; <nl> - <nl> - / * Returns the ares_channel owned by \ a ev_driver . To bind a c - ares query to <nl> - \ a ev_driver , use the ares_channel owned by \ a ev_driver as the arg of the <nl> - query . * / <nl> - ares_channel * grpc_ares_ev_driver_get_channel_locked ( <nl> - grpc_ares_ev_driver * ev_driver ) ; <nl> - <nl> - / * Creates a new grpc_ares_ev_driver . Returns GRPC_ERROR_NONE if \ a ev_driver is <nl> - created successfully . * / <nl> - grpc_error * grpc_ares_ev_driver_create_locked ( <nl> - grpc_ares_ev_driver * * ev_driver , grpc_pollset_set * pollset_set , <nl> - int query_timeout_ms , <nl> - std : : shared_ptr < grpc_core : : WorkSerializer > work_serializer , <nl> - grpc_ares_request * request ) ; <nl> - <nl> - / * Called back when all DNS lookups have completed . * / <nl> - void grpc_ares_ev_driver_on_queries_complete_locked ( <nl> - grpc_ares_ev_driver * ev_driver ) ; <nl> - <nl> - / * Shutdown all the grpc_fds used by \ a ev_driver * / <nl> - void grpc_ares_ev_driver_shutdown_locked ( grpc_ares_ev_driver * ev_driver ) ; <nl> - <nl> - / * Exposed in this header for C - core tests only * / <nl> - extern void ( * grpc_ares_test_only_inject_config ) ( ares_channel channel ) ; <nl> + # include " src / core / lib / iomgr / work_serializer . h " <nl> <nl> namespace grpc_core { <nl> <nl> mmm a / src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_wrapper . cc <nl> ppp b / src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_wrapper . cc <nl> <nl> # include " src / core / lib / iomgr / nameser . h " <nl> # include " src / core / lib / iomgr / parse_address . h " <nl> # include " src / core / lib / iomgr / sockaddr_utils . h " <nl> + # include " src / core / lib / iomgr / timer . h " <nl> # include " src / core / lib / transport / authority_override . h " <nl> <nl> using grpc_core : : ServerAddress ; <nl> grpc_core : : TraceFlag grpc_trace_cares_address_sorting ( false , <nl> <nl> grpc_core : : TraceFlag grpc_trace_cares_resolver ( false , " cares_resolver " ) ; <nl> <nl> + typedef struct grpc_ares_ev_driver grpc_ares_ev_driver ; <nl> + <nl> struct grpc_ares_request { <nl> / * * indicates the DNS server to use , if specified * / <nl> struct ares_addr_port_node dns_server_addr ; <nl> struct grpc_ares_request { <nl> grpc_error * error ; <nl> } ; <nl> <nl> + typedef struct fd_node { <nl> + / * * the owner of this fd node * / <nl> + grpc_ares_ev_driver * ev_driver ; <nl> + / * * a closure wrapping on_readable_locked , which should be <nl> + invoked when the grpc_fd in this node becomes readable . * / <nl> + grpc_closure read_closure ; <nl> + / * * a closure wrapping on_writable_locked , which should be <nl> + invoked when the grpc_fd in this node becomes writable . * / <nl> + grpc_closure write_closure ; <nl> + / * * next fd node in the list * / <nl> + struct fd_node * next ; <nl> + <nl> + / * * wrapped fd that ' s polled by grpc ' s poller for the current platform * / <nl> + grpc_core : : GrpcPolledFd * grpc_polled_fd ; <nl> + / * * if the readable closure has been registered * / <nl> + bool readable_registered ; <nl> + / * * if the writable closure has been registered * / <nl> + bool writable_registered ; <nl> + / * * if the fd has been shutdown yet from grpc iomgr perspective * / <nl> + bool already_shutdown ; <nl> + } fd_node ; <nl> + <nl> + struct grpc_ares_ev_driver { <nl> + / * * the ares_channel owned by this event driver * / <nl> + ares_channel channel ; <nl> + / * * pollset set for driving the IO events of the channel * / <nl> + grpc_pollset_set * pollset_set ; <nl> + / * * refcount of the event driver * / <nl> + gpr_refcount refs ; <nl> + <nl> + / * * work_serializer to synchronize c - ares and I / O callbacks on * / <nl> + std : : shared_ptr < grpc_core : : WorkSerializer > work_serializer ; <nl> + / * * a list of grpc_fd that this event driver is currently using . * / <nl> + fd_node * fds ; <nl> + / * * is this event driver currently working ? * / <nl> + bool working ; <nl> + / * * is this event driver being shut down * / <nl> + bool shutting_down ; <nl> + / * * request object that ' s using this ev driver * / <nl> + grpc_ares_request * request ; <nl> + / * * Owned by the ev_driver . Creates new GrpcPolledFd ' s * / <nl> + std : : unique_ptr < grpc_core : : GrpcPolledFdFactory > polled_fd_factory ; <nl> + / * * query timeout in milliseconds * / <nl> + int query_timeout_ms ; <nl> + / * * alarm to cancel active queries * / <nl> + grpc_timer query_timeout ; <nl> + / * * cancels queries on a timeout * / <nl> + grpc_closure on_timeout_locked ; <nl> + / * * alarm to poll ares_process on in case fd events don ' t happen * / <nl> + grpc_timer ares_backup_poll_alarm ; <nl> + / * * polls ares_process on a periodic timer * / <nl> + grpc_closure on_ares_backup_poll_alarm_locked ; <nl> + } ; <nl> + <nl> / / TODO ( apolcyn ) : make grpc_ares_hostbyname_request a sub - class <nl> / / of GrpcAresQuery . <nl> typedef struct grpc_ares_hostbyname_request { <nl> class GrpcAresQuery { <nl> const std : : string name_ ; <nl> } ; <nl> <nl> + static grpc_ares_ev_driver * grpc_ares_ev_driver_ref ( <nl> + grpc_ares_ev_driver * ev_driver ) { <nl> + GRPC_CARES_TRACE_LOG ( " request : % p Ref ev_driver % p " , ev_driver - > request , <nl> + ev_driver ) ; <nl> + gpr_ref ( & ev_driver - > refs ) ; <nl> + return ev_driver ; <nl> + } <nl> + <nl> + static void grpc_ares_ev_driver_unref ( grpc_ares_ev_driver * ev_driver ) { <nl> + GRPC_CARES_TRACE_LOG ( " request : % p Unref ev_driver % p " , ev_driver - > request , <nl> + ev_driver ) ; <nl> + if ( gpr_unref ( & ev_driver - > refs ) ) { <nl> + GRPC_CARES_TRACE_LOG ( " request : % p destroy ev_driver % p " , ev_driver - > request , <nl> + ev_driver ) ; <nl> + GPR_ASSERT ( ev_driver - > fds = = nullptr ) ; <nl> + ares_destroy ( ev_driver - > channel ) ; <nl> + grpc_ares_complete_request_locked ( ev_driver - > request ) ; <nl> + delete ev_driver ; <nl> + } <nl> + } <nl> + <nl> + static void fd_node_destroy_locked ( fd_node * fdn ) { <nl> + GRPC_CARES_TRACE_LOG ( " request : % p delete fd : % s " , fdn - > ev_driver - > request , <nl> + fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> + GPR_ASSERT ( ! fdn - > readable_registered ) ; <nl> + GPR_ASSERT ( ! fdn - > writable_registered ) ; <nl> + GPR_ASSERT ( fdn - > already_shutdown ) ; <nl> + delete fdn - > grpc_polled_fd ; <nl> + gpr_free ( fdn ) ; <nl> + } <nl> + <nl> + static void fd_node_shutdown_locked ( fd_node * fdn , const char * reason ) { <nl> + if ( ! fdn - > already_shutdown ) { <nl> + fdn - > already_shutdown = true ; <nl> + fdn - > grpc_polled_fd - > ShutdownLocked ( <nl> + GRPC_ERROR_CREATE_FROM_STATIC_STRING ( reason ) ) ; <nl> + } <nl> + } <nl> + <nl> + void grpc_ares_ev_driver_on_queries_complete_locked ( <nl> + grpc_ares_ev_driver * ev_driver ) { <nl> + / / We mark the event driver as being shut down . If the event driver <nl> + / / is working , grpc_ares_notify_on_event_locked will shut down the <nl> + / / fds ; if it ' s not working , there are no fds to shut down . <nl> + ev_driver - > shutting_down = true ; <nl> + grpc_timer_cancel ( & ev_driver - > query_timeout ) ; <nl> + grpc_timer_cancel ( & ev_driver - > ares_backup_poll_alarm ) ; <nl> + grpc_ares_ev_driver_unref ( ev_driver ) ; <nl> + } <nl> + <nl> + void grpc_ares_ev_driver_shutdown_locked ( grpc_ares_ev_driver * ev_driver ) { <nl> + ev_driver - > shutting_down = true ; <nl> + fd_node * fn = ev_driver - > fds ; <nl> + while ( fn ! = nullptr ) { <nl> + fd_node_shutdown_locked ( fn , " grpc_ares_ev_driver_shutdown " ) ; <nl> + fn = fn - > next ; <nl> + } <nl> + } <nl> + <nl> + / / Search fd in the fd_node list head . This is an O ( n ) search , the max possible <nl> + / / value of n is ARES_GETSOCK_MAXNUM ( 16 ) . n is typically 1 - 2 in our tests . <nl> + static fd_node * pop_fd_node_locked ( fd_node * * head , ares_socket_t as ) { <nl> + fd_node dummy_head ; <nl> + dummy_head . next = * head ; <nl> + fd_node * node = & dummy_head ; <nl> + while ( node - > next ! = nullptr ) { <nl> + if ( node - > next - > grpc_polled_fd - > GetWrappedAresSocketLocked ( ) = = as ) { <nl> + fd_node * ret = node - > next ; <nl> + node - > next = node - > next - > next ; <nl> + * head = dummy_head . next ; <nl> + return ret ; <nl> + } <nl> + node = node - > next ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> + <nl> + static grpc_millis calculate_next_ares_backup_poll_alarm_ms ( <nl> + grpc_ares_ev_driver * driver ) { <nl> + / / An alternative here could be to use ares_timeout to try to be more <nl> + / / accurate , but that would require using " struct timeval " ' s , which just makes <nl> + / / things a bit more complicated . So just poll every second , as suggested <nl> + / / by the c - ares code comments . <nl> + grpc_millis ms_until_next_ares_backup_poll_alarm = 1000 ; <nl> + GRPC_CARES_TRACE_LOG ( <nl> + " request : % p ev_driver = % p . next ares process poll time in " <nl> + " % " PRId64 " ms " , <nl> + driver - > request , driver , ms_until_next_ares_backup_poll_alarm ) ; <nl> + return ms_until_next_ares_backup_poll_alarm + <nl> + grpc_core : : ExecCtx : : Get ( ) - > Now ( ) ; <nl> + } <nl> + <nl> + static void on_timeout_locked ( grpc_ares_ev_driver * driver , grpc_error * error ) { <nl> + GRPC_CARES_TRACE_LOG ( <nl> + " request : % p ev_driver = % p on_timeout_locked . driver - > shutting_down = % d . " <nl> + " err = % s " , <nl> + driver - > request , driver , driver - > shutting_down , grpc_error_string ( error ) ) ; <nl> + if ( ! driver - > shutting_down & & error = = GRPC_ERROR_NONE ) { <nl> + grpc_ares_ev_driver_shutdown_locked ( driver ) ; <nl> + } <nl> + grpc_ares_ev_driver_unref ( driver ) ; <nl> + GRPC_ERROR_UNREF ( error ) ; <nl> + } <nl> + <nl> + static void on_timeout ( void * arg , grpc_error * error ) { <nl> + grpc_ares_ev_driver * driver = static_cast < grpc_ares_ev_driver * > ( arg ) ; <nl> + GRPC_ERROR_REF ( error ) ; / / ref owned by lambda <nl> + driver - > work_serializer - > Run ( <nl> + [ driver , error ] ( ) { on_timeout_locked ( driver , error ) ; } , DEBUG_LOCATION ) ; <nl> + } <nl> + <nl> + static void grpc_ares_notify_on_event_locked ( grpc_ares_ev_driver * ev_driver ) ; <nl> + <nl> + static void on_ares_backup_poll_alarm_locked ( grpc_ares_ev_driver * driver , <nl> + grpc_error * error ) ; <nl> + <nl> + static void on_ares_backup_poll_alarm ( void * arg , grpc_error * error ) { <nl> + grpc_ares_ev_driver * driver = static_cast < grpc_ares_ev_driver * > ( arg ) ; <nl> + GRPC_ERROR_REF ( error ) ; <nl> + driver - > work_serializer - > Run ( <nl> + [ driver , error ] ( ) { on_ares_backup_poll_alarm_locked ( driver , error ) ; } , <nl> + DEBUG_LOCATION ) ; <nl> + } <nl> + <nl> + / * In case of non - responsive DNS servers , dropped packets , etc . , c - ares has <nl> + * intelligent timeout and retry logic , which we can take advantage of by <nl> + * polling ares_process_fd on time intervals . Overall , the c - ares library is <nl> + * meant to be called into and given a chance to proceed name resolution : <nl> + * a ) when fd events happen <nl> + * b ) when some time has passed without fd events having happened <nl> + * For the latter , we use this backup poller . Also see <nl> + * https : / / github . com / grpc / grpc / pull / 17688 description for more details . * / <nl> + static void on_ares_backup_poll_alarm_locked ( grpc_ares_ev_driver * driver , <nl> + grpc_error * error ) { <nl> + GRPC_CARES_TRACE_LOG ( <nl> + " request : % p ev_driver = % p on_ares_backup_poll_alarm_locked . " <nl> + " driver - > shutting_down = % d . " <nl> + " err = % s " , <nl> + driver - > request , driver , driver - > shutting_down , grpc_error_string ( error ) ) ; <nl> + if ( ! driver - > shutting_down & & error = = GRPC_ERROR_NONE ) { <nl> + fd_node * fdn = driver - > fds ; <nl> + while ( fdn ! = nullptr ) { <nl> + if ( ! fdn - > already_shutdown ) { <nl> + GRPC_CARES_TRACE_LOG ( <nl> + " request : % p ev_driver = % p on_ares_backup_poll_alarm_locked ; " <nl> + " ares_process_fd . fd = % s " , <nl> + driver - > request , driver , fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> + ares_socket_t as = fdn - > grpc_polled_fd - > GetWrappedAresSocketLocked ( ) ; <nl> + ares_process_fd ( driver - > channel , as , as ) ; <nl> + } <nl> + fdn = fdn - > next ; <nl> + } <nl> + if ( ! driver - > shutting_down ) { <nl> + grpc_millis next_ares_backup_poll_alarm = <nl> + calculate_next_ares_backup_poll_alarm_ms ( driver ) ; <nl> + grpc_ares_ev_driver_ref ( driver ) ; <nl> + GRPC_CLOSURE_INIT ( & driver - > on_ares_backup_poll_alarm_locked , <nl> + on_ares_backup_poll_alarm , driver , <nl> + grpc_schedule_on_exec_ctx ) ; <nl> + grpc_timer_init ( & driver - > ares_backup_poll_alarm , <nl> + next_ares_backup_poll_alarm , <nl> + & driver - > on_ares_backup_poll_alarm_locked ) ; <nl> + } <nl> + grpc_ares_notify_on_event_locked ( driver ) ; <nl> + } <nl> + grpc_ares_ev_driver_unref ( driver ) ; <nl> + GRPC_ERROR_UNREF ( error ) ; <nl> + } <nl> + <nl> + static void on_readable_locked ( fd_node * fdn , grpc_error * error ) { <nl> + GPR_ASSERT ( fdn - > readable_registered ) ; <nl> + grpc_ares_ev_driver * ev_driver = fdn - > ev_driver ; <nl> + const ares_socket_t as = fdn - > grpc_polled_fd - > GetWrappedAresSocketLocked ( ) ; <nl> + fdn - > readable_registered = false ; <nl> + GRPC_CARES_TRACE_LOG ( " request : % p readable on % s " , fdn - > ev_driver - > request , <nl> + fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> + if ( error = = GRPC_ERROR_NONE ) { <nl> + do { <nl> + ares_process_fd ( ev_driver - > channel , as , ARES_SOCKET_BAD ) ; <nl> + } while ( fdn - > grpc_polled_fd - > IsFdStillReadableLocked ( ) ) ; <nl> + } else { <nl> + / / If error is not GRPC_ERROR_NONE , it means the fd has been shutdown or <nl> + / / timed out . The pending lookups made on this ev_driver will be cancelled <nl> + / / by the following ares_cancel ( ) and the on_done callbacks will be invoked <nl> + / / with a status of ARES_ECANCELLED . The remaining file descriptors in this <nl> + / / ev_driver will be cleaned up in the follwing <nl> + / / grpc_ares_notify_on_event_locked ( ) . <nl> + ares_cancel ( ev_driver - > channel ) ; <nl> + } <nl> + grpc_ares_notify_on_event_locked ( ev_driver ) ; <nl> + grpc_ares_ev_driver_unref ( ev_driver ) ; <nl> + GRPC_ERROR_UNREF ( error ) ; <nl> + } <nl> + <nl> + static void on_readable ( void * arg , grpc_error * error ) { <nl> + fd_node * fdn = static_cast < fd_node * > ( arg ) ; <nl> + GRPC_ERROR_REF ( error ) ; / * ref owned by lambda * / <nl> + fdn - > ev_driver - > work_serializer - > Run ( <nl> + [ fdn , error ] ( ) { on_readable_locked ( fdn , error ) ; } , DEBUG_LOCATION ) ; <nl> + } <nl> + <nl> + static void on_writable_locked ( fd_node * fdn , grpc_error * error ) { <nl> + GPR_ASSERT ( fdn - > writable_registered ) ; <nl> + grpc_ares_ev_driver * ev_driver = fdn - > ev_driver ; <nl> + const ares_socket_t as = fdn - > grpc_polled_fd - > GetWrappedAresSocketLocked ( ) ; <nl> + fdn - > writable_registered = false ; <nl> + GRPC_CARES_TRACE_LOG ( " request : % p writable on % s " , ev_driver - > request , <nl> + fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> + if ( error = = GRPC_ERROR_NONE ) { <nl> + ares_process_fd ( ev_driver - > channel , ARES_SOCKET_BAD , as ) ; <nl> + } else { <nl> + / / If error is not GRPC_ERROR_NONE , it means the fd has been shutdown or <nl> + / / timed out . The pending lookups made on this ev_driver will be cancelled <nl> + / / by the following ares_cancel ( ) and the on_done callbacks will be invoked <nl> + / / with a status of ARES_ECANCELLED . The remaining file descriptors in this <nl> + / / ev_driver will be cleaned up in the follwing <nl> + / / grpc_ares_notify_on_event_locked ( ) . <nl> + ares_cancel ( ev_driver - > channel ) ; <nl> + } <nl> + grpc_ares_notify_on_event_locked ( ev_driver ) ; <nl> + grpc_ares_ev_driver_unref ( ev_driver ) ; <nl> + GRPC_ERROR_UNREF ( error ) ; <nl> + } <nl> + <nl> + static void on_writable ( void * arg , grpc_error * error ) { <nl> + fd_node * fdn = static_cast < fd_node * > ( arg ) ; <nl> + GRPC_ERROR_REF ( error ) ; / * ref owned by lambda * / <nl> + fdn - > ev_driver - > work_serializer - > Run ( <nl> + [ fdn , error ] ( ) { on_writable_locked ( fdn , error ) ; } , DEBUG_LOCATION ) ; <nl> + } <nl> + <nl> + / / Get the file descriptors used by the ev_driver ' s ares channel , register <nl> + / / driver_closure with these filedescriptors . <nl> + static void grpc_ares_notify_on_event_locked ( grpc_ares_ev_driver * ev_driver ) { <nl> + fd_node * new_list = nullptr ; <nl> + if ( ! ev_driver - > shutting_down ) { <nl> + ares_socket_t socks [ ARES_GETSOCK_MAXNUM ] ; <nl> + int socks_bitmask = <nl> + ares_getsock ( ev_driver - > channel , socks , ARES_GETSOCK_MAXNUM ) ; <nl> + for ( size_t i = 0 ; i < ARES_GETSOCK_MAXNUM ; i + + ) { <nl> + if ( ARES_GETSOCK_READABLE ( socks_bitmask , i ) | | <nl> + ARES_GETSOCK_WRITABLE ( socks_bitmask , i ) ) { <nl> + fd_node * fdn = pop_fd_node_locked ( & ev_driver - > fds , socks [ i ] ) ; <nl> + / / Create a new fd_node if sock [ i ] is not in the fd_node list . <nl> + if ( fdn = = nullptr ) { <nl> + fdn = static_cast < fd_node * > ( gpr_malloc ( sizeof ( fd_node ) ) ) ; <nl> + fdn - > grpc_polled_fd = <nl> + ev_driver - > polled_fd_factory - > NewGrpcPolledFdLocked ( <nl> + socks [ i ] , ev_driver - > pollset_set , ev_driver - > work_serializer ) ; <nl> + GRPC_CARES_TRACE_LOG ( " request : % p new fd : % s " , ev_driver - > request , <nl> + fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> + fdn - > ev_driver = ev_driver ; <nl> + fdn - > readable_registered = false ; <nl> + fdn - > writable_registered = false ; <nl> + fdn - > already_shutdown = false ; <nl> + } <nl> + fdn - > next = new_list ; <nl> + new_list = fdn ; <nl> + / / Register read_closure if the socket is readable and read_closure has <nl> + / / not been registered with this socket . <nl> + if ( ARES_GETSOCK_READABLE ( socks_bitmask , i ) & & <nl> + ! fdn - > readable_registered ) { <nl> + grpc_ares_ev_driver_ref ( ev_driver ) ; <nl> + GRPC_CARES_TRACE_LOG ( " request : % p notify read on : % s " , <nl> + ev_driver - > request , <nl> + fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> + GRPC_CLOSURE_INIT ( & fdn - > read_closure , on_readable , fdn , <nl> + grpc_schedule_on_exec_ctx ) ; <nl> + fdn - > grpc_polled_fd - > RegisterForOnReadableLocked ( & fdn - > read_closure ) ; <nl> + fdn - > readable_registered = true ; <nl> + } <nl> + / / Register write_closure if the socket is writable and write_closure <nl> + / / has not been registered with this socket . <nl> + if ( ARES_GETSOCK_WRITABLE ( socks_bitmask , i ) & & <nl> + ! fdn - > writable_registered ) { <nl> + GRPC_CARES_TRACE_LOG ( " request : % p notify write on : % s " , <nl> + ev_driver - > request , <nl> + fdn - > grpc_polled_fd - > GetName ( ) ) ; <nl> + grpc_ares_ev_driver_ref ( ev_driver ) ; <nl> + GRPC_CLOSURE_INIT ( & fdn - > write_closure , on_writable , fdn , <nl> + grpc_schedule_on_exec_ctx ) ; <nl> + GRPC_CLOSURE_INIT ( & fdn - > write_closure , on_writable , fdn , <nl> + grpc_schedule_on_exec_ctx ) ; <nl> + fdn - > grpc_polled_fd - > RegisterForOnWriteableLocked ( <nl> + & fdn - > write_closure ) ; <nl> + fdn - > writable_registered = true ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + / / Any remaining fds in ev_driver - > fds were not returned by ares_getsock ( ) and <nl> + / / are therefore no longer in use , so they can be shut down and removed from <nl> + / / the list . <nl> + while ( ev_driver - > fds ! = nullptr ) { <nl> + fd_node * cur = ev_driver - > fds ; <nl> + ev_driver - > fds = ev_driver - > fds - > next ; <nl> + fd_node_shutdown_locked ( cur , " c - ares fd shutdown " ) ; <nl> + if ( ! cur - > readable_registered & & ! cur - > writable_registered ) { <nl> + fd_node_destroy_locked ( cur ) ; <nl> + } else { <nl> + cur - > next = new_list ; <nl> + new_list = cur ; <nl> + } <nl> + } <nl> + ev_driver - > fds = new_list ; <nl> + / / If the ev driver has no working fd , all the tasks are done . <nl> + if ( new_list = = nullptr ) { <nl> + ev_driver - > working = false ; <nl> + GRPC_CARES_TRACE_LOG ( " request : % p ev driver stop working " , <nl> + ev_driver - > request ) ; <nl> + } <nl> + } <nl> + <nl> + void grpc_ares_ev_driver_start_locked ( grpc_ares_ev_driver * ev_driver ) { <nl> + if ( ! ev_driver - > working ) { <nl> + ev_driver - > working = true ; <nl> + grpc_ares_notify_on_event_locked ( ev_driver ) ; <nl> + / / Initialize overall DNS resolution timeout alarm <nl> + grpc_millis timeout = <nl> + ev_driver - > query_timeout_ms = = 0 <nl> + ? GRPC_MILLIS_INF_FUTURE <nl> + : ev_driver - > query_timeout_ms + grpc_core : : ExecCtx : : Get ( ) - > Now ( ) ; <nl> + GRPC_CARES_TRACE_LOG ( <nl> + " request : % p ev_driver = % p grpc_ares_ev_driver_start_locked . timeout in " <nl> + " % " PRId64 " ms " , <nl> + ev_driver - > request , ev_driver , timeout ) ; <nl> + grpc_ares_ev_driver_ref ( ev_driver ) ; <nl> + GRPC_CLOSURE_INIT ( & ev_driver - > on_timeout_locked , on_timeout , ev_driver , <nl> + grpc_schedule_on_exec_ctx ) ; <nl> + grpc_timer_init ( & ev_driver - > query_timeout , timeout , <nl> + & ev_driver - > on_timeout_locked ) ; <nl> + / / Initialize the backup poll alarm <nl> + grpc_millis next_ares_backup_poll_alarm = <nl> + calculate_next_ares_backup_poll_alarm_ms ( ev_driver ) ; <nl> + grpc_ares_ev_driver_ref ( ev_driver ) ; <nl> + GRPC_CLOSURE_INIT ( & ev_driver - > on_ares_backup_poll_alarm_locked , <nl> + on_ares_backup_poll_alarm , ev_driver , <nl> + grpc_schedule_on_exec_ctx ) ; <nl> + grpc_timer_init ( & ev_driver - > ares_backup_poll_alarm , <nl> + next_ares_backup_poll_alarm , <nl> + & ev_driver - > on_ares_backup_poll_alarm_locked ) ; <nl> + } <nl> + } <nl> + <nl> + static void noop_inject_channel_config ( ares_channel / * channel * / ) { } <nl> + <nl> + void ( * grpc_ares_test_only_inject_config ) ( ares_channel channel ) = <nl> + noop_inject_channel_config ; <nl> + <nl> + grpc_error * grpc_ares_ev_driver_create_locked ( <nl> + grpc_ares_ev_driver * * ev_driver , grpc_pollset_set * pollset_set , <nl> + int query_timeout_ms , <nl> + std : : shared_ptr < grpc_core : : WorkSerializer > work_serializer , <nl> + grpc_ares_request * request ) { <nl> + * ev_driver = new grpc_ares_ev_driver ( ) ; <nl> + ares_options opts ; <nl> + memset ( & opts , 0 , sizeof ( opts ) ) ; <nl> + opts . flags | = ARES_FLAG_STAYOPEN ; <nl> + int status = ares_init_options ( & ( * ev_driver ) - > channel , & opts , ARES_OPT_FLAGS ) ; <nl> + grpc_ares_test_only_inject_config ( ( * ev_driver ) - > channel ) ; <nl> + GRPC_CARES_TRACE_LOG ( " request : % p grpc_ares_ev_driver_create_locked " , request ) ; <nl> + if ( status ! = ARES_SUCCESS ) { <nl> + grpc_error * err = GRPC_ERROR_CREATE_FROM_COPIED_STRING ( <nl> + absl : : StrCat ( " Failed to init ares channel . C - ares error : " , <nl> + ares_strerror ( status ) ) <nl> + . c_str ( ) ) ; <nl> + gpr_free ( * ev_driver ) ; <nl> + return err ; <nl> + } <nl> + ( * ev_driver ) - > work_serializer = std : : move ( work_serializer ) ; <nl> + gpr_ref_init ( & ( * ev_driver ) - > refs , 1 ) ; <nl> + ( * ev_driver ) - > pollset_set = pollset_set ; <nl> + ( * ev_driver ) - > fds = nullptr ; <nl> + ( * ev_driver ) - > working = false ; <nl> + ( * ev_driver ) - > shutting_down = false ; <nl> + ( * ev_driver ) - > request = request ; <nl> + ( * ev_driver ) - > polled_fd_factory = <nl> + grpc_core : : NewGrpcPolledFdFactory ( ( * ev_driver ) - > work_serializer ) ; <nl> + ( * ev_driver ) <nl> + - > polled_fd_factory - > ConfigureAresChannelLocked ( ( * ev_driver ) - > channel ) ; <nl> + ( * ev_driver ) - > query_timeout_ms = query_timeout_ms ; <nl> + return GRPC_ERROR_NONE ; <nl> + } <nl> + <nl> static void log_address_sorting_list ( const grpc_ares_request * r , <nl> const ServerAddressList & addresses , <nl> const char * input_output_str ) { <nl> static void on_srv_query_done_locked ( void * arg , int status , int / * timeouts * / , <nl> GRPC_CARES_TRACE_LOG ( " request : % p ares_parse_srv_reply : % d " , r , <nl> parse_status ) ; <nl> if ( parse_status = = ARES_SUCCESS ) { <nl> - ares_channel * channel = <nl> - grpc_ares_ev_driver_get_channel_locked ( r - > ev_driver ) ; <nl> for ( struct ares_srv_reply * srv_it = reply ; srv_it ! = nullptr ; <nl> srv_it = srv_it - > next ) { <nl> if ( grpc_ares_query_ipv6 ( ) ) { <nl> grpc_ares_hostbyname_request * hr = create_hostbyname_request_locked ( <nl> r , srv_it - > host , htons ( srv_it - > port ) , true / * is_balancer * / , <nl> " AAAA " ) ; <nl> - ares_gethostbyname ( * channel , hr - > host , AF_INET6 , <nl> + ares_gethostbyname ( r - > ev_driver - > channel , hr - > host , AF_INET6 , <nl> on_hostbyname_done_locked , hr ) ; <nl> } <nl> grpc_ares_hostbyname_request * hr = create_hostbyname_request_locked ( <nl> r , srv_it - > host , htons ( srv_it - > port ) , true / * is_balancer * / , " A " ) ; <nl> - ares_gethostbyname ( * channel , hr - > host , AF_INET , <nl> + ares_gethostbyname ( r - > ev_driver - > channel , hr - > host , AF_INET , <nl> on_hostbyname_done_locked , hr ) ; <nl> grpc_ares_ev_driver_start_locked ( r - > ev_driver ) ; <nl> } <nl> void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked ( <nl> std : : shared_ptr < grpc_core : : WorkSerializer > work_serializer ) { <nl> grpc_error * error = GRPC_ERROR_NONE ; <nl> grpc_ares_hostbyname_request * hr = nullptr ; <nl> - ares_channel * channel = nullptr ; <nl> / * parse name , splitting it into host and port parts * / <nl> std : : string host ; <nl> std : : string port ; <nl> void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked ( <nl> query_timeout_ms , <nl> std : : move ( work_serializer ) , r ) ; <nl> if ( error ! = GRPC_ERROR_NONE ) goto error_cleanup ; <nl> - channel = grpc_ares_ev_driver_get_channel_locked ( r - > ev_driver ) ; <nl> / / If dns_server is specified , use it . <nl> if ( dns_server ! = nullptr & & dns_server [ 0 ] ! = ' \ 0 ' ) { <nl> GRPC_CARES_TRACE_LOG ( " request : % p Using DNS server % s " , r , dns_server ) ; <nl> void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked ( <nl> GRPC_ERROR_STR_TARGET_ADDRESS , grpc_slice_from_copied_string ( name ) ) ; <nl> goto error_cleanup ; <nl> } <nl> - int status = ares_set_servers_ports ( * channel , & r - > dns_server_addr ) ; <nl> + int status = <nl> + ares_set_servers_ports ( r - > ev_driver - > channel , & r - > dns_server_addr ) ; <nl> if ( status ! = ARES_SUCCESS ) { <nl> error = GRPC_ERROR_CREATE_FROM_COPIED_STRING ( <nl> absl : : StrCat ( " C - ares status is not ARES_SUCCESS : " , <nl> void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked ( <nl> hr = create_hostbyname_request_locked ( r , host . c_str ( ) , <nl> grpc_strhtons ( port . c_str ( ) ) , <nl> / * is_balancer = * / false , " AAAA " ) ; <nl> - ares_gethostbyname ( * channel , hr - > host , AF_INET6 , on_hostbyname_done_locked , <nl> - hr ) ; <nl> + ares_gethostbyname ( r - > ev_driver - > channel , hr - > host , AF_INET6 , <nl> + on_hostbyname_done_locked , hr ) ; <nl> } <nl> hr = create_hostbyname_request_locked ( r , host . c_str ( ) , <nl> grpc_strhtons ( port . c_str ( ) ) , <nl> / * is_balancer = * / false , " A " ) ; <nl> - ares_gethostbyname ( * channel , hr - > host , AF_INET , on_hostbyname_done_locked , <nl> - hr ) ; <nl> + ares_gethostbyname ( r - > ev_driver - > channel , hr - > host , AF_INET , <nl> + on_hostbyname_done_locked , hr ) ; <nl> if ( r - > balancer_addresses_out ! = nullptr ) { <nl> / * Query the SRV record * / <nl> std : : string service_name = absl : : StrCat ( " _grpclb . _tcp . " , host ) ; <nl> GrpcAresQuery * srv_query = new GrpcAresQuery ( r , service_name ) ; <nl> - ares_query ( * channel , service_name . c_str ( ) , ns_c_in , ns_t_srv , <nl> + ares_query ( r - > ev_driver - > channel , service_name . c_str ( ) , ns_c_in , ns_t_srv , <nl> on_srv_query_done_locked , srv_query ) ; <nl> } <nl> if ( r - > service_config_json_out ! = nullptr ) { <nl> std : : string config_name = absl : : StrCat ( " _grpc_config . " , host ) ; <nl> GrpcAresQuery * txt_query = new GrpcAresQuery ( r , config_name ) ; <nl> - ares_search ( * channel , config_name . c_str ( ) , ns_c_in , ns_t_txt , <nl> + ares_search ( r - > ev_driver - > channel , config_name . c_str ( ) , ns_c_in , ns_t_txt , <nl> on_txt_done_locked , txt_query ) ; <nl> } <nl> grpc_ares_ev_driver_start_locked ( r - > ev_driver ) ; <nl> mmm a / src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_wrapper . h <nl> ppp b / src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_wrapper . h <nl> <nl> <nl> # include < grpc / support / port_platform . h > <nl> <nl> + # include < ares . h > <nl> + <nl> # include " src / core / ext / filters / client_channel / server_address . h " <nl> # include " src / core / lib / iomgr / iomgr . h " <nl> # include " src / core / lib / iomgr / polling_entity . h " <nl> bool grpc_ares_query_ipv6 ( ) ; <nl> void grpc_cares_wrapper_address_sorting_sort ( <nl> const grpc_ares_request * request , grpc_core : : ServerAddressList * addresses ) ; <nl> <nl> + / * Exposed in this header for C - core tests only * / <nl> + extern void ( * grpc_ares_test_only_inject_config ) ( ares_channel channel ) ; <nl> + <nl> # endif / * GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H \ <nl> * / <nl> mmm a / src / python / grpcio / grpc_core_dependencies . py <nl> ppp b / src / python / grpcio / grpc_core_dependencies . py <nl> <nl> ' src / core / ext / filters / client_channel / proxy_mapper_registry . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc ' , <nl> - ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc ' , <nl> ' src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_windows . cc ' , <nl> mmm a / test / cpp / naming / resolver_component_test . cc <nl> ppp b / test / cpp / naming / resolver_component_test . cc <nl> <nl> # include " src / core / ext / filters / client_channel / client_channel . h " <nl> # include " src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb_balancer_addresses . h " <nl> # include " src / core / ext / filters / client_channel / resolver . h " <nl> - # include " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h " <nl> # include " src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_wrapper . h " <nl> # include " src / core / ext / filters / client_channel / resolver_registry . h " <nl> # include " src / core / ext / filters / client_channel / server_address . h " <nl> mmm a / tools / doxygen / Doxyfile . c + + . internal <nl> ppp b / tools / doxygen / Doxyfile . c + + . internal <nl> src / core / ext / filters / client_channel / proxy_mapper_registry . h \ <nl> src / core / ext / filters / client_channel / resolver . cc \ <nl> src / core / ext / filters / client_channel / resolver . h \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc \ <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc \ <nl> mmm a / tools / doxygen / Doxyfile . core . internal <nl> ppp b / tools / doxygen / Doxyfile . core . internal <nl> src / core / ext / filters / client_channel / resolver . cc \ <nl> src / core / ext / filters / client_channel / resolver . h \ <nl> src / core / ext / filters / client_channel / resolver / README . md \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / dns_resolver_ares . cc \ <nl> - src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver . h \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_libuv . cc \ <nl> src / core / ext / filters / client_channel / resolver / dns / c_ares / grpc_ares_ev_driver_posix . cc \ <nl>
move grpc_ares_ev_driver and fd_node definitions into grpc_ares_wrapper . cc
grpc/grpc
8215b21dc1f39cd5af294881703a19161e811e7e
2020-12-28T19:51:16Z
mmm a / distros / debian / libopenalpr2 . install <nl> ppp b / distros / debian / libopenalpr2 . install <nl> <nl> usr / lib / lib * . so . * <nl> - usr / etc / openalpr / openalpr . conf etc / openalpr <nl> + etc / openalpr / openalpr . conf etc / openalpr <nl>
Fix a missing file error when building the package
openalpr/openalpr
eb3743dcc990e6eeae56ba300230a8d97a56a58f
2014-12-14T22:17:52Z
new file mode 100644 <nl> index 000000000000 . . 20703e08be56 <nl> mmm / dev / null <nl> ppp b / validation - test / compiler_crashers / 28334 - swift - typechecker - resolvetypewitness . swift <nl> <nl> + / / This source file is part of the Swift . org open source project <nl> + / / Copyright ( c ) 2014 - 2016 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + / / RUN : not - - crash % target - swift - frontend % s - parse <nl> + / / REQUIRES : asserts <nl> + { <nl> + enum S < H : A { <nl> + protocol c { <nl> + { <nl> + } <nl> + class A <nl> + class B : A { <nl> + } } <nl> + } <nl> + protocol A { <nl> + typealias e : A <nl> + typealias d <nl>
[ swiftc ] Add 💥 case ( 😢 → 53 , 😀 → 5091 ) triggered in swift : : TypeChecker : : resolveTypeWitness ( … )
apple/swift
c9fecd5d3cbfe8eb82aaff737e5d7d8fb956edbd
2016-06-28T21:14:14Z
mmm a / dbms / src / DataTypes / NestedUtils . cpp <nl> ppp b / dbms / src / DataTypes / NestedUtils . cpp <nl> void validateArraySizes ( const Block & block ) <nl> { <nl> const auto & elem = block . getByPosition ( i ) ; <nl> <nl> - if ( const DataTypeArray * type_arr = typeid_cast < const DataTypeArray * > ( elem . type . get ( ) ) ) <nl> + if ( isArray ( elem . type ) ) <nl> { <nl> if ( ! typeid_cast < const ColumnArray * > ( elem . column . get ( ) ) ) <nl> throw Exception ( " Column with Array type is not represented by ColumnArray column : " + elem . column - > dumpStructure ( ) , ErrorCodes : : ILLEGAL_COLUMN ) ; <nl>
Fixed build [ # CLICKHOUSE - 3692 ]
ClickHouse/ClickHouse
727ef40a03ef32f9f0e00cc0fbc98641ab3743b1
2018-09-12T22:44:42Z
mmm a / cocos / scripting / javascript / bindings / network / XMLHTTPRequest . cpp <nl> ppp b / cocos / scripting / javascript / bindings / network / XMLHTTPRequest . cpp <nl> void MinXmlHttpRequest : : _setHttpRequestHeader ( ) <nl> * @ param sender Object which initialized callback <nl> * @ param respone Response object <nl> * / <nl> - void MinXmlHttpRequest : : handle_requestResponse ( network : : HttpClient * sender , network : : HttpResponse * response ) <nl> + void MinXmlHttpRequest : : handle_requestResponse ( cocos2d : : network : : HttpClient * sender , cocos2d : : network : : HttpResponse * response ) <nl> { <nl> if ( 0 ! = strlen ( response - > getHttpRequest ( ) - > getTag ( ) ) ) <nl> { <nl> void MinXmlHttpRequest : : handle_requestResponse ( network : : HttpClient * sender , netw <nl> void MinXmlHttpRequest : : _sendRequest ( JSContext * cx ) <nl> { <nl> _httpRequest - > setResponseCallback ( this , httpresponse_selector ( MinXmlHttpRequest : : handle_requestResponse ) ) ; <nl> - network : : HttpClient : : getInstance ( ) - > send ( _httpRequest ) ; <nl> + cocos2d : : network : : HttpClient : : getInstance ( ) - > send ( _httpRequest ) ; <nl> _httpRequest - > release ( ) ; <nl> } <nl> <nl> MinXmlHttpRequest : : MinXmlHttpRequest ( ) <nl> _requestHeader . clear ( ) ; <nl> _withCredentialsValue = true ; <nl> _cx = ScriptingCore : : getInstance ( ) - > getGlobalContext ( ) ; <nl> - _httpRequest = new network : : HttpRequest ( ) ; <nl> + _httpRequest = new cocos2d : : network : : HttpRequest ( ) ; <nl> } <nl> <nl> / * * <nl> JS_BINDED_FUNC_IMPL ( MinXmlHttpRequest , open ) <nl> <nl> if ( _meth . compare ( " post " ) = = 0 | | _meth . compare ( " POST " ) = = 0 ) <nl> { <nl> - _httpRequest - > setRequestType ( network : : HttpRequest : : Type : : POST ) ; <nl> + _httpRequest - > setRequestType ( cocos2d : : network : : HttpRequest : : Type : : POST ) ; <nl> } <nl> else <nl> { <nl> - _httpRequest - > setRequestType ( network : : HttpRequest : : Type : : GET ) ; <nl> + _httpRequest - > setRequestType ( cocos2d : : network : : HttpRequest : : Type : : GET ) ; <nl> } <nl> <nl> _httpRequest - > setUrl ( _url . c_str ( ) ) ; <nl> mmm a / cocos / scripting / javascript / bindings / network / XMLHTTPRequest . h <nl> ppp b / cocos / scripting / javascript / bindings / network / XMLHTTPRequest . h <nl> class MinXmlHttpRequest : public cocos2d : : Object <nl> JS_BINDED_FUNC ( MinXmlHttpRequest , setRequestHeader ) ; <nl> JS_BINDED_FUNC ( MinXmlHttpRequest , overrideMimeType ) ; <nl> <nl> - void handle_requestResponse ( network : : HttpClient * sender , network : : HttpResponse * response ) ; <nl> + void handle_requestResponse ( cocos2d : : network : : HttpClient * sender , cocos2d : : network : : HttpResponse * response ) ; <nl> <nl> <nl> private : <nl> mmm a / cocos / scripting / lua / bindings / Lua_web_socket . h <nl> ppp b / cocos / scripting / lua / bindings / Lua_web_socket . h <nl> extern " C " { <nl> # endif <nl> <nl> # include " network / WebSocket . h " <nl> - class LuaWebSocket : public network : : WebSocket , public network : : WebSocket : : Delegate <nl> + class LuaWebSocket : public cocos2d : : network : : WebSocket , public cocos2d : : network : : WebSocket : : Delegate <nl> { <nl> public : <nl> virtual ~ LuaWebSocket ( ) ; <nl> mmm a / cocos / scripting / lua / bindings / lua_xml_http_request . h <nl> ppp b / cocos / scripting / lua / bindings / lua_xml_http_request . h <nl> class LuaMinXmlHttpRequest : public cocos2d : : Object <nl> LuaMinXmlHttpRequest ( ) ; <nl> ~ LuaMinXmlHttpRequest ( ) ; <nl> <nl> - void handle_requestResponse ( network : : HttpClient * sender , network : : HttpResponse * response ) ; <nl> + void handle_requestResponse ( cocos2d : : network : : HttpClient * sender , cocos2d : : network : : HttpResponse * response ) ; <nl> <nl> inline void setResponseType ( ResponseType type ) { _responseType = type ; } <nl> inline ResponseType getResponseType ( ) { return _responseType ; } <nl> class LuaMinXmlHttpRequest : public cocos2d : : Object <nl> inline void setReadyState ( int readyState ) { _readyState = readyState ; } <nl> inline int getReadyState ( ) { return _readyState ; } <nl> <nl> - inline network : : HttpRequest * getHttpRequest ( ) { return _httpRequest ; } <nl> + inline cocos2d : : network : : HttpRequest * getHttpRequest ( ) { return _httpRequest ; } <nl> inline int getStatus ( ) { return _status ; } <nl> inline std : : string getStatusText ( ) { return _statusText ; } <nl> <nl> class LuaMinXmlHttpRequest : public cocos2d : : Object <nl> ResponseType _responseType ; <nl> unsigned _timeout ; <nl> bool _isAsync ; <nl> - network : : HttpRequest * _httpRequest ; <nl> + cocos2d : : network : : HttpRequest * _httpRequest ; <nl> bool _isNetwork ; <nl> bool _withCredentialsValue ; <nl> std : : map < std : : string , std : : string > _httpHeader ; <nl>
fix compiling errors because of new namespace of network module
cocos2d/cocos2d-x
9124f189c326b9c248714c5dbb0d8150c3a03910
2014-01-02T11:44:46Z
mmm a / tensorflow / python / kernel_tests / decode_jpeg_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / decode_jpeg_op_test . py <nl> def _evalDecodeJpeg ( self , <nl> start_time = time . time ( ) <nl> for _ in xrange ( num_iters ) : <nl> sess . run ( r ) <nl> - return time . time ( ) - start_time <nl> + end_time = time . time ( ) <nl> + return end_time - start_time <nl> <nl> def benchmarkDecodeJpegSmall ( self ) : <nl> " " " Evaluate single DecodeImageOp for small size image . " " " <nl>
Don ' t wait for session . close ( ) to finish when calculating benchmark timing .
tensorflow/tensorflow
cfd9cc499c895135b88e69980a65d215ddb589e9
2018-07-30T20:22:48Z