diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / xbmc / lib / libUPnP / Neptune / Source / System / Bsd / NptBsdNetwork . cpp <nl> ppp b / xbmc / lib / libUPnP / Neptune / Source / System / Bsd / NptBsdNetwork . cpp <nl> NPT_NetworkInterface : : GetNetworkInterfaces ( NPT_List < NPT_NetworkInterface * > & inte <nl> buffer_size + = 256 ; <nl> delete [ ] buffer ; <nl> } <nl> - <nl> + <nl> unsigned char * entries ; <nl> - for ( entries = buffer ; entries < buffer + config . ifc_len ; ) { <nl> + for ( entries = ( unsigned char * ) config . ifc_req ; entries < ( unsigned char * ) config . ifc_req + config . ifc_len ; ) { <nl> struct ifreq * entry = ( struct ifreq * ) entries ; <nl> / / point to the next entry <nl> entries + = IFREQ_SIZE ( entry ) ; <nl> | changed : don ' t assume the list of interfaces starts at the allocated buffer | xbmc/xbmc | f13f20aaa9493d58264c55f2a5b2cafd09435b0e | 2010-09-02T21:27:45Z |
mmm a / README <nl> ppp b / README <nl> @ @ - 1 + 1 @ @ <nl> - RethinkDB key value store . <nl> + An open - source , distributed database system . <nl> | Fixing up readme | rethinkdb/rethinkdb | 0944f5972a9534fc8ec5047e4da45ad6e5791254 | 2012-10-30T06:46:09Z |
mmm a / hphp / runtime / vm / jit / region - tracelet . cpp <nl> ppp b / hphp / runtime / vm / jit / region - tracelet . cpp <nl> bool RegionFormer : : prepareInstruction ( ) { <nl> m_inst . funcd = m_arStates . back ( ) . knownFunc ( ) ; <nl> irgen : : prepareForNextHHBC ( m_hts , & m_inst , m_sk . offset ( ) , false ) ; <nl> <nl> - auto const inputInfos = getInputs ( m_startSk , m_inst ) ; <nl> + auto const inputInfos = getInputs ( m_inst ) ; <nl> <nl> / / Read types for all the inputs and apply MetaData . <nl> auto newDynLoc = [ & ] ( const InputInfo & ii ) { <nl> mmm a / hphp / runtime / vm / jit / translator . cpp <nl> ppp b / hphp / runtime / vm / jit / translator . cpp <nl> static void addMVectorInputs ( NormalizedInstruction & ni , <nl> * Truncate the tracelet at the preceding instruction , which must <nl> * exists because * something * modified something in it . <nl> * / <nl> - static void getInputsImpl ( SrcKey startSk , <nl> - NormalizedInstruction * ni , <nl> + static void getInputsImpl ( NormalizedInstruction * ni , <nl> int & currentStackOffset , <nl> InputInfoVec & inputs ) { <nl> # ifdef USE_TRACE <nl> static void getInputsImpl ( SrcKey startSk , <nl> } <nl> } <nl> <nl> - InputInfoVec getInputs ( SrcKey startSk , NormalizedInstruction & inst ) { <nl> + InputInfoVec getInputs ( NormalizedInstruction & inst ) { <nl> InputInfoVec infos ; <nl> / / MCGenerator expected top of stack to be index - 1 , with indexes growing <nl> / / down from there . hhir defines top of stack to be index 0 , with indexes <nl> / / growing up from there . To compensate we start with a stack offset of 1 and <nl> / / negate the index of any stack input after the call to getInputs . <nl> int stackOff = 1 ; <nl> - getInputsImpl ( startSk , & inst , stackOff , infos ) ; <nl> + getInputsImpl ( & inst , stackOff , infos ) ; <nl> for ( auto & info : infos ) { <nl> if ( info . loc . isStack ( ) ) info . loc . offset = - info . loc . offset ; <nl> } <nl> void translateInstr ( HTS & hts , const NormalizedInstruction & ni ) { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> + / * <nl> + * Emit type and reffiness prediction guards . <nl> + * / <nl> + static void emitPredictionGuards ( HTS & hts , <nl> + const RegionDesc & region , <nl> + const RegionDesc : : BlockPtr block , <nl> + bool useGuards ) { <nl> + auto sk = block - > start ( ) ; <nl> + auto bcOff = sk . offset ( ) ; <nl> + auto typePreds = makeMapWalker ( block - > typePreds ( ) ) ; <nl> + auto refPreds = makeMapWalker ( block - > reffinessPreds ( ) ) ; <nl> + <nl> + if ( useGuards ) irgen : : ringbuffer ( hts , Trace : : RBTypeTraceletGuards , sk ) ; <nl> + <nl> + / / Emit type guards . <nl> + while ( typePreds . hasNext ( sk ) ) { <nl> + auto const & pred = typePreds . next ( ) ; <nl> + auto type = pred . type ; <nl> + auto loc = pred . location ; <nl> + if ( type < = Type : : Cls ) { <nl> + / / Do not generate guards for class ; instead assert the type . <nl> + assert ( loc . tag ( ) = = RegionDesc : : Location : : Tag : : Stack ) ; <nl> + irgen : : assertTypeLocation ( hts , loc , type ) ; <nl> + } else if ( useGuards ) { <nl> + bool checkOuterTypeOnly = mcg - > tx ( ) . mode ( ) ! = TransKind : : Profile ; <nl> + irgen : : guardTypeLocation ( hts , loc , type , checkOuterTypeOnly ) ; <nl> + } else { <nl> + irgen : : checkTypeLocation ( hts , loc , type , bcOff ) ; <nl> + } <nl> + } <nl> + <nl> + / / Emit reffiness guards . <nl> + while ( refPreds . hasNext ( sk ) ) { <nl> + auto const & pred = refPreds . next ( ) ; <nl> + if ( useGuards ) { <nl> + irgen : : guardRefs ( hts , pred . arSpOffset , pred . mask , pred . vals ) ; <nl> + } else { <nl> + irgen : : checkRefs ( hts , pred . arSpOffset , pred . mask , pred . vals , bcOff ) ; <nl> + } <nl> + } <nl> + <nl> + / / Finish emitting guards , and emit profiling counters . <nl> + if ( useGuards ) { <nl> + irgen : : gen ( hts , EndGuards ) ; <nl> + if ( RuntimeOption : : EvalJitTransCounters ) { <nl> + irgen : : incTransCounter ( hts ) ; <nl> + } <nl> + <nl> + if ( mcg - > tx ( ) . mode ( ) = = TransKind : : Profile ) { <nl> + if ( block - > func ( ) - > isEntry ( bcOff ) ) { <nl> + irgen : : checkCold ( hts , mcg - > tx ( ) . profData ( ) - > curTransID ( ) ) ; <nl> + } else { <nl> + irgen : : incProfCounter ( hts , mcg - > tx ( ) . profData ( ) - > curTransID ( ) ) ; <nl> + } <nl> + } <nl> + irgen : : ringbuffer ( hts , Trace : : RBTypeTraceletBody , sk ) ; <nl> + } <nl> + <nl> + / / In the entry block , hhbc - translator gets a chance to emit some code <nl> + / / immediately after the initial guards / checks on the first instruction . <nl> + if ( block = = region . entry ( ) ) { <nl> + switch ( arch ( ) ) { <nl> + case Arch : : X64 : <nl> + irgen : : prepareEntry ( hts ) ; <nl> + break ; <nl> + case Arch : : ARM : <nl> + / / Don ' t do this for ARM , because it can lead to interpOne on the <nl> + / / first SrcKey in a translation , which isn ' t allowed . <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + assert ( ! typePreds . hasNext ( ) ) ; <nl> + assert ( ! refPreds . hasNext ( ) ) ; <nl> + } <nl> + <nl> TranslateResult translateRegion ( HTS & hts , <nl> const RegionDesc & region , <nl> RegionBlacklist & toInterp , <nl> TranslateResult translateRegion ( HTS & hts , <nl> Timer irGenTimer ( Timer : : translateRegion_irGeneration ) ; <nl> auto & blocks = region . blocks ( ) ; <nl> for ( auto b = 0 ; b < blocks . size ( ) ; b + + ) { <nl> - auto const & block = blocks [ b ] ; <nl> - auto const blockId = block - > id ( ) ; <nl> - auto sk = block - > start ( ) ; <nl> - auto typePreds = makeMapWalker ( block - > typePreds ( ) ) ; <nl> - auto byRefs = makeMapWalker ( block - > paramByRefs ( ) ) ; <nl> - auto refPreds = makeMapWalker ( block - > reffinessPreds ( ) ) ; <nl> - auto knownFuncs = makeMapWalker ( block - > knownFuncs ( ) ) ; <nl> - auto skipTrans = false ; <nl> + auto const & block = blocks [ b ] ; <nl> + auto const blockId = block - > id ( ) ; <nl> + auto sk = block - > start ( ) ; <nl> + auto byRefs = makeMapWalker ( block - > paramByRefs ( ) ) ; <nl> + auto knownFuncs = makeMapWalker ( block - > knownFuncs ( ) ) ; <nl> + auto skipTrans = false ; <nl> + auto const lastBlock = b = = blocks . size ( ) - 1 ; <nl> <nl> const Func * topFunc = nullptr ; <nl> TransID profTransId = getTransId ( blockId ) ; <nl> TranslateResult translateRegion ( HTS & hts , <nl> setSuccIRBlocks ( hts , region , blockId , blockIdToIRBlock ) ; <nl> } <nl> <nl> + / / Emit the type and reffiness predictions for this region block . <nl> + / / If this is the first instruction in the region , and the <nl> + / / region ' s entry block is not a loop header , the guards will go <nl> + / / to a retranslate request . Otherwise , they ' ll go to a side <nl> + / / exit . <nl> + auto const useGuards = block = = region . entry ( ) & & ! isLoopHeader ; <nl> + emitPredictionGuards ( hts , region , block , useGuards ) ; <nl> + <nl> for ( unsigned i = 0 ; i < block - > length ( ) ; + + i , sk . advance ( block - > unit ( ) ) ) { <nl> + auto const lastInstr = i = = block - > length ( ) - 1 ; <nl> + <nl> / / Update bcOff here so any guards or assertions from metadata are <nl> / / attributed to this instruction . <nl> irgen : : prepareForNextHHBC ( hts , nullptr , sk . offset ( ) , false ) ; <nl> <nl> - / / Emit prediction guards . If this is the first instruction in the <nl> - / / region , and the region ' s entry block is not a loop header , the guards <nl> - / / will go to a retranslate request . Otherwise , they ' ll go to a side <nl> - / / exit . <nl> - auto const isEntry = block = = region . entry ( ) ; <nl> - auto const useGuards = ( isEntry & & ! isLoopHeader & & i = = 0 ) ; <nl> - if ( useGuards ) irgen : : ringbuffer ( hts , Trace : : RBTypeTraceletGuards , sk ) ; <nl> - <nl> - / / Emit type guards . <nl> - while ( typePreds . hasNext ( sk ) ) { <nl> - auto const & pred = typePreds . next ( ) ; <nl> - auto type = pred . type ; <nl> - auto loc = pred . location ; <nl> - if ( type < = Type : : Cls ) { <nl> - / / Do not generate guards for class ; instead assert the type . <nl> - assert ( loc . tag ( ) = = RegionDesc : : Location : : Tag : : Stack ) ; <nl> - irgen : : assertTypeLocation ( hts , loc , type ) ; <nl> - } else if ( useGuards ) { <nl> - bool checkOuterTypeOnly = mcg - > tx ( ) . mode ( ) ! = TransKind : : Profile ; <nl> - irgen : : guardTypeLocation ( hts , loc , type , checkOuterTypeOnly ) ; <nl> - } else { <nl> - irgen : : checkTypeLocation ( hts , loc , type , sk . offset ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - while ( refPreds . hasNext ( sk ) ) { <nl> - auto const & pred = refPreds . next ( ) ; <nl> - if ( useGuards ) { <nl> - irgen : : guardRefs ( hts , pred . arSpOffset , pred . mask , pred . vals ) ; <nl> - } else { <nl> - irgen : : checkRefs ( hts , pred . arSpOffset , pred . mask , pred . vals , <nl> - sk . offset ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / Finish emitting guards , and emit profiling counters . <nl> - if ( useGuards ) { <nl> - irgen : : gen ( hts , EndGuards ) ; <nl> - if ( RuntimeOption : : EvalJitTransCounters ) { <nl> - irgen : : incTransCounter ( hts ) ; <nl> - } <nl> - <nl> - if ( mcg - > tx ( ) . mode ( ) = = TransKind : : Profile ) { <nl> - if ( block - > func ( ) - > isEntry ( block - > start ( ) . offset ( ) ) ) { <nl> - irgen : : checkCold ( hts , mcg - > tx ( ) . profData ( ) - > curTransID ( ) ) ; <nl> - } else { <nl> - irgen : : incProfCounter ( hts , mcg - > tx ( ) . profData ( ) - > curTransID ( ) ) ; <nl> - } <nl> - } <nl> - irgen : : ringbuffer ( hts , Trace : : RBTypeTraceletBody , sk ) ; <nl> - } <nl> - <nl> - / / In the entry block , hhbc - translator gets a chance to emit some code <nl> - / / immediately after the initial guards / checks on the first instruction . <nl> - if ( isEntry & & i = = 0 ) { <nl> - switch ( arch ( ) ) { <nl> - case Arch : : X64 : <nl> - irgen : : prepareEntry ( hts ) ; <nl> - break ; <nl> - case Arch : : ARM : <nl> - / / Don ' t do this for ARM , because it can lead to interpOne on the <nl> - / / first SrcKey in a translation , which isn ' t allowed . <nl> - break ; <nl> - } <nl> - } <nl> - <nl> / / Update the current funcd , if we have a new one . <nl> if ( knownFuncs . hasNext ( sk ) ) { <nl> topFunc = knownFuncs . next ( ) ; <nl> TranslateResult translateRegion ( HTS & hts , <nl> / / Create and initialize the instruction . <nl> NormalizedInstruction inst ( sk , block - > unit ( ) ) ; <nl> inst . funcd = topFunc ; <nl> - if ( i = = block - > length ( ) - 1 ) { <nl> + if ( lastInstr ) { <nl> inst . endsRegion = region . isExit ( blockId ) ; <nl> inst . nextIsMerge = nextIsMerge ( inst , region ) ; <nl> if ( hts . mode = = IRGenMode : : Trace & & <nl> instrIsNonCallControlFlow ( inst . op ( ) ) & & <nl> - b < blocks . size ( ) - 1 ) { <nl> - inst . nextOffset = blocks [ b + 1 ] - > start ( ) . offset ( ) ; <nl> + ! lastBlock ) { <nl> + inst . nextOffset = blocks [ b + 1 ] - > start ( ) . offset ( ) ; <nl> } <nl> } <nl> <nl> TranslateResult translateRegion ( HTS & hts , <nl> / / this is true . <nl> inst . interp = toInterp . count ( ProfSrcKey { profTransId , sk } ) ; <nl> <nl> - auto const inputInfos = getInputs ( startSk , inst ) ; <nl> + auto const inputInfos = getInputs ( inst ) ; <nl> <nl> - / / Populate the NormalizedInstruction ' s input vector , using types from <nl> - / / HhbcTranslator . <nl> - std : : vector < DynLocation > dynLocs ; <nl> + / / Populate the NormalizedInstruction ' s input vector , using types <nl> + / / from IRBuilder . <nl> + jit : : vector < DynLocation > dynLocs ; <nl> dynLocs . reserve ( inputInfos . size ( ) ) ; <nl> auto newDynLoc = [ & ] ( const InputInfo & ii ) { <nl> - dynLocs . emplace_back ( <nl> - ii . loc , <nl> - irgen : : predictedTypeFromLocation ( hts , ii . loc ) <nl> - ) ; <nl> + dynLocs . emplace_back ( ii . loc , <nl> + irgen : : predictedTypeFromLocation ( hts , ii . loc ) ) ; <nl> FTRACE ( 2 , " predictedTypeFromLocation : { } - > { } \ n " , <nl> ii . loc . pretty ( ) , dynLocs . back ( ) . rtt ) ; <nl> return & dynLocs . back ( ) ; <nl> TranslateResult translateRegion ( HTS & hts , <nl> / / If this block ends with an inlined FCall , we don ' t emit anything for <nl> / / the FCall and instead set up HhbcTranslator for inlining . Blocks from <nl> / / the callee will be next in the region . <nl> - if ( i = = block - > length ( ) - 1 & & <nl> - ( inst . op ( ) = = Op : : FCall | | inst . op ( ) = = Op : : FCallD ) & & <nl> - block - > inlinedCallee ( ) ) { <nl> + if ( lastInstr & & block - > inlinedCallee ( ) ) { <nl> + always_assert ( inst . op ( ) = = Op : : FCall | | inst . op ( ) = = Op : : FCallD ) ; <nl> auto const * callee = block - > inlinedCallee ( ) ; <nl> FTRACE ( 1 , " \ nstarting inlined call from { } to { } with { } args " <nl> " and stack : \ n { } \ n " , <nl> TranslateResult translateRegion ( HTS & hts , <nl> } <nl> <nl> / / . . . and also if this is the end of the block . <nl> - if ( i = = block - > length ( ) - 1 ) return false ; <nl> + if ( lastInstr ) return false ; <nl> <nl> auto nextSK = inst . nextSk ( ) ; <nl> <nl> TranslateResult translateRegion ( HTS & hts , <nl> skipTrans = false ; <nl> <nl> / / In CFG mode , insert a fallthrough jump at the end of each block . <nl> - if ( hts . mode = = IRGenMode : : CFG & & i = = block - > length ( ) - 1 ) { <nl> + if ( hts . mode = = IRGenMode : : CFG & & lastInstr ) { <nl> if ( instrAllowsFallThru ( inst . op ( ) ) ) { <nl> auto nextOffset = inst . offset ( ) + instrLen ( ( Op * ) ( inst . pc ( ) ) ) ; <nl> / / prepareForSideExit is done later in Trace mode , but it <nl> / / needs to happen here or else we generate the SpillStack <nl> / / after the fallthrough jump , which is just weird . <nl> - if ( b < blocks . size ( ) - 1 & & region . isSideExitingBlock ( blockId ) ) { <nl> + if ( ! lastBlock & & region . isSideExitingBlock ( blockId ) ) { <nl> irgen : : prepareForSideExit ( hts ) ; <nl> } <nl> irgen : : endBlock ( hts , nextOffset , inst . nextIsMerge ) ; <nl> - } else if ( b < blocks . size ( ) - 1 & & <nl> + } else if ( ! lastBlock & & <nl> ( isRet ( inst . op ( ) ) | | inst . op ( ) = = OpNativeImpl ) ) { <nl> / / " Fallthrough " from inlined return to the next block <nl> irgen : : endBlock ( hts , blocks [ b + 1 ] - > start ( ) . offset ( ) , <nl> TranslateResult translateRegion ( HTS & hts , <nl> } <nl> <nl> if ( hts . mode = = IRGenMode : : Trace ) { <nl> - if ( b < blocks . size ( ) - 1 & & region . isSideExitingBlock ( blockId ) ) { <nl> + if ( ! lastBlock & & region . isSideExitingBlock ( blockId ) ) { <nl> irgen : : prepareForSideExit ( hts ) ; <nl> } <nl> } <nl> <nl> processedBlocks . insert ( blockId ) ; <nl> <nl> - assert ( ! typePreds . hasNext ( ) ) ; <nl> assert ( ! byRefs . hasNext ( ) ) ; <nl> - assert ( ! refPreds . hasNext ( ) ) ; <nl> assert ( ! knownFuncs . hasNext ( ) ) ; <nl> } <nl> <nl> mmm a / hphp / runtime / vm / jit / translator . h <nl> ppp b / hphp / runtime / vm / jit / translator . h <nl> struct InputInfoVec : public std : : vector < InputInfo > { <nl> / * <nl> * Get input location info and flags for a NormalizedInstruction . Some flags <nl> * on ` ni ' may be updated . <nl> - * <nl> - * ` startSk ' should be the SrcKey for the first instruction in the region <nl> - * containing the instruction . <nl> * / <nl> - InputInfoVec getInputs ( SrcKey startSk , NormalizedInstruction & ) ; <nl> + InputInfoVec getInputs ( NormalizedInstruction & ) ; <nl> <nl> namespace InstrFlags { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> | Move code that emits guards out of translateRegion | facebook/hhvm | 5a46b50d809590b8feeeb05ede056106bcfb12a6 | 2015-01-28T03:37:40Z |
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> matrix : <nl> - compiler : " true 5 " <nl> env : HOST = x86_64 - apple - darwin11 PACKAGES = " gcc - multilib g + + - multilib cmake libcap - dev libz - dev libbz2 - dev " OSX_SDK = 10 . 7 GOAL = " deploy " <nl> - compiler : " true 6 " <nl> - env : HOST = x86_64 - w64 - mingw32 PACKAGES = " nsis gcc - mingw - w64 - x86 - 64 g + + - mingw - w64 - x86 - 64 binutils - mingw - w64 - x86 - 64 mingw - w64 - dev " GOAL = " deploy " <nl> + env : HOST = x86_64 - w64 - mingw32 PACKAGES = " nsis gcc - mingw - w64 - x86 - 64 g + + - mingw - w64 - x86 - 64 binutils - mingw - w64 - x86 - 64 mingw - w64 - dev wine " RUN_TESTS = true GOAL = " deploy " <nl> - compiler : " true 7 " <nl> - env : HOST = i686 - w64 - mingw32 PACKAGES = " nsis gcc - mingw - w64 - i686 g + + - mingw - w64 - i686 binutils - mingw - w64 - i686 mingw - w64 - dev " GOAL = " deploy " <nl> + env : HOST = i686 - w64 - mingw32 PACKAGES = " nsis gcc - mingw - w64 - i686 g + + - mingw - w64 - i686 binutils - mingw - w64 - i686 mingw - w64 - dev wine " RUN_TESTS = true GOAL = " deploy " <nl> install : <nl> - if [ - n " $ PACKAGES " ] ; then travis_retry sudo apt - get update ; fi <nl> - if [ - n " $ PACKAGES " ] ; then travis_retry sudo apt - get install - - no - upgrade - qq $ PACKAGES ; fi <nl> | Merge pull request | bitcoin/bitcoin | a41943df586136e774a68cd381fedffa38980e78 | 2014-10-01T11:21:32Z |
mmm a / include / swift / SILOptimizer / Analysis / Analysis . h <nl> ppp b / include / swift / SILOptimizer / Analysis / Analysis . h <nl> <nl> / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> + # ifndef SWIFT_SILOPTIMIZER_ANALYSIS_ANALYSIS_H <nl> + # define SWIFT_SILOPTIMIZER_ANALYSIS_ANALYSIS_H <nl> + <nl> + # include " swift / SIL / Notifications . h " <nl> # include " llvm / Support / Casting . h " <nl> # include " llvm / ADT / DenseMap . h " <nl> # include " llvm / ADT / DenseSet . h " <nl> # include " llvm / ADT / Optional . h " <nl> # include " llvm / ADT / SmallVector . h " <nl> - # include " swift / SIL / Notifications . h " <nl> # include < vector > <nl> <nl> - # ifndef SWIFT_SILOPTIMIZER_ANALYSIS_ANALYSIS_H <nl> - # define SWIFT_SILOPTIMIZER_ANALYSIS_ANALYSIS_H <nl> - <nl> namespace swift { <nl> class SILModule ; <nl> class SILFunction ; <nl> | Move the include guard of Analysis . h / above / the includes . | apple/swift | 6b54531455c7898b54a8d59c5e3b6a1b472a34c1 | 2017-08-11T21:40:36Z |
mmm a / db / cmdline . cpp <nl> ppp b / db / cmdline . cpp <nl> namespace mongo { <nl> ( " remove " , " remove mongodb service " ) <nl> ( " reinstall " , " reinstall mongodb service ( equivilant of mongod - - remove followed by mongod - - install ) " ) <nl> ( " serviceName " , po : : value < string > ( ) , " windows service name " ) <nl> + ( " serviceDisplayName " , po : : value < string > ( ) , " windows service display name " ) <nl> + ( " serviceDescription " , po : : value < string > ( ) , " windows service description " ) <nl> ( " serviceUser " , po : : value < string > ( ) , " user name service executes as " ) <nl> ( " servicePassword " , po : : value < string > ( ) , " password used to authenticate serviceUser " ) <nl> ; <nl> mmm a / util / ntservice . cpp <nl> ppp b / util / ntservice . cpp <nl> namespace mongo { <nl> bool startService = false ; <nl> <nl> std : : wstring windowsServiceName = L " MongoDB " ; <nl> + std : : wstring windowsServiceDisplayName = L " Mongo DB " ; <nl> + std : : wstring windowsServiceDescription = L " Mongo DB Server " ; <nl> std : : wstring windowsServiceUser = L " " ; <nl> std : : wstring windowsServicePassword = L " " ; <nl> <nl> namespace mongo { <nl> windowsServiceName [ i ] = x [ i ] ; <nl> } <nl> } <nl> + if ( params . count ( " serviceDisplayName " ) ) { <nl> + string x = params [ " serviceDisplayName " ] . as < string > ( ) ; <nl> + windowsServiceDisplayName = wstring ( x . size ( ) , L ' ' ) ; <nl> + for ( size_t i = 0 ; i < x . size ( ) ; i + + ) { <nl> + windowsServiceDisplayName [ i ] = x [ i ] ; <nl> + } <nl> + } <nl> + if ( params . count ( " serviceDescription " ) ) { <nl> + string x = params [ " serviceDescription " ] . as < string > ( ) ; <nl> + windowsServiceDescription = wstring ( x . size ( ) , L ' ' ) ; <nl> + for ( size_t i = 0 ; i < x . size ( ) ; i + + ) { <nl> + windowsServiceDescription [ i ] = x [ i ] ; <nl> + } <nl> + } <nl> if ( params . count ( " serviceUser " ) ) { <nl> string x = params [ " serviceUser " ] . as < string > ( ) ; <nl> windowsServiceUser = wstring ( x . size ( ) , L ' ' ) ; <nl> namespace mongo { <nl> ServiceController : : removeService ( windowsServiceName ) ; <nl> } <nl> if ( installService | | reinstallService ) { <nl> - if ( ! ServiceController : : installService ( windowsServiceName , L " Mongo DB " , L " Mongo DB Server " , windowsServiceUser , windowsServicePassword , dbpath , argc , argv ) ) <nl> + if ( ! ServiceController : : installService ( windowsServiceName , windowsServiceDisplayName , windowsServiceDescription , windowsServiceUser , windowsServicePassword , dbpath , argc , argv ) ) <nl> dbexit ( EXIT_NTSERVICE_ERROR ) ; <nl> dbexit ( EXIT_CLEAN ) ; <nl> } <nl> | SERVER - 1590 Add - - serviceDisplayName and - - serviceDescription options to mongod / mongos on windows . | mongodb/mongo | 2735160f15fa448e79e317b1ba6bdba7b8109765 | 2010-09-24T20:05:17Z |
mmm a / src / wasm / module - compiler . cc <nl> ppp b / src / wasm / module - compiler . cc <nl> void CompilationState : : RestartBackgroundTasks ( size_t max ) { <nl> size_t num_restart ; <nl> { <nl> base : : LockGuard < base : : Mutex > guard ( & mutex_ ) ; <nl> + / / No need to restart tasks if compilation already failed . <nl> + if ( failed_ ) return ; <nl> + <nl> bool should_increase_workload = allocated_memory_ < = max_memory_ / 2 ; <nl> if ( ! should_increase_workload ) return ; <nl> DCHECK_LE ( num_background_tasks_ , max_background_tasks_ ) ; <nl> | [ wasm ] Do not restart compilation tasks after compilation failed | v8/v8 | 2301ffe71ab0655ee91850f3518cadc2e1c834a5 | 2018-05-29T19:34:43Z |
mmm a / language / English / strings . po <nl> ppp b / language / English / strings . po <nl> msgctxt " # 19278 " <nl> msgid " Recording error " <nl> msgstr " " <nl> <nl> - # empty strings from id 19279 to 19498 <nl> + # : xbmc / settings / GUISettings . cpp <nl> + msgctxt " # 19279 " <nl> + msgid " Client specific " <nl> + msgstr " " <nl> + <nl> + # : xbmc / settings / GUISettings . cpp <nl> + msgctxt " # 19280 " <nl> + msgid " Client specific settings " <nl> + msgstr " " <nl> + <nl> + # empty strings from id 19281 to 19498 <nl> <nl> msgctxt " # 19499 " <nl> msgid " Other / Unknown " <nl> mmm a / xbmc / settings / GUISettings . cpp <nl> ppp b / xbmc / settings / GUISettings . cpp <nl> void CGUISettings : : Initialize ( ) <nl> AddSeparator ( pvrpa , " pvrparental . sep1 " ) ; <nl> AddString ( pvrpa , " pvrparental . pin " , 19261 , " " , EDIT_CONTROL_HIDDEN_NUMBER_VERIFY_NEW , true ) ; <nl> AddInt ( pvrpa , " pvrparental . duration " , 19260 , 300 , 5 , 5 , 1200 , SPIN_CONTROL_INT_PLUS , MASK_SECS ) ; <nl> + <nl> + CSettingsCategory * pvrc = AddCategory ( SETTINGS_PVR , " pvrclient " , 19279 ) ; <nl> + AddString ( pvrc , " pvrclient . menuhook " , 19280 , " " , BUTTON_CONTROL_STANDARD ) ; <nl> } <nl> <nl> CGUISettings : : ~ CGUISettings ( void ) <nl> mmm a / xbmc / settings / GUIWindowSettingsCategory . cpp <nl> ppp b / xbmc / settings / GUIWindowSettingsCategory . cpp <nl> void CGUIWindowSettingsCategory : : OnSettingChanged ( CBaseSettingControl * pSettingC <nl> dialog - > DoModal ( ) ; <nl> } <nl> } <nl> + else if ( strSetting . Equals ( " pvrclient . menuhook " ) & & g_PVRManager . IsStarted ( ) ) <nl> + { <nl> + g_PVRManager . Get ( ) . Clients ( ) - > ProcessMenuHooks ( - 1 , PVR_MENUHOOK_SETTING ) ; <nl> + } <nl> else if ( strSetting . compare ( 0 , 12 , " audiooutput . " ) = = 0 ) <nl> { <nl> if ( strSetting . Equals ( " audiooutput . audiodevice " ) ) <nl> | pvr : add menu hook to pvr settings | xbmc/xbmc | 7002e666afae9bc81471f1a80a168eebd0bcfc73 | 2012-11-10T00:13:20Z |
new file mode 100644 <nl> index 00000000000 . . 7e619bc79c1 <nl> mmm / dev / null <nl> ppp b / arangod / Cluster / ClusterComm . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Library for intra - cluster communications <nl> + / / / <nl> + / / / @ file ClusterComm . cpp <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2013 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 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Max Neunhoeffer <nl> + / / / @ author Copyright 2013 , triagens GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include < arangod / Cluster / ClusterComm . h > <nl> + <nl> + using namespace triagens : : arango ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> + <nl> + <nl> new file mode 100644 <nl> index 00000000000 . . decba862489 <nl> mmm / dev / null <nl> ppp b / arangod / Cluster / ClusterComm . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Library for intra - cluster communications <nl> + / / / <nl> + / / / @ file ClusterComm . h <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2013 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 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Max Neunhoeffer <nl> + / / / @ author Copyright 2013 , triagens GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef TRIAGENS_CLUSTER_COMM_H <nl> + # define TRIAGENS_CLUSTER_COMM_H 1 <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Basics / ReadWriteLock . h " <nl> + # include " Rest / HttpRequest . h " <nl> + <nl> + # ifdef __cplusplus <nl> + extern " C " { <nl> + # endif <nl> + <nl> + namespace triagens { <nl> + namespace arango { <nl> + <nl> + typedef string ClientTID ; <nl> + typedef string CoordTID ; <nl> + typedef int32_t OpID ; <nl> + typedef string ShardID ; <nl> + typedef string ServerID ; <nl> + <nl> + class ClusterCommResult { <nl> + OpID opID ; <nl> + / / All the stuff from the HTTP request result <nl> + <nl> + } ; <nl> + <nl> + class ClusterCommCallback { <nl> + / / The idea is that one inherits from this class and implements <nl> + / / the callback . <nl> + <nl> + ClusterCommCallback ( ) ; <nl> + ~ ClusterCommCallback ( ) ; <nl> + <nl> + / / Result indicates whether or not the returned result shall be queued <nl> + virtual bool operator ( ) ( ClusterCommResult * ) ; <nl> + } ; <nl> + <nl> + typedef uint64_t ClusterCommTimeout ; / / in microseconds <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - ClusterComm <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + class ClusterComm { <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - constructors and destructors <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + public : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief initialises library <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + ClusterComm ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief shuts down library <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + ~ ClusterComm ( ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - public methods <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief produces an operation ID which is unique in this process <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + OpID getOpID ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief submit an HTTP request to a shard synchronously <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int request ( const ClientTID & clientTID , <nl> + const CoordTID & coordTID , <nl> + const OpID & opID , <nl> + const ShardID & shardID , <nl> + rest : : HttpRequest : : HttpRequestType reqtype , <nl> + const string & path , <nl> + const char * body , <nl> + size_t bodyLength , <nl> + const map < string , string > & headerFields , <nl> + ClusterCommCallback * callback , <nl> + ClusterCommTimeout & timeout ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief poll one answer for a given opID <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + ClusterCommResult * poll ( const ClientTID & clientTID , <nl> + const CoordTID & coordTID , <nl> + const OpID & opID , <nl> + const ShardID & shardID , <nl> + bool blocking = false , <nl> + ClusterCommTimeout timeout = 0 ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief poll many answers for some given opIDs <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + vector < ClusterCommResult * > multipoll ( <nl> + const ClientTID & clientTID , <nl> + const CoordTID & coordTID , <nl> + const OpID & opID , <nl> + const ShardID & shardID , <nl> + int maxanswers = 0 , <nl> + bool blocking = false , <nl> + ClusterCommTimeout timeout = 0 ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief ignore and drop current and future answers <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void drop ( const ClientTID & clientTID , <nl> + const CoordTID & coordTID , <nl> + const OpID & opID , <nl> + const ShardID & shardID ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief send an answer HTTP request to a coordinator <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int answer ( rest : : HttpRequest & request , <nl> + rest : : HttpRequest : : HttpRequestType reqtype , <nl> + const string & path , <nl> + const char * body , <nl> + size_t bodyLength , <nl> + const map < string , string > & headerFields , <nl> + ClusterCommTimeout & timeout ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - private data <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + private : <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief process global last used operation ID <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + static OpID _lastUsedOpID ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief global lock to protect _lastUsedOpID <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + static triagens : : basics : : ReadWriteLock _lock ; <nl> + <nl> + } ; / / end of class ClusterComm <nl> + <nl> + } / / namespace arango <nl> + } / / namespace triagens <nl> + <nl> + # ifdef __cplusplus <nl> + } <nl> + # endif <nl> + <nl> + # endif <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> + <nl> + <nl> | Very first incomplete draft of ClusterComm . | arangodb/arangodb | e4cebe053642ca8373b8b99d173f53f61e98c908 | 2013-12-11T15:48:43Z |
mmm a / plugins / state_history_plugin / include / eosio / state_history_plugin / state_history_plugin . hpp <nl> ppp b / plugins / state_history_plugin / include / eosio / state_history_plugin / state_history_plugin . hpp <nl> struct table_delta { <nl> struct get_status_request_v0 { } ; <nl> <nl> struct get_status_result_v0 { <nl> + uint32_t head_block_num = 0 ; <nl> + chain : : block_id_type head_block_id = { } ; <nl> uint32_t last_irreversible_block_num = 0 ; <nl> chain : : block_id_type last_irreversible_block_id = { } ; <nl> - uint32_t state_begin_block_num = 0 ; <nl> - uint32_t state_end_block_num = 0 ; <nl> + uint32_t block_state_begin_block = 0 ; <nl> + uint32_t block_state_end_block = 0 ; <nl> + uint32_t trace_begin_block = 0 ; <nl> + uint32_t trace_end_block = 0 ; <nl> + uint32_t chain_state_begin_block = 0 ; <nl> + uint32_t chain_state_end_block = 0 ; <nl> } ; <nl> <nl> struct get_block_request_v0 { <nl> class state_history_plugin : public plugin < state_history_plugin > { <nl> <nl> FC_REFLECT ( eosio : : table_delta , ( struct_version ) ( name ) ( rows ) ) ; <nl> FC_REFLECT_EMPTY ( eosio : : get_status_request_v0 ) ; <nl> - FC_REFLECT ( eosio : : get_status_result_v0 , <nl> - ( last_irreversible_block_num ) ( last_irreversible_block_id ) ( state_begin_block_num ) ( state_end_block_num ) ) ; <nl> + FC_REFLECT ( <nl> + eosio : : get_status_result_v0 , <nl> + ( head_block_num ) ( head_block_id ) ( last_irreversible_block_num ) ( last_irreversible_block_id ) ( block_state_begin_block ) ( <nl> + block_state_end_block ) ( trace_begin_block ) ( trace_end_block ) ( chain_state_begin_block ) ( chain_state_end_block ) ) ; <nl> FC_REFLECT ( eosio : : get_block_request_v0 , ( block_num ) ) ; <nl> FC_REFLECT ( eosio : : get_block_result_v0 , ( block_num ) ( block ) ( block_state ) ( traces ) ( deltas ) ) ; <nl> mmm a / plugins / state_history_plugin / include / eosio / state_history_plugin / state_history_serialization . hpp <nl> ppp b / plugins / state_history_plugin / include / eosio / state_history_plugin / state_history_serialization . hpp <nl> datastream < ST > & operator < < ( datastream < ST > & ds , const history_serial_wrapper < eosi <nl> <nl> template < typename ST > <nl> datastream < ST > & operator < < ( datastream < ST > & ds , const history_serial_wrapper < eosio : : chain : : permission_level > & obj ) { <nl> - fc : : raw : : pack ( ds , fc : : unsigned_int ( 0 ) ) ; <nl> fc : : raw : : pack ( ds , as_type < uint64_t > ( obj . obj . actor . value ) ) ; <nl> fc : : raw : : pack ( ds , as_type < uint64_t > ( obj . obj . permission . value ) ) ; <nl> return ds ; <nl> datastream < ST > & operator < < ( datastream < ST > & ds , const history_serial_wrapper < eosi <nl> template < typename ST > <nl> datastream < ST > & operator < < ( datastream < ST > & ds , <nl> const history_serial_wrapper < eosio : : chain : : permission_level_weight > & obj ) { <nl> - fc : : raw : : pack ( ds , fc : : unsigned_int ( 0 ) ) ; <nl> fc : : raw : : pack ( ds , make_history_serial_wrapper ( as_type < eosio : : chain : : permission_level > ( obj . obj . permission ) ) ) ; <nl> fc : : raw : : pack ( ds , as_type < uint16_t > ( obj . obj . weight ) ) ; <nl> return ds ; <nl> operator < < ( datastream < ST > & <nl> <nl> template < typename ST > <nl> datastream < ST > & operator < < ( datastream < ST > & ds , const history_serial_wrapper < eosio : : chain : : action > & obj ) { <nl> - fc : : raw : : pack ( ds , fc : : unsigned_int ( 0 ) ) ; <nl> fc : : raw : : pack ( ds , as_type < uint64_t > ( obj . obj . account . value ) ) ; <nl> fc : : raw : : pack ( ds , as_type < uint64_t > ( obj . obj . name . value ) ) ; <nl> history_serialize_container ( ds , as_type < std : : vector < eosio : : chain : : permission_level > > ( obj . obj . authorization ) ) ; <nl> mmm a / plugins / state_history_plugin / state_history_plugin . cpp <nl> ppp b / plugins / state_history_plugin / state_history_plugin . cpp <nl> struct state_history_plugin_impl : std : : enable_shared_from_this < state_history_pl <nl> void operator ( ) ( get_status_request_v0 & ) { <nl> auto & chain = plugin - > chain_plug - > chain ( ) ; <nl> get_status_result_v0 result ; <nl> + result . head_block_num = chain . head_block_num ( ) ; <nl> + result . head_block_id = chain . head_block_id ( ) ; <nl> result . last_irreversible_block_num = chain . last_irreversible_block_num ( ) ; <nl> result . last_irreversible_block_id = chain . last_irreversible_block_id ( ) ; <nl> - result . state_begin_block_num = plugin - > chain_state_log . begin_block ( ) ; <nl> - result . state_end_block_num = plugin - > chain_state_log . end_block ( ) ; <nl> + result . block_state_begin_block = plugin - > block_state_log . begin_block ( ) ; <nl> + result . block_state_end_block = plugin - > block_state_log . end_block ( ) ; <nl> + result . trace_begin_block = plugin - > trace_log . begin_block ( ) ; <nl> + result . trace_end_block = plugin - > trace_log . end_block ( ) ; <nl> + result . chain_state_begin_block = plugin - > chain_state_log . begin_block ( ) ; <nl> + result . chain_state_end_block = plugin - > chain_state_log . end_block ( ) ; <nl> send ( std : : move ( result ) ) ; <nl> } <nl> <nl> mmm a / plugins / state_history_plugin / state_history_plugin_abi . cpp <nl> ppp b / plugins / state_history_plugin / state_history_plugin_abi . cpp <nl> extern const char * const state_history_plugin_abi = R " ( { <nl> } , <nl> { <nl> " name " : " get_status_result_v0 " , " fields " : [ <nl> + { " name " : " head_block_num " , " type " : " uint32 " } , <nl> + { " name " : " head_block_id " , " type " : " checksum256 " } , <nl> { " name " : " last_irreversible_block_num " , " type " : " uint32 " } , <nl> { " name " : " last_irreversible_block_id " , " type " : " checksum256 " } , <nl> - { " name " : " state_begin_block_num " , " type " : " uint32 " } , <nl> - { " name " : " state_end_block_num " , " type " : " uint32 " } <nl> + { " name " : " block_state_begin_block " , " type " : " uint32 " } , <nl> + { " name " : " block_state_end_block " , " type " : " uint32 " } , <nl> + { " name " : " trace_begin_block " , " type " : " uint32 " } , <nl> + { " name " : " trace_end_block " , " type " : " uint32 " } , <nl> + { " name " : " chain_state_begin_block " , " type " : " uint32 " } , <nl> + { " name " : " chain_state_end_block " , " type " : " uint32 " } <nl> ] <nl> } , <nl> { <nl> extern const char * const state_history_plugin_abi = R " ( { <nl> ] <nl> } , <nl> { <nl> - " name " : " action_v0 " , " fields " : [ <nl> + " name " : " action " , " fields " : [ <nl> { " name " : " account " , " type " : " name " } , <nl> { " name " : " name " , " type " : " name " } , <nl> { " name " : " authorization " , " type " : " permission_level [ ] " } , <nl> extern const char * const state_history_plugin_abi = R " ( { <nl> " name " : " action_trace_v0 " , " fields " : [ <nl> { " name " : " receipt " , " type " : " action_receipt " } , <nl> { " name " : " act " , " type " : " action " } , <nl> - <nl> { " name " : " context_free " , " type " : " bool " } , <nl> { " name " : " elapsed " , " type " : " int64 " } , <nl> { " name " : " console " , " type " : " string " } , <nl> extern const char * const state_history_plugin_abi = R " ( { <nl> " name " : " block_header " , " fields " : [ <nl> { " name " : " timestamp " , " type " : " block_timestamp_type " } , <nl> { " name " : " producer " , " type " : " name " } , <nl> - { " name " : " confirmed ; " , " type " : " uint16 " } , <nl> + { " name " : " confirmed " , " type " : " uint16 " } , <nl> { " name " : " previous " , " type " : " checksum256 " } , <nl> { " name " : " transaction_mroot " , " type " : " checksum256 " } , <nl> { " name " : " action_mroot " , " type " : " checksum256 " } , <nl> extern const char * const state_history_plugin_abi = R " ( { <nl> { " name " : " block_extensions " , " type " : " extension [ ] " } <nl> ] <nl> } , <nl> + { " name " : " transaction_header " , " fields " : [ <nl> + { " name " : " expiration " , " type " : " time_point_sec " } , <nl> + { " name " : " ref_block_num " , " type " : " uint16 " } , <nl> + { " name " : " ref_block_prefix " , " type " : " uint32 " } , <nl> + { " name " : " max_net_usage_words " , " type " : " varuint32 " } , <nl> + { " name " : " max_cpu_usage_ms " , " type " : " uint8 " } , <nl> + { " name " : " delay_sec " , " type " : " varuint32 " } <nl> + ] <nl> + } , <nl> + { " name " : " transaction " , " base " : " transaction_header " , " fields " : [ <nl> + { " name " : " context_free_actions " , " type " : " action [ ] " } , <nl> + { " name " : " actions " , " type " : " action [ ] " } , <nl> + { " name " : " transaction_extensions " , " type " : " extension [ ] " } <nl> + ] <nl> + } , <nl> { <nl> " name " : " account_v0 " , " fields " : [ <nl> { " type " : " name " , " name " : " name " } , <nl> extern const char * const state_history_plugin_abi = R " ( { <nl> ] <nl> } , <nl> { <nl> - " name " : " permission_level_v0 " , " fields " : [ <nl> + " name " : " permission_level " , " fields " : [ <nl> { " type " : " name " , " name " : " actor " } , <nl> { " type " : " name " , " name " : " permission " } <nl> ] <nl> } , <nl> { <nl> - " name " : " permission_level_weight_v0 " , " fields " : [ <nl> + " name " : " permission_level_weight " , " fields " : [ <nl> { " type " : " permission_level " , " name " : " permission " } , <nl> { " type " : " uint16 " , " name " : " weight " } <nl> ] <nl> extern const char * const state_history_plugin_abi = R " ( { <nl> { " name " : " request " , " types " : [ " get_status_request_v0 " , " get_block_request_v0 " ] } , <nl> { " name " : " result " , " types " : [ " get_status_result_v0 " , " get_block_result_v0 " ] } , <nl> <nl> - { " name " : " action " , " types " : [ " action_v0 " ] } , <nl> { " name " : " action_receipt " , " types " : [ " action_receipt_v0 " ] } , <nl> { " name " : " action_trace " , " types " : [ " action_trace_v0 " ] } , <nl> { " name " : " transaction_trace " , " types " : [ " transaction_trace_v0 " ] } , <nl> extern const char * const state_history_plugin_abi = R " ( { <nl> { " name " : " global_property " , " types " : [ " global_property_v0 " ] } , <nl> { " name " : " generated_transaction " , " types " : [ " generated_transaction_v0 " ] } , <nl> { " name " : " key_weight " , " types " : [ " key_weight_v0 " ] } , <nl> - { " name " : " permission_level " , " types " : [ " permission_level_v0 " ] } , <nl> - { " name " : " permission_level_weight " , " types " : [ " permission_level_weight_v0 " ] } , <nl> { " name " : " wait_weight " , " types " : [ " wait_weight_v0 " ] } , <nl> { " name " : " shared_authority " , " types " : [ " shared_authority_v0 " ] } , <nl> { " name " : " permission " , " types " : [ " permission_v0 " ] } , <nl> | state history plugin | EOSIO/eos | 036c4563809dc291af9207936451bef1dcf61d35 | 2018-10-12T19:14:51Z |
mmm a / src / mongo / base / error_codes . err <nl> ppp b / src / mongo / base / error_codes . err <nl> error_code ( " IndexNotFound " , 27 ) <nl> error_code ( " PathNotViable " , 28 ) <nl> error_code ( " NonExistentPath " , 29 ) <nl> error_code ( " InvalidPath " , 30 ) <nl> + error_code ( " RoleNotFound " , 31 ) <nl> + error_code ( " RolesNotRelated " , 32 ) <nl> + error_code ( " PrivilegeNotFound " , 33 ) <nl> <nl> error_class ( " NetworkError " , [ " HostUnreachable " , " HostNotFound " ] ) <nl> mmm a / src / mongo / db / auth / SConscript <nl> ppp b / src / mongo / db / auth / SConscript <nl> env . StaticLibrary ( ' authcore ' , [ ' action_set . cpp ' , <nl> ' action_type . cpp ' , <nl> ' auth_external_state . cpp ' , <nl> ' authorization_manager . cpp ' , <nl> + ' role_graph . cpp ' , <nl> + ' role_name . cpp ' , <nl> ' principal . cpp ' , <nl> ' principal_name . cpp ' , <nl> ' principal_set . cpp ' , <nl> env . StaticLibrary ( ' authmongos ' , <nl> env . CppUnitTest ( ' action_set_test ' , ' action_set_test . cpp ' , LIBDEPS = [ ' authcore ' ] ) <nl> env . CppUnitTest ( ' principal_set_test ' , ' principal_set_test . cpp ' , LIBDEPS = [ ' authcore ' ] ) <nl> env . CppUnitTest ( ' privilege_set_test ' , ' privilege_set_test . cpp ' , LIBDEPS = [ ' authcore ' ] ) <nl> + env . CppUnitTest ( ' role_graph_test ' , ' role_graph_test . cpp ' , LIBDEPS = [ ' authcore ' ] ) <nl> env . CppUnitTest ( ' authorization_manager_test ' , ' authorization_manager_test . cpp ' , <nl> LIBDEPS = [ ' authcore ' ] ) <nl> mmm a / src / mongo / db / auth / action_set . h <nl> ppp b / src / mongo / db / auth / action_set . h <nl> namespace mongo { <nl> <nl> bool empty ( ) const { return _actions . none ( ) ; } <nl> <nl> + bool equals ( const ActionSet & other ) const { return this - > _actions = = other . _actions ; } <nl> + <nl> bool contains ( const ActionType & action ) const ; <nl> <nl> / / Returns true only if this ActionSet contains all the actions present in the ' other ' <nl> namespace mongo { <nl> std : : bitset < ActionType : : NUM_ACTION_TYPES > _actions ; <nl> } ; <nl> <nl> + static inline bool operator = = ( const ActionSet & lhs , const ActionSet & rhs ) { <nl> + return lhs . equals ( rhs ) ; <nl> + } <nl> + <nl> } / / namespace mongo <nl> mmm a / src / mongo / db / auth / principal_name . h <nl> ppp b / src / mongo / db / auth / principal_name . h <nl> <nl> # include < string > <nl> <nl> # include " mongo / base / string_data . h " <nl> + # include " mongo / platform / hash_namespace . h " <nl> <nl> namespace mongo { <nl> <nl> namespace mongo { <nl> } <nl> <nl> } / / namespace mongo <nl> + <nl> + / / Define hash function for PrincipalNames so they can be keys in std : : unordered_map <nl> + MONGO_HASH_NAMESPACE_START <nl> + template < > struct hash < mongo : : PrincipalName > { <nl> + size_t operator ( ) ( const mongo : : PrincipalName & pname ) const { <nl> + return hash < const std : : string & > ( ) ( pname . getFullName ( ) ) ; <nl> + } <nl> + } ; <nl> + MONGO_HASH_NAMESPACE_END <nl> mmm a / src / mongo / db / auth / privilege . cpp <nl> ppp b / src / mongo / db / auth / privilege . cpp <nl> namespace mongo { <nl> Privilege : : Privilege ( const std : : string & resource , const ActionSet & actions ) : <nl> _resource ( resource ) , _actions ( actions ) { } <nl> <nl> + void Privilege : : addActions ( const ActionSet & actionsToAdd ) { <nl> + _actions . addAllActionsFromSet ( actionsToAdd ) ; <nl> + } <nl> + <nl> + void Privilege : : removeActions ( const ActionSet & actionsToRemove ) { <nl> + _actions . removeAllActionsFromSet ( actionsToRemove ) ; <nl> + } <nl> + <nl> bool Privilege : : includesAction ( const ActionType & action ) const { <nl> return _actions . contains ( action ) ; <nl> } <nl> mmm a / src / mongo / db / auth / privilege . h <nl> ppp b / src / mongo / db / auth / privilege . h <nl> <nl> # pragma once <nl> <nl> # include < string > <nl> + # include < vector > <nl> <nl> # include " mongo / db / auth / action_set . h " <nl> # include " mongo / db / auth / action_type . h " <nl> namespace mongo { <nl> <nl> const ActionSet & getActions ( ) const { return _actions ; } <nl> <nl> + void addActions ( const ActionSet & actionsToAdd ) ; <nl> + void removeActions ( const ActionSet & actionsToRemove ) ; <nl> + <nl> / / Checks if the given action is present in the Privilege . <nl> bool includesAction ( const ActionType & action ) const ; <nl> / / Checks if the given actions are present in the Privilege . <nl> namespace mongo { <nl> ActionSet _actions ; / / bitmask of actions this privilege grants <nl> } ; <nl> <nl> + typedef std : : vector < Privilege > PrivilegeVector ; <nl> + <nl> } / / namespace mongo <nl> new file mode 100644 <nl> index 000000000000 . . da4c69283c7d <nl> mmm / dev / null <nl> ppp b / src / mongo / db / auth / role_graph . cpp <nl> <nl> + / * * <nl> + * Copyright ( C ) 2013 10gen Inc . <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU Affero General Public License , version 3 , <nl> + * as published by the Free Software Foundation . <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 Affero General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU Affero General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * / <nl> + <nl> + # include " mongo / db / auth / role_graph . h " <nl> + <nl> + # include < algorithm > <nl> + <nl> + # include " mongo / db / auth / privilege . h " <nl> + # include " mongo / db / auth / role_name . h " <nl> + # include " mongo / platform / unordered_set . h " <nl> + # include " mongo / util / mongoutils / str . h " <nl> + <nl> + namespace mongo { <nl> + <nl> + namespace { <nl> + PrivilegeVector emptyPrivilegeVector ; <nl> + <nl> + class RoleNameSetIterator : public RoleNameIterator : : Impl { <nl> + MONGO_DISALLOW_COPYING ( RoleNameSetIterator ) ; <nl> + <nl> + public : <nl> + RoleNameSetIterator ( unordered_set < RoleName > : : const_iterator begin , <nl> + unordered_set < RoleName > : : const_iterator end ) : <nl> + _begin ( begin ) , _end ( end ) { } <nl> + <nl> + virtual ~ RoleNameSetIterator ( ) { } ; <nl> + <nl> + virtual bool more ( ) const { <nl> + return _begin ! = _end ; <nl> + } <nl> + <nl> + virtual const RoleName & next ( ) { <nl> + const RoleName & toReturn = get ( ) ; <nl> + + + _begin ; <nl> + return toReturn ; <nl> + } <nl> + <nl> + virtual const RoleName & get ( ) const { <nl> + return * _begin ; <nl> + } <nl> + <nl> + private : <nl> + virtual Impl * doClone ( ) const { <nl> + return new RoleNameSetIterator ( _begin , _end ) ; <nl> + } <nl> + <nl> + unordered_set < RoleName > : : const_iterator _begin ; <nl> + unordered_set < RoleName > : : const_iterator _end ; <nl> + } ; <nl> + } / / namespace <nl> + <nl> + RoleGraph : : RoleGraph ( ) { } ; <nl> + RoleGraph : : RoleGraph ( const RoleGraph & other ) : _roleToSubordinates ( other . _roleToSubordinates ) , <nl> + _roleToMembers ( other . _roleToMembers ) , <nl> + _directPrivilegesForRole ( other . _directPrivilegesForRole ) , <nl> + _allPrivilegesForRole ( other . _allPrivilegesForRole ) { } <nl> + RoleGraph : : ~ RoleGraph ( ) { } ; <nl> + <nl> + void RoleGraph : : swap ( RoleGraph & other ) { <nl> + using std : : swap ; <nl> + swap ( this - > _roleToSubordinates , other . _roleToSubordinates ) ; <nl> + swap ( this - > _roleToMembers , other . _roleToMembers ) ; <nl> + swap ( this - > _directPrivilegesForRole , other . _directPrivilegesForRole ) ; <nl> + swap ( this - > _allPrivilegesForRole , other . _allPrivilegesForRole ) ; <nl> + } <nl> + <nl> + void swap ( RoleGraph & lhs , RoleGraph & rhs ) { <nl> + lhs . swap ( rhs ) ; <nl> + } <nl> + <nl> + bool RoleGraph : : roleExists ( const RoleName & role ) const { <nl> + EdgeSet : : const_iterator edgeIt = _roleToSubordinates . find ( role ) ; <nl> + if ( edgeIt = = _roleToSubordinates . end ( ) ) <nl> + return false ; <nl> + edgeIt = _roleToMembers . find ( role ) ; <nl> + massert ( 16825 , <nl> + " Role found in forward edges but not all reverse edges map , this should not " <nl> + " be possible " , <nl> + edgeIt ! = _roleToMembers . end ( ) ) ; <nl> + <nl> + RolePrivilegeMap : : const_iterator strIt = _directPrivilegesForRole . find ( role ) ; <nl> + if ( strIt = = _directPrivilegesForRole . end ( ) ) <nl> + return false ; <nl> + strIt = _allPrivilegesForRole . find ( role ) ; <nl> + massert ( 16826 , <nl> + " Role found in direct privileges map but not all privileges map , this should not " <nl> + " be possible " , <nl> + strIt ! = _allPrivilegesForRole . end ( ) ) ; <nl> + return true ; <nl> + } <nl> + <nl> + Status RoleGraph : : createRole ( const RoleName & role ) { <nl> + if ( roleExists ( role ) ) { <nl> + return Status ( ErrorCodes : : DuplicateKey , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " already exists " , <nl> + 0 ) ; <nl> + } <nl> + / / Just reference the role in all the maps so that an entry gets created with empty <nl> + / / containers for the value . <nl> + _roleToSubordinates [ role ] ; <nl> + _roleToMembers [ role ] ; <nl> + _directPrivilegesForRole [ role ] ; <nl> + _allPrivilegesForRole [ role ] ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status RoleGraph : : deleteRole ( const RoleName & role ) { <nl> + if ( ! roleExists ( role ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + for ( unordered_set < RoleName > : : iterator it = _roleToSubordinates [ role ] . begin ( ) ; <nl> + it ! = _roleToSubordinates [ role ] . end ( ) ; + + it ) { <nl> + _roleToMembers [ * it ] . erase ( role ) ; <nl> + } <nl> + for ( unordered_set < RoleName > : : iterator it = _roleToMembers [ role ] . begin ( ) ; <nl> + it ! = _roleToMembers [ role ] . end ( ) ; + + it ) { <nl> + _roleToSubordinates [ * it ] . erase ( role ) ; <nl> + } <nl> + _roleToSubordinates . erase ( role ) ; <nl> + _roleToMembers . erase ( role ) ; <nl> + _directPrivilegesForRole . erase ( role ) ; <nl> + _allPrivilegesForRole . erase ( role ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + RoleNameIterator RoleGraph : : getDirectSubordinates ( const RoleName & role ) const { <nl> + if ( ! roleExists ( role ) ) <nl> + return RoleNameIterator ( NULL ) ; <nl> + const unordered_set < RoleName > & edges = _roleToSubordinates . find ( role ) - > second ; <nl> + return RoleNameIterator ( new RoleNameSetIterator ( edges . begin ( ) , edges . end ( ) ) ) ; <nl> + } <nl> + <nl> + RoleNameIterator RoleGraph : : getDirectMembers ( const RoleName & role ) const { <nl> + if ( ! roleExists ( role ) ) <nl> + return RoleNameIterator ( NULL ) ; <nl> + const unordered_set < RoleName > & edges = _roleToMembers . find ( role ) - > second ; <nl> + return RoleNameIterator ( new RoleNameSetIterator ( edges . begin ( ) , edges . end ( ) ) ) ; <nl> + } <nl> + <nl> + const PrivilegeVector & RoleGraph : : getDirectPrivileges ( const RoleName & role ) const { <nl> + if ( ! roleExists ( role ) ) <nl> + return emptyPrivilegeVector ; <nl> + return _directPrivilegesForRole . find ( role ) - > second ; <nl> + } <nl> + <nl> + const PrivilegeVector & RoleGraph : : getAllPrivileges ( const RoleName & role ) const { <nl> + if ( ! roleExists ( role ) ) <nl> + return emptyPrivilegeVector ; <nl> + return _allPrivilegesForRole . find ( role ) - > second ; <nl> + } <nl> + <nl> + Status RoleGraph : : addRoleToRole ( const RoleName & recipient , const RoleName & role ) { <nl> + if ( ! roleExists ( recipient ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < recipient . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + if ( ! roleExists ( role ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + <nl> + _roleToSubordinates [ recipient ] . insert ( role ) ; <nl> + _roleToMembers [ role ] . insert ( recipient ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status RoleGraph : : removeRoleFromRole ( const RoleName & recipient , const RoleName & role ) { <nl> + if ( ! roleExists ( recipient ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < recipient . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + if ( ! roleExists ( role ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + <nl> + if ( ! _roleToMembers [ role ] . erase ( recipient ) ) { <nl> + return Status ( ErrorCodes : : RolesNotRelated , <nl> + mongoutils : : str : : stream ( ) < < recipient . getFullName ( ) < < " is not a member " <nl> + " of " < < role . getFullName ( ) , <nl> + 0 ) ; <nl> + } <nl> + <nl> + massert ( 16827 , <nl> + mongoutils : : str : : stream ( ) < < role . getFullName ( ) < < " is not a subordinate " <nl> + " of " < < recipient . getFullName ( ) < < " , even though " < < <nl> + recipient . getFullName ( ) < < " is a member of " < < role . getFullName ( ) < < <nl> + " . This shouldn ' t be possible " , <nl> + _roleToSubordinates [ recipient ] . erase ( role ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + namespace { <nl> + / / Helper function for adding a privilege to a privilege vector , de - duping the privilege if <nl> + / / the vector already contains a privilege on the same resource . <nl> + void addPrivilegeToPrivilegeVector ( PrivilegeVector & currentPrivileges , <nl> + const Privilege & privilegeToAdd ) { <nl> + for ( PrivilegeVector : : iterator it = currentPrivileges . begin ( ) ; <nl> + it ! = currentPrivileges . end ( ) ; + + it ) { <nl> + Privilege & curPrivilege = * it ; <nl> + if ( curPrivilege . getResource ( ) = = privilegeToAdd . getResource ( ) ) { <nl> + curPrivilege . addActions ( privilegeToAdd . getActions ( ) ) ; <nl> + return ; <nl> + } <nl> + } <nl> + / / No privilege exists yet for this resource <nl> + currentPrivileges . push_back ( privilegeToAdd ) ; <nl> + } <nl> + } / / namespace <nl> + <nl> + Status RoleGraph : : addPrivilegeToRole ( const RoleName & role , const Privilege & privilegeToAdd ) { <nl> + if ( ! roleExists ( role ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + <nl> + addPrivilegeToPrivilegeVector ( _directPrivilegesForRole [ role ] , privilegeToAdd ) ; <nl> + return Status : : OK ( ) ; <nl> + <nl> + } <nl> + <nl> + / / NOTE : Current runtime of this is O ( n * m ) where n is the size of the current PrivilegeVector <nl> + / / for the given role , and m is the size of the privilegesToAdd vector . <nl> + / / If this was a PrivilegeSet ( sorted on resource ) rather than a PrivilegeVector , we <nl> + / / could do this in O ( n + m ) instead . <nl> + Status RoleGraph : : addPrivilegesToRole ( const RoleName & role , <nl> + const PrivilegeVector & privilegesToAdd ) { <nl> + for ( PrivilegeVector : : const_iterator it = privilegesToAdd . begin ( ) ; <nl> + it ! = privilegesToAdd . end ( ) ; + + it ) { <nl> + Status status = addPrivilegeToRole ( role , * it ) ; <nl> + if ( ! status . isOK ( ) ) { <nl> + return status ; <nl> + } <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status RoleGraph : : removePrivilegeFromRole ( const RoleName & role , <nl> + const Privilege & privilegeToRemove ) { <nl> + if ( ! roleExists ( role ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + <nl> + PrivilegeVector & currentPrivileges = _directPrivilegesForRole [ role ] ; <nl> + for ( PrivilegeVector : : iterator it = currentPrivileges . begin ( ) ; <nl> + it ! = currentPrivileges . end ( ) ; + + it ) { <nl> + <nl> + Privilege & curPrivilege = * it ; <nl> + if ( curPrivilege . getResource ( ) = = privilegeToRemove . getResource ( ) ) { <nl> + ActionSet curActions = curPrivilege . getActions ( ) ; <nl> + <nl> + if ( ! curActions . isSupersetOf ( privilegeToRemove . getActions ( ) ) ) { <nl> + / / Didn ' t possess all the actions being removed . <nl> + return Status ( ErrorCodes : : PrivilegeNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " does not contain a privilege on " < < <nl> + privilegeToRemove . getResource ( ) < < " with actions : " < < <nl> + privilegeToRemove . getActions ( ) . toString ( ) , <nl> + 0 ) ; <nl> + } <nl> + <nl> + curPrivilege . removeActions ( privilegeToRemove . getActions ( ) ) ; <nl> + if ( curPrivilege . getActions ( ) . empty ( ) ) { <nl> + currentPrivileges . erase ( it ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + } <nl> + return Status ( ErrorCodes : : PrivilegeNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < " does not " <nl> + " contain any privileges on " < < privilegeToRemove . getResource ( ) , <nl> + 0 ) ; <nl> + } <nl> + <nl> + Status RoleGraph : : removePrivilegesFromRole ( const RoleName & role , <nl> + const PrivilegeVector & privilegesToRemove ) { <nl> + if ( ! roleExists ( role ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + for ( PrivilegeVector : : const_iterator it = privilegesToRemove . begin ( ) ; <nl> + it ! = privilegesToRemove . end ( ) ; + + it ) { <nl> + Status status = removePrivilegeFromRole ( role , * it ) ; <nl> + if ( ! status . isOK ( ) ) { <nl> + return status ; <nl> + } <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status RoleGraph : : removeAllPrivilegesFromRole ( const RoleName & role ) { <nl> + if ( ! roleExists ( role ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < role . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + _directPrivilegesForRole [ role ] . clear ( ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status RoleGraph : : recomputePrivilegeData ( ) { <nl> + / * <nl> + * This method is used to recompute the " allPrivileges " vector for each node in the graph , <nl> + * as well as look for cycles . It is implemented by performing a depth - first traversal of <nl> + * the dependency graph , once for each node . " visitedRoles " tracks the set of role names <nl> + * ever visited , and it is used to prune each DFS . A node that has been visited once on any <nl> + * DFS is never visited again . Complexity of this implementation is O ( n + m ) where " n " is the <nl> + * number of nodes and " m " is the number of prerequisite edges . Space complexity is O ( n ) , <nl> + * in both stack space and size of the " visitedRoles " set . <nl> + * <nl> + * " inProgressRoles " is used to detect and report cycles . <nl> + * / <nl> + <nl> + std : : vector < RoleName > inProgressRoles ; <nl> + unordered_set < RoleName > visitedRoles ; <nl> + <nl> + for ( EdgeSet : : const_iterator it = _roleToSubordinates . begin ( ) ; <nl> + it ! = _roleToSubordinates . end ( ) ; + + it ) { <nl> + Status status = _recomputePrivilegeDataHelper ( it - > first , inProgressRoles , visitedRoles ) ; <nl> + if ( status ! = Status : : OK ( ) ) { <nl> + return status ; <nl> + } <nl> + } <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + / * <nl> + * Recursive helper method for performing the depth - first traversal of the roles graph . Called <nl> + * once for every node in the graph by recomputePrivilegeData ( ) , above . <nl> + * / <nl> + Status RoleGraph : : _recomputePrivilegeDataHelper ( const RoleName & currentRole , <nl> + std : : vector < RoleName > & inProgressRoles , <nl> + unordered_set < RoleName > & visitedRoles ) { <nl> + <nl> + if ( visitedRoles . count ( currentRole ) ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + if ( ! roleExists ( currentRole ) ) { <nl> + return Status ( ErrorCodes : : RoleNotFound , <nl> + mongoutils : : str : : stream ( ) < < " Role : " < < currentRole . getFullName ( ) < < <nl> + " does not exist " , <nl> + 0 ) ; <nl> + } <nl> + <nl> + / / Check for cycles <nl> + std : : vector < RoleName > : : iterator firstOccurence = std : : find ( <nl> + inProgressRoles . begin ( ) , inProgressRoles . end ( ) , currentRole ) ; <nl> + if ( firstOccurence ! = inProgressRoles . end ( ) ) { <nl> + std : : ostringstream os ; <nl> + os < < " Cycle in dependency graph : " ; <nl> + for ( std : : vector < RoleName > : : iterator it = firstOccurence ; <nl> + it ! = inProgressRoles . end ( ) ; + + it ) { <nl> + os < < it - > getFullName ( ) < < " - > " ; <nl> + } <nl> + os < < currentRole . getFullName ( ) ; <nl> + return Status ( ErrorCodes : : GraphContainsCycle , os . str ( ) ) ; <nl> + } <nl> + <nl> + inProgressRoles . push_back ( currentRole ) ; <nl> + <nl> + / / Need to clear out the " all privileges " vector for the current role , and re - fill it with <nl> + / / just the direct privileges for this role . <nl> + PrivilegeVector & currentRoleAllPrivileges = _allPrivilegesForRole [ currentRole ] ; <nl> + const PrivilegeVector & currentRoleDirectPrivileges = _directPrivilegesForRole [ currentRole ] ; <nl> + currentRoleAllPrivileges . clear ( ) ; <nl> + for ( PrivilegeVector : : const_iterator it = currentRoleDirectPrivileges . begin ( ) ; <nl> + it ! = currentRoleDirectPrivileges . end ( ) ; + + it ) { <nl> + currentRoleAllPrivileges . push_back ( * it ) ; <nl> + } <nl> + <nl> + / / Recursively add children ' s privileges to current role ' s " all privileges " vector . <nl> + const unordered_set < RoleName > & children = _roleToSubordinates [ currentRole ] ; <nl> + for ( unordered_set < RoleName > : : const_iterator roleIt = children . begin ( ) ; <nl> + roleIt ! = children . end ( ) ; + + roleIt ) { <nl> + const RoleName & childRole = * roleIt ; <nl> + Status status = _recomputePrivilegeDataHelper ( childRole , inProgressRoles , visitedRoles ) ; <nl> + if ( status ! = Status : : OK ( ) ) { <nl> + return status ; <nl> + } <nl> + <nl> + / / At this point , we know that the " all privilege " set for the child is correct , so <nl> + / / add those privileges to our " all privilege " set . <nl> + const PrivilegeVector & childsPrivileges = _allPrivilegesForRole [ childRole ] ; <nl> + for ( PrivilegeVector : : const_iterator privIt = childsPrivileges . begin ( ) ; <nl> + privIt ! = childsPrivileges . end ( ) ; + + privIt ) { <nl> + addPrivilegeToPrivilegeVector ( currentRoleAllPrivileges , * privIt ) ; <nl> + } <nl> + } <nl> + <nl> + if ( inProgressRoles . back ( ) ! = currentRole ) <nl> + return Status ( ErrorCodes : : InternalError , " inProgressRoles stack corrupt " ) ; <nl> + inProgressRoles . pop_back ( ) ; <nl> + visitedRoles . insert ( currentRole ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + <nl> + } / / namespace mongo <nl> new file mode 100644 <nl> index 000000000000 . . 413393db2769 <nl> mmm / dev / null <nl> ppp b / src / mongo / db / auth / role_graph . h <nl> <nl> + / * * <nl> + * Copyright ( C ) 2013 10gen Inc . <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU Affero General Public License , version 3 , <nl> + * as published by the Free Software Foundation . <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 Affero General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU Affero General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * / <nl> + <nl> + # pragma once <nl> + <nl> + # include < algorithm > <nl> + # include < set > <nl> + <nl> + # include " mongo / base / status . h " <nl> + # include " mongo / db / auth / privilege . h " <nl> + # include " mongo / db / auth / role_name . h " <nl> + # include " mongo / platform / unordered_map . h " <nl> + # include " mongo / platform / unordered_set . h " <nl> + <nl> + namespace mongo { <nl> + <nl> + / * * <nl> + * A graph of role and privilege relationships . <nl> + * <nl> + * This structure is used to store an in - memory representation of the admin . system . roledata <nl> + * collection , specifically the graph of which roles are members of other roles and what <nl> + * privileges each role has , both directly and transitively through membership in other roles . <nl> + * There are some restrictions on calls to getAllPrivileges ( ) , specifically , one must call <nl> + * recomputePrivilegeData ( ) before calling getAllPrivileges ( ) if any of the mutation methods <nl> + * have been called on the instance since the later of its construction or the last call to <nl> + * recomputePrivilegeData ( ) on the object . <nl> + * / <nl> + class RoleGraph { <nl> + public : <nl> + RoleGraph ( ) ; <nl> + RoleGraph ( const RoleGraph & other ) ; <nl> + ~ RoleGraph ( ) ; <nl> + <nl> + / / Swaps the contents of this RoleGraph with those of " other " <nl> + void swap ( RoleGraph & other ) ; <nl> + <nl> + / * * <nl> + * Returns an iterator that can be used to get a list of the members of the given role . <nl> + * Members of a role are roles that have been granted this role directly ( roles that are <nl> + * members transitively through another role are not included ) . These are the " parents " of <nl> + * this node in the graph . The iterator is valid until the next call to addRole or <nl> + * removeRole . <nl> + * / <nl> + RoleNameIterator getDirectMembers ( const RoleName & role ) const ; <nl> + <nl> + / * * <nl> + * Returns an iterator that can be used to get a list of " subordinate " roles of the given <nl> + * role . Subordinate roles are the roles that this role has been granted directly ( roles <nl> + * that have been granted transitively through another role are not included ) . These are <nl> + * the " children " of this node in the graph . The iterator is valid until the next call to <nl> + * addRole or removeRole . <nl> + * / <nl> + RoleNameIterator getDirectSubordinates ( const RoleName & role ) const ; <nl> + <nl> + / * * <nl> + * Returns a vector of the privileges that the given role has been directly granted . <nl> + * Privileges that have been granted transitively through this role ' s subordinate roles are <nl> + * not included . <nl> + * / <nl> + const PrivilegeVector & getDirectPrivileges ( const RoleName & role ) const ; <nl> + <nl> + / * * <nl> + * Returns a vector of all privileges that the given role contains . This includes both the <nl> + * privileges that have been granted to this role directly , as well as any privileges <nl> + * inherited from the role ' s subordinate roles . <nl> + * / <nl> + const PrivilegeVector & getAllPrivileges ( const RoleName & role ) const ; <nl> + <nl> + / * * <nl> + * Returns whether or not the given role exists in the role graph . <nl> + * / <nl> + bool roleExists ( const RoleName & role ) const ; <nl> + <nl> + / / Mutation functions <nl> + <nl> + / * * <nl> + * Puts an entry into the RoleGraph for the given RoleName . <nl> + * Returns DuplicateKey if the role already exists . <nl> + * / <nl> + Status createRole ( const RoleName & role ) ; <nl> + <nl> + / * * <nl> + * Deletes the given role by first removing it from the members / subordinates arrays for <nl> + * all other roles , and then by removing its own entries in the 4 member maps . <nl> + * Returns RoleNotFound if the role doesn ' t exist . <nl> + * / <nl> + Status deleteRole ( const RoleName & role ) ; <nl> + <nl> + / * * <nl> + * Grants " role " to " recipient " . This leaves " recipient " as a member of " role " and " role " <nl> + * as a subordinate of " recipient " . <nl> + * Returns RoleNotFound if either of " role " or " recipient " doesn ' t exist in <nl> + * the RoleGraph . <nl> + * / <nl> + Status addRoleToRole ( const RoleName & recipient , const RoleName & role ) ; <nl> + <nl> + / * * <nl> + * Revokes " role " from " recipient " . <nl> + * Returns RoleNotFound if either of " role " or " recipient " doesn ' t exist in <nl> + * the RoleGraph . Returns RolesNotRelated if " recipient " is not currently a <nl> + * member of " role " . <nl> + * / <nl> + Status removeRoleFromRole ( const RoleName & recipient , const RoleName & role ) ; <nl> + <nl> + / * * <nl> + * Grants " privilegeToAdd " to " role " . <nl> + * Returns RoleNotFound if " role " doesn ' t exist in the role graph . <nl> + * / <nl> + Status addPrivilegeToRole ( const RoleName & role , const Privilege & privilegeToAdd ) ; <nl> + <nl> + / * * <nl> + * Grants Privileges from " privilegesToAdd " to " role " . <nl> + * Returns RoleNotFound if " role " doesn ' t exist in the role graph . <nl> + * / <nl> + Status addPrivilegesToRole ( const RoleName & role , const PrivilegeVector & privilegesToAdd ) ; <nl> + <nl> + / * * <nl> + * Removes " privilegeToRemove " from " role " . <nl> + * Returns RoleNotFound if " role " doesn ' t exist in the role graph . <nl> + * Returns PrivilegeNotFound if " role " doesn ' t contain the full privilege being removed . <nl> + * / <nl> + Status removePrivilegeFromRole ( const RoleName & role , <nl> + const Privilege & privilegeToRemove ) ; <nl> + <nl> + / * * <nl> + * Removes all privileges in the " privilegesToRemove " vector from " role " . <nl> + * Returns RoleNotFound if " role " doesn ' t exist in the role graph . <nl> + * Returns PrivilegeNotFound if " role " is missing any of the privileges being removed . If <nl> + * PrivilegeNotFound is returned then the graph may be in an inconsistent state and needs to <nl> + * be abandoned . <nl> + * / <nl> + Status removePrivilegesFromRole ( const RoleName & role , <nl> + const PrivilegeVector & privilegesToRemove ) ; <nl> + <nl> + / * * <nl> + * Removes all privileges from " role " . <nl> + * Returns RoleNotFound if " role " doesn ' t exist in the role graph . <nl> + * / <nl> + Status removeAllPrivilegesFromRole ( const RoleName & role ) ; <nl> + <nl> + / * * <nl> + * Recomputes the indirect ( getAllPrivileges ) data for this graph . <nl> + * <nl> + * Must be called between calls to any of the mutation functions and calls <nl> + * to getAllPrivileges ( ) . <nl> + * <nl> + * Returns Status : : OK ( ) on success . If a cycle is detected , returns <nl> + * ErrorCodes : : GraphContainsCycle , and the status message reveals the cycle . <nl> + * / <nl> + Status recomputePrivilegeData ( ) ; <nl> + <nl> + private : <nl> + / / Helper method for recursively doing a topological DFS to compute the indirect privilege <nl> + / / data and look for cycles <nl> + Status _recomputePrivilegeDataHelper ( const RoleName & currentRole , <nl> + std : : vector < RoleName > & inProgressRoles , <nl> + unordered_set < RoleName > & visitedRoles ) ; <nl> + <nl> + / / Represents all the outgoing edges to other roles from any given role . <nl> + typedef unordered_map < RoleName , unordered_set < RoleName > > EdgeSet ; <nl> + / / Maps a role name to a list of privileges associated with that role . <nl> + typedef unordered_map < RoleName , PrivilegeVector > RolePrivilegeMap ; <nl> + <nl> + EdgeSet _roleToSubordinates ; <nl> + EdgeSet _roleToMembers ; <nl> + RolePrivilegeMap _directPrivilegesForRole ; <nl> + RolePrivilegeMap _allPrivilegesForRole ; <nl> + } ; <nl> + <nl> + void swap ( RoleGraph & lhs , RoleGraph & rhs ) ; <nl> + <nl> + } / / namespace mongo <nl> new file mode 100644 <nl> index 000000000000 . . 7a91929078d8 <nl> mmm / dev / null <nl> ppp b / src / mongo / db / auth / role_graph_test . cpp <nl> <nl> + / * * <nl> + * Copyright ( C ) 2013 10gen Inc . <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU Affero General Public License , version 3 , <nl> + * as published by the Free Software Foundation . <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 Affero General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU Affero General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * / <nl> + <nl> + / * * <nl> + * Unit tests of the RoleGraph type . <nl> + * / <nl> + <nl> + # include < algorithm > <nl> + <nl> + # include " mongo / db / auth / role_graph . h " <nl> + # include " mongo / unittest / unittest . h " <nl> + # include " mongo / util / mongoutils / str . h " <nl> + <nl> + namespace mongo { <nl> + namespace { <nl> + <nl> + / / Tests adding and removing roles from other roles , the RoleNameIterator , and the <nl> + / / getDirectMembers and getDirectSubordinates methods <nl> + TEST ( RoleGraphTest , AddRemoveRoles ) { <nl> + RoleName roleA ( " roleA " , " dbA " ) ; <nl> + RoleName roleB ( " roleB " , " dbB " ) ; <nl> + RoleName roleC ( " roleC " , " dbC " ) ; <nl> + RoleName roleD ( " roleD " , " dbD " ) ; <nl> + <nl> + RoleGraph graph ; <nl> + ASSERT_OK ( graph . createRole ( roleA ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleB ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleC ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleD ) ) ; <nl> + <nl> + RoleNameIterator it ; <nl> + it = graph . getDirectSubordinates ( roleA ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + it = graph . getDirectMembers ( roleA ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + <nl> + / / A - > B <nl> + it = graph . getDirectSubordinates ( roleA ) ; <nl> + ASSERT_TRUE ( it . more ( ) ) ; <nl> + / / should not advance the iterator <nl> + ASSERT_EQUALS ( it . get ( ) . getFullName ( ) , roleB . getFullName ( ) ) ; <nl> + ASSERT_EQUALS ( it . get ( ) . getFullName ( ) , roleB . getFullName ( ) ) ; <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleB . getFullName ( ) ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectMembers ( roleA ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectMembers ( roleB ) ; <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleA . getFullName ( ) ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectSubordinates ( roleB ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleC ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleB , roleC ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleB , roleD ) ) ; <nl> + <nl> + / * <nl> + * Graph now looks like : <nl> + * A <nl> + * / \ <nl> + * v v <nl> + * B - > C <nl> + * | <nl> + * v <nl> + * D <nl> + * / <nl> + <nl> + <nl> + it = graph . getDirectSubordinates ( roleA ) ; / / should be roleB and roleC , order doesn ' t matter <nl> + RoleName cur = it . next ( ) ; <nl> + if ( cur = = roleB ) { <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleC . getFullName ( ) ) ; <nl> + } else if ( cur = = roleC ) { <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleB . getFullName ( ) ) ; <nl> + } else { <nl> + FAIL ( mongoutils : : str : : stream ( ) < < " unexpected role returned : " < < cur . getFullName ( ) ) ; <nl> + } <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectSubordinates ( roleB ) ; / / should be roleC and roleD , order doesn ' t matter <nl> + cur = it . next ( ) ; <nl> + if ( cur = = roleC ) { <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleD . getFullName ( ) ) ; <nl> + } else if ( cur = = roleD ) { <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleC . getFullName ( ) ) ; <nl> + } else { <nl> + FAIL ( mongoutils : : str : : stream ( ) < < " unexpected role returned : " < < cur . getFullName ( ) ) ; <nl> + } <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectSubordinates ( roleC ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectMembers ( roleA ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectMembers ( roleB ) ; <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleA . getFullName ( ) ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectMembers ( roleC ) ; / / should be role A and role B , order doesn ' t matter <nl> + cur = it . next ( ) ; <nl> + if ( cur = = roleA ) { <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleB . getFullName ( ) ) ; <nl> + } else if ( cur = = roleB ) { <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleA . getFullName ( ) ) ; <nl> + } else { <nl> + FAIL ( mongoutils : : str : : stream ( ) < < " unexpected role returned : " < < cur . getFullName ( ) ) ; <nl> + } <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + / / Now remove roleD from roleB and make sure graph is update correctly <nl> + ASSERT_OK ( graph . removeRoleFromRole ( roleB , roleD ) ) ; <nl> + <nl> + / * <nl> + * Graph now looks like : <nl> + * A <nl> + * / \ <nl> + * v v <nl> + * B - > C <nl> + * / <nl> + it = graph . getDirectSubordinates ( roleB ) ; / / should be just roleC <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleC . getFullName ( ) ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + it = graph . getDirectSubordinates ( roleD ) ; / / should be empty <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + <nl> + / / Now delete roleB entirely and make sure that the other roles are updated properly <nl> + ASSERT_OK ( graph . deleteRole ( roleB ) ) ; <nl> + ASSERT_NOT_OK ( graph . deleteRole ( roleB ) ) ; <nl> + it = graph . getDirectSubordinates ( roleA ) ; <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleC . getFullName ( ) ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + it = graph . getDirectMembers ( roleC ) ; <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleA . getFullName ( ) ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + } <nl> + <nl> + / / Tests that adding multiple privileges on the same resource correctly collapses those to one <nl> + / / privilege <nl> + TEST ( RoleGraphTest , AddPrivileges ) { <nl> + RoleName roleA ( " roleA " , " dbA " ) ; <nl> + <nl> + RoleGraph graph ; <nl> + ASSERT_OK ( graph . createRole ( roleA ) ) ; <nl> + <nl> + / / Test adding a single privilege <nl> + ActionSet actions ; <nl> + actions . addAction ( ActionType : : find ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , Privilege ( " dbA " , actions ) ) ) ; <nl> + <nl> + PrivilegeVector privileges = graph . getDirectPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( actions . toString ( ) , privileges [ 0 ] . getActions ( ) . toString ( ) ) ; <nl> + <nl> + / / Add a privilege on a different resource <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , Privilege ( " dbA . foo " , actions ) ) ) ; <nl> + privileges = graph . getDirectPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 2 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( actions . toString ( ) , privileges [ 0 ] . getActions ( ) . toString ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA . foo " , privileges [ 1 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( actions . toString ( ) , privileges [ 1 ] . getActions ( ) . toString ( ) ) ; <nl> + <nl> + <nl> + / / Add different privileges on an existing resource and make sure they get de - duped <nl> + actions . removeAllActions ( ) ; <nl> + actions . addAction ( ActionType : : insert ) ; <nl> + <nl> + PrivilegeVector privilegesToAdd ; <nl> + privilegesToAdd . push_back ( Privilege ( " dbA " , actions ) ) ; <nl> + <nl> + actions . removeAllActions ( ) ; <nl> + actions . addAction ( ActionType : : update ) ; <nl> + privilegesToAdd . push_back ( Privilege ( " dbA " , actions ) ) ; <nl> + <nl> + ASSERT_OK ( graph . addPrivilegesToRole ( roleA , privilegesToAdd ) ) ; <nl> + <nl> + privileges = graph . getDirectPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 2 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_NOT_EQUALS ( actions . toString ( ) , privileges [ 0 ] . getActions ( ) . toString ( ) ) ; <nl> + actions . addAction ( ActionType : : find ) ; <nl> + actions . addAction ( ActionType : : insert ) ; <nl> + ASSERT_EQUALS ( actions . toString ( ) , privileges [ 0 ] . getActions ( ) . toString ( ) ) ; <nl> + actions . removeAction ( ActionType : : insert ) ; <nl> + actions . removeAction ( ActionType : : update ) ; <nl> + ASSERT_EQUALS ( " dbA . foo " , privileges [ 1 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( actions . toString ( ) , privileges [ 1 ] . getActions ( ) . toString ( ) ) ; <nl> + } <nl> + <nl> + / / Tests that recomputePrivilegeData correctly detects cycles in the graph . <nl> + TEST ( RoleGraphTest , DetectCycles ) { <nl> + RoleName roleA ( " roleA " , " dbA " ) ; <nl> + RoleName roleB ( " roleB " , " dbB " ) ; <nl> + RoleName roleC ( " roleC " , " dbC " ) ; <nl> + RoleName roleD ( " roleD " , " dbD " ) ; <nl> + <nl> + RoleGraph graph ; <nl> + ASSERT_OK ( graph . createRole ( roleA ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleB ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleC ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleD ) ) ; <nl> + <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleC ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleB , roleC ) ) ; <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + / * <nl> + * Graph now looks like : <nl> + * A <nl> + * / \ <nl> + * v v <nl> + * B - > C <nl> + * / <nl> + ASSERT_OK ( graph . addRoleToRole ( roleC , roleD ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleD , roleB ) ) ; / / Add a cycle <nl> + / * <nl> + * Graph now looks like : <nl> + * A <nl> + * / \ <nl> + * v v <nl> + * B - > C <nl> + * ^ / <nl> + * \ v <nl> + * D <nl> + * / <nl> + ASSERT_NOT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + ASSERT_OK ( graph . removeRoleFromRole ( roleD , roleB ) ) ; <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + } <nl> + <nl> + / / Tests that recomputePrivilegeData correctly updates transitive privilege data for all roles . <nl> + TEST ( RoleGraphTest , RecomputePrivilegeData ) { <nl> + / / We create 4 roles and give each of them a unique privilege . After that the direct <nl> + / / privileges for all the roles are not touched . The only thing that is changed is the <nl> + / / role membership graph , and we test how that affects the set of all transitive privileges <nl> + / / for each role . <nl> + RoleName roleA ( " roleA " , " dbA " ) ; <nl> + RoleName roleB ( " roleB " , " dbB " ) ; <nl> + RoleName roleC ( " roleC " , " dbC " ) ; <nl> + RoleName roleD ( " roleD " , " dbD " ) ; <nl> + <nl> + ActionSet actions ; <nl> + actions . addAllActions ( ) ; <nl> + <nl> + RoleGraph graph ; <nl> + ASSERT_OK ( graph . createRole ( roleA ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleB ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleC ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleD ) ) ; <nl> + <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , Privilege ( " dbA " , actions ) ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleB , Privilege ( " dbB " , actions ) ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleC , Privilege ( " dbC " , actions ) ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleD , Privilege ( " dbD " , actions ) ) ) ; <nl> + <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + <nl> + PrivilegeVector privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + <nl> + / / At this point we have all 4 roles set up , each with their own privilege , but no <nl> + / / roles have been granted to each other . <nl> + <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + / / Role graph : A - > B <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 2 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 1 ] . getResource ( ) ) ; <nl> + <nl> + / / Add ' s roleC ' s privileges to roleB and make sure roleA gets them as well . <nl> + ASSERT_OK ( graph . addRoleToRole ( roleB , roleC ) ) ; <nl> + / / Role graph : A - > B - > C <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 3 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 1 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbC " , privileges [ 2 ] . getResource ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleB ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 2 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbC " , privileges [ 1 ] . getResource ( ) ) ; <nl> + <nl> + / / Add ' s roleD ' s privileges to roleC and make sure that roleA and roleB get them as well . <nl> + ASSERT_OK ( graph . addRoleToRole ( roleC , roleD ) ) ; <nl> + / / Role graph : A - > B - > C - > D <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 4 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 1 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbC " , privileges [ 2 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbD " , privileges [ 3 ] . getResource ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleB ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 3 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbC " , privileges [ 1 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbD " , privileges [ 2 ] . getResource ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleC ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 2 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbC " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbD " , privileges [ 1 ] . getResource ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleD ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbD " , privileges [ 0 ] . getResource ( ) ) ; <nl> + <nl> + / / Remove roleC from roleB , make sure that roleA then loses both roleC ' s and roleD ' s <nl> + / / privileges <nl> + ASSERT_OK ( graph . removeRoleFromRole ( roleB , roleC ) ) ; <nl> + / / Role graph : A - > B C - > D <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 2 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 1 ] . getResource ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleB ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 0 ] . getResource ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleC ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 2 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbC " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbD " , privileges [ 1 ] . getResource ( ) ) ; <nl> + privileges = graph . getAllPrivileges ( roleD ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbD " , privileges [ 0 ] . getResource ( ) ) ; <nl> + <nl> + / / Make sure direct privileges were untouched <nl> + privileges = graph . getDirectPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + privileges = graph . getDirectPrivileges ( roleB ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 0 ] . getResource ( ) ) ; <nl> + privileges = graph . getDirectPrivileges ( roleC ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbC " , privileges [ 0 ] . getResource ( ) ) ; <nl> + privileges = graph . getDirectPrivileges ( roleD ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbD " , privileges [ 0 ] . getResource ( ) ) ; <nl> + } <nl> + <nl> + / / Test that if you grant 1 role to another , then remove it and change it ' s privileges , then <nl> + / / re - grant it , the receiving role sees the new privileges and not the old ones . <nl> + TEST ( RoleGraphTest , ReAddRole ) { <nl> + RoleName roleA ( " roleA " , " dbA " ) ; <nl> + RoleName roleB ( " roleB " , " dbB " ) ; <nl> + RoleName roleC ( " roleC " , " dbC " ) ; <nl> + <nl> + ActionSet actionsA , actionsB , actionsC ; <nl> + actionsA . addAction ( ActionType : : find ) ; <nl> + actionsB . addAction ( ActionType : : insert ) ; <nl> + actionsC . addAction ( ActionType : : update ) ; <nl> + <nl> + RoleGraph graph ; <nl> + ASSERT_OK ( graph . createRole ( roleA ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleB ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleC ) ) ; <nl> + <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , Privilege ( " db " , actionsA ) ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleB , Privilege ( " db " , actionsB ) ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleC , Privilege ( " db " , actionsC ) ) ) ; <nl> + <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleB , roleC ) ) ; / / graph : A < - B < - C <nl> + <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + <nl> + / / roleA should have privileges from roleB and roleC <nl> + PrivilegeVector privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : find ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : insert ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : update ) ) ; <nl> + <nl> + / / Now remove roleB from roleA . B still is a member of C , but A no longer should have <nl> + / / privileges from B or C . <nl> + ASSERT_OK ( graph . removeRoleFromRole ( roleA , roleB ) ) ; <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + <nl> + / / roleA should no longer have the privileges from roleB or roleC <nl> + privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : find ) ) ; <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : insert ) ) ; <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : update ) ) ; <nl> + <nl> + / / Change the privileges that roleB grants <nl> + ASSERT_OK ( graph . removeAllPrivilegesFromRole ( roleB ) ) ; <nl> + ActionSet newActionsB ; <nl> + newActionsB . addAction ( ActionType : : remove ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleB , Privilege ( " db " , newActionsB ) ) ) ; <nl> + <nl> + / / Grant roleB back to roleA , make sure roleA has roleB ' s new privilege but not its old one . <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + <nl> + privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : find ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : update ) ) ; / / should get roleC ' s actions again <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : remove ) ) ; / / roleB should grant this to roleA <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : insert ) ) ; / / no roles have this action anymore <nl> + <nl> + / / Now delete roleB completely . A should once again lose the privileges from both B and C . <nl> + ASSERT_OK ( graph . deleteRole ( roleB ) ) ; <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + <nl> + / / roleA should no longer have the privileges from roleB or roleC <nl> + privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : find ) ) ; <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : update ) ) ; <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : remove ) ) ; <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : insert ) ) ; <nl> + <nl> + / / Now re - create roleB and give it a new privilege , then grant it back to roleA . <nl> + / / RoleA should get its new privilege but not roleC ' s privilege this time nor either of <nl> + / / roleB ' s old privileges . <nl> + ASSERT_OK ( graph . createRole ( roleB ) ) ; <nl> + actionsB . removeAllActions ( ) ; <nl> + actionsB . addAction ( ActionType : : shutdown ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleB , Privilege ( " db " , actionsB ) ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + ASSERT_OK ( graph . recomputePrivilegeData ( ) ) ; <nl> + <nl> + privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 1 ) , privileges . size ( ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : find ) ) ; <nl> + ASSERT_TRUE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : shutdown ) ) ; <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : update ) ) ; <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : remove ) ) ; <nl> + ASSERT_FALSE ( privileges [ 0 ] . getActions ( ) . contains ( ActionType : : insert ) ) ; <nl> + } <nl> + <nl> + / / Tests copy constructor and swap functionality . <nl> + TEST ( RoleGraphTest , CopySwap ) { <nl> + RoleName roleA ( " roleA " , " dbA " ) ; <nl> + RoleName roleB ( " roleB " , " dbB " ) ; <nl> + RoleName roleC ( " roleC " , " dbC " ) ; <nl> + <nl> + RoleGraph graph ; <nl> + ASSERT_OK ( graph . createRole ( roleA ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleB ) ) ; <nl> + ASSERT_OK ( graph . createRole ( roleC ) ) ; <nl> + <nl> + ActionSet actions ; <nl> + actions . addAction ( ActionType : : find ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , Privilege ( " dbA " , actions ) ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleB , Privilege ( " dbB " , actions ) ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleC , Privilege ( " dbC " , actions ) ) ) ; <nl> + <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + <nl> + / / Make a copy of the graph to do further modifications on . <nl> + RoleGraph tempGraph ( graph ) ; <nl> + ASSERT_OK ( tempGraph . addRoleToRole ( roleB , roleC ) ) ; <nl> + tempGraph . recomputePrivilegeData ( ) ; <nl> + <nl> + / / Now swap the copy back with the original graph and make sure the original was updated <nl> + / / properly . <nl> + swap ( tempGraph , graph ) ; <nl> + <nl> + RoleNameIterator it = graph . getDirectSubordinates ( roleB ) ; <nl> + ASSERT_TRUE ( it . more ( ) ) ; <nl> + ASSERT_EQUALS ( it . next ( ) . getFullName ( ) , roleC . getFullName ( ) ) ; <nl> + ASSERT_FALSE ( it . more ( ) ) ; <nl> + <nl> + graph . getAllPrivileges ( roleA ) ; / / should have privileges from roleB * and * role C <nl> + PrivilegeVector privileges = graph . getAllPrivileges ( roleA ) ; <nl> + ASSERT_EQUALS ( static_cast < size_t > ( 3 ) , privileges . size ( ) ) ; <nl> + ASSERT_EQUALS ( " dbA " , privileges [ 0 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbB " , privileges [ 1 ] . getResource ( ) ) ; <nl> + ASSERT_EQUALS ( " dbC " , privileges [ 2 ] . getResource ( ) ) ; <nl> + } <nl> + <nl> + / / Tests error handling <nl> + TEST ( RoleGraphTest , ErrorHandling ) { <nl> + RoleName roleA ( " roleA " , " dbA " ) ; <nl> + RoleName roleB ( " roleB " , " dbB " ) ; <nl> + RoleName roleC ( " roleC " , " dbC " ) ; <nl> + <nl> + ActionSet actions ; <nl> + actions . addAction ( ActionType : : find ) ; <nl> + Privilege privilege1 ( " db1 " , actions ) ; <nl> + Privilege privilege2 ( " db2 " , actions ) ; <nl> + PrivilegeVector privileges ; <nl> + privileges . push_back ( privilege1 ) ; <nl> + privileges . push_back ( privilege2 ) ; <nl> + <nl> + RoleGraph graph ; <nl> + / / None of the roles exist yet . <nl> + ASSERT_NOT_OK ( graph . addPrivilegeToRole ( roleA , privilege1 ) ) ; <nl> + ASSERT_NOT_OK ( graph . addPrivilegesToRole ( roleA , privileges ) ) ; <nl> + ASSERT_NOT_OK ( graph . removePrivilegeFromRole ( roleA , privilege1 ) ) ; <nl> + ASSERT_NOT_OK ( graph . removePrivilegesFromRole ( roleA , privileges ) ) ; <nl> + ASSERT_NOT_OK ( graph . removeAllPrivilegesFromRole ( roleA ) ) ; <nl> + ASSERT_NOT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + ASSERT_NOT_OK ( graph . removeRoleFromRole ( roleA , roleB ) ) ; <nl> + <nl> + / / One of the roles exists <nl> + ASSERT_OK ( graph . createRole ( roleA ) ) ; <nl> + ASSERT_NOT_OK ( graph . createRole ( roleA ) ) ; / / Can ' t create same role twice <nl> + ASSERT_NOT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + ASSERT_NOT_OK ( graph . addRoleToRole ( roleB , roleA ) ) ; <nl> + ASSERT_NOT_OK ( graph . removeRoleFromRole ( roleA , roleB ) ) ; <nl> + ASSERT_NOT_OK ( graph . removeRoleFromRole ( roleB , roleA ) ) ; <nl> + <nl> + / / Should work now that both exist . <nl> + ASSERT_OK ( graph . createRole ( roleB ) ) ; <nl> + ASSERT_OK ( graph . addRoleToRole ( roleA , roleB ) ) ; <nl> + ASSERT_OK ( graph . removeRoleFromRole ( roleA , roleB ) ) ; <nl> + ASSERT_NOT_OK ( graph . removeRoleFromRole ( roleA , roleB ) ) ; / / roleA isn ' t actually a member of roleB <nl> + <nl> + / / Can ' t remove a privilege from a role that doesn ' t have it . <nl> + ASSERT_NOT_OK ( graph . removePrivilegeFromRole ( roleA , privilege1 ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , privilege1 ) ) ; <nl> + ASSERT_OK ( graph . removePrivilegeFromRole ( roleA , privilege1 ) ) ; / / now should work <nl> + <nl> + / / Test that removing a vector of privileges fails if * any * of the privileges are missing . <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , privilege1 ) ) ; <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , privilege2 ) ) ; <nl> + / / Removing both privileges should work since it has both <nl> + ASSERT_OK ( graph . removePrivilegesFromRole ( roleA , privileges ) ) ; <nl> + / / Now add only 1 back and this time removing both should fail <nl> + ASSERT_OK ( graph . addPrivilegeToRole ( roleA , privilege1 ) ) ; <nl> + ASSERT_NOT_OK ( graph . removePrivilegesFromRole ( roleA , privileges ) ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + } / / namespace mongo <nl> new file mode 100644 <nl> index 000000000000 . . d691e826f77e <nl> mmm / dev / null <nl> ppp b / src / mongo / db / auth / role_name . cpp <nl> <nl> + / * * <nl> + * Copyright ( C ) 2013 10gen Inc . <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU Affero General Public License , version 3 , <nl> + * as published by the Free Software Foundation . <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 Affero General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU Affero General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * / <nl> + <nl> + # include " mongo / db / auth / role_name . h " <nl> + <nl> + # include < algorithm > <nl> + # include < string > <nl> + <nl> + # include " mongo / base / string_data . h " <nl> + # include " mongo / util / assert_util . h " <nl> + <nl> + namespace mongo { <nl> + <nl> + RoleName : : RoleName ( const StringData & role , const StringData & dbname ) { <nl> + _fullName . resize ( role . size ( ) + dbname . size ( ) + 1 ) ; <nl> + std : : string : : iterator iter = std : : copy ( role . rawData ( ) , <nl> + role . rawData ( ) + role . size ( ) , <nl> + _fullName . begin ( ) ) ; <nl> + * iter = ' @ ' ; <nl> + + + iter ; <nl> + iter = std : : copy ( dbname . rawData ( ) , dbname . rawData ( ) + dbname . size ( ) , iter ) ; <nl> + dassert ( iter = = _fullName . end ( ) ) ; <nl> + _splitPoint = role . size ( ) ; <nl> + } <nl> + <nl> + } / / namespace mongo <nl> new file mode 100644 <nl> index 000000000000 . . a7b249eb6bd5 <nl> mmm / dev / null <nl> ppp b / src / mongo / db / auth / role_name . h <nl> <nl> + / * * <nl> + * Copyright ( C ) 2013 10gen Inc . <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU Affero General Public License , version 3 , <nl> + * as published by the Free Software Foundation . <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 Affero General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU Affero General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * / <nl> + <nl> + # pragma once <nl> + <nl> + # include < string > <nl> + <nl> + # include < boost / scoped_ptr . hpp > <nl> + <nl> + # include " mongo / base / disallow_copying . h " <nl> + # include " mongo / base / string_data . h " <nl> + # include " mongo / platform / hash_namespace . h " <nl> + # include " mongo / util / assert_util . h " <nl> + <nl> + namespace mongo { <nl> + <nl> + / * * <nl> + * Representation of a name of a role in a MongoDB system . <nl> + * <nl> + * Consists of a " role name " part and a " datbase name " part . <nl> + * / <nl> + class RoleName { <nl> + public : <nl> + RoleName ( ) : _splitPoint ( 0 ) { } <nl> + RoleName ( const StringData & role , const StringData & dbname ) ; <nl> + <nl> + / * * <nl> + * Gets the name of the role excluding the " @ dbname " component . <nl> + * / <nl> + StringData getRole ( ) const { return StringData ( _fullName ) . substr ( 0 , _splitPoint ) ; } <nl> + <nl> + / * * <nl> + * Gets the database name part of a role name . <nl> + * / <nl> + StringData getDB ( ) const { return StringData ( _fullName ) . substr ( _splitPoint + 1 ) ; } <nl> + <nl> + / * * <nl> + * Gets the full name of a role as a string , formatted as " role @ db " . <nl> + * <nl> + * Allowed for keys in non - persistent data structures , such as std : : map . <nl> + * / <nl> + const std : : string & getFullName ( ) const { return _fullName ; } <nl> + <nl> + / * * <nl> + * Stringifies the object , for logging / debugging . <nl> + * / <nl> + const std : : string & toString ( ) const { return getFullName ( ) ; } <nl> + <nl> + private : <nl> + std : : string _fullName ; / / The full name , stored as a string . " role @ db " . <nl> + size_t _splitPoint ; / / The index of the " @ " separating the role and db name parts . <nl> + } ; <nl> + <nl> + static inline bool operator = = ( const RoleName & lhs , const RoleName & rhs ) { <nl> + return lhs . getFullName ( ) = = rhs . getFullName ( ) ; <nl> + } <nl> + <nl> + static inline bool operator ! = ( const RoleName & lhs , const RoleName & rhs ) { <nl> + return lhs . getFullName ( ) ! = rhs . getFullName ( ) ; <nl> + } <nl> + <nl> + static inline bool operator < ( const RoleName & lhs , const RoleName & rhs ) { <nl> + return lhs . getFullName ( ) < rhs . getFullName ( ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Iterator over an unspecified container of RoleName objects . <nl> + * / <nl> + class RoleNameIterator { <nl> + public : <nl> + class Impl { <nl> + MONGO_DISALLOW_COPYING ( Impl ) ; <nl> + public : <nl> + Impl ( ) { } ; <nl> + virtual ~ Impl ( ) { } ; <nl> + static Impl * clone ( Impl * orig ) { return orig ? orig - > doClone ( ) : NULL ; } <nl> + virtual bool more ( ) const = 0 ; <nl> + virtual const RoleName & get ( ) const = 0 ; <nl> + <nl> + virtual const RoleName & next ( ) = 0 ; <nl> + <nl> + private : <nl> + virtual Impl * doClone ( ) const = 0 ; <nl> + } ; <nl> + <nl> + RoleNameIterator ( ) : _impl ( NULL ) { } <nl> + RoleNameIterator ( const RoleNameIterator & other ) : _impl ( Impl : : clone ( other . _impl . get ( ) ) ) { } <nl> + explicit RoleNameIterator ( Impl * impl ) : _impl ( impl ) { } <nl> + <nl> + RoleNameIterator & operator = ( const RoleNameIterator & other ) { <nl> + _impl . reset ( Impl : : clone ( other . _impl . get ( ) ) ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + bool more ( ) const { return _impl . get ( ) & & _impl - > more ( ) ; } <nl> + const RoleName & get ( ) const { return _impl - > get ( ) ; } <nl> + <nl> + const RoleName & next ( ) { return _impl - > next ( ) ; } <nl> + <nl> + const RoleName & operator * ( ) const { return get ( ) ; } <nl> + const RoleName * operator - > ( ) const { return & get ( ) ; } <nl> + <nl> + private : <nl> + boost : : scoped_ptr < Impl > _impl ; <nl> + } ; <nl> + <nl> + } / / namespace mongo <nl> + <nl> + / / Define hash function for RoleNames so they can be keys in std : : unordered_map <nl> + MONGO_HASH_NAMESPACE_START <nl> + template < > struct hash < mongo : : RoleName > { <nl> + size_t operator ( ) ( const mongo : : RoleName & rname ) const { <nl> + return hash < const std : : string & > ( ) ( rname . getFullName ( ) ) ; <nl> + } <nl> + } ; <nl> + MONGO_HASH_NAMESPACE_END <nl> | SERVER - 9518 Initial implementation of RoleGraph data structures | mongodb/mongo | 0467aeb4416f82ff18927f3f887cd181073e1db6 | 2013-05-22T18:08:54Z |
mmm a / tensorflow / lite / micro / simple_memory_allocator . cc <nl> ppp b / tensorflow / lite / micro / simple_memory_allocator . cc <nl> size_t SimpleMemoryAllocator : : GetTailUsedBytes ( ) const { <nl> } <nl> <nl> size_t SimpleMemoryAllocator : : GetAvailableMemory ( size_t alignment ) const { <nl> - uint8_t * const aligned_head = AlignPointerUp ( head_ , alignment ) ; <nl> + uint8_t * const aligned_temp = AlignPointerUp ( temp_ , alignment ) ; <nl> uint8_t * const aligned_tail = AlignPointerDown ( tail_ , alignment ) ; <nl> - return aligned_tail - aligned_head ; <nl> + return aligned_tail - aligned_temp ; <nl> } <nl> <nl> size_t SimpleMemoryAllocator : : GetUsedBytes ( ) const { <nl> - return GetBufferSize ( ) - ( tail_ - head_ ) ; <nl> + return GetBufferSize ( ) - ( tail_ - temp_ ) ; <nl> } <nl> <nl> size_t SimpleMemoryAllocator : : GetBufferSize ( ) const { <nl> mmm a / tensorflow / lite / micro / simple_memory_allocator . h <nl> ppp b / tensorflow / lite / micro / simple_memory_allocator . h <nl> class SimpleMemoryAllocator { <nl> size_t GetHeadUsedBytes ( ) const ; <nl> size_t GetTailUsedBytes ( ) const ; <nl> <nl> - / / Returns the number of bytes available with a given alignment . <nl> + / / Returns the number of bytes available with a given alignment . This number <nl> + / / takes in account any temporary allocations . <nl> size_t GetAvailableMemory ( size_t alignment ) const ; <nl> <nl> + / / Returns the number of used bytes in the allocator . This number takes in <nl> + / / account any temporary allocations . <nl> size_t GetUsedBytes ( ) const ; <nl> <nl> private : <nl> mmm a / tensorflow / lite / micro / simple_memory_allocator_test . cc <nl> ppp b / tensorflow / lite / micro / simple_memory_allocator_test . cc <nl> TF_LITE_MICRO_TEST ( TestAdjustHeadSizeMisalignedHandlesCorrectBytesAvailable ) { <nl> TF_LITE_MICRO_EXPECT_GE ( aligned_available_bytes , arena_size - 1000 - 24 ) ; <nl> } <nl> <nl> + TF_LITE_MICRO_TEST ( TestGetAvailableMemory ) { <nl> + constexpr size_t arena_size = 1024 ; <nl> + uint8_t arena [ arena_size ] ; <nl> + tflite : : SimpleMemoryAllocator allocator ( micro_test : : reporter , arena , <nl> + arena_size ) ; <nl> + <nl> + constexpr size_t allocation_size = 100 ; <nl> + allocator . SetHeadSize ( / * size = * / allocation_size , <nl> + / * alignment = * / 1 ) ; <nl> + allocator . AllocateFromTail ( / * size = * / allocation_size , <nl> + / * alignment = * / 1 ) ; <nl> + <nl> + TF_LITE_MICRO_EXPECT_EQ ( allocator . GetAvailableMemory ( / * alignment = * / 1 ) , <nl> + arena_size - allocation_size * 2 ) ; <nl> + } <nl> + <nl> + TF_LITE_MICRO_TEST ( TestGetAvailableMemoryWithTempAllocations ) { <nl> + constexpr size_t arena_size = 1024 ; <nl> + uint8_t arena [ arena_size ] ; <nl> + tflite : : SimpleMemoryAllocator allocator ( micro_test : : reporter , arena , <nl> + arena_size ) ; <nl> + <nl> + constexpr size_t allocation_size = 100 ; <nl> + allocator . AllocateTemp ( / * size = * / allocation_size , <nl> + / * alignment = * / 1 ) ; <nl> + <nl> + TF_LITE_MICRO_EXPECT_EQ ( allocator . GetAvailableMemory ( / * alignment = * / 1 ) , <nl> + arena_size - allocation_size ) ; <nl> + <nl> + / / Reset temp allocations and ensure GetAvailableMemory ( ) is back to the <nl> + / / starting size : <nl> + allocator . ResetTempAllocations ( ) ; <nl> + <nl> + TF_LITE_MICRO_EXPECT_EQ ( allocator . GetAvailableMemory ( / * alignment = * / 1 ) , <nl> + arena_size ) ; <nl> + } <nl> + <nl> + TF_LITE_MICRO_TEST ( TestGetUsedBytes ) { <nl> + constexpr size_t arena_size = 1024 ; <nl> + uint8_t arena [ arena_size ] ; <nl> + tflite : : SimpleMemoryAllocator allocator ( micro_test : : reporter , arena , <nl> + arena_size ) ; <nl> + TF_LITE_MICRO_EXPECT_EQ ( allocator . GetUsedBytes ( ) , static_cast < size_t > ( 0 ) ) ; <nl> + <nl> + constexpr size_t allocation_size = 100 ; <nl> + allocator . SetHeadSize ( / * size = * / allocation_size , <nl> + / * alignment = * / 1 ) ; <nl> + allocator . AllocateFromTail ( / * size = * / allocation_size , <nl> + / * alignment = * / 1 ) ; <nl> + <nl> + TF_LITE_MICRO_EXPECT_EQ ( allocator . GetUsedBytes ( ) , allocation_size * 2 ) ; <nl> + } <nl> + <nl> + TF_LITE_MICRO_TEST ( TestGetUsedBytesTempAllocations ) { <nl> + constexpr size_t arena_size = 1024 ; <nl> + uint8_t arena [ arena_size ] ; <nl> + tflite : : SimpleMemoryAllocator allocator ( micro_test : : reporter , arena , <nl> + arena_size ) ; <nl> + <nl> + constexpr size_t allocation_size = 100 ; <nl> + allocator . AllocateTemp ( / * size = * / allocation_size , <nl> + / * alignment = * / 1 ) ; <nl> + <nl> + TF_LITE_MICRO_EXPECT_EQ ( allocator . GetUsedBytes ( ) , allocation_size ) ; <nl> + <nl> + / / Reset temp allocations and ensure GetUsedBytes ( ) is back to the starting <nl> + / / size : <nl> + allocator . ResetTempAllocations ( ) ; <nl> + <nl> + TF_LITE_MICRO_EXPECT_EQ ( allocator . GetUsedBytes ( ) , static_cast < size_t > ( 0 ) ) ; <nl> + } <nl> + <nl> TF_LITE_MICRO_TEST ( TestJustFits ) { <nl> constexpr size_t arena_size = 1024 ; <nl> uint8_t arena [ arena_size ] ; <nl> | Return correct size for GetAvailableMemory ( ) and GetUsedBytes ( ) in SimpleMemoryAllocator when temp allocations are used . | tensorflow/tensorflow | 083a88f29d6a4311d682cb63f85fd5b8d0489c37 | 2020-10-06T02:23:18Z |
mmm a / hphp / runtime / vm / extern - compiler . cpp <nl> ppp b / hphp / runtime / vm / extern - compiler . cpp <nl> void ExternCompiler : : start ( ) { <nl> } <nl> <nl> if ( m_pid = = kInvalidPid ) { <nl> - throw BadCompilerException ( <nl> - folly : : to < std : : string > ( <nl> - " Unable to start external compiler with command : " , <nl> - m_options . command ) ) ; <nl> + const auto msg = folly : : to < std : : string > ( <nl> + " Unable to start external compiler with command : " , m_options . command ) ; <nl> + Logger : : Error ( msg ) ; <nl> + throw BadCompilerException ( msg ) ; <nl> } <nl> <nl> m_in = in . detach ( " w " ) ; <nl> | Trivial : log error if hhvm can ' t spawn hackc compiler subprocess | facebook/hhvm | d8903d9b257f812ed77392f53c29b6b91c61f2bb | 2018-02-20T04:07:37Z |
mmm a / cyber / common / file . cc <nl> ppp b / cyber / common / file . cc <nl> bool PathExists ( const std : : string & path ) { <nl> <nl> bool DirectoryExists ( const std : : string & directory_path ) { <nl> struct stat info ; <nl> - return ( stat ( directory_path . c_str ( ) , & info ) = = 0 & & <nl> - info . st_mode & S_IFDIR ) ; <nl> + return stat ( directory_path . c_str ( ) , & info ) = = 0 & & <nl> + ( info . st_mode & S_IFDIR ) ; <nl> } <nl> <nl> std : : vector < std : : string > Glob ( const std : : string & pattern ) { <nl> | Update file . cc | ApolloAuto/apollo | b5b5b1aa433ba15445aad0c5984fb5c61705f2f6 | 2019-04-19T18:07:53Z |
mmm a / hphp / hack / src / heap / hh_shared . c <nl> ppp b / hphp / hack / src / heap / hh_shared . c <nl> void hh_call_after_init ( ) { <nl> * The collector should only be called by the master . <nl> * / <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - void hh_collect ( ) { <nl> + void hh_collect ( value aggressive_val ) { <nl> # ifdef _WIN32 <nl> / / TODO GRGR <nl> return ; <nl> # else <nl> + int aggressive = Bool_val ( aggressive_val ) ; <nl> int flags = MAP_PRIVATE | MAP_ANON | MAP_NORESERVE ; <nl> int prot = PROT_READ | PROT_WRITE ; <nl> char * dest ; <nl> size_t mem_size = 0 ; <nl> char * tmp_heap ; <nl> <nl> - if ( used_heap_size ( ) < 2 * heap_init_size ) { <nl> + float space_overhead = aggressive ? 1 . 2 : 2 . 0 ; <nl> + if ( used_heap_size ( ) < ( size_t ) ( space_overhead * heap_init_size ) ) { <nl> / / We have not grown past twice the size of the initial size <nl> return ; <nl> } <nl> mmm a / hphp / hack / src / heap / sharedMem . ml <nl> ppp b / hphp / hack / src / heap / sharedMem . ml <nl> let init config = <nl> * free data ( cf hh_shared . c for the underlying C implementation ) . <nl> * ) <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> - external hh_collect : unit - > unit = " hh_collect " <nl> + external hh_collect : bool - > unit = " hh_collect " <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Serializes the shared memory and writes it to a file * ) <nl> let hash_stats ( ) = { <nl> slots = hash_slots ( ) ; <nl> } <nl> <nl> - let collect ( ) = <nl> + let collect ( effort : [ ` gentle | ` aggressive ] ) = <nl> let old_size = heap_size ( ) in <nl> let start_t = Unix . gettimeofday ( ) in <nl> - hh_collect ( ) ; <nl> + hh_collect ( effort = ` aggressive ) ; <nl> let new_size = heap_size ( ) in <nl> let time_taken = Unix . gettimeofday ( ) - . start_t in <nl> if old_size < > new_size then <nl> mmm a / hphp / hack / src / heap / sharedMem . mli <nl> ppp b / hphp / hack / src / heap / sharedMem . mli <nl> val init : config - > unit <nl> * ) <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> <nl> - val collect : unit - > unit <nl> + val collect : [ ` gentle | ` aggressive ] - > unit <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Must be called after the initialization of the hack server is over . <nl> mmm a / hphp / hack / src / server / serverIdle . ml <nl> ppp b / hphp / hack / src / server / serverIdle . ml <nl> type callback = <nl> | Once of ( float ref * ( unit - > unit ) ) <nl> <nl> module Periodical : sig <nl> + val always : float <nl> val one_day : float <nl> val one_week : float <nl> <nl> module Periodical : sig <nl> val register_callback : callback - > unit <nl> <nl> end = struct <nl> + let always = 0 . 0 <nl> let one_day = 86400 . 0 <nl> let one_week = 604800 . 0 <nl> <nl> let exit_if_unused ( ) = <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> let init ( root : Path . t ) = <nl> let jobs = [ <nl> + Periodical . always , ( fun ( ) - > SharedMem . collect ` aggressive ) ; <nl> Periodical . one_day , exit_if_unused ; <nl> Periodical . one_day , Hhi . touch ; <nl> ( * try_touch wraps Unix . utimes , which doesn ' t open / close any fds , so we <nl> mmm a / hphp / hack / src / server / serverTypeCheck . ml <nl> ppp b / hphp / hack / src / server / serverTypeCheck . ml <nl> let parsing genv env = <nl> Parser_heap . ParserHeap . remove_batch env . failed_parsing ; <nl> Parser_heap . HH_FIXMES . remove_batch env . failed_parsing ; <nl> HackSearchService . MasterApi . clear_shared_memory env . failed_parsing ; <nl> - SharedMem . collect ( ) ; <nl> + SharedMem . collect ` gentle ; <nl> let get_next = Bucket . make ( Relative_path . Set . elements env . failed_parsing ) in <nl> Parsing_service . go genv . workers ~ get_next <nl> <nl> mmm a / hphp / hack / src / typing / typing_redecl_service . ml <nl> ppp b / hphp / hack / src / typing / typing_redecl_service . ml <nl> let invalidate_heap { FileInfo . n_funs ; n_classes ; n_types ; n_consts } = <nl> Naming_heap . ClassHeap . remove_batch n_classes ; <nl> Naming_heap . TypedefHeap . remove_batch n_types ; <nl> Naming_heap . ConstHeap . remove_batch n_consts ; <nl> - SharedMem . collect ( ) ; <nl> + SharedMem . collect ` gentle ; <nl> ( ) <nl> <nl> let remove_old_defs { FileInfo . n_funs ; n_classes ; n_types ; n_consts } = <nl> let remove_old_defs { FileInfo . n_funs ; n_classes ; n_types ; n_consts } = <nl> Typing_env . Classes . remove_old_batch n_classes ; <nl> Typing_env . Typedefs . remove_old_batch n_types ; <nl> Typing_env . GConsts . remove_old_batch n_consts ; <nl> - SharedMem . collect ( ) ; <nl> + SharedMem . collect ` gentle ; <nl> ( ) <nl> <nl> let get_defs fast = <nl> | GC the shared memory area more aggressively | facebook/hhvm | 220bbc644bd9e81807f71c46b5e1439aaad5eea1 | 2015-08-22T01:00:52Z |
mmm a / src / core / ext / filters / client_channel / client_channel_plugin . cc <nl> ppp b / src / core / ext / filters / client_channel / client_channel_plugin . cc <nl> void grpc_client_channel_init ( void ) { <nl> grpc_core : : GlobalSubchannelPool : : Init ( ) ; <nl> grpc_channel_init_register_stage ( <nl> GRPC_CLIENT_CHANNEL , GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , append_filter , <nl> - ( void * ) & grpc_client_channel_filter ) ; <nl> + const_cast < grpc_channel_filter * > ( & grpc_client_channel_filter ) ) ; <nl> grpc_http_connect_register_handshaker_factory ( ) ; <nl> grpc_client_channel_global_init_backup_polling ( ) ; <nl> } <nl> mmm a / src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb . cc <nl> ppp b / src / core / ext / filters / client_channel / lb_policy / grpclb / grpclb . cc <nl> GrpcLb : : GrpcLb ( Args args ) <nl> } <nl> <nl> GrpcLb : : ~ GrpcLb ( ) { <nl> - gpr_free ( ( void * ) server_name_ ) ; <nl> + gpr_free ( const_cast < char * > ( server_name_ ) ) ; <nl> grpc_channel_args_destroy ( args_ ) ; <nl> } <nl> <nl> void grpc_lb_policy_grpclb_init ( ) { <nl> grpc_core : : LoadBalancingPolicyRegistry : : Builder : : <nl> RegisterLoadBalancingPolicyFactory ( <nl> absl : : make_unique < grpc_core : : GrpcLbFactory > ( ) ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_SUBCHANNEL , <nl> - GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> - maybe_add_client_load_reporting_filter , <nl> - ( void * ) & grpc_client_load_reporting_filter ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_SUBCHANNEL , GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> + maybe_add_client_load_reporting_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_client_load_reporting_filter ) ) ; <nl> } <nl> <nl> void grpc_lb_policy_grpclb_shutdown ( ) { } <nl> mmm a / src / core / ext / filters / deadline / deadline_filter . cc <nl> ppp b / src / core / ext / filters / deadline / deadline_filter . cc <nl> static bool maybe_add_deadline_filter ( grpc_channel_stack_builder * builder , <nl> void grpc_deadline_filter_init ( void ) { <nl> grpc_channel_init_register_stage ( <nl> GRPC_CLIENT_DIRECT_CHANNEL , GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> - maybe_add_deadline_filter , ( void * ) & grpc_client_deadline_filter ) ; <nl> + maybe_add_deadline_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_client_deadline_filter ) ) ; <nl> grpc_channel_init_register_stage ( <nl> GRPC_SERVER_CHANNEL , GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> - maybe_add_deadline_filter , ( void * ) & grpc_server_deadline_filter ) ; <nl> + maybe_add_deadline_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_server_deadline_filter ) ) ; <nl> } <nl> <nl> void grpc_deadline_filter_shutdown ( void ) { } <nl> mmm a / src / core / ext / filters / http / client_authority_filter . cc <nl> ppp b / src / core / ext / filters / http / client_authority_filter . cc <nl> static bool add_client_authority_filter ( grpc_channel_stack_builder * builder , <nl> } <nl> <nl> void grpc_client_authority_filter_init ( void ) { <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_SUBCHANNEL , INT_MAX , <nl> - add_client_authority_filter , <nl> - ( void * ) & grpc_client_authority_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , <nl> - add_client_authority_filter , <nl> - ( void * ) & grpc_client_authority_filter ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_SUBCHANNEL , INT_MAX , add_client_authority_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_client_authority_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , add_client_authority_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_client_authority_filter ) ) ; <nl> } <nl> <nl> void grpc_client_authority_filter_shutdown ( void ) { } <nl> mmm a / src / core / ext / filters / http / http_filters_plugin . cc <nl> ppp b / src / core / ext / filters / http / http_filters_plugin . cc <nl> void grpc_http_filters_init ( void ) { <nl> maybe_add_optional_filter < true > , & decompress_filter ) ; <nl> grpc_channel_init_register_stage ( <nl> GRPC_CLIENT_SUBCHANNEL , GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> - maybe_add_required_filter , ( void * ) & grpc_http_client_filter ) ; <nl> + maybe_add_required_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_http_client_filter ) ) ; <nl> grpc_channel_init_register_stage ( <nl> GRPC_CLIENT_DIRECT_CHANNEL , GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> - maybe_add_required_filter , ( void * ) & grpc_http_client_filter ) ; <nl> + maybe_add_required_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_http_client_filter ) ) ; <nl> grpc_channel_init_register_stage ( <nl> GRPC_SERVER_CHANNEL , GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> - maybe_add_required_filter , ( void * ) & grpc_http_server_filter ) ; <nl> + maybe_add_required_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_http_server_filter ) ) ; <nl> } <nl> <nl> void grpc_http_filters_shutdown ( void ) { } <nl> mmm a / src / core / ext / filters / workarounds / workaround_utils . cc <nl> ppp b / src / core / ext / filters / workarounds / workaround_utils . cc <nl> grpc_workaround_user_agent_md * grpc_parse_user_agent ( grpc_mdelem md ) { <nl> user_agent_md - > workaround_active [ i ] = ua_parser [ i ] ( md ) ; <nl> } <nl> } <nl> - grpc_mdelem_set_user_data ( md , destroy_user_agent_md , ( void * ) user_agent_md ) ; <nl> + grpc_mdelem_set_user_data ( md , destroy_user_agent_md , user_agent_md ) ; <nl> <nl> return user_agent_md ; <nl> } <nl> mmm a / src / core / ext / transport / chttp2 / transport / chttp2_transport . cc <nl> ppp b / src / core / ext / transport / chttp2 / transport / chttp2_transport . cc <nl> grpc_chttp2_stream * grpc_chttp2_parsing_accept_stream ( grpc_chttp2_transport * t , <nl> GPR_ASSERT ( t - > accepting_stream = = nullptr ) ; <nl> t - > accepting_stream = & accepting ; <nl> t - > accept_stream_cb ( t - > accept_stream_cb_user_data , & t - > base , <nl> - ( void * ) static_cast < uintptr_t > ( id ) ) ; <nl> + reinterpret_cast < void * > ( id ) ) ; <nl> t - > accepting_stream = nullptr ; <nl> return accepting ; <nl> } <nl> mmm a / src / core / ext / transport / cronet / transport / cronet_transport . cc <nl> ppp b / src / core / ext / transport / cronet / transport / cronet_transport . cc <nl> static enum e_op_result execute_stream_op ( struct op_and_state * oas ) { <nl> unsigned int header_index ; <nl> for ( header_index = 0 ; header_index < s - > header_array . count ; <nl> header_index + + ) { <nl> - gpr_free ( ( void * ) s - > header_array . headers [ header_index ] . key ) ; <nl> - gpr_free ( ( void * ) s - > header_array . headers [ header_index ] . value ) ; <nl> + gpr_free ( s - > header_array . headers [ header_index ] . key ) ; <nl> + gpr_free ( s - > header_array . headers [ header_index ] . value ) ; <nl> } <nl> stream_state - > state_op_done [ OP_SEND_INITIAL_METADATA ] = true ; <nl> if ( t - > use_packet_coalescing ) { <nl> mmm a / src / core / ext / transport / inproc / inproc_transport . cc <nl> ppp b / src / core / ext / transport / inproc / inproc_transport . cc <nl> struct inproc_stream { <nl> / / side to avoid destruction <nl> INPROC_LOG ( GPR_INFO , " calling accept stream cb % p % p " , <nl> st - > accept_stream_cb , st - > accept_stream_data ) ; <nl> - ( * st - > accept_stream_cb ) ( st - > accept_stream_data , & st - > base , ( void * ) this ) ; <nl> + ( * st - > accept_stream_cb ) ( st - > accept_stream_data , & st - > base , this ) ; <nl> } else { <nl> / / This is the server - side and is being called through accept_stream_cb <nl> inproc_stream * cs = ( inproc_stream * ) server_data ; <nl> mmm a / src / core / lib / gpr / alloc . cc <nl> ppp b / src / core / lib / gpr / alloc . cc <nl> void * gpr_malloc_aligned ( size_t size , size_t alignment ) { <nl> void * p = gpr_malloc ( size + extra ) ; <nl> void * * ret = ( void * * ) ( ( ( uintptr_t ) p + extra ) & ~ ( alignment - 1 ) ) ; <nl> ret [ - 1 ] = p ; <nl> - return ( void * ) ret ; <nl> + return ret ; <nl> } <nl> <nl> void gpr_free_aligned ( void * ptr ) { gpr_free ( ( static_cast < void * * > ( ptr ) ) [ - 1 ] ) ; } <nl> mmm a / src / core / lib / gpr / sync . cc <nl> ppp b / src / core / lib / gpr / sync . cc <nl> void gpr_event_set ( gpr_event * ev , void * value ) { <nl> } <nl> <nl> void * gpr_event_get ( gpr_event * ev ) { <nl> - return ( void * ) gpr_atm_acq_load ( & ev - > state ) ; <nl> + return reinterpret_cast < void * > ( gpr_atm_acq_load ( & ev - > state ) ) ; <nl> } <nl> <nl> void * gpr_event_wait ( gpr_event * ev , gpr_timespec abs_deadline ) { <nl> - void * result = ( void * ) gpr_atm_acq_load ( & ev - > state ) ; <nl> + void * result = reinterpret_cast < void * > ( gpr_atm_acq_load ( & ev - > state ) ) ; <nl> if ( result = = nullptr ) { <nl> struct sync_array_s * s = hash ( ev ) ; <nl> gpr_mu_lock ( & s - > mu ) ; <nl> do { <nl> - result = ( void * ) gpr_atm_acq_load ( & ev - > state ) ; <nl> + result = reinterpret_cast < void * > ( gpr_atm_acq_load ( & ev - > state ) ) ; <nl> } while ( result = = nullptr & & ! gpr_cv_wait ( & s - > cv , & s - > mu , abs_deadline ) ) ; <nl> gpr_mu_unlock ( & s - > mu ) ; <nl> } <nl> mmm a / src / core / lib / http / parser . cc <nl> ppp b / src / core / lib / http / parser . cc <nl> static grpc_error * addbyte_body ( grpc_http_parser * parser , uint8_t byte ) { <nl> <nl> if ( * body_length = = parser - > body_capacity ) { <nl> parser - > body_capacity = GPR_MAX ( 8 , parser - > body_capacity * 3 / 2 ) ; <nl> - * body = <nl> - static_cast < char * > ( gpr_realloc ( ( void * ) * body , parser - > body_capacity ) ) ; <nl> + * body = static_cast < char * > ( gpr_realloc ( * body , parser - > body_capacity ) ) ; <nl> } <nl> ( * body ) [ * body_length ] = static_cast < char > ( byte ) ; <nl> ( * body_length ) + + ; <nl> mmm a / src / core / lib / iomgr / error . cc <nl> ppp b / src / core / lib / iomgr / error . cc <nl> static void error_destroy ( grpc_error * err ) { <nl> GPR_ASSERT ( ! grpc_error_is_special ( err ) ) ; <nl> unref_errs ( err ) ; <nl> unref_strs ( err ) ; <nl> - gpr_free ( ( void * ) gpr_atm_acq_load ( & err - > atomics . error_string ) ) ; <nl> + gpr_free ( <nl> + reinterpret_cast < void * > ( gpr_atm_acq_load ( & err - > atomics . error_string ) ) ) ; <nl> gpr_free ( err ) ; <nl> } <nl> <nl> static void internal_set_str ( grpc_error * * err , grpc_error_strs which , <nl> if ( slot = = UINT8_MAX ) { <nl> slot = get_placement ( err , sizeof ( value ) ) ; <nl> if ( slot = = UINT8_MAX ) { <nl> - const char * str = grpc_slice_to_c_string ( value ) ; <nl> + char * str = grpc_slice_to_c_string ( value ) ; <nl> gpr_log ( GPR_ERROR , " Error % p is full , dropping string { \ " % s \ " : \ " % s \ " } " , <nl> * err , error_str_name ( which ) , str ) ; <nl> - gpr_free ( ( void * ) str ) ; <nl> + gpr_free ( str ) ; <nl> return ; <nl> } <nl> } else { <nl> static void internal_set_time ( grpc_error * * err , grpc_error_times which , <nl> if ( slot = = UINT8_MAX ) { <nl> slot = get_placement ( err , sizeof ( value ) ) ; <nl> if ( slot = = UINT8_MAX ) { <nl> - const char * time_str = fmt_time ( value ) ; <nl> + char * time_str = fmt_time ( value ) ; <nl> gpr_log ( GPR_ERROR , " Error % p is full , dropping \ " % s \ " : \ " % s \ " } " , * err , <nl> error_time_name ( which ) , time_str ) ; <nl> - gpr_free ( ( void * ) time_str ) ; <nl> + gpr_free ( time_str ) ; <nl> return ; <nl> } <nl> } <nl> static grpc_error * copy_error_and_unref ( grpc_error * in ) { <nl> / / bulk memcpy of the rest of the struct . <nl> / / NOLINTNEXTLINE ( bugprone - sizeof - expression ) <nl> size_t skip = sizeof ( & out - > atomics ) ; <nl> - memcpy ( ( void * ) ( ( uintptr_t ) out + skip ) , ( void * ) ( ( uintptr_t ) in + skip ) , <nl> + memcpy ( reinterpret_cast < void * > ( ( uintptr_t ) out + skip ) , <nl> + ( void * ) ( ( uintptr_t ) in + skip ) , <nl> sizeof ( * in ) + ( in - > arena_size * sizeof ( intptr_t ) ) - skip ) ; <nl> / / manually set the atomics and the new capacity <nl> gpr_atm_no_barrier_store ( & out - > atomics . error_string , 0 ) ; <nl> const char * grpc_error_string ( grpc_error * err ) { <nl> if ( err = = GRPC_ERROR_OOM ) return oom_error_string ; <nl> if ( err = = GRPC_ERROR_CANCELLED ) return cancelled_error_string ; <nl> <nl> - void * p = ( void * ) gpr_atm_acq_load ( & err - > atomics . error_string ) ; <nl> + void * p = <nl> + reinterpret_cast < void * > ( gpr_atm_acq_load ( & err - > atomics . error_string ) ) ; <nl> if ( p ! = nullptr ) { <nl> return static_cast < const char * > ( p ) ; <nl> } <nl> mmm a / src / core / lib / iomgr / ev_epoll1_linux . cc <nl> ppp b / src / core / lib / iomgr / ev_epoll1_linux . cc <nl> static grpc_error * pollset_kick ( grpc_pollset * pollset , <nl> std : : vector < std : : string > log ; <nl> log . push_back ( absl : : StrFormat ( <nl> " PS : % p KICK : % p curps = % p curworker = % p root = % p " , pollset , specific_worker , <nl> - ( void * ) gpr_tls_get ( & g_current_thread_pollset ) , <nl> - ( void * ) gpr_tls_get ( & g_current_thread_worker ) , pollset - > root_worker ) ) ; <nl> + reinterpret_cast < void * > ( gpr_tls_get ( & g_current_thread_pollset ) ) , <nl> + reinterpret_cast < void * > ( gpr_tls_get ( & g_current_thread_worker ) ) , <nl> + pollset - > root_worker ) ) ; <nl> if ( pollset - > root_worker ! = nullptr ) { <nl> log . push_back ( absl : : StrFormat ( <nl> " { kick_state = % s next = % p { kick_state = % s } } " , <nl> mmm a / src / core / lib / iomgr / ev_epollex_linux . cc <nl> ppp b / src / core / lib / iomgr / ev_epollex_linux . cc <nl> static grpc_error * pollable_create ( pollable_type type , pollable * * p ) { <nl> } <nl> struct epoll_event ev ; <nl> ev . events = static_cast < uint32_t > ( EPOLLIN | EPOLLET ) ; <nl> - ev . data . ptr = ( void * ) ( 1 | ( intptr_t ) & ( * p ) - > wakeup ) ; <nl> + ev . data . ptr = reinterpret_cast < void * > ( 1 | ( intptr_t ) & ( * p ) - > wakeup ) ; <nl> if ( epoll_ctl ( epfd , EPOLL_CTL_ADD , ( * p ) - > wakeup . read_fd , & ev ) ! = 0 ) { <nl> err = GRPC_OS_ERROR ( errno , " epoll_ctl " ) ; <nl> GRPC_FD_TRACE ( <nl> static grpc_error * pollset_kick ( grpc_pollset * pollset , <nl> if ( GRPC_TRACE_FLAG_ENABLED ( grpc_polling_trace ) ) { <nl> gpr_log ( GPR_INFO , <nl> " PS : % p kick % p tls_pollset = % p tls_worker = % p pollset . root_worker = % p " , <nl> - pollset , specific_worker , <nl> - ( void * ) gpr_tls_get ( & g_current_thread_pollset ) , <nl> - ( void * ) gpr_tls_get ( & g_current_thread_worker ) , pollset - > root_worker ) ; <nl> + static_cast < void * > ( pollset ) , specific_worker , <nl> + gpr_tls_get ( & g_current_thread_pollset ) , <nl> + gpr_tls_get ( & g_current_thread_worker ) , pollset - > root_worker ) ; <nl> } <nl> if ( specific_worker = = nullptr ) { <nl> if ( gpr_tls_get ( & g_current_thread_pollset ) ! = ( intptr_t ) pollset ) { <nl> mmm a / src / core / lib / iomgr / ev_poll_posix . cc <nl> ppp b / src / core / lib / iomgr / ev_poll_posix . cc <nl> static grpc_error * pollset_work ( grpc_pollset * pollset , <nl> void * buf = gpr_malloc ( pfd_size + watch_size ) ; <nl> pfds = static_cast < struct pollfd * > ( buf ) ; <nl> watchers = static_cast < grpc_fd_watcher * > ( <nl> - ( void * ) ( static_cast < char * > ( buf ) + pfd_size ) ) ; <nl> + static_cast < void * > ( ( static_cast < char * > ( buf ) + pfd_size ) ) ) ; <nl> } <nl> <nl> fd_count = 0 ; <nl> mmm a / src / core / lib / iomgr / lockfree_event . cc <nl> ppp b / src / core / lib / iomgr / lockfree_event . cc <nl> void LockfreeEvent : : NotifyOn ( grpc_closure * closure ) { <nl> gpr_atm curr = gpr_atm_acq_load ( & state_ ) ; <nl> if ( GRPC_TRACE_FLAG_ENABLED ( grpc_polling_trace ) ) { <nl> gpr_log ( GPR_DEBUG , " LockfreeEvent : : NotifyOn : % p curr = % p closure = % p " , this , <nl> - ( void * ) curr , closure ) ; <nl> + reinterpret_cast < void * > ( curr ) , closure ) ; <nl> } <nl> switch ( curr ) { <nl> case kClosureNotReady : { <nl> bool LockfreeEvent : : SetShutdown ( grpc_error * shutdown_error ) { <nl> gpr_atm curr = gpr_atm_no_barrier_load ( & state_ ) ; <nl> if ( GRPC_TRACE_FLAG_ENABLED ( grpc_polling_trace ) ) { <nl> gpr_log ( GPR_DEBUG , " LockfreeEvent : : SetShutdown : % p curr = % p err = % s " , <nl> - & state_ , ( void * ) curr , grpc_error_string ( shutdown_error ) ) ; <nl> + & state_ , reinterpret_cast < void * > ( curr ) , <nl> + grpc_error_string ( shutdown_err ) ) ; <nl> } <nl> switch ( curr ) { <nl> case kClosureReady : <nl> void LockfreeEvent : : SetReady ( ) { <nl> <nl> if ( GRPC_TRACE_FLAG_ENABLED ( grpc_polling_trace ) ) { <nl> gpr_log ( GPR_DEBUG , " LockfreeEvent : : SetReady : % p curr = % p " , & state_ , <nl> - ( void * ) curr ) ; <nl> + reinterpret_cast < void * > ( curr ) ) ; <nl> } <nl> <nl> switch ( curr ) { <nl> mmm a / src / core / lib / iomgr / tcp_server_custom . cc <nl> ppp b / src / core / lib / iomgr / tcp_server_custom . cc <nl> static grpc_error * add_socket_to_server ( grpc_tcp_server * s , <nl> } <nl> <nl> error = grpc_custom_socket_vtable - > bind ( <nl> - socket , reinterpret_cast < grpc_sockaddr * > ( addr - > addr ) , addr - > len , flags ) ; <nl> + socket , reinterpret_cast < grpc_sockaddr * > ( const_cast < char * > ( addr - > addr ) ) , <nl> + addr - > len , flags ) ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> return error ; <nl> } <nl> mmm a / src / core / lib / iomgr / timer_custom . cc <nl> ppp b / src / core / lib / iomgr / timer_custom . cc <nl> static void timer_init ( grpc_timer * timer , grpc_millis deadline , <nl> grpc_custom_timer * timer_wrapper = <nl> static_cast < grpc_custom_timer * > ( gpr_malloc ( sizeof ( grpc_custom_timer ) ) ) ; <nl> timer_wrapper - > timeout_ms = timeout ; <nl> - timer - > custom_timer = ( void * ) timer_wrapper ; <nl> + timer - > custom_timer = timer_wrapper ; <nl> timer_wrapper - > original = timer ; <nl> custom_timer_impl - > start ( timer_wrapper ) ; <nl> } <nl> mmm a / src / core / lib / security / credentials / jwt / json_token . cc <nl> ppp b / src / core / lib / security / credentials / jwt / json_token . cc <nl> grpc_auth_json_key grpc_auth_json_key_create_from_json ( const Json & json ) { <nl> goto end ; <nl> } <nl> result . private_key = <nl> - PEM_read_bio_RSAPrivateKey ( bio , nullptr , nullptr , ( void * ) " " ) ; <nl> + PEM_read_bio_RSAPrivateKey ( bio , nullptr , nullptr , const_cast < char * > ( " " ) ) ; <nl> if ( result . private_key = = nullptr ) { <nl> gpr_log ( GPR_ERROR , " Could not deserialize private key . " ) ; <nl> goto end ; <nl> mmm a / src / core / lib / security / credentials / jwt / jwt_verifier . cc <nl> ppp b / src / core / lib / security / credentials / jwt / jwt_verifier . cc <nl> const char * grpc_jwt_issuer_email_domain ( const char * issuer ) { <nl> if ( dot = = nullptr | | dot = = email_domain ) return email_domain ; <nl> GPR_ASSERT ( dot > email_domain ) ; <nl> / * There may be a subdomain , we just want the domain . * / <nl> - dot = static_cast < const char * > ( gpr_memrchr ( <nl> - ( void * ) email_domain , ' . ' , static_cast < size_t > ( dot - email_domain ) ) ) ; <nl> + dot = static_cast < const char * > ( <nl> + gpr_memrchr ( email_domain , ' . ' , static_cast < size_t > ( dot - email_domain ) ) ) ; <nl> if ( dot = = nullptr ) return email_domain ; <nl> return dot + 1 ; <nl> } <nl> mmm a / src / core / lib / security / credentials / plugin / plugin_credentials . cc <nl> ppp b / src / core / lib / security / credentials / plugin / plugin_credentials . cc <nl> bool grpc_plugin_credentials : : get_request_metadata ( <nl> grpc_slice_unref_internal ( creds_md [ i ] . key ) ; <nl> grpc_slice_unref_internal ( creds_md [ i ] . value ) ; <nl> } <nl> - gpr_free ( ( void * ) error_details ) ; <nl> + gpr_free ( const_cast < char * > ( error_details ) ) ; <nl> gpr_free ( request ) ; <nl> } <nl> return retval ; <nl> mmm a / src / core / lib / security / credentials / ssl / ssl_credentials . cc <nl> ppp b / src / core / lib / security / credentials / ssl / ssl_credentials . cc <nl> void grpc_tsi_ssl_pem_key_cert_pairs_destroy ( tsi_ssl_pem_key_cert_pair * kp , <nl> size_t num_key_cert_pairs ) { <nl> if ( kp = = nullptr ) return ; <nl> for ( size_t i = 0 ; i < num_key_cert_pairs ; i + + ) { <nl> - gpr_free ( ( void * ) kp [ i ] . private_key ) ; <nl> - gpr_free ( ( void * ) kp [ i ] . cert_chain ) ; <nl> + gpr_free ( const_cast < char * > ( kp [ i ] . private_key ) ) ; <nl> + gpr_free ( const_cast < char * > ( kp [ i ] . cert_chain ) ) ; <nl> } <nl> gpr_free ( kp ) ; <nl> } <nl> void grpc_ssl_server_certificate_config_destroy ( <nl> grpc_ssl_server_certificate_config * config ) { <nl> if ( config = = nullptr ) return ; <nl> for ( size_t i = 0 ; i < config - > num_key_cert_pairs ; i + + ) { <nl> - gpr_free ( ( void * ) config - > pem_key_cert_pairs [ i ] . private_key ) ; <nl> - gpr_free ( ( void * ) config - > pem_key_cert_pairs [ i ] . cert_chain ) ; <nl> + gpr_free ( const_cast < char * > ( config - > pem_key_cert_pairs [ i ] . private_key ) ) ; <nl> + gpr_free ( const_cast < char * > ( config - > pem_key_cert_pairs [ i ] . cert_chain ) ) ; <nl> } <nl> gpr_free ( config - > pem_key_cert_pairs ) ; <nl> gpr_free ( config - > pem_root_certs ) ; <nl> mmm a / src / core / lib / security / credentials / tls / grpc_tls_certificate_provider . cc <nl> ppp b / src / core / lib / security / credentials / tls / grpc_tls_certificate_provider . cc <nl> FileWatcherCertificateProvider : : ~ FileWatcherCertificateProvider ( ) { <nl> / / Reset distributor ' s callback to make sure the callback won ' t be invoked <nl> / / again after this object ( provider ) is destroyed . <nl> distributor_ - > SetWatchStatusCallback ( nullptr ) ; <nl> - gpr_event_set ( & shutdown_event_ , ( void * ) ( 1 ) ) ; <nl> + gpr_event_set ( & shutdown_event_ , reinterpret_cast < void * > ( 1 ) ) ; <nl> refresh_thread_ . Join ( ) ; <nl> } <nl> <nl> mmm a / src / core / lib / security / security_connector / ssl / ssl_security_connector . cc <nl> ppp b / src / core / lib / security / security_connector / ssl / ssl_security_connector . cc <nl> class grpc_ssl_channel_security_connector final <nl> const tsi_result result = <nl> tsi_create_ssl_client_handshaker_factory_with_options ( <nl> & options , & client_handshaker_factory_ ) ; <nl> - gpr_free ( ( void * ) options . alpn_protocols ) ; <nl> + gpr_free ( options . alpn_protocols ) ; <nl> if ( result ! = TSI_OK ) { <nl> gpr_log ( GPR_ERROR , " Handshaker factory creation failed with % s . " , <nl> tsi_result_to_string ( result ) ) ; <nl> class grpc_ssl_server_security_connector <nl> const tsi_result result = <nl> tsi_create_ssl_server_handshaker_factory_with_options ( <nl> & options , & server_handshaker_factory_ ) ; <nl> - gpr_free ( ( void * ) alpn_protocol_strings ) ; <nl> + gpr_free ( alpn_protocol_strings ) ; <nl> if ( result ! = TSI_OK ) { <nl> gpr_log ( GPR_ERROR , " Handshaker factory creation failed with % s . " , <nl> tsi_result_to_string ( result ) ) ; <nl> class grpc_ssl_server_security_connector <nl> grpc_tsi_ssl_pem_key_cert_pairs_destroy ( <nl> const_cast < tsi_ssl_pem_key_cert_pair * > ( options . pem_key_cert_pairs ) , <nl> options . num_key_cert_pairs ) ; <nl> - gpr_free ( ( void * ) alpn_protocol_strings ) ; <nl> + gpr_free ( alpn_protocol_strings ) ; <nl> <nl> if ( result ! = TSI_OK ) { <nl> gpr_log ( GPR_ERROR , " Handshaker factory creation failed with % s . " , <nl> mmm a / src / core / lib / security / security_connector / ssl_utils . cc <nl> ppp b / src / core / lib / security / security_connector / ssl_utils . cc <nl> grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init ( <nl> const tsi_result result = <nl> tsi_create_ssl_client_handshaker_factory_with_options ( & options , <nl> handshaker_factory ) ; <nl> - gpr_free ( ( void * ) options . alpn_protocols ) ; <nl> + gpr_free ( options . alpn_protocols ) ; <nl> if ( result ! = TSI_OK ) { <nl> gpr_log ( GPR_ERROR , " Handshaker factory creation failed with % s . " , <nl> tsi_result_to_string ( result ) ) ; <nl> grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init ( <nl> const tsi_result result = <nl> tsi_create_ssl_server_handshaker_factory_with_options ( & options , <nl> handshaker_factory ) ; <nl> - gpr_free ( ( void * ) alpn_protocol_strings ) ; <nl> + gpr_free ( alpn_protocol_strings ) ; <nl> if ( result ! = TSI_OK ) { <nl> gpr_log ( GPR_ERROR , " Handshaker factory creation failed with % s . " , <nl> tsi_result_to_string ( result ) ) ; <nl> mmm a / src / core / lib / security / security_connector / tls / tls_security_connector . cc <nl> ppp b / src / core / lib / security / security_connector / tls / tls_security_connector . cc <nl> void TlsChannelSecurityConnector : : ServerAuthorizationCheckArgDestroy ( <nl> if ( arg = = nullptr ) { <nl> return ; <nl> } <nl> - gpr_free ( ( void * ) arg - > target_name ) ; <nl> - gpr_free ( ( void * ) arg - > peer_cert ) ; <nl> - if ( arg - > peer_cert_full_chain ) gpr_free ( ( void * ) arg - > peer_cert_full_chain ) ; <nl> + gpr_free ( const_cast < char * > ( arg - > target_name ) ) ; <nl> + gpr_free ( const_cast < char * > ( arg - > peer_cert ) ) ; <nl> + if ( arg - > peer_cert_full_chain ) { <nl> + gpr_free ( const_cast < char * > ( arg - > peer_cert_full_chain ) ) ; <nl> + } <nl> delete arg - > error_details ; <nl> if ( arg - > destroy_context ! = nullptr ) { <nl> arg - > destroy_context ( arg - > context ) ; <nl> mmm a / src / core / lib / surface / call . cc <nl> ppp b / src / core / lib / surface / call . cc <nl> static void set_encodings_accepted_by_peer ( grpc_call * / * call * / , <nl> <nl> grpc_mdelem_set_user_data ( <nl> mdel , destroy_encodings_accepted_by_peer , <nl> - ( void * ) ( ( static_cast < uintptr_t > ( * encodings_accepted_by_peer ) ) + 1 ) ) ; <nl> + reinterpret_cast < void * > ( <nl> + ( static_cast < uintptr_t > ( * encodings_accepted_by_peer ) ) + 1 ) ) ; <nl> } <nl> <nl> uint32_t grpc_call_test_only_get_encodings_accepted_by_peer ( grpc_call * call ) { <nl> mmm a / src / core / lib / surface / channel_init . cc <nl> ppp b / src / core / lib / surface / channel_init . cc <nl> void grpc_channel_init_shutdown ( void ) { <nl> for ( int i = 0 ; i < GRPC_NUM_CHANNEL_STACK_TYPES ; i + + ) { <nl> gpr_free ( g_slots [ i ] . slots ) ; <nl> g_slots [ i ] . slots = <nl> - static_cast < stage_slot * > ( ( void * ) static_cast < uintptr_t > ( 0xdeadbeef ) ) ; <nl> + static_cast < stage_slot * > ( reinterpret_cast < void * > ( 0xdeadbeef ) ) ; <nl> } <nl> } <nl> <nl> mmm a / src / core / lib / surface / init . cc <nl> ppp b / src / core / lib / surface / init . cc <nl> static void register_builtin_channel_init ( ) { <nl> grpc_channel_init_register_stage ( GRPC_SERVER_CHANNEL , <nl> GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> grpc_add_connected_filter , nullptr ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_LAME_CHANNEL , <nl> - GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> - append_filter , ( void * ) & grpc_lame_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_SERVER_CHANNEL , INT_MAX , prepend_filter , <nl> - ( void * ) & grpc_core : : Server : : kServerTopFilter ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_LAME_CHANNEL , GRPC_CHANNEL_INIT_BUILTIN_PRIORITY , <nl> + append_filter , const_cast < grpc_channel_filter * > ( & grpc_lame_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_SERVER_CHANNEL , INT_MAX , prepend_filter , <nl> + const_cast < grpc_channel_filter * > ( & grpc_core : : Server : : kServerTopFilter ) ) ; <nl> } <nl> <nl> typedef struct grpc_plugin { <nl> mmm a / src / core / lib / transport / status_metadata . cc <nl> ppp b / src / core / lib / transport / status_metadata . cc <nl> grpc_status_code grpc_get_status_code_from_metadata ( grpc_mdelem md ) { <nl> if ( ! grpc_parse_slice_to_uint32 ( GRPC_MDVALUE ( md ) , & status ) ) { <nl> status = GRPC_STATUS_UNKNOWN ; / * could not parse status code * / <nl> } <nl> - grpc_mdelem_set_user_data ( <nl> - md , destroy_status , ( void * ) static_cast < intptr_t > ( status + STATUS_OFFSET ) ) ; <nl> + grpc_mdelem_set_user_data ( md , destroy_status , <nl> + reinterpret_cast < void * > ( status + STATUS_OFFSET ) ) ; <nl> return static_cast < grpc_status_code > ( status ) ; <nl> } <nl> <nl> mmm a / src / core / tsi / alts / crypt / gsec . cc <nl> ppp b / src / core / tsi / alts / crypt / gsec . cc <nl> grpc_status_code gsec_aead_crypter_encrypt ( <nl> char * * error_details ) { <nl> if ( crypter ! = nullptr & & crypter - > vtable ! = nullptr & & <nl> crypter - > vtable - > encrypt_iovec ! = nullptr ) { <nl> - struct iovec aad_vec = { ( void * ) aad , aad_length } ; <nl> - struct iovec plaintext_vec = { ( void * ) plaintext , plaintext_length } ; <nl> + struct iovec aad_vec = { const_cast < uint8_t * > ( aad ) , aad_length } ; <nl> + struct iovec plaintext_vec = { const_cast < uint8_t * > ( plaintext ) , <nl> + plaintext_length } ; <nl> struct iovec ciphertext_vec = { ciphertext_and_tag , <nl> ciphertext_and_tag_length } ; <nl> return crypter - > vtable - > encrypt_iovec ( <nl> grpc_status_code gsec_aead_crypter_decrypt ( <nl> size_t plaintext_length , size_t * bytes_written , char * * error_details ) { <nl> if ( crypter ! = nullptr & & crypter - > vtable ! = nullptr & & <nl> crypter - > vtable - > decrypt_iovec ! = nullptr ) { <nl> - struct iovec aad_vec = { ( void * ) aad , aad_length } ; <nl> - struct iovec ciphertext_vec = { ( void * ) ciphertext_and_tag , <nl> + struct iovec aad_vec = { const_cast < uint8_t * > ( aad ) , aad_length } ; <nl> + struct iovec ciphertext_vec = { const_cast < uint8_t * > ( ciphertext_and_tag ) , <nl> ciphertext_and_tag_length } ; <nl> struct iovec plaintext_vec = { plaintext , plaintext_length } ; <nl> return crypter - > vtable - > decrypt_iovec ( <nl> mmm a / src / core / tsi / ssl_transport_security . cc <nl> ppp b / src / core / tsi / ssl_transport_security . cc <nl> static tsi_result ssl_ctx_use_certificate_chain ( SSL_CTX * context , <nl> X509 * certificate = nullptr ; <nl> BIO * pem ; <nl> GPR_ASSERT ( pem_cert_chain_size < = INT_MAX ) ; <nl> - pem = BIO_new_mem_buf ( ( void * ) pem_cert_chain , <nl> - static_cast < int > ( pem_cert_chain_size ) ) ; <nl> + pem = BIO_new_mem_buf ( pem_cert_chain , static_cast < int > ( pem_cert_chain_size ) ) ; <nl> if ( pem = = nullptr ) return TSI_OUT_OF_RESOURCES ; <nl> <nl> do { <nl> - certificate = PEM_read_bio_X509_AUX ( pem , nullptr , nullptr , ( void * ) " " ) ; <nl> + certificate = <nl> + PEM_read_bio_X509_AUX ( pem , nullptr , nullptr , const_cast < char * > ( " " ) ) ; <nl> if ( certificate = = nullptr ) { <nl> result = TSI_INVALID_ARGUMENT ; <nl> break ; <nl> static tsi_result ssl_ctx_use_certificate_chain ( SSL_CTX * context , <nl> } <nl> while ( true ) { <nl> X509 * certificate_authority = <nl> - PEM_read_bio_X509 ( pem , nullptr , nullptr , ( void * ) " " ) ; <nl> + PEM_read_bio_X509 ( pem , nullptr , nullptr , const_cast < char * > ( " " ) ) ; <nl> if ( certificate_authority = = nullptr ) { <nl> ERR_clear_error ( ) ; <nl> break ; / * Done reading . * / <nl> static tsi_result ssl_ctx_use_pem_private_key ( SSL_CTX * context , <nl> EVP_PKEY * private_key = nullptr ; <nl> BIO * pem ; <nl> GPR_ASSERT ( pem_key_size < = INT_MAX ) ; <nl> - pem = BIO_new_mem_buf ( ( void * ) pem_key , static_cast < int > ( pem_key_size ) ) ; <nl> + pem = BIO_new_mem_buf ( pem_key , static_cast < int > ( pem_key_size ) ) ; <nl> if ( pem = = nullptr ) return TSI_OUT_OF_RESOURCES ; <nl> do { <nl> - private_key = PEM_read_bio_PrivateKey ( pem , nullptr , nullptr , ( void * ) " " ) ; <nl> + private_key = <nl> + PEM_read_bio_PrivateKey ( pem , nullptr , nullptr , const_cast < char * > ( " " ) ) ; <nl> if ( private_key = = nullptr ) { <nl> result = TSI_INVALID_ARGUMENT ; <nl> break ; <nl> static tsi_result x509_store_load_certs ( X509_STORE * cert_store , <nl> X509_NAME * root_name = nullptr ; <nl> BIO * pem ; <nl> GPR_ASSERT ( pem_roots_size < = INT_MAX ) ; <nl> - pem = BIO_new_mem_buf ( ( void * ) pem_roots , static_cast < int > ( pem_roots_size ) ) ; <nl> + pem = BIO_new_mem_buf ( pem_roots , static_cast < int > ( pem_roots_size ) ) ; <nl> if ( cert_store = = nullptr ) return TSI_INVALID_ARGUMENT ; <nl> if ( pem = = nullptr ) return TSI_OUT_OF_RESOURCES ; <nl> if ( root_names ! = nullptr ) { <nl> static tsi_result x509_store_load_certs ( X509_STORE * cert_store , <nl> } <nl> <nl> while ( true ) { <nl> - root = PEM_read_bio_X509_AUX ( pem , nullptr , nullptr , ( void * ) " " ) ; <nl> + root = PEM_read_bio_X509_AUX ( pem , nullptr , nullptr , const_cast < char * > ( " " ) ) ; <nl> if ( root = = nullptr ) { <nl> ERR_clear_error ( ) ; <nl> break ; / * We ' re at the end of stream . * / <nl> tsi_result tsi_ssl_extract_x509_subject_names_from_pem_cert ( <nl> tsi_result result = TSI_OK ; <nl> X509 * cert = nullptr ; <nl> BIO * pem ; <nl> - pem = BIO_new_mem_buf ( ( void * ) pem_cert , static_cast < int > ( strlen ( pem_cert ) ) ) ; <nl> + pem = BIO_new_mem_buf ( pem_cert , static_cast < int > ( strlen ( pem_cert ) ) ) ; <nl> if ( pem = = nullptr ) return TSI_OUT_OF_RESOURCES ; <nl> <nl> - cert = PEM_read_bio_X509 ( pem , nullptr , nullptr , ( void * ) " " ) ; <nl> + cert = PEM_read_bio_X509 ( pem , nullptr , nullptr , const_cast < char * > ( " " ) ) ; <nl> if ( cert = = nullptr ) { <nl> gpr_log ( GPR_ERROR , " Invalid certificate " ) ; <nl> result = TSI_INVALID_ARGUMENT ; <nl> mmm a / src / cpp / common / channel_filter . cc <nl> ppp b / src / cpp / common / channel_filter . cc <nl> void ChannelFilterPluginInit ( ) { <nl> for ( size_t i = 0 ; i < channel_filters - > size ( ) ; + + i ) { <nl> FilterRecord & filter = ( * channel_filters ) [ i ] ; <nl> grpc_channel_init_register_stage ( filter . stack_type , filter . priority , <nl> - MaybeAddFilter , ( void * ) & filter ) ; <nl> + MaybeAddFilter , & filter ) ; <nl> } <nl> } <nl> <nl> mmm a / src / cpp / server / server_builder . cc <nl> ppp b / src / cpp / server / server_builder . cc <nl> ServerBuilder & ServerBuilder : : RegisterAsyncGenericService ( <nl> gpr_log ( GPR_ERROR , <nl> " Adding multiple generic services is unsupported for now . " <nl> " Dropping the service % p " , <nl> - ( void * ) service ) ; <nl> + service ) ; <nl> } else { <nl> generic_service_ = service ; <nl> } <nl> ServerBuilder & ServerBuilder : : experimental_type : : RegisterCallbackGenericService ( <nl> gpr_log ( GPR_ERROR , <nl> " Adding multiple generic services is unsupported for now . " <nl> " Dropping the service % p " , <nl> - ( void * ) service ) ; <nl> + service ) ; <nl> } else { <nl> builder_ - > callback_generic_service_ = service ; <nl> } <nl> mmm a / test / core / bad_client / bad_client . cc <nl> ppp b / test / core / bad_client / bad_client . cc <nl> static void thd_func ( void * arg ) { <nl> if ( a - > validator ! = nullptr ) { <nl> a - > validator ( a - > server , a - > cq , a - > registered_method ) ; <nl> } <nl> - gpr_event_set ( & a - > done_thd , ( void * ) 1 ) ; <nl> + gpr_event_set ( & a - > done_thd , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> / * Sets the done_write event * / <nl> static void set_done_write ( void * arg , grpc_error * / * error * / ) { <nl> gpr_event * done_write = static_cast < gpr_event * > ( arg ) ; <nl> - gpr_event_set ( done_write , ( void * ) 1 ) ; <nl> + gpr_event_set ( done_write , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> static void server_setup_transport ( void * ts , grpc_transport * transport ) { <nl> static void server_setup_transport ( void * ts , grpc_transport * transport ) { <nl> / * Sets the read_done event * / <nl> static void set_read_done ( void * arg , grpc_error * / * error * / ) { <nl> gpr_event * read_done = static_cast < gpr_event * > ( arg ) ; <nl> - gpr_event_set ( read_done , ( void * ) 1 ) ; <nl> + gpr_event_set ( read_done , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> / * shutdown client * / <nl> bool rst_stream_client_validator ( grpc_slice_buffer * incoming , void * / * arg * / ) { <nl> return success ; <nl> } <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> void server_verifier_request_call ( grpc_server * server , <nl> grpc_completion_queue * cq , <nl> mmm a / test / core / bad_client / tests / duplicate_header . cc <nl> ppp b / test / core / bad_client / tests / duplicate_header . cc <nl> <nl> " \ x00 \ x00 \ x20 \ x00 \ x00 \ x00 \ x00 \ x00 \ x01 " \ <nl> " \ x00 \ x00 \ x00 \ x00 " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void verifier ( grpc_server * server , grpc_completion_queue * cq , <nl> void * / * registered_method * / ) { <nl> mmm a / test / core / bad_client / tests / head_of_line_blocking . cc <nl> ppp b / test / core / bad_client / tests / head_of_line_blocking . cc <nl> static const char prefix [ ] = <nl> " \ x01 \ x00 \ x00 \ x27 \ x10 " <nl> " " ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void verifier ( grpc_server * server , grpc_completion_queue * cq , <nl> void * registered_method ) { <nl> mmm a / test / core / bad_client / tests / server_registered_method . cc <nl> ppp b / test / core / bad_client / tests / server_registered_method . cc <nl> <nl> " \ x10 \ x02te \ x08trailers " \ <nl> " \ x10 \ x0auser - agent \ " bad - client grpc - c / 0 . 12 . 0 . 0 ( linux ) " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void verifier_succeeds ( grpc_server * server , grpc_completion_queue * cq , <nl> void * registered_method ) { <nl> mmm a / test / core / bad_client / tests / simple_request . cc <nl> ppp b / test / core / bad_client / tests / simple_request . cc <nl> <nl> " \ x10 \ x0cgrpc - timeout \ x02 " \ <nl> " 5S " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void verifier ( grpc_server * server , grpc_completion_queue * cq , <nl> void * / * registered_method * / ) { <nl> mmm a / test / core / bad_connection / close_fd_test . cc <nl> ppp b / test / core / bad_connection / close_fd_test . cc <nl> <nl> # include " src / core / lib / surface / completion_queue . h " <nl> # include " src / core / lib / surface / server . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> typedef struct test_ctx test_ctx ; <nl> <nl> mmm a / test / core / bad_ssl / bad_ssl_test . cc <nl> ppp b / test / core / bad_ssl / bad_ssl_test . cc <nl> <nl> # include " test / core / util / subprocess . h " <nl> # include " test / core / util / test_config . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void run_test ( const char * target , size_t nops ) { <nl> grpc_channel_credentials * ssl_creds = <nl> mmm a / test / core / bad_ssl / server_common . cc <nl> ppp b / test / core / bad_ssl / server_common . cc <nl> void bad_ssl_run ( grpc_server * server ) { <nl> grpc_server_start ( server ) ; <nl> <nl> error = grpc_server_request_call ( server , & s , & call_details , <nl> - & request_metadata_recv , cq , cq , ( void * ) 1 ) ; <nl> + & request_metadata_recv , cq , cq , <nl> + reinterpret_cast < void * > ( 1 ) ) ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> <nl> signal ( SIGINT , sigint_handler ) ; <nl> mmm a / test / core / channel / channel_stack_builder_test . cc <nl> ppp b / test / core / channel / channel_stack_builder_test . cc <nl> static bool add_original_filter ( grpc_channel_stack_builder * builder , <nl> } <nl> <nl> static void init_plugin ( void ) { <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_CHANNEL , INT_MAX , <nl> - add_original_filter , <nl> - ( void * ) & original_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_CHANNEL , INT_MAX , <nl> - add_replacement_filter , <nl> - ( void * ) & replacement_filter ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_CHANNEL , INT_MAX , add_original_filter , <nl> + const_cast < grpc_channel_filter * > ( & original_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_CHANNEL , INT_MAX , add_replacement_filter , <nl> + const_cast < grpc_channel_filter * > ( & replacement_filter ) ) ; <nl> } <nl> <nl> static void destroy_plugin ( void ) { } <nl> mmm a / test / core / client_channel / resolvers / dns_resolver_connectivity_test . cc <nl> ppp b / test / core / client_channel / resolvers / dns_resolver_connectivity_test . cc <nl> class ResultHandler : public grpc_core : : Resolver : : ResultHandler { <nl> GPR_ASSERT ( output ! = nullptr ) ; <nl> output - > result = std : : move ( result ) ; <nl> output - > error = GRPC_ERROR_NONE ; <nl> - gpr_event_set ( & output - > ev , ( void * ) 1 ) ; <nl> + gpr_event_set ( & output - > ev , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> void ReturnError ( grpc_error * error ) override { <nl> class ResultHandler : public grpc_core : : Resolver : : ResultHandler { <nl> reinterpret_cast < ResolverOutput * > ( gpr_atm_acq_load ( & output_ ) ) ; <nl> GPR_ASSERT ( output ! = nullptr ) ; <nl> output - > error = error ; <nl> - gpr_event_set ( & output - > ev , ( void * ) 1 ) ; <nl> + gpr_event_set ( & output - > ev , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> private : <nl> mmm a / test / core / client_channel / resolvers / dns_resolver_cooldown_test . cc <nl> ppp b / test / core / client_channel / resolvers / dns_resolver_cooldown_test . cc <nl> static void poll_pollset_until_request_done ( iomgr_args * args ) { <nl> gpr_mu_unlock ( args - > mu ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> } <nl> - gpr_event_set ( & args - > ev , ( void * ) 1 ) ; <nl> + gpr_event_set ( & args - > ev , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> struct OnResolutionCallbackArg ; <nl> mmm a / test / core / client_channel / resolvers / fake_resolver_test . cc <nl> ppp b / test / core / client_channel / resolvers / fake_resolver_test . cc <nl> class ResultHandler : public grpc_core : : Resolver : : ResultHandler { <nl> for ( size_t i = 0 ; i < expected_ . addresses . size ( ) ; + + i ) { <nl> GPR_ASSERT ( actual . addresses [ i ] = = expected_ . addresses [ i ] ) ; <nl> } <nl> - gpr_event_set ( ev_ , ( void * ) 1 ) ; <nl> + gpr_event_set ( ev_ , reinterpret_cast < void * > ( 1 ) ) ; <nl> ev_ = nullptr ; <nl> } <nl> <nl> mmm a / test / core / end2end / bad_server_response_test . cc <nl> ppp b / test / core / end2end / bad_server_response_test . cc <nl> static grpc_closure on_read ; <nl> static grpc_closure on_writing_settings_frame ; <nl> static grpc_closure on_write ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void done_write ( void * / * arg * / , grpc_error * error ) { <nl> GPR_ASSERT ( error = = GRPC_ERROR_NONE ) ; <nl> static void actually_poll_server ( void * arg ) { <nl> } <nl> test_tcp_server_poll ( pa - > server , 1000 ) ; <nl> } <nl> - gpr_event_set ( pa - > signal_when_done , ( void * ) 1 ) ; <nl> + gpr_event_set ( pa - > signal_when_done , reinterpret_cast < void * > ( 1 ) ) ; <nl> gpr_free ( pa ) ; <nl> } <nl> <nl> mmm a / test / core / end2end / connection_refused_test . cc <nl> ppp b / test / core / end2end / connection_refused_test . cc <nl> <nl> # include " test / core / util / port . h " <nl> # include " test / core / util / test_config . h " <nl> <nl> - static void * tag ( intptr_t i ) { return ( void * ) i ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void run_test ( bool wait_for_ready , bool use_service_config ) { <nl> grpc_channel * chan ; <nl> mmm a / test / core / end2end / dualstack_socket_test . cc <nl> ppp b / test / core / end2end / dualstack_socket_test . cc <nl> <nl> <nl> / * This test exercises IPv4 , IPv6 , and dualstack sockets in various ways . * / <nl> <nl> - static void * tag ( intptr_t i ) { return ( void * ) i ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> grpc_event ev ; <nl> mmm a / test / core / end2end / fuzzers / client_fuzzer . cc <nl> ppp b / test / core / end2end / fuzzers / client_fuzzer . cc <nl> bool leak_check = true ; <nl> <nl> static void discard_write ( grpc_slice / * slice * / ) { } <nl> <nl> - static void * tag ( int n ) { return ( void * ) static_cast < uintptr_t > ( n ) ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void dont_log ( gpr_log_func_args * / * args * / ) { } <nl> <nl> mmm a / test / core / end2end / fuzzers / server_fuzzer . cc <nl> ppp b / test / core / end2end / fuzzers / server_fuzzer . cc <nl> bool leak_check = true ; <nl> <nl> static void discard_write ( grpc_slice / * slice * / ) { } <nl> <nl> - static void * tag ( int n ) { return ( void * ) static_cast < uintptr_t > ( n ) ; } <nl> - static int detag ( void * p ) { return static_cast < int > ( ( uintptr_t ) p ) ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void dont_log ( gpr_log_func_args * / * args * / ) { } <nl> <nl> extern " C " int LLVMFuzzerTestOneInput ( const uint8_t * data , size_t size ) { <nl> case GRPC_QUEUE_SHUTDOWN : <nl> break ; <nl> case GRPC_OP_COMPLETE : <nl> - switch ( detag ( ev . tag ) ) { <nl> - case 1 : <nl> - requested_calls - - ; <nl> - / / TODO ( ctiller ) : keep reading that call ! <nl> - break ; <nl> + if ( ev . tag = = tag ( 1 ) ) { <nl> + requested_calls - - ; <nl> + / / TODO ( ctiller ) : keep reading that call ! <nl> } <nl> + break ; <nl> } <nl> } <nl> <nl> mmm a / test / core / end2end / goaway_server_test . cc <nl> ppp b / test / core / end2end / goaway_server_test . cc <nl> <nl> extern grpc_address_resolver_vtable * grpc_resolve_address_impl ; <nl> static grpc_address_resolver_vtable * default_resolver ; <nl> <nl> - static void * tag ( intptr_t i ) { return ( void * ) i ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static gpr_mu g_mu ; <nl> static int g_resolve_port = - 1 ; <nl> mmm a / test / core / end2end / h2_ssl_session_reuse_test . cc <nl> ppp b / test / core / end2end / h2_ssl_session_reuse_test . cc <nl> namespace grpc { <nl> namespace testing { <nl> namespace { <nl> <nl> - void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> gpr_timespec five_seconds_time ( ) { return grpc_timeout_seconds_to_deadline ( 5 ) ; } <nl> <nl> mmm a / test / core / end2end / invalid_call_argument_test . cc <nl> ppp b / test / core / end2end / invalid_call_argument_test . cc <nl> <nl> # include " test / core / util / port . h " <nl> # include " test / core / util / test_config . h " <nl> <nl> - static void * tag ( intptr_t i ) { return ( void * ) i ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> struct test_state { <nl> int is_client ; <nl> mmm a / test / core / end2end / no_server_test . cc <nl> ppp b / test / core / end2end / no_server_test . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / util / test_config . h " <nl> <nl> - static void * tag ( intptr_t i ) { return ( void * ) i ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> void run_test ( bool wait_for_ready ) { <nl> gpr_log ( GPR_INFO , " TEST : wait_for_ready = % d " , wait_for_ready ) ; <nl> mmm a / test / core / end2end / tests / authority_not_supported . cc <nl> ppp b / test / core / end2end / tests / authority_not_supported . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / bad_hostname . cc <nl> ppp b / test / core / end2end / tests / bad_hostname . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / bad_ping . cc <nl> ppp b / test / core / end2end / tests / bad_ping . cc <nl> <nl> <nl> # define MAX_PING_STRIKES 2 <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> grpc_event ev ; <nl> mmm a / test / core / end2end / tests / binary_metadata . cc <nl> ppp b / test / core / end2end / tests / binary_metadata . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / call_creds . cc <nl> ppp b / test / core / end2end / tests / call_creds . cc <nl> static const char overridden_iam_selector [ ] = " overridden_selector " ; <nl> <nl> typedef enum { NONE , OVERRIDE , DESTROY , FAIL } override_mode ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / call_host_override . cc <nl> ppp b / test / core / end2end / tests / call_host_override . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / cancel_after_accept . cc <nl> ppp b / test / core / end2end / tests / cancel_after_accept . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / cancel_after_client_done . cc <nl> ppp b / test / core / end2end / tests / cancel_after_client_done . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / cancel_after_invoke . cc <nl> ppp b / test / core / end2end / tests / cancel_after_invoke . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / cancel_after_round_trip . cc <nl> ppp b / test / core / end2end / tests / cancel_after_round_trip . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / cancel_before_invoke . cc <nl> ppp b / test / core / end2end / tests / cancel_before_invoke . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / cancel_in_a_vacuum . cc <nl> ppp b / test / core / end2end / tests / cancel_in_a_vacuum . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / cancel_with_status . cc <nl> ppp b / test / core / end2end / tests / cancel_with_status . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / channelz . cc <nl> ppp b / test / core / end2end / tests / channelz . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / client_streaming . cc <nl> ppp b / test / core / end2end / tests / client_streaming . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / compressed_payload . cc <nl> ppp b / test / core / end2end / tests / compressed_payload . cc <nl> <nl> # include " src / core / lib / transport / static_metadata . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / connectivity . cc <nl> ppp b / test / core / end2end / tests / connectivity . cc <nl> <nl> # include " src / core / lib / gprpp / thd . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> typedef struct { <nl> gpr_event started ; <nl> struct CallbackContext { <nl> static void child_thread ( void * arg ) { <nl> child_events * ce = static_cast < child_events * > ( arg ) ; <nl> grpc_event ev ; <nl> - gpr_event_set ( & ce - > started , ( void * ) 1 ) ; <nl> + gpr_event_set ( & ce - > started , reinterpret_cast < void * > ( 1 ) ) ; <nl> gpr_log ( GPR_DEBUG , " verifying " ) ; <nl> ev = grpc_completion_queue_next ( ce - > cq , gpr_inf_future ( GPR_CLOCK_MONOTONIC ) , <nl> nullptr ) ; <nl> static void cb_watch_connectivity ( <nl> / * callback must not have errors * / <nl> GPR_ASSERT ( success ! = 0 ) ; <nl> <nl> - gpr_event_set ( & cb_ctx - > finished , ( void * ) 1 ) ; <nl> + gpr_event_set ( & cb_ctx - > finished , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> static void cb_shutdown ( grpc_experimental_completion_queue_functor * functor , <nl> static void cb_shutdown ( grpc_experimental_completion_queue_functor * functor , <nl> CallbackContext * cb_ctx = reinterpret_cast < CallbackContext * > ( functor ) ; <nl> <nl> gpr_log ( GPR_DEBUG , " cb_shutdown called , nothing to do " ) ; <nl> - gpr_event_set ( & cb_ctx - > finished , ( void * ) 1 ) ; <nl> + gpr_event_set ( & cb_ctx - > finished , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> static void test_watch_connectivity_cq_callback ( <nl> mmm a / test / core / end2end / tests / default_host . cc <nl> ppp b / test / core / end2end / tests / default_host . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / disappearing_server . cc <nl> ppp b / test / core / end2end / tests / disappearing_server . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static gpr_timespec n_seconds_from_now ( int n ) { <nl> return grpc_timeout_seconds_to_deadline ( n ) ; <nl> mmm a / test / core / end2end / tests / empty_batch . cc <nl> ppp b / test / core / end2end / tests / empty_batch . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / filter_causes_close . cc <nl> ppp b / test / core / end2end / tests / filter_causes_close . cc <nl> <nl> <nl> static bool g_enable_filter = false ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / filter_context . cc <nl> ppp b / test / core / end2end / tests / filter_context . cc <nl> enum { TIMEOUT = 200000 } ; <nl> <nl> static bool g_enable_filter = false ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> static bool maybe_add_filter ( grpc_channel_stack_builder * builder , void * arg ) { <nl> } <nl> <nl> static void init_plugin ( void ) { <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_CHANNEL , INT_MAX , <nl> - maybe_add_filter , ( void * ) & test_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_SUBCHANNEL , INT_MAX , <nl> - maybe_add_filter , ( void * ) & test_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , <nl> - maybe_add_filter , ( void * ) & test_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_SERVER_CHANNEL , INT_MAX , <nl> - maybe_add_filter , ( void * ) & test_filter ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_SUBCHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_SERVER_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_filter ) ) ; <nl> } <nl> <nl> static void destroy_plugin ( void ) { } <nl> mmm a / test / core / end2end / tests / filter_init_fails . cc <nl> ppp b / test / core / end2end / tests / filter_init_fails . cc <nl> static bool g_enable_client_channel_filter = false ; <nl> static bool g_enable_client_subchannel_filter = false ; <nl> static bool g_channel_filter_init_failure = false ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / filter_latency . cc <nl> ppp b / test / core / end2end / tests / filter_latency . cc <nl> static gpr_mu g_mu ; <nl> static gpr_timespec g_client_latency ; <nl> static gpr_timespec g_server_latency ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> static bool maybe_add_filter ( grpc_channel_stack_builder * builder , void * arg ) { <nl> <nl> static void init_plugin ( void ) { <nl> gpr_mu_init ( & g_mu ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_CHANNEL , INT_MAX , <nl> - maybe_add_filter , <nl> - ( void * ) & test_client_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , <nl> - maybe_add_filter , <nl> - ( void * ) & test_client_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_SERVER_CHANNEL , INT_MAX , <nl> - maybe_add_filter , <nl> - ( void * ) & test_server_filter ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_client_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_client_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_SERVER_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_server_filter ) ) ; <nl> } <nl> <nl> static void destroy_plugin ( void ) { gpr_mu_destroy ( & g_mu ) ; } <nl> mmm a / test / core / end2end / tests / filter_status_code . cc <nl> ppp b / test / core / end2end / tests / filter_status_code . cc <nl> static gpr_cv g_server_code_cv ; <nl> static grpc_status_code g_client_status_code ; <nl> static grpc_status_code g_server_status_code ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> static void init_plugin ( void ) { <nl> g_client_code_recv = false ; <nl> g_server_code_recv = false ; <nl> <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_CHANNEL , INT_MAX , <nl> - maybe_add_filter , <nl> - ( void * ) & test_client_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , <nl> - maybe_add_filter , <nl> - ( void * ) & test_client_filter ) ; <nl> - grpc_channel_init_register_stage ( GRPC_SERVER_CHANNEL , INT_MAX , <nl> - maybe_add_filter , <nl> - ( void * ) & test_server_filter ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_client_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_CLIENT_DIRECT_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_client_filter ) ) ; <nl> + grpc_channel_init_register_stage ( <nl> + GRPC_SERVER_CHANNEL , INT_MAX , maybe_add_filter , <nl> + const_cast < grpc_channel_filter * > ( & test_server_filter ) ) ; <nl> } <nl> <nl> static void destroy_plugin ( void ) { <nl> mmm a / test / core / end2end / tests / graceful_server_shutdown . cc <nl> ppp b / test / core / end2end / tests / graceful_server_shutdown . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / high_initial_seqno . cc <nl> ppp b / test / core / end2end / tests / high_initial_seqno . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / hpack_size . cc <nl> ppp b / test / core / end2end / tests / hpack_size . cc <nl> <nl> # include " src / core / lib / gpr / useful . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> const char * hobbits [ ] [ 2 ] = { <nl> { " Adaldrida " , " Brandybuck " } , { " Adamanta " , " Took " } , <nl> mmm a / test / core / end2end / tests / idempotent_request . cc <nl> ppp b / test / core / end2end / tests / idempotent_request . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / invoke_large_request . cc <nl> ppp b / test / core / end2end / tests / invoke_large_request . cc <nl> <nl> # include " src / core / lib / gpr / useful . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / keepalive_timeout . cc <nl> ppp b / test / core / end2end / tests / keepalive_timeout . cc <nl> <nl> # include " src / core / lib / iomgr / ev_posix . h " <nl> # endif / / GRPC_POSIX_SOCKET <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / large_metadata . cc <nl> ppp b / test / core / end2end / tests / large_metadata . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / max_concurrent_streams . cc <nl> ppp b / test / core / end2end / tests / max_concurrent_streams . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / max_connection_age . cc <nl> ppp b / test / core / end2end / tests / max_connection_age . cc <nl> <nl> / * The grace period for the test to observe the channel shutdown process * / <nl> # define IMMEDIATE_SHUTDOWN_GRACE_TIME_MS 3000 <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> grpc_event ev ; <nl> mmm a / test / core / end2end / tests / max_connection_idle . cc <nl> ppp b / test / core / end2end / tests / max_connection_idle . cc <nl> <nl> # define MAX_CONNECTION_IDLE_MS 500 <nl> # define MAX_CONNECTION_AGE_MS 9999 <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void drain_cq ( grpc_completion_queue * cq ) { <nl> grpc_event ev ; <nl> mmm a / test / core / end2end / tests / max_message_length . cc <nl> ppp b / test / core / end2end / tests / max_message_length . cc <nl> <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / negative_deadline . cc <nl> ppp b / test / core / end2end / tests / negative_deadline . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / no_error_on_hotpath . cc <nl> ppp b / test / core / end2end / tests / no_error_on_hotpath . cc <nl> <nl> # include " src / core / lib / iomgr / error . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / no_logging . cc <nl> ppp b / test / core / end2end / tests / no_logging . cc <nl> <nl> <nl> enum { TIMEOUT = 200000 } ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> void gpr_default_log ( gpr_log_func_args * args ) ; <nl> <nl> mmm a / test / core / end2end / tests / no_op . cc <nl> ppp b / test / core / end2end / tests / no_op . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / payload . cc <nl> ppp b / test / core / end2end / tests / payload . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / ping . cc <nl> ppp b / test / core / end2end / tests / ping . cc <nl> <nl> <nl> # define PING_NUM 5 <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static void test_ping ( grpc_end2end_test_config config , <nl> int min_time_between_pings_ms ) { <nl> mmm a / test / core / end2end / tests / ping_pong_streaming . cc <nl> ppp b / test / core / end2end / tests / ping_pong_streaming . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / proxy_auth . cc <nl> ppp b / test / core / end2end / tests / proxy_auth . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / registered_call . cc <nl> ppp b / test / core / end2end / tests / registered_call . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / request_with_flags . cc <nl> ppp b / test / core / end2end / tests / request_with_flags . cc <nl> <nl> # include " src / core / lib / transport / byte_stream . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / request_with_payload . cc <nl> ppp b / test / core / end2end / tests / request_with_payload . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / resource_quota_server . cc <nl> ppp b / test / core / end2end / tests / resource_quota_server . cc <nl> <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry . cc <nl> ppp b / test / core / end2end / tests / retry . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_cancellation . cc <nl> ppp b / test / core / end2end / tests / retry_cancellation . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_disabled . cc <nl> ppp b / test / core / end2end / tests / retry_disabled . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_exceeds_buffer_size_in_initial_batch . cc <nl> ppp b / test / core / end2end / tests / retry_exceeds_buffer_size_in_initial_batch . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_exceeds_buffer_size_in_subsequent_batch . cc <nl> ppp b / test / core / end2end / tests / retry_exceeds_buffer_size_in_subsequent_batch . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_non_retriable_status . cc <nl> ppp b / test / core / end2end / tests / retry_non_retriable_status . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_non_retriable_status_before_recv_trailing_metadata_started . cc <nl> ppp b / test / core / end2end / tests / retry_non_retriable_status_before_recv_trailing_metadata_started . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_recv_initial_metadata . cc <nl> ppp b / test / core / end2end / tests / retry_recv_initial_metadata . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_recv_message . cc <nl> ppp b / test / core / end2end / tests / retry_recv_message . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_server_pushback_delay . cc <nl> ppp b / test / core / end2end / tests / retry_server_pushback_delay . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_server_pushback_disabled . cc <nl> ppp b / test / core / end2end / tests / retry_server_pushback_disabled . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_streaming . cc <nl> ppp b / test / core / end2end / tests / retry_streaming . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_streaming_after_commit . cc <nl> ppp b / test / core / end2end / tests / retry_streaming_after_commit . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_streaming_succeeds_before_replay_finished . cc <nl> ppp b / test / core / end2end / tests / retry_streaming_succeeds_before_replay_finished . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_throttled . cc <nl> ppp b / test / core / end2end / tests / retry_throttled . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / retry_too_many_attempts . cc <nl> ppp b / test / core / end2end / tests / retry_too_many_attempts . cc <nl> <nl> # include " test / core / end2end / cq_verifier . h " <nl> # include " test / core / end2end / tests / cancel_test_helpers . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / server_finishes_request . cc <nl> ppp b / test / core / end2end / tests / server_finishes_request . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / server_streaming . cc <nl> ppp b / test / core / end2end / tests / server_streaming . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / shutdown_finishes_calls . cc <nl> ppp b / test / core / end2end / tests / shutdown_finishes_calls . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / shutdown_finishes_tags . cc <nl> ppp b / test / core / end2end / tests / shutdown_finishes_tags . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / simple_cacheable_request . cc <nl> ppp b / test / core / end2end / tests / simple_cacheable_request . cc <nl> <nl> <nl> enum { TIMEOUT = 200000 } ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / simple_delayed_request . cc <nl> ppp b / test / core / end2end / tests / simple_delayed_request . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static gpr_timespec n_seconds_from_now ( int n ) { <nl> return grpc_timeout_seconds_to_deadline ( n ) ; <nl> mmm a / test / core / end2end / tests / simple_metadata . cc <nl> ppp b / test / core / end2end / tests / simple_metadata . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / simple_request . cc <nl> ppp b / test / core / end2end / tests / simple_request . cc <nl> <nl> # include " src / core / lib / gpr / string . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> static void simple_request_body ( grpc_end2end_test_config config , <nl> GPR_ASSERT ( was_cancelled = = 0 ) ; <nl> <nl> grpc_slice_unref ( details ) ; <nl> - gpr_free ( ( void * ) error_string ) ; <nl> + gpr_free ( const_cast < char * > ( error_string ) ) ; <nl> grpc_metadata_array_destroy ( & initial_metadata_recv ) ; <nl> grpc_metadata_array_destroy ( & trailing_metadata_recv ) ; <nl> grpc_metadata_array_destroy ( & request_metadata_recv ) ; <nl> mmm a / test / core / end2end / tests / stream_compression_compressed_payload . cc <nl> ppp b / test / core / end2end / tests / stream_compression_compressed_payload . cc <nl> <nl> # include " src / core / lib / transport / static_metadata . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / stream_compression_payload . cc <nl> ppp b / test / core / end2end / tests / stream_compression_payload . cc <nl> <nl> # include " src / core / lib / surface / call . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / stream_compression_ping_pong_streaming . cc <nl> ppp b / test / core / end2end / tests / stream_compression_ping_pong_streaming . cc <nl> <nl> # include " src / core / lib / surface / call . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / streaming_error_response . cc <nl> ppp b / test / core / end2end / tests / streaming_error_response . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / trailing_metadata . cc <nl> ppp b / test / core / end2end / tests / trailing_metadata . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / workaround_cronet_compression . cc <nl> ppp b / test / core / end2end / tests / workaround_cronet_compression . cc <nl> <nl> # include " src / core / lib / transport / static_metadata . h " <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / write_buffering . cc <nl> ppp b / test / core / end2end / tests / write_buffering . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / end2end / tests / write_buffering_at_end . cc <nl> ppp b / test / core / end2end / tests / write_buffering_at_end . cc <nl> <nl> # include < grpc / support / time . h > <nl> # include " test / core / end2end / cq_verifier . h " <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_end2end_test_fixture begin_test ( grpc_end2end_test_config config , <nl> const char * test_name , <nl> mmm a / test / core / fling / client . cc <nl> ppp b / test / core / fling / client . cc <nl> static void init_ping_pong_stream ( void ) { <nl> stream_init_ops [ 1 ] . op = GRPC_OP_RECV_INITIAL_METADATA ; <nl> stream_init_ops [ 1 ] . data . recv_initial_metadata . recv_initial_metadata = <nl> & initial_metadata_recv ; <nl> - error = grpc_call_start_batch ( call , stream_init_ops , 2 , ( void * ) 1 , nullptr ) ; <nl> + error = grpc_call_start_batch ( call , stream_init_ops , 2 , <nl> + reinterpret_cast < void * > ( 1 ) , nullptr ) ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> grpc_completion_queue_next ( cq , gpr_inf_future ( GPR_CLOCK_REALTIME ) , nullptr ) ; <nl> <nl> static void init_ping_pong_stream ( void ) { <nl> static void step_ping_pong_stream ( void ) { <nl> GPR_TIMER_SCOPE ( " ping_pong " , 1 ) ; <nl> grpc_call_error error ; <nl> - error = grpc_call_start_batch ( call , stream_step_ops , 2 , ( void * ) 1 , nullptr ) ; <nl> + error = grpc_call_start_batch ( call , stream_step_ops , 2 , <nl> + reinterpret_cast < void * > ( 1 ) , nullptr ) ; <nl> GPR_ASSERT ( GRPC_CALL_OK = = error ) ; <nl> grpc_completion_queue_next ( cq , gpr_inf_future ( GPR_CLOCK_REALTIME ) , nullptr ) ; <nl> grpc_byte_buffer_destroy ( response_payload_recv ) ; <nl> mmm a / test / core / fling / server . cc <nl> ppp b / test / core / fling / server . cc <nl> static int was_cancelled = 2 ; <nl> static grpc_op unary_ops [ 6 ] ; <nl> static int got_sigint = 0 ; <nl> <nl> - static void * tag ( intptr_t t ) { return ( void * ) t ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> typedef enum { <nl> FLING_SERVER_NEW_REQUEST = 1 , <nl> mmm a / test / core / gpr / arena_test . cc <nl> ppp b / test / core / gpr / arena_test . cc <nl> static void concurrent_test ( void ) { <nl> thds [ i ] . Start ( ) ; <nl> } <nl> <nl> - gpr_event_set ( & args . ev_start , ( void * ) 1 ) ; <nl> + gpr_event_set ( & args . ev_start , reinterpret_cast < void * > ( 1 ) ) ; <nl> <nl> for ( auto & th : thds ) { <nl> th . Join ( ) ; <nl> mmm a / test / core / gpr / sync_test . cc <nl> ppp b / test / core / gpr / sync_test . cc <nl> static void refinc ( void * v / * = m * / ) { <nl> } <nl> } <nl> if ( gpr_unref ( & m - > thread_refcount ) ) { <nl> - gpr_event_set ( & m - > event , ( void * ) 1 ) ; <nl> + gpr_event_set ( & m - > event , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> mark_thread_done ( m ) ; <nl> } <nl> mmm a / test / core / gprpp / fork_test . cc <nl> ppp b / test / core / gprpp / fork_test . cc <nl> static void test_thd_count ( ) { <nl> for ( int i = 0 ; i < CONCURRENT_TEST_THREADS ; i + + ) { <nl> intptr_t sleep_time_ms = <nl> ( i * THREAD_DELAY_MS ) / ( CONCURRENT_TEST_THREADS - 1 ) ; <nl> - thds [ i ] = <nl> - grpc_core : : Thread ( " grpc_fork_test " , sleeping_thd , ( void * ) sleep_time_ms ) ; <nl> + thds [ i ] = grpc_core : : Thread ( " grpc_fork_test " , sleeping_thd , <nl> + reinterpret_cast < void * > ( sleep_time_ms ) ) ; <nl> thds [ i ] . Start ( ) ; <nl> } <nl> grpc_core : : Fork : : AwaitThreads ( ) ; <nl> mmm a / test / core / gprpp / mpscq_test . cc <nl> ppp b / test / core / gprpp / mpscq_test . cc <nl> static void test_mt ( void ) { <nl> } <nl> size_t num_done = 0 ; <nl> size_t spins = 0 ; <nl> - gpr_event_set ( & start , ( void * ) 1 ) ; <nl> + gpr_event_set ( & start , reinterpret_cast < void * > ( 1 ) ) ; <nl> while ( num_done ! = GPR_ARRAY_SIZE ( thds ) ) { <nl> MultiProducerSingleConsumerQueue : : Node * n ; <nl> while ( ( n = q . Pop ( ) ) = = nullptr ) { <nl> static void test_mt_multipop ( void ) { <nl> pull_thds [ i ] = grpc_core : : Thread ( " grpc_multipop_pull " , pull_thread , & pa ) ; <nl> pull_thds [ i ] . Start ( ) ; <nl> } <nl> - gpr_event_set ( & start , ( void * ) 1 ) ; <nl> + gpr_event_set ( & start , reinterpret_cast < void * > ( 1 ) ) ; <nl> for ( auto & pth : pull_thds ) { <nl> pth . Join ( ) ; <nl> } <nl> mmm a / test / core / iomgr / combiner_test . cc <nl> ppp b / test / core / iomgr / combiner_test . cc <nl> static void test_no_op ( void ) { <nl> } <nl> <nl> static void set_event_to_true ( void * value , grpc_error * / * error * / ) { <nl> - gpr_event_set ( static_cast < gpr_event * > ( value ) , ( void * ) 1 ) ; <nl> + gpr_event_set ( static_cast < gpr_event * > ( value ) , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> static void test_execute_one ( void ) { <nl> static void test_execute_many ( void ) { <nl> static gpr_event got_in_finally ; <nl> <nl> static void in_finally ( void * / * arg * / , grpc_error * / * error * / ) { <nl> - gpr_event_set ( & got_in_finally , ( void * ) 1 ) ; <nl> + gpr_event_set ( & got_in_finally , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> static void add_finally ( void * arg , grpc_error * / * error * / ) { <nl> mmm a / test / core / iomgr / resolve_address_posix_test . cc <nl> ppp b / test / core / iomgr / resolve_address_posix_test . cc <nl> static void actually_poll ( void * argsp ) { <nl> gpr_mu_unlock ( args - > mu ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> } <nl> - gpr_event_set ( & args - > ev , ( void * ) 1 ) ; <nl> + gpr_event_set ( & args - > ev , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> static void poll_pollset_until_request_done ( args_struct * args ) { <nl> mmm a / test / core / iomgr / resolve_address_test . cc <nl> ppp b / test / core / iomgr / resolve_address_test . cc <nl> static void poll_pollset_until_request_done ( args_struct * args ) { <nl> gpr_mu_unlock ( args - > mu ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> } <nl> - gpr_event_set ( & args - > ev , ( void * ) 1 ) ; <nl> + gpr_event_set ( & args - > ev , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> static void must_succeed ( void * argsp , grpc_error * err ) { <nl> mmm a / test / core / iomgr / resource_quota_test . cc <nl> ppp b / test / core / iomgr / resource_quota_test . cc <nl> static void assert_counter_becomes ( int * ctr , int value ) { <nl> } <nl> <nl> static void set_event_cb ( void * a , grpc_error * / * error * / ) { <nl> - gpr_event_set ( static_cast < gpr_event * > ( a ) , ( void * ) 1 ) ; <nl> + gpr_event_set ( static_cast < gpr_event * > ( a ) , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> grpc_closure * set_event ( gpr_event * ev ) { <nl> return GRPC_CLOSURE_CREATE ( set_event_cb , ev , grpc_schedule_on_exec_ctx ) ; <nl> mmm a / test / core / iomgr / tcp_posix_test . cc <nl> ppp b / test / core / iomgr / tcp_posix_test . cc <nl> static void write_test ( size_t num_bytes , size_t slice_size , <nl> gpr_atm_rel_store ( & done_timestamps , static_cast < gpr_atm > ( 0 ) ) ; <nl> grpc_endpoint_write ( ep , & outgoing , & write_done_closure , <nl> grpc_event_engine_can_track_errors ( ) & & collect_timestamps <nl> - ? ( void * ) & done_timestamps <nl> + ? & done_timestamps <nl> : nullptr ) ; <nl> drain_socket_blocking ( sv [ 0 ] , num_bytes , num_bytes ) ; <nl> exec_ctx . Flush ( ) ; <nl> mmm a / test / core / iomgr / work_serializer_test . cc <nl> ppp b / test / core / iomgr / work_serializer_test . cc <nl> TEST ( WorkSerializerTest , ExecuteOne ) { <nl> grpc_core : : WorkSerializer lock ; <nl> gpr_event done ; <nl> gpr_event_init ( & done ) ; <nl> - lock . Run ( [ & done ] ( ) { gpr_event_set ( & done , ( void * ) 1 ) ; } , DEBUG_LOCATION ) ; <nl> + lock . Run ( [ & done ] ( ) { gpr_event_set ( & done , reinterpret_cast < void * > ( 1 ) ) ; } , <nl> + DEBUG_LOCATION ) ; <nl> EXPECT_TRUE ( gpr_event_wait ( & done , grpc_timeout_seconds_to_deadline ( 5 ) ) ! = <nl> nullptr ) ; <nl> } <nl> class TestThread { <nl> / / sleep for a little bit , to test other threads picking up the load <nl> gpr_sleep_until ( grpc_timeout_milliseconds_to_deadline ( 100 ) ) ; <nl> } <nl> - self - > lock_ - > Run ( [ self ] ( ) { gpr_event_set ( & self - > done_ , ( void * ) 1 ) ; } , <nl> - DEBUG_LOCATION ) ; <nl> + self - > lock_ - > Run ( <nl> + [ self ] ( ) { gpr_event_set ( & self - > done_ , reinterpret_cast < void * > ( 1 ) ) ; } , <nl> + DEBUG_LOCATION ) ; <nl> } <nl> <nl> grpc_core : : WorkSerializer * lock_ = nullptr ; <nl> mmm a / test / core / security / jwt_verifier_test . cc <nl> ppp b / test / core / security / jwt_verifier_test . cc <nl> static void test_jwt_verifier_google_email_issuer_success ( void ) { <nl> grpc_auth_json_key_destruct ( & key ) ; <nl> GPR_ASSERT ( jwt ! = nullptr ) ; <nl> grpc_jwt_verifier_verify ( verifier , nullptr , jwt , expected_audience , <nl> - on_verification_success , ( void * ) expected_user_data ) ; <nl> + on_verification_success , <nl> + const_cast < char * > ( expected_user_data ) ) ; <nl> grpc_jwt_verifier_destroy ( verifier ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> gpr_free ( jwt ) ; <nl> static void test_jwt_verifier_custom_email_issuer_success ( void ) { <nl> grpc_auth_json_key_destruct ( & key ) ; <nl> GPR_ASSERT ( jwt ! = nullptr ) ; <nl> grpc_jwt_verifier_verify ( verifier , nullptr , jwt , expected_audience , <nl> - on_verification_success , ( void * ) expected_user_data ) ; <nl> + on_verification_success , <nl> + const_cast < char * > ( expected_user_data ) ) ; <nl> grpc_jwt_verifier_destroy ( verifier ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> gpr_free ( jwt ) ; <nl> static void test_jwt_verifier_url_issuer_success ( void ) { <nl> grpc_auth_json_key_destruct ( & key ) ; <nl> GPR_ASSERT ( jwt ! = nullptr ) ; <nl> grpc_jwt_verifier_verify ( verifier , nullptr , jwt , expected_audience , <nl> - on_verification_success , ( void * ) expected_user_data ) ; <nl> + on_verification_success , <nl> + const_cast < char * > ( expected_user_data ) ) ; <nl> grpc_jwt_verifier_destroy ( verifier ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> gpr_free ( jwt ) ; <nl> static void test_jwt_verifier_url_issuer_bad_config ( void ) { <nl> GPR_ASSERT ( jwt ! = nullptr ) ; <nl> grpc_jwt_verifier_verify ( verifier , nullptr , jwt , expected_audience , <nl> on_verification_key_retrieval_error , <nl> - ( void * ) expected_user_data ) ; <nl> + const_cast < char * > ( expected_user_data ) ) ; <nl> grpc_jwt_verifier_destroy ( verifier ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> gpr_free ( jwt ) ; <nl> static void test_jwt_verifier_bad_json_key ( void ) { <nl> GPR_ASSERT ( jwt ! = nullptr ) ; <nl> grpc_jwt_verifier_verify ( verifier , nullptr , jwt , expected_audience , <nl> on_verification_key_retrieval_error , <nl> - ( void * ) expected_user_data ) ; <nl> + const_cast < char * > ( expected_user_data ) ) ; <nl> grpc_jwt_verifier_destroy ( verifier ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> gpr_free ( jwt ) ; <nl> static void test_jwt_verifier_bad_signature ( void ) { <nl> GPR_ASSERT ( jwt ! = nullptr ) ; <nl> grpc_jwt_verifier_verify ( verifier , nullptr , jwt , expected_audience , <nl> on_verification_bad_signature , <nl> - ( void * ) expected_user_data ) ; <nl> + const_cast < char * > ( expected_user_data ) ) ; <nl> gpr_free ( jwt ) ; <nl> grpc_jwt_verifier_destroy ( verifier ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> static void test_jwt_verifier_bad_format ( void ) { <nl> httpcli_post_should_not_be_called ) ; <nl> grpc_jwt_verifier_verify ( verifier , nullptr , " bad jwt " , expected_audience , <nl> on_verification_bad_format , <nl> - ( void * ) expected_user_data ) ; <nl> + const_cast < char * > ( expected_user_data ) ) ; <nl> grpc_jwt_verifier_destroy ( verifier ) ; <nl> grpc_core : : ExecCtx : : Get ( ) - > Flush ( ) ; <nl> grpc_httpcli_set_override ( nullptr , nullptr ) ; <nl> mmm a / test / core / surface / completion_queue_test . cc <nl> ppp b / test / core / surface / completion_queue_test . cc <nl> <nl> <nl> static void * create_test_tag ( void ) { <nl> static intptr_t i = 0 ; <nl> - return ( void * ) ( + + i ) ; <nl> + return reinterpret_cast < void * > ( + + i ) ; <nl> } <nl> <nl> / * helper for tests to shutdown correctly and tersely * / <nl> mmm a / test / core / surface / completion_queue_threading_test . cc <nl> ppp b / test / core / surface / completion_queue_threading_test . cc <nl> <nl> <nl> static void * create_test_tag ( void ) { <nl> static intptr_t i = 0 ; <nl> - return ( void * ) ( + + i ) ; <nl> + return reinterpret_cast < void * > ( + + i ) ; <nl> } <nl> <nl> / * helper for tests to shutdown correctly and tersely * / <nl> static void producer_thread ( void * arg ) { <nl> int i ; <nl> <nl> gpr_log ( GPR_INFO , " producer % d started " , opt - > id ) ; <nl> - gpr_event_set ( & opt - > on_started , ( void * ) static_cast < intptr_t > ( 1 ) ) ; <nl> + gpr_event_set ( & opt - > on_started , reinterpret_cast < void * > ( 1 ) ) ; <nl> GPR_ASSERT ( gpr_event_wait ( opt - > phase1 , ten_seconds_time ( ) ) ) ; <nl> <nl> gpr_log ( GPR_INFO , " producer % d phase 1 " , opt - > id ) ; <nl> static void producer_thread ( void * arg ) { <nl> } <nl> <nl> gpr_log ( GPR_INFO , " producer % d phase 1 done " , opt - > id ) ; <nl> - gpr_event_set ( & opt - > on_phase1_done , ( void * ) static_cast < intptr_t > ( 1 ) ) ; <nl> + gpr_event_set ( & opt - > on_phase1_done , reinterpret_cast < void * > ( 1 ) ) ; <nl> GPR_ASSERT ( gpr_event_wait ( opt - > phase2 , ten_seconds_time ( ) ) ) ; <nl> <nl> gpr_log ( GPR_INFO , " producer % d phase 2 " , opt - > id ) ; <nl> for ( i = 0 ; i < TEST_THREAD_EVENTS ; i + + ) { <nl> grpc_core : : ExecCtx exec_ctx ; <nl> - grpc_cq_end_op ( opt - > cc , ( void * ) static_cast < intptr_t > ( 1 ) , GRPC_ERROR_NONE , <nl> + grpc_cq_end_op ( opt - > cc , reinterpret_cast < void * > ( 1 ) , GRPC_ERROR_NONE , <nl> free_completion , nullptr , <nl> static_cast < grpc_cq_completion * > ( <nl> gpr_malloc ( sizeof ( grpc_cq_completion ) ) ) ) ; <nl> static void producer_thread ( void * arg ) { <nl> } <nl> <nl> gpr_log ( GPR_INFO , " producer % d phase 2 done " , opt - > id ) ; <nl> - gpr_event_set ( & opt - > on_finished , ( void * ) static_cast < intptr_t > ( 1 ) ) ; <nl> + gpr_event_set ( & opt - > on_finished , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> static void consumer_thread ( void * arg ) { <nl> static void consumer_thread ( void * arg ) { <nl> grpc_event ev ; <nl> <nl> gpr_log ( GPR_INFO , " consumer % d started " , opt - > id ) ; <nl> - gpr_event_set ( & opt - > on_started , ( void * ) static_cast < intptr_t > ( 1 ) ) ; <nl> + gpr_event_set ( & opt - > on_started , reinterpret_cast < void * > ( 1 ) ) ; <nl> GPR_ASSERT ( gpr_event_wait ( opt - > phase1 , ten_seconds_time ( ) ) ) ; <nl> <nl> gpr_log ( GPR_INFO , " consumer % d phase 1 " , opt - > id ) ; <nl> <nl> gpr_log ( GPR_INFO , " consumer % d phase 1 done " , opt - > id ) ; <nl> - gpr_event_set ( & opt - > on_phase1_done , ( void * ) static_cast < intptr_t > ( 1 ) ) ; <nl> + gpr_event_set ( & opt - > on_phase1_done , reinterpret_cast < void * > ( 1 ) ) ; <nl> GPR_ASSERT ( gpr_event_wait ( opt - > phase2 , ten_seconds_time ( ) ) ) ; <nl> <nl> gpr_log ( GPR_INFO , " consumer % d phase 2 " , opt - > id ) ; <nl> static void consumer_thread ( void * arg ) { <nl> break ; <nl> case GRPC_QUEUE_SHUTDOWN : <nl> gpr_log ( GPR_INFO , " consumer % d phase 2 done " , opt - > id ) ; <nl> - gpr_event_set ( & opt - > on_finished , ( void * ) static_cast < intptr_t > ( 1 ) ) ; <nl> + gpr_event_set ( & opt - > on_finished , reinterpret_cast < void * > ( 1 ) ) ; <nl> return ; <nl> case GRPC_QUEUE_TIMEOUT : <nl> gpr_log ( GPR_ERROR , " Invalid timeout received " ) ; <nl> static void test_threading ( size_t producers , size_t consumers ) { <nl> / * start phase1 : producers will pre - declare all operations they will <nl> complete * / <nl> gpr_log ( GPR_INFO , " start phase 1 " ) ; <nl> - gpr_event_set ( & phase1 , ( void * ) static_cast < intptr_t > ( 1 ) ) ; <nl> + gpr_event_set ( & phase1 , reinterpret_cast < void * > ( 1 ) ) ; <nl> <nl> gpr_log ( GPR_INFO , " wait phase 1 " ) ; <nl> for ( i = 0 ; i < producers + consumers ; i + + ) { <nl> static void test_threading ( size_t producers , size_t consumers ) { <nl> <nl> / * start phase2 : operations will complete , and consumers will consume them * / <nl> gpr_log ( GPR_INFO , " start phase 2 " ) ; <nl> - gpr_event_set ( & phase2 , ( void * ) static_cast < intptr_t > ( 1 ) ) ; <nl> + gpr_event_set ( & phase2 , reinterpret_cast < void * > ( 1 ) ) ; <nl> <nl> / * in parallel , we shutdown the completion channel - all events should still <nl> be consumed * / <nl> mmm a / test / core / surface / concurrent_connectivity_test . cc <nl> ppp b / test / core / surface / concurrent_connectivity_test . cc <nl> <nl> / / it should never take longer that this to shutdown the server <nl> # define SERVER_SHUTDOWN_TIMEOUT 30000 <nl> <nl> - static void * tag ( int n ) { return ( void * ) static_cast < uintptr_t > ( n ) ; } <nl> - static int detag ( void * p ) { return static_cast < int > ( ( uintptr_t ) p ) ; } <nl> + static void * tag ( int n ) { return reinterpret_cast < void * > ( n ) ; } <nl> <nl> void create_loop_destroy ( void * addr ) { <nl> for ( int i = 0 ; i < NUM_OUTER_LOOPS ; + + i ) { <nl> void server_thread ( void * vargs ) { <nl> grpc_timeout_milliseconds_to_deadline ( SERVER_SHUTDOWN_TIMEOUT ) ; <nl> ev = grpc_completion_queue_next ( args - > cq , deadline , nullptr ) ; <nl> GPR_ASSERT ( ev . type = = GRPC_OP_COMPLETE ) ; <nl> - GPR_ASSERT ( detag ( ev . tag ) = = 0xd1e ) ; <nl> + GPR_ASSERT ( ev . tag = = tag ( 0xd1e ) ) ; <nl> } <nl> <nl> static void on_connect ( void * vargs , grpc_endpoint * tcp , <nl> void bad_server_thread ( void * vargs ) { <nl> args - > addr = absl : : StrCat ( " localhost : " , port ) ; <nl> <nl> grpc_tcp_server_start ( s , & args - > pollset , on_connect , args ) ; <nl> - gpr_event_set ( & args - > ready , ( void * ) 1 ) ; <nl> + gpr_event_set ( & args - > ready , reinterpret_cast < void * > ( 1 ) ) ; <nl> <nl> gpr_mu_lock ( args - > mu ) ; <nl> while ( args - > stop . load ( std : : memory_order_acquire ) = = false ) { <nl> mmm a / test / core / surface / lame_client_test . cc <nl> ppp b / test / core / surface / lame_client_test . cc <nl> class Watcher : public grpc_core : : ConnectivityStateWatcherInterface { <nl> } <nl> } ; <nl> <nl> - static void * tag ( intptr_t x ) { return ( void * ) x ; } <nl> + static void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> static grpc_closure transport_op_cb ; <nl> <nl> mmm a / test / core / surface / num_external_connectivity_watchers_test . cc <nl> ppp b / test / core / surface / num_external_connectivity_watchers_test . cc <nl> static void channel_idle_start_watch ( grpc_channel * channel , <nl> GPR_ASSERT ( grpc_channel_check_connectivity_state ( channel , 0 ) = = <nl> GRPC_CHANNEL_IDLE ) ; <nl> <nl> - grpc_channel_watch_connectivity_state ( <nl> - channel , GRPC_CHANNEL_IDLE , connect_deadline , cq , ( void * ) ( next_tag + + ) ) ; <nl> + grpc_channel_watch_connectivity_state ( channel , GRPC_CHANNEL_IDLE , <nl> + connect_deadline , cq , <nl> + reinterpret_cast < void * > ( next_tag + + ) ) ; <nl> gpr_log ( GPR_DEBUG , " number of active connect watchers : % d " , <nl> grpc_channel_num_external_connectivity_watchers ( channel ) ) ; <nl> } <nl> static void run_channel_shutdown_before_timeout_test ( <nl> GRPC_CHANNEL_IDLE ) ; <nl> <nl> grpc_channel_watch_connectivity_state ( channel , GRPC_CHANNEL_IDLE , <nl> - connect_deadline , cq , ( void * ) 1 ) ; <nl> + connect_deadline , cq , <nl> + reinterpret_cast < void * > ( 1 ) ) ; <nl> grpc_channel_destroy ( channel ) ; <nl> <nl> grpc_event ev = grpc_completion_queue_next ( <nl> mmm a / test / core / transport / chttp2 / stream_map_test . cc <nl> ppp b / test / core / transport / chttp2 / stream_map_test . cc <nl> static void test_basic_add_find ( uint32_t n ) { <nl> grpc_chttp2_stream_map_init ( & map , 8 ) ; <nl> GPR_ASSERT ( 0 = = grpc_chttp2_stream_map_size ( & map ) ) ; <nl> for ( i = 1 ; i < = n ; i + + ) { <nl> - grpc_chttp2_stream_map_add ( & map , i , ( void * ) static_cast < uintptr_t > ( i ) ) ; <nl> + grpc_chttp2_stream_map_add ( & map , i , reinterpret_cast < void * > ( i ) ) ; <nl> } <nl> GPR_ASSERT ( n = = grpc_chttp2_stream_map_size ( & map ) ) ; <nl> GPR_ASSERT ( nullptr = = grpc_chttp2_stream_map_find ( & map , 0 ) ) ; <nl> static void test_delete_evens_sweep ( uint32_t n ) { <nl> <nl> grpc_chttp2_stream_map_init ( & map , 8 ) ; <nl> for ( i = 1 ; i < = n ; i + + ) { <nl> - grpc_chttp2_stream_map_add ( & map , i , ( void * ) static_cast < uintptr_t > ( i ) ) ; <nl> + grpc_chttp2_stream_map_add ( & map , i , reinterpret_cast < void * > ( i ) ) ; <nl> } <nl> for ( i = 1 ; i < = n ; i + + ) { <nl> if ( ( i & 1 ) = = 0 ) { <nl> static void test_delete_evens_incremental ( uint32_t n ) { <nl> <nl> grpc_chttp2_stream_map_init ( & map , 8 ) ; <nl> for ( i = 1 ; i < = n ; i + + ) { <nl> - grpc_chttp2_stream_map_add ( & map , i , ( void * ) static_cast < uintptr_t > ( i ) ) ; <nl> + grpc_chttp2_stream_map_add ( & map , i , reinterpret_cast < void * > ( i ) ) ; <nl> if ( ( i & 1 ) = = 0 ) { <nl> grpc_chttp2_stream_map_delete ( & map , i ) ; <nl> } <nl> static void test_periodic_compaction ( uint32_t n ) { <nl> grpc_chttp2_stream_map_init ( & map , 16 ) ; <nl> GPR_ASSERT ( map . capacity = = 16 ) ; <nl> for ( i = 1 ; i < = n ; i + + ) { <nl> - grpc_chttp2_stream_map_add ( & map , i , ( void * ) static_cast < uintptr_t > ( i ) ) ; <nl> + grpc_chttp2_stream_map_add ( & map , i , reinterpret_cast < void * > ( i ) ) ; <nl> if ( i > 8 ) { <nl> del = i - 8 ; <nl> GPR_ASSERT ( ( void * ) ( uintptr_t ) del = = <nl> mmm a / test / core / transport / chttp2 / too_many_pings_test . cc <nl> ppp b / test / core / transport / chttp2 / too_many_pings_test . cc <nl> <nl> <nl> namespace { <nl> <nl> - void * tag ( int i ) { return ( void * ) static_cast < intptr_t > ( i ) ; } <nl> + void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> / / Perform a simple RPC where the server cancels the request with <nl> / / grpc_call_cancel_with_status <nl> grpc_status_code PerformWaitingCall ( grpc_channel * channel , grpc_server * server , <nl> / / Shuts down and destroys the server . <nl> void ServerShutdownAndDestroy ( grpc_server * server , grpc_completion_queue * cq ) { <nl> / / Shutdown and destroy server <nl> - grpc_server_shutdown_and_notify ( server , cq , ( void * ) ( 1000 ) ) ; <nl> + grpc_server_shutdown_and_notify ( server , cq , reinterpret_cast < void * > ( 1000 ) ) ; <nl> while ( grpc_completion_queue_next ( cq , gpr_inf_future ( GPR_CLOCK_REALTIME ) , <nl> nullptr ) <nl> - . tag ! = ( void * ) ( 1000 ) ) { <nl> + . tag ! = reinterpret_cast < void * > ( 1000 ) ) { <nl> } <nl> grpc_server_destroy ( server ) ; <nl> } <nl> void VerifyChannelDisconnected ( grpc_channel * channel , <nl> grpc_completion_queue * cq ) { <nl> / / Verify channel gets disconnected . Use a ping to make sure that clients <nl> / / tries sending / receiving bytes if the channel is connected . <nl> - grpc_channel_ping ( channel , cq , ( void * ) ( 2000 ) , nullptr ) ; <nl> + grpc_channel_ping ( channel , cq , reinterpret_cast < void * > ( 2000 ) , nullptr ) ; <nl> grpc_event ev = grpc_completion_queue_next ( <nl> cq , grpc_timeout_seconds_to_deadline ( 5 ) , nullptr ) ; <nl> GPR_ASSERT ( ev . type = = GRPC_OP_COMPLETE ) ; <nl> - GPR_ASSERT ( ev . tag = = ( void * ) ( 2000 ) ) ; <nl> + GPR_ASSERT ( ev . tag = = reinterpret_cast < void * > ( 2000 ) ) ; <nl> GPR_ASSERT ( ev . success = = 0 ) ; <nl> GPR_ASSERT ( grpc_channel_check_connectivity_state ( channel , 0 ) ! = <nl> GRPC_CHANNEL_READY ) ; <nl> mmm a / test / core / tsi / alts / handshaker / alts_concurrent_connectivity_test . cc <nl> ppp b / test / core / tsi / alts / handshaker / alts_concurrent_connectivity_test . cc <nl> class FakeTcpServer { <nl> gpr_log ( GPR_DEBUG , <nl> " FakeTcpServer stop and " <nl> " join server thread " ) ; <nl> - gpr_event_set ( & stop_ev_ , ( void * ) 1 ) ; <nl> + gpr_event_set ( & stop_ev_ , reinterpret_cast < void * > ( 1 ) ) ; <nl> run_server_loop_thd_ - > join ( ) ; <nl> gpr_log ( GPR_DEBUG , <nl> " FakeTcpServer join server " <nl> mmm a / test / core / tsi / ssl_transport_security_test . cc <nl> ppp b / test / core / tsi / ssl_transport_security_test . cc <nl> static void ssl_test_check_handshaker_peers ( tsi_test_fixture * fixture ) { <nl> } <nl> <nl> static void ssl_test_pem_key_cert_pair_destroy ( tsi_ssl_pem_key_cert_pair kp ) { <nl> - gpr_free ( ( void * ) kp . private_key ) ; <nl> - gpr_free ( ( void * ) kp . cert_chain ) ; <nl> + gpr_free ( const_cast < char * > ( kp . private_key ) ) ; <nl> + gpr_free ( const_cast < char * > ( kp . cert_chain ) ) ; <nl> } <nl> <nl> static void ssl_test_destruct ( tsi_test_fixture * fixture ) { <nl> mmm a / test / core / util / stack_tracer . cc <nl> ppp b / test / core / util / stack_tracer . cc <nl> std : : string GetCurrentStackTrace ( ) { <nl> void * stack [ kNumStackFrames ] ; <nl> int frame_sizes [ kNumStackFrames ] ; <nl> int depth = absl : : GetStackFrames ( stack , frame_sizes , kNumStackFrames , 1 ) ; <nl> - DumpStackTrace ( stack , frame_sizes , depth , true , DebugWriteToString , <nl> - ( void * ) & result ) ; <nl> + DumpStackTrace ( stack , frame_sizes , depth , true , DebugWriteToString , & result ) ; <nl> return result ; <nl> } <nl> <nl> mmm a / test / cpp / end2end / async_end2end_test . cc <nl> ppp b / test / cpp / end2end / async_end2end_test . cc <nl> namespace testing { <nl> <nl> namespace { <nl> <nl> - void * tag ( int i ) { return ( void * ) static_cast < intptr_t > ( i ) ; } <nl> + void * tag ( int t ) { return reinterpret_cast < void * > ( t ) ; } <nl> int detag ( void * p ) { return static_cast < int > ( reinterpret_cast < intptr_t > ( p ) ) ; } <nl> <nl> class Verifier { <nl> mmm a / test / cpp / end2end / end2end_test . cc <nl> ppp b / test / cpp / end2end / end2end_test . cc <nl> TEST_P ( End2endTest , RpcMaxMessageSize ) { <nl> void ReaderThreadFunc ( ClientReaderWriter < EchoRequest , EchoResponse > * stream , <nl> gpr_event * ev ) { <nl> EchoResponse resp ; <nl> - gpr_event_set ( ev , ( void * ) 1 ) ; <nl> + gpr_event_set ( ev , reinterpret_cast < void * > ( 1 ) ) ; <nl> while ( stream - > Read ( & resp ) ) { <nl> gpr_log ( GPR_INFO , " Read message " ) ; <nl> } <nl> mmm a / test / cpp / end2end / filter_end2end_test . cc <nl> ppp b / test / cpp / end2end / filter_end2end_test . cc <nl> namespace grpc { <nl> namespace testing { <nl> namespace { <nl> <nl> - void * tag ( int i ) { return ( void * ) static_cast < intptr_t > ( i ) ; } <nl> + void * tag ( int i ) { return reinterpret_cast < void * > ( i ) ; } <nl> <nl> void verify_ok ( CompletionQueue * cq , int i , bool expect_ok ) { <nl> bool ok ; <nl> mmm a / test / cpp / end2end / generic_end2end_test . cc <nl> ppp b / test / cpp / end2end / generic_end2end_test . cc <nl> namespace grpc { <nl> namespace testing { <nl> namespace { <nl> <nl> - void * tag ( int i ) { return ( void * ) static_cast < intptr_t > ( i ) ; } <nl> + void * tag ( int i ) { return reinterpret_cast < void * > ( i ) ; } <nl> <nl> void verify_ok ( CompletionQueue * cq , int i , bool expect_ok ) { <nl> bool ok ; <nl> mmm a / test / cpp / end2end / hybrid_end2end_test . cc <nl> ppp b / test / cpp / end2end / hybrid_end2end_test . cc <nl> using : : grpc : : experimental : : GenericCallbackServerContext ; <nl> using : : grpc : : experimental : : ServerGenericBidiReactor ; <nl> # endif <nl> <nl> - void * tag ( int i ) { return ( void * ) static_cast < intptr_t > ( i ) ; } <nl> + void * tag ( int i ) { return reinterpret_cast < void * > ( i ) ; } <nl> <nl> bool VerifyReturnSuccess ( CompletionQueue * cq , int i ) { <nl> void * got_tag ; <nl> mmm a / test / cpp / end2end / interceptors_util . h <nl> ppp b / test / cpp / end2end / interceptors_util . h <nl> bool CheckMetadata ( const std : : multimap < std : : string , std : : string > & map , <nl> std : : vector < std : : unique_ptr < experimental : : ClientInterceptorFactoryInterface > > <nl> CreateDummyClientInterceptors ( ) ; <nl> <nl> - inline void * tag ( int i ) { return ( void * ) static_cast < intptr_t > ( i ) ; } <nl> + inline void * tag ( int i ) { return reinterpret_cast < void * > ( i ) ; } <nl> inline int detag ( void * p ) { <nl> return static_cast < int > ( reinterpret_cast < intptr_t > ( p ) ) ; <nl> } <nl> mmm a / test / cpp / end2end / raw_end2end_test . cc <nl> ppp b / test / cpp / end2end / raw_end2end_test . cc <nl> namespace testing { <nl> <nl> namespace { <nl> <nl> - void * tag ( int i ) { return ( void * ) static_cast < intptr_t > ( i ) ; } <nl> + void * tag ( int i ) { return reinterpret_cast < void * > ( i ) ; } <nl> int detag ( void * p ) { return static_cast < int > ( reinterpret_cast < intptr_t > ( p ) ) ; } <nl> <nl> class Verifier { <nl> mmm a / test / cpp / end2end / shutdown_test . cc <nl> ppp b / test / cpp / end2end / shutdown_test . cc <nl> class TestServiceImpl : public : : grpc : : testing : : EchoTestService : : Service { <nl> <nl> Status Echo ( ServerContext * context , const EchoRequest * / * request * / , <nl> EchoResponse * / * response * / ) override { <nl> - gpr_event_set ( ev_ , ( void * ) 1 ) ; <nl> + gpr_event_set ( ev_ , reinterpret_cast < void * > ( 1 ) ) ; <nl> while ( ! context - > IsCancelled ( ) ) { <nl> } <nl> return Status : : OK ; <nl> mmm a / test / cpp / end2end / thread_stress_test . cc <nl> ppp b / test / cpp / end2end / thread_stress_test . cc <nl> class CommonStressTestAsyncServer : public BaseClass { <nl> service_ . RequestEcho ( contexts_ [ i ] . srv_ctx . get ( ) , <nl> & contexts_ [ i ] . recv_request , <nl> contexts_ [ i ] . response_writer . get ( ) , cq_ . get ( ) , <nl> - cq_ . get ( ) , ( void * ) static_cast < intptr_t > ( i ) ) ; <nl> + cq_ . get ( ) , reinterpret_cast < void * > ( i ) ) ; <nl> } <nl> } <nl> struct Context { <nl> class AsyncClientEnd2endTest : public : : testing : : Test { <nl> request . set_message ( " Hello : " + std : : to_string ( i ) ) ; <nl> call - > response_reader = <nl> common_ . GetStub ( ) - > AsyncEcho ( & call - > context , request , & cq_ ) ; <nl> - call - > response_reader - > Finish ( & call - > response , & call - > status , <nl> - ( void * ) call ) ; <nl> + call - > response_reader - > Finish ( & call - > response , & call - > status , call ) ; <nl> <nl> grpc : : internal : : MutexLock l ( & mu_ ) ; <nl> rpcs_outstanding_ + + ; <nl> mmm a / test / cpp / interop / xds_interop_client . cc <nl> ppp b / test / cpp / interop / xds_interop_client . cc <nl> class TestClient { <nl> & call - > context , SimpleRequest : : default_instance ( ) , & cq_ ) ; <nl> call - > simple_response_reader - > StartCall ( ) ; <nl> call - > simple_response_reader - > Finish ( & call - > simple_response , & call - > status , <nl> - ( void * ) call ) ; <nl> + call ) ; <nl> } <nl> <nl> void AsyncEmptyCall ( <nl> class TestClient { <nl> & call - > context , Empty : : default_instance ( ) , & cq_ ) ; <nl> call - > empty_response_reader - > StartCall ( ) ; <nl> call - > empty_response_reader - > Finish ( & call - > empty_response , & call - > status , <nl> - ( void * ) call ) ; <nl> + call ) ; <nl> } <nl> <nl> void AsyncCompleteRpc ( ) { <nl> mmm a / test / cpp / microbenchmarks / bm_chttp2_transport . cc <nl> ppp b / test / cpp / microbenchmarks / bm_chttp2_transport . cc <nl> class Stream { <nl> grpc_transport_destroy_stream ( stream - > f_ - > transport ( ) , <nl> static_cast < grpc_stream * > ( stream - > stream_ ) , <nl> stream - > destroy_closure_ ) ; <nl> - gpr_event_set ( & stream - > done_ , ( void * ) ( 1 ) ) ; <nl> + gpr_event_set ( & stream - > done_ , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> Fixture * f_ ; <nl> static void BM_TransportEmptyOp ( benchmark : : State & state ) { <nl> std : : unique_ptr < TestClosure > stream_cancel_closure = <nl> MakeTestClosure ( [ & ] ( grpc_error * error ) { <nl> GPR_ASSERT ( error = = GRPC_ERROR_NONE ) ; <nl> - gpr_event_set ( stream_cancel_done , ( void * ) ( 1 ) ) ; <nl> + gpr_event_set ( stream_cancel_done , reinterpret_cast < void * > ( 1 ) ) ; <nl> } ) ; <nl> op . on_complete = stream_cancel_closure . get ( ) ; <nl> s - > Op ( & op ) ; <nl> static void BM_TransportStreamSend ( benchmark : : State & state ) { <nl> <nl> std : : unique_ptr < TestClosure > c = MakeTestClosure ( [ & ] ( grpc_error * / * error * / ) { <nl> if ( ! state . KeepRunning ( ) ) { <nl> - gpr_event_set ( bm_done , ( void * ) ( 1 ) ) ; <nl> + gpr_event_set ( bm_done , reinterpret_cast < void * > ( 1 ) ) ; <nl> return ; <nl> } <nl> grpc_slice_buffer send_buffer ; <nl> static void BM_TransportStreamSend ( benchmark : : State & state ) { <nl> std : : unique_ptr < TestClosure > stream_cancel_closure = <nl> MakeTestClosure ( [ & ] ( grpc_error * error ) { <nl> GPR_ASSERT ( error = = GRPC_ERROR_NONE ) ; <nl> - gpr_event_set ( stream_cancel_done , ( void * ) ( 1 ) ) ; <nl> + gpr_event_set ( stream_cancel_done , reinterpret_cast < void * > ( 1 ) ) ; <nl> } ) ; <nl> op . on_complete = stream_cancel_closure . get ( ) ; <nl> s - > Op ( & op ) ; <nl> static void BM_TransportStreamRecv ( benchmark : : State & state ) { <nl> std : : unique_ptr < TestClosure > stream_cancel_closure = <nl> MakeTestClosure ( [ & ] ( grpc_error * error ) { <nl> GPR_ASSERT ( error = = GRPC_ERROR_NONE ) ; <nl> - gpr_event_set ( stream_cancel_done , ( void * ) ( 1 ) ) ; <nl> + gpr_event_set ( stream_cancel_done , reinterpret_cast < void * > ( 1 ) ) ; <nl> } ) ; <nl> op . on_complete = stream_cancel_closure . get ( ) ; <nl> s - > Op ( & op ) ; <nl> mmm a / test / cpp / microbenchmarks / bm_cq_multiple_threads . cc <nl> ppp b / test / cpp / microbenchmarks / bm_cq_multiple_threads . cc <nl> static grpc_error * pollset_work ( grpc_pollset * ps , <nl> <nl> gpr_mu_unlock ( & ps - > mu ) ; <nl> <nl> - void * tag = ( void * ) static_cast < intptr_t > ( 10 ) ; / / Some random number <nl> + void * tag = reinterpret_cast < void * > ( 10 ) ; / / Some random number <nl> GPR_ASSERT ( grpc_cq_begin_op ( g_cq , tag ) ) ; <nl> grpc_cq_end_op ( <nl> g_cq , tag , GRPC_ERROR_NONE , cq_done_cb , nullptr , <nl> mmm a / test / cpp / naming / cancel_ares_query_test . cc <nl> ppp b / test / cpp / naming / cancel_ares_query_test . cc <nl> <nl> <nl> namespace { <nl> <nl> - void * Tag ( intptr_t t ) { return ( void * ) t ; } <nl> + void * Tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> <nl> gpr_timespec FiveSecondsFromNow ( void ) { <nl> return grpc_timeout_seconds_to_deadline ( 5 ) ; <nl> void TestCancelDuringActiveQuery ( <nl> / / Teardown <nl> grpc_channel_args_destroy ( client_args ) ; <nl> grpc_slice_unref ( details ) ; <nl> - gpr_free ( ( void * ) error_string ) ; <nl> + gpr_free ( const_cast < char * > ( error_string ) ) ; <nl> grpc_metadata_array_destroy ( & initial_metadata_recv ) ; <nl> grpc_metadata_array_destroy ( & trailing_metadata_recv ) ; <nl> grpc_metadata_array_destroy ( & request_metadata_recv ) ; <nl> mmm a / test / cpp / naming / resolver_component_test . cc <nl> ppp b / test / cpp / naming / resolver_component_test . cc <nl> void PollPollsetUntilRequestDone ( ArgsStruct * args ) { <nl> NSecondDeadline ( 1 ) ) ) ) ; <nl> gpr_mu_unlock ( args - > mu ) ; <nl> } <nl> - gpr_event_set ( & args - > ev , ( void * ) 1 ) ; <nl> + gpr_event_set ( & args - > ev , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> <nl> void CheckServiceConfigResultLocked ( const char * service_config_json , <nl> TEST ( ResolverComponentTest , TestResolvesRelevantRecordsWithConcurrentFdStress ) { <nl> / / Run the resolver test <nl> RunResolvesRelevantRecordsTest ( ResultHandler : : Create ) ; <nl> / / Shutdown and join stress thread <nl> - gpr_event_set ( & done_ev , ( void * ) 1 ) ; <nl> + gpr_event_set ( & done_ev , reinterpret_cast < void * > ( 1 ) ) ; <nl> socket_stress_thread . join ( ) ; <nl> } <nl> <nl> mmm a / test / cpp / qps / client . h <nl> ppp b / test / cpp / qps / client . h <nl> class Client { <nl> void MaybeStartRequests ( ) { <nl> if ( ! started_requests_ ) { <nl> started_requests_ = true ; <nl> - gpr_event_set ( & start_requests_ , ( void * ) 1 ) ; <nl> + gpr_event_set ( & start_requests_ , reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> } <nl> <nl> mmm a / test / cpp / server / server_request_call_test . cc <nl> ppp b / test / cpp / server / server_request_call_test . cc <nl> TEST ( ServerRequestCallTest , ShortDeadlineDoesNotCauseOkayFalse ) { <nl> std : : lock_guard < std : : mutex > lock ( mu ) ; <nl> if ( ! shutting_down ) { <nl> service . RequestEcho ( & ctx , & req , & responder , cq . get ( ) , cq . get ( ) , <nl> - ( void * ) 1 ) ; <nl> + reinterpret_cast < void * > ( 1 ) ) ; <nl> } <nl> } <nl> <nl> TEST ( ServerRequestCallTest , ShortDeadlineDoesNotCauseOkayFalse ) { <nl> continue ; <nl> } <nl> gpr_log ( GPR_INFO , " Finishing request % d " , n ) ; <nl> - responder . Finish ( response , grpc : : Status : : OK , ( void * ) 2 ) ; <nl> + responder . Finish ( response , grpc : : Status : : OK , <nl> + reinterpret_cast < void * > ( 2 ) ) ; <nl> if ( ! cq - > Next ( & tag , & ok ) ) { <nl> break ; <nl> } <nl> mmm a / test / cpp / util / channelz_sampler_test . cc <nl> ppp b / test / cpp / util / channelz_sampler_test . cc <nl> TEST ( ChannelzSamplerTest , SimpleTest ) { <nl> GPR_ASSERT ( 0 ) ; <nl> } <nl> delete test_driver ; <nl> - gpr_event_set ( & done_ev1 , ( void * ) 1 ) ; <nl> - gpr_event_set ( & done_ev2 , ( void * ) 1 ) ; <nl> + gpr_event_set ( & done_ev1 , reinterpret_cast < void * > ( 1 ) ) ; <nl> + gpr_event_set ( & done_ev2 , reinterpret_cast < void * > ( 1 ) ) ; <nl> client_thread_1 . join ( ) ; <nl> client_thread_2 . join ( ) ; <nl> } <nl> mmm a / test / cpp / util / cli_call . cc <nl> ppp b / test / cpp / util / cli_call . cc <nl> <nl> namespace grpc { <nl> namespace testing { <nl> namespace { <nl> - void * tag ( int i ) { return ( void * ) static_cast < intptr_t > ( i ) ; } <nl> + void * tag ( intptr_t t ) { return reinterpret_cast < void * > ( t ) ; } <nl> } / / namespace <nl> <nl> Status CliCall : : Call ( const std : : shared_ptr < grpc : : Channel > & channel , <nl> | C + + cast for void * | grpc/grpc | 2ff84ed8c2cb272b26766039d5bb07b009df2617 | 2020-12-01T01:29:15Z |
mmm a / src / ppc / lithium - codegen - ppc . cc <nl> ppp b / src / ppc / lithium - codegen - ppc . cc <nl> void LCodeGen : : DoReturn ( LReturn * instr ) { <nl> } <nl> <nl> <nl> - void LCodeGen : : DoLoadGlobalCell ( LLoadGlobalCell * instr ) { <nl> - Register result = ToRegister ( instr - > result ( ) ) ; <nl> - __ mov ( ip , Operand ( Handle < Object > ( instr - > hydrogen ( ) - > cell ( ) . handle ( ) ) ) ) ; <nl> - __ LoadP ( result , FieldMemOperand ( ip , Cell : : kValueOffset ) ) ; <nl> - if ( instr - > hydrogen ( ) - > RequiresHoleCheck ( ) ) { <nl> - __ LoadRoot ( ip , Heap : : kTheHoleValueRootIndex ) ; <nl> - __ cmp ( result , ip ) ; <nl> - DeoptimizeIf ( eq , instr , Deoptimizer : : kHole ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> template < class T > <nl> void LCodeGen : : EmitVectorLoadICRegisters ( T * instr ) { <nl> DCHECK ( FLAG_vector_ics ) ; <nl> void LCodeGen : : DoLoadGlobalGeneric ( LLoadGlobalGeneric * instr ) { <nl> } <nl> <nl> <nl> - void LCodeGen : : DoStoreGlobalCell ( LStoreGlobalCell * instr ) { <nl> - Register value = ToRegister ( instr - > value ( ) ) ; <nl> - Register cell = scratch0 ( ) ; <nl> - <nl> - / / Load the cell . <nl> - __ mov ( cell , Operand ( instr - > hydrogen ( ) - > cell ( ) . handle ( ) ) ) ; <nl> - <nl> - / / If the cell we are storing to contains the hole it could have <nl> - / / been deleted from the property dictionary . In that case , we need <nl> - / / to update the property details in the property dictionary to mark <nl> - / / it as no longer deleted . <nl> - if ( instr - > hydrogen ( ) - > RequiresHoleCheck ( ) ) { <nl> - / / We use a temp to check the payload ( CompareRoot might clobber ip ) . <nl> - Register payload = ToRegister ( instr - > temp ( ) ) ; <nl> - __ LoadP ( payload , FieldMemOperand ( cell , Cell : : kValueOffset ) ) ; <nl> - __ CompareRoot ( payload , Heap : : kTheHoleValueRootIndex ) ; <nl> - DeoptimizeIf ( eq , instr , Deoptimizer : : kHole ) ; <nl> - } <nl> - <nl> - / / Store the value . <nl> - __ StoreP ( value , FieldMemOperand ( cell , Cell : : kValueOffset ) , r0 ) ; <nl> - / / Cells are always rescanned , so no write barrier here . <nl> - } <nl> - <nl> - <nl> void LCodeGen : : DoLoadContextSlot ( LLoadContextSlot * instr ) { <nl> Register context = ToRegister ( instr - > context ( ) ) ; <nl> Register result = ToRegister ( instr - > result ( ) ) ; <nl> mmm a / src / ppc / lithium - ppc . cc <nl> ppp b / src / ppc / lithium - ppc . cc <nl> LInstruction * LChunkBuilder : : DoConstant ( HConstant * instr ) { <nl> } <nl> <nl> <nl> - LInstruction * LChunkBuilder : : DoLoadGlobalCell ( HLoadGlobalCell * instr ) { <nl> - LLoadGlobalCell * result = new ( zone ( ) ) LLoadGlobalCell ; <nl> - return instr - > RequiresHoleCheck ( ) <nl> - ? AssignEnvironment ( DefineAsRegister ( result ) ) <nl> - : DefineAsRegister ( result ) ; <nl> - } <nl> - <nl> - <nl> LInstruction * LChunkBuilder : : DoLoadGlobalGeneric ( HLoadGlobalGeneric * instr ) { <nl> LOperand * context = UseFixed ( instr - > context ( ) , cp ) ; <nl> LOperand * global_object = <nl> LInstruction * LChunkBuilder : : DoLoadGlobalGeneric ( HLoadGlobalGeneric * instr ) { <nl> } <nl> <nl> <nl> - LInstruction * LChunkBuilder : : DoStoreGlobalCell ( HStoreGlobalCell * instr ) { <nl> - LOperand * value = UseRegister ( instr - > value ( ) ) ; <nl> - / / Use a temp to check the value in the cell in the case where we perform <nl> - / / a hole check . <nl> - return instr - > RequiresHoleCheck ( ) <nl> - ? AssignEnvironment ( new ( zone ( ) ) <nl> - LStoreGlobalCell ( value , TempRegister ( ) ) ) <nl> - : new ( zone ( ) ) LStoreGlobalCell ( value , NULL ) ; <nl> - } <nl> - <nl> - <nl> LInstruction * LChunkBuilder : : DoLoadContextSlot ( HLoadContextSlot * instr ) { <nl> LOperand * context = UseRegisterAtStart ( instr - > value ( ) ) ; <nl> LInstruction * result = <nl> mmm a / src / ppc / lithium - ppc . h <nl> ppp b / src / ppc / lithium - ppc . h <nl> class LCodeGen ; <nl> V ( LoadRoot ) \ <nl> V ( LoadFieldByIndex ) \ <nl> V ( LoadFunctionPrototype ) \ <nl> - V ( LoadGlobalCell ) \ <nl> V ( LoadGlobalGeneric ) \ <nl> V ( LoadKeyed ) \ <nl> V ( LoadKeyedGeneric ) \ <nl> class LCodeGen ; <nl> V ( StoreCodeEntry ) \ <nl> V ( StoreContextSlot ) \ <nl> V ( StoreFrameContext ) \ <nl> - V ( StoreGlobalCell ) \ <nl> V ( StoreKeyed ) \ <nl> V ( StoreKeyedGeneric ) \ <nl> V ( StoreNamedField ) \ <nl> class LLoadKeyedGeneric FINAL : public LTemplateInstruction < 1 , 3 , 1 > { <nl> } ; <nl> <nl> <nl> - class LLoadGlobalCell FINAL : public LTemplateInstruction < 1 , 0 , 0 > { <nl> - public : <nl> - DECLARE_CONCRETE_INSTRUCTION ( LoadGlobalCell , " load - global - cell " ) <nl> - DECLARE_HYDROGEN_ACCESSOR ( LoadGlobalCell ) <nl> - } ; <nl> - <nl> - <nl> class LLoadGlobalGeneric FINAL : public LTemplateInstruction < 1 , 2 , 1 > { <nl> public : <nl> LLoadGlobalGeneric ( LOperand * context , LOperand * global_object , <nl> class LLoadGlobalGeneric FINAL : public LTemplateInstruction < 1 , 2 , 1 > { <nl> } ; <nl> <nl> <nl> - class LStoreGlobalCell FINAL : public LTemplateInstruction < 0 , 1 , 1 > { <nl> - public : <nl> - LStoreGlobalCell ( LOperand * value , LOperand * temp ) { <nl> - inputs_ [ 0 ] = value ; <nl> - temps_ [ 0 ] = temp ; <nl> - } <nl> - <nl> - LOperand * value ( ) { return inputs_ [ 0 ] ; } <nl> - LOperand * temp ( ) { return temps_ [ 0 ] ; } <nl> - <nl> - DECLARE_CONCRETE_INSTRUCTION ( StoreGlobalCell , " store - global - cell " ) <nl> - DECLARE_HYDROGEN_ACCESSOR ( StoreGlobalCell ) <nl> - } ; <nl> - <nl> - <nl> class LLoadContextSlot FINAL : public LTemplateInstruction < 1 , 1 , 0 > { <nl> public : <nl> explicit LLoadContextSlot ( LOperand * context ) { inputs_ [ 0 ] = context ; } <nl> | PPC : Remove PropertyCell space | v8/v8 | c277e7efad70f4c3ac512c0fcece223c2dc66cae | 2015-03-23T21:31:43Z |
mmm a / test / config . ini . in <nl> ppp b / test / config . ini . in <nl> RPCAUTH = @ abs_top_srcdir @ / share / rpcauth / rpcauth . py <nl> [ components ] <nl> # Which components are enabled . These are commented out by ` configure ` if they were disabled when running config . <nl> @ ENABLE_WALLET_TRUE @ ENABLE_WALLET = true <nl> + @ USE_SQLITE_TRUE @ USE_SQLITE = true <nl> @ BUILD_BITCOIN_CLI_TRUE @ ENABLE_CLI = true <nl> @ BUILD_BITCOIN_WALLET_TRUE @ ENABLE_WALLET_TOOL = true <nl> @ BUILD_BITCOIND_TRUE @ ENABLE_BITCOIND = true <nl> mmm a / test / functional / test_framework / test_framework . py <nl> ppp b / test / functional / test_framework / test_framework . py <nl> def skip_if_no_wallet ( self ) : <nl> " " " Skip the running test if wallet has not been compiled . " " " <nl> if not self . is_wallet_compiled ( ) : <nl> raise SkipTest ( " wallet has not been compiled . " ) <nl> + if self . options . descriptors : <nl> + self . skip_if_no_sqlite ( ) <nl> + <nl> + def skip_if_no_sqlite ( self ) : <nl> + " " " Skip the running test if sqlite has not been compiled . " " " <nl> + if not self . is_sqlite_compiled ( ) : <nl> + raise SkipTest ( " sqlite has not been compiled . " ) <nl> <nl> def skip_if_no_wallet_tool ( self ) : <nl> " " " Skip the running test if bitcoin - wallet has not been compiled . " " " <nl> def is_wallet_tool_compiled ( self ) : <nl> def is_zmq_compiled ( self ) : <nl> " " " Checks whether the zmq module was compiled . " " " <nl> return self . config [ " components " ] . getboolean ( " ENABLE_ZMQ " ) <nl> + <nl> + def is_sqlite_compiled ( self ) : <nl> + " " " Checks whether the wallet module was compiled . " " " <nl> + return self . config [ " components " ] . getboolean ( " USE_SQLITE " ) <nl> mmm a / test / functional / test_runner . py <nl> ppp b / test / functional / test_runner . py <nl> <nl> ' rpc_net . py ' , <nl> ' wallet_keypool . py ' , <nl> ' wallet_keypool . py - - descriptors ' , <nl> - ' wallet_descriptor . py ' , <nl> + ' wallet_descriptor . py - - descriptors ' , <nl> ' p2p_nobloomfilter_messages . py ' , <nl> ' p2p_filter . py ' , <nl> ' rpc_setban . py ' , <nl> <nl> ' mempool_expiry . py ' , <nl> ' wallet_import_rescan . py ' , <nl> ' wallet_import_with_label . py ' , <nl> - ' wallet_importdescriptors . py ' , <nl> + ' wallet_importdescriptors . py - - descriptors ' , <nl> ' wallet_upgradewallet . py ' , <nl> ' rpc_bind . py - - ipv4 ' , <nl> ' rpc_bind . py - - ipv6 ' , <nl> mmm a / test / functional / wallet_descriptor . py <nl> ppp b / test / functional / wallet_descriptor . py <nl> def set_test_params ( self ) : <nl> <nl> def skip_test_if_missing_module ( self ) : <nl> self . skip_if_no_wallet ( ) <nl> + self . skip_if_no_sqlite ( ) <nl> <nl> def run_test ( self ) : <nl> wallet_info = self . nodes [ 0 ] . getwalletinfo ( ) <nl> mmm a / test / functional / wallet_importdescriptors . py <nl> ppp b / test / functional / wallet_importdescriptors . py <nl> def set_test_params ( self ) : <nl> <nl> def skip_test_if_missing_module ( self ) : <nl> self . skip_if_no_wallet ( ) <nl> + self . skip_if_no_sqlite ( ) <nl> <nl> def test_importdesc ( self , req , success , error_code = None , error_message = None , warnings = None , wallet = None ) : <nl> " " " Run importdescriptors and assert success " " " <nl> | Skip - - descriptor tests if sqlite is not compiled | bitcoin/bitcoin | 586640381a2c379ce3d6366b1b4534ccc4e8ccf2 | 2020-10-29T16:34:16Z |
mmm a / src / serializer / log / log_serializer . cc <nl> ppp b / src / serializer / log / log_serializer . cc <nl> void log_serializer_t : : remap_block_to_new_offset ( off64_t current_offset , off64_t <nl> <nl> while ( range . first ! = range . second ) { <nl> have_to_update_gc = true ; <nl> - rassert ( token_offsets [ range . first - > second ] = = current_offset ) ; <nl> + # ifndef NDEBUG <nl> + std : : map < ls_block_token_pointee_t * , off64_t > : : const_iterator token_offsets_iter = token_offsets . find ( range . first - > second ) ; <nl> + rassert ( token_offsets_iter ! = token_offsets . end ( ) ) ; <nl> + rassert ( token_offsets_iter - > second = = current_offset ) ; <nl> + # endif <nl> token_offsets [ range . first - > second ] = new_offset ; <nl> offset_tokens . insert ( std : : pair < off64_t , ls_block_token_pointee_t * > ( new_offset , range . first - > second ) ) ; <nl> <nl> | Made the token_offsets assertion in remap_block_to_new_offset more specific . | rethinkdb/rethinkdb | 9ee89701634672104ba93f22cc4c65bda0bcf020 | 2012-10-09T23:19:50Z |
mmm a / src / yuzu / CMakeLists . txt <nl> ppp b / src / yuzu / CMakeLists . txt <nl> add_executable ( yuzu <nl> configuration / configure_mouse_advanced . h <nl> configuration / configure_system . cpp <nl> configuration / configure_system . h <nl> + configuration / configure_per_general . cpp <nl> + configuration / configure_per_general . h <nl> configuration / configure_touchscreen_advanced . cpp <nl> configuration / configure_touchscreen_advanced . h <nl> configuration / configure_web . cpp <nl> set ( UIS <nl> configuration / configure_input . ui <nl> configuration / configure_input_player . ui <nl> configuration / configure_mouse_advanced . ui <nl> + configuration / configure_per_general . ui <nl> configuration / configure_system . ui <nl> configuration / configure_touchscreen_advanced . ui <nl> configuration / configure_web . ui <nl> new file mode 100644 <nl> index 00000000000 . . ed85f84a92c <nl> mmm / dev / null <nl> ppp b / src / yuzu / configuration / configure_per_general . cpp <nl> <nl> + / / Copyright 2016 Citra Emulator Project <nl> + / / Licensed under GPLv2 or any later version <nl> + / / Refer to the license . txt file included . <nl> + <nl> + # include < algorithm > <nl> + # include < memory > <nl> + # include < utility > <nl> + # include < QMenu > <nl> + # include < QMessageBox > <nl> + # include < QStandardItemModel > <nl> + # include < QString > <nl> + # include < QTimer > <nl> + # include < QTreeView > <nl> + # include " common / param_package . h " <nl> + # include " core / file_sys / control_metadata . h " <nl> + # include " core / file_sys / patch_manager . h " <nl> + # include " core / file_sys / xts_archive . h " <nl> + # include " core / loader / loader . h " <nl> + # include " input_common / main . h " <nl> + # include " yuzu / configuration / config . h " <nl> + # include " yuzu / configuration / configure_input . h " <nl> + # include " yuzu / configuration / configure_per_general . h " <nl> + # include " yuzu / ui_settings . h " <nl> + <nl> + ConfigurePerGameGeneral : : ConfigurePerGameGeneral ( u64 title_id , QWidget * parent ) <nl> + : QDialog ( parent ) , ui ( std : : make_unique < Ui : : ConfigurePerGameGeneral > ( ) ) , title_id ( title_id ) { <nl> + <nl> + ui - > setupUi ( this ) ; <nl> + setFocusPolicy ( Qt : : ClickFocus ) ; <nl> + setWindowTitle ( tr ( " Properties " ) ) ; <nl> + <nl> + layout = new QVBoxLayout ; <nl> + tree_view = new QTreeView ; <nl> + item_model = new QStandardItemModel ( tree_view ) ; <nl> + tree_view - > setModel ( item_model ) ; <nl> + tree_view - > setAlternatingRowColors ( true ) ; <nl> + tree_view - > setSelectionMode ( QHeaderView : : SingleSelection ) ; <nl> + tree_view - > setSelectionBehavior ( QHeaderView : : SelectRows ) ; <nl> + tree_view - > setVerticalScrollMode ( QHeaderView : : ScrollPerPixel ) ; <nl> + tree_view - > setHorizontalScrollMode ( QHeaderView : : ScrollPerPixel ) ; <nl> + tree_view - > setSortingEnabled ( true ) ; <nl> + tree_view - > setEditTriggers ( QHeaderView : : NoEditTriggers ) ; <nl> + tree_view - > setUniformRowHeights ( true ) ; <nl> + tree_view - > setContextMenuPolicy ( Qt : : NoContextMenu ) ; <nl> + <nl> + item_model - > insertColumns ( 0 , 2 ) ; <nl> + item_model - > setHeaderData ( 0 , Qt : : Horizontal , " Patch Name " ) ; <nl> + item_model - > setHeaderData ( 1 , Qt : : Horizontal , " Version " ) ; <nl> + <nl> + / / We must register all custom types with the Qt Automoc system so that we are able to use it <nl> + / / with signals / slots . In this case , QList falls under the umbrells of custom types . <nl> + qRegisterMetaType < QList < QStandardItem * > > ( " QList < QStandardItem * > " ) ; <nl> + <nl> + layout - > setContentsMargins ( 0 , 0 , 0 , 0 ) ; <nl> + layout - > setSpacing ( 0 ) ; <nl> + layout - > addWidget ( tree_view ) ; <nl> + <nl> + ui - > scrollArea - > setLayout ( layout ) ; <nl> + <nl> + scene = new QGraphicsScene ; <nl> + ui - > icon_view - > setScene ( scene ) ; <nl> + <nl> + connect ( item_model , & QStandardItemModel : : itemChanged , <nl> + [ & ] ( ) { UISettings : : values . is_game_list_reload_pending . exchange ( true ) ; } ) ; <nl> + <nl> + this - > loadConfiguration ( ) ; <nl> + } <nl> + <nl> + void ConfigurePerGameGeneral : : applyConfiguration ( ) { <nl> + std : : vector < std : : string > disabled_addons ; <nl> + <nl> + for ( const auto & item : list_items ) { <nl> + const auto disabled = item . front ( ) - > checkState ( ) = = Qt : : Unchecked ; <nl> + if ( disabled ) <nl> + disabled_addons . push_back ( item . front ( ) - > text ( ) . toStdString ( ) ) ; <nl> + } <nl> + <nl> + Settings : : values . disabled_addons [ title_id ] = disabled_addons ; <nl> + } <nl> + <nl> + void ConfigurePerGameGeneral : : loadFromFile ( FileSys : : VirtualFile file ) { <nl> + this - > file = std : : move ( file ) ; <nl> + this - > loadConfiguration ( ) ; <nl> + } <nl> + <nl> + void ConfigurePerGameGeneral : : loadConfiguration ( ) { <nl> + if ( file = = nullptr ) <nl> + return ; <nl> + <nl> + const auto loader = Loader : : GetLoader ( file ) ; <nl> + <nl> + ui - > display_title_id - > setText ( fmt : : format ( " { : 016X } " , title_id ) . c_str ( ) ) ; <nl> + <nl> + FileSys : : PatchManager pm { title_id } ; <nl> + const auto control = pm . GetControlMetadata ( ) ; <nl> + <nl> + if ( control . first ! = nullptr ) { <nl> + ui - > display_version - > setText ( QString : : fromStdString ( control . first - > GetVersionString ( ) ) ) ; <nl> + ui - > display_name - > setText ( QString : : fromStdString ( control . first - > GetApplicationName ( ) ) ) ; <nl> + ui - > display_developer - > setText ( QString : : fromStdString ( control . first - > GetDeveloperName ( ) ) ) ; <nl> + } else { <nl> + std : : string title ; <nl> + if ( loader - > ReadTitle ( title ) = = Loader : : ResultStatus : : Success ) <nl> + ui - > display_name - > setText ( QString : : fromStdString ( title ) ) ; <nl> + <nl> + std : : string developer ; <nl> + if ( loader - > ReadDeveloper ( developer ) = = Loader : : ResultStatus : : Success ) <nl> + ui - > display_developer - > setText ( QString : : fromStdString ( developer ) ) ; <nl> + <nl> + ui - > display_version - > setText ( " 1 . 0 . 0 " ) ; <nl> + } <nl> + <nl> + if ( control . second ! = nullptr ) { <nl> + scene - > clear ( ) ; <nl> + <nl> + QPixmap map ; <nl> + const auto bytes = control . second - > ReadAllBytes ( ) ; <nl> + map . loadFromData ( bytes . data ( ) , bytes . size ( ) ) ; <nl> + <nl> + scene - > addPixmap ( map . scaled ( ui - > icon_view - > width ( ) , ui - > icon_view - > height ( ) , <nl> + Qt : : IgnoreAspectRatio , Qt : : SmoothTransformation ) ) ; <nl> + } else { <nl> + std : : vector < u8 > bytes ; <nl> + if ( loader - > ReadIcon ( bytes ) = = Loader : : ResultStatus : : Success ) { <nl> + scene - > clear ( ) ; <nl> + <nl> + QPixmap map ; <nl> + map . loadFromData ( bytes . data ( ) , bytes . size ( ) ) ; <nl> + <nl> + scene - > addPixmap ( map . scaled ( ui - > icon_view - > width ( ) , ui - > icon_view - > height ( ) , <nl> + Qt : : IgnoreAspectRatio , Qt : : SmoothTransformation ) ) ; <nl> + } <nl> + } <nl> + <nl> + FileSys : : VirtualFile update_raw ; <nl> + loader - > ReadUpdateRaw ( update_raw ) ; <nl> + <nl> + const auto & disabled = Settings : : values . disabled_addons [ title_id ] ; <nl> + <nl> + for ( const auto & patch : pm . GetPatchVersionNames ( update_raw ) ) { <nl> + QStandardItem * first_item = new QStandardItem ; <nl> + const auto name = QString : : fromStdString ( patch . first ) . replace ( " [ D ] " , " " ) ; <nl> + first_item - > setText ( name ) ; <nl> + first_item - > setCheckable ( true ) ; <nl> + <nl> + const auto patch_disabled = <nl> + std : : find ( disabled . begin ( ) , disabled . end ( ) , name . toStdString ( ) ) ! = disabled . end ( ) ; <nl> + <nl> + first_item - > setCheckState ( patch_disabled ? Qt : : Unchecked : Qt : : Checked ) ; <nl> + <nl> + list_items . push_back ( QList < QStandardItem * > { <nl> + first_item , new QStandardItem { QString : : fromStdString ( patch . second ) } } ) ; <nl> + item_model - > appendRow ( list_items . back ( ) ) ; <nl> + } <nl> + <nl> + tree_view - > setColumnWidth ( 0 , 5 * tree_view - > width ( ) / 16 ) ; <nl> + <nl> + ui - > display_filename - > setText ( QString : : fromStdString ( file - > GetName ( ) ) ) ; <nl> + <nl> + ui - > display_format - > setText ( <nl> + QString : : fromStdString ( Loader : : GetFileTypeString ( loader - > GetFileType ( ) ) ) ) ; <nl> + <nl> + QLocale locale = this - > locale ( ) ; <nl> + QString valueText = locale . formattedDataSize ( file - > GetSize ( ) ) ; <nl> + ui - > display_size - > setText ( valueText ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 5f958bbbabc <nl> mmm / dev / null <nl> ppp b / src / yuzu / configuration / configure_per_general . h <nl> <nl> + / / Copyright 2016 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 < array > <nl> + # include < functional > <nl> + # include < memory > <nl> + # include < string > <nl> + # include < unordered_map > <nl> + # include < QKeyEvent > <nl> + # include < QList > <nl> + # include < QWidget > <nl> + # include < boost / optional . hpp > <nl> + # include " common / param_package . h " <nl> + # include " core / file_sys / vfs . h " <nl> + # include " core / settings . h " <nl> + # include " input_common / main . h " <nl> + # include " ui_configure_per_general . h " <nl> + # include " yuzu / configuration / config . h " <nl> + <nl> + class QTreeView ; <nl> + class QGraphicsScene ; <nl> + class QStandardItem ; <nl> + class QStandardItemModel ; <nl> + <nl> + namespace Ui { <nl> + class ConfigurePerGameGeneral ; <nl> + } <nl> + <nl> + class ConfigurePerGameGeneral : public QDialog { <nl> + Q_OBJECT <nl> + <nl> + public : <nl> + explicit ConfigurePerGameGeneral ( u64 title_id , QWidget * parent = nullptr ) ; <nl> + <nl> + / / / Save all button configurations to settings file <nl> + void applyConfiguration ( ) ; <nl> + <nl> + void loadFromFile ( FileSys : : VirtualFile file ) ; <nl> + <nl> + private : <nl> + std : : unique_ptr < Ui : : ConfigurePerGameGeneral > ui ; <nl> + FileSys : : VirtualFile file ; <nl> + u64 title_id ; <nl> + <nl> + QVBoxLayout * layout ; <nl> + QTreeView * tree_view ; <nl> + QStandardItemModel * item_model ; <nl> + QGraphicsScene * scene ; <nl> + <nl> + std : : vector < QList < QStandardItem * > > list_items ; <nl> + <nl> + void loadConfiguration ( ) ; <nl> + } ; <nl> new file mode 100644 <nl> index 00000000000 . . 8fdd96fa418 <nl> mmm / dev / null <nl> ppp b / src / yuzu / configuration / configure_per_general . ui <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> + < ui version = " 4 . 0 " > <nl> + < class > ConfigurePerGameGeneral < / class > <nl> + < widget class = " QDialog " name = " ConfigurePerGameGeneral " > <nl> + < property name = " geometry " > <nl> + < rect > <nl> + < x > 0 < / x > <nl> + < y > 0 < / y > <nl> + < width > 400 < / width > <nl> + < height > 520 < / height > <nl> + < / rect > <nl> + < / property > <nl> + < property name = " windowTitle " > <nl> + < string > ConfigurePerGameGeneral < / string > <nl> + < / property > <nl> + < layout class = " QHBoxLayout " name = " HorizontalLayout " > <nl> + < item > <nl> + < layout class = " QVBoxLayout " name = " VerticalLayout " > <nl> + < item > <nl> + < widget class = " QGroupBox " name = " GeneralGroupBox " > <nl> + < property name = " title " > <nl> + < string > Info < / string > <nl> + < / property > <nl> + < layout class = " QHBoxLayout " name = " GeneralHorizontalLayout " > <nl> + < item > <nl> + < layout class = " QGridLayout " name = " gridLayout_2 " > <nl> + < item row = " 6 " column = " 1 " colspan = " 2 " > <nl> + < widget class = " QLineEdit " name = " display_filename " > <nl> + < property name = " enabled " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < property name = " readOnly " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 0 " column = " 1 " > <nl> + < widget class = " QLineEdit " name = " display_name " > <nl> + < property name = " enabled " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < property name = " readOnly " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 1 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_2 " > <nl> + < property name = " text " > <nl> + < string > Developer < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 5 " column = " 1 " colspan = " 2 " > <nl> + < widget class = " QLineEdit " name = " display_size " > <nl> + < property name = " enabled " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < property name = " readOnly " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 0 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label " > <nl> + < property name = " text " > <nl> + < string > Name < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 6 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_7 " > <nl> + < property name = " text " > <nl> + < string > Filename < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 2 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_3 " > <nl> + < property name = " text " > <nl> + < string > Version < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 4 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_5 " > <nl> + < property name = " text " > <nl> + < string > Format < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 2 " column = " 1 " > <nl> + < widget class = " QLineEdit " name = " display_version " > <nl> + < property name = " enabled " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < property name = " readOnly " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 4 " column = " 1 " > <nl> + < widget class = " QLineEdit " name = " display_format " > <nl> + < property name = " enabled " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < property name = " readOnly " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 5 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_6 " > <nl> + < property name = " text " > <nl> + < string > Size < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 1 " column = " 1 " > <nl> + < widget class = " QLineEdit " name = " display_developer " > <nl> + < property name = " enabled " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < property name = " readOnly " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 3 " column = " 0 " > <nl> + < widget class = " QLabel " name = " label_4 " > <nl> + < property name = " text " > <nl> + < string > Title ID < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 3 " column = " 1 " > <nl> + < widget class = " QLineEdit " name = " display_title_id " > <nl> + < property name = " enabled " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < property name = " readOnly " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < item row = " 0 " column = " 2 " rowspan = " 5 " > <nl> + < widget class = " QGraphicsView " name = " icon_view " > <nl> + < property name = " sizePolicy " > <nl> + < sizepolicy hsizetype = " Maximum " vsizetype = " Maximum " > <nl> + < horstretch > 0 < / horstretch > <nl> + < verstretch > 0 < / verstretch > <nl> + < / sizepolicy > <nl> + < / property > <nl> + < property name = " minimumSize " > <nl> + < size > <nl> + < width > 128 < / width > <nl> + < height > 128 < / height > <nl> + < / size > <nl> + < / property > <nl> + < property name = " maximumSize " > <nl> + < size > <nl> + < width > 128 < / width > <nl> + < height > 128 < / height > <nl> + < / size > <nl> + < / property > <nl> + < property name = " verticalScrollBarPolicy " > <nl> + < enum > Qt : : ScrollBarAlwaysOff < / enum > <nl> + < / property > <nl> + < property name = " horizontalScrollBarPolicy " > <nl> + < enum > Qt : : ScrollBarAlwaysOff < / enum > <nl> + < / property > <nl> + < property name = " sizeAdjustPolicy " > <nl> + < enum > QAbstractScrollArea : : AdjustToContents < / enum > <nl> + < / property > <nl> + < property name = " interactive " > <nl> + < bool > false < / bool > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < / layout > <nl> + < / item > <nl> + < / layout > <nl> + < / widget > <nl> + < / item > <nl> + < item > <nl> + < widget class = " QGroupBox " name = " PerformanceGroupBox " > <nl> + < property name = " title " > <nl> + < string > Add - Ons < / string > <nl> + < / property > <nl> + < layout class = " QHBoxLayout " name = " PerformanceHorizontalLayout " > <nl> + < item > <nl> + < widget class = " QScrollArea " name = " scrollArea " > <nl> + < property name = " widgetResizable " > <nl> + < bool > true < / bool > <nl> + < / property > <nl> + < widget class = " QWidget " name = " scrollAreaWidgetContents " > <nl> + < property name = " geometry " > <nl> + < rect > <nl> + < x > 0 < / x > <nl> + < y > 0 < / y > <nl> + < width > 350 < / width > <nl> + < height > 169 < / height > <nl> + < / rect > <nl> + < / property > <nl> + < / widget > <nl> + < / widget > <nl> + < / item > <nl> + < item > <nl> + < layout class = " QVBoxLayout " name = " PerformanceVerticalLayout " / > <nl> + < / item > <nl> + < / layout > <nl> + < / widget > <nl> + < / item > <nl> + < item > <nl> + < spacer name = " verticalSpacer " > <nl> + < property name = " orientation " > <nl> + < enum > Qt : : Vertical < / enum > <nl> + < / property > <nl> + < property name = " sizeType " > <nl> + < enum > QSizePolicy : : Fixed < / 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> + < item > <nl> + < widget class = " QDialogButtonBox " name = " buttonBox " > <nl> + < property name = " standardButtons " > <nl> + < set > QDialogButtonBox : : Cancel | QDialogButtonBox : : Ok < / set > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> + < / layout > <nl> + < / item > <nl> + < / layout > <nl> + < / widget > <nl> + < resources / > <nl> + < connections > <nl> + < connection > <nl> + < sender > buttonBox < / sender > <nl> + < signal > accepted ( ) < / signal > <nl> + < receiver > ConfigurePerGameGeneral < / receiver > <nl> + < slot > accept ( ) < / slot > <nl> + < hints > <nl> + < hint type = " sourcelabel " > <nl> + < x > 269 < / x > <nl> + < y > 567 < / y > <nl> + < / hint > <nl> + < hint type = " destinationlabel " > <nl> + < x > 269 < / x > <nl> + < y > 294 < / y > <nl> + < / hint > <nl> + < / hints > <nl> + < / connection > <nl> + < connection > <nl> + < sender > buttonBox < / sender > <nl> + < signal > rejected ( ) < / signal > <nl> + < receiver > ConfigurePerGameGeneral < / receiver > <nl> + < slot > reject ( ) < / slot > <nl> + < hints > <nl> + < hint type = " sourcelabel " > <nl> + < x > 269 < / x > <nl> + < y > 567 < / y > <nl> + < / hint > <nl> + < hint type = " destinationlabel " > <nl> + < x > 269 < / x > <nl> + < y > 294 < / y > <nl> + < / hint > <nl> + < / hints > <nl> + < / connection > <nl> + < / connections > <nl> + < / ui > <nl> | qt : Add UI to display game properties and disable add - ons | yuzu-emu/yuzu | 60e27252a52e9cb4f2d9671036c0bfc811979a15 | 2018-12-03T22:21:25Z |
mmm a / lib / SILOptimizer / LoopTransforms / LICM . cpp <nl> ppp b / lib / SILOptimizer / LoopTransforms / LICM . cpp <nl> static bool handledEndAccesses ( BeginAccessInst * BI , SILLoop * Loop ) { <nl> return true ; <nl> } <nl> <nl> + static bool isCoveredByScope ( BeginAccessInst * BI , DominanceInfo * DT , <nl> + SILInstruction * applyInstr ) { <nl> + if ( ! DT - > dominates ( BI , applyInstr ) ) <nl> + return false ; <nl> + for ( auto * EI : BI - > getEndAccesses ( ) ) { <nl> + if ( ! DT - > dominates ( applyInstr , EI ) ) <nl> + return false ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> static bool analyzeBeginAccess ( BeginAccessInst * BI , <nl> SmallVector < BeginAccessInst * , 8 > & BeginAccesses , <nl> SmallVector < FullApplySite , 8 > & fullApplies , <nl> + WriteSet & MayWrites , <nl> AccessedStorageAnalysis * ASA , <nl> DominanceInfo * DT ) { <nl> if ( BI - > getEnforcement ( ) ! = SILAccessEnforcement : : Dynamic ) { <nl> static bool analyzeBeginAccess ( BeginAccessInst * BI , <nl> / / If the apply is “ sandwiched ” between the begin and end access , <nl> / / there ’ s no reason we can ’ t hoist out of the loop . <nl> auto * applyInstr = fullApply . getInstruction ( ) ; <nl> - if ( ! DT - > dominates ( BI , applyInstr ) ) <nl> + if ( ! isCoveredByScope ( BI , DT , applyInstr ) ) <nl> return false ; <nl> - for ( auto * EI : BI - > getEndAccesses ( ) ) { <nl> - if ( ! DT - > dominates ( applyInstr , EI ) ) <nl> - return false ; <nl> + } <nl> + <nl> + / / Check may releases <nl> + / / Only class and global access that may alias would conflict <nl> + const AccessedStorage : : Kind kind = storage . getKind ( ) ; <nl> + if ( kind ! = AccessedStorage : : Class & & kind ! = AccessedStorage : : Global ) { <nl> + return true ; <nl> + } <nl> + / / TODO Introduce " Pure Swift " deinitializers <nl> + / / We can then make use of alias information for instr ' s operands <nl> + / / If they don ' t alias - we might get away with not recording a conflict <nl> + for ( auto mayWrite : MayWrites ) { <nl> + / / we actually compute all MayWrites in analyzeCurrentLoop <nl> + if ( ! mayWrite - > mayRelease ( ) ) { <nl> + continue ; <nl> } <nl> + if ( ! isCoveredByScope ( BI , DT , mayWrite ) ) <nl> + return false ; <nl> } <nl> <nl> return true ; <nl> void LoopTreeOptimization : : analyzeCurrentLoop ( <nl> LLVM_DEBUG ( llvm : : dbgs ( ) < < " Some end accesses can ' t be handled \ n " ) ; <nl> continue ; <nl> } <nl> - if ( analyzeBeginAccess ( BI , BeginAccesses , fullApplies , ASA , DomTree ) ) { <nl> + if ( analyzeBeginAccess ( BI , BeginAccesses , fullApplies , MayWrites , ASA , <nl> + DomTree ) ) { <nl> SpecialHoist . insert ( BI ) ; <nl> } <nl> } <nl> mmm a / lib / SILOptimizer / Transforms / AccessEnforcementOpts . cpp <nl> ppp b / lib / SILOptimizer / Transforms / AccessEnforcementOpts . cpp <nl> namespace { <nl> / / / Reachability results are stored here because very few accesses are <nl> / / / typically in - progress at a particular program point , <nl> / / / particularly at block boundaries . <nl> - using DenseAccessMap = llvm : : SmallMapVector < unsigned , BeginAccessInst * , 4 > ; <nl> + using DenseAccessVec = llvm : : SmallSetVector < BeginAccessInst * , 4 > ; <nl> <nl> / / Tracks the local data flow result for a basic block <nl> struct RegionInfo { <nl> struct AccessSummary { <nl> / / The actual begin_access instructions <nl> - DenseAccessMap conflictFreeAccesses ; <nl> + DenseAccessVec conflictFreeAccesses ; <nl> / / Flag to Indicate if we started a merging process <nl> bool merged ; <nl> AccessSummary ( unsigned size ) : merged ( false ) { } <nl> struct RegionInfo { <nl> unidentifiedAccess = false ; <nl> } <nl> <nl> - const DenseAccessMap & getInScopeAccesses ( ) { <nl> + const DenseAccessVec & getInScopeAccesses ( ) { <nl> return inScopeConflictFreeAccesses . conflictFreeAccesses ; <nl> } <nl> <nl> - const DenseAccessMap & getOutOfScopeAccesses ( ) { <nl> + const DenseAccessVec & getOutOfScopeAccesses ( ) { <nl> return outOfScopeConflictFreeAccesses . conflictFreeAccesses ; <nl> } <nl> } ; <nl> class AccessConflictAndMergeAnalysis { <nl> <nl> void visitFullApply ( FullApplySite fullApply , RegionInfo & info ) ; <nl> <nl> + void visitMayRelease ( SILInstruction * instr , RegionInfo & info ) ; <nl> + <nl> void mergePredAccesses ( LoopRegion * region , <nl> RegionIDToLocalInfoMap & localRegionInfos ) ; <nl> <nl> class AccessConflictAndMergeAnalysis { <nl> void merge ( RegionInfo & info , const RegionInfo & RHS ) ; <nl> void removeConflictFromStruct ( RegionInfo & info , <nl> RegionInfo : : AccessSummary & accessStruct , <nl> - const AccessedStorage & storage ) ; <nl> + const AccessedStorage & storage , bool isInScope ) ; <nl> void visitSetForConflicts ( <nl> - const DenseAccessMap & accessSet , RegionInfo & info , <nl> + const DenseAccessVec & accessSet , RegionInfo & info , <nl> AccessConflictAndMergeAnalysis : : AccessedStorageSet & loopStorage ) ; <nl> void <nl> detectApplyConflicts ( const swift : : FunctionAccessedStorage & callSiteAccesses , <nl> - const DenseAccessMap & conflictFreeSet , <nl> + const DenseAccessVec & conflictFreeSet , <nl> const swift : : FullApplySite & fullApply , RegionInfo & info ) ; <nl> + <nl> + void detectMayReleaseConflicts ( const DenseAccessVec & conflictFreeSet , <nl> + SILInstruction * instr , RegionInfo & info ) ; <nl> } ; <nl> } / / namespace <nl> <nl> void AccessConflictAndMergeAnalysis : : addInScopeAccess ( <nl> RegionInfo & info , BeginAccessInst * beginAccess ) { <nl> - auto & ai = result . getAccessInfo ( beginAccess ) ; <nl> - auto index = ai . getAccessIndex ( ) ; <nl> - assert ( info . getInScopeAccesses ( ) . find ( index ) = = <nl> - info . inScopeConflictFreeAccesses . conflictFreeAccesses . end ( ) & & <nl> - " the begin_access should not have been in Set . " ) ; <nl> - info . inScopeConflictFreeAccesses . conflictFreeAccesses . insert ( <nl> - std : : make_pair ( index , beginAccess ) ) ; <nl> + assert ( <nl> + std : : find ( info . inScopeConflictFreeAccesses . conflictFreeAccesses . begin ( ) , <nl> + info . inScopeConflictFreeAccesses . conflictFreeAccesses . end ( ) , <nl> + beginAccess ) = = <nl> + info . inScopeConflictFreeAccesses . conflictFreeAccesses . end ( ) & & <nl> + " the begin_access should not have been in Vec . " ) ; <nl> + info . inScopeConflictFreeAccesses . conflictFreeAccesses . insert ( beginAccess ) ; <nl> } <nl> <nl> void AccessConflictAndMergeAnalysis : : removeInScopeAccess ( <nl> RegionInfo & info , BeginAccessInst * beginAccess ) { <nl> - auto & ai = result . getAccessInfo ( beginAccess ) ; <nl> - auto index = ai . getAccessIndex ( ) ; <nl> - auto it = info . inScopeConflictFreeAccesses . conflictFreeAccesses . find ( index ) ; <nl> + auto it = std : : find ( <nl> + info . inScopeConflictFreeAccesses . conflictFreeAccesses . begin ( ) , <nl> + info . inScopeConflictFreeAccesses . conflictFreeAccesses . end ( ) , beginAccess ) ; <nl> assert ( it ! = info . inScopeConflictFreeAccesses . conflictFreeAccesses . end ( ) & & <nl> - " the begin_access should have been in Set . " ) ; <nl> + " the begin_access should have been in Vec . " ) ; <nl> info . inScopeConflictFreeAccesses . conflictFreeAccesses . erase ( it ) ; <nl> } <nl> <nl> void AccessConflictAndMergeAnalysis : : removeConflictFromStruct ( <nl> RegionInfo & info , RegionInfo : : AccessSummary & accessStruct , <nl> - const AccessedStorage & storage ) { <nl> - auto pred = [ & ] ( const std : : pair < unsigned , BeginAccessInst * > & pair ) { <nl> - auto & currStorage = result . getAccessInfo ( pair . second ) ; <nl> + const AccessedStorage & storage , bool isInScope ) { <nl> + auto pred = [ & ] ( BeginAccessInst * it ) { <nl> + auto & currStorage = result . getAccessInfo ( it ) ; <nl> return ! currStorage . isDistinctFrom ( storage ) ; <nl> } ; <nl> auto it = std : : find_if ( accessStruct . conflictFreeAccesses . begin ( ) , <nl> accessStruct . conflictFreeAccesses . end ( ) , pred ) ; <nl> while ( it ! = accessStruct . conflictFreeAccesses . end ( ) ) { <nl> + if ( isInScope ) { <nl> + auto & ai = result . getAccessInfo ( * it ) ; <nl> + ai . setSeenNestedConflict ( ) ; <nl> + } <nl> accessStruct . conflictFreeAccesses . erase ( it ) ; <nl> it = std : : find_if ( accessStruct . conflictFreeAccesses . begin ( ) , <nl> accessStruct . conflictFreeAccesses . end ( ) , pred ) ; <nl> void AccessConflictAndMergeAnalysis : : removeConflictFromStruct ( <nl> <nl> void AccessConflictAndMergeAnalysis : : recordConflict ( <nl> RegionInfo & info , const AccessedStorage & storage ) { <nl> - removeConflictFromStruct ( info , info . outOfScopeConflictFreeAccesses , storage ) ; <nl> - DenseAccessMap tmpSet ( info . inScopeConflictFreeAccesses . conflictFreeAccesses ) ; <nl> - removeConflictFromStruct ( info , info . inScopeConflictFreeAccesses , storage ) ; <nl> - for ( auto it : tmpSet ) { <nl> - if ( std : : find ( info . inScopeConflictFreeAccesses . conflictFreeAccesses . begin ( ) , <nl> - info . inScopeConflictFreeAccesses . conflictFreeAccesses . end ( ) , <nl> - it ) = = <nl> - info . inScopeConflictFreeAccesses . conflictFreeAccesses . end ( ) ) { <nl> - auto & ai = result . getAccessInfo ( it . second ) ; <nl> - ai . setSeenNestedConflict ( ) ; <nl> - } <nl> - } <nl> + removeConflictFromStruct ( info , info . outOfScopeConflictFreeAccesses , storage , <nl> + false / * isInScope * / ) ; <nl> + removeConflictFromStruct ( info , info . inScopeConflictFreeAccesses , storage , <nl> + true / * isInScope * / ) ; <nl> } <nl> <nl> void AccessConflictAndMergeAnalysis : : addOutOfScopeAccess ( <nl> RegionInfo & info , BeginAccessInst * beginAccess ) { <nl> auto newStorageInfo = result . getAccessInfo ( beginAccess ) ; <nl> - auto newIndex = newStorageInfo . getAccessIndex ( ) ; <nl> - auto pred = [ & ] ( const std : : pair < unsigned , BeginAccessInst * > & pair ) { <nl> - auto currStorageInfo = result . getAccessInfo ( pair . second ) ; <nl> + auto pred = [ & ] ( BeginAccessInst * it ) { <nl> + auto currStorageInfo = result . getAccessInfo ( it ) ; <nl> return currStorageInfo . hasIdenticalBase ( newStorageInfo ) ; <nl> } ; <nl> <nl> void AccessConflictAndMergeAnalysis : : addOutOfScopeAccess ( <nl> / / We don ' t have a match in outOfScopeConflictFreeAccesses <nl> / / Just add it and return <nl> info . outOfScopeConflictFreeAccesses . conflictFreeAccesses . insert ( <nl> - std : : make_pair ( newIndex , beginAccess ) ) ; <nl> + beginAccess ) ; <nl> return ; <nl> } <nl> <nl> - auto * otherBegin = it - > second ; <nl> - auto index = it - > first ; <nl> - info . outOfScopeConflictFreeAccesses . conflictFreeAccesses . erase ( index ) ; <nl> + auto * otherBegin = * it ; <nl> + auto rmIt = std : : find ( <nl> + info . outOfScopeConflictFreeAccesses . conflictFreeAccesses . begin ( ) , <nl> + info . outOfScopeConflictFreeAccesses . conflictFreeAccesses . end ( ) , <nl> + otherBegin ) ; <nl> + info . outOfScopeConflictFreeAccesses . conflictFreeAccesses . erase ( rmIt ) ; <nl> <nl> - auto predDistinct = [ & ] ( const std : : pair < unsigned , BeginAccessInst * > & pair ) { <nl> - auto currStorageInfo = result . getAccessInfo ( pair . second ) ; <nl> + auto predDistinct = [ & ] ( BeginAccessInst * it ) { <nl> + auto currStorageInfo = result . getAccessInfo ( it ) ; <nl> return ! currStorageInfo . isDistinctFrom ( newStorageInfo ) ; <nl> } ; <nl> <nl> void AccessConflictAndMergeAnalysis : : addOutOfScopeAccess ( <nl> } <nl> } <nl> <nl> - info . outOfScopeConflictFreeAccesses . conflictFreeAccesses . insert ( <nl> - std : : make_pair ( newIndex , beginAccess ) ) ; <nl> - } <nl> - <nl> - static void copyMap ( DenseAccessMap & to , const DenseAccessMap & from ) { <nl> - for ( auto it : from ) { <nl> - to . insert ( it ) ; <nl> - } <nl> + info . outOfScopeConflictFreeAccesses . conflictFreeAccesses . insert ( beginAccess ) ; <nl> } <nl> <nl> void AccessConflictAndMergeAnalysis : : mergeAccessStruct ( <nl> RegionInfo & info , RegionInfo : : AccessSummary & accessStruct , <nl> const RegionInfo : : AccessSummary & RHSAccessStruct ) { <nl> if ( ! accessStruct . merged ) { <nl> - copyMap ( accessStruct . conflictFreeAccesses , <nl> - RHSAccessStruct . conflictFreeAccesses ) ; <nl> + accessStruct . conflictFreeAccesses . insert ( <nl> + RHSAccessStruct . conflictFreeAccesses . begin ( ) , <nl> + RHSAccessStruct . conflictFreeAccesses . end ( ) ) ; <nl> accessStruct . merged = true ; <nl> return ; <nl> } <nl> <nl> - DenseAccessMap tmpMap ; <nl> - copyMap ( tmpMap , accessStruct . conflictFreeAccesses ) ; <nl> - <nl> - for ( auto pair : tmpMap ) { <nl> - auto index = pair . first ; <nl> - if ( RHSAccessStruct . conflictFreeAccesses . find ( index ) ! = <nl> - RHSAccessStruct . conflictFreeAccesses . end ( ) ) <nl> - continue ; <nl> - / / Not in RHS - remove from intersect <nl> - accessStruct . conflictFreeAccesses . erase ( index ) ; <nl> - } <nl> + auto pred = [ & ] ( BeginAccessInst * it ) { <nl> + auto rhsIt = std : : find ( RHSAccessStruct . conflictFreeAccesses . begin ( ) , <nl> + RHSAccessStruct . conflictFreeAccesses . end ( ) , it ) ; <nl> + return rhsIt = = RHSAccessStruct . conflictFreeAccesses . end ( ) ; <nl> + } ; <nl> + accessStruct . conflictFreeAccesses . remove_if ( pred ) ; <nl> } <nl> <nl> void AccessConflictAndMergeAnalysis : : merge ( RegionInfo & info , <nl> void AccessConflictAndMergeAnalysis : : visitBeginAccess ( <nl> } <nl> SILAccessKind beginAccessKind = beginAccess - > getAccessKind ( ) ; <nl> / / check the current in - scope accesses for conflicts : <nl> - bool changed = false ; <nl> - do { <nl> - changed = false ; <nl> - for ( auto pair : info . getInScopeAccesses ( ) ) { <nl> - auto * outerBeginAccess = pair . second ; <nl> - / / If both are reads , keep the mapped access . <nl> - if ( ! accessKindMayConflict ( beginAccessKind , <nl> - outerBeginAccess - > getAccessKind ( ) ) ) { <nl> - continue ; <nl> - } <nl> + for ( auto * outerBeginAccess : info . getInScopeAccesses ( ) ) { <nl> + / / If both are reads , keep the mapped access . <nl> + if ( ! accessKindMayConflict ( beginAccessKind , <nl> + outerBeginAccess - > getAccessKind ( ) ) ) { <nl> + continue ; <nl> + } <nl> <nl> - auto & outerAccessInfo = result . getAccessInfo ( outerBeginAccess ) ; <nl> - / / If there is no potential conflict , leave the outer access mapped . <nl> - if ( ! outerAccessInfo . isDistinctFrom ( beginAccessInfo ) ) <nl> - continue ; <nl> + auto & outerAccessInfo = result . getAccessInfo ( outerBeginAccess ) ; <nl> + / / If there is no potential conflict , leave the outer access mapped . <nl> + if ( ! outerAccessInfo . isDistinctFrom ( beginAccessInfo ) ) <nl> + continue ; <nl> <nl> - LLVM_DEBUG ( beginAccessInfo . dump ( ) ; <nl> - llvm : : dbgs ( ) < < " may conflict with : \ n " ; <nl> - outerAccessInfo . dump ( ) ) ; <nl> + LLVM_DEBUG ( beginAccessInfo . dump ( ) ; llvm : : dbgs ( ) < < " may conflict with : \ n " ; <nl> + outerAccessInfo . dump ( ) ) ; <nl> <nl> - recordConflict ( info , outerAccessInfo ) ; <nl> - changed = true ; <nl> - break ; <nl> - } <nl> - } while ( changed ) ; <nl> + recordConflict ( info , outerAccessInfo ) ; <nl> + } <nl> <nl> / / Record the current access to InScopeAccesses . <nl> / / It can potentially be folded <nl> void AccessConflictAndMergeAnalysis : : visitEndAccess ( EndAccessInst * endAccess , <nl> auto * beginAccess = endAccess - > getBeginAccess ( ) ; <nl> if ( beginAccess - > getEnforcement ( ) ! = SILAccessEnforcement : : Dynamic ) <nl> return ; <nl> - auto & ai = result . getAccessInfo ( beginAccess ) ; <nl> auto & inScope = info . getInScopeAccesses ( ) ; <nl> - if ( inScope . find ( ai . getAccessIndex ( ) ) ! = inScope . end ( ) ) { <nl> + auto it = std : : find ( inScope . begin ( ) , inScope . end ( ) , beginAccess ) ; <nl> + if ( it ! = inScope . end ( ) ) { <nl> LLVM_DEBUG ( llvm : : dbgs ( ) < < " No conflict on one path from " < < * beginAccess <nl> < < " to " < < * endAccess ) ; <nl> removeInScopeAccess ( info , beginAccess ) ; <nl> void AccessConflictAndMergeAnalysis : : visitEndAccess ( EndAccessInst * endAccess , <nl> <nl> void AccessConflictAndMergeAnalysis : : detectApplyConflicts ( <nl> const swift : : FunctionAccessedStorage & callSiteAccesses , <nl> - const DenseAccessMap & conflictFreeSet , <nl> + const DenseAccessVec & conflictFreeSet , <nl> const swift : : FullApplySite & fullApply , RegionInfo & info ) { <nl> - bool changed = false ; <nl> - do { <nl> - changed = false ; <nl> - for ( auto pair : conflictFreeSet ) { <nl> - auto * outerBeginAccess = pair . second ; <nl> - / / If there is no potential conflict , leave the outer access mapped . <nl> - SILAccessKind accessKind = outerBeginAccess - > getAccessKind ( ) ; <nl> - AccessInfo & outerAccessInfo = result . getAccessInfo ( outerBeginAccess ) ; <nl> - if ( ! callSiteAccesses . mayConflictWith ( accessKind , outerAccessInfo ) ) <nl> - continue ; <nl> + for ( auto * outerBeginAccess : conflictFreeSet ) { <nl> + / / If there is no potential conflict , leave the outer access mapped . <nl> + SILAccessKind accessKind = outerBeginAccess - > getAccessKind ( ) ; <nl> + AccessInfo & outerAccessInfo = result . getAccessInfo ( outerBeginAccess ) ; <nl> + if ( ! callSiteAccesses . mayConflictWith ( accessKind , outerAccessInfo ) ) <nl> + continue ; <nl> <nl> - LLVM_DEBUG ( <nl> - llvm : : dbgs ( ) < < * fullApply . getInstruction ( ) < < " call site access : " ; <nl> - callSiteAccesses . dump ( ) ; llvm : : dbgs ( ) < < " may conflict with : \ n " ; <nl> - outerAccessInfo . dump ( ) ) ; <nl> + LLVM_DEBUG ( <nl> + llvm : : dbgs ( ) < < * fullApply . getInstruction ( ) < < " call site access : " ; <nl> + callSiteAccesses . dump ( ) ; llvm : : dbgs ( ) < < " may conflict with : \ n " ; <nl> + outerAccessInfo . dump ( ) ) ; <nl> <nl> - recordConflict ( info , outerAccessInfo ) ; <nl> - changed = true ; <nl> - break ; <nl> - } <nl> - } while ( changed ) ; <nl> + recordConflict ( info , outerAccessInfo ) ; <nl> + } <nl> } <nl> <nl> void AccessConflictAndMergeAnalysis : : visitFullApply ( FullApplySite fullApply , <nl> void AccessConflictAndMergeAnalysis : : visitFullApply ( FullApplySite fullApply , <nl> fullApply , info ) ; <nl> } <nl> <nl> + void AccessConflictAndMergeAnalysis : : detectMayReleaseConflicts ( <nl> + const DenseAccessVec & conflictFreeSet , SILInstruction * instr , <nl> + RegionInfo & info ) { <nl> + / / TODO Introduce " Pure Swift " deinitializers <nl> + / / We can then make use of alias information for instr ' s operands <nl> + / / If they don ' t alias - we might get away with not recording a conflict <nl> + for ( auto * outerBeginAccess : conflictFreeSet ) { <nl> + / / Only class and global access that may alias would conflict <nl> + AccessInfo & outerAccessInfo = result . getAccessInfo ( outerBeginAccess ) ; <nl> + const AccessedStorage : : Kind outerKind = outerAccessInfo . getKind ( ) ; <nl> + if ( outerKind ! = AccessedStorage : : Class & & <nl> + outerKind ! = AccessedStorage : : Global ) { <nl> + continue ; <nl> + } <nl> + / / We can ' t prove what the deinitializer might do <nl> + / / TODO Introduce " Pure Swift " deinitializers <nl> + LLVM_DEBUG ( llvm : : dbgs ( ) < < " MayRelease Instruction : " < < * instr <nl> + < < " may conflict with : \ n " ; <nl> + outerAccessInfo . dump ( ) ) ; <nl> + recordConflict ( info , outerAccessInfo ) ; <nl> + } <nl> + } <nl> + <nl> + void AccessConflictAndMergeAnalysis : : visitMayRelease ( SILInstruction * instr , <nl> + RegionInfo & info ) { <nl> + detectMayReleaseConflicts ( info . getInScopeAccesses ( ) , instr , info ) ; <nl> + detectMayReleaseConflicts ( info . getOutOfScopeAccesses ( ) , instr , info ) ; <nl> + } <nl> + <nl> void AccessConflictAndMergeAnalysis : : mergePredAccesses ( <nl> LoopRegion * region , RegionIDToLocalInfoMap & localRegionInfos ) { <nl> RegionInfo & info = localRegionInfos . find ( region - > getID ( ) ) - > getSecond ( ) ; <nl> void AccessConflictAndMergeAnalysis : : mergePredAccesses ( <nl> } <nl> <nl> void AccessConflictAndMergeAnalysis : : visitSetForConflicts ( <nl> - const DenseAccessMap & accessSet , RegionInfo & info , <nl> + const DenseAccessVec & accessSet , RegionInfo & info , <nl> AccessConflictAndMergeAnalysis : : AccessedStorageSet & loopStorage ) { <nl> bool changed = false ; <nl> do { <nl> changed = false ; <nl> - for ( auto pair : accessSet ) { <nl> - BeginAccessInst * beginAccess = pair . second ; <nl> + for ( BeginAccessInst * beginAccess : accessSet ) { <nl> AccessInfo & accessInfo = result . getAccessInfo ( beginAccess ) ; <nl> <nl> for ( auto loopAccess : loopStorage ) { <nl> void AccessConflictAndMergeAnalysis : : localDataFlowInBlock ( <nl> } <nl> if ( auto fullApply = FullApplySite : : isa ( & instr ) ) { <nl> visitFullApply ( fullApply , info ) ; <nl> + continue ; <nl> + } <nl> + if ( instr . mayRelease ( ) ) { <nl> + visitMayRelease ( & instr , info ) ; <nl> } <nl> } <nl> } <nl> mmm a / test / SILOptimizer / access_enforcement_opts . sil <nl> ppp b / test / SILOptimizer / access_enforcement_opts . sil <nl> bb0 : <nl> return % 10 : $ ( ) <nl> } <nl> <nl> + <nl> + / / public func testOldToNewMapReadMayRelease ( ) { <nl> + / / Checks merging 2 out of 3 scopes resulting in a larger read scope <nl> + / / Due to a MayRelease instruction before the 3rd scope <nl> + / / <nl> + / / CHECK - LABEL : sil @ testOldToNewMapReadMayRelease : $ @ convention ( thin ) ( ) - > ( ) { <nl> + / / CHECK : [ [ GLOBAL : % . * ] ] = global_addr @ globalX : $ * X <nl> + / / CHECK - NEXT : [ [ BEGIN : % . * ] ] = begin_access [ read ] [ dynamic ] [ [ GLOBAL ] ] : $ * X <nl> + / / CHECK - NEXT : load [ [ BEGIN ] ] : $ * X <nl> + / / CHECK - NEXT : load [ [ BEGIN ] ] : $ * X <nl> + / / CHECK - NEXT : end_access [ [ BEGIN ] ] : $ * X <nl> + / / CHECK - NEXT : strong_release <nl> + / / CHECK - NEXT : [ [ BEGIN : % . * ] ] = begin_access [ read ] [ dynamic ] [ no_nested_conflict ] [ [ GLOBAL ] ] : $ * X <nl> + / / CHECK - LABEL : } / / end sil function ' testOldToNewMapReadMayRelease ' <nl> + sil @ testOldToNewMapReadMayRelease : $ @ convention ( thin ) ( ) - > ( ) { <nl> + bb0 : <nl> + % alloc = alloc_box $ { var Int32 } , var , name " y " <nl> + % 0 = global_addr @ globalX : $ * X <nl> + % 1 = begin_access [ read ] [ dynamic ] % 0 : $ * X <nl> + % 2 = load % 1 : $ * X <nl> + end_access % 1 : $ * X <nl> + % 4 = begin_access [ read ] [ dynamic ] % 0 : $ * X <nl> + % 5 = load % 4 : $ * X <nl> + end_access % 4 : $ * X <nl> + strong_release % alloc : $ { var Int32 } <nl> + % 7 = begin_access [ read ] [ dynamic ] % 0 : $ * X <nl> + % 8 = load % 7 : $ * X <nl> + end_access % 7 : $ * X <nl> + % 10 = tuple ( ) <nl> + return % 10 : $ ( ) <nl> + } <nl> + <nl> / / public func testOldToNewMapWrite ) { <nl> / / Checks merging of 3 scopes resulting in a larger modify scope <nl> / / <nl> mmm a / test / SILOptimizer / licm_exclusivity . sil <nl> ppp b / test / SILOptimizer / licm_exclusivity . sil <nl> sil hidden_external [ global_init ] @ globalAddressor : $ @ convention ( thin ) ( ) - > Bu <nl> / / <nl> / / CHECK - LABEL : sil @ hoist_access_with_conflict : $ @ convention ( thin ) ( ) - > ( ) { <nl> / / CHECK : [ [ GLOBAL : % . * ] ] = global_addr @ globalX : $ * X <nl> - / / CHECK : [ [ BEGIN : % . * ] ] = begin_access [ read ] [ dynamic ] % 0 : $ * X <nl> + / / CHECK : [ [ BEGIN : % . * ] ] = begin_access [ read ] [ dynamic ] [ [ GLOBAL ] ] : $ * X <nl> / / CHECK - NEXT : br bb1 <nl> / / CHECK : apply <nl> / / CHECK : load <nl> bb2 : <nl> / / CHECK : [ [ GLOBAL : % . * ] ] = global_addr @ globalX : $ * X <nl> / / CHECK : br bb1 <nl> / / CHECK : apply <nl> - / / CHECK - NEXT : [ [ BEGIN : % . * ] ] = begin_access [ read ] [ dynamic ] % 0 : $ * X <nl> + / / CHECK - NEXT : [ [ BEGIN : % . * ] ] = begin_access [ read ] [ dynamic ] [ [ GLOBAL ] ] : $ * X <nl> / / CHECK - NEXT : load <nl> / / CHECK - NEXT : end_access [ [ BEGIN ] ] <nl> / / CHECK - LABEL : } / / end sil function ' dont_hoist_access_with_conflict ' <nl> bb2 : <nl> % 10 = tuple ( ) <nl> return % 10 : $ ( ) <nl> } <nl> + <nl> + / / public func hoist_access_with_may_release ( ) { <nl> + / / Tests Hoisting of begin / end access when there ' s a " sandwiched " MayRelease instruction <nl> + / / <nl> + / / CHECK - LABEL : sil @ hoist_access_with_may_release : $ @ convention ( thin ) ( ) - > ( ) { <nl> + / / CHECK : [ [ GLOBAL : % . * ] ] = global_addr @ globalX : $ * X <nl> + / / CHECK : [ [ BEGIN : % . * ] ] = begin_access [ read ] [ dynamic ] [ [ GLOBAL ] ] : $ * X <nl> + / / CHECK - NEXT : br bb1 <nl> + / / CHECK : apply <nl> + / / CHECK : load <nl> + / / CHECK : cond_br <nl> + / / CHECK : bb2 <nl> + / / CHECK : end_access [ [ BEGIN ] ] <nl> + / / CHECK - LABEL : } / / end sil function ' hoist_access_with_may_release ' <nl> + sil @ hoist_access_with_may_release : $ @ convention ( thin ) ( ) - > ( ) { <nl> + bb0 : <nl> + % alloc = alloc_box $ { var Int32 } , var , name " y " <nl> + % 0 = global_addr @ globalX : $ * X <nl> + % u0 = function_ref @ globalAddressor : $ @ convention ( thin ) ( ) - > Builtin . RawPointer <nl> + br bb1 <nl> + <nl> + bb1 : <nl> + % u3 = begin_access [ read ] [ dynamic ] % 0 : $ * X <nl> + % u1 = apply % u0 ( ) : $ @ convention ( thin ) ( ) - > Builtin . RawPointer <nl> + % u4 = load % u3 : $ * X <nl> + strong_release % alloc : $ { var Int32 } <nl> + end_access % u3 : $ * X <nl> + cond_br undef , bb1 , bb2 <nl> + <nl> + bb2 : <nl> + % 10 = tuple ( ) <nl> + return % 10 : $ ( ) <nl> + } <nl> + <nl> + / / public func dont_hoist_access_with_may_release ( ) { <nl> + / / Tests * not * hoisting begin / end access when there ' s a MayRelease not protected by them <nl> + / / <nl> + / / CHECK - LABEL : sil @ dont_hoist_access_with_may_release : $ @ convention ( thin ) ( ) - > ( ) { <nl> + / / CHECK : [ [ GLOBAL : % . * ] ] = global_addr @ globalX : $ * X <nl> + / / CHECK : br bb1 <nl> + / / CHECK : [ [ BEGIN : % . * ] ] = begin_access [ read ] [ dynamic ] [ [ GLOBAL ] ] : $ * X <nl> + / / CHECK - NEXT : apply <nl> + / / CHECK - NEXT : load <nl> + / / CHECK - NEXT : end_access [ [ BEGIN ] ] <nl> + / / CHECK - LABEL : } / / end sil function ' dont_hoist_access_with_may_release ' <nl> + sil @ dont_hoist_access_with_may_release : $ @ convention ( thin ) ( ) - > ( ) { <nl> + bb0 : <nl> + % alloc = alloc_box $ { var Int32 } , var , name " y " <nl> + % 0 = global_addr @ globalX : $ * X <nl> + % u0 = function_ref @ globalAddressor : $ @ convention ( thin ) ( ) - > Builtin . RawPointer <nl> + br bb1 <nl> + <nl> + bb1 : <nl> + % u3 = begin_access [ read ] [ dynamic ] % 0 : $ * X <nl> + % u1 = apply % u0 ( ) : $ @ convention ( thin ) ( ) - > Builtin . RawPointer <nl> + % u4 = load % u3 : $ * X <nl> + end_access % u3 : $ * X <nl> + strong_release % alloc : $ { var Int32 } <nl> + cond_br undef , bb1 , bb2 <nl> + <nl> + bb2 : <nl> + % 10 = tuple ( ) <nl> + return % 10 : $ ( ) <nl> + } <nl> | Merge remote - tracking branch ' origin / master ' into master - next | apple/swift | cf4983fbe989c3ecb3a9f2d3f353457357fd8fec | 2018-09-05T00:49:18Z |
mmm a / CHANGELOG . txt <nl> ppp b / CHANGELOG . txt <nl> Other Changes : <nl> - ImFontConfig : Added GlyphMinAdvanceX / GlyphMaxAdvanceX settings useful to make a font appears monospaced , particularly useful for icon fonts . ( # 1869 ) <nl> - ImFontAtlas : Added GetGlyphRangesChineseSimplifiedCommon ( ) helper that returns a list of ~ 2500 most common Simplified Chinese characters . ( # 1859 ) [ @ JX - Master , @ ocornut ] <nl> - Examples : GLFW : Made it possible to Shutdown / Init the backend again ( by reseting the time storage properly ) . ( # 1827 ) [ @ ice1000 ] <nl> + - Examples : Win32 : Fixed handling of mouse wheel messages to support finer position messages ( typically sent by track - pads ) . ( # 1874 ) [ zx64 ] <nl> - Examples : Allegro5 : Added support for ImGuiConfigFlags_NoMouseCursorChange flag . <nl> - Misc : Updated stb_textedit from 1 . 09 + patches to 1 . 12 + minor patches . <nl> - Internals : PushItemFlag ( ) flags are inherited by BeginChild ( ) . <nl> mmm a / examples / imgui_impl_win32 . cpp <nl> ppp b / examples / imgui_impl_win32 . cpp <nl> <nl> <nl> / / CHANGELOG <nl> / / ( minor and older changes stripped away , please see git history for details ) <nl> + / / 2018 - 06 - 10 : Inputs : Fixed handling of mouse wheel messages to support fine position messages ( typically sent by track - pads ) . <nl> / / 2018 - 06 - 08 : Misc : Extracted imgui_impl_win32 . cpp / . h away from the old combined DX9 / DX10 / DX11 / DX12 examples . <nl> / / 2018 - 03 - 20 : Misc : Setup io . BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoMouseCursorChange flag . <nl> / / 2018 - 02 - 20 : Inputs : Added support for mouse cursors ( ImGui : : GetMouseCursor ( ) value and WM_SETCURSOR message handling ) . <nl> IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler ( HWND hwnd , UINT msg , WPARAM wPa <nl> return 0 ; <nl> } <nl> case WM_MOUSEWHEEL : <nl> - io . MouseWheel + = GET_WHEEL_DELTA_WPARAM ( wParam ) > 0 ? + 1 . 0f : - 1 . 0f ; <nl> + io . MouseWheel + = ( float ) GET_WHEEL_DELTA_WPARAM ( wParam ) / ( float ) WHEEL_DELTA ; <nl> return 0 ; <nl> case WM_MOUSEHWHEEL : <nl> - io . MouseWheelH + = GET_WHEEL_DELTA_WPARAM ( wParam ) > 0 ? + 1 . 0f : - 1 . 0f ; <nl> + io . MouseWheelH + = ( float ) GET_WHEEL_DELTA_WPARAM ( wParam ) / ( float ) WHEEL_DELTA ; <nl> return 0 ; <nl> case WM_KEYDOWN : <nl> case WM_SYSKEYDOWN : <nl> | Examples : Win32 : Fixed handling of mouse wheel messages to support finer position messages ( typically sent by track - pads ) . ( ) | ocornut/imgui | bdb3d72d3719a6c23e179ddff7fa975afa381aea | 2018-06-11T15:36:18Z |
deleted file mode 100644 <nl> index 4bf022c6 . . 00000000 <nl> mmm a / src / logger . cpp <nl> ppp / dev / null <nl> <nl> - # include " stdafx . h " <nl> - # include < algorithm > <nl> - <nl> - # include " c11log / logger . h " <nl> - <nl> - void c11log : : logger : : set_name ( const std : : string & name ) <nl> - { <nl> - std : : lock_guard < std : : mutex > lock ( _mutex ) ; <nl> - _logger_name = name ; <nl> - } <nl> - <nl> - const std : : string & c11log : : logger : : get_name ( ) <nl> - { <nl> - std : : lock_guard < std : : mutex > lock ( _mutex ) ; <nl> - return _logger_name ; <nl> - } <nl> - <nl> - void c11log : : logger : : add_sink ( sink_ptr_t sink_ptr ) <nl> - { <nl> - std : : lock_guard < std : : mutex > lock ( _mutex ) ; <nl> - _sinks . push_back ( sink_ptr ) ; <nl> - } <nl> - <nl> - void c11log : : logger : : remove_sink ( sink_ptr_t sink_ptr ) <nl> - { <nl> - std : : lock_guard < std : : mutex > lock ( _mutex ) ; <nl> - _sinks . erase ( std : : remove ( _sinks . begin ( ) , _sinks . end ( ) , sink_ptr ) , _sinks . end ( ) ) ; <nl> - } <nl> - <nl> - void c11log : : logger : : set_formatter ( std : : unique_ptr < formatters : : formatter > formatter ) <nl> - { <nl> - std : : lock_guard < std : : mutex > lock ( _mutex ) ; <nl> - _formatter = std : : move ( formatter ) ; <nl> - } <nl> - <nl> - void c11log : : logger : : set_level ( c11log : : level : : level_enum level ) <nl> - { <nl> - std : : lock_guard < std : : mutex > lock ( _mutex ) ; <nl> - _level = level ; <nl> - } <nl> - <nl> - bool c11log : : logger : : should_log ( c11log : : level : : level_enum level ) <nl> - { <nl> - std : : lock_guard < std : : mutex > lock ( _mutex ) ; <nl> - return level > = _level ; <nl> - } <nl> - <nl> - c11log : : logger & c11log : : get_logger ( const std : : string & name ) <nl> - { <nl> - return * ( c11log : : details : : factory : : instance ( ) . get_logger ( name ) ) ; <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 7cce5dbb . . 00000000 <nl> mmm a / stdafx . cpp <nl> ppp / dev / null <nl> <nl> - / / stdafx . cpp : source file that includes just the standard includes <nl> - / / c11log . pch will be the pre - compiled header <nl> - / / stdafx . obj will contain the pre - compiled type information <nl> - <nl> - # include " stdafx . h " <nl> - <nl> - / / TODO : reference any additional headers you need in STDAFX . H <nl> - / / and not in this file <nl> deleted file mode 100644 <nl> index ae597376 . . 00000000 <nl> mmm a / stdafx . h <nl> ppp / dev / null <nl> <nl> - / / stdafx . h : include file for standard system include files , <nl> - / / or project specific include files that are used frequently , but <nl> - / / are changed infrequently <nl> - / / <nl> - <nl> - # pragma once <nl> - <nl> - # include " targetver . h " <nl> - <nl> - # define WIN32_LEAN_AND_MEAN / / Exclude rarely - used stuff from Windows headers <nl> - <nl> - # include < string > <nl> - # include < chrono > <nl> - # include < ctime > <nl> - # include < memory > <nl> - # include < iostream > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 90e767bf . . 00000000 <nl> mmm a / targetver . h <nl> ppp / dev / null <nl> <nl> - # pragma once <nl> - <nl> - / / Including SDKDDKVer . h defines the highest available Windows platform . <nl> - <nl> - / / If you wish to build your application for a previous Windows platform , include WinSDKVer . h and <nl> - / / set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer . h . <nl> - <nl> - # include < SDKDDKVer . h > <nl> | makefile fixes | gabime/spdlog | fa6f8b3c9a62bfd4486bbfc14eec770bb41efa7a | 2014-01-27T09:27:50Z |
mmm a / include / swift / SIL / SILInstruction . h <nl> ppp b / include / swift / SIL / SILInstruction . h <nl> <nl> # include " swift / Strings . h " <nl> # include " llvm / ADT / APFloat . h " <nl> # include " llvm / ADT / APInt . h " <nl> + # include " llvm / ADT / SmallPtrSet . h " <nl> # include " llvm / ADT / ilist . h " <nl> # include " llvm / ADT / ilist_node . h " <nl> # include " llvm / Support / TrailingObjects . h " <nl> class TermInst : public NonValueInstruction { <nl> } <nl> } ; <nl> <nl> + class OwnershipForwardingTermInst : public TermInst { <nl> + ValueOwnershipKind ownershipKind ; <nl> + <nl> + protected : <nl> + OwnershipForwardingTermInst ( SILInstructionKind kind , <nl> + SILDebugLocation debugLoc , <nl> + ValueOwnershipKind ownershipKind ) <nl> + : TermInst ( kind , debugLoc ) , ownershipKind ( ownershipKind ) { } <nl> + <nl> + public : <nl> + ValueOwnershipKind getOwnershipKind ( ) const { return ownershipKind ; } <nl> + void setOwnershipKind ( ValueOwnershipKind newKind ) { ownershipKind = newKind ; } <nl> + } ; <nl> + <nl> / / / UnreachableInst - Position in the code which would be undefined to reach . <nl> / / / These are always implicitly generated , e . g . when falling off the end of a <nl> / / / function or after a no - return function call . <nl> class SwitchValueInst final <nl> } <nl> } ; <nl> <nl> - / / / Common implementation for the switch_enum and <nl> - / / / switch_enum_addr instructions . <nl> - class SwitchEnumInstBase : public TermInst { <nl> + / / / Common implementation for the switch_enum and switch_enum_addr instructions . <nl> + template < typename BaseTy > <nl> + class SwitchEnumInstBase : public BaseTy { <nl> FixedOperandList < 1 > Operands ; <nl> <nl> / / Tail - allocated after the SwitchEnumInst record are : <nl> class SwitchEnumInstBase : public TermInst { <nl> } <nl> <nl> protected : <nl> + template < typename . . . Rest > <nl> SwitchEnumInstBase ( <nl> SILInstructionKind Kind , SILDebugLocation DebugLoc , SILValue Operand , <nl> SILBasicBlock * DefaultBB , <nl> ArrayRef < std : : pair < EnumElementDecl * , SILBasicBlock * > > CaseBBs , <nl> - Optional < ArrayRef < ProfileCounter > > Counts , ProfileCounter DefaultCount ) ; <nl> + Optional < ArrayRef < ProfileCounter > > Counts , ProfileCounter DefaultCount , <nl> + Rest & & . . . rest ) <nl> + : BaseTy ( Kind , DebugLoc , std : : forward < Rest > ( rest ) . . . ) , <nl> + Operands ( this , Operand ) { <nl> + SILInstruction : : Bits . SEIBase . HasDefault = bool ( DefaultBB ) ; <nl> + SILInstruction : : Bits . SEIBase . NumCases = CaseBBs . size ( ) ; <nl> + / / Initialize the case and successor arrays . <nl> + auto * cases = getCaseBuf ( ) ; <nl> + auto * succs = getSuccessorBuf ( ) ; <nl> + for ( unsigned i = 0 , size = CaseBBs . size ( ) ; i < size ; + + i ) { <nl> + cases [ i ] = CaseBBs [ i ] . first ; <nl> + if ( Counts ) { <nl> + : : new ( succs + i ) <nl> + SILSuccessor ( this , CaseBBs [ i ] . second , Counts . getValue ( ) [ i ] ) ; <nl> + } else { <nl> + : : new ( succs + i ) SILSuccessor ( this , CaseBBs [ i ] . second ) ; <nl> + } <nl> + } <nl> + <nl> + if ( hasDefault ( ) ) { <nl> + : : new ( succs + getNumCases ( ) ) SILSuccessor ( this , DefaultBB , DefaultCount ) ; <nl> + } <nl> + } <nl> <nl> - template < typename SWITCH_ENUM_INST > <nl> + template < typename SWITCH_ENUM_INST , typename . . . RestTys > <nl> static SWITCH_ENUM_INST * createSwitchEnum ( <nl> SILDebugLocation DebugLoc , SILValue Operand , SILBasicBlock * DefaultBB , <nl> ArrayRef < std : : pair < EnumElementDecl * , SILBasicBlock * > > CaseBBs , <nl> SILFunction & F , Optional < ArrayRef < ProfileCounter > > Counts , <nl> - ProfileCounter DefaultCount ) ; <nl> + ProfileCounter DefaultCount , RestTys & & . . . restArgs ) ; <nl> <nl> public : <nl> / / / Clean up tail - allocated successor records for the switch cases . <nl> - ~ SwitchEnumInstBase ( ) ; <nl> + ~ SwitchEnumInstBase ( ) { <nl> + / / Destroy the successor records to keep the CFG up to date . <nl> + auto * succs = getSuccessorBuf ( ) ; <nl> + for ( unsigned i = 0 , end = getNumCases ( ) + hasDefault ( ) ; i < end ; + + i ) { <nl> + succs [ i ] . ~ SILSuccessor ( ) ; <nl> + } <nl> + } <nl> <nl> SILValue getOperand ( ) const { return Operands [ 0 ] . get ( ) ; } <nl> <nl> ArrayRef < Operand > getAllOperands ( ) const { return Operands . asArray ( ) ; } <nl> MutableArrayRef < Operand > getAllOperands ( ) { return Operands . asArray ( ) ; } <nl> <nl> - SuccessorListTy getSuccessors ( ) { <nl> + TermInst : : SuccessorListTy getSuccessors ( ) { <nl> return MutableArrayRef < SILSuccessor > { getSuccessorBuf ( ) , <nl> static_cast < size_t > ( getNumCases ( ) + hasDefault ( ) ) } ; <nl> } <nl> <nl> - unsigned getNumCases ( ) const { <nl> - return SILInstruction : : Bits . SwitchEnumInstBase . NumCases ; <nl> - } <nl> + unsigned getNumCases ( ) const { return SILInstruction : : Bits . SEIBase . NumCases ; } <nl> + <nl> std : : pair < EnumElementDecl * , SILBasicBlock * > <nl> getCase ( unsigned i ) const { <nl> assert ( i < getNumCases ( ) & & " case out of bounds " ) ; <nl> return { getCaseBuf ( ) [ i ] , getSuccessorBuf ( ) [ i ] . getBB ( ) } ; <nl> } <nl> + <nl> ProfileCounter getCaseCount ( unsigned i ) const { <nl> assert ( i < getNumCases ( ) & & " case out of bounds " ) ; <nl> return getSuccessorBuf ( ) [ i ] . getCount ( ) ; <nl> } <nl> <nl> / / Swap the cases at indices \ p i and \ p j . <nl> - void swapCase ( unsigned i , unsigned j ) ; <nl> + void swapCase ( unsigned i , unsigned j ) { <nl> + assert ( i < getNumCases ( ) & & " First index is out of bounds ? ! " ) ; <nl> + assert ( j < getNumCases ( ) & & " Second index is out of bounds ? ! " ) ; <nl> + <nl> + auto * succs = getSuccessorBuf ( ) ; <nl> + <nl> + / / First grab our destination blocks . <nl> + SILBasicBlock * iBlock = succs [ i ] . getBB ( ) ; <nl> + SILBasicBlock * jBlock = succs [ j ] . getBB ( ) ; <nl> + <nl> + / / Then destroy the sil successors and reinitialize them with the new things <nl> + / / that they are pointing at . <nl> + succs [ i ] . ~ SILSuccessor ( ) ; <nl> + : : new ( succs + i ) SILSuccessor ( this , jBlock ) ; <nl> + succs [ j ] . ~ SILSuccessor ( ) ; <nl> + : : new ( succs + j ) SILSuccessor ( this , iBlock ) ; <nl> + <nl> + / / Now swap our cases . <nl> + auto * cases = getCaseBuf ( ) ; <nl> + std : : swap ( cases [ i ] , cases [ j ] ) ; <nl> + } <nl> <nl> / / / Return the block that will be branched to on the specified enum <nl> / / / case . <nl> class SwitchEnumInstBase : public TermInst { <nl> } <nl> <nl> / / / If the default refers to exactly one case decl , return it . <nl> - NullablePtr < EnumElementDecl > getUniqueCaseForDefault ( ) ; <nl> + NullablePtr < EnumElementDecl > getUniqueCaseForDefault ( ) { <nl> + auto enumValue = getOperand ( ) ; <nl> + SILType enumType = enumValue - > getType ( ) ; <nl> + <nl> + auto * f = SILInstruction : : getFunction ( ) ; <nl> + if ( ! enumType . isEffectivelyExhaustiveEnumType ( f ) ) <nl> + return nullptr ; <nl> + <nl> + EnumDecl * decl = enumType . getEnumOrBoundGenericEnum ( ) ; <nl> + assert ( decl & & " switch_enum operand is not an enum " ) ; <nl> + <nl> + SmallPtrSet < EnumElementDecl * , 4 > unswitchedElts ; <nl> + for ( auto elt : decl - > getAllElements ( ) ) <nl> + unswitchedElts . insert ( elt ) ; <nl> + <nl> + for ( unsigned i = 0 , e = getNumCases ( ) ; i ! = e ; + + i ) { <nl> + auto Entry = getCase ( i ) ; <nl> + unswitchedElts . erase ( Entry . first ) ; <nl> + } <nl> + <nl> + if ( unswitchedElts . size ( ) = = 1 ) <nl> + return * unswitchedElts . begin ( ) ; <nl> + <nl> + return nullptr ; <nl> + } <nl> <nl> / / / If the given block only has one enum element decl matched to it , <nl> / / / return it . <nl> - NullablePtr < EnumElementDecl > getUniqueCaseForDestination ( SILBasicBlock * BB ) ; <nl> - <nl> - bool hasDefault ( ) const { <nl> - return SILInstruction : : Bits . SwitchEnumInstBase . HasDefault ; <nl> + NullablePtr < EnumElementDecl > <nl> + getUniqueCaseForDestination ( SILBasicBlock * block ) { <nl> + SILValue value = getOperand ( ) ; <nl> + SILType enumType = value - > getType ( ) ; <nl> + EnumDecl * decl = enumType . getEnumOrBoundGenericEnum ( ) ; <nl> + assert ( decl & & " switch_enum operand is not an enum " ) ; <nl> + ( void ) decl ; <nl> + <nl> + EnumElementDecl * eltDecl = nullptr ; <nl> + for ( unsigned i : range ( getNumCases ( ) ) ) { <nl> + auto entry = getCase ( i ) ; <nl> + if ( entry . second = = block ) { <nl> + if ( eltDecl ! = nullptr ) <nl> + return nullptr ; <nl> + eltDecl = entry . first ; <nl> + } <nl> + } <nl> + if ( ! eltDecl & & hasDefault ( ) & & getDefaultBB ( ) = = block ) { <nl> + return getUniqueCaseForDefault ( ) ; <nl> + } <nl> + return eltDecl ; <nl> } <nl> <nl> + bool hasDefault ( ) const { return SILInstruction : : Bits . SEIBase . HasDefault ; } <nl> + <nl> SILBasicBlock * getDefaultBB ( ) const { <nl> assert ( hasDefault ( ) & & " doesn ' t have a default " ) ; <nl> return getSuccessorBuf ( ) [ getNumCases ( ) ] ; <nl> } <nl> <nl> - NullablePtr < SILBasicBlock > getDefaultBBOrNull ( ) const ; <nl> + NullablePtr < SILBasicBlock > getDefaultBBOrNull ( ) const { <nl> + if ( ! hasDefault ( ) ) <nl> + return nullptr ; <nl> + return getDefaultBB ( ) ; <nl> + } <nl> <nl> ProfileCounter getDefaultCount ( ) const { <nl> assert ( hasDefault ( ) & & " doesn ' t have a default " ) ; <nl> class SwitchEnumInstBase : public TermInst { <nl> / / / passed into the corresponding destination block as an argument . <nl> class SwitchEnumInst <nl> : public InstructionBase < SILInstructionKind : : SwitchEnumInst , <nl> - SwitchEnumInstBase > { <nl> + SwitchEnumInstBase < OwnershipForwardingTermInst > > { <nl> friend SILBuilder ; <nl> <nl> private : <nl> class SwitchEnumInst <nl> Optional < ArrayRef < ProfileCounter > > CaseCounts , <nl> ProfileCounter DefaultCount ) <nl> : InstructionBase ( DebugLoc , Operand , DefaultBB , CaseBBs , CaseCounts , <nl> - DefaultCount ) { } <nl> + DefaultCount , Operand . getOwnershipKind ( ) ) { } <nl> static SwitchEnumInst * <nl> create ( SILDebugLocation DebugLoc , SILValue Operand , SILBasicBlock * DefaultBB , <nl> ArrayRef < std : : pair < EnumElementDecl * , SILBasicBlock * > > CaseBBs , <nl> class SwitchEnumInst <nl> / / / A switch on an enum ' s discriminator in memory . <nl> class SwitchEnumAddrInst <nl> : public InstructionBase < SILInstructionKind : : SwitchEnumAddrInst , <nl> - SwitchEnumInstBase > { <nl> + SwitchEnumInstBase < TermInst > > { <nl> friend SILBuilder ; <nl> <nl> private : <nl> mmm a / include / swift / SIL / SILNode . h <nl> ppp b / include / swift / SIL / SILNode . h <nl> class alignas ( 8 ) SILNode { <nl> IBWTO_BITFIELD ( SwitchValueInst , TermInst , 1 , <nl> HasDefault : 1 <nl> ) ; <nl> - SWIFT_INLINE_BITFIELD_FULL ( SwitchEnumInstBase , TermInst , 1 + 32 , <nl> + <nl> + / / Special handling for SwitchEnumInstBase . <nl> + / / <nl> + / / We assume all subsequent SwitchEnumBit uses do not use any further bits . <nl> + SWIFT_INLINE_BITFIELD ( SEIBase , TermInst , 32 - NumTermInstBits , <nl> + / / Does this switch enum inst have a default block . <nl> HasDefault : 1 , <nl> - : NumPadBits , <nl> - NumCases : 32 <nl> + / / Number of cases <nl> + NumCases : 31 - NumTermInstBits ; <nl> + template < typename BaseTy > <nl> + friend class SwitchEnumInstBase ; <nl> ) ; <nl> <nl> + # define SEIB_BITFIELD_EMPTY ( T , U ) \ <nl> + IBWTO_BITFIELD_EMPTY ( T , U ) <nl> + <nl> + SEIB_BITFIELD_EMPTY ( SwitchEnumInst , SEIBase ) ; <nl> + SEIB_BITFIELD_EMPTY ( SwitchEnumAddrInst , SEIBase ) ; <nl> + <nl> SWIFT_INLINE_BITFIELD_EMPTY ( MultipleValueInstruction , SILInstruction ) ; <nl> <nl> SWIFT_INLINE_BITFIELD ( BeginCOWMutationInst , MultipleValueInstruction , 1 , <nl> mmm a / include / swift / SIL / SILType . h <nl> ppp b / include / swift / SIL / SILType . h <nl> class SILType { <nl> SILType getEnumElementType ( EnumElementDecl * elt , SILModule & M , <nl> TypeExpansionContext context ) const ; <nl> <nl> + / / / Given that this is an enum type , return true if this type is effectively <nl> + / / / exhausted . <nl> + bool isEffectivelyExhaustiveEnumType ( SILFunction * f ) ; <nl> + <nl> / / / Given that this is a tuple type , return the lowered type of the <nl> / / / given tuple element . The result will have the same value <nl> / / / category as the base type . <nl> new file mode 100644 <nl> index 000000000000 . . 6481d8c77de8 <nl> mmm / dev / null <nl> ppp b / include / swift / SIL / TerminatorUtils . h <nl> <nl> + / / = = = mmm TerminatorUtils . h mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2020 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See https : / / swift . org / LICENSE . txt for license information <nl> + / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / / <nl> + / / / \ file <nl> + / / / <nl> + / / / ADTs for working with various forms of terminators . <nl> + / / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # ifndef SWIFT_SIL_TERMINATORUTILS_H <nl> + # define SWIFT_SIL_TERMINATORUTILS_H <nl> + <nl> + # include " swift / Basic / LLVM . h " <nl> + # include " swift / SIL / SILInstruction . h " <nl> + <nl> + # include " llvm / ADT / PointerUnion . h " <nl> + <nl> + namespace swift { <nl> + <nl> + / / / An ADT for writing generic code against SwitchEnumAddrInst and <nl> + / / / SwitchEnumInst . <nl> + / / / <nl> + / / / We use this instead of SwitchEnumInstBase for this purpose in order to avoid <nl> + / / / the need for templating SwitchEnumInstBase from causing this ADT type of <nl> + / / / usage to require templates . <nl> + class SwitchEnumTermInst { <nl> + PointerUnion < SwitchEnumAddrInst * , SwitchEnumInst * > value ; <nl> + <nl> + public : <nl> + SwitchEnumTermInst ( SwitchEnumAddrInst * seai ) : value ( seai ) { } <nl> + SwitchEnumTermInst ( SwitchEnumInst * seai ) : value ( seai ) { } <nl> + SwitchEnumTermInst ( SILInstruction * i ) : value ( nullptr ) { <nl> + if ( auto * seai = dyn_cast < SwitchEnumAddrInst > ( i ) ) { <nl> + value = seai ; <nl> + return ; <nl> + } <nl> + <nl> + if ( auto * sei = dyn_cast < SwitchEnumInst > ( i ) ) { <nl> + value = sei ; <nl> + return ; <nl> + } <nl> + } <nl> + <nl> + SwitchEnumTermInst ( const SILInstruction * i ) <nl> + : SwitchEnumTermInst ( const_cast < SILInstruction * > ( i ) ) { } <nl> + <nl> + operator TermInst * ( ) const { <nl> + if ( auto * seai = value . dyn_cast < SwitchEnumAddrInst * > ( ) ) <nl> + return seai ; <nl> + return value . get < SwitchEnumInst * > ( ) ; <nl> + } <nl> + <nl> + TermInst * operator * ( ) const { <nl> + if ( auto * seai = value . dyn_cast < SwitchEnumAddrInst * > ( ) ) <nl> + return seai ; <nl> + return value . get < SwitchEnumInst * > ( ) ; <nl> + } <nl> + <nl> + TermInst * operator - > ( ) const { <nl> + if ( auto * seai = value . dyn_cast < SwitchEnumAddrInst * > ( ) ) <nl> + return seai ; <nl> + return value . get < SwitchEnumInst * > ( ) ; <nl> + } <nl> + <nl> + operator bool ( ) const { return bool ( value ) ; } <nl> + <nl> + SILValue getOperand ( ) { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getOperand ( ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getOperand ( ) ; <nl> + } <nl> + <nl> + unsigned getNumCases ( ) { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getNumCases ( ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getNumCases ( ) ; <nl> + } <nl> + <nl> + std : : pair < EnumElementDecl * , SILBasicBlock * > getCase ( unsigned i ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getCase ( i ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getCase ( i ) ; <nl> + } <nl> + <nl> + SILBasicBlock * getCaseDestination ( EnumElementDecl * decl ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getCaseDestination ( decl ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getCaseDestination ( decl ) ; <nl> + } <nl> + <nl> + ProfileCounter getCaseCount ( unsigned i ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getCaseCount ( i ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getCaseCount ( i ) ; <nl> + } <nl> + <nl> + ProfileCounter getDefaultCount ( ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getDefaultCount ( ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getDefaultCount ( ) ; <nl> + } <nl> + <nl> + bool hasDefault ( ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > hasDefault ( ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > hasDefault ( ) ; <nl> + } <nl> + <nl> + SILBasicBlock * getDefaultBB ( ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getDefaultBB ( ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getDefaultBB ( ) ; <nl> + } <nl> + <nl> + NullablePtr < SILBasicBlock > getDefaultBBOrNull ( ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getDefaultBBOrNull ( ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getDefaultBBOrNull ( ) ; <nl> + } <nl> + <nl> + / / / If the default refers to exactly one case decl , return it . <nl> + NullablePtr < EnumElementDecl > getUniqueCaseForDefault ( ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getUniqueCaseForDefault ( ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getUniqueCaseForDefault ( ) ; <nl> + } <nl> + <nl> + / / / If the given block only has one enum element decl matched to it , <nl> + / / / return it . <nl> + NullablePtr < EnumElementDecl > <nl> + getUniqueCaseForDestination ( SILBasicBlock * BB ) const { <nl> + if ( auto * sei = value . dyn_cast < SwitchEnumInst * > ( ) ) <nl> + return sei - > getUniqueCaseForDestination ( BB ) ; <nl> + return value . get < SwitchEnumAddrInst * > ( ) - > getUniqueCaseForDestination ( BB ) ; <nl> + } <nl> + } ; <nl> + <nl> + } / / namespace swift <nl> + <nl> + # endif <nl> mmm a / lib / IRGen / IRGenSIL . cpp <nl> ppp b / lib / IRGen / IRGenSIL . cpp <nl> <nl> # include " swift / SIL / SILModule . h " <nl> # include " swift / SIL / SILType . h " <nl> # include " swift / SIL / SILVisitor . h " <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> # include " clang / AST / ASTContext . h " <nl> # include " clang / AST / DeclCXX . h " <nl> # include " clang / Basic / TargetInfo . h " <nl> static void addIncomingSILArgumentsToPHINodes ( IRGenSILFunction & IGF , <nl> } <nl> <nl> static llvm : : BasicBlock * emitBBMapForSwitchEnum ( <nl> - IRGenSILFunction & IGF , <nl> - SmallVectorImpl < std : : pair < EnumElementDecl * , llvm : : BasicBlock * > > & dests , <nl> - SwitchEnumInstBase * inst ) { <nl> - for ( unsigned i = 0 , e = inst - > getNumCases ( ) ; i < e ; + + i ) { <nl> - auto casePair = inst - > getCase ( i ) ; <nl> - <nl> + IRGenSILFunction & IGF , <nl> + SmallVectorImpl < std : : pair < EnumElementDecl * , llvm : : BasicBlock * > > & dests , <nl> + SwitchEnumTermInst inst ) { <nl> + for ( unsigned i = 0 , e = inst . getNumCases ( ) ; i < e ; + + i ) { <nl> + auto casePair = inst . getCase ( i ) ; <nl> + <nl> / / If the destination BB accepts the case argument , set up a waypoint BB so <nl> / / we can feed the values into the argument ' s PHI node ( s ) . <nl> / / <nl> static llvm : : BasicBlock * emitBBMapForSwitchEnum ( <nl> else <nl> dests . push_back ( { casePair . first , IGF . getLoweredBB ( casePair . second ) . bb } ) ; <nl> } <nl> - <nl> + <nl> llvm : : BasicBlock * defaultDest = nullptr ; <nl> - if ( inst - > hasDefault ( ) ) <nl> - defaultDest = IGF . getLoweredBB ( inst - > getDefaultBB ( ) ) . bb ; <nl> + if ( inst . hasDefault ( ) ) <nl> + defaultDest = IGF . getLoweredBB ( inst . getDefaultBB ( ) ) . bb ; <nl> return defaultDest ; <nl> } <nl> <nl> mmm a / lib / SIL / IR / OperandOwnership . cpp <nl> ppp b / lib / SIL / IR / OperandOwnership . cpp <nl> OperandOwnershipKindClassifier : : visitCondBranchInst ( CondBranchInst * cbi ) { <nl> <nl> OperandOwnershipKindMap <nl> OperandOwnershipKindClassifier : : visitSwitchEnumInst ( SwitchEnumInst * sei ) { <nl> - auto opTy = sei - > getOperand ( ) - > getType ( ) ; <nl> - <nl> - / / If our passed in type is trivial , we shouldn ' t have any non - trivial <nl> - / / successors . Just bail early returning trivial . <nl> - if ( opTy . isTrivial ( * sei - > getFunction ( ) ) ) <nl> - return Map : : allLive ( ) ; <nl> - <nl> - / / Otherwise , go through the ownership constraints of our successor arguments <nl> - / / and merge them . <nl> - auto mergedKind = ValueOwnershipKind : : merge ( makeTransformRange ( <nl> - sei - > getSuccessorBlockArgumentLists ( ) , <nl> - [ & ] ( ArrayRef < SILArgument * > array ) - > ValueOwnershipKind { <nl> - / / If the array is empty , we have a non - payloaded case . Return any . <nl> - if ( array . empty ( ) ) <nl> - return ValueOwnershipKind : : None ; <nl> - <nl> - / / Otherwise , we should have a single element since a payload is <nl> - / / a tuple . <nl> - assert ( std : : distance ( array . begin ( ) , array . end ( ) ) = = 1 ) ; <nl> - return array . front ( ) - > getOwnershipKind ( ) ; <nl> - } ) ) ; <nl> - <nl> - / / If we failed to merge , return an empty map so we will fail to pattern match <nl> - / / with any operand . This is a known signal to the verifier that we failed to <nl> - / / merge in a forwarding context . <nl> - if ( ! mergedKind ) <nl> - return Map ( ) ; <nl> - auto kind = mergedKind . getValue ( ) ; <nl> - if ( kind = = ValueOwnershipKind : : None ) <nl> - return Map : : allLive ( ) ; <nl> + auto kind = getOwnershipKind ( ) ; <nl> auto lifetimeConstraint = kind . getForwardingLifetimeConstraint ( ) ; <nl> return Map : : compatibilityMap ( kind , lifetimeConstraint ) ; <nl> } <nl> mmm a / lib / SIL / IR / SILInstructions . cpp <nl> ppp b / lib / SIL / IR / SILInstructions . cpp <nl> SelectEnumAddrInst * SelectEnumAddrInst : : create ( <nl> false / * HasOwnership * / ) ; <nl> } <nl> <nl> - SwitchEnumInstBase : : SwitchEnumInstBase ( <nl> - SILInstructionKind Kind , SILDebugLocation Loc , SILValue Operand , <nl> - SILBasicBlock * DefaultBB , <nl> - ArrayRef < std : : pair < EnumElementDecl * , SILBasicBlock * > > CaseBBs , <nl> - Optional < ArrayRef < ProfileCounter > > CaseCounts , ProfileCounter DefaultCount ) <nl> - : TermInst ( Kind , Loc ) , Operands ( this , Operand ) { <nl> - SILInstruction : : Bits . SwitchEnumInstBase . HasDefault = bool ( DefaultBB ) ; <nl> - SILInstruction : : Bits . SwitchEnumInstBase . NumCases = CaseBBs . size ( ) ; <nl> - / / Initialize the case and successor arrays . <nl> - auto * cases = getCaseBuf ( ) ; <nl> - auto * succs = getSuccessorBuf ( ) ; <nl> - for ( unsigned i = 0 , size = CaseBBs . size ( ) ; i < size ; + + i ) { <nl> - cases [ i ] = CaseBBs [ i ] . first ; <nl> - if ( CaseCounts ) { <nl> - : : new ( succs + i ) <nl> - SILSuccessor ( this , CaseBBs [ i ] . second , CaseCounts . getValue ( ) [ i ] ) ; <nl> - } else { <nl> - : : new ( succs + i ) SILSuccessor ( this , CaseBBs [ i ] . second ) ; <nl> - } <nl> - } <nl> - <nl> - if ( hasDefault ( ) ) { <nl> - : : new ( succs + getNumCases ( ) ) SILSuccessor ( this , DefaultBB , DefaultCount ) ; <nl> - } <nl> - } <nl> - <nl> - void SwitchEnumInstBase : : swapCase ( unsigned i , unsigned j ) { <nl> - assert ( i < getNumCases ( ) & & " First index is out of bounds ? ! " ) ; <nl> - assert ( j < getNumCases ( ) & & " Second index is out of bounds ? ! " ) ; <nl> - <nl> - auto * succs = getSuccessorBuf ( ) ; <nl> - <nl> - / / First grab our destination blocks . <nl> - SILBasicBlock * iBlock = succs [ i ] . getBB ( ) ; <nl> - SILBasicBlock * jBlock = succs [ j ] . getBB ( ) ; <nl> - <nl> - / / Then destroy the sil successors and reinitialize them with the new things <nl> - / / that they are pointing at . <nl> - succs [ i ] . ~ SILSuccessor ( ) ; <nl> - : : new ( succs + i ) SILSuccessor ( this , jBlock ) ; <nl> - succs [ j ] . ~ SILSuccessor ( ) ; <nl> - : : new ( succs + j ) SILSuccessor ( this , iBlock ) ; <nl> - <nl> - / / Now swap our cases . <nl> - auto * cases = getCaseBuf ( ) ; <nl> - std : : swap ( cases [ i ] , cases [ j ] ) ; <nl> - } <nl> - <nl> namespace { <nl> template < class Inst > EnumElementDecl * <nl> getUniqueCaseForDefaultValue ( Inst * inst , SILValue enumValue ) { <nl> NullablePtr < EnumElementDecl > SelectEnumInstBase : : getSingleTrueElement ( ) const { <nl> return * TrueElement ; <nl> } <nl> <nl> - SwitchEnumInstBase : : ~ SwitchEnumInstBase ( ) { <nl> - / / Destroy the successor records to keep the CFG up to date . <nl> - auto * succs = getSuccessorBuf ( ) ; <nl> - for ( unsigned i = 0 , end = getNumCases ( ) + hasDefault ( ) ; i < end ; + + i ) { <nl> - succs [ i ] . ~ SILSuccessor ( ) ; <nl> - } <nl> - } <nl> - <nl> - template < typename SWITCH_ENUM_INST > <nl> - SWITCH_ENUM_INST * SwitchEnumInstBase : : createSwitchEnum ( <nl> + template < typename BaseTy > <nl> + template < typename SWITCH_ENUM_INST , typename . . . RestTys > <nl> + SWITCH_ENUM_INST * SwitchEnumInstBase < BaseTy > : : createSwitchEnum ( <nl> SILDebugLocation Loc , SILValue Operand , SILBasicBlock * DefaultBB , <nl> ArrayRef < std : : pair < EnumElementDecl * , SILBasicBlock * > > CaseBBs , <nl> SILFunction & F , Optional < ArrayRef < ProfileCounter > > CaseCounts , <nl> - ProfileCounter DefaultCount ) { <nl> + ProfileCounter DefaultCount , RestTys & & . . . restArgs ) { <nl> / / Allocate enough room for the instruction with tail - allocated <nl> / / EnumElementDecl and SILSuccessor arrays . There are ` CaseBBs . size ( ) ` decls <nl> / / and ` CaseBBs . size ( ) + ( DefaultBB ? 1 : 0 ) ` successors . <nl> SWITCH_ENUM_INST * SwitchEnumInstBase : : createSwitchEnum ( <nl> sizeof ( SWITCH_ENUM_INST ) + sizeof ( EnumElementDecl * ) * numCases + <nl> sizeof ( SILSuccessor ) * numSuccessors , <nl> alignof ( SWITCH_ENUM_INST ) ) ; <nl> - return : : new ( buf ) SWITCH_ENUM_INST ( Loc , Operand , DefaultBB , CaseBBs , <nl> - CaseCounts , DefaultCount ) ; <nl> - } <nl> - <nl> - NullablePtr < EnumElementDecl > SwitchEnumInstBase : : getUniqueCaseForDefault ( ) { <nl> - return getUniqueCaseForDefaultValue ( this , getOperand ( ) ) ; <nl> - } <nl> - <nl> - NullablePtr < EnumElementDecl > <nl> - SwitchEnumInstBase : : getUniqueCaseForDestination ( SILBasicBlock * BB ) { <nl> - SILValue value = getOperand ( ) ; <nl> - SILType enumType = value - > getType ( ) ; <nl> - EnumDecl * decl = enumType . getEnumOrBoundGenericEnum ( ) ; <nl> - assert ( decl & & " switch_enum operand is not an enum " ) ; <nl> - ( void ) decl ; <nl> - <nl> - EnumElementDecl * D = nullptr ; <nl> - for ( unsigned i = 0 , e = getNumCases ( ) ; i ! = e ; + + i ) { <nl> - auto Entry = getCase ( i ) ; <nl> - if ( Entry . second = = BB ) { <nl> - if ( D ! = nullptr ) <nl> - return nullptr ; <nl> - D = Entry . first ; <nl> - } <nl> - } <nl> - if ( ! D & & hasDefault ( ) & & getDefaultBB ( ) = = BB ) { <nl> - return getUniqueCaseForDefault ( ) ; <nl> - } <nl> - return D ; <nl> - } <nl> - <nl> - NullablePtr < SILBasicBlock > SwitchEnumInstBase : : getDefaultBBOrNull ( ) const { <nl> - if ( ! hasDefault ( ) ) <nl> - return nullptr ; <nl> - return getDefaultBB ( ) ; <nl> + return : : new ( buf ) <nl> + SWITCH_ENUM_INST ( Loc , Operand , DefaultBB , CaseBBs , CaseCounts , <nl> + DefaultCount , std : : forward < RestTys > ( restArgs ) . . . ) ; <nl> } <nl> <nl> SwitchEnumInst * SwitchEnumInst : : create ( <nl> mmm a / lib / SIL / IR / SILPrinter . cpp <nl> ppp b / lib / SIL / IR / SILPrinter . cpp <nl> <nl> / / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - # include " swift / Strings . h " <nl> - # include " swift / Demangling / Demangle . h " <nl> + # include " swift / AST / Decl . h " <nl> + # include " swift / AST / GenericEnvironment . h " <nl> + # include " swift / AST / Module . h " <nl> + # include " swift / AST / PrintOptions . h " <nl> + # include " swift / AST / ProtocolConformance . h " <nl> + # include " swift / AST / Types . h " <nl> # include " swift / Basic / QuotedString . h " <nl> - # include " swift / SIL / SILPrintContext . h " <nl> + # include " swift / Basic / STLExtras . h " <nl> + # include " swift / Demangling / Demangle . h " <nl> # include " swift / SIL / ApplySite . h " <nl> # include " swift / SIL / CFG . h " <nl> - # include " swift / SIL / SILFunction . h " <nl> # include " swift / SIL / SILCoverageMap . h " <nl> # include " swift / SIL / SILDebugScope . h " <nl> # include " swift / SIL / SILDeclRef . h " <nl> + # include " swift / SIL / SILFunction . h " <nl> # include " swift / SIL / SILModule . h " <nl> - # include " swift / SIL / SILVisitor . h " <nl> + # include " swift / SIL / SILPrintContext . h " <nl> # include " swift / SIL / SILVTable . h " <nl> - # include " swift / AST / Decl . h " <nl> - # include " swift / AST / GenericEnvironment . h " <nl> - # include " swift / AST / Module . h " <nl> - # include " swift / AST / PrintOptions . h " <nl> - # include " swift / AST / ProtocolConformance . h " <nl> - # include " swift / AST / Types . h " <nl> - # include " swift / Basic / STLExtras . h " <nl> + # include " swift / SIL / SILVisitor . h " <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> + # include " swift / Strings . h " <nl> # include " clang / AST / ASTContext . h " <nl> # include " clang / AST / Decl . h " <nl> # include " llvm / ADT / APFloat . h " <nl> <nl> # include " llvm / ADT / StringRef . h " <nl> # include " llvm / ADT / StringSwitch . h " <nl> # include " llvm / Support / CommandLine . h " <nl> - # include " llvm / Support / FormattedStream . h " <nl> # include " llvm / Support / FileSystem . h " <nl> + # include " llvm / Support / FormattedStream . h " <nl> # include < set > <nl> <nl> - <nl> using namespace swift ; <nl> using ID = SILPrintContext : : ID ; <nl> <nl> class SILPrinter : public SILInstructionVisitor < SILPrinter > { <nl> if ( SII - > hasDefault ( ) ) <nl> * this < < " , default " < < Ctx . getID ( SII - > getDefaultBB ( ) ) ; <nl> } <nl> - <nl> - void printSwitchEnumInst ( SwitchEnumInstBase * SOI ) { <nl> - * this < < getIDAndType ( SOI - > getOperand ( ) ) ; <nl> - for ( unsigned i = 0 , e = SOI - > getNumCases ( ) ; i < e ; + + i ) { <nl> + <nl> + void printSwitchEnumInst ( SwitchEnumTermInst SOI ) { <nl> + * this < < getIDAndType ( SOI . getOperand ( ) ) ; <nl> + for ( unsigned i = 0 , e = SOI . getNumCases ( ) ; i < e ; + + i ) { <nl> EnumElementDecl * elt ; <nl> SILBasicBlock * dest ; <nl> - std : : tie ( elt , dest ) = SOI - > getCase ( i ) ; <nl> + std : : tie ( elt , dest ) = SOI . getCase ( i ) ; <nl> * this < < " , case " < < SILDeclRef ( elt , SILDeclRef : : Kind : : EnumElement ) <nl> < < " : " < < Ctx . getID ( dest ) ; <nl> - if ( SOI - > getCaseCount ( i ) ) { <nl> - * this < < " ! case_count ( " < < SOI - > getCaseCount ( i ) . getValue ( ) < < " ) " ; <nl> + if ( SOI . getCaseCount ( i ) ) { <nl> + * this < < " ! case_count ( " < < SOI . getCaseCount ( i ) . getValue ( ) < < " ) " ; <nl> } <nl> } <nl> - if ( SOI - > hasDefault ( ) ) { <nl> - * this < < " , default " < < Ctx . getID ( SOI - > getDefaultBB ( ) ) ; <nl> - if ( SOI - > getDefaultCount ( ) ) { <nl> - * this < < " ! default_count ( " < < SOI - > getDefaultCount ( ) . getValue ( ) < < " ) " ; <nl> + if ( SOI . hasDefault ( ) ) { <nl> + * this < < " , default " < < Ctx . getID ( SOI . getDefaultBB ( ) ) ; <nl> + if ( SOI . getDefaultCount ( ) ) { <nl> + * this < < " ! default_count ( " < < SOI . getDefaultCount ( ) . getValue ( ) < < " ) " ; <nl> } <nl> } <nl> } <nl> - <nl> + <nl> void visitSwitchEnumInst ( SwitchEnumInst * SOI ) { <nl> printSwitchEnumInst ( SOI ) ; <nl> } <nl> mmm a / lib / SIL / IR / SILType . cpp <nl> ppp b / lib / SIL / IR / SILType . cpp <nl> TypeBase : : replaceSubstitutedSILFunctionTypesWithUnsubstituted ( SILModule & M ) cons <nl> return t ; <nl> } ) ; <nl> } <nl> + <nl> + bool SILType : : isEffectivelyExhaustiveEnumType ( SILFunction * f ) { <nl> + EnumDecl * decl = getEnumOrBoundGenericEnum ( ) ; <nl> + assert ( decl & & " Called for a non enum type " ) ; <nl> + return decl - > isEffectivelyExhaustive ( f - > getModule ( ) . getSwiftModule ( ) , <nl> + f - > getResilienceExpansion ( ) ) ; <nl> + } <nl> mmm a / lib / SIL / Utils / BasicBlockUtils . cpp <nl> ppp b / lib / SIL / Utils / BasicBlockUtils . cpp <nl> <nl> # include " swift / SIL / SILBasicBlock . h " <nl> # include " swift / SIL / SILBuilder . h " <nl> # include " swift / SIL / SILFunction . h " <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> <nl> using namespace swift ; <nl> <nl> static SILBasicBlock * getNthEdgeBlock ( SwitchInstTy * S , unsigned edgeIdx ) { <nl> return S - > getCase ( edgeIdx ) . second ; <nl> } <nl> <nl> + static SILBasicBlock * getNthEdgeBlock ( SwitchEnumTermInst S , unsigned edgeIdx ) { <nl> + if ( S . getNumCases ( ) = = edgeIdx ) <nl> + return S . getDefaultBB ( ) ; <nl> + return S . getCase ( edgeIdx ) . second ; <nl> + } <nl> + <nl> void swift : : getEdgeArgs ( TermInst * T , unsigned edgeIdx , SILBasicBlock * newEdgeBB , <nl> llvm : : SmallVectorImpl < SILValue > & args ) { <nl> switch ( T - > getKind ( ) ) { <nl> void swift : : getEdgeArgs ( TermInst * T , unsigned edgeIdx , SILBasicBlock * newEdgeBB , <nl> / / destination block to figure this out . <nl> case SILInstructionKind : : SwitchEnumInst : <nl> case SILInstructionKind : : SwitchEnumAddrInst : { <nl> - auto SEI = cast < SwitchEnumInstBase > ( T ) ; <nl> - auto * succBB = getNthEdgeBlock ( SEI , edgeIdx ) ; <nl> + SwitchEnumTermInst branch ( T ) ; <nl> + auto * succBB = getNthEdgeBlock ( branch , edgeIdx ) ; <nl> assert ( succBB - > getNumArguments ( ) < 2 & & " Can take at most one argument " ) ; <nl> if ( ! succBB - > getNumArguments ( ) ) <nl> return ; <nl> mmm a / lib / SIL / Verifier / SILVerifier . cpp <nl> ppp b / lib / SIL / Verifier / SILVerifier . cpp <nl> class SILVerifier : public SILVerifierBase < SILVerifier > { <nl> require ( dest - > getArguments ( ) . size ( ) = = 1 , <nl> " switch_enum destination for case w / args must take 1 " <nl> " argument " ) ; <nl> + if ( ! dest - > getArgument ( 0 ) - > getType ( ) . isTrivial ( * SOI - > getFunction ( ) ) ) { <nl> + require ( <nl> + dest - > getArgument ( 0 ) - > getOwnershipKind ( ) . isCompatibleWith ( <nl> + SOI - > getOwnershipKind ( ) ) , <nl> + " Switch enum non - trivial destination arg must have ownership " <nl> + " kind that is compatible with the switch_enum ' s operand " ) ; <nl> + } <nl> } else { <nl> require ( dest - > getArguments ( ) . empty ( ) | | <nl> dest - > getArguments ( ) . size ( ) = = 1 , <nl> class SILVerifier : public SILVerifierBase < SILVerifier > { <nl> SOI - > getOperand ( ) - > getType ( ) , <nl> " Switch enum default block should have one argument that is " <nl> " the same as the input type " ) ; <nl> + auto defaultKind = <nl> + SOI - > getDefaultBB ( ) - > getArgument ( 0 ) - > getOwnershipKind ( ) ; <nl> + require ( <nl> + defaultKind . isCompatibleWith ( SOI - > getOperand ( ) . getOwnershipKind ( ) ) , <nl> + " Switch enum default block arg must have same ownership kind " <nl> + " as operand " ) ; <nl> } else if ( ! F . hasOwnership ( ) ) { <nl> require ( SOI - > getDefaultBB ( ) - > args_empty ( ) , <nl> " switch_enum default destination must take no arguments " ) ; <nl> mmm a / lib / SILOptimizer / Differentiation / VJPCloner . cpp <nl> ppp b / lib / SILOptimizer / Differentiation / VJPCloner . cpp <nl> <nl> # include " swift / SILOptimizer / Differentiation / PullbackCloner . h " <nl> # include " swift / SILOptimizer / Differentiation / Thunk . h " <nl> <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> # include " swift / SIL / TypeSubstCloner . h " <nl> # include " swift / SILOptimizer / PassManager / PrettyStackTrace . h " <nl> # include " swift / SILOptimizer / Utils / CFGOptUtils . h " <nl> class VJPCloner : : Implementation final <nl> createTrampolineBasicBlock ( cbi , pbStructVal , cbi - > getFalseBB ( ) ) ) ; <nl> } <nl> <nl> - void visitSwitchEnumInstBase ( SwitchEnumInstBase * inst ) { <nl> + void visitSwitchEnumTermInst ( SwitchEnumTermInst inst ) { <nl> / / Build pullback struct value for original block . <nl> - auto * pbStructVal = buildPullbackValueStructValue ( inst ) ; <nl> + auto * pbStructVal = buildPullbackValueStructValue ( * inst ) ; <nl> <nl> / / Create trampoline successor basic blocks . <nl> SmallVector < std : : pair < EnumElementDecl * , SILBasicBlock * > , 4 > caseBBs ; <nl> - for ( unsigned i : range ( inst - > getNumCases ( ) ) ) { <nl> - auto caseBB = inst - > getCase ( i ) ; <nl> + for ( unsigned i : range ( inst . getNumCases ( ) ) ) { <nl> + auto caseBB = inst . getCase ( i ) ; <nl> auto * trampolineBB = <nl> createTrampolineBasicBlock ( inst , pbStructVal , caseBB . second ) ; <nl> caseBBs . push_back ( { caseBB . first , trampolineBB } ) ; <nl> } <nl> / / Create trampoline default basic block . <nl> SILBasicBlock * newDefaultBB = nullptr ; <nl> - if ( auto * defaultBB = inst - > getDefaultBBOrNull ( ) . getPtrOrNull ( ) ) <nl> + if ( auto * defaultBB = inst . getDefaultBBOrNull ( ) . getPtrOrNull ( ) ) <nl> newDefaultBB = createTrampolineBasicBlock ( inst , pbStructVal , defaultBB ) ; <nl> <nl> / / Create a new ` switch_enum ` instruction . <nl> switch ( inst - > getKind ( ) ) { <nl> case SILInstructionKind : : SwitchEnumInst : <nl> - getBuilder ( ) . createSwitchEnum ( inst - > getLoc ( ) , <nl> - getOpValue ( inst - > getOperand ( ) ) , <nl> - newDefaultBB , caseBBs ) ; <nl> + getBuilder ( ) . createSwitchEnum ( <nl> + inst - > getLoc ( ) , getOpValue ( inst . getOperand ( ) ) , newDefaultBB , caseBBs ) ; <nl> break ; <nl> case SILInstructionKind : : SwitchEnumAddrInst : <nl> - getBuilder ( ) . createSwitchEnumAddr ( inst - > getLoc ( ) , <nl> - getOpValue ( inst - > getOperand ( ) ) , <nl> - newDefaultBB , caseBBs ) ; <nl> + getBuilder ( ) . createSwitchEnumAddr ( <nl> + inst - > getLoc ( ) , getOpValue ( inst . getOperand ( ) ) , newDefaultBB , caseBBs ) ; <nl> break ; <nl> default : <nl> llvm_unreachable ( " Expected ` switch_enum ` or ` switch_enum_addr ` " ) ; <nl> class VJPCloner : : Implementation final <nl> } <nl> <nl> void visitSwitchEnumInst ( SwitchEnumInst * sei ) { <nl> - visitSwitchEnumInstBase ( sei ) ; <nl> + visitSwitchEnumTermInst ( sei ) ; <nl> } <nl> <nl> void visitSwitchEnumAddrInst ( SwitchEnumAddrInst * seai ) { <nl> - visitSwitchEnumInstBase ( seai ) ; <nl> + visitSwitchEnumTermInst ( seai ) ; <nl> } <nl> <nl> void visitCheckedCastBranchInst ( CheckedCastBranchInst * ccbi ) { <nl> mmm a / lib / SILOptimizer / Mandatory / DiagnoseUnreachable . cpp <nl> ppp b / lib / SILOptimizer / Mandatory / DiagnoseUnreachable . cpp <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> # define DEBUG_TYPE " sil - diagnose - unreachable " <nl> + <nl> # include " swift / AST / DiagnosticsSIL . h " <nl> # include " swift / AST / Expr . h " <nl> # include " swift / AST / Pattern . h " <nl> <nl> # include " swift / SIL / SILArgument . h " <nl> # include " swift / SIL / SILBuilder . h " <nl> # include " swift / SIL / SILUndef . h " <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> # include " swift / SILOptimizer / PassManager / Passes . h " <nl> # include " swift / SILOptimizer / PassManager / Transforms . h " <nl> # include " swift / SILOptimizer / Utils / BasicBlockOptUtils . h " <nl> <nl> # include " llvm / ADT / STLExtras . h " <nl> # include " llvm / ADT / Statistic . h " <nl> # include " llvm / Support / Debug . h " <nl> + <nl> using namespace swift ; <nl> <nl> STATISTIC ( NumBlocksRemoved , " Number of unreachable basic blocks removed " ) ; <nl> static void propagateBasicBlockArgs ( SILBasicBlock & BB ) { <nl> <nl> static bool constantFoldEnumTerminator ( SILBasicBlock & BB , <nl> UnreachableUserCodeReportingState * State , <nl> - SwitchEnumInstBase * SUI , <nl> + SwitchEnumTermInst SUI , <nl> EnumElementDecl * TheEnumElem , <nl> EnumInst * EnumInst ) { <nl> SILBasicBlock * TheSuccessorBlock = nullptr ; <nl> int ReachableBlockIdx = - 1 ; <nl> - for ( unsigned Idx = 0 ; Idx < SUI - > getNumCases ( ) ; + + Idx ) { <nl> + for ( unsigned Idx = 0 ; Idx < SUI . getNumCases ( ) ; + + Idx ) { <nl> const EnumElementDecl * EI ; <nl> SILBasicBlock * BI ; <nl> - std : : tie ( EI , BI ) = SUI - > getCase ( Idx ) ; <nl> + std : : tie ( EI , BI ) = SUI . getCase ( Idx ) ; <nl> if ( EI = = TheEnumElem ) { <nl> TheSuccessorBlock = BI ; <nl> ReachableBlockIdx = Idx ; <nl> static bool constantFoldEnumTerminator ( SILBasicBlock & BB , <nl> <nl> SILBasicBlock * DB = nullptr ; <nl> if ( ! TheSuccessorBlock ) { <nl> - if ( SUI - > hasDefault ( ) ) { <nl> - DB = SUI - > getDefaultBB ( ) ; <nl> + if ( SUI . hasDefault ( ) ) { <nl> + DB = SUI . getDefaultBB ( ) ; <nl> if ( ! isa < UnreachableInst > ( DB - > getTerminator ( ) ) ) { <nl> TheSuccessorBlock = DB ; <nl> - ReachableBlockIdx = SUI - > getNumCases ( ) ; <nl> + ReachableBlockIdx = SUI . getNumCases ( ) ; <nl> } <nl> } <nl> } <nl> static bool constantFoldEnumTerminator ( SILBasicBlock & BB , <nl> / / Find the first unreachable block in the switch so that we could use <nl> / / it for better diagnostics . <nl> SILBasicBlock * UnreachableBlock = nullptr ; <nl> - if ( SUI - > getNumCases ( ) > 1 ) { <nl> + if ( SUI . getNumCases ( ) > 1 ) { <nl> / / More than one case . <nl> - UnreachableBlock = ( ReachableBlockIdx = = 0 ) ? SUI - > getCase ( 1 ) . second <nl> - : SUI - > getCase ( 0 ) . second ; <nl> + UnreachableBlock = ( ReachableBlockIdx = = 0 ) ? SUI . getCase ( 1 ) . second <nl> + : SUI . getCase ( 0 ) . second ; <nl> } else { <nl> - if ( SUI - > getNumCases ( ) = = 1 & & SUI - > hasDefault ( ) ) { <nl> + if ( SUI . getNumCases ( ) = = 1 & & SUI . hasDefault ( ) ) { <nl> / / One case and a default . <nl> - UnreachableBlock = ( ReachableBlockIdx = = 0 ) ? SUI - > getDefaultBB ( ) <nl> - : SUI - > getCase ( 0 ) . second ; <nl> + UnreachableBlock = ( ReachableBlockIdx = = 0 ) ? SUI . getDefaultBB ( ) <nl> + : SUI . getCase ( 0 ) . second ; <nl> } <nl> } <nl> <nl> static bool constantFoldEnumTerminator ( SILBasicBlock & BB , <nl> } <nl> } <nl> <nl> - LLVM_DEBUG ( llvm : : dbgs ( ) < < " Folding terminator : " < < * SUI ) ; <nl> + LLVM_DEBUG ( llvm : : dbgs ( ) < < " Folding terminator : " < < * * SUI ) ; <nl> recursivelyDeleteTriviallyDeadInstructions ( SUI , true ) ; <nl> + + NumTerminatorsFolded ; <nl> return true ; <nl> static bool constantFoldEnumTerminator ( SILBasicBlock & BB , <nl> <nl> static bool constantFoldEnumAddrTerminator ( <nl> SILBasicBlock & BB , UnreachableUserCodeReportingState * State , <nl> - SwitchEnumInstBase * SUI , const EnumElementDecl * TheEnumElem ) { <nl> + SwitchEnumTermInst SUI , const EnumElementDecl * TheEnumElem ) { <nl> SILBasicBlock * TheSuccessorBlock = nullptr ; <nl> int ReachableBlockIdx = - 1 ; <nl> - for ( unsigned Idx = 0 ; Idx < SUI - > getNumCases ( ) ; + + Idx ) { <nl> + for ( unsigned Idx = 0 ; Idx < SUI . getNumCases ( ) ; + + Idx ) { <nl> const EnumElementDecl * EI ; <nl> SILBasicBlock * BI ; <nl> - std : : tie ( EI , BI ) = SUI - > getCase ( Idx ) ; <nl> + std : : tie ( EI , BI ) = SUI . getCase ( Idx ) ; <nl> if ( EI = = TheEnumElem ) { <nl> TheSuccessorBlock = BI ; <nl> ReachableBlockIdx = Idx ; <nl> static bool constantFoldEnumAddrTerminator ( <nl> <nl> SILBasicBlock * DB = nullptr ; <nl> if ( ! TheSuccessorBlock ) { <nl> - if ( SUI - > hasDefault ( ) ) { <nl> - DB = SUI - > getDefaultBB ( ) ; <nl> + if ( SUI . hasDefault ( ) ) { <nl> + DB = SUI . getDefaultBB ( ) ; <nl> if ( ! isa < UnreachableInst > ( DB - > getTerminator ( ) ) ) { <nl> TheSuccessorBlock = DB ; <nl> - ReachableBlockIdx = SUI - > getNumCases ( ) ; <nl> + ReachableBlockIdx = SUI . getNumCases ( ) ; <nl> } <nl> } <nl> } <nl> static bool constantFoldEnumAddrTerminator ( <nl> / / Find the first unreachable block in the switch so that we could use <nl> / / it for better diagnostics . <nl> SILBasicBlock * UnreachableBlock = nullptr ; <nl> - if ( SUI - > getNumCases ( ) > 1 ) { <nl> + if ( SUI . getNumCases ( ) > 1 ) { <nl> / / More than one case . <nl> - UnreachableBlock = ( ReachableBlockIdx = = 0 ) ? SUI - > getCase ( 1 ) . second <nl> - : SUI - > getCase ( 0 ) . second ; <nl> + UnreachableBlock = ( ReachableBlockIdx = = 0 ) ? SUI . getCase ( 1 ) . second <nl> + : SUI . getCase ( 0 ) . second ; <nl> } else { <nl> - if ( SUI - > getNumCases ( ) = = 1 & & SUI - > hasDefault ( ) ) { <nl> + if ( SUI . getNumCases ( ) = = 1 & & SUI . hasDefault ( ) ) { <nl> / / One case and a default . <nl> - UnreachableBlock = ( ReachableBlockIdx = = 0 ) ? SUI - > getDefaultBB ( ) <nl> - : SUI - > getCase ( 0 ) . second ; <nl> + UnreachableBlock = ( ReachableBlockIdx = = 0 ) ? SUI . getDefaultBB ( ) <nl> + : SUI . getCase ( 0 ) . second ; <nl> } <nl> } <nl> <nl> mmm a / lib / SILOptimizer / Mandatory / YieldOnceCheck . cpp <nl> ppp b / lib / SILOptimizer / Mandatory / YieldOnceCheck . cpp <nl> <nl> / / graph of the coroutine has a yield instruction before a return instruction . <nl> <nl> # define DEBUG_TYPE " yield - once - check " <nl> + <nl> # include " swift / AST / ASTWalker . h " <nl> # include " swift / AST / DiagnosticsSIL . h " <nl> # include " swift / AST / Expr . h " <nl> <nl> # include " swift / SIL / BasicBlockUtils . h " <nl> # include " swift / SIL / CFG . h " <nl> # include " swift / SIL / Dominance . h " <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> # include " swift / SILOptimizer / PassManager / Transforms . h " <nl> # include " llvm / ADT / BreadthFirstIterator . h " <nl> # include " llvm / ADT / DenseSet . h " <nl> class YieldOnceCheck : public SILFunctionTransform { <nl> / / For switch_enum instructions , report the case that doesn ' t yield . <nl> enum SwitchCaseKind { Default , OptionNil , OptionSome } ; <nl> <nl> - if ( auto * switchEnum = dyn_cast < SwitchEnumInstBase > ( conflictingBranch ) ) { <nl> + if ( auto switchEnum = SwitchEnumTermInst ( conflictingBranch ) ) { <nl> auto enumCaseLoc = noYieldTarget - > begin ( ) - > getLoc ( ) . getSourceLoc ( ) ; <nl> <nl> - if ( switchEnum - > hasDefault ( ) & & <nl> - switchEnum - > getDefaultBB ( ) = = noYieldTarget ) { <nl> + if ( switchEnum . hasDefault ( ) & & <nl> + switchEnum . getDefaultBB ( ) = = noYieldTarget ) { <nl> diagnose ( astCtx , enumCaseLoc , diag : : case_doesnt_yield , Default ) ; <nl> return ; <nl> } <nl> <nl> / / Find the case identifier that doesn ' t yield . <nl> NullablePtr < EnumElementDecl > enumElemDecl = <nl> - switchEnum - > getUniqueCaseForDestination ( noYieldTarget ) ; <nl> + switchEnum . getUniqueCaseForDestination ( noYieldTarget ) ; <nl> assert ( enumElemDecl . isNonNull ( ) ) ; <nl> <nl> / / Specialize diagnostics for cases of an optional . <nl> mmm a / lib / SILOptimizer / SemanticARC / OwnershipLiveRange . cpp <nl> ppp b / lib / SILOptimizer / SemanticARC / OwnershipLiveRange . cpp <nl> void OwnershipLiveRange : : insertEndBorrowsAtDestroys ( <nl> static void convertInstructionOwnership ( SILInstruction * i , <nl> ValueOwnershipKind oldOwnership , <nl> ValueOwnershipKind newOwnership ) { <nl> - / / If this is a term inst , just convert all of its incoming values that are <nl> - / / owned to be guaranteed . <nl> + / / If this is a term inst . . . <nl> if ( auto * ti = dyn_cast < TermInst > ( i ) ) { <nl> + / / First see if it is an ownership forwarding term inst . In such a case , <nl> + / / change the ownership kind as appropriate . <nl> + if ( auto * ofti = dyn_cast < OwnershipForwardingTermInst > ( ti ) ) <nl> + if ( ofti - > getOwnershipKind ( ) = = oldOwnership ) <nl> + ofti - > setOwnershipKind ( newOwnership ) ; <nl> + <nl> + / / Then convert all of its incoming values that are owned to be guaranteed . <nl> for ( auto & succ : ti - > getSuccessors ( ) ) { <nl> auto * succBlock = succ . getBB ( ) ; <nl> <nl> mmm a / lib / SILOptimizer / Transforms / SimplifyCFG . cpp <nl> ppp b / lib / SILOptimizer / Transforms / SimplifyCFG . cpp <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> # define DEBUG_TYPE " sil - simplify - cfg " <nl> + <nl> # include " swift / AST / Module . h " <nl> # include " swift / SIL / DebugUtils . h " <nl> # include " swift / SIL / Dominance . h " <nl> <nl> # include " swift / SIL / SILArgument . h " <nl> # include " swift / SIL / SILModule . h " <nl> # include " swift / SIL / SILUndef . h " <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> # include " swift / SILOptimizer / Analysis / DominanceAnalysis . h " <nl> # include " swift / SILOptimizer / Analysis / ProgramTerminationAnalysis . h " <nl> # include " swift / SILOptimizer / Analysis / SimplifyInstruction . h " <nl> bool SimplifyCFG : : canonicalizeSwitchEnums ( ) { <nl> bool Changed = false ; <nl> for ( auto & BB : Fn ) { <nl> TermInst * TI = BB . getTerminator ( ) ; <nl> - <nl> - auto * SWI = dyn_cast < SwitchEnumInstBase > ( TI ) ; <nl> + <nl> + SwitchEnumTermInst SWI ( TI ) ; <nl> if ( ! SWI ) <nl> continue ; <nl> - <nl> - if ( ! SWI - > hasDefault ( ) ) <nl> + <nl> + if ( ! SWI . hasDefault ( ) ) <nl> continue ; <nl> <nl> - NullablePtr < EnumElementDecl > elementDecl = SWI - > getUniqueCaseForDefault ( ) ; <nl> + NullablePtr < EnumElementDecl > elementDecl = SWI . getUniqueCaseForDefault ( ) ; <nl> if ( ! elementDecl ) <nl> continue ; <nl> <nl> / / Construct a new instruction by copying all the case entries . <nl> SmallVector < std : : pair < EnumElementDecl * , SILBasicBlock * > , 4 > CaseBBs ; <nl> - for ( int idx = 0 , numIdcs = SWI - > getNumCases ( ) ; idx < numIdcs ; + + idx ) { <nl> - CaseBBs . push_back ( SWI - > getCase ( idx ) ) ; <nl> + for ( int idx = 0 , numIdcs = SWI . getNumCases ( ) ; idx < numIdcs ; + + idx ) { <nl> + CaseBBs . push_back ( SWI . getCase ( idx ) ) ; <nl> } <nl> / / Add the default - entry of the original instruction as case - entry . <nl> - CaseBBs . push_back ( std : : make_pair ( elementDecl . get ( ) , SWI - > getDefaultBB ( ) ) ) ; <nl> + CaseBBs . push_back ( std : : make_pair ( elementDecl . get ( ) , SWI . getDefaultBB ( ) ) ) ; <nl> <nl> - if ( isa < SwitchEnumInst > ( SWI ) ) { <nl> - SILBuilderWithScope ( SWI ) <nl> - . createSwitchEnum ( SWI - > getLoc ( ) , SWI - > getOperand ( ) , nullptr , CaseBBs ) ; <nl> + if ( isa < SwitchEnumInst > ( * SWI ) ) { <nl> + SILBuilderWithScope ( SWI ) . createSwitchEnum ( SWI - > getLoc ( ) , SWI . getOperand ( ) , <nl> + nullptr , CaseBBs ) ; <nl> } else { <nl> - assert ( isa < SwitchEnumAddrInst > ( SWI ) & & <nl> + assert ( isa < SwitchEnumAddrInst > ( * SWI ) & & <nl> " unknown switch_enum instruction " ) ; <nl> SILBuilderWithScope ( SWI ) . createSwitchEnumAddr ( <nl> - SWI - > getLoc ( ) , SWI - > getOperand ( ) , nullptr , CaseBBs ) ; <nl> + SWI - > getLoc ( ) , SWI . getOperand ( ) , nullptr , CaseBBs ) ; <nl> } <nl> SWI - > eraseFromParent ( ) ; <nl> Changed = true ; <nl> mmm a / lib / SILOptimizer / Utils / ConstExpr . cpp <nl> ppp b / lib / SILOptimizer / Utils / ConstExpr . cpp <nl> <nl> / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - # include " swift / SIL / SILInstruction . h " <nl> # define DEBUG_TYPE " ConstExpr " <nl> + <nl> # include " swift / SILOptimizer / Utils / ConstExpr . h " <nl> # include " swift / AST / Builtins . h " <nl> # include " swift / AST / ProtocolConformance . h " <nl> <nl> # include " swift / SIL / InstructionUtils . h " <nl> # include " swift / SIL / SILBuilder . h " <nl> # include " swift / SIL / SILConstants . h " <nl> + # include " swift / SIL / SILInstruction . h " <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> # include " swift / SILOptimizer / Utils / Devirtualize . h " <nl> # include " swift / Serialization / SerializedSILLoader . h " <nl> # include " llvm / ADT / PointerEmbeddedInt . h " <nl> ConstExprFunctionState : : evaluateInstructionAndGetNext ( <nl> return { destBB - > begin ( ) , None } ; <nl> } <nl> <nl> - if ( isa < SwitchEnumAddrInst > ( inst ) | | isa < SwitchEnumInst > ( inst ) ) { <nl> + if ( auto switchInst = SwitchEnumTermInst ( inst ) ) { <nl> SymbolicValue value ; <nl> - SwitchEnumInstBase * switchInst = dyn_cast < SwitchEnumInst > ( inst ) ; <nl> - if ( switchInst ) { <nl> - value = getConstantValue ( switchInst - > getOperand ( ) ) ; <nl> + if ( isa < SwitchEnumInst > ( * switchInst ) ) { <nl> + value = getConstantValue ( switchInst . getOperand ( ) ) ; <nl> } else { <nl> - switchInst = cast < SwitchEnumAddrInst > ( inst ) ; <nl> - value = getConstAddrAndLoadResult ( switchInst - > getOperand ( ) ) ; <nl> + value = getConstAddrAndLoadResult ( switchInst . getOperand ( ) ) ; <nl> } <nl> if ( ! value . isConstant ( ) ) <nl> return { None , value } ; <nl> ConstExprFunctionState : : evaluateInstructionAndGetNext ( <nl> assert ( value . getKind ( ) = = SymbolicValue : : Enum | | <nl> value . getKind ( ) = = SymbolicValue : : EnumWithPayload ) ; <nl> <nl> - SILBasicBlock * caseBB = <nl> - switchInst - > getCaseDestination ( value . getEnumValue ( ) ) ; <nl> + SILBasicBlock * caseBB = switchInst . getCaseDestination ( value . getEnumValue ( ) ) ; <nl> if ( caseBB - > getNumArguments ( ) = = 0 ) <nl> return { caseBB - > begin ( ) , None } ; <nl> <nl> ConstExprFunctionState : : evaluateInstructionAndGetNext ( <nl> assert ( caseBB - > getNumArguments ( ) = = 1 ) ; <nl> <nl> if ( caseBB - > getParent ( ) - > hasOwnership ( ) & & <nl> - switchInst - > getDefaultBBOrNull ( ) = = caseBB ) { <nl> + switchInst . getDefaultBBOrNull ( ) = = caseBB ) { <nl> / / If we are visiting the default block and we are in ossa , then we may <nl> / / have uses of the failure parameter . That means we need to map the <nl> / / original value to the argument . <nl> mmm a / lib / Serialization / SerializeSIL . cpp <nl> ppp b / lib / Serialization / SerializeSIL . cpp <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> # define DEBUG_TYPE " sil - serialize " <nl> + <nl> # include " SILFormat . h " <nl> # include " Serialization . h " <nl> + # include " swift / AST / ASTMangler . h " <nl> # include " swift / AST / GenericEnvironment . h " <nl> # include " swift / AST / GenericSignature . h " <nl> # include " swift / AST / Module . h " <nl> # include " swift / AST / ProtocolConformance . h " <nl> - # include " swift / AST / ASTMangler . h " <nl> # include " swift / SIL / CFG . h " <nl> # include " swift / SIL / PrettyStackTrace . h " <nl> # include " swift / SIL / SILArgument . h " <nl> # include " swift / SIL / SILModule . h " <nl> # include " swift / SIL / SILUndef . h " <nl> + # include " swift / SIL / TerminatorUtils . h " <nl> # include " swift / SILOptimizer / Utils / Generics . h " <nl> # include " swift / Strings . h " <nl> <nl> void SILSerializer : : writeSILInstruction ( const SILInstruction & SI ) { <nl> / / default basic block ID . Use SILOneTypeValuesLayout : the type is <nl> / / for condition , the list has value for condition , hasDefault , default <nl> / / basic block ID , a list of ( DeclID , BasicBlock ID ) . <nl> - const SwitchEnumInstBase * SOI = cast < SwitchEnumInstBase > ( & SI ) ; <nl> + SwitchEnumTermInst SOI ( & SI ) ; <nl> + assert ( SOI ) ; <nl> SmallVector < ValueID , 4 > ListOfValues ; <nl> - ListOfValues . push_back ( addValueRef ( SOI - > getOperand ( ) ) ) ; <nl> - ListOfValues . push_back ( ( unsigned ) SOI - > hasDefault ( ) ) ; <nl> - if ( SOI - > hasDefault ( ) ) <nl> - ListOfValues . push_back ( BasicBlockMap [ SOI - > getDefaultBB ( ) ] ) ; <nl> + ListOfValues . push_back ( addValueRef ( SOI . getOperand ( ) ) ) ; <nl> + ListOfValues . push_back ( ( unsigned ) SOI . hasDefault ( ) ) ; <nl> + if ( SOI . hasDefault ( ) ) <nl> + ListOfValues . push_back ( BasicBlockMap [ SOI . getDefaultBB ( ) ] ) ; <nl> else <nl> ListOfValues . push_back ( 0 ) ; <nl> <nl> - for ( unsigned i = 0 , e = SOI - > getNumCases ( ) ; i < e ; + + i ) { <nl> + for ( unsigned i = 0 , e = SOI . getNumCases ( ) ; i < e ; + + i ) { <nl> EnumElementDecl * elt ; <nl> SILBasicBlock * dest ; <nl> - std : : tie ( elt , dest ) = SOI - > getCase ( i ) ; <nl> + std : : tie ( elt , dest ) = SOI . getCase ( i ) ; <nl> ListOfValues . push_back ( S . addDeclRef ( elt ) ) ; <nl> ListOfValues . push_back ( BasicBlockMap [ dest ] ) ; <nl> } <nl> - SILOneTypeValuesLayout : : emitRecord ( Out , ScratchRecord , <nl> - SILAbbrCodes [ SILOneTypeValuesLayout : : Code ] , <nl> + SILOneTypeValuesLayout : : emitRecord ( <nl> + Out , ScratchRecord , SILAbbrCodes [ SILOneTypeValuesLayout : : Code ] , <nl> ( unsigned ) SI . getKind ( ) , <nl> - S . addTypeRef ( SOI - > getOperand ( ) - > getType ( ) . getASTType ( ) ) , <nl> - ( unsigned ) SOI - > getOperand ( ) - > getType ( ) . getCategory ( ) , <nl> - ListOfValues ) ; <nl> + S . addTypeRef ( SOI . getOperand ( ) - > getType ( ) . getASTType ( ) ) , <nl> + ( unsigned ) SOI . getOperand ( ) - > getType ( ) . getCategory ( ) , ListOfValues ) ; <nl> break ; <nl> } <nl> case SILInstructionKind : : SelectEnumInst : <nl> mmm a / test / SIL / ownership - verifier / arguments . sil <nl> ppp b / test / SIL / ownership - verifier / arguments . sil <nl> struct NativeObjectPair { <nl> var obj2 : Builtin . NativeObject <nl> } <nl> <nl> + enum FakeOptional < T > { <nl> + case none <nl> + case some ( T ) <nl> + } <nl> + <nl> / / / / / / / / / / / <nl> / / Tests / / <nl> / / / / / / / / / / / <nl> bb3 : <nl> % 9999 = tuple ( ) <nl> return % 9999 : $ ( ) <nl> } <nl> + <nl> mmm a / test / SIL / ownership - verifier / over_consume . sil <nl> ppp b / test / SIL / ownership - verifier / over_consume . sil <nl> bb0 ( % 0 : @ owned $ Optional < Builtin . NativeObject > ) : <nl> return % 9999 : $ ( ) <nl> } <nl> <nl> - / / CHECK - LABEL : Function : ' switch_enum_mismatching_argument_guaranteed_to_owned ' <nl> - / / CHECK : Have operand with incompatible ownership ? ! <nl> - / / CHECK : Value : % 0 = argument of bb0 <nl> - / / CHECK : User : switch_enum % 0 <nl> - / / CHECK : Conv : guaranteed <nl> - / / CHECK : OwnershipMap : <nl> - / / CHECK : - - OperandOwnershipKindMap - - <nl> - / / CHECK : unowned : No . <nl> - / / CHECK : owned : Yes . Liveness : LifetimeEnding <nl> - / / CHECK : guaranteed : No . <nl> - / / CHECK : any : Yes . Liveness : NonLifetimeEnding <nl> - sil [ ossa ] @ switch_enum_mismatching_argument_guaranteed_to_owned : $ @ convention ( thin ) ( @ guaranteed Optional < Builtin . NativeObject > ) - > ( ) { <nl> - bb0 ( % 0 : @ guaranteed $ Optional < Builtin . NativeObject > ) : <nl> - switch_enum % 0 : $ Optional < Builtin . NativeObject > , case # Optional . some ! enumelt : bb1 , case # Optional . none ! enumelt : bb2 <nl> - <nl> - bb1 ( % 1 : @ owned $ Builtin . NativeObject ) : <nl> - destroy_value % 1 : $ Builtin . NativeObject <nl> - br bb3 <nl> - <nl> - bb2 : <nl> - br bb3 <nl> - <nl> - bb3 : <nl> - % 9999 = tuple ( ) <nl> - return % 9999 : $ ( ) <nl> - } <nl> - <nl> - / / CHECK - LABEL : Function : ' switch_enum_mismatching_argument_owned_to_guaranteed ' <nl> - / / CHECK : Have operand with incompatible ownership ? ! <nl> - / / CHECK : Value : % 0 = argument of bb0 : $ Optional < Builtin . NativeObject > <nl> - / / CHECK : User : switch_enum % 0 : $ Optional < Builtin . NativeObject > <nl> - / / CHECK : Conv : owned <nl> - / / CHECK : OwnershipMap : <nl> - / / CHECK : - - OperandOwnershipKindMap - - <nl> - / / CHECK : unowned : No . <nl> - / / CHECK : owned : No . <nl> - / / CHECK : guaranteed : Yes . Liveness : NonLifetimeEnding <nl> - / / CHECK : any : Yes . Liveness : NonLifetimeEnding <nl> - sil [ ossa ] @ switch_enum_mismatching_argument_owned_to_guaranteed : $ @ convention ( thin ) ( @ owned Optional < Builtin . NativeObject > ) - > ( ) { <nl> - bb0 ( % 0 : @ owned $ Optional < Builtin . NativeObject > ) : <nl> - switch_enum % 0 : $ Optional < Builtin . NativeObject > , case # Optional . some ! enumelt : bb1 , case # Optional . none ! enumelt : bb2 <nl> - <nl> - bb1 ( % 1 : @ guaranteed $ Builtin . NativeObject ) : <nl> - br bb3 <nl> - <nl> - bb2 : <nl> - br bb3 <nl> - <nl> - bb3 : <nl> - % 9999 = tuple ( ) <nl> - return % 9999 : $ ( ) <nl> - } <nl> - <nl> - <nl> / / CHECK - LABEL : Function : ' switch_enum_guaranteed_arg_outlives_original_value ' <nl> / / CHECK : Found outside of lifetime use ? ! <nl> / / CHECK : Value : % 1 = begin_borrow % 0 : $ Optional < Builtin . NativeObject > <nl> | Merge pull request from gottesmm / pr - 200203a48964c3efb090a7f4f2389b115a88b607 | apple/swift | 6f60a17cc7cd32603cd623e1d293f5099de0fcb3 | 2020-11-09T07:54:50Z |
mmm a / stdlib / public / core / ArrayBuffer . swift <nl> ppp b / stdlib / public / core / ArrayBuffer . swift <nl> extension _ArrayBuffer { <nl> internal func _typeCheckSlowPath ( _ index : Int ) { <nl> if _fastPath ( _isNative ) { <nl> let element : AnyObject = cast ( toBufferOf : AnyObject . self ) . _native [ index ] <nl> - _precondition ( <nl> + precondition ( <nl> element is Element , <nl> - " Down - casted Array element failed to match the target type " ) <nl> + " " " <nl> + Down - casted Array element failed to match the target type <nl> + Expected \ ( Element . self ) but found \ ( type ( of : element ) ) <nl> + " " " <nl> + ) <nl> } <nl> else { <nl> let ns = _nonNative <nl> - _precondition ( <nl> - ns . objectAt ( index ) is Element , <nl> - " NSArray element failed to match the Swift Array Element type " ) <nl> + let element = ns . objectAt ( index ) <nl> + precondition ( <nl> + element is Element , <nl> + " " " <nl> + NSArray element failed to match the Swift Array Element type <nl> + Expected \ ( Element . self ) but found \ ( type ( of : element ) ) <nl> + " " " <nl> + ) <nl> } <nl> } <nl> <nl> extension _ArrayBuffer { <nl> _native . _checkValidSubscript ( i ) <nl> <nl> element = cast ( toBufferOf : AnyObject . self ) . _native [ i ] <nl> - _precondition ( <nl> + precondition ( <nl> element is Element , <nl> - " Down - casted Array element failed to match the target type " ) <nl> + " " " <nl> + Down - casted Array element failed to match the target type <nl> + Expected \ ( Element . self ) but found \ ( type ( of : element ) ) <nl> + " " " <nl> + ) <nl> } else { <nl> / / ObjC arrays do their own subscript checking . <nl> element = _nonNative . objectAt ( i ) <nl> - _precondition ( <nl> + precondition ( <nl> element is Element , <nl> - " NSArray element failed to match the Swift Array Element type " ) <nl> + " " " <nl> + NSArray element failed to match the Swift Array Element type <nl> + Expected \ ( Element . self ) but found \ ( type ( of : element ) ) <nl> + " " " <nl> + ) <nl> } <nl> return element <nl> } <nl> mmm a / stdlib / public / core / Assert . swift <nl> ppp b / stdlib / public / core / Assert . swift <nl> public func precondition ( <nl> _ message : @ autoclosure ( ) - > String = String ( ) , <nl> file : StaticString = # file , line : UInt = # line <nl> ) { <nl> - / / Only check in debug and release mode . In release mode just trap . <nl> + / / Only check in debug and release mode . In release mode just trap . <nl> if _isDebugAssertConfiguration ( ) { <nl> if ! _branchHint ( condition ( ) , expected : true ) { <nl> _assertionFailure ( " Precondition failed " , message ( ) , file : file , line : line , <nl> | Merge pull request from lancep / print_mismatched_types | apple/swift | 6c0d3258058ea0c8ef3705d7eaac4fd418a72b93 | 2018-07-10T18:33:43Z |
mmm a / modules / core / include / opencv2 / core / core . hpp <nl> ppp b / modules / core / include / opencv2 / core / core . hpp <nl> class CV_EXPORTS Algorithm <nl> <nl> The class is used for reading command arguments . <nl> Supports the following syntax : <nl> - / / - k 10 1 2 - - x 0 . 001 - - size 640 480 - - inputFile lena . jpg <nl> + / / - k = 10 - - x 0 . 001 - - inputFile lena . jpg <nl> int k = parser . get < int > ( " - - k | - k " , - 1 ) ; <nl> - vector < int > kValues = parser . getVec < int > ( " - - k | - k " ) ; <nl> double x = parser . get < double > ( " - - x " ) ; <nl> - cv : : Size size = parser . get < cv : : Size > ( " - - size " ) ; <nl> string inputFile = parser . get < string > ( " - - inputFile " ) ; <nl> * / <nl> class CV_EXPORTS CommandLineParser <nl> { <nl> - public : <nl> - / / ! the default constructor <nl> - CommandLineParser ( int argc , const char * argv [ ] ) ; <nl> - <nl> - / / ! allows to check if parameter is given <nl> - bool has ( const std : : string & keys ) const ; <nl> + public : <nl> <nl> - / / ! get parameter <nl> - template < typename _Tp > <nl> - _Tp get ( const std : : string & name ) <nl> - { <nl> - return fromStringsVec < _Tp > ( getVec < std : : string > ( name ) ) ; <nl> - } <nl> - <nl> - / / ! get parameter with default value <nl> - template < typename _Tp > <nl> - _Tp get ( const std : : string & name , const _Tp & default_value ) <nl> - { <nl> - if ( ! has ( name ) ) <nl> - return default_value ; <nl> - <nl> - return get < _Tp > ( name ) ; <nl> - } <nl> + / / ! the default constructor <nl> + CommandLineParser ( int argc , const char * argv [ ] ) ; <nl> <nl> - / / ! get a vector of values for specified key <nl> - template < typename _Tp > <nl> - std : : vector < _Tp > getVec ( const std : : string & keys ) ; <nl> + / / ! allows to check if parameter is given <nl> + bool has ( const std : : string & keys ) const ; <nl> <nl> - protected : <nl> - std : : map < std : : string , std : : vector < std : : string > > data ; <nl> - <nl> - template < typename _Tp > <nl> - static _Tp fromStringSimple ( const std : : string & str ) / / the default conversion function <nl> - { <nl> - _Tp res ; <nl> - std : : stringstream s1 ( str ) ; <nl> - s1 > > res ; <nl> - return res ; <nl> - } <nl> - <nl> - template < typename _Tp > <nl> - static _Tp fromString ( const std : : string & str ) <nl> - { <nl> - return fromStringSimple < _Tp > ( str ) ; <nl> - } <nl> + / / ! get parameter , if parameter is not given get default parameter <nl> + template < typename _Tp > <nl> + _Tp get ( const std : : string & name , const _Tp & default_value = _Tp ( ) ) <nl> + { <nl> + std : : string str = getString ( name ) ; <nl> + if ( ! has ( name ) ) <nl> + return default_value ; <nl> + return analizeValue < _Tp > ( str ) ; <nl> + } <nl> <nl> - template < typename _Tp > <nl> - static _Tp fromStringNumber ( const std : : string & str ) / / the default conversion function for numbers <nl> - { <nl> - _Tp dummy_val = 0 ; dummy_val + = 1 ; <nl> + protected : <nl> + std : : map < std : : string , std : : vector < std : : string > > data ; <nl> + std : : string getString ( const std : : string & name ) const ; <nl> <nl> - if ( str . empty ( ) ) <nl> - CV_Error ( CV_StsParseError , " Empty string cannot be converted to a number " ) ; <nl> + template < typename _Tp > <nl> + _Tp analizeValue ( const std : : string & str ) ; <nl> <nl> - const char * c_str = str . c_str ( ) ; <nl> - if ( ( ! isdigit ( c_str [ 0 ] ) ) <nl> - & & <nl> - ( <nl> - ( c_str [ 0 ] ! = ' - ' ) | | ( strlen ( c_str ) < = 1 ) | | ( ! isdigit ( c_str [ 1 ] ) ) <nl> - ) <nl> - ) <nl> + template < typename _Tp > <nl> + static _Tp getData ( const std : : string & str ) <nl> { <nl> - CV_Error ( CV_StsParseError , " The string ' " + str + " ' cannot be converted to a number " ) ; <nl> + _Tp res ; <nl> + std : : stringstream s1 ( str ) ; <nl> + s1 > > res ; <nl> + return res ; <nl> } <nl> <nl> - return fromStringSimple < _Tp > ( str ) ; <nl> - } <nl> + template < typename _Tp > <nl> + static _Tp fromStringNumber ( const std : : string & str ) / / the default conversion function for numbers <nl> + { <nl> <nl> - template < typename _Tp > <nl> - static _Tp fromStringsVec ( const std : : vector < std : : string > & vec_str ) <nl> - { <nl> - if ( vec_str . empty ( ) ) <nl> - CV_Error ( CV_StsParseError , " Cannot convert from an empty vector " ) ; <nl> - return fromString < _Tp > ( vec_str [ 0 ] ) ; <nl> - } <nl> - } ; <nl> + if ( str . empty ( ) ) <nl> + CV_Error ( CV_StsParseError , " Empty string cannot be converted to a number " ) ; <nl> <nl> - template < > CV_EXPORTS <nl> - std : : vector < std : : string > CommandLineParser : : getVec < std : : string > ( const std : : string & keys ) ; <nl> + const char * c_str = str . c_str ( ) ; <nl> + if ( ( ! isdigit ( c_str [ 0 ] ) ) <nl> + & & <nl> + ( <nl> + ( c_str [ 0 ] ! = ' - ' ) | | ( strlen ( c_str ) < = 1 ) | | ( ! isdigit ( c_str [ 1 ] ) ) <nl> + ) <nl> + ) <nl> <nl> - template < typename _Tp > inline <nl> - std : : vector < _Tp > CommandLineParser : : getVec ( const std : : string & keys ) <nl> - { <nl> - if ( ! has ( keys ) ) <nl> - return std : : vector < _Tp > ( ) ; <nl> + { <nl> + CV_Error ( CV_StsParseError , " The string ' " + str + " ' cannot be converted to a number " ) ; <nl> + } <nl> <nl> - std : : vector < std : : string > v = getVec < std : : string > ( keys ) ; <nl> + return getData < _Tp > ( str ) ; <nl> + } <nl> <nl> - std : : vector < _Tp > res ; <nl> - for ( size_t i = 0 ; i < v . size ( ) ; i + + ) <nl> - { <nl> - _Tp val = fromString < _Tp > ( v [ i ] ) ; <nl> - res . push_back ( val ) ; <nl> - } <nl> - return res ; <nl> - } <nl> + } ; <nl> <nl> - template < > CV_EXPORTS <nl> - std : : string CommandLineParser : : fromString < std : : string > ( const std : : string & str ) ; <nl> + template < > CV_EXPORTS <nl> + std : : string CommandLineParser : : analizeValue < std : : string > ( const std : : string & str ) ; <nl> <nl> - template < > CV_EXPORTS <nl> - int CommandLineParser : : fromString < int > ( const std : : string & str ) ; <nl> + template < > CV_EXPORTS <nl> + int CommandLineParser : : analizeValue < int > ( const std : : string & str ) ; <nl> <nl> - template < > CV_EXPORTS <nl> - unsigned int CommandLineParser : : fromString < unsigned int > ( const std : : string & str ) ; <nl> + template < > CV_EXPORTS <nl> + unsigned CommandLineParser : : analizeValue < unsigned int > ( const std : : string & str ) ; <nl> <nl> - template < > CV_EXPORTS <nl> - double CommandLineParser : : fromString < double > ( const std : : string & str ) ; <nl> + template < > CV_EXPORTS <nl> + float CommandLineParser : : analizeValue < float > ( const std : : string & str ) ; <nl> <nl> - template < > CV_EXPORTS <nl> - cv : : Size CommandLineParser : : fromStringsVec < cv : : Size > ( const std : : vector < std : : string > & str ) ; <nl> + template < > CV_EXPORTS <nl> + double CommandLineParser : : analizeValue < double > ( const std : : string & str ) ; <nl> <nl> } <nl> <nl> mmm a / modules / core / src / cmdparser . cpp <nl> ppp b / modules / core / src / cmdparser . cpp <nl> void PreprocessArgs ( int _argc , const char * _argv [ ] , int & argc , char * * & argv ) <nl> find_symbol = buffer_string . find ( ' = ' ) ; <nl> if ( find_symbol = = - 1 ) <nl> buffer_vector . push_back ( buffer_string ) ; <nl> - else if ( find_symbol = = 0 | | find_symbol = = ( ( int ) buffer_string . length ( ) - 1 ) ) <nl> + else if ( find_symbol = = 0 | | find_symbol = = ( buffer_string . length ( ) - 1 ) ) <nl> { <nl> buffer_string . erase ( find_symbol , ( find_symbol + 1 ) ) ; <nl> if ( ! buffer_string . empty ( ) ) <nl> void PreprocessArgs ( int _argc , const char * _argv [ ] , int & argc , char * * & argv ) <nl> buffer_vector . push_back ( buffer_string ) ; <nl> buffer2_string . erase ( 0 , find_symbol + 1 ) ; <nl> buffer_vector . push_back ( buffer2_string ) ; <nl> + <nl> } <nl> } <nl> <nl> void PreprocessArgs ( int _argc , const char * _argv [ ] , int & argc , char * * & argv ) <nl> } <nl> } <nl> <nl> + <nl> CommandLineParser : : CommandLineParser ( int _argc , const char * _argv [ ] ) <nl> { <nl> std : : string cur_name ; <nl> bool was_pushed = false ; <nl> int argc ; <nl> char * * argv ; <nl> - <nl> PreprocessArgs ( _argc , _argv , argc , argv ) ; <nl> <nl> - for ( int i = 1 ; i < argc ; i + + ) <nl> - { <nl> - if ( ! argv [ i ] ) <nl> - break ; <nl> - <nl> - if ( ( argv [ i ] [ 0 ] = = ' - ' ) & & ( strlen ( argv [ i ] ) > 1 ) & & <nl> - ( ( argv [ i ] [ 1 ] < ' 0 ' ) | | ( argv [ i ] [ 1 ] > ' 9 ' ) ) ) <nl> - { <nl> - if ( ! cur_name . empty ( ) & & ! was_pushed ) <nl> - { <nl> - data [ cur_name ] . push_back ( " " ) ; <nl> - } <nl> - <nl> - cur_name = argv [ i ] ; <nl> - <nl> - while ( cur_name . find ( ' - ' ) = = 0 ) <nl> - { <nl> - cur_name . erase ( 0 , 1 ) ; <nl> - } <nl> + for ( int i = 1 ; i < argc ; i + + ) { <nl> <nl> - was_pushed = false ; <nl> + if ( ! argv [ i ] ) <nl> + break ; <nl> <nl> - if ( data . find ( cur_name ) ! = data . end ( ) ) <nl> + if ( ( argv [ i ] [ 0 ] = = ' - ' ) & & ( strlen ( argv [ i ] ) > 1 ) <nl> + & & <nl> + ( ( argv [ i ] [ 1 ] < ' 0 ' ) | | ( argv [ i ] [ 1 ] > ' 9 ' ) ) ) <nl> { <nl> - string str_exception = " dublicating parameters for name = ' " + cur_name + " ' " ; <nl> - CV_Error ( CV_StsParseError , str_exception ) ; <nl> + if ( ! cur_name . empty ( ) & & ! was_pushed ) { <nl> + data [ cur_name ] . push_back ( " " ) ; <nl> + } <nl> + cur_name = argv [ i ] ; <nl> + while ( cur_name . find ( ' - ' ) = = 0 ) <nl> + { <nl> + cur_name . erase ( 0 , 1 ) ; <nl> + } <nl> + was_pushed = false ; <nl> + <nl> + if ( data . find ( cur_name ) ! = data . end ( ) ) { <nl> + string str_exception = " dublicating parameters for name = ' " + cur_name + " ' " ; <nl> + CV_Error ( CV_StsParseError , str_exception ) ; <nl> + } <nl> + continue ; <nl> } <nl> - continue ; <nl> - } <nl> <nl> - data [ cur_name ] . push_back ( argv [ i ] ) ; <nl> - was_pushed = true ; <nl> + data [ cur_name ] . push_back ( argv [ i ] ) ; <nl> + was_pushed = true ; <nl> } <nl> if ( ! cur_name . empty ( ) & & ! was_pushed ) <nl> - data [ cur_name ] . push_back ( " " ) ; <nl> + data [ cur_name ] . push_back ( " " ) ; <nl> } <nl> <nl> bool CommandLineParser : : has ( const std : : string & keys ) const <nl> { <nl> vector < string > names = split_string ( keys , " | " ) ; <nl> - for ( size_t j = 0 ; j < names . size ( ) ; j + + ) <nl> - { <nl> + for ( size_t j = 0 ; j < names . size ( ) ; j + + ) { <nl> if ( data . find ( names [ j ] ) ! = data . end ( ) ) <nl> return true ; <nl> } <nl> return false ; <nl> } <nl> <nl> - template < > <nl> - std : : vector < std : : string > CommandLineParser : : getVec < std : : string > ( const std : : string & keys ) <nl> + std : : string CommandLineParser : : getString ( const std : : string & keys ) const <nl> { <nl> vector < string > names = split_string ( keys , " | " ) ; <nl> <nl> int found_index = - 1 ; <nl> - for ( size_t j = 0 ; j < names . size ( ) ; j + + ) <nl> - { <nl> + for ( size_t j = 0 ; j < names . size ( ) ; j + + ) { <nl> const string & cur_name = names [ j ] ; <nl> bool is_cur_found = has ( cur_name ) ; <nl> <nl> - if ( is_cur_found & & ( found_index > = 0 ) ) <nl> - { <nl> - string str_exception = " dublicating parameters for " <nl> - " name = ' " + names [ found_index ] + " ' and name = ' " + cur_name + " ' " ; <nl> + if ( is_cur_found & & ( found_index > = 0 ) ) { <nl> + string str_exception = " dublicating parameters for " <nl> + " name = ' " + names [ found_index ] + " ' and name = ' " + cur_name + " ' " ; <nl> CV_Error ( CV_StsParseError , str_exception ) ; <nl> } <nl> <nl> std : : vector < std : : string > CommandLineParser : : getVec < std : : string > ( const std : : strin <nl> } <nl> <nl> if ( found_index < 0 ) <nl> - return vector < string > ( ) ; <nl> - <nl> - return data . find ( names [ found_index ] ) - > second ; <nl> + return string ( ) ; <nl> + return data . find ( names [ found_index ] ) - > second [ 0 ] ; <nl> } <nl> <nl> + <nl> template < > <nl> - std : : string CommandLineParser : : fromString < std : : string > ( const std : : string & str ) <nl> + std : : string CommandLineParser : : analizeValue < std : : string > ( const std : : string & str ) <nl> { <nl> return str ; <nl> } <nl> <nl> template < > <nl> - int CommandLineParser : : fromString < int > ( const std : : string & str ) <nl> + int CommandLineParser : : analizeValue < int > ( const std : : string & str ) <nl> { <nl> return fromStringNumber < int > ( str ) ; <nl> } <nl> <nl> template < > <nl> - unsigned int CommandLineParser : : fromString < unsigned int > ( const std : : string & str ) <nl> + unsigned int CommandLineParser : : analizeValue < unsigned int > ( const std : : string & str ) <nl> { <nl> return fromStringNumber < unsigned int > ( str ) ; <nl> } <nl> <nl> template < > <nl> - double CommandLineParser : : fromString < double > ( const std : : string & str ) <nl> + float CommandLineParser : : analizeValue < float > ( const std : : string & str ) <nl> { <nl> - return fromStringNumber < double > ( str ) ; <nl> + return fromStringNumber < float > ( str ) ; <nl> } <nl> <nl> template < > <nl> - cv : : Size CommandLineParser : : fromStringsVec < cv : : Size > ( const std : : vector < std : : string > & vec_str ) <nl> + double CommandLineParser : : analizeValue < double > ( const std : : string & str ) <nl> { <nl> - if ( vec_str . size ( ) < 2 ) <nl> - CV_Error ( CV_StsParseError , " Cannot convert vector of string to cv : : Size : less than two strings " ) ; <nl> - <nl> - cv : : Size res ; <nl> - res . width = fromString < int > ( vec_str [ 0 ] ) ; <nl> - res . height = fromString < int > ( vec_str [ 1 ] ) ; <nl> - <nl> - return res ; <nl> + return fromStringNumber < double > ( str ) ; <nl> } <nl> <nl> | Update CommandLineParser class | opencv/opencv | fe279279e65adc7209011479f9daf1c5a8b7565a | 2011-05-28T06:55:41Z |
mmm a / setup . py <nl> ppp b / setup . py <nl> def check_file ( f ) : <nl> " torch / csrc / utils / invalid_arguments . cpp " , <nl> " torch / csrc / utils / object_ptr . cpp " , <nl> " torch / csrc / utils / python_arg_parser . cpp " , <nl> + " torch / csrc / utils / tensor_list . cpp " , <nl> " torch / csrc / utils / tuple_parser . cpp " , <nl> " torch / csrc / allocators . cpp " , <nl> " torch / csrc / serialization . cpp " , <nl> mmm a / tools / autograd / templates / python_variable_methods . cpp <nl> ppp b / tools / autograd / templates / python_variable_methods . cpp <nl> <nl> # include " torch / csrc / utils / python_arg_parser . h " <nl> # include " torch / csrc / utils / python_numbers . h " <nl> # include " torch / csrc / utils / python_tuples . h " <nl> + # include " torch / csrc / utils / tensor_list . h " <nl> <nl> # include " python_variable_methods_dispatch . h " <nl> <nl> static PyObject * THPVariable_storage_type ( PyObject * self , PyObject * arg ) <nl> END_HANDLE_TH_ERRORS <nl> } <nl> <nl> + static PyObject * THPVariable_tolist ( PyObject * self , PyObject * args ) <nl> + { <nl> + HANDLE_TH_ERRORS <nl> + auto self_ = reinterpret_cast < THPVariable * > ( self ) - > cdata ; <nl> + return THPUtils_tensorToList ( self_ . data ( ) ) ; <nl> + END_HANDLE_TH_ERRORS <nl> + } <nl> + <nl> / / generated methods start here <nl> <nl> $ { py_methods } <nl> PyMethodDef variable_methods [ ] = { <nl> { " storage " , ( PyCFunction ) THPVariable_storage , METH_NOARGS , NULL } , <nl> { " storage_type " , ( PyCFunction ) THPVariable_storage_type , METH_NOARGS , NULL } , <nl> { " stride " , ( PyCFunction ) THPVariable_stride , METH_VARARGS | METH_KEYWORDS , NULL } , <nl> + { " tolist " , ( PyCFunction ) THPVariable_tolist , METH_NOARGS , NULL } , <nl> $ { py_method_defs } <nl> { NULL } <nl> } ; <nl> mmm a / torch / csrc / utils / python_numbers . h <nl> ppp b / torch / csrc / utils / python_numbers . h <nl> <nl> <nl> # include < Python . h > <nl> # include < stdint . h > <nl> + # include < stdexcept > <nl> <nl> / / largest integer that can be represented consecutively in a double <nl> const int64_t DOUBLE_INT_MAX = 9007199254740992 ; <nl> <nl> inline PyObject * THPUtils_packInt64 ( int64_t value ) { <nl> # if PY_MAJOR_VERSION = = 2 <nl> - if ( value < = INT32_MAX & & value > = INT32_MIN ) { <nl> + if ( sizeof ( long ) = = sizeof ( int64_t ) ) { <nl> + return PyInt_FromLong ( static_cast < long > ( value ) ) ; <nl> + } else if ( value < = INT32_MAX & & value > = INT32_MIN ) { <nl> return PyInt_FromLong ( static_cast < long > ( value ) ) ; <nl> } <nl> # endif <nl> new file mode 100644 <nl> index 000000000000 . . a61097270f9e <nl> mmm / dev / null <nl> ppp b / torch / csrc / utils / tensor_list . cpp <nl> <nl> + # include " tensor_list . h " <nl> + <nl> + # include " torch / csrc / Exceptions . h " <nl> + # include " torch / csrc / utils / auto_gil . h " <nl> + # include " torch / csrc / utils / python_numbers . h " <nl> + <nl> + using namespace at ; <nl> + <nl> + namespace torch { <nl> + <nl> + static PyObject * toList ( char * data , IntList sizes , IntList strides , int64_t dim , <nl> + ScalarType scalarType , int64_t elementSize ) <nl> + { <nl> + int64_t ndim = sizes . size ( ) ; <nl> + if ( dim = = ndim ) { <nl> + switch ( scalarType ) { <nl> + case kByte : return THPUtils_packInt64 ( * ( uint8_t * ) data ) ; <nl> + case kChar : return THPUtils_packInt64 ( * ( char * ) data ) ; <nl> + case kShort : return THPUtils_packInt64 ( * ( int16_t * ) data ) ; <nl> + case kInt : return THPUtils_packInt64 ( * ( int32_t * ) data ) ; <nl> + case kLong : return THPUtils_packInt64 ( * ( int64_t * ) data ) ; <nl> + case kHalf : return PyFloat_FromDouble ( at : : convert < double , Half > ( * ( at : : Half * ) data ) ) ; <nl> + case kFloat : return PyFloat_FromDouble ( * ( float * ) data ) ; <nl> + case kDouble : return PyFloat_FromDouble ( * ( double * ) data ) ; <nl> + default : throw std : : runtime_error ( " invalid type " ) ; <nl> + } <nl> + } <nl> + auto n = sizes [ dim ] ; <nl> + auto list = THPObjectPtr ( PyList_New ( n ) ) ; <nl> + if ( ! list ) throw python_error ( ) ; <nl> + for ( int64_t i = 0 ; i < n ; i + + ) { <nl> + PyObject * obj = toList ( data , sizes , strides , dim + 1 , scalarType , elementSize ) ; <nl> + if ( ! obj ) throw python_error ( ) ; <nl> + PyList_SET_ITEM ( list . get ( ) , i , obj ) ; <nl> + data + = strides [ dim ] * elementSize ; <nl> + } <nl> + return list . release ( ) ; <nl> + } <nl> + <nl> + PyObject * THPUtils_tensorToList ( const Tensor & tensor ) { <nl> + Tensor data = tensor ; <nl> + if ( data . type ( ) . backend ( ) ! = kCPU ) { <nl> + with_no_gil ( [ & ] ( ) { <nl> + data = data . toBackend ( kCPU ) ; <nl> + } ) ; <nl> + } <nl> + auto & type = data . type ( ) ; <nl> + return toList ( <nl> + ( char * ) data . data_ptr ( ) , data . sizes ( ) , data . strides ( ) , 0 , <nl> + type . scalarType ( ) , type . elementSizeInBytes ( ) ) ; <nl> + } <nl> + <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 7296aac999c3 <nl> mmm / dev / null <nl> ppp b / torch / csrc / utils / tensor_list . h <nl> <nl> + # pragma once <nl> + <nl> + # include < ATen / ATen . h > <nl> + # include < Python . h > <nl> + <nl> + namespace torch { <nl> + <nl> + PyObject * THPUtils_tensorToList ( const at : : Tensor & tensor ) ; <nl> + <nl> + } <nl> mmm a / torch / tensor . py <nl> ppp b / torch / tensor . py <nl> def matmul ( self , other ) : <nl> <nl> def tolist ( self ) : <nl> r " " " Returns a nested list represenation of this tensor . " " " <nl> - dim = self . dim ( ) <nl> - if dim = = 1 : <nl> - return [ v for v in self ] <nl> - elif dim > 0 : <nl> - return [ subt . tolist ( ) for subt in self ] <nl> - return [ ] <nl> + return torch . autograd . Variable ( self ) . tolist ( ) <nl> <nl> def view_as ( self , tensor ) : <nl> r " " " Returns this tensor viewed as the size as the specified tensor . <nl> | Implement Variable . tolist ( ) ( ) | pytorch/pytorch | 38f13447bce8b7dfe925664c2ef7e42659551cb4 | 2017-12-06T17:35:05Z |
mmm a / xbmc / music / MusicDatabase . cpp <nl> ppp b / xbmc / music / MusicDatabase . cpp <nl> bool CMusicDatabase : : GetAlbumsByWhere ( const CStdString & baseDir , const CStdStrin <nl> int idAlbum = m_pDS - > fv ( " idAlbum " ) . get_asInt ( ) ; <nl> strDir . Format ( " % s % ld / " , baseDir . c_str ( ) , idAlbum ) ; <nl> CFileItemPtr pItem ( new CFileItem ( strDir , GetAlbumFromDataset ( m_pDS . get ( ) ) ) ) ; <nl> + pItem - > SetIconImage ( " DefaultAlbumCover . png " ) ; <nl> items . Add ( pItem ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> | added : set Music Album fallback icon to " DefaultAlbumCover . png " | xbmc/xbmc | 0bbfe03c92d1405bf6af12408b08b1008435b796 | 2011-07-16T23:36:02Z |
mmm a / jstests / noPassthrough / libs / index_build . js <nl> ppp b / jstests / noPassthrough / libs / index_build . js <nl> const ResumableIndexBuildTest = class { <nl> / / Ensure that the resumable index build failed as expected . <nl> if ( failWhileParsing ) { <nl> assert ( RegExp ( " 4916300 . * " ) . test ( rawMongoProgramOutput ( ) ) ) ; <nl> + assert ( RegExp ( " 22257 . * " ) . test ( rawMongoProgramOutput ( ) ) ) ; <nl> } else { <nl> assert ( RegExp ( " 4841701 . * " + buildUUID ) . test ( rawMongoProgramOutput ( ) ) ) ; <nl> } <nl> const ResumableIndexBuildTest = class { <nl> <nl> ResumableIndexBuildTest . checkIndexes ( <nl> rst , dbName , collName , indexName , postIndexBuildInserts ) ; <nl> + <nl> + / / If we fail after parsing , any remaining internal idents will only be cleaned up after <nl> + / / another restart . <nl> + if ( ! failWhileParsing ) { <nl> + clearRawMongoProgramOutput ( ) ; <nl> + rst . stop ( primary ) ; <nl> + rst . start ( primary , { noCleanData : true } ) ; <nl> + assert ( RegExp ( " 22257 . * " ) . test ( rawMongoProgramOutput ( ) ) ) ; <nl> + } <nl> } <nl> } ; <nl> mmm a / jstests / noPassthrough / restart_index_build_if_resume_fails . js <nl> ppp b / jstests / noPassthrough / restart_index_build_if_resume_fails . js <nl> ResumableIndexBuildTest . runFailToResume ( rst , <nl> [ { a : 2 } , { a : 3 } ] , <nl> [ { a : 4 } , { a : 5 } ] , <nl> true / * failWhileParsing * / ) ; <nl> - assert . commandWorked ( <nl> - primary . adminCommand ( { configureFailPoint : ' failToParseResumeIndexInfo ' , mode : ' off ' } ) ) ; <nl> <nl> ResumableIndexBuildTest . runFailToResume ( <nl> rst , dbName , collName , { a : 1 } , " failSetUpResumeIndexBuild " , [ { a : 6 } , { a : 7 } ] , [ { a : 8 } , { a : 9 } ] ) ; <nl> mmm a / src / mongo / db / storage / storage_engine_impl . cpp <nl> ppp b / src / mongo / db / storage / storage_engine_impl . cpp <nl> bool StorageEngineImpl : : _handleInternalIdents ( <nl> const std : : string & ident , <nl> InternalIdentReconcilePolicy internalIdentReconcilePolicy , <nl> ReconcileResult * reconcileResult , <nl> - std : : set < std : : string > * internalIdentsToDrop ) { <nl> + std : : set < std : : string > * internalIdentsToDrop , <nl> + std : : set < std : : string > * allInternalIdents ) { <nl> if ( ! _catalog - > isInternalIdent ( ident ) ) { <nl> return false ; <nl> } <nl> <nl> + allInternalIdents - > insert ( ident ) ; <nl> + <nl> if ( InternalIdentReconcilePolicy : : kDrop = = internalIdentReconcilePolicy | | <nl> ! supportsResumableIndexBuilds ( ) ) { <nl> internalIdentsToDrop - > insert ( ident ) ; <nl> bool StorageEngineImpl : : _handleInternalIdents ( <nl> reconcileResult - > indexBuildsToResume . push_back ( resumeInfo ) ; <nl> <nl> / / Once we have parsed the resume info , we can safely drop the internal ident . <nl> - / / TODO SERVER - 49846 : revisit this logic since this could cause the side tables <nl> - / / associated with the index build to be orphaned if resuming fails . <nl> internalIdentsToDrop - > insert ( ident ) ; <nl> <nl> LOGV2 ( 4916301 , <nl> StatusWith < StorageEngine : : ReconcileResult > StorageEngineImpl : : reconcileCatalogAn <nl> catalogIdents . insert ( vec . begin ( ) , vec . end ( ) ) ; <nl> } <nl> std : : set < std : : string > internalIdentsToDrop ; <nl> + std : : set < std : : string > allInternalIdents ; <nl> <nl> auto dropPendingIdents = _dropPendingIdentReaper . getAllIdentNames ( ) ; <nl> <nl> StatusWith < StorageEngine : : ReconcileResult > StorageEngineImpl : : reconcileCatalogAn <nl> continue ; <nl> } <nl> <nl> - if ( _handleInternalIdents ( <nl> - opCtx , it , internalIdentReconcilePolicy , & reconcileResult , & internalIdentsToDrop ) ) { <nl> + if ( _handleInternalIdents ( opCtx , <nl> + it , <nl> + internalIdentReconcilePolicy , <nl> + & reconcileResult , <nl> + & internalIdentsToDrop , <nl> + & allInternalIdents ) ) { <nl> continue ; <nl> } <nl> <nl> StatusWith < StorageEngine : : ReconcileResult > StorageEngineImpl : : reconcileCatalogAn <nl> } <nl> } <nl> <nl> + / / If there are no index builds to resume , we should drop all internal idents . <nl> + if ( reconcileResult . indexBuildsToResume . empty ( ) ) { <nl> + internalIdentsToDrop . swap ( allInternalIdents ) ; <nl> + } <nl> + <nl> for ( auto & & temp : internalIdentsToDrop ) { <nl> LOGV2 ( 22257 , " Dropping internal ident " , " ident " _attr = temp ) ; <nl> WriteUnitOfWork wuow ( opCtx ) ; <nl> mmm a / src / mongo / db / storage / storage_engine_impl . h <nl> ppp b / src / mongo / db / storage / storage_engine_impl . h <nl> class StorageEngineImpl final : public StorageEngineInterface , public StorageEng <nl> const std : : string & ident , <nl> InternalIdentReconcilePolicy internalIdentReconcilePolicy , <nl> ReconcileResult * reconcileResult , <nl> - std : : set < std : : string > * internalIdentsToDrop ) ; <nl> + std : : set < std : : string > * internalIdentsToDrop , <nl> + std : : set < std : : string > * allInternalIdents ) ; <nl> <nl> class RemoveDBChange ; <nl> <nl> | SERVER - 49846 Drop internal idents on startup if there are no index builds to resume | mongodb/mongo | 4f3f3a43ec61ef103ce4503e1de78e8906cab805 | 2020-08-21T15:38:17Z |
mmm a / util / sock . cpp <nl> ppp b / util / sock . cpp <nl> namespace mongo { <nl> return _instance ; <nl> } <nl> <nl> + <nl> + string getHostNameCached ( ) { <nl> + static string host ; <nl> + if ( host . empty ( ) ) { <nl> + string s = getHostName ( ) ; <nl> + host = s ; <nl> + } <nl> + return host ; <nl> + } <nl> + <nl> } / / namespace mongo <nl> mmm a / util / sock . h <nl> ppp b / util / sock . h <nl> namespace mongo { <nl> return buf ; <nl> } <nl> <nl> + string getHostNameCached ( ) ; <nl> + <nl> class ListeningSockets { <nl> public : <nl> ListeningSockets ( ) : _mutex ( " ListeningSockets " ) , _sockets ( new set < int > ( ) ) { <nl> | added string getHostNameCached ( ) ; | mongodb/mongo | 8ec52793532033d3722cb934ad31a05aaa23871c | 2010-07-13T04:55:22Z |
mmm a / buildscripts / resmokeconfig / suites / sharding_last_stable_mongos_and_mixed_shards . yml <nl> ppp b / buildscripts / resmokeconfig / suites / sharding_last_stable_mongos_and_mixed_shards . yml <nl> selector : <nl> - jstests / sharding / upsert_sharded . js <nl> - jstests / sharding / write_transactions_during_migration . js <nl> - jstests / sharding / change_stream_show_migration_events . js <nl> + - jstests / sharding / features3 . js <nl> - jstests / sharding / prepare_transaction_then_migrate . js <nl> # Enable after SERVER - 40258 gets backported and available in the official 4 . 2 binaries . <nl> - jstests / sharding / prepared_txn_metadata_refresh . js <nl> mmm a / jstests / core / apitest_dbcollection . js <nl> ppp b / jstests / core / apitest_dbcollection . js <nl> assert . eq ( 0 , db . getCollection ( " test_db " ) . getIndexes ( ) . length , " 24 " ) ; <nl> assert . eq ( 0 , noCollStats . nindexes , " All properties should be 0 on nonexistant collections " ) ; <nl> assert . eq ( <nl> 0 , noCollStats . totalIndexSize , " All properties should be 0 on nonexistant collections " ) ; <nl> + assert . eq ( 0 , noCollStats . totalSize , " All properties should be 0 on nonexistant collections " ) ; <nl> <nl> / / scale - passed to stats ( ) as sole numerical argument or part of an options object . <nl> t . drop ( ) ; <nl> mmm a / jstests / core / collection_truncate . js <nl> ppp b / jstests / core / collection_truncate . js <nl> function assertEmpty ( ) { <nl> assert . eq ( stats . count , 0 ) ; <nl> assert . eq ( stats . size , 0 ) ; <nl> <nl> - if ( ' numExtents ' in stats ) { <nl> - assert . lte ( stats . numExtents , 1 ) ; <nl> - } <nl> - <nl> assert . eq ( t . count ( ) , 0 ) ; <nl> assert . eq ( t . find ( ) . itcount ( ) , 0 ) ; <nl> <nl> mmm a / jstests / core / dbstats . js <nl> ppp b / jstests / core / dbstats . js <nl> <nl> } <nl> <nl> assert ( dbStats . hasOwnProperty ( " storageSize " ) , tojson ( dbStats ) ) ; <nl> - assert ( dbStats . hasOwnProperty ( " numExtents " ) , tojson ( dbStats ) ) ; <nl> + assert ( dbStats . hasOwnProperty ( " totalSize " ) , tojson ( dbStats ) ) ; <nl> assert ( dbStats . hasOwnProperty ( " indexSize " ) , tojson ( dbStats ) ) ; <nl> <nl> if ( isUsingPersistentStorage ) { <nl> mmm a / jstests / sharding / features3 . js <nl> ppp b / jstests / sharding / features3 . js <nl> <nl> assert . eq ( numDocs / 2 , x . shards [ s . shard0 . shardName ] . count , " count on " + s . shard0 . shardName ) ; <nl> assert . eq ( numDocs / 2 , x . shards [ s . shard1 . shardName ] . count , " count on " + s . shard1 . shardName ) ; <nl> assert ( x . totalIndexSize > 0 ) ; <nl> + assert ( x . totalSize > 0 ) ; <nl> <nl> / / insert one doc into a non - sharded collection <nl> dbForTest . bar . insert ( { x : 1 } ) ; <nl> mmm a / jstests / sharding / stats . js <nl> ppp b / jstests / sharding / stats . js <nl> <nl> statComp ( stat_obj . size , stat_obj_scaled . size , scale ) ; <nl> statComp ( stat_obj . storageSize , stat_obj_scaled . storageSize , scale ) ; <nl> statComp ( stat_obj . totalIndexSize , stat_obj_scaled . totalIndexSize , scale ) ; <nl> + statComp ( stat_obj . totalSize , stat_obj_scaled . totalSize , scale ) ; <nl> statComp ( stat_obj . avgObjSize , stat_obj_scaled . avgObjSize , 1 ) ; <nl> / * lastExtentSize doesn ' t exist in mongos level collection stats * / <nl> if ( ! mongos ) { <nl> mmm a / src / mongo / db / catalog / database_impl . cpp <nl> ppp b / src / mongo / db / catalog / database_impl . cpp <nl> void DatabaseImpl : : getStats ( OperationContext * opCtx , BSONObjBuilder * output , dou <nl> long long objects = 0 ; <nl> long long size = 0 ; <nl> long long storageSize = 0 ; <nl> - long long numExtents = 0 ; <nl> long long indexes = 0 ; <nl> long long indexSize = 0 ; <nl> <nl> void DatabaseImpl : : getStats ( OperationContext * opCtx , BSONObjBuilder * output , dou <nl> <nl> BSONObjBuilder temp ; <nl> storageSize + = collection - > getRecordStore ( ) - > storageSize ( opCtx , & temp ) ; <nl> - numExtents + = temp . obj ( ) [ " numExtents " ] . numberInt ( ) ; / / XXX <nl> <nl> indexes + = collection - > getIndexCatalog ( ) - > numIndexesTotal ( opCtx ) ; <nl> indexSize + = collection - > getIndexSize ( opCtx ) ; <nl> void DatabaseImpl : : getStats ( OperationContext * opCtx , BSONObjBuilder * output , dou <nl> output - > append ( " avgObjSize " , objects = = 0 ? 0 : double ( size ) / double ( objects ) ) ; <nl> output - > appendNumber ( " dataSize " , size / scale ) ; <nl> output - > appendNumber ( " storageSize " , storageSize / scale ) ; <nl> - output - > appendNumber ( " numExtents " , numExtents ) ; <nl> output - > appendNumber ( " indexes " , indexes ) ; <nl> output - > appendNumber ( " indexSize " , indexSize / scale ) ; <nl> + output - > appendNumber ( " totalSize " , ( storageSize + indexSize ) / scale ) ; <nl> output - > appendNumber ( " scaleFactor " , scale ) ; <nl> <nl> if ( ! opCtx - > getServiceContext ( ) - > getStorageEngine ( ) - > isEphemeral ( ) ) { <nl> mmm a / src / mongo / db / commands / dbcommands . cpp <nl> ppp b / src / mongo / db / commands / dbcommands . cpp <nl> class DBStats : public ErrmsgCommandDeprecated { <nl> result . append ( " avgObjSize " , 0 ) ; <nl> result . appendNumber ( " dataSize " , 0 ) ; <nl> result . appendNumber ( " storageSize " , 0 ) ; <nl> - result . appendNumber ( " numExtents " , 0 ) ; <nl> + result . appendNumber ( " totalSize " , 0 ) ; <nl> result . appendNumber ( " indexes " , 0 ) ; <nl> result . appendNumber ( " indexSize " , 0 ) ; <nl> result . appendNumber ( " scaleFactor " , scale ) ; <nl> mmm a / src / mongo / db / stats / storage_stats . cpp <nl> ppp b / src / mongo / db / stats / storage_stats . cpp <nl> Status appendCollectionStorageStats ( OperationContext * opCtx , <nl> result - > appendNumber ( " size " , 0 ) ; <nl> result - > appendNumber ( " count " , 0 ) ; <nl> result - > appendNumber ( " storageSize " , 0 ) ; <nl> + result - > append ( " totalSize " , 0 ) ; <nl> result - > append ( " nindexes " , 0 ) ; <nl> result - > appendNumber ( " totalIndexSize " , 0 ) ; <nl> result - > append ( " indexDetails " , BSONObj ( ) ) ; <nl> Status appendCollectionStorageStats ( OperationContext * opCtx , <nl> result - > append ( " avgObjSize " , collection - > averageObjectSize ( opCtx ) ) ; <nl> <nl> RecordStore * recordStore = collection - > getRecordStore ( ) ; <nl> - result - > appendNumber ( <nl> - " storageSize " , <nl> - static_cast < long long > ( recordStore - > storageSize ( opCtx , result , verbose ? 1 : 0 ) ) / scale ) ; <nl> + auto storageSize = <nl> + static_cast < long long > ( recordStore - > storageSize ( opCtx , result , verbose ? 1 : 0 ) ) ; <nl> + result - > appendNumber ( " storageSize " , storageSize / scale ) ; <nl> <nl> recordStore - > appendCustomStats ( opCtx , result , scale ) ; <nl> <nl> Status appendCollectionStorageStats ( OperationContext * opCtx , <nl> long long indexSize = collection - > getIndexSize ( opCtx , & indexSizes , scale ) ; <nl> <nl> result - > appendNumber ( " totalIndexSize " , indexSize / scale ) ; <nl> + result - > appendNumber ( " totalSize " , ( storageSize + indexSize ) / scale ) ; <nl> result - > append ( " indexSizes " , indexSizes . obj ( ) ) ; <nl> result - > append ( " scaleFactor " , scale ) ; <nl> <nl> mmm a / src / mongo / s / commands / cluster_coll_stats_cmd . cpp <nl> ppp b / src / mongo / s / commands / cluster_coll_stats_cmd . cpp <nl> class CollectionStats : public BasicCommand { <nl> result . append ( e ) ; <nl> } else if ( fieldIsAnyOf ( <nl> fieldName , <nl> - { " count " , " size " , " storageSize " , " numExtents " , " totalIndexSize " } ) ) { <nl> + { " count " , " size " , " storageSize " , " totalIndexSize " , " totalSize " } ) ) { <nl> counts [ e . fieldName ( ) ] + = e . numberLong ( ) ; <nl> } else if ( fieldName = = " avgObjSize " ) { <nl> const auto shardAvgObjSize = e . numberLong ( ) ; <nl> mmm a / src / mongo / s / commands / cluster_db_stats_cmd . cpp <nl> ppp b / src / mongo / s / commands / cluster_db_stats_cmd . cpp <nl> void aggregateResults ( int scale , <nl> long long unscaledDataSize = 0 ; <nl> long long dataSize = 0 ; <nl> long long storageSize = 0 ; <nl> - long long numExtents = 0 ; <nl> + long long totalSize = 0 ; <nl> long long indexes = 0 ; <nl> long long indexSize = 0 ; <nl> long long fileSize = 0 ; <nl> void aggregateResults ( int scale , <nl> unscaledDataSize + = b [ " avgObjSize " ] . numberLong ( ) * b [ " objects " ] . numberLong ( ) ; <nl> dataSize + = b [ " dataSize " ] . numberLong ( ) ; <nl> storageSize + = b [ " storageSize " ] . numberLong ( ) ; <nl> - numExtents + = b [ " numExtents " ] . numberLong ( ) ; <nl> + totalSize + = b [ " totalSize " ] . numberLong ( ) ; <nl> indexes + = b [ " indexes " ] . numberLong ( ) ; <nl> indexSize + = b [ " indexSize " ] . numberLong ( ) ; <nl> fileSize + = b [ " fileSize " ] . numberLong ( ) ; <nl> void aggregateResults ( int scale , <nl> output . append ( " avgObjSize " , objects = = 0 ? 0 : double ( unscaledDataSize ) / double ( objects ) ) ; <nl> output . appendNumber ( " dataSize " , dataSize ) ; <nl> output . appendNumber ( " storageSize " , storageSize ) ; <nl> - output . appendNumber ( " numExtents " , numExtents ) ; <nl> + output . appendNumber ( " totalSize " , totalSize ) ; <nl> output . appendNumber ( " indexes " , indexes ) ; <nl> output . appendNumber ( " indexSize " , indexSize ) ; <nl> output . appendNumber ( " scaleFactor " , scale ) ; <nl> | SERVER - 16917 Add totalSize field to dbStats and collStats | mongodb/mongo | 47ee8f8cde1d1e116caf223458c15b4af10943d6 | 2019-06-28T18:38:04Z |
mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> int Heap : : GetMaximumFillToAlign ( AllocationAlignment alignment ) { <nl> return 0 ; <nl> } <nl> <nl> - <nl> + / / static <nl> int Heap : : GetFillToAlign ( Address address , AllocationAlignment alignment ) { <nl> if ( alignment = = kDoubleAligned & & ( address & kDoubleAlignmentMask ) ! = 0 ) <nl> return kTaggedSize ; <nl> size_t Heap : : GetCodeRangeReservedAreaSize ( ) { <nl> return kReservedCodeRangePages * MemoryAllocator : : GetCommitPageSize ( ) ; <nl> } <nl> <nl> - HeapObject Heap : : PrecedeWithFiller ( HeapObject object , int filler_size ) { <nl> - CreateFillerObjectAt ( object . address ( ) , filler_size , ClearRecordedSlots : : kNo ) ; <nl> + / / static <nl> + HeapObject Heap : : PrecedeWithFiller ( ReadOnlyRoots roots , HeapObject object , <nl> + int filler_size ) { <nl> + CreateFillerObjectAt ( roots , object . address ( ) , filler_size , <nl> + ClearFreedMemoryMode : : kDontClearFreedMemory ) ; <nl> return HeapObject : : FromAddress ( object . address ( ) + filler_size ) ; <nl> } <nl> <nl> - HeapObject Heap : : AlignWithFiller ( HeapObject object , int object_size , <nl> - int allocation_size , <nl> + / / static <nl> + HeapObject Heap : : AlignWithFiller ( ReadOnlyRoots roots , HeapObject object , <nl> + int object_size , int allocation_size , <nl> AllocationAlignment alignment ) { <nl> int filler_size = allocation_size - object_size ; <nl> DCHECK_LT ( 0 , filler_size ) ; <nl> int pre_filler = GetFillToAlign ( object . address ( ) , alignment ) ; <nl> if ( pre_filler ) { <nl> - object = PrecedeWithFiller ( object , pre_filler ) ; <nl> + object = PrecedeWithFiller ( roots , object , pre_filler ) ; <nl> filler_size - = pre_filler ; <nl> } <nl> if ( filler_size ) { <nl> - CreateFillerObjectAt ( object . address ( ) + object_size , filler_size , <nl> - ClearRecordedSlots : : kNo ) ; <nl> + CreateFillerObjectAt ( roots , object . address ( ) + object_size , filler_size , <nl> + ClearFreedMemoryMode : : kDontClearFreedMemory ) ; <nl> } <nl> return object ; <nl> } <nl> mmm a / src / heap / heap . h <nl> ppp b / src / heap / heap . h <nl> class Heap { <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> / / Creates a filler object and returns a heap object immediately after it . <nl> - V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT HeapObject <nl> - PrecedeWithFiller ( HeapObject object , int filler_size ) ; <nl> + V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT HeapObject <nl> + PrecedeWithFiller ( ReadOnlyRoots roots , HeapObject object , int filler_size ) ; <nl> <nl> / / Creates a filler object if needed for alignment and returns a heap object <nl> / / immediately after it . If any space is left after the returned object , <nl> / / another filler object is created so the over allocated memory is iterable . <nl> - V8_WARN_UNUSED_RESULT HeapObject <nl> - AlignWithFiller ( HeapObject object , int object_size , int allocation_size , <nl> - AllocationAlignment alignment ) ; <nl> + static V8_WARN_UNUSED_RESULT HeapObject <nl> + AlignWithFiller ( ReadOnlyRoots roots , HeapObject object , int object_size , <nl> + int allocation_size , AllocationAlignment alignment ) ; <nl> <nl> / / Allocate an external backing store with the given allocation callback . <nl> / / If the callback fails ( indicated by a nullptr result ) then this function <nl> mmm a / src / heap / spaces - inl . h <nl> ppp b / src / heap / spaces - inl . h <nl> AllocationResult LocalAllocationBuffer : : AllocateRawAligned ( <nl> <nl> allocation_info_ . set_top ( new_top ) ; <nl> if ( filler_size > 0 ) { <nl> - return heap_ - > PrecedeWithFiller ( HeapObject : : FromAddress ( current_top ) , <nl> - filler_size ) ; <nl> + return Heap : : PrecedeWithFiller ( ReadOnlyRoots ( heap_ ) , <nl> + HeapObject : : FromAddress ( current_top ) , <nl> + filler_size ) ; <nl> } <nl> <nl> return AllocationResult ( HeapObject : : FromAddress ( current_top ) ) ; <nl> HeapObject PagedSpace : : TryAllocateLinearlyAligned ( <nl> allocation_info_ . set_top ( new_top ) ; <nl> if ( filler_size > 0 ) { <nl> * size_in_bytes + = filler_size ; <nl> - return heap ( ) - > PrecedeWithFiller ( HeapObject : : FromAddress ( current_top ) , <nl> - filler_size ) ; <nl> + return Heap : : PrecedeWithFiller ( ReadOnlyRoots ( heap ( ) ) , <nl> + HeapObject : : FromAddress ( current_top ) , <nl> + filler_size ) ; <nl> } <nl> <nl> return HeapObject : : FromAddress ( current_top ) ; <nl> AllocationResult NewSpace : : AllocateRawAligned ( int size_in_bytes , <nl> DCHECK_SEMISPACE_ALLOCATION_INFO ( allocation_info_ , to_space_ ) ; <nl> <nl> if ( filler_size > 0 ) { <nl> - obj = heap ( ) - > PrecedeWithFiller ( obj , filler_size ) ; <nl> + obj = Heap : : PrecedeWithFiller ( ReadOnlyRoots ( heap ( ) ) , obj , filler_size ) ; <nl> } <nl> <nl> MSAN_ALLOCATED_UNINITIALIZED_MEMORY ( obj . address ( ) , size_in_bytes ) ; <nl> mmm a / src / snapshot / deserializer - allocator . cc <nl> ppp b / src / snapshot / deserializer - allocator . cc <nl> Address DeserializerAllocator : : Allocate ( SnapshotSpace space , int size ) { <nl> DCHECK ( ReadOnlyRoots ( heap_ ) . free_space_map ( ) . IsMap ( ) ) ; <nl> DCHECK ( ReadOnlyRoots ( heap_ ) . one_pointer_filler_map ( ) . IsMap ( ) ) ; <nl> DCHECK ( ReadOnlyRoots ( heap_ ) . two_pointer_filler_map ( ) . IsMap ( ) ) ; <nl> - obj = heap_ - > AlignWithFiller ( obj , size , reserved , next_alignment_ ) ; <nl> + obj = Heap : : AlignWithFiller ( ReadOnlyRoots ( heap_ ) , obj , size , reserved , <nl> + next_alignment_ ) ; <nl> address = obj . address ( ) ; <nl> next_alignment_ = kWordAligned ; <nl> return address ; <nl> | [ offthread ] Make Heap : : AlignWithFiller static | v8/v8 | bc2bc6bf7244e5bb49733810725e25f78687e5ba | 2020-05-06T12:38:31Z |
mmm a / xbmc / DateTime . cpp <nl> ppp b / xbmc / DateTime . cpp <nl> CStdString CDateTime : : GetAsDBDateTime ( ) const <nl> return date ; <nl> } <nl> <nl> + void CDateTime : : SetFromW3CDate ( const CStdString & dateTime ) <nl> + { <nl> + CStdString date , time , zone ; <nl> + <nl> + int posT = dateTime . Find ( " T " ) ; <nl> + if ( posT > = 0 ) <nl> + { <nl> + date = dateTime . Left ( posT ) ; <nl> + CStdString : : size_type posZ = dateTime . find_first_of ( " + - Z " , posT ) ; <nl> + if ( posZ = = CStdString : : npos ) <nl> + time = dateTime . Mid ( posT + 1 ) ; <nl> + else <nl> + { <nl> + time = dateTime . Mid ( posT + 1 , posZ - posT - 1 ) ; <nl> + zone = dateTime . Mid ( posZ ) ; <nl> + } <nl> + } <nl> + else <nl> + date = dateTime ; <nl> + <nl> + int year = 0 , month = 1 , day = 1 , hour = 0 , min = 0 , sec = 0 ; <nl> + <nl> + if ( date . size ( ) > = 4 ) <nl> + year = atoi ( date . Mid ( 0 , 4 ) . c_str ( ) ) ; <nl> + <nl> + if ( date . size ( ) > = 10 ) <nl> + { <nl> + month = atoi ( date . Mid ( 5 , 2 ) . c_str ( ) ) ; <nl> + day = atoi ( date . Mid ( 8 , 2 ) . c_str ( ) ) ; <nl> + } <nl> + <nl> + if ( time . length ( ) > = 5 ) <nl> + { <nl> + hour = atoi ( time . Mid ( 0 , 2 ) . c_str ( ) ) ; <nl> + min = atoi ( time . Mid ( 3 , 2 ) . c_str ( ) ) ; <nl> + } <nl> + <nl> + if ( time . length ( ) > = 8 ) <nl> + sec = atoi ( time . Mid ( 6 , 2 ) . c_str ( ) ) ; <nl> + <nl> + SetDateTime ( year , month , day , hour , min , sec ) ; <nl> + } <nl> + <nl> void CDateTime : : SetFromDBDateTime ( const CStdString & dateTime ) <nl> { <nl> / / assumes format YYYY - MM - DD HH : MM : SS <nl> mmm a / xbmc / DateTime . h <nl> ppp b / xbmc / DateTime . h <nl> class CDateTime : public IArchivable <nl> void SetTime ( int hour , int minute , int second ) ; <nl> void SetFromDBDate ( const CStdString & date ) ; <nl> void SetFromDBTime ( const CStdString & time ) ; <nl> + void SetFromW3CDate ( const CStdString & date ) ; <nl> <nl> / * ! \ brief set from a database datetime format YYYY - MM - DD HH : MM : SS <nl> \ sa GetAsDBDateTime ( ) <nl> | added : method to parse W3C date time string to CDateTime ( currently doesn ' t support timezone shift ) | xbmc/xbmc | e210dbcc3b04ed639c4bde0d2b3ffd85775453d2 | 2010-12-16T15:33:35Z |
mmm a / test / mjsunit / compiler / inline - construct . js <nl> ppp b / test / mjsunit / compiler / inline - construct . js <nl> <nl> <nl> / / Test inlining of constructor calls . <nl> <nl> - function TestInlinedConstructor ( closure ) { <nl> + function TestInlinedConstructor ( constructor , closure ) { <nl> var result ; <nl> var counter = { value : 0 } ; <nl> - result = closure ( 11 , 12 , counter ) ; <nl> + <nl> + result = closure ( constructor , 11 , 12 , counter ) ; <nl> assertEquals ( 23 , result ) ; <nl> assertEquals ( 1 , counter . value ) ; <nl> - result = closure ( 23 , 19 , counter ) ; <nl> + <nl> + result = closure ( constructor , 23 , 19 , counter ) ; <nl> assertEquals ( 42 , result ) ; <nl> assertEquals ( 2 , counter . value ) ; <nl> + <nl> % OptimizeFunctionOnNextCall ( closure ) ; <nl> - result = closure ( 1 , 42 , counter ) <nl> + result = closure ( constructor , 1 , 42 , counter ) ; <nl> assertEquals ( 43 , result ) ; <nl> assertEquals ( 3 , counter . value ) ; <nl> - result = closure ( " foo " , " bar " , counter ) <nl> + <nl> + result = closure ( constructor , " foo " , " bar " , counter ) ; <nl> assertEquals ( " foobar " , result ) <nl> assertEquals ( 4 , counter . value ) ; <nl> + <nl> + % DeoptimizeFunction ( closure ) ; <nl> + % ClearFunctionTypeFeedback ( closure ) ; <nl> } <nl> <nl> - function TestInAllContexts ( constructor ) { <nl> - function value_context ( a , b , counter ) { <nl> - var obj = new constructor ( a , b , counter ) ; <nl> - return obj . x ; <nl> - } <nl> - function test_context ( a , b , counter ) { <nl> - if ( ! new constructor ( a , b , counter ) ) { <nl> - assertUnreachable ( " should not happen " ) ; <nl> - } <nl> - return a + b ; <nl> - } <nl> - function effect_context ( a , b , counter ) { <nl> - new constructor ( a , b , counter ) ; <nl> - return a + b ; <nl> + function value_context ( constructor , a , b , counter ) { <nl> + var obj = new constructor ( a , b , counter ) ; <nl> + return obj . x ; <nl> + } <nl> + <nl> + function test_context ( constructor , a , b , counter ) { <nl> + if ( ! new constructor ( a , b , counter ) ) { <nl> + assertUnreachable ( " should not happen " ) ; <nl> } <nl> - TestInlinedConstructor ( value_context ) ; <nl> - TestInlinedConstructor ( test_context ) ; <nl> - TestInlinedConstructor ( effect_context ) ; <nl> - % DeoptimizeFunction ( value_context ) ; <nl> - % DeoptimizeFunction ( test_context ) ; <nl> - % DeoptimizeFunction ( effect_context ) ; <nl> - % ClearFunctionTypeFeedback ( value_context ) ; <nl> - % ClearFunctionTypeFeedback ( test_context ) ; <nl> - % ClearFunctionTypeFeedback ( effect_context ) ; <nl> + return a + b ; <nl> + } <nl> + <nl> + function effect_context ( constructor , a , b , counter ) { <nl> + new constructor ( a , b , counter ) ; <nl> + return a + b ; <nl> + } <nl> + <nl> + function TestInAllContexts ( constructor ) { <nl> + TestInlinedConstructor ( constructor , value_context ) ; <nl> + TestInlinedConstructor ( constructor , test_context ) ; <nl> + TestInlinedConstructor ( constructor , effect_context ) ; <nl> } <nl> <nl> <nl> TestInAllContexts ( c1 ) ; <nl> <nl> / / Test constructor returning an object in all contexts . <nl> function c2 ( a , b , counter ) { <nl> - var obj = new Object ( ) ; <nl> + var obj = { } ; <nl> obj . x = a + b ; <nl> counter . value + + ; <nl> return obj ; <nl> | Improved constructor inlining unit tests . | v8/v8 | 1ee6c0e30bc63995b50341e89552d9ae61cdc5b0 | 2012-08-15T09:39:13Z |
mmm a / src / flag - definitions . h <nl> ppp b / src / flag - definitions . h <nl> DEFINE_IMPLICATION ( es_staging , move_object_start ) <nl> " harmony restrictions on generator declarations " ) \ <nl> V ( harmony_tailcalls , " harmony tail calls " ) \ <nl> V ( harmony_trailing_commas , \ <nl> - " harmony trailing commas in function parameter lists " ) \ <nl> - V ( harmony_string_padding , " harmony String - padding methods " ) <nl> + " harmony trailing commas in function parameter lists " ) <nl> <nl> # ifdef V8_I18N_SUPPORT <nl> # define HARMONY_STAGED ( V ) \ <nl> DEFINE_IMPLICATION ( es_staging , move_object_start ) <nl> # endif <nl> <nl> / / Features that are shipping ( turned on by default , but internal flag remains ) . <nl> - # define HARMONY_SHIPPING_BASE ( V ) V ( harmony_async_await , " harmony async - await " ) <nl> + # define HARMONY_SHIPPING_BASE ( V ) \ <nl> + V ( harmony_async_await , " harmony async - await " ) \ <nl> + V ( harmony_string_padding , " harmony String - padding methods " ) <nl> <nl> # ifdef V8_I18N_SUPPORT <nl> # define HARMONY_SHIPPING ( V ) \ <nl> | Ship String . prototype . pad { Start , End } | v8/v8 | ba357cadf2b58abf312c16b754c8961fc0c3c0cd | 2016-12-20T23:12:26Z |
mmm a / atom / browser / native_window_views . cc <nl> ppp b / atom / browser / native_window_views . cc <nl> NativeWindowViews : : NativeWindowViews ( <nl> else <nl> last_window_state_ = ui : : SHOW_STATE_NORMAL ; <nl> <nl> + last_normal_size_ = gfx : : Size ( widget_size_ ) ; <nl> + <nl> if ( ! has_frame ( ) ) { <nl> / / Set Window style so that we get a minimize and maximize animation when <nl> / / frameless . <nl> void NativeWindowViews : : HandleSizeEvent ( WPARAM w_param , LPARAM l_param ) { <nl> NotifyWindowMinimize ( ) ; <nl> break ; <nl> case SIZE_RESTORED : <nl> - if ( last_window_state_ = = ui : : SHOW_STATE_NORMAL ) <nl> - return ; <nl> - <nl> - switch ( last_window_state_ ) { <nl> - case ui : : SHOW_STATE_MAXIMIZED : <nl> - last_window_state_ = ui : : SHOW_STATE_NORMAL ; <nl> - NotifyWindowUnmaximize ( ) ; <nl> - break ; <nl> - case ui : : SHOW_STATE_MINIMIZED : <nl> - if ( IsFullscreen ( ) ) { <nl> - last_window_state_ = ui : : SHOW_STATE_FULLSCREEN ; <nl> - NotifyWindowEnterFullScreen ( ) ; <nl> - } else { <nl> + if ( last_window_state_ = = ui : : SHOW_STATE_NORMAL ) { <nl> + / / Window was resized so we save it ' s new size . <nl> + last_normal_size_ = GetSize ( ) ; <nl> + } else { <nl> + switch ( last_window_state_ ) { <nl> + case ui : : SHOW_STATE_MAXIMIZED : <nl> last_window_state_ = ui : : SHOW_STATE_NORMAL ; <nl> - NotifyWindowRestore ( ) ; <nl> - } <nl> - break ; <nl> + <nl> + / / When the window is restored we resize it to the previous known <nl> + / / normal size . <nl> + NativeWindow : : SetSize ( last_normal_size_ ) ; <nl> + <nl> + NotifyWindowUnmaximize ( ) ; <nl> + break ; <nl> + case ui : : SHOW_STATE_MINIMIZED : <nl> + if ( IsFullscreen ( ) ) { <nl> + last_window_state_ = ui : : SHOW_STATE_FULLSCREEN ; <nl> + NotifyWindowEnterFullScreen ( ) ; <nl> + } else { <nl> + last_window_state_ = ui : : SHOW_STATE_NORMAL ; <nl> + <nl> + / / When the window is restored we resize it to the previous known <nl> + / / normal size . <nl> + NativeWindow : : SetSize ( last_normal_size_ ) ; <nl> + <nl> + NotifyWindowRestore ( ) ; <nl> + } <nl> + break ; <nl> + } <nl> } <nl> break ; <nl> } <nl> mmm a / atom / browser / native_window_views . h <nl> ppp b / atom / browser / native_window_views . h <nl> class NativeWindowViews : public NativeWindow , <nl> <nl> ui : : WindowShowState last_window_state_ ; <nl> <nl> + / / There ' s an issue with restore on Windows , that sometimes causes the Window <nl> + / / to receive the wrong size ( # 2498 ) . To circumvent that , we keep tabs on the <nl> + / / size of the window while in the normal state ( not maximized , minimized or <nl> + / / fullscreen ) , so we restore it correctly . <nl> + gfx : : Size last_normal_size_ ; <nl> + <nl> / / In charge of running taskbar related APIs . <nl> TaskbarHost taskbar_host_ ; <nl> # endif <nl> | Fix restore / unmaximize wrong window size | electron/electron | 4d02fc58fa183c13273888cc30a874abaee52238 | 2015-10-05T00:29:02Z |
mmm a / tests / jenkins / run_test_installation_docs . sh <nl> ppp b / tests / jenkins / run_test_installation_docs . sh <nl> echo <nl> echo " # # # Testing Virtualenv # # # " <nl> echo " $ { virtualenv_commands } " <nl> echo <nl> - nvidia - docker run - - rm nvidia / cuda : 7 . 5 - cudnn5 - devel bash - c " $ { virtualenv_commands } " <nl> + nvidia - docker run - - rm nvidia / cuda : 9 . 0 - cudnn7 - devel bash - c " $ { virtualenv_commands } " <nl> <nl> echo <nl> echo " # # # Testing Pip # # # " <nl> echo " $ { pip_commands } " <nl> echo <nl> - nvidia - docker run - - rm nvidia / cuda : 7 . 5 - cudnn5 - devel bash - c " $ { pip_commands } " <nl> + nvidia - docker run - - rm nvidia / cuda : 9 . 0 - cudnn7 - devel bash - c " $ { pip_commands } " <nl> <nl> echo <nl> echo " # # # Testing Docker # # # " <nl> echo <nl> echo " # # # Testing Build From Source # # # " <nl> echo " $ { buildfromsource_commands } " <nl> echo <nl> - nvidia - docker run - - rm nvidia / cuda : 7 . 5 - cudnn5 - devel bash - c " $ { buildfromsource_commands } " <nl> + nvidia - docker run - - rm nvidia / cuda : 9 . 0 - cudnn7 - devel bash - c " $ { buildfromsource_commands } " <nl> | Change the cuda version for docs test script ( ) | apache/incubator-mxnet | 7d513dbde48c57ef336812454f3ae76f08fc00c9 | 2018-04-10T01:23:42Z |
mmm a / js / server / modules / org / arangodb / foxx / model . js <nl> ppp b / js / server / modules / org / arangodb / foxx / model . js <nl> _ . extend ( Model . prototype , { <nl> metadataSchema [ attributeName ] | | <nl> joi . forbidden ( ) <nl> ) , <nl> - result = schema . validate ( value ) ; <nl> + result = ( <nl> + schema . isJoi ? schema : joi . object ( ) . keys ( schema ) <nl> + ) . validate ( value ) ; <nl> <nl> if ( result . error ) { <nl> this . errors [ attributeName ] = result . error ; <nl> | Wrap non - Joi objects as Joi schemas . | arangodb/arangodb | 2747bf8b04b7fcb2a50eebaeb88944b12ee767b6 | 2014-10-21T15:20:34Z |
mmm a / xbmc / cores / AudioEngine / Engines / ActiveAE / ActiveAE . cpp <nl> ppp b / xbmc / cores / AudioEngine / Engines / ActiveAE / ActiveAE . cpp <nl> bool CActiveAE : : RunStages ( ) <nl> CSampleBuffer * buffer ; <nl> if ( ! ( * it ) - > m_drain ) <nl> { <nl> + float buftime = ( float ) ( * it ) - > m_inputBuffers - > m_format . m_frames / ( * it ) - > m_inputBuffers - > m_format . m_sampleRate ; <nl> + time + = buftime * ( * it ) - > m_processingSamples . size ( ) ; <nl> while ( time < MAX_CACHE_LEVEL & & ! ( * it ) - > m_inputBuffers - > m_freeSamples . empty ( ) ) <nl> { <nl> buffer = ( * it ) - > m_inputBuffers - > GetFreeBuffer ( ) ; <nl> ( * it ) - > m_processingSamples . push_back ( buffer ) ; <nl> ( * it ) - > m_streamPort - > SendInMessage ( CActiveAEDataProtocol : : STREAMBUFFER , & buffer , sizeof ( CSampleBuffer * ) ) ; <nl> ( * it ) - > IncFreeBuffers ( ) ; <nl> - time + = ( float ) buffer - > pkt - > max_nb_samples / buffer - > pkt - > config . sample_rate ; <nl> + time + = buftime ; <nl> } <nl> } <nl> else <nl> | Merge pull request from FernetMenta / aefixes | xbmc/xbmc | a7ba370af5a042b9fbbf217d155f5add7535e580 | 2014-05-31T21:30:53Z |
mmm a / scripting / javascript / bindings / generated <nl> ppp b / scripting / javascript / bindings / generated <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 2c645cce1bdd5b739a6ef1a9d6aa9b880e988afa <nl> + Subproject commit f85c95751a8a59846776789be30519e45b3911fd <nl> | Merge pull request from CocosRobot / updategeneratedsubmodule_1371352083 | cocos2d/cocos2d-x | b6f0c7e85bd0e2e2ca8c7ba4e9fcd13b2a8af841 | 2013-06-16T03:15:13Z |
mmm a / tests / test_main . cpp <nl> ppp b / tests / test_main . cpp <nl> <nl> # include " test_method_bind . h " <nl> # include " test_oa_hash_map . h " <nl> # include " test_ordered_hash_map . h " <nl> + # include " test_pck_packer . h " <nl> # include " test_physics_2d . h " <nl> # include " test_physics_3d . h " <nl> # include " test_render . h " <nl> new file mode 100644 <nl> index 00000000000 . . 17904d8d8a3 <nl> mmm / dev / null <nl> ppp b / tests / test_pck_packer . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * test_pck_packer . h * / <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * This file is part of : * / <nl> + / * GODOT ENGINE * / <nl> + / * https : / / godotengine . org * / <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + / * Copyright ( c ) 2007 - 2020 Juan Linietsky , Ariel Manzur . * / <nl> + / * Copyright ( c ) 2014 - 2020 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> + <nl> + # ifndef TEST_PCK_PACKER_H <nl> + # define TEST_PCK_PACKER_H <nl> + <nl> + # include " core / io / file_access_pack . h " <nl> + # include " core / io / pck_packer . h " <nl> + # include " core / os / os . h " <nl> + <nl> + # include " thirdparty / doctest / doctest . h " <nl> + <nl> + namespace TestPCKPacker { <nl> + <nl> + / / Dummy 64 - character encryption key ( since it ' s required ) . <nl> + constexpr const char * ENCRYPTION_KEY = " 0000000000000000000000000000000000000000000000000000000000000000 " ; <nl> + <nl> + TEST_CASE ( " [ PCKPacker ] Pack an empty PCK file " ) { <nl> + PCKPacker pck_packer ; <nl> + const String output_pck_path = OS : : get_singleton ( ) - > get_cache_path ( ) . plus_file ( " output_empty . pck " ) ; <nl> + CHECK_MESSAGE ( <nl> + pck_packer . pck_start ( <nl> + output_pck_path , <nl> + 32 , <nl> + ENCRYPTION_KEY ) = = OK , <nl> + " Starting a PCK file should return an OK error code . " ) ; <nl> + <nl> + CHECK_MESSAGE ( <nl> + pck_packer . flush ( ) = = OK , <nl> + " Flushing the PCK should return an OK error code . " ) ; <nl> + <nl> + Error err ; <nl> + FileAccessRef f = FileAccess : : open ( output_pck_path , FileAccess : : READ , & err ) ; <nl> + CHECK_MESSAGE ( <nl> + err = = OK , <nl> + " The generated empty PCK file should be opened successfully . " ) ; <nl> + CHECK_MESSAGE ( <nl> + f - > get_len ( ) > = 100 , <nl> + " The generated empty PCK file shouldn ' t be too small ( it should have the PCK header ) . " ) ; <nl> + CHECK_MESSAGE ( <nl> + f - > get_len ( ) < = 500 , <nl> + " The generated empty PCK file shouldn ' t be too large . " ) ; <nl> + } <nl> + <nl> + TEST_CASE ( " [ PCKPacker ] Pack a PCK file with some files and directories " ) { <nl> + PCKPacker pck_packer ; <nl> + const String output_pck_path = OS : : get_singleton ( ) - > get_cache_path ( ) . plus_file ( " output_with_files . pck " ) ; <nl> + CHECK_MESSAGE ( <nl> + pck_packer . pck_start ( <nl> + output_pck_path , <nl> + 32 , <nl> + ENCRYPTION_KEY ) = = OK , <nl> + " Starting a PCK file should return an OK error code . " ) ; <nl> + <nl> + const String base_dir = OS : : get_singleton ( ) - > get_executable_path ( ) . get_base_dir ( ) ; <nl> + <nl> + CHECK_MESSAGE ( <nl> + pck_packer . add_file ( " version . py " , base_dir . plus_file ( " . . / version . py " ) , " version . py " ) = = OK , <nl> + " Adding a file to the PCK should return an OK error code . " ) ; <nl> + CHECK_MESSAGE ( <nl> + pck_packer . add_file ( " some / directories with spaces / to / create / icon . png " , base_dir . plus_file ( " . . / icon . png " ) ) = = OK , <nl> + " Adding a file to a new subdirectory in the PCK should return an OK error code . " ) ; <nl> + CHECK_MESSAGE ( <nl> + pck_packer . add_file ( " some / directories with spaces / to / create / icon . svg " , base_dir . plus_file ( " . . / icon . svg " ) ) = = OK , <nl> + " Adding a file to an existing subdirectory in the PCK should return an OK error code . " ) ; <nl> + CHECK_MESSAGE ( <nl> + pck_packer . add_file ( " some / directories with spaces / to / create / icon . png " , base_dir . plus_file ( " . . / logo . png " ) ) = = OK , <nl> + " Overriding a non - flushed file to an existing subdirectory in the PCK should return an OK error code . " ) ; <nl> + CHECK_MESSAGE ( <nl> + pck_packer . flush ( ) = = OK , <nl> + " Flushing the PCK should return an OK error code . " ) ; <nl> + <nl> + Error err ; <nl> + FileAccessRef f = FileAccess : : open ( output_pck_path , FileAccess : : READ , & err ) ; <nl> + CHECK_MESSAGE ( <nl> + err = = OK , <nl> + " The generated non - empty PCK file should be opened successfully . " ) ; <nl> + CHECK_MESSAGE ( <nl> + f - > get_len ( ) > = 25000 , <nl> + " The generated non - empty PCK file should be large enough to actually hold the contents specified above . " ) ; <nl> + CHECK_MESSAGE ( <nl> + f - > get_len ( ) < = 35000 , <nl> + " The generated non - empty PCK file shouldn ' t be too large . " ) ; <nl> + } <nl> + <nl> + } / / namespace TestPCKPacker <nl> + <nl> + # endif / / TEST_PCK_PACKER_H <nl> | Add a test suite for PCKPacker | godotengine/godot | 9574a834e513959ae8021d458d3a0427e7266219 | 2020-11-15T19:05:46Z |
mmm a / tools / autograd / gen_python_functions . py <nl> ppp b / tools / autograd / gen_python_functions . py <nl> <nl> # These functions require manual Python bindings or are not exposed to Python <nl> SKIP_PYTHON_BINDINGS = [ <nl> ' alias ' , ' contiguous ' , ' clamp . * ' , ' is_cuda ' , ' is_sparse ' , ' size ' , ' stride ' , <nl> - ' . * _backward ' , ' . * _backward_out ' , ' . * _forward ' , ' . * _forward_out ' , <nl> - ' sparse_raw_resize_ ' , ' _unsafe_view ' , ' tensor ' , ' sparse_coo_tensor ' , <nl> - ' _arange . * ' , ' _range . * ' , ' _linspace . * ' , ' _logspace . * ' , ' _indexCopy_ ' , <nl> + ' . * _backward ' , ' . * _backward_ ( out | input | weight | bias ) ' , ' . * _forward ' , <nl> + ' . * _forward_out ' , ' sparse_raw_resize_ ' , ' _unsafe_view ' , ' tensor ' , <nl> + ' sparse_coo_tensor ' , ' _arange . * ' , ' _range . * ' , ' _linspace . * ' , ' _logspace . * ' , <nl> + ' _indexCopy_ ' , <nl> ] <nl> <nl> PY_VARIABLE_METHODS_CPP = CodeTemplate . from_file ( template_path + ' / python_variable_methods . cpp ' ) <nl> | avoid generating torch . * _backward_ ( input | weight | bias ) ( ) | pytorch/pytorch | d2c0f8bb57dcc39b158b09179935fae5c9192ce5 | 2018-03-30T19:23:56Z |
mmm a / hphp / runtime / base / type - structure - helpers . cpp <nl> ppp b / hphp / runtime / base / type - structure - helpers . cpp <nl> <nl> # include " hphp / runtime / base / unit - cache . h " <nl> <nl> # include " hphp / runtime / vm / bytecode . h " <nl> + # include " hphp / runtime / vm / type - constraint . h " <nl> <nl> # include " hphp / system / systemlib . h " <nl> <nl> bool isOptionalShapeField ( const ArrayData * field ) { <nl> return field - > exists ( property ) & & tvCastToBoolean ( field - > at ( property ) ) ; <nl> } <nl> <nl> - ALWAYS_INLINE <nl> - std : : string expressionTypeToString ( DataType type ) { <nl> - switch ( type ) { <nl> - case KindOfInt64 : <nl> - return " Int " ; <nl> - case KindOfPersistentString : <nl> - case KindOfString : <nl> - return " String " ; <nl> - case KindOfPersistentVec : <nl> - case KindOfVec : <nl> - return " Vec " ; <nl> - case KindOfPersistentDict : <nl> - case KindOfDict : <nl> - return " Dict " ; <nl> - case KindOfPersistentKeyset : <nl> - case KindOfKeyset : <nl> - return " Keyset " ; <nl> - case KindOfPersistentArray : <nl> - case KindOfArray : <nl> - return " Array " ; <nl> - case KindOfNull : <nl> - case KindOfBoolean : <nl> - case KindOfDouble : <nl> - case KindOfUninit : <nl> - case KindOfRef : <nl> - case KindOfObject : <nl> - case KindOfResource : <nl> - return tname ( type ) ; <nl> - } <nl> - not_reached ( ) ; <nl> - } <nl> - <nl> template < bool genErrorMessage > <nl> bool checkTypeStructureMatchesCellImpl ( <nl> const Array & ts , <nl> bool checkTypeStructureMatchesCellImpl ( <nl> std : : string & expectedType , <nl> std : : string & errorKey <nl> ) { <nl> - auto errOnLen = [ & givenType ] ( auto type , auto len ) { <nl> + auto errOnLen = [ & givenType ] ( auto cell , auto len ) { <nl> if ( genErrorMessage ) { <nl> givenType = folly : : sformat ( " { } of length { } " , <nl> - expressionTypeToString ( type ) , len ) ; <nl> + describe_actual_type ( & cell , true ) , len ) ; <nl> } <nl> } ; <nl> <nl> bool checkTypeStructureMatchesCellImpl ( <nl> assertx ( ts . exists ( s_elem_types ) ) ; <nl> auto const tsElems = ts [ s_elem_types ] . getArrayData ( ) ; <nl> if ( elems - > size ( ) ! = tsElems - > size ( ) ) { <nl> - errOnLen ( type , elems - > size ( ) ) ; <nl> + errOnLen ( c1 , elems - > size ( ) ) ; <nl> result = false ; <nl> break ; <nl> } <nl> bool checkTypeStructureMatchesCellImpl ( <nl> } <nl> ) ; <nl> if ( numFields < numRequiredFields ) { <nl> - errOnLen ( type , numFields ) ; <nl> + errOnLen ( c1 , numFields ) ; <nl> result = false ; <nl> break ; <nl> } <nl> auto const allowsUnknownFields = shapeAllowsUnknownFields ( ts ) ; <nl> if ( ! allowsUnknownFields & & numFields > numDefinedFields ) { <nl> - errOnLen ( type , numFields ) ; <nl> + errOnLen ( c1 , numFields ) ; <nl> result = false ; <nl> break ; <nl> } <nl> bool checkTypeStructureMatchesCellImpl ( <nl> always_assert ( false ) ; <nl> } <nl> if ( genErrorMessage & & ! result ) { <nl> - if ( givenType . empty ( ) ) givenType = expressionTypeToString ( type ) ; <nl> + if ( givenType . empty ( ) ) givenType = describe_actual_type ( & c1 , true ) ; <nl> if ( expectedType . empty ( ) ) { <nl> expectedType = TypeStructure : : toString ( ts ) . toCppString ( ) ; <nl> } <nl> mmm a / hphp / test / slow / as_expression / primitives . php . expect <nl> ppp b / hphp / test / slow / as_expression / primitives . php . expect <nl> <nl> $ x is 1 <nl> - string ( 27 ) " Expected HH \ string , got Int " <nl> + string ( 27 ) " Expected HH \ string , got int " <nl> $ x is 2 <nl> - string ( 27 ) " Expected HH \ string , got Int " <nl> + string ( 27 ) " Expected HH \ string , got int " <nl> $ x is 3 <nl> - string ( 27 ) " Expected HH \ string , got Int " <nl> + string ( 27 ) " Expected HH \ string , got int " <nl> $ x is 3 . 14 <nl> - string ( 30 ) " Expected HH \ string , got Double " <nl> - string ( 32 ) " Expected HH \ arraykey , got Double " <nl> + string ( 29 ) " Expected HH \ string , got float " <nl> + string ( 31 ) " Expected HH \ arraykey , got float " <nl> $ x is Vector <nl> - string ( 30 ) " Expected HH \ string , got Object " <nl> - string ( 32 ) " Expected HH \ arraykey , got Object " <nl> + string ( 33 ) " Expected HH \ string , got HH \ Vector " <nl> + string ( 35 ) " Expected HH \ arraykey , got HH \ Vector " <nl> $ x is hiii <nl> mmm a / hphp / test / slow / as_expression / shape_errors . php . expect <nl> ppp b / hphp / test / slow / as_expression / shape_errors . php . expect <nl> <nl> - string ( 72 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string ) , got Array of length 1 " <nl> - string ( 38 ) " Expected HH \ string at [ " wow " ] , got Int " <nl> - string ( 72 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string ) , got Array of length 3 " <nl> - string ( 72 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string ) , got Array of length 1 " <nl> + string ( 72 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string ) , got array of length 1 " <nl> + string ( 38 ) " Expected HH \ string at [ " wow " ] , got int " <nl> + string ( 72 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string ) , got array of length 3 " <nl> + string ( 72 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string ) , got array of length 1 " <nl> <nl> - string ( 77 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string , . . . ) , got Array of length 1 " <nl> - string ( 38 ) " Expected HH \ string at [ " wow " ] , got Int " <nl> - string ( 38 ) " Expected HH \ string at [ " wow " ] , got Int " <nl> - string ( 77 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string , . . . ) , got Array of length 1 " <nl> + string ( 77 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string , . . . ) , got array of length 1 " <nl> + string ( 38 ) " Expected HH \ string at [ " wow " ] , got int " <nl> + string ( 38 ) " Expected HH \ string at [ " wow " ] , got int " <nl> + string ( 77 ) " Expected HH \ shape ( ' hi ' = > HH \ int , ' wow ' = > HH \ string , . . . ) , got array of length 1 " <nl> <nl> - string ( 37 ) " Expected HH \ int at [ " hi " ] , got String " <nl> - string ( 38 ) " Expected HH \ string at [ " wow " ] , got Int " <nl> - string ( 73 ) " Expected HH \ shape ( ? ' hi ' = > HH \ int , ' wow ' = > HH \ string ) , got Array of length 3 " <nl> + string ( 37 ) " Expected HH \ int at [ " hi " ] , got string " <nl> + string ( 38 ) " Expected HH \ string at [ " wow " ] , got int " <nl> + string ( 73 ) " Expected HH \ shape ( ? ' hi ' = > HH \ int , ' wow ' = > HH \ string ) , got array of length 3 " <nl> OK <nl> mmm a / hphp / test / slow / as_expression / shape_escaped_key_errors . php . expect <nl> ppp b / hphp / test / slow / as_expression / shape_escaped_key_errors . php . expect <nl> <nl> - string ( 42 ) " Expected HH \ int at [ " h \ \ ' \ " i " ] , got String " <nl> - string ( 43 ) " Expected HH \ string at [ " w \ \ ' o \ \ w " ] , got Int " <nl> \ No newline at end of file <nl> + string ( 42 ) " Expected HH \ int at [ " h \ \ ' \ " i " ] , got string " <nl> + string ( 43 ) " Expected HH \ string at [ " w \ \ ' o \ \ w " ] , got int " <nl> mmm a / hphp / test / slow / as_expression / tuple_errors . php . expect <nl> ppp b / hphp / test / slow / as_expression / tuple_errors . php . expect <nl> <nl> OK <nl> - string ( 32 ) " Expected HH \ bool at [ 1 ] , got Int " <nl> - string ( 34 ) " Expected HH \ string at [ 2 ] , got Int " <nl> - string ( 60 ) " Expected ( HH \ int , HH \ bool , HH \ string ) , got Array of length 2 " <nl> - string ( 60 ) " Expected ( HH \ int , HH \ bool , HH \ string ) , got Array of length 2 " <nl> - string ( 60 ) " Expected ( HH \ int , HH \ bool , HH \ string ) , got Array of length 2 " <nl> - string ( 60 ) " Expected ( HH \ int , HH \ bool , HH \ string ) , got Array of length 4 " <nl> + string ( 32 ) " Expected HH \ bool at [ 1 ] , got int " <nl> + string ( 34 ) " Expected HH \ string at [ 2 ] , got int " <nl> + string ( 60 ) " Expected ( HH \ int , HH \ bool , HH \ string ) , got array of length 2 " <nl> + string ( 60 ) " Expected ( HH \ int , HH \ bool , HH \ string ) , got array of length 2 " <nl> + string ( 60 ) " Expected ( HH \ int , HH \ bool , HH \ string ) , got array of length 2 " <nl> + string ( 60 ) " Expected ( HH \ int , HH \ bool , HH \ string ) , got array of length 4 " <nl> <nl> - string ( 69 ) " Expected ( HH \ int , ( HH \ int , ( HH \ int , HH \ bool ) ) ) , got Array of length 3 " <nl> - string ( 69 ) " Expected ( HH \ int , ( HH \ int , ( HH \ int , HH \ bool ) ) ) , got Array of length 3 " <nl> - string ( 69 ) " Expected ( HH \ int , ( HH \ int , ( HH \ int , HH \ bool ) ) ) , got Array of length 3 " <nl> + string ( 69 ) " Expected ( HH \ int , ( HH \ int , ( HH \ int , HH \ bool ) ) ) , got array of length 3 " <nl> + string ( 69 ) " Expected ( HH \ int , ( HH \ int , ( HH \ int , HH \ bool ) ) ) , got array of length 3 " <nl> + string ( 69 ) " Expected ( HH \ int , ( HH \ int , ( HH \ int , HH \ bool ) ) ) , got array of length 3 " <nl> OK <nl> - string ( 41 ) " Expected HH \ int at [ 1 ] [ 1 ] [ 0 ] , got Boolean " <nl> - string ( 37 ) " Expected HH \ int at [ 1 ] [ 0 ] , got String " <nl> - string ( 69 ) " Expected ( HH \ int , ( HH \ int , ( HH \ int , HH \ bool ) ) ) , got Array of length 4 " <nl> + string ( 38 ) " Expected HH \ int at [ 1 ] [ 1 ] [ 0 ] , got bool " <nl> + string ( 37 ) " Expected HH \ int at [ 1 ] [ 0 ] , got string " <nl> + string ( 69 ) " Expected ( HH \ int , ( HH \ int , ( HH \ int , HH \ bool ) ) ) , got array of length 4 " <nl> | Reuse existing type - to - string mapping for as - expressions | facebook/hhvm | 161b89088d4d26bb01abe0473e1f5dc41f298033 | 2018-05-11T00:38:57Z |
mmm a / website / index . html <nl> ppp b / website / index . html <nl> < h2 id = " quick - start " > Quick Start < / h2 > <nl> < pre > <nl> sudo apt - key adv - - keyserver keyserver . ubuntu . com - - recv E0C56BD4 # optional <nl> <nl> - sudo apt - add - repository " deb http : / / repo . yandex . ru / clickhouse / deb / stable / main / " <nl> + sudo echo " deb http : / / repo . yandex . ru / clickhouse / deb / stable / main / " > / etc / apt / sources . list . d / clickhouse . list <nl> sudo apt - get update <nl> <nl> sudo apt - get install - y clickhouse - server clickhouse - client <nl> | Better commands to install ClickHouse [ # CLICKHOUSE - 3 ] | ClickHouse/ClickHouse | 3e5daae2cb933c2a8c85c1afb8f8fd29913dadf0 | 2018-07-23T21:23:12Z |
mmm a / tensorflow / core / BUILD <nl> ppp b / tensorflow / core / BUILD <nl> CORE_CPU_LIB_HEADERS = CORE_CPU_BASE_HDRS + [ <nl> " common_runtime / executor . h " , <nl> " common_runtime / graph_optimizer . h " , <nl> " common_runtime / local_device . h " , <nl> + " common_runtime / lower_if_op . h " , <nl> " common_runtime / memory_types . h " , <nl> " common_runtime / mkl_cpu_allocator . h " , <nl> " common_runtime / optimization_registry . h " , <nl> tf_cuda_library ( <nl> " common_runtime / graph_optimizer . cc " , <nl> " common_runtime / graph_runner . cc " , <nl> " common_runtime / local_device . cc " , <nl> + " common_runtime / lower_if_op . cc " , <nl> " common_runtime / memory_types . cc " , <nl> " common_runtime / mkl_cpu_allocator . cc " , <nl> " common_runtime / optimization_registry . cc " , <nl> tf_cc_test_gpu ( <nl> ] , <nl> ) <nl> <nl> + tf_cc_tests ( <nl> + name = " common_runtime_lower_if_op_test " , <nl> + size = " small " , <nl> + srcs = [ " common_runtime / lower_if_op_test . cc " ] , <nl> + deps = [ <nl> + " : all_kernels " , <nl> + " : core_cpu " , <nl> + " : core_cpu_internal " , <nl> + " : direct_session " , <nl> + " : framework " , <nl> + " : framework_internal " , <nl> + " : lib " , <nl> + " : test " , <nl> + " : test_main " , <nl> + " : testlib " , <nl> + " / / tensorflow / cc : cc_ops " , <nl> + " / / tensorflow / cc : cc_ops_internal " , <nl> + " / / tensorflow / cc : client_session " , <nl> + " / / tensorflow / cc : function_ops " , <nl> + " / / tensorflow / cc : ops " , <nl> + ] , <nl> + ) <nl> + <nl> # Test data <nl> filegroup ( <nl> name = " image_testdata " , <nl> new file mode 100644 <nl> index 0000000000000 . . b5fee36ff43e0 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / common_runtime / lower_if_op . cc <nl> <nl> + / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / core / common_runtime / lower_if_op . h " <nl> + <nl> + # include " tensorflow / core / common_runtime / function . h " <nl> + # include " tensorflow / core / framework / node_def_builder . h " <nl> + # include " tensorflow / core / graph / graph . h " <nl> + # include " tensorflow / core / graph / node_builder . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + / / TODO ( jpienaar ) : Consider making it a public attribute . <nl> + const char * const LowerIfOpPass : : kLowerUsingSwitchMergeAttr = <nl> + " _lower_using_switch_merge " ; <nl> + <nl> + namespace { <nl> + <nl> + using NodeOut = NodeBuilder : : NodeOut ; <nl> + <nl> + / / Convenience builder to make it easy to construct a conditional with a single <nl> + / / function call in the then and else branch . This first converts the if node <nl> + / / into switches ( for inputs ) and merges ( for outputs ) around a function call <nl> + / / per branch , then inlines the function calls . <nl> + class CondBuilder { <nl> + public : <nl> + enum Branch { kElseBranch = 0 , kThenBranch = 1 } ; <nl> + <nl> + / / Create a CondBuilder to create the lowering of If op . that has then and <nl> + / / else functions named ` then_fn_name ` and ` else_fn_name ` respectively in the <nl> + / / given graph . <nl> + CondBuilder ( Node * if_op , const string & then_fn_name , <nl> + const string & else_fn_name , Graph * graph ) ; <nl> + <nl> + / / Constructs the basic conditional control flow using switch and merge nodes . <nl> + Status CreatePivotNodes ( ) ; <nl> + <nl> + / / Adds the inputs from the if node to the merge nodes of the lowered if . <nl> + Status AddInputs ( ) ; <nl> + <nl> + / / Adds the outputs from the if node to the merge nodes of the lowered if . <nl> + / / Note : no inputs can be added once outputs are added as the then and else <nl> + / / nodes are finalized while adding outputs . <nl> + Status AddOutputs ( ) ; <nl> + <nl> + / / Builds an identity node with the same outputs as If . <nl> + Status BuildLoweredIfOutput ( ) ; <nl> + <nl> + / / Inline call nodes for then and else . <nl> + Status InlineCallNodes ( ) ; <nl> + <nl> + private : <nl> + / / Returns unique name containing the name of the If op being rewritten <nl> + / / ( name_ ) , infix and a suffix to ensure it is unique within the graph . <nl> + string NewName ( const string & infix ) ; <nl> + <nl> + / / Adds input to both the then and else nodes from src : src_output . <nl> + Status AddInput ( Node * src , int src_output ) ; <nl> + <nl> + / / The merged outputs of the then and else nodes . <nl> + std : : vector < NodeOut > outputs_ ; <nl> + <nl> + / / The node that dominates all execution of the then and else body nodes . <nl> + Node * control_predecessor_ ; <nl> + / / The original If op . <nl> + Node * if_op_ ; <nl> + / / The identity node with the same outputs as the original If op . <nl> + Node * lowered_if_output_ ; <nl> + / / The predicate of the conditional . <nl> + Node * pred_ ; <nl> + / / Node corresponding to pivot_f branch of predicate switch which is <nl> + / / the pivot node that dominates all nodes in the false / else branch . <nl> + Node * pivot_f_ ; <nl> + / / Node corresponding to pivot_t branch of predicate switch which is <nl> + / / the pivot node that dominates all nodes in the true / then branch . <nl> + Node * pivot_t_ ; <nl> + Node * then_call_node_ ; <nl> + Node * else_call_node_ ; <nl> + Graph * graph_ ; <nl> + string name_ ; <nl> + <nl> + NodeBuilder then_call_builder_ ; <nl> + NodeBuilder else_call_builder_ ; <nl> + } ; <nl> + <nl> + CondBuilder : : CondBuilder ( Node * if_op , const string & then_fn_name , <nl> + const string & else_fn_name , Graph * graph ) <nl> + : if_op_ ( if_op ) , <nl> + graph_ ( graph ) , <nl> + name_ ( if_op - > name ( ) ) , <nl> + then_call_builder_ ( NewName ( " then " ) , then_fn_name , graph - > op_registry ( ) ) , <nl> + else_call_builder_ ( NewName ( " else " ) , else_fn_name , graph - > op_registry ( ) ) { <nl> + TF_CHECK_OK ( if_op_ - > input_node ( 0 , & pred_ ) ) ; <nl> + } <nl> + <nl> + Status CondBuilder : : CreatePivotNodes ( ) { <nl> + / / Construct the basic cond body ( consisting of feeding in the predicate to <nl> + / / create pivot nodes ) . <nl> + Node * switch_pred ; <nl> + TF_RETURN_IF_ERROR ( <nl> + NodeBuilder ( NewName ( " switch_pred " ) , " Switch " , graph_ - > op_registry ( ) ) <nl> + . Input ( NodeOut ( pred_ , 0 ) ) <nl> + . Input ( NodeOut ( pred_ , 0 ) ) <nl> + . Finalize ( graph_ , & switch_pred ) ) ; <nl> + control_predecessor_ = switch_pred ; <nl> + TF_RETURN_IF_ERROR ( <nl> + NodeBuilder ( NewName ( " pivot_f " ) , " Identity " , graph_ - > op_registry ( ) ) <nl> + . Input ( switch_pred , kElseBranch ) <nl> + . Finalize ( graph_ , & pivot_f_ ) ) ; <nl> + TF_RETURN_IF_ERROR ( <nl> + NodeBuilder ( NewName ( " pivot_t " ) , " Identity " , graph_ - > op_registry ( ) ) <nl> + . Input ( switch_pred , kThenBranch ) <nl> + . Finalize ( graph_ , & pivot_t_ ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + string CondBuilder : : NewName ( const string & infix ) { <nl> + return graph_ - > NewName ( strings : : StrCat ( name_ , " / " , infix ) ) ; <nl> + } <nl> + <nl> + Status CondBuilder : : AddInput ( Node * src , int src_output ) { <nl> + Node * input ; <nl> + TF_RETURN_IF_ERROR ( <nl> + NodeBuilder ( NewName ( src - > name ( ) ) , " Switch " , graph_ - > op_registry ( ) ) <nl> + . Input ( src , src_output ) <nl> + . Input ( pred_ , 0 ) <nl> + . Finalize ( graph_ , & input ) ) ; <nl> + then_call_builder_ . Input ( input , kThenBranch ) ; <nl> + else_call_builder_ . Input ( input , kElseBranch ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status CondBuilder : : AddInputs ( ) { <nl> + / / Add input data edges . <nl> + std : : vector < const Edge * > edges ; <nl> + TF_RETURN_IF_ERROR ( if_op_ - > input_edges ( & edges ) ) ; <nl> + / / Start at index 1 as the first input is the predicate . <nl> + for ( int i = 1 ; i < edges . size ( ) ; + + i ) { <nl> + const Edge * e = edges [ i ] ; <nl> + TF_RETURN_IF_ERROR ( AddInput ( e - > src ( ) , e - > src_output ( ) ) ) ; <nl> + } <nl> + / / Add input control edges . <nl> + for ( const Edge * e : if_op_ - > in_edges ( ) ) { <nl> + if ( e - > IsControlEdge ( ) ) { <nl> + graph_ - > AddControlEdge ( e - > src ( ) , control_predecessor_ ) ; <nl> + } <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status CondBuilder : : AddOutputs ( ) { <nl> + / / Construct the then and else nodes . <nl> + TF_RETURN_IF_ERROR ( then_call_builder_ . Finalize ( graph_ , & then_call_node_ ) ) ; <nl> + graph_ - > AddControlEdge ( pivot_t_ , then_call_node_ ) ; <nl> + TF_RETURN_IF_ERROR ( else_call_builder_ . Finalize ( graph_ , & else_call_node_ ) ) ; <nl> + graph_ - > AddControlEdge ( pivot_f_ , else_call_node_ ) ; <nl> + <nl> + / / Merge the outputs from the two branches . <nl> + std : : vector < Node * > merges ( then_call_node_ - > num_outputs ( ) ) ; <nl> + outputs_ . resize ( merges . size ( ) ) ; <nl> + for ( int i = 0 ; i < then_call_node_ - > num_outputs ( ) ; + + i ) { <nl> + TF_RETURN_IF_ERROR ( <nl> + NodeBuilder ( graph_ - > NewName ( " merge " ) , " Merge " , graph_ - > op_registry ( ) ) <nl> + . Input ( { NodeOut ( then_call_node_ , i ) , NodeOut ( else_call_node_ , i ) } ) <nl> + . Finalize ( graph_ , & merges [ i ] ) ) ; <nl> + outputs_ [ i ] = NodeOut ( merges [ i ] , 0 ) ; <nl> + } <nl> + <nl> + TF_RETURN_IF_ERROR ( BuildLoweredIfOutput ( ) ) ; <nl> + <nl> + / / Add outputs . <nl> + for ( const Edge * e : if_op_ - > out_edges ( ) ) { <nl> + if ( e - > IsControlEdge ( ) ) { <nl> + graph_ - > AddControlEdge ( lowered_if_output_ , e - > dst ( ) ) ; <nl> + } else { <nl> + / / Feed the outputs directly from the merge nodes so that downstream ops <nl> + / / can start before all the outputs have been computed . <nl> + graph_ - > AddEdge ( merges [ e - > src_output ( ) ] , e - > src_output ( ) , e - > dst ( ) , <nl> + e - > dst_input ( ) ) ; <nl> + } <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status InlineCallInGraph ( Node * n , Graph * g ) { <nl> + const auto & lib = g - > flib_def ( ) ; <nl> + const FunctionDef * fdef = lib . Find ( n - > type_string ( ) ) ; <nl> + CHECK ( fdef ! = nullptr ) ; <nl> + FunctionBody * fbody ; <nl> + TF_RETURN_IF_ERROR ( <nl> + FunctionDefToBodyHelper ( * fdef , n - > attrs ( ) , & lib , <nl> + [ & lib ] ( const string & op , const OpDef * * sig ) { <nl> + return lib . LookUpOpDef ( op , sig ) ; <nl> + } , <nl> + & fbody ) ) ; <nl> + / / TODO ( jpienaar ) : Improve this interface to make the need to delete it <nl> + / / explicit . <nl> + InlineFunctionBody ( g - > flib_def ( ) , g , n , fbody ) ; <nl> + delete fbody ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status CondBuilder : : BuildLoweredIfOutput ( ) { <nl> + / / Build the identity node output . <nl> + NodeBuilder ib ( name_ , " IdentityN " ) ; <nl> + ib . Input ( outputs_ ) ; <nl> + return ib . Finalize ( graph_ , & lowered_if_output_ ) ; <nl> + } <nl> + <nl> + Status CondBuilder : : InlineCallNodes ( ) { <nl> + TF_RETURN_IF_ERROR ( InlineCallInGraph ( then_call_node_ , graph_ ) ) ; <nl> + TF_RETURN_IF_ERROR ( InlineCallInGraph ( else_call_node_ , graph_ ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + Status LowerIfOpPass : : Run ( const GraphOptimizationPassOptions & options ) { <nl> + if ( options . partition_graphs ! = nullptr ) { <nl> + return errors : : Internal ( <nl> + " Lowering If op should happen before partitioning . " ) ; <nl> + } <nl> + if ( options . graph = = nullptr ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Graph * g = options . graph - > get ( ) ; <nl> + if ( g = = nullptr ) { <nl> + return errors : : Internal ( " Lowering If op requires a graph to be available . " ) ; <nl> + } <nl> + <nl> + / / Match all the nodes that need to be rewritten . <nl> + gtl : : InlinedVector < Node * , 2 > matches ; <nl> + for ( Node * n : g - > op_nodes ( ) ) { <nl> + if ( n - > type_string ( ) = = " If " ) { <nl> + / / Only rewrite if the If op is marked as needing to be lowered . <nl> + bool match ; <nl> + Status s = GetNodeAttr ( n - > attrs ( ) , kLowerUsingSwitchMergeAttr , & match ) ; <nl> + if ( s . ok ( ) & & match ) matches . push_back ( n ) ; <nl> + } <nl> + } <nl> + for ( Node * n : matches ) { <nl> + TF_RETURN_IF_ERROR ( RewriteNode ( n , g ) ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status LowerIfOpPass : : RewriteNode ( Node * n , Graph * g ) { <nl> + const AttrValue * then_attr = n - > attrs ( ) . Find ( " then_branch " ) ; <nl> + if ( then_attr = = nullptr ) { <nl> + return errors : : InvalidArgument ( " Then branch function missing " ) ; <nl> + } <nl> + const AttrValue * else_attr = n - > attrs ( ) . Find ( " else_branch " ) ; <nl> + if ( else_attr = = nullptr ) { <nl> + return errors : : InvalidArgument ( " Else branch function missing " ) ; <nl> + } <nl> + <nl> + CondBuilder cb ( n , then_attr - > func ( ) . name ( ) , else_attr - > func ( ) . name ( ) , g ) ; <nl> + TF_RETURN_IF_ERROR ( cb . CreatePivotNodes ( ) ) ; <nl> + TF_RETURN_IF_ERROR ( cb . AddInputs ( ) ) ; <nl> + TF_RETURN_IF_ERROR ( cb . AddOutputs ( ) ) ; <nl> + TF_RETURN_IF_ERROR ( cb . InlineCallNodes ( ) ) ; <nl> + g - > RemoveNode ( n ) ; <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + REGISTER_OPTIMIZATION ( OptimizationPassRegistry : : PRE_PLACEMENT , 0 , <nl> + LowerIfOpPass ) ; <nl> + <nl> + } / / namespace tensorflow <nl> new file mode 100644 <nl> index 0000000000000 . . a9ef39ae5c828 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / common_runtime / lower_if_op . h <nl> <nl> + / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # ifndef TENSORFLOW_CORE_COMMON_RUNTIME_LOWER_IF_OP_H_ <nl> + # define TENSORFLOW_CORE_COMMON_RUNTIME_LOWER_IF_OP_H_ <nl> + <nl> + # include " tensorflow / core / common_runtime / optimization_registry . h " <nl> + # include " tensorflow / core / lib / core / status . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + / / Rewrite If ops to use switch and merge nodes instead . <nl> + class LowerIfOpPass : public GraphOptimizationPass { <nl> + public : <nl> + static const char * const kLowerUsingSwitchMergeAttr ; <nl> + <nl> + Status Run ( const GraphOptimizationPassOptions & options ) override ; <nl> + <nl> + private : <nl> + / / Rewrite the given If node ` n ` in graph ` g ` to use the switch - merge form . <nl> + Status RewriteNode ( Node * n , Graph * g ) ; <nl> + } ; <nl> + <nl> + } / / namespace tensorflow <nl> + <nl> + # endif / / TENSORFLOW_CORE_COMMON_RUNTIME_LOWER_IF_OP_H_ <nl> new file mode 100644 <nl> index 0000000000000 . . 319a617b32259 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / common_runtime / lower_if_op_test . cc <nl> <nl> + / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / core / common_runtime / lower_if_op . h " <nl> + <nl> + # include " tensorflow / cc / client / client_session . h " <nl> + # include " tensorflow / cc / framework / ops . h " <nl> + # include " tensorflow / cc / ops / array_ops . h " <nl> + # include " tensorflow / cc / ops / control_flow_ops_internal . h " <nl> + # include " tensorflow / cc / ops / function_ops . h " <nl> + # include " tensorflow / cc / ops / standard_ops . h " <nl> + # include " tensorflow / core / common_runtime / graph_runner . h " <nl> + # include " tensorflow / core / framework / function_testlib . h " <nl> + # include " tensorflow / core / framework / node_def_util . h " <nl> + # include " tensorflow / core / framework / op . h " <nl> + # include " tensorflow / core / graph / graph_constructor . h " <nl> + # include " tensorflow / core / graph / graph_def_builder . h " <nl> + # include " tensorflow / core / graph / graph_def_builder_util . h " <nl> + # include " tensorflow / core / lib / core / status_test_util . h " <nl> + # include " tensorflow / core / lib / strings / str_util . h " <nl> + # include " tensorflow / core / platform / test . h " <nl> + <nl> + namespace tensorflow { <nl> + namespace { <nl> + <nl> + Status Rewrite ( std : : unique_ptr < Graph > * graph ) { <nl> + FunctionDefLibrary flib ; <nl> + FunctionLibraryDefinition flib_def ( ( * graph ) - > op_registry ( ) , flib ) ; <nl> + <nl> + GraphOptimizationPassOptions opt_options ; <nl> + opt_options . graph = graph ; <nl> + opt_options . flib_def = & flib_def ; <nl> + LowerIfOpPass pass ; <nl> + return pass . Run ( opt_options ) ; <nl> + } <nl> + <nl> + TEST ( LowerIfOpTest , Simple ) { <nl> + std : : unique_ptr < Graph > graph ( new Graph ( OpRegistry : : Global ( ) ) ) ; <nl> + <nl> + / / Add test functions for then and else branch . <nl> + FunctionDefLibrary f_lib_proto ; <nl> + * ( f_lib_proto . add_function ( ) ) = test : : function : : XTimesTwo ( ) ; <nl> + * ( f_lib_proto . add_function ( ) ) = test : : function : : XTimesFour ( ) ; <nl> + FunctionLibraryDefinition f_lib ( OpRegistry : : Global ( ) , f_lib_proto ) ; <nl> + <nl> + / / Construct simple conditional that switches on ` pred ` and operates only on <nl> + / / single input ` A ` . <nl> + Scope root = Scope : : NewRootScope ( ) . ExitOnError ( ) ; <nl> + TF_ASSERT_OK ( root . graph ( ) - > AddFunctionLibrary ( f_lib_proto ) ) ; <nl> + auto a = ops : : _Arg ( root . WithOpName ( " A " ) , DT_INT32 , 0 ) ; <nl> + auto pred = ops : : _Arg ( root . WithOpName ( " pred " ) , DT_BOOL , 1 ) ; <nl> + Node * written_if ; <nl> + std : : vector < NodeBuilder : : NodeOut > inputs ( { NodeBuilder : : NodeOut ( a . node ( ) ) } ) ; <nl> + AttrValue tb ; <nl> + tb . mutable_func ( ) - > set_name ( " XTimesTwo " ) ; <nl> + AttrValue eb ; <nl> + eb . mutable_func ( ) - > set_name ( " XTimesFour " ) ; <nl> + TF_ASSERT_OK ( NodeBuilder ( " if " , " If " , & f_lib ) <nl> + . Input ( pred . node ( ) ) <nl> + . Input ( inputs ) <nl> + . Attr ( " then_branch " , tb ) <nl> + . Attr ( " else_branch " , eb ) <nl> + . Attr ( LowerIfOpPass : : kLowerUsingSwitchMergeAttr , true ) <nl> + . Attr ( " Tout " , { DT_INT32 } ) <nl> + . Finalize ( root . graph ( ) , & written_if ) ) ; <nl> + TF_ASSERT_OK ( root . DoShapeInference ( written_if ) ) ; <nl> + TF_ASSERT_OK ( root . ToGraph ( graph . get ( ) ) ) ; <nl> + <nl> + / / The input graph has no switch or merge nodes . <nl> + int node_called_if_count = 0 ; <nl> + for ( const auto * op : graph - > op_nodes ( ) ) { <nl> + ASSERT_FALSE ( op - > IsSwitch ( ) ) ; <nl> + ASSERT_FALSE ( op - > IsMerge ( ) ) ; <nl> + if ( op - > name ( ) = = " if " ) { <nl> + + + node_called_if_count ; <nl> + } <nl> + } <nl> + ASSERT_EQ ( node_called_if_count , 1 ) ; <nl> + <nl> + TF_ASSERT_OK ( Rewrite ( & graph ) ) ; <nl> + <nl> + / / Verify the resultant graph has switch and merge nodes , and a node called <nl> + / / ` if ` ( but not If nodes ) . <nl> + int switch_count = 0 ; <nl> + int merge_count = 0 ; <nl> + node_called_if_count = 0 ; <nl> + for ( const auto * op : graph - > op_nodes ( ) ) { <nl> + if ( op - > IsSwitch ( ) ) { <nl> + + + switch_count ; <nl> + } <nl> + if ( op - > IsMerge ( ) ) { <nl> + + + merge_count ; <nl> + } <nl> + ASSERT_NE ( op - > type_string ( ) , " If " ) ; <nl> + if ( op - > name ( ) = = " if " ) { <nl> + + + node_called_if_count ; <nl> + } <nl> + } <nl> + / / One switch for predicate and one for input ( A ) . <nl> + ASSERT_EQ ( switch_count , 2 ) ; <nl> + / / One merge for the single output values of then and else . <nl> + ASSERT_EQ ( merge_count , 1 ) ; <nl> + ASSERT_EQ ( node_called_if_count , 1 ) ; <nl> + <nl> + / / Verify execution . <nl> + ClientSession session ( root ) ; <nl> + { <nl> + ClientSession : : FeedType feeds ; <nl> + feeds . emplace ( Output ( pred . node ( ) ) , Input : : Initializer ( false ) ) ; <nl> + feeds . emplace ( Output ( a . node ( ) ) , Input : : Initializer ( 10 ) ) ; <nl> + std : : vector < Tensor > out_tensors ; <nl> + TF_ASSERT_OK ( session . Run ( feeds , { Output ( written_if ) } , & out_tensors ) ) ; <nl> + EXPECT_EQ ( out_tensors . size ( ) , 1 ) ; <nl> + EXPECT_EQ ( out_tensors [ 0 ] . scalar < int > ( ) ( ) , 40 ) ; <nl> + } <nl> + { <nl> + ClientSession : : FeedType feeds ; <nl> + feeds . emplace ( Output ( pred . node ( ) ) , Input : : Initializer ( true ) ) ; <nl> + feeds . emplace ( Output ( a . node ( ) ) , Input : : Initializer ( 10 ) ) ; <nl> + std : : vector < Tensor > out_tensors ; <nl> + TF_ASSERT_OK ( session . Run ( feeds , { Output ( written_if ) } , & out_tensors ) ) ; <nl> + EXPECT_EQ ( out_tensors . size ( ) , 1 ) ; <nl> + EXPECT_EQ ( out_tensors [ 0 ] . scalar < int > ( ) ( ) , 20 ) ; <nl> + } <nl> + } <nl> + <nl> + } / / namespace <nl> + } / / namespace tensorflow <nl> | Add If op rewriter . | tensorflow/tensorflow | 321d69b55a61a623360b70fc96dac2c7e1f71ad3 | 2018-05-14T21:06:56Z |
mmm a / libraries / fc / include / fc / log / appender . hpp <nl> ppp b / libraries / fc / include / fc / log / appender . hpp <nl> <nl> # include < fc / shared_ptr . hpp > <nl> # include < fc / string . hpp > <nl> <nl> + # if BOOST_VERSION > = 106600 <nl> + namespace boost { namespace asio { class io_context ; typedef io_context io_service ; } } <nl> + # else <nl> namespace boost { namespace asio { class io_service ; } } <nl> + # endif <nl> <nl> namespace fc { <nl> class appender ; <nl> mmm a / libraries / fc / include / fc / log / gelf_appender . hpp <nl> ppp b / libraries / fc / include / fc / log / gelf_appender . hpp <nl> <nl> # include < fc / log / logger . hpp > <nl> # include < fc / time . hpp > <nl> <nl> - namespace boost { namespace asio { class io_service ; } } <nl> - <nl> namespace fc <nl> { <nl> / / Log appender that sends log messages in JSON format over UDP <nl> mmm a / tests / api_tests / api_tests . cpp <nl> ppp b / tests / api_tests / api_tests . cpp <nl> <nl> # include < eos / chain / staked_balance_objects . hpp > <nl> # include < eos / chain / balance_object . hpp > <nl> <nl> + # include < eos / chain_plugin / chain_plugin . hpp > <nl> + <nl> FC_REFLECT ( dummy_message , ( a ) ( b ) ( c ) ) ; <nl> FC_REFLECT ( u128_msg , ( values ) ) ; <nl> <nl> mmm a / tests / common / database_fixture . hpp <nl> ppp b / tests / common / database_fixture . hpp <nl> <nl> # include < eos / chain / chain_controller . hpp > <nl> # include < eos / chain / producer_object . hpp > <nl> # include < eos / chain / exceptions . hpp > <nl> - # include < eos / chain_plugin / chain_plugin . hpp > <nl> <nl> # include < eos / native_contract / native_contract_chain_initializer . hpp > <nl> # include < eos / native_contract / native_contract_chain_administrator . hpp > <nl> mmm a / tests / slow_tests / slow_tests . cpp <nl> ppp b / tests / slow_tests / slow_tests . cpp <nl> <nl> <nl> # include < eos / utilities / tempdir . hpp > <nl> <nl> + # include < eos / chain_plugin / chain_plugin . hpp > <nl> + <nl> # include < fc / crypto / digest . hpp > <nl> <nl> # include " . . / common / database_fixture . hpp " <nl> mmm a / tests / tests / message_buffer_tests . cpp <nl> ppp b / tests / tests / message_buffer_tests . cpp <nl> <nl> # include < boost / test / unit_test . hpp > <nl> # include < iostream > <nl> <nl> + # if BOOST_VERSION > = 106600 <nl> + namespace boost <nl> + { <nl> + namespace asio <nl> + { <nl> + namespace detail <nl> + { <nl> + inline void * buffer_cast_helper ( const mutable_buffer & b ) <nl> + { <nl> + # if defined ( BOOST_ASIO_ENABLE_BUFFER_DEBUGGING ) <nl> + if ( b . size ( ) & & b . get_debug_check ( ) ) <nl> + b . get_debug_check ( ) ( ) ; <nl> + # endif / / BOOST_ASIO_ENABLE_BUFFER_DEBUGGING <nl> + return b . data ( ) ; <nl> + } <nl> + inline size_t buffer_size_helper ( const mutable_buffer & b ) <nl> + { <nl> + return b . size ( ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + # endif <nl> <nl> namespace eosio { <nl> using namespace std ; <nl> | Merge pull request from EOSIO / boost - 166 - compatibility - 984 | EOSIO/eos | c5685481cf82761241f271ac52c8ad5976c39502 | 2018-01-04T14:40:39Z |
mmm a / core / variant_call . cpp <nl> ppp b / core / variant_call . cpp <nl> Variant Variant : : construct ( const Variant : : Type p_type , const Variant * * p_args , i <nl> / / math types <nl> case VECTOR2 : <nl> return Vector2 ( ) ; <nl> + case VECTOR2I : <nl> + return Vector2i ( ) ; <nl> case RECT2 : <nl> return Rect2 ( ) ; <nl> + case RECT2I : <nl> + return Rect2i ( ) ; <nl> case VECTOR3 : <nl> return Vector3 ( ) ; <nl> + case VECTOR3I : <nl> + return Vector3i ( ) ; <nl> case TRANSFORM2D : <nl> return Transform2D ( ) ; <nl> case PLANE : <nl> mmm a / doc / classes / Rect2i . xml <nl> ppp b / doc / classes / Rect2i . xml <nl> <nl> Constructs a new [ Rect2i ] from [ Rect2 ] . The floating point coordinates will be truncated . <nl> < / description > <nl> < / method > <nl> + < method name = " abs " > <nl> + < return type = " Rect2i " > <nl> + < / return > <nl> + < description > <nl> + Returns a [ Rect2i ] with equivalent position and area , modified so that the top - left corner is the origin and [ code ] width [ / code ] and [ code ] height [ / code ] are positive . <nl> + < / description > <nl> + < / method > <nl> + < method name = " clip " > <nl> + < return type = " Rect2i " > <nl> + < / return > <nl> + < argument index = " 0 " name = " b " type = " Rect2i " > <nl> + < / argument > <nl> + < description > <nl> + Returns the intersection of this [ Rect2i ] and b . <nl> + < / description > <nl> + < / method > <nl> + < method name = " encloses " > <nl> + < return type = " bool " > <nl> + < / return > <nl> + < argument index = " 0 " name = " b " type = " Rect2i " > <nl> + < / argument > <nl> + < description > <nl> + Returns [ code ] true [ / code ] if this [ Rect2i ] completely encloses another one . <nl> + < / description > <nl> + < / method > <nl> + < method name = " expand " > <nl> + < return type = " Rect2i " > <nl> + < / return > <nl> + < argument index = " 0 " name = " to " type = " Vector2i " > <nl> + < / argument > <nl> + < description > <nl> + Returns this [ Rect2i ] expanded to include a given point . <nl> + < / description > <nl> + < / method > <nl> + < method name = " get_area " > <nl> + < return type = " int " > <nl> + < / return > <nl> + < description > <nl> + Returns the area of the [ Rect2i ] . <nl> + < / description > <nl> + < / method > <nl> + < method name = " grow " > <nl> + < return type = " Rect2i " > <nl> + < / return > <nl> + < argument index = " 0 " name = " by " type = " int " > <nl> + < / argument > <nl> + < description > <nl> + Returns a copy of the [ Rect2i ] grown a given amount of units towards all the sides . <nl> + < / description > <nl> + < / method > <nl> + < method name = " grow_individual " > <nl> + < return type = " Rect2i " > <nl> + < / return > <nl> + < argument index = " 0 " name = " left " type = " int " > <nl> + < / argument > <nl> + < argument index = " 1 " name = " top " type = " int " > <nl> + < / argument > <nl> + < argument index = " 2 " name = " right " type = " int " > <nl> + < / argument > <nl> + < argument index = " 3 " name = " bottom " type = " int " > <nl> + < / argument > <nl> + < description > <nl> + Returns a copy of the [ Rect2i ] grown a given amount of units towards each direction individually . <nl> + < / description > <nl> + < / method > <nl> + < method name = " grow_margin " > <nl> + < return type = " Rect2i " > <nl> + < / return > <nl> + < argument index = " 0 " name = " margin " type = " int " > <nl> + < / argument > <nl> + < argument index = " 1 " name = " by " type = " int " > <nl> + < / argument > <nl> + < description > <nl> + Returns a copy of the [ Rect2i ] grown a given amount of units towards the [ enum Margin ] direction . <nl> + < / description > <nl> + < / method > <nl> + < method name = " has_no_area " > <nl> + < return type = " bool " > <nl> + < / return > <nl> + < description > <nl> + Returns [ code ] true [ / code ] if the [ Rect2i ] is flat or empty . <nl> + < / description > <nl> + < / method > <nl> + < method name = " has_point " > <nl> + < return type = " bool " > <nl> + < / return > <nl> + < argument index = " 0 " name = " point " type = " Vector2i " > <nl> + < / argument > <nl> + < description > <nl> + Returns [ code ] true [ / code ] if the [ Rect2i ] contains a point . <nl> + < / description > <nl> + < / method > <nl> + < method name = " intersects " > <nl> + < return type = " bool " > <nl> + < / return > <nl> + < argument index = " 0 " name = " b " type = " Rect2i " > <nl> + < / argument > <nl> + < description > <nl> + Returns [ code ] true [ / code ] if the [ Rect2i ] overlaps with [ code ] b [ / code ] ( i . e . they have at least one point in common ) . <nl> + If [ code ] include_borders [ / code ] is [ code ] true [ / code ] , they will also be considered overlapping if their borders touch , even without intersection . <nl> + < / description > <nl> + < / method > <nl> + < method name = " merge " > <nl> + < return type = " Rect2i " > <nl> + < / return > <nl> + < argument index = " 0 " name = " b " type = " Rect2i " > <nl> + < / argument > <nl> + < description > <nl> + Returns a larger [ Rect2i ] that contains this [ Rect2i ] and [ code ] b [ / code ] . <nl> + < / description > <nl> + < / method > <nl> < / methods > <nl> + < members > <nl> + < member name = " end " type = " Vector2i " setter = " " getter = " " default = " Vector2i ( 0 , 0 ) " > <nl> + Ending corner . <nl> + < / member > <nl> + < member name = " position " type = " Vector2i " setter = " " getter = " " default = " Vector2i ( 0 , 0 ) " > <nl> + Position ( starting corner ) . <nl> + < / member > <nl> + < member name = " size " type = " Vector2i " setter = " " getter = " " default = " Vector2i ( 0 , 0 ) " > <nl> + Size from position to end . <nl> + < / member > <nl> + < / members > <nl> < constants > <nl> < / constants > <nl> < / class > <nl> mmm a / doc / classes / Vector2i . xml <nl> ppp b / doc / classes / Vector2i . xml <nl> <nl> Constructs a new [ Vector2i ] from [ Vector2 ] . The floating point coordinates will be truncated . <nl> < / description > <nl> < / method > <nl> + < method name = " abs " > <nl> + < return type = " Vector2i " > <nl> + < / return > <nl> + < description > <nl> + Returns a new vector with all components in absolute values ( i . e . positive ) . <nl> + < / description > <nl> + < / method > <nl> + < method name = " aspect " > <nl> + < return type = " float " > <nl> + < / return > <nl> + < description > <nl> + Returns the ratio of [ member x ] to [ member y ] . <nl> + < / description > <nl> + < / method > <nl> + < method name = " sign " > <nl> + < return type = " Vector2i " > <nl> + < / return > <nl> + < description > <nl> + Returns the vector with each component set to one or negative one , depending on the signs of the components . <nl> + < / description > <nl> + < / method > <nl> < / methods > <nl> + < members > <nl> + < member name = " x " type = " int " setter = " " getter = " " default = " 0 " > <nl> + The vector ' s X component . Also accessible by using the index position [ code ] [ 0 ] [ / code ] . <nl> + < / member > <nl> + < member name = " y " type = " int " setter = " " getter = " " default = " 0 " > <nl> + The vector ' s Y component . Also accessible by using the index position [ code ] [ 1 ] [ / code ] . <nl> + < / member > <nl> + < / members > <nl> < constants > <nl> < constant name = " AXIS_X " value = " 0 " > <nl> Enumerated value for the X axis . <nl> mmm a / doc / classes / Vector3i . xml <nl> ppp b / doc / classes / Vector3i . xml <nl> <nl> Constructs a new [ Vector3i ] from [ Vector3 ] . The floating point coordinates will be truncated . <nl> < / description > <nl> < / method > <nl> + < method name = " max_axis " > <nl> + < return type = " int " > <nl> + < / return > <nl> + < description > <nl> + Returns the axis of the vector ' s largest value . See [ code ] AXIS_ * [ / code ] constants . <nl> + < / description > <nl> + < / method > <nl> + < method name = " min_axis " > <nl> + < return type = " int " > <nl> + < / return > <nl> + < description > <nl> + Returns the axis of the vector ' s smallest value . See [ code ] AXIS_ * [ / code ] constants . <nl> + < / description > <nl> + < / method > <nl> + < method name = " sign " > <nl> + < return type = " Vector3i " > <nl> + < / return > <nl> + < description > <nl> + Returns the vector with each component set to one or negative one , depending on the signs of the components . <nl> + < / description > <nl> + < / method > <nl> < / methods > <nl> + < members > <nl> + < member name = " x " type = " int " setter = " " getter = " " default = " 0 " > <nl> + The vector ' s X component . Also accessible by using the index position [ code ] [ 0 ] [ / code ] . <nl> + < / member > <nl> + < member name = " y " type = " int " setter = " " getter = " " default = " 0 " > <nl> + The vector ' s Y component . Also accessible by using the index position [ code ] [ 1 ] [ / code ] . <nl> + < / member > <nl> + < member name = " z " type = " int " setter = " " getter = " " default = " 0 " > <nl> + The vector ' s Z component . Also accessible by using the index position [ code ] [ 2 ] [ / code ] . <nl> + < / member > <nl> + < / members > <nl> < constants > <nl> < constant name = " AXIS_X " value = " 0 " > <nl> Enumerated value for the X axis . <nl> | Fix docs generation for Vector2i / Vector3i / Rect2i | godotengine/godot | d7cf1b5c7371c64059298bcf711f1ac6353222fe | 2020-06-03T12:22:26Z |
mmm a / caffe2 / CMakeLists . txt <nl> ppp b / caffe2 / CMakeLists . txt <nl> if ( Caffe2_EXTERNAL_DEPENDENCIES ) <nl> endif ( ) <nl> <nl> # Write the macros file . <nl> - file ( MAKE_DIRECTORY $ { PROJECT_BINARY_DIR } / caffe2 / core ) <nl> - file ( WRITE $ { PROJECT_BINARY_DIR } / caffe2 / core / macros . h <nl> - " / / Automatically generated header file for caffe2 macros . These \ n " <nl> - " / / macros are used to build the Caffe2 binary , and if you are \ n " <nl> - " / / building a dependent library , they will need to be set as well \ n " <nl> - " / / for your program to link correctly . \ n \ n " <nl> - " # pragma once \ n \ n " ) <nl> - get_directory_property ( tmp DIRECTORY $ { PROJECT_SOURCE_DIR } COMPILE_DEFINITIONS ) <nl> - foreach ( item $ { tmp } ) <nl> - if ( $ { item } MATCHES " CAFFE2 . * " ) <nl> - file ( APPEND $ { PROJECT_BINARY_DIR } / caffe2 / core / macros . h <nl> - " \ n # ifndef $ { item } \ n # define $ { item } \ n # endif / / $ { item } \ n " ) <nl> - endif ( ) <nl> - endforeach ( ) <nl> + configure_file ( <nl> + $ { PROJECT_SOURCE_DIR } / caffe2 / core / macros . h . in <nl> + $ { PROJECT_BINARY_DIR } / caffe2 / core / macros . h ) <nl> <nl> # Installing the header files <nl> install ( DIRECTORY $ { CMAKE_CURRENT_LIST_DIR } <nl> new file mode 100644 <nl> index 000000000000 . . fed702b3b93f <nl> mmm / dev / null <nl> ppp b / caffe2 / core / macros . h . in <nl> <nl> + / / Automatically generated header file for caffe2 macros . These <nl> + / / macros are used to build the Caffe2 binary , and if you are <nl> + / / building a dependent library , they will need to be set as well <nl> + / / for your program to link correctly . <nl> + <nl> + # pragma once <nl> + <nl> + # cmakedefine CAFFE2_ANDROID <nl> + # cmakedefine CAFFE2_FORCE_FALLBACK_CUDA_MPI <nl> + # cmakedefine CAFFE2_HAS_MKL_DNN <nl> + # cmakedefine CAFFE2_HAS_MKL_SGEMM_PACK <nl> + # cmakedefine CAFFE2_PERF_WITH_AVX <nl> + # cmakedefine CAFFE2_PERF_WITH_AVX2 <nl> + # cmakedefine CAFFE2_THREADPOOL_MAIN_IMBALANCE <nl> + # cmakedefine CAFFE2_THREADPOOL_STATS <nl> + # cmakedefine CAFFE2_UNIQUE_LONG_TYPEMETA <nl> + # cmakedefine CAFFE2_USE_ACCELERATE <nl> + # cmakedefine CAFFE2_USE_EIGEN_FOR_BLAS <nl> + # cmakedefine CAFFE2_USE_FBCODE <nl> + # cmakedefine CAFFE2_USE_GFLAGS <nl> + # cmakedefine CAFFE2_USE_GOOGLE_GLOG <nl> + # cmakedefine CAFFE2_USE_LITE_PROTO <nl> + # cmakedefine CAFFE2_USE_MKL <nl> + # cmakedefine CAFFE2_USE_NVTX <nl> mmm a / caffe2 / perfkernels / common_avx . cc <nl> ppp b / caffe2 / perfkernels / common_avx . cc <nl> <nl> / / example , if your compiler did not specify - mavx , you should not provide <nl> / / the CAFFE2_PERF_WITH_AVX macro . <nl> <nl> + # include " caffe2 / core / common . h " <nl> + <nl> # ifdef CAFFE2_PERF_WITH_AVX <nl> # ifndef __AVX__ <nl> # error ( \ <nl> mmm a / caffe2 / perfkernels / common_avx2 . cc <nl> ppp b / caffe2 / perfkernels / common_avx2 . cc <nl> <nl> / / example , if your compiler did not specify - mavx2 , you should not provide <nl> / / the CAFFE2_PERF_WITH_AVX2 macro . <nl> <nl> + # include " caffe2 / core / common . h " <nl> + <nl> # ifdef CAFFE2_PERF_WITH_AVX2 <nl> # ifndef __AVX2__ <nl> # error ( \ <nl> mmm a / cmake / Dependencies . cmake <nl> ppp b / cmake / Dependencies . cmake <nl> endif ( ) <nl> <nl> # mmm [ protobuf <nl> if ( USE_LITE_PROTO ) <nl> - add_definitions ( - DCAFFE2_USE_LITE_PROTO ) <nl> + set ( CAFFE2_USE_LITE_PROTO 1 ) <nl> endif ( ) <nl> <nl> # mmm [ BLAS <nl> message ( STATUS " The BLAS backend of choice : " $ { BLAS } ) <nl> <nl> if ( BLAS STREQUAL " Eigen " ) <nl> # Eigen is header - only and we do not have any dependent libraries <nl> - add_definitions ( - DCAFFE2_USE_EIGEN_FOR_BLAS ) <nl> + set ( CAFFE2_USE_EIGEN_FOR_BLAS 1 ) <nl> elseif ( BLAS STREQUAL " ATLAS " ) <nl> find_package ( Atlas REQUIRED ) <nl> include_directories ( SYSTEM $ { ATLAS_INCLUDE_DIRS } ) <nl> elseif ( BLAS STREQUAL " MKL " ) <nl> find_package ( MKL REQUIRED ) <nl> include_directories ( SYSTEM $ { MKL_INCLUDE_DIR } ) <nl> list ( APPEND Caffe2_DEPENDENCY_LIBS $ { MKL_LIBRARIES } ) <nl> - add_definitions ( - DCAFFE2_USE_MKL ) <nl> + set ( CAFFE2_USE_MKL 1 ) <nl> elseif ( BLAS STREQUAL " vecLib " ) <nl> find_package ( vecLib REQUIRED ) <nl> include_directories ( SYSTEM $ { vecLib_INCLUDE_DIR } ) <nl> endif ( ) <nl> if ( USE_GLOG ) <nl> include ( " cmake / External / glog . cmake " ) <nl> if ( GLOG_FOUND ) <nl> - add_definitions ( - DCAFFE2_USE_GOOGLE_GLOG ) <nl> + set ( CAFFE2_USE_GOOGLE_GLOG 1 ) <nl> include_directories ( SYSTEM $ { GLOG_INCLUDE_DIRS } ) <nl> list ( APPEND Caffe2_DEPENDENCY_LIBS $ { GLOG_LIBRARIES } ) <nl> else ( ) <nl> endif ( ) <nl> if ( USE_GFLAGS ) <nl> include ( " cmake / External / gflags . cmake " ) <nl> if ( GFLAGS_FOUND ) <nl> - add_definitions ( - DCAFFE2_USE_GFLAGS ) <nl> + set ( CAFFE2_USE_GFLAGS 1 ) <nl> include_directories ( SYSTEM $ { GFLAGS_INCLUDE_DIRS } ) <nl> list ( APPEND Caffe2_DEPENDENCY_LIBS $ { GFLAGS_LIBRARIES } ) <nl> else ( ) <nl> if ( USE_FFMPEG ) <nl> endif ( ) <nl> <nl> # mmm [ EIGEN <nl> - add_definitions ( - DEIGEN_MPL2_ONLY ) <nl> + set ( EIGEN_MPL2_ONLY 1 ) <nl> find_package ( Eigen3 QUIET ) <nl> if ( EIGEN3_FOUND ) <nl> include_directories ( SYSTEM $ { EIGEN3_INCLUDE_DIRS } ) <nl> if ( USE_MPI ) <nl> message ( STATUS " Found OpenMPI with CUDA support built . " ) <nl> else ( ) <nl> message ( WARNING " OpenMPI found , but it is not built with CUDA support . " ) <nl> - add_definitions ( - DCAFFE2_FORCE_FALLBACK_CUDA_MPI ) <nl> + set ( CAFFE2_FORCE_FALLBACK_CUDA_MPI 1 ) <nl> endif ( ) <nl> endif ( ) <nl> else ( ) <nl> mmm a / cmake / MiscCheck . cmake <nl> ppp b / cmake / MiscCheck . cmake <nl> if ( CAFFE2_LONG_IS_INT32_OR_64 ) <nl> message ( STATUS " Does not need to define long separately . " ) <nl> else ( ) <nl> message ( STATUS " Need to define long as a separate typeid . " ) <nl> - add_definitions ( - DCAFFE2_UNIQUE_LONG_TYPEMETA ) <nl> + set ( CAFFE2_UNIQUE_LONG_TYPEMETA 1 ) <nl> endif ( ) <nl> <nl> <nl> if ( CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS ) <nl> # in msvc . <nl> # Also see CMakeLists . txt under caffe2 / perfkernels . <nl> if ( NOT MSVC ) <nl> - add_definitions ( - DCAFFE2_PERF_WITH_AVX ) <nl> - add_definitions ( - DCAFFE2_PERF_WITH_AVX2 ) <nl> + set ( CAFFE2_PERF_WITH_AVX 1 ) <nl> + set ( CAFFE2_PERF_WITH_AVX2 1 ) <nl> endif ( ) <nl> endif ( ) <nl> <nl> | cmake : generate macros . h with configure_file ( ) | pytorch/pytorch | c1356216a272a2a52479e87e183000922e1844fc | 2017-08-22T21:22:36Z |
mmm a / aten / src / ATen / native / cuda / Activation . cu <nl> ppp b / aten / src / ATen / native / cuda / Activation . cu <nl> void elu_kernel ( TensorIterator & iter , Scalar alpha , Scalar scale , Scalar input_s <nl> auto poscoef = scale . to < scalar_t > ( ) ; <nl> auto negiptcoef = input_scale . to < scalar_t > ( ) ; <nl> gpu_kernel ( iter , [ negcoef , poscoef , negiptcoef ] GPU_LAMBDA ( scalar_t a ) - > scalar_t { <nl> - / / WARNING ( @ zasdfgbnm , 2020 - 01 - 16 ) : This is very fragile ! <nl> - / / <nl> - / / The code below does not look like a great implementation because both positive <nl> - / / and negative case are computed regardless of the condition , and you might want <nl> - / / to optimize this . But this implementation is due to a compiler bug in handling <nl> - / / branch . If we implement it in a correct way , the generated code will produce <nl> - / / wrong result . This bug should be fixed in future CUDA , but we will need this <nl> - / / workaround for maybe years until all the current CUDAs become obsolete . <nl> - / / <nl> - / / TODO : this workaround might become no longer necessary if the implementation of <nl> - / / GPU loop in ` Loops . cuh ` is changed . We should make this great again once that <nl> - / / change happens . <nl> - scalar_t positive_case = a * poscoef ; <nl> - scalar_t negative_case = ( static_cast < scalar_t > ( std : : exp ( a * negiptcoef ) ) - scalar_t ( 1 . ) ) * negcoef ; <nl> - return a > scalar_t ( 0 ) ? positive_case : negative_case ; <nl> + return a > scalar_t ( 0 ) ? a * poscoef : ( static_cast < scalar_t > ( std : : exp ( a * negiptcoef ) ) - scalar_t ( 1 . ) ) * negcoef ; <nl> } ) ; <nl> } ) ; <nl> } ) ; <nl> | Make ELU great again ( ) | pytorch/pytorch | 54e41a87eb2f8c64641cc359c5c14095e9b32b90 | 2020-02-25T01:18:30Z |
mmm a / arangod / RocksDBEngine / RocksDBCollection . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBCollection . cpp <nl> arangodb : : Result RocksDBCollection : : updateProperties ( VPackSlice const & slice , <nl> } <nl> <nl> arangodb : : Result RocksDBCollection : : persistProperties ( ) { <nl> - Result res ; <nl> - try { <nl> - VPackBuilder infoBuilder = _logicalCollection - > toVelocyPackIgnore ( <nl> - { " path " , " statusString " } , true , true ) ; <nl> - <nl> - RocksDBKey key ( RocksDBKey : : Collection ( _logicalCollection - > vocbase ( ) - > id ( ) , <nl> - _logicalCollection - > cid ( ) ) ) ; <nl> - RocksDBValue value ( RocksDBValue : : Document ( infoBuilder . slice ( ) ) ) ; <nl> - res = globalRocksDBPut ( key . string ( ) , value . string ( ) ) ; <nl> - <nl> - } catch ( arangodb : : basics : : Exception const & ex ) { <nl> - res . reset ( ex . code ( ) ) ; <nl> - } catch ( . . . ) { <nl> - res . reset ( TRI_ERROR_INTERNAL ) ; <nl> - } <nl> - <nl> - if ( res . fail ( ) ) { <nl> - / / TODO : what to do here <nl> - LOG_TOPIC ( ERR , arangodb : : Logger : : ENGINES ) <nl> - < < " could not save collection change marker in log : " <nl> - < < res . errorMessage ( ) ; <nl> - } <nl> - return res ; <nl> + / / only code path calling this causes these properties to be <nl> + / / already written in RocksDBEngine : : changeCollection ( ) <nl> + return arangodb : : Result { } ; <nl> } <nl> <nl> PhysicalCollection * RocksDBCollection : : clone ( LogicalCollection * logical , <nl> mmm a / arangod / RocksDBEngine / RocksDBEngine . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBEngine . cpp <nl> Result RocksDBEngine : : createLoggerState ( TRI_vocbase_t * vocbase , <nl> builder . add ( " running " , VPackValue ( true ) ) ; <nl> builder . add ( " lastLogTick " , VPackValue ( std : : to_string ( lastTick ) ) ) ; <nl> builder . add ( " lastUncommittedLogTick " , VPackValue ( std : : to_string ( lastTick ) ) ) ; <nl> - builder . add ( " totalEvents " , VPackValue ( 0 ) ) ; / / s . numEvents + s . numEventsSync <nl> + builder . add ( " totalEvents " , VPackValue ( lastTick ) ) ; / / s . numEvents + s . numEventsSync <nl> builder . add ( " time " , VPackValue ( utilities : : timeString ( ) ) ) ; <nl> builder . close ( ) ; <nl> <nl> mmm a / arangod / RocksDBEngine / RocksDBReplicationTailing . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBReplicationTailing . cpp <nl> static TRI_replication_operation_e convertLogType ( RocksDBLogType t ) { <nl> / / return REPLICATION_MARKER_DOCUMENT ; <nl> / / case TRI_DF_MARKER_VPACK_REMOVE : <nl> / / return REPLICATION_MARKER_REMOVE ; <nl> - case RocksDBLogType : : BeginTransaction : <nl> - return REPLICATION_TRANSACTION_START ; <nl> + / / case RocksDBLogType : : BeginTransaction : <nl> + / / return REPLICATION_TRANSACTION_START ; <nl> / / case TRI_DF_MARKER_VPACK_COMMIT_TRANSACTION : <nl> / / return REPLICATION_TRANSACTION_COMMIT ; <nl> / / case TRI_DF_MARKER_VPACK_ABORT_TRANSACTION : <nl> class WALParser : public rocksdb : : WriteBatch : : Handler { <nl> _builder . add ( <nl> " type " , <nl> VPackValue ( static_cast < uint64_t > ( REPLICATION_INDEX_CREATE ) ) ) ; <nl> - _builder . add ( " database " , VPackValue ( _currentDbId ) ) ; <nl> - _builder . add ( " cid " , VPackValue ( _currentCollectionId ) ) ; <nl> + _builder . add ( " database " , VPackValue ( std : : to_string ( _currentDbId ) ) ) ; <nl> + _builder . add ( " cid " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> _builder . add ( " data " , indexSlice ) ; <nl> _builder . close ( ) ; <nl> break ; <nl> class WALParser : public rocksdb : : WriteBatch : : Handler { <nl> _builder . add ( <nl> " type " , <nl> VPackValue ( static_cast < uint64_t > ( REPLICATION_INDEX_CREATE ) ) ) ; <nl> - _builder . add ( " database " , VPackValue ( _currentDbId ) ) ; <nl> - _builder . add ( " cid " , VPackValue ( _currentCollectionId ) ) ; <nl> + _builder . add ( " database " , VPackValue ( std : : to_string ( _currentDbId ) ) ) ; <nl> + _builder . add ( " cid " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> _builder . add ( " data " , VPackValue ( VPackValueType : : Object ) ) ; <nl> _builder . add ( " id " , VPackValue ( std : : to_string ( iid ) ) ) ; <nl> _builder . close ( ) ; <nl> class WALParser : public rocksdb : : WriteBatch : : Handler { <nl> _currentTrxId = RocksDBLogValue : : transactionId ( blob ) ; <nl> <nl> _builder . openObject ( ) ; <nl> - _builder . add ( " tick " , VPackValue ( _currentSequence ) ) ; <nl> + _builder . add ( " tick " , VPackValue ( std : : to_string ( _currentSequence ) ) ) ; <nl> _builder . add ( <nl> " type " , <nl> VPackValue ( static_cast < uint64_t > ( REPLICATION_TRANSACTION_START ) ) ) ; <nl> - _builder . add ( " database " , VPackValue ( _currentDbId ) ) ; <nl> - _builder . add ( " tid " , VPackValue ( _currentTrxId ) ) ; <nl> + _builder . add ( " database " , VPackValue ( std : : to_string ( _currentDbId ) ) ) ; <nl> + _builder . add ( " cid " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> _builder . close ( ) ; <nl> break ; <nl> } <nl> class WALParser : public rocksdb : : WriteBatch : : Handler { <nl> int res = TRI_ERROR_NO_ERROR ; <nl> switch ( RocksDBKey : : type ( key ) ) { <nl> case RocksDBEntryType : : Collection : { <nl> + usleep ( 1000000 ) ; <nl> + usleep ( 1000000 ) ; <nl> + <nl> TRI_ASSERT ( _lastLogType = = RocksDBLogType : : CollectionCreate | | <nl> _lastLogType = = RocksDBLogType : : CollectionChange | | <nl> - _lastLogType = = RocksDBLogType : : CollectionRename ) ; <nl> + _lastLogType = = RocksDBLogType : : CollectionRename | | <nl> + _lastLogType = = RocksDBLogType : : IndexCreate | | <nl> + _lastLogType = = RocksDBLogType : : IndexDrop ) ; <nl> TRI_ASSERT ( _currentDbId ! = 0 & & _currentCollectionId ! = 0 ) ; <nl> _builder . openObject ( ) ; <nl> - _builder . add ( " tick " , VPackValue ( _currentSequence ) ) ; <nl> + _builder . add ( " tick " , VPackValue ( std : : to_string ( _currentSequence ) ) ) ; <nl> _builder . add ( " type " , VPackValue ( convertLogType ( _lastLogType ) ) ) ; <nl> - _builder . add ( " database " , VPackValue ( _currentDbId ) ) ; <nl> - _builder . add ( " cid " , VPackValue ( _currentCollectionId ) ) ; <nl> + _builder . add ( " database " , VPackValue ( std : : to_string ( _currentDbId ) ) ) ; <nl> + _builder . add ( " cid " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> <nl> if ( _lastLogType = = RocksDBLogType : : CollectionRename ) { <nl> VPackSlice collectionData ( value . data ( ) ) ; <nl> class WALParser : public rocksdb : : WriteBatch : : Handler { <nl> _builder . openObject ( ) ; <nl> _builder . add ( " type " , VPackValue ( REPLICATION_MARKER_DOCUMENT ) ) ; <nl> / / auto containers = getContainerIds ( key ) ; <nl> - _builder . add ( " database " , VPackValue ( _currentDbId ) ) ; <nl> - _builder . add ( " cid " , VPackValue ( _currentCollectionId ) ) ; <nl> + _builder . add ( " database " , VPackValue ( std : : to_string ( _currentDbId ) ) ) ; <nl> + _builder . add ( " cid " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> if ( _singleOpTransaction ) { / / single op is defined to 0 <nl> - _builder . add ( " tid " , VPackValue ( 0 ) ) ; <nl> + _builder . add ( " tid " , VPackValue ( " 0 " ) ) ; <nl> } else { <nl> - _builder . add ( " tid " , VPackValue ( _currentTrxId ) ) ; <nl> + _builder . add ( " tid " , VPackValue ( std : : to_string ( _currentTrxId ) ) ) ; <nl> } <nl> _builder . add ( " data " , RocksDBValue : : data ( value ) ) ; <nl> _builder . close ( ) ; <nl> class WALParser : public rocksdb : : WriteBatch : : Handler { <nl> TRI_ASSERT ( _currentDbId ! = 0 & & _currentCollectionId ! = 0 ) ; <nl> <nl> _builder . openObject ( ) ; <nl> - _builder . add ( " tick " , VPackValue ( _currentSequence ) ) ; <nl> + _builder . add ( " tick " , VPackValue ( std : : to_string ( _currentSequence ) ) ) ; <nl> _builder . add ( " type " , VPackValue ( REPLICATION_INDEX_DROP ) ) ; <nl> - _builder . add ( " database " , VPackValue ( _currentDbId ) ) ; <nl> - _builder . add ( " cid " , VPackValue ( _currentCollectionId ) ) ; <nl> + _builder . add ( " database " , VPackValue ( std : : to_string ( _currentDbId ) ) ) ; <nl> + _builder . add ( " cid " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> _builder . add ( " data " , VPackValue ( VPackValueType : : Object ) ) ; <nl> - _builder . add ( " id " , VPackValue ( _currentCollectionId ) ) ; <nl> + _builder . add ( " id " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> _builder . add ( " name " , VPackValue ( " " ) ) ; / / not used at all <nl> _builder . close ( ) ; <nl> _builder . close ( ) ; <nl> class WALParser : public rocksdb : : WriteBatch : : Handler { <nl> _builder . add ( <nl> " type " , <nl> VPackValue ( static_cast < uint64_t > ( REPLICATION_MARKER_REMOVE ) ) ) ; <nl> - _builder . add ( " database " , VPackValue ( _currentDbId ) ) ; <nl> - _builder . add ( " cid " , VPackValue ( _currentCollectionId ) ) ; <nl> + _builder . add ( " database " , VPackValue ( std : : to_string ( _currentDbId ) ) ) ; <nl> + _builder . add ( " cid " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> if ( _singleOpTransaction ) { / / single op is defined to 0 <nl> _builder . add ( " tid " , VPackValue ( 0 ) ) ; <nl> } else { <nl> class WALParser : public rocksdb : : WriteBatch : : Handler { <nl> void endBatch ( ) { <nl> if ( _seenBeginTransaction ) { <nl> _builder . openObject ( ) ; <nl> - _builder . add ( " tick " , VPackValue ( _currentSequence ) ) ; <nl> + _builder . add ( " tick " , VPackValue ( std : : to_string ( _currentSequence ) ) ) ; <nl> _builder . add ( <nl> " type " , <nl> VPackValue ( static_cast < uint64_t > ( REPLICATION_TRANSACTION_COMMIT ) ) ) ; <nl> - _builder . add ( " database " , VPackValue ( _currentDbId ) ) ; <nl> - _builder . add ( " tid " , VPackValue ( _currentTrxId ) ) ; <nl> + _builder . add ( " database " , VPackValue ( std : : to_string ( _currentDbId ) ) ) ; <nl> + _builder . add ( " cid " , VPackValue ( std : : to_string ( _currentCollectionId ) ) ) ; <nl> _builder . close ( ) ; <nl> } <nl> _seenBeginTransaction = false ; <nl> mmm a / arangod / RocksDBEngine / RocksDBRestReplicationHandler . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBRestReplicationHandler . cpp <nl> <nl> # include " Basics / ConditionLocker . h " <nl> # include " Basics / ReadLocker . h " <nl> # include " Basics / VelocyPackHelper . h " <nl> + # include " Basics / VPackStringBufferAdapter . h " <nl> # include " Basics / conversions . h " <nl> # include " Basics / files . h " <nl> # include " Cluster / ClusterComm . h " <nl> void RocksDBRestReplicationHandler : : handleCommandLoggerFollow ( ) { <nl> if ( found ) { <nl> limit = static_cast < size_t > ( StringUtils : : uint64 ( value5 ) ) ; <nl> } <nl> - <nl> - VPackBuilder builder ; <nl> + <nl> + std : : shared_ptr < transaction : : Context > transactionContext = <nl> + transaction : : StandaloneContext : : Create ( _vocbase ) ; <nl> + <nl> + VPackBuilder builder ( transactionContext - > getVPackOptions ( ) ) ; <nl> builder . openArray ( ) ; <nl> auto result = tailWal ( _vocbase , tickStart , limit , includeSystem , builder ) ; <nl> builder . close ( ) ; <nl> void RocksDBRestReplicationHandler : : handleCommandLoggerFollow ( ) { <nl> <nl> if ( length > 0 ) { <nl> if ( useVpp ) { <nl> - auto iter = arangodb : : velocypack : : ArrayIterator ( data ) ; <nl> - auto opts = arangodb : : velocypack : : Options : : Defaults ; <nl> - for ( auto message : iter ) { <nl> - _response - > addPayload ( VPackSlice ( message ) , & opts , true ) ; <nl> + for ( auto message : arangodb : : velocypack : : ArrayIterator ( data ) ) { <nl> + _response - > addPayload ( VPackSlice ( message ) , <nl> + transactionContext - > getVPackOptions ( ) , true ) ; <nl> } <nl> } else { <nl> HttpResponse * httpResponse = <nl> void RocksDBRestReplicationHandler : : handleCommandLoggerFollow ( ) { <nl> " invalid response type " ) ; <nl> } <nl> <nl> - if ( length > 0 ) { <nl> - httpResponse - > body ( ) . appendText ( data . toJson ( ) ) ; <nl> + basics : : StringBuffer & buffer = httpResponse - > body ( ) ; <nl> + arangodb : : basics : : VPackStringBufferAdapter adapter ( buffer . stringBuffer ( ) ) ; <nl> + VPackDumper dumper ( & adapter , <nl> + transactionContext - > getVPackOptions ( ) ) ; / / note : we need the CustomTypeHandler here <nl> + for ( auto marker : arangodb : : velocypack : : ArrayIterator ( data ) ) { <nl> + dumper . dump ( marker ) ; <nl> + httpResponse - > body ( ) . appendChar ( ' \ n ' ) ; <nl> } <nl> } <nl> / / add client <nl> void RocksDBRestReplicationHandler : : handleCommandInventory ( ) { <nl> builder . add ( " running " , VPackValue ( true ) ) ; <nl> builder . add ( " lastLogTick " , VPackValue ( std : : to_string ( ctx - > lastTick ( ) ) ) ) ; <nl> builder . add ( " lastUncommittedLogTick " , <nl> - VPackValue ( std : : to_string ( 0 ) ) ) ; / / s . lastAssignedTick <nl> - builder . add ( " totalEvents " , VPackValue ( 0 ) ) ; / / s . numEvents + s . numEventsSync <nl> + VPackValue ( std : : to_string ( ctx - > lastTick ( ) ) ) ) ; / / s . lastAssignedTick <nl> + builder . add ( " totalEvents " , VPackValue ( ctx - > lastTick ( ) ) ) ; / / s . numEvents + s . numEventsSync <nl> builder . add ( " time " , VPackValue ( utilities : : timeString ( ) ) ) ; <nl> builder . close ( ) ; / / state <nl> <nl> mmm a / arangod / V8Server / v8 - replication . cpp <nl> ppp b / arangod / V8Server / v8 - replication . cpp <nl> <nl> # include " MMFiles / mmfiles - replication - dump . h " <nl> # include " RocksDBEngine / RocksDBEngine . h " <nl> # include " RocksDBEngine / RocksDBCommon . h " <nl> - <nl> + # include " RocksDBEngine / RocksDBReplicationTailing . h " <nl> # include < velocypack / Builder . h > <nl> # include < velocypack / Parser . h > <nl> # include < velocypack / Slice . h > <nl> static void JS_StateLoggerReplication ( <nl> std : : string engineName = EngineSelectorFeature : : ENGINE - > typeName ( ) ; <nl> v8 : : Handle < v8 : : Object > result = v8 : : Object : : New ( isolate ) ; <nl> <nl> - <nl> if ( engineName = = " mmfiles " ) { <nl> - v8 : : Handle < v8 : : Object > state = v8 : : Object : : New ( isolate ) ; <nl> + v8 : : Handle < v8 : : Object > state = v8 : : Object : : New ( isolate ) ; <nl> MMFilesLogfileManagerState const s = MMFilesLogfileManager : : instance ( ) - > state ( ) ; <nl> state - > Set ( TRI_V8_ASCII_STRING ( " running " ) , v8 : : True ( isolate ) ) ; <nl> state - > Set ( TRI_V8_ASCII_STRING ( " lastLogTick " ) , <nl> TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , s . lastCommittedTick ) ) ; <nl> - state - > Set ( TRI_V8_ASCII_STRING ( " lastUncommittedLogTick " ) , TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , s . lastAssignedTick ) ) ; <nl> + state - > Set ( TRI_V8_ASCII_STRING ( " lastUncommittedLogTick " ) , <nl> + TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , s . lastAssignedTick ) ) ; <nl> state - > Set ( TRI_V8_ASCII_STRING ( " totalEvents " ) , <nl> v8 : : Number : : New ( isolate , static_cast < double > ( s . numEvents + s . numEventsSync ) ) ) ; <nl> state - > Set ( TRI_V8_ASCII_STRING ( " time " ) , TRI_V8_STD_STRING ( s . timeString ) ) ; <nl> static void JS_StateLoggerReplication ( <nl> auto res = rocksutils : : globalRocksEngine ( ) - > createLoggerState ( nullptr , builder ) ; <nl> if ( res . fail ( ) ) { <nl> TRI_V8_THROW_EXCEPTION ( res ) ; <nl> - return ; <nl> } <nl> v8 : : Handle < v8 : : Value > resultValue = TRI_VPackToV8 ( isolate , builder . slice ( ) ) ; <nl> result = v8 : : Handle < v8 : : Object > : : Cast ( resultValue ) ; <nl> } else { <nl> TRI_V8_THROW_EXCEPTION_MESSAGE ( TRI_ERROR_INTERNAL , " invalid storage engine " ) ; <nl> - return ; <nl> } <nl> <nl> TRI_V8_RETURN ( result ) ; <nl> static void JS_TickRangesLoggerReplication ( <nl> v8 : : FunctionCallbackInfo < v8 : : Value > const & args ) { <nl> TRI_V8_TRY_CATCH_BEGIN ( isolate ) ; <nl> v8 : : HandleScope scope ( isolate ) ; <nl> - <nl> + v8 : : Handle < v8 : : Array > result ; <nl> + <nl> std : : string engineName = EngineSelectorFeature : : ENGINE - > typeName ( ) ; <nl> - if ( engineName ! = " mmfiles " ) { <nl> - TRI_V8_THROW_EXCEPTION_MESSAGE ( TRI_ERROR_INTERNAL , " only implemented for mmfiles engine " ) ; <nl> - return ; <nl> - } <nl> - <nl> - auto const & ranges = MMFilesLogfileManager : : instance ( ) - > ranges ( ) ; <nl> - <nl> - v8 : : Handle < v8 : : Array > result = v8 : : Array : : New ( isolate , ( int ) ranges . size ( ) ) ; <nl> - uint32_t i = 0 ; <nl> - <nl> - for ( auto & it : ranges ) { <nl> - v8 : : Handle < v8 : : Object > df = v8 : : Object : : New ( isolate ) ; <nl> - <nl> - df - > ForceSet ( TRI_V8_ASCII_STRING ( " datafile " ) , TRI_V8_STD_STRING ( it . filename ) ) ; <nl> - df - > ForceSet ( TRI_V8_ASCII_STRING ( " state " ) , TRI_V8_STD_STRING ( it . state ) ) ; <nl> - df - > ForceSet ( TRI_V8_ASCII_STRING ( " tickMin " ) , TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , it . tickMin ) ) ; <nl> - df - > ForceSet ( TRI_V8_ASCII_STRING ( " tickMax " ) , TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , it . tickMax ) ) ; <nl> - <nl> - result - > Set ( i + + , df ) ; <nl> + if ( engineName = = " mmfiles " ) { <nl> + auto const & ranges = MMFilesLogfileManager : : instance ( ) - > ranges ( ) ; <nl> + result = v8 : : Array : : New ( isolate , ( int ) ranges . size ( ) ) ; <nl> + <nl> + uint32_t i = 0 ; <nl> + <nl> + for ( auto & it : ranges ) { <nl> + v8 : : Handle < v8 : : Object > df = v8 : : Object : : New ( isolate ) ; <nl> + <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " datafile " ) , TRI_V8_STD_STRING ( it . filename ) ) ; <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " state " ) , TRI_V8_STD_STRING ( it . state ) ) ; <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " tickMin " ) , TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , it . tickMin ) ) ; <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " tickMax " ) , TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , it . tickMax ) ) ; <nl> + <nl> + result - > Set ( i + + , df ) ; <nl> + } <nl> + } else if ( engineName = = " rocksdb " ) { <nl> + rocksdb : : TransactionDB * tdb = rocksutils : : globalRocksDB ( ) ; <nl> + rocksdb : : VectorLogPtr walFiles ; <nl> + rocksdb : : Status s = tdb - > GetSortedWalFiles ( walFiles ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + Result r = rocksutils : : convertStatus ( s ) ; <nl> + TRI_V8_THROW_EXCEPTION_MESSAGE ( r . errorNumber ( ) , r . errorMessage ( ) ) ; <nl> + } <nl> + <nl> + result = v8 : : Array : : New ( isolate , ( int ) walFiles . size ( ) ) ; <nl> + for ( uint32_t i = 0 ; i < walFiles . size ( ) ; i + + ) { <nl> + std : : unique_ptr < rocksdb : : LogFile > & logfile = walFiles [ i ] ; <nl> + <nl> + v8 : : Handle < v8 : : Object > df = v8 : : Object : : New ( isolate ) ; <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " datafile " ) , TRI_V8_STD_STRING ( logfile - > PathName ( ) ) ) ; <nl> + / / setting state of each file <nl> + if ( logfile - > Type ( ) = = rocksdb : : WalFileType : : kAliveLogFile ) { <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " state " ) , TRI_V8_STRING ( " open " ) ) ; <nl> + } else if ( logfile - > Type ( ) = = rocksdb : : WalFileType : : kArchivedLogFile ) { <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " state " ) , TRI_V8_STRING ( " collected " ) ) ; <nl> + } <nl> + rocksdb : : SequenceNumber min = logfile - > StartSequence ( ) ; <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " tickMin " ) , <nl> + TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , min ) ) ; <nl> + <nl> + rocksdb : : SequenceNumber max = UINT64_MAX ; <nl> + if ( i + 1 < walFiles . size ( ) ) { <nl> + max = walFiles [ i + 1 ] - > StartSequence ( ) ; <nl> + } <nl> + df - > ForceSet ( TRI_V8_ASCII_STRING ( " tickMax " ) , <nl> + TRI_V8UInt64String < rocksdb : : SequenceNumber > ( isolate , max ) ) ; <nl> + <nl> + result - > Set ( i + + , df ) ; <nl> + } <nl> + } else { <nl> + TRI_V8_THROW_EXCEPTION_MESSAGE ( TRI_ERROR_INTERNAL , " invalid storage engine " ) ; <nl> } <nl> - <nl> TRI_V8_RETURN ( result ) ; <nl> TRI_V8_TRY_CATCH_END <nl> } <nl> static void JS_FirstTickLoggerReplication ( <nl> TRI_V8_TRY_CATCH_BEGIN ( isolate ) ; <nl> v8 : : HandleScope scope ( isolate ) ; <nl> <nl> - std : : string engineName = EngineSelectorFeature : : ENGINE - > typeName ( ) ; <nl> - if ( engineName ! = " mmfiles " ) { <nl> - TRI_V8_THROW_EXCEPTION_MESSAGE ( TRI_ERROR_INTERNAL , " only implemented for mmfiles engine " ) ; <nl> - return ; <nl> - } <nl> - <nl> - auto const & ranges = MMFilesLogfileManager : : instance ( ) - > ranges ( ) ; <nl> - <nl> TRI_voc_tick_t tick = UINT64_MAX ; <nl> - <nl> - for ( auto & it : ranges ) { <nl> - if ( it . tickMin = = 0 ) { <nl> - continue ; <nl> + std : : string engineName = EngineSelectorFeature : : ENGINE - > typeName ( ) ; <nl> + if ( engineName = = " mmfiles " ) { <nl> + auto const & ranges = MMFilesLogfileManager : : instance ( ) - > ranges ( ) ; <nl> + <nl> + <nl> + for ( auto & it : ranges ) { <nl> + if ( it . tickMin = = 0 ) { <nl> + continue ; <nl> + } <nl> + <nl> + if ( it . tickMin < tick ) { <nl> + tick = it . tickMin ; <nl> + } <nl> } <nl> - <nl> - if ( it . tickMin < tick ) { <nl> - tick = it . tickMin ; <nl> + } else if ( engineName = = " rocksdb " ) { <nl> + rocksdb : : TransactionDB * tdb = rocksutils : : globalRocksDB ( ) ; <nl> + rocksdb : : VectorLogPtr walFiles ; <nl> + rocksdb : : Status s = tdb - > GetSortedWalFiles ( walFiles ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + Result r = rocksutils : : convertStatus ( s ) ; <nl> + TRI_V8_THROW_EXCEPTION_MESSAGE ( r . errorNumber ( ) , r . errorMessage ( ) ) ; <nl> + } <nl> + / / read minium possible tick <nl> + if ( ! walFiles . empty ( ) ) { <nl> + tick = walFiles [ 0 ] - > StartSequence ( ) ; <nl> } <nl> + } else { <nl> + TRI_V8_THROW_EXCEPTION_MESSAGE ( TRI_ERROR_INTERNAL , " invalid storage engine " ) ; <nl> } <nl> - <nl> if ( tick = = UINT64_MAX ) { <nl> TRI_V8_RETURN ( v8 : : Null ( isolate ) ) ; <nl> } <nl> - <nl> + <nl> TRI_V8_RETURN ( TRI_V8UInt64String < TRI_voc_tick_t > ( isolate , tick ) ) ; <nl> TRI_V8_TRY_CATCH_END <nl> } <nl> static void JS_LastLoggerReplication ( <nl> v8 : : FunctionCallbackInfo < v8 : : Value > const & args ) { <nl> TRI_V8_TRY_CATCH_BEGIN ( isolate ) ; <nl> v8 : : HandleScope scope ( isolate ) ; <nl> - <nl> - std : : string engineName = EngineSelectorFeature : : ENGINE - > typeName ( ) ; <nl> - if ( engineName ! = " mmfiles " ) { <nl> - TRI_V8_THROW_EXCEPTION_MESSAGE ( TRI_ERROR_INTERNAL , " only implemented for mmfiles engine " ) ; <nl> - return ; <nl> - } <nl> - <nl> + <nl> TRI_vocbase_t * vocbase = GetContextVocBase ( isolate ) ; <nl> - <nl> + <nl> if ( vocbase = = nullptr ) { <nl> TRI_V8_THROW_EXCEPTION ( TRI_ERROR_ARANGO_DATABASE_NOT_FOUND ) ; <nl> } <nl> - <nl> + <nl> if ( args . Length ( ) ! = 2 ) { <nl> TRI_V8_THROW_EXCEPTION_USAGE ( <nl> - " REPLICATION_LOGGER_LAST ( < fromTick > , < toTick > ) " ) ; <nl> + " REPLICATION_LOGGER_LAST ( < fromTick > , < toTick > ) " ) ; <nl> } <nl> - <nl> - auto transactionContext = std : : make_shared < transaction : : StandaloneContext > ( vocbase ) ; <nl> - <nl> - MMFilesReplicationDumpContext dump ( transactionContext , 0 , true , 0 ) ; <nl> TRI_voc_tick_t tickStart = TRI_ObjectToUInt64 ( args [ 0 ] , true ) ; <nl> TRI_voc_tick_t tickEnd = TRI_ObjectToUInt64 ( args [ 1 ] , true ) ; <nl> + <nl> + v8 : : Handle < v8 : : Value > result ; <nl> + std : : string engineName = EngineSelectorFeature : : ENGINE - > typeName ( ) ; <nl> + if ( engineName = = " mmfiles " ) { <nl> + auto transactionContext = std : : make_shared < transaction : : StandaloneContext > ( vocbase ) ; <nl> + <nl> + MMFilesReplicationDumpContext dump ( transactionContext , 0 , true , 0 ) ; <nl> + <nl> + <nl> + int res = MMFilesDumpLogReplication ( & dump , std : : unordered_set < TRI_voc_tid_t > ( ) , <nl> + 0 , tickStart , tickEnd , true ) ; <nl> + <nl> + if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> + TRI_V8_THROW_EXCEPTION ( res ) ; <nl> + } <nl> + / / parsing JSON <nl> + VPackParser parser ; <nl> + parser . parse ( dump . _buffer - > _buffer ) ; <nl> + result = TRI_VPackToV8 ( isolate , VPackSlice ( parser . start ( ) ) ) ; <nl> <nl> - int res = MMFilesDumpLogReplication ( & dump , std : : unordered_set < TRI_voc_tid_t > ( ) , <nl> - 0 , tickStart , tickEnd , true ) ; <nl> - <nl> - if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - TRI_V8_THROW_EXCEPTION ( res ) ; <nl> + } else if ( engineName = = " rocksdb " ) { <nl> + bool includeSystem = true ; <nl> + size_t limit = 10000 ; / / TODO : determine good default value ? <nl> + <nl> + / / construct vocbase with proper handler <nl> + std : : shared_ptr < transaction : : Context > transactionContext = <nl> + transaction : : StandaloneContext : : Create ( vocbase ) ; <nl> + VPackBuilder builder ( transactionContext - > getVPackOptions ( ) ) ; <nl> + <nl> + builder . openArray ( ) ; <nl> + RocksDBReplicationResult rep = rocksutils : : tailWal ( vocbase , tickStart , limit , <nl> + includeSystem , builder ) ; <nl> + builder . close ( ) ; <nl> + <nl> + if ( rep . ok ( ) ) { <nl> + result = TRI_VPackToV8 ( isolate , builder . slice ( ) ) ; <nl> + } else { <nl> + result = v8 : : Null ( isolate ) ; <nl> + } <nl> + } else { <nl> + TRI_V8_THROW_EXCEPTION_MESSAGE ( TRI_ERROR_INTERNAL , " invalid storage engine " ) ; <nl> } <nl> <nl> - VPackParser parser ; <nl> - parser . parse ( dump . _buffer - > _buffer ) ; <nl> - <nl> - std : : shared_ptr < VPackBuilder > builder = parser . steal ( ) ; <nl> - <nl> - v8 : : Handle < v8 : : Value > result = TRI_VPackToV8 ( isolate , builder - > slice ( ) ) ; <nl> - <nl> TRI_V8_RETURN ( result ) ; <nl> TRI_V8_TRY_CATCH_END <nl> } <nl> mmm a / etc / testing / arangod - common . conf <nl> ppp b / etc / testing / arangod - common . conf <nl> threads = 20 <nl> <nl> [ ssl ] <nl> keyfile = @ TOP_DIR @ / UnitTests / server . pem <nl> - <nl> - [ cluster ] <nl> - system - replication - factor = 1 <nl> mmm a / js / common / tests / replication / replication . js <nl> ppp b / js / common / tests / replication / replication . js <nl> function ReplicationLoggerSuite ( ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> testFirstTick : function ( ) { <nl> + if ( db . _engine ( ) . name = = = " mmfiles " ) { <nl> + return ; <nl> + } <nl> + <nl> var state = replication . logger . state ( ) . state ; <nl> assertTrue ( state . running ) ; <nl> var tick = state . lastLogTick ; <nl> function ReplicationLoggerSuite ( ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> testTickRanges : function ( ) { <nl> + if ( db . _engine ( ) . name = = = " mmfiles " ) { <nl> + return ; <nl> + } <nl> + <nl> var state = replication . logger . state ( ) . state ; <nl> assertTrue ( state . running ) ; <nl> var tick = state . lastLogTick ; <nl> | Fixed broken JSON output | arangodb/arangodb | 0a00a7eb67ea0edea9e0cca1fbb228303f24a42c | 2017-04-28T12:28:34Z |
deleted file mode 100644 <nl> index d7c1cc2d7ef . . 00000000000 <nl> mmm a / modules / tools / lattice_autotuning / generate_future_adc_trajectory . py <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env python <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # Copyright 2018 The Apollo Authors . All Rights Reserved . <nl> - # <nl> - # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - # you may not use this file except in compliance with the License . <nl> - # You may obtain a copy of the License at <nl> - # <nl> - # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - # <nl> - # Unless required by applicable law or agreed to in writing , software <nl> - # distributed under the License is distributed on an " AS IS " BASIS , <nl> - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - # See the License for the specific language governing permissions and <nl> - # limitations under the License . <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - <nl> - import os <nl> - import sys <nl> - import argparse <nl> - import rosbag <nl> - import genpy <nl> - import glob <nl> - import math <nl> - from std_msgs . msg import String <nl> - import numpy as np <nl> - <nl> - import common . proto_utils as proto_utils <nl> - from modules . localization . proto . localization_pb2 import LocalizationEstimate <nl> - <nl> - import logging <nl> - logging . basicConfig ( level = logging . DEBUG ) <nl> - <nl> - <nl> - def generate_future_pose_list ( rosbag_in , period ) : <nl> - # iteration to generate total trajectory <nl> - total_adc_trajectory = [ ] <nl> - with rosbag . Bag ( rosbag_in , ' r ' ) as bag_in : <nl> - for topic , localization , t in bag_in . read_messages ( ) : <nl> - if topic = = ' / apollo / localization / pose ' : <nl> - total_adc_trajectory . append ( ( t . to_sec ( ) , localization . pose ) ) <nl> - print ( " Total # Frames for Localization = " + str ( len ( total_adc_trajectory ) ) ) <nl> - <nl> - # dedup trajectory by position <nl> - ret = [ ] <nl> - remove_index_list = [ ] <nl> - for i in range ( len ( total_adc_trajectory ) - 1 ) : <nl> - # pair wise <nl> - curr_pose = total_adc_trajectory [ i ] [ 1 ] <nl> - next_pose = total_adc_trajectory [ i + 1 ] [ 1 ] <nl> - ds = math . sqrt ( <nl> - ( curr_pose . position . x - next_pose . position . x ) * <nl> - ( curr_pose . position . x - next_pose . position . x ) + <nl> - ( curr_pose . position . y - next_pose . position . y ) * <nl> - ( curr_pose . position . y - next_pose . position . y ) ) <nl> - if ds < 0 . 001 : <nl> - remove_index_list . append ( i ) <nl> - remove_index_list = set ( remove_index_list ) <nl> - for i in range ( len ( total_adc_trajectory ) ) : <nl> - if i in remove_index_list : <nl> - continue <nl> - ret . append ( total_adc_trajectory [ i ] ) <nl> - return ret <nl> - <nl> - <nl> - def generate_future_traj ( rosbag_in , rosbag_out , future_pose_list ) : <nl> - # Write to bag <nl> - ptr_start = 0 <nl> - ptr_end = 800 <nl> - if ( len ( future_pose_list ) < ptr_end ) : <nl> - return <nl> - with rosbag . Bag ( rosbag_in , ' r ' ) as bag_in , \ <nl> - rosbag . Bag ( rosbag_out , ' w ' ) as bag_out : <nl> - for topic , msg , t in bag_in . read_messages ( ) : <nl> - if topic = = ' / apollo / localization / pose ' and \ <nl> - ptr_end < len ( future_pose_list ) : <nl> - # Augment localization with future localization <nl> - new_localization = msg <nl> - augment_future_traj ( new_localization , ptr_start , ptr_end , <nl> - future_pose_list ) <nl> - bag_out . write ( topic , new_localization , t ) <nl> - print ( " Write to bag start = " , ptr_start , " end = " , ptr_end ) <nl> - ptr_start + = 1 <nl> - ptr_end + = 1 <nl> - else : <nl> - bag_out . write ( topic , msg , t ) <nl> - <nl> - <nl> - def augment_future_traj ( new_localization , ptr_start , ptr_end , pose_list ) : <nl> - # Convert a list of pose to traj <nl> - sum_s = 0 . 0 <nl> - relative_time = 0 . 0 <nl> - for i in range ( ptr_start , ptr_end - 1 ) : <nl> - trajectory_point = new_localization . trajectory_point . add ( ) <nl> - pose1 = pose_list [ i ] [ 1 ] <nl> - pose2 = pose_list [ i + 1 ] [ 1 ] <nl> - trajectory_point . path_point . x = pose1 . position . x <nl> - trajectory_point . path_point . y = pose1 . position . y <nl> - trajectory_point . path_point . z = pose1 . position . z <nl> - trajectory_point . path_point . theta = pose1 . heading <nl> - ds = math . sqrt ( ( pose2 . position . y - pose1 . position . y ) * <nl> - ( pose2 . position . y - pose1 . position . y ) + <nl> - ( pose2 . position . x - pose1 . position . x ) * <nl> - ( pose2 . position . x - pose1 . position . x ) ) <nl> - trajectory_point . path_point . kappa = \ <nl> - ( pose2 . heading - pose1 . heading ) / ds <nl> - trajectory_point . path_point . s = sum_s <nl> - sum_s + = ds <nl> - trajectory_point . v = math . sqrt ( <nl> - ( pose1 . linear_velocity . x - pose2 . linear_velocity . x ) * <nl> - ( pose1 . linear_velocity . x - pose2 . linear_velocity . x ) + <nl> - ( pose1 . linear_velocity . y - pose2 . linear_velocity . y ) * <nl> - ( pose1 . linear_velocity . y - pose2 . linear_velocity . y ) ) <nl> - trajectory_point . a = math . sqrt ( <nl> - ( pose1 . linear_acceleration . x - pose2 . linear_acceleration . x ) * <nl> - ( pose1 . linear_acceleration . x - pose2 . linear_acceleration . x ) + <nl> - ( pose1 . linear_acceleration . y - pose2 . linear_acceleration . y ) * <nl> - ( pose1 . linear_acceleration . y - pose2 . linear_acceleration . y ) ) <nl> - trajectory_point . relative_time = relative_time <nl> - relative_time + = pose_list [ i + 1 ] [ 0 ] - pose_list [ i ] [ 0 ] <nl> - # not setting dkappa <nl> - <nl> - # last point <nl> - last_trajectory_point = new_localization . trajectory_point . add ( ) <nl> - last_pose = pose_list [ ptr_end - 1 ] [ 1 ] <nl> - last_trajectory_point . path_point . x = last_pose . position . x <nl> - last_trajectory_point . path_point . y = last_pose . position . y <nl> - last_trajectory_point . path_point . z = last_pose . position . z <nl> - last_trajectory_point . path_point . theta = last_pose . heading <nl> - # kappa is from previous trajectory_point <nl> - last_idx = len ( new_localization . trajectory_point ) - 1 <nl> - last_trajectory_point . path_point . kappa = \ <nl> - new_localization . trajectory_point [ last_idx ] . path_point . kappa <nl> - last_trajectory_point . path_point . s = sum_s <nl> - trajectory_point . relative_time = relative_time <nl> - <nl> - <nl> - if __name__ = = ' __main__ ' : <nl> - parser = argparse . ArgumentParser ( <nl> - description = " Generate future trajectory based on localization " ) <nl> - parser . add_argument ( ' path ' , type = str , help = ' rosbag file or directory ' ) <nl> - parser . add_argument ( ' period ' , type = float , default = 3 . 0 , <nl> - help = ' duration for future trajectory ' ) <nl> - args = parser . parse_args ( ) <nl> - path = args . path <nl> - period = args . period <nl> - if not os . path . exists ( path ) : <nl> - logging . error ( " Fail to find path : { } " . format ( path ) ) <nl> - os . _exists ( - 1 ) <nl> - if os . path . isdir ( path ) : <nl> - pass <nl> - if os . path . isfile ( path ) : <nl> - bag_name = os . path . splitext ( os . path . basename ( path ) ) [ 0 ] <nl> - path_out = os . path . dirname ( path ) + ' / ' + bag_name + \ <nl> - ' _with_future_trajectory . bag ' <nl> - future_pose_list = generate_future_pose_list ( path , period ) <nl> - generate_future_traj ( path , path_out , future_pose_list ) <nl> deleted file mode 100755 <nl> index 6eb9bf2adcf . . 00000000000 <nl> mmm a / modules / tools / map_gen / create_traffic_light_from_event . py <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env python <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # Copyright 2017 The Apollo Authors . All Rights Reserved . <nl> - # <nl> - # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - # you may not use this file except in compliance with the License . <nl> - # You may obtain a copy of the License at <nl> - # <nl> - # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - # <nl> - # Unless required by applicable law or agreed to in writing , software <nl> - # distributed under the License is distributed on an " AS IS " BASIS , <nl> - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - # See the License for the specific language governing permissions and <nl> - # limitations under the License . <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - " " " <nl> - This program can create a traffic light protobuf from localization message <nl> - " " " <nl> - <nl> - import rosbag <nl> - import std_msgs <nl> - import argparse <nl> - import shutil <nl> - import os <nl> - import rospy <nl> - import sys <nl> - import math <nl> - <nl> - from std_msgs . msg import String <nl> - <nl> - import common . proto_utils as proto_utils <nl> - from common . message_manager import PbMessageManager <nl> - <nl> - from modules . map . proto import map_signal_pb2 <nl> - from modules . map . proto import map_geometry_pb2 <nl> - <nl> - g_message_manager = PbMessageManager ( ) <nl> - <nl> - g_args = None <nl> - # mkz vehicle configuration <nl> - g_front_to_center = 4 . 0 <nl> - g_left_to_center = 1 . 043 + 0 . 5 <nl> - g_right_to_center = 1 . 043 + 0 . 5 <nl> - g_lane_width = 3 . 7 <nl> - <nl> - <nl> - def create_stop_line ( center_x , center_y , heading ) : <nl> - " " " create a stop line from center point " " " <nl> - left_x = center_x + g_left_to_center * math . cos ( heading + math . pi / 2 . 0 ) <nl> - left_y = center_y + g_left_to_center * math . sin ( heading + math . pi / 2 . 0 ) <nl> - right_x = center_x + g_right_to_center * math . cos ( heading - math . pi / 2 . 0 ) <nl> - right_y = center_y + g_right_to_center * math . sin ( heading - math . pi / 2 . 0 ) <nl> - stop_line = map_geometry_pb2 . Curve ( ) <nl> - curve_segment = stop_line . segment . add ( ) <nl> - left_point = curve_segment . line_segment . point . add ( ) <nl> - left_point . x = left_x <nl> - left_point . y = left_y <nl> - center_point = curve_segment . line_segment . point . add ( ) <nl> - center_point . x = center_x <nl> - center_point . y = center_y <nl> - right_point = curve_segment . line_segment . point . add ( ) <nl> - right_point . x = right_x <nl> - right_point . y = right_y <nl> - return stop_line <nl> - <nl> - <nl> - def create_signal_proto ( x , y , heading ) : <nl> - # mkz vehicle configuration <nl> - <nl> - center_x = x + g_front_to_center * math . cos ( heading ) <nl> - center_y = y + g_front_to_center * math . sin ( heading ) <nl> - <nl> - map_signal = map_signal_pb2 . Signal ( ) <nl> - <nl> - map_signal . id . id = " % 2 . 5f_ % 2 . 5f " % ( center_x , center_y ) <nl> - <nl> - map_signal . type = map_signal_pb2 . Signal . MIX_3_VERTICAL <nl> - <nl> - # left subsignal <nl> - left_subsignal = map_signal . subsignal . add ( ) <nl> - left_x = center_x + g_left_to_center * math . cos ( heading + math . pi / 2 . 0 ) <nl> - left_y = center_y + g_left_to_center * math . sin ( heading + math . pi / 2 . 0 ) <nl> - left_subsignal . id . id = " % 2 . 5f_ % 2 . 5f " % ( left_x , left_y ) <nl> - left_subsignal . type = map_signal_pb2 . Subsignal . CIRCLE <nl> - left_subsignal . location . x = left_x <nl> - left_subsignal . location . y = left_y <nl> - left_subsignal . location . z = 5 . 0 <nl> - <nl> - stopline = map_signal . stop_line . add ( ) <nl> - stopline . CopyFrom ( create_stop_line ( center_x , center_y , heading ) ) <nl> - <nl> - if g_args . extend_to_neighbor_lane : <nl> - # add stop line on left lane <nl> - left_shift_x = center_x + g_lane_width * math . cos ( <nl> - heading + math . pi / 2 . 0 ) <nl> - left_shift_y = center_y + g_lane_width * math . sin ( <nl> - heading + math . pi / 2 . 0 ) <nl> - stopline = map_signal . stop_line . add ( ) <nl> - stopline . CopyFrom ( <nl> - create_stop_line ( left_shift_x , left_shift_y , heading ) ) <nl> - <nl> - # add stop line on right lane <nl> - right_shift_x = center_x + g_lane_width * math . cos ( <nl> - heading - math . pi / 2 . 0 ) <nl> - right_shift_y = center_y + g_lane_width * math . sin ( <nl> - heading - math . pi / 2 . 0 ) <nl> - stopline = map_signal . stop_line . add ( ) <nl> - stopline . CopyFrom ( <nl> - create_stop_line ( right_shift_x , right_shift_y , heading ) ) <nl> - <nl> - return map_signal <nl> - <nl> - <nl> - def parse_drive_event_file ( drive_event_filename , signal_filename ) : <nl> - drive_event = g_message_manager . parse_topic_file ( " / apollo / drive_event " , <nl> - drive_event_filename ) <nl> - if not drive_event : <nl> - print ( " Failed to find localization in % s " % drive_event_filename ) <nl> - return None <nl> - <nl> - pose = drive_event . location <nl> - map_signal = create_signal_proto ( pose . position . x , pose . position . y , <nl> - pose . heading ) <nl> - proto_utils . write_pb_to_text_file ( map_signal , signal_filename ) <nl> - return map_signal <nl> - <nl> - <nl> - if __name__ = = " __main__ " : <nl> - parser = argparse . ArgumentParser ( <nl> - description = " A tool to create traffic light protobuf message from localization . " ) <nl> - parser . add_argument ( <nl> - " drive_event_filename " , <nl> - action = " store " , <nl> - help = " " " the drive event file name " " " ) <nl> - parser . add_argument ( <nl> - " signal_filename " , action = " store " , help = " " " the signal file name " " " ) <nl> - parser . add_argument ( <nl> - " - - extend_to_neighbor_lane " , <nl> - action = " store_true " , <nl> - help = " " " the signal file name " " " ) <nl> - g_args = parser . parse_args ( ) <nl> - parse_drive_event_file ( g_args . drive_event_filename , g_args . signal_filename ) <nl> deleted file mode 100644 <nl> index 80f361087cd . . 00000000000 <nl> mmm a / modules / tools / navigator / extractor . py <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env python <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # Copyright 2017 The Apollo Authors . All Rights Reserved . <nl> - # <nl> - # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - # you may not use this file except in compliance with the License . <nl> - # You may obtain a copy of the License at <nl> - # <nl> - # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - # <nl> - # Unless required by applicable law or agreed to in writing , software <nl> - # distributed under the License is distributed on an " AS IS " BASIS , <nl> - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - # See the License for the specific language governing permissions and <nl> - # limitations under the License . <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - <nl> - import sys <nl> - import datetime <nl> - import rosbag <nl> - <nl> - if __name__ = = ' __main__ ' : <nl> - fbags = sys . argv [ 1 : ] <nl> - <nl> - fbag = fbags [ 0 ] <nl> - now = datetime . datetime . now ( ) . strftime ( " % Y - % m - % d_ % H . % M . % S " ) <nl> - f = open ( " path_ " + fbag . split ( ' / ' ) [ - 1 ] + " . txt " , ' w ' ) <nl> - <nl> - for fbag in fbags : <nl> - print ( fbag ) <nl> - bag = rosbag . Bag ( fbag ) <nl> - for topic , localization_pb , t in bag . read_messages ( <nl> - topics = [ ' / apollo / localization / pose ' ] ) : <nl> - x = localization_pb . pose . position . x <nl> - y = localization_pb . pose . position . y <nl> - f . write ( str ( x ) + " , " + str ( y ) + " \ n " ) <nl> - bag . close ( ) <nl> - f . close ( ) <nl> deleted file mode 100755 <nl> index 6b68552330f . . 00000000000 <nl> mmm a / modules / tools / rosbag / copy_bags_between_disks . py <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env python <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # Copyright 2018 The Apollo Authors . All Rights Reserved . <nl> - # <nl> - # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - # you may not use this file except in compliance with the License . <nl> - # You may obtain a copy of the License at <nl> - # <nl> - # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - # <nl> - # Unless required by applicable law or agreed to in writing , software <nl> - # distributed under the License is distributed on an " AS IS " BASIS , <nl> - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - # See the License for the specific language governing permissions and <nl> - # limitations under the License . <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - <nl> - " " " <nl> - Copy bags between disks . <nl> - " " " <nl> - <nl> - from __future__ import print_function <nl> - import argparse <nl> - import glob <nl> - import os <nl> - import shutil <nl> - import sys <nl> - <nl> - from rosbag . bag import Bag <nl> - import psutil <nl> - <nl> - from modules . canbus . proto . chassis_pb2 import Chassis <nl> - <nl> - K_CHASSIS_TOPIC = ' / apollo / canbus / chassis ' <nl> - K_DRIVE_EVENT_TOPIC = ' / apollo / drive_event ' <nl> - <nl> - K_LARGE_SIZE_TOPICS = set ( [ <nl> - ' / apollo / sensor / camera / obstacle / front_6mm ' , <nl> - ' / apollo / sensor / camera / traffic / image_long ' , <nl> - ' / apollo / sensor / camera / traffic / image_short ' , <nl> - ' / apollo / sensor / velodyne64 / compensator / PointCloud2 ' , <nl> - ] ) <nl> - K_COPY_LARGE_SIZE_TOPICS_SECONDS_BEFORE_EVENT = 20 . 0 <nl> - <nl> - <nl> - def GetDisks ( ) : <nl> - " " " Get disks , which should be mounted under / media . " " " <nl> - <nl> - disks = [ disk . mountpoint for disk in psutil . disk_partitions ( ) <nl> - if disk . mountpoint . startswith ( ' / media / ' ) ] <nl> - disks . append ( ' / apollo ' ) <nl> - # The disks are sorted like <nl> - # / media / apollo / internal_nvme <nl> - # / media / apollo / apollo8 <nl> - # / apollo <nl> - disks = sorted ( disks , reverse = True ) <nl> - if len ( disks ) < = 1 : <nl> - print ( ' Cannot find disks . ' ) <nl> - sys . exit ( 1 ) <nl> - <nl> - copy_from = None <nl> - copy_to = None <nl> - for index , disk in enumerate ( disks ) : <nl> - print ( ' \ t { } : { } ' . format ( index , disk ) ) <nl> - try : <nl> - selected = int ( input ( ' Which disk do you want to copy from : ' ) ) <nl> - copy_from = disks [ selected ] <nl> - except : <nl> - print ( ' Bad input ' ) <nl> - sys . exit ( 1 ) <nl> - <nl> - for index , disk in enumerate ( disks ) : <nl> - if index ! = selected : <nl> - print ( ' \ t { } : { } ' . format ( index , disk ) ) <nl> - try : <nl> - selected = int ( input ( ' Which disk do you want to copy to : ' ) ) <nl> - copy_to = disks [ selected ] <nl> - except : <nl> - print ( ' Bad input ' ) <nl> - sys . exit ( 1 ) <nl> - <nl> - if copy_from and copy_to and ( copy_from ! = copy_to ) : <nl> - print ( ' Copy disk : { } - > { } ' . format ( copy_from , copy_to ) ) <nl> - else : <nl> - sys . exit ( 1 ) <nl> - return copy_from , copy_to <nl> - <nl> - <nl> - def CollectEvents ( bags ) : <nl> - " " " Collect interested event timestamps . " " " <nl> - <nl> - print ( ' Collecting events . . . ' , end = ' ' ) <nl> - events = [ ] <nl> - cur_driving_mode = None <nl> - for bag_file in bags : <nl> - with Bag ( bag_file , ' r ' ) as bag : <nl> - for topic , msg , t in bag . read_messages ( topics = [ K_CHASSIS_TOPIC , <nl> - K_DRIVE_EVENT_TOPIC ] ) : <nl> - # For disengagement , take the message time as event time . <nl> - if topic = = K_CHASSIS_TOPIC : <nl> - if ( cur_driving_mode = = Chassis . COMPLETE_AUTO_DRIVE and <nl> - msg . driving_mode = = Chassis . EMERGENCY_MODE ) : <nl> - events . append ( t . to_sec ( ) ) <nl> - cur_driving_mode = msg . driving_mode <nl> - # For DriveEvent , take the header time as event time . <nl> - elif topic = = K_DRIVE_EVENT_TOPIC : <nl> - events . append ( msg . header . timestamp_sec ) <nl> - print ( ' Collected { } events . ' . format ( len ( events ) ) ) <nl> - return events <nl> - <nl> - <nl> - def SmartCopyBags ( from_dir , to_dir ) : <nl> - " " " Copy a task but filter useless sensor data . " " " <nl> - <nl> - bags = sorted ( glob . glob ( os . path . join ( from_dir , ' * . bag ' ) ) ) <nl> - if len ( bags ) = = 0 : <nl> - return <nl> - if not os . path . exists ( to_dir ) : <nl> - os . makedirs ( to_dir ) <nl> - <nl> - events = CollectEvents ( bags ) <nl> - next_event = 0 <nl> - for from_bag in bags : <nl> - to_bag = os . path . join ( to_dir , os . path . basename ( from_bag ) ) <nl> - print ( ' Copy bag : { } - > { } ' . format ( from_bag , to_bag ) ) <nl> - <nl> - # Do the copy <nl> - with Bag ( from_bag , ' r ' ) as bag_in , Bag ( to_bag , ' w ' ) as bag_out : <nl> - for topic , msg , t in bag_in . read_messages ( ) : <nl> - # For small size topics , always copy . <nl> - if topic not in K_LARGE_SIZE_TOPICS : <nl> - bag_out . write ( topic , msg , t ) <nl> - continue <nl> - <nl> - msg_sec = t . to_sec ( ) <nl> - while next_event < len ( events ) and events [ next_event ] < msg_sec : <nl> - next_event + = 1 <nl> - # For large size topics , only copy when it ' s near an event . <nl> - if ( next_event < len ( events ) and events [ next_event ] - msg_sec < <nl> - K_COPY_LARGE_SIZE_TOPICS_SECONDS_BEFORE_EVENT ) : <nl> - bag_out . write ( topic , msg , t ) <nl> - <nl> - <nl> - def SmartCopyDir ( from_dir , to_dir ) : <nl> - " " " Copy directory . " " " <nl> - <nl> - print ( ' Copy dir : { } - > { } ' . format ( from_dir , to_dir ) ) <nl> - is_task_dir = False <nl> - for f in sorted ( os . listdir ( from_dir ) , reverse = True ) : <nl> - sub_path = os . path . join ( from_dir , f ) <nl> - if os . path . isdir ( sub_path ) : <nl> - SmartCopyDir ( sub_path , os . path . join ( to_dir , f ) ) <nl> - continue <nl> - <nl> - if f . endswith ( ' . bag . active ' ) : <nl> - # Found unindexed bag , always copy it . <nl> - # TODO ( xiaoxq ) : Index the bag and go to next step . <nl> - shutil . copy ( sub_path , to_dir ) <nl> - continue <nl> - <nl> - if f . endswith ( ' . bag ' ) : <nl> - is_task_dir = True <nl> - break ; <nl> - <nl> - if is_task_dir : <nl> - SmartCopyBags ( from_dir , to_dir ) <nl> - <nl> - <nl> - def main ( ) : <nl> - " " " Do the job . " " " <nl> - <nl> - copy_from , copy_to = GetDisks ( ) <nl> - from_dir = os . path . join ( copy_from , ' data / bag ' ) <nl> - if not os . path . exists ( from_dir ) : <nl> - print ( ' Bag dir doesn \ ' t exist : ' , from_dir ) <nl> - sys . exit ( 1 ) <nl> - to_dir = os . path . join ( copy_to , ' data / bag ' ) <nl> - <nl> - print ( ' \ t1 . Only keep sensor data for drive events ' ) <nl> - print ( ' \ t2 . Eveything ' ) <nl> - selected = input ( ' What kind of data do you need : ' ) <nl> - if selected = = ' 1 ' : <nl> - SmartCopyDir ( from_dir , to_dir ) <nl> - elif selected = = ' 2 ' : <nl> - shutil . copytree ( from_dir , to_dir ) <nl> - else : <nl> - print ( ' Bad input ' ) <nl> - sys . exit ( 1 ) <nl> - <nl> - # TODO ( xiaoxq ) : We always try to make data structurized , such as putting <nl> - # them into rosbag , instead of copying raw files around . <nl> - other_data_dirs = { ' / apollo / data / gpsbin ' : ' data / gpsbin ' } <nl> - for src , dst in other_data_dirs . items ( ) : <nl> - if os . path . exists ( src ) : <nl> - print ( ' Copying ' , src ) <nl> - shutil . copytree ( src , os . path . join ( copy_to , dst ) ) <nl> - <nl> - <nl> - if __name__ = = " __main__ " : <nl> - main ( ) <nl> deleted file mode 100644 <nl> index 1c46971c776 . . 00000000000 <nl> mmm a / modules / tools / rosbag / extract_images . py <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env python <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # Copyright 2018 The Apollo Authors . All Rights Reserved . <nl> - # <nl> - # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - # you may not use this file except in compliance with the License . <nl> - # You may obtain a copy of the License at <nl> - # <nl> - # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - # <nl> - # Unless required by applicable law or agreed to in writing , software <nl> - # distributed under the License is distributed on an " AS IS " BASIS , <nl> - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - # See the License for the specific language governing permissions and <nl> - # limitations under the License . <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - " " " <nl> - Extract images from a recorded bag . <nl> - <nl> - Usage : <nl> - extract_images . py - - input_bag = a . bag <nl> - <nl> - See the gflags for more optional args . <nl> - " " " <nl> - <nl> - import os <nl> - import sys <nl> - <nl> - import cv2 <nl> - import cv_bridge <nl> - import gflags <nl> - import glog <nl> - import rosbag <nl> - import yaml <nl> - <nl> - # Requried flags . <nl> - gflags . DEFINE_string ( ' input_bag ' , None , ' Input bag path . ' ) <nl> - <nl> - # Optional flags . <nl> - gflags . DEFINE_string ( ' output_path ' , ' . / ' , ' Output path . ' ) <nl> - gflags . DEFINE_string ( ' weather ' , ' CLEAR ' , ' Options : CLEAR , SUNNY , RAINY . ' ) <nl> - gflags . DEFINE_string ( ' scene ' , ' CITY ' , ' Options : CITY , HIGHWAY . ' ) <nl> - gflags . DEFINE_string ( ' time_interval ' , ' DAYTIME ' , ' Options : DAYTIME , NIGHT . ' ) <nl> - gflags . DEFINE_float ( ' extract_rate ' , 3 , ' Rate to extract image , in seconds . ' ) <nl> - <nl> - # Stable flags which rarely change . <nl> - gflags . DEFINE_string ( ' topic ' , ' / apollo / sensor / camera / obstacle / front_6mm ' , <nl> - ' Source topic . ' ) <nl> - gflags . DEFINE_integer ( ' sensor_id ' , 436 , ' Source sensor ID . ' ) <nl> - gflags . DEFINE_string ( ' capture_place ' , ' Multiple ' , ' E . g . : Multiple , Sunnyvale . ' ) <nl> - <nl> - <nl> - def extract_meta_info ( bag ) : <nl> - " " " Extract information from a bag file , return an info dict . " " " <nl> - # Extract from bag info . <nl> - info_dict = yaml . load ( bag . _get_yaml_info ( ) ) <nl> - meta_info = { <nl> - ' car_id ' : ' MKZ056 ' , <nl> - ' driver ' : ' UNKNOWN ' , <nl> - ' start ' : int ( info_dict [ ' start ' ] ) , <nl> - ' end ' : int ( info_dict [ ' end ' ] ) , <nl> - } <nl> - <nl> - # Extract from bag message . <nl> - kStaticInfoTopic = ' / apollo / monitor / static_info ' <nl> - static_info = next ( <nl> - ( msg for _ , msg , _ in bag . read_messages ( topics = [ kStaticInfoTopic ] ) ) , <nl> - None ) <nl> - if static_info is not None : <nl> - if static_info . vehicle . name : <nl> - meta_info [ ' car_id ' ] = static_info . vehicle . name . upper ( ) <nl> - if static_info . user . driver : <nl> - meta_info [ ' driver ' ] = static_info . user . driver <nl> - return meta_info <nl> - <nl> - <nl> - def extract_images ( bag , dst_dir , args ) : <nl> - " " " Extract images to the destination dir . " " " <nl> - time_nsecs = [ ] <nl> - pre_time_sec = 0 <nl> - bridge = cv_bridge . CvBridge ( ) <nl> - seq = 0 <nl> - for _ , msg , t in bag . read_messages ( topics = args . topic ) : <nl> - # Check timestamp . <nl> - cur_time_sec = msg . header . stamp . to_sec ( ) <nl> - if cur_time_sec - pre_time_sec < args . extract_rate : <nl> - continue <nl> - pre_time_sec = cur_time_sec <nl> - time_nsecs . append ( msg . header . stamp . to_nsec ( ) ) <nl> - <nl> - # Save image . <nl> - seq + = 1 <nl> - msg . encoding = ' yuv422 ' <nl> - img = bridge . imgmsg_to_cv2 ( msg , ' yuv422 ' ) <nl> - img = cv2 . cvtColor ( img , cv2 . COLOR_YUV2BGR_YUYV ) <nl> - img_file = os . path . join ( dst_dir , ' { } . jpg ' . format ( seq ) ) <nl> - cv2 . imwrite ( img_file , img ) <nl> - <nl> - glog . info ( ' # { } : header . seq = { } , header . stamp = { } , saved as { } ' . format ( <nl> - seq , msg . header . seq , cur_time_sec , img_file ) ) <nl> - return time_nsecs <nl> - <nl> - <nl> - def process_bag ( bag , args ) : <nl> - " " " Process a bag . " " " <nl> - meta_info = extract_meta_info ( bag ) <nl> - dst_dir_name = ' { } _ { } _ { } _ { } ' . format ( meta_info [ ' car_id ' ] , args . sensor_id , <nl> - meta_info [ ' start ' ] , meta_info [ ' end ' ] ) <nl> - dst_dir = os . path . join ( args . output_path , dst_dir_name ) <nl> - if not os . path . exists ( dst_dir ) : <nl> - os . makedirs ( dst_dir ) <nl> - <nl> - # Generate meta file . <nl> - meta_file = os . path . join ( dst_dir , dst_dir_name + ' . meta ' ) <nl> - with open ( meta_file , ' w ' ) as meta_w : <nl> - meta_w . write ( ' car_id : { } \ n ' . format ( meta_info [ ' car_id ' ] ) ) <nl> - meta_w . write ( ' driver : { } \ n ' . format ( meta_info [ ' driver ' ] ) ) <nl> - meta_w . write ( ' capture_place : { } \ n ' . format ( args . capture_place ) ) <nl> - meta_w . write ( ' weather : { } \ n ' . format ( args . weather ) ) <nl> - meta_w . write ( ' topic : { } \ n ' . format ( args . topic ) ) <nl> - meta_w . write ( ' scene : { } \ n ' . format ( args . scene ) ) <nl> - meta_w . write ( ' time_interval : { } \ n ' . format ( args . time_interval ) ) <nl> - <nl> - # Generate images . <nl> - time_nsecs = extract_images ( bag , dst_dir , args ) <nl> - <nl> - # Generate timestamp sequence . <nl> - timestamp_file = os . path . join ( dst_dir , ' timestamp . txt ' ) <nl> - with open ( timestamp_file , ' w ' ) as timestamp_w : <nl> - timestamp_w . write ( ' seq \ ttimestamp_ns \ n ' ) <nl> - for seq , timestamp_ns in enumerate ( time_nsecs , start = 1 ) : <nl> - timestamp_w . write ( ' { } \ t { } \ n ' . format ( seq , timestamp_ns ) ) <nl> - <nl> - <nl> - def main ( ) : <nl> - " " " Entry point . " " " <nl> - gflags . FLAGS ( sys . argv ) <nl> - with rosbag . Bag ( gflags . FLAGS . input_bag ) as bag : <nl> - process_bag ( bag , gflags . FLAGS ) <nl> - <nl> - <nl> - if __name__ = = ' __main__ ' : <nl> - main ( ) <nl> deleted file mode 100755 <nl> index 0746614eabb . . 00000000000 <nl> mmm a / modules / tools / rosbag / profile_planning . py <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env python <nl> - <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - # Copyright 2017 The Apollo Authors . All Rights Reserved . <nl> - # <nl> - # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - # you may not use this file except in compliance with the License . <nl> - # You may obtain a copy of the License at <nl> - # <nl> - # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - # <nl> - # Unless required by applicable law or agreed to in writing , software <nl> - # distributed under the License is distributed on an " AS IS " BASIS , <nl> - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - # See the License for the specific language governing permissions and <nl> - # limitations under the License . <nl> - # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - " " " <nl> - This program can dump a rosbag into separate text files that contains the pb messages <nl> - " " " <nl> - <nl> - import rosbag <nl> - import rospy <nl> - import std_msgs <nl> - import argparse <nl> - import shutil <nl> - import StringIO <nl> - import os <nl> - import sys <nl> - <nl> - from std_msgs . msg import String <nl> - from common . message_manager import PbMessageManager <nl> - <nl> - g_message_manager = PbMessageManager ( ) <nl> - g_args = None <nl> - <nl> - def stat_planning ( planning_msg ) : <nl> - stats = { } <nl> - if planning_msg . HasField ( " estop " ) : <nl> - return stats <nl> - stats [ " total_time " ] = planning_msg . latency_stats . total_time_ms <nl> - stats [ " init_time " ] = planning_msg . latency_stats . init_frame_time_ms <nl> - used_time = stats [ " init_time " ] <nl> - stats [ " obstacles " ] = len ( planning_msg . decision . object_decision . decision ) <nl> - for task in planning_msg . latency_stats . task_stats : <nl> - stats [ task . name ] = task . time_ms <nl> - used_time + = task . time_ms <nl> - stats [ " other " ] = stats [ " total_time " ] - used_time <nl> - return stats <nl> - <nl> - g_first_time = True <nl> - <nl> - def print_stat ( msg , fhandle ) : <nl> - if not msg : <nl> - return <nl> - global g_first_time <nl> - keywords = [ <nl> - ' obstacles ' , ' total_time ' , ' init_time ' , u ' TrafficDecider ' , <nl> - u ' DpPolyPathOptimizer ' , u ' PathDecider ' , u ' DpStSpeedOptimizer ' , <nl> - u ' SpeedDecider ' , u ' QpSplinePathOptimizer ' , u ' QpSplineStSpeedOptimizer ' , <nl> - u ' ReferenceLineProvider ' , u ' other ' <nl> - ] <nl> - <nl> - output = StringIO . StringIO ( ) <nl> - valid = True <nl> - if g_first_time : <nl> - g_first_time = False <nl> - output . write ( " \ t " . join ( keywords ) + " \ n " ) <nl> - for key in keywords : <nl> - if key not in msg : <nl> - valid = False <nl> - break <nl> - if key = = " obstacles " : <nl> - output . write ( " % d \ t " % msg [ key ] ) <nl> - else : <nl> - output . write ( " % . 3f \ t " % msg [ key ] ) <nl> - if valid : <nl> - output . write ( " \ n " ) <nl> - fhandle . write ( output . getvalue ( ) ) <nl> - fhandle . flush ( ) <nl> - output . close ( ) <nl> - <nl> - def on_receive_planning ( planning_msg ) : <nl> - ss = stat_planning ( planning_msg ) <nl> - print_stat ( ss , g_args . report ) <nl> - <nl> - def dump_bag ( in_bag , msg_meta , fhandle ) : <nl> - bag = rosbag . Bag ( in_bag , ' r ' ) <nl> - for topic , msg , t in bag . read_messages ( ) : <nl> - if topic ! = msg_meta . topic : <nl> - continue <nl> - ss = stat_planning ( msg ) <nl> - print_stat ( ss , g_args . report ) <nl> - <nl> - def main ( args ) : <nl> - if not args . report : <nl> - args . report = sys . stdout <nl> - else : <nl> - args . report = file ( args . report , ' w ' ) <nl> - meta_msg = g_message_manager . get_msg_meta_by_topic ( args . topic ) <nl> - if not meta_msg : <nl> - print ( ' Failed to find topic [ % s ] in message manager ' % args . topic ) <nl> - sys . exit ( 1 ) <nl> - <nl> - if args . rosbag : <nl> - dump_bag ( args . rosbag , meta_msg , args . report ) <nl> - else : <nl> - rospy . init_node ( " stat_planning " , anonymous = True ) <nl> - rospy . Subscriber ( args . topic , meta_msg . msg_type , <nl> - on_receive_planning ) <nl> - rospy . spin ( ) <nl> - <nl> - if args . report ! = sys . stdout : <nl> - args . report . close ( ) <nl> - <nl> - if __name__ = = ' __main__ ' : <nl> - parser = argparse . ArgumentParser ( <nl> - description = " A tool to profile the runtime statistic of planning module " <nl> - ) <nl> - parser . add_argument ( <nl> - " - - rosbag " , action = " store " , type = str , help = " the input ros bag " ) <nl> - parser . add_argument ( <nl> - " - - report " , <nl> - type = str , <nl> - action = " store " , <nl> - help = " The output file , if not use , will use stdout " ) <nl> - parser . add_argument ( <nl> - " - - topic " , <nl> - action = " store " , <nl> - default = " / apollo / planning " , <nl> - help = " The planning module topic name " ) <nl> - <nl> - g_args = parser . parse_args ( ) <nl> - main ( g_args ) <nl> | Tools : Retire outdated rosbag tools . | ApolloAuto/apollo | 48d081fbbd2cd5e98135f737d6bd44cde5556124 | 2019-12-04T23:07:15Z |
mmm a / tensorflow / core / framework / op . h <nl> ppp b / tensorflow / core / framework / op . h <nl> class OpDefBuilderWrapper < true > { <nl> builder_ . Doc ( std : : move ( text ) ) ; <nl> return * this ; <nl> } <nl> - OpDefBuilderWrapper < true > & SetShapeFn ( <nl> - Status ( * fn ) ( shape_inference : : InferenceContext * ) ) { <nl> - builder_ . SetShapeFn ( fn ) ; <nl> + OpDefBuilderWrapper < true > & SetShapeFn ( OpShapeInferenceFn fn ) { <nl> + builder_ . SetShapeFn ( std : : move ( fn ) ) ; <nl> return * this ; <nl> } <nl> const : : tensorflow : : OpDefBuilder & builder ( ) const { return builder_ ; } <nl> | Changed OpDefBuilderWrapper < true > : : SetShapeFn declaration to use | tensorflow/tensorflow | 690c33e4b5dd7d4b7a5a36ab020b7d69362aa80a | 2020-03-17T22:31:43Z |
mmm a / yoga / Yoga . cpp <nl> ppp b / yoga / Yoga . cpp <nl> static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues ( <nl> return flexAlgoRowMeasurement ; <nl> } <nl> <nl> + static void YGDistributeFreeSpaceSecondPass ( <nl> + YGCollectFlexItemsRowValues & collectedFlexItemsValues , <nl> + const YGNodeRef node , <nl> + const YGFlexDirection mainAxis , <nl> + const YGFlexDirection crossAxis , <nl> + const float mainAxisParentSize , <nl> + const float availableInnerMainDim , <nl> + const float availableInnerCrossDim , <nl> + const float availableInnerWidth , <nl> + const float availableInnerHeight , <nl> + const bool flexBasisOverflows , <nl> + const YGMeasureMode measureModeCrossDim , <nl> + const bool performLayout , <nl> + const YGConfigRef config ) { <nl> + float childFlexBasis = 0 ; <nl> + float flexShrinkScaledFactor = 0 ; <nl> + float flexGrowFactor = 0 ; <nl> + float deltaFreeSpace = 0 ; <nl> + const bool isMainAxisRow = YGFlexDirectionIsRow ( mainAxis ) ; <nl> + const bool isNodeFlexWrap = node - > getStyle ( ) . flexWrap ! = YGWrapNoWrap ; <nl> + <nl> + for ( auto currentRelativeChild : collectedFlexItemsValues . relativeChildren ) { <nl> + childFlexBasis = YGNodeBoundAxisWithinMinAndMax ( <nl> + currentRelativeChild , <nl> + mainAxis , <nl> + currentRelativeChild - > getLayout ( ) . computedFlexBasis , <nl> + mainAxisParentSize ) ; <nl> + float updatedMainSize = childFlexBasis ; <nl> + <nl> + if ( collectedFlexItemsValues . remainingFreeSpace < 0 ) { <nl> + flexShrinkScaledFactor = <nl> + - currentRelativeChild - > resolveFlexShrink ( ) * childFlexBasis ; <nl> + / / Is this child able to shrink ? <nl> + if ( flexShrinkScaledFactor ! = 0 ) { <nl> + float childSize ; <nl> + <nl> + if ( collectedFlexItemsValues . totalFlexShrinkScaledFactors = = 0 ) { <nl> + childSize = childFlexBasis + flexShrinkScaledFactor ; <nl> + } else { <nl> + childSize = childFlexBasis + <nl> + ( collectedFlexItemsValues . remainingFreeSpace / <nl> + collectedFlexItemsValues . totalFlexShrinkScaledFactors ) * <nl> + flexShrinkScaledFactor ; <nl> + } <nl> + <nl> + updatedMainSize = YGNodeBoundAxis ( <nl> + currentRelativeChild , <nl> + mainAxis , <nl> + childSize , <nl> + availableInnerMainDim , <nl> + availableInnerWidth ) ; <nl> + } <nl> + } else if ( collectedFlexItemsValues . remainingFreeSpace > 0 ) { <nl> + flexGrowFactor = currentRelativeChild - > resolveFlexGrow ( ) ; <nl> + <nl> + / / Is this child able to grow ? <nl> + if ( flexGrowFactor ! = 0 ) { <nl> + updatedMainSize = YGNodeBoundAxis ( <nl> + currentRelativeChild , <nl> + mainAxis , <nl> + childFlexBasis + <nl> + collectedFlexItemsValues . remainingFreeSpace / <nl> + collectedFlexItemsValues . totalFlexGrowFactors * <nl> + flexGrowFactor , <nl> + availableInnerMainDim , <nl> + availableInnerWidth ) ; <nl> + } <nl> + } <nl> + <nl> + deltaFreeSpace - = updatedMainSize - childFlexBasis ; <nl> + <nl> + const float marginMain = YGNodeMarginForAxis ( <nl> + currentRelativeChild , mainAxis , availableInnerWidth ) ; <nl> + const float marginCross = YGNodeMarginForAxis ( <nl> + currentRelativeChild , crossAxis , availableInnerWidth ) ; <nl> + <nl> + float childCrossSize ; <nl> + float childMainSize = updatedMainSize + marginMain ; <nl> + YGMeasureMode childCrossMeasureMode ; <nl> + YGMeasureMode childMainMeasureMode = YGMeasureModeExactly ; <nl> + <nl> + if ( ! YGFloatIsUndefined ( currentRelativeChild - > getStyle ( ) . aspectRatio ) ) { <nl> + childCrossSize = isMainAxisRow ? ( childMainSize - marginMain ) / <nl> + currentRelativeChild - > getStyle ( ) . aspectRatio <nl> + : ( childMainSize - marginMain ) * <nl> + currentRelativeChild - > getStyle ( ) . aspectRatio ; <nl> + childCrossMeasureMode = YGMeasureModeExactly ; <nl> + <nl> + childCrossSize + = marginCross ; <nl> + } else if ( <nl> + ! YGFloatIsUndefined ( availableInnerCrossDim ) & & <nl> + ! YGNodeIsStyleDimDefined ( <nl> + currentRelativeChild , crossAxis , availableInnerCrossDim ) & & <nl> + measureModeCrossDim = = YGMeasureModeExactly & & <nl> + ! ( isNodeFlexWrap & & flexBasisOverflows ) & & <nl> + YGNodeAlignItem ( node , currentRelativeChild ) = = YGAlignStretch & & <nl> + currentRelativeChild - > marginLeadingValue ( crossAxis ) . unit ! = <nl> + YGUnitAuto & & <nl> + currentRelativeChild - > marginTrailingValue ( crossAxis ) . unit ! = <nl> + YGUnitAuto ) { <nl> + childCrossSize = availableInnerCrossDim ; <nl> + childCrossMeasureMode = YGMeasureModeExactly ; <nl> + } else if ( ! YGNodeIsStyleDimDefined ( <nl> + currentRelativeChild , crossAxis , availableInnerCrossDim ) ) { <nl> + childCrossSize = availableInnerCrossDim ; <nl> + childCrossMeasureMode = YGFloatIsUndefined ( childCrossSize ) <nl> + ? YGMeasureModeUndefined <nl> + : YGMeasureModeAtMost ; <nl> + } else { <nl> + childCrossSize = <nl> + YGResolveValue ( <nl> + currentRelativeChild - > getResolvedDimension ( dim [ crossAxis ] ) , <nl> + availableInnerCrossDim ) + <nl> + marginCross ; <nl> + const bool isLoosePercentageMeasurement = <nl> + currentRelativeChild - > getResolvedDimension ( dim [ crossAxis ] ) . unit = = <nl> + YGUnitPercent & & <nl> + measureModeCrossDim ! = YGMeasureModeExactly ; <nl> + childCrossMeasureMode = <nl> + YGFloatIsUndefined ( childCrossSize ) | | isLoosePercentageMeasurement <nl> + ? YGMeasureModeUndefined <nl> + : YGMeasureModeExactly ; <nl> + } <nl> + <nl> + YGConstrainMaxSizeForMode ( <nl> + currentRelativeChild , <nl> + mainAxis , <nl> + availableInnerMainDim , <nl> + availableInnerWidth , <nl> + & childMainMeasureMode , <nl> + & childMainSize ) ; <nl> + YGConstrainMaxSizeForMode ( <nl> + currentRelativeChild , <nl> + crossAxis , <nl> + availableInnerCrossDim , <nl> + availableInnerWidth , <nl> + & childCrossMeasureMode , <nl> + & childCrossSize ) ; <nl> + <nl> + const bool requiresStretchLayout = <nl> + ! YGNodeIsStyleDimDefined ( <nl> + currentRelativeChild , crossAxis , availableInnerCrossDim ) & & <nl> + YGNodeAlignItem ( node , currentRelativeChild ) = = YGAlignStretch & & <nl> + currentRelativeChild - > marginLeadingValue ( crossAxis ) . unit ! = <nl> + YGUnitAuto & & <nl> + currentRelativeChild - > marginTrailingValue ( crossAxis ) . unit ! = YGUnitAuto ; <nl> + <nl> + const float childWidth = isMainAxisRow ? childMainSize : childCrossSize ; <nl> + const float childHeight = ! isMainAxisRow ? childMainSize : childCrossSize ; <nl> + <nl> + const YGMeasureMode childWidthMeasureMode = <nl> + isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode ; <nl> + const YGMeasureMode childHeightMeasureMode = <nl> + ! isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode ; <nl> + <nl> + / / Recursively call the layout algorithm for this child with the updated <nl> + / / main size . <nl> + YGLayoutNodeInternal ( <nl> + currentRelativeChild , <nl> + childWidth , <nl> + childHeight , <nl> + node - > getLayout ( ) . direction , <nl> + childWidthMeasureMode , <nl> + childHeightMeasureMode , <nl> + availableInnerWidth , <nl> + availableInnerHeight , <nl> + performLayout & & ! requiresStretchLayout , <nl> + " flex " , <nl> + config ) ; <nl> + node - > setLayoutHadOverflow ( <nl> + node - > getLayout ( ) . hadOverflow | <nl> + currentRelativeChild - > getLayout ( ) . hadOverflow ) ; <nl> + } <nl> + <nl> + collectedFlexItemsValues . remainingFreeSpace + = deltaFreeSpace ; <nl> + } <nl> + <nl> / / It distributes the free space to the flexible items , for those flexible items <nl> / / whose min and max constraints are triggered , the clamped size is removed from <nl> / / the remaingfreespace . <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> - collectedFlexItemsValues . sizeConsumedOnCurrentLine ; <nl> } <nl> <nl> - const float originalRemainingFreeSpace = <nl> - collectedFlexItemsValues . remainingFreeSpace ; <nl> - float deltaFreeSpace = 0 ; <nl> - <nl> if ( ! canSkipFlex ) { <nl> - float childFlexBasis ; <nl> - float flexShrinkScaledFactor ; <nl> - float flexGrowFactor ; <nl> - <nl> / / Do two passes over the flex items to figure out how to distribute the <nl> / / remaining space . <nl> / / The first pass finds the items whose min / max constraints trigger , <nl> static void YGNodelayoutImpl ( const YGNodeRef node , <nl> availableInnerWidth ) ; <nl> <nl> / / Second pass : resolve the sizes of the flexible items <nl> - deltaFreeSpace = 0 ; <nl> - for ( auto currentRelativeChild : <nl> - collectedFlexItemsValues . relativeChildren ) { <nl> - childFlexBasis = YGNodeBoundAxisWithinMinAndMax ( <nl> - currentRelativeChild , <nl> - mainAxis , <nl> - currentRelativeChild - > getLayout ( ) . computedFlexBasis , <nl> - mainAxisParentSize ) ; <nl> - float updatedMainSize = childFlexBasis ; <nl> - <nl> - if ( collectedFlexItemsValues . remainingFreeSpace < 0 ) { <nl> - flexShrinkScaledFactor = <nl> - - currentRelativeChild - > resolveFlexShrink ( ) * childFlexBasis ; <nl> - / / Is this child able to shrink ? <nl> - if ( flexShrinkScaledFactor ! = 0 ) { <nl> - float childSize ; <nl> - <nl> - if ( collectedFlexItemsValues . totalFlexShrinkScaledFactors = = 0 ) { <nl> - childSize = childFlexBasis + flexShrinkScaledFactor ; <nl> - } else { <nl> - childSize = childFlexBasis + <nl> - ( collectedFlexItemsValues . remainingFreeSpace / <nl> - collectedFlexItemsValues . totalFlexShrinkScaledFactors ) * <nl> - flexShrinkScaledFactor ; <nl> - } <nl> - <nl> - updatedMainSize = YGNodeBoundAxis ( <nl> - currentRelativeChild , <nl> - mainAxis , <nl> - childSize , <nl> - availableInnerMainDim , <nl> - availableInnerWidth ) ; <nl> - } <nl> - } else if ( collectedFlexItemsValues . remainingFreeSpace > 0 ) { <nl> - flexGrowFactor = currentRelativeChild - > resolveFlexGrow ( ) ; <nl> - <nl> - / / Is this child able to grow ? <nl> - if ( flexGrowFactor ! = 0 ) { <nl> - updatedMainSize = YGNodeBoundAxis ( <nl> - currentRelativeChild , <nl> - mainAxis , <nl> - childFlexBasis + <nl> - collectedFlexItemsValues . remainingFreeSpace / <nl> - collectedFlexItemsValues . totalFlexGrowFactors * <nl> - flexGrowFactor , <nl> - availableInnerMainDim , <nl> - availableInnerWidth ) ; <nl> - } <nl> - } <nl> - <nl> - deltaFreeSpace - = updatedMainSize - childFlexBasis ; <nl> - <nl> - const float marginMain = YGNodeMarginForAxis ( <nl> - currentRelativeChild , mainAxis , availableInnerWidth ) ; <nl> - const float marginCross = YGNodeMarginForAxis ( <nl> - currentRelativeChild , crossAxis , availableInnerWidth ) ; <nl> - <nl> - float childCrossSize ; <nl> - float childMainSize = updatedMainSize + marginMain ; <nl> - YGMeasureMode childCrossMeasureMode ; <nl> - YGMeasureMode childMainMeasureMode = YGMeasureModeExactly ; <nl> - <nl> - if ( ! YGFloatIsUndefined ( currentRelativeChild - > getStyle ( ) . aspectRatio ) ) { <nl> - childCrossSize = isMainAxisRow ? ( childMainSize - marginMain ) / <nl> - currentRelativeChild - > getStyle ( ) . aspectRatio <nl> - : ( childMainSize - marginMain ) * <nl> - currentRelativeChild - > getStyle ( ) . aspectRatio ; <nl> - childCrossMeasureMode = YGMeasureModeExactly ; <nl> - <nl> - childCrossSize + = marginCross ; <nl> - } else if ( <nl> - ! YGFloatIsUndefined ( availableInnerCrossDim ) & & <nl> - ! YGNodeIsStyleDimDefined ( <nl> - currentRelativeChild , crossAxis , availableInnerCrossDim ) & & <nl> - measureModeCrossDim = = YGMeasureModeExactly & & <nl> - ! ( isNodeFlexWrap & & flexBasisOverflows ) & & <nl> - YGNodeAlignItem ( node , currentRelativeChild ) = = YGAlignStretch & & <nl> - currentRelativeChild - > marginLeadingValue ( crossAxis ) . unit ! = <nl> - YGUnitAuto & & <nl> - currentRelativeChild - > marginTrailingValue ( crossAxis ) . unit ! = <nl> - YGUnitAuto ) { <nl> - childCrossSize = availableInnerCrossDim ; <nl> - childCrossMeasureMode = YGMeasureModeExactly ; <nl> - } else if ( ! YGNodeIsStyleDimDefined ( <nl> - currentRelativeChild , <nl> - crossAxis , <nl> - availableInnerCrossDim ) ) { <nl> - childCrossSize = availableInnerCrossDim ; <nl> - childCrossMeasureMode = YGFloatIsUndefined ( childCrossSize ) <nl> - ? YGMeasureModeUndefined <nl> - : YGMeasureModeAtMost ; <nl> - } else { <nl> - childCrossSize = <nl> - YGResolveValue ( <nl> - currentRelativeChild - > getResolvedDimension ( dim [ crossAxis ] ) , <nl> - availableInnerCrossDim ) + <nl> - marginCross ; <nl> - const bool isLoosePercentageMeasurement = <nl> - currentRelativeChild - > getResolvedDimension ( dim [ crossAxis ] ) . unit = = <nl> - YGUnitPercent & & <nl> - measureModeCrossDim ! = YGMeasureModeExactly ; <nl> - childCrossMeasureMode = <nl> - YGFloatIsUndefined ( childCrossSize ) | | isLoosePercentageMeasurement <nl> - ? YGMeasureModeUndefined <nl> - : YGMeasureModeExactly ; <nl> - } <nl> - <nl> - YGConstrainMaxSizeForMode ( <nl> - currentRelativeChild , <nl> - mainAxis , <nl> - availableInnerMainDim , <nl> - availableInnerWidth , <nl> - & childMainMeasureMode , <nl> - & childMainSize ) ; <nl> - YGConstrainMaxSizeForMode ( <nl> - currentRelativeChild , <nl> - crossAxis , <nl> - availableInnerCrossDim , <nl> - availableInnerWidth , <nl> - & childCrossMeasureMode , <nl> - & childCrossSize ) ; <nl> - <nl> - const bool requiresStretchLayout = <nl> - ! YGNodeIsStyleDimDefined ( <nl> - currentRelativeChild , crossAxis , availableInnerCrossDim ) & & <nl> - YGNodeAlignItem ( node , currentRelativeChild ) = = YGAlignStretch & & <nl> - currentRelativeChild - > marginLeadingValue ( crossAxis ) . unit ! = <nl> - YGUnitAuto & & <nl> - currentRelativeChild - > marginTrailingValue ( crossAxis ) . unit ! = <nl> - YGUnitAuto ; <nl> - <nl> - const float childWidth = isMainAxisRow ? childMainSize : childCrossSize ; <nl> - const float childHeight = <nl> - ! isMainAxisRow ? childMainSize : childCrossSize ; <nl> - <nl> - const YGMeasureMode childWidthMeasureMode = <nl> - isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode ; <nl> - const YGMeasureMode childHeightMeasureMode = <nl> - ! isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode ; <nl> - <nl> - / / Recursively call the layout algorithm for this child with the updated <nl> - / / main size . <nl> - YGLayoutNodeInternal ( <nl> - currentRelativeChild , <nl> - childWidth , <nl> - childHeight , <nl> - direction , <nl> - childWidthMeasureMode , <nl> - childHeightMeasureMode , <nl> - availableInnerWidth , <nl> - availableInnerHeight , <nl> - performLayout & & ! requiresStretchLayout , <nl> - " flex " , <nl> - config ) ; <nl> - node - > setLayoutHadOverflow ( <nl> - node - > getLayout ( ) . hadOverflow | <nl> - currentRelativeChild - > getLayout ( ) . hadOverflow ) ; <nl> - currentRelativeChild = currentRelativeChild - > getNextChild ( ) ; <nl> - } <nl> + YGDistributeFreeSpaceSecondPass ( <nl> + collectedFlexItemsValues , <nl> + node , <nl> + mainAxis , <nl> + crossAxis , <nl> + mainAxisParentSize , <nl> + availableInnerMainDim , <nl> + availableInnerCrossDim , <nl> + availableInnerWidth , <nl> + availableInnerHeight , <nl> + flexBasisOverflows , <nl> + measureModeCrossDim , <nl> + performLayout , <nl> + config ) ; <nl> } <nl> <nl> - collectedFlexItemsValues . remainingFreeSpace = <nl> - originalRemainingFreeSpace + deltaFreeSpace ; <nl> node - > setLayoutHadOverflow ( <nl> node - > getLayout ( ) . hadOverflow | <nl> ( collectedFlexItemsValues . remainingFreeSpace < 0 ) ) ; <nl> | Seperate function for second pass | facebook/yoga | 5df815786365843f23352ea6b30849c1dcfd87aa | 2018-02-05T14:42:52Z |
mmm a / src / rdb_protocol / protocol . cc <nl> ppp b / src / rdb_protocol / protocol . cc <nl> struct rdb_w_shard_visitor_t : public boost : : static_visitor < bool > { <nl> if ( ! region_is_empty ( intersection ) ) { <nl> T tmp = arg ; <nl> tmp . region = intersection ; <nl> - * write_out = write_t ( tmp ) ; <nl> + * write_out = write_t ( tmp , durability_requirement ) ; <nl> return true ; <nl> } else { <nl> return false ; <nl> struct rdb_w_shard_visitor_t : public boost : : static_visitor < bool > { <nl> } <nl> <nl> bool operator ( ) ( const sync_t & s ) const { <nl> - / / Sync always applied to the whole region . <nl> - sync_t tmp = s ; <nl> - tmp . region = * region ; <nl> - * write_out = write_t ( tmp , durability_requirement ) ; <nl> - return true ; <nl> + return rangey_write ( s ) ; <nl> } <nl> <nl> const region_t * region ; <nl> mmm a / src / rdb_protocol / protocol . hpp <nl> ppp b / src / rdb_protocol / protocol . hpp <nl> struct rdb_protocol_t { <nl> explicit write_t ( const point_delete_t & d , <nl> durability_requirement_t durability ) <nl> : write ( d ) , durability_requirement ( durability ) { } <nl> - explicit write_t ( const sindex_create_t & c ) <nl> + explicit write_t ( const sindex_create_t & c , <nl> + durability_requirement_t = DURABILITY_REQUIREMENT_DEFAULT ) <nl> : write ( c ) , durability_requirement ( DURABILITY_REQUIREMENT_DEFAULT ) { } <nl> - explicit write_t ( const sindex_drop_t & c ) <nl> + explicit write_t ( const sindex_drop_t & c , <nl> + durability_requirement_t = DURABILITY_REQUIREMENT_DEFAULT ) <nl> : write ( c ) , durability_requirement ( DURABILITY_REQUIREMENT_DEFAULT ) { } <nl> / / Note that for durability ! = DURABILITY_REQUIREMENT_HARD , sync might <nl> / / not have the desired effect ( of writing unsaved data to disk ) . <nl> | Made write_t constructors have consistent argument signatures , so we can use rangey_write more often . | rethinkdb/rethinkdb | aae117f0dd5a1aa04732827700cfc8c1101871a8 | 2013-10-08T23:36:07Z |
mmm a / hphp / hack / src / hhbc / hhbc_id . ml <nl> ppp b / hphp / hack / src / hhbc / hhbc_id . ml <nl> <nl> open Core_kernel <nl> module SU = Hhbc_string_utils <nl> <nl> - let elaborate_id ns kind ( _ , id ) = <nl> - let ( was_renamed , fq_id ) = Namespaces . elaborate_id_impl ns kind id in <nl> - ( was_renamed , SU . strip_global_ns fq_id ) <nl> + let elaborate_id ns kind id = <nl> + Namespaces . elaborate_id ns kind id | > snd | > SU . strip_global_ns <nl> <nl> ( * Class identifier , with namespace qualification if not global , but without <nl> * initial backslash . <nl> let elaborate_id ns kind ( _ , id ) = <nl> module Class = struct <nl> type t = string <nl> <nl> - let from_ast_name s = Hh_autoimport . normalize ( SU . strip_global_ns s ) <nl> + let from_ast_name s = <nl> + if Hh_autoimport . lookup_type ( SU . strip_global_ns s ) = None then <nl> + s <nl> + else <nl> + " HH \ \ " ^ s <nl> <nl> let from_raw_string s = s <nl> <nl> let to_raw_string s = s <nl> <nl> - let elaborate_id ns ( ( _ , n ) as id ) = <nl> + let elaborate_id ns ( p , id_ ) = <nl> let ns = <nl> - if SU . Xhp . is_xhp n then <nl> - Namespace_env . empty <nl> - ns . Namespace_env . ns_auto_ns_map <nl> - ns . Namespace_env . ns_is_codegen <nl> + if SU . Xhp . is_xhp id_ then <nl> + Namespace_env . empty_from_env ns <nl> else <nl> ns <nl> in <nl> - let mangled_name = SU . Xhp . mangle n in <nl> - let stripped_mangled_name = SU . strip_global_ns mangled_name in <nl> - let ( was_renamed , id ) = <nl> - elaborate_id ns Namespaces . ElaborateClass ( fst id , mangled_name ) <nl> - in <nl> - if was_renamed | | mangled_name . [ 0 ] = ' \ \ ' then <nl> - id <nl> - else <nl> - match Hh_autoimport . opt_normalize stripped_mangled_name with <nl> - | None - > id <nl> - | Some s - > s <nl> + elaborate_id ns Namespaces . ElaborateClass ( p , SU . Xhp . mangle id_ ) <nl> <nl> let to_unmangled_string s = SU . Xhp . unmangle s <nl> end <nl> module Function = struct <nl> <nl> let add_suffix s suffix = s ^ suffix <nl> <nl> - let elaborate_id ns id = <nl> - let ( _ , fq_id ) = elaborate_id ns Namespaces . ElaborateFun id in <nl> - fq_id <nl> + let elaborate_id ns id = elaborate_id ns Namespaces . ElaborateFun id <nl> end <nl> <nl> module Const = struct <nl> module Const = struct <nl> <nl> let to_raw_string s = s <nl> <nl> - let elaborate_id ns id = <nl> - let ( _ , fq_id ) = elaborate_id ns Namespaces . ElaborateConst id in <nl> - fq_id <nl> + let elaborate_id ns id = elaborate_id ns Namespaces . ElaborateConst id <nl> end <nl> <nl> module Record = struct <nl> module Record = struct <nl> <nl> let to_raw_string s = s <nl> <nl> - let elaborate_id ns id = <nl> - let ( _ , fq_id ) = elaborate_id ns Namespaces . ElaborateRecord id in <nl> - fq_id <nl> + let elaborate_id ns id = elaborate_id ns Namespaces . ElaborateRecord id <nl> end <nl> mmm a / hphp / hack / src / naming / naming_special_names . ml <nl> ppp b / hphp / hack / src / naming / naming_special_names . ml <nl> module Typehints = struct <nl> | | x = real <nl> | | x = dynamic <nl> | | x = wildcard <nl> + | | x = null <nl> | | x = nonnull <nl> | | x = nothing <nl> <nl> mmm a / hphp / hack / src / parser / dune . inc <nl> ppp b / hphp / hack / src / parser / dune . inc <nl> <nl> fixme_provider <nl> full_fidelity <nl> heap_shared_mem <nl> + hh_autoimport <nl> html_entities <nl> logging <nl> namespace_env <nl> <nl> ( preprocess ( pps visitors . ppx ppx_deriving . std ) ) ; See T41851208 <nl> ( libraries <nl> collections <nl> - core_kernel ) ) <nl> + core_kernel <nl> + naming_special_names ) ) <nl> <nl> ( library <nl> ( name parsing_service ) <nl> mmm a / hphp / hack / src / parser / hh_autoimport . ml <nl> ppp b / hphp / hack / src / parser / hh_autoimport . ml <nl> <nl> <nl> open Core_kernel <nl> <nl> - ( * Create map from name to alias * ) <nl> - let add_alias m s = SMap . add s ( " HH \ \ " ^ s ) m <nl> + ( * The typechecker has a different view of HH autoimporting than the compiler . <nl> + * This type exists to track the unification of HH autoimporting between the <nl> + * typechecker and the compiler , after which it will be deleted . * ) <nl> + type autoimport_ns = <nl> + | Global <nl> + | HH <nl> <nl> - let alias_map = <nl> - List . fold_left <nl> - ~ f : add_alias <nl> - ~ init : SMap . empty <nl> + ( * * <nl> + * Convenience function for maps that have been completely unified to autoimport <nl> + * into the HH namespace . <nl> + * ) <nl> + let autoimport_map_of_list ids = <nl> + List . fold_left ids ~ init : SMap . empty ~ f : ( fun map id - > <nl> + SMap . add id ( HH , HH ) map ) <nl> + <nl> + let autoimport_map_of_tuples ids = <nl> + List . fold_left ids ~ init : SMap . empty ~ f : ( fun map ( id , typechecker_ns ) - > <nl> + SMap . add id ( typechecker_ns , HH ) map ) <nl> + <nl> + let types = <nl> + autoimport_map_of_tuples <nl> [ <nl> - " AsyncIterator " ; <nl> - " AsyncKeyedIterator " ; <nl> - " Traversable " ; <nl> - " Container " ; <nl> - " KeyedTraversable " ; <nl> - " KeyedContainer " ; <nl> - " Iterator " ; <nl> - " KeyedIterator " ; <nl> - " Iterable " ; <nl> - " KeyedIterable " ; <nl> - " Collection " ; <nl> - " Vector " ; <nl> - " Map " ; <nl> - " Set " ; <nl> - " Pair " ; <nl> - " ImmVector " ; <nl> - " ImmMap " ; <nl> - " ImmSet " ; <nl> - " InvariantException " ; <nl> - " IMemoizeParam " ; <nl> - " Shapes " ; <nl> - " TypeStructureKind " ; <nl> - " TypeStructure " ; <nl> + ( " arraylike " , HH ) ; <nl> + ( " AsyncFunctionWaitHandle " , Global ) ; <nl> + ( " AsyncGenerator " , Global ) ; <nl> + ( " AsyncGeneratorWaitHandle " , Global ) ; <nl> + ( " AsyncIterator " , Global ) ; <nl> + ( " AsyncKeyedIterator " , Global ) ; <nl> + ( " Awaitable " , Global ) ; <nl> + ( " AwaitAllWaitHandle " , Global ) ; <nl> + ( " classname " , Global ) ; <nl> + ( " Collection " , Global ) ; <nl> + ( " ConditionWaitHandle " , Global ) ; <nl> + ( " Container " , Global ) ; <nl> + ( " darray " , HH ) ; <nl> + ( " dict " , Global ) ; <nl> + ( " ExternalThreadEventWaitHandle " , Global ) ; <nl> + ( " IMemoizeParam " , Global ) ; <nl> + ( " ImmMap " , Global ) ; <nl> + ( " ImmSet " , Global ) ; <nl> + ( " ImmVector " , Global ) ; <nl> + ( " InvariantException " , Global ) ; <nl> + ( " Iterable " , Global ) ; <nl> + ( " Iterator " , Global ) ; <nl> + ( " KeyedContainer " , Global ) ; <nl> + ( " KeyedIterable " , Global ) ; <nl> + ( " KeyedIterator " , Global ) ; <nl> + ( " KeyedTraversable " , Global ) ; <nl> + ( " keyset " , Global ) ; <nl> + ( " Map " , Global ) ; <nl> + ( " ObjprofObjectStats " , HH ) ; <nl> + ( " ObjprofPathsStats " , HH ) ; <nl> + ( " ObjprofStringStats " , HH ) ; <nl> + ( " Pair " , Global ) ; <nl> + ( " RescheduleWaitHandle " , Global ) ; <nl> + ( " ResumableWaitHandle " , Global ) ; <nl> + ( " Set " , Global ) ; <nl> + ( " Shapes " , Global ) ; <nl> + ( " SleepWaitHandle " , Global ) ; <nl> + ( " StableMap " , Global ) ; <nl> + ( " StaticWaitHandle " , Global ) ; <nl> + ( " this " , Global ) ; <nl> + ( " Traversable " , Global ) ; <nl> + ( " typename " , Global ) ; <nl> + ( " TypeStructure " , HH ) ; <nl> + ( " TypeStructureKind " , HH ) ; <nl> + ( " varray_or_darray " , HH ) ; <nl> + ( " varray " , HH ) ; <nl> + ( " vec_or_dict " , HH ) ; <nl> + ( " vec " , Global ) ; <nl> + ( " Vector " , Global ) ; <nl> + ( " WaitableWaitHandle " , Global ) ; <nl> + ( " XenonSample " , HH ) ; <nl> + ] <nl> + <nl> + let funcs = <nl> + autoimport_map_of_list <nl> + [ <nl> + " asio_get_current_context_idx " ; <nl> + " asio_get_running_in_context " ; <nl> + " asio_get_running " ; <nl> + " class_meth " ; <nl> + " darray " ; <nl> " dict " ; <nl> - " vec " ; <nl> + " fun " ; <nl> + " heapgraph_create " ; <nl> + " heapgraph_dfs_edges " ; <nl> + " heapgraph_dfs_nodes " ; <nl> + " heapgraph_edge " ; <nl> + " heapgraph_foreach_edge " ; <nl> + " heapgraph_foreach_node " ; <nl> + " heapgraph_foreach_root " ; <nl> + " heapgraph_node_in_edges " ; <nl> + " heapgraph_node_out_edges " ; <nl> + " heapgraph_node " ; <nl> + " heapgraph_stats " ; <nl> + " idx " ; <nl> + " inst_meth " ; <nl> + " invariant_callback_register " ; <nl> + " invariant_violation " ; <nl> + " invariant " ; <nl> + " is_darray " ; <nl> + " is_dict " ; <nl> + " is_keyset " ; <nl> + " is_varray " ; <nl> + " is_vec " ; <nl> " keyset " ; <nl> + " meth_caller " ; <nl> + " objprof_get_data " ; <nl> + " objprof_get_paths " ; <nl> + " objprof_get_strings " ; <nl> + " server_warmup_status " ; <nl> + " thread_mark_stack " ; <nl> + " thread_memory_stats " ; <nl> + " type_structure " ; <nl> " varray " ; <nl> - " darray " ; <nl> - " Awaitable " ; <nl> - " AsyncGenerator " ; <nl> - " StaticWaitHandle " ; <nl> - " WaitableWaitHandle " ; <nl> - " ResumableWaitHandle " ; <nl> - " AsyncFunctionWaitHandle " ; <nl> - " AsyncGeneratorWaitHandle " ; <nl> - " AwaitAllWaitHandle " ; <nl> - " ConditionWaitHandle " ; <nl> - " RescheduleWaitHandle " ; <nl> - " SleepWaitHandle " ; <nl> - " ExternalThreadEventWaitHandle " ; <nl> - " bool " ; <nl> - " int " ; <nl> - " float " ; <nl> - " string " ; <nl> - " void " ; <nl> - " num " ; <nl> - " arraykey " ; <nl> - " resource " ; <nl> - " mixed " ; <nl> - " noreturn " ; <nl> - " this " ; <nl> - " varray_or_darray " ; <nl> - " vec_or_dict " ; <nl> - " arraylike " ; <nl> - " nonnull " ; <nl> - " null " ; <nl> - " nothing " ; <nl> - " dynamic " ; <nl> + " vec " ; <nl> + " xenon_get_data " ; <nl> ] <nl> <nl> - let opt_normalize s = SMap . get s alias_map <nl> + let consts = autoimport_map_of_list [ " Rx \ \ IS_ENABLED " ] <nl> + <nl> + let is_hh_autoimport s = SMap . mem s types <nl> + <nl> + let lookup_type id = <nl> + if Naming_special_names . Typehints . is_reserved_hh_name id then <nl> + Some ( Global , HH ) <nl> + else <nl> + SMap . get id types <nl> + <nl> + let lookup_func id = SMap . get id funcs <nl> <nl> - let normalize s = Option . value ( opt_normalize s ) ~ default : s <nl> + let lookup_const id = SMap . get id consts <nl> <nl> - let is_hh_autoimport s = SMap . mem s alias_map <nl> + let string_of_ns ns = <nl> + match ns with <nl> + | Global - > None <nl> + | HH - > Some " HH " <nl> mmm a / hphp / hack / src / parser / namespaces . ml <nl> ppp b / hphp / hack / src / parser / namespaces . ml <nl> open Ast <nl> open Namespace_env <nl> module SN = Naming_special_names <nl> <nl> - ( * The typechecker has a different view of HH autoimporting than the compiler . <nl> - * This type exists to track the unification of HH autoimporting between the <nl> - * typechecker and the compiler , after which it will be deleted . * ) <nl> - type autoimport_ns = <nl> - | Global <nl> - | HH <nl> - <nl> type elaborate_kind = <nl> | ElaborateFun <nl> | ElaborateClass <nl> | ElaborateRecord <nl> | ElaborateConst <nl> <nl> - ( * * <nl> - * Convenience function for maps that have been completely unified to autoimport <nl> - * into the HH namespace . <nl> - * ) <nl> - let autoimport_map_of_list ids = <nl> - List . fold_left ids ~ init : SMap . empty ~ f : ( fun map id - > SMap . add id HH map ) <nl> - <nl> - ( * When dealing with an < ? hh file , HHVM automatically imports a few <nl> - * " core " classes into every namespace , mostly collections . Their <nl> - * unqualified names always refer to this global version . <nl> - * <nl> - * Note that these are technically in the \ HH namespace as far as the <nl> - * runtime is concerned , but we treat them as in the global <nl> - * namespace . This is a tiny bit weird , but since Facebook www all runs <nl> - * in the global namespace relying on this autoimport , this makes the <nl> - * most sense there . <nl> - * ) <nl> - let autoimport_types = <nl> - SMap . of_list <nl> - [ <nl> - ( " AsyncFunctionWaitHandle " , Global ) ; <nl> - ( " AsyncGenerator " , Global ) ; <nl> - ( " AsyncGeneratorWaitHandle " , Global ) ; <nl> - ( " AsyncIterator " , Global ) ; <nl> - ( " AsyncKeyedIterator " , Global ) ; <nl> - ( " Awaitable " , Global ) ; <nl> - ( " AwaitAllWaitHandle " , Global ) ; <nl> - ( " classname " , Global ) ; <nl> - ( " Collection " , Global ) ; <nl> - ( " ConditionWaitHandle " , Global ) ; <nl> - ( " Container " , Global ) ; <nl> - ( " dict " , Global ) ; <nl> - ( " ExternalThreadEventWaitHandle " , Global ) ; <nl> - ( " IMemoizeParam " , Global ) ; <nl> - ( " ImmMap " , Global ) ; <nl> - ( " ImmSet " , Global ) ; <nl> - ( " ImmVector " , Global ) ; <nl> - ( " InvariantException " , Global ) ; <nl> - ( " Iterable " , Global ) ; <nl> - ( " Iterator " , Global ) ; <nl> - ( " KeyedContainer " , Global ) ; <nl> - ( " KeyedIterable " , Global ) ; <nl> - ( " KeyedIterator " , Global ) ; <nl> - ( " KeyedTraversable " , Global ) ; <nl> - ( " keyset " , Global ) ; <nl> - ( " Map " , Global ) ; <nl> - ( " ObjprofObjectStats " , HH ) ; <nl> - ( " ObjprofPathsStats " , HH ) ; <nl> - ( " ObjprofStringStats " , HH ) ; <nl> - ( " Pair " , Global ) ; <nl> - ( " RescheduleWaitHandle " , Global ) ; <nl> - ( " ResumableWaitHandle " , Global ) ; <nl> - ( " Set " , Global ) ; <nl> - ( " Shapes " , Global ) ; <nl> - ( " SleepWaitHandle " , Global ) ; <nl> - ( " StableMap " , Global ) ; <nl> - ( " StaticWaitHandle " , Global ) ; <nl> - ( " Traversable " , Global ) ; <nl> - ( " typename " , Global ) ; <nl> - ( " TypeStructure " , HH ) ; <nl> - ( " TypeStructureKind " , HH ) ; <nl> - ( " vec " , Global ) ; <nl> - ( " Vector " , Global ) ; <nl> - ( " WaitableWaitHandle " , Global ) ; <nl> - ( " XenonSample " , HH ) ; <nl> - ] <nl> - <nl> - let autoimport_funcs = <nl> - autoimport_map_of_list <nl> - [ <nl> - " asio_get_current_context_idx " ; <nl> - " asio_get_running_in_context " ; <nl> - " asio_get_running " ; <nl> - " class_meth " ; <nl> - " darray " ; <nl> - " dict " ; <nl> - " fun " ; <nl> - " heapgraph_create " ; <nl> - " heapgraph_dfs_edges " ; <nl> - " heapgraph_dfs_nodes " ; <nl> - " heapgraph_edge " ; <nl> - " heapgraph_foreach_edge " ; <nl> - " heapgraph_foreach_node " ; <nl> - " heapgraph_foreach_root " ; <nl> - " heapgraph_node_in_edges " ; <nl> - " heapgraph_node_out_edges " ; <nl> - " heapgraph_node " ; <nl> - " heapgraph_stats " ; <nl> - " idx " ; <nl> - " inst_meth " ; <nl> - " invariant_callback_register " ; <nl> - " invariant_violation " ; <nl> - " invariant " ; <nl> - " is_darray " ; <nl> - " is_dict " ; <nl> - " is_keyset " ; <nl> - " is_varray " ; <nl> - " is_vec " ; <nl> - " keyset " ; <nl> - " meth_caller " ; <nl> - " objprof_get_data " ; <nl> - " objprof_get_paths " ; <nl> - " objprof_get_strings " ; <nl> - " server_warmup_status " ; <nl> - " thread_mark_stack " ; <nl> - " thread_memory_stats " ; <nl> - " type_structure " ; <nl> - " varray " ; <nl> - " vec " ; <nl> - " xenon_get_data " ; <nl> - ] <nl> - <nl> - let autoimport_consts = autoimport_map_of_list [ " Rx \ \ IS_ENABLED " ] <nl> - <nl> ( * * <nl> * Return the namespace into which id is auto imported for the typechecker and <nl> * compiler , respectively . Return None if it is not auto imported . <nl> * ) <nl> let get_autoimport_name_namespace id kind = <nl> - let lookup_name map = Option . map ( SMap . get id map ) ( fun ns - > ( ns , HH ) ) in <nl> match kind with <nl> - | ElaborateClass - > <nl> - if SN . Typehints . is_reserved_hh_name id then <nl> - Some ( Global , HH ) <nl> - else <nl> - lookup_name autoimport_types <nl> - | ElaborateRecord - > lookup_name autoimport_types <nl> - | ElaborateFun - > lookup_name autoimport_funcs <nl> - | ElaborateConst - > lookup_name autoimport_consts <nl> + | ElaborateClass - > Hh_autoimport . lookup_type id <nl> + | ElaborateRecord - > Hh_autoimport . lookup_type id <nl> + | ElaborateFun - > Hh_autoimport . lookup_func id <nl> + | ElaborateConst - > Hh_autoimport . lookup_const id <nl> <nl> let is_autoimport_name id kind = get_autoimport_name_namespace id kind < > None <nl> <nl> let elaborate_id_impl nsenv kind id = <nl> else <nl> typechecker_ns <nl> in <nl> - begin <nl> - match ns with <nl> - | Global - > ( true , elaborate_into_ns None id ) <nl> - | HH - > ( true , elaborate_into_ns ( Some " HH " ) id ) <nl> - end <nl> + ( true , elaborate_into_ns ( Hh_autoimport . string_of_ns ns ) id ) <nl> ) <nl> <nl> let elaborate_id nsenv kind ( p , id ) = <nl> mmm a / hphp / hack / src / parser / namespaces . mli <nl> ppp b / hphp / hack / src / parser / namespaces . mli <nl> type elaborate_kind = <nl> val elaborate_id : <nl> Namespace_env . env - > elaborate_kind - > Ast_defs . id - > Ast_defs . id <nl> <nl> - val elaborate_id_impl : <nl> - Namespace_env . env - > elaborate_kind - > string - > bool * string <nl> - <nl> ( * This function processes only top - level declarations and does not dive <nl> into inline classes / functions - those are disallowed in Hack and doing it will <nl> incur a perf hit that everybody will have to pay . For codegen purposed <nl> | Unify autoimport implementations between typechecker and compiler | facebook/hhvm | c64e3afbdd2e7bef0a64787ea6435d388dbe4398 | 2019-10-09T06:40:25Z |
diff - - git a / Linear Search . cpp b / Linear Search . cpp <nl> mmm a / Linear Search . cpp <nl> ppp b / Linear Search . cpp <nl> <nl> # include < iostream > <nl> using namespace std ; <nl> <nl> - int LinearSearch ( int * array , int key ) <nl> + int LinearSearch ( int * array , int size , int key ) <nl> { <nl> - for ( int i = 0 ; i < 10 ; + + i ) <nl> + for ( int i = 0 ; i < size ; + + i ) <nl> { <nl> if ( array [ i ] = = key ) <nl> { <nl> - return key ; <nl> + return i ; <nl> } <nl> } <nl> <nl> int LinearSearch ( int * array , int key ) <nl> <nl> int main ( ) <nl> { <nl> - int array [ 10 ] ; <nl> + int size ; <nl> + cout < < " \ nEnter the size of the Array : " ; <nl> + cin > > size ; <nl> + <nl> + int array [ size ] ; <nl> int key ; <nl> <nl> / / Input array <nl> - cout < < " \ nEnter the Array of 10 numbers : " ; <nl> - for ( int i = 0 ; i < 10 ; i + + ) <nl> + cout < < " \ nEnter the Array of " < < size < < " numbers : " ; <nl> + for ( int i = 0 ; i < size ; i + + ) <nl> { <nl> cin > > array [ i ] ; <nl> } <nl> + <nl> cout < < " \ nEnter the number to be searched : " ; <nl> cin > > key ; <nl> <nl> - int index = LinearSearch ( array , key ) ; <nl> + int index = LinearSearch ( array , size , key ) ; <nl> if ( index ! = - 1 ) <nl> { <nl> cout < < " \ nNumber found at index : " < < index ; <nl> | Merge pull request from hegdenaveen1 / patch - 8 | TheAlgorithms/C-Plus-Plus | f2ca4b9a29c7e5884172cee9904faee517e61b8a | 2017-12-27T12:53:12Z |
deleted file mode 100644 <nl> index 4ae73a2e720 . . 00000000000 <nl> mmm a / . github / label - pr . yml <nl> ppp / dev / null <nl> <nl> - - regExp : " . * \ \ . md $ " <nl> - labels : [ " documentation " , " pr - documentation " ] <nl> new file mode 100644 <nl> index 00000000000 . . c41d6431b51 <nl> mmm / dev / null <nl> ppp b / . github / labeler . yml <nl> <nl> + # Documentation PRs <nl> + documentation : <nl> + - * * / * . md <nl> + pr - documentation : <nl> + - * * / * . md <nl> deleted file mode 100644 <nl> index a450195b955 . . 00000000000 <nl> mmm a / . github / main . workflow <nl> ppp / dev / null <nl> <nl> - workflow " Main workflow " { <nl> - resolves = [ " Label PR " ] <nl> - on = " pull_request " <nl> - } <nl> - <nl> - action " Label PR " { <nl> - uses = " decathlon / pull - request - labeler - action @ v1 . 0 . 0 " <nl> - secrets = [ " GITHUB_TOKEN " ] <nl> - } <nl> new file mode 100644 <nl> index 00000000000 . . dcafb97dc98 <nl> mmm / dev / null <nl> ppp b / . github / workflows / labeler . yml <nl> <nl> + name : " Pull Request Labeler " <nl> + on : <nl> + - pull_request <nl> + <nl> + jobs : <nl> + triage : <nl> + runs - on : ubuntu - latest <nl> + steps : <nl> + - uses : actions / labeler @ v2 <nl> + with : <nl> + repo - token : " $ { { secrets . GITHUB_TOKEN } } " <nl> | GitHub labeler configuration changes ( ) | ClickHouse/ClickHouse | 1c02fed19bae8c20c65fc5440d67d99eeabaaf4d | 2019-10-20T03:59:21Z |
mmm a / build / cocos2d_libs . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / build / cocos2d_libs . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - 457a8cf1e18a912cbe5fd7538504337d2c8069ed <nl> \ No newline at end of file <nl> + ff210e4a55306fce7f69c41995a746c084b6b074 <nl> \ No newline at end of file <nl> mmm a / build / cocos2d_samples . xcodeproj / project . pbxproj . REMOVED . git - id <nl> ppp b / build / cocos2d_samples . xcodeproj / project . pbxproj . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - f36b451a97f9a0c93a4e23c417d7333f1e293993 <nl> \ No newline at end of file <nl> + 90bb8f93ddfe16e1337c0e278efe123ca1b92891 <nl> \ No newline at end of file <nl> mmm a / cocos / editor - support / cocostudio / CCActionNode . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCActionNode . cpp <nl> void ActionNode : : initActionNodeFromRoot ( Object * root ) <nl> } <nl> else <nl> { <nl> - UIWidget * rootWidget = dynamic_cast < UIWidget * > ( root ) ; <nl> + Widget * rootWidget = dynamic_cast < Widget * > ( root ) ; <nl> if ( rootWidget ! = NULL ) <nl> { <nl> - UIWidget * widget = UIHelper : : seekActionWidgetByActionTag ( rootWidget , getActionTag ( ) ) ; <nl> + Widget * widget = UIHelper : : seekActionWidgetByActionTag ( rootWidget , getActionTag ( ) ) ; <nl> if ( widget ! = NULL ) <nl> { <nl> setObject ( widget ) ; <nl> Node * ActionNode : : getActionNode ( ) <nl> } <nl> else <nl> { <nl> - UIWidget * rootWidget = dynamic_cast < UIWidget * > ( _object ) ; <nl> + Widget * rootWidget = dynamic_cast < Widget * > ( _object ) ; <nl> if ( rootWidget ! = NULL ) <nl> { <nl> - return rootWidget - > getRenderer ( ) ; <nl> + return rootWidget ; <nl> } <nl> } <nl> return NULL ; <nl> mmm a / cocos / editor - support / cocostudio / CCSGUIReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCSGUIReader . cpp <nl> <nl> # include < fstream > <nl> # include < iostream > <nl> <nl> - using namespace gui ; <nl> - using namespace cocos2d ; <nl> + using namespace cocos2d : : gui ; <nl> + using namespace cocos2d ; <nl> <nl> <nl> namespace cocostudio { <nl> static GUIReader * sharedReader = nullptr ; <nl> GUIReader : : GUIReader ( ) : <nl> m_strFilePath ( " " ) <nl> { <nl> - _fileDesignSizes = CCDictionary : : create ( ) ; <nl> - CC_SAFE_RETAIN ( _fileDesignSizes ) ; <nl> } <nl> <nl> GUIReader : : ~ GUIReader ( ) <nl> { <nl> - _fileDesignSizes - > removeAllObjects ( ) ; <nl> - CC_SAFE_RELEASE ( _fileDesignSizes ) ; <nl> } <nl> <nl> GUIReader * GUIReader : : shareReader ( ) <nl> int GUIReader : : getVersionInteger ( const char * str ) <nl> <nl> void GUIReader : : storeFileDesignSize ( const char * fileName , const cocos2d : : Size & size ) <nl> { <nl> - if ( ! _fileDesignSizes ) <nl> - { <nl> - return ; <nl> - } <nl> - cocos2d : : String * strSize = cocos2d : : String : : createWithFormat ( " { % f , % f } " , size . width , size . height ) ; <nl> - _fileDesignSizes - > setObject ( strSize , fileName ) ; <nl> + std : : string keyWidth = fileName ; <nl> + keyWidth . append ( " width " ) ; <nl> + std : : string keyHeight = fileName ; <nl> + keyHeight . append ( " height " ) ; <nl> + _fileDesignSizes [ keyWidth ] = Value ( size . width ) ; <nl> + _fileDesignSizes [ keyHeight ] = Value ( size . height ) ; <nl> } <nl> <nl> const cocos2d : : Size GUIReader : : getFileDesignSize ( const char * fileName ) const <nl> { <nl> - if ( ! _fileDesignSizes ) <nl> - { <nl> - return cocos2d : : Size : : ZERO ; <nl> - } <nl> - cocos2d : : Size designSize = cocos2d : : SizeFromString ( ( ( cocos2d : : String * ) _fileDesignSizes - > objectForKey ( fileName ) ) - > _string . c_str ( ) ) ; <nl> - return designSize ; <nl> + std : : string keyWidth = fileName ; <nl> + keyWidth . append ( " width " ) ; <nl> + std : : string keyHeight = fileName ; <nl> + keyHeight . append ( " height " ) ; <nl> + float w = _fileDesignSizes . at ( keyWidth ) . asFloat ( ) ; <nl> + float h = _fileDesignSizes . at ( keyHeight ) . asFloat ( ) ; <nl> + return Size ( w , h ) ; <nl> } <nl> <nl> <nl> - UIWidget * GUIReader : : widgetFromJsonFile ( const char * fileName ) <nl> + Widget * GUIReader : : widgetFromJsonFile ( const char * fileName ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> <nl> UIWidget * GUIReader : : widgetFromJsonFile ( const char * fileName ) <nl> jsonDict = new JsonDictionary ( ) ; <nl> jsonDict - > initWithDescription ( des . c_str ( ) ) ; <nl> <nl> - UIWidget * widget = nullptr ; <nl> + Widget * widget = nullptr ; <nl> const char * fileVersion = dicHelper - > getStringValue_json ( jsonDict , " version " ) ; <nl> WidgetPropertiesReader * pReader = nullptr ; <nl> if ( fileVersion ) <nl> UIWidget * GUIReader : : widgetFromJsonFile ( const char * fileName ) <nl> <nl> <nl> <nl> - UIWidget * WidgetPropertiesReader0250 : : createWidget ( JsonDictionary * data , const char * fullPath , const char * fileName ) <nl> + Widget * WidgetPropertiesReader0250 : : createWidget ( JsonDictionary * data , const char * fullPath , const char * fileName ) <nl> { <nl> m_strFilePath = fullPath ; <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> UIWidget * WidgetPropertiesReader0250 : : createWidget ( JsonDictionary * data , const c <nl> GUIReader : : shareReader ( ) - > storeFileDesignSize ( fileName , Size ( fileDesignWidth , fileDesignHeight ) ) ; <nl> } <nl> JsonDictionary * widgetTree = dicHelper - > getSubDictionary_json ( data , " widgetTree " ) ; <nl> - UIWidget * widget = widgetFromJsonDictionary ( widgetTree ) ; <nl> + Widget * widget = widgetFromJsonDictionary ( widgetTree ) ; <nl> <nl> / * * * * * * * * * * temp * * * * * * * * * * / <nl> if ( widget - > getContentSize ( ) . equals ( Size : : ZERO ) ) <nl> { <nl> - UILayout * rootWidget = dynamic_cast < UILayout * > ( widget ) ; <nl> + Layout * rootWidget = dynamic_cast < Layout * > ( widget ) ; <nl> rootWidget - > setSize ( Size ( fileDesignWidth , fileDesignHeight ) ) ; <nl> } <nl> / * * * * * * * * * * * * * * * * * * * * * * * * / <nl> UIWidget * WidgetPropertiesReader0250 : : createWidget ( JsonDictionary * data , const c <nl> return widget ; <nl> } <nl> <nl> - UIWidget * WidgetPropertiesReader0250 : : widgetFromJsonDictionary ( JsonDictionary * data ) <nl> + Widget * WidgetPropertiesReader0250 : : widgetFromJsonDictionary ( JsonDictionary * data ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> - UIWidget * widget = nullptr ; <nl> + Widget * widget = nullptr ; <nl> const char * classname = dicHelper - > getStringValue_json ( data , " classname " ) ; <nl> JsonDictionary * uiOptions = dicHelper - > getSubDictionary_json ( data , " options " ) ; <nl> if ( classname & & strcmp ( classname , " Button " ) = = 0 ) <nl> { <nl> - widget = UIButton : : create ( ) ; <nl> + widget = cocos2d : : gui : : Button : : create ( ) ; <nl> setPropsForButtonFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " CheckBox " ) = = 0 ) <nl> { <nl> - widget = UICheckBox : : create ( ) ; <nl> + widget = CheckBox : : create ( ) ; <nl> setPropsForCheckBoxFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " Label " ) = = 0 ) <nl> { <nl> - widget = UILabel : : create ( ) ; <nl> + widget = cocos2d : : gui : : Label : : create ( ) ; <nl> setPropsForLabelFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " LabelAtlas " ) = = 0 ) <nl> { <nl> - widget = UILabelAtlas : : create ( ) ; <nl> + widget = cocos2d : : gui : : LabelAtlas : : create ( ) ; <nl> setPropsForLabelAtlasFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " LoadingBar " ) = = 0 ) <nl> { <nl> - widget = UILoadingBar : : create ( ) ; <nl> + widget = cocos2d : : gui : : LoadingBar : : create ( ) ; <nl> setPropsForLoadingBarFromJsonDictionary ( widget , uiOptions ) ; <nl> } else if ( classname & & strcmp ( classname , " ScrollView " ) = = 0 ) { <nl> - widget = UIScrollView : : create ( ) ; <nl> + widget = cocos2d : : gui : : ScrollView : : create ( ) ; <nl> setPropsForScrollViewFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " TextArea " ) = = 0 ) <nl> { <nl> - widget = UILabel : : create ( ) ; <nl> + widget = cocos2d : : gui : : Label : : create ( ) ; <nl> setPropsForLabelFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " TextButton " ) = = 0 ) <nl> { <nl> - widget = UIButton : : create ( ) ; <nl> + widget = cocos2d : : gui : : Button : : create ( ) ; <nl> setPropsForButtonFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " TextField " ) = = 0 ) <nl> { <nl> - widget = UITextField : : create ( ) ; <nl> + widget = cocos2d : : gui : : TextField : : create ( ) ; <nl> setPropsForTextFieldFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " ImageView " ) = = 0 ) <nl> { <nl> - widget = UIImageView : : create ( ) ; <nl> + widget = cocos2d : : gui : : ImageView : : create ( ) ; <nl> setPropsForImageViewFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " Panel " ) = = 0 ) <nl> { <nl> - widget = UILayout : : create ( ) ; <nl> + widget = Layout : : create ( ) ; <nl> setPropsForLayoutFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " Slider " ) = = 0 ) <nl> { <nl> - widget = UISlider : : create ( ) ; <nl> + widget = cocos2d : : gui : : Slider : : create ( ) ; <nl> setPropsForSliderFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " LabelBMFont " ) = = 0 ) <nl> { <nl> - widget = UILabelBMFont : : create ( ) ; <nl> + widget = cocos2d : : gui : : LabelBMFont : : create ( ) ; <nl> setPropsForLabelBMFontFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " DragPanel " ) = = 0 ) <nl> { <nl> - widget = UIScrollView : : create ( ) ; <nl> + widget = cocos2d : : gui : : ScrollView : : create ( ) ; <nl> setPropsForScrollViewFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> <nl> UIWidget * WidgetPropertiesReader0250 : : widgetFromJsonDictionary ( JsonDictionary * d <nl> for ( int i = 0 ; i < childrenCount ; i + + ) <nl> { <nl> JsonDictionary * subData = dicHelper - > getDictionaryFromArray_json ( data , " children " , i ) ; <nl> - UIWidget * child = widgetFromJsonDictionary ( subData ) ; <nl> + Widget * child = widgetFromJsonDictionary ( subData ) ; <nl> if ( child ) <nl> { <nl> widget - > addChild ( child ) ; <nl> UIWidget * WidgetPropertiesReader0250 : : widgetFromJsonDictionary ( JsonDictionary * d <nl> return widget ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForWidgetFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForWidgetFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> bool ignoreSizeExsit = dicHelper - > checkObjectExist_json ( options , " ignoreSize " ) ; <nl> void WidgetPropertiesReader0250 : : setPropsForWidgetFromJsonDictionary ( UIWidget * wi <nl> widget - > setZOrder ( z ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setColorPropsForWidgetFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setColorPropsForWidgetFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> bool op = dicHelper - > checkObjectExist_json ( options , " opacity " ) ; <nl> void WidgetPropertiesReader0250 : : setColorPropsForWidgetFromJsonDictionary ( UIWidg <nl> widget - > setFlipY ( flipY ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForButtonFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForButtonFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UIButton * button = ( UIButton * ) widget ; <nl> + cocos2d : : gui : : Button * button = static_cast < Button * > ( widget ) ; <nl> bool scale9Enable = dicHelper - > getBooleanValue_json ( options , " scale9Enable " ) ; <nl> button - > setScale9Enabled ( scale9Enable ) ; <nl> <nl> void WidgetPropertiesReader0250 : : setPropsForButtonFromJsonDictionary ( UIWidget * wi <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForCheckBoxFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForCheckBoxFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UICheckBox * checkBox = ( UICheckBox * ) widget ; <nl> + CheckBox * checkBox = static_cast < CheckBox * > ( widget ) ; <nl> const char * backGroundFileName = dicHelper - > getStringValue_json ( options , " backGroundBox " ) ; <nl> const char * backGroundSelectedFileName = dicHelper - > getStringValue_json ( options , " backGroundBoxSelected " ) ; <nl> const char * frontCrossFileName = dicHelper - > getStringValue_json ( options , " frontCross " ) ; <nl> void WidgetPropertiesReader0250 : : setPropsForCheckBoxFromJsonDictionary ( UIWidget * <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForImageViewFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForImageViewFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> <nl> - UIImageView * imageView = ( UIImageView * ) widget ; <nl> + cocos2d : : gui : : ImageView * imageView = static_cast < ImageView * > ( widget ) ; <nl> const char * imageFileName = dicHelper - > getStringValue_json ( options , " fileName " ) ; <nl> bool scale9EnableExist = dicHelper - > checkObjectExist_json ( options , " scale9Enable " ) ; <nl> bool scale9Enable = false ; <nl> void WidgetPropertiesReader0250 : : setPropsForImageViewFromJsonDictionary ( UIWidget <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForLabelFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForLabelFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UILabel * label = ( UILabel * ) widget ; <nl> + cocos2d : : gui : : Label * label = static_cast < cocos2d : : gui : : Label * > ( widget ) ; <nl> bool touchScaleChangeAble = dicHelper - > getBooleanValue_json ( options , " touchScaleEnable " ) ; <nl> label - > setTouchScaleChangeEnabled ( touchScaleChangeAble ) ; <nl> const char * text = dicHelper - > getStringValue_json ( options , " text " ) ; <nl> void WidgetPropertiesReader0250 : : setPropsForLabelFromJsonDictionary ( UIWidget * wid <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForLabelAtlasFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForLabelAtlasFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UILabelAtlas * labelAtlas = ( UILabelAtlas * ) widget ; <nl> + cocos2d : : gui : : LabelAtlas * labelAtlas = static_cast < cocos2d : : gui : : LabelAtlas * > ( widget ) ; <nl> bool sv = dicHelper - > checkObjectExist_json ( options , " stringValue " ) ; <nl> bool cmf = dicHelper - > checkObjectExist_json ( options , " charMapFile " ) ; <nl> bool iw = dicHelper - > checkObjectExist_json ( options , " itemWidth " ) ; <nl> void WidgetPropertiesReader0250 : : setPropsForLabelAtlasFromJsonDictionary ( UIWidge <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForLayoutFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForLayoutFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UILayout * containerWidget = ( UILayout * ) widget ; <nl> - if ( ! dynamic_cast < UIScrollView * > ( containerWidget ) <nl> - & & ! dynamic_cast < UIListView * > ( containerWidget ) ) <nl> + Layout * containerWidget = static_cast < Layout * > ( widget ) ; <nl> + if ( ! dynamic_cast < cocos2d : : gui : : ScrollView * > ( containerWidget ) <nl> + & & ! dynamic_cast < cocos2d : : gui : : ListView * > ( containerWidget ) ) <nl> { <nl> containerWidget - > setClippingEnabled ( dicHelper - > getBooleanValue_json ( options , " clipAble " ) ) ; <nl> } <nl> - UILayout * panel = ( UILayout * ) widget ; <nl> + Layout * panel = ( Layout * ) widget ; <nl> bool backGroundScale9Enable = dicHelper - > getBooleanValue_json ( options , " backGroundScale9Enable " ) ; <nl> panel - > setBackGroundImageScale9Enabled ( backGroundScale9Enable ) ; <nl> int cr = dicHelper - > getIntValue_json ( options , " bgColorR " ) ; <nl> void WidgetPropertiesReader0250 : : setPropsForLayoutFromJsonDictionary ( UIWidget * wi <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForScrollViewFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForScrollViewFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForLayoutFromJsonDictionary ( widget , options ) ; <nl> - UIScrollView * scrollView = ( UIScrollView * ) widget ; <nl> + cocos2d : : gui : : ScrollView * scrollView = static_cast < cocos2d : : gui : : ScrollView * > ( widget ) ; <nl> float innerWidth = dicHelper - > getFloatValue_json ( options , " innerWidth " ) ; <nl> float innerHeight = dicHelper - > getFloatValue_json ( options , " innerHeight " ) ; <nl> scrollView - > setInnerContainerSize ( Size ( innerWidth , innerHeight ) ) ; <nl> void WidgetPropertiesReader0250 : : setPropsForScrollViewFromJsonDictionary ( UIWidge <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForSliderFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForSliderFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UISlider * slider = ( UISlider * ) widget ; <nl> + cocos2d : : gui : : Slider * slider = static_cast < cocos2d : : gui : : Slider * > ( widget ) ; <nl> <nl> bool barTextureScale9Enable = dicHelper - > getBooleanValue_json ( options , " barTextureScale9Enable " ) ; <nl> slider - > setScale9Enabled ( barTextureScale9Enable ) ; <nl> void WidgetPropertiesReader0250 : : setPropsForSliderFromJsonDictionary ( UIWidget * wi <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForTextFieldFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForTextFieldFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UITextField * textField = ( UITextField * ) widget ; <nl> + cocos2d : : gui : : TextField * textField = static_cast < cocos2d : : gui : : TextField * > ( widget ) ; <nl> bool ph = dicHelper - > checkObjectExist_json ( options , " placeHolder " ) ; <nl> if ( ph ) <nl> { <nl> void WidgetPropertiesReader0250 : : setPropsForTextFieldFromJsonDictionary ( UIWidget <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForLoadingBarFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForLoadingBarFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UILoadingBar * loadingBar = ( UILoadingBar * ) widget ; <nl> + cocos2d : : gui : : LoadingBar * loadingBar = static_cast < cocos2d : : gui : : LoadingBar * > ( widget ) ; <nl> bool useMergedTexture = dicHelper - > getBooleanValue_json ( options , " useMergedTexture " ) ; <nl> std : : string tp_b = m_strFilePath ; <nl> const char * imageFileName = dicHelper - > getStringValue_json ( options , " texture " ) ; <nl> void WidgetPropertiesReader0250 : : setPropsForLoadingBarFromJsonDictionary ( UIWidge <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0250 : : setPropsForLabelBMFontFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0250 : : setPropsForLabelBMFontFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> <nl> - UILabelBMFont * labelBMFont = ( UILabelBMFont * ) widget ; <nl> + cocos2d : : gui : : LabelBMFont * labelBMFont = static_cast < cocos2d : : gui : : LabelBMFont * > ( widget ) ; <nl> <nl> std : : string tp_c = m_strFilePath ; <nl> const char * cmf_tp = nullptr ; <nl> void WidgetPropertiesReader0250 : : setPropsForLabelBMFontFromJsonDictionary ( UIWidg <nl> <nl> <nl> / * 0 . 3 . 0 . 0 ~ 1 . 0 . 0 . 0 * / <nl> - UIWidget * WidgetPropertiesReader0300 : : createWidget ( JsonDictionary * data , const char * fullPath , const char * fileName ) <nl> + Widget * WidgetPropertiesReader0300 : : createWidget ( JsonDictionary * data , const char * fullPath , const char * fileName ) <nl> { <nl> m_strFilePath = fullPath ; <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> UIWidget * WidgetPropertiesReader0300 : : createWidget ( JsonDictionary * data , const c <nl> GUIReader : : shareReader ( ) - > storeFileDesignSize ( fileName , Size ( fileDesignWidth , fileDesignHeight ) ) ; <nl> } <nl> JsonDictionary * widgetTree = dicHelper - > getSubDictionary_json ( data , " widgetTree " ) ; <nl> - UIWidget * widget = widgetFromJsonDictionary ( widgetTree ) ; <nl> + Widget * widget = widgetFromJsonDictionary ( widgetTree ) ; <nl> <nl> / * * * * * * * * * * temp * * * * * * * * * * / <nl> if ( widget - > getContentSize ( ) . equals ( Size : : ZERO ) ) <nl> { <nl> - UILayout * rootWidget = dynamic_cast < UILayout * > ( widget ) ; <nl> + Layout * rootWidget = dynamic_cast < Layout * > ( widget ) ; <nl> rootWidget - > setSize ( Size ( fileDesignWidth , fileDesignHeight ) ) ; <nl> } <nl> / * * * * * * * * * * * * * * * * * * * * * * * * / <nl> UIWidget * WidgetPropertiesReader0300 : : createWidget ( JsonDictionary * data , const c <nl> return widget ; <nl> } <nl> <nl> - UIWidget * WidgetPropertiesReader0300 : : widgetFromJsonDictionary ( JsonDictionary * data ) <nl> + Widget * WidgetPropertiesReader0300 : : widgetFromJsonDictionary ( JsonDictionary * data ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> - UIWidget * widget = nullptr ; <nl> + Widget * widget = nullptr ; <nl> const char * classname = dicHelper - > getStringValue_json ( data , " classname " ) ; <nl> JsonDictionary * uiOptions = dicHelper - > getSubDictionary_json ( data , " options " ) ; <nl> if ( classname & & strcmp ( classname , " Button " ) = = 0 ) <nl> { <nl> - widget = UIButton : : create ( ) ; <nl> + widget = cocos2d : : gui : : Button : : create ( ) ; <nl> setPropsForButtonFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " CheckBox " ) = = 0 ) <nl> { <nl> - widget = UICheckBox : : create ( ) ; <nl> + widget = CheckBox : : create ( ) ; <nl> setPropsForCheckBoxFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " Label " ) = = 0 ) <nl> { <nl> - widget = UILabel : : create ( ) ; <nl> + widget = cocos2d : : gui : : Label : : create ( ) ; <nl> setPropsForLabelFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " LabelAtlas " ) = = 0 ) <nl> { <nl> - widget = UILabelAtlas : : create ( ) ; <nl> + widget = cocos2d : : gui : : LabelAtlas : : create ( ) ; <nl> setPropsForLabelAtlasFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " LoadingBar " ) = = 0 ) <nl> { <nl> - widget = UILoadingBar : : create ( ) ; <nl> + widget = cocos2d : : gui : : LoadingBar : : create ( ) ; <nl> setPropsForLoadingBarFromJsonDictionary ( widget , uiOptions ) ; <nl> } else if ( classname & & strcmp ( classname , " ScrollView " ) = = 0 ) { <nl> - widget = UIScrollView : : create ( ) ; <nl> + widget = cocos2d : : gui : : ScrollView : : create ( ) ; <nl> setPropsForScrollViewFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " TextArea " ) = = 0 ) <nl> { <nl> - widget = UILabel : : create ( ) ; <nl> + widget = cocos2d : : gui : : Label : : create ( ) ; <nl> setPropsForLabelFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " TextButton " ) = = 0 ) <nl> { <nl> - widget = UIButton : : create ( ) ; <nl> + widget = cocos2d : : gui : : Button : : create ( ) ; <nl> setPropsForButtonFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " TextField " ) = = 0 ) <nl> { <nl> - widget = UITextField : : create ( ) ; <nl> + widget = cocos2d : : gui : : TextField : : create ( ) ; <nl> setPropsForTextFieldFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " ImageView " ) = = 0 ) <nl> { <nl> - widget = UIImageView : : create ( ) ; <nl> + widget = cocos2d : : gui : : ImageView : : create ( ) ; <nl> setPropsForImageViewFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " Panel " ) = = 0 ) <nl> { <nl> - widget = UILayout : : create ( ) ; <nl> + widget = Layout : : create ( ) ; <nl> setPropsForLayoutFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " Slider " ) = = 0 ) <nl> { <nl> - widget = UISlider : : create ( ) ; <nl> + widget = cocos2d : : gui : : Slider : : create ( ) ; <nl> setPropsForSliderFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " LabelBMFont " ) = = 0 ) <nl> { <nl> - widget = UILabelBMFont : : create ( ) ; <nl> + widget = cocos2d : : gui : : LabelBMFont : : create ( ) ; <nl> setPropsForLabelBMFontFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " DragPanel " ) = = 0 ) <nl> { <nl> - widget = UIScrollView : : create ( ) ; <nl> + widget = cocos2d : : gui : : ScrollView : : create ( ) ; <nl> setPropsForScrollViewFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " ListView " ) = = 0 ) <nl> { <nl> - widget = UIListView : : create ( ) ; <nl> + widget = cocos2d : : gui : : ListView : : create ( ) ; <nl> setPropsForListViewFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> else if ( classname & & strcmp ( classname , " PageView " ) = = 0 ) <nl> { <nl> - widget = UIPageView : : create ( ) ; <nl> + widget = cocos2d : : gui : : PageView : : create ( ) ; <nl> setPropsForPageViewFromJsonDictionary ( widget , uiOptions ) ; <nl> } <nl> <nl> UIWidget * WidgetPropertiesReader0300 : : widgetFromJsonDictionary ( JsonDictionary * d <nl> for ( int i = 0 ; i < childrenCount ; i + + ) <nl> { <nl> JsonDictionary * subData = dicHelper - > getDictionaryFromArray_json ( data , " children " , i ) ; <nl> - UIWidget * child = widgetFromJsonDictionary ( subData ) ; <nl> + Widget * child = widgetFromJsonDictionary ( subData ) ; <nl> if ( child ) <nl> { <nl> widget - > addChild ( child ) ; <nl> } <nl> CC_SAFE_DELETE ( subData ) ; <nl> } <nl> - <nl> - UILayout * layout = dynamic_cast < UILayout * > ( widget ) ; <nl> - if ( layout ) <nl> - { <nl> - layout - > doLayout ( ) ; <nl> - } <nl> <nl> CC_SAFE_DELETE ( uiOptions ) ; <nl> return widget ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForWidgetFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForWidgetFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> bool ignoreSizeExsit = dicHelper - > checkObjectExist_json ( options , " ignoreSize " ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForWidgetFromJsonDictionary ( UIWidget * wi <nl> if ( layoutParameterDic ) <nl> { <nl> int paramType = dicHelper - > getIntValue_json ( layoutParameterDic , " type " ) ; <nl> - UILayoutParameter * parameter = nullptr ; <nl> + LayoutParameter * parameter = nullptr ; <nl> switch ( paramType ) <nl> { <nl> case 0 : <nl> break ; <nl> case 1 : <nl> { <nl> - parameter = UILinearLayoutParameter : : create ( ) ; <nl> + parameter = LinearLayoutParameter : : create ( ) ; <nl> int gravity = dicHelper - > getIntValue_json ( layoutParameterDic , " gravity " ) ; <nl> - ( ( UILinearLayoutParameter * ) parameter ) - > setGravity ( ( UILinearGravity ) gravity ) ; <nl> + ( ( LinearLayoutParameter * ) parameter ) - > setGravity ( ( LinearGravity ) gravity ) ; <nl> break ; <nl> } <nl> case 2 : <nl> { <nl> - parameter = UIRelativeLayoutParameter : : create ( ) ; <nl> - UIRelativeLayoutParameter * rParameter = ( UIRelativeLayoutParameter * ) parameter ; <nl> + parameter = RelativeLayoutParameter : : create ( ) ; <nl> + RelativeLayoutParameter * rParameter = ( RelativeLayoutParameter * ) parameter ; <nl> const char * relativeName = dicHelper - > getStringValue_json ( layoutParameterDic , " relativeName " ) ; <nl> rParameter - > setRelativeName ( relativeName ) ; <nl> const char * relativeToName = dicHelper - > getStringValue_json ( layoutParameterDic , " relativeToName " ) ; <nl> rParameter - > setRelativeToWidgetName ( relativeToName ) ; <nl> int align = dicHelper - > getIntValue_json ( layoutParameterDic , " align " ) ; <nl> - rParameter - > setAlign ( ( UIRelativeAlign ) align ) ; <nl> + rParameter - > setAlign ( ( RelativeAlign ) align ) ; <nl> break ; <nl> } <nl> default : <nl> void WidgetPropertiesReader0300 : : setPropsForWidgetFromJsonDictionary ( UIWidget * wi <nl> float mgt = dicHelper - > getFloatValue_json ( layoutParameterDic , " marginTop " ) ; <nl> float mgr = dicHelper - > getFloatValue_json ( layoutParameterDic , " marginRight " ) ; <nl> float mgb = dicHelper - > getFloatValue_json ( layoutParameterDic , " marginDown " ) ; <nl> - parameter - > setMargin ( UIMargin ( mgl , mgt , mgr , mgb ) ) ; <nl> + parameter - > setMargin ( Margin ( mgl , mgt , mgr , mgb ) ) ; <nl> widget - > setLayoutParameter ( parameter ) ; <nl> } <nl> } <nl> CC_SAFE_DELETE ( layoutParameterDic ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setColorPropsForWidgetFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setColorPropsForWidgetFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> bool op = dicHelper - > checkObjectExist_json ( options , " opacity " ) ; <nl> void WidgetPropertiesReader0300 : : setColorPropsForWidgetFromJsonDictionary ( UIWidg <nl> widget - > setFlipY ( flipY ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForButtonFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForButtonFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UIButton * button = ( UIButton * ) widget ; <nl> + cocos2d : : gui : : Button * button = static_cast < cocos2d : : gui : : Button * > ( widget ) ; <nl> bool scale9Enable = dicHelper - > getBooleanValue_json ( options , " scale9Enable " ) ; <nl> button - > setScale9Enabled ( scale9Enable ) ; <nl> <nl> void WidgetPropertiesReader0300 : : setPropsForButtonFromJsonDictionary ( UIWidget * wi <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForCheckBoxFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForCheckBoxFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UICheckBox * checkBox = ( UICheckBox * ) widget ; <nl> + CheckBox * checkBox = static_cast < cocos2d : : gui : : CheckBox * > ( widget ) ; <nl> <nl> JsonDictionary * backGroundDic = dicHelper - > getSubDictionary_json ( options , " backGroundBoxData " ) ; <nl> int backGroundType = dicHelper - > getIntValue_json ( backGroundDic , " resourceType " ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForCheckBoxFromJsonDictionary ( UIWidget * <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForImageViewFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForImageViewFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> <nl> - UIImageView * imageView = ( UIImageView * ) widget ; <nl> + cocos2d : : gui : : ImageView * imageView = static_cast < cocos2d : : gui : : ImageView * > ( widget ) ; <nl> <nl> JsonDictionary * imageFileNameDic = dicHelper - > getSubDictionary_json ( options , " fileNameData " ) ; <nl> int imageFileNameType = dicHelper - > getIntValue_json ( imageFileNameDic , " resourceType " ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForImageViewFromJsonDictionary ( UIWidget <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForLabelFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForLabelFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UILabel * label = ( UILabel * ) widget ; <nl> + cocos2d : : gui : : Label * label = static_cast < cocos2d : : gui : : Label * > ( widget ) ; <nl> bool touchScaleChangeAble = dicHelper - > getBooleanValue_json ( options , " touchScaleEnable " ) ; <nl> label - > setTouchScaleChangeEnabled ( touchScaleChangeAble ) ; <nl> const char * text = dicHelper - > getStringValue_json ( options , " text " ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForLabelFromJsonDictionary ( UIWidget * wid <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForLabelAtlasFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForLabelAtlasFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UILabelAtlas * labelAtlas = ( UILabelAtlas * ) widget ; <nl> + cocos2d : : gui : : LabelAtlas * labelAtlas = static_cast < cocos2d : : gui : : LabelAtlas * > ( widget ) ; <nl> bool sv = dicHelper - > checkObjectExist_json ( options , " stringValue " ) ; <nl> bool cmf = dicHelper - > checkObjectExist_json ( options , " charMapFile " ) ; <nl> bool iw = dicHelper - > checkObjectExist_json ( options , " itemWidth " ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForLabelAtlasFromJsonDictionary ( UIWidge <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForLayoutFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForLayoutFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UILayout * panel = ( UILayout * ) widget ; <nl> - if ( ! dynamic_cast < UIScrollView * > ( widget ) <nl> - & & ! dynamic_cast < UIListView * > ( widget ) ) <nl> + Layout * panel = static_cast < cocos2d : : gui : : Layout * > ( widget ) ; <nl> + if ( ! dynamic_cast < cocos2d : : gui : : ScrollView * > ( widget ) <nl> + & & ! dynamic_cast < cocos2d : : gui : : ListView * > ( widget ) ) <nl> { <nl> panel - > setClippingEnabled ( dicHelper - > getBooleanValue_json ( options , " clipAble " ) ) ; <nl> } <nl> void WidgetPropertiesReader0300 : : setPropsForLayoutFromJsonDictionary ( UIWidget * wi <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForScrollViewFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForScrollViewFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForLayoutFromJsonDictionary ( widget , options ) ; <nl> - UIScrollView * scrollView = ( UIScrollView * ) widget ; <nl> + cocos2d : : gui : : ScrollView * scrollView = static_cast < cocos2d : : gui : : ScrollView * > ( widget ) ; <nl> float innerWidth = dicHelper - > getFloatValue_json ( options , " innerWidth " ) ; <nl> float innerHeight = dicHelper - > getFloatValue_json ( options , " innerHeight " ) ; <nl> scrollView - > setInnerContainerSize ( Size ( innerWidth , innerHeight ) ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForScrollViewFromJsonDictionary ( UIWidge <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForSliderFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForSliderFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UISlider * slider = ( UISlider * ) widget ; <nl> + cocos2d : : gui : : Slider * slider = static_cast < cocos2d : : gui : : Slider * > ( widget ) ; <nl> <nl> bool barTextureScale9Enable = dicHelper - > getBooleanValue_json ( options , " barTextureScale9Enable " ) ; <nl> slider - > setScale9Enabled ( barTextureScale9Enable ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForSliderFromJsonDictionary ( UIWidget * wi <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForTextFieldFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForTextFieldFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UITextField * textField = ( UITextField * ) widget ; <nl> + cocos2d : : gui : : TextField * textField = static_cast < cocos2d : : gui : : TextField * > ( widget ) ; <nl> bool ph = dicHelper - > checkObjectExist_json ( options , " placeHolder " ) ; <nl> if ( ph ) <nl> { <nl> void WidgetPropertiesReader0300 : : setPropsForTextFieldFromJsonDictionary ( UIWidget <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForLoadingBarFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForLoadingBarFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> - UILoadingBar * loadingBar = ( UILoadingBar * ) widget ; <nl> + cocos2d : : gui : : LoadingBar * loadingBar = static_cast < cocos2d : : gui : : LoadingBar * > ( widget ) ; <nl> <nl> JsonDictionary * imageFileNameDic = dicHelper - > getSubDictionary_json ( options , " textureData " ) ; <nl> int imageFileNameType = dicHelper - > getIntValue_json ( imageFileNameDic , " resourceType " ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForLoadingBarFromJsonDictionary ( UIWidge <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForLabelBMFontFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForLabelBMFontFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> DictionaryHelper * dicHelper = DICTOOL ; <nl> setPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> <nl> - UILabelBMFont * labelBMFont = ( UILabelBMFont * ) widget ; <nl> + cocos2d : : gui : : LabelBMFont * labelBMFont = static_cast < cocos2d : : gui : : LabelBMFont * > ( widget ) ; <nl> <nl> JsonDictionary * cmftDic = dicHelper - > getSubDictionary_json ( options , " fileNameData " ) ; <nl> int cmfType = dicHelper - > getIntValue_json ( cmftDic , " resourceType " ) ; <nl> void WidgetPropertiesReader0300 : : setPropsForLabelBMFontFromJsonDictionary ( UIWidg <nl> setColorPropsForWidgetFromJsonDictionary ( widget , options ) ; <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForPageViewFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForPageViewFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> <nl> } <nl> <nl> - void WidgetPropertiesReader0300 : : setPropsForListViewFromJsonDictionary ( UIWidget * widget , JsonDictionary * options ) <nl> + void WidgetPropertiesReader0300 : : setPropsForListViewFromJsonDictionary ( Widget * widget , JsonDictionary * options ) <nl> { <nl> <nl> } <nl> mmm a / cocos / editor - support / cocostudio / CCSGUIReader . h <nl> ppp b / cocos / editor - support / cocostudio / CCSGUIReader . h <nl> class GUIReader : public cocos2d : : Object <nl> * / <nl> static void purgeGUIReader ( ) ; <nl> <nl> - gui : : UIWidget * widgetFromJsonFile ( const char * fileName ) ; <nl> + cocos2d : : gui : : Widget * widgetFromJsonFile ( const char * fileName ) ; <nl> int getVersionInteger ( const char * str ) ; <nl> / * * <nl> * @ js NA <nl> class GUIReader : public cocos2d : : Object <nl> const cocos2d : : Size getFileDesignSize ( const char * fileName ) const ; <nl> protected : <nl> std : : string m_strFilePath ; <nl> - cocos2d : : Dictionary * _fileDesignSizes ; <nl> + cocos2d : : ValueMap _fileDesignSizes ; <nl> + <nl> } ; <nl> <nl> class WidgetPropertiesReader : public cocos2d : : Object <nl> { <nl> public : <nl> - virtual gui : : UIWidget * createWidget ( JsonDictionary * dic , const char * fullPath , const char * fileName ) = 0 ; <nl> - virtual gui : : UIWidget * widgetFromJsonDictionary ( JsonDictionary * dic ) = 0 ; <nl> + virtual cocos2d : : gui : : Widget * createWidget ( JsonDictionary * dic , const char * fullPath , const char * fileName ) = 0 ; <nl> + virtual cocos2d : : gui : : Widget * widgetFromJsonDictionary ( JsonDictionary * dic ) = 0 ; <nl> protected : <nl> std : : string m_strFilePath ; <nl> } ; <nl> class WidgetPropertiesReader0250 : public WidgetPropertiesReader <nl> WidgetPropertiesReader0250 ( ) { } ; <nl> virtual ~ WidgetPropertiesReader0250 ( ) { } ; <nl> <nl> - virtual gui : : UIWidget * createWidget ( JsonDictionary * dic , const char * fullPath , const char * fileName ) ; <nl> - virtual gui : : UIWidget * widgetFromJsonDictionary ( JsonDictionary * dic ) ; <nl> - virtual void setPropsForWidgetFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> + virtual cocos2d : : gui : : Widget * createWidget ( JsonDictionary * dic , const char * fullPath , const char * fileName ) ; <nl> + virtual cocos2d : : gui : : Widget * widgetFromJsonDictionary ( JsonDictionary * dic ) ; <nl> + virtual void setPropsForWidgetFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> <nl> - virtual void setColorPropsForWidgetFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForButtonFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForCheckBoxFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForImageViewFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForLabelFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForLabelAtlasFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForLabelBMFontFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForLoadingBarFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForSliderFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForTextFieldFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> + virtual void setColorPropsForWidgetFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForButtonFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForCheckBoxFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForImageViewFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLabelFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLabelAtlasFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLabelBMFontFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLoadingBarFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForSliderFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForTextFieldFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> <nl> - virtual void setPropsForLayoutFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForScrollViewFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLayoutFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForScrollViewFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> } ; <nl> <nl> class WidgetPropertiesReader0300 : public WidgetPropertiesReader <nl> class WidgetPropertiesReader0300 : public WidgetPropertiesReader <nl> WidgetPropertiesReader0300 ( ) { } ; <nl> virtual ~ WidgetPropertiesReader0300 ( ) { } ; <nl> <nl> - virtual gui : : UIWidget * createWidget ( JsonDictionary * dic , const char * fullPath , const char * fileName ) ; <nl> - virtual gui : : UIWidget * widgetFromJsonDictionary ( JsonDictionary * dic ) ; <nl> - virtual void setPropsForWidgetFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> + virtual cocos2d : : gui : : Widget * createWidget ( JsonDictionary * dic , const char * fullPath , const char * fileName ) ; <nl> + virtual cocos2d : : gui : : Widget * widgetFromJsonDictionary ( JsonDictionary * dic ) ; <nl> + virtual void setPropsForWidgetFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> <nl> - virtual void setColorPropsForWidgetFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForButtonFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForCheckBoxFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForImageViewFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForLabelFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForLabelAtlasFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForLabelBMFontFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForLoadingBarFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForSliderFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForTextFieldFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> + virtual void setColorPropsForWidgetFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForButtonFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForCheckBoxFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForImageViewFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLabelFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLabelAtlasFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLabelBMFontFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLoadingBarFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForSliderFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForTextFieldFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> <nl> - virtual void setPropsForLayoutFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForPageViewFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForScrollViewFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> - virtual void setPropsForListViewFromJsonDictionary ( gui : : UIWidget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForLayoutFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForPageViewFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForScrollViewFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> + virtual void setPropsForListViewFromJsonDictionary ( cocos2d : : gui : : Widget * widget , JsonDictionary * options ) ; <nl> } ; <nl> <nl> <nl> mmm a / cocos / editor - support / cocostudio / CCSSceneReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCSSceneReader . cpp <nl> namespace cocostudio { <nl> } <nl> else if ( comName ! = nullptr & & strcmp ( comName , " GUIComponent " ) = = 0 ) <nl> { <nl> - gui : : UILayer * pLayer = gui : : UILayer : : create ( ) ; <nl> - pLayer - > scheduleUpdate ( ) ; <nl> - UIWidget * widget = GUIReader : : shareReader ( ) - > widgetFromJsonFile ( pPath . c_str ( ) ) ; <nl> - pLayer - > addWidget ( widget ) ; <nl> - ComRender * pRender = ComRender : : create ( pLayer , " GUIComponent " ) ; <nl> + Widget * widget = GUIReader : : shareReader ( ) - > widgetFromJsonFile ( pPath . c_str ( ) ) ; <nl> + ComRender * pRender = ComRender : : create ( widget , " GUIComponent " ) ; <nl> if ( pComName ! = nullptr ) <nl> { <nl> pRender - > setName ( pComName ) ; <nl> mmm a / cocos / gui / CocosGUI . cpp <nl> ppp b / cocos / gui / CocosGUI . cpp <nl> <nl> <nl> # include " gui / CocosGUI . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> const char * CocosGUIVersion ( ) <nl> const char * CocosGUIVersion ( ) <nl> } <nl> <nl> } <nl> + NS_CC_END <nl> mmm a / cocos / gui / CocosGUI . h <nl> ppp b / cocos / gui / CocosGUI . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> # include " gui / UILayout . h " <nl> - # include " gui / UIRootWidget . h " <nl> # include " gui / UIButton . h " <nl> # include " gui / UICheckBox . h " <nl> # include " gui / UIImageView . h " <nl> <nl> # include " gui / UILabelBMFont . h " <nl> # include " gui / UIPageView . h " <nl> # include " gui / UIHelper . h " <nl> - # include " gui / UILayer . h " <nl> + <nl> + NS_CC_BEGIN <nl> namespace gui { <nl> <nl> const char * CocosGUIVersion ( ) ; <nl> <nl> } <nl> + NS_CC_END <nl> <nl> # endif / * defined ( __CocosGUITest__Cocos__ ) * / <nl> mmm a / cocos / gui / UIButton . cpp <nl> ppp b / cocos / gui / UIButton . cpp <nl> <nl> # include " gui / UIButton . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> # define NORMALRENDERERZ ( 0 ) <nl> namespace gui { <nl> # define DISABLEDRENDERERZ ( 0 ) <nl> # define TITLERENDERERZ ( 1 ) <nl> <nl> - UIButton : : UIButton ( ) : <nl> + Button : : Button ( ) : <nl> _buttonNormalRenderer ( nullptr ) , <nl> _buttonClickedRenderer ( nullptr ) , <nl> _buttonDisableRenderer ( nullptr ) , <nl> _clickedFileName ( " " ) , <nl> _disabledFileName ( " " ) , <nl> _prevIgnoreSize ( true ) , <nl> _scale9Enabled ( false ) , <nl> - _capInsetsNormal ( cocos2d : : Rect : : ZERO ) , <nl> - _capInsetsPressed ( cocos2d : : Rect : : ZERO ) , <nl> - _capInsetsDisabled ( cocos2d : : Rect : : ZERO ) , <nl> + _capInsetsNormal ( Rect : : ZERO ) , <nl> + _capInsetsPressed ( Rect : : ZERO ) , <nl> + _capInsetsDisabled ( Rect : : ZERO ) , <nl> _normalTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _pressedTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _disabledTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _normalTextureSize ( _size ) , <nl> _pressedTextureSize ( _size ) , <nl> _disabledTextureSize ( _size ) , <nl> _pressedActionEnabled ( false ) , <nl> - _titleColor ( cocos2d : : Color3B : : WHITE ) <nl> + _titleColor ( Color3B : : WHITE ) <nl> { <nl> <nl> } <nl> <nl> - UIButton : : ~ UIButton ( ) <nl> + Button : : ~ Button ( ) <nl> { <nl> } <nl> <nl> - UIButton * UIButton : : create ( ) <nl> + Button * Button : : create ( ) <nl> { <nl> - UIButton * widget = new UIButton ( ) ; <nl> + Button * widget = new Button ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UIButton * UIButton : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UIButton : : init ( ) <nl> + bool Button : : init ( ) <nl> { <nl> - if ( UIWidget : : init ( ) ) <nl> + if ( Widget : : init ( ) ) <nl> { <nl> return true ; <nl> } <nl> return false ; <nl> } <nl> <nl> - void UIButton : : initRenderer ( ) <nl> + void Button : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> - _buttonNormalRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _buttonClickedRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _buttonDisableRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _titleRenderer = cocos2d : : LabelTTF : : create ( ) ; <nl> - _renderer - > addChild ( _buttonNormalRenderer , NORMALRENDERERZ ) ; <nl> - _renderer - > addChild ( _buttonClickedRenderer , PRESSEDRENDERERZ ) ; <nl> - _renderer - > addChild ( _buttonDisableRenderer , DISABLEDRENDERERZ ) ; <nl> - _renderer - > addChild ( _titleRenderer , TITLERENDERERZ ) ; <nl> + _buttonNormalRenderer = Sprite : : create ( ) ; <nl> + _buttonClickedRenderer = Sprite : : create ( ) ; <nl> + _buttonDisableRenderer = Sprite : : create ( ) ; <nl> + _titleRenderer = LabelTTF : : create ( ) ; <nl> + Node : : addChild ( _buttonNormalRenderer , NORMALRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _buttonClickedRenderer , PRESSEDRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _buttonDisableRenderer , DISABLEDRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _titleRenderer , TITLERENDERERZ , - 1 ) ; <nl> } <nl> <nl> - void UIButton : : setScale9Enabled ( bool able ) <nl> + void Button : : setScale9Enabled ( bool able ) <nl> { <nl> if ( _scale9Enabled = = able ) <nl> { <nl> void UIButton : : setScale9Enabled ( bool able ) <nl> _brightStyle = BRIGHT_NONE ; <nl> _scale9Enabled = able ; <nl> <nl> - <nl> - _renderer - > removeChild ( _buttonNormalRenderer , true ) ; <nl> - _renderer - > removeChild ( _buttonClickedRenderer , true ) ; <nl> - _renderer - > removeChild ( _buttonDisableRenderer , true ) ; <nl> + Node : : removeChild ( _buttonNormalRenderer ) ; <nl> + Node : : removeChild ( _buttonClickedRenderer ) ; <nl> + Node : : removeChild ( _buttonDisableRenderer ) ; <nl> <nl> _buttonNormalRenderer = nullptr ; <nl> _buttonClickedRenderer = nullptr ; <nl> _buttonDisableRenderer = nullptr ; <nl> if ( _scale9Enabled ) <nl> { <nl> - _buttonNormalRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> - _buttonClickedRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> - _buttonDisableRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _buttonNormalRenderer = extension : : Scale9Sprite : : create ( ) ; <nl> + _buttonClickedRenderer = extension : : Scale9Sprite : : create ( ) ; <nl> + _buttonDisableRenderer = extension : : Scale9Sprite : : create ( ) ; <nl> } <nl> else <nl> { <nl> - _buttonNormalRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _buttonClickedRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _buttonDisableRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _buttonNormalRenderer = Sprite : : create ( ) ; <nl> + _buttonClickedRenderer = Sprite : : create ( ) ; <nl> + _buttonDisableRenderer = Sprite : : create ( ) ; <nl> } <nl> <nl> loadTextureNormal ( _normalFileName . c_str ( ) , _normalTexType ) ; <nl> loadTexturePressed ( _clickedFileName . c_str ( ) , _pressedTexType ) ; <nl> loadTextureDisabled ( _disabledFileName . c_str ( ) , _disabledTexType ) ; <nl> - _renderer - > addChild ( _buttonNormalRenderer , NORMALRENDERERZ ) ; <nl> - _renderer - > addChild ( _buttonClickedRenderer , PRESSEDRENDERERZ ) ; <nl> - _renderer - > addChild ( _buttonDisableRenderer , DISABLEDRENDERERZ ) ; <nl> + Node : : addChild ( _buttonNormalRenderer , NORMALRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _buttonClickedRenderer , PRESSEDRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _buttonDisableRenderer , DISABLEDRENDERERZ , - 1 ) ; <nl> if ( _scale9Enabled ) <nl> { <nl> bool ignoreBefore = _ignoreSize ; <nl> void UIButton : : setScale9Enabled ( bool able ) <nl> setBright ( _bright ) ; <nl> } <nl> <nl> - void UIButton : : ignoreContentAdaptWithSize ( bool ignore ) <nl> + void Button : : ignoreContentAdaptWithSize ( bool ignore ) <nl> { <nl> if ( ! _scale9Enabled | | ( _scale9Enabled & & ! ignore ) ) <nl> { <nl> - UIWidget : : ignoreContentAdaptWithSize ( ignore ) ; <nl> + Widget : : ignoreContentAdaptWithSize ( ignore ) ; <nl> _prevIgnoreSize = ignore ; <nl> } <nl> } <nl> <nl> - void UIButton : : loadTextures ( const char * normal , const char * selected , const char * disabled , TextureResType texType ) <nl> + void Button : : loadTextures ( const char * normal , const char * selected , const char * disabled , TextureResType texType ) <nl> { <nl> loadTextureNormal ( normal , texType ) ; <nl> loadTexturePressed ( selected , texType ) ; <nl> loadTextureDisabled ( disabled , texType ) ; <nl> } <nl> <nl> - void UIButton : : loadTextureNormal ( const char * normal , TextureResType texType ) <nl> + void Button : : loadTextureNormal ( const char * normal , TextureResType texType ) <nl> { <nl> if ( ! normal | | strcmp ( normal , " " ) = = 0 ) <nl> { <nl> void UIButton : : loadTextureNormal ( const char * normal , TextureResType texType ) <nl> _normalTexType = texType ; <nl> if ( _scale9Enabled ) <nl> { <nl> + extension : : Scale9Sprite * normalRendererScale9 = static_cast < extension : : Scale9Sprite * > ( _buttonNormalRenderer ) ; <nl> switch ( _normalTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > initWithFile ( normal ) ; <nl> + normalRendererScale9 - > initWithFile ( normal ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > initWithSpriteFrameName ( normal ) ; <nl> + normalRendererScale9 - > initWithSpriteFrameName ( normal ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setCapInsets ( _capInsetsNormal ) ; <nl> + normalRendererScale9 - > setCapInsets ( _capInsetsNormal ) ; <nl> } <nl> else <nl> { <nl> + Sprite * normalRenderer = static_cast < Sprite * > ( _buttonNormalRenderer ) ; <nl> switch ( _normalTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setTexture ( normal ) ; <nl> + normalRenderer - > setTexture ( normal ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setSpriteFrame ( normal ) ; <nl> + normalRenderer - > setSpriteFrame ( normal ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> _normalTextureSize = _buttonNormalRenderer - > getContentSize ( ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> updateAnchorPoint ( ) ; <nl> normalTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UIButton : : loadTexturePressed ( const char * selected , TextureResType texType ) <nl> + void Button : : loadTexturePressed ( const char * selected , TextureResType texType ) <nl> { <nl> if ( ! selected | | strcmp ( selected , " " ) = = 0 ) <nl> { <nl> void UIButton : : loadTexturePressed ( const char * selected , TextureResType texType ) <nl> _pressedTexType = texType ; <nl> if ( _scale9Enabled ) <nl> { <nl> + extension : : Scale9Sprite * clickedRendererScale9 = static_cast < extension : : Scale9Sprite * > ( _buttonClickedRenderer ) ; <nl> switch ( _pressedTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > initWithFile ( selected ) ; <nl> + clickedRendererScale9 - > initWithFile ( selected ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > initWithSpriteFrameName ( selected ) ; <nl> + clickedRendererScale9 - > initWithSpriteFrameName ( selected ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setCapInsets ( _capInsetsPressed ) ; <nl> + clickedRendererScale9 - > setCapInsets ( _capInsetsPressed ) ; <nl> } <nl> else <nl> { <nl> + Sprite * clickedRenderer = static_cast < Sprite * > ( _buttonClickedRenderer ) ; <nl> switch ( _pressedTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setTexture ( selected ) ; <nl> + clickedRenderer - > setTexture ( selected ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setSpriteFrame ( selected ) ; <nl> + clickedRenderer - > setSpriteFrame ( selected ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> _pressedTextureSize = _buttonClickedRenderer - > getContentSize ( ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> updateAnchorPoint ( ) ; <nl> pressedTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UIButton : : loadTextureDisabled ( const char * disabled , TextureResType texType ) <nl> + void Button : : loadTextureDisabled ( const char * disabled , TextureResType texType ) <nl> { <nl> if ( ! disabled | | strcmp ( disabled , " " ) = = 0 ) <nl> { <nl> void UIButton : : loadTextureDisabled ( const char * disabled , TextureResType texType ) <nl> _disabledTexType = texType ; <nl> if ( _scale9Enabled ) <nl> { <nl> + extension : : Scale9Sprite * disabledScale9 = static_cast < extension : : Scale9Sprite * > ( _buttonDisableRenderer ) ; <nl> switch ( _disabledTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > initWithFile ( disabled ) ; <nl> + disabledScale9 - > initWithFile ( disabled ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > initWithSpriteFrameName ( disabled ) ; <nl> + disabledScale9 - > initWithSpriteFrameName ( disabled ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setCapInsets ( _capInsetsDisabled ) ; <nl> + disabledScale9 - > setCapInsets ( _capInsetsDisabled ) ; <nl> } <nl> else <nl> { <nl> + Sprite * disabledRenderer = static_cast < Sprite * > ( _buttonDisableRenderer ) ; <nl> switch ( _disabledTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setTexture ( disabled ) ; <nl> + disabledRenderer - > setTexture ( disabled ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setSpriteFrame ( disabled ) ; <nl> + disabledRenderer - > setSpriteFrame ( disabled ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> _disabledTextureSize = _buttonDisableRenderer - > getContentSize ( ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> updateAnchorPoint ( ) ; <nl> disabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UIButton : : setCapInsets ( const cocos2d : : Rect & capInsets ) <nl> + void Button : : setCapInsets ( const Rect & capInsets ) <nl> { <nl> setCapInsetsNormalRenderer ( capInsets ) ; <nl> setCapInsetsPressedRenderer ( capInsets ) ; <nl> setCapInsetsDisabledRenderer ( capInsets ) ; <nl> } <nl> <nl> - void UIButton : : setCapInsetsNormalRenderer ( const cocos2d : : Rect & capInsets ) <nl> + void Button : : setCapInsetsNormalRenderer ( const Rect & capInsets ) <nl> { <nl> _capInsetsNormal = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setCapInsets ( capInsets ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UIButton : : setCapInsetsPressedRenderer ( const cocos2d : : Rect & capInsets ) <nl> + void Button : : setCapInsetsPressedRenderer ( const Rect & capInsets ) <nl> { <nl> _capInsetsPressed = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setCapInsets ( capInsets ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UIButton : : setCapInsetsDisabledRenderer ( const cocos2d : : Rect & capInsets ) <nl> + void Button : : setCapInsetsDisabledRenderer ( const Rect & capInsets ) <nl> { <nl> _capInsetsDisabled = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setCapInsets ( capInsets ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UIButton : : onPressStateChangedToNormal ( ) <nl> + void Button : : onPressStateChangedToNormal ( ) <nl> { <nl> _buttonNormalRenderer - > setVisible ( true ) ; <nl> _buttonClickedRenderer - > setVisible ( false ) ; <nl> void UIButton : : onPressStateChangedToNormal ( ) <nl> _buttonNormalRenderer - > stopAllActions ( ) ; <nl> _buttonClickedRenderer - > stopAllActions ( ) ; <nl> _buttonDisableRenderer - > stopAllActions ( ) ; <nl> - cocos2d : : Action * zoomAction = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> - cocos2d : : Action * zoomAction1 = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> - cocos2d : : Action * zoomAction2 = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> + Action * zoomAction = ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> + Action * zoomAction1 = ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> + Action * zoomAction2 = ScaleTo : : create ( 0 . 05f , 1 . 0f ) ; <nl> _buttonNormalRenderer - > runAction ( zoomAction ) ; <nl> _buttonClickedRenderer - > runAction ( zoomAction1 ) ; <nl> _buttonDisableRenderer - > runAction ( zoomAction2 ) ; <nl> } <nl> } <nl> <nl> - void UIButton : : onPressStateChangedToPressed ( ) <nl> + void Button : : onPressStateChangedToPressed ( ) <nl> { <nl> _buttonNormalRenderer - > setVisible ( false ) ; <nl> _buttonClickedRenderer - > setVisible ( true ) ; <nl> void UIButton : : onPressStateChangedToPressed ( ) <nl> _buttonNormalRenderer - > stopAllActions ( ) ; <nl> _buttonClickedRenderer - > stopAllActions ( ) ; <nl> _buttonDisableRenderer - > stopAllActions ( ) ; <nl> - cocos2d : : Action * zoomAction = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> - cocos2d : : Action * zoomAction1 = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> - cocos2d : : Action * zoomAction2 = cocos2d : : ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> + Action * zoomAction = ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> + Action * zoomAction1 = ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> + Action * zoomAction2 = ScaleTo : : create ( 0 . 05f , 1 . 1f ) ; <nl> _buttonNormalRenderer - > runAction ( zoomAction ) ; <nl> _buttonClickedRenderer - > runAction ( zoomAction1 ) ; <nl> _buttonDisableRenderer - > runAction ( zoomAction2 ) ; <nl> } <nl> } <nl> <nl> - void UIButton : : onPressStateChangedToDisabled ( ) <nl> + void Button : : onPressStateChangedToDisabled ( ) <nl> { <nl> _buttonNormalRenderer - > setVisible ( false ) ; <nl> _buttonClickedRenderer - > setVisible ( false ) ; <nl> _buttonDisableRenderer - > setVisible ( true ) ; <nl> } <nl> <nl> - void UIButton : : setFlipX ( bool flipX ) <nl> + void Button : : setFlipX ( bool flipX ) <nl> { <nl> _titleRenderer - > setFlippedX ( flipX ) ; <nl> if ( _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setFlippedX ( flipX ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setFlippedX ( flipX ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setFlippedX ( flipX ) ; <nl> + static_cast < Sprite * > ( _buttonNormalRenderer ) - > setFlippedX ( flipX ) ; <nl> + static_cast < Sprite * > ( _buttonClickedRenderer ) - > setFlippedX ( flipX ) ; <nl> + static_cast < Sprite * > ( _buttonDisableRenderer ) - > setFlippedX ( flipX ) ; <nl> } <nl> <nl> - void UIButton : : setFlipY ( bool flipY ) <nl> + void Button : : setFlipY ( bool flipY ) <nl> { <nl> _titleRenderer - > setFlippedY ( flipY ) ; <nl> if ( _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > setFlippedY ( flipY ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonClickedRenderer ) - > setFlippedY ( flipY ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _buttonDisableRenderer ) - > setFlippedY ( flipY ) ; <nl> + static_cast < Sprite * > ( _buttonNormalRenderer ) - > setFlippedY ( flipY ) ; <nl> + static_cast < Sprite * > ( _buttonClickedRenderer ) - > setFlippedY ( flipY ) ; <nl> + static_cast < Sprite * > ( _buttonDisableRenderer ) - > setFlippedY ( flipY ) ; <nl> } <nl> <nl> - bool UIButton : : isFlipX ( ) <nl> + bool Button : : isFlipX ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> return false ; <nl> } <nl> - return dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > isFlippedX ( ) ; <nl> + return static_cast < Sprite * > ( _buttonNormalRenderer ) - > isFlippedX ( ) ; <nl> } <nl> <nl> - bool UIButton : : isFlipY ( ) <nl> + bool Button : : isFlipY ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> return false ; <nl> } <nl> - return dynamic_cast < cocos2d : : Sprite * > ( _buttonNormalRenderer ) - > isFlippedY ( ) ; <nl> + return static_cast < Sprite * > ( _buttonNormalRenderer ) - > isFlippedY ( ) ; <nl> } <nl> <nl> - void UIButton : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> + void Button : : setAnchorPoint ( const Point & pt ) <nl> { <nl> - UIWidget : : setAnchorPoint ( pt ) ; <nl> + Widget : : setAnchorPoint ( pt ) ; <nl> _buttonNormalRenderer - > setAnchorPoint ( pt ) ; <nl> _buttonClickedRenderer - > setAnchorPoint ( pt ) ; <nl> _buttonDisableRenderer - > setAnchorPoint ( pt ) ; <nl> - _titleRenderer - > setPosition ( cocos2d : : Point ( _size . width * ( 0 . 5f - _anchorPoint . x ) , _size . height * ( 0 . 5f - _anchorPoint . y ) ) ) ; <nl> + _titleRenderer - > setPosition ( Point ( _size . width * ( 0 . 5f - _anchorPoint . x ) , _size . height * ( 0 . 5f - _anchorPoint . y ) ) ) ; <nl> } <nl> <nl> - void UIButton : : onSizeChanged ( ) <nl> + void Button : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> normalTextureScaleChangedWithSize ( ) ; <nl> pressedTextureScaleChangedWithSize ( ) ; <nl> disabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const cocos2d : : Size & UIButton : : getContentSize ( ) const <nl> + const Size & Button : : getContentSize ( ) const <nl> { <nl> return _normalTextureSize ; <nl> } <nl> <nl> - cocos2d : : Node * UIButton : : getVirtualRenderer ( ) <nl> + Node * Button : : getVirtualRenderer ( ) <nl> { <nl> if ( _bright ) <nl> { <nl> cocos2d : : Node * UIButton : : getVirtualRenderer ( ) <nl> } <nl> } <nl> <nl> - void UIButton : : normalTextureScaleChangedWithSize ( ) <nl> + void Button : : normalTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UIButton : : normalTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setPreferredSize ( _size ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _buttonNormalRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _normalTextureSize ; <nl> + Size textureSize = _normalTextureSize ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _buttonNormalRenderer - > setScale ( 1 . 0f ) ; <nl> void UIButton : : normalTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - void UIButton : : pressedTextureScaleChangedWithSize ( ) <nl> + void Button : : pressedTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UIButton : : pressedTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setPreferredSize ( _size ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _buttonClickedRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _pressedTextureSize ; <nl> + Size textureSize = _pressedTextureSize ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _buttonClickedRenderer - > setScale ( 1 . 0f ) ; <nl> void UIButton : : pressedTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - void UIButton : : disabledTextureScaleChangedWithSize ( ) <nl> + void Button : : disabledTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UIButton : : disabledTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setPreferredSize ( _size ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _buttonDisableRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _disabledTextureSize ; <nl> + Size textureSize = _disabledTextureSize ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _buttonDisableRenderer - > setScale ( 1 . 0f ) ; <nl> void UIButton : : disabledTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - void UIButton : : setPressedActionEnabled ( bool enabled ) <nl> + void Button : : setPressedActionEnabled ( bool enabled ) <nl> { <nl> _pressedActionEnabled = enabled ; <nl> } <nl> <nl> - void UIButton : : setTitleText ( const std : : string & text ) <nl> + void Button : : setTitleText ( const std : : string & text ) <nl> { <nl> _titleRenderer - > setString ( text ) ; <nl> } <nl> <nl> - const std : : string & UIButton : : getTitleText ( ) const <nl> + const std : : string & Button : : getTitleText ( ) const <nl> { <nl> return _titleRenderer - > getString ( ) ; <nl> } <nl> <nl> - void UIButton : : setTitleColor ( const cocos2d : : Color3B & color ) <nl> + void Button : : setTitleColor ( const Color3B & color ) <nl> { <nl> _titleColor = color ; <nl> - _titleRenderer - > setColor ( color ) ; <nl> + _titleRenderer - > updateDisplayedColor ( color ) ; <nl> } <nl> <nl> - const cocos2d : : Color3B & UIButton : : getTitleColor ( ) const <nl> + const Color3B & Button : : getTitleColor ( ) const <nl> { <nl> return _titleRenderer - > getColor ( ) ; <nl> } <nl> <nl> - void UIButton : : setTitleFontSize ( float size ) <nl> + void Button : : setTitleFontSize ( float size ) <nl> { <nl> _titleRenderer - > setFontSize ( size ) ; <nl> } <nl> <nl> - float UIButton : : getTitleFontSize ( ) const <nl> + float Button : : getTitleFontSize ( ) const <nl> { <nl> return _titleRenderer - > getFontSize ( ) ; <nl> } <nl> <nl> - void UIButton : : setTitleFontName ( const char * fontName ) <nl> + void Button : : setTitleFontName ( const char * fontName ) <nl> { <nl> _titleRenderer - > setFontName ( fontName ) ; <nl> } <nl> <nl> - const char * UIButton : : getTitleFontName ( ) const <nl> + const char * Button : : getTitleFontName ( ) const <nl> { <nl> return _titleRenderer - > getFontName ( ) . c_str ( ) ; <nl> } <nl> <nl> - void UIButton : : setColor ( const cocos2d : : Color3B & color ) <nl> + void Button : : setColor ( const Color3B & color ) <nl> { <nl> - UIWidget : : setColor ( color ) ; <nl> + Widget : : setColor ( color ) ; <nl> setTitleColor ( _titleColor ) ; <nl> } <nl> <nl> - const char * UIButton : : getDescription ( ) const <nl> + std : : string Button : : getDescription ( ) const <nl> { <nl> return " Button " ; <nl> } <nl> <nl> - UIWidget * UIButton : : createCloneInstance ( ) <nl> + Widget * Button : : createCloneInstance ( ) <nl> { <nl> - return UIButton : : create ( ) ; <nl> + return Button : : create ( ) ; <nl> } <nl> <nl> - void UIButton : : copySpecialProperties ( UIWidget * widget ) <nl> + void Button : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UIButton * button = dynamic_cast < UIButton * > ( widget ) ; <nl> + Button * button = dynamic_cast < Button * > ( widget ) ; <nl> if ( button ) <nl> { <nl> _prevIgnoreSize = button - > _prevIgnoreSize ; <nl> void UIButton : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIButton . h <nl> ppp b / cocos / gui / UIButton . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> - class UIButton : public UIWidget <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class Button : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UIButton ( ) ; <nl> + Button ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UIButton ( ) ; <nl> + virtual ~ Button ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UIButton * create ( ) ; <nl> + static Button * create ( ) ; <nl> <nl> / * * <nl> * Load textures for button . <nl> class UIButton : public UIWidget <nl> * <nl> * @ param capInsets capinsets for button <nl> * / <nl> - void setCapInsets ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsets ( const Rect & capInsets ) ; <nl> <nl> / * * <nl> * Sets capinsets for button , if button is using scale9 renderer . <nl> * <nl> * @ param capInsets capinsets for button <nl> * / <nl> - void setCapInsetsNormalRenderer ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsetsNormalRenderer ( const Rect & capInsets ) ; <nl> <nl> / * * <nl> * Sets capinsets for button , if button is using scale9 renderer . <nl> * <nl> * @ param capInsets capinsets for button <nl> * / <nl> - void setCapInsetsPressedRenderer ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsetsPressedRenderer ( const Rect & capInsets ) ; <nl> <nl> / * * <nl> * Sets capinsets for button , if button is using scale9 renderer . <nl> * <nl> * @ param capInsets capinsets for button <nl> * / <nl> - void setCapInsetsDisabledRenderer ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsetsDisabledRenderer ( const Rect & capInsets ) ; <nl> <nl> / / override " setAnchorPoint " of widget . <nl> - virtual void setAnchorPoint ( const cocos2d : : Point & pt ) override ; <nl> + virtual void setAnchorPoint ( const Point & pt ) override ; <nl> <nl> / * * <nl> * Sets if button is using scale9 renderer . <nl> class UIButton : public UIWidget <nl> virtual void ignoreContentAdaptWithSize ( bool ignore ) override ; <nl> <nl> / / override " getContentSize " method of widget . <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> <nl> / / override " getVirtualRenderer " method of widget . <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> <nl> / * * <nl> * Sets color to widget <nl> class UIButton : public UIWidget <nl> * <nl> * @ param color <nl> * / <nl> - virtual void setColor ( const cocos2d : : Color3B & color ) override ; <nl> + virtual void setColor ( const Color3B & color ) override ; <nl> <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> void setTitleText ( const std : : string & text ) ; <nl> const std : : string & getTitleText ( ) const ; <nl> - void setTitleColor ( const cocos2d : : Color3B & color ) ; <nl> - const cocos2d : : Color3B & getTitleColor ( ) const ; <nl> + void setTitleColor ( const Color3B & color ) ; <nl> + const Color3B & getTitleColor ( ) const ; <nl> void setTitleFontSize ( float size ) ; <nl> float getTitleFontSize ( ) const ; <nl> void setTitleFontName ( const char * fontName ) ; <nl> class UIButton : public UIWidget <nl> void normalTextureScaleChangedWithSize ( ) ; <nl> void pressedTextureScaleChangedWithSize ( ) ; <nl> void disabledTextureScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> - cocos2d : : Node * _buttonNormalRenderer ; <nl> - cocos2d : : Node * _buttonClickedRenderer ; <nl> - cocos2d : : Node * _buttonDisableRenderer ; <nl> - cocos2d : : LabelTTF * _titleRenderer ; <nl> + Node * _buttonNormalRenderer ; <nl> + Node * _buttonClickedRenderer ; <nl> + Node * _buttonDisableRenderer ; <nl> + LabelTTF * _titleRenderer ; <nl> std : : string _normalFileName ; <nl> std : : string _clickedFileName ; <nl> std : : string _disabledFileName ; <nl> bool _prevIgnoreSize ; <nl> bool _scale9Enabled ; <nl> - cocos2d : : Rect _capInsetsNormal ; <nl> - cocos2d : : Rect _capInsetsPressed ; <nl> - cocos2d : : Rect _capInsetsDisabled ; <nl> + Rect _capInsetsNormal ; <nl> + Rect _capInsetsPressed ; <nl> + Rect _capInsetsDisabled ; <nl> TextureResType _normalTexType ; <nl> TextureResType _pressedTexType ; <nl> TextureResType _disabledTexType ; <nl> - cocos2d : : Size _normalTextureSize ; <nl> - cocos2d : : Size _pressedTextureSize ; <nl> - cocos2d : : Size _disabledTextureSize ; <nl> + Size _normalTextureSize ; <nl> + Size _pressedTextureSize ; <nl> + Size _disabledTextureSize ; <nl> bool _pressedActionEnabled ; <nl> - cocos2d : : Color3B _titleColor ; <nl> + Color3B _titleColor ; <nl> } ; <nl> <nl> } <nl> <nl> - # endif / * defined ( __CocoGUI__UIButton__ ) * / <nl> + NS_CC_END <nl> + <nl> + # endif / * defined ( __CocoGUI__Button__ ) * / <nl> mmm a / cocos / gui / UICheckBox . cpp <nl> ppp b / cocos / gui / UICheckBox . cpp <nl> <nl> <nl> # include " gui / UICheckBox . h " <nl> <nl> - namespace gui { <nl> - <nl> + NS_CC_BEGIN <nl> <nl> - UICheckBox : : UICheckBox ( ) : <nl> + namespace gui { <nl> + <nl> + # define BACKGROUNDBOXRENDERERZ ( - 1 ) <nl> + # define BACKGROUNDSELECTEDBOXRENDERERZ ( - 1 ) <nl> + # define FRONTCROSSRENDERERZ ( - 1 ) <nl> + # define BACKGROUNDBOXDISABLEDRENDERERZ ( - 1 ) <nl> + # define FRONTCROSSDISABLEDRENDERERZ ( - 1 ) <nl> + <nl> + CheckBox : : CheckBox ( ) : <nl> _backGroundBoxRenderer ( nullptr ) , <nl> _backGroundSelectedBoxRenderer ( nullptr ) , <nl> _frontCrossRenderer ( nullptr ) , <nl> _frontCrossDisabledFileName ( " " ) <nl> { <nl> } <nl> <nl> - UICheckBox : : ~ UICheckBox ( ) <nl> + CheckBox : : ~ CheckBox ( ) <nl> { <nl> _checkBoxEventListener = nullptr ; <nl> _checkBoxEventSelector = nullptr ; <nl> } <nl> <nl> - UICheckBox * UICheckBox : : create ( ) <nl> + CheckBox * CheckBox : : create ( ) <nl> { <nl> - UICheckBox * widget = new UICheckBox ( ) ; <nl> + CheckBox * widget = new CheckBox ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UICheckBox * UICheckBox : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UICheckBox : : init ( ) <nl> + bool CheckBox : : init ( ) <nl> { <nl> - if ( UIWidget : : init ( ) ) <nl> + if ( Widget : : init ( ) ) <nl> { <nl> setSelectedState ( false ) ; <nl> return true ; <nl> bool UICheckBox : : init ( ) <nl> return false ; <nl> } <nl> <nl> - void UICheckBox : : initRenderer ( ) <nl> + void CheckBox : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> - _backGroundBoxRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _backGroundSelectedBoxRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _frontCrossRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _backGroundBoxDisabledRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _frontCrossDisabledRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _renderer - > addChild ( _backGroundBoxRenderer ) ; <nl> - _renderer - > addChild ( _backGroundSelectedBoxRenderer ) ; <nl> - _renderer - > addChild ( _frontCrossRenderer ) ; <nl> - _renderer - > addChild ( _backGroundBoxDisabledRenderer ) ; <nl> - _renderer - > addChild ( _frontCrossDisabledRenderer ) ; <nl> + _backGroundBoxRenderer = Sprite : : create ( ) ; <nl> + _backGroundSelectedBoxRenderer = Sprite : : create ( ) ; <nl> + _frontCrossRenderer = Sprite : : create ( ) ; <nl> + _backGroundBoxDisabledRenderer = Sprite : : create ( ) ; <nl> + _frontCrossDisabledRenderer = Sprite : : create ( ) ; <nl> + <nl> + Node : : addChild ( _backGroundBoxRenderer , BACKGROUNDBOXRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _backGroundSelectedBoxRenderer , BACKGROUNDSELECTEDBOXRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _frontCrossRenderer , FRONTCROSSRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _backGroundBoxDisabledRenderer , BACKGROUNDBOXDISABLEDRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _frontCrossDisabledRenderer , FRONTCROSSDISABLEDRENDERERZ , - 1 ) ; <nl> } <nl> <nl> - void UICheckBox : : loadTextures ( const char * backGround , const char * backGroundSelected , const char * cross , const char * backGroundDisabled , const char * frontCrossDisabled , TextureResType texType ) <nl> + void CheckBox : : loadTextures ( const char * backGround , const char * backGroundSelected , const char * cross , const char * backGroundDisabled , const char * frontCrossDisabled , TextureResType texType ) <nl> { <nl> loadTextureBackGround ( backGround , texType ) ; <nl> loadTextureBackGroundSelected ( backGroundSelected , texType ) ; <nl> void UICheckBox : : loadTextures ( const char * backGround , const char * backGroundSele <nl> loadTextureFrontCrossDisabled ( frontCrossDisabled , texType ) ; <nl> } <nl> <nl> - void UICheckBox : : loadTextureBackGround ( const char * backGround , TextureResType texType ) <nl> + void CheckBox : : loadTextureBackGround ( const char * backGround , TextureResType texType ) <nl> { <nl> if ( ! backGround | | strcmp ( backGround , " " ) = = 0 ) <nl> { <nl> void UICheckBox : : loadTextureBackGround ( const char * backGround , TextureResType tex <nl> default : <nl> break ; <nl> } <nl> - _backGroundBoxRenderer - > setColor ( getColor ( ) ) ; <nl> - _backGroundBoxRenderer - > setOpacity ( getOpacity ( ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> + updateAnchorPoint ( ) ; <nl> backGroundTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UICheckBox : : loadTextureBackGroundSelected ( const char * backGroundSelected , TextureResType texType ) <nl> + void CheckBox : : loadTextureBackGroundSelected ( const char * backGroundSelected , TextureResType texType ) <nl> { <nl> if ( ! backGroundSelected | | strcmp ( backGroundSelected , " " ) = = 0 ) <nl> { <nl> void UICheckBox : : loadTextureBackGroundSelected ( const char * backGroundSelected , Te <nl> default : <nl> break ; <nl> } <nl> - _backGroundSelectedBoxRenderer - > setColor ( getColor ( ) ) ; <nl> - _backGroundSelectedBoxRenderer - > setOpacity ( getOpacity ( ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> + updateAnchorPoint ( ) ; <nl> backGroundSelectedTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UICheckBox : : loadTextureFrontCross ( const char * cross , TextureResType texType ) <nl> + void CheckBox : : loadTextureFrontCross ( const char * cross , TextureResType texType ) <nl> { <nl> if ( ! cross | | strcmp ( cross , " " ) = = 0 ) <nl> { <nl> void UICheckBox : : loadTextureFrontCross ( const char * cross , TextureResType texType ) <nl> default : <nl> break ; <nl> } <nl> - _frontCrossRenderer - > setColor ( getColor ( ) ) ; <nl> - _frontCrossRenderer - > setOpacity ( getOpacity ( ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> + updateAnchorPoint ( ) ; <nl> frontCrossTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UICheckBox : : loadTextureBackGroundDisabled ( const char * backGroundDisabled , TextureResType texType ) <nl> + void CheckBox : : loadTextureBackGroundDisabled ( const char * backGroundDisabled , TextureResType texType ) <nl> { <nl> if ( ! backGroundDisabled | | strcmp ( backGroundDisabled , " " ) = = 0 ) <nl> { <nl> void UICheckBox : : loadTextureBackGroundDisabled ( const char * backGroundDisabled , Te <nl> default : <nl> break ; <nl> } <nl> - _backGroundBoxDisabledRenderer - > setColor ( getColor ( ) ) ; <nl> - _backGroundBoxDisabledRenderer - > setOpacity ( getOpacity ( ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> + updateAnchorPoint ( ) ; <nl> backGroundDisabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UICheckBox : : loadTextureFrontCrossDisabled ( const char * frontCrossDisabled , TextureResType texType ) <nl> + void CheckBox : : loadTextureFrontCrossDisabled ( const char * frontCrossDisabled , TextureResType texType ) <nl> { <nl> if ( ! frontCrossDisabled | | strcmp ( frontCrossDisabled , " " ) = = 0 ) <nl> { <nl> void UICheckBox : : loadTextureFrontCrossDisabled ( const char * frontCrossDisabled , Te <nl> default : <nl> break ; <nl> } <nl> - _frontCrossDisabledRenderer - > setColor ( getColor ( ) ) ; <nl> - _frontCrossRenderer - > setOpacity ( getOpacity ( ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> + updateAnchorPoint ( ) ; <nl> frontCrossDisabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UICheckBox : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> + void CheckBox : : onTouchEnded ( Touch * touch , Event * unusedEvent ) <nl> { <nl> + _touchEndPos = touch - > getLocation ( ) ; <nl> if ( _focus ) <nl> { <nl> releaseUpEvent ( ) ; <nl> void UICheckBox : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> } <nl> } <nl> setFocused ( false ) ; <nl> - _widgetParent - > checkChildInfo ( 2 , this , touchPoint ) ; <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> + { <nl> + widgetParent - > checkChildInfo ( 2 , this , _touchEndPos ) ; <nl> + } <nl> } <nl> <nl> - void UICheckBox : : onPressStateChangedToNormal ( ) <nl> + void CheckBox : : onPressStateChangedToNormal ( ) <nl> { <nl> _backGroundBoxRenderer - > setVisible ( true ) ; <nl> _backGroundSelectedBoxRenderer - > setVisible ( false ) ; <nl> void UICheckBox : : onPressStateChangedToNormal ( ) <nl> _frontCrossDisabledRenderer - > setVisible ( false ) ; <nl> } <nl> <nl> - void UICheckBox : : onPressStateChangedToPressed ( ) <nl> + void CheckBox : : onPressStateChangedToPressed ( ) <nl> { <nl> _backGroundBoxRenderer - > setVisible ( false ) ; <nl> _backGroundSelectedBoxRenderer - > setVisible ( true ) ; <nl> void UICheckBox : : onPressStateChangedToPressed ( ) <nl> _frontCrossDisabledRenderer - > setVisible ( false ) ; <nl> } <nl> <nl> - void UICheckBox : : onPressStateChangedToDisabled ( ) <nl> + void CheckBox : : onPressStateChangedToDisabled ( ) <nl> { <nl> _backGroundBoxRenderer - > setVisible ( false ) ; <nl> _backGroundSelectedBoxRenderer - > setVisible ( false ) ; <nl> void UICheckBox : : onPressStateChangedToDisabled ( ) <nl> } <nl> } <nl> <nl> - void UICheckBox : : setSelectedState ( bool selected ) <nl> + void CheckBox : : setSelectedState ( bool selected ) <nl> { <nl> if ( selected = = _isSelected ) <nl> { <nl> void UICheckBox : : setSelectedState ( bool selected ) <nl> _frontCrossRenderer - > setVisible ( _isSelected ) ; <nl> } <nl> <nl> - bool UICheckBox : : getSelectedState ( ) <nl> + bool CheckBox : : getSelectedState ( ) <nl> { <nl> return _isSelected ; <nl> } <nl> <nl> - void UICheckBox : : selectedEvent ( ) <nl> + void CheckBox : : selectedEvent ( ) <nl> { <nl> if ( _checkBoxEventListener & & _checkBoxEventSelector ) <nl> { <nl> void UICheckBox : : selectedEvent ( ) <nl> } <nl> } <nl> <nl> - void UICheckBox : : unSelectedEvent ( ) <nl> + void CheckBox : : unSelectedEvent ( ) <nl> { <nl> if ( _checkBoxEventListener & & _checkBoxEventSelector ) <nl> { <nl> void UICheckBox : : unSelectedEvent ( ) <nl> } <nl> } <nl> <nl> - void UICheckBox : : addEventListenerCheckBox ( cocos2d : : Object * target , SEL_SelectedStateEvent selector ) <nl> + void CheckBox : : addEventListenerCheckBox ( Object * target , SEL_SelectedStateEvent selector ) <nl> { <nl> _checkBoxEventListener = target ; <nl> _checkBoxEventSelector = selector ; <nl> } <nl> <nl> - void UICheckBox : : setFlipX ( bool flipX ) <nl> + void CheckBox : : setFlipX ( bool flipX ) <nl> { <nl> _backGroundBoxRenderer - > setFlippedX ( flipX ) ; <nl> _backGroundSelectedBoxRenderer - > setFlippedX ( flipX ) ; <nl> void UICheckBox : : setFlipX ( bool flipX ) <nl> _frontCrossDisabledRenderer - > setFlippedX ( flipX ) ; <nl> } <nl> <nl> - void UICheckBox : : setFlipY ( bool flipY ) <nl> + void CheckBox : : setFlipY ( bool flipY ) <nl> { <nl> _backGroundBoxRenderer - > setFlippedY ( flipY ) ; <nl> _backGroundSelectedBoxRenderer - > setFlippedY ( flipY ) ; <nl> void UICheckBox : : setFlipY ( bool flipY ) <nl> _frontCrossDisabledRenderer - > setFlippedY ( flipY ) ; <nl> } <nl> <nl> - bool UICheckBox : : isFlipX ( ) <nl> + bool CheckBox : : isFlipX ( ) <nl> { <nl> return _backGroundBoxRenderer - > isFlippedX ( ) ; <nl> } <nl> <nl> - bool UICheckBox : : isFlipY ( ) <nl> + bool CheckBox : : isFlipY ( ) <nl> { <nl> return _backGroundBoxRenderer - > isFlippedY ( ) ; <nl> } <nl> <nl> - void UICheckBox : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> + void CheckBox : : setAnchorPoint ( const Point & pt ) <nl> { <nl> - UIWidget : : setAnchorPoint ( pt ) ; <nl> + Widget : : setAnchorPoint ( pt ) ; <nl> _backGroundBoxRenderer - > setAnchorPoint ( pt ) ; <nl> _backGroundSelectedBoxRenderer - > setAnchorPoint ( pt ) ; <nl> _backGroundBoxDisabledRenderer - > setAnchorPoint ( pt ) ; <nl> void UICheckBox : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> _frontCrossDisabledRenderer - > setAnchorPoint ( pt ) ; <nl> } <nl> <nl> - void UICheckBox : : onSizeChanged ( ) <nl> + void CheckBox : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> backGroundTextureScaleChangedWithSize ( ) ; <nl> backGroundSelectedTextureScaleChangedWithSize ( ) ; <nl> frontCrossTextureScaleChangedWithSize ( ) ; <nl> void UICheckBox : : onSizeChanged ( ) <nl> frontCrossDisabledTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const cocos2d : : Size & UICheckBox : : getContentSize ( ) const <nl> + const Size & CheckBox : : getContentSize ( ) const <nl> { <nl> return _backGroundBoxRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - cocos2d : : Node * UICheckBox : : getVirtualRenderer ( ) <nl> + Node * CheckBox : : getVirtualRenderer ( ) <nl> { <nl> return _backGroundBoxRenderer ; <nl> } <nl> <nl> - void UICheckBox : : backGroundTextureScaleChangedWithSize ( ) <nl> + void CheckBox : : backGroundTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UICheckBox : : backGroundTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _backGroundBoxRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _backGroundBoxRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _backGroundBoxRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : backGroundTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - void UICheckBox : : backGroundSelectedTextureScaleChangedWithSize ( ) <nl> + void CheckBox : : backGroundSelectedTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UICheckBox : : backGroundSelectedTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _backGroundSelectedBoxRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _backGroundSelectedBoxRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _backGroundSelectedBoxRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : backGroundSelectedTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - void UICheckBox : : frontCrossTextureScaleChangedWithSize ( ) <nl> + void CheckBox : : frontCrossTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UICheckBox : : frontCrossTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _frontCrossRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _frontCrossRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _frontCrossRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : frontCrossTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - void UICheckBox : : backGroundDisabledTextureScaleChangedWithSize ( ) <nl> + void CheckBox : : backGroundDisabledTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UICheckBox : : backGroundDisabledTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _backGroundBoxDisabledRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _backGroundBoxDisabledRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _backGroundBoxDisabledRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : backGroundDisabledTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - void UICheckBox : : frontCrossDisabledTextureScaleChangedWithSize ( ) <nl> + void CheckBox : : frontCrossDisabledTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UICheckBox : : frontCrossDisabledTextureScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _frontCrossDisabledRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _frontCrossDisabledRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _frontCrossDisabledRenderer - > setScale ( 1 . 0f ) ; <nl> void UICheckBox : : frontCrossDisabledTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - const char * UICheckBox : : getDescription ( ) const <nl> + std : : string CheckBox : : getDescription ( ) const <nl> { <nl> return " CheckBox " ; <nl> } <nl> <nl> - UIWidget * UICheckBox : : createCloneInstance ( ) <nl> + Widget * CheckBox : : createCloneInstance ( ) <nl> { <nl> - return UICheckBox : : create ( ) ; <nl> + return CheckBox : : create ( ) ; <nl> } <nl> <nl> - void UICheckBox : : copySpecialProperties ( UIWidget * widget ) <nl> + void CheckBox : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UICheckBox * checkBox = dynamic_cast < UICheckBox * > ( widget ) ; <nl> + CheckBox * checkBox = dynamic_cast < CheckBox * > ( widget ) ; <nl> if ( checkBox ) <nl> { <nl> loadTextureBackGround ( checkBox - > _backGroundFileName . c_str ( ) , checkBox - > _backGroundTexType ) ; <nl> void UICheckBox : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UICheckBox . h <nl> ppp b / cocos / gui / UICheckBox . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> typedef enum <nl> typedef enum <nl> CHECKBOX_STATE_EVENT_UNSELECTED <nl> } CheckBoxEventType ; <nl> <nl> - typedef void ( cocos2d : : Object : : * SEL_SelectedStateEvent ) ( cocos2d : : Object * , CheckBoxEventType ) ; <nl> + typedef void ( Object : : * SEL_SelectedStateEvent ) ( Object * , CheckBoxEventType ) ; <nl> # define checkboxselectedeventselector ( _SELECTOR ) ( SEL_SelectedStateEvent ) ( & _SELECTOR ) <nl> <nl> - class UICheckBox : public UIWidget <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class CheckBox : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UICheckBox ( ) ; <nl> + CheckBox ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UICheckBox ( ) ; <nl> + virtual ~ CheckBox ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UICheckBox * create ( ) ; <nl> + static CheckBox * create ( ) ; <nl> <nl> / * * <nl> * Load textures for checkbox . <nl> class UICheckBox : public UIWidget <nl> bool getSelectedState ( ) ; <nl> <nl> / / override " setAnchorPoint " method of widget . <nl> - virtual void setAnchorPoint ( const cocos2d : : Point & pt ) override ; <nl> + virtual void setAnchorPoint ( const Point & pt ) override ; <nl> <nl> / / add a call back function would called when checkbox is selected or unselected . <nl> - void addEventListenerCheckBox ( cocos2d : : Object * target , SEL_SelectedStateEvent selector ) ; <nl> + void addEventListenerCheckBox ( Object * target , SEL_SelectedStateEvent selector ) ; <nl> <nl> / / override " setFlipX " method of widget . <nl> virtual void setFlipX ( bool flipX ) override ; <nl> class UICheckBox : public UIWidget <nl> / / override " isFlipY " method of widget . <nl> virtual bool isFlipY ( ) override ; <nl> <nl> - / * * override " onTouchEnded " method of widget . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onTouchEnded ( const cocos2d : : Point & touchPoint ) override ; <nl> + / / override " onTouchEnded " method of widget . <nl> + virtual void onTouchEnded ( Touch * touch , Event * unusedEvent ) ; <nl> <nl> / / override " getContentSize " method of widget . <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> <nl> / / override " getVirtualRenderer " method of widget . <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> protected : <nl> virtual bool init ( ) override ; <nl> class UICheckBox : public UIWidget <nl> void frontCrossTextureScaleChangedWithSize ( ) ; <nl> void backGroundDisabledTextureScaleChangedWithSize ( ) ; <nl> void frontCrossDisabledTextureScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> - cocos2d : : Sprite * _backGroundBoxRenderer ; <nl> - cocos2d : : Sprite * _backGroundSelectedBoxRenderer ; <nl> - cocos2d : : Sprite * _frontCrossRenderer ; <nl> - cocos2d : : Sprite * _backGroundBoxDisabledRenderer ; <nl> - cocos2d : : Sprite * _frontCrossDisabledRenderer ; <nl> + Sprite * _backGroundBoxRenderer ; <nl> + Sprite * _backGroundSelectedBoxRenderer ; <nl> + Sprite * _frontCrossRenderer ; <nl> + Sprite * _backGroundBoxDisabledRenderer ; <nl> + Sprite * _frontCrossDisabledRenderer ; <nl> bool _isSelected ; <nl> <nl> - cocos2d : : Object * _checkBoxEventListener ; <nl> + Object * _checkBoxEventListener ; <nl> SEL_SelectedStateEvent _checkBoxEventSelector ; <nl> <nl> TextureResType _backGroundTexType ; <nl> class UICheckBox : public UIWidget <nl> <nl> } <nl> <nl> - # endif / * defined ( __CocoGUI__UICheckBox__ ) * / <nl> + NS_CC_END <nl> + <nl> + # endif / * defined ( __CocoGUI__CheckBox__ ) * / <nl> mmm a / cocos / gui / UIHelper . cpp <nl> ppp b / cocos / gui / UIHelper . cpp <nl> <nl> <nl> # include " CocosGUI . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> - UIWidget * UIHelper : : seekWidgetByTag ( UIWidget * root , int tag ) <nl> + Widget * UIHelper : : seekWidgetByTag ( Widget * root , int tag ) <nl> { <nl> if ( ! root ) <nl> { <nl> UIWidget * UIHelper : : seekWidgetByTag ( UIWidget * root , int tag ) <nl> { <nl> return root ; <nl> } <nl> - cocos2d : : ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> - ssize_t length = arrayRootChildren - > num ; <nl> + Vector < Node * > arrayRootChildren = root - > getChildren ( ) ; <nl> + int length = arrayRootChildren . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = ( UIWidget * ) ( arrayRootChildren - > arr [ i ] ) ; <nl> - UIWidget * res = seekWidgetByTag ( child , tag ) ; <nl> + Widget * child = static_cast < Widget * > ( arrayRootChildren . at ( i ) ) ; <nl> + Widget * res = seekWidgetByTag ( child , tag ) ; <nl> if ( res ! = nullptr ) <nl> { <nl> return res ; <nl> UIWidget * UIHelper : : seekWidgetByTag ( UIWidget * root , int tag ) <nl> return nullptr ; <nl> } <nl> <nl> - UIWidget * UIHelper : : seekWidgetByName ( UIWidget * root , const char * name ) <nl> + Widget * UIHelper : : seekWidgetByName ( Widget * root , const char * name ) <nl> { <nl> if ( ! root ) <nl> { <nl> UIWidget * UIHelper : : seekWidgetByName ( UIWidget * root , const char * name ) <nl> { <nl> return root ; <nl> } <nl> - cocos2d : : ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> - ssize_t length = arrayRootChildren - > num ; <nl> + Vector < Node * > arrayRootChildren = root - > getChildren ( ) ; <nl> + int length = arrayRootChildren . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = ( UIWidget * ) ( arrayRootChildren - > arr [ i ] ) ; <nl> - UIWidget * res = seekWidgetByName ( child , name ) ; <nl> + Widget * child = static_cast < Widget * > ( arrayRootChildren . at ( i ) ) ; <nl> + Widget * res = seekWidgetByName ( child , name ) ; <nl> if ( res ! = nullptr ) <nl> { <nl> return res ; <nl> UIWidget * UIHelper : : seekWidgetByName ( UIWidget * root , const char * name ) <nl> return nullptr ; <nl> } <nl> <nl> - UIWidget * UIHelper : : seekWidgetByRelativeName ( UIWidget * root , const char * name ) <nl> + Widget * UIHelper : : seekWidgetByRelativeName ( Widget * root , const char * name ) <nl> { <nl> if ( ! root ) <nl> { <nl> return nullptr ; <nl> } <nl> - cocos2d : : ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> - ssize_t length = arrayRootChildren - > num ; <nl> + Vector < Node * > arrayRootChildren = root - > getChildren ( ) ; <nl> + int length = arrayRootChildren . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = ( UIWidget * ) ( arrayRootChildren - > arr [ i ] ) ; <nl> - UIRelativeLayoutParameter * layoutParameter = dynamic_cast < UIRelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + Widget * child = static_cast < Widget * > ( arrayRootChildren . at ( i ) ) ; <nl> + RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> if ( layoutParameter & & strcmp ( layoutParameter - > getRelativeName ( ) , name ) = = 0 ) <nl> { <nl> return child ; <nl> UIWidget * UIHelper : : seekWidgetByRelativeName ( UIWidget * root , const char * name ) <nl> } <nl> <nl> / * temp action * / <nl> - UIWidget * UIHelper : : seekActionWidgetByActionTag ( UIWidget * root , int tag ) <nl> + Widget * UIHelper : : seekActionWidgetByActionTag ( Widget * root , int tag ) <nl> { <nl> if ( ! root ) <nl> { <nl> UIWidget * UIHelper : : seekActionWidgetByActionTag ( UIWidget * root , int tag ) <nl> { <nl> return root ; <nl> } <nl> - cocos2d : : ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> - ssize_t length = arrayRootChildren - > num ; <nl> + Vector < Node * > arrayRootChildren = root - > getChildren ( ) ; <nl> + int length = arrayRootChildren . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = ( UIWidget * ) ( arrayRootChildren - > arr [ i ] ) ; <nl> - UIWidget * res = seekActionWidgetByActionTag ( child , tag ) ; <nl> + Widget * child = static_cast < Widget * > ( arrayRootChildren . at ( i ) ) ; <nl> + Widget * res = seekActionWidgetByActionTag ( child , tag ) ; <nl> if ( res ! = nullptr ) <nl> { <nl> return res ; <nl> UIWidget * UIHelper : : seekActionWidgetByActionTag ( UIWidget * root , int tag ) <nl> return nullptr ; <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIHelper . h <nl> ppp b / cocos / gui / UIHelper . h <nl> <nl> # ifndef __UIHELPER_H__ <nl> # define __UIHELPER_H__ <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> class UIHelper <nl> { <nl> public : <nl> class UIHelper <nl> * <nl> * @ return finded result . <nl> * / <nl> - static UIWidget * seekWidgetByTag ( UIWidget * root , int tag ) ; <nl> + static Widget * seekWidgetByTag ( Widget * root , int tag ) ; <nl> <nl> / * * <nl> * Finds a widget whose name equals to param name from root widget . <nl> class UIHelper <nl> * <nl> * @ return finded result . <nl> * / <nl> - static UIWidget * seekWidgetByName ( UIWidget * root , const char * name ) ; <nl> + static Widget * seekWidgetByName ( Widget * root , const char * name ) ; <nl> <nl> / * * <nl> * Finds a widget whose name equals to param name from root widget . <nl> class UIHelper <nl> * <nl> * @ return finded result . <nl> * / <nl> - static UIWidget * seekWidgetByRelativeName ( UIWidget * root , const char * name ) ; <nl> + static Widget * seekWidgetByRelativeName ( Widget * root , const char * name ) ; <nl> <nl> / * temp action * / <nl> - static UIWidget * seekActionWidgetByActionTag ( UIWidget * root , int tag ) ; <nl> + static Widget * seekActionWidgetByActionTag ( Widget * root , int tag ) ; <nl> } ; <nl> } <nl> <nl> + NS_CC_END <nl> + <nl> # endif / * defined ( __CocoGUI__UISystem__ ) * / <nl> mmm a / cocos / gui / UIImageView . cpp <nl> ppp b / cocos / gui / UIImageView . cpp <nl> <nl> # include " gui / UIImageView . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> <nl> - # define DYNAMIC_CAST_CCSPRITE dynamic_cast < cocos2d : : Sprite * > ( _imageRenderer ) <nl> - # define DYNAMIC_CAST_SCALE9SPRITE dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _imageRenderer ) <nl> + # define STATIC_CAST_CCSPRITE static_cast < Sprite * > ( _imageRenderer ) <nl> + # define STATIC_CAST_SCALE9SPRITE static_cast < extension : : Scale9Sprite * > ( _imageRenderer ) <nl> + <nl> + # define IMAGERENDERERZ ( - 1 ) <nl> <nl> - UIImageView : : UIImageView ( ) : <nl> - _clickCount ( 0 ) , <nl> - _clickTimeInterval ( 0 . 0 ) , <nl> - _startCheckDoubleClick ( false ) , <nl> - _touchRelease ( false ) , <nl> - _doubleClickEnabled ( false ) , <nl> + ImageView : : ImageView ( ) : <nl> _scale9Enabled ( false ) , <nl> _prevIgnoreSize ( true ) , <nl> - _capInsets ( cocos2d : : Rect : : ZERO ) , <nl> + _capInsets ( Rect : : ZERO ) , <nl> _imageRenderer ( nullptr ) , <nl> _textureFile ( " " ) , <nl> _imageTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _imageTextureSize ( _size ) <nl> <nl> } <nl> <nl> - UIImageView : : ~ UIImageView ( ) <nl> + ImageView : : ~ ImageView ( ) <nl> { <nl> <nl> } <nl> <nl> - UIImageView * UIImageView : : create ( ) <nl> + ImageView * ImageView : : create ( ) <nl> { <nl> - UIImageView * widget = new UIImageView ( ) ; <nl> + ImageView * widget = new ImageView ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UIImageView * UIImageView : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - void UIImageView : : initRenderer ( ) <nl> + void ImageView : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> - _imageRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _renderer - > addChild ( _imageRenderer ) ; <nl> + _imageRenderer = Sprite : : create ( ) ; <nl> + Node : : addChild ( _imageRenderer , IMAGERENDERERZ , - 1 ) ; <nl> } <nl> <nl> - void UIImageView : : loadTexture ( const char * fileName , TextureResType texType ) <nl> + void ImageView : : loadTexture ( const char * fileName , TextureResType texType ) <nl> { <nl> if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> { <nl> void UIImageView : : loadTexture ( const char * fileName , TextureResType texType ) <nl> case UI_TEX_TYPE_LOCAL : <nl> if ( _scale9Enabled ) <nl> { <nl> - DYNAMIC_CAST_SCALE9SPRITE - > initWithFile ( fileName ) ; <nl> - DYNAMIC_CAST_SCALE9SPRITE - > setColor ( getColor ( ) ) ; <nl> - DYNAMIC_CAST_SCALE9SPRITE - > setOpacity ( getOpacity ( ) ) ; <nl> - DYNAMIC_CAST_SCALE9SPRITE - > setCapInsets ( _capInsets ) ; <nl> + extension : : Scale9Sprite * imageRendererScale9 = STATIC_CAST_SCALE9SPRITE ; <nl> + imageRendererScale9 - > initWithFile ( fileName ) ; <nl> + imageRendererScale9 - > setCapInsets ( _capInsets ) ; <nl> } <nl> else <nl> { <nl> - DYNAMIC_CAST_CCSPRITE - > setTexture ( fileName ) ; <nl> - DYNAMIC_CAST_CCSPRITE - > setColor ( getColor ( ) ) ; <nl> - DYNAMIC_CAST_CCSPRITE - > setOpacity ( getOpacity ( ) ) ; <nl> + Sprite * imageRenderer = STATIC_CAST_CCSPRITE ; <nl> + imageRenderer - > setTexture ( fileName ) ; <nl> } <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> if ( _scale9Enabled ) <nl> { <nl> - DYNAMIC_CAST_SCALE9SPRITE - > initWithSpriteFrameName ( fileName ) ; <nl> - DYNAMIC_CAST_SCALE9SPRITE - > setColor ( getColor ( ) ) ; <nl> - DYNAMIC_CAST_SCALE9SPRITE - > setOpacity ( getOpacity ( ) ) ; <nl> - DYNAMIC_CAST_SCALE9SPRITE - > setCapInsets ( _capInsets ) ; <nl> + extension : : Scale9Sprite * imageRendererScale9 = STATIC_CAST_SCALE9SPRITE ; <nl> + imageRendererScale9 - > initWithSpriteFrameName ( fileName ) ; <nl> + imageRendererScale9 - > setCapInsets ( _capInsets ) ; <nl> } <nl> else <nl> { <nl> - DYNAMIC_CAST_CCSPRITE - > setSpriteFrame ( fileName ) ; <nl> - DYNAMIC_CAST_CCSPRITE - > setColor ( getColor ( ) ) ; <nl> - DYNAMIC_CAST_CCSPRITE - > setOpacity ( getOpacity ( ) ) ; <nl> + Sprite * imageRenderer = STATIC_CAST_CCSPRITE ; <nl> + imageRenderer - > setSpriteFrame ( fileName ) ; <nl> } <nl> break ; <nl> default : <nl> break ; <nl> } <nl> _imageTextureSize = _imageRenderer - > getContentSize ( ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> updateAnchorPoint ( ) ; <nl> imageTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UIImageView : : setTextureRect ( const cocos2d : : Rect & rect ) <nl> + void ImageView : : setTextureRect ( const Rect & rect ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> } <nl> else <nl> { <nl> - DYNAMIC_CAST_CCSPRITE - > setTextureRect ( rect ) ; <nl> - } <nl> - } <nl> - <nl> - bool UIImageView : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> - { <nl> - setFocused ( true ) ; <nl> - _touchStartPos . x = touchPoint . x ; <nl> - _touchStartPos . y = touchPoint . y ; <nl> - _widgetParent - > checkChildInfo ( 0 , this , touchPoint ) ; <nl> - pushDownEvent ( ) ; <nl> - <nl> - if ( _doubleClickEnabled ) <nl> - { <nl> - _clickTimeInterval = 0 ; <nl> - _startCheckDoubleClick = true ; <nl> - _clickCount + + ; <nl> - _touchRelease = false ; <nl> - } <nl> - return _touchPassedEnabled ; <nl> - } <nl> - <nl> - void UIImageView : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> - { <nl> - if ( _doubleClickEnabled ) <nl> - { <nl> - if ( _clickCount > = 2 ) <nl> - { <nl> - doubleClickEvent ( ) ; <nl> - _clickCount = 0 ; <nl> - _startCheckDoubleClick = false ; <nl> - } <nl> - else <nl> - { <nl> - _touchRelease = true ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - UIWidget : : onTouchEnded ( touchPoint ) ; <nl> - } <nl> - } <nl> - <nl> - void UIImageView : : doubleClickEvent ( ) <nl> - { <nl> - <nl> - } <nl> - <nl> - void UIImageView : : checkDoubleClick ( float dt ) <nl> - { <nl> - if ( _startCheckDoubleClick ) <nl> - { <nl> - _clickTimeInterval + = dt ; <nl> - if ( _clickTimeInterval > = 200 & & _clickCount > 0 ) <nl> - { <nl> - _clickTimeInterval = 0 ; <nl> - _clickCount - - ; <nl> - _startCheckDoubleClick = false ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - if ( _clickCount < = 1 ) <nl> - { <nl> - if ( _touchRelease ) <nl> - { <nl> - releaseUpEvent ( ) ; <nl> - _clickTimeInterval = 0 ; <nl> - _clickCount = 0 ; <nl> - _touchRelease = false ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - void UIImageView : : setDoubleClickEnabled ( bool able ) <nl> - { <nl> - if ( able = = _doubleClickEnabled ) <nl> - { <nl> - return ; <nl> - } <nl> - _doubleClickEnabled = able ; <nl> - if ( able ) <nl> - { <nl> - / / COCOUISYSTEM - > getUIInputManager ( ) - > addCheckedDoubleClickWidget ( this ) ; <nl> - } <nl> - else <nl> - { <nl> - <nl> + STATIC_CAST_CCSPRITE - > setTextureRect ( rect ) ; <nl> } <nl> } <nl> <nl> - void UIImageView : : setFlipX ( bool flipX ) <nl> + void ImageView : : setFlipX ( bool flipX ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> } <nl> else <nl> { <nl> - DYNAMIC_CAST_CCSPRITE - > setFlippedX ( flipX ) ; <nl> + STATIC_CAST_CCSPRITE - > setFlippedX ( flipX ) ; <nl> } <nl> } <nl> <nl> - void UIImageView : : setFlipY ( bool flipY ) <nl> + void ImageView : : setFlipY ( bool flipY ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> } <nl> else <nl> { <nl> - DYNAMIC_CAST_CCSPRITE - > setFlippedY ( flipY ) ; <nl> + STATIC_CAST_CCSPRITE - > setFlippedY ( flipY ) ; <nl> } <nl> } <nl> <nl> - bool UIImageView : : isFlipX ( ) <nl> + bool ImageView : : isFlipX ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> bool UIImageView : : isFlipX ( ) <nl> } <nl> else <nl> { <nl> - return DYNAMIC_CAST_CCSPRITE - > isFlippedX ( ) ; <nl> + return STATIC_CAST_CCSPRITE - > isFlippedX ( ) ; <nl> } <nl> } <nl> <nl> - bool UIImageView : : isFlipY ( ) <nl> + bool ImageView : : isFlipY ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> bool UIImageView : : isFlipY ( ) <nl> } <nl> else <nl> { <nl> - return DYNAMIC_CAST_CCSPRITE - > isFlippedY ( ) ; <nl> + return STATIC_CAST_CCSPRITE - > isFlippedY ( ) ; <nl> } <nl> } <nl> <nl> - void UIImageView : : setScale9Enabled ( bool able ) <nl> + void ImageView : : setScale9Enabled ( bool able ) <nl> { <nl> if ( _scale9Enabled = = able ) <nl> { <nl> void UIImageView : : setScale9Enabled ( bool able ) <nl> <nl> <nl> _scale9Enabled = able ; <nl> - _renderer - > removeChild ( _imageRenderer , true ) ; <nl> + Node : : removeChild ( _imageRenderer ) ; <nl> _imageRenderer = nullptr ; <nl> if ( _scale9Enabled ) <nl> { <nl> - _imageRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _imageRenderer = extension : : Scale9Sprite : : create ( ) ; <nl> } <nl> else <nl> { <nl> - _imageRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _imageRenderer = Sprite : : create ( ) ; <nl> } <nl> loadTexture ( _textureFile . c_str ( ) , _imageTexType ) ; <nl> - _renderer - > addChild ( _imageRenderer ) ; <nl> + Node : : addChild ( _imageRenderer , IMAGERENDERERZ , - 1 ) ; <nl> if ( _scale9Enabled ) <nl> { <nl> bool ignoreBefore = _ignoreSize ; <nl> void UIImageView : : setScale9Enabled ( bool able ) <nl> setCapInsets ( _capInsets ) ; <nl> } <nl> <nl> - void UIImageView : : ignoreContentAdaptWithSize ( bool ignore ) <nl> + void ImageView : : ignoreContentAdaptWithSize ( bool ignore ) <nl> { <nl> if ( ! _scale9Enabled | | ( _scale9Enabled & & ! ignore ) ) <nl> { <nl> - UIWidget : : ignoreContentAdaptWithSize ( ignore ) ; <nl> + Widget : : ignoreContentAdaptWithSize ( ignore ) ; <nl> _prevIgnoreSize = ignore ; <nl> } <nl> } <nl> <nl> - void UIImageView : : setCapInsets ( const cocos2d : : Rect & capInsets ) <nl> + void ImageView : : setCapInsets ( const Rect & capInsets ) <nl> { <nl> _capInsets = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - DYNAMIC_CAST_SCALE9SPRITE - > setCapInsets ( capInsets ) ; <nl> + STATIC_CAST_SCALE9SPRITE - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UIImageView : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> + void ImageView : : setAnchorPoint ( const Point & pt ) <nl> { <nl> - UIWidget : : setAnchorPoint ( pt ) ; <nl> + Widget : : setAnchorPoint ( pt ) ; <nl> _imageRenderer - > setAnchorPoint ( pt ) ; <nl> } <nl> <nl> - void UIImageView : : onSizeChanged ( ) <nl> + void ImageView : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> imageTextureScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const cocos2d : : Size & UIImageView : : getContentSize ( ) const <nl> + const Size & ImageView : : getContentSize ( ) const <nl> { <nl> return _imageTextureSize ; <nl> } <nl> <nl> - cocos2d : : Node * UIImageView : : getVirtualRenderer ( ) <nl> + Node * ImageView : : getVirtualRenderer ( ) <nl> { <nl> return _imageRenderer ; <nl> } <nl> <nl> - void UIImageView : : imageTextureScaleChangedWithSize ( ) <nl> + void ImageView : : imageTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UIImageView : : imageTextureScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _imageRenderer ) - > setPreferredSize ( _size ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _imageRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _imageRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _imageRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _imageRenderer - > setScale ( 1 . 0f ) ; <nl> void UIImageView : : imageTextureScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - const char * UIImageView : : getDescription ( ) const <nl> + std : : string ImageView : : getDescription ( ) const <nl> { <nl> return " ImageView " ; <nl> } <nl> <nl> - UIWidget * UIImageView : : createCloneInstance ( ) <nl> + Widget * ImageView : : createCloneInstance ( ) <nl> { <nl> - return UIImageView : : create ( ) ; <nl> + return ImageView : : create ( ) ; <nl> } <nl> <nl> - void UIImageView : : copySpecialProperties ( UIWidget * widget ) <nl> + void ImageView : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UIImageView * imageView = dynamic_cast < UIImageView * > ( widget ) ; <nl> + ImageView * imageView = dynamic_cast < ImageView * > ( widget ) ; <nl> if ( imageView ) <nl> { <nl> _prevIgnoreSize = imageView - > _prevIgnoreSize ; <nl> void UIImageView : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIImageView . h <nl> ppp b / cocos / gui / UIImageView . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> - class UIImageView : public UIWidget <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class ImageView : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UIImageView ( ) ; <nl> + ImageView ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UIImageView ( ) ; <nl> + virtual ~ ImageView ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UIImageView * create ( ) ; <nl> + static ImageView * create ( ) ; <nl> <nl> / * * <nl> * Load texture for imageview . <nl> class UIImageView : public UIWidget <nl> void loadTexture ( const char * fileName , TextureResType texType = UI_TEX_TYPE_LOCAL ) ; <nl> <nl> / * * <nl> - * Updates the texture rect of the UIImageView in points . <nl> + * Updates the texture rect of the ImageView in points . <nl> * It will call setTextureRect : rotated : untrimmedSize with rotated = NO , and utrimmedSize = rect . size . <nl> * / <nl> - void setTextureRect ( const cocos2d : : Rect & rect ) ; <nl> + void setTextureRect ( const Rect & rect ) ; <nl> <nl> / * * <nl> * Sets if imageview is using scale9 renderer . <nl> class UIImageView : public UIWidget <nl> * <nl> * @ param capInsets capinsets for imageview <nl> * / <nl> - void setCapInsets ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsets ( const Rect & capInsets ) ; <nl> <nl> / / override " setFlipX " method of widget . <nl> virtual void setFlipX ( bool flipX ) override ; <nl> class UIImageView : public UIWidget <nl> virtual bool isFlipY ( ) override ; <nl> <nl> / / override " setAnchorPoint " method of widget . <nl> - virtual void setAnchorPoint ( const cocos2d : : Point & pt ) override ; <nl> - <nl> - / * * override " onTouchBegan " method of widget . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual bool onTouchBegan ( const cocos2d : : Point & touchPoint ) override ; <nl> - <nl> - / * * override " onTouchEnded " method of widget . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onTouchEnded ( const cocos2d : : Point & touchPoint ) override ; <nl> + virtual void setAnchorPoint ( const Point & pt ) override ; <nl> <nl> / / override " ignoreContentAdaptWithSize " method of widget . <nl> virtual void ignoreContentAdaptWithSize ( bool ignore ) override ; <nl> class UIImageView : public UIWidget <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> - void setDoubleClickEnabled ( bool able ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void doubleClickEvent ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - void checkDoubleClick ( float dt ) ; <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> protected : <nl> virtual void initRenderer ( ) override ; <nl> virtual void onSizeChanged ( ) override ; <nl> void imageTextureScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> - int _clickCount ; <nl> - float _clickTimeInterval ; <nl> - bool _startCheckDoubleClick ; <nl> - bool _touchRelease ; <nl> - bool _doubleClickEnabled ; <nl> bool _scale9Enabled ; <nl> bool _prevIgnoreSize ; <nl> - cocos2d : : Rect _capInsets ; <nl> - cocos2d : : Node * _imageRenderer ; <nl> + Rect _capInsets ; <nl> + Node * _imageRenderer ; <nl> std : : string _textureFile ; <nl> TextureResType _imageTexType ; <nl> - cocos2d : : Size _imageTextureSize ; <nl> + Size _imageTextureSize ; <nl> } ; <nl> <nl> } <nl> <nl> - # endif / * defined ( __CocoGUI__UIImageView__ ) * / <nl> + NS_CC_END <nl> + <nl> + # endif / * defined ( __CocoGUI__ImageView__ ) * / <nl> deleted file mode 100644 <nl> index a8cd486f61c0 . . 000000000000 <nl> mmm a / cocos / gui / UIInputManager . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all 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 , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " gui / UIInputManager . h " <nl> - # include " gui / UIHelper . h " <nl> - <nl> - using namespace cocos2d ; <nl> - <nl> - namespace gui { <nl> - <nl> - UIInputManager : : UIInputManager ( ) : <nl> - _manageredWidget ( nullptr ) , <nl> - _touchDown ( false ) , <nl> - _longClickTime ( 0 . 0 ) , <nl> - _longClickRecordTime ( 0 . 0 ) , <nl> - _checkedDoubleClickWidget ( nullptr ) , <nl> - _rootWidget ( nullptr ) <nl> - { <nl> - _manageredWidget = Array : : create ( ) ; <nl> - _manageredWidget - > retain ( ) ; <nl> - _checkedDoubleClickWidget = Array : : create ( ) ; <nl> - _checkedDoubleClickWidget - > retain ( ) ; <nl> - _selectedWidgets = Array : : create ( ) ; <nl> - _selectedWidgets - > retain ( ) ; <nl> - } <nl> - <nl> - UIInputManager : : ~ UIInputManager ( ) <nl> - { <nl> - _manageredWidget - > removeAllObjects ( ) ; <nl> - CC_SAFE_RELEASE_NULL ( _manageredWidget ) ; <nl> - _checkedDoubleClickWidget - > removeAllObjects ( ) ; <nl> - CC_SAFE_RELEASE_NULL ( _checkedDoubleClickWidget ) ; <nl> - _selectedWidgets - > removeAllObjects ( ) ; <nl> - CC_SAFE_RELEASE_NULL ( _selectedWidgets ) ; <nl> - } <nl> - <nl> - void UIInputManager : : registWidget ( UIWidget * widget ) <nl> - { <nl> - if ( ! widget ) <nl> - { <nl> - return ; <nl> - } <nl> - if ( _manageredWidget - > containsObject ( widget ) ) <nl> - { <nl> - return ; <nl> - } <nl> - _manageredWidget - > addObject ( widget ) ; <nl> - } <nl> - <nl> - bool UIInputManager : : checkTouchEvent ( UIWidget * root , const Point & touchPoint ) <nl> - { <nl> - ccArray * arrayRootChildren = root - > getChildren ( ) - > data ; <nl> - ssize_t length = arrayRootChildren - > num ; <nl> - for ( ssize_t i = length - 1 ; i > = 0 ; i - - ) <nl> - { <nl> - UIWidget * widget = ( UIWidget * ) ( arrayRootChildren - > arr [ i ] ) ; <nl> - if ( checkTouchEvent ( widget , touchPoint ) ) <nl> - { <nl> - return true ; <nl> - } <nl> - } <nl> - if ( root - > isEnabled ( ) & & root - > isTouchEnabled ( ) & & root - > hitTest ( touchPoint ) & & root - > clippingParentAreaContainPoint ( touchPoint ) ) <nl> - { <nl> - _selectedWidgets - > addObject ( root ) ; <nl> - root - > onTouchBegan ( touchPoint ) ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - void UIInputManager : : removeManageredWidget ( UIWidget * widget ) <nl> - { <nl> - if ( ! widget ) <nl> - { <nl> - return ; <nl> - } <nl> - if ( ! _manageredWidget - > containsObject ( widget ) ) <nl> - { <nl> - return ; <nl> - } <nl> - _manageredWidget - > removeObject ( widget ) ; <nl> - } <nl> - <nl> - bool UIInputManager : : checkEventWidget ( const Point & touchPoint ) <nl> - { <nl> - checkTouchEvent ( _rootWidget , touchPoint ) ; <nl> - return ( _selectedWidgets - > count ( ) > 0 ) ; <nl> - } <nl> - <nl> - void UIInputManager : : addCheckedDoubleClickWidget ( UIWidget * widget ) <nl> - { <nl> - if ( _checkedDoubleClickWidget - > containsObject ( widget ) ) <nl> - { <nl> - return ; <nl> - } <nl> - _checkedDoubleClickWidget - > addObject ( widget ) ; <nl> - } <nl> - <nl> - void UIInputManager : : update ( float dt ) <nl> - { <nl> - if ( _touchDown ) <nl> - { <nl> - _longClickRecordTime + = dt ; <nl> - if ( _longClickRecordTime > = _longClickTime ) <nl> - { <nl> - _longClickRecordTime = 0 ; <nl> - _touchDown = false ; <nl> - / / m_pCurSelectedWidget - > onTouchLongClicked ( touchBeganedPoint ) ; <nl> - } <nl> - } <nl> - ccArray * arrayWidget = _checkedDoubleClickWidget - > data ; <nl> - ssize_t widgetCount = arrayWidget - > num ; <nl> - for ( int i = 0 ; i < widgetCount ; i + + ) <nl> - { <nl> - UIWidget * widget = ( UIWidget * ) ( arrayWidget - > arr [ i ] ) ; <nl> - if ( ! widget - > isVisible ( ) ) <nl> - { <nl> - continue ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - bool UIInputManager : : onTouchBegan ( Touch * touch ) <nl> - { <nl> - _touchBeganedPoint . x = touch - > getLocation ( ) . x ; <nl> - _touchBeganedPoint . y = touch - > getLocation ( ) . y ; <nl> - _touchDown = true ; <nl> - return checkEventWidget ( _touchBeganedPoint ) ; <nl> - } <nl> - <nl> - void UIInputManager : : onTouchMoved ( Touch * touch ) <nl> - { <nl> - _touchMovedPoint . x = touch - > getLocation ( ) . x ; <nl> - _touchMovedPoint . y = touch - > getLocation ( ) . y ; <nl> - ccArray * selectedWidgetArray = _selectedWidgets - > data ; <nl> - int length = selectedWidgetArray - > num ; <nl> - for ( int i = 0 ; i < length ; + + i ) <nl> - { <nl> - UIWidget * hitWidget = ( UIWidget * ) ( selectedWidgetArray - > arr [ i ] ) ; <nl> - hitWidget - > onTouchMoved ( _touchMovedPoint ) ; <nl> - } <nl> - if ( _touchDown ) <nl> - { <nl> - _longClickRecordTime = 0 ; <nl> - _touchDown = false ; <nl> - } <nl> - } <nl> - <nl> - void UIInputManager : : onTouchEnd ( Touch * touch ) <nl> - { <nl> - _touchDown = false ; <nl> - _touchEndedPoint . x = touch - > getLocation ( ) . x ; <nl> - _touchEndedPoint . y = touch - > getLocation ( ) . y ; <nl> - ccArray * selectedWidgetArray = _selectedWidgets - > data ; <nl> - ssize_t length = selectedWidgetArray - > num ; <nl> - for ( int i = 0 ; i < length ; + + i ) <nl> - { <nl> - UIWidget * hitWidget = ( UIWidget * ) ( selectedWidgetArray - > arr [ 0 ] ) ; <nl> - _selectedWidgets - > removeObject ( hitWidget ) ; <nl> - hitWidget - > onTouchEnded ( _touchEndedPoint ) ; <nl> - } <nl> - } <nl> - <nl> - void UIInputManager : : onTouchCancelled ( Touch * touch ) <nl> - { <nl> - _touchDown = false ; <nl> - _touchEndedPoint . x = touch - > getLocation ( ) . x ; <nl> - _touchEndedPoint . y = touch - > getLocation ( ) . y ; <nl> - ccArray * selectedWidgetArray = _selectedWidgets - > data ; <nl> - ssize_t length = selectedWidgetArray - > num ; <nl> - for ( int i = 0 ; i < length ; + + i ) <nl> - { <nl> - UIWidget * hitWidget = ( UIWidget * ) ( selectedWidgetArray - > arr [ 0 ] ) ; <nl> - _selectedWidgets - > removeObject ( hitWidget ) ; <nl> - hitWidget - > onTouchCancelled ( _touchEndedPoint ) ; <nl> - } <nl> - } <nl> - <nl> - void UIInputManager : : setRootWidget ( UIWidget * root ) <nl> - { <nl> - _rootWidget = root ; <nl> - } <nl> - <nl> - UIWidget * UIInputManager : : getRootWidget ( ) <nl> - { <nl> - return _rootWidget ; <nl> - } <nl> - <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 52a1cb4d9f50 . . 000000000000 <nl> mmm a / cocos / gui / UIInputManager . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all 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 , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __UIINPUTMANAGER_H__ <nl> - # define __UIINPUTMANAGER_H__ <nl> - <nl> - # include " cocos2d . h " <nl> - # include " gui / UILayout . h " <nl> - <nl> - namespace gui { <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - class UIInputManager <nl> - { <nl> - public : <nl> - / * * <nl> - * Default constructor <nl> - * / <nl> - UIInputManager ( ) ; <nl> - <nl> - / * * <nl> - * Default destructor <nl> - * / <nl> - virtual ~ UIInputManager ( ) ; <nl> - <nl> - / * * <nl> - * Regist a widget to input manager . <nl> - * <nl> - * @ param widget registed widget can be touched . <nl> - * / <nl> - void registWidget ( UIWidget * widget ) ; <nl> - <nl> - / * * <nl> - * Remove a registed widget from input manager . <nl> - * <nl> - * @ param widget widget which will be removed . <nl> - * / <nl> - void removeManageredWidget ( UIWidget * widget ) ; <nl> - <nl> - / * * <nl> - * Finds a widget which is selected and call it ' s " onTouchBegan " method . <nl> - * <nl> - * @ param touch point . <nl> - * <nl> - * @ return true that find a widget selected , false otherwise . <nl> - * / <nl> - bool checkEventWidget ( const cocos2d : : Point & touchPoint ) ; <nl> - <nl> - <nl> - void update ( float dt ) ; <nl> - bool onTouchBegan ( cocos2d : : Touch * touch ) ; <nl> - void onTouchMoved ( cocos2d : : Touch * touch ) ; <nl> - void onTouchEnd ( cocos2d : : Touch * touch ) ; <nl> - void onTouchCancelled ( cocos2d : : Touch * touch ) ; <nl> - <nl> - void setRootWidget ( UIWidget * root ) ; <nl> - UIWidget * getRootWidget ( ) ; <nl> - void addCheckedDoubleClickWidget ( UIWidget * widget ) ; <nl> - protected : <nl> - bool checkTouchEvent ( UIWidget * root , const cocos2d : : Point & touchPoint ) ; <nl> - protected : <nl> - cocos2d : : Array * _manageredWidget ; <nl> - cocos2d : : Array * _selectedWidgets ; <nl> - cocos2d : : Point _touchBeganedPoint ; <nl> - cocos2d : : Point _touchMovedPoint ; <nl> - cocos2d : : Point _touchEndedPoint ; <nl> - cocos2d : : Point _touchCanceledPoint ; <nl> - bool _touchDown ; <nl> - float _longClickTime ; <nl> - float _longClickRecordTime ; <nl> - cocos2d : : Array * _checkedDoubleClickWidget ; <nl> - UIWidget * _rootWidget ; <nl> - } ; <nl> - <nl> - } <nl> - <nl> - # endif / * defined ( __CocoGUI__UIInputManager__ ) * / <nl> mmm a / cocos / gui / UILabel . cpp <nl> ppp b / cocos / gui / UILabel . cpp <nl> <nl> <nl> # include " gui / UILabel . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> + # define LABELRENDERERZ ( - 1 ) <nl> <nl> - UILabel : : UILabel ( ) : <nl> + Label : : Label ( ) : <nl> _touchScaleChangeEnabled ( false ) , <nl> _normalScaleValueX ( 1 . 0f ) , <nl> _normalScaleValueY ( 1 . 0f ) , <nl> _labelRenderer ( nullptr ) <nl> { <nl> } <nl> <nl> - UILabel : : ~ UILabel ( ) <nl> + Label : : ~ Label ( ) <nl> { <nl> <nl> } <nl> <nl> - UILabel * UILabel : : create ( ) <nl> + Label * Label : : create ( ) <nl> { <nl> - UILabel * widget = new UILabel ( ) ; <nl> + Label * widget = new Label ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UILabel * UILabel : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UILabel : : init ( ) <nl> + bool Label : : init ( ) <nl> { <nl> - if ( UIWidget : : init ( ) ) <nl> + if ( Widget : : init ( ) ) <nl> { <nl> return true ; <nl> } <nl> return false ; <nl> } <nl> <nl> - void UILabel : : initRenderer ( ) <nl> + void Label : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> - _labelRenderer = cocos2d : : LabelTTF : : create ( ) ; <nl> - _renderer - > addChild ( _labelRenderer ) ; <nl> + _labelRenderer = LabelTTF : : create ( ) ; <nl> + Node : : addChild ( _labelRenderer , LABELRENDERERZ , - 1 ) ; <nl> } <nl> <nl> - void UILabel : : setText ( const std : : string & text ) <nl> + void Label : : setText ( const std : : string & text ) <nl> { <nl> if ( text . size ( ) = = 0 ) <nl> return ; <nl> void UILabel : : setText ( const std : : string & text ) <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const std : : string & UILabel : : getStringValue ( ) <nl> + const std : : string & Label : : getStringValue ( ) <nl> { <nl> return _labelRenderer - > getString ( ) ; <nl> } <nl> <nl> - int UILabel : : getStringLength ( ) <nl> + int Label : : getStringLength ( ) <nl> { <nl> return _labelRenderer - > getString ( ) . size ( ) ; <nl> } <nl> <nl> - void UILabel : : setFontSize ( int size ) <nl> + void Label : : setFontSize ( int size ) <nl> { <nl> _fontSize = size ; <nl> _labelRenderer - > setFontSize ( size ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabel : : setFontName ( const std : : string & name ) <nl> + void Label : : setFontName ( const std : : string & name ) <nl> { <nl> _fontName = name ; <nl> _labelRenderer - > setFontName ( name ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabel : : setTextAreaSize ( const cocos2d : : Size & size ) <nl> + void Label : : setTextAreaSize ( const Size & size ) <nl> { <nl> _labelRenderer - > setDimensions ( size ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabel : : setTextHorizontalAlignment ( cocos2d : : TextHAlignment alignment ) <nl> + void Label : : setTextHorizontalAlignment ( TextHAlignment alignment ) <nl> { <nl> _labelRenderer - > setHorizontalAlignment ( alignment ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabel : : setTextVerticalAlignment ( cocos2d : : TextVAlignment alignment ) <nl> + void Label : : setTextVerticalAlignment ( TextVAlignment alignment ) <nl> { <nl> _labelRenderer - > setVerticalAlignment ( alignment ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabel : : setTouchScaleChangeEnabled ( bool enable ) <nl> + void Label : : setTouchScaleChangeEnabled ( bool enable ) <nl> { <nl> _touchScaleChangeEnabled = enable ; <nl> _normalScaleValueX = getScaleX ( ) ; <nl> _normalScaleValueY = getScaleY ( ) ; <nl> } <nl> <nl> - void UILabel : : setScale ( float fScale ) <nl> + void Label : : setScale ( float fScale ) <nl> { <nl> - UIWidget : : setScale ( fScale ) ; <nl> + Widget : : setScale ( fScale ) ; <nl> _normalScaleValueX = _normalScaleValueY = fScale ; <nl> } <nl> <nl> - void UILabel : : setScaleX ( float fScaleX ) <nl> + void Label : : setScaleX ( float fScaleX ) <nl> { <nl> - UIWidget : : setScaleX ( fScaleX ) ; <nl> + Widget : : setScaleX ( fScaleX ) ; <nl> _normalScaleValueX = fScaleX ; <nl> } <nl> <nl> - void UILabel : : setScaleY ( float fScaleY ) <nl> + void Label : : setScaleY ( float fScaleY ) <nl> { <nl> - UIWidget : : setScaleY ( fScaleY ) ; <nl> + Widget : : setScaleY ( fScaleY ) ; <nl> _normalScaleValueY = fScaleY ; <nl> } <nl> <nl> - bool UILabel : : isTouchScaleChangeEnabled ( ) <nl> + bool Label : : isTouchScaleChangeEnabled ( ) <nl> { <nl> return _touchScaleChangeEnabled ; <nl> } <nl> <nl> - void UILabel : : onPressStateChangedToNormal ( ) <nl> + void Label : : onPressStateChangedToNormal ( ) <nl> { <nl> if ( ! _touchScaleChangeEnabled ) <nl> { <nl> void UILabel : : onPressStateChangedToNormal ( ) <nl> clickScale ( _normalScaleValueX , _normalScaleValueY ) ; <nl> } <nl> <nl> - void UILabel : : onPressStateChangedToPressed ( ) <nl> + void Label : : onPressStateChangedToPressed ( ) <nl> { <nl> if ( ! _touchScaleChangeEnabled ) <nl> { <nl> void UILabel : : onPressStateChangedToPressed ( ) <nl> clickScale ( _normalScaleValueX + _onSelectedScaleOffset , _normalScaleValueY + _onSelectedScaleOffset ) ; <nl> } <nl> <nl> - void UILabel : : onPressStateChangedToDisabled ( ) <nl> + void Label : : onPressStateChangedToDisabled ( ) <nl> { <nl> <nl> } <nl> <nl> - void UILabel : : clickScale ( float scaleX , float scaleY ) <nl> + void Label : : clickScale ( float scaleX , float scaleY ) <nl> { <nl> - _renderer - > setScaleX ( scaleX ) ; <nl> - _renderer - > setScaleY ( scaleY ) ; <nl> + setScaleX ( scaleX ) ; <nl> + setScaleY ( scaleY ) ; <nl> } <nl> <nl> - void UILabel : : setFlipX ( bool flipX ) <nl> + void Label : : setFlipX ( bool flipX ) <nl> { <nl> _labelRenderer - > setFlippedX ( flipX ) ; <nl> } <nl> <nl> - void UILabel : : setFlipY ( bool flipY ) <nl> + void Label : : setFlipY ( bool flipY ) <nl> { <nl> _labelRenderer - > setFlippedY ( flipY ) ; <nl> } <nl> <nl> - bool UILabel : : isFlipX ( ) <nl> + bool Label : : isFlipX ( ) <nl> { <nl> return _labelRenderer - > isFlippedX ( ) ; <nl> } <nl> <nl> - bool UILabel : : isFlipY ( ) <nl> + bool Label : : isFlipY ( ) <nl> { <nl> return _labelRenderer - > isFlippedY ( ) ; <nl> } <nl> <nl> - void UILabel : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> + void Label : : setAnchorPoint ( const Point & pt ) <nl> { <nl> - UIWidget : : setAnchorPoint ( pt ) ; <nl> + Widget : : setAnchorPoint ( pt ) ; <nl> _labelRenderer - > setAnchorPoint ( pt ) ; <nl> } <nl> <nl> - void UILabel : : onSizeChanged ( ) <nl> + void Label : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> labelScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const cocos2d : : Size & UILabel : : getContentSize ( ) const <nl> + const Size & Label : : getContentSize ( ) const <nl> { <nl> return _labelRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - cocos2d : : Node * UILabel : : getVirtualRenderer ( ) <nl> + Node * Label : : getVirtualRenderer ( ) <nl> { <nl> return _labelRenderer ; <nl> } <nl> <nl> - void UILabel : : labelScaleChangedWithSize ( ) <nl> + void Label : : labelScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UILabel : : labelScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _labelRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _labelRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _labelRenderer - > setScale ( 1 . 0f ) ; <nl> void UILabel : : labelScaleChangedWithSize ( ) <nl> <nl> } <nl> <nl> - const char * UILabel : : getDescription ( ) const <nl> + std : : string Label : : getDescription ( ) const <nl> { <nl> return " Label " ; <nl> } <nl> <nl> - UIWidget * UILabel : : createCloneInstance ( ) <nl> + Widget * Label : : createCloneInstance ( ) <nl> { <nl> - return UILabel : : create ( ) ; <nl> + return Label : : create ( ) ; <nl> } <nl> <nl> - void UILabel : : copySpecialProperties ( UIWidget * widget ) <nl> + void Label : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UILabel * label = dynamic_cast < UILabel * > ( widget ) ; <nl> + Label * label = dynamic_cast < Label * > ( widget ) ; <nl> if ( label ) <nl> { <nl> setFontName ( label - > _fontName . c_str ( ) ) ; <nl> void UILabel : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILabel . h <nl> ppp b / cocos / gui / UILabel . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> <nl> namespace gui { <nl> <nl> - class UILabel : public UIWidget <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class Label : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UILabel ( ) ; <nl> + Label ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UILabel ( ) ; <nl> + virtual ~ Label ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UILabel * create ( ) ; <nl> + static Label * create ( ) ; <nl> <nl> / * * <nl> * Changes the string value of label . <nl> class UILabel : public UIWidget <nl> virtual bool isFlipY ( ) override ; <nl> <nl> / / override " setAnchorPoint " method of widget . <nl> - virtual void setAnchorPoint ( const cocos2d : : Point & pt ) override ; <nl> + virtual void setAnchorPoint ( const Point & pt ) override ; <nl> <nl> / / override " getContentSize " method of widget . <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> <nl> / / override " getVirtualRenderer " method of widget . <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> - void setTextAreaSize ( const cocos2d : : Size & size ) ; <nl> - void setTextHorizontalAlignment ( cocos2d : : TextHAlignment alignment ) ; <nl> - void setTextVerticalAlignment ( cocos2d : : TextVAlignment alignment ) ; <nl> + void setTextAreaSize ( const Size & size ) ; <nl> + void setTextHorizontalAlignment ( TextHAlignment alignment ) ; <nl> + void setTextVerticalAlignment ( TextVAlignment alignment ) ; <nl> protected : <nl> virtual bool init ( ) override ; <nl> virtual void initRenderer ( ) override ; <nl> class UILabel : public UIWidget <nl> virtual void onSizeChanged ( ) override ; <nl> void clickScale ( float scaleX , float scaleY ) ; <nl> void labelScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> bool _touchScaleChangeEnabled ; <nl> float _normalScaleValueX ; <nl> class UILabel : public UIWidget <nl> std : : string _fontName ; <nl> int _fontSize ; <nl> float _onSelectedScaleOffset ; <nl> - cocos2d : : LabelTTF * _labelRenderer ; <nl> + LabelTTF * _labelRenderer ; <nl> } ; <nl> <nl> } <nl> <nl> + NS_CC_END <nl> + <nl> # endif / * defined ( __CocoGUI__Label__ ) * / <nl> mmm a / cocos / gui / UILabelAtlas . cpp <nl> ppp b / cocos / gui / UILabelAtlas . cpp <nl> <nl> <nl> # include " gui / UILabelAtlas . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> + <nl> + # define LABELATLASRENDERERZ ( - 1 ) <nl> <nl> <nl> UICCLabelAtlas : : UICCLabelAtlas ( ) <nl> void UICCLabelAtlas : : setProperty ( const std : : string & string , const std : : string & c <nl> initWithString ( string , charMapFile , itemWidth , itemHeight , startCharMap ) ; <nl> } <nl> <nl> - void UICCLabelAtlas : : setProperty ( const std : : string & string , cocos2d : : Texture2D * texture , unsigned int itemWidth , unsigned int itemHeight , unsigned int startCharMap ) <nl> + void UICCLabelAtlas : : setProperty ( const std : : string & string , Texture2D * texture , unsigned int itemWidth , unsigned int itemHeight , unsigned int startCharMap ) <nl> { <nl> initWithString ( string , texture , itemWidth , itemHeight , startCharMap ) ; <nl> } <nl> void UICCLabelAtlas : : draw ( ) <nl> return ; <nl> } <nl> <nl> - cocos2d : : AtlasNode : : draw ( ) ; <nl> + AtlasNode : : draw ( ) ; <nl> } <nl> <nl> - void UICCLabelAtlas : : updateDisplayedOpacity ( GLubyte opacity ) <nl> - { <nl> - cocos2d : : AtlasNode : : setOpacity ( opacity ) ; <nl> - } <nl> <nl> <nl> - <nl> - <nl> - UILabelAtlas : : UILabelAtlas ( ) : <nl> - _laberAtlasRenderer ( nullptr ) , <nl> + LabelAtlas : : LabelAtlas ( ) : <nl> + _labelAtlasRenderer ( nullptr ) , <nl> _stringValue ( " " ) , <nl> _charMapFileName ( " " ) , <nl> _itemWidth ( 0 ) , <nl> _startCharMap ( " " ) <nl> <nl> } <nl> <nl> - UILabelAtlas : : ~ UILabelAtlas ( ) <nl> + LabelAtlas : : ~ LabelAtlas ( ) <nl> { <nl> <nl> } <nl> <nl> - UILabelAtlas * UILabelAtlas : : create ( ) <nl> + LabelAtlas * LabelAtlas : : create ( ) <nl> { <nl> - UILabelAtlas * widget = new UILabelAtlas ( ) ; <nl> + LabelAtlas * widget = new LabelAtlas ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UILabelAtlas * UILabelAtlas : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - void UILabelAtlas : : initRenderer ( ) <nl> + void LabelAtlas : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> - _laberAtlasRenderer = UICCLabelAtlas : : create ( ) ; <nl> - _renderer - > addChild ( _laberAtlasRenderer ) ; <nl> + _labelAtlasRenderer = UICCLabelAtlas : : create ( ) ; <nl> + Node : : addChild ( _labelAtlasRenderer , LABELATLASRENDERERZ , - 1 ) ; <nl> } <nl> <nl> - void UILabelAtlas : : setProperty ( const std : : string & stringValue , const std : : string & charMapFile , int itemWidth , int itemHeight , const std : : string & startCharMap ) <nl> + void LabelAtlas : : setProperty ( const std : : string & stringValue , const std : : string & charMapFile , int itemWidth , int itemHeight , const std : : string & startCharMap ) <nl> { <nl> _stringValue = stringValue ; <nl> _charMapFileName = charMapFile ; <nl> _itemWidth = itemWidth ; <nl> _itemHeight = itemHeight ; <nl> _startCharMap = startCharMap ; <nl> - _laberAtlasRenderer - > setProperty ( stringValue , charMapFile , itemWidth , itemHeight , ( int ) ( startCharMap [ 0 ] ) ) ; <nl> + _labelAtlasRenderer - > setProperty ( stringValue , charMapFile , itemWidth , itemHeight , ( int ) ( startCharMap [ 0 ] ) ) ; <nl> updateAnchorPoint ( ) ; <nl> labelAtlasScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILabelAtlas : : setStringValue ( const std : : string & value ) <nl> + void LabelAtlas : : setStringValue ( const std : : string & value ) <nl> { <nl> _stringValue = value ; <nl> - _laberAtlasRenderer - > setString ( value ) ; <nl> + _labelAtlasRenderer - > setString ( value ) ; <nl> labelAtlasScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const std : : string & UILabelAtlas : : getStringValue ( ) const <nl> + const std : : string & LabelAtlas : : getStringValue ( ) const <nl> { <nl> - return _laberAtlasRenderer - > getString ( ) ; <nl> + return _labelAtlasRenderer - > getString ( ) ; <nl> } <nl> <nl> - void UILabelAtlas : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> + void LabelAtlas : : setAnchorPoint ( const Point & pt ) <nl> { <nl> - UIWidget : : setAnchorPoint ( pt ) ; <nl> - _laberAtlasRenderer - > setAnchorPoint ( cocos2d : : Point ( pt . x , pt . y ) ) ; <nl> + Widget : : setAnchorPoint ( pt ) ; <nl> + _labelAtlasRenderer - > setAnchorPoint ( Point ( pt . x , pt . y ) ) ; <nl> } <nl> <nl> - void UILabelAtlas : : onSizeChanged ( ) <nl> + void LabelAtlas : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> labelAtlasScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const cocos2d : : Size & UILabelAtlas : : getContentSize ( ) const <nl> + const Size & LabelAtlas : : getContentSize ( ) const <nl> { <nl> - return _laberAtlasRenderer - > getContentSize ( ) ; <nl> + return _labelAtlasRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - cocos2d : : Node * UILabelAtlas : : getVirtualRenderer ( ) <nl> + Node * LabelAtlas : : getVirtualRenderer ( ) <nl> { <nl> - return _laberAtlasRenderer ; <nl> + return _labelAtlasRenderer ; <nl> } <nl> <nl> - void UILabelAtlas : : labelAtlasScaleChangedWithSize ( ) <nl> + void LabelAtlas : : labelAtlasScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> - _laberAtlasRenderer - > setScale ( 1 . 0f ) ; <nl> - _size = _laberAtlasRenderer - > getContentSize ( ) ; <nl> + _labelAtlasRenderer - > setScale ( 1 . 0f ) ; <nl> + _size = _labelAtlasRenderer - > getContentSize ( ) ; <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _laberAtlasRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _labelAtlasRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> - _laberAtlasRenderer - > setScale ( 1 . 0f ) ; <nl> + _labelAtlasRenderer - > setScale ( 1 . 0f ) ; <nl> return ; <nl> } <nl> float scaleX = _size . width / textureSize . width ; <nl> float scaleY = _size . height / textureSize . height ; <nl> - _laberAtlasRenderer - > setScaleX ( scaleX ) ; <nl> - _laberAtlasRenderer - > setScaleY ( scaleY ) ; <nl> + _labelAtlasRenderer - > setScaleX ( scaleX ) ; <nl> + _labelAtlasRenderer - > setScaleY ( scaleY ) ; <nl> } <nl> } <nl> <nl> - const char * UILabelAtlas : : getDescription ( ) const <nl> + std : : string LabelAtlas : : getDescription ( ) const <nl> { <nl> return " LabelAtlas " ; <nl> } <nl> <nl> - UIWidget * UILabelAtlas : : createCloneInstance ( ) <nl> + Widget * LabelAtlas : : createCloneInstance ( ) <nl> { <nl> - return UILabelAtlas : : create ( ) ; <nl> + return LabelAtlas : : create ( ) ; <nl> } <nl> <nl> - void UILabelAtlas : : copySpecialProperties ( UIWidget * widget ) <nl> + void LabelAtlas : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UILabelAtlas * labelAtlas = dynamic_cast < UILabelAtlas * > ( widget ) ; <nl> + LabelAtlas * labelAtlas = dynamic_cast < LabelAtlas * > ( widget ) ; <nl> if ( labelAtlas ) <nl> { <nl> setProperty ( labelAtlas - > _stringValue , labelAtlas - > _charMapFileName , labelAtlas - > _itemWidth , labelAtlas - > _itemHeight , labelAtlas - > _startCharMap ) ; <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILabelAtlas . h <nl> ppp b / cocos / gui / UILabelAtlas . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> - class UICCLabelAtlas : public cocos2d : : LabelAtlas <nl> + class UICCLabelAtlas : public LabelAtlas <nl> { <nl> public : <nl> / * * <nl> class UICCLabelAtlas : public cocos2d : : LabelAtlas <nl> * / <nl> static UICCLabelAtlas * create ( ) ; <nl> void setProperty ( const std : : string & string , const std : : string & charMapFile , unsigned int itemWidth , unsigned int itemHeight , unsigned int startCharMap ) ; <nl> - void setProperty ( const std : : string & string , cocos2d : : Texture2D * texture , unsigned int itemWidth , unsigned int itemHeight , unsigned int startCharMap ) ; <nl> - virtual void updateDisplayedOpacity ( GLubyte opacity ) override ; <nl> + void setProperty ( const std : : string & string , Texture2D * texture , unsigned int itemWidth , unsigned int itemHeight , unsigned int startCharMap ) ; <nl> virtual void draw ( void ) override ; <nl> } ; <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> - class UILabelAtlas : public UIWidget <nl> + class LabelAtlas : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> * / <nl> - UILabelAtlas ( ) ; <nl> + LabelAtlas ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> * / <nl> - virtual ~ UILabelAtlas ( ) ; <nl> + virtual ~ LabelAtlas ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UILabelAtlas * create ( ) ; <nl> + static LabelAtlas * create ( ) ; <nl> <nl> - / * * initializes the UILabelAtlas with a string , a char map file ( the atlas ) , the width and height of each element and the starting char of the atlas * / <nl> + / * * initializes the LabelAtlas with a string , a char map file ( the atlas ) , the width and height of each element and the starting char of the atlas * / <nl> void setProperty ( const std : : string & stringValue , const std : : string & charMapFile , int itemWidth , int itemHeight , const std : : string & startCharMap ) ; <nl> <nl> / / set string value for labelatlas . <nl> class UILabelAtlas : public UIWidget <nl> const std : : string & getStringValue ( ) const ; <nl> <nl> / / override " setAnchorPoint " method of widget . <nl> - virtual void setAnchorPoint ( const cocos2d : : Point & pt ) override ; <nl> + virtual void setAnchorPoint ( const Point & pt ) override ; <nl> <nl> / / override " getContentSize " method of widget . <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> <nl> / / override " getVirtualRenderer " method of widget . <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> protected : <nl> virtual void initRenderer ( ) override ; <nl> virtual void onSizeChanged ( ) override ; <nl> void labelAtlasScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> - UICCLabelAtlas * _laberAtlasRenderer ; <nl> + UICCLabelAtlas * _labelAtlasRenderer ; <nl> std : : string _stringValue ; <nl> std : : string _charMapFileName ; <nl> int _itemWidth ; <nl> class UILabelAtlas : public UIWidget <nl> } ; <nl> <nl> } <nl> + NS_CC_END <nl> <nl> - # endif / * defined ( __CocoGUI__UILabelAtlas__ ) * / <nl> + # endif / * defined ( __CocoGUI__LabelAtlas__ ) * / <nl> mmm a / cocos / gui / UILabelBMFont . cpp <nl> ppp b / cocos / gui / UILabelBMFont . cpp <nl> <nl> <nl> # include " gui / UILabelBMFont . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> - UILabelBMFont : : UILabelBMFont ( ) : <nl> + # define LABELBMFONTRENDERERZ ( - 1 ) <nl> + <nl> + LabelBMFont : : LabelBMFont ( ) : <nl> _labelBMFontRenderer ( nullptr ) , <nl> _fntFileHasInit ( false ) , <nl> _fntFileName ( " " ) , <nl> _stringValue ( " " ) <nl> { <nl> } <nl> <nl> - UILabelBMFont : : ~ UILabelBMFont ( ) <nl> + LabelBMFont : : ~ LabelBMFont ( ) <nl> { <nl> <nl> } <nl> <nl> - UILabelBMFont * UILabelBMFont : : create ( ) <nl> + LabelBMFont * LabelBMFont : : create ( ) <nl> { <nl> - UILabelBMFont * widget = new UILabelBMFont ( ) ; <nl> + LabelBMFont * widget = new LabelBMFont ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UILabelBMFont * UILabelBMFont : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - void UILabelBMFont : : initRenderer ( ) <nl> + void LabelBMFont : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> _labelBMFontRenderer = cocos2d : : LabelBMFont : : create ( ) ; <nl> - _renderer - > addChild ( _labelBMFontRenderer ) ; <nl> + Node : : addChild ( _labelBMFontRenderer , LABELBMFONTRENDERERZ , - 1 ) ; <nl> } <nl> <nl> - void UILabelBMFont : : setFntFile ( const char * fileName ) <nl> + void LabelBMFont : : setFntFile ( const char * fileName ) <nl> { <nl> if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> { <nl> void UILabelBMFont : : setFntFile ( const char * fileName ) <nl> setText ( _stringValue . c_str ( ) ) ; <nl> } <nl> <nl> - void UILabelBMFont : : setText ( const char * value ) <nl> + void LabelBMFont : : setText ( const char * value ) <nl> { <nl> if ( ! value ) <nl> { <nl> void UILabelBMFont : : setText ( const char * value ) <nl> labelBMFontScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const char * UILabelBMFont : : getStringValue ( ) <nl> + const char * LabelBMFont : : getStringValue ( ) <nl> { <nl> return _stringValue . c_str ( ) ; <nl> } <nl> <nl> - void UILabelBMFont : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> + void LabelBMFont : : setAnchorPoint ( const Point & pt ) <nl> { <nl> - UIWidget : : setAnchorPoint ( pt ) ; <nl> + Widget : : setAnchorPoint ( pt ) ; <nl> _labelBMFontRenderer - > setAnchorPoint ( pt ) ; <nl> } <nl> <nl> - void UILabelBMFont : : onSizeChanged ( ) <nl> + void LabelBMFont : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> labelBMFontScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const cocos2d : : Size & UILabelBMFont : : getContentSize ( ) const <nl> + const Size & LabelBMFont : : getContentSize ( ) const <nl> { <nl> return _labelBMFontRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - cocos2d : : Node * UILabelBMFont : : getVirtualRenderer ( ) <nl> + Node * LabelBMFont : : getVirtualRenderer ( ) <nl> { <nl> return _labelBMFontRenderer ; <nl> } <nl> <nl> - void UILabelBMFont : : labelBMFontScaleChangedWithSize ( ) <nl> + void LabelBMFont : : labelBMFontScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UILabelBMFont : : labelBMFontScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = _labelBMFontRenderer - > getContentSize ( ) ; <nl> + Size textureSize = _labelBMFontRenderer - > getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _labelBMFontRenderer - > setScale ( 1 . 0f ) ; <nl> void UILabelBMFont : : labelBMFontScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - const char * UILabelBMFont : : getDescription ( ) const <nl> + std : : string LabelBMFont : : getDescription ( ) const <nl> { <nl> return " LabelBMFont " ; <nl> } <nl> <nl> - UIWidget * UILabelBMFont : : createCloneInstance ( ) <nl> + Widget * LabelBMFont : : createCloneInstance ( ) <nl> { <nl> - return UILabelBMFont : : create ( ) ; <nl> + return LabelBMFont : : create ( ) ; <nl> } <nl> <nl> - void UILabelBMFont : : copySpecialProperties ( UIWidget * widget ) <nl> + void LabelBMFont : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UILabelBMFont * labelBMFont = dynamic_cast < UILabelBMFont * > ( widget ) ; <nl> + LabelBMFont * labelBMFont = dynamic_cast < LabelBMFont * > ( widget ) ; <nl> if ( labelBMFont ) <nl> { <nl> setFntFile ( labelBMFont - > _fntFileName . c_str ( ) ) ; <nl> void UILabelBMFont : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILabelBMFont . h <nl> ppp b / cocos / gui / UILabelBMFont . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> - class UILabelBMFont : public UIWidget <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class LabelBMFont : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UILabelBMFont ( ) ; <nl> + LabelBMFont ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UILabelBMFont ( ) ; <nl> + virtual ~ LabelBMFont ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UILabelBMFont * create ( ) ; <nl> + static LabelBMFont * create ( ) ; <nl> <nl> / * * init a bitmap font atlas with an initial string and the FNT file * / <nl> void setFntFile ( const char * fileName ) ; <nl> class UILabelBMFont : public UIWidget <nl> <nl> / * * get string value for labelbmfont * / <nl> const char * getStringValue ( ) ; <nl> - virtual void setAnchorPoint ( const cocos2d : : Point & pt ) override ; <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual void setAnchorPoint ( const Point & pt ) override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> protected : <nl> virtual void initRenderer ( ) override ; <nl> virtual void onSizeChanged ( ) override ; <nl> void labelBMFontScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> cocos2d : : LabelBMFont * _labelBMFontRenderer ; <nl> bool _fntFileHasInit ; <nl> class UILabelBMFont : public UIWidget <nl> } ; <nl> <nl> } <nl> + NS_CC_END <nl> <nl> - # endif / * defined ( __UILabelBMFont__ ) * / <nl> + # endif / * defined ( __LabelBMFont__ ) * / <nl> deleted file mode 100644 <nl> index 31472cb83f2a . . 000000000000 <nl> mmm a / cocos / gui / UILayer . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all 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 , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " gui / UILayer . h " <nl> - # include " gui / UIHelper . h " <nl> - <nl> - using namespace cocos2d ; <nl> - <nl> - namespace gui { <nl> - <nl> - UILayer : : UILayer ( ) : <nl> - _rootWidget ( nullptr ) , <nl> - _inputManager ( nullptr ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UILayer : : ~ UILayer ( ) <nl> - { <nl> - _rootWidget - > release ( ) ; <nl> - CC_SAFE_DELETE ( _inputManager ) ; <nl> - } <nl> - <nl> - bool UILayer : : init ( ) <nl> - { <nl> - if ( CCLayer : : init ( ) ) <nl> - { <nl> - _rootWidget = UIRootWidget : : create ( ) ; <nl> - _rootWidget - > retain ( ) ; <nl> - addChild ( _rootWidget - > getRenderer ( ) ) ; <nl> - _inputManager = new UIInputManager ( ) ; <nl> - _inputManager - > setRootWidget ( _rootWidget ) ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - UILayer * UILayer : : create ( void ) <nl> - { <nl> - UILayer * pRet = new UILayer ( ) ; <nl> - if ( pRet & & pRet - > init ( ) ) <nl> - { <nl> - pRet - > autorelease ( ) ; <nl> - return pRet ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( pRet ) ; <nl> - return nullptr ; <nl> - } <nl> - } <nl> - <nl> - void UILayer : : onEnter ( ) <nl> - { <nl> - CCLayer : : onEnter ( ) ; <nl> - <nl> - auto listener = EventListenerTouchOneByOne : : create ( ) ; <nl> - listener - > setSwallowTouches ( true ) ; <nl> - <nl> - listener - > onTouchBegan = CC_CALLBACK_2 ( UILayer : : onTouchBegan , this ) ; <nl> - listener - > onTouchMoved = CC_CALLBACK_2 ( UILayer : : onTouchMoved , this ) ; <nl> - listener - > onTouchEnded = CC_CALLBACK_2 ( UILayer : : onTouchEnded , this ) ; <nl> - listener - > onTouchCancelled = CC_CALLBACK_2 ( UILayer : : onTouchCancelled , this ) ; <nl> - <nl> - _eventDispatcher - > addEventListenerWithSceneGraphPriority ( listener , this ) ; <nl> - _rootWidget - > onEnter ( ) ; <nl> - } <nl> - <nl> - void UILayer : : onExit ( ) <nl> - { <nl> - _rootWidget - > onExit ( ) ; <nl> - CCLayer : : onExit ( ) ; <nl> - } <nl> - <nl> - void UILayer : : onEnterTransitionDidFinish ( ) <nl> - { <nl> - CCLayer : : onEnterTransitionDidFinish ( ) ; <nl> - } <nl> - <nl> - void UILayer : : addWidget ( UIWidget * widget ) <nl> - { <nl> - _rootWidget - > addChild ( widget ) ; <nl> - } <nl> - <nl> - void UILayer : : removeWidget ( UIWidget * widget ) <nl> - { <nl> - _rootWidget - > removeChild ( widget ) ; <nl> - } <nl> - <nl> - void UILayer : : setVisible ( bool visible ) <nl> - { <nl> - CCLayer : : setVisible ( visible ) ; <nl> - _rootWidget - > setVisible ( visible ) ; <nl> - } <nl> - <nl> - UIWidget * UILayer : : getWidgetByTag ( int tag ) <nl> - { <nl> - if ( ! _rootWidget ) <nl> - { <nl> - return nullptr ; <nl> - } <nl> - return UIHelper : : seekWidgetByTag ( _rootWidget , tag ) ; <nl> - } <nl> - <nl> - UIWidget * UILayer : : getWidgetByName ( const char * name ) <nl> - { <nl> - if ( ! _rootWidget ) <nl> - { <nl> - return nullptr ; <nl> - } <nl> - return UIHelper : : seekWidgetByName ( _rootWidget , name ) ; <nl> - } <nl> - <nl> - UIRootWidget * UILayer : : getRootWidget ( ) <nl> - { <nl> - return _rootWidget ; <nl> - } <nl> - <nl> - UIInputManager * UILayer : : getInputManager ( ) <nl> - { <nl> - return _inputManager ; <nl> - } <nl> - <nl> - void UILayer : : clear ( ) <nl> - { <nl> - _rootWidget - > removeAllChildren ( ) ; <nl> - } <nl> - <nl> - bool UILayer : : onTouchBegan ( Touch * pTouch , Event * pEvent ) <nl> - { <nl> - if ( _inputManager & & _inputManager - > onTouchBegan ( pTouch ) ) <nl> - { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - void UILayer : : onTouchMoved ( Touch * pTouch , Event * pEvent ) <nl> - { <nl> - _inputManager - > onTouchMoved ( pTouch ) ; <nl> - } <nl> - <nl> - void UILayer : : onTouchEnded ( Touch * pTouch , Event * pEvent ) <nl> - { <nl> - _inputManager - > onTouchEnd ( pTouch ) ; <nl> - } <nl> - <nl> - void UILayer : : onTouchCancelled ( Touch * pTouch , Event * pEvent ) <nl> - { <nl> - _inputManager - > onTouchCancelled ( pTouch ) ; <nl> - } <nl> - <nl> - } <nl> deleted file mode 100644 <nl> index b59ad9555195 . . 000000000000 <nl> mmm a / cocos / gui / UILayer . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all 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 , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - <nl> - # ifndef __UILAYER_H__ <nl> - # define __UILAYER_H__ <nl> - <nl> - # include " cocos2d . h " <nl> - # include " gui / UIRootWidget . h " <nl> - # include " gui / UIInputManager . h " <nl> - <nl> - namespace gui { <nl> - <nl> - <nl> - class UILayer : public cocos2d : : Layer <nl> - { <nl> - <nl> - public : <nl> - / * * <nl> - * Default constructor <nl> - * @ js ctor <nl> - * / <nl> - UILayer ( ) ; <nl> - <nl> - / * * <nl> - * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ UILayer ( ) ; <nl> - <nl> - / * * <nl> - * Allocates and initializes a widget . <nl> - * / <nl> - static UILayer * create ( void ) ; <nl> - <nl> - / / initializes state of uilayer . <nl> - virtual bool init ( ) override ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onEnter ( ) override ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onExit ( ) override ; <nl> - virtual void onEnterTransitionDidFinish ( ) override ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual bool onTouchBegan ( cocos2d : : Touch * pTouch , cocos2d : : Event * pEvent ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onTouchMoved ( cocos2d : : Touch * pTouch , cocos2d : : Event * pEvent ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onTouchEnded ( cocos2d : : Touch * pTouch , cocos2d : : Event * pEvent ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onTouchCancelled ( cocos2d : : Touch * pTouch , cocos2d : : Event * pEvent ) ; <nl> - <nl> - / * * <nl> - * Add a widget to UILayer , for drawing . <nl> - * <nl> - * @ param widget . <nl> - * / <nl> - void addWidget ( UIWidget * widget ) ; <nl> - <nl> - / * * <nl> - * Remove a widget from UILayer . <nl> - * <nl> - * @ param widget . <nl> - * <nl> - * @ param cleanup true if all running actions on all children widgets should be cleanup , false otherwise . <nl> - * / <nl> - void removeWidget ( UIWidget * widget ) ; <nl> - <nl> - / * * <nl> - * Sets whether the UILayer is visible <nl> - * <nl> - * The default value is true , a UILayer is default to visible <nl> - * <nl> - * @ param visible true if the UILayer is visible , false if the UILayer is hidden . <nl> - * / <nl> - virtual void setVisible ( bool visible ) override ; <nl> - <nl> - / * * <nl> - * Finds a widget whose tag is equal tag param from widget tree . <nl> - * <nl> - * @ param tag . <nl> - * / <nl> - UIWidget * getWidgetByTag ( int tag ) ; <nl> - <nl> - / * * <nl> - * Seek a widget whose name is equal name param from widget tree . <nl> - * <nl> - * @ param name . <nl> - * / <nl> - UIWidget * getWidgetByName ( const char * name ) ; <nl> - <nl> - / * * <nl> - * Gets UIInputManager . <nl> - * <nl> - * UIInputManager is the touch manager of UILayer . <nl> - * <nl> - * @ return UIInputManager . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - UIInputManager * getInputManager ( ) ; <nl> - <nl> - / * * <nl> - * Remove and clean up all of UILayer ' s widget . <nl> - * / <nl> - virtual void clear ( ) ; <nl> - <nl> - / * * <nl> - * Gets root widget of UILayer . <nl> - * <nl> - * @ return UIRootWidget , " UIRootWidget " is the root widget of UILayer . <nl> - * / <nl> - UIRootWidget * getRootWidget ( ) ; <nl> - <nl> - protected : <nl> - UIRootWidget * _rootWidget ; <nl> - UIInputManager * _inputManager ; <nl> - } ; <nl> - <nl> - } <nl> - <nl> - <nl> - <nl> - # endif / * defined ( __UILAYER_H__ ) * / <nl> mmm a / cocos / gui / UILayout . cpp <nl> ppp b / cocos / gui / UILayout . cpp <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> # include " gui / UILayout . h " <nl> - # include " gui / UILayer . h " <nl> # include " gui / UIHelper . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> - namespace gui { <nl> + NS_CC_BEGIN <nl> <nl> + namespace gui { <nl> + <nl> + # define BACKGROUNDIMAGEZ ( - 1 ) <nl> + # define BCAKGROUNDCOLORRENDERERZ ( - 2 ) <nl> <nl> - # define DYNAMIC_CAST_CLIPPINGLAYER dynamic_cast < UIRectClippingNode * > ( _renderer ) <nl> + static GLint g_sStencilBits = - 1 ; <nl> <nl> - UILayout : : UILayout ( ) : <nl> + Layout : : Layout ( ) : <nl> _clippingEnabled ( false ) , <nl> _backGroundScale9Enabled ( false ) , <nl> _backGroundImage ( nullptr ) , <nl> _backGroundImageFileName ( " " ) , <nl> - _backGroundImageCapInsets ( cocos2d : : Rect : : ZERO ) , <nl> + _backGroundImageCapInsets ( Rect : : ZERO ) , <nl> _colorType ( LAYOUT_COLOR_NONE ) , <nl> _bgImageTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _colorRender ( nullptr ) , <nl> _gradientRender ( nullptr ) , <nl> - _cColor ( cocos2d : : Color3B : : WHITE ) , <nl> - _gStartColor ( cocos2d : : Color3B : : WHITE ) , <nl> - _gEndColor ( cocos2d : : Color3B : : WHITE ) , <nl> - _alongVector ( cocos2d : : Point ( 0 . 0f , - 1 . 0f ) ) , <nl> + _cColor ( Color3B : : WHITE ) , <nl> + _gStartColor ( Color3B : : WHITE ) , <nl> + _gEndColor ( Color3B : : WHITE ) , <nl> + _alongVector ( Point ( 0 . 0f , - 1 . 0f ) ) , <nl> _cOpacity ( 255 ) , <nl> - _backGroundImageTextureSize ( cocos2d : : Size : : ZERO ) , <nl> - _layoutType ( LAYOUT_ABSOLUTE ) <nl> + _backGroundImageTextureSize ( Size : : ZERO ) , <nl> + _layoutType ( LAYOUT_ABSOLUTE ) , <nl> + _clippingType ( LAYOUT_CLIPPING_STENCIL ) , <nl> + _clippingStencil ( nullptr ) , <nl> + _handleScissor ( false ) , <nl> + _scissorRectDirty ( false ) , <nl> + _clippingRect ( Rect : : ZERO ) , <nl> + _clippingParent ( nullptr ) , <nl> + _doLayoutDirty ( true ) <nl> { <nl> _widgetType = WidgetTypeContainer ; <nl> } <nl> <nl> - UILayout : : ~ UILayout ( ) <nl> + Layout : : ~ Layout ( ) <nl> { <nl> } <nl> <nl> - UILayout * UILayout : : create ( ) <nl> + Layout * Layout : : create ( ) <nl> { <nl> - UILayout * layout = new UILayout ( ) ; <nl> + Layout * layout = new Layout ( ) ; <nl> if ( layout & & layout - > init ( ) ) <nl> { <nl> layout - > autorelease ( ) ; <nl> UILayout * UILayout : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UILayout : : init ( ) <nl> + bool Layout : : init ( ) <nl> + { <nl> + if ( Node : : init ( ) ) <nl> + { <nl> + initRenderer ( ) ; <nl> + setCascadeColorEnabled ( true ) ; <nl> + setCascadeOpacityEnabled ( true ) ; <nl> + setBright ( true ) ; <nl> + ignoreContentAdaptWithSize ( false ) ; <nl> + setSize ( Size : : ZERO ) ; <nl> + setAnchorPoint ( Point : : ZERO ) ; <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void Layout : : addChild ( Node * child ) <nl> { <nl> - _children = cocos2d : : Array : : create ( ) ; <nl> - _children - > retain ( ) ; <nl> - _layoutParameterDictionary = cocos2d : : Dictionary : : create ( ) ; <nl> - CC_SAFE_RETAIN ( _layoutParameterDictionary ) ; <nl> - initRenderer ( ) ; <nl> - _renderer - > retain ( ) ; <nl> - _renderer - > setZOrder ( _widgetZOrder ) ; <nl> - _renderer - > setCascadeColorEnabled ( false ) ; <nl> - _renderer - > setCascadeOpacityEnabled ( false ) ; <nl> - ignoreContentAdaptWithSize ( false ) ; <nl> - setSize ( cocos2d : : Size : : ZERO ) ; <nl> - setBright ( true ) ; <nl> - setAnchorPoint ( cocos2d : : Point ( 0 , 0 ) ) ; <nl> - _scheduler = cocos2d : : Director : : getInstance ( ) - > getScheduler ( ) ; <nl> - CC_SAFE_RETAIN ( _scheduler ) ; <nl> - return true ; <nl> + Widget : : addChild ( child ) ; <nl> } <nl> <nl> - void UILayout : : initRenderer ( ) <nl> + void Layout : : addChild ( Node * child , int zOrder ) <nl> { <nl> - _renderer = UIRectClippingNode : : create ( ) ; <nl> + Widget : : addChild ( child , zOrder ) ; <nl> } <nl> <nl> - bool UILayout : : addChild ( UIWidget * child ) <nl> + void Layout : : addChild ( Node * child , int zOrder , int tag ) <nl> { <nl> - supplyTheLayoutParameterLackToChild ( child ) ; <nl> - return UIWidget : : addChild ( child ) ; <nl> + supplyTheLayoutParameterLackToChild ( static_cast < Widget * > ( child ) ) ; <nl> + Widget : : addChild ( child , zOrder , tag ) ; <nl> + _doLayoutDirty = true ; <nl> } <nl> <nl> - bool UILayout : : isClippingEnabled ( ) <nl> + bool Layout : : isClippingEnabled ( ) <nl> { <nl> return _clippingEnabled ; <nl> } <nl> - <nl> - bool UILayout : : hitTest ( const cocos2d : : Point & pt ) <nl> + <nl> + void Layout : : visit ( ) <nl> { <nl> - cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( pt ) ; <nl> - cocos2d : : Rect bb = cocos2d : : Rect ( 0 . 0f , 0 . 0f , _size . width , _size . height ) ; <nl> - if ( nsp . x > = bb . origin . x & & nsp . x < = bb . origin . x + bb . size . width & & nsp . y > = bb . origin . y & & nsp . y < = bb . origin . y + bb . size . height ) <nl> + if ( ! _enabled ) <nl> { <nl> - return true ; <nl> + return ; <nl> + } <nl> + if ( _clippingEnabled ) <nl> + { <nl> + switch ( _clippingType ) <nl> + { <nl> + case LAYOUT_CLIPPING_STENCIL : <nl> + stencilClippingVisit ( ) ; <nl> + break ; <nl> + case LAYOUT_CLIPPING_SCISSOR : <nl> + scissorClippingVisit ( ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + Node : : visit ( ) ; <nl> + } <nl> + } <nl> + <nl> + void Layout : : sortAllChildren ( ) <nl> + { <nl> + Widget : : sortAllChildren ( ) ; <nl> + doLayout ( ) ; <nl> + } <nl> + <nl> + void Layout : : stencilClippingVisit ( ) <nl> + { <nl> + if ( ! _clippingStencil | | ! _clippingStencil - > isVisible ( ) ) <nl> + { <nl> + Node : : visit ( ) ; <nl> + return ; <nl> + } <nl> + if ( g_sStencilBits < 1 ) <nl> + { <nl> + Node : : visit ( ) ; <nl> + return ; <nl> + } <nl> + static GLint layer = - 1 ; <nl> + if ( layer + 1 = = g_sStencilBits ) <nl> + { <nl> + static bool once = true ; <nl> + if ( once ) <nl> + { <nl> + char warning [ 200 ] = { 0 } ; <nl> + snprintf ( warning , sizeof ( warning ) , " Nesting more than % d stencils is not supported . Everything will be drawn without stencil for this node and its childs . " , g_sStencilBits ) ; <nl> + CCLOG ( " % s " , warning ) ; <nl> + <nl> + once = false ; <nl> + } <nl> + Node : : visit ( ) ; <nl> + return ; <nl> + } <nl> + layer + + ; <nl> + GLint mask_layer = 0x1 < < layer ; <nl> + GLint mask_layer_l = mask_layer - 1 ; <nl> + GLint mask_layer_le = mask_layer | mask_layer_l ; <nl> + GLboolean currentStencilEnabled = GL_FALSE ; <nl> + GLuint currentStencilWriteMask = ~ 0 ; <nl> + GLenum currentStencilFunc = GL_ALWAYS ; <nl> + GLint currentStencilRef = 0 ; <nl> + GLuint currentStencilValueMask = ~ 0 ; <nl> + GLenum currentStencilFail = GL_KEEP ; <nl> + GLenum currentStencilPassDepthFail = GL_KEEP ; <nl> + GLenum currentStencilPassDepthPass = GL_KEEP ; <nl> + currentStencilEnabled = glIsEnabled ( GL_STENCIL_TEST ) ; <nl> + glGetIntegerv ( GL_STENCIL_WRITEMASK , ( GLint * ) & currentStencilWriteMask ) ; <nl> + glGetIntegerv ( GL_STENCIL_FUNC , ( GLint * ) & currentStencilFunc ) ; <nl> + glGetIntegerv ( GL_STENCIL_REF , & currentStencilRef ) ; <nl> + glGetIntegerv ( GL_STENCIL_VALUE_MASK , ( GLint * ) & currentStencilValueMask ) ; <nl> + glGetIntegerv ( GL_STENCIL_FAIL , ( GLint * ) & currentStencilFail ) ; <nl> + glGetIntegerv ( GL_STENCIL_PASS_DEPTH_FAIL , ( GLint * ) & currentStencilPassDepthFail ) ; <nl> + glGetIntegerv ( GL_STENCIL_PASS_DEPTH_PASS , ( GLint * ) & currentStencilPassDepthPass ) ; <nl> + glEnable ( GL_STENCIL_TEST ) ; <nl> + CHECK_GL_ERROR_DEBUG ( ) ; <nl> + glStencilMask ( mask_layer ) ; <nl> + GLboolean currentDepthWriteMask = GL_TRUE ; <nl> + glGetBooleanv ( GL_DEPTH_WRITEMASK , & currentDepthWriteMask ) ; <nl> + glDepthMask ( GL_FALSE ) ; <nl> + glStencilFunc ( GL_NEVER , mask_layer , mask_layer ) ; <nl> + glStencilOp ( GL_ZERO , GL_KEEP , GL_KEEP ) ; <nl> + kmGLMatrixMode ( KM_GL_MODELVIEW ) ; <nl> + kmGLPushMatrix ( ) ; <nl> + kmGLLoadIdentity ( ) ; <nl> + kmGLMatrixMode ( KM_GL_PROJECTION ) ; <nl> + kmGLPushMatrix ( ) ; <nl> + kmGLLoadIdentity ( ) ; <nl> + DrawPrimitives : : drawSolidRect ( Point ( - 1 , - 1 ) , Point ( 1 , 1 ) , Color4F ( 1 , 1 , 1 , 1 ) ) ; <nl> + kmGLMatrixMode ( KM_GL_PROJECTION ) ; <nl> + kmGLPopMatrix ( ) ; <nl> + kmGLMatrixMode ( KM_GL_MODELVIEW ) ; <nl> + kmGLPopMatrix ( ) ; <nl> + glStencilFunc ( GL_NEVER , mask_layer , mask_layer ) ; <nl> + glStencilOp ( GL_REPLACE , GL_KEEP , GL_KEEP ) ; <nl> + # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_MAC | | CC_TARGET_PLATFORM = = CC_PLATFORM_WINDOWS | | CC_TARGET_PLATFORM = = CC_PLATFORM_LINUX ) <nl> + GLboolean currentAlphaTestEnabled = GL_FALSE ; <nl> + GLenum currentAlphaTestFunc = GL_ALWAYS ; <nl> + GLclampf currentAlphaTestRef = 1 ; <nl> + # endif <nl> + kmGLPushMatrix ( ) ; <nl> + transform ( ) ; <nl> + _clippingStencil - > visit ( ) ; <nl> + kmGLPopMatrix ( ) ; <nl> + glDepthMask ( currentDepthWriteMask ) ; <nl> + glStencilFunc ( GL_EQUAL , mask_layer_le , mask_layer_le ) ; <nl> + glStencilOp ( GL_KEEP , GL_KEEP , GL_KEEP ) ; <nl> + Node : : visit ( ) ; <nl> + glStencilFunc ( currentStencilFunc , currentStencilRef , currentStencilValueMask ) ; <nl> + glStencilOp ( currentStencilFail , currentStencilPassDepthFail , currentStencilPassDepthPass ) ; <nl> + glStencilMask ( currentStencilWriteMask ) ; <nl> + if ( ! currentStencilEnabled ) <nl> + { <nl> + glDisable ( GL_STENCIL_TEST ) ; <nl> + } <nl> + layer - - ; <nl> + } <nl> + <nl> + void Layout : : scissorClippingVisit ( ) <nl> + { <nl> + Rect clippingRect = getClippingRect ( ) ; <nl> + if ( _handleScissor ) <nl> + { <nl> + glEnable ( GL_SCISSOR_TEST ) ; <nl> + } <nl> + EGLView : : getInstance ( ) - > setScissorInPoints ( clippingRect . origin . x , clippingRect . origin . y , clippingRect . size . width , clippingRect . size . height ) ; <nl> + Node : : visit ( ) ; <nl> + if ( _handleScissor ) <nl> + { <nl> + glDisable ( GL_SCISSOR_TEST ) ; <nl> } <nl> - return false ; <nl> } <nl> <nl> - void UILayout : : setClippingEnabled ( bool able ) <nl> + void Layout : : setClippingEnabled ( bool able ) <nl> { <nl> + if ( able = = _clippingEnabled ) <nl> + { <nl> + return ; <nl> + } <nl> _clippingEnabled = able ; <nl> - DYNAMIC_CAST_CLIPPINGLAYER - > setClippingEnabled ( able ) ; <nl> + switch ( _clippingType ) <nl> + { <nl> + case LAYOUT_CLIPPING_STENCIL : <nl> + if ( able ) <nl> + { <nl> + glGetIntegerv ( GL_STENCIL_BITS , & g_sStencilBits ) ; <nl> + _clippingStencil = DrawNode : : create ( ) ; <nl> + _clippingStencil - > onEnter ( ) ; <nl> + _clippingStencil - > retain ( ) ; <nl> + setStencilClippingSize ( _size ) ; <nl> + } <nl> + else <nl> + { <nl> + _clippingStencil - > onExit ( ) ; <nl> + _clippingStencil - > release ( ) ; <nl> + _clippingStencil = nullptr ; <nl> + } <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> } <nl> - <nl> - void UILayout : : onSizeChanged ( ) <nl> + <nl> + void Layout : : setClippingType ( LayoutClippingType type ) <nl> + { <nl> + if ( type = = _clippingType ) <nl> + { <nl> + return ; <nl> + } <nl> + bool clippingEnabled = isClippingEnabled ( ) ; <nl> + setClippingEnabled ( false ) ; <nl> + _clippingType = type ; <nl> + setClippingEnabled ( clippingEnabled ) ; <nl> + } <nl> + <nl> + void Layout : : setStencilClippingSize ( const Size & size ) <nl> + { <nl> + if ( _clippingEnabled & & _clippingType = = LAYOUT_CLIPPING_STENCIL ) <nl> + { <nl> + Point rect [ 4 ] ; <nl> + rect [ 0 ] = Point : : ZERO ; <nl> + rect [ 1 ] = Point ( _size . width , 0 ) ; <nl> + rect [ 2 ] = Point ( _size . width , _size . height ) ; <nl> + rect [ 3 ] = Point ( 0 , _size . height ) ; <nl> + Color4F green ( 0 , 1 , 0 , 1 ) ; <nl> + _clippingStencil - > clear ( ) ; <nl> + _clippingStencil - > drawPolygon ( rect , 4 , green , 0 , green ) ; <nl> + } <nl> + } <nl> + <nl> + const Rect & Layout : : getClippingRect ( ) <nl> { <nl> - DYNAMIC_CAST_CLIPPINGLAYER - > setClippingSize ( _size ) ; <nl> - if ( strcmp ( getDescription ( ) , " Layout " ) = = 0 ) <nl> + _handleScissor = true ; <nl> + Point worldPos = convertToWorldSpace ( Point : : ZERO ) ; <nl> + AffineTransform t = nodeToWorldTransform ( ) ; <nl> + float scissorWidth = _size . width * t . a ; <nl> + float scissorHeight = _size . height * t . d ; <nl> + Rect parentClippingRect ; <nl> + Layout * parent = this ; <nl> + bool firstClippingParentFounded = false ; <nl> + while ( parent ) <nl> + { <nl> + parent = dynamic_cast < Layout * > ( parent - > getParent ( ) ) ; <nl> + if ( parent ) <nl> + { <nl> + if ( parent - > isClippingEnabled ( ) ) <nl> + { <nl> + if ( ! firstClippingParentFounded ) <nl> + { <nl> + _clippingParent = parent ; <nl> + firstClippingParentFounded = true ; <nl> + } <nl> + <nl> + if ( parent - > _clippingType = = LAYOUT_CLIPPING_SCISSOR ) <nl> + { <nl> + _handleScissor = false ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( _clippingParent ) <nl> { <nl> - cocos2d : : ccArray * arrayChildren = _children - > data ; <nl> - ssize_t length = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < length ; + + i ) <nl> + parentClippingRect = _clippingParent - > getClippingRect ( ) ; <nl> + float finalX = worldPos . x - ( scissorWidth * _anchorPoint . x ) ; <nl> + float finalY = worldPos . y - ( scissorHeight * _anchorPoint . y ) ; <nl> + float finalWidth = scissorWidth ; <nl> + float finalHeight = scissorHeight ; <nl> + <nl> + float leftOffset = worldPos . x - parentClippingRect . origin . x ; <nl> + if ( leftOffset < 0 . 0f ) <nl> + { <nl> + finalX = parentClippingRect . origin . x ; <nl> + finalWidth + = leftOffset ; <nl> + } <nl> + float rightOffset = ( worldPos . x + scissorWidth ) - ( parentClippingRect . origin . x + parentClippingRect . size . width ) ; <nl> + if ( rightOffset > 0 . 0f ) <nl> + { <nl> + finalWidth - = rightOffset ; <nl> + } <nl> + float topOffset = ( worldPos . y + scissorHeight ) - ( parentClippingRect . origin . y + parentClippingRect . size . height ) ; <nl> + if ( topOffset > 0 . 0f ) <nl> + { <nl> + finalHeight - = topOffset ; <nl> + } <nl> + float bottomOffset = worldPos . y - parentClippingRect . origin . y ; <nl> + if ( bottomOffset < 0 . 0f ) <nl> + { <nl> + finalY = parentClippingRect . origin . x ; <nl> + finalHeight + = bottomOffset ; <nl> + } <nl> + if ( finalWidth < 0 . 0f ) <nl> + { <nl> + finalWidth = 0 . 0f ; <nl> + } <nl> + if ( finalHeight < 0 . 0f ) <nl> { <nl> - UIWidget * child = ( UIWidget * ) arrayChildren - > arr [ i ] ; <nl> - child - > updateSizeAndPosition ( ) ; <nl> + finalHeight = 0 . 0f ; <nl> } <nl> - doLayout ( ) ; <nl> + _clippingRect . origin . x = finalX ; <nl> + _clippingRect . origin . y = finalY ; <nl> + _clippingRect . size . width = finalWidth ; <nl> + _clippingRect . size . height = finalHeight ; <nl> } <nl> + else <nl> + { <nl> + _clippingRect . origin . x = worldPos . x - ( scissorWidth * _anchorPoint . x ) ; <nl> + _clippingRect . origin . y = worldPos . y - ( scissorHeight * _anchorPoint . y ) ; <nl> + _clippingRect . size . width = scissorWidth ; <nl> + _clippingRect . size . height = scissorHeight ; <nl> + } <nl> + return _clippingRect ; <nl> + } <nl> + <nl> + void Layout : : onSizeChanged ( ) <nl> + { <nl> + Widget : : onSizeChanged ( ) ; <nl> + setStencilClippingSize ( _size ) ; <nl> + _doLayoutDirty = true ; <nl> if ( _backGroundImage ) <nl> { <nl> - _backGroundImage - > setPosition ( cocos2d : : Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> + _backGroundImage - > setPosition ( Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> if ( _backGroundScale9Enabled & & _backGroundImage ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> } <nl> } <nl> if ( _colorRender ) <nl> void UILayout : : onSizeChanged ( ) <nl> } <nl> } <nl> <nl> - void UILayout : : setBackGroundImageScale9Enabled ( bool able ) <nl> + void Layout : : setBackGroundImageScale9Enabled ( bool able ) <nl> { <nl> if ( _backGroundScale9Enabled = = able ) <nl> { <nl> return ; <nl> } <nl> - _renderer - > removeChild ( _backGroundImage , true ) ; <nl> + Node : : removeChild ( _backGroundImage ) ; <nl> _backGroundImage = nullptr ; <nl> _backGroundScale9Enabled = able ; <nl> if ( _backGroundScale9Enabled ) <nl> { <nl> - _backGroundImage = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> - _renderer - > addChild ( _backGroundImage ) ; <nl> + _backGroundImage = extension : : Scale9Sprite : : create ( ) ; <nl> + Node : : addChild ( _backGroundImage , BACKGROUNDIMAGEZ , - 1 ) ; <nl> } <nl> else <nl> { <nl> - _backGroundImage = cocos2d : : Sprite : : create ( ) ; <nl> - _renderer - > addChild ( _backGroundImage ) ; <nl> + _backGroundImage = Sprite : : create ( ) ; <nl> + Node : : addChild ( _backGroundImage , BACKGROUNDIMAGEZ , - 1 ) ; <nl> } <nl> - _backGroundImage - > setZOrder ( - 1 ) ; <nl> - setBackGroundImage ( _backGroundImageFileName . c_str ( ) , _bgImageTexType ) ; <nl> + setBackGroundImage ( _backGroundImageFileName . c_str ( ) , _bgImageTexType ) ; <nl> setBackGroundImageCapInsets ( _backGroundImageCapInsets ) ; <nl> } <nl> <nl> - void UILayout : : setBackGroundImage ( const char * fileName , TextureResType texType ) <nl> + void Layout : : setBackGroundImage ( const char * fileName , TextureResType texType ) <nl> { <nl> if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> { <nl> void UILayout : : setBackGroundImage ( const char * fileName , TextureResType texType ) <nl> _bgImageTexType = texType ; <nl> if ( _backGroundScale9Enabled ) <nl> { <nl> + extension : : Scale9Sprite * bgiScale9 = static_cast < extension : : Scale9Sprite * > ( _backGroundImage ) ; <nl> switch ( _bgImageTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > initWithFile ( fileName ) ; <nl> + bgiScale9 - > initWithFile ( fileName ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > initWithSpriteFrameName ( fileName ) ; <nl> + bgiScale9 - > initWithSpriteFrameName ( fileName ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> + bgiScale9 - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> switch ( _bgImageTexType ) <nl> { <nl> case UI_TEX_TYPE_LOCAL : <nl> - dynamic_cast < cocos2d : : Sprite * > ( _backGroundImage ) - > setTexture ( fileName ) ; <nl> + static_cast < Sprite * > ( _backGroundImage ) - > setTexture ( fileName ) ; <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> - dynamic_cast < cocos2d : : Sprite * > ( _backGroundImage ) - > setSpriteFrame ( fileName ) ; <nl> + static_cast < Sprite * > ( _backGroundImage ) - > setSpriteFrame ( fileName ) ; <nl> break ; <nl> default : <nl> break ; <nl> void UILayout : : setBackGroundImage ( const char * fileName , TextureResType texType ) <nl> } <nl> if ( _backGroundScale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setOpacity ( getOpacity ( ) ) ; <nl> + extension : : Scale9Sprite * bgiScale9 = static_cast < extension : : Scale9Sprite * > ( _backGroundImage ) ; <nl> + bgiScale9 - > setColor ( getColor ( ) ) ; <nl> + bgiScale9 - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _backGroundImage ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _backGroundImage ) - > setOpacity ( getOpacity ( ) ) ; <nl> + Sprite * bgiScale9 = static_cast < Sprite * > ( _backGroundImage ) ; <nl> + bgiScale9 - > setColor ( getColor ( ) ) ; <nl> + bgiScale9 - > setOpacity ( getOpacity ( ) ) ; <nl> } <nl> _backGroundImageTextureSize = _backGroundImage - > getContentSize ( ) ; <nl> - _backGroundImage - > setPosition ( cocos2d : : Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> + _backGroundImage - > setPosition ( Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> } <nl> <nl> - void UILayout : : setBackGroundImageCapInsets ( const cocos2d : : Rect & capInsets ) <nl> + void Layout : : setBackGroundImageCapInsets ( const Rect & capInsets ) <nl> { <nl> _backGroundImageCapInsets = capInsets ; <nl> if ( _backGroundScale9Enabled & & _backGroundImage ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setCapInsets ( capInsets ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _backGroundImage ) - > setCapInsets ( capInsets ) ; <nl> } <nl> } <nl> <nl> - void UILayout : : supplyTheLayoutParameterLackToChild ( UIWidget * child ) <nl> + void Layout : : supplyTheLayoutParameterLackToChild ( Widget * child ) <nl> { <nl> if ( ! child ) <nl> { <nl> void UILayout : : supplyTheLayoutParameterLackToChild ( UIWidget * child ) <nl> case LAYOUT_LINEAR_HORIZONTAL : <nl> case LAYOUT_LINEAR_VERTICAL : <nl> { <nl> - UILinearLayoutParameter * layoutParameter = dynamic_cast < UILinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> if ( ! layoutParameter ) <nl> { <nl> - child - > setLayoutParameter ( UILinearLayoutParameter : : create ( ) ) ; <nl> + child - > setLayoutParameter ( LinearLayoutParameter : : create ( ) ) ; <nl> } <nl> break ; <nl> } <nl> case LAYOUT_RELATIVE : <nl> { <nl> - UIRelativeLayoutParameter * layoutParameter = dynamic_cast < UIRelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> if ( ! layoutParameter ) <nl> { <nl> - child - > setLayoutParameter ( UIRelativeLayoutParameter : : create ( ) ) ; <nl> + child - > setLayoutParameter ( RelativeLayoutParameter : : create ( ) ) ; <nl> } <nl> break ; <nl> } <nl> void UILayout : : supplyTheLayoutParameterLackToChild ( UIWidget * child ) <nl> } <nl> } <nl> <nl> - void UILayout : : addBackGroundImage ( ) <nl> + void Layout : : addBackGroundImage ( ) <nl> { <nl> if ( _backGroundScale9Enabled ) <nl> { <nl> - _backGroundImage = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _backGroundImage = extension : : Scale9Sprite : : create ( ) ; <nl> _backGroundImage - > setZOrder ( - 1 ) ; <nl> - _renderer - > addChild ( _backGroundImage ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> + Node : : addChild ( _backGroundImage , BACKGROUNDIMAGEZ , - 1 ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _backGroundImage ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - _backGroundImage = cocos2d : : Sprite : : create ( ) ; <nl> + _backGroundImage = Sprite : : create ( ) ; <nl> _backGroundImage - > setZOrder ( - 1 ) ; <nl> - _renderer - > addChild ( _backGroundImage ) ; <nl> + Node : : addChild ( _backGroundImage , BACKGROUNDIMAGEZ , - 1 ) ; <nl> } <nl> - _backGroundImage - > setPosition ( cocos2d : : Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> + _backGroundImage - > setPosition ( Point ( _size . width / 2 . 0f , _size . height / 2 . 0f ) ) ; <nl> } <nl> <nl> - void UILayout : : removeBackGroundImage ( ) <nl> + void Layout : : removeBackGroundImage ( ) <nl> { <nl> if ( ! _backGroundImage ) <nl> { <nl> return ; <nl> } <nl> - _renderer - > removeChild ( _backGroundImage , true ) ; <nl> + Node : : removeChild ( _backGroundImage ) ; <nl> _backGroundImage = nullptr ; <nl> _backGroundImageFileName = " " ; <nl> - _backGroundImageTextureSize = cocos2d : : Size : : ZERO ; <nl> + _backGroundImageTextureSize = Size : : ZERO ; <nl> } <nl> <nl> - void UILayout : : setBackGroundColorType ( LayoutBackGroundColorType type ) <nl> + void Layout : : setBackGroundColorType ( LayoutBackGroundColorType type ) <nl> { <nl> if ( _colorType = = type ) <nl> { <nl> void UILayout : : setBackGroundColorType ( LayoutBackGroundColorType type ) <nl> case LAYOUT_COLOR_NONE : <nl> if ( _colorRender ) <nl> { <nl> - _renderer - > removeChild ( _colorRender , true ) ; <nl> + Node : : removeChild ( _colorRender ) ; <nl> _colorRender = nullptr ; <nl> } <nl> if ( _gradientRender ) <nl> { <nl> - _renderer - > removeChild ( _gradientRender , true ) ; <nl> + Node : : removeChild ( _gradientRender ) ; <nl> _gradientRender = nullptr ; <nl> } <nl> break ; <nl> case LAYOUT_COLOR_SOLID : <nl> if ( _colorRender ) <nl> { <nl> - _renderer - > removeChild ( _colorRender , true ) ; <nl> + Node : : removeChild ( _colorRender ) ; <nl> _colorRender = nullptr ; <nl> } <nl> break ; <nl> case LAYOUT_COLOR_GRADIENT : <nl> if ( _gradientRender ) <nl> { <nl> - _renderer - > removeChild ( _gradientRender , true ) ; <nl> + Node : : removeChild ( _gradientRender ) ; <nl> _gradientRender = nullptr ; <nl> } <nl> break ; <nl> void UILayout : : setBackGroundColorType ( LayoutBackGroundColorType type ) <nl> case LAYOUT_COLOR_NONE : <nl> break ; <nl> case LAYOUT_COLOR_SOLID : <nl> - _colorRender = cocos2d : : LayerColor : : create ( ) ; <nl> + _colorRender = LayerColor : : create ( ) ; <nl> _colorRender - > setContentSize ( _size ) ; <nl> _colorRender - > setOpacity ( _cOpacity ) ; <nl> _colorRender - > setColor ( _cColor ) ; <nl> - _renderer - > addChild ( _colorRender , - 2 ) ; <nl> + Node : : addChild ( _colorRender , BACKGROUNDIMAGEZ , - 1 ) ; <nl> break ; <nl> case LAYOUT_COLOR_GRADIENT : <nl> - _gradientRender = cocos2d : : LayerGradient : : create ( ) ; <nl> + _gradientRender = LayerGradient : : create ( ) ; <nl> _gradientRender - > setContentSize ( _size ) ; <nl> _gradientRender - > setOpacity ( _cOpacity ) ; <nl> _gradientRender - > setStartColor ( _gStartColor ) ; <nl> _gradientRender - > setEndColor ( _gEndColor ) ; <nl> _gradientRender - > setVector ( _alongVector ) ; <nl> - _renderer - > addChild ( _gradientRender , - 2 ) ; <nl> + Node : : addChild ( _gradientRender , BACKGROUNDIMAGEZ , - 1 ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> } <nl> <nl> - void UILayout : : setBackGroundColor ( const cocos2d : : Color3B & color ) <nl> + void Layout : : setBackGroundColor ( const Color3B & color ) <nl> { <nl> _cColor = color ; <nl> if ( _colorRender ) <nl> void UILayout : : setBackGroundColor ( const cocos2d : : Color3B & color ) <nl> } <nl> } <nl> <nl> - void UILayout : : setBackGroundColor ( const cocos2d : : Color3B & startColor , const cocos2d : : Color3B & endColor ) <nl> + void Layout : : setBackGroundColor ( const Color3B & startColor , const Color3B & endColor ) <nl> { <nl> _gStartColor = startColor ; <nl> if ( _gradientRender ) <nl> void UILayout : : setBackGroundColor ( const cocos2d : : Color3B & startColor , const coco <nl> } <nl> } <nl> <nl> - void UILayout : : setBackGroundColorOpacity ( int opacity ) <nl> + void Layout : : setBackGroundColorOpacity ( int opacity ) <nl> { <nl> _cOpacity = opacity ; <nl> switch ( _colorType ) <nl> void UILayout : : setBackGroundColorOpacity ( int opacity ) <nl> } <nl> } <nl> <nl> - void UILayout : : setBackGroundColorVector ( const cocos2d : : Point & vector ) <nl> + void Layout : : setBackGroundColorVector ( const Point & vector ) <nl> { <nl> _alongVector = vector ; <nl> if ( _gradientRender ) <nl> void UILayout : : setBackGroundColorVector ( const cocos2d : : Point & vector ) <nl> } <nl> } <nl> <nl> - void UILayout : : setColor ( const cocos2d : : Color3B & color ) <nl> - { <nl> - UIWidget : : setColor ( color ) ; <nl> - if ( _backGroundImage ) <nl> - { <nl> - _backGroundImage - > setColor ( color ) ; <nl> - } <nl> - } <nl> - <nl> - void UILayout : : setOpacity ( int opacity ) <nl> - { <nl> - UIWidget : : setOpacity ( opacity ) ; <nl> - if ( _backGroundImage ) <nl> - { <nl> - _backGroundImage - > setOpacity ( opacity ) ; <nl> - } <nl> - } <nl> - <nl> - const cocos2d : : Size & UILayout : : getBackGroundImageTextureSize ( ) const <nl> + const Size & Layout : : getBackGroundImageTextureSize ( ) const <nl> { <nl> return _backGroundImageTextureSize ; <nl> } <nl> <nl> - const cocos2d : : Size & UILayout : : getContentSize ( ) const <nl> - { <nl> - return _renderer - > getContentSize ( ) ; <nl> - } <nl> - <nl> - void UILayout : : setLayoutType ( LayoutType type ) <nl> + void Layout : : setLayoutType ( LayoutType type ) <nl> { <nl> _layoutType = type ; <nl> - <nl> - cocos2d : : ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> - ssize_t length = layoutChildrenArray - > num ; <nl> - for ( int i = 0 ; i < length ; i + + ) <nl> + for ( auto & child : _widgetChildren ) <nl> { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> - supplyTheLayoutParameterLackToChild ( child ) ; <nl> + if ( child ) <nl> + { <nl> + supplyTheLayoutParameterLackToChild ( static_cast < Widget * > ( child ) ) ; <nl> + } <nl> } <nl> + _doLayoutDirty = true ; <nl> } <nl> <nl> - LayoutType UILayout : : getLayoutType ( ) const <nl> + LayoutType Layout : : getLayoutType ( ) const <nl> { <nl> return _layoutType ; <nl> } <nl> <nl> - void UILayout : : doLayout ( ) <nl> + void Layout : : doLayout ( ) <nl> { <nl> + if ( ! _doLayoutDirty ) <nl> + { <nl> + return ; <nl> + } <nl> switch ( _layoutType ) <nl> { <nl> case LAYOUT_ABSOLUTE : <nl> break ; <nl> case LAYOUT_LINEAR_VERTICAL : <nl> { <nl> - cocos2d : : ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> - ssize_t length = layoutChildrenArray - > num ; <nl> - cocos2d : : Size layoutSize = getSize ( ) ; <nl> + int length = _widgetChildren . size ( ) ; <nl> + Size layoutSize = getSize ( ) ; <nl> float topBoundary = layoutSize . height ; <nl> for ( int i = 0 ; i < length ; + + i ) <nl> { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> - UILinearLayoutParameter * layoutParameter = dynamic_cast < UILinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + Widget * child = static_cast < Widget * > ( _widgetChildren . at ( i ) ) ; <nl> + LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> <nl> if ( layoutParameter ) <nl> { <nl> - UILinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> - cocos2d : : Point ap = child - > getAnchorPoint ( ) ; <nl> - cocos2d : : Size cs = child - > getSize ( ) ; <nl> + LinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> + Point ap = child - > getAnchorPoint ( ) ; <nl> + Size cs = child - > getSize ( ) ; <nl> float finalPosX = ap . x * cs . width ; <nl> float finalPosY = topBoundary - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> switch ( childGravity ) <nl> void UILayout : : doLayout ( ) <nl> default : <nl> break ; <nl> } <nl> - UIMargin mg = layoutParameter - > getMargin ( ) ; <nl> + Margin mg = layoutParameter - > getMargin ( ) ; <nl> finalPosX + = mg . left ; <nl> finalPosY - = mg . top ; <nl> - child - > setPosition ( cocos2d : : Point ( finalPosX , finalPosY ) ) ; <nl> + child - > setPosition ( Point ( finalPosX , finalPosY ) ) ; <nl> topBoundary = child - > getBottomInParent ( ) - mg . bottom ; <nl> } <nl> } <nl> void UILayout : : doLayout ( ) <nl> } <nl> case LAYOUT_LINEAR_HORIZONTAL : <nl> { <nl> - cocos2d : : ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> - ssize_t length = layoutChildrenArray - > num ; <nl> - cocos2d : : Size layoutSize = getSize ( ) ; <nl> + int length = _widgetChildren . size ( ) ; <nl> + Size layoutSize = getSize ( ) ; <nl> float leftBoundary = 0 . 0f ; <nl> for ( int i = 0 ; i < length ; + + i ) <nl> { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> - UILinearLayoutParameter * layoutParameter = dynamic_cast < UILinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + Widget * child = static_cast < Widget * > ( _widgetChildren . at ( i ) ) ; <nl> + LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> <nl> if ( layoutParameter ) <nl> { <nl> - UILinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> - cocos2d : : Point ap = child - > getAnchorPoint ( ) ; <nl> - cocos2d : : Size cs = child - > getSize ( ) ; <nl> + LinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> + Point ap = child - > getAnchorPoint ( ) ; <nl> + Size cs = child - > getSize ( ) ; <nl> float finalPosX = leftBoundary + ( ap . x * cs . width ) ; <nl> float finalPosY = layoutSize . height - ( 1 . 0f - ap . y ) * cs . height ; <nl> switch ( childGravity ) <nl> void UILayout : : doLayout ( ) <nl> default : <nl> break ; <nl> } <nl> - UIMargin mg = layoutParameter - > getMargin ( ) ; <nl> + Margin mg = layoutParameter - > getMargin ( ) ; <nl> finalPosX + = mg . left ; <nl> finalPosY - = mg . top ; <nl> - child - > setPosition ( cocos2d : : Point ( finalPosX , finalPosY ) ) ; <nl> + child - > setPosition ( Point ( finalPosX , finalPosY ) ) ; <nl> leftBoundary = child - > getRightInParent ( ) + mg . right ; <nl> } <nl> } <nl> void UILayout : : doLayout ( ) <nl> } <nl> case LAYOUT_RELATIVE : <nl> { <nl> - cocos2d : : ccArray * layoutChildrenArray = getChildren ( ) - > data ; <nl> - ssize_t length , unlayoutChildCount ; <nl> - length = unlayoutChildCount = layoutChildrenArray - > num ; <nl> - cocos2d : : Size layoutSize = getSize ( ) ; <nl> + int length = _widgetChildren . size ( ) ; <nl> + int unlayoutChildCount = length ; <nl> + Size layoutSize = getSize ( ) ; <nl> <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> - UIRelativeLayoutParameter * layoutParameter = dynamic_cast < UIRelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + Widget * child = static_cast < Widget * > ( _widgetChildren . at ( i ) ) ; <nl> + RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> layoutParameter - > _put = false ; <nl> } <nl> <nl> void UILayout : : doLayout ( ) <nl> { <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( layoutChildrenArray - > arr [ i ] ) ; <nl> - UIRelativeLayoutParameter * layoutParameter = dynamic_cast < UIRelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + Widget * child = static_cast < Widget * > ( _widgetChildren . at ( i ) ) ; <nl> + RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> <nl> if ( layoutParameter ) <nl> { <nl> void UILayout : : doLayout ( ) <nl> { <nl> continue ; <nl> } <nl> - cocos2d : : Point ap = child - > getAnchorPoint ( ) ; <nl> - cocos2d : : Size cs = child - > getSize ( ) ; <nl> - UIRelativeAlign align = layoutParameter - > getAlign ( ) ; <nl> + Point ap = child - > getAnchorPoint ( ) ; <nl> + Size cs = child - > getSize ( ) ; <nl> + RelativeAlign align = layoutParameter - > getAlign ( ) ; <nl> const char * relativeName = layoutParameter - > getRelativeToWidgetName ( ) ; <nl> - UIWidget * relativeWidget = nullptr ; <nl> - UIRelativeLayoutParameter * relativeWidgetLP = nullptr ; <nl> + Widget * relativeWidget = nullptr ; <nl> + RelativeLayoutParameter * relativeWidgetLP = nullptr ; <nl> float finalPosX = 0 . 0f ; <nl> float finalPosY = 0 . 0f ; <nl> if ( relativeName & & strcmp ( relativeName , " " ) ) <nl> void UILayout : : doLayout ( ) <nl> relativeWidget = UIHelper : : seekWidgetByRelativeName ( this , relativeName ) ; <nl> if ( relativeWidget ) <nl> { <nl> - relativeWidgetLP = dynamic_cast < UIRelativeLayoutParameter * > ( relativeWidget - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> + relativeWidgetLP = dynamic_cast < RelativeLayoutParameter * > ( relativeWidget - > getLayoutParameter ( LAYOUT_PARAMETER_RELATIVE ) ) ; <nl> } <nl> } <nl> switch ( align ) <nl> void UILayout : : doLayout ( ) <nl> { <nl> continue ; <nl> } <nl> - cocos2d : : Size rbs = relativeWidget - > getSize ( ) ; <nl> + Size rbs = relativeWidget - > getSize ( ) ; <nl> float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> <nl> finalPosY = locationBottom + ap . y * cs . height ; <nl> void UILayout : : doLayout ( ) <nl> { <nl> continue ; <nl> } <nl> - cocos2d : : Size rbs = relativeWidget - > getSize ( ) ; <nl> + Size rbs = relativeWidget - > getSize ( ) ; <nl> float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> <nl> void UILayout : : doLayout ( ) <nl> { <nl> continue ; <nl> } <nl> - cocos2d : : Size rbs = relativeWidget - > getSize ( ) ; <nl> + Size rbs = relativeWidget - > getSize ( ) ; <nl> float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> finalPosX = locationLeft + ap . x * cs . width ; <nl> <nl> void UILayout : : doLayout ( ) <nl> { <nl> continue ; <nl> } <nl> - cocos2d : : Size rbs = relativeWidget - > getSize ( ) ; <nl> + Size rbs = relativeWidget - > getSize ( ) ; <nl> float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> <nl> finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> void UILayout : : doLayout ( ) <nl> default : <nl> break ; <nl> } <nl> - UIMargin relativeWidgetMargin ; <nl> - UIMargin mg = layoutParameter - > getMargin ( ) ; <nl> + Margin relativeWidgetMargin ; <nl> + Margin mg = layoutParameter - > getMargin ( ) ; <nl> if ( relativeWidgetLP ) <nl> { <nl> relativeWidgetMargin = relativeWidgetLP - > getMargin ( ) ; <nl> void UILayout : : doLayout ( ) <nl> default : <nl> break ; <nl> } <nl> - child - > setPosition ( cocos2d : : Point ( finalPosX , finalPosY ) ) ; <nl> + child - > setPosition ( Point ( finalPosX , finalPosY ) ) ; <nl> layoutParameter - > _put = true ; <nl> unlayoutChildCount - - ; <nl> } <nl> void UILayout : : doLayout ( ) <nl> default : <nl> break ; <nl> } <nl> + _doLayoutDirty = false ; <nl> } <nl> <nl> - const char * UILayout : : getDescription ( ) const <nl> + std : : string Layout : : getDescription ( ) const <nl> { <nl> return " Layout " ; <nl> } <nl> <nl> - UIWidget * UILayout : : createCloneInstance ( ) <nl> + Widget * Layout : : createCloneInstance ( ) <nl> { <nl> - return UILayout : : create ( ) ; <nl> + return Layout : : create ( ) ; <nl> } <nl> <nl> - void UILayout : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + void Layout : : copyClonedWidgetChildren ( Widget * model ) <nl> { <nl> - UIWidget : : copyClonedWidgetChildren ( model ) ; <nl> - doLayout ( ) ; <nl> + Widget : : copyClonedWidgetChildren ( model ) ; <nl> } <nl> <nl> - void UILayout : : copySpecialProperties ( UIWidget * widget ) <nl> + void Layout : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UILayout * layout = dynamic_cast < UILayout * > ( widget ) ; <nl> + Layout * layout = dynamic_cast < Layout * > ( widget ) ; <nl> if ( layout ) <nl> { <nl> setBackGroundImageScale9Enabled ( layout - > _backGroundScale9Enabled ) ; <nl> void UILayout : : copySpecialProperties ( UIWidget * widget ) <nl> setBackGroundColorVector ( layout - > _alongVector ) ; <nl> setLayoutType ( layout - > _layoutType ) ; <nl> setClippingEnabled ( layout - > _clippingEnabled ) ; <nl> + setClippingType ( layout - > _clippingType ) ; <nl> } <nl> } <nl> - <nl> - UIRectClippingNode : : UIRectClippingNode ( ) : <nl> - _innerStencil ( nullptr ) , <nl> - _enabled ( true ) , <nl> - _clippingSize ( cocos2d : : Size ( 50 . 0f , 50 . 0f ) ) , <nl> - _clippingEnabled ( false ) <nl> - { <nl> - <nl> } <nl> - <nl> - UIRectClippingNode : : ~ UIRectClippingNode ( ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UIRectClippingNode * UIRectClippingNode : : create ( ) <nl> - { <nl> - UIRectClippingNode * pRet = new UIRectClippingNode ( ) ; <nl> - if ( pRet & & pRet - > init ( ) ) <nl> - { <nl> - pRet - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( pRet ) ; <nl> - } <nl> - <nl> - return pRet ; <nl> - } <nl> - <nl> - bool UIRectClippingNode : : init ( ) <nl> - { <nl> - _innerStencil = cocos2d : : DrawNode : : create ( ) ; <nl> - rect [ 0 ] = cocos2d : : Point ( 0 , 0 ) ; <nl> - rect [ 1 ] = cocos2d : : Point ( _clippingSize . width , 0 ) ; <nl> - rect [ 2 ] = cocos2d : : Point ( _clippingSize . width , _clippingSize . height ) ; <nl> - rect [ 3 ] = cocos2d : : Point ( 0 , _clippingSize . height ) ; <nl> - <nl> - cocos2d : : Color4F green ( 0 , 1 , 0 , 1 ) ; <nl> - _innerStencil - > drawPolygon ( rect , 4 , green , 0 , green ) ; <nl> - if ( cocos2d : : ClippingNode : : init ( _innerStencil ) ) <nl> - { <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - <nl> - void UIRectClippingNode : : setClippingSize ( const cocos2d : : Size & size ) <nl> - { <nl> - setContentSize ( size ) ; <nl> - _clippingSize = size ; <nl> - rect [ 0 ] = cocos2d : : Point ( 0 , 0 ) ; <nl> - rect [ 1 ] = cocos2d : : Point ( _clippingSize . width , 0 ) ; <nl> - rect [ 2 ] = cocos2d : : Point ( _clippingSize . width , _clippingSize . height ) ; <nl> - rect [ 3 ] = cocos2d : : Point ( 0 , _clippingSize . height ) ; <nl> - cocos2d : : Color4F green ( 0 , 1 , 0 , 1 ) ; <nl> - _innerStencil - > clear ( ) ; <nl> - _innerStencil - > drawPolygon ( rect , 4 , green , 0 , green ) ; <nl> - } <nl> - <nl> - void UIRectClippingNode : : setClippingEnabled ( bool enabled ) <nl> - { <nl> - _clippingEnabled = enabled ; <nl> - } <nl> - <nl> - void UIRectClippingNode : : visit ( ) <nl> - { <nl> - if ( ! _enabled ) <nl> - { <nl> - return ; <nl> - } <nl> - if ( _clippingEnabled ) <nl> - { <nl> - cocos2d : : ClippingNode : : visit ( ) ; <nl> - } <nl> - else <nl> - { <nl> - cocos2d : : Node : : visit ( ) ; <nl> - } <nl> - } <nl> - <nl> - void UIRectClippingNode : : setEnabled ( bool enabled ) <nl> - { <nl> - _enabled = enabled ; <nl> - } <nl> - <nl> - bool UIRectClippingNode : : isEnabled ( ) const <nl> - { <nl> - return _enabled ; <nl> - } <nl> - <nl> - } <nl> \ No newline at end of file <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILayout . h <nl> ppp b / cocos / gui / UILayout . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> typedef enum <nl> typedef enum <nl> LAYOUT_RELATIVE <nl> } LayoutType ; <nl> <nl> - class UILayout : public UIWidget <nl> + typedef enum { <nl> + LAYOUT_CLIPPING_STENCIL , <nl> + LAYOUT_CLIPPING_SCISSOR <nl> + } LayoutClippingType ; <nl> + <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class Layout : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UILayout ( ) ; <nl> + Layout ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UILayout ( ) ; <nl> + virtual ~ Layout ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes a layout . <nl> * / <nl> - static UILayout * create ( ) ; <nl> - <nl> - / / override " hitTest " method of widget . <nl> - virtual bool hitTest ( const cocos2d : : Point & pt ) override ; <nl> - <nl> + static Layout * create ( ) ; <nl> + <nl> / / background <nl> / * * <nl> * Sets a background image for layout <nl> class UILayout : public UIWidget <nl> * @ param capinsets of background image . <nl> * <nl> * / <nl> - void setBackGroundImageCapInsets ( const cocos2d : : Rect & capInsets ) ; <nl> + void setBackGroundImageCapInsets ( const Rect & capInsets ) ; <nl> <nl> / * * <nl> * Sets Color Type for layout . <nl> class UILayout : public UIWidget <nl> * <nl> * @ param color <nl> * / <nl> - void setBackGroundColor ( const cocos2d : : Color3B & color ) ; <nl> + void setBackGroundColor ( const Color3B & color ) ; <nl> <nl> / * * <nl> * Sets background color for layout , if color type is LAYOUT_COLOR_GRADIENT <nl> class UILayout : public UIWidget <nl> * <nl> * @ param end color <nl> * / <nl> - void setBackGroundColor ( const cocos2d : : Color3B & startColor , const cocos2d : : Color3B & endColor ) ; <nl> + void setBackGroundColor ( const Color3B & startColor , const Color3B & endColor ) ; <nl> <nl> / * * <nl> * Sets background opacity layout . <nl> class UILayout : public UIWidget <nl> * <nl> * @ param vector <nl> * / <nl> - void setBackGroundColorVector ( const cocos2d : : Point & vector ) ; <nl> - <nl> - / / override " setColor " method of widget . <nl> - virtual void setColor ( const cocos2d : : Color3B & color ) override ; <nl> - <nl> - / / override " setOpacity " method of widget . <nl> - virtual void setOpacity ( int opacity ) override ; <nl> + void setBackGroundColorVector ( const Point & vector ) ; <nl> <nl> / * * <nl> * Remove the background image of layout . <nl> class UILayout : public UIWidget <nl> * <nl> * @ return background image texture size . <nl> * / <nl> - const cocos2d : : Size & getBackGroundImageTextureSize ( ) const ; <nl> + const Size & getBackGroundImageTextureSize ( ) const ; <nl> <nl> / * * <nl> * Changes if layout can clip it ' s content and child . <nl> class UILayout : public UIWidget <nl> * / <nl> virtual void setClippingEnabled ( bool enabled ) ; <nl> <nl> + void setClippingType ( LayoutClippingType type ) ; <nl> + <nl> / * * <nl> * Gets if layout is clipping enabled . <nl> * <nl> class UILayout : public UIWidget <nl> * / <nl> virtual bool isClippingEnabled ( ) ; <nl> <nl> - / * * <nl> - * Gets the content size of widget . <nl> - * <nl> - * Content size is widget ' s texture size . <nl> - * / <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> - <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> / * * <nl> * Sets LayoutType . <nl> class UILayout : public UIWidget <nl> * @ return LayoutType <nl> * / <nl> virtual LayoutType getLayoutType ( ) const ; <nl> - <nl> - virtual void doLayout ( ) ; <nl> - <nl> + <nl> + virtual void addChild ( Node * child ) override ; <nl> + / * * <nl> + * Adds a child to the container with a z - order <nl> + * <nl> + * If the child is added to a ' running ' node , then ' onEnter ' and ' onEnterTransitionDidFinish ' will be called immediately . <nl> + * <nl> + * @ param child A child node <nl> + * @ param zOrder Z order for drawing priority . Please refer to setZOrder ( int ) <nl> + * / <nl> + virtual void addChild ( Node * child , int zOrder ) override ; <nl> / * * <nl> - * Adds a child to the container . <nl> + * Adds a child to the container with z order and tag <nl> + * <nl> + * If the child is added to a ' running ' node , then ' onEnter ' and ' onEnterTransitionDidFinish ' will be called immediately . <nl> * <nl> - * @ param child A child widget <nl> + * @ param child A child node <nl> + * @ param zOrder Z order for drawing priority . Please refer to setZOrder ( int ) <nl> + * @ param tag A interger to identify the node easily . Please refer to setTag ( int ) <nl> * / <nl> - virtual bool addChild ( UIWidget * child ) override ; <nl> + virtual void addChild ( Node * child , int zOrder , int tag ) override ; <nl> + <nl> + virtual void visit ( ) ; <nl> <nl> + virtual void sortAllChildren ( ) override ; <nl> protected : <nl> / / override " init " method of widget . <nl> virtual bool init ( ) override ; <nl> - <nl> - / / override " initRenderer " method of widget . <nl> - virtual void initRenderer ( ) override ; <nl> - <nl> + <nl> / / override " onSizeChanged " method of widget . <nl> virtual void onSizeChanged ( ) override ; <nl> <nl> / / init background image renderer . <nl> void addBackGroundImage ( ) ; <nl> <nl> - void supplyTheLayoutParameterLackToChild ( UIWidget * child ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> - virtual void copyClonedWidgetChildren ( UIWidget * model ) override ; <nl> + void supplyTheLayoutParameterLackToChild ( Widget * child ) ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> + virtual void copyClonedWidgetChildren ( Widget * model ) override ; <nl> + <nl> + void stencilClippingVisit ( ) ; <nl> + void scissorClippingVisit ( ) ; <nl> + <nl> + void setStencilClippingSize ( const Size & size ) ; <nl> + const Rect & getClippingRect ( ) ; <nl> + virtual void doLayout ( ) ; <nl> protected : <nl> bool _clippingEnabled ; <nl> <nl> / / background <nl> bool _backGroundScale9Enabled ; <nl> - cocos2d : : Node * _backGroundImage ; <nl> + Node * _backGroundImage ; <nl> std : : string _backGroundImageFileName ; <nl> - cocos2d : : Rect _backGroundImageCapInsets ; <nl> + Rect _backGroundImageCapInsets ; <nl> LayoutBackGroundColorType _colorType ; <nl> TextureResType _bgImageTexType ; <nl> - cocos2d : : LayerColor * _colorRender ; <nl> - cocos2d : : LayerGradient * _gradientRender ; <nl> - cocos2d : : Color3B _cColor ; <nl> - cocos2d : : Color3B _gStartColor ; <nl> - cocos2d : : Color3B _gEndColor ; <nl> - cocos2d : : Point _alongVector ; <nl> + LayerColor * _colorRender ; <nl> + LayerGradient * _gradientRender ; <nl> + Color3B _cColor ; <nl> + Color3B _gStartColor ; <nl> + Color3B _gEndColor ; <nl> + Point _alongVector ; <nl> int _cOpacity ; <nl> - cocos2d : : Size _backGroundImageTextureSize ; <nl> + Size _backGroundImageTextureSize ; <nl> LayoutType _layoutType ; <nl> + LayoutClippingType _clippingType ; <nl> + DrawNode * _clippingStencil ; <nl> + bool _handleScissor ; <nl> + bool _scissorRectDirty ; <nl> + Rect _clippingRect ; <nl> + Layout * _clippingParent ; <nl> + bool _doLayoutDirty ; <nl> } ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - class UIRectClippingNode : public cocos2d : : ClippingNode <nl> - { <nl> - public : <nl> - virtual ~ UIRectClippingNode ( ) ; <nl> - virtual bool init ( ) ; <nl> - static UIRectClippingNode * create ( ) ; <nl> - void setClippingSize ( const cocos2d : : Size & size ) ; <nl> - void setClippingEnabled ( bool enabled ) ; <nl> - virtual void visit ( ) ; <nl> - void setEnabled ( bool enabled ) ; <nl> - bool isEnabled ( ) const ; <nl> - protected : <nl> - cocos2d : : DrawNode * _innerStencil ; <nl> - bool _enabled ; <nl> - private : <nl> - UIRectClippingNode ( ) ; <nl> - cocos2d : : Point rect [ 4 ] ; <nl> - cocos2d : : Size _clippingSize ; <nl> - bool _clippingEnabled ; <nl> - } ; <nl> - <nl> + <nl> } <nl> - <nl> + NS_CC_END <nl> # endif / * defined ( __Layout__ ) * / <nl> mmm a / cocos / gui / UILayoutDefine . cpp <nl> ppp b / cocos / gui / UILayoutDefine . cpp <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> # include " UILayoutDefine . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> <nl> - UIMargin : : UIMargin ( void ) : left ( 0 ) , top ( 0 ) , right ( 0 ) , bottom ( 0 ) <nl> + Margin : : Margin ( void ) : left ( 0 ) , top ( 0 ) , right ( 0 ) , bottom ( 0 ) <nl> { <nl> } <nl> <nl> - UIMargin : : UIMargin ( float l , float t , float r , float b ) : left ( l ) , top ( t ) , right ( r ) , bottom ( b ) <nl> + Margin : : Margin ( float l , float t , float r , float b ) : left ( l ) , top ( t ) , right ( r ) , bottom ( b ) <nl> { <nl> } <nl> <nl> - UIMargin : : UIMargin ( const UIMargin & other ) : left ( other . left ) , top ( other . top ) , right ( other . right ) , bottom ( other . bottom ) <nl> + Margin : : Margin ( const Margin & other ) : left ( other . left ) , top ( other . top ) , right ( other . right ) , bottom ( other . bottom ) <nl> { <nl> } <nl> <nl> - UIMargin & UIMargin : : operator = ( const UIMargin & other ) <nl> + Margin & Margin : : operator = ( const Margin & other ) <nl> { <nl> setMargin ( other . left , other . top , other . right , other . bottom ) ; <nl> return * this ; <nl> } <nl> <nl> - void UIMargin : : setMargin ( float l , float t , float r , float b ) <nl> + void Margin : : setMargin ( float l , float t , float r , float b ) <nl> { <nl> left = l ; <nl> top = t ; <nl> void UIMargin : : setMargin ( float l , float t , float r , float b ) <nl> bottom = b ; <nl> } <nl> <nl> - bool UIMargin : : equals ( const UIMargin & target ) const <nl> + bool Margin : : equals ( const Margin & target ) const <nl> { <nl> return ( left = = target . left & & top = = target . top & & right = = target . right & & bottom = = target . bottom ) ; <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILayoutDefine . h <nl> ppp b / cocos / gui / UILayoutDefine . h <nl> <nl> <nl> # include " cocos2d . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> - class UIMargin <nl> + class Margin <nl> { <nl> public : <nl> float left ; <nl> class UIMargin <nl> float bottom ; <nl> <nl> public : <nl> - UIMargin ( ) ; <nl> - UIMargin ( float l , float t , float r , float b ) ; <nl> - UIMargin ( const UIMargin & other ) ; <nl> - UIMargin & operator = ( const UIMargin & other ) ; <nl> + Margin ( ) ; <nl> + Margin ( float l , float t , float r , float b ) ; <nl> + Margin ( const Margin & other ) ; <nl> + Margin & operator = ( const Margin & other ) ; <nl> void setMargin ( float l , float t , float r , float b ) ; <nl> - bool equals ( const UIMargin & target ) const ; <nl> + bool equals ( const Margin & target ) const ; <nl> } ; <nl> <nl> - const UIMargin UIMarginZero = UIMargin ( ) ; <nl> + const Margin MarginZero = Margin ( ) ; <nl> <nl> typedef enum <nl> { <nl> typedef enum <nl> LINEAR_GRAVITY_BOTTOM , <nl> LINEAR_GRAVITY_CENTER_VERTICAL , <nl> LINEAR_GRAVITY_CENTER_HORIZONTAL <nl> - } UILinearGravity ; <nl> + } LinearGravity ; <nl> <nl> typedef enum <nl> { <nl> typedef enum <nl> RELATIVE_LOCATION_BELOW_LEFTALIGN , <nl> RELATIVE_LOCATION_BELOW_CENTER , <nl> RELATIVE_LOCATION_BELOW_RIGHTALIGN <nl> - } UIRelativeAlign ; <nl> + } RelativeAlign ; <nl> <nl> } <nl> - <nl> + NS_CC_END <nl> # endif / * defined ( __UILayoutDefine__ ) * / <nl> mmm a / cocos / gui / UILayoutParameter . cpp <nl> ppp b / cocos / gui / UILayoutParameter . cpp <nl> <nl> # include " gui / UILayoutParameter . h " <nl> # include " gui / UILayout . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> <nl> - UILayoutParameter * UILayoutParameter : : create ( ) <nl> + LayoutParameter * LayoutParameter : : create ( ) <nl> { <nl> - UILayoutParameter * parameter = new UILayoutParameter ( ) ; <nl> + LayoutParameter * parameter = new LayoutParameter ( ) ; <nl> if ( parameter ) <nl> { <nl> parameter - > autorelease ( ) ; <nl> UILayoutParameter * UILayoutParameter : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - void UILayoutParameter : : setMargin ( const UIMargin & margin ) <nl> + void LayoutParameter : : setMargin ( const Margin & margin ) <nl> { <nl> _margin = margin ; <nl> } <nl> <nl> - const UIMargin & UILayoutParameter : : getMargin ( ) const <nl> + const Margin & LayoutParameter : : getMargin ( ) const <nl> { <nl> return _margin ; <nl> } <nl> <nl> - LayoutParameterType UILayoutParameter : : getLayoutType ( ) const <nl> + LayoutParameterType LayoutParameter : : getLayoutType ( ) const <nl> { <nl> return _layoutParameterType ; <nl> } <nl> <nl> - UILinearLayoutParameter * UILinearLayoutParameter : : create ( ) <nl> + LinearLayoutParameter * LinearLayoutParameter : : create ( ) <nl> { <nl> - UILinearLayoutParameter * parameter = new UILinearLayoutParameter ( ) ; <nl> + LinearLayoutParameter * parameter = new LinearLayoutParameter ( ) ; <nl> if ( parameter ) <nl> { <nl> parameter - > autorelease ( ) ; <nl> UILinearLayoutParameter * UILinearLayoutParameter : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - void UILinearLayoutParameter : : setGravity ( UILinearGravity gravity ) <nl> + void LinearLayoutParameter : : setGravity ( LinearGravity gravity ) <nl> { <nl> _linearGravity = gravity ; <nl> } <nl> <nl> - UILinearGravity UILinearLayoutParameter : : getGravity ( ) const <nl> + LinearGravity LinearLayoutParameter : : getGravity ( ) const <nl> { <nl> return _linearGravity ; <nl> } <nl> <nl> - UIRelativeLayoutParameter * UIRelativeLayoutParameter : : create ( ) <nl> + RelativeLayoutParameter * RelativeLayoutParameter : : create ( ) <nl> { <nl> - UIRelativeLayoutParameter * parameter = new UIRelativeLayoutParameter ( ) ; <nl> + RelativeLayoutParameter * parameter = new RelativeLayoutParameter ( ) ; <nl> if ( parameter ) <nl> { <nl> parameter - > autorelease ( ) ; <nl> UIRelativeLayoutParameter * UIRelativeLayoutParameter : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - void UIRelativeLayoutParameter : : setAlign ( UIRelativeAlign align ) <nl> + void RelativeLayoutParameter : : setAlign ( RelativeAlign align ) <nl> { <nl> _relativeAlign = align ; <nl> } <nl> <nl> - UIRelativeAlign UIRelativeLayoutParameter : : getAlign ( ) const <nl> + RelativeAlign RelativeLayoutParameter : : getAlign ( ) const <nl> { <nl> return _relativeAlign ; <nl> } <nl> <nl> - void UIRelativeLayoutParameter : : setRelativeToWidgetName ( const char * name ) <nl> + void RelativeLayoutParameter : : setRelativeToWidgetName ( const char * name ) <nl> { <nl> _relativeWidgetName = name ; <nl> } <nl> <nl> - const char * UIRelativeLayoutParameter : : getRelativeToWidgetName ( ) const <nl> + const char * RelativeLayoutParameter : : getRelativeToWidgetName ( ) const <nl> { <nl> return _relativeWidgetName . c_str ( ) ; <nl> } <nl> <nl> - void UIRelativeLayoutParameter : : setRelativeName ( const char * name ) <nl> + void RelativeLayoutParameter : : setRelativeName ( const char * name ) <nl> { <nl> _relativeLayoutName = name ; <nl> } <nl> <nl> - const char * UIRelativeLayoutParameter : : getRelativeName ( ) const <nl> + const char * RelativeLayoutParameter : : getRelativeName ( ) const <nl> { <nl> return _relativeLayoutName . c_str ( ) ; <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILayoutParameter . h <nl> ppp b / cocos / gui / UILayoutParameter . h <nl> <nl> <nl> # include " gui / UILayoutDefine . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> typedef enum <nl> typedef enum <nl> LAYOUT_PARAMETER_LINEAR , <nl> LAYOUT_PARAMETER_RELATIVE <nl> } LayoutParameterType ; <nl> - <nl> - class UILayoutParameter : public cocos2d : : Object <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class LayoutParameter : public Object <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UILayoutParameter ( ) : _margin ( UIMargin ( ) ) { _layoutParameterType = LAYOUT_PARAMETER_NONE ; } ; <nl> + LayoutParameter ( ) : _margin ( Margin ( ) ) { _layoutParameterType = LAYOUT_PARAMETER_NONE ; } ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UILayoutParameter ( ) { } ; <nl> + virtual ~ LayoutParameter ( ) { } ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * @ return A initialized LayoutParameter which is marked as " autorelease " . <nl> * / <nl> - static UILayoutParameter * create ( ) ; <nl> + static LayoutParameter * create ( ) ; <nl> <nl> / * * <nl> * Sets Margin parameter for LayoutParameter . <nl> * <nl> - * @ see UIMargin <nl> + * @ see Margin <nl> * <nl> * @ param margin <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - void setMargin ( const UIMargin & margin ) ; <nl> + void setMargin ( const Margin & margin ) ; <nl> <nl> / * * <nl> * Gets Margin parameter of LayoutParameter . <nl> * <nl> - * @ see UIMargin <nl> + * @ see Margin <nl> * <nl> - * @ return const UIMargin & <nl> - * @ js NA <nl> - * @ lua NA <nl> + * @ return const Margin & <nl> * / <nl> - const UIMargin & getMargin ( ) const ; <nl> + const Margin & getMargin ( ) const ; <nl> <nl> / * * <nl> * Gets LayoutParameterType of LayoutParameter . <nl> class UILayoutParameter : public cocos2d : : Object <nl> * / <nl> LayoutParameterType getLayoutType ( ) const ; <nl> protected : <nl> - UIMargin _margin ; <nl> + Margin _margin ; <nl> LayoutParameterType _layoutParameterType ; <nl> } ; <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> - class UILinearLayoutParameter : public UILayoutParameter <nl> + class LinearLayoutParameter : public LayoutParameter <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> * / <nl> - UILinearLayoutParameter ( ) : _linearGravity ( LINEAR_GRAVITY_NONE ) { _layoutParameterType = LAYOUT_PARAMETER_LINEAR ; } ; <nl> + LinearLayoutParameter ( ) : _linearGravity ( LINEAR_GRAVITY_NONE ) { _layoutParameterType = LAYOUT_PARAMETER_LINEAR ; } ; <nl> <nl> / * * <nl> * Default destructor <nl> * / <nl> - virtual ~ UILinearLayoutParameter ( ) { } ; <nl> + virtual ~ LinearLayoutParameter ( ) { } ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * @ return A initialized LayoutParameter which is marked as " autorelease " . <nl> * / <nl> - static UILinearLayoutParameter * create ( ) ; <nl> + static LinearLayoutParameter * create ( ) ; <nl> <nl> / * * <nl> - * Sets UILinearGravity parameter for LayoutParameter . <nl> + * Sets LinearGravity parameter for LayoutParameter . <nl> * <nl> - * @ see UILinearGravity <nl> + * @ see LinearGravity <nl> * <nl> - * @ param UILinearGravity <nl> + * @ param LinearGravity <nl> * / <nl> - void setGravity ( UILinearGravity gravity ) ; <nl> + void setGravity ( LinearGravity gravity ) ; <nl> <nl> / * * <nl> - * Gets UILinearGravity parameter for LayoutParameter . <nl> + * Gets LinearGravity parameter for LayoutParameter . <nl> * <nl> - * @ see UILinearGravity <nl> + * @ see LinearGravity <nl> * <nl> - * @ return UILinearGravity <nl> + * @ return LinearGravity <nl> * / <nl> - UILinearGravity getGravity ( ) const ; <nl> + LinearGravity getGravity ( ) const ; <nl> protected : <nl> - UILinearGravity _linearGravity ; <nl> + LinearGravity _linearGravity ; <nl> } ; <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> <nl> - class UILayout ; <nl> - <nl> - class UIRelativeLayoutParameter : public UILayoutParameter <nl> + class RelativeLayoutParameter : public LayoutParameter <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> * / <nl> - UIRelativeLayoutParameter ( ) : _relativeAlign ( RELATIVE_ALIGN_NONE ) , _relativeWidgetName ( " " ) , _relativeLayoutName ( " " ) , _put ( false ) { _layoutParameterType = LAYOUT_PARAMETER_RELATIVE ; } ; <nl> + RelativeLayoutParameter ( ) : _relativeAlign ( RELATIVE_ALIGN_NONE ) , _relativeWidgetName ( " " ) , _relativeLayoutName ( " " ) , _put ( false ) { _layoutParameterType = LAYOUT_PARAMETER_RELATIVE ; } ; <nl> <nl> / * * <nl> * Default destructor <nl> * / <nl> - virtual ~ UIRelativeLayoutParameter ( ) { } ; <nl> + virtual ~ RelativeLayoutParameter ( ) { } ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * @ return A initialized LayoutParameter which is marked as " autorelease " . <nl> * / <nl> - static UIRelativeLayoutParameter * create ( ) ; <nl> + static RelativeLayoutParameter * create ( ) ; <nl> <nl> / * * <nl> - * Sets UIRelativeAlign parameter for LayoutParameter . <nl> + * Sets RelativeAlign parameter for LayoutParameter . <nl> * <nl> - * @ see UIRelativeAlign <nl> + * @ see RelativeAlign <nl> * <nl> - * @ param UIRelativeAlign <nl> + * @ param RelativeAlign <nl> * / <nl> - void setAlign ( UIRelativeAlign align ) ; <nl> + void setAlign ( RelativeAlign align ) ; <nl> <nl> / * * <nl> - * Gets UIRelativeAlign parameter for LayoutParameter . <nl> + * Gets RelativeAlign parameter for LayoutParameter . <nl> * <nl> - * @ see UIRelativeAlign <nl> + * @ see RelativeAlign <nl> * <nl> - * @ return UIRelativeAlign <nl> + * @ return RelativeAlign <nl> * / <nl> - UIRelativeAlign getAlign ( ) const ; <nl> + RelativeAlign getAlign ( ) const ; <nl> <nl> / * * <nl> * Sets a key for LayoutParameter . Witch widget named this is relative to . <nl> class UIRelativeLayoutParameter : public UILayoutParameter <nl> * / <nl> const char * getRelativeName ( ) const ; <nl> protected : <nl> - UIRelativeAlign _relativeAlign ; <nl> + RelativeAlign _relativeAlign ; <nl> std : : string _relativeWidgetName ; <nl> std : : string _relativeLayoutName ; <nl> bool _put ; <nl> - friend class UILayout ; <nl> + friend class Layout ; <nl> } ; <nl> <nl> } <nl> <nl> + NS_CC_END <nl> + <nl> # endif / * defined ( __LayoutParameter__ ) * / <nl> mmm a / cocos / gui / UIListView . cpp <nl> ppp b / cocos / gui / UIListView . cpp <nl> <nl> # include " gui / UIHelper . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> - UIListView : : UIListView ( ) : <nl> + ListView : : ListView ( ) : <nl> _model ( nullptr ) , <nl> - _items ( nullptr ) , <nl> _gravity ( LISTVIEW_GRAVITY_CENTER_HORIZONTAL ) , <nl> _itemsMargin ( 0 . 0f ) , <nl> _listViewEventListener ( nullptr ) , <nl> _listViewEventSelector ( nullptr ) , <nl> - _curSelectedIndex ( 0 ) <nl> + _curSelectedIndex ( 0 ) , <nl> + _refreshViewDirty ( true ) <nl> { <nl> <nl> } <nl> <nl> - UIListView : : ~ UIListView ( ) <nl> + ListView : : ~ ListView ( ) <nl> { <nl> - _items - > removeAllObjects ( ) ; <nl> - CC_SAFE_RELEASE ( _items ) ; <nl> _listViewEventListener = nullptr ; <nl> _listViewEventSelector = nullptr ; <nl> + _items . clear ( ) ; <nl> } <nl> <nl> - UIListView * UIListView : : create ( ) <nl> + ListView * ListView : : create ( ) <nl> { <nl> - UIListView * widget = new UIListView ( ) ; <nl> + ListView * widget = new ListView ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UIListView * UIListView : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UIListView : : init ( ) <nl> + bool ListView : : init ( ) <nl> { <nl> - if ( UIScrollView : : init ( ) ) <nl> + if ( ScrollView : : init ( ) ) <nl> { <nl> - _items = cocos2d : : Array : : create ( ) ; <nl> - CC_SAFE_RETAIN ( _items ) ; <nl> setLayoutType ( LAYOUT_LINEAR_VERTICAL ) ; <nl> return true ; <nl> } <nl> return false ; <nl> } <nl> <nl> - void UIListView : : setItemModel ( UIWidget * model ) <nl> + void ListView : : setItemModel ( Widget * model ) <nl> { <nl> if ( ! model ) <nl> { <nl> void UIListView : : setItemModel ( UIWidget * model ) <nl> CC_SAFE_RETAIN ( _model ) ; <nl> } <nl> <nl> - void UIListView : : updateInnerContainerSize ( ) <nl> + void ListView : : updateInnerContainerSize ( ) <nl> { <nl> - if ( ! _model ) <nl> + switch ( _direction ) <nl> { <nl> - return ; <nl> - } <nl> - switch ( _direction ) { <nl> case SCROLLVIEW_DIR_VERTICAL : <nl> { <nl> - ssize_t childrenCount = _items - > count ( ) ; <nl> - float totalHeight = _model - > getSize ( ) . height * childrenCount + ( childrenCount - 1 ) * _itemsMargin ; <nl> + int length = _items . size ( ) ; <nl> + float totalHeight = ( length - 1 ) * _itemsMargin ; <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> + { <nl> + Widget * item = _items . at ( i ) ; <nl> + totalHeight + = item - > getSize ( ) . height ; <nl> + } <nl> float finalWidth = _size . width ; <nl> float finalHeight = totalHeight ; <nl> - setInnerContainerSize ( cocos2d : : Size ( finalWidth , finalHeight ) ) ; <nl> + setInnerContainerSize ( Size ( finalWidth , finalHeight ) ) ; <nl> break ; <nl> } <nl> case SCROLLVIEW_DIR_HORIZONTAL : <nl> { <nl> - ssize_t childrenCount = _items - > count ( ) ; <nl> - float totalWidth = _model - > getSize ( ) . width * childrenCount + ( childrenCount - 1 ) * _itemsMargin ; <nl> + int length = _items . size ( ) ; <nl> + float totalWidth = ( length - 1 ) * _itemsMargin ; <nl> + for ( int i = 0 ; i < length ; i + + ) <nl> + { <nl> + Widget * item = _items . at ( i ) ; <nl> + totalWidth + = item - > getSize ( ) . width ; <nl> + } <nl> float finalWidth = totalWidth ; <nl> float finalHeight = _size . height ; <nl> - setInnerContainerSize ( cocos2d : : Size ( finalWidth , finalHeight ) ) ; <nl> + setInnerContainerSize ( Size ( finalWidth , finalHeight ) ) ; <nl> break ; <nl> } <nl> default : <nl> void UIListView : : updateInnerContainerSize ( ) <nl> } <nl> } <nl> <nl> - void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> + void ListView : : remedyLayoutParameter ( Widget * item ) <nl> { <nl> if ( ! item ) <nl> { <nl> void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> switch ( _direction ) { <nl> case SCROLLVIEW_DIR_VERTICAL : <nl> { <nl> - UILinearLayoutParameter * llp = ( UILinearLayoutParameter * ) ( item - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + LinearLayoutParameter * llp = ( LinearLayoutParameter * ) ( item - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> if ( ! llp ) <nl> { <nl> - UILinearLayoutParameter * defaultLp = UILinearLayoutParameter : : create ( ) ; <nl> + LinearLayoutParameter * defaultLp = LinearLayoutParameter : : create ( ) ; <nl> switch ( _gravity ) { <nl> case LISTVIEW_GRAVITY_LEFT : <nl> defaultLp - > setGravity ( LINEAR_GRAVITY_LEFT ) ; <nl> void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> } <nl> if ( getIndex ( item ) = = 0 ) <nl> { <nl> - defaultLp - > setMargin ( UIMarginZero ) ; <nl> + defaultLp - > setMargin ( MarginZero ) ; <nl> } <nl> else <nl> { <nl> - defaultLp - > setMargin ( UIMargin ( 0 . 0f , _itemsMargin , 0 . 0f , 0 . 0f ) ) ; <nl> + defaultLp - > setMargin ( Margin ( 0 . 0f , _itemsMargin , 0 . 0f , 0 . 0f ) ) ; <nl> } <nl> item - > setLayoutParameter ( defaultLp ) ; <nl> } <nl> void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> { <nl> if ( getIndex ( item ) = = 0 ) <nl> { <nl> - llp - > setMargin ( UIMarginZero ) ; <nl> + llp - > setMargin ( MarginZero ) ; <nl> } <nl> else <nl> { <nl> - llp - > setMargin ( UIMargin ( 0 . 0f , _itemsMargin , 0 . 0f , 0 . 0f ) ) ; <nl> + llp - > setMargin ( Margin ( 0 . 0f , _itemsMargin , 0 . 0f , 0 . 0f ) ) ; <nl> } <nl> switch ( _gravity ) { <nl> case LISTVIEW_GRAVITY_LEFT : <nl> void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> } <nl> case SCROLLVIEW_DIR_HORIZONTAL : <nl> { <nl> - UILinearLayoutParameter * llp = ( UILinearLayoutParameter * ) ( item - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> + LinearLayoutParameter * llp = ( LinearLayoutParameter * ) ( item - > getLayoutParameter ( LAYOUT_PARAMETER_LINEAR ) ) ; <nl> if ( ! llp ) <nl> { <nl> - UILinearLayoutParameter * defaultLp = UILinearLayoutParameter : : create ( ) ; <nl> + LinearLayoutParameter * defaultLp = LinearLayoutParameter : : create ( ) ; <nl> switch ( _gravity ) { <nl> case LISTVIEW_GRAVITY_TOP : <nl> defaultLp - > setGravity ( LINEAR_GRAVITY_TOP ) ; <nl> void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> } <nl> if ( getIndex ( item ) = = 0 ) <nl> { <nl> - defaultLp - > setMargin ( UIMarginZero ) ; <nl> + defaultLp - > setMargin ( MarginZero ) ; <nl> } <nl> else <nl> { <nl> - defaultLp - > setMargin ( UIMargin ( _itemsMargin , 0 . 0f , 0 . 0f , 0 . 0f ) ) ; <nl> + defaultLp - > setMargin ( Margin ( _itemsMargin , 0 . 0f , 0 . 0f , 0 . 0f ) ) ; <nl> } <nl> item - > setLayoutParameter ( defaultLp ) ; <nl> } <nl> void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> { <nl> if ( getIndex ( item ) = = 0 ) <nl> { <nl> - llp - > setMargin ( UIMarginZero ) ; <nl> + llp - > setMargin ( MarginZero ) ; <nl> } <nl> else <nl> { <nl> - llp - > setMargin ( UIMargin ( _itemsMargin , 0 . 0f , 0 . 0f , 0 . 0f ) ) ; <nl> + llp - > setMargin ( Margin ( _itemsMargin , 0 . 0f , 0 . 0f , 0 . 0f ) ) ; <nl> } <nl> switch ( _gravity ) { <nl> case LISTVIEW_GRAVITY_TOP : <nl> void UIListView : : remedyLayoutParameter ( UIWidget * item ) <nl> <nl> } <nl> <nl> - void UIListView : : pushBackDefaultItem ( ) <nl> + void ListView : : pushBackDefaultItem ( ) <nl> { <nl> if ( ! _model ) <nl> { <nl> return ; <nl> } <nl> - UIWidget * newItem = _model - > clone ( ) ; <nl> - _items - > addObject ( newItem ) ; <nl> + Widget * newItem = _model - > clone ( ) ; <nl> + _items . pushBack ( newItem ) ; <nl> remedyLayoutParameter ( newItem ) ; <nl> addChild ( newItem ) ; <nl> + _refreshViewDirty = true ; <nl> } <nl> <nl> - void UIListView : : insertDefaultItem ( int index ) <nl> + void ListView : : insertDefaultItem ( int index ) <nl> { <nl> - if ( ! _items ) <nl> - { <nl> - return ; <nl> - } <nl> if ( ! _model ) <nl> { <nl> return ; <nl> } <nl> - UIWidget * newItem = _model - > clone ( ) ; <nl> - _items - > insertObject ( newItem , index ) ; <nl> + Widget * newItem = _model - > clone ( ) ; <nl> + _items . insert ( index , newItem ) ; <nl> remedyLayoutParameter ( newItem ) ; <nl> addChild ( newItem ) ; <nl> + _refreshViewDirty = true ; <nl> } <nl> <nl> - void UIListView : : pushBackCustomItem ( UIWidget * item ) <nl> + void ListView : : pushBackCustomItem ( Widget * item ) <nl> { <nl> - _items - > addObject ( item ) ; <nl> + _items . pushBack ( item ) ; <nl> remedyLayoutParameter ( item ) ; <nl> addChild ( item ) ; <nl> + _refreshViewDirty = true ; <nl> } <nl> <nl> - void UIListView : : insertCustomItem ( UIWidget * item , int index ) <nl> + void ListView : : insertCustomItem ( Widget * item , int index ) <nl> { <nl> - _items - > insertObject ( item , index ) ; <nl> + _items . insert ( index , item ) ; <nl> remedyLayoutParameter ( item ) ; <nl> addChild ( item ) ; <nl> + _refreshViewDirty = true ; <nl> } <nl> <nl> - void UIListView : : removeItem ( int index ) <nl> + void ListView : : removeItem ( int index ) <nl> { <nl> - if ( ! _items ) <nl> - { <nl> - return ; <nl> - } <nl> - UIWidget * item = getItem ( index ) ; <nl> + Widget * item = getItem ( index ) ; <nl> if ( ! item ) <nl> { <nl> return ; <nl> - <nl> } <nl> - _items - > removeObject ( item ) ; <nl> + _items . eraseObject ( item ) ; <nl> removeChild ( item ) ; <nl> + _refreshViewDirty = true ; <nl> } <nl> <nl> - void UIListView : : removeLastItem ( ) <nl> + void ListView : : removeLastItem ( ) <nl> { <nl> - removeItem ( _items - > count ( ) - 1 ) ; <nl> + removeItem ( _items . size ( ) - 1 ) ; <nl> } <nl> <nl> - UIWidget * UIListView : : getItem ( unsigned int index ) <nl> + Widget * ListView : : getItem ( unsigned int index ) <nl> { <nl> - if ( ( int ) index < 0 | | index > = _items - > count ( ) ) <nl> + if ( ( int ) index < 0 | | index > = _items . size ( ) ) <nl> { <nl> return nullptr ; <nl> } <nl> - return ( UIWidget * ) ( _items - > data - > arr [ index ] ) ; <nl> + return _items . at ( index ) ; <nl> } <nl> <nl> - cocos2d : : Array * UIListView : : getItems ( ) <nl> + Vector < Widget * > & ListView : : getItems ( ) <nl> { <nl> return _items ; <nl> } <nl> <nl> - unsigned int UIListView : : getIndex ( UIWidget * item ) const <nl> + unsigned int ListView : : getIndex ( Widget * item ) const <nl> { <nl> - if ( ! _items ) <nl> - { <nl> - return - 1 ; <nl> - } <nl> if ( ! item ) <nl> { <nl> return - 1 ; <nl> } <nl> - return _items - > getIndexOfObject ( item ) ; <nl> + return _items . getIndex ( item ) ; <nl> } <nl> <nl> - void UIListView : : setGravity ( ListViewGravity gravity ) <nl> + void ListView : : setGravity ( ListViewGravity gravity ) <nl> { <nl> if ( _gravity = = gravity ) <nl> { <nl> return ; <nl> } <nl> _gravity = gravity ; <nl> - refreshView ( ) ; <nl> + _refreshViewDirty = true ; <nl> } <nl> <nl> - void UIListView : : setItemsMargin ( float margin ) <nl> + void ListView : : setItemsMargin ( float margin ) <nl> { <nl> if ( _itemsMargin = = margin ) <nl> { <nl> return ; <nl> } <nl> _itemsMargin = margin ; <nl> - refreshView ( ) ; <nl> + _refreshViewDirty = true ; <nl> } <nl> <nl> - void UIListView : : setDirection ( SCROLLVIEW_DIR dir ) <nl> + void ListView : : setDirection ( SCROLLVIEW_DIR dir ) <nl> { <nl> switch ( dir ) <nl> { <nl> void UIListView : : setDirection ( SCROLLVIEW_DIR dir ) <nl> return ; <nl> break ; <nl> } <nl> - UIScrollView : : setDirection ( dir ) ; <nl> - <nl> + ScrollView : : setDirection ( dir ) ; <nl> } <nl> <nl> - void UIListView : : refreshView ( ) <nl> + void ListView : : refreshView ( ) <nl> { <nl> - if ( ! _items ) <nl> - { <nl> - return ; <nl> - } <nl> - cocos2d : : ccArray * arrayItems = _items - > data ; <nl> - ssize_t length = arrayItems - > num ; <nl> + int length = _items . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * item = ( UIWidget * ) ( arrayItems - > arr [ i ] ) ; <nl> + Widget * item = _items . at ( i ) ; <nl> item - > setZOrder ( i ) ; <nl> remedyLayoutParameter ( item ) ; <nl> } <nl> updateInnerContainerSize ( ) ; <nl> } <nl> <nl> - void UIListView : : addEventListenerListView ( cocos2d : : Object * target , SEL_ListViewEvent selector ) <nl> + void ListView : : sortAllChildren ( ) <nl> + { <nl> + ScrollView : : sortAllChildren ( ) ; <nl> + if ( _refreshViewDirty ) <nl> + { <nl> + refreshView ( ) ; <nl> + _refreshViewDirty = false ; <nl> + } <nl> + } <nl> + <nl> + void ListView : : addEventListenerListView ( Object * target , SEL_ListViewEvent selector ) <nl> { <nl> _listViewEventListener = target ; <nl> _listViewEventSelector = selector ; <nl> } <nl> <nl> - void UIListView : : selectedItemEvent ( ) <nl> + void ListView : : selectedItemEvent ( ) <nl> { <nl> if ( _listViewEventListener & & _listViewEventSelector ) <nl> { <nl> void UIListView : : selectedItemEvent ( ) <nl> } <nl> } <nl> <nl> - void UIListView : : interceptTouchEvent ( int handleState , gui : : UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> + void ListView : : interceptTouchEvent ( int handleState , Widget * sender , const Point & touchPoint ) <nl> { <nl> - UIScrollView : : interceptTouchEvent ( handleState , sender , touchPoint ) ; <nl> + ScrollView : : interceptTouchEvent ( handleState , sender , touchPoint ) ; <nl> if ( handleState ! = 1 ) <nl> { <nl> - UIWidget * parent = sender ; <nl> + Widget * parent = sender ; <nl> while ( parent ) <nl> { <nl> if ( parent & & parent - > getParent ( ) = = _innerContainer ) <nl> void UIListView : : interceptTouchEvent ( int handleState , gui : : UIWidget * sender , con <nl> _curSelectedIndex = getIndex ( parent ) ; <nl> break ; <nl> } <nl> - parent = parent - > getParent ( ) ; <nl> + parent = dynamic_cast < Widget * > ( parent - > getParent ( ) ) ; <nl> } <nl> selectedItemEvent ( ) ; <nl> } <nl> } <nl> <nl> - int UIListView : : getCurSelectedIndex ( ) const <nl> + int ListView : : getCurSelectedIndex ( ) const <nl> { <nl> return _curSelectedIndex ; <nl> } <nl> <nl> - void UIListView : : onSizeChanged ( ) <nl> + void ListView : : onSizeChanged ( ) <nl> { <nl> - UIScrollView : : onSizeChanged ( ) ; <nl> - refreshView ( ) ; <nl> + ScrollView : : onSizeChanged ( ) ; <nl> + _refreshViewDirty = true ; <nl> } <nl> <nl> - const char * UIListView : : getDescription ( ) const <nl> + std : : string ListView : : getDescription ( ) const <nl> { <nl> return " ListViewEx " ; <nl> } <nl> <nl> - UIWidget * UIListView : : createCloneInstance ( ) <nl> + Widget * ListView : : createCloneInstance ( ) <nl> { <nl> - return UIListView : : create ( ) ; <nl> + return ListView : : create ( ) ; <nl> } <nl> <nl> - void UIListView : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + void ListView : : copyClonedWidgetChildren ( Widget * model ) <nl> { <nl> - cocos2d : : ccArray * arrayItems = dynamic_cast < UIListView * > ( model ) - > getItems ( ) - > data ; <nl> - int length = arrayItems - > num ; <nl> + Vector < Widget * > arrayItems = getItems ( ) ; <nl> + <nl> + int length = arrayItems . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * item = ( UIWidget * ) ( arrayItems - > arr [ i ] ) ; <nl> + Widget * item = arrayItems . at ( i ) ; <nl> pushBackCustomItem ( item - > clone ( ) ) ; <nl> } <nl> } <nl> <nl> - void UIListView : : copySpecialProperties ( UIWidget * widget ) <nl> + void ListView : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UIListView * listViewEx = dynamic_cast < UIListView * > ( widget ) ; <nl> + ListView * listViewEx = dynamic_cast < ListView * > ( widget ) ; <nl> if ( listViewEx ) <nl> { <nl> - UIScrollView : : copySpecialProperties ( widget ) ; <nl> + ScrollView : : copySpecialProperties ( widget ) ; <nl> setItemModel ( listViewEx - > _model ) ; <nl> setItemsMargin ( listViewEx - > _itemsMargin ) ; <nl> setGravity ( listViewEx - > _gravity ) ; <nl> void UIListView : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> <nl> } <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIListView . h <nl> ppp b / cocos / gui / UIListView . h <nl> <nl> <nl> # include " gui / UIScrollView . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> typedef enum <nl> typedef enum <nl> LISTVIEW_ONSELECTEDITEM <nl> } ListViewEventType ; <nl> <nl> - typedef void ( cocos2d : : Object : : * SEL_ListViewEvent ) ( cocos2d : : Object * , ListViewEventType ) ; <nl> + typedef void ( Object : : * SEL_ListViewEvent ) ( Object * , ListViewEventType ) ; <nl> # define listvieweventselector ( _SELECTOR ) ( SEL_ListViewEvent ) ( & _SELECTOR ) <nl> <nl> - class UIListView : public UIScrollView <nl> + class ListView : public ScrollView <nl> { <nl> <nl> public : <nl> <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UIListView ( ) ; <nl> + ListView ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UIListView ( ) ; <nl> + virtual ~ ListView ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UIListView * create ( ) ; <nl> + static ListView * create ( ) ; <nl> <nl> / * * <nl> * Sets a item model for listview <nl> class UIListView : public UIScrollView <nl> * <nl> * @ param model item model for listview <nl> * / <nl> - void setItemModel ( UIWidget * model ) ; <nl> + void setItemModel ( Widget * model ) ; <nl> <nl> / * * <nl> * Push back a default item ( create by a cloned model ) into listview . <nl> class UIListView : public UIScrollView <nl> / * * <nl> * Push back custom item into listview . <nl> * / <nl> - void pushBackCustomItem ( UIWidget * item ) ; <nl> + void pushBackCustomItem ( Widget * item ) ; <nl> <nl> / * * <nl> * Insert custom item into listview . <nl> * / <nl> - void insertCustomItem ( UIWidget * item , int index ) ; <nl> + void insertCustomItem ( Widget * item , int index ) ; <nl> <nl> / * * <nl> * Removes the last item of listview . <nl> class UIListView : public UIScrollView <nl> * <nl> * @ return the item widget . <nl> * / <nl> - UIWidget * getItem ( unsigned int index ) ; <nl> + Widget * getItem ( unsigned int index ) ; <nl> <nl> / * * <nl> * Returns the item container . <nl> * / <nl> - cocos2d : : Array * getItems ( ) ; <nl> + Vector < Widget * > & getItems ( ) ; <nl> <nl> / * * <nl> * Returns the index of item . <nl> class UIListView : public UIScrollView <nl> * <nl> * @ return the index of item . <nl> * / <nl> - unsigned int getIndex ( UIWidget * item ) const ; <nl> + unsigned int getIndex ( Widget * item ) const ; <nl> <nl> / * * <nl> * Changes the gravity of listview . <nl> class UIListView : public UIScrollView <nl> * / <nl> void setItemsMargin ( float margin ) ; <nl> <nl> - / * * <nl> - * Refresh the view of list . <nl> - * <nl> - * If you change the data , you need to call this mathod . <nl> - * / <nl> - void refreshView ( ) ; <nl> + virtual void sortAllChildren ( ) override ; <nl> <nl> int getCurSelectedIndex ( ) const ; <nl> <nl> - void addEventListenerListView ( cocos2d : : Object * target , SEL_ListViewEvent selector ) ; <nl> + void addEventListenerListView ( Object * target , SEL_ListViewEvent selector ) ; <nl> <nl> / * * <nl> * Changes scroll direction of scrollview . <nl> class UIListView : public UIScrollView <nl> * / <nl> virtual void setDirection ( SCROLLVIEW_DIR dir ) override ; <nl> <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> protected : <nl> - virtual bool addChild ( UIWidget * widget ) override { return UIScrollView : : addChild ( widget ) ; } ; <nl> - virtual bool removeChild ( UIWidget * widget ) override { return UIScrollView : : removeChild ( widget ) ; } ; <nl> - virtual void removeAllChildren ( ) override { UIScrollView : : removeAllChildren ( ) ; } ; <nl> - virtual cocos2d : : Array * getChildren ( ) override { return UIScrollView : : getChildren ( ) ; } ; <nl> + virtual void addChild ( Node * child ) override { ScrollView : : addChild ( child ) ; } ; <nl> + virtual void addChild ( Node * child , int zOrder ) override { ScrollView : : addChild ( child , zOrder ) ; } ; <nl> + virtual void addChild ( Node * child , int zOrder , int tag ) override { ScrollView : : addChild ( child , zOrder , tag ) ; } ; <nl> + virtual void removeChild ( Node * widget , bool cleanup = true ) override { ScrollView : : removeChild ( widget , cleanup ) ; } ; <nl> + <nl> + virtual void removeAllChildren ( ) override { ScrollView : : removeAllChildren ( ) ; } ; <nl> + virtual Vector < Node * > & getChildren ( ) override { return ScrollView : : getChildren ( ) ; } ; <nl> + virtual const Vector < Node * > & getChildren ( ) const override { return ScrollView : : getChildren ( ) ; } ; <nl> virtual bool init ( ) override ; <nl> void updateInnerContainerSize ( ) ; <nl> - void remedyLayoutParameter ( UIWidget * item ) ; <nl> + void remedyLayoutParameter ( Widget * item ) ; <nl> virtual void onSizeChanged ( ) override ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> - virtual void copyClonedWidgetChildren ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> + virtual void copyClonedWidgetChildren ( Widget * model ) override ; <nl> void selectedItemEvent ( ) ; <nl> - virtual void interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) override ; <nl> + virtual void interceptTouchEvent ( int handleState , Widget * sender , const Point & touchPoint ) override ; <nl> + void refreshView ( ) ; <nl> protected : <nl> <nl> - UIWidget * _model ; <nl> - cocos2d : : Array * _items ; <nl> + Widget * _model ; <nl> + Vector < Widget * > _items ; <nl> ListViewGravity _gravity ; <nl> float _itemsMargin ; <nl> - cocos2d : : Object * _listViewEventListener ; <nl> + Object * _listViewEventListener ; <nl> SEL_ListViewEvent _listViewEventSelector ; <nl> int _curSelectedIndex ; <nl> + bool _refreshViewDirty ; <nl> } ; <nl> <nl> } <nl> + NS_CC_END <nl> <nl> - # endif / * defined ( __UIListView__ ) * / <nl> + # endif / * defined ( __ListView__ ) * / <nl> mmm a / cocos / gui / UILoadingBar . cpp <nl> ppp b / cocos / gui / UILoadingBar . cpp <nl> <nl> # include " gui / UILoadingBar . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> - namespace gui { <nl> - <nl> + NS_CC_BEGIN <nl> <nl> - # define DYNAMIC_CAST_CCSPRITE dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) <nl> - <nl> - UILoadingBar : : UILoadingBar ( ) : <nl> + namespace gui { <nl> + <nl> + # define BARRENDERERZ ( - 1 ) <nl> + <nl> + LoadingBar : : LoadingBar ( ) : <nl> _barType ( LoadingBarTypeLeft ) , <nl> _percent ( 100 ) , <nl> _totalLength ( 0 ) , <nl> _barRenderer ( nullptr ) , <nl> _renderBarTexType ( UI_TEX_TYPE_LOCAL ) , <nl> - _barRendererTextureSize ( cocos2d : : Size : : ZERO ) , <nl> + _barRendererTextureSize ( Size : : ZERO ) , <nl> _scale9Enabled ( false ) , <nl> _prevIgnoreSize ( true ) , <nl> - _capInsets ( cocos2d : : Rect : : ZERO ) , <nl> + _capInsets ( Rect : : ZERO ) , <nl> _textureFile ( " " ) <nl> { <nl> } <nl> <nl> - UILoadingBar : : ~ UILoadingBar ( ) <nl> + LoadingBar : : ~ LoadingBar ( ) <nl> { <nl> <nl> } <nl> <nl> - UILoadingBar * UILoadingBar : : create ( ) <nl> + LoadingBar * LoadingBar : : create ( ) <nl> { <nl> - UILoadingBar * widget = new UILoadingBar ( ) ; <nl> + LoadingBar * widget = new LoadingBar ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UILoadingBar * UILoadingBar : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - void UILoadingBar : : initRenderer ( ) <nl> + void LoadingBar : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> - _barRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _renderer - > addChild ( _barRenderer ) ; <nl> - _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0 , 0 . 5 ) ) ; <nl> + _barRenderer = Sprite : : create ( ) ; <nl> + Node : : addChild ( _barRenderer , BARRENDERERZ , - 1 ) ; <nl> + _barRenderer - > setAnchorPoint ( Point ( 0 . 0 , 0 . 5 ) ) ; <nl> } <nl> <nl> - void UILoadingBar : : setDirection ( LoadingBarType dir ) <nl> + void LoadingBar : : setDirection ( LoadingBarType dir ) <nl> { <nl> if ( _barType = = dir ) <nl> { <nl> void UILoadingBar : : setDirection ( LoadingBarType dir ) <nl> switch ( _barType ) <nl> { <nl> case LoadingBarTypeLeft : <nl> - _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0f , 0 . 5f ) ) ; <nl> - _barRenderer - > setPosition ( cocos2d : : Point ( - _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setPosition ( Point ( - _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setFlippedX ( false ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setFlippedX ( false ) ; <nl> } <nl> break ; <nl> case LoadingBarTypeRight : <nl> - _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 1 . 0f , 0 . 5f ) ) ; <nl> - _barRenderer - > setPosition ( cocos2d : : Point ( _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( Point ( 1 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setPosition ( Point ( _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setFlippedX ( true ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setFlippedX ( true ) ; <nl> } <nl> break ; <nl> } <nl> } <nl> <nl> - int UILoadingBar : : getDirection ( ) <nl> + int LoadingBar : : getDirection ( ) <nl> { <nl> return _barType ; <nl> } <nl> <nl> - void UILoadingBar : : loadTexture ( const char * texture , TextureResType texType ) <nl> + void LoadingBar : : loadTexture ( const char * texture , TextureResType texType ) <nl> { <nl> if ( ! texture | | strcmp ( texture , " " ) = = 0 ) <nl> { <nl> void UILoadingBar : : loadTexture ( const char * texture , TextureResType texType ) <nl> case UI_TEX_TYPE_LOCAL : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > initWithFile ( texture ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( _capInsets ) ; <nl> + extension : : Scale9Sprite * barRendererScale9 = static_cast < extension : : Scale9Sprite * > ( _barRenderer ) ; <nl> + barRendererScale9 - > initWithFile ( texture ) ; <nl> + barRendererScale9 - > setCapInsets ( _capInsets ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setTexture ( texture ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setTexture ( texture ) ; <nl> } <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( texture ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( _capInsets ) ; <nl> + extension : : Scale9Sprite * barRendererScale9 = static_cast < extension : : Scale9Sprite * > ( _barRenderer ) ; <nl> + barRendererScale9 - > initWithSpriteFrameName ( texture ) ; <nl> + barRendererScale9 - > setCapInsets ( _capInsets ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setSpriteFrame ( texture ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setSpriteFrame ( texture ) ; <nl> } <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - if ( _scale9Enabled ) <nl> - { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - <nl> - } <nl> - else <nl> - { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - } <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> _barRendererTextureSize = _barRenderer - > getContentSize ( ) ; <nl> <nl> switch ( _barType ) <nl> { <nl> case LoadingBarTypeLeft : <nl> - _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setFlippedX ( false ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setFlippedX ( false ) ; <nl> } <nl> break ; <nl> case LoadingBarTypeRight : <nl> - _barRenderer - > setAnchorPoint ( cocos2d : : Point ( 1 . 0f , 0 . 5f ) ) ; <nl> + _barRenderer - > setAnchorPoint ( Point ( 1 . 0f , 0 . 5f ) ) ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setFlippedX ( true ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setFlippedX ( true ) ; <nl> } <nl> break ; <nl> } <nl> barRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILoadingBar : : setScale9Enabled ( bool enabled ) <nl> + void LoadingBar : : setScale9Enabled ( bool enabled ) <nl> { <nl> if ( _scale9Enabled = = enabled ) <nl> { <nl> return ; <nl> } <nl> _scale9Enabled = enabled ; <nl> - _renderer - > removeChild ( _barRenderer , true ) ; <nl> + Node : : removeChild ( _barRenderer ) ; <nl> _barRenderer = nullptr ; <nl> if ( _scale9Enabled ) <nl> { <nl> - _barRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _barRenderer = extension : : Scale9Sprite : : create ( ) ; <nl> } <nl> else <nl> { <nl> - _barRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _barRenderer = Sprite : : create ( ) ; <nl> } <nl> loadTexture ( _textureFile . c_str ( ) , _renderBarTexType ) ; <nl> - _renderer - > addChild ( _barRenderer ) ; <nl> + Node : : addChild ( _barRenderer , BARRENDERERZ , - 1 ) ; <nl> if ( _scale9Enabled ) <nl> { <nl> bool ignoreBefore = _ignoreSize ; <nl> void UILoadingBar : : setScale9Enabled ( bool enabled ) <nl> setCapInsets ( _capInsets ) ; <nl> } <nl> <nl> - void UILoadingBar : : setCapInsets ( const cocos2d : : Rect & capInsets ) <nl> + void LoadingBar : : setCapInsets ( const Rect & capInsets ) <nl> { <nl> _capInsets = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( capInsets ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UILoadingBar : : setPercent ( int percent ) <nl> + void LoadingBar : : setPercent ( int percent ) <nl> { <nl> if ( percent < 0 | | percent > 100 ) <nl> { <nl> void UILoadingBar : : setPercent ( int percent ) <nl> { <nl> case UI_TEX_TYPE_PLIST : <nl> { <nl> - cocos2d : : Sprite * barNode = DYNAMIC_CAST_CCSPRITE ; <nl> + Sprite * barNode = dynamic_cast < Sprite * > ( _barRenderer ) ; <nl> if ( barNode ) <nl> { <nl> - cocos2d : : Point to = barNode - > getTextureRect ( ) . origin ; <nl> + Point to = barNode - > getTextureRect ( ) . origin ; <nl> x = to . x ; <nl> y = to . y ; <nl> } <nl> void UILoadingBar : : setPercent ( int percent ) <nl> } <nl> else <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setTextureRect ( cocos2d : : Rect ( x , y , _barRendererTextureSize . width * res , _barRendererTextureSize . height ) ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setTextureRect ( Rect ( x , y , _barRendererTextureSize . width * res , _barRendererTextureSize . height ) ) ; <nl> } <nl> } <nl> <nl> - int UILoadingBar : : getPercent ( ) <nl> + int LoadingBar : : getPercent ( ) <nl> { <nl> return _percent ; <nl> } <nl> <nl> - void UILoadingBar : : onSizeChanged ( ) <nl> + void LoadingBar : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> barRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UILoadingBar : : ignoreContentAdaptWithSize ( bool ignore ) <nl> + void LoadingBar : : ignoreContentAdaptWithSize ( bool ignore ) <nl> { <nl> if ( ! _scale9Enabled | | ( _scale9Enabled & & ! ignore ) ) <nl> { <nl> - UIWidget : : ignoreContentAdaptWithSize ( ignore ) ; <nl> + Widget : : ignoreContentAdaptWithSize ( ignore ) ; <nl> _prevIgnoreSize = ignore ; <nl> } <nl> } <nl> <nl> - const cocos2d : : Size & UILoadingBar : : getContentSize ( ) const <nl> + const Size & LoadingBar : : getContentSize ( ) const <nl> { <nl> return _barRendererTextureSize ; <nl> } <nl> <nl> - cocos2d : : Node * UILoadingBar : : getVirtualRenderer ( ) <nl> + Node * LoadingBar : : getVirtualRenderer ( ) <nl> { <nl> return _barRenderer ; <nl> } <nl> <nl> - void UILoadingBar : : barRendererScaleChangedWithSize ( ) <nl> + void LoadingBar : : barRendererScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UILoadingBar : : barRendererScaleChangedWithSize ( ) <nl> else <nl> { <nl> <nl> - cocos2d : : Size textureSize = _barRendererTextureSize ; <nl> + Size textureSize = _barRendererTextureSize ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _barRenderer - > setScale ( 1 . 0f ) ; <nl> void UILoadingBar : : barRendererScaleChangedWithSize ( ) <nl> switch ( _barType ) <nl> { <nl> case LoadingBarTypeLeft : <nl> - _barRenderer - > setPosition ( cocos2d : : Point ( - _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _barRenderer - > setPosition ( Point ( - _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> break ; <nl> case LoadingBarTypeRight : <nl> - _barRenderer - > setPosition ( cocos2d : : Point ( _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _barRenderer - > setPosition ( Point ( _totalLength * 0 . 5f , 0 . 0f ) ) ; <nl> break ; <nl> default : <nl> break ; <nl> } <nl> } <nl> <nl> - void UILoadingBar : : setScale9Scale ( ) <nl> + void LoadingBar : : setScale9Scale ( ) <nl> { <nl> float width = ( float ) ( _percent ) / 100 * _totalLength ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setPreferredSize ( cocos2d : : Size ( width , _size . height ) ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _barRenderer ) - > setPreferredSize ( Size ( width , _size . height ) ) ; <nl> } <nl> <nl> - const char * UILoadingBar : : getDescription ( ) const <nl> + std : : string LoadingBar : : getDescription ( ) const <nl> { <nl> return " LoadingBar " ; <nl> } <nl> <nl> - UIWidget * UILoadingBar : : createCloneInstance ( ) <nl> + Widget * LoadingBar : : createCloneInstance ( ) <nl> { <nl> - return UILoadingBar : : create ( ) ; <nl> + return LoadingBar : : create ( ) ; <nl> } <nl> <nl> - void UILoadingBar : : copySpecialProperties ( UIWidget * widget ) <nl> + void LoadingBar : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UILoadingBar * loadingBar = dynamic_cast < UILoadingBar * > ( widget ) ; <nl> + LoadingBar * loadingBar = dynamic_cast < LoadingBar * > ( widget ) ; <nl> if ( loadingBar ) <nl> { <nl> _prevIgnoreSize = loadingBar - > _prevIgnoreSize ; <nl> void UILoadingBar : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UILoadingBar . h <nl> ppp b / cocos / gui / UILoadingBar . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> typedef enum <nl> typedef enum <nl> LoadingBarTypeLeft , <nl> LoadingBarTypeRight <nl> } LoadingBarType ; <nl> - <nl> - class UILoadingBar : public UIWidget <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class LoadingBar : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UILoadingBar ( ) ; <nl> + LoadingBar ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UILoadingBar ( ) ; <nl> + virtual ~ LoadingBar ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UILoadingBar * create ( ) ; <nl> + static LoadingBar * create ( ) ; <nl> <nl> / * * <nl> * Changes the progress direction of loadingbar . <nl> class UILoadingBar : public UIWidget <nl> * <nl> * @ param capInsets capinsets for loadingbar <nl> * / <nl> - void setCapInsets ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsets ( const Rect & capInsets ) ; <nl> <nl> / / override " ignoreContentAdaptWithSize " method of widget . <nl> virtual void ignoreContentAdaptWithSize ( bool ignore ) override ; <nl> <nl> / / override " getContentSize " method of widget . <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> <nl> / / override " getVirtualRenderer " method of widget . <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> protected : <nl> virtual void initRenderer ( ) override ; <nl> virtual void onSizeChanged ( ) override ; <nl> void setScale9Scale ( ) ; <nl> void barRendererScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> LoadingBarType _barType ; <nl> int _percent ; <nl> float _totalLength ; <nl> - cocos2d : : Node * _barRenderer ; <nl> + Node * _barRenderer ; <nl> TextureResType _renderBarTexType ; <nl> - cocos2d : : Size _barRendererTextureSize ; <nl> + Size _barRendererTextureSize ; <nl> bool _scale9Enabled ; <nl> bool _prevIgnoreSize ; <nl> - cocos2d : : Rect _capInsets ; <nl> + Rect _capInsets ; <nl> std : : string _textureFile ; <nl> } ; <nl> <nl> } <nl> - <nl> - # endif / * defined ( __CocoGUI__UILoadingBar__ ) * / <nl> + NS_CC_END <nl> + # endif / * defined ( __CocoGUI__LoadingBar__ ) * / <nl> mmm a / cocos / gui / UIPageView . cpp <nl> ppp b / cocos / gui / UIPageView . cpp <nl> <nl> <nl> # include " gui / UIPageView . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> - UIPageView : : UIPageView ( ) : <nl> + PageView : : PageView ( ) : <nl> _curPageIdx ( 0 ) , <nl> - _pages ( nullptr ) , <nl> _touchMoveDir ( PAGEVIEW_TOUCHLEFT ) , <nl> _touchStartLocation ( 0 . 0f ) , <nl> _touchMoveStartLocation ( 0 . 0f ) , <nl> - _movePagePoint ( cocos2d : : Point : : ZERO ) , <nl> + _movePagePoint ( Point : : ZERO ) , <nl> _leftChild ( nullptr ) , <nl> _rightChild ( nullptr ) , <nl> _leftBoundary ( 0 . 0f ) , <nl> _pageViewEventSelector ( nullptr ) <nl> { <nl> } <nl> <nl> - UIPageView : : ~ UIPageView ( ) <nl> + PageView : : ~ PageView ( ) <nl> { <nl> - _pages - > removeAllObjects ( ) ; <nl> - CC_SAFE_RELEASE ( _pages ) ; <nl> + _pages . clear ( ) ; <nl> _pageViewEventListener = nullptr ; <nl> _pageViewEventSelector = nullptr ; <nl> } <nl> <nl> - UIPageView * UIPageView : : create ( ) <nl> + PageView * PageView : : create ( ) <nl> { <nl> - UIPageView * widget = new UIPageView ( ) ; <nl> + PageView * widget = new PageView ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UIPageView * UIPageView : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UIPageView : : init ( ) <nl> + bool PageView : : init ( ) <nl> { <nl> - if ( UILayout : : init ( ) ) <nl> + if ( Layout : : init ( ) ) <nl> { <nl> - _pages = cocos2d : : Array : : create ( ) ; <nl> - _pages - > retain ( ) ; <nl> setClippingEnabled ( true ) ; <nl> setUpdateEnabled ( true ) ; <nl> setTouchEnabled ( true ) ; <nl> bool UIPageView : : init ( ) <nl> return false ; <nl> } <nl> <nl> - void UIPageView : : addWidgetToPage ( UIWidget * widget , int pageIdx , bool forceCreate ) <nl> + void PageView : : addWidgetToPage ( Widget * widget , int pageIdx , bool forceCreate ) <nl> { <nl> if ( ! widget ) <nl> { <nl> void UIPageView : : addWidgetToPage ( UIWidget * widget , int pageIdx , bool forceCreate <nl> { <nl> return ; <nl> } <nl> - ssize_t pageCount = _pages - > count ( ) ; <nl> + int pageCount = _pages . size ( ) ; <nl> if ( pageIdx < 0 | | pageIdx > = pageCount ) <nl> { <nl> if ( forceCreate ) <nl> void UIPageView : : addWidgetToPage ( UIWidget * widget , int pageIdx , bool forceCreate <nl> { <nl> CCLOG ( " pageIdx is % d , it will be added as page id [ % d ] " , pageIdx , pageCount ) ; <nl> } <nl> - UILayout * newPage = createPage ( ) ; <nl> + Layout * newPage = createPage ( ) ; <nl> newPage - > addChild ( widget ) ; <nl> addPage ( newPage ) ; <nl> } <nl> } <nl> else <nl> { <nl> - UILayout * page = dynamic_cast < UILayout * > ( _pages - > getObjectAtIndex ( pageIdx ) ) ; <nl> - if ( page ) <nl> - { <nl> - page - > addChild ( widget ) ; <nl> - } <nl> + Layout * page = _pages . at ( pageIdx ) ; <nl> + page - > addChild ( widget ) ; <nl> } <nl> } <nl> <nl> - UILayout * UIPageView : : createPage ( ) <nl> + Layout * PageView : : createPage ( ) <nl> { <nl> - UILayout * newPage = UILayout : : create ( ) ; <nl> + Layout * newPage = Layout : : create ( ) ; <nl> newPage - > setSize ( getSize ( ) ) ; <nl> return newPage ; <nl> } <nl> <nl> - void UIPageView : : addPage ( UILayout * page ) <nl> + void PageView : : addPage ( Layout * page ) <nl> { <nl> if ( ! page ) <nl> { <nl> void UIPageView : : addPage ( UILayout * page ) <nl> { <nl> return ; <nl> } <nl> - if ( _pages - > containsObject ( page ) ) <nl> + if ( _pages . contains ( page ) ) <nl> { <nl> return ; <nl> } <nl> - cocos2d : : Size pSize = page - > getSize ( ) ; <nl> - cocos2d : : Size pvSize = getSize ( ) ; <nl> + Size pSize = page - > getSize ( ) ; <nl> + Size pvSize = getSize ( ) ; <nl> if ( ! pSize . equals ( pvSize ) ) <nl> { <nl> CCLOG ( " page size does not match pageview size , it will be force sized ! " ) ; <nl> page - > setSize ( pvSize ) ; <nl> } <nl> - page - > setPosition ( cocos2d : : Point ( getPositionXByIndex ( _pages - > count ( ) ) , 0 ) ) ; <nl> - _pages - > addObject ( page ) ; <nl> + page - > setPosition ( Point ( getPositionXByIndex ( _pages . size ( ) ) , 0 ) ) ; <nl> + _pages . pushBack ( page ) ; <nl> addChild ( page ) ; <nl> updateBoundaryPages ( ) ; <nl> } <nl> <nl> - void UIPageView : : insertPage ( UILayout * page , int idx ) <nl> + void PageView : : insertPage ( Layout * page , int idx ) <nl> { <nl> if ( idx < 0 ) <nl> { <nl> void UIPageView : : insertPage ( UILayout * page , int idx ) <nl> { <nl> return ; <nl> } <nl> - if ( _pages - > containsObject ( page ) ) <nl> + if ( _pages . contains ( page ) ) <nl> { <nl> return ; <nl> } <nl> <nl> - ssize_t pageCount = _pages - > count ( ) ; <nl> + int pageCount = _pages . size ( ) ; <nl> if ( idx > = pageCount ) <nl> { <nl> addPage ( page ) ; <nl> } <nl> else <nl> { <nl> - _pages - > insertObject ( page , idx ) ; <nl> - page - > setPosition ( cocos2d : : Point ( getPositionXByIndex ( idx ) , 0 ) ) ; <nl> + _pages . insert ( idx , page ) ; <nl> + page - > setPosition ( Point ( getPositionXByIndex ( idx ) , 0 ) ) ; <nl> addChild ( page ) ; <nl> - cocos2d : : Size pSize = page - > getSize ( ) ; <nl> - cocos2d : : Size pvSize = getSize ( ) ; <nl> + Size pSize = page - > getSize ( ) ; <nl> + Size pvSize = getSize ( ) ; <nl> if ( ! pSize . equals ( pvSize ) ) <nl> { <nl> CCLOG ( " page size does not match pageview size , it will be force sized ! " ) ; <nl> page - > setSize ( pvSize ) ; <nl> } <nl> - cocos2d : : ccArray * arrayPages = _pages - > data ; <nl> - ssize_t length = arrayPages - > num ; <nl> + int length = _pages . size ( ) ; <nl> for ( int i = ( idx + 1 ) ; i < length ; i + + ) { <nl> - UIWidget * behindPage = dynamic_cast < UIWidget * > ( arrayPages - > arr [ i ] ) ; <nl> - cocos2d : : Point formerPos = behindPage - > getPosition ( ) ; <nl> - behindPage - > setPosition ( cocos2d : : Point ( formerPos . x + getSize ( ) . width , 0 ) ) ; <nl> + Widget * behindPage = _pages . at ( i ) ; <nl> + Point formerPos = behindPage - > getPosition ( ) ; <nl> + behindPage - > setPosition ( Point ( formerPos . x + getSize ( ) . width , 0 ) ) ; <nl> } <nl> updateBoundaryPages ( ) ; <nl> } <nl> } <nl> <nl> - void UIPageView : : removePage ( UILayout * page ) <nl> + void PageView : : removePage ( Layout * page ) <nl> { <nl> if ( ! page ) <nl> { <nl> void UIPageView : : removePage ( UILayout * page ) <nl> updateBoundaryPages ( ) ; <nl> } <nl> <nl> - void UIPageView : : removePageAtIndex ( int index ) <nl> + void PageView : : removePageAtIndex ( int index ) <nl> { <nl> - if ( index < 0 | | index > = ( int ) ( _pages - > count ( ) ) ) <nl> + if ( index < 0 | | index > = ( int ) ( _pages . size ( ) ) ) <nl> { <nl> return ; <nl> } <nl> - UILayout * page = dynamic_cast < UILayout * > ( _pages - > getObjectAtIndex ( index ) ) ; <nl> - if ( page ) <nl> - { <nl> - removePage ( page ) ; <nl> - } <nl> + Layout * page = _pages . at ( index ) ; <nl> + removePage ( page ) ; <nl> } <nl> <nl> - void UIPageView : : removeAllPages ( ) <nl> + void PageView : : removeAllPages ( ) <nl> { <nl> removeAllChildren ( ) ; <nl> } <nl> <nl> - void UIPageView : : updateBoundaryPages ( ) <nl> + void PageView : : updateBoundaryPages ( ) <nl> { <nl> - if ( _pages - > count ( ) < = 0 ) <nl> + if ( _pages . size ( ) < = 0 ) <nl> { <nl> _leftChild = nullptr ; <nl> _rightChild = nullptr ; <nl> return ; <nl> } <nl> - _leftChild = dynamic_cast < UIWidget * > ( _pages - > getObjectAtIndex ( 0 ) ) ; <nl> - _rightChild = dynamic_cast < UIWidget * > ( _pages - > getLastObject ( ) ) ; <nl> + _leftChild = _pages . at ( 0 ) ; <nl> + _rightChild = _pages . at ( _pages . size ( ) - 1 ) ; <nl> } <nl> <nl> - float UIPageView : : getPositionXByIndex ( int idx ) <nl> + float PageView : : getPositionXByIndex ( int idx ) <nl> { <nl> return ( getSize ( ) . width * ( idx - _curPageIdx ) ) ; <nl> } <nl> + <nl> + void PageView : : addChild ( Node * child ) <nl> + { <nl> + Layout : : addChild ( child ) ; <nl> + } <nl> <nl> - bool UIPageView : : addChild ( UIWidget * widget ) <nl> + void PageView : : addChild ( Node * child , int zOrder ) <nl> { <nl> - return UILayout : : addChild ( widget ) ; <nl> + Layout : : addChild ( child , zOrder ) ; <nl> } <nl> <nl> - bool UIPageView : : removeChild ( UIWidget * widget ) <nl> + void PageView : : addChild ( Node * child , int zOrder , int tag ) <nl> { <nl> - if ( _pages - > containsObject ( widget ) ) <nl> + Layout : : addChild ( child , zOrder , tag ) ; <nl> + } <nl> + <nl> + void PageView : : removeChild ( Node * child , bool cleanup ) <nl> + { <nl> + if ( _pages . contains ( static_cast < Layout * > ( child ) ) ) <nl> { <nl> - _pages - > removeObject ( widget ) ; <nl> + _pages . eraseObject ( static_cast < Layout * > ( child ) ) ; <nl> } <nl> - return UILayout : : removeChild ( widget ) ; <nl> + Layout : : removeChild ( child , cleanup ) ; <nl> } <nl> <nl> - void UIPageView : : onSizeChanged ( ) <nl> + void PageView : : onSizeChanged ( ) <nl> { <nl> - UILayout : : onSizeChanged ( ) ; <nl> + Layout : : onSizeChanged ( ) ; <nl> _rightBoundary = getSize ( ) . width ; <nl> updateChildrenSize ( ) ; <nl> updateChildrenPosition ( ) ; <nl> } <nl> <nl> - void UIPageView : : updateChildrenSize ( ) <nl> + void PageView : : updateChildrenSize ( ) <nl> { <nl> - if ( ! _pages ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - cocos2d : : Size selfSize = getSize ( ) ; <nl> - for ( long i = 0 ; i < _pages - > count ( ) ; i + + ) <nl> + Size selfSize = getSize ( ) ; <nl> + int length = _pages . size ( ) ; <nl> + for ( long i = 0 ; i < length ; i + + ) <nl> { <nl> - UILayout * page = dynamic_cast < UILayout * > ( _pages - > getObjectAtIndex ( i ) ) ; <nl> + Layout * page = _pages . at ( i ) ; <nl> page - > setSize ( selfSize ) ; <nl> } <nl> } <nl> <nl> - void UIPageView : : updateChildrenPosition ( ) <nl> + void PageView : : updateChildrenPosition ( ) <nl> { <nl> - if ( ! _pages ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - ssize_t pageCount = _pages - > data - > num ; <nl> + int pageCount = _pages . size ( ) ; <nl> if ( pageCount < = 0 ) <nl> { <nl> _curPageIdx = 0 ; <nl> void UIPageView : : updateChildrenPosition ( ) <nl> _curPageIdx = pageCount - 1 ; <nl> } <nl> float pageWidth = getSize ( ) . width ; <nl> - cocos2d : : ccArray * arrayPages = _pages - > data ; <nl> for ( int i = 0 ; i < pageCount ; i + + ) <nl> { <nl> - UILayout * page = dynamic_cast < UILayout * > ( arrayPages - > arr [ i ] ) ; <nl> - page - > setPosition ( cocos2d : : Point ( ( i - _curPageIdx ) * pageWidth , 0 ) ) ; <nl> + Layout * page = _pages . at ( i ) ; <nl> + page - > setPosition ( Point ( ( i - _curPageIdx ) * pageWidth , 0 ) ) ; <nl> } <nl> } <nl> <nl> - void UIPageView : : removeAllChildren ( ) <nl> + void PageView : : removeAllChildren ( ) <nl> { <nl> - _pages - > removeAllObjects ( ) ; <nl> - UILayout : : removeAllChildren ( ) ; <nl> + _pages . clear ( ) ; <nl> + Layout : : removeAllChildren ( ) ; <nl> } <nl> <nl> - void UIPageView : : scrollToPage ( int idx ) <nl> + void PageView : : scrollToPage ( int idx ) <nl> { <nl> - if ( idx < 0 | | idx > = ( int ) ( _pages - > count ( ) ) ) <nl> + if ( idx < 0 | | idx > = ( int ) ( _pages . size ( ) ) ) <nl> { <nl> return ; <nl> } <nl> _curPageIdx = idx ; <nl> - UIWidget * curPage = dynamic_cast < UIWidget * > ( _pages - > getObjectAtIndex ( idx ) ) ; <nl> + Widget * curPage = _pages . at ( idx ) ; <nl> _autoScrollDistance = - ( curPage - > getPosition ( ) . x ) ; <nl> _autoScrollSpeed = fabs ( _autoScrollDistance ) / 0 . 2f ; <nl> _autoScrollDir = _autoScrollDistance > 0 ? 1 : 0 ; <nl> _isAutoScrolling = true ; <nl> } <nl> <nl> - void UIPageView : : update ( float dt ) <nl> + void PageView : : update ( float dt ) <nl> { <nl> if ( _isAutoScrolling ) <nl> { <nl> void UIPageView : : update ( float dt ) <nl> } <nl> } <nl> <nl> - bool UIPageView : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> + bool PageView : : onTouchBegan ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - bool pass = UILayout : : onTouchBegan ( touchPoint ) ; <nl> - handlePressLogic ( touchPoint ) ; <nl> + bool pass = Layout : : onTouchBegan ( touch , unusedEvent ) ; <nl> + if ( _hitted ) <nl> + { <nl> + handlePressLogic ( touch - > getLocation ( ) ) ; <nl> + } <nl> return pass ; <nl> } <nl> <nl> - void UIPageView : : onTouchMoved ( const cocos2d : : Point & touchPoint ) <nl> + void PageView : : onTouchMoved ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - _touchMovePos . x = touchPoint . x ; <nl> - _touchMovePos . y = touchPoint . y ; <nl> - handleMoveLogic ( touchPoint ) ; <nl> - if ( _widgetParent ) <nl> + _touchMovePos = touch - > getLocation ( ) ; <nl> + handleMoveLogic ( _touchMovePos ) ; <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - _widgetParent - > checkChildInfo ( 1 , this , touchPoint ) ; <nl> + widgetParent - > checkChildInfo ( 1 , this , _touchMovePos ) ; <nl> } <nl> moveEvent ( ) ; <nl> - if ( ! hitTest ( touchPoint ) ) <nl> + if ( ! hitTest ( _touchMovePos ) ) <nl> { <nl> setFocused ( false ) ; <nl> - onTouchEnded ( touchPoint ) ; <nl> + onTouchEnded ( touch , unusedEvent ) ; <nl> } <nl> } <nl> <nl> - void UIPageView : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> + void PageView : : onTouchEnded ( Touch * touch , Event * unusedEvent ) <nl> + { <nl> + Layout : : onTouchEnded ( touch , unusedEvent ) ; <nl> + handleReleaseLogic ( _touchEndPos ) ; <nl> + } <nl> + <nl> + void PageView : : onTouchCancelled ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - UILayout : : onTouchEnded ( touchPoint ) ; <nl> - handleReleaseLogic ( touchPoint ) ; <nl> + Layout : : onTouchCancelled ( touch , unusedEvent ) ; <nl> + handleReleaseLogic ( touch - > getLocation ( ) ) ; <nl> } <nl> <nl> - void UIPageView : : movePages ( float offset ) <nl> + void PageView : : movePages ( float offset ) <nl> { <nl> - cocos2d : : ccArray * arrayPages = _pages - > data ; <nl> - ssize_t length = arrayPages - > num ; <nl> + int length = _pages . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = ( UIWidget * ) ( arrayPages - > arr [ i ] ) ; <nl> + Widget * child = _pages . at ( i ) ; <nl> _movePagePoint . x = child - > getPosition ( ) . x + offset ; <nl> _movePagePoint . y = child - > getPosition ( ) . y ; <nl> child - > setPosition ( _movePagePoint ) ; <nl> } <nl> } <nl> <nl> - bool UIPageView : : scrollPages ( float touchOffset ) <nl> + bool PageView : : scrollPages ( float touchOffset ) <nl> { <nl> - if ( _pages - > count ( ) < = 0 ) <nl> + if ( _pages . size ( ) < = 0 ) <nl> { <nl> return false ; <nl> } <nl> bool UIPageView : : scrollPages ( float touchOffset ) <nl> return true ; <nl> } <nl> <nl> - void UIPageView : : onTouchCancelled ( const cocos2d : : Point & touchPoint ) <nl> + void PageView : : handlePressLogic ( const Point & touchPoint ) <nl> { <nl> - UILayout : : onTouchCancelled ( touchPoint ) ; <nl> - } <nl> - <nl> - void UIPageView : : handlePressLogic ( const cocos2d : : Point & touchPoint ) <nl> - { <nl> - cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + Point nsp = convertToNodeSpace ( touchPoint ) ; <nl> _touchMoveStartLocation = nsp . x ; <nl> _touchStartLocation = nsp . x ; <nl> } <nl> <nl> - void UIPageView : : handleMoveLogic ( const cocos2d : : Point & touchPoint ) <nl> + void PageView : : handleMoveLogic ( const Point & touchPoint ) <nl> { <nl> - cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + Point nsp = convertToNodeSpace ( touchPoint ) ; <nl> float offset = 0 . 0 ; <nl> float moveX = nsp . x ; <nl> offset = moveX - _touchMoveStartLocation ; <nl> void UIPageView : : handleMoveLogic ( const cocos2d : : Point & touchPoint ) <nl> scrollPages ( offset ) ; <nl> } <nl> <nl> - void UIPageView : : handleReleaseLogic ( const cocos2d : : Point & touchPoint ) <nl> + void PageView : : handleReleaseLogic ( const Point & touchPoint ) <nl> { <nl> - if ( _pages - > count ( ) < = 0 ) <nl> + if ( _pages . size ( ) < = 0 ) <nl> { <nl> return ; <nl> } <nl> - UIWidget * curPage = dynamic_cast < UIWidget * > ( _pages - > getObjectAtIndex ( _curPageIdx ) ) ; <nl> + Widget * curPage = _pages . at ( _curPageIdx ) ; <nl> if ( curPage ) <nl> { <nl> - cocos2d : : Point curPagePos = curPage - > getPosition ( ) ; <nl> - ssize_t pageCount = _pages - > count ( ) ; <nl> + Point curPagePos = curPage - > getPosition ( ) ; <nl> + int pageCount = _pages . size ( ) ; <nl> float curPageLocation = curPagePos . x ; <nl> float pageWidth = getSize ( ) . width ; <nl> float boundary = pageWidth / 2 . 0f ; <nl> void UIPageView : : handleReleaseLogic ( const cocos2d : : Point & touchPoint ) <nl> } <nl> } <nl> <nl> - void UIPageView : : checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> + void PageView : : checkChildInfo ( int handleState , Widget * sender , const Point & touchPoint ) <nl> { <nl> interceptTouchEvent ( handleState , sender , touchPoint ) ; <nl> } <nl> <nl> - void UIPageView : : interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> + void PageView : : interceptTouchEvent ( int handleState , Widget * sender , const Point & touchPoint ) <nl> { <nl> switch ( handleState ) <nl> { <nl> void UIPageView : : interceptTouchEvent ( int handleState , UIWidget * sender , const co <nl> } <nl> } <nl> <nl> - void UIPageView : : pageTurningEvent ( ) <nl> + void PageView : : pageTurningEvent ( ) <nl> { <nl> if ( _pageViewEventListener & & _pageViewEventSelector ) <nl> { <nl> void UIPageView : : pageTurningEvent ( ) <nl> } <nl> } <nl> <nl> - void UIPageView : : addEventListenerPageView ( cocos2d : : Object * target , SEL_PageViewEvent selector ) <nl> + void PageView : : addEventListenerPageView ( Object * target , SEL_PageViewEvent selector ) <nl> { <nl> _pageViewEventListener = target ; <nl> _pageViewEventSelector = selector ; <nl> } <nl> <nl> - int UIPageView : : getCurPageIndex ( ) const <nl> + int PageView : : getCurPageIndex ( ) const <nl> { <nl> return _curPageIdx ; <nl> } <nl> <nl> - cocos2d : : Array * UIPageView : : getPages ( ) <nl> + Vector < Layout * > & PageView : : getPages ( ) <nl> { <nl> return _pages ; <nl> } <nl> <nl> - UILayout * UIPageView : : getPage ( int index ) <nl> + Layout * PageView : : getPage ( int index ) <nl> { <nl> - if ( index < 0 | | index > = ( int ) ( _pages - > count ( ) ) ) <nl> + if ( index < 0 | | index > = ( int ) ( _pages . size ( ) ) ) <nl> { <nl> return nullptr ; <nl> } <nl> - return ( UILayout * ) _pages - > getObjectAtIndex ( index ) ; <nl> + return _pages . at ( index ) ; <nl> } <nl> <nl> - const char * UIPageView : : getDescription ( ) const <nl> + std : : string PageView : : getDescription ( ) const <nl> { <nl> return " PageView " ; <nl> } <nl> <nl> - UIWidget * UIPageView : : createCloneInstance ( ) <nl> + Widget * PageView : : createCloneInstance ( ) <nl> { <nl> - return UIPageView : : create ( ) ; <nl> + return PageView : : create ( ) ; <nl> } <nl> <nl> - void UIPageView : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + void PageView : : copyClonedWidgetChildren ( Widget * model ) <nl> { <nl> - cocos2d : : ccArray * arrayPages = dynamic_cast < UIPageView * > ( model ) - > getPages ( ) - > data ; <nl> - ssize_t length = arrayPages - > num ; <nl> + Vector < Layout * > modelPages = dynamic_cast < PageView * > ( model ) - > getPages ( ) ; <nl> + int length = modelPages . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UILayout * page = ( UILayout * ) ( arrayPages - > arr [ i ] ) ; <nl> - addPage ( dynamic_cast < UILayout * > ( page - > clone ( ) ) ) ; <nl> + Layout * page = modelPages . at ( i ) ; <nl> + addPage ( dynamic_cast < Layout * > ( page - > clone ( ) ) ) ; <nl> } <nl> } <nl> <nl> - void UIPageView : : copySpecialProperties ( UIWidget * widget ) <nl> + void PageView : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UIPageView * pageView = dynamic_cast < UIPageView * > ( widget ) ; <nl> + PageView * pageView = dynamic_cast < PageView * > ( widget ) ; <nl> if ( pageView ) <nl> { <nl> - UILayout : : copySpecialProperties ( widget ) ; <nl> + Layout : : copySpecialProperties ( widget ) ; <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIPageView . h <nl> ppp b / cocos / gui / UIPageView . h <nl> <nl> # include " gui / UILayout . h " <nl> # include " gui / UIScrollInterface . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> typedef enum <nl> typedef enum <nl> PAGEVIEW_EVENT_TURNING , <nl> } PageViewEventType ; <nl> <nl> - typedef void ( cocos2d : : Object : : * SEL_PageViewEvent ) ( cocos2d : : Object * , PageViewEventType ) ; <nl> + typedef void ( Object : : * SEL_PageViewEvent ) ( Object * , PageViewEventType ) ; <nl> # define pagevieweventselector ( _SELECTOR ) ( SEL_PageViewEvent ) ( & _SELECTOR ) <nl> <nl> typedef enum { <nl> typedef enum { <nl> PAGEVIEW_TOUCHRIGHT <nl> } PVTouchDir ; <nl> <nl> - class UIPageView : public UILayout , public UIScrollInterface <nl> + class PageView : public Layout , public UIScrollInterface <nl> { <nl> <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UIPageView ( ) ; <nl> + PageView ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ lua NA <nl> - * @ js NA <nl> * / <nl> - virtual ~ UIPageView ( ) ; <nl> + virtual ~ PageView ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UIPageView * create ( ) ; <nl> + static PageView * create ( ) ; <nl> <nl> / * * <nl> * Add a widget to a page of pageview . <nl> class UIPageView : public UILayout , public UIScrollInterface <nl> * <nl> * @ param forceCreate if force create and there is no page exsit , pageview would create a default page for adding widget . <nl> * / <nl> - void addWidgetToPage ( UIWidget * widget , int pageIdx , bool forceCreate ) ; <nl> + void addWidgetToPage ( Widget * widget , int pageIdx , bool forceCreate ) ; <nl> <nl> / * * <nl> * Push back a page to pageview . <nl> * <nl> * @ param page page to be added to pageview . <nl> * / <nl> - void addPage ( UILayout * page ) ; <nl> + void addPage ( Layout * page ) ; <nl> <nl> / * * <nl> * Inert a page to pageview . <nl> * <nl> * @ param page page to be added to pageview . <nl> * / <nl> - void insertPage ( UILayout * page , int idx ) ; <nl> + void insertPage ( Layout * page , int idx ) ; <nl> <nl> / * * <nl> * Remove a page of pageview . <nl> * <nl> * @ param page page which will be removed . <nl> * / <nl> - void removePage ( UILayout * page ) ; <nl> + void removePage ( Layout * page ) ; <nl> <nl> / * * <nl> * Remove a page at index of pageview . <nl> class UIPageView : public UILayout , public UIScrollInterface <nl> * / <nl> int getCurPageIndex ( ) const ; <nl> <nl> - cocos2d : : Array * getPages ( ) ; <nl> + Vector < Layout * > & getPages ( ) ; <nl> <nl> - UILayout * getPage ( int index ) ; <nl> + Layout * getPage ( int index ) ; <nl> <nl> / / event <nl> - void addEventListenerPageView ( cocos2d : : Object * target , SEL_PageViewEvent selector ) ; <nl> + void addEventListenerPageView ( Object * target , SEL_PageViewEvent selector ) ; <nl> <nl> <nl> <nl> <nl> - / * * override " onTouchBegan " method of widget . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual bool onTouchBegan ( const cocos2d : : Point & touchPoint ) override ; <nl> - <nl> - / * * override " onTouchMoved " method of widget . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onTouchMoved ( const cocos2d : : Point & touchPoint ) override ; <nl> - <nl> - / * * override " onTouchEnded " method of widget . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onTouchEnded ( const cocos2d : : Point & touchPoint ) override ; <nl> - <nl> - / * * override " onTouchCancelled " method of widget . <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void onTouchCancelled ( const cocos2d : : Point & touchPoint ) override ; <nl> + virtual bool onTouchBegan ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchMoved ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchEnded ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchCancelled ( Touch * touch , Event * unusedEvent ) override ; <nl> <nl> / / override " update " method of widget . <nl> virtual void update ( float dt ) override ; <nl> - <nl> - virtual void doLayout ( ) override { } ; <nl> - <nl> / * * <nl> * Sets LayoutType . <nl> * <nl> class UIPageView : public UILayout , public UIScrollInterface <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> protected : <nl> - virtual bool addChild ( UIWidget * widget ) override ; <nl> - virtual bool removeChild ( UIWidget * widget ) override ; <nl> + virtual void addChild ( Node * child ) override ; <nl> + virtual void addChild ( Node * child , int zOrder ) override ; <nl> + virtual void addChild ( Node * child , int zOrder , int tag ) override ; <nl> + virtual void removeChild ( Node * widget , bool cleanup = true ) override ; <nl> virtual void removeAllChildren ( ) override ; <nl> - virtual cocos2d : : Array * getChildren ( ) override { return UIWidget : : getChildren ( ) ; } ; <nl> + virtual Vector < Node * > & getChildren ( ) override { return Widget : : getChildren ( ) ; } ; <nl> + virtual const Vector < Node * > & getChildren ( ) const override { return Widget : : getChildren ( ) ; } ; <nl> virtual bool init ( ) override ; <nl> - UILayout * createPage ( ) ; <nl> + Layout * createPage ( ) ; <nl> float getPositionXByIndex ( int idx ) ; <nl> void updateBoundaryPages ( ) ; <nl> - virtual void handlePressLogic ( const cocos2d : : Point & touchPoint ) override ; <nl> - virtual void handleMoveLogic ( const cocos2d : : Point & touchPoint ) override ; <nl> - virtual void handleReleaseLogic ( const cocos2d : : Point & touchPoint ) override ; <nl> - virtual void interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) override ; <nl> - virtual void checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) override ; <nl> + virtual void handlePressLogic ( const Point & touchPoint ) override ; <nl> + virtual void handleMoveLogic ( const Point & touchPoint ) override ; <nl> + virtual void handleReleaseLogic ( const Point & touchPoint ) override ; <nl> + virtual void interceptTouchEvent ( int handleState , Widget * sender , const Point & touchPoint ) override ; <nl> + virtual void checkChildInfo ( int handleState , Widget * sender , const Point & touchPoint ) override ; <nl> virtual bool scrollPages ( float touchOffset ) ; <nl> void movePages ( float offset ) ; <nl> void pageTurningEvent ( ) ; <nl> void updateChildrenSize ( ) ; <nl> void updateChildrenPosition ( ) ; <nl> virtual void onSizeChanged ( ) override ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> - virtual void copyClonedWidgetChildren ( UIWidget * model ) override ; <nl> - virtual void setClippingEnabled ( bool enabled ) override { UILayout : : setClippingEnabled ( enabled ) ; } ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> + virtual void copyClonedWidgetChildren ( Widget * model ) override ; <nl> + virtual void setClippingEnabled ( bool enabled ) override { Layout : : setClippingEnabled ( enabled ) ; } ; <nl> + virtual void doLayout ( ) override { if ( ! _doLayoutDirty ) { return ; } _doLayoutDirty = false ; } ; <nl> protected : <nl> int _curPageIdx ; <nl> - cocos2d : : Array * _pages ; <nl> + Vector < Layout * > _pages ; <nl> PVTouchDir _touchMoveDir ; <nl> float _touchStartLocation ; <nl> float _touchMoveStartLocation ; <nl> - cocos2d : : Point _movePagePoint ; <nl> - UIWidget * _leftChild ; <nl> - UIWidget * _rightChild ; <nl> + Point _movePagePoint ; <nl> + Widget * _leftChild ; <nl> + Widget * _rightChild ; <nl> float _leftBoundary ; <nl> float _rightBoundary ; <nl> bool _isAutoScrolling ; <nl> class UIPageView : public UILayout , public UIScrollInterface <nl> float _autoScrollSpeed ; <nl> int _autoScrollDir ; <nl> float _childFocusCancelOffset ; <nl> - cocos2d : : Object * _pageViewEventListener ; <nl> + Object * _pageViewEventListener ; <nl> SEL_PageViewEvent _pageViewEventSelector ; <nl> <nl> } ; <nl> <nl> } <nl> + NS_CC_END <nl> <nl> - # endif / * defined ( __UIPageView__ ) * / <nl> + # endif / * defined ( __PageView__ ) * / <nl> deleted file mode 100644 <nl> index 4c3ad39210e0 . . 000000000000 <nl> mmm a / cocos / gui / UIRootWidget . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all 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 , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " gui / UIRootWidget . h " <nl> - <nl> - namespace gui { <nl> - <nl> - UIRootWidget : : UIRootWidget ( ) <nl> - { <nl> - } <nl> - <nl> - UIRootWidget : : ~ UIRootWidget ( ) <nl> - { <nl> - } <nl> - <nl> - UIRootWidget * UIRootWidget : : create ( ) <nl> - { <nl> - UIRootWidget * widget = new UIRootWidget ( ) ; <nl> - if ( widget & & widget - > init ( ) ) <nl> - { <nl> - widget - > autorelease ( ) ; <nl> - return widget ; <nl> - } <nl> - CC_SAFE_DELETE ( widget ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> - bool UIRootWidget : : init ( ) <nl> - { <nl> - if ( UILayout : : init ( ) ) <nl> - { <nl> - setSize ( cocos2d : : Director : : getInstance ( ) - > getWinSize ( ) ) ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - const char * UIRootWidget : : getDescription ( ) const <nl> - { <nl> - return " RootWidget " ; <nl> - } <nl> - <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 3a50824cf806 . . 000000000000 <nl> mmm a / cocos / gui / UIRootWidget . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all 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 , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __UIROOTWIDGET_H__ <nl> - # define __UIROOTWIDGET_H__ <nl> - <nl> - # include " gui / UILayout . h " <nl> - <nl> - namespace gui { <nl> - <nl> - / * * <nl> - * @ js NA <nl> - * / <nl> - class UIRootWidget : public UILayout <nl> - { <nl> - public : <nl> - / * * <nl> - * Default constructor <nl> - * / <nl> - UIRootWidget ( ) ; <nl> - <nl> - / * * <nl> - * Default destructor <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ UIRootWidget ( ) ; <nl> - <nl> - / * * <nl> - * Allocates and initializes a widget . <nl> - * / <nl> - static UIRootWidget * create ( ) ; <nl> - <nl> - / * * <nl> - * Returns the " class name " of widget . <nl> - * / <nl> - virtual const char * getDescription ( ) const override ; <nl> - protected : <nl> - / / initializes state of widget . <nl> - virtual bool init ( ) override ; <nl> - } ; <nl> - <nl> - } <nl> - <nl> - # endif / * defined ( __CocoGUI__RootWidget__ ) * / <nl> mmm a / cocos / gui / UIScrollInterface . h <nl> ppp b / cocos / gui / UIScrollInterface . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> class UIScrollInterface <nl> class UIScrollInterface <nl> virtual ~ UIScrollInterface ( ) { } <nl> <nl> protected : <nl> - virtual void handlePressLogic ( const cocos2d : : Point & touchPoint ) = 0 ; <nl> - virtual void handleMoveLogic ( const cocos2d : : Point & touchPoint ) = 0 ; <nl> - virtual void handleReleaseLogic ( const cocos2d : : Point & touchPoint ) = 0 ; <nl> - virtual void interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) = 0 ; <nl> + virtual void handlePressLogic ( const Point & touchPoint ) = 0 ; <nl> + virtual void handleMoveLogic ( const Point & touchPoint ) = 0 ; <nl> + virtual void handleReleaseLogic ( const Point & touchPoint ) = 0 ; <nl> + virtual void interceptTouchEvent ( int handleState , Widget * sender , const Point & touchPoint ) = 0 ; <nl> } ; <nl> <nl> } <nl> + NS_CC_END <nl> <nl> # endif / * defined ( __UIScrollDelegate__ ) * / <nl> mmm a / cocos / gui / UIScrollView . cpp <nl> ppp b / cocos / gui / UIScrollView . cpp <nl> <nl> <nl> # include " gui / UIScrollView . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> # define AUTOSCROLLMAXSPEED 1000 . 0f <nl> <nl> - const cocos2d : : Point SCROLLDIR_UP = cocos2d : : Point ( 0 . 0f , 1 . 0f ) ; <nl> - const cocos2d : : Point SCROLLDIR_DOWN = cocos2d : : Point ( 0 . 0f , - 1 . 0f ) ; <nl> - const cocos2d : : Point SCROLLDIR_LEFT = cocos2d : : Point ( - 1 . 0f , 0 . 0f ) ; <nl> - const cocos2d : : Point SCROLLDIR_RIGHT = cocos2d : : Point ( 1 . 0f , 0 . 0f ) ; <nl> + const Point SCROLLDIR_UP = Point ( 0 . 0f , 1 . 0f ) ; <nl> + const Point SCROLLDIR_DOWN = Point ( 0 . 0f , - 1 . 0f ) ; <nl> + const Point SCROLLDIR_LEFT = Point ( - 1 . 0f , 0 . 0f ) ; <nl> + const Point SCROLLDIR_RIGHT = Point ( 1 . 0f , 0 . 0f ) ; <nl> <nl> - UIScrollView : : UIScrollView ( ) : <nl> + ScrollView : : ScrollView ( ) : <nl> _innerContainer ( nullptr ) , <nl> _direction ( SCROLLVIEW_DIR_VERTICAL ) , <nl> - _touchBeganPoint ( cocos2d : : Point : : ZERO ) , <nl> - _touchMovedPoint ( cocos2d : : Point : : ZERO ) , <nl> - _touchEndedPoint ( cocos2d : : Point : : ZERO ) , <nl> - _touchMovingPoint ( cocos2d : : Point : : ZERO ) , <nl> - _autoScrollDir ( cocos2d : : Point : : ZERO ) , <nl> + _touchBeganPoint ( Point : : ZERO ) , <nl> + _touchMovedPoint ( Point : : ZERO ) , <nl> + _touchEndedPoint ( Point : : ZERO ) , <nl> + _touchMovingPoint ( Point : : ZERO ) , <nl> + _autoScrollDir ( Point : : ZERO ) , <nl> _topBoundary ( 0 . 0f ) , <nl> _bottomBoundary ( 0 . 0f ) , <nl> _leftBoundary ( 0 . 0f ) , <nl> _autoScrollOriginalSpeed ( 0 . 0f ) , <nl> _autoScrollAcceleration ( - 1000 . 0f ) , <nl> _isAutoScrollSpeedAttenuated ( false ) , <nl> _needCheckAutoScrollDestination ( false ) , <nl> - _autoScrollDestination ( cocos2d : : Point : : ZERO ) , <nl> + _autoScrollDestination ( Point : : ZERO ) , <nl> _bePressed ( false ) , <nl> _slidTime ( 0 . 0f ) , <nl> - _moveChildPoint ( cocos2d : : Point : : ZERO ) , <nl> + _moveChildPoint ( Point : : ZERO ) , <nl> _childFocusCancelOffset ( 5 . 0f ) , <nl> _leftBounceNeeded ( false ) , <nl> _topBounceNeeded ( false ) , <nl> _rightBounceNeeded ( false ) , <nl> _bottomBounceNeeded ( false ) , <nl> _bounceEnabled ( false ) , <nl> _bouncing ( false ) , <nl> - _bounceDir ( cocos2d : : Point : : ZERO ) , <nl> + _bounceDir ( Point : : ZERO ) , <nl> _bounceOriginalSpeed ( 0 . 0f ) , <nl> _inertiaScrollEnabled ( true ) , <nl> _scrollViewEventListener ( nullptr ) , <nl> _scrollViewEventSelector ( nullptr ) <nl> { <nl> } <nl> <nl> - UIScrollView : : ~ UIScrollView ( ) <nl> + ScrollView : : ~ ScrollView ( ) <nl> { <nl> _scrollViewEventListener = nullptr ; <nl> _scrollViewEventSelector = nullptr ; <nl> } <nl> <nl> - UIScrollView * UIScrollView : : create ( ) <nl> + ScrollView * ScrollView : : create ( ) <nl> { <nl> - UIScrollView * widget = new UIScrollView ( ) ; <nl> + ScrollView * widget = new ScrollView ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UIScrollView * UIScrollView : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UIScrollView : : init ( ) <nl> + bool ScrollView : : init ( ) <nl> { <nl> - if ( UILayout : : init ( ) ) <nl> + if ( Layout : : init ( ) ) <nl> { <nl> setUpdateEnabled ( true ) ; <nl> setTouchEnabled ( true ) ; <nl> bool UIScrollView : : init ( ) <nl> return false ; <nl> } <nl> <nl> - void UIScrollView : : initRenderer ( ) <nl> + void ScrollView : : initRenderer ( ) <nl> { <nl> - UILayout : : initRenderer ( ) ; <nl> - _innerContainer = UILayout : : create ( ) ; <nl> - UILayout : : addChild ( _innerContainer ) ; <nl> + Layout : : initRenderer ( ) ; <nl> + _innerContainer = Layout : : create ( ) ; <nl> + Layout : : addChild ( _innerContainer , 1 , 1 ) ; <nl> } <nl> <nl> - void UIScrollView : : onSizeChanged ( ) <nl> + void ScrollView : : onSizeChanged ( ) <nl> { <nl> - UILayout : : onSizeChanged ( ) ; <nl> + Layout : : onSizeChanged ( ) ; <nl> _topBoundary = _size . height ; <nl> _rightBoundary = _size . width ; <nl> float bounceBoundaryParameterX = _size . width / 3 . 0f ; <nl> void UIScrollView : : onSizeChanged ( ) <nl> _bounceBottomBoundary = bounceBoundaryParameterY ; <nl> _bounceLeftBoundary = bounceBoundaryParameterX ; <nl> _bounceRightBoundary = _size . width - bounceBoundaryParameterX ; <nl> - cocos2d : : Size innerSize = _innerContainer - > getSize ( ) ; <nl> + Size innerSize = _innerContainer - > getSize ( ) ; <nl> float orginInnerSizeWidth = innerSize . width ; <nl> float orginInnerSizeHeight = innerSize . height ; <nl> float innerSizeWidth = MAX ( orginInnerSizeWidth , _size . width ) ; <nl> float innerSizeHeight = MAX ( orginInnerSizeHeight , _size . height ) ; <nl> - _innerContainer - > setSize ( cocos2d : : Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> - _innerContainer - > setPosition ( cocos2d : : Point ( 0 , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> + _innerContainer - > setSize ( Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> + _innerContainer - > setPosition ( Point ( 0 , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> <nl> - void UIScrollView : : setInnerContainerSize ( const cocos2d : : Size & size ) <nl> + void ScrollView : : setInnerContainerSize ( const Size & size ) <nl> { <nl> float innerSizeWidth = _size . width ; <nl> float innerSizeHeight = _size . height ; <nl> - cocos2d : : Size originalInnerSize = _innerContainer - > getSize ( ) ; <nl> + Size originalInnerSize = _innerContainer - > getSize ( ) ; <nl> if ( size . width < _size . width ) <nl> { <nl> CCLOG ( " Inner width < = scrollview width , it will be force sized ! " ) ; <nl> void UIScrollView : : setInnerContainerSize ( const cocos2d : : Size & size ) <nl> { <nl> innerSizeHeight = size . height ; <nl> } <nl> - _innerContainer - > setSize ( cocos2d : : Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> + _innerContainer - > setSize ( Size ( innerSizeWidth , innerSizeHeight ) ) ; <nl> <nl> switch ( _direction ) <nl> { <nl> case SCROLLVIEW_DIR_VERTICAL : <nl> { <nl> - cocos2d : : Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> + Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> float offset = originalInnerSize . height - newInnerSize . height ; <nl> scrollChildren ( 0 . 0f , offset ) ; <nl> break ; <nl> void UIScrollView : : setInnerContainerSize ( const cocos2d : : Size & size ) <nl> { <nl> if ( _innerContainer - > getRightInParent ( ) < = _size . width ) <nl> { <nl> - cocos2d : : Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> + Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> float offset = originalInnerSize . width - newInnerSize . width ; <nl> scrollChildren ( offset , 0 . 0f ) ; <nl> } <nl> void UIScrollView : : setInnerContainerSize ( const cocos2d : : Size & size ) <nl> } <nl> case SCROLLVIEW_DIR_BOTH : <nl> { <nl> - cocos2d : : Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> + Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> float offsetY = originalInnerSize . height - newInnerSize . height ; <nl> float offsetX = 0 . 0f ; <nl> if ( _innerContainer - > getRightInParent ( ) < = _size . width ) <nl> void UIScrollView : : setInnerContainerSize ( const cocos2d : : Size & size ) <nl> default : <nl> break ; <nl> } <nl> + if ( _innerContainer - > getLeftInParent ( ) > 0 . 0f ) <nl> + { <nl> + _innerContainer - > setPosition ( Point ( _innerContainer - > getAnchorPoint ( ) . x * _innerContainer - > getSize ( ) . width , _innerContainer - > getPosition ( ) . y ) ) ; <nl> + } <nl> + if ( _innerContainer - > getRightInParent ( ) < _size . width ) <nl> + { <nl> + _innerContainer - > setPosition ( Point ( _size . width - ( ( 1 . 0f - _innerContainer - > getAnchorPoint ( ) . x ) * _innerContainer - > getSize ( ) . width ) , _innerContainer - > getPosition ( ) . y ) ) ; <nl> + } <nl> + if ( _innerContainer - > getPosition ( ) . y > 0 . 0f ) <nl> + { <nl> + _innerContainer - > setPosition ( Point ( _innerContainer - > getPosition ( ) . x , _innerContainer - > getAnchorPoint ( ) . y * _innerContainer - > getSize ( ) . height ) ) ; <nl> + } <nl> + if ( _innerContainer - > getTopInParent ( ) < _size . height ) <nl> + { <nl> + _innerContainer - > setPosition ( Point ( _innerContainer - > getPosition ( ) . x , _size . height - ( 1 . 0f - _innerContainer - > getAnchorPoint ( ) . y ) * _innerContainer - > getSize ( ) . height ) ) ; <nl> + } <nl> } <nl> <nl> - const cocos2d : : Size & UIScrollView : : getInnerContainerSize ( ) const <nl> + const Size & ScrollView : : getInnerContainerSize ( ) const <nl> { <nl> return _innerContainer - > getSize ( ) ; <nl> } <nl> + <nl> + void ScrollView : : addChild ( Node * child ) <nl> + { <nl> + Layout : : addChild ( child ) ; <nl> + } <nl> + <nl> + void ScrollView : : addChild ( Node * child , int zOrder ) <nl> + { <nl> + Layout : : addChild ( child , zOrder ) ; <nl> + } <nl> <nl> - bool UIScrollView : : addChild ( UIWidget * widget ) <nl> + void ScrollView : : addChild ( Node * child , int zOrder , int tag ) <nl> { <nl> - return _innerContainer - > addChild ( widget ) ; <nl> + return _innerContainer - > addChild ( child , zOrder , tag ) ; <nl> } <nl> <nl> - void UIScrollView : : removeAllChildren ( ) <nl> + void ScrollView : : removeAllChildren ( ) <nl> { <nl> _innerContainer - > removeAllChildren ( ) ; <nl> } <nl> <nl> - bool UIScrollView : : removeChild ( UIWidget * child ) <nl> + void ScrollView : : removeChild ( Node * child , bool cleanup ) <nl> { <nl> - return _innerContainer - > removeChild ( child ) ; <nl> + return _innerContainer - > removeChild ( child , cleanup ) ; <nl> } <nl> <nl> - cocos2d : : Array * UIScrollView : : getChildren ( ) <nl> + Vector < Node * > & ScrollView : : getChildren ( ) <nl> { <nl> return _innerContainer - > getChildren ( ) ; <nl> } <nl> <nl> - void UIScrollView : : moveChildren ( float offsetX , float offsetY ) <nl> + const Vector < Node * > & ScrollView : : getChildren ( ) const <nl> { <nl> - _moveChildPoint = _innerContainer - > getPosition ( ) + cocos2d : : Point ( offsetX , offsetY ) ; <nl> + return _innerContainer - > getChildren ( ) ; <nl> + } <nl> + <nl> + void ScrollView : : moveChildren ( float offsetX , float offsetY ) <nl> + { <nl> + _moveChildPoint = _innerContainer - > getPosition ( ) + Point ( offsetX , offsetY ) ; <nl> _innerContainer - > setPosition ( _moveChildPoint ) ; <nl> } <nl> <nl> - void UIScrollView : : autoScrollChildren ( float dt ) <nl> + void ScrollView : : autoScrollChildren ( float dt ) <nl> { <nl> float lastTime = _autoScrollAddUpTime ; <nl> _autoScrollAddUpTime + = dt ; <nl> void UIScrollView : : autoScrollChildren ( float dt ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : bounceChildren ( float dt ) <nl> + void ScrollView : : bounceChildren ( float dt ) <nl> { <nl> if ( _bounceOriginalSpeed < = 0 . 0f ) <nl> { <nl> void UIScrollView : : bounceChildren ( float dt ) <nl> } <nl> } <nl> <nl> - bool UIScrollView : : checkNeedBounce ( ) <nl> + bool ScrollView : : checkNeedBounce ( ) <nl> { <nl> if ( ! _bounceEnabled ) <nl> { <nl> bool UIScrollView : : checkNeedBounce ( ) <nl> { <nl> if ( _topBounceNeeded & & _leftBounceNeeded ) <nl> { <nl> - cocos2d : : Point scrollVector = cocos2d : : Point ( 0 . 0f , _size . height ) - cocos2d : : Point ( _innerContainer - > getLeftInParent ( ) , _innerContainer - > getTopInParent ( ) ) ; <nl> + Point scrollVector = Point ( 0 . 0f , _size . height ) - Point ( _innerContainer - > getLeftInParent ( ) , _innerContainer - > getTopInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . normalize ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _topBounceNeeded & & _rightBounceNeeded ) <nl> { <nl> - cocos2d : : Point scrollVector = cocos2d : : Point ( _size . width , _size . height ) - cocos2d : : Point ( _innerContainer - > getRightInParent ( ) , _innerContainer - > getTopInParent ( ) ) ; <nl> + Point scrollVector = Point ( _size . width , _size . height ) - Point ( _innerContainer - > getRightInParent ( ) , _innerContainer - > getTopInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . normalize ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _bottomBounceNeeded & & _leftBounceNeeded ) <nl> { <nl> - cocos2d : : Point scrollVector = cocos2d : : Point : : ZERO - cocos2d : : Point ( _innerContainer - > getLeftInParent ( ) , _innerContainer - > getBottomInParent ( ) ) ; <nl> + Point scrollVector = Point : : ZERO - Point ( _innerContainer - > getLeftInParent ( ) , _innerContainer - > getBottomInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . normalize ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _bottomBounceNeeded & & _rightBounceNeeded ) <nl> { <nl> - cocos2d : : Point scrollVector = cocos2d : : Point ( _size . width , 0 . 0f ) - cocos2d : : Point ( _innerContainer - > getRightInParent ( ) , _innerContainer - > getBottomInParent ( ) ) ; <nl> + Point scrollVector = Point ( _size . width , 0 . 0f ) - Point ( _innerContainer - > getRightInParent ( ) , _innerContainer - > getBottomInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . normalize ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _topBounceNeeded ) <nl> { <nl> - cocos2d : : Point scrollVector = cocos2d : : Point ( 0 . 0f , _size . height ) - cocos2d : : Point ( 0 . 0f , _innerContainer - > getTopInParent ( ) ) ; <nl> + Point scrollVector = Point ( 0 . 0f , _size . height ) - Point ( 0 . 0f , _innerContainer - > getTopInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . normalize ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _bottomBounceNeeded ) <nl> { <nl> - cocos2d : : Point scrollVector = cocos2d : : Point : : ZERO - cocos2d : : Point ( 0 . 0f , _innerContainer - > getBottomInParent ( ) ) ; <nl> + Point scrollVector = Point : : ZERO - Point ( 0 . 0f , _innerContainer - > getBottomInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . normalize ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _leftBounceNeeded ) <nl> { <nl> - cocos2d : : Point scrollVector = cocos2d : : Point : : ZERO - cocos2d : : Point ( _innerContainer - > getLeftInParent ( ) , 0 . 0f ) ; <nl> + Point scrollVector = Point : : ZERO - Point ( _innerContainer - > getLeftInParent ( ) , 0 . 0f ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . normalize ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _rightBounceNeeded ) <nl> { <nl> - cocos2d : : Point scrollVector = cocos2d : : Point ( _size . width , 0 . 0f ) - cocos2d : : Point ( _innerContainer - > getRightInParent ( ) , 0 . 0f ) ; <nl> + Point scrollVector = Point ( _size . width , 0 . 0f ) - Point ( _innerContainer - > getRightInParent ( ) , 0 . 0f ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . normalize ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> bool UIScrollView : : checkNeedBounce ( ) <nl> return false ; <nl> } <nl> <nl> - void UIScrollView : : checkBounceBoundary ( ) <nl> + void ScrollView : : checkBounceBoundary ( ) <nl> { <nl> float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos > _bottomBoundary ) <nl> void UIScrollView : : checkBounceBoundary ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : startBounceChildren ( float v ) <nl> + void ScrollView : : startBounceChildren ( float v ) <nl> { <nl> _bounceOriginalSpeed = v ; <nl> _bouncing = true ; <nl> } <nl> <nl> - void UIScrollView : : stopBounceChildren ( ) <nl> + void ScrollView : : stopBounceChildren ( ) <nl> { <nl> _bouncing = false ; <nl> _bounceOriginalSpeed = 0 . 0f ; <nl> void UIScrollView : : stopBounceChildren ( ) <nl> _bottomBounceNeeded = false ; <nl> } <nl> <nl> - void UIScrollView : : startAutoScrollChildrenWithOriginalSpeed ( const cocos2d : : Point & dir , float v , bool attenuated , float acceleration ) <nl> + void ScrollView : : startAutoScrollChildrenWithOriginalSpeed ( const Point & dir , float v , bool attenuated , float acceleration ) <nl> { <nl> stopAutoScrollChildren ( ) ; <nl> _autoScrollDir = dir ; <nl> void UIScrollView : : startAutoScrollChildrenWithOriginalSpeed ( const cocos2d : : Point <nl> _autoScrollAcceleration = acceleration ; <nl> } <nl> <nl> - void UIScrollView : : startAutoScrollChildrenWithDestination ( const cocos2d : : Point & des , float time , bool attenuated ) <nl> + void ScrollView : : startAutoScrollChildrenWithDestination ( const Point & des , float time , bool attenuated ) <nl> { <nl> _needCheckAutoScrollDestination = false ; <nl> _autoScrollDestination = des ; <nl> - cocos2d : : Point dis = des - _innerContainer - > getPosition ( ) ; <nl> - cocos2d : : Point dir = dis . normalize ( ) ; <nl> + Point dis = des - _innerContainer - > getPosition ( ) ; <nl> + Point dir = dis . normalize ( ) ; <nl> float orSpeed = 0 . 0f ; <nl> float acceleration = - 1000 . 0f ; <nl> if ( attenuated ) <nl> void UIScrollView : : startAutoScrollChildrenWithDestination ( const cocos2d : : Point & <nl> startAutoScrollChildrenWithOriginalSpeed ( dir , orSpeed , attenuated , acceleration ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToDestination ( const cocos2d : : Point & des ) <nl> + void ScrollView : : jumpToDestination ( const Point & des ) <nl> { <nl> float finalOffsetX = des . x ; <nl> float finalOffsetY = des . y ; <nl> void UIScrollView : : jumpToDestination ( const cocos2d : : Point & des ) <nl> default : <nl> break ; <nl> } <nl> - _innerContainer - > setPosition ( cocos2d : : Point ( finalOffsetX , finalOffsetY ) ) ; <nl> + _innerContainer - > setPosition ( Point ( finalOffsetX , finalOffsetY ) ) ; <nl> } <nl> <nl> - void UIScrollView : : stopAutoScrollChildren ( ) <nl> + void ScrollView : : stopAutoScrollChildren ( ) <nl> { <nl> _autoScroll = false ; <nl> _autoScrollOriginalSpeed = 0 . 0f ; <nl> _autoScrollAddUpTime = 0 . 0f ; <nl> } <nl> <nl> - bool UIScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> + bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> { <nl> bool scrollenabled = true ; <nl> if ( touchOffsetX > 0 . 0f & & touchOffsetY > 0 . 0f ) / / first quadrant / / bounce to top - right <nl> bool UIScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> return scrollenabled ; <nl> } <nl> <nl> - bool UIScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchOffsetY ) <nl> + bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchOffsetY ) <nl> { <nl> bool scrollenabled = true ; <nl> switch ( _direction ) <nl> bool UIScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touc <nl> return scrollenabled ; <nl> } <nl> <nl> - bool UIScrollView : : scrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> + bool ScrollView : : scrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> { <nl> bool scrollenabled = true ; <nl> scrollingEvent ( ) ; <nl> bool UIScrollView : : scrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> return scrollenabled ; <nl> } <nl> <nl> - void UIScrollView : : scrollToBottom ( float time , bool attenuated ) <nl> + void ScrollView : : scrollToBottom ( float time , bool attenuated ) <nl> { <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , 0 . 0f ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( _innerContainer - > getPosition ( ) . x , 0 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToTop ( float time , bool attenuated ) <nl> + void ScrollView : : scrollToTop ( float time , bool attenuated ) <nl> { <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( _innerContainer - > getPosition ( ) . x , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToLeft ( float time , bool attenuated ) <nl> + void ScrollView : : scrollToLeft ( float time , bool attenuated ) <nl> { <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( 0 . 0f , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( 0 . 0f , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToRight ( float time , bool attenuated ) <nl> + void ScrollView : : scrollToRight ( float time , bool attenuated ) <nl> { <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( _size . width - _innerContainer - > getSize ( ) . width , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToTopLeft ( float time , bool attenuated ) <nl> + void ScrollView : : scrollToTopLeft ( float time , bool attenuated ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> CCLOG ( " Scroll diretion is not both ! " ) ; <nl> return ; <nl> } <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( 0 . 0f , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( 0 . 0f , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToTopRight ( float time , bool attenuated ) <nl> + void ScrollView : : scrollToTopRight ( float time , bool attenuated ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> CCLOG ( " Scroll diretion is not both ! " ) ; <nl> return ; <nl> } <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( _size . width - _innerContainer - > getSize ( ) . width , _size . height - _innerContainer - > getSize ( ) . height ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToBottomLeft ( float time , bool attenuated ) <nl> + void ScrollView : : scrollToBottomLeft ( float time , bool attenuated ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> CCLOG ( " Scroll diretion is not both ! " ) ; <nl> return ; <nl> } <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point : : ZERO , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point : : ZERO , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToBottomRight ( float time , bool attenuated ) <nl> + void ScrollView : : scrollToBottomRight ( float time , bool attenuated ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> CCLOG ( " Scroll diretion is not both ! " ) ; <nl> return ; <nl> } <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , 0 . 0f ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( _size . width - _innerContainer - > getSize ( ) . width , 0 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToPercentVertical ( float percent , float time , bool attenuated ) <nl> + void ScrollView : : scrollToPercentVertical ( float percent , float time , bool attenuated ) <nl> { <nl> float minY = _size . height - _innerContainer - > getSize ( ) . height ; <nl> float h = - minY ; <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , minY + percent * h / 100 . 0f ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( _innerContainer - > getPosition ( ) . x , minY + percent * h / 100 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToPercentHorizontal ( float percent , float time , bool attenuated ) <nl> + void ScrollView : : scrollToPercentHorizontal ( float percent , float time , bool attenuated ) <nl> { <nl> float w = _innerContainer - > getSize ( ) . width - _size . width ; <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( - ( percent * w / 100 . 0f ) , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( - ( percent * w / 100 . 0f ) , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToPercentBothDirection ( const cocos2d : : Point & percent , float time , bool attenuated ) <nl> + void ScrollView : : scrollToPercentBothDirection ( const Point & percent , float time , bool attenuated ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> void UIScrollView : : scrollToPercentBothDirection ( const cocos2d : : Point & percent , f <nl> float minY = _size . height - _innerContainer - > getSize ( ) . height ; <nl> float h = - minY ; <nl> float w = _innerContainer - > getSize ( ) . width - _size . width ; <nl> - startAutoScrollChildrenWithDestination ( cocos2d : : Point ( - ( percent . x * w / 100 . 0f ) , minY + percent . y * h / 100 . 0f ) , time , attenuated ) ; <nl> + startAutoScrollChildrenWithDestination ( Point ( - ( percent . x * w / 100 . 0f ) , minY + percent . y * h / 100 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToBottom ( ) <nl> + void ScrollView : : jumpToBottom ( ) <nl> { <nl> - jumpToDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , 0 . 0f ) ) ; <nl> + jumpToDestination ( Point ( _innerContainer - > getPosition ( ) . x , 0 . 0f ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToTop ( ) <nl> + void ScrollView : : jumpToTop ( ) <nl> { <nl> - jumpToDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> + jumpToDestination ( Point ( _innerContainer - > getPosition ( ) . x , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToLeft ( ) <nl> + void ScrollView : : jumpToLeft ( ) <nl> { <nl> - jumpToDestination ( cocos2d : : Point ( 0 . 0f , _innerContainer - > getPosition ( ) . y ) ) ; <nl> + jumpToDestination ( Point ( 0 . 0f , _innerContainer - > getPosition ( ) . y ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToRight ( ) <nl> + void ScrollView : : jumpToRight ( ) <nl> { <nl> - jumpToDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , _innerContainer - > getPosition ( ) . y ) ) ; <nl> + jumpToDestination ( Point ( _size . width - _innerContainer - > getSize ( ) . width , _innerContainer - > getPosition ( ) . y ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToTopLeft ( ) <nl> + void ScrollView : : jumpToTopLeft ( ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> CCLOG ( " Scroll diretion is not both ! " ) ; <nl> return ; <nl> } <nl> - jumpToDestination ( cocos2d : : Point ( 0 . 0f , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> + jumpToDestination ( Point ( 0 . 0f , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToTopRight ( ) <nl> + void ScrollView : : jumpToTopRight ( ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> CCLOG ( " Scroll diretion is not both ! " ) ; <nl> return ; <nl> } <nl> - jumpToDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> + jumpToDestination ( Point ( _size . width - _innerContainer - > getSize ( ) . width , _size . height - _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToBottomLeft ( ) <nl> + void ScrollView : : jumpToBottomLeft ( ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> CCLOG ( " Scroll diretion is not both ! " ) ; <nl> return ; <nl> } <nl> - jumpToDestination ( cocos2d : : Point : : ZERO ) ; <nl> + jumpToDestination ( Point : : ZERO ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToBottomRight ( ) <nl> + void ScrollView : : jumpToBottomRight ( ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> CCLOG ( " Scroll diretion is not both ! " ) ; <nl> return ; <nl> } <nl> - jumpToDestination ( cocos2d : : Point ( _size . width - _innerContainer - > getSize ( ) . width , 0 . 0f ) ) ; <nl> + jumpToDestination ( Point ( _size . width - _innerContainer - > getSize ( ) . width , 0 . 0f ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToPercentVertical ( float percent ) <nl> + void ScrollView : : jumpToPercentVertical ( float percent ) <nl> { <nl> float minY = _size . height - _innerContainer - > getSize ( ) . height ; <nl> float h = - minY ; <nl> - jumpToDestination ( cocos2d : : Point ( _innerContainer - > getPosition ( ) . x , minY + percent * h / 100 . 0f ) ) ; <nl> + jumpToDestination ( Point ( _innerContainer - > getPosition ( ) . x , minY + percent * h / 100 . 0f ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToPercentHorizontal ( float percent ) <nl> + void ScrollView : : jumpToPercentHorizontal ( float percent ) <nl> { <nl> float w = _innerContainer - > getSize ( ) . width - _size . width ; <nl> - jumpToDestination ( cocos2d : : Point ( - ( percent * w / 100 . 0f ) , _innerContainer - > getPosition ( ) . y ) ) ; <nl> + jumpToDestination ( Point ( - ( percent * w / 100 . 0f ) , _innerContainer - > getPosition ( ) . y ) ) ; <nl> } <nl> <nl> - void UIScrollView : : jumpToPercentBothDirection ( const cocos2d : : Point & percent ) <nl> + void ScrollView : : jumpToPercentBothDirection ( const Point & percent ) <nl> { <nl> if ( _direction ! = SCROLLVIEW_DIR_BOTH ) <nl> { <nl> void UIScrollView : : jumpToPercentBothDirection ( const cocos2d : : Point & percent ) <nl> float minY = _size . height - _innerContainer - > getSize ( ) . height ; <nl> float h = - minY ; <nl> float w = _innerContainer - > getSize ( ) . width - _size . width ; <nl> - jumpToDestination ( cocos2d : : Point ( - ( percent . x * w / 100 . 0f ) , minY + percent . y * h / 100 . 0f ) ) ; <nl> + jumpToDestination ( Point ( - ( percent . x * w / 100 . 0f ) , minY + percent . y * h / 100 . 0f ) ) ; <nl> } <nl> <nl> - void UIScrollView : : startRecordSlidAction ( ) <nl> + void ScrollView : : startRecordSlidAction ( ) <nl> { <nl> if ( _autoScroll ) <nl> { <nl> void UIScrollView : : startRecordSlidAction ( ) <nl> _slidTime = 0 . 0f ; <nl> } <nl> <nl> - void UIScrollView : : endRecordSlidAction ( ) <nl> + void ScrollView : : endRecordSlidAction ( ) <nl> { <nl> if ( ! checkNeedBounce ( ) & & _inertiaScrollEnabled ) <nl> { <nl> void UIScrollView : : endRecordSlidAction ( ) <nl> return ; <nl> } <nl> float totalDis = 0 . 0f ; <nl> - cocos2d : : Point dir ; <nl> + Point dir ; <nl> switch ( _direction ) <nl> { <nl> case SCROLLVIEW_DIR_VERTICAL : <nl> void UIScrollView : : endRecordSlidAction ( ) <nl> break ; <nl> case SCROLLVIEW_DIR_BOTH : <nl> { <nl> - cocos2d : : Point subVector = _touchEndedPoint - _touchBeganPoint ; <nl> + Point subVector = _touchEndedPoint - _touchBeganPoint ; <nl> totalDis = subVector . getLength ( ) ; <nl> dir = subVector . normalize ( ) ; <nl> break ; <nl> void UIScrollView : : endRecordSlidAction ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : handlePressLogic ( const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : handlePressLogic ( const Point & touchPoint ) <nl> { <nl> - _touchBeganPoint = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + _touchBeganPoint = convertToNodeSpace ( touchPoint ) ; <nl> _touchMovingPoint = _touchBeganPoint ; <nl> startRecordSlidAction ( ) ; <nl> _bePressed = true ; <nl> } <nl> <nl> - void UIScrollView : : handleMoveLogic ( const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : handleMoveLogic ( const Point & touchPoint ) <nl> { <nl> - _touchMovedPoint = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - cocos2d : : Point delta = _touchMovedPoint - _touchMovingPoint ; <nl> + _touchMovedPoint = convertToNodeSpace ( touchPoint ) ; <nl> + Point delta = _touchMovedPoint - _touchMovingPoint ; <nl> _touchMovingPoint = _touchMovedPoint ; <nl> switch ( _direction ) <nl> { <nl> void UIScrollView : : handleMoveLogic ( const cocos2d : : Point & touchPoint ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : handleReleaseLogic ( const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : handleReleaseLogic ( const Point & touchPoint ) <nl> { <nl> - _touchEndedPoint = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> + _touchEndedPoint = convertToNodeSpace ( touchPoint ) ; <nl> endRecordSlidAction ( ) ; <nl> _bePressed = false ; <nl> } <nl> <nl> - bool UIScrollView : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> + bool ScrollView : : onTouchBegan ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - bool pass = UILayout : : onTouchBegan ( touchPoint ) ; <nl> - handlePressLogic ( touchPoint ) ; <nl> + bool pass = Layout : : onTouchBegan ( touch , unusedEvent ) ; <nl> + if ( _hitted ) <nl> + { <nl> + handlePressLogic ( _touchStartPos ) ; <nl> + } <nl> return pass ; <nl> } <nl> <nl> - void UIScrollView : : onTouchMoved ( const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : onTouchMoved ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - UILayout : : onTouchMoved ( touchPoint ) ; <nl> - handleMoveLogic ( touchPoint ) ; <nl> + Layout : : onTouchMoved ( touch , unusedEvent ) ; <nl> + handleMoveLogic ( _touchMovePos ) ; <nl> } <nl> <nl> - void UIScrollView : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : onTouchEnded ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - UILayout : : onTouchEnded ( touchPoint ) ; <nl> - handleReleaseLogic ( touchPoint ) ; <nl> + Layout : : onTouchEnded ( touch , unusedEvent ) ; <nl> + handleReleaseLogic ( _touchEndPos ) ; <nl> } <nl> <nl> - void UIScrollView : : onTouchCancelled ( const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : onTouchCancelled ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - UILayout : : onTouchCancelled ( touchPoint ) ; <nl> - handleReleaseLogic ( touchPoint ) ; <nl> + Layout : : onTouchCancelled ( touch , unusedEvent ) ; <nl> + handleReleaseLogic ( touch - > getLocation ( ) ) ; <nl> } <nl> <nl> - void UIScrollView : : onTouchLongClicked ( const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : onTouchLongClicked ( const Point & touchPoint ) <nl> { <nl> <nl> } <nl> <nl> - void UIScrollView : : update ( float dt ) <nl> + void ScrollView : : update ( float dt ) <nl> { <nl> if ( _autoScroll ) <nl> { <nl> void UIScrollView : : update ( float dt ) <nl> recordSlidTime ( dt ) ; <nl> } <nl> <nl> - void UIScrollView : : recordSlidTime ( float dt ) <nl> + void ScrollView : : recordSlidTime ( float dt ) <nl> { <nl> if ( _bePressed ) <nl> { <nl> void UIScrollView : : recordSlidTime ( float dt ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : interceptTouchEvent ( int handleState , Widget * sender , const Point & touchPoint ) <nl> { <nl> switch ( handleState ) <nl> { <nl> void UIScrollView : : interceptTouchEvent ( int handleState , UIWidget * sender , const <nl> } <nl> } <nl> <nl> - void UIScrollView : : checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> + void ScrollView : : checkChildInfo ( int handleState , Widget * sender , const Point & touchPoint ) <nl> { <nl> interceptTouchEvent ( handleState , sender , touchPoint ) ; <nl> } <nl> <nl> - void UIScrollView : : scrollToTopEvent ( ) <nl> + void ScrollView : : scrollToTopEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : scrollToTopEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : scrollToBottomEvent ( ) <nl> + void ScrollView : : scrollToBottomEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : scrollToBottomEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : scrollToLeftEvent ( ) <nl> + void ScrollView : : scrollToLeftEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : scrollToLeftEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : scrollToRightEvent ( ) <nl> + void ScrollView : : scrollToRightEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : scrollToRightEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : scrollingEvent ( ) <nl> + void ScrollView : : scrollingEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : scrollingEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : bounceTopEvent ( ) <nl> + void ScrollView : : bounceTopEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : bounceTopEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : bounceBottomEvent ( ) <nl> + void ScrollView : : bounceBottomEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : bounceBottomEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : bounceLeftEvent ( ) <nl> + void ScrollView : : bounceLeftEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : bounceLeftEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : bounceRightEvent ( ) <nl> + void ScrollView : : bounceRightEvent ( ) <nl> { <nl> if ( _scrollViewEventListener & & _scrollViewEventSelector ) <nl> { <nl> void UIScrollView : : bounceRightEvent ( ) <nl> } <nl> } <nl> <nl> - void UIScrollView : : addEventListenerScrollView ( cocos2d : : Object * target , SEL_ScrollViewEvent selector ) <nl> + void ScrollView : : addEventListenerScrollView ( Object * target , SEL_ScrollViewEvent selector ) <nl> { <nl> _scrollViewEventListener = target ; <nl> _scrollViewEventSelector = selector ; <nl> } <nl> <nl> - void UIScrollView : : setDirection ( SCROLLVIEW_DIR dir ) <nl> + void ScrollView : : setDirection ( SCROLLVIEW_DIR dir ) <nl> { <nl> _direction = dir ; <nl> } <nl> <nl> - SCROLLVIEW_DIR UIScrollView : : getDirection ( ) <nl> + SCROLLVIEW_DIR ScrollView : : getDirection ( ) <nl> { <nl> return _direction ; <nl> } <nl> <nl> - void UIScrollView : : setBounceEnabled ( bool enabled ) <nl> + void ScrollView : : setBounceEnabled ( bool enabled ) <nl> { <nl> _bounceEnabled = enabled ; <nl> } <nl> <nl> - bool UIScrollView : : isBounceEnabled ( ) const <nl> + bool ScrollView : : isBounceEnabled ( ) const <nl> { <nl> return _bounceEnabled ; <nl> } <nl> <nl> - void UIScrollView : : setInertiaScrollEnabled ( bool enabled ) <nl> + void ScrollView : : setInertiaScrollEnabled ( bool enabled ) <nl> { <nl> _inertiaScrollEnabled = enabled ; <nl> } <nl> <nl> - bool UIScrollView : : isInertiaScrollEnabled ( ) const <nl> + bool ScrollView : : isInertiaScrollEnabled ( ) const <nl> { <nl> return _inertiaScrollEnabled ; <nl> } <nl> <nl> - UILayout * UIScrollView : : getInnerContainer ( ) <nl> + Layout * ScrollView : : getInnerContainer ( ) <nl> { <nl> return _innerContainer ; <nl> } <nl> <nl> - void UIScrollView : : setLayoutType ( LayoutType type ) <nl> + void ScrollView : : setLayoutType ( LayoutType type ) <nl> { <nl> _innerContainer - > setLayoutType ( type ) ; <nl> } <nl> <nl> - LayoutType UIScrollView : : getLayoutType ( ) const <nl> + LayoutType ScrollView : : getLayoutType ( ) const <nl> { <nl> return _innerContainer - > getLayoutType ( ) ; <nl> } <nl> <nl> - void UIScrollView : : doLayout ( ) <nl> + void ScrollView : : doLayout ( ) <nl> { <nl> - _innerContainer - > doLayout ( ) ; <nl> + if ( ! _doLayoutDirty ) <nl> + { <nl> + return ; <nl> + } <nl> + _doLayoutDirty = false ; <nl> } <nl> <nl> - const char * UIScrollView : : getDescription ( ) const <nl> + std : : string ScrollView : : getDescription ( ) const <nl> { <nl> return " ScrollView " ; <nl> } <nl> <nl> - UIWidget * UIScrollView : : createCloneInstance ( ) <nl> + Widget * ScrollView : : createCloneInstance ( ) <nl> { <nl> - return UIScrollView : : create ( ) ; <nl> + return ScrollView : : create ( ) ; <nl> } <nl> <nl> - void UIScrollView : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + void ScrollView : : copyClonedWidgetChildren ( Widget * model ) <nl> { <nl> - UILayout : : copyClonedWidgetChildren ( model ) ; <nl> + Layout : : copyClonedWidgetChildren ( model ) ; <nl> } <nl> <nl> - void UIScrollView : : copySpecialProperties ( UIWidget * widget ) <nl> + void ScrollView : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UIScrollView * scrollView = dynamic_cast < UIScrollView * > ( widget ) ; <nl> + ScrollView * scrollView = dynamic_cast < ScrollView * > ( widget ) ; <nl> if ( scrollView ) <nl> { <nl> - UILayout : : copySpecialProperties ( widget ) ; <nl> + Layout : : copySpecialProperties ( widget ) ; <nl> setInnerContainerSize ( scrollView - > getInnerContainerSize ( ) ) ; <nl> setDirection ( scrollView - > _direction ) ; <nl> setBounceEnabled ( scrollView - > _bounceEnabled ) ; <nl> void UIScrollView : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UIScrollView . h <nl> ppp b / cocos / gui / UIScrollView . h <nl> <nl> # include " gui / UILayout . h " <nl> # include " gui / UIScrollInterface . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> enum SCROLLVIEW_DIR <nl> typedef enum <nl> SCROLLVIEW_EVENT_BOUNCE_RIGHT <nl> } ScrollviewEventType ; <nl> <nl> - typedef void ( cocos2d : : CCObject : : * SEL_ScrollViewEvent ) ( cocos2d : : Object * , ScrollviewEventType ) ; <nl> + typedef void ( Object : : * SEL_ScrollViewEvent ) ( Object * , ScrollviewEventType ) ; <nl> # define scrollvieweventselector ( _SELECTOR ) ( SEL_ScrollViewEvent ) ( & _SELECTOR ) <nl> <nl> <nl> - class UIScrollView : public UILayout , public UIScrollInterface <nl> + class ScrollView : public Layout , public UIScrollInterface <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UIScrollView ( ) ; <nl> + ScrollView ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ lua NA <nl> - * @ js NA <nl> * / <nl> - virtual ~ UIScrollView ( ) ; <nl> + virtual ~ ScrollView ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UIScrollView * create ( ) ; <nl> + static ScrollView * create ( ) ; <nl> <nl> / * * <nl> * Changes scroll direction of scrollview . <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> * <nl> * @ return inner container . <nl> * / <nl> - UILayout * getInnerContainer ( ) ; <nl> + Layout * getInnerContainer ( ) ; <nl> <nl> / * * <nl> * Scroll inner container to bottom boundary of scrollview . <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> / * * <nl> * Scroll inner container to both direction percent position of scrollview . <nl> * / <nl> - void scrollToPercentBothDirection ( const cocos2d : : Point & percent , float time , bool attenuated ) ; <nl> + void scrollToPercentBothDirection ( const Point & percent , float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Move inner container to bottom boundary of scrollview . <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> / * * <nl> * Move inner container to both direction percent position of scrollview . <nl> * / <nl> - void jumpToPercentBothDirection ( const cocos2d : : Point & percent ) ; <nl> + void jumpToPercentBothDirection ( const Point & percent ) ; <nl> <nl> / * * <nl> * Changes inner container size of scrollview . <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> * <nl> * @ param inner container size . <nl> * / <nl> - void setInnerContainerSize ( const cocos2d : : Size & size ) ; <nl> + void setInnerContainerSize ( const Size & size ) ; <nl> <nl> / * * <nl> * Gets inner container size of scrollview . <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> * <nl> * @ return inner container size . <nl> * / <nl> - const cocos2d : : Size & getInnerContainerSize ( ) const ; <nl> + const Size & getInnerContainerSize ( ) const ; <nl> <nl> / * * <nl> * Add call back function called scrollview event triggered <nl> * / <nl> - void addEventListenerScrollView ( cocos2d : : Object * target , SEL_ScrollViewEvent selector ) ; <nl> + void addEventListenerScrollView ( Object * target , SEL_ScrollViewEvent selector ) ; <nl> <nl> - / / override " addChild " method of widget . <nl> - virtual bool addChild ( UIWidget * widget ) override ; <nl> + virtual void addChild ( Node * child ) override ; <nl> + / * * <nl> + * Adds a child to the container with a z - order <nl> + * <nl> + * If the child is added to a ' running ' node , then ' onEnter ' and ' onEnterTransitionDidFinish ' will be called immediately . <nl> + * <nl> + * @ param child A child node <nl> + * @ param zOrder Z order for drawing priority . Please refer to setZOrder ( int ) <nl> + * / <nl> + virtual void addChild ( Node * child , int zOrder ) override ; <nl> + / * * <nl> + * Adds a child to the container with z order and tag <nl> + * <nl> + * If the child is added to a ' running ' node , then ' onEnter ' and ' onEnterTransitionDidFinish ' will be called immediately . <nl> + * <nl> + * @ param child A child node <nl> + * @ param zOrder Z order for drawing priority . Please refer to setZOrder ( int ) <nl> + * @ param tag A interger to identify the node easily . Please refer to setTag ( int ) <nl> + * / <nl> + virtual void addChild ( Node * child , int zOrder , int tag ) override ; <nl> <nl> / / override " removeAllChildrenAndCleanUp " method of widget . <nl> virtual void removeAllChildren ( ) override ; <nl> <nl> / / override " removeChild " method of widget . <nl> - virtual bool removeChild ( UIWidget * child ) override ; <nl> + virtual void removeChild ( Node * child , bool cleaup = true ) override ; <nl> <nl> / / override " getChildren " method of widget . <nl> - virtual cocos2d : : Array * getChildren ( ) override ; <nl> - <nl> - / / override " onTouchBegan " method of widget . <nl> - virtual bool onTouchBegan ( const cocos2d : : Point & touchPoint ) override ; <nl> - <nl> - / / override " onTouchMoved " method of widget . <nl> - virtual void onTouchMoved ( const cocos2d : : Point & touchPoint ) override ; <nl> - <nl> - / / override " onTouchEnded " method of widget . <nl> - virtual void onTouchEnded ( const cocos2d : : Point & touchPoint ) override ; <nl> + virtual Vector < Node * > & getChildren ( ) override ; <nl> + virtual const Vector < Node * > & getChildren ( ) const override ; <nl> <nl> - / / override " onTouchCancelled " method of widget . <nl> - virtual void onTouchCancelled ( const cocos2d : : Point & touchPoint ) override ; <nl> + virtual bool onTouchBegan ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchMoved ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchEnded ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchCancelled ( Touch * touch , Event * unusedEvent ) override ; <nl> <nl> / / override " onTouchLongClicked " method of widget . <nl> - virtual void onTouchLongClicked ( const cocos2d : : Point & touchPoint ) override ; <nl> + virtual void onTouchLongClicked ( const Point & touchPoint ) override ; <nl> <nl> virtual void update ( float dt ) override ; <nl> <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> * / <nl> virtual LayoutType getLayoutType ( ) const override ; <nl> <nl> - virtual void doLayout ( ) override ; <nl> - <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> protected : <nl> virtual bool init ( ) override ; <nl> virtual void initRenderer ( ) override ; <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> void bounceChildren ( float dt ) ; <nl> void checkBounceBoundary ( ) ; <nl> bool checkNeedBounce ( ) ; <nl> - void startAutoScrollChildrenWithOriginalSpeed ( const cocos2d : : Point & dir , float v , bool attenuated , float acceleration ) ; <nl> - void startAutoScrollChildrenWithDestination ( const cocos2d : : Point & des , float time , bool attenuated ) ; <nl> - void jumpToDestination ( const cocos2d : : Point & des ) ; <nl> + void startAutoScrollChildrenWithOriginalSpeed ( const Point & dir , float v , bool attenuated , float acceleration ) ; <nl> + void startAutoScrollChildrenWithDestination ( const Point & des , float time , bool attenuated ) ; <nl> + void jumpToDestination ( const Point & des ) ; <nl> void stopAutoScrollChildren ( ) ; <nl> void startBounceChildren ( float v ) ; <nl> void stopBounceChildren ( ) ; <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> bool bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) ; <nl> void startRecordSlidAction ( ) ; <nl> virtual void endRecordSlidAction ( ) ; <nl> - virtual void handlePressLogic ( const cocos2d : : Point & touchPoint ) override ; <nl> - virtual void handleMoveLogic ( const cocos2d : : Point & touchPoint ) override ; <nl> - virtual void handleReleaseLogic ( const cocos2d : : Point & touchPoint ) override ; <nl> - virtual void interceptTouchEvent ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) override ; <nl> - virtual void checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) override ; <nl> + virtual void handlePressLogic ( const Point & touchPoint ) override ; <nl> + virtual void handleMoveLogic ( const Point & touchPoint ) override ; <nl> + virtual void handleReleaseLogic ( const Point & touchPoint ) override ; <nl> + virtual void interceptTouchEvent ( int handleState , Widget * sender , const Point & touchPoint ) override ; <nl> + virtual void checkChildInfo ( int handleState , Widget * sender , const Point & touchPoint ) override ; <nl> void recordSlidTime ( float dt ) ; <nl> void scrollToTopEvent ( ) ; <nl> void scrollToBottomEvent ( ) ; <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> void bounceLeftEvent ( ) ; <nl> void bounceRightEvent ( ) ; <nl> virtual void onSizeChanged ( ) override ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> - virtual void copyClonedWidgetChildren ( UIWidget * model ) override ; <nl> - virtual void setClippingEnabled ( bool able ) override { UILayout : : setClippingEnabled ( able ) ; } ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> + virtual void copyClonedWidgetChildren ( Widget * model ) override ; <nl> + virtual void setClippingEnabled ( bool able ) override { Layout : : setClippingEnabled ( able ) ; } ; <nl> + virtual void doLayout ( ) override ; <nl> protected : <nl> - UILayout * _innerContainer ; <nl> + Layout * _innerContainer ; <nl> <nl> SCROLLVIEW_DIR _direction ; <nl> <nl> - cocos2d : : Point _touchBeganPoint ; <nl> - cocos2d : : Point _touchMovedPoint ; <nl> - cocos2d : : Point _touchEndedPoint ; <nl> - cocos2d : : Point _touchMovingPoint ; <nl> - cocos2d : : Point _autoScrollDir ; <nl> + Point _touchBeganPoint ; <nl> + Point _touchMovedPoint ; <nl> + Point _touchEndedPoint ; <nl> + Point _touchMovingPoint ; <nl> + Point _autoScrollDir ; <nl> <nl> float _topBoundary ; <nl> float _bottomBoundary ; <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> float _autoScrollAcceleration ; <nl> bool _isAutoScrollSpeedAttenuated ; <nl> bool _needCheckAutoScrollDestination ; <nl> - cocos2d : : Point _autoScrollDestination ; <nl> + Point _autoScrollDestination ; <nl> <nl> bool _bePressed ; <nl> float _slidTime ; <nl> - cocos2d : : Point _moveChildPoint ; <nl> + Point _moveChildPoint ; <nl> float _childFocusCancelOffset ; <nl> <nl> bool _leftBounceNeeded ; <nl> class UIScrollView : public UILayout , public UIScrollInterface <nl> <nl> bool _bounceEnabled ; <nl> bool _bouncing ; <nl> - cocos2d : : Point _bounceDir ; <nl> + Point _bounceDir ; <nl> float _bounceOriginalSpeed ; <nl> bool _inertiaScrollEnabled ; <nl> <nl> <nl> <nl> - cocos2d : : Object * _scrollViewEventListener ; <nl> + Object * _scrollViewEventListener ; <nl> SEL_ScrollViewEvent _scrollViewEventSelector ; <nl> } ; <nl> <nl> } <nl> - <nl> - # endif / * defined ( __CocoGUI__UIScrollView__ ) * / <nl> + NS_CC_END <nl> + # endif / * defined ( __CocoGUI__ScrollView__ ) * / <nl> mmm a / cocos / gui / UISlider . cpp <nl> ppp b / cocos / gui / UISlider . cpp <nl> <nl> # include " gui / UISlider . h " <nl> # include " extensions / GUI / CCControlExtension / CCScale9Sprite . h " <nl> <nl> - namespace gui { <nl> + NS_CC_BEGIN <nl> <nl> - UISlider : : UISlider ( ) : <nl> + namespace gui { <nl> + <nl> + # define BASEBARRENDERERZ ( - 2 ) <nl> + # define PROGRESSBARRENDERERZ ( - 2 ) <nl> + # define SLIDBALLRENDERERZ ( - 1 ) <nl> + <nl> + Slider : : Slider ( ) : <nl> _barRenderer ( nullptr ) , <nl> _progressBarRenderer ( nullptr ) , <nl> - _progressBarTextureSize ( cocos2d : : Size : : ZERO ) , <nl> + _progressBarTextureSize ( Size : : ZERO ) , <nl> _slidBallNormalRenderer ( nullptr ) , <nl> _slidBallPressedRenderer ( nullptr ) , <nl> _slidBallDisabledRenderer ( nullptr ) , <nl> _progressBarTextureFile ( " " ) , <nl> _slidBallNormalTextureFile ( " " ) , <nl> _slidBallPressedTextureFile ( " " ) , <nl> _slidBallDisabledTextureFile ( " " ) , <nl> - _capInsetsBarRenderer ( cocos2d : : Rect : : ZERO ) , <nl> - _capInsetsProgressBarRenderer ( cocos2d : : Rect : : ZERO ) , <nl> + _capInsetsBarRenderer ( Rect : : ZERO ) , <nl> + _capInsetsProgressBarRenderer ( Rect : : ZERO ) , <nl> _sliderEventListener ( nullptr ) , <nl> _sliderEventSelector ( nullptr ) , <nl> _barTexType ( UI_TEX_TYPE_LOCAL ) , <nl> _ballDTexType ( UI_TEX_TYPE_LOCAL ) <nl> { <nl> } <nl> <nl> - UISlider : : ~ UISlider ( ) <nl> + Slider : : ~ Slider ( ) <nl> { <nl> _sliderEventListener = nullptr ; <nl> _sliderEventSelector = nullptr ; <nl> } <nl> <nl> - UISlider * UISlider : : create ( ) <nl> + Slider * Slider : : create ( ) <nl> { <nl> - UISlider * widget = new UISlider ( ) ; <nl> + Slider * widget = new Slider ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UISlider * UISlider : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - void UISlider : : initRenderer ( ) <nl> + void Slider : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> - _barRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _progressBarRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _progressBarRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0f , 0 . 5f ) ) ; <nl> - _renderer - > addChild ( _barRenderer , - 1 ) ; <nl> - _renderer - > addChild ( _progressBarRenderer , - 1 ) ; <nl> - _slidBallNormalRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _slidBallPressedRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _barRenderer = Sprite : : create ( ) ; <nl> + _progressBarRenderer = Sprite : : create ( ) ; <nl> + _progressBarRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + Node : : addChild ( _barRenderer , BASEBARRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _progressBarRenderer , PROGRESSBARRENDERERZ , - 1 ) ; <nl> + _slidBallNormalRenderer = Sprite : : create ( ) ; <nl> + _slidBallPressedRenderer = Sprite : : create ( ) ; <nl> _slidBallPressedRenderer - > setVisible ( false ) ; <nl> - _slidBallDisabledRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _slidBallDisabledRenderer = Sprite : : create ( ) ; <nl> _slidBallDisabledRenderer - > setVisible ( false ) ; <nl> - _slidBallRenderer = cocos2d : : Node : : create ( ) ; <nl> + _slidBallRenderer = Node : : create ( ) ; <nl> _slidBallRenderer - > addChild ( _slidBallNormalRenderer ) ; <nl> _slidBallRenderer - > addChild ( _slidBallPressedRenderer ) ; <nl> _slidBallRenderer - > addChild ( _slidBallDisabledRenderer ) ; <nl> - _renderer - > addChild ( _slidBallRenderer ) ; <nl> + Node : : addChild ( _slidBallRenderer , SLIDBALLRENDERERZ , - 1 ) ; <nl> } <nl> <nl> - void UISlider : : loadBarTexture ( const char * fileName , TextureResType texType ) <nl> + void Slider : : loadBarTexture ( const char * fileName , TextureResType texType ) <nl> { <nl> if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> { <nl> void UISlider : : loadBarTexture ( const char * fileName , TextureResType texType ) <nl> case UI_TEX_TYPE_LOCAL : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > initWithFile ( fileName ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _barRenderer ) - > initWithFile ( fileName ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setTexture ( fileName ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setTexture ( fileName ) ; <nl> } <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _barRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setSpriteFrame ( fileName ) ; <nl> + static_cast < Sprite * > ( _barRenderer ) - > setSpriteFrame ( fileName ) ; <nl> } <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - if ( _scale9Enabled ) <nl> - { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _barRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - } <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> barRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UISlider : : loadProgressBarTexture ( const char * fileName , TextureResType texType ) <nl> + void Slider : : loadProgressBarTexture ( const char * fileName , TextureResType texType ) <nl> { <nl> if ( ! fileName | | strcmp ( fileName , " " ) = = 0 ) <nl> { <nl> void UISlider : : loadProgressBarTexture ( const char * fileName , TextureResType texTy <nl> case UI_TEX_TYPE_LOCAL : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > initWithFile ( fileName ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _progressBarRenderer ) - > initWithFile ( fileName ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > setTexture ( fileName ) ; <nl> + static_cast < Sprite * > ( _progressBarRenderer ) - > setTexture ( fileName ) ; <nl> } <nl> break ; <nl> case UI_TEX_TYPE_PLIST : <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _progressBarRenderer ) - > initWithSpriteFrameName ( fileName ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > setSpriteFrame ( fileName ) ; <nl> + static_cast < Sprite * > ( _progressBarRenderer ) - > setSpriteFrame ( fileName ) ; <nl> } <nl> break ; <nl> default : <nl> break ; <nl> } <nl> - if ( _scale9Enabled ) <nl> - { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > setColor ( getColor ( ) ) ; <nl> - dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > setOpacity ( getOpacity ( ) ) ; <nl> - } <nl> - _progressBarRenderer - > setAnchorPoint ( cocos2d : : Point ( 0 . 0f , 0 . 5f ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> + _progressBarRenderer - > setAnchorPoint ( Point ( 0 . 0f , 0 . 5f ) ) ; <nl> _progressBarTextureSize = _progressBarRenderer - > getContentSize ( ) ; <nl> progressBarRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UISlider : : setScale9Enabled ( bool able ) <nl> + void Slider : : setScale9Enabled ( bool able ) <nl> { <nl> if ( _scale9Enabled = = able ) <nl> { <nl> void UISlider : : setScale9Enabled ( bool able ) <nl> } <nl> <nl> _scale9Enabled = able ; <nl> - _renderer - > removeChild ( _barRenderer , true ) ; <nl> - _renderer - > removeChild ( _progressBarRenderer , true ) ; <nl> + Node : : removeChild ( _barRenderer ) ; <nl> + Node : : removeChild ( _progressBarRenderer ) ; <nl> _barRenderer = nullptr ; <nl> _progressBarRenderer = nullptr ; <nl> if ( _scale9Enabled ) <nl> { <nl> - _barRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> - _progressBarRenderer = cocos2d : : extension : : Scale9Sprite : : create ( ) ; <nl> + _barRenderer = extension : : Scale9Sprite : : create ( ) ; <nl> + _progressBarRenderer = extension : : Scale9Sprite : : create ( ) ; <nl> } <nl> else <nl> { <nl> - _barRenderer = cocos2d : : Sprite : : create ( ) ; <nl> - _progressBarRenderer = cocos2d : : Sprite : : create ( ) ; <nl> + _barRenderer = Sprite : : create ( ) ; <nl> + _progressBarRenderer = Sprite : : create ( ) ; <nl> } <nl> loadBarTexture ( _textureFile . c_str ( ) , _barTexType ) ; <nl> loadProgressBarTexture ( _progressBarTextureFile . c_str ( ) , _progressBarTexType ) ; <nl> - _renderer - > addChild ( _barRenderer , - 1 ) ; <nl> - _renderer - > addChild ( _progressBarRenderer , - 1 ) ; <nl> + Node : : addChild ( _barRenderer , BASEBARRENDERERZ , - 1 ) ; <nl> + Node : : addChild ( _progressBarRenderer , PROGRESSBARRENDERERZ , - 1 ) ; <nl> if ( _scale9Enabled ) <nl> { <nl> bool ignoreBefore = _ignoreSize ; <nl> void UISlider : : setScale9Enabled ( bool able ) <nl> setCapInsetProgressBarRebderer ( _capInsetsProgressBarRenderer ) ; <nl> } <nl> <nl> - void UISlider : : ignoreContentAdaptWithSize ( bool ignore ) <nl> + void Slider : : ignoreContentAdaptWithSize ( bool ignore ) <nl> { <nl> if ( ! _scale9Enabled | | ( _scale9Enabled & & ! ignore ) ) <nl> { <nl> - UIWidget : : ignoreContentAdaptWithSize ( ignore ) ; <nl> + Widget : : ignoreContentAdaptWithSize ( ignore ) ; <nl> _prevIgnoreSize = ignore ; <nl> } <nl> } <nl> <nl> - void UISlider : : setCapInsets ( const cocos2d : : Rect & capInsets ) <nl> + void Slider : : setCapInsets ( const Rect & capInsets ) <nl> { <nl> setCapInsetsBarRenderer ( capInsets ) ; <nl> setCapInsetProgressBarRebderer ( capInsets ) ; <nl> } <nl> <nl> - void UISlider : : setCapInsetsBarRenderer ( const cocos2d : : Rect & capInsets ) <nl> + void Slider : : setCapInsetsBarRenderer ( const Rect & capInsets ) <nl> { <nl> _capInsetsBarRenderer = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( capInsets ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _barRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UISlider : : setCapInsetProgressBarRebderer ( const cocos2d : : Rect & capInsets ) <nl> + void Slider : : setCapInsetProgressBarRebderer ( const Rect & capInsets ) <nl> { <nl> _capInsetsProgressBarRenderer = capInsets ; <nl> if ( ! _scale9Enabled ) <nl> { <nl> return ; <nl> } <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setCapInsets ( capInsets ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setCapInsets ( capInsets ) ; <nl> } <nl> <nl> - void UISlider : : loadSlidBallTextures ( const char * normal , const char * pressed , const char * disabled , TextureResType texType ) <nl> + void Slider : : loadSlidBallTextures ( const char * normal , const char * pressed , const char * disabled , TextureResType texType ) <nl> { <nl> loadSlidBallTextureNormal ( normal , texType ) ; <nl> loadSlidBallTexturePressed ( pressed , texType ) ; <nl> loadSlidBallTextureDisabled ( disabled , texType ) ; <nl> } <nl> <nl> - void UISlider : : loadSlidBallTextureNormal ( const char * normal , TextureResType texType ) <nl> + void Slider : : loadSlidBallTextureNormal ( const char * normal , TextureResType texType ) <nl> { <nl> if ( ! normal | | strcmp ( normal , " " ) = = 0 ) <nl> { <nl> void UISlider : : loadSlidBallTextureNormal ( const char * normal , TextureResType texTy <nl> default : <nl> break ; <nl> } <nl> - _slidBallNormalRenderer - > setColor ( getColor ( ) ) ; <nl> - _slidBallNormalRenderer - > setOpacity ( getOpacity ( ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> } <nl> <nl> - void UISlider : : loadSlidBallTexturePressed ( const char * pressed , TextureResType texType ) <nl> + void Slider : : loadSlidBallTexturePressed ( const char * pressed , TextureResType texType ) <nl> { <nl> if ( ! pressed | | strcmp ( pressed , " " ) = = 0 ) <nl> { <nl> void UISlider : : loadSlidBallTexturePressed ( const char * pressed , TextureResType tex <nl> default : <nl> break ; <nl> } <nl> - _slidBallPressedRenderer - > setColor ( getColor ( ) ) ; <nl> - _slidBallPressedRenderer - > setOpacity ( getOpacity ( ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> } <nl> <nl> - void UISlider : : loadSlidBallTextureDisabled ( const char * disabled , TextureResType texType ) <nl> + void Slider : : loadSlidBallTextureDisabled ( const char * disabled , TextureResType texType ) <nl> { <nl> if ( ! disabled | | strcmp ( disabled , " " ) = = 0 ) <nl> { <nl> void UISlider : : loadSlidBallTextureDisabled ( const char * disabled , TextureResType t <nl> default : <nl> break ; <nl> } <nl> - _slidBallDisabledRenderer - > setColor ( getColor ( ) ) ; <nl> - _slidBallDisabledRenderer - > setOpacity ( getOpacity ( ) ) ; <nl> + updateDisplayedColor ( getColor ( ) ) ; <nl> + updateDisplayedOpacity ( getOpacity ( ) ) ; <nl> } <nl> <nl> - void UISlider : : setPercent ( int percent ) <nl> + void Slider : : setPercent ( int percent ) <nl> { <nl> if ( percent > 100 ) <nl> { <nl> void UISlider : : setPercent ( int percent ) <nl> } <nl> _percent = percent ; <nl> float dis = _barLength * ( percent / 100 . 0f ) ; <nl> - _slidBallRenderer - > setPosition ( cocos2d : : Point ( - _barLength / 2 . 0f + dis , 0 . 0f ) ) ; <nl> + _slidBallRenderer - > setPosition ( Point ( - _barLength / 2 . 0f + dis , 0 . 0f ) ) ; <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setPreferredSize ( cocos2d : : Size ( dis , _progressBarTextureSize . height ) ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setPreferredSize ( Size ( dis , _progressBarTextureSize . height ) ) ; <nl> } <nl> else <nl> { <nl> void UISlider : : setPercent ( int percent ) <nl> { <nl> case UI_TEX_TYPE_PLIST : <nl> { <nl> - cocos2d : : Sprite * barNode = dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) ; <nl> + Sprite * barNode = dynamic_cast < Sprite * > ( _progressBarRenderer ) ; <nl> if ( barNode ) <nl> { <nl> - cocos2d : : Point to = barNode - > getTextureRect ( ) . origin ; <nl> + Point to = barNode - > getTextureRect ( ) . origin ; <nl> x = to . x ; <nl> y = to . y ; <nl> } <nl> void UISlider : : setPercent ( int percent ) <nl> default : <nl> break ; <nl> } <nl> - dynamic_cast < cocos2d : : Sprite * > ( _progressBarRenderer ) - > setTextureRect ( cocos2d : : Rect ( x , y , _progressBarTextureSize . width * ( percent / 100 . 0f ) , _progressBarTextureSize . height ) ) ; <nl> + static_cast < Sprite * > ( _progressBarRenderer ) - > setTextureRect ( Rect ( x , y , _progressBarTextureSize . width * ( percent / 100 . 0f ) , _progressBarTextureSize . height ) ) ; <nl> } <nl> } <nl> <nl> - bool UISlider : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> + bool Slider : : onTouchBegan ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - bool pass = UIWidget : : onTouchBegan ( touchPoint ) ; <nl> - cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - setPercent ( getPercentWithBallPos ( nsp . x ) ) ; <nl> - percentChangedEvent ( ) ; <nl> + bool pass = Widget : : onTouchBegan ( touch , unusedEvent ) ; <nl> + if ( _hitted ) <nl> + { <nl> + Point nsp = convertToNodeSpace ( _touchStartPos ) ; <nl> + setPercent ( getPercentWithBallPos ( nsp . x ) ) ; <nl> + percentChangedEvent ( ) ; <nl> + } <nl> return pass ; <nl> } <nl> <nl> - void UISlider : : onTouchMoved ( const cocos2d : : Point & touchPoint ) <nl> + void Slider : : onTouchMoved ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( touchPoint ) ; <nl> - _slidBallRenderer - > setPosition ( cocos2d : : Point ( nsp . x , 0 ) ) ; <nl> + _touchMovePos = touch - > getLocation ( ) ; <nl> + Point nsp = convertToNodeSpace ( _touchMovePos ) ; <nl> + _slidBallRenderer - > setPosition ( Point ( nsp . x , 0 ) ) ; <nl> setPercent ( getPercentWithBallPos ( nsp . x ) ) ; <nl> percentChangedEvent ( ) ; <nl> } <nl> <nl> - void UISlider : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> + void Slider : : onTouchEnded ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - UIWidget : : onTouchEnded ( touchPoint ) ; <nl> + Widget : : onTouchEnded ( touch , unusedEvent ) ; <nl> } <nl> <nl> - void UISlider : : onTouchCancelled ( const cocos2d : : Point & touchPoint ) <nl> + void Slider : : onTouchCancelled ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - UIWidget : : onTouchCancelled ( touchPoint ) ; <nl> + Widget : : onTouchCancelled ( touch , unusedEvent ) ; <nl> } <nl> <nl> - float UISlider : : getPercentWithBallPos ( float px ) <nl> + float Slider : : getPercentWithBallPos ( float px ) <nl> { <nl> return ( ( ( px - ( - _barLength / 2 . 0f ) ) / _barLength ) * 100 . 0f ) ; <nl> } <nl> <nl> - void UISlider : : addEventListenerSlider ( cocos2d : : Object * target , SEL_SlidPercentChangedEvent selector ) <nl> + void Slider : : addEventListenerSlider ( Object * target , SEL_SlidPercentChangedEvent selector ) <nl> { <nl> _sliderEventListener = target ; <nl> _sliderEventSelector = selector ; <nl> } <nl> <nl> - void UISlider : : percentChangedEvent ( ) <nl> + void Slider : : percentChangedEvent ( ) <nl> { <nl> if ( _sliderEventListener & & _sliderEventSelector ) <nl> { <nl> void UISlider : : percentChangedEvent ( ) <nl> } <nl> } <nl> <nl> - int UISlider : : getPercent ( ) <nl> + int Slider : : getPercent ( ) <nl> { <nl> return _percent ; <nl> } <nl> <nl> - void UISlider : : onSizeChanged ( ) <nl> + void Slider : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> barRendererScaleChangedWithSize ( ) ; <nl> progressBarRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - const cocos2d : : Size & UISlider : : getContentSize ( ) const <nl> + const Size & Slider : : getContentSize ( ) const <nl> { <nl> return _barRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - cocos2d : : Node * UISlider : : getVirtualRenderer ( ) <nl> + Node * Slider : : getVirtualRenderer ( ) <nl> { <nl> return _barRenderer ; <nl> } <nl> <nl> - void UISlider : : barRendererScaleChangedWithSize ( ) <nl> + void Slider : : barRendererScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UISlider : : barRendererScaleChangedWithSize ( ) <nl> _barLength = _size . width ; <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _barRenderer ) - > setPreferredSize ( _size ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _barRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - cocos2d : : Size btextureSize = _barRenderer - > getContentSize ( ) ; <nl> + Size btextureSize = _barRenderer - > getContentSize ( ) ; <nl> if ( btextureSize . width < = 0 . 0f | | btextureSize . height < = 0 . 0f ) <nl> { <nl> _barRenderer - > setScale ( 1 . 0f ) ; <nl> void UISlider : : barRendererScaleChangedWithSize ( ) <nl> setPercent ( _percent ) ; <nl> } <nl> <nl> - void UISlider : : progressBarRendererScaleChangedWithSize ( ) <nl> + void Slider : : progressBarRendererScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> if ( ! _scale9Enabled ) <nl> { <nl> - cocos2d : : Size ptextureSize = _progressBarTextureSize ; <nl> + Size ptextureSize = _progressBarTextureSize ; <nl> float pscaleX = _size . width / ptextureSize . width ; <nl> float pscaleY = _size . height / ptextureSize . height ; <nl> _progressBarRenderer - > setScaleX ( pscaleX ) ; <nl> void UISlider : : progressBarRendererScaleChangedWithSize ( ) <nl> { <nl> if ( _scale9Enabled ) <nl> { <nl> - dynamic_cast < cocos2d : : extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setPreferredSize ( _size ) ; <nl> + static_cast < extension : : Scale9Sprite * > ( _progressBarRenderer ) - > setPreferredSize ( _size ) ; <nl> } <nl> else <nl> { <nl> - cocos2d : : Size ptextureSize = _progressBarTextureSize ; <nl> + Size ptextureSize = _progressBarTextureSize ; <nl> if ( ptextureSize . width < = 0 . 0f | | ptextureSize . height < = 0 . 0f ) <nl> { <nl> _progressBarRenderer - > setScale ( 1 . 0f ) ; <nl> void UISlider : : progressBarRendererScaleChangedWithSize ( ) <nl> _progressBarRenderer - > setScaleY ( pscaleY ) ; <nl> } <nl> } <nl> - _progressBarRenderer - > setPosition ( cocos2d : : Point ( - _barLength * 0 . 5f , 0 . 0f ) ) ; <nl> + _progressBarRenderer - > setPosition ( Point ( - _barLength * 0 . 5f , 0 . 0f ) ) ; <nl> setPercent ( _percent ) ; <nl> } <nl> <nl> - void UISlider : : onPressStateChangedToNormal ( ) <nl> + void Slider : : onPressStateChangedToNormal ( ) <nl> { <nl> _slidBallNormalRenderer - > setVisible ( true ) ; <nl> _slidBallPressedRenderer - > setVisible ( false ) ; <nl> _slidBallDisabledRenderer - > setVisible ( false ) ; <nl> } <nl> <nl> - void UISlider : : onPressStateChangedToPressed ( ) <nl> + void Slider : : onPressStateChangedToPressed ( ) <nl> { <nl> _slidBallNormalRenderer - > setVisible ( false ) ; <nl> _slidBallPressedRenderer - > setVisible ( true ) ; <nl> _slidBallDisabledRenderer - > setVisible ( false ) ; <nl> } <nl> <nl> - void UISlider : : onPressStateChangedToDisabled ( ) <nl> + void Slider : : onPressStateChangedToDisabled ( ) <nl> { <nl> _slidBallNormalRenderer - > setVisible ( false ) ; <nl> _slidBallPressedRenderer - > setVisible ( false ) ; <nl> _slidBallDisabledRenderer - > setVisible ( true ) ; <nl> } <nl> <nl> - const char * UISlider : : getDescription ( ) const <nl> + std : : string Slider : : getDescription ( ) const <nl> { <nl> return " Slider " ; <nl> } <nl> <nl> - UIWidget * UISlider : : createCloneInstance ( ) <nl> + Widget * Slider : : createCloneInstance ( ) <nl> { <nl> - return UISlider : : create ( ) ; <nl> + return Slider : : create ( ) ; <nl> } <nl> <nl> - void UISlider : : copySpecialProperties ( UIWidget * widget ) <nl> + void Slider : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UISlider * slider = dynamic_cast < UISlider * > ( widget ) ; <nl> + Slider * slider = dynamic_cast < Slider * > ( widget ) ; <nl> if ( slider ) <nl> { <nl> _prevIgnoreSize = slider - > _prevIgnoreSize ; <nl> void UISlider : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UISlider . h <nl> ppp b / cocos / gui / UISlider . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> typedef enum <nl> typedef enum <nl> SLIDER_PERCENTCHANGED <nl> } SliderEventType ; <nl> <nl> - typedef void ( cocos2d : : Object : : * SEL_SlidPercentChangedEvent ) ( cocos2d : : Object * , SliderEventType ) ; <nl> + typedef void ( Object : : * SEL_SlidPercentChangedEvent ) ( Object * , SliderEventType ) ; <nl> # define sliderpercentchangedselector ( _SELECTOR ) ( SEL_SlidPercentChangedEvent ) ( & _SELECTOR ) <nl> <nl> - class UISlider : public UIWidget <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class Slider : public Widget <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UISlider ( ) ; <nl> + Slider ( ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UISlider ( ) ; <nl> + virtual ~ Slider ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes . <nl> * / <nl> - static UISlider * create ( ) ; <nl> + static Slider * create ( ) ; <nl> <nl> / * * <nl> * Load texture for slider bar . <nl> class UISlider : public UIWidget <nl> * <nl> * @ param capInsets capinsets for slider <nl> * / <nl> - void setCapInsets ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsets ( const Rect & capInsets ) ; <nl> <nl> / * * <nl> * Sets capinsets for slider , if slider is using scale9 renderer . <nl> * <nl> * @ param capInsets capinsets for slider <nl> * / <nl> - void setCapInsetsBarRenderer ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsetsBarRenderer ( const Rect & capInsets ) ; <nl> <nl> / * * <nl> * Sets capinsets for slider , if slider is using scale9 renderer . <nl> * <nl> * @ param capInsets capinsets for slider <nl> * / <nl> - void setCapInsetProgressBarRebderer ( const cocos2d : : Rect & capInsets ) ; <nl> + void setCapInsetProgressBarRebderer ( const Rect & capInsets ) ; <nl> <nl> / * * <nl> * Load textures for slider ball . <nl> class UISlider : public UIWidget <nl> / * * <nl> * Add call back function called when slider ' s percent has changed to slider . <nl> * / <nl> - void addEventListenerSlider ( cocos2d : : Object * target , SEL_SlidPercentChangedEvent selector ) ; <nl> - <nl> - / / override " onTouchBegan " method of widget . <nl> - virtual bool onTouchBegan ( const cocos2d : : Point & touchPoint ) override ; <nl> - <nl> - / / override " onTouchMoved " method of widget . <nl> - virtual void onTouchMoved ( const cocos2d : : Point & touchPoint ) override ; <nl> - <nl> - / / override " onTouchEnded " method of widget . <nl> - virtual void onTouchEnded ( const cocos2d : : Point & touchPoint ) override ; <nl> + void addEventListenerSlider ( Object * target , SEL_SlidPercentChangedEvent selector ) ; <nl> <nl> - / / override " onTouchCancelled " method of widget . <nl> - virtual void onTouchCancelled ( const cocos2d : : Point & touchPoint ) override ; <nl> + virtual bool onTouchBegan ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchMoved ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchEnded ( Touch * touch , Event * unusedEvent ) override ; <nl> + virtual void onTouchCancelled ( Touch * touch , Event * unusedEvent ) override ; <nl> <nl> / / override " getContentSize " method of widget . <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> <nl> / / override " getVirtualRenderer " method of widget . <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> <nl> / / override " ignoreContentAdaptWithSize " method of widget . <nl> virtual void ignoreContentAdaptWithSize ( bool ignore ) override ; <nl> class UISlider : public UIWidget <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> protected : <nl> virtual void initRenderer ( ) override ; <nl> class UISlider : public UIWidget <nl> virtual void onSizeChanged ( ) override ; <nl> void barRendererScaleChangedWithSize ( ) ; <nl> void progressBarRendererScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> - cocos2d : : Node * _barRenderer ; <nl> - cocos2d : : Node * _progressBarRenderer ; <nl> - cocos2d : : Size _progressBarTextureSize ; <nl> + Node * _barRenderer ; <nl> + Node * _progressBarRenderer ; <nl> + Size _progressBarTextureSize ; <nl> <nl> - cocos2d : : Sprite * _slidBallNormalRenderer ; <nl> - cocos2d : : Sprite * _slidBallPressedRenderer ; <nl> - cocos2d : : Sprite * _slidBallDisabledRenderer ; <nl> - cocos2d : : Node * _slidBallRenderer ; <nl> + Sprite * _slidBallNormalRenderer ; <nl> + Sprite * _slidBallPressedRenderer ; <nl> + Sprite * _slidBallDisabledRenderer ; <nl> + Node * _slidBallRenderer ; <nl> <nl> float _barLength ; <nl> int _percent ; <nl> class UISlider : public UIWidget <nl> std : : string _slidBallPressedTextureFile ; <nl> std : : string _slidBallDisabledTextureFile ; <nl> <nl> - cocos2d : : Rect _capInsetsBarRenderer ; <nl> - cocos2d : : Rect _capInsetsProgressBarRenderer ; <nl> + Rect _capInsetsBarRenderer ; <nl> + Rect _capInsetsProgressBarRenderer ; <nl> <nl> - cocos2d : : Object * _sliderEventListener ; <nl> + Object * _sliderEventListener ; <nl> SEL_SlidPercentChangedEvent _sliderEventSelector ; <nl> TextureResType _barTexType ; <nl> TextureResType _progressBarTexType ; <nl> class UISlider : public UIWidget <nl> } ; <nl> <nl> } <nl> + NS_CC_END <nl> <nl> - # endif / * defined ( __CocoGUI__UISlider__ ) * / <nl> + # endif / * defined ( __CocoGUI__Slider__ ) * / <nl> mmm a / cocos / gui / UITextField . cpp <nl> ppp b / cocos / gui / UITextField . cpp <nl> <nl> <nl> # include " gui / UITextField . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> UICCTextField : : UICCTextField ( ) <nl> UICCTextField * UICCTextField : : create ( const char * placeholder , const char * fontN <nl> <nl> void UICCTextField : : onEnter ( ) <nl> { <nl> - cocos2d : : TextFieldTTF : : setDelegate ( this ) ; <nl> + TextFieldTTF : : setDelegate ( this ) ; <nl> } <nl> <nl> <nl> - bool UICCTextField : : onTextFieldAttachWithIME ( cocos2d : : TextFieldTTF * pSender ) <nl> + bool UICCTextField : : onTextFieldAttachWithIME ( TextFieldTTF * pSender ) <nl> { <nl> setAttachWithIME ( true ) ; <nl> return false ; <nl> } <nl> <nl> - bool UICCTextField : : onTextFieldInsertText ( cocos2d : : TextFieldTTF * pSender , const char * text , int nLen ) <nl> + bool UICCTextField : : onTextFieldInsertText ( TextFieldTTF * pSender , const char * text , int nLen ) <nl> { <nl> if ( nLen = = 1 & & strcmp ( text , " \ n " ) = = 0 ) <nl> { <nl> bool UICCTextField : : onTextFieldInsertText ( cocos2d : : TextFieldTTF * pSender , const <nl> setInsertText ( true ) ; <nl> if ( _maxLengthEnabled ) <nl> { <nl> - if ( cocos2d : : TextFieldTTF : : getCharCount ( ) > = _maxLength ) <nl> + if ( TextFieldTTF : : getCharCount ( ) > = _maxLength ) <nl> { <nl> return true ; <nl> } <nl> bool UICCTextField : : onTextFieldInsertText ( cocos2d : : TextFieldTTF * pSender , const <nl> return false ; <nl> } <nl> <nl> - bool UICCTextField : : onTextFieldDeleteBackward ( cocos2d : : TextFieldTTF * pSender , const char * delText , int nLen ) <nl> + bool UICCTextField : : onTextFieldDeleteBackward ( TextFieldTTF * pSender , const char * delText , int nLen ) <nl> { <nl> setDeleteBackward ( true ) ; <nl> return false ; <nl> } <nl> <nl> - bool UICCTextField : : onTextFieldDetachWithIME ( cocos2d : : TextFieldTTF * pSender ) <nl> + bool UICCTextField : : onTextFieldDetachWithIME ( TextFieldTTF * pSender ) <nl> { <nl> setDetachWithIME ( true ) ; <nl> return false ; <nl> bool UICCTextField : : onTextFieldDetachWithIME ( cocos2d : : TextFieldTTF * pSender ) <nl> void UICCTextField : : insertText ( const char * text , int len ) <nl> { <nl> std : : string str_text = text ; <nl> - size_t str_len = cocos2d : : TextFieldTTF : : getString ( ) . size ( ) ; <nl> + int str_len = TextFieldTTF : : getString ( ) . size ( ) ; <nl> <nl> if ( strcmp ( text , " \ n " ) ! = 0 ) <nl> { <nl> void UICCTextField : : insertText ( const char * text , int len ) <nl> } <nl> } <nl> } <nl> - cocos2d : : TextFieldTTF : : insertText ( str_text . c_str ( ) , len ) ; <nl> + TextFieldTTF : : insertText ( str_text . c_str ( ) , len ) ; <nl> <nl> / / password <nl> if ( _passwordEnabled ) <nl> { <nl> - if ( cocos2d : : TextFieldTTF : : getCharCount ( ) > 0 ) <nl> + if ( TextFieldTTF : : getCharCount ( ) > 0 ) <nl> { <nl> setPasswordText ( _inputText . c_str ( ) ) ; <nl> } <nl> void UICCTextField : : insertText ( const char * text , int len ) <nl> <nl> void UICCTextField : : deleteBackward ( ) <nl> { <nl> - cocos2d : : TextFieldTTF : : deleteBackward ( ) ; <nl> + TextFieldTTF : : deleteBackward ( ) ; <nl> <nl> - if ( cocos2d : : TextFieldTTF : : getCharCount ( ) > 0 ) <nl> + if ( TextFieldTTF : : getCharCount ( ) > 0 ) <nl> { <nl> / / password <nl> if ( _passwordEnabled ) <nl> void UICCTextField : : deleteBackward ( ) <nl> <nl> void UICCTextField : : openIME ( ) <nl> { <nl> - cocos2d : : TextFieldTTF : : attachWithIME ( ) ; <nl> + TextFieldTTF : : attachWithIME ( ) ; <nl> } <nl> <nl> void UICCTextField : : closeIME ( ) <nl> { <nl> - cocos2d : : TextFieldTTF : : detachWithIME ( ) ; <nl> + TextFieldTTF : : detachWithIME ( ) ; <nl> } <nl> <nl> void UICCTextField : : setMaxLengthEnabled ( bool enable ) <nl> int UICCTextField : : getMaxLength ( ) <nl> <nl> int UICCTextField : : getCharCount ( ) <nl> { <nl> - return cocos2d : : TextFieldTTF : : getCharCount ( ) ; <nl> + return TextFieldTTF : : getCharCount ( ) ; <nl> } <nl> <nl> void UICCTextField : : setPasswordEnabled ( bool enable ) <nl> void UICCTextField : : setPasswordText ( const char * text ) <nl> { <nl> tempStr . append ( _passwordStyleText ) ; <nl> } <nl> - cocos2d : : LabelTTF : : setString ( tempStr . c_str ( ) ) ; <nl> + LabelTTF : : setString ( tempStr . c_str ( ) ) ; <nl> } <nl> <nl> void UICCTextField : : setAttachWithIME ( bool attach ) <nl> bool UICCTextField : : getDeleteBackward ( ) <nl> return _deleteBackward ; <nl> } <nl> <nl> - <nl> + # define TEXTFIELDRENDERERZ ( - 1 ) <nl> <nl> <nl> - UITextField : : UITextField ( ) : <nl> + TextField : : TextField ( ) : <nl> _textFieldRenderer ( nullptr ) , <nl> _touchWidth ( 0 . 0f ) , <nl> _touchHeight ( 0 . 0f ) , <nl> _passwordStyleText ( " " ) <nl> { <nl> } <nl> <nl> - UITextField : : ~ UITextField ( ) <nl> + TextField : : ~ TextField ( ) <nl> { <nl> _textFieldEventListener = nullptr ; <nl> _textFieldEventSelector = nullptr ; <nl> } <nl> <nl> - UITextField * UITextField : : create ( ) <nl> + TextField * TextField : : create ( ) <nl> { <nl> - UITextField * widget = new UITextField ( ) ; <nl> + TextField * widget = new TextField ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UITextField * UITextField : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UITextField : : init ( ) <nl> + bool TextField : : init ( ) <nl> { <nl> - if ( UIWidget : : init ( ) ) <nl> + if ( Widget : : init ( ) ) <nl> { <nl> setUpdateEnabled ( true ) ; <nl> return true ; <nl> bool UITextField : : init ( ) <nl> return false ; <nl> } <nl> <nl> - void UITextField : : initRenderer ( ) <nl> + void TextField : : initRenderer ( ) <nl> { <nl> - UIWidget : : initRenderer ( ) ; <nl> _textFieldRenderer = UICCTextField : : create ( " input words here " , " Thonburi " , 20 ) ; <nl> - _renderer - > addChild ( _textFieldRenderer ) ; <nl> + Node : : addChild ( _textFieldRenderer , TEXTFIELDRENDERERZ , - 1 ) ; <nl> } <nl> <nl> - void UITextField : : setTouchSize ( const cocos2d : : Size & size ) <nl> + void TextField : : setTouchSize ( const Size & size ) <nl> { <nl> _useTouchArea = true ; <nl> _touchWidth = size . width ; <nl> _touchHeight = size . height ; <nl> } <nl> <nl> - void UITextField : : setText ( const std : : string & text ) <nl> + void TextField : : setText ( const std : : string & text ) <nl> { <nl> if ( text . size ( ) = = 0 ) <nl> return ; <nl> void UITextField : : setText ( const std : : string & text ) <nl> textfieldRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UITextField : : setPlaceHolder ( const std : : string & value ) <nl> + void TextField : : setPlaceHolder ( const std : : string & value ) <nl> { <nl> _textFieldRenderer - > setPlaceHolder ( value ) ; <nl> textfieldRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UITextField : : setFontSize ( int size ) <nl> + void TextField : : setFontSize ( int size ) <nl> { <nl> _textFieldRenderer - > setFontSize ( size ) ; <nl> textfieldRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UITextField : : setFontName ( const std : : string & name ) <nl> + void TextField : : setFontName ( const std : : string & name ) <nl> { <nl> _textFieldRenderer - > setFontName ( name ) ; <nl> textfieldRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UITextField : : didNotSelectSelf ( ) <nl> + void TextField : : didNotSelectSelf ( ) <nl> { <nl> _textFieldRenderer - > detachWithIME ( ) ; <nl> } <nl> <nl> - const std : : string & UITextField : : getStringValue ( ) <nl> + const std : : string & TextField : : getStringValue ( ) <nl> { <nl> return _textFieldRenderer - > getString ( ) ; <nl> } <nl> <nl> - bool UITextField : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> + bool TextField : : onTouchBegan ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - bool pass = UIWidget : : onTouchBegan ( touchPoint ) ; <nl> - _textFieldRenderer - > attachWithIME ( ) ; <nl> + bool pass = Widget : : onTouchBegan ( touch , unusedEvent ) ; <nl> + if ( _hitted ) <nl> + { <nl> + _textFieldRenderer - > attachWithIME ( ) ; <nl> + } <nl> return pass ; <nl> } <nl> <nl> - void UITextField : : setMaxLengthEnabled ( bool enable ) <nl> + void TextField : : setMaxLengthEnabled ( bool enable ) <nl> { <nl> _textFieldRenderer - > setMaxLengthEnabled ( enable ) ; <nl> } <nl> <nl> - bool UITextField : : isMaxLengthEnabled ( ) <nl> + bool TextField : : isMaxLengthEnabled ( ) <nl> { <nl> return _textFieldRenderer - > isMaxLengthEnabled ( ) ; <nl> } <nl> <nl> - void UITextField : : setMaxLength ( int length ) <nl> + void TextField : : setMaxLength ( int length ) <nl> { <nl> _textFieldRenderer - > setMaxLength ( length ) ; <nl> } <nl> <nl> - int UITextField : : getMaxLength ( ) <nl> + int TextField : : getMaxLength ( ) <nl> { <nl> return _textFieldRenderer - > getMaxLength ( ) ; <nl> } <nl> <nl> - void UITextField : : setPasswordEnabled ( bool enable ) <nl> + void TextField : : setPasswordEnabled ( bool enable ) <nl> { <nl> _textFieldRenderer - > setPasswordEnabled ( enable ) ; <nl> } <nl> <nl> - bool UITextField : : isPasswordEnabled ( ) <nl> + bool TextField : : isPasswordEnabled ( ) <nl> { <nl> return _textFieldRenderer - > isPasswordEnabled ( ) ; <nl> } <nl> <nl> - void UITextField : : setPasswordStyleText ( const char * styleText ) <nl> + void TextField : : setPasswordStyleText ( const char * styleText ) <nl> { <nl> _textFieldRenderer - > setPasswordStyleText ( styleText ) ; <nl> <nl> _passwordStyleText = styleText ; <nl> } <nl> <nl> - void UITextField : : update ( float dt ) <nl> + void TextField : : update ( float dt ) <nl> { <nl> if ( getAttachWithIME ( ) ) <nl> { <nl> void UITextField : : update ( float dt ) <nl> } <nl> } <nl> <nl> - bool UITextField : : getAttachWithIME ( ) <nl> + bool TextField : : getAttachWithIME ( ) <nl> { <nl> return _textFieldRenderer - > getAttachWithIME ( ) ; <nl> } <nl> <nl> - void UITextField : : setAttachWithIME ( bool attach ) <nl> + void TextField : : setAttachWithIME ( bool attach ) <nl> { <nl> _textFieldRenderer - > setAttachWithIME ( attach ) ; <nl> } <nl> <nl> - bool UITextField : : getDetachWithIME ( ) <nl> + bool TextField : : getDetachWithIME ( ) <nl> { <nl> return _textFieldRenderer - > getDetachWithIME ( ) ; <nl> } <nl> <nl> - void UITextField : : setDetachWithIME ( bool detach ) <nl> + void TextField : : setDetachWithIME ( bool detach ) <nl> { <nl> _textFieldRenderer - > setDetachWithIME ( detach ) ; <nl> } <nl> <nl> - bool UITextField : : getInsertText ( ) <nl> + bool TextField : : getInsertText ( ) <nl> { <nl> return _textFieldRenderer - > getInsertText ( ) ; <nl> } <nl> <nl> - void UITextField : : setInsertText ( bool insertText ) <nl> + void TextField : : setInsertText ( bool insertText ) <nl> { <nl> _textFieldRenderer - > setInsertText ( insertText ) ; <nl> } <nl> <nl> - bool UITextField : : getDeleteBackward ( ) <nl> + bool TextField : : getDeleteBackward ( ) <nl> { <nl> return _textFieldRenderer - > getDeleteBackward ( ) ; <nl> } <nl> <nl> - void UITextField : : setDeleteBackward ( bool deleteBackward ) <nl> + void TextField : : setDeleteBackward ( bool deleteBackward ) <nl> { <nl> _textFieldRenderer - > setDeleteBackward ( deleteBackward ) ; <nl> } <nl> <nl> - void UITextField : : attachWithIMEEvent ( ) <nl> + void TextField : : attachWithIMEEvent ( ) <nl> { <nl> if ( _textFieldEventListener & & _textFieldEventSelector ) <nl> { <nl> void UITextField : : attachWithIMEEvent ( ) <nl> } <nl> } <nl> <nl> - void UITextField : : detachWithIMEEvent ( ) <nl> + void TextField : : detachWithIMEEvent ( ) <nl> { <nl> if ( _textFieldEventListener & & _textFieldEventSelector ) <nl> { <nl> void UITextField : : detachWithIMEEvent ( ) <nl> } <nl> } <nl> <nl> - void UITextField : : insertTextEvent ( ) <nl> + void TextField : : insertTextEvent ( ) <nl> { <nl> if ( _textFieldEventListener & & _textFieldEventSelector ) <nl> { <nl> void UITextField : : insertTextEvent ( ) <nl> } <nl> } <nl> <nl> - void UITextField : : deleteBackwardEvent ( ) <nl> + void TextField : : deleteBackwardEvent ( ) <nl> { <nl> if ( _textFieldEventListener & & _textFieldEventSelector ) <nl> { <nl> void UITextField : : deleteBackwardEvent ( ) <nl> } <nl> } <nl> <nl> - void UITextField : : addEventListenerTextField ( cocos2d : : Object * target , SEL_TextFieldEvent selecor ) <nl> + void TextField : : addEventListenerTextField ( Object * target , SEL_TextFieldEvent selecor ) <nl> { <nl> _textFieldEventListener = target ; <nl> _textFieldEventSelector = selecor ; <nl> } <nl> <nl> - void UITextField : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> + void TextField : : setAnchorPoint ( const Point & pt ) <nl> { <nl> - UIWidget : : setAnchorPoint ( pt ) ; <nl> + Widget : : setAnchorPoint ( pt ) ; <nl> _textFieldRenderer - > setAnchorPoint ( pt ) ; <nl> } <nl> <nl> - void UITextField : : setColor ( const cocos2d : : Color3B & color ) <nl> - { <nl> - UIWidget : : setColor ( color ) ; <nl> - _textFieldRenderer - > setColor ( color ) ; <nl> - } <nl> - <nl> - void UITextField : : setOpacity ( int opacity ) <nl> - { <nl> - UIWidget : : setOpacity ( opacity ) ; <nl> - _textFieldRenderer - > setOpacity ( opacity ) ; <nl> - } <nl> - <nl> - void UITextField : : onSizeChanged ( ) <nl> + void TextField : : onSizeChanged ( ) <nl> { <nl> + Widget : : onSizeChanged ( ) ; <nl> textfieldRendererScaleChangedWithSize ( ) ; <nl> } <nl> <nl> - void UITextField : : textfieldRendererScaleChangedWithSize ( ) <nl> + void TextField : : textfieldRendererScaleChangedWithSize ( ) <nl> { <nl> if ( _ignoreSize ) <nl> { <nl> void UITextField : : textfieldRendererScaleChangedWithSize ( ) <nl> } <nl> else <nl> { <nl> - cocos2d : : Size textureSize = getContentSize ( ) ; <nl> + Size textureSize = getContentSize ( ) ; <nl> if ( textureSize . width < = 0 . 0f | | textureSize . height < = 0 . 0f ) <nl> { <nl> _textFieldRenderer - > setScale ( 1 . 0f ) ; <nl> void UITextField : : textfieldRendererScaleChangedWithSize ( ) <nl> } <nl> } <nl> <nl> - const cocos2d : : Size & UITextField : : getContentSize ( ) const <nl> + const Size & TextField : : getContentSize ( ) const <nl> { <nl> return _textFieldRenderer - > getContentSize ( ) ; <nl> } <nl> <nl> - cocos2d : : Node * UITextField : : getVirtualRenderer ( ) <nl> + Node * TextField : : getVirtualRenderer ( ) <nl> { <nl> return _textFieldRenderer ; <nl> } <nl> <nl> - const char * UITextField : : getDescription ( ) const <nl> + std : : string TextField : : getDescription ( ) const <nl> { <nl> return " TextField " ; <nl> } <nl> <nl> - void UITextField : : attachWithIME ( ) <nl> + void TextField : : attachWithIME ( ) <nl> { <nl> _textFieldRenderer - > attachWithIME ( ) ; <nl> } <nl> <nl> - UIWidget * UITextField : : createCloneInstance ( ) <nl> + Widget * TextField : : createCloneInstance ( ) <nl> { <nl> - return UITextField : : create ( ) ; <nl> + return TextField : : create ( ) ; <nl> } <nl> <nl> - void UITextField : : copySpecialProperties ( UIWidget * widget ) <nl> + void TextField : : copySpecialProperties ( Widget * widget ) <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( widget ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( widget ) ; <nl> if ( textField ) <nl> { <nl> setText ( textField - > _textFieldRenderer - > getString ( ) ) ; <nl> void UITextField : : copySpecialProperties ( UIWidget * widget ) <nl> } <nl> } <nl> <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + NS_CC_END <nl> \ No newline at end of file <nl> mmm a / cocos / gui / UITextField . h <nl> ppp b / cocos / gui / UITextField . h <nl> <nl> <nl> # include " gui / UIWidget . h " <nl> <nl> + NS_CC_BEGIN <nl> <nl> namespace gui { <nl> <nl> / * * <nl> * @ js NA <nl> + * @ lua NA <nl> * / <nl> - class UICCTextField : public cocos2d : : TextFieldTTF , public cocos2d : : TextFieldDelegate <nl> + class UICCTextField : public TextFieldTTF , public TextFieldDelegate <nl> { <nl> public : <nl> UICCTextField ( ) ; <nl> - / * * <nl> - * @ lua NA <nl> - * / <nl> ~ UICCTextField ( ) ; <nl> - / * * <nl> - * @ lua NA <nl> - * / <nl> + <nl> virtual void onEnter ( ) ; <nl> <nl> / / static <nl> static UICCTextField * create ( const char * placeholder , const char * fontName , float fontSize ) ; <nl> <nl> / / CCTextFieldDelegate <nl> - virtual bool onTextFieldAttachWithIME ( cocos2d : : TextFieldTTF * pSender ) ; <nl> - virtual bool onTextFieldDetachWithIME ( cocos2d : : TextFieldTTF * pSender ) ; <nl> - virtual bool onTextFieldInsertText ( cocos2d : : TextFieldTTF * pSender , const char * text , int nLen ) ; <nl> - virtual bool onTextFieldDeleteBackward ( cocos2d : : TextFieldTTF * pSender , const char * delText , int nLen ) ; <nl> + virtual bool onTextFieldAttachWithIME ( TextFieldTTF * pSender ) ; <nl> + virtual bool onTextFieldDetachWithIME ( TextFieldTTF * pSender ) ; <nl> + virtual bool onTextFieldInsertText ( TextFieldTTF * pSender , const char * text , int nLen ) ; <nl> + virtual bool onTextFieldDeleteBackward ( TextFieldTTF * pSender , const char * delText , int nLen ) ; <nl> <nl> void insertText ( const char * text , int len ) ; <nl> void deleteBackward ( ) ; <nl> typedef enum <nl> TEXTFIELD_EVENT_DELETE_BACKWARD , <nl> } TextFiledEventType ; <nl> <nl> - typedef void ( cocos2d : : Object : : * SEL_TextFieldEvent ) ( cocos2d : : Object * , TextFiledEventType ) ; <nl> + typedef void ( Object : : * SEL_TextFieldEvent ) ( Object * , TextFiledEventType ) ; <nl> # define textfieldeventselector ( _SELECTOR ) ( SEL_TextFieldEvent ) ( & _SELECTOR ) <nl> <nl> - / * * class UITextField : public UIWidget <nl> - * / <nl> - class UITextField : public UIWidget <nl> + / * * class UITextField : public Widget <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class TextField : public Widget <nl> { <nl> public : <nl> - / * * <nl> - * @ js ctor <nl> - * / <nl> - UITextField ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ UITextField ( ) ; <nl> - static UITextField * create ( ) ; <nl> + TextField ( ) ; <nl> + virtual ~ TextField ( ) ; <nl> + static TextField * create ( ) ; <nl> virtual bool init ( ) override ; <nl> virtual void initRenderer ( ) override ; <nl> - void setTouchSize ( const cocos2d : : Size & size ) ; <nl> + void setTouchSize ( const Size & size ) ; <nl> void setText ( const std : : string & text ) ; <nl> void setPlaceHolder ( const std : : string & value ) ; <nl> void setFontSize ( int size ) ; <nl> void setFontName ( const std : : string & name ) ; <nl> virtual void didNotSelectSelf ( ) ; <nl> const std : : string & getStringValue ( ) ; <nl> - virtual bool onTouchBegan ( const cocos2d : : Point & touchPoint ) override ; <nl> + virtual bool onTouchBegan ( Touch * touch , Event * unusedEvent ) override ; <nl> void setMaxLengthEnabled ( bool enable ) ; <nl> bool isMaxLengthEnabled ( ) ; <nl> void setMaxLength ( int length ) ; <nl> class UITextField : public UIWidget <nl> void setInsertText ( bool insertText ) ; <nl> bool getDeleteBackward ( ) ; <nl> void setDeleteBackward ( bool deleteBackward ) ; <nl> - void addEventListenerTextField ( cocos2d : : Object * target , SEL_TextFieldEvent selecor ) ; <nl> + void addEventListenerTextField ( Object * target , SEL_TextFieldEvent selecor ) ; <nl> <nl> - virtual void setAnchorPoint ( const cocos2d : : Point & pt ) override ; <nl> - virtual void setColor ( const cocos2d : : Color3B & color ) override ; <nl> - virtual void setOpacity ( int opacity ) override ; <nl> + virtual void setAnchorPoint ( const Point & pt ) override ; <nl> <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const override ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> - virtual const cocos2d : : Size & getContentSize ( ) const override ; <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) override ; <nl> + virtual const Size & getContentSize ( ) const override ; <nl> + virtual Node * getVirtualRenderer ( ) override ; <nl> void attachWithIME ( ) ; <nl> protected : <nl> / / event <nl> class UITextField : public UIWidget <nl> void deleteBackwardEvent ( ) ; <nl> virtual void onSizeChanged ( ) override ; <nl> void textfieldRendererScaleChangedWithSize ( ) ; <nl> - virtual UIWidget * createCloneInstance ( ) override ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) override ; <nl> + virtual Widget * createCloneInstance ( ) override ; <nl> + virtual void copySpecialProperties ( Widget * model ) override ; <nl> protected : <nl> UICCTextField * _textFieldRenderer ; <nl> <nl> class UITextField : public UIWidget <nl> float _touchHeight ; <nl> bool _useTouchArea ; <nl> <nl> - cocos2d : : Object * _textFieldEventListener ; <nl> + Object * _textFieldEventListener ; <nl> SEL_TextFieldEvent _textFieldEventSelector ; <nl> <nl> std : : string _passwordStyleText ; <nl> class UITextField : public UIWidget <nl> <nl> } <nl> <nl> - # endif / * defined ( __CocoGUI__UITextField__ ) * / <nl> + NS_CC_END <nl> + <nl> + # endif / * defined ( __TextField__ ) * / <nl> mmm a / cocos / gui / UIWidget . cpp <nl> ppp b / cocos / gui / UIWidget . cpp <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> # include " gui / UIWidget . h " <nl> - # include " gui / UILayer . h " <nl> # include " gui / UILayout . h " <nl> # include " gui / UIHelper . h " <nl> <nl> - namespace gui { <nl> - <nl> - # define DYNAMIC_CAST_CCBLENDPROTOCOL dynamic_cast < cocos2d : : BlendProtocol * > ( _renderer ) <nl> + NS_CC_BEGIN <nl> <nl> - # define DYNAMIC_CAST_CCNODERGBA dynamic_cast < GUIRenderer * > ( _renderer ) <nl> + namespace gui { <nl> <nl> - UIWidget : : UIWidget ( ) : <nl> + Widget : : Widget ( ) : <nl> _enabled ( true ) , <nl> - _visible ( true ) , <nl> _bright ( true ) , <nl> _touchEnabled ( false ) , <nl> _touchPassedEnabled ( false ) , <nl> _focus ( false ) , <nl> - _widgetZOrder ( 0 ) , <nl> - _anchorPoint ( cocos2d : : Point ( 0 . 5f , 0 . 5f ) ) , <nl> - _widgetParent ( nullptr ) , <nl> _brightStyle ( BRIGHT_NONE ) , <nl> _updateEnabled ( false ) , <nl> - _renderer ( nullptr ) , <nl> - _touchStartPos ( cocos2d : : Point : : ZERO ) , <nl> - _touchMovePos ( cocos2d : : Point : : ZERO ) , <nl> - _touchEndPos ( cocos2d : : Point : : ZERO ) , <nl> + _touchStartPos ( Point : : ZERO ) , <nl> + _touchMovePos ( Point : : ZERO ) , <nl> + _touchEndPos ( Point : : ZERO ) , <nl> _touchEventListener ( nullptr ) , <nl> _touchEventSelector ( nullptr ) , <nl> - _widgetTag ( - 1 ) , <nl> _name ( " default " ) , <nl> _widgetType ( WidgetTypeWidget ) , <nl> _actionTag ( 0 ) , <nl> - _size ( cocos2d : : Size : : ZERO ) , <nl> - _customSize ( cocos2d : : Size : : ZERO ) , <nl> - _layoutParameterDictionary ( nullptr ) , <nl> + _size ( Size : : ZERO ) , <nl> + _customSize ( Size : : ZERO ) , <nl> _ignoreSize ( false ) , <nl> - _children ( nullptr ) , <nl> _affectByClipping ( false ) , <nl> - _scheduler ( nullptr ) , <nl> _sizeType ( SIZE_ABSOLUTE ) , <nl> - _sizePercent ( cocos2d : : Point : : ZERO ) , <nl> + _sizePercent ( Point : : ZERO ) , <nl> _positionType ( POSITION_ABSOLUTE ) , <nl> - _positionPercent ( cocos2d : : Point : : ZERO ) , <nl> - _isRunning ( false ) , <nl> - _userObject ( nullptr ) <nl> + _positionPercent ( Point : : ZERO ) , <nl> + _reorderWidgetChildDirty ( true ) , <nl> + _hitted ( false ) , <nl> + _touchListener ( nullptr ) <nl> { <nl> <nl> } <nl> <nl> - UIWidget : : ~ UIWidget ( ) <nl> + Widget : : ~ Widget ( ) <nl> { <nl> _touchEventListener = nullptr ; <nl> _touchEventSelector = nullptr ; <nl> - removeAllChildren ( ) ; <nl> - _children - > release ( ) ; <nl> - _renderer - > removeAllChildrenWithCleanup ( true ) ; <nl> - _renderer - > removeFromParentAndCleanup ( true ) ; <nl> - _renderer - > release ( ) ; <nl> - setParent ( nullptr ) ; <nl> - _layoutParameterDictionary - > removeAllObjects ( ) ; <nl> - CC_SAFE_RELEASE ( _layoutParameterDictionary ) ; <nl> - CC_SAFE_RELEASE ( _scheduler ) ; <nl> - CC_SAFE_RELEASE ( _userObject ) ; <nl> + _widgetChildren . clear ( ) ; <nl> + CC_SAFE_RELEASE ( _touchListener ) ; <nl> } <nl> <nl> - UIWidget * UIWidget : : create ( ) <nl> + Widget * Widget : : create ( ) <nl> { <nl> - UIWidget * widget = new UIWidget ( ) ; <nl> + Widget * widget = new Widget ( ) ; <nl> if ( widget & & widget - > init ( ) ) <nl> { <nl> widget - > autorelease ( ) ; <nl> UIWidget * UIWidget : : create ( ) <nl> return nullptr ; <nl> } <nl> <nl> - bool UIWidget : : init ( ) <nl> - { <nl> - _children = cocos2d : : Array : : create ( ) ; <nl> - _children - > retain ( ) ; <nl> - _layoutParameterDictionary = cocos2d : : Dictionary : : create ( ) ; <nl> - CC_SAFE_RETAIN ( _layoutParameterDictionary ) ; <nl> - initRenderer ( ) ; <nl> - _renderer - > retain ( ) ; <nl> - _renderer - > setZOrder ( _widgetZOrder ) ; <nl> - _renderer - > setCascadeColorEnabled ( true ) ; <nl> - _renderer - > setCascadeOpacityEnabled ( true ) ; <nl> - setBright ( true ) ; <nl> - ignoreContentAdaptWithSize ( true ) ; <nl> - _scheduler = cocos2d : : Director : : getInstance ( ) - > getScheduler ( ) ; <nl> - CC_SAFE_RETAIN ( _scheduler ) ; <nl> - return true ; <nl> + bool Widget : : init ( ) <nl> + { <nl> + if ( Node : : init ( ) ) <nl> + { <nl> + initRenderer ( ) ; <nl> + setCascadeColorEnabled ( true ) ; <nl> + setCascadeOpacityEnabled ( true ) ; <nl> + setBright ( true ) ; <nl> + ignoreContentAdaptWithSize ( true ) ; <nl> + setAnchorPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + return true ; <nl> + } <nl> + return false ; <nl> } <nl> <nl> - void UIWidget : : onEnter ( ) <nl> + void Widget : : onEnter ( ) <nl> { <nl> - arrayMakeObjectsPerformSelector ( _children , onEnter , UIWidget * ) ; <nl> - _isRunning = true ; <nl> updateSizeAndPosition ( ) ; <nl> + Node : : onEnter ( ) ; <nl> } <nl> <nl> - void UIWidget : : onExit ( ) <nl> + void Widget : : onExit ( ) <nl> { <nl> - _isRunning = false ; <nl> - arrayMakeObjectsPerformSelector ( _children , onExit , UIWidget * ) ; <nl> + Node : : onExit ( ) ; <nl> } <nl> <nl> - void UIWidget : : setUserObject ( cocos2d : : Object * pUserObject ) <nl> + void Widget : : visit ( ) <nl> { <nl> - CC_SAFE_RETAIN ( pUserObject ) ; <nl> - CC_SAFE_RELEASE ( _userObject ) ; <nl> - _userObject = pUserObject ; <nl> + if ( _enabled ) <nl> + { <nl> + Node : : visit ( ) ; <nl> + } <nl> } <nl> <nl> - bool UIWidget : : addChild ( UIWidget * child ) <nl> + void Widget : : addChild ( Node * child ) <nl> { <nl> - if ( ! child ) <nl> - { <nl> - return false ; <nl> - } <nl> - if ( _children - > containsObject ( child ) ) <nl> - { <nl> - return false ; <nl> - } <nl> - child - > setParent ( this ) ; <nl> - ssize_t childrenCount = _children - > data - > num ; <nl> - if ( childrenCount < = 0 ) <nl> - { <nl> - _children - > addObject ( child ) ; <nl> - } <nl> - else <nl> - { <nl> - bool seekSucceed = false ; <nl> - cocos2d : : ccArray * arrayChildren = _children - > data ; <nl> - for ( ssize_t i = childrenCount - 1 ; i > = 0 ; - - i ) <nl> - { <nl> - UIWidget * widget = ( UIWidget * ) ( arrayChildren - > arr [ i ] ) ; <nl> - if ( child - > getZOrder ( ) > = widget - > getZOrder ( ) ) <nl> - { <nl> - if ( i = = childrenCount - 1 ) <nl> - { <nl> - _children - > addObject ( child ) ; <nl> - seekSucceed = true ; <nl> - break ; <nl> - } <nl> - else <nl> - { <nl> - _children - > insertObject ( child , i + 1 ) ; <nl> - seekSucceed = true ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - if ( ! seekSucceed ) <nl> - { <nl> - _children - > insertObject ( child , 0 ) ; <nl> - } <nl> - } <nl> - child - > getRenderer ( ) - > setZOrder ( child - > getZOrder ( ) ) ; <nl> - _renderer - > addChild ( child - > getRenderer ( ) ) ; <nl> - if ( _isRunning ) <nl> - { <nl> - child - > onEnter ( ) ; <nl> - } <nl> - return true ; <nl> + Node : : addChild ( child ) ; <nl> } <nl> <nl> - bool UIWidget : : removeChild ( UIWidget * child ) <nl> + void Widget : : addChild ( Node * child , int zOrder ) <nl> + { <nl> + Node : : addChild ( child , zOrder ) ; <nl> + } <nl> + <nl> + void Widget : : addChild ( Node * child , int zOrder , int tag ) <nl> { <nl> - if ( ! child ) <nl> + CCASSERT ( dynamic_cast < Widget * > ( child ) ! = NULL , " Widget only supports Widgets as children " ) ; <nl> + Node : : addChild ( child , zOrder , tag ) ; <nl> + _widgetChildren . pushBack ( child ) ; <nl> + } <nl> + <nl> + void Widget : : sortAllChildren ( ) <nl> + { <nl> + _reorderWidgetChildDirty = _reorderChildDirty ; <nl> + Node : : sortAllChildren ( ) ; <nl> + if ( _reorderWidgetChildDirty ) <nl> { <nl> - return false ; <nl> + std : : sort ( std : : begin ( _widgetChildren ) , std : : end ( _widgetChildren ) , nodeComparisonLess ) ; <nl> + _reorderWidgetChildDirty = false ; <nl> } <nl> - if ( _children - > containsObject ( child ) ) <nl> + } <nl> + <nl> + Node * Widget : : getChildByTag ( int aTag ) <nl> + { <nl> + CCASSERT ( aTag ! = Node : : INVALID_TAG , " Invalid tag " ) ; <nl> + <nl> + for ( auto & child : _widgetChildren ) <nl> { <nl> - if ( _isRunning ) <nl> - { <nl> - child - > onExit ( ) ; <nl> - } <nl> - child - > setUpdateEnabled ( false ) ; <nl> - child - > setParent ( nullptr ) ; <nl> - _renderer - > removeChild ( child - > getRenderer ( ) ) ; <nl> - _children - > removeObject ( child ) ; <nl> - return true ; <nl> + if ( child & & child - > getTag ( ) = = aTag ) <nl> + return child ; <nl> } <nl> - return false ; <nl> + return nullptr ; <nl> } <nl> <nl> - void UIWidget : : removeFromParent ( ) <nl> + Vector < Node * > & Widget : : getChildren ( ) <nl> { <nl> - if ( _widgetParent ) <nl> - { <nl> - _widgetParent - > removeChild ( this ) ; <nl> - } <nl> + return _widgetChildren ; <nl> + } <nl> + <nl> + const Vector < Node * > & Widget : : getChildren ( ) const <nl> + { <nl> + return _widgetChildren ; <nl> + } <nl> + <nl> + long Widget : : getChildrenCount ( ) const <nl> + { <nl> + return _widgetChildren . size ( ) ; <nl> } <nl> <nl> - void UIWidget : : removeAllChildren ( ) <nl> + Widget * Widget : : getWidgetParent ( ) <nl> { <nl> - if ( ! _children | | _children - > count ( ) < = 0 ) <nl> - { <nl> - return ; <nl> - } <nl> - ssize_t times = _children - > data - > num ; <nl> - for ( int i = 0 ; i < times ; + + i ) <nl> - { <nl> - UIWidget * lastChild = ( UIWidget * ) ( _children - > getLastObject ( ) ) ; <nl> - removeChild ( lastChild ) ; <nl> - } <nl> + return dynamic_cast < Widget * > ( getParent ( ) ) ; <nl> + } <nl> + <nl> + void Widget : : removeFromParent ( ) <nl> + { <nl> + removeFromParentAndCleanup ( true ) ; <nl> } <nl> <nl> - void UIWidget : : reorderChild ( UIWidget * child ) <nl> + void Widget : : removeFromParentAndCleanup ( bool cleanup ) <nl> { <nl> - CC_SAFE_RETAIN ( child ) ; <nl> - _children - > removeObject ( child ) ; <nl> - ssize_t childrenCount = _children - > data - > num ; <nl> - if ( childrenCount < = 0 ) <nl> - { <nl> - _children - > addObject ( child ) ; <nl> - } <nl> - else <nl> - { <nl> - bool seekSucceed = false ; <nl> - cocos2d : : ccArray * arrayChildren = _children - > data ; <nl> - for ( ssize_t i = childrenCount - 1 ; i > = 0 ; - - i ) <nl> - { <nl> - UIWidget * widget = ( UIWidget * ) ( arrayChildren - > arr [ i ] ) ; <nl> - if ( child - > getZOrder ( ) > = widget - > getZOrder ( ) ) <nl> - { <nl> - if ( i = = childrenCount - 1 ) <nl> - { <nl> - _children - > addObject ( child ) ; <nl> - seekSucceed = true ; <nl> - break ; <nl> - } <nl> - else <nl> - { <nl> - _children - > insertObject ( child , i + 1 ) ; <nl> - seekSucceed = true ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - if ( ! seekSucceed ) <nl> - { <nl> - _children - > insertObject ( child , 0 ) ; <nl> - } <nl> - } <nl> - CC_SAFE_RELEASE ( child ) ; <nl> + Node : : removeFromParentAndCleanup ( cleanup ) ; <nl> } <nl> <nl> - void UIWidget : : setEnabled ( bool enabled ) <nl> + void Widget : : removeChild ( Node * child , bool cleanup ) <nl> { <nl> - _enabled = enabled ; <nl> - GUIRenderer * renderer = DYNAMIC_CAST_CCNODERGBA ; <nl> - if ( renderer ) <nl> + Node : : removeChild ( child , cleanup ) ; <nl> + _widgetChildren . eraseObject ( child ) ; <nl> + } <nl> + <nl> + void Widget : : removeChildByTag ( int tag , bool cleanup ) <nl> + { <nl> + CCASSERT ( tag ! = Node : : INVALID_TAG , " Invalid tag " ) ; <nl> + <nl> + Node * child = getChildByTag ( tag ) ; <nl> + <nl> + if ( child = = NULL ) <nl> { <nl> - renderer - > setEnabled ( enabled ) ; <nl> + CCLOG ( " cocos2d : removeChildByTag ( tag = % d ) : child not found ! " , tag ) ; <nl> } <nl> else <nl> { <nl> - dynamic_cast < UIRectClippingNode * > ( _renderer ) - > setEnabled ( enabled ) ; <nl> - } <nl> - cocos2d : : ccArray * arrayChildren = _children - > data ; <nl> - ssize_t childrenCount = arrayChildren - > num ; <nl> - for ( int i = 0 ; i < childrenCount ; i + + ) <nl> - { <nl> - UIWidget * child = dynamic_cast < UIWidget * > ( arrayChildren - > arr [ i ] ) ; <nl> - child - > setEnabled ( enabled ) ; <nl> + removeChild ( child , cleanup ) ; <nl> } <nl> } <nl> <nl> - UIWidget * UIWidget : : getChildByName ( const char * name ) <nl> + void Widget : : removeAllChildren ( ) <nl> { <nl> - return UIHelper : : seekWidgetByName ( this , name ) ; <nl> + removeAllChildrenWithCleanup ( true ) ; <nl> + } <nl> + <nl> + void Widget : : removeAllChildrenWithCleanup ( bool cleanup ) <nl> + { <nl> + for ( auto & child : _widgetChildren ) <nl> + { <nl> + if ( child ) <nl> + { <nl> + Node : : removeChild ( child ) ; <nl> + } <nl> + } <nl> + _widgetChildren . clear ( ) ; <nl> } <nl> <nl> - UIWidget * UIWidget : : getChildByTag ( int tag ) <nl> + void Widget : : setEnabled ( bool enabled ) <nl> { <nl> - return UIHelper : : seekWidgetByTag ( this , tag ) ; <nl> + _enabled = enabled ; <nl> + for ( auto & child : _widgetChildren ) <nl> + { <nl> + if ( child ) <nl> + { <nl> + static_cast < Widget * > ( child ) - > setEnabled ( enabled ) ; <nl> + } <nl> + } <nl> } <nl> <nl> - cocos2d : : Array * UIWidget : : getChildren ( ) <nl> + Widget * Widget : : getChildByName ( const char * name ) <nl> { <nl> - return _children ; <nl> + for ( auto & child : _widgetChildren ) <nl> + { <nl> + if ( child ) <nl> + { <nl> + Widget * widgetChild = static_cast < Widget * > ( child ) ; <nl> + if ( strcmp ( widgetChild - > getName ( ) , name ) = = 0 ) <nl> + { <nl> + return widgetChild ; <nl> + } <nl> + } <nl> + } <nl> + return nullptr ; <nl> } <nl> <nl> - void UIWidget : : initRenderer ( ) <nl> + void Widget : : initRenderer ( ) <nl> { <nl> - _renderer = GUIRenderer : : create ( ) ; <nl> } <nl> <nl> - void UIWidget : : setSize ( const cocos2d : : Size & size ) <nl> + void Widget : : setSize ( const Size & size ) <nl> { <nl> _customSize = size ; <nl> if ( _ignoreSize ) <nl> void UIWidget : : setSize ( const cocos2d : : Size & size ) <nl> { <nl> _size = size ; <nl> } <nl> - if ( _isRunning & & _widgetParent ) <nl> + if ( _running ) <nl> { <nl> - cocos2d : : Size pSize = _widgetParent - > getSize ( ) ; <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + Size pSize ; <nl> + if ( widgetParent ) <nl> + { <nl> + pSize = widgetParent - > getSize ( ) ; <nl> + } <nl> + else <nl> + { <nl> + pSize = _parent - > getContentSize ( ) ; <nl> + } <nl> float spx = 0 . 0f ; <nl> float spy = 0 . 0f ; <nl> if ( pSize . width > 0 . 0f ) <nl> void UIWidget : : setSize ( const cocos2d : : Size & size ) <nl> { <nl> spy = _customSize . height / pSize . height ; <nl> } <nl> - _sizePercent = cocos2d : : Point ( spx , spy ) ; <nl> + _sizePercent = Point ( spx , spy ) ; <nl> } <nl> - <nl> onSizeChanged ( ) ; <nl> } <nl> <nl> - void UIWidget : : setSizePercent ( const cocos2d : : Point & percent ) <nl> + void Widget : : setSizePercent ( const Point & percent ) <nl> { <nl> _sizePercent = percent ; <nl> - cocos2d : : Size cSize = _customSize ; <nl> - if ( _isRunning ) <nl> + Size cSize = _customSize ; <nl> + if ( _running ) <nl> { <nl> - cSize = ( _widgetParent = = nullptr ) ? cocos2d : : Size : : ZERO : cocos2d : : Size ( _widgetParent - > getSize ( ) . width * percent . x , _widgetParent - > getSize ( ) . height * percent . y ) ; <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> + { <nl> + cSize = Size ( widgetParent - > getSize ( ) . width * percent . x , widgetParent - > getSize ( ) . height * percent . y ) ; <nl> + } <nl> + else <nl> + { <nl> + cSize = Size ( _parent - > getContentSize ( ) . width * percent . x , _parent - > getContentSize ( ) . height * percent . y ) ; <nl> + } <nl> } <nl> if ( _ignoreSize ) <nl> { <nl> void UIWidget : : setSizePercent ( const cocos2d : : Point & percent ) <nl> onSizeChanged ( ) ; <nl> } <nl> <nl> - void UIWidget : : updateSizeAndPosition ( ) <nl> + void Widget : : updateSizeAndPosition ( ) <nl> { <nl> switch ( _sizeType ) <nl> { <nl> void UIWidget : : updateSizeAndPosition ( ) <nl> { <nl> _size = _customSize ; <nl> } <nl> - if ( _widgetParent ) <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - cocos2d : : Size pSize = _widgetParent - > getSize ( ) ; <nl> + Size pSize = widgetParent - > getSize ( ) ; <nl> float spx = 0 . 0f ; <nl> float spy = 0 . 0f ; <nl> if ( pSize . width > 0 . 0f ) <nl> void UIWidget : : updateSizeAndPosition ( ) <nl> { <nl> spy = _customSize . height / pSize . height ; <nl> } <nl> - _sizePercent = cocos2d : : Point ( spx , spy ) ; <nl> + _sizePercent = Point ( spx , spy ) ; <nl> + } <nl> + else <nl> + { <nl> + Size pSize = _parent - > getContentSize ( ) ; <nl> + float spx = 0 . 0f ; <nl> + float spy = 0 . 0f ; <nl> + if ( pSize . width > 0 . 0f ) <nl> + { <nl> + spx = _customSize . width / pSize . width ; <nl> + } <nl> + if ( pSize . height > 0 . 0f ) <nl> + { <nl> + spy = _customSize . height / pSize . height ; <nl> + } <nl> + _sizePercent = Point ( spx , spy ) ; <nl> } <nl> break ; <nl> } <nl> case SIZE_PERCENT : <nl> { <nl> - cocos2d : : Size cSize = ( _widgetParent = = NULL ) ? cocos2d : : Size : : ZERO : cocos2d : : Size ( _widgetParent - > getSize ( ) . width * _sizePercent . x , _widgetParent - > getSize ( ) . height * _sizePercent . y ) ; <nl> - if ( _ignoreSize ) <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - _size = getContentSize ( ) ; <nl> + Size cSize = Size ( widgetParent - > getSize ( ) . width * _sizePercent . x , widgetParent - > getSize ( ) . height * _sizePercent . y ) ; <nl> + if ( _ignoreSize ) <nl> + { <nl> + _size = getContentSize ( ) ; <nl> + } <nl> + else <nl> + { <nl> + _size = cSize ; <nl> + } <nl> + _customSize = cSize ; <nl> } <nl> else <nl> { <nl> - _size = cSize ; <nl> + Size cSize = Size ( _parent - > getContentSize ( ) . width * _sizePercent . x , _parent - > getContentSize ( ) . height * _sizePercent . y ) ; <nl> + if ( _ignoreSize ) <nl> + { <nl> + _size = getContentSize ( ) ; <nl> + } <nl> + else <nl> + { <nl> + _size = cSize ; <nl> + } <nl> + _customSize = cSize ; <nl> } <nl> - _customSize = cSize ; <nl> } <nl> break ; <nl> default : <nl> break ; <nl> } <nl> onSizeChanged ( ) ; <nl> - cocos2d : : Point absPos = getPosition ( ) ; <nl> + Point absPos = getPosition ( ) ; <nl> switch ( _positionType ) <nl> { <nl> case POSITION_ABSOLUTE : <nl> { <nl> - if ( _widgetParent ) <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - cocos2d : : Size pSize = _widgetParent - > getSize ( ) ; <nl> + Size pSize = widgetParent - > getSize ( ) ; <nl> if ( pSize . width < = 0 . 0f | | pSize . height < = 0 . 0f ) <nl> { <nl> - _positionPercent = cocos2d : : Point : : ZERO ; <nl> + _positionPercent = Point : : ZERO ; <nl> } <nl> else <nl> { <nl> - _positionPercent = cocos2d : : Point ( absPos . x / pSize . width , absPos . y / pSize . height ) ; <nl> + _positionPercent = Point ( absPos . x / pSize . width , absPos . y / pSize . height ) ; <nl> } <nl> } <nl> else <nl> { <nl> - _positionPercent = cocos2d : : Point : : ZERO ; <nl> + Size pSize = _parent - > getContentSize ( ) ; <nl> + if ( pSize . width < = 0 . 0f | | pSize . height < = 0 . 0f ) <nl> + { <nl> + _positionPercent = Point : : ZERO ; <nl> + } <nl> + else <nl> + { <nl> + _positionPercent = Point ( absPos . x / pSize . width , absPos . y / pSize . height ) ; <nl> + } <nl> } <nl> break ; <nl> } <nl> case POSITION_PERCENT : <nl> { <nl> - if ( _widgetParent ) <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - cocos2d : : Size parentSize = _widgetParent - > getSize ( ) ; <nl> - absPos = cocos2d : : Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> + Size parentSize = widgetParent - > getSize ( ) ; <nl> + absPos = Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> } <nl> else <nl> { <nl> - absPos = cocos2d : : Point : : ZERO ; <nl> + Size parentSize = _parent - > getContentSize ( ) ; <nl> + absPos = Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> } <nl> break ; <nl> } <nl> default : <nl> break ; <nl> } <nl> - _renderer - > setPosition ( absPos ) ; <nl> + setPosition ( absPos ) ; <nl> } <nl> <nl> - void UIWidget : : setSizeType ( SizeType type ) <nl> + void Widget : : setSizeType ( SizeType type ) <nl> { <nl> _sizeType = type ; <nl> } <nl> <nl> - SizeType UIWidget : : getSizeType ( ) const <nl> + SizeType Widget : : getSizeType ( ) const <nl> { <nl> return _sizeType ; <nl> } <nl> <nl> - void UIWidget : : ignoreContentAdaptWithSize ( bool ignore ) <nl> + void Widget : : ignoreContentAdaptWithSize ( bool ignore ) <nl> { <nl> _ignoreSize = ignore ; <nl> if ( _ignoreSize ) <nl> { <nl> - cocos2d : : Size s = getContentSize ( ) ; <nl> + Size s = getContentSize ( ) ; <nl> _size = s ; <nl> } <nl> else <nl> void UIWidget : : ignoreContentAdaptWithSize ( bool ignore ) <nl> onSizeChanged ( ) ; <nl> } <nl> <nl> - bool UIWidget : : isIgnoreContentAdaptWithSize ( ) const <nl> + bool Widget : : isIgnoreContentAdaptWithSize ( ) const <nl> { <nl> return _ignoreSize ; <nl> } <nl> <nl> - const cocos2d : : Size & UIWidget : : getSize ( ) const <nl> + const Size & Widget : : getSize ( ) const <nl> { <nl> return _size ; <nl> } <nl> <nl> - const cocos2d : : Point & UIWidget : : getSizePercent ( ) const <nl> + const Point & Widget : : getSizePercent ( ) const <nl> { <nl> return _sizePercent ; <nl> } <nl> <nl> - cocos2d : : Point UIWidget : : getWorldPosition ( ) <nl> - { <nl> - return _renderer - > convertToWorldSpace ( cocos2d : : Point : : ZERO ) ; <nl> - } <nl> - <nl> - cocos2d : : Point UIWidget : : convertToWorldSpace ( const cocos2d : : Point & pt ) <nl> + Point Widget : : getWorldPosition ( ) <nl> { <nl> - return _renderer - > convertToWorldSpace ( pt ) ; <nl> + return convertToWorldSpace ( Point : : ZERO ) ; <nl> } <nl> <nl> - cocos2d : : Node * UIWidget : : getVirtualRenderer ( ) <nl> + Node * Widget : : getVirtualRenderer ( ) <nl> { <nl> - return _renderer ; <nl> + return this ; <nl> } <nl> <nl> - void UIWidget : : onSizeChanged ( ) <nl> + void Widget : : onSizeChanged ( ) <nl> { <nl> - <nl> + for ( auto & child : getChildren ( ) ) <nl> + { <nl> + if ( child ) <nl> + { <nl> + static_cast < Widget * > ( child ) - > updateSizeAndPosition ( ) ; <nl> + } <nl> + } <nl> } <nl> <nl> - const cocos2d : : Size & UIWidget : : getContentSize ( ) const <nl> + const Size & Widget : : getContentSize ( ) const <nl> { <nl> return _size ; <nl> } <nl> <nl> - void UIWidget : : setZOrder ( int z ) <nl> + void Widget : : setTouchEnabled ( bool enable ) <nl> { <nl> - _widgetZOrder = z ; <nl> - _renderer - > setZOrder ( z ) ; <nl> - if ( _widgetParent ) <nl> + if ( enable = = _touchEnabled ) <nl> { <nl> - _widgetParent - > reorderChild ( this ) ; <nl> + return ; <nl> } <nl> - } <nl> - <nl> - int UIWidget : : getZOrder ( ) <nl> - { <nl> - return _widgetZOrder ; <nl> - } <nl> - <nl> - void UIWidget : : setTouchEnabled ( bool enable ) <nl> - { <nl> _touchEnabled = enable ; <nl> + if ( _touchEnabled ) <nl> + { <nl> + _touchListener = EventListenerTouchOneByOne : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _touchListener ) ; <nl> + _touchListener - > setSwallowTouches ( true ) ; <nl> + _touchListener - > onTouchBegan = CC_CALLBACK_2 ( Widget : : onTouchBegan , this ) ; <nl> + _touchListener - > onTouchMoved = CC_CALLBACK_2 ( Widget : : onTouchMoved , this ) ; <nl> + _touchListener - > onTouchEnded = CC_CALLBACK_2 ( Widget : : onTouchEnded , this ) ; <nl> + _touchListener - > onTouchCancelled = CC_CALLBACK_2 ( Widget : : onTouchCancelled , this ) ; <nl> + _eventDispatcher - > addEventListenerWithSceneGraphPriority ( _touchListener , this ) ; <nl> + } <nl> + else <nl> + { <nl> + _eventDispatcher - > removeEventListener ( _touchListener ) ; <nl> + CC_SAFE_RELEASE_NULL ( _touchListener ) ; <nl> + } <nl> } <nl> <nl> - bool UIWidget : : isTouchEnabled ( ) const <nl> + bool Widget : : isTouchEnabled ( ) const <nl> { <nl> return _touchEnabled ; <nl> } <nl> <nl> - void UIWidget : : setUpdateEnabled ( bool enable ) <nl> + void Widget : : setUpdateEnabled ( bool enable ) <nl> { <nl> if ( enable = = _updateEnabled ) <nl> { <nl> void UIWidget : : setUpdateEnabled ( bool enable ) <nl> _updateEnabled = enable ; <nl> if ( enable ) <nl> { <nl> - if ( _scheduler ) <nl> - { <nl> - _scheduler - > scheduleUpdateForTarget ( this , 0 , false ) ; <nl> - } <nl> + scheduleUpdate ( ) ; <nl> } <nl> else <nl> { <nl> - if ( _scheduler ) <nl> - { <nl> - _scheduler - > unscheduleUpdateForTarget ( this ) ; <nl> - } <nl> + unscheduleUpdate ( ) ; <nl> } <nl> } <nl> <nl> - bool UIWidget : : isUpdateEnabled ( ) <nl> + bool Widget : : isUpdateEnabled ( ) <nl> { <nl> return _updateEnabled ; <nl> } <nl> <nl> - bool UIWidget : : isFocused ( ) const <nl> + bool Widget : : isFocused ( ) const <nl> { <nl> return _focus ; <nl> } <nl> <nl> - void UIWidget : : setFocused ( bool fucos ) <nl> + void Widget : : setFocused ( bool fucos ) <nl> { <nl> if ( fucos = = _focus ) <nl> { <nl> void UIWidget : : setFocused ( bool fucos ) <nl> } <nl> } <nl> <nl> - void UIWidget : : setBright ( bool bright ) <nl> + void Widget : : setBright ( bool bright ) <nl> { <nl> _bright = bright ; <nl> if ( _bright ) <nl> void UIWidget : : setBright ( bool bright ) <nl> } <nl> } <nl> <nl> - void UIWidget : : setBrightStyle ( BrightStyle style ) <nl> + void Widget : : setBrightStyle ( BrightStyle style ) <nl> { <nl> if ( _brightStyle = = style ) <nl> { <nl> void UIWidget : : setBrightStyle ( BrightStyle style ) <nl> } <nl> } <nl> <nl> - void UIWidget : : onPressStateChangedToNormal ( ) <nl> + void Widget : : onPressStateChangedToNormal ( ) <nl> { <nl> <nl> } <nl> <nl> - void UIWidget : : onPressStateChangedToPressed ( ) <nl> + void Widget : : onPressStateChangedToPressed ( ) <nl> { <nl> <nl> } <nl> <nl> - void UIWidget : : onPressStateChangedToDisabled ( ) <nl> + void Widget : : onPressStateChangedToDisabled ( ) <nl> { <nl> <nl> } <nl> <nl> - void UIWidget : : didNotSelectSelf ( ) <nl> + void Widget : : didNotSelectSelf ( ) <nl> { <nl> <nl> } <nl> <nl> - bool UIWidget : : onTouchBegan ( const cocos2d : : Point & touchPoint ) <nl> + bool Widget : : onTouchBegan ( Touch * touch , Event * unusedEvent ) <nl> { <nl> + _touchStartPos = touch - > getLocation ( ) ; <nl> + _hitted = isEnabled ( ) <nl> + & isTouchEnabled ( ) <nl> + & hitTest ( _touchStartPos ) <nl> + & clippingParentAreaContainPoint ( _touchStartPos ) ; <nl> + if ( ! _hitted ) <nl> + { <nl> + return false ; <nl> + } <nl> setFocused ( true ) ; <nl> - _touchStartPos . x = touchPoint . x ; <nl> - _touchStartPos . y = touchPoint . y ; <nl> - if ( _widgetParent ) <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - _widgetParent - > checkChildInfo ( 0 , this , touchPoint ) ; <nl> + widgetParent - > checkChildInfo ( 0 , this , _touchStartPos ) ; <nl> } <nl> pushDownEvent ( ) ; <nl> - return _touchPassedEnabled ; <nl> + return ! _touchPassedEnabled ; <nl> } <nl> <nl> - void UIWidget : : onTouchMoved ( const cocos2d : : Point & touchPoint ) <nl> + void Widget : : onTouchMoved ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - _touchMovePos . x = touchPoint . x ; <nl> - _touchMovePos . y = touchPoint . y ; <nl> - setFocused ( hitTest ( touchPoint ) ) ; <nl> - if ( _widgetParent ) <nl> + _touchMovePos = touch - > getLocation ( ) ; <nl> + setFocused ( hitTest ( _touchMovePos ) ) ; <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - _widgetParent - > checkChildInfo ( 1 , this , touchPoint ) ; <nl> + widgetParent - > checkChildInfo ( 1 , this , _touchMovePos ) ; <nl> } <nl> moveEvent ( ) ; <nl> } <nl> <nl> - void UIWidget : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> + void Widget : : onTouchEnded ( Touch * touch , Event * unusedEvent ) <nl> { <nl> - _touchEndPos . x = touchPoint . x ; <nl> - _touchEndPos . y = touchPoint . y ; <nl> + _touchEndPos = touch - > getLocation ( ) ; <nl> bool focus = _focus ; <nl> setFocused ( false ) ; <nl> - if ( _widgetParent ) <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - _widgetParent - > checkChildInfo ( 2 , this , touchPoint ) ; <nl> + widgetParent - > checkChildInfo ( 2 , this , _touchEndPos ) ; <nl> } <nl> if ( focus ) <nl> { <nl> void UIWidget : : onTouchEnded ( const cocos2d : : Point & touchPoint ) <nl> } <nl> } <nl> <nl> - void UIWidget : : onTouchCancelled ( const cocos2d : : Point & touchPoint ) <nl> + void Widget : : onTouchCancelled ( Touch * touch , Event * unusedEvent ) <nl> { <nl> setFocused ( false ) ; <nl> cancelUpEvent ( ) ; <nl> } <nl> <nl> - void UIWidget : : onTouchLongClicked ( const cocos2d : : Point & touchPoint ) <nl> + void Widget : : onTouchLongClicked ( const Point & touchPoint ) <nl> { <nl> longClickEvent ( ) ; <nl> } <nl> <nl> - void UIWidget : : pushDownEvent ( ) <nl> + void Widget : : pushDownEvent ( ) <nl> { <nl> if ( _touchEventListener & & _touchEventSelector ) <nl> { <nl> void UIWidget : : pushDownEvent ( ) <nl> } <nl> } <nl> <nl> - void UIWidget : : moveEvent ( ) <nl> + void Widget : : moveEvent ( ) <nl> { <nl> if ( _touchEventListener & & _touchEventSelector ) <nl> { <nl> void UIWidget : : moveEvent ( ) <nl> } <nl> } <nl> <nl> - void UIWidget : : releaseUpEvent ( ) <nl> + void Widget : : releaseUpEvent ( ) <nl> { <nl> if ( _touchEventListener & & _touchEventSelector ) <nl> { <nl> void UIWidget : : releaseUpEvent ( ) <nl> } <nl> } <nl> <nl> - void UIWidget : : cancelUpEvent ( ) <nl> + void Widget : : cancelUpEvent ( ) <nl> { <nl> if ( _touchEventListener & & _touchEventSelector ) <nl> { <nl> void UIWidget : : cancelUpEvent ( ) <nl> } <nl> } <nl> <nl> - void UIWidget : : longClickEvent ( ) <nl> + void Widget : : longClickEvent ( ) <nl> { <nl> <nl> } <nl> <nl> - void UIWidget : : addTouchEventListener ( cocos2d : : Object * target , SEL_TouchEvent selector ) <nl> + void Widget : : addTouchEventListener ( Object * target , SEL_TouchEvent selector ) <nl> { <nl> _touchEventListener = target ; <nl> _touchEventSelector = selector ; <nl> } <nl> <nl> - cocos2d : : Node * UIWidget : : getRenderer ( ) <nl> - { <nl> - return _renderer ; <nl> - } <nl> - <nl> - void UIWidget : : addRenderer ( cocos2d : : Node * renderer , int zOrder ) <nl> - { <nl> - _renderer - > addChild ( renderer , zOrder ) ; <nl> - } <nl> - <nl> - void UIWidget : : removeRenderer ( cocos2d : : Node * renderer , bool cleanup ) <nl> + bool Widget : : hitTest ( const Point & pt ) <nl> { <nl> - _renderer - > removeChild ( renderer , cleanup ) ; <nl> - } <nl> - <nl> - bool UIWidget : : hitTest ( const cocos2d : : Point & pt ) <nl> - { <nl> - cocos2d : : Point nsp = _renderer - > convertToNodeSpace ( pt ) ; <nl> - cocos2d : : Rect bb = cocos2d : : Rect ( - _size . width * _anchorPoint . x , - _size . height * _anchorPoint . y , _size . width , _size . height ) ; <nl> + Point nsp = convertToNodeSpace ( pt ) ; <nl> + Rect bb = Rect ( - _size . width * _anchorPoint . x , - _size . height * _anchorPoint . y , _size . width , _size . height ) ; <nl> if ( nsp . x > = bb . origin . x & & nsp . x < = bb . origin . x + bb . size . width & & nsp . y > = bb . origin . y & & nsp . y < = bb . origin . y + bb . size . height ) <nl> { <nl> return true ; <nl> bool UIWidget : : hitTest ( const cocos2d : : Point & pt ) <nl> return false ; <nl> } <nl> <nl> - bool UIWidget : : clippingParentAreaContainPoint ( const cocos2d : : Point & pt ) <nl> + bool Widget : : clippingParentAreaContainPoint ( const Point & pt ) <nl> { <nl> _affectByClipping = false ; <nl> - UIWidget * parent = getParent ( ) ; <nl> - UIWidget * clippingParent = nullptr ; <nl> + Widget * parent = getWidgetParent ( ) ; <nl> + Widget * clippingParent = nullptr ; <nl> while ( parent ) <nl> { <nl> - UILayout * layoutParent = dynamic_cast < UILayout * > ( parent ) ; <nl> + Layout * layoutParent = dynamic_cast < Layout * > ( parent ) ; <nl> if ( layoutParent ) <nl> { <nl> if ( layoutParent - > isClippingEnabled ( ) ) <nl> bool UIWidget : : clippingParentAreaContainPoint ( const cocos2d : : Point & pt ) <nl> break ; <nl> } <nl> } <nl> - parent = parent - > getParent ( ) ; <nl> + parent = parent - > getWidgetParent ( ) ; <nl> } <nl> <nl> if ( ! _affectByClipping ) <nl> bool UIWidget : : clippingParentAreaContainPoint ( const cocos2d : : Point & pt ) <nl> return true ; <nl> } <nl> <nl> - void UIWidget : : checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) <nl> + void Widget : : checkChildInfo ( int handleState , Widget * sender , const Point & touchPoint ) <nl> { <nl> - if ( _widgetParent ) <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - _widgetParent - > checkChildInfo ( handleState , sender , touchPoint ) ; <nl> + widgetParent - > checkChildInfo ( handleState , sender , touchPoint ) ; <nl> } <nl> } <nl> <nl> - void UIWidget : : setPosition ( const cocos2d : : Point & pos ) <nl> + void Widget : : setPosition ( const Point & pos ) <nl> { <nl> - if ( _isRunning & & _widgetParent ) <nl> + if ( _running ) <nl> { <nl> - cocos2d : : Size pSize = _widgetParent - > getSize ( ) ; <nl> - if ( pSize . width < = 0 . 0f | | pSize . height < = 0 . 0f ) <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> { <nl> - _positionPercent = cocos2d : : Point : : ZERO ; <nl> - } <nl> - else <nl> - { <nl> - _positionPercent = ( _widgetParent = = NULL ) ? cocos2d : : Point : : ZERO : cocos2d : : Point ( pos . x / pSize . width , pos . y / pSize . height ) ; <nl> + Size pSize = widgetParent - > getSize ( ) ; <nl> + if ( pSize . width < = 0 . 0f | | pSize . height < = 0 . 0f ) <nl> + { <nl> + _positionPercent = Point : : ZERO ; <nl> + } <nl> + else <nl> + { <nl> + _positionPercent = Point ( pos . x / pSize . width , pos . y / pSize . height ) ; <nl> + } <nl> } <nl> } <nl> - _renderer - > setPosition ( pos ) ; <nl> + Node : : setPosition ( pos ) ; <nl> } <nl> <nl> - void UIWidget : : setPositionPercent ( const cocos2d : : Point & percent ) <nl> + void Widget : : setPositionPercent ( const Point & percent ) <nl> { <nl> _positionPercent = percent ; <nl> - if ( _isRunning & & _widgetParent ) <nl> + if ( _running ) <nl> { <nl> - cocos2d : : Size parentSize = _widgetParent - > getSize ( ) ; <nl> - cocos2d : : Point absPos = cocos2d : : Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> - _renderer - > setPosition ( absPos ) ; <nl> + Widget * widgetParent = getWidgetParent ( ) ; <nl> + if ( widgetParent ) <nl> + { <nl> + Size parentSize = widgetParent - > getSize ( ) ; <nl> + Point absPos = Point ( parentSize . width * _positionPercent . x , parentSize . height * _positionPercent . y ) ; <nl> + setPosition ( absPos ) ; <nl> + } <nl> } <nl> } <nl> <nl> - void UIWidget : : setAnchorPoint ( const cocos2d : : Point & pt ) <nl> + void Widget : : updateAnchorPoint ( ) <nl> { <nl> - _anchorPoint = pt ; <nl> - _renderer - > setAnchorPoint ( pt ) ; <nl> + setAnchorPoint ( getAnchorPoint ( ) ) ; <nl> } <nl> <nl> - void UIWidget : : updateAnchorPoint ( ) <nl> - { <nl> - setAnchorPoint ( _anchorPoint ) ; <nl> - } <nl> - <nl> - const cocos2d : : Point & UIWidget : : getPosition ( ) <nl> - { <nl> - return _renderer - > getPosition ( ) ; <nl> - } <nl> - <nl> - const cocos2d : : Point & UIWidget : : getPositionPercent ( ) <nl> + const Point & Widget : : getPositionPercent ( ) <nl> { <nl> return _positionPercent ; <nl> } <nl> <nl> - void UIWidget : : setPositionType ( PositionType type ) <nl> + void Widget : : setPositionType ( PositionType type ) <nl> { <nl> _positionType = type ; <nl> } <nl> <nl> - PositionType UIWidget : : getPositionType ( ) const <nl> + PositionType Widget : : getPositionType ( ) const <nl> { <nl> return _positionType ; <nl> } <nl> <nl> - const cocos2d : : Point & UIWidget : : getAnchorPoint ( ) <nl> - { <nl> - return _anchorPoint ; <nl> - } <nl> - <nl> - void UIWidget : : setScale ( float scale ) <nl> - { <nl> - _renderer - > setScale ( scale ) ; <nl> - } <nl> - <nl> - float UIWidget : : getScale ( ) <nl> - { <nl> - return _renderer - > getScale ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setScaleX ( float scaleX ) <nl> - { <nl> - _renderer - > setScaleX ( scaleX ) ; <nl> - } <nl> - <nl> - float UIWidget : : getScaleX ( ) <nl> - { <nl> - return _renderer - > getScaleX ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setScaleY ( float scaleY ) <nl> - { <nl> - _renderer - > setScaleY ( scaleY ) ; <nl> - } <nl> - <nl> - float UIWidget : : getScaleY ( ) <nl> - { <nl> - return _renderer - > getScaleY ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setRotation ( float rotation ) <nl> - { <nl> - _renderer - > setRotation ( rotation ) ; <nl> - } <nl> - <nl> - float UIWidget : : getRotation ( ) <nl> - { <nl> - return _renderer - > getRotation ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setRotationX ( float rotationX ) <nl> - { <nl> - _renderer - > setRotationX ( rotationX ) ; <nl> - } <nl> - <nl> - float UIWidget : : getRotationX ( ) <nl> - { <nl> - return _renderer - > getRotationX ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setRotationY ( float rotationY ) <nl> - { <nl> - _renderer - > setRotationY ( rotationY ) ; <nl> - } <nl> - <nl> - float UIWidget : : getRotationY ( ) <nl> - { <nl> - return _renderer - > getRotationY ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setVisible ( bool visible ) <nl> - { <nl> - _visible = visible ; <nl> - _renderer - > setVisible ( visible ) ; <nl> - } <nl> - <nl> - bool UIWidget : : isVisible ( ) const <nl> - { <nl> - return _visible ; <nl> - } <nl> - <nl> - bool UIWidget : : isBright ( ) const <nl> + bool Widget : : isBright ( ) const <nl> { <nl> return _bright ; <nl> } <nl> <nl> - bool UIWidget : : isEnabled ( ) const <nl> + bool Widget : : isEnabled ( ) const <nl> { <nl> return _enabled ; <nl> } <nl> <nl> - float UIWidget : : getLeftInParent ( ) <nl> + float Widget : : getLeftInParent ( ) <nl> { <nl> return getPosition ( ) . x - getAnchorPoint ( ) . x * _size . width ; ; <nl> } <nl> <nl> - float UIWidget : : getBottomInParent ( ) <nl> + float Widget : : getBottomInParent ( ) <nl> { <nl> return getPosition ( ) . y - getAnchorPoint ( ) . y * _size . height ; ; <nl> } <nl> <nl> - float UIWidget : : getRightInParent ( ) <nl> + float Widget : : getRightInParent ( ) <nl> { <nl> return getLeftInParent ( ) + _size . width ; <nl> } <nl> <nl> - float UIWidget : : getTopInParent ( ) <nl> + float Widget : : getTopInParent ( ) <nl> { <nl> return getBottomInParent ( ) + _size . height ; <nl> } <nl> <nl> - UIWidget * UIWidget : : getParent ( ) <nl> - { <nl> - return _widgetParent ; <nl> - } <nl> - <nl> - void UIWidget : : setParent ( UIWidget * parent ) <nl> - { <nl> - _widgetParent = parent ; <nl> - } <nl> - <nl> - cocos2d : : Action * UIWidget : : runAction ( cocos2d : : Action * action ) <nl> - { <nl> - return _renderer - > runAction ( action ) ; <nl> - } <nl> - <nl> - void UIWidget : : setActionManager ( cocos2d : : ActionManager * actionManager ) <nl> - { <nl> - _renderer - > setActionManager ( actionManager ) ; <nl> - } <nl> - <nl> - cocos2d : : ActionManager * UIWidget : : getActionManager ( ) <nl> - { <nl> - return _renderer - > getActionManager ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : stopAllActions ( ) <nl> - { <nl> - _renderer - > stopAllActions ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : stopAction ( cocos2d : : Action * action ) <nl> - { <nl> - _renderer - > stopAction ( action ) ; <nl> - } <nl> - <nl> - void UIWidget : : stopActionByTag ( int tag ) <nl> - { <nl> - _renderer - > stopActionByTag ( tag ) ; <nl> - } <nl> - <nl> - cocos2d : : Action * UIWidget : : getActionByTag ( int tag ) <nl> - { <nl> - return _renderer - > getActionByTag ( tag ) ; <nl> - } <nl> - <nl> - void UIWidget : : setColor ( const cocos2d : : Color3B & color ) <nl> - { <nl> - _renderer - > setColor ( color ) ; <nl> - } <nl> - <nl> - const cocos2d : : Color3B & UIWidget : : getColor ( ) <nl> - { <nl> - return _renderer - > getColor ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setOpacity ( int opacity ) <nl> - { <nl> - _renderer - > setOpacity ( opacity ) ; <nl> - } <nl> - <nl> - int UIWidget : : getOpacity ( ) <nl> - { <nl> - return _renderer - > getOpacity ( ) ; <nl> - } <nl> - <nl> - bool UIWidget : : isCascadeOpacityEnabled ( ) <nl> - { <nl> - return _renderer - > isCascadeOpacityEnabled ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setCascadeOpacityEnabled ( bool cascadeOpacityEnabled ) <nl> - { <nl> - _renderer - > setCascadeOpacityEnabled ( cascadeOpacityEnabled ) ; <nl> - } <nl> - <nl> - bool UIWidget : : isCascadeColorEnabled ( ) <nl> - { <nl> - return _renderer - > isCascadeColorEnabled ( ) ; <nl> - } <nl> - <nl> - void UIWidget : : setCascadeColorEnabled ( bool cascadeColorEnabled ) <nl> - { <nl> - _renderer - > setCascadeColorEnabled ( cascadeColorEnabled ) ; <nl> - } <nl> - <nl> - void UIWidget : : setBlendFunc ( cocos2d : : BlendFunc blendFunc ) <nl> - { <nl> - cocos2d : : BlendProtocol * blendNode = DYNAMIC_CAST_CCBLENDPROTOCOL ; <nl> - if ( blendNode ) <nl> - { <nl> - blendNode - > setBlendFunc ( blendFunc ) ; <nl> - } <nl> - } <nl> - <nl> - const cocos2d : : Point & UIWidget : : getTouchStartPos ( ) <nl> + const Point & Widget : : getTouchStartPos ( ) <nl> { <nl> return _touchStartPos ; <nl> } <nl> <nl> - const cocos2d : : Point & UIWidget : : getTouchMovePos ( ) <nl> + const Point & Widget : : getTouchMovePos ( ) <nl> { <nl> return _touchMovePos ; <nl> } <nl> <nl> - const cocos2d : : Point & UIWidget : : getTouchEndPos ( ) <nl> + const Point & Widget : : getTouchEndPos ( ) <nl> { <nl> return _touchEndPos ; <nl> } <nl> <nl> - void UIWidget : : setTag ( int tag ) <nl> - { <nl> - _widgetTag = tag ; <nl> - } <nl> - <nl> - int UIWidget : : getTag ( ) const <nl> - { <nl> - return _widgetTag ; <nl> - } <nl> - <nl> - void UIWidget : : setName ( const char * name ) <nl> + void Widget : : setName ( const char * name ) <nl> { <nl> _name = name ; <nl> } <nl> <nl> - const char * UIWidget : : getName ( ) const <nl> + const char * Widget : : getName ( ) const <nl> { <nl> return _name . c_str ( ) ; <nl> } <nl> <nl> - WidgetType UIWidget : : getWidgetType ( ) const <nl> + WidgetType Widget : : getWidgetType ( ) const <nl> { <nl> return _widgetType ; <nl> } <nl> <nl> - void UIWidget : : setLayoutParameter ( UILayoutParameter * parameter ) <nl> + void Widget : : setLayoutParameter ( LayoutParameter * parameter ) <nl> { <nl> if ( ! parameter ) <nl> { <nl> return ; <nl> } <nl> - _layoutParameterDictionary - > setObject ( parameter , parameter - > getLayoutType ( ) ) ; <nl> + _layoutParameterDictionary . insert ( parameter - > getLayoutType ( ) , parameter ) ; <nl> } <nl> <nl> - UILayoutParameter * UIWidget : : getLayoutParameter ( LayoutParameterType type ) <nl> + LayoutParameter * Widget : : getLayoutParameter ( LayoutParameterType type ) <nl> { <nl> - return dynamic_cast < UILayoutParameter * > ( _layoutParameterDictionary - > objectForKey ( type ) ) ; <nl> + return dynamic_cast < LayoutParameter * > ( _layoutParameterDictionary . at ( type ) ) ; <nl> } <nl> <nl> - const char * UIWidget : : getDescription ( ) const <nl> + std : : string Widget : : getDescription ( ) const <nl> { <nl> return " Widget " ; <nl> } <nl> <nl> - UIWidget * UIWidget : : clone ( ) <nl> + Widget * Widget : : clone ( ) <nl> { <nl> - UIWidget * clonedWidget = createCloneInstance ( ) ; <nl> + Widget * clonedWidget = createCloneInstance ( ) ; <nl> clonedWidget - > copyProperties ( this ) ; <nl> clonedWidget - > copyClonedWidgetChildren ( this ) ; <nl> return clonedWidget ; <nl> } <nl> <nl> - UIWidget * UIWidget : : createCloneInstance ( ) <nl> + Widget * Widget : : createCloneInstance ( ) <nl> { <nl> - return UIWidget : : create ( ) ; <nl> + return Widget : : create ( ) ; <nl> } <nl> <nl> - void UIWidget : : copyClonedWidgetChildren ( UIWidget * model ) <nl> + void Widget : : copyClonedWidgetChildren ( Widget * model ) <nl> { <nl> - cocos2d : : ccArray * arrayWidgetChildren = model - > getChildren ( ) - > data ; <nl> - ssize_t length = arrayWidgetChildren - > num ; <nl> + int length = model - > getChildren ( ) . size ( ) ; <nl> for ( int i = 0 ; i < length ; i + + ) <nl> { <nl> - UIWidget * child = ( UIWidget * ) ( arrayWidgetChildren - > arr [ i ] ) ; <nl> + Widget * child = static_cast < Widget * > ( model - > getChildren ( ) . at ( i ) ) ; <nl> addChild ( child - > clone ( ) ) ; <nl> } <nl> } <nl> <nl> - void UIWidget : : copySpecialProperties ( UIWidget * model ) <nl> + void Widget : : copySpecialProperties ( Widget * model ) <nl> { <nl> <nl> } <nl> <nl> - void UIWidget : : copyProperties ( UIWidget * widget ) <nl> + void Widget : : copyProperties ( Widget * widget ) <nl> { <nl> setEnabled ( widget - > isEnabled ( ) ) ; <nl> setVisible ( widget - > isVisible ( ) ) ; <nl> void UIWidget : : copyProperties ( UIWidget * widget ) <nl> } <nl> <nl> / * temp action * / <nl> - void UIWidget : : setActionTag ( int tag ) <nl> + void Widget : : setActionTag ( int tag ) <nl> { <nl> _actionTag = tag ; <nl> } <nl> <nl> - int UIWidget : : getActionTag ( ) <nl> + int Widget : : getActionTag ( ) <nl> { <nl> return _actionTag ; <nl> } <nl> - <nl> - GUIRenderer : : GUIRenderer ( ) : <nl> - _enabled ( true ) <nl> - { <nl> - <nl> - } <nl> - <nl> - GUIRenderer : : ~ GUIRenderer ( ) <nl> - { <nl> <nl> } <nl> <nl> - GUIRenderer * GUIRenderer : : create ( ) <nl> - { <nl> - GUIRenderer * renderer = new GUIRenderer ( ) ; <nl> - if ( renderer & & renderer - > init ( ) ) <nl> - { <nl> - renderer - > autorelease ( ) ; <nl> - } <nl> - else <nl> - { <nl> - CC_SAFE_DELETE ( renderer ) ; <nl> - } <nl> - return renderer ; <nl> - } <nl> - <nl> - void GUIRenderer : : setEnabled ( bool enabled ) <nl> - { <nl> - _enabled = enabled ; <nl> - } <nl> - <nl> - bool GUIRenderer : : isEnabled ( ) const <nl> - { <nl> - return _enabled ; <nl> - } <nl> - <nl> - void GUIRenderer : : visit ( ) <nl> - { <nl> - if ( ! _enabled ) <nl> - { <nl> - return ; <nl> - } <nl> - cocos2d : : Node : : visit ( ) ; <nl> - } <nl> - <nl> - } <nl> + NS_CC_END <nl> mmm a / cocos / gui / UIWidget . h <nl> ppp b / cocos / gui / UIWidget . h <nl> <nl> # include " gui / UILayoutDefine . h " <nl> # include " gui / UILayoutParameter . h " <nl> <nl> + NS_CC_BEGIN <nl> + <nl> namespace gui { <nl> <nl> typedef enum <nl> typedef enum <nl> POSITION_PERCENT <nl> } PositionType ; <nl> <nl> - typedef void ( cocos2d : : Object : : * SEL_TouchEvent ) ( cocos2d : : Object * , TouchEventType ) ; <nl> - # define toucheventselector ( _SELECTOR ) ( gui : : SEL_TouchEvent ) ( & _SELECTOR ) <nl> - <nl> - class UIWidget : public cocos2d : : Object <nl> + typedef void ( Object : : * SEL_TouchEvent ) ( Object * , TouchEventType ) ; <nl> + # define toucheventselector ( _SELECTOR ) ( SEL_TouchEvent ) ( & _SELECTOR ) <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + class Widget : public Node <nl> { <nl> public : <nl> / * * <nl> * Default constructor <nl> - * @ js ctor <nl> * / <nl> - UIWidget ( void ) ; <nl> + Widget ( void ) ; <nl> <nl> / * * <nl> * Default destructor <nl> - * @ js NA <nl> - * @ lua NA <nl> * / <nl> - virtual ~ UIWidget ( ) ; <nl> + virtual ~ Widget ( ) ; <nl> <nl> / * * <nl> * Allocates and initializes a widget . <nl> * / <nl> - static UIWidget * create ( ) ; <nl> + static Widget * create ( ) ; <nl> <nl> / * * <nl> * Sets whether the widget is enabled <nl> class UIWidget : public cocos2d : : Object <nl> * / <nl> bool isEnabled ( ) const ; <nl> <nl> - / * * <nl> - * Sets whether the widget is visible <nl> - * <nl> - * The default value is true , a widget is default to visible <nl> - * <nl> - * @ param visible true if the widget is visible , false if the widget is hidden . <nl> - * / <nl> - void setVisible ( bool visible ) ; <nl> - <nl> - / * * <nl> - * Determines if the widget is visible <nl> - * <nl> - * @ return true if the widget is visible , false if the widget is hidden . <nl> - * / <nl> - bool isVisible ( ) const ; <nl> - <nl> / * * <nl> * Sets whether the widget is bright <nl> * <nl> class UIWidget : public cocos2d : : Object <nl> * / <nl> void setFocused ( bool fucosed ) ; <nl> <nl> - / * * <nl> - * Sets the Z order which stands for the drawing order , and reorder this widget in its parent ' s children array . <nl> - * <nl> - * The Z order of widget is relative to its " brothers " : children of the same parent . <nl> - * It ' s nothing to do with OpenGL ' s z vertex . This one only affects the draw order of widgets in cocos2d . <nl> - * The larger number it is , the later this widget will be drawn in each message loop . <nl> - * Please refer to setVertexZ ( float ) for the difference . <nl> - * <nl> - * @ param nZOrder Z order of this widget . <nl> - * / <nl> - void setZOrder ( int z ) ; <nl> - <nl> - / * * <nl> - * Gets the Z order of this widget . <nl> - * <nl> - * @ see setZOrder ( int ) <nl> - * <nl> - * @ return The Z order . <nl> - * / <nl> - int getZOrder ( ) ; <nl> - <nl> / * * <nl> * Gets the left boundary position of this widget . <nl> * <nl> class UIWidget : public cocos2d : : Object <nl> float getTopInParent ( ) ; <nl> <nl> / * * <nl> - * Adds a child to the container . <nl> - * <nl> - * @ param child A child widget <nl> - * / <nl> - virtual bool addChild ( UIWidget * child ) ; <nl> - <nl> - / * * <nl> - * Removes a child from the container with a cleanup <nl> + * Adds a child to the container with z - order as 0 . <nl> * <nl> - * @ param child The child widget which will be removed . <nl> + * If the child is added to a ' running ' node , then ' onEnter ' and ' onEnterTransitionDidFinish ' will be called immediately . <nl> * <nl> - * @ return the result of removing , succeeded or failed . <nl> - * / <nl> - virtual bool removeChild ( UIWidget * child ) ; <nl> - <nl> - / * * <nl> - * Removes this widget itself from its parent widget . <nl> - * If the widget orphan , then it will destroy itself . <nl> - * / <nl> - virtual void removeFromParent ( ) ; <nl> - <nl> - / * * <nl> - * Removes all children from the container , and do a cleanup to all running actions depending on the cleanup parameter . <nl> + * @ param child A child node <nl> * / <nl> - virtual void removeAllChildren ( ) ; <nl> - <nl> + virtual void addChild ( Node * child ) override ; <nl> / * * <nl> - * Reorders a child according to a new z value . <nl> + * Adds a child to the container with a z - order <nl> * <nl> - * @ param child An already added child node . It MUST be already added . <nl> - * @ param zOrder Z order for drawing priority and touched priority . Please refer to setZOrder ( int ) <nl> + * If the child is added to a ' running ' node , then ' onEnter ' and ' onEnterTransitionDidFinish ' will be called immediately . <nl> + * <nl> + * @ param child A child node <nl> + * @ param zOrder Z order for drawing priority . Please refer to setZOrder ( int ) <nl> * / <nl> - virtual void reorderChild ( UIWidget * child ) ; <nl> - <nl> + virtual void addChild ( Node * child , int zOrder ) override ; <nl> / * * <nl> - * Gets a child from the container with its name <nl> + * Adds a child to the container with z order and tag <nl> * <nl> - * @ param name An key to find the child widget . <nl> + * If the child is added to a ' running ' node , then ' onEnter ' and ' onEnterTransitionDidFinish ' will be called immediately . <nl> * <nl> - * @ return a UIWidget object whose name equals to the input parameter <nl> + * @ param child A child node <nl> + * @ param zOrder Z order for drawing priority . Please refer to setZOrder ( int ) <nl> + * @ param tag A interger to identify the node easily . Please refer to setTag ( int ) <nl> * / <nl> - UIWidget * getChildByName ( const char * name ) ; <nl> - <nl> + virtual void addChild ( Node * child , int zOrder , int tag ) override ; <nl> / * * <nl> * Gets a child from the container with its tag <nl> * <nl> - * @ param tag An identifier to find the child widget . <nl> + * @ param tag An identifier to find the child node . <nl> * <nl> - * @ return a UIWidget object whose tag equals to the input parameter <nl> + * @ return a Node object whose tag equals to the input parameter <nl> * / <nl> - UIWidget * getChildByTag ( int tag ) ; <nl> + Node * getChildByTag ( int tag ) ; <nl> <nl> + virtual void sortAllChildren ( ) override ; <nl> / * * <nl> * Return an array of children <nl> * <nl> - * Composing a " tree " structure is a very important feature of UIWidget <nl> + * Composing a " tree " structure is a very important feature of Node <nl> + * Here ' s a sample code of traversing children array : <nl> + @ code <nl> + Node * node = NULL ; <nl> + CCARRAY_FOREACH ( parent - > getChildren ( ) , node ) <nl> + { <nl> + node - > setPosition ( 0 , 0 ) ; <nl> + } <nl> + @ endcode <nl> + * This sample code traverses all children nodes , and set their position to ( 0 , 0 ) <nl> * <nl> * @ return An array of children <nl> * / <nl> - virtual cocos2d : : Array * getChildren ( ) ; <nl> + virtual Vector < Node * > & getChildren ( ) override ; <nl> + virtual const Vector < Node * > & getChildren ( ) const override ; <nl> <nl> / * * <nl> - * Gets the renderer of widget <nl> + * Get the amount of children . <nl> * <nl> - * renderer is a Node , it ' s for drawing <nl> - * <nl> - * @ return a Node object <nl> + * @ return The amount of children . <nl> * / <nl> - cocos2d : : Node * getRenderer ( ) ; <nl> + long getChildrenCount ( ) const ; <nl> <nl> / * * <nl> - * Add a Node for rendering . <nl> - * <nl> - * renderer is a Node , it ' s for drawing <nl> - * <nl> - * @ param renderer A render node <nl> - * <nl> - * @ param zOrder Z order for drawing priority . Please refer to Node : : setZOrder ( int ) <nl> + * Removes this node itself from its parent node with a cleanup . <nl> + * If the node orphan , then nothing happens . <nl> + * @ see ` removeFromParentAndCleanup ( bool ) ` <nl> + * / <nl> + virtual void removeFromParent ( ) ; <nl> + / * * <nl> + * Removes this node itself from its parent node . <nl> + * If the node orphan , then nothing happens . <nl> + * @ param cleanup true if all actions and callbacks on this node should be removed , false otherwise . <nl> + * @ js removeFromParent <nl> + * @ lua removeFromParent <nl> * / <nl> - void addRenderer ( cocos2d : : Node * renderer , int zOrder ) ; <nl> + virtual void removeFromParentAndCleanup ( bool cleanup ) ; <nl> <nl> / * * <nl> - * Remove a Node from widget . <nl> + * Removes a child from the container . It will also cleanup all running actions depending on the cleanup parameter . <nl> * <nl> - * renderer is a Node , it ' s for drawing <nl> + * @ param child The child node which will be removed . <nl> + * @ param cleanup true if all running actions and callbacks on the child node will be cleanup , false otherwise . <nl> + * / <nl> + virtual void removeChild ( Node * child , bool cleanup = true ) ; <nl> + <nl> + / * * <nl> + * Removes a child from the container by tag value . It will also cleanup all running actions depending on the cleanup parameter <nl> * <nl> - * @ param renderer A render node which needs to be removed <nl> + * @ param tag An interger number that identifies a child node <nl> + * @ param cleanup true if all running actions and callbacks on the child node will be cleanup , false otherwise . <nl> + * / <nl> + virtual void removeChildByTag ( int tag , bool cleanup = true ) ; <nl> + / * * <nl> + * Removes all children from the container with a cleanup . <nl> * <nl> - * @ param cleanup true if all running actions and callbacks on the render node will be cleanup , false otherwise . <nl> + * @ see ` removeAllChildrenWithCleanup ( bool ) ` <nl> * / <nl> - void removeRenderer ( cocos2d : : Node * renderer , bool cleanup ) ; <nl> - <nl> + virtual void removeAllChildren ( ) ; <nl> / * * <nl> - * Sets the parent widget <nl> + * Removes all children from the container , and do a cleanup to all running actions depending on the cleanup parameter . <nl> * <nl> - * @ param parent A pointer to the parnet widget <nl> + * @ param cleanup true if all running actions on all children nodes should be cleanup , false oterwise . <nl> + * @ js removeAllChildren <nl> + * @ lua removeAllChildren <nl> * / <nl> - void setParent ( UIWidget * parent ) ; <nl> + virtual void removeAllChildrenWithCleanup ( bool cleanup ) ; <nl> <nl> / * * <nl> - * Returns a pointer to the parent widget <nl> + * Gets a child from the container with its name <nl> * <nl> - * @ see setParent ( UIWidget * ) <nl> + * @ param name An key to find the child widget . <nl> * <nl> - * @ returns A pointer to the parnet widget <nl> + * @ return a Widget object whose name equals to the input parameter <nl> * / <nl> - UIWidget * getParent ( ) ; <nl> + Widget * getChildByName ( const char * name ) ; <nl> + <nl> + virtual void visit ( ) ; <nl> <nl> / * * <nl> * Sets the touch event target / selector of the menu item <nl> * / <nl> - void addTouchEventListener ( cocos2d : : Object * target , SEL_TouchEvent selector ) ; <nl> + void addTouchEventListener ( Object * target , SEL_TouchEvent selector ) ; <nl> <nl> <nl> / / cocos2d property <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ param position The position ( x , y ) of the widget in OpenGL coordinates <nl> * / <nl> - void setPosition ( const cocos2d : : Point & pos ) ; <nl> + void setPosition ( const Point & pos ) ; <nl> <nl> / * * <nl> * Changes the position ( x , y ) of the widget in OpenGL coordinates <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ param percent The percent ( x , y ) of the widget in OpenGL coordinates <nl> * / <nl> - void setPositionPercent ( const cocos2d : : Point & percent ) ; <nl> - <nl> - / * * <nl> - * Gets the position ( x , y ) of the widget in OpenGL coordinates <nl> - * <nl> - * @ see setPosition ( const Point & ) <nl> - * <nl> - * @ return The position ( x , y ) of the widget in OpenGL coordinates <nl> - * / <nl> - const cocos2d : : Point & getPosition ( ) ; <nl> - <nl> + void setPositionPercent ( const Point & percent ) ; <nl> + <nl> / * * <nl> * Gets the percent ( x , y ) of the widget in OpenGL coordinates <nl> * <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ return The percent ( x , y ) of the widget in OpenGL coordinates <nl> * / <nl> - const cocos2d : : Point & getPositionPercent ( ) ; <nl> + const Point & getPositionPercent ( ) ; <nl> <nl> / * * <nl> * Changes the position type of the widget <nl> class UIWidget : public cocos2d : : Object <nl> * / <nl> PositionType getPositionType ( ) const ; <nl> <nl> - / * * <nl> - * Sets the anchor point in percent . <nl> - * <nl> - * anchorPoint is the point around which all transformations and positioning manipulations take place . <nl> - * It ' s like a pin in the widget where it is " attached " to its parent . <nl> - * The anchorPoint is normalized , like a percentage . ( 0 , 0 ) means the bottom - left corner and ( 1 , 1 ) means the top - right corner . <nl> - * But you can use values higher than ( 1 , 1 ) and lower than ( 0 , 0 ) too . <nl> - * The default anchorPoint is ( 0 . 5 , 0 . 5 ) , so it starts in the center of the widget . <nl> - * <nl> - * @ param anchorPoint The anchor point of widget . <nl> - * / <nl> - virtual void setAnchorPoint ( const cocos2d : : Point & pt ) ; <nl> - <nl> - / * * <nl> - * Returns the anchor point in percent . <nl> - * <nl> - * @ see setAnchorPoint ( const Point & ) <nl> - * <nl> - * @ return The anchor point of widget . <nl> - * / <nl> - const cocos2d : : Point & getAnchorPoint ( ) ; <nl> - <nl> - / * * <nl> - * Changes both X and Y scale factor of the widget . <nl> - * <nl> - * 1 . 0 is the default scale factor . It modifies the X and Y scale at the same time . <nl> - * <nl> - * @ param scale The scale factor for both X and Y axis . <nl> - * / <nl> - virtual void setScale ( float fScale ) ; <nl> - <nl> - / * * <nl> - * Gets the scale factor of the widget , when X and Y have the same scale factor . <nl> - * <nl> - * @ warning Assert when m_fScaleX ! = m_fScaleY . <nl> - * @ see setScale ( float ) <nl> - * <nl> - * @ return The scale factor of the widget . <nl> - * / <nl> - float getScale ( ) ; <nl> - <nl> - / * * <nl> - * Changes the scale factor on X axis of this widget <nl> - * <nl> - * The deafult value is 1 . 0 if you haven ' t changed it before <nl> - * <nl> - * @ param fScaleX The scale factor on X axis . <nl> - * / <nl> - virtual void setScaleX ( float fScaleX ) ; <nl> - <nl> - / * * <nl> - * Returns the scale factor on X axis of this widget <nl> - * <nl> - * @ see setScaleX ( float ) <nl> - * <nl> - * @ return The scale factor on X axis . <nl> - * / <nl> - float getScaleX ( ) ; <nl> - <nl> - / * * <nl> - * Changes the scale factor on Y axis of this widget <nl> - * <nl> - * The Default value is 1 . 0 if you haven ' t changed it before . <nl> - * <nl> - * @ param fScaleY The scale factor on Y axis . <nl> - * / <nl> - virtual void setScaleY ( float fScaleY ) ; <nl> - <nl> - / * * <nl> - * Returns the scale factor on Y axis of this widget <nl> - * <nl> - * @ see setScaleY ( float ) <nl> - * <nl> - * @ return The scale factor on Y axis . <nl> - * / <nl> - float getScaleY ( ) ; <nl> - <nl> - / * * <nl> - * Sets the rotation ( angle ) of the widget in degrees . <nl> - * <nl> - * 0 is the default rotation angle . <nl> - * Positive values rotate widget clockwise , and negative values for anti - clockwise . <nl> - * <nl> - * @ param fRotation The roration of the widget in degrees . <nl> - * / <nl> - void setRotation ( float rotation ) ; <nl> - <nl> - / * * <nl> - * Returns the rotation of the widget in degrees . <nl> - * <nl> - * @ see setRotation ( float ) <nl> - * <nl> - * @ return The rotation of the widget in degrees . <nl> - * / <nl> - float getRotation ( ) ; <nl> - <nl> - / * * <nl> - * Sets the X rotation ( angle ) of the widget in degrees which performs a horizontal rotational skew . <nl> - * <nl> - * 0 is the default rotation angle . <nl> - * Positive values rotate widget clockwise , and negative values for anti - clockwise . <nl> - * <nl> - * @ param fRotationX The X rotation in degrees which performs a horizontal rotational skew . <nl> - * / <nl> - void setRotationX ( float rotationX ) ; <nl> - <nl> - / * * <nl> - * Gets the X rotation ( angle ) of the widget in degrees which performs a horizontal rotation skew . <nl> - * <nl> - * @ see setRotationX ( float ) <nl> - * <nl> - * @ return The X rotation in degrees . <nl> - * / <nl> - float getRotationX ( ) ; <nl> - <nl> - / * * <nl> - * Sets the Y rotation ( angle ) of the widget in degrees which performs a vertical rotational skew . <nl> - * <nl> - * 0 is the default rotation angle . <nl> - * Positive values rotate widget clockwise , and negative values for anti - clockwise . <nl> - * <nl> - * @ param fRotationY The Y rotation in degrees . <nl> - * / <nl> - void setRotationY ( float rotationY ) ; <nl> - <nl> - / * * <nl> - * Gets the Y rotation ( angle ) of the widget in degrees which performs a vertical rotational skew . <nl> - * <nl> - * @ see setRotationY ( float ) <nl> - * <nl> - * @ return The Y rotation in degrees . <nl> - * / <nl> - float getRotationY ( ) ; <nl> - <nl> / * * <nl> * Sets whether the widget should be flipped horizontally or not . <nl> * <nl> class UIWidget : public cocos2d : : Object <nl> * / <nl> virtual bool isFlipY ( ) { return false ; } ; <nl> <nl> - / * * <nl> - * Sets color to widget <nl> - * <nl> - * It default change the color of widget ' s children . <nl> - * <nl> - * @ param color <nl> - * / <nl> - virtual void setColor ( const cocos2d : : Color3B & color ) ; <nl> - <nl> - / * * <nl> - * Gets color of widget <nl> - * <nl> - * @ return color <nl> - * / <nl> - virtual const cocos2d : : Color3B & getColor ( ) ; <nl> - <nl> - / * * <nl> - * Sets opacity to widget <nl> - * <nl> - * It default change the opacity of widget ' s children . <nl> - * <nl> - * @ param color <nl> - * / <nl> - virtual void setOpacity ( int opacity ) ; <nl> - <nl> - / * * <nl> - * Gets opacity of widget <nl> - * <nl> - * @ return opacity <nl> - * / <nl> - virtual int getOpacity ( ) ; <nl> - virtual bool isCascadeOpacityEnabled ( ) ; <nl> - virtual void setCascadeOpacityEnabled ( bool cascadeOpacityEnabled ) ; <nl> - virtual bool isCascadeColorEnabled ( ) ; <nl> - virtual void setCascadeColorEnabled ( bool cascadeColorEnabled ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - void setBlendFunc ( cocos2d : : BlendFunc blendFunc ) ; <nl> - <nl> - / / cocos action <nl> - virtual void setActionManager ( cocos2d : : ActionManager * actionManager ) ; <nl> - virtual cocos2d : : ActionManager * getActionManager ( ) ; <nl> - cocos2d : : Action * runAction ( cocos2d : : Action * action ) ; <nl> - void stopAllActions ( void ) ; <nl> - void stopAction ( cocos2d : : Action * action ) ; <nl> - void stopActionByTag ( int tag ) ; <nl> - cocos2d : : Action * getActionByTag ( int tag ) ; <nl> - <nl> / * * <nl> * A call back function when widget lost of focus . <nl> * / <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ return true if the point is in parent ' s area , flase otherwise . <nl> * / <nl> - bool clippingParentAreaContainPoint ( const cocos2d : : Point & pt ) ; <nl> + bool clippingParentAreaContainPoint ( const Point & pt ) ; <nl> <nl> / * <nl> * Sends the touch event to widget ' s parent <nl> * / <nl> - virtual void checkChildInfo ( int handleState , UIWidget * sender , const cocos2d : : Point & touchPoint ) ; <nl> + virtual void checkChildInfo ( int handleState , Widget * sender , const Point & touchPoint ) ; <nl> <nl> / * <nl> * Gets the touch began point of widget when widget is selected . <nl> * <nl> * @ return the touch began point . <nl> * / <nl> - const cocos2d : : Point & getTouchStartPos ( ) ; <nl> + const Point & getTouchStartPos ( ) ; <nl> <nl> / * <nl> * Gets the touch move point of widget when widget is selected . <nl> * <nl> * @ return the touch move point . <nl> * / <nl> - const cocos2d : : Point & getTouchMovePos ( ) ; <nl> + const Point & getTouchMovePos ( ) ; <nl> <nl> / * <nl> * Gets the touch end point of widget when widget is selected . <nl> * <nl> * @ return the touch end point . <nl> * / <nl> - const cocos2d : : Point & getTouchEndPos ( ) ; <nl> - <nl> - / * * <nl> - * Changes the tag that is used to identify the widget easily . <nl> - * <nl> - * @ param A interger that indentifies the widget . <nl> - * / <nl> - void setTag ( int tag ) ; <nl> - <nl> - / * * <nl> - * Returns a tag that is used to identify the widget easily . <nl> - * <nl> - * You can set tags to widget then identify them easily . <nl> - * <nl> - * @ return A interger that identifies the widget . <nl> - * / <nl> - int getTag ( ) const ; <nl> + const Point & getTouchEndPos ( ) ; <nl> <nl> / * * <nl> * Changes the name that is used to identify the widget easily . <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ param size that is widget ' s size <nl> * / <nl> - virtual void setSize ( const cocos2d : : Size & size ) ; <nl> + virtual void setSize ( const Size & size ) ; <nl> <nl> / * * <nl> * Changes the percent that is widget ' s percent size <nl> * <nl> * @ param percent that is widget ' s percent size <nl> * / <nl> - virtual void setSizePercent ( const cocos2d : : Point & percent ) ; <nl> + virtual void setSizePercent ( const Point & percent ) ; <nl> <nl> / * * <nl> * Changes the size type of widget . <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ return size <nl> * / <nl> - const cocos2d : : Size & getSize ( ) const ; <nl> + const Size & getSize ( ) const ; <nl> <nl> / * * <nl> * Returns size percent of widget <nl> * <nl> * @ return size percent <nl> * / <nl> - const cocos2d : : Point & getSizePercent ( ) const ; <nl> + const Point & getSizePercent ( ) const ; <nl> <nl> / * * <nl> * Checks a point if is in widget ' s space <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ return true if the point is in widget ' s space , flase otherwise . <nl> * / <nl> - virtual bool hitTest ( const cocos2d : : Point & pt ) ; <nl> - <nl> - / * * <nl> - * A call back function called when widget is selected , and on touch began . <nl> - * <nl> - * @ param touch point <nl> - * <nl> - * @ return true if the event should be pass to parent , flase otherwise . <nl> - * / <nl> - virtual bool onTouchBegan ( const cocos2d : : Point & touchPoint ) ; <nl> - <nl> - / * * <nl> - * A call back function called when widget is selected , and on touch moved . <nl> - * <nl> - * @ param touch point <nl> - * / <nl> - virtual void onTouchMoved ( const cocos2d : : Point & touchPoint ) ; <nl> + virtual bool hitTest ( const Point & pt ) ; <nl> <nl> - / * * <nl> - * A call back function called when widget is selected , and on touch ended . <nl> - * <nl> - * @ param touch point <nl> - * / <nl> - virtual void onTouchEnded ( const cocos2d : : Point & touchPoint ) ; <nl> - <nl> - / * * <nl> - * A call back function called when widget is selected , and on touch canceled . <nl> - * <nl> - * @ param touch point <nl> - * / <nl> - virtual void onTouchCancelled ( const cocos2d : : Point & touchPoint ) ; <nl> + virtual bool onTouchBegan ( Touch * touch , Event * unusedEvent ) ; <nl> + virtual void onTouchMoved ( Touch * touch , Event * unusedEvent ) ; <nl> + virtual void onTouchEnded ( Touch * touch , Event * unusedEvent ) ; <nl> + virtual void onTouchCancelled ( Touch * touch , Event * unusedEvent ) ; <nl> <nl> / * * <nl> * A call back function called when widget is selected , and on touch long clicked . <nl> * <nl> * @ param touch point <nl> * / <nl> - virtual void onTouchLongClicked ( const cocos2d : : Point & touchPoint ) ; <nl> + virtual void onTouchLongClicked ( const Point & touchPoint ) ; <nl> <nl> / * * <nl> * Sets a LayoutParameter to widget . <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ param type Relative or Linear <nl> * / <nl> - void setLayoutParameter ( UILayoutParameter * parameter ) ; <nl> + void setLayoutParameter ( LayoutParameter * parameter ) ; <nl> <nl> / * * <nl> * Gets LayoutParameter of widget . <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ return LayoutParameter <nl> * / <nl> - UILayoutParameter * getLayoutParameter ( LayoutParameterType type ) ; <nl> + LayoutParameter * getLayoutParameter ( LayoutParameterType type ) ; <nl> <nl> / * * <nl> * Ignore the widget size <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ return world position of widget . <nl> * / <nl> - cocos2d : : Point getWorldPosition ( ) ; <nl> - <nl> - / * * <nl> - * Converts a Point to world space coordinates . The result is in Points . <nl> - * / <nl> - cocos2d : : Point convertToWorldSpace ( const cocos2d : : Point & pt ) ; <nl> - <nl> + Point getWorldPosition ( ) ; <nl> + <nl> / * * <nl> * Gets the Virtual Renderer of widget . <nl> * <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * @ return Node pointer . <nl> * / <nl> - virtual cocos2d : : Node * getVirtualRenderer ( ) ; <nl> + virtual Node * getVirtualRenderer ( ) ; <nl> <nl> / * * <nl> * Schedules the " update " method . <nl> class UIWidget : public cocos2d : : Object <nl> * <nl> * Content size is widget ' s texture size . <nl> * / <nl> - virtual const cocos2d : : Size & getContentSize ( ) const ; <nl> + virtual const Size & getContentSize ( ) const ; <nl> <nl> / * * <nl> * Returns the " class name " of widget . <nl> * / <nl> - virtual const char * getDescription ( ) const ; <nl> + virtual std : : string getDescription ( ) const override ; <nl> <nl> - UIWidget * clone ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> + Widget * clone ( ) ; <nl> + <nl> virtual void onEnter ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> virtual void onExit ( ) ; <nl> <nl> void updateSizeAndPosition ( ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual Object * getUserObject ( ) { return _userObject ; } <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual const Object * getUserObject ( ) const { return _userObject ; } <nl> <nl> - / * * <nl> - * Returns a user assigned Object <nl> - * <nl> - * Similar to UserData , but instead of holding a void * it holds an object . <nl> - * The UserObject will be retained once in this method , <nl> - * and the previous UserObject ( if existed ) will be relese . <nl> - * The UserObject will be released in Node ' s destructure . <nl> - * <nl> - * @ param userObject A user assigned Object <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual void setUserObject ( Object * userObject ) ; <nl> / * temp action * / <nl> void setActionTag ( int tag ) ; <nl> int getActionTag ( ) ; <nl> class UIWidget : public cocos2d : : Object <nl> void cancelUpEvent ( ) ; <nl> void longClickEvent ( ) ; <nl> void updateAnchorPoint ( ) ; <nl> - void copyProperties ( UIWidget * model ) ; <nl> - virtual UIWidget * createCloneInstance ( ) ; <nl> - virtual void copySpecialProperties ( UIWidget * model ) ; <nl> - virtual void copyClonedWidgetChildren ( UIWidget * model ) ; <nl> + void copyProperties ( Widget * model ) ; <nl> + virtual Widget * createCloneInstance ( ) ; <nl> + virtual void copySpecialProperties ( Widget * model ) ; <nl> + virtual void copyClonedWidgetChildren ( Widget * model ) ; <nl> + Widget * getWidgetParent ( ) ; <nl> protected : <nl> bool _enabled ; / / / < Highest control of widget <nl> - bool _visible ; / / / < is this widget visible <nl> bool _bright ; / / / < is this widget bright <nl> bool _touchEnabled ; / / / < is this widget touch endabled <nl> bool _touchPassedEnabled ; / / / < is the touch event should be passed <nl> bool _focus ; / / / < is the widget on focus <nl> - int _widgetZOrder ; / / / < z - order value that affects the draw order and touch order <nl> - cocos2d : : Point _anchorPoint ; / / / < anchor point normalized <nl> - UIWidget * _widgetParent ; / / / < parent of widget <nl> BrightStyle _brightStyle ; / / / < bright style <nl> bool _updateEnabled ; / / / < is " update " method scheduled <nl> - cocos2d : : Node * _renderer ; / / / < base renderer <nl> - cocos2d : : Point _touchStartPos ; / / / < touch began point <nl> - cocos2d : : Point _touchMovePos ; / / / < touch moved point <nl> - cocos2d : : Point _touchEndPos ; / / / < touch ended point <nl> + / / Node * _renderer ; / / / < base renderer <nl> + Point _touchStartPos ; / / / < touch began point <nl> + Point _touchMovePos ; / / / < touch moved point <nl> + Point _touchEndPos ; / / / < touch ended point <nl> <nl> Object * _touchEventListener ; <nl> SEL_TouchEvent _touchEventSelector ; <nl> <nl> <nl> <nl> - int _widgetTag ; <nl> std : : string _name ; <nl> WidgetType _widgetType ; <nl> int _actionTag ; <nl> - cocos2d : : Size _size ; <nl> - cocos2d : : Size _customSize ; <nl> - cocos2d : : Dictionary * _layoutParameterDictionary ; <nl> + Size _size ; <nl> + Size _customSize ; <nl> + Map < int , LayoutParameter * > _layoutParameterDictionary ; <nl> bool _ignoreSize ; <nl> - cocos2d : : Array * _children ; <nl> + Vector < Node * > _widgetChildren ; <nl> bool _affectByClipping ; <nl> <nl> - cocos2d : : Scheduler * _scheduler ; <nl> - <nl> SizeType _sizeType ; <nl> - cocos2d : : Point _sizePercent ; <nl> + Point _sizePercent ; <nl> PositionType _positionType ; <nl> - cocos2d : : Point _positionPercent ; <nl> - bool _isRunning ; <nl> - cocos2d : : Object * _userObject ; <nl> - } ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - class GUIRenderer : public cocos2d : : Node <nl> - { <nl> - public : <nl> - GUIRenderer ( ) ; <nl> - virtual ~ GUIRenderer ( ) ; <nl> - virtual void visit ( void ) ; <nl> - static GUIRenderer * create ( ) ; <nl> - void setEnabled ( bool enabled ) ; <nl> - bool isEnabled ( ) const ; <nl> - protected : <nl> - bool _enabled ; <nl> + Point _positionPercent ; <nl> + <nl> + bool _reorderWidgetChildDirty ; <nl> + <nl> + bool _hitted ; <nl> + <nl> + EventListenerTouchOneByOne * _touchListener ; <nl> } ; <nl> - <nl> } <nl> - # endif / * defined ( __UIWidget__ ) * / <nl> + <nl> + NS_CC_END <nl> + <nl> + # endif / * defined ( __Widget__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / CocosGUIScene . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / CocosGUIScene . cpp <nl> <nl> # include " . . / ExtensionsTest . h " <nl> # include " cocostudio / CocoStudio . h " <nl> <nl> - const char * gui_scene_names [ 2 ] = <nl> + enum <nl> + { <nl> + LINE_SPACE = 40 , <nl> + kItemTagBasic = 1000 , <nl> + } ; <nl> + <nl> + static struct <nl> + { <nl> + const char * name ; <nl> + std : : function < void ( Object * sender ) > callback ; <nl> + } <nl> + g_guisTests [ ] = <nl> + { <nl> + { <nl> + " gui ButtonTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIButtonTest ) ; <nl> + pManager - > setMinUISceneId ( kUIButtonTest ) ; <nl> + pManager - > setMaxUISceneId ( kUIButtonTest_Title ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui CheckBoxTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUICheckBoxTest ) ; <nl> + pManager - > setMinUISceneId ( kUICheckBoxTest ) ; <nl> + pManager - > setMaxUISceneId ( kUICheckBoxTest ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui SliderTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUISliderTest ) ; <nl> + pManager - > setMinUISceneId ( kUISliderTest ) ; <nl> + pManager - > setMaxUISceneId ( kUISliderTest_Scale9 ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + / * <nl> + { <nl> + " gui PotentiometerTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIPotentiometerTest ) ; <nl> + pManager - > setMinUISceneId ( kUIPotentiometerTest ) ; <nl> + pManager - > setMaxUISceneId ( kUIPotentiometerTest ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui SwitchTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUISwitchTest_Horizontal ) ; <nl> + pManager - > setMinUISceneId ( kUISwitchTest_Horizontal ) ; <nl> + pManager - > setMaxUISceneId ( kUISwitchTest_VerticalAndTitleVertical ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + * / <nl> + { <nl> + " gui ImageViewTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIImageViewTest ) ; <nl> + pManager - > setMinUISceneId ( kUIImageViewTest ) ; <nl> + pManager - > setMaxUISceneId ( kUIImageViewTest_Scale9 ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui LoadingBarTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUILoadingBarTest_Left ) ; <nl> + pManager - > setMinUISceneId ( kUILoadingBarTest_Left ) ; <nl> + pManager - > setMaxUISceneId ( kUILoadingBarTest_Right_Scale9 ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + / * <nl> + { <nl> + " gui ProgressTimerTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIProgressTimerTest_Radial ) ; <nl> + pManager - > setMinUISceneId ( kUIProgressTimerTest_Radial ) ; <nl> + pManager - > setMaxUISceneId ( kUIProgressTimerTest_WithSpriteFrame ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + * / <nl> + { <nl> + " gui LabelAtalsTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUILabelAtlasTest ) ; <nl> + pManager - > setMinUISceneId ( kUILabelAtlasTest ) ; <nl> + pManager - > setMaxUISceneId ( kUILabelAtlasTest ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui LabelTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUILabelTest ) ; <nl> + pManager - > setMinUISceneId ( kUILabelTest ) ; <nl> + pManager - > setMaxUISceneId ( kUILabelTest_TTF ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui LabelBMFontTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUILabelBMFontTest ) ; <nl> + pManager - > setMinUISceneId ( kUILabelBMFontTest ) ; <nl> + pManager - > setMaxUISceneId ( kUILabelBMFontTest ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui TextFieldTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUITextFieldTest ) ; <nl> + pManager - > setMinUISceneId ( kUITextFieldTest ) ; <nl> + pManager - > setMaxUISceneId ( kUITextFieldTest_Password ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui LayoutTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUILayoutTest ) ; <nl> + pManager - > setMinUISceneId ( kUILayoutTest ) ; <nl> + pManager - > setMaxUISceneId ( kUILayoutTest_Layout_Relative_Location ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui ScrollViewTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIScrollViewTest_Vertical ) ; <nl> + pManager - > setMinUISceneId ( kUIScrollViewTest_Vertical ) ; <nl> + pManager - > setMaxUISceneId ( kUIScrollViewTest_ScrollToPercentBothDirection_Bounce ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui PageViewTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIPageViewTest ) ; <nl> + pManager - > setMinUISceneId ( kUIPageViewTest ) ; <nl> + pManager - > setMaxUISceneId ( kUIPageViewTest ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui ListViewTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIListViewTest_Vertical ) ; <nl> + pManager - > setMinUISceneId ( kUIListViewTest_Vertical ) ; <nl> + pManager - > setMaxUISceneId ( kUIListViewTest_Horizontal ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + / * <nl> + { <nl> + " gui GridViewTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIGridViewTest_Mode_Column ) ; <nl> + pManager - > setMinUISceneId ( kUIGridViewTest_Mode_Column ) ; <nl> + pManager - > setMaxUISceneId ( kUIGridViewTest_Mode_Row ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + { <nl> + " gui PickerViewTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIPickerViewTest_Vertical ) ; <nl> + pManager - > setMinUISceneId ( kUIPickerViewTest_Vertical ) ; <nl> + pManager - > setMaxUISceneId ( kUIPickerViewTest_Horizontal ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + * / <nl> + { <nl> + " gui WidgetAddNodeTest " , <nl> + [ ] ( Object * sender ) <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + pManager - > setCurrentUISceneId ( kUIWidgetAddNodeTest ) ; <nl> + pManager - > setMinUISceneId ( kUIWidgetAddNodeTest ) ; <nl> + pManager - > setMaxUISceneId ( kUIWidgetAddNodeTest ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> + } , <nl> + } ; <nl> + <nl> + static const int g_maxTests = sizeof ( g_guisTests ) / sizeof ( g_guisTests [ 0 ] ) ; <nl> + <nl> + static Point s_tCurPos = Point : : ZERO ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / CocosGUITestMainLayer <nl> + / / <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void CocosGUITestMainLayer : : onEnter ( ) <nl> + { <nl> + Layer : : onEnter ( ) ; <nl> + <nl> + auto s = Director : : getInstance ( ) - > getWinSize ( ) ; <nl> + <nl> + _itemMenu = Menu : : create ( ) ; <nl> + _itemMenu - > setPosition ( s_tCurPos ) ; <nl> + MenuItemFont : : setFontName ( " Arial " ) ; <nl> + MenuItemFont : : setFontSize ( 24 ) ; <nl> + for ( int i = 0 ; i < g_maxTests ; + + i ) <nl> + { <nl> + auto pItem = MenuItemFont : : create ( g_guisTests [ i ] . name , g_guisTests [ i ] . callback ) ; <nl> + pItem - > setPosition ( Point ( s . width / 2 , s . height - ( i + 1 ) * LINE_SPACE ) ) ; <nl> + _itemMenu - > addChild ( pItem , kItemTagBasic + i ) ; <nl> + } <nl> + <nl> + auto listener = EventListenerTouchAllAtOnce : : create ( ) ; <nl> + listener - > onTouchesBegan = CC_CALLBACK_2 ( CocosGUITestMainLayer : : onTouchesBegan , this ) ; <nl> + listener - > onTouchesMoved = CC_CALLBACK_2 ( CocosGUITestMainLayer : : onTouchesMoved , this ) ; <nl> + <nl> + _eventDispatcher - > addEventListenerWithSceneGraphPriority ( listener , this ) ; <nl> + <nl> + addChild ( _itemMenu ) ; <nl> + } <nl> + <nl> + void CocosGUITestMainLayer : : onTouchesBegan ( const std : : vector < Touch * > & touches , Event * event ) <nl> + { <nl> + auto touch = static_cast < Touch * > ( touches [ 0 ] ) ; <nl> + <nl> + _beginPos = touch - > getLocation ( ) ; <nl> + } <nl> + <nl> + void CocosGUITestMainLayer : : onTouchesMoved ( const std : : vector < Touch * > & touches , Event * event ) <nl> + { <nl> + auto touch = static_cast < Touch * > ( touches [ 0 ] ) ; <nl> + <nl> + auto touchLocation = touch - > getLocation ( ) ; <nl> + float nMoveY = touchLocation . y - _beginPos . y ; <nl> + <nl> + auto curPos = _itemMenu - > getPosition ( ) ; <nl> + auto nextPos = Point ( curPos . x , curPos . y + nMoveY ) ; <nl> + <nl> + if ( nextPos . y < 0 . 0f ) <nl> + { <nl> + _itemMenu - > setPosition ( Point : : ZERO ) ; <nl> + return ; <nl> + } <nl> + <nl> + if ( nextPos . y > ( ( g_maxTests + 1 ) * LINE_SPACE - VisibleRect : : getVisibleRect ( ) . size . height ) ) <nl> + { <nl> + _itemMenu - > setPosition ( Point ( 0 , ( ( g_maxTests + 1 ) * LINE_SPACE - VisibleRect : : getVisibleRect ( ) . size . height ) ) ) ; <nl> + return ; <nl> + } <nl> + <nl> + _itemMenu - > setPosition ( nextPos ) ; <nl> + _beginPos = touchLocation ; <nl> + s_tCurPos = nextPos ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / CocosGUITestScene <nl> + / / <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void CocosGUITestScene : : runThisTest ( ) <nl> + { <nl> + auto layer = new CocosGUITestMainLayer ( ) ; <nl> + addChild ( layer ) ; <nl> + layer - > release ( ) ; <nl> + <nl> + Director : : getInstance ( ) - > replaceScene ( this ) ; <nl> + } <nl> + <nl> + / * <nl> + const char * gui_scene_names [ 1 ] = <nl> { <nl> " CocosGUIWidgetTest " , <nl> - " CocosGUIExampleTest " , <nl> } ; <nl> <nl> CocosGUITestScene : : CocosGUITestScene ( bool bPortrait ) <nl> - : _label ( NULL ) <nl> + : _ul ( nullptr ) <nl> + , _label ( nullptr ) <nl> + , _itemMenu ( nullptr ) <nl> { <nl> TestScene : : init ( ) ; <nl> } <nl> void CocosGUITestScene : : runThisTest ( ) <nl> <nl> Director : : getInstance ( ) - > replaceScene ( this ) ; <nl> <nl> - Size s = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> + Size s = Director : : getInstance ( ) - > getWinSize ( ) ; <nl> <nl> - _itemMenu = CCMenu : : create ( ) ; <nl> + _itemMenu = Menu : : create ( ) ; <nl> _itemMenu - > setPosition ( Point : : ZERO ) ; <nl> MenuItemFont : : setFontName ( " Arial " ) ; <nl> MenuItemFont : : setFontSize ( 24 ) ; <nl> - for ( int i = 0 ; i < 1 ; + + i ) <nl> + for ( int i = 0 ; i < sizeof ( gui_scene_names ) / sizeof ( gui_scene_names [ 0 ] ) ; + + i ) <nl> { <nl> - auto item = MenuItemFont : : create ( <nl> - gui_scene_names [ i ] , <nl> + auto item = MenuItemFont : : create ( gui_scene_names [ i ] , <nl> CC_CALLBACK_1 ( CocosGUITestScene : : menuCallback , this ) ) ; <nl> item - > setPosition ( Point ( s . width / 2 , s . height - s . height / 4 - ( i + 1 ) * 40 ) ) ; <nl> item - > setTag ( i ) ; <nl> _itemMenu - > addChild ( item ) ; <nl> } <nl> addChild ( _itemMenu ) ; <nl> - / / * / <nl> } <nl> void CocosGUITestScene : : MainMenuCallback ( Object * pSender ) <nl> { <nl> - ExtensionsTestScene * pScene = new ExtensionsTestScene ( ) ; <nl> + auto pScene = new ExtensionsTestScene ( ) ; <nl> pScene - > runThisTest ( ) ; <nl> - pScene - > release ( ) ; <nl> - } <nl> - <nl> - void CocosGUITestScene : : toCocosGUIExampleScene ( Object * sender ) <nl> - { <nl> - auto scrollView = static_cast < UIScrollView * > ( sender ) ; <nl> - scrollView - > setDirection ( SCROLLVIEW_DIR_HORIZONTAL ) ; <nl> - scrollView - > getChildByName ( " backtotopbutton " ) - > setBright ( false ) ; <nl> - scrollView - > getChildByName ( " backtotopbutton " ) - > setTouchEnabled ( false ) ; <nl> - CCLOG ( " p2 click " ) ; <nl> - ul - > removeFromParent ( ) ; <nl> - <nl> } <nl> <nl> void CocosGUITestScene : : load ( Object * pSender , int count ) <nl> void CocosGUITestScene : : load ( Object * pSender , int count ) <nl> <nl> void CocosGUITestScene : : menuCallback ( Object * pSender ) <nl> { <nl> - MenuItemFont * pItem = dynamic_cast < MenuItemFont * > ( pSender ) ; <nl> + auto pItem = static_cast < MenuItemFont * > ( pSender ) ; <nl> <nl> switch ( pItem - > getTag ( ) ) <nl> { <nl> case 0 : <nl> - { <nl> - UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> - Scene * pScene = pManager - > currentUIScene ( ) ; <nl> - CCDirector : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> - } <nl> + { <nl> + UISceneManager * pManager = UISceneManager : : sharedUISceneManager ( ) ; <nl> + Scene * pScene = pManager - > currentUIScene ( ) ; <nl> + Director : : getInstance ( ) - > replaceScene ( pScene ) ; <nl> + } <nl> break ; <nl> - <nl> - / * <nl> - case 1 : <nl> - { <nl> - CocosGUIExamplesRegisterScene * pScene = new CocosGUIExamplesRegisterScene ( ) ; <nl> - pScene - > runThisTest ( ) ; <nl> - pScene - > release ( ) ; <nl> - } <nl> - * / <nl> break ; <nl> <nl> default : <nl> break ; <nl> } <nl> } <nl> + * / <nl> \ No newline at end of file <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / CocosGUIScene . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / CocosGUIScene . h <nl> using namespace cocos2d ; <nl> using namespace cocos2d : : extension ; <nl> using namespace gui ; <nl> <nl> + class CocosGUITestMainLayer : public Layer <nl> + { <nl> + public : <nl> + virtual void onEnter ( ) ; <nl> + <nl> + void onTouchesBegan ( const std : : vector < Touch * > & touches , Event * event ) ; <nl> + void onTouchesMoved ( const std : : vector < Touch * > & touches , Event * event ) ; <nl> + <nl> + Point _beginPos ; <nl> + Menu * _itemMenu ; <nl> + <nl> + int _testcount ; <nl> + } ; <nl> + <nl> + class CocosGUITestScene : public TestScene <nl> + { <nl> + public : <nl> + virtual void runThisTest ( ) ; <nl> + } ; <nl> + <nl> + / * <nl> class CocosGUITestScene : public TestScene <nl> { <nl> public : <nl> class CocosGUITestScene : public TestScene <nl> virtual void runThisTest ( ) ; <nl> <nl> / / The CallBack for back to the main menu scene <nl> - virtual void MainMenuCallback ( Object * sender ) ; <nl> - <nl> - void toCocosGUIExampleScene ( Object * sender ) ; <nl> + virtual void MainMenuCallback ( Object * sender ) ; <nl> <nl> void load ( Object * pSender , int count ) ; <nl> void loadTextureCallBack ( Object * obj ) ; <nl> <nl> void menuCallback ( Object * pSender ) ; <nl> <nl> - UILayer * ul ; <nl> + UILayer * _ul ; <nl> <nl> LabelTTF * _label ; <nl> <nl> Menu * _itemMenu ; <nl> } ; <nl> + * / <nl> <nl> # endif / * defined ( __TestCpp__CocosGUIScene__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIButtonTest / UIButtonTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIButtonTest / UIButtonTest . cpp <nl> <nl> <nl> # include " UIButtonTest . h " <nl> <nl> - const char * font_UIButtonTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UIButtonTest <nl> UIButtonTest : : UIButtonTest ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> + <nl> } <nl> <nl> UIButtonTest : : ~ UIButtonTest ( ) <nl> bool UIButtonTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the button events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIButtonTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " Button " ) ; <nl> - alert - > setFontName ( font_UIButtonTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the button <nl> - UIButton * button = UIButton : : create ( ) ; <nl> + Button * button = Button : : create ( ) ; <nl> button - > setTouchEnabled ( true ) ; <nl> button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> button - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> button - > addTouchEventListener ( this , toucheventselector ( UIButtonTest : : touchEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( button ) ; <nl> + _uiLayer - > addChild ( button ) ; <nl> <nl> return true ; <nl> } <nl> void UIButtonTest : : touchEvent ( Object * pSender , TouchEventType type ) <nl> switch ( type ) <nl> { <nl> case gui : : TOUCH_EVENT_BEGAN : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_MOVED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_ENDED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_CANCELED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> default : <nl> void UIButtonTest : : touchEvent ( Object * pSender , TouchEventType type ) <nl> <nl> / / UIButtonTest_Scale9 <nl> UIButtonTest_Scale9 : : UIButtonTest_Scale9 ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> <nl> } <nl> bool UIButtonTest_Scale9 : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the button events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIButtonTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " Button scale9 render " ) ; <nl> - alert - > setFontName ( font_UIButtonTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the button <nl> - UIButton * button = UIButton : : create ( ) ; <nl> + Button * button = Button : : create ( ) ; <nl> button - > setTouchEnabled ( true ) ; <nl> / / open scale9 render <nl> button - > setScale9Enabled ( true ) ; <nl> bool UIButtonTest_Scale9 : : init ( ) <nl> button - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> button - > setSize ( Size ( 150 , button - > getContentSize ( ) . height * 1 . 5f ) ) ; <nl> button - > addTouchEventListener ( this , toucheventselector ( UIButtonTest_Scale9 : : touchEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( button ) ; <nl> + _uiLayer - > addChild ( button ) ; <nl> <nl> return true ; <nl> } <nl> void UIButtonTest_Scale9 : : touchEvent ( Object * pSender , TouchEventType type ) <nl> switch ( type ) <nl> { <nl> case gui : : TOUCH_EVENT_BEGAN : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_MOVED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_ENDED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_CANCELED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> default : <nl> void UIButtonTest_Scale9 : : touchEvent ( Object * pSender , TouchEventType type ) <nl> <nl> / / UIButtonTest_PressAction <nl> UIButtonTest_PressedAction : : UIButtonTest_PressedAction ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> } <nl> <nl> bool UIButtonTest_PressedAction : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the button events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIButtonTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " Button Pressed Action " ) ; <nl> - alert - > setFontName ( font_UIButtonTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the button <nl> - UIButton * button = UIButton : : create ( ) ; <nl> + Button * button = Button : : create ( ) ; <nl> button - > setTouchEnabled ( true ) ; <nl> button - > setPressedActionEnabled ( true ) ; <nl> button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> button - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> button - > addTouchEventListener ( this , toucheventselector ( UIButtonTest_PressedAction : : touchEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( button ) ; <nl> + _uiLayer - > addChild ( button ) ; <nl> <nl> return true ; <nl> } <nl> void UIButtonTest_PressedAction : : touchEvent ( Object * pSender , TouchEventType type <nl> switch ( type ) <nl> { <nl> case gui : : TOUCH_EVENT_BEGAN : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_MOVED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_ENDED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case gui : : TOUCH_EVENT_CANCELED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + / / UIButtonTest_Title <nl> + UIButtonTest_Title : : UIButtonTest_Title ( ) <nl> + : _displayValueLabel ( nullptr ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIButtonTest_Title : : ~ UIButtonTest_Title ( ) <nl> + { <nl> + } <nl> + <nl> + bool UIButtonTest_Title : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the text button events will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Button with title " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the button with title <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / backtotoppressed . png " , " cocosgui / backtotopnormal . png " , " " ) ; <nl> + button - > setTitleText ( " Title Button " ) ; <nl> + button - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + button - > addTouchEventListener ( this , toucheventselector ( UIButtonTest_Title : : touchEvent ) ) ; <nl> + _uiLayer - > addChild ( button ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + <nl> + void UIButtonTest_Title : : touchEvent ( Object * pSender , TouchEventType type ) <nl> + { <nl> + switch ( type ) <nl> + { <nl> + case TOUCH_EVENT_BEGAN : <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> + break ; <nl> + <nl> + case TOUCH_EVENT_MOVED : <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> + break ; <nl> + <nl> + case TOUCH_EVENT_ENDED : <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> + break ; <nl> + <nl> + case TOUCH_EVENT_CANCELED : <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> default : <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIButtonTest / UIButtonTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIButtonTest / UIButtonTest . h <nl> class UIButtonTest : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIButtonTest ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> class UIButtonTest_Scale9 : public UIScene <nl> class UIButtonTest_Scale9 : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIButtonTest_Scale9 ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> class UIButtonTest_PressedAction : public UIScene <nl> class UIButtonTest_PressedAction : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIButtonTest_PressedAction ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> + } ; <nl> + <nl> + class UIButtonTest_Title : public UIScene <nl> + { <nl> + public : <nl> + UIButtonTest_Title ( ) ; <nl> + ~ UIButtonTest_Title ( ) ; <nl> + bool init ( ) ; <nl> + void touchEvent ( Object * pSender , TouchEventType type ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIButtonTest_Title ) <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UIButtonTest__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest . cpp <nl> <nl> <nl> # include " UICheckBoxTest . h " <nl> <nl> - const char * font_UICheckBoxTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UICheckBoxTest <nl> UICheckBoxTest : : UICheckBoxTest ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> <nl> } <nl> bool UICheckBoxTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; ; <nl> + Size widgetSize = _widget - > getSize ( ) ; ; <nl> <nl> / / Add a label in which the checkbox events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UICheckBoxTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " CheckBox " ) ; <nl> - alert - > setFontName ( font_UICheckBoxTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the checkbox <nl> - UICheckBox * checkBox = UICheckBox : : create ( ) ; <nl> + CheckBox * checkBox = CheckBox : : create ( ) ; <nl> checkBox - > setTouchEnabled ( true ) ; <nl> checkBox - > loadTextures ( " cocosgui / check_box_normal . png " , <nl> " cocosgui / check_box_normal_press . png " , <nl> bool UICheckBoxTest : : init ( ) <nl> checkBox - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> <nl> checkBox - > addEventListenerCheckBox ( this , checkboxselectedeventselector ( UICheckBoxTest : : selectedEvent ) ) ; <nl> - <nl> - / / checkBox - > addSelectEvent ( this , coco_selectselector ( UICheckBoxTest : : selectedEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( checkBox ) ; <nl> + _uiLayer - > addChild ( checkBox ) ; <nl> <nl> return true ; <nl> } <nl> bool UICheckBoxTest : : init ( ) <nl> <nl> void UICheckBoxTest : : selectedEvent ( Object * pSender , CheckBoxEventType type ) <nl> { <nl> - switch ( type ) { <nl> - case gui : : CHECKBOX_STATE_EVENT_SELECTED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Selected " ) - > getCString ( ) ) ; <nl> + switch ( type ) <nl> + { <nl> + case CHECKBOX_STATE_EVENT_SELECTED : <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Selected " ) - > getCString ( ) ) ; <nl> break ; <nl> - case gui : : CHECKBOX_STATE_EVENT_UNSELECTED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Unselected " ) - > getCString ( ) ) ; <nl> + <nl> + case CHECKBOX_STATE_EVENT_UNSELECTED : <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Unselected " ) - > getCString ( ) ) ; <nl> break ; <nl> + <nl> default : <nl> break ; <nl> } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UICheckBoxTest / UICheckBoxTest . h <nl> class UICheckBoxTest : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UICheckBoxTest ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UICheckBoxTest__ ) * / <nl> deleted file mode 100644 <nl> index dacec9ba8414 . . 000000000000 <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIDragPanelTest / UIDragPanelTest . cpp <nl> ppp / dev / null <nl> <nl> - <nl> - <nl> - # include " UIDragPanelTest . h " <nl> - <nl> - const char * font_UIDragPanelTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> - <nl> - / / UIDragPanelTest <nl> - UIDragPanelTest : : UIDragPanelTest ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UIDragPanelTest : : ~ UIDragPanelTest ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIDragPanelTest : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add a label in which the dragpanel events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIDragPanelTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " DragPanel " ) ; <nl> - alert - > setFontName ( font_UIDragPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UIScrollView * sc = UIScrollView : : create ( ) ; <nl> - sc - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> - sc - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> - sc - > setDirection ( SCROLLVIEW_DIR_BOTH ) ; <nl> - sc - > setInnerContainerSize ( Size ( 480 , 320 ) ) ; <nl> - sc - > setSize ( Size ( 100 , 100 ) ) ; <nl> - sc - > setPosition ( Point ( 100 , 100 ) ) ; <nl> - sc - > scrollToPercentBothDirection ( Point ( 50 , 50 ) , 1 , true ) ; <nl> - UIImageView * iv = UIImageView : : create ( ) ; <nl> - iv - > loadTexture ( " cocosgui / Hello . png " ) ; <nl> - iv - > setPosition ( Point ( 240 , 160 ) ) ; <nl> - sc - > addChild ( iv ) ; <nl> - m_pUiLayer - > addWidget ( sc ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - / / UIDragPanelTest_Bounce <nl> - UIDragPanelTest_Bounce : : UIDragPanelTest_Bounce ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UIDragPanelTest_Bounce : : ~ UIDragPanelTest_Bounce ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIDragPanelTest_Bounce : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add a label in which the dragpanel events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIDragPanelTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " DragPanel Bounce " ) ; <nl> - alert - > setFontName ( font_UIDragPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UIScrollView * sc = UIScrollView : : create ( ) ; <nl> - sc - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> - sc - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> - sc - > setBounceEnabled ( true ) ; <nl> - sc - > setDirection ( SCROLLVIEW_DIR_BOTH ) ; <nl> - sc - > setInnerContainerSize ( Size ( 480 , 320 ) ) ; <nl> - sc - > setSize ( Size ( 100 , 100 ) ) ; <nl> - sc - > setPosition ( Point ( 100 , 100 ) ) ; <nl> - sc - > scrollToPercentBothDirection ( Point ( 50 , 50 ) , 1 , true ) ; <nl> - UIImageView * iv = UIImageView : : create ( ) ; <nl> - iv - > loadTexture ( " cocosgui / Hello . png " ) ; <nl> - iv - > setPosition ( Point ( 240 , 160 ) ) ; <nl> - sc - > addChild ( iv ) ; <nl> - m_pUiLayer - > addWidget ( sc ) ; <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> new file mode 100644 <nl> index 000000000000 . . d43ea27233c2 <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIGridViewTest / UIGridViewTest . cpp <nl> <nl> + <nl> + <nl> + # include " UIGridViewTest . h " <nl> + <nl> + <nl> + / / UIGridViewTest_Mode_Column <nl> + <nl> + UIGridViewTest_Mode_Column : : UIGridViewTest_Mode_Column ( ) <nl> + { <nl> + } <nl> + <nl> + UIGridViewTest_Mode_Column : : ~ UIGridViewTest_Mode_Column ( ) <nl> + { <nl> + } <nl> + <nl> + bool UIGridViewTest_Mode_Column : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the scrollview alert will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move by vertical direction " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout is in use with GridView bases on column mode " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the grid view with grid layout mode column <nl> + GridView * gridView = GridView : : create ( ) ; <nl> + gridView - > setLayoutType ( LAYOUT_GRID_MODE_COLUMN ) ; <nl> + gridView - > setScrollEnabled ( true ) ; <nl> + gridView - > setDirection ( SCROLLVIEW_DIR_VERTICAL ) ; <nl> + gridView - > setBounceEnabled ( true ) ; <nl> + gridView - > setTouchEnabled ( true ) ; <nl> + gridView - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getSize ( ) ; <nl> + gridView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - gridView - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - gridView - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + gridView - > addEventListenerScrollView ( this , scrollvieweventselector ( UIGridViewTest_Mode_Column : : selectedChildEvent ) ) ; <nl> + _uiLayer - > addChild ( gridView ) ; <nl> + <nl> + <nl> + / / create items <nl> + int count = 19 ; <nl> + for ( int i = 0 ; i < count ; + + i ) <nl> + { <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button - > setScale9Enabled ( true ) ; <nl> + AffineTransform transform = AffineTransformMakeIdentity ( ) ; <nl> + transform = AffineTransformScale ( transform , 3 . 0f , 1 . 3f ) ; <nl> + button - > setSize ( SizeApplyAffineTransform ( button - > getContentSize ( ) , transform ) ) ; <nl> + button - > setTitleText ( String : : createWithFormat ( " grid_ % d " , i ) - > getCString ( ) ) ; <nl> + <nl> + Layout * item = Layout : : create ( ) ; <nl> + item - > setTouchEnabled ( true ) ; <nl> + item - > setSize ( button - > getSize ( ) ) ; <nl> + button - > setPosition ( Point ( item - > getSize ( ) . width / 2 . 0f , item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + item - > addChild ( button ) ; <nl> + <nl> + gridView - > addChild ( item ) ; <nl> + } <nl> + <nl> + / / set grid view row and column <nl> + Widget * item = static_cast < Widget * > ( gridView - > getChildren ( ) . at ( 0 ) ) ; <nl> + int rowCount = gridView - > getSize ( ) . height / item - > getSize ( ) . height ; <nl> + int columnCount = gridView - > getSize ( ) . width / item - > getSize ( ) . width ; <nl> + gridView - > setGridLayoutRowAndColumnCount ( rowCount , columnCount ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + void UIGridViewTest_Mode_Column : : selectedChildEvent ( Object * pSender , ScrollviewEventType type ) <nl> + { <nl> + switch ( type ) <nl> + { <nl> + case SCROLLVIEW_EVENT_SELECT_CHILD : <nl> + { <nl> + GridView * gridView = static_cast < GridView * > ( pSender ) ; <nl> + CCLOG ( " select child index = % d " , gridView - > getSelectedChildIndex ( ) ) ; <nl> + } <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / / UIGridViewTest_Mode_Row <nl> + <nl> + UIGridViewTest_Mode_Row : : UIGridViewTest_Mode_Row ( ) <nl> + { <nl> + } <nl> + <nl> + UIGridViewTest_Mode_Row : : ~ UIGridViewTest_Mode_Row ( ) <nl> + { <nl> + } <nl> + <nl> + bool UIGridViewTest_Mode_Row : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the scrollview alert will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move by horizontal direction " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout is in use with GridView bases on row mode " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the scroll grid with grid layout mode row <nl> + GridView * gridView = GridView : : create ( ) ; <nl> + gridView - > setLayoutType ( LAYOUT_GRID_MODE_ROW ) ; <nl> + gridView - > setScrollEnabled ( true ) ; <nl> + gridView - > setDirection ( SCROLLVIEW_DIR_HORIZONTAL ) ; <nl> + gridView - > setBounceEnabled ( true ) ; <nl> + gridView - > setTouchEnabled ( true ) ; <nl> + gridView - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getSize ( ) ; <nl> + gridView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - gridView - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - gridView - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + gridView - > addEventListenerScrollView ( this , scrollvieweventselector ( UIGridViewTest_Mode_Row : : selectedChildEvent ) ) ; <nl> + _uiLayer - > addChild ( gridView ) ; <nl> + <nl> + <nl> + / / create items <nl> + int count = 19 ; <nl> + for ( int i = 0 ; i < count ; + + i ) <nl> + { <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button - > setScale9Enabled ( true ) ; <nl> + AffineTransform transform = AffineTransformMakeIdentity ( ) ; <nl> + transform = AffineTransformScale ( transform , 3 . 0f , 1 . 3f ) ; <nl> + button - > setSize ( SizeApplyAffineTransform ( button - > getContentSize ( ) , transform ) ) ; <nl> + button - > setTitleText ( String : : createWithFormat ( " grid_ % d " , i ) - > getCString ( ) ) ; <nl> + <nl> + Layout * item = Layout : : create ( ) ; <nl> + item - > setTouchEnabled ( true ) ; <nl> + item - > setSize ( button - > getSize ( ) ) ; <nl> + button - > setPosition ( Point ( item - > getSize ( ) . width / 2 . 0f , item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + item - > addChild ( button ) ; <nl> + <nl> + gridView - > addChild ( item ) ; <nl> + } <nl> + <nl> + / / set grid view row and column <nl> + Widget * item = static_cast < Widget * > ( gridView - > getChildren ( ) . at ( 0 ) ) ; <nl> + int rowCount = gridView - > getSize ( ) . height / item - > getSize ( ) . height ; <nl> + int columnCount = gridView - > getSize ( ) . width / item - > getSize ( ) . width ; <nl> + gridView - > setGridLayoutRowAndColumnCount ( rowCount , columnCount ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + void UIGridViewTest_Mode_Row : : selectedChildEvent ( Object * pSender , ScrollviewEventType type ) <nl> + { <nl> + switch ( type ) <nl> + { <nl> + case SCROLLVIEW_EVENT_SELECT_CHILD : <nl> + { <nl> + GridView * gridView = static_cast < GridView * > ( pSender ) ; <nl> + CCLOG ( " select child index = % d " , gridView - > getSelectedChildIndex ( ) ) ; <nl> + } <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> similarity index 67 % <nl> rename from samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIDragPanelTest / UIDragPanelTest . h <nl> rename to samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIGridViewTest / UIGridViewTest . h <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIDragPanelTest / UIDragPanelTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIGridViewTest / UIGridViewTest . h <nl> <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # ifndef __TestCpp__UIDragPanelTest__ <nl> - # define __TestCpp__UIDragPanelTest__ <nl> + # ifndef __TestCpp__UIGridViewTest__ <nl> + # define __TestCpp__UIGridViewTest__ <nl> <nl> # include " . . / UIScene . h " <nl> <nl> - class UIDragPanelTest : public UIScene <nl> + class UIGridViewTest_Mode_Column : public UIScene <nl> { <nl> public : <nl> - UIDragPanelTest ( ) ; <nl> - ~ UIDragPanelTest ( ) ; <nl> + UIGridViewTest_Mode_Column ( ) ; <nl> + ~ UIGridViewTest_Mode_Column ( ) ; <nl> bool init ( ) ; <nl> + void selectedChildEvent ( Object * pSender , ScrollviewEventType type ) ; <nl> <nl> protected : <nl> - UI_SCENE_CREATE_FUNC ( UIDragPanelTest ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + UI_SCENE_CREATE_FUNC ( UIGridViewTest_Mode_Column ) <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> - class UIDragPanelTest_Bounce : public UIScene <nl> + class UIGridViewTest_Mode_Row : public UIScene <nl> { <nl> public : <nl> - UIDragPanelTest_Bounce ( ) ; <nl> - ~ UIDragPanelTest_Bounce ( ) ; <nl> + UIGridViewTest_Mode_Row ( ) ; <nl> + ~ UIGridViewTest_Mode_Row ( ) ; <nl> bool init ( ) ; <nl> + void selectedChildEvent ( Object * pSender , ScrollviewEventType type ) ; <nl> <nl> protected : <nl> - UI_SCENE_CREATE_FUNC ( UIDragPanelTest_Bounce ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + UI_SCENE_CREATE_FUNC ( UIGridViewTest_Mode_Row ) <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> - # endif / * defined ( __TestCpp__UIDragPanelTest__ ) * / <nl> + # endif / * defined ( __TestCpp__UIGridViewTest__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIImageViewTest / UIImageViewTest . cpp <nl> <nl> <nl> # include " UIImageViewTest . h " <nl> <nl> - const char * font_UIImageViewTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UIImageViewTest <nl> <nl> bool UIImageViewTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " ImageView " ) ; <nl> - alert - > setFontName ( font_UIImageViewTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the imageview <nl> - UIImageView * imageView = UIImageView : : create ( ) ; <nl> + ImageView * imageView = ImageView : : create ( ) ; <nl> imageView - > loadTexture ( " cocosgui / ccicon . png " ) ; <nl> imageView - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + imageView - > getSize ( ) . height / 4 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( imageView ) ; <nl> + <nl> + / / imageView - > setOpacity ( 64 ) ; <nl> + _uiLayer - > addChild ( imageView ) ; <nl> + <nl> + / * <nl> + NodeRGBA * root = NodeRGBA : : create ( ) ; <nl> + root - > setCascadeOpacityEnabled ( true ) ; <nl> + NodeRGBA * render = Sprite : : create ( ) ; <nl> + static_cast < Sprite * > ( render ) - > setTexture ( " cocosgui / ccicon . png " ) ; <nl> + root - > addChild ( render ) ; <nl> + / / root - > setOpacity ( 64 ) ; <nl> + root - > setPosition ( Point ( 200 , 180 ) ) ; <nl> + _uiLayer - > addChild ( root ) ; <nl> + * / <nl> + <nl> + / * <nl> + NodeRGBA * nodergba = NodeRGBA : : create ( ) ; <nl> + Sprite * child = Sprite : : create ( ) ; <nl> + child - > setTexture ( " cocosgui / ccicon . png " ) ; <nl> + nodergba - > addChild ( child ) ; <nl> + nodergba - > setPosition ( Point ( 120 , 80 ) ) ; <nl> + nodergba - > setOpacity ( 64 ) ; <nl> + _uiLayer - > addChild ( nodergba ) ; <nl> + * / <nl> + <nl> + / * <nl> + Sprite * sprite = Sprite : : create ( ) ; <nl> + sprite - > setTexture ( " cocosgui / ccicon . png " ) ; <nl> + sprite - > setPosition ( Point ( 200 , 180 ) ) ; <nl> + / / sprite - > setOpacity ( 64 ) ; <nl> + _uiLayer - > addChild ( sprite ) ; <nl> + * / <nl> + <nl> + / / imageView - > setZOrder ( 20 ) ; <nl> <nl> return true ; <nl> } <nl> bool UIImageViewTest_Scale9 : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " ImageView scale9 render " ) ; <nl> - alert - > setFontName ( font_UIImageViewTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 26 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 125f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the imageview <nl> - UIImageView * imageView = UIImageView : : create ( ) ; <nl> + ImageView * imageView = ImageView : : create ( ) ; <nl> imageView - > setScale9Enabled ( true ) ; <nl> imageView - > loadTexture ( " cocosgui / buttonHighlighted . png " ) ; <nl> imageView - > setSize ( Size ( 200 , 85 ) ) ; <nl> imageView - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + imageView - > getSize ( ) . height / 4 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( imageView ) ; <nl> + _uiLayer - > addChild ( imageView ) ; <nl> <nl> return true ; <nl> } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILabelAtlasTest / UILabelAtlasTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILabelAtlasTest / UILabelAtlasTest . cpp <nl> <nl> <nl> # include " UILabelAtlasTest . h " <nl> <nl> - const char * font_UILabelAtlasTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UILabelAtlasTest <nl> <nl> bool UILabelAtlasTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " LabelAtlas " ) ; <nl> - alert - > setFontName ( font_UILabelAtlasTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the label atlas <nl> - UILabelAtlas * labelAtlas = UILabelAtlas : : create ( ) ; <nl> + gui : : LabelAtlas * labelAtlas = gui : : LabelAtlas : : create ( ) ; <nl> labelAtlas - > setProperty ( " 1234567890 " , " cocosgui / labelatlas . png " , 17 , 22 , " 0 " ) ; <nl> - labelAtlas - > setPosition ( Point ( ( widgetSize . width ) / 2 , widgetSize . height / 2 . 0f ) ) ; <nl> - <nl> - m_pUiLayer - > addWidget ( labelAtlas ) ; <nl> + labelAtlas - > setPosition ( Point ( ( widgetSize . width ) / 2 , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( labelAtlas ) ; <nl> <nl> return true ; <nl> } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILabelBMFontTest / UILabelBMFontTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILabelBMFontTest / UILabelBMFontTest . cpp <nl> <nl> <nl> # include " UILabelBMFontTest . h " <nl> <nl> - const char * font_UILabelBMFontTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UILabelBMFontTest <nl> <nl> bool UILabelBMFontTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " LabelBMFont " ) ; <nl> - alert - > setFontName ( font_UILabelBMFontTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the LabelBMFont <nl> - UILabelBMFont * labelBMFont = UILabelBMFont : : create ( ) ; <nl> + gui : : LabelBMFont * labelBMFont = gui : : LabelBMFont : : create ( ) ; <nl> labelBMFont - > setFntFile ( " cocosgui / bitmapFontTest2 . fnt " ) ; <nl> labelBMFont - > setText ( " BMFont " ) ; <nl> labelBMFont - > setPosition ( Point ( widgetSize . width / 2 , widgetSize . height / 2 . 0f + labelBMFont - > getSize ( ) . height / 8 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( labelBMFont ) ; <nl> + _uiLayer - > addChild ( labelBMFont ) ; <nl> <nl> return true ; <nl> } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILabelTest / UILabelTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILabelTest / UILabelTest . cpp <nl> <nl> <nl> # include " UILabelTest . h " <nl> <nl> - const char * font_UILabelTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UILabelTest <nl> <nl> bool UILabelTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " Label " ) ; <nl> - alert - > setFontName ( font_UILabelTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the label <nl> - UILabel * label = UILabel : : create ( ) ; <nl> + gui : : Label * label = gui : : Label : : create ( ) ; <nl> label - > setText ( " Label " ) ; <nl> label - > setFontName ( " AmericanTypewriter " ) ; <nl> label - > setFontSize ( 30 ) ; <nl> - label - > setPosition ( Point ( widgetSize . width / 2 , widgetSize . height / 2 + label - > getSize ( ) . height / 4 ) ) ; <nl> - m_pUiLayer - > addWidget ( label ) ; <nl> + label - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + label - > getSize ( ) . height / 4 . 0f ) ) ; <nl> + _uiLayer - > addChild ( label ) ; <nl> <nl> return true ; <nl> } <nl> return false ; <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + / / UILabelTest_LineWrap <nl> + <nl> + bool UILabelTest_LineWrap : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Label line wrap " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the line wrap <nl> + gui : : Label * label = gui : : Label : : create ( ) ; <nl> + label - > setTextAreaSize ( Size ( 280 , 150 ) ) ; <nl> + label - > setTextHorizontalAlignment ( TextHAlignment : : CENTER ) ; <nl> + label - > setText ( " Label can line wrap " ) ; <nl> + label - > setFontName ( " AmericanTypewriter " ) ; <nl> + label - > setFontSize ( 32 ) ; <nl> + label - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - label - > getSize ( ) . height / 8 . 0f ) ) ; <nl> + _uiLayer - > addChild ( label ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / * <nl> + / / UILabelTest_Effect <nl> + <nl> + bool UILabelTest_Effect : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Label Effect " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 05f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + <nl> + / / create the shadow only label <nl> + gui : : Label * shadow_label = gui : : Label : : create ( ) ; <nl> + <nl> + Color3B tintColorRed = { 255 , 0 , 0 } ; <nl> + Size shadowOffset ( 12 . 0f , 12 . 0f ) ; <nl> + <nl> + FontDefinition shadowTextDef ; <nl> + shadowTextDef . _fontSize = 20 ; <nl> + shadowTextDef . _fontName = std : : string ( " Marker Felt " ) ; <nl> + <nl> + shadowTextDef . _shadow . _shadowEnabled = true ; <nl> + shadowTextDef . _shadow . _shadowOffset = shadowOffset ; <nl> + shadowTextDef . _shadow . _shadowOpacity = 1 . 0f ; <nl> + shadowTextDef . _shadow . _shadowBlur = 1 . 0f ; <nl> + shadowTextDef . _fontFillColor = tintColorRed ; <nl> + <nl> + shadow_label - > setTextDefinition ( shadowTextDef ) ; <nl> + shadow_label - > setText ( " Shadow " ) ; <nl> + shadow_label - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + shadow_label - > getSize ( ) . height ) ) ; <nl> + <nl> + _uiLayer - > addChild ( shadow_label ) ; <nl> + <nl> + <nl> + / / create the stroke only label <nl> + gui : : Label * stroke_label = gui : : Label : : create ( ) ; <nl> + <nl> + Color3B tintColorYellow = { 255 , 255 , 0 } ; <nl> + Color3B strokeColor = { 0 , 10 , 255 } ; <nl> + <nl> + FontDefinition strokeTextDef ; <nl> + strokeTextDef . _fontSize = 20 ; <nl> + strokeTextDef . _fontName = std : : string ( " Marker Felt " ) ; <nl> + <nl> + strokeTextDef . _stroke . _strokeEnabled = true ; <nl> + strokeTextDef . _stroke . _strokeColor = strokeColor ; <nl> + strokeTextDef . _stroke . _strokeSize = 1 . 5f ; <nl> + <nl> + strokeTextDef . _fontFillColor = tintColorYellow ; <nl> + <nl> + stroke_label - > setTextDefinition ( strokeTextDef ) ; <nl> + stroke_label - > setText ( " Stroke " ) ; <nl> + stroke_label - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + <nl> + _uiLayer - > addChild ( stroke_label ) ; <nl> + <nl> + <nl> + / / create the label stroke and shadow <nl> + gui : : Label * strokeAndShadow_label = gui : : Label : : create ( ) ; <nl> + <nl> + Color3B tintColorBlue = { 0 , 0 , 255 } ; <nl> + Color3B strokeShadowColor = { 255 , 0 , 0 } ; <nl> + <nl> + FontDefinition strokeShaodwTextDef ; <nl> + strokeShaodwTextDef . _fontSize = 20 ; <nl> + strokeShaodwTextDef . _fontName = std : : string ( " Marker Felt " ) ; <nl> + <nl> + strokeShaodwTextDef . _stroke . _strokeEnabled = true ; <nl> + strokeShaodwTextDef . _stroke . _strokeColor = strokeShadowColor ; <nl> + strokeShaodwTextDef . _stroke . _strokeSize = 1 . 5f ; <nl> + <nl> + strokeShaodwTextDef . _shadow . _shadowEnabled = true ; <nl> + strokeShaodwTextDef . _shadow . _shadowOffset = shadowOffset ; <nl> + strokeShaodwTextDef . _shadow . _shadowOpacity = 1 . 0f ; <nl> + strokeShaodwTextDef . _shadow . _shadowBlur = 1 . 0f ; <nl> + <nl> + strokeShaodwTextDef . _fontFillColor = tintColorBlue ; <nl> + <nl> + strokeAndShadow_label - > setTextDefinition ( strokeShaodwTextDef ) ; <nl> + / / strokeAndShadow_label - > setFontFillColor ( tintColorRed ) ; <nl> + strokeAndShadow_label - > setText ( " Stroke and Shadow " ) ; <nl> + strokeAndShadow_label - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - shadow_label - > getSize ( ) . height ) ) ; <nl> + <nl> + _uiLayer - > addChild ( strokeAndShadow_label ) ; <nl> + <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + * / <nl> + <nl> + / / UILabelTest_TTF <nl> + <nl> + bool UILabelTest_TTF : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Label set TTF font " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the label <nl> + gui : : Label * label = gui : : Label : : create ( ) ; <nl> + label - > setText ( " Label " ) ; <nl> + label - > setFontName ( " fonts / A Damn Mess . ttf " ) ; <nl> + label - > setFontSize ( 30 ) ; <nl> + label - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + label - > getSize ( ) . height / 4 . 0f ) ) ; <nl> + _uiLayer - > addChild ( label ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILabelTest / UILabelTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILabelTest / UILabelTest . h <nl> class UILabelTest : public UIScene <nl> UI_SCENE_CREATE_FUNC ( UILabelTest ) <nl> } ; <nl> <nl> + class UILabelTest_LineWrap : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILabelTest_LineWrap ) <nl> + } ; <nl> + <nl> + / * <nl> + class UILabelTest_Effect : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILabelTest_Effect ) <nl> + } ; <nl> + * / <nl> + <nl> + class UILabelTest_TTF : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILabelTest_TTF ) <nl> + } ; <nl> + <nl> # endif / * defined ( __TestCpp__UILabelTest__ ) * / <nl> new file mode 100644 <nl> index 000000000000 . . 0463da85210f <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILayoutTest / UILayoutTest . cpp <nl> <nl> + <nl> + <nl> + # include " UILayoutTest . h " <nl> + <nl> + <nl> + / / UILayoutTest <nl> + <nl> + UILayoutTest : : UILayoutTest ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest : : ~ UILayoutTest ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + button - > setPosition ( Point ( button - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button ) ; <nl> + <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + titleButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( titleButton ) ; <nl> + <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> + button_scale9 - > setTouchEnabled ( true ) ; <nl> + button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button_scale9 - > setScale9Enabled ( true ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 . 0f , button_scale9 - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + / / UILayoutTest_Color <nl> + <nl> + UILayoutTest_Color : : UILayoutTest_Color ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_Color : : ~ UILayoutTest_Color ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_Color : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout color render " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout with color render <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> + layout - > setBackGroundColor ( Color3B ( 128 , 128 , 128 ) ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + button - > setPosition ( Point ( button - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button ) ; <nl> + <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + titleButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( titleButton ) ; <nl> + <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> + button_scale9 - > setTouchEnabled ( true ) ; <nl> + button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button_scale9 - > setScale9Enabled ( true ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 . 0f , button_scale9 - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UILayoutTest_Gradient <nl> + <nl> + UILayoutTest_Gradient : : UILayoutTest_Gradient ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_Gradient : : ~ UILayoutTest_Gradient ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_Gradient : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout gradient render " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout with gradient render <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setBackGroundColorType ( LAYOUT_COLOR_GRADIENT ) ; <nl> + layout - > setBackGroundColor ( Color3B ( 64 , 64 , 64 ) , Color3B ( 192 , 192 , 192 ) ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + button - > setPosition ( Point ( button - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button ) ; <nl> + <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + titleButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( titleButton ) ; <nl> + <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> + button_scale9 - > setTouchEnabled ( true ) ; <nl> + button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button_scale9 - > setScale9Enabled ( true ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 . 0f , button_scale9 - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UILayoutTest_BackGroundImage <nl> + <nl> + UILayoutTest_BackGroundImage : : UILayoutTest_BackGroundImage ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_BackGroundImage : : ~ UILayoutTest_BackGroundImage ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_BackGroundImage : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout background image " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout with background image <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setClippingEnabled ( true ) ; <nl> + layout - > setBackGroundImage ( " cocosgui / Hello . png " ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + button - > setPosition ( Point ( button - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button ) ; <nl> + <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + titleButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( titleButton ) ; <nl> + <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> + button_scale9 - > setTouchEnabled ( true ) ; <nl> + button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button_scale9 - > setScale9Enabled ( true ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 . 0f , button_scale9 - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UILayoutTest_BackGroundImage_Scale9 <nl> + <nl> + UILayoutTest_BackGroundImage_Scale9 : : UILayoutTest_BackGroundImage_Scale9 ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_BackGroundImage_Scale9 : : ~ UILayoutTest_BackGroundImage_Scale9 ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_BackGroundImage_Scale9 : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout background image scale9 " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout with background image <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setBackGroundImageScale9Enabled ( true ) ; <nl> + layout - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + button - > setPosition ( Point ( button - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button ) ; <nl> + <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + titleButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( titleButton ) ; <nl> + <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> + button_scale9 - > setTouchEnabled ( true ) ; <nl> + button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button_scale9 - > setScale9Enabled ( true ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 . 0f , button_scale9 - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UILayoutTest_Layout_Linear_Vertical <nl> + <nl> + UILayoutTest_Layout_Linear_Vertical : : UILayoutTest_Layout_Linear_Vertical ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_Layout_Linear_Vertical : : ~ UILayoutTest_Layout_Linear_Vertical ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_Layout_Linear_Vertical : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout Linear Vertical " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setLayoutType ( LAYOUT_LINEAR_VERTICAL ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button ) ; <nl> + <nl> + LinearLayoutParameter * lp1 = LinearLayoutParameter : : create ( ) ; <nl> + button - > setLayoutParameter ( lp1 ) ; <nl> + lp1 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> + lp1 - > setMargin ( Margin ( 0 . 0f , 5 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> + <nl> + <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + layout - > addChild ( titleButton ) ; <nl> + <nl> + LinearLayoutParameter * lp2 = LinearLayoutParameter : : create ( ) ; <nl> + titleButton - > setLayoutParameter ( lp2 ) ; <nl> + lp2 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> + lp2 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> + <nl> + <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> + button_scale9 - > setTouchEnabled ( true ) ; <nl> + button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button_scale9 - > setScale9Enabled ( true ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> + LinearLayoutParameter * lp3 = LinearLayoutParameter : : create ( ) ; <nl> + button_scale9 - > setLayoutParameter ( lp3 ) ; <nl> + lp3 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> + lp3 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> + <nl> + <nl> + / / layout - > doLayout ( ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + / / UILayoutTest_Layout_Linear_Horizontal <nl> + <nl> + UILayoutTest_Layout_Linear_Horizontal : : UILayoutTest_Layout_Linear_Horizontal ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_Layout_Linear_Horizontal : : ~ UILayoutTest_Layout_Linear_Horizontal ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_Layout_Linear_Horizontal : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout Linear Horizontal " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setLayoutType ( LAYOUT_LINEAR_HORIZONTAL ) ; <nl> + layout - > setClippingEnabled ( true ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button ) ; <nl> + <nl> + LinearLayoutParameter * lp1 = LinearLayoutParameter : : create ( ) ; <nl> + button - > setLayoutParameter ( lp1 ) ; <nl> + lp1 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> + lp1 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> + <nl> + <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + layout - > addChild ( titleButton ) ; <nl> + <nl> + LinearLayoutParameter * lp2 = LinearLayoutParameter : : create ( ) ; <nl> + titleButton - > setLayoutParameter ( lp2 ) ; <nl> + lp2 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> + lp2 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> + <nl> + <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> + button_scale9 - > setTouchEnabled ( true ) ; <nl> + button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button_scale9 - > setScale9Enabled ( true ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + layout - > addChild ( button_scale9 ) ; <nl> + <nl> + LinearLayoutParameter * lp3 = LinearLayoutParameter : : create ( ) ; <nl> + button_scale9 - > setLayoutParameter ( lp3 ) ; <nl> + lp3 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> + lp3 - > setMargin ( Margin ( 0 . 0f , 10 . 0f , 0 . 0f , 10 . 0f ) ) ; <nl> + <nl> + <nl> + / / layout - > doLayout ( ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + / / UILayoutTest_Layout_Relative_Align_Parent <nl> + <nl> + UILayoutTest_Layout_Relative_Align_Parent : : UILayoutTest_Layout_Relative_Align_Parent ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_Layout_Relative_Align_Parent : : ~ UILayoutTest_Layout_Relative_Align_Parent ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_Layout_Relative_Align_Parent : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout Relative Align Parent " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setLayoutType ( LAYOUT_RELATIVE ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + layout - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> + layout - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> + Size backgroundSize = background - > getSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + / / top left <nl> + Button * button_TopLeft = Button : : create ( ) ; <nl> + button_TopLeft - > setTouchEnabled ( true ) ; <nl> + button_TopLeft - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button_TopLeft ) ; <nl> + <nl> + RelativeLayoutParameter * rp_TopLeft = RelativeLayoutParameter : : create ( ) ; <nl> + rp_TopLeft - > setAlign ( RELATIVE_ALIGN_PARENT_TOP_LEFT ) ; <nl> + button_TopLeft - > setLayoutParameter ( rp_TopLeft ) ; <nl> + <nl> + <nl> + / / top center horizontal <nl> + Button * button_TopCenter = Button : : create ( ) ; <nl> + button_TopCenter - > setTouchEnabled ( true ) ; <nl> + button_TopCenter - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button_TopCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rp_TopCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rp_TopCenter - > setAlign ( RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL ) ; <nl> + button_TopCenter - > setLayoutParameter ( rp_TopCenter ) ; <nl> + <nl> + <nl> + / / top right <nl> + Button * button_TopRight = Button : : create ( ) ; <nl> + button_TopRight - > setTouchEnabled ( true ) ; <nl> + button_TopRight - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button_TopRight ) ; <nl> + <nl> + RelativeLayoutParameter * rp_TopRight = RelativeLayoutParameter : : create ( ) ; <nl> + rp_TopRight - > setAlign ( RELATIVE_ALIGN_PARENT_TOP_RIGHT ) ; <nl> + button_TopRight - > setLayoutParameter ( rp_TopRight ) ; <nl> + <nl> + <nl> + / / left center <nl> + Button * button_LeftCenter = Button : : create ( ) ; <nl> + button_LeftCenter - > setTouchEnabled ( true ) ; <nl> + button_LeftCenter - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button_LeftCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rp_LeftCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rp_LeftCenter - > setAlign ( RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL ) ; <nl> + button_LeftCenter - > setLayoutParameter ( rp_LeftCenter ) ; <nl> + <nl> + <nl> + / / center <nl> + Button * buttonCenter = Button : : create ( ) ; <nl> + buttonCenter - > setTouchEnabled ( true ) ; <nl> + buttonCenter - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( buttonCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rpCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rpCenter - > setAlign ( RELATIVE_CENTER_IN_PARENT ) ; <nl> + buttonCenter - > setLayoutParameter ( rpCenter ) ; <nl> + <nl> + <nl> + / / right center <nl> + Button * button_RightCenter = Button : : create ( ) ; <nl> + button_RightCenter - > setTouchEnabled ( true ) ; <nl> + button_RightCenter - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button_RightCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rp_RightCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rp_RightCenter - > setAlign ( RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL ) ; <nl> + button_RightCenter - > setLayoutParameter ( rp_RightCenter ) ; <nl> + <nl> + <nl> + / / left bottom <nl> + Button * button_LeftBottom = Button : : create ( ) ; <nl> + button_LeftBottom - > setTouchEnabled ( true ) ; <nl> + button_LeftBottom - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button_LeftBottom ) ; <nl> + <nl> + RelativeLayoutParameter * rp_LeftBottom = RelativeLayoutParameter : : create ( ) ; <nl> + rp_LeftBottom - > setAlign ( RELATIVE_ALIGN_PARENT_LEFT_BOTTOM ) ; <nl> + button_LeftBottom - > setLayoutParameter ( rp_LeftBottom ) ; <nl> + <nl> + <nl> + / / bottom center <nl> + Button * button_BottomCenter = Button : : create ( ) ; <nl> + button_BottomCenter - > setTouchEnabled ( true ) ; <nl> + button_BottomCenter - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button_BottomCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rp_BottomCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rp_BottomCenter - > setAlign ( RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL ) ; <nl> + button_BottomCenter - > setLayoutParameter ( rp_BottomCenter ) ; <nl> + <nl> + <nl> + / / right bottom <nl> + Button * button_RightBottom = Button : : create ( ) ; <nl> + button_RightBottom - > setTouchEnabled ( true ) ; <nl> + button_RightBottom - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> + layout - > addChild ( button_RightBottom ) ; <nl> + <nl> + RelativeLayoutParameter * rp_RightBottom = RelativeLayoutParameter : : create ( ) ; <nl> + rp_RightBottom - > setAlign ( RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM ) ; <nl> + button_RightBottom - > setLayoutParameter ( rp_RightBottom ) ; <nl> + <nl> + <nl> + / / layout - > doLayout ( ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + / / UILayoutTest_Layout_Relative_Location <nl> + <nl> + UILayoutTest_Layout_Relative_Location : : UILayoutTest_Layout_Relative_Location ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_Layout_Relative_Location : : ~ UILayoutTest_Layout_Relative_Location ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_Layout_Relative_Location : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout Relative Location " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setLayoutType ( LAYOUT_RELATIVE ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + / / center <nl> + ImageView * imageView_Center = ImageView : : create ( ) ; <nl> + imageView_Center - > loadTexture ( " cocosgui / scrollviewbg . png " ) ; <nl> + layout - > addChild ( imageView_Center ) ; <nl> + <nl> + RelativeLayoutParameter * rp_Center = RelativeLayoutParameter : : create ( ) ; <nl> + rp_Center - > setRelativeName ( " rp_Center " ) ; <nl> + rp_Center - > setAlign ( RELATIVE_CENTER_IN_PARENT ) ; <nl> + imageView_Center - > setLayoutParameter ( rp_Center ) ; <nl> + <nl> + <nl> + / / above center <nl> + ImageView * imageView_AboveCenter = ImageView : : create ( ) ; <nl> + imageView_AboveCenter - > loadTexture ( " cocosgui / switch - mask . png " ) ; <nl> + layout - > addChild ( imageView_AboveCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rp_AboveCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rp_AboveCenter - > setRelativeToWidgetName ( " rp_Center " ) ; <nl> + rp_AboveCenter - > setAlign ( RELATIVE_LOCATION_ABOVE_CENTER ) ; <nl> + imageView_AboveCenter - > setLayoutParameter ( rp_AboveCenter ) ; <nl> + <nl> + <nl> + / / below center <nl> + ImageView * imageView_BelowCenter = ImageView : : create ( ) ; <nl> + imageView_BelowCenter - > loadTexture ( " cocosgui / switch - mask . png " ) ; <nl> + layout - > addChild ( imageView_BelowCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rp_BelowCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rp_BelowCenter - > setRelativeToWidgetName ( " rp_Center " ) ; <nl> + rp_BelowCenter - > setAlign ( RELATIVE_LOCATION_BELOW_CENTER ) ; <nl> + imageView_BelowCenter - > setLayoutParameter ( rp_BelowCenter ) ; <nl> + <nl> + <nl> + / / left center <nl> + ImageView * imageView_LeftCenter = ImageView : : create ( ) ; <nl> + imageView_LeftCenter - > loadTexture ( " cocosgui / switch - mask . png " ) ; <nl> + layout - > addChild ( imageView_LeftCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rp_LeftCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rp_LeftCenter - > setRelativeToWidgetName ( " rp_Center " ) ; <nl> + rp_LeftCenter - > setAlign ( RELATIVE_LOCATION_LEFT_OF_CENTER ) ; <nl> + imageView_LeftCenter - > setLayoutParameter ( rp_LeftCenter ) ; <nl> + <nl> + <nl> + <nl> + / / right center <nl> + ImageView * imageView_RightCenter = ImageView : : create ( ) ; <nl> + imageView_RightCenter - > loadTexture ( " cocosgui / switch - mask . png " ) ; <nl> + layout - > addChild ( imageView_RightCenter ) ; <nl> + <nl> + RelativeLayoutParameter * rp_RightCenter = RelativeLayoutParameter : : create ( ) ; <nl> + rp_RightCenter - > setRelativeToWidgetName ( " rp_Center " ) ; <nl> + rp_RightCenter - > setAlign ( RELATIVE_LOCATION_RIGHT_OF_CENTER ) ; <nl> + imageView_RightCenter - > setLayoutParameter ( rp_RightCenter ) ; <nl> + <nl> + <nl> + / / layout - > doLayout ( ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + / * <nl> + / / UILayoutTest_Layout_Grid <nl> + <nl> + UILayoutTest_Layout_Grid : : UILayoutTest_Layout_Grid ( ) <nl> + { <nl> + } <nl> + <nl> + UILayoutTest_Layout_Grid : : ~ UILayoutTest_Layout_Grid ( ) <nl> + { <nl> + } <nl> + <nl> + bool UILayoutTest_Layout_Grid : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Layout Grid " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the layout <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setLayoutType ( LAYOUT_GRID_MODE_COLUMN ) ; <nl> + layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> + Size backgroundSize = background - > getSize ( ) ; <nl> + layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( layout ) ; <nl> + <nl> + <nl> + / / create items <nl> + for ( int i = 0 ; i < 14 ; + + i ) <nl> + { <nl> + Button * button = Button : : create ( ) ; <nl> + button - > setName ( " TextButton " ) ; <nl> + button - > setTouchEnabled ( true ) ; <nl> + button - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + button - > setScale9Enabled ( true ) ; <nl> + AffineTransform transform = AffineTransformMakeIdentity ( ) ; <nl> + transform = AffineTransformScale ( transform , 3 . 0f , 1 . 3f ) ; <nl> + button - > setSize ( SizeApplyAffineTransform ( button - > getContentSize ( ) , transform ) ) ; <nl> + button - > setTitleText ( CCString : : createWithFormat ( " grid_ % d " , i ) - > getCString ( ) ) ; <nl> + <nl> + Layout * item = Layout : : create ( ) ; <nl> + item - > setTouchEnabled ( true ) ; <nl> + item - > setSize ( button - > getSize ( ) ) ; <nl> + button - > setPosition ( Point ( item - > getSize ( ) . width / 2 . 0f , item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + item - > addChild ( button ) ; <nl> + <nl> + GridLayoutParameter * gp = GridLayoutParameter : : create ( ) ; <nl> + item - > setLayoutParameter ( gp ) ; <nl> + gp - > setMargin ( Margin ( 0 . 0f , 0 . 0f , 0 . 0f , 0 . 0f ) ) ; <nl> + <nl> + layout - > addChild ( item ) ; <nl> + } <nl> + <nl> + / / set grid view row and column <nl> + Widget * item = static_cast < Widget * > ( layout - > getChildren ( ) . at ( 0 ) ) ; <nl> + int rowCount = layout - > getSize ( ) . height / item - > getSize ( ) . height ; <nl> + int columnCount = layout - > getSize ( ) . width / item - > getSize ( ) . width ; <nl> + layout - > setGridLayoutRowAndColumnCount ( rowCount , columnCount ) ; <nl> + <nl> + / / layout - > doLayout ( ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + * / <nl> + <nl> new file mode 100644 <nl> index 000000000000 . . 811192d55af7 <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILayoutTest / UILayoutTest . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2013 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all 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 , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # ifndef __TestCpp__UILayoutTest__ <nl> + # define __TestCpp__UILayoutTest__ <nl> + <nl> + # include " . . / UIScene . h " <nl> + <nl> + class UILayoutTest : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest ( ) ; <nl> + ~ UILayoutTest ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest ) <nl> + } ; <nl> + <nl> + class UILayoutTest_Color : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_Color ( ) ; <nl> + ~ UILayoutTest_Color ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_Color ) <nl> + } ; <nl> + <nl> + class UILayoutTest_Gradient : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_Gradient ( ) ; <nl> + ~ UILayoutTest_Gradient ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_Gradient ) <nl> + } ; <nl> + <nl> + class UILayoutTest_BackGroundImage : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_BackGroundImage ( ) ; <nl> + ~ UILayoutTest_BackGroundImage ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_BackGroundImage ) <nl> + } ; <nl> + <nl> + class UILayoutTest_BackGroundImage_Scale9 : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_BackGroundImage_Scale9 ( ) ; <nl> + ~ UILayoutTest_BackGroundImage_Scale9 ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_BackGroundImage_Scale9 ) <nl> + } ; <nl> + <nl> + class UILayoutTest_Layout_Linear_Vertical : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_Layout_Linear_Vertical ( ) ; <nl> + ~ UILayoutTest_Layout_Linear_Vertical ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_Layout_Linear_Vertical ) <nl> + } ; <nl> + <nl> + class UILayoutTest_Layout_Linear_Horizontal : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_Layout_Linear_Horizontal ( ) ; <nl> + ~ UILayoutTest_Layout_Linear_Horizontal ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_Layout_Linear_Horizontal ) <nl> + } ; <nl> + <nl> + class UILayoutTest_Layout_Relative_Align_Parent : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_Layout_Relative_Align_Parent ( ) ; <nl> + ~ UILayoutTest_Layout_Relative_Align_Parent ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_Layout_Relative_Align_Parent ) <nl> + } ; <nl> + <nl> + class UILayoutTest_Layout_Relative_Location : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_Layout_Relative_Location ( ) ; <nl> + ~ UILayoutTest_Layout_Relative_Location ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_Layout_Relative_Location ) <nl> + } ; <nl> + <nl> + / * <nl> + class UILayoutTest_Layout_Grid : public UIScene <nl> + { <nl> + public : <nl> + UILayoutTest_Layout_Grid ( ) ; <nl> + ~ UILayoutTest_Layout_Grid ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UILayoutTest_Layout_Grid ) <nl> + } ; <nl> + * / <nl> + <nl> + # endif / * defined ( __TestCpp__UILayoutTest__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIListViewTest / UIListViewTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIListViewTest / UIListViewTest . cpp <nl> const char * font_UIListViewTest = <nl> / / UIListViewTest_Vertical <nl> <nl> UIListViewTest_Vertical : : UIListViewTest_Vertical ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> - , m_nCount ( 0 ) <nl> - , m_array ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> + , _array ( nullptr ) <nl> { <nl> + <nl> } <nl> <nl> UIListViewTest_Vertical : : ~ UIListViewTest_Vertical ( ) <nl> - { <nl> + { <nl> + CC_SAFE_RELEASE ( _array ) ; <nl> } <nl> <nl> bool UIListViewTest_Vertical : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add a label in which the button events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " Move by vertical direction " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIListViewTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> - <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " ListView " ) ; <nl> - alert - > setFontName ( font_UIListViewTest ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move by vertical direction " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getContentSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " ListView vertical " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> <nl> - UIListView * lv = UIListView : : create ( ) ; <nl> - UIButton * model = UIButton : : create ( ) ; <nl> - model - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - lv - > setItemModel ( model ) ; <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> <nl> - for ( int i = 0 ; i < 20 ; i + + ) <nl> + <nl> + / / create list view ex data <nl> + _array = Array : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _array ) ; <nl> + for ( int i = 0 ; i < 20 ; + + i ) <nl> { <nl> - lv - > pushBackDefaultItem ( ) ; <nl> + String * ccstr = String : : createWithFormat ( " listview_item_ % d " , i ) ; <nl> + _array - > addObject ( ccstr ) ; <nl> } <nl> - lv - > setItemsMargin ( 10 ) ; <nl> - lv - > setGravity ( LISTVIEW_GRAVITY_CENTER_HORIZONTAL ) ; <nl> - lv - > setSize ( Size ( 100 , 100 ) ) ; <nl> - lv - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> - lv - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> - lv - > setPosition ( Point ( 100 , 100 ) ) ; <nl> - m_pUiLayer - > addWidget ( lv ) ; <nl> + <nl> + <nl> + / / Create the list view ex <nl> + ListView * listView = ListView : : create ( ) ; <nl> + / / set list view ex direction <nl> + listView - > setDirection ( SCROLLVIEW_DIR_VERTICAL ) ; <nl> + listView - > setTouchEnabled ( true ) ; <nl> + listView - > setBounceEnabled ( true ) ; <nl> + listView - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> + listView - > setBackGroundImageScale9Enabled ( true ) ; <nl> + listView - > setSize ( Size ( 240 , 130 ) ) ; <nl> + listView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - listView - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - listView - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + listView - > addEventListenerScrollView ( this , scrollvieweventselector ( UIListViewTest_Vertical : : selectedItemEvent ) ) ; <nl> + _uiLayer - > addChild ( listView ) ; <nl> + <nl> + <nl> + / / create model <nl> + Button * default_button = Button : : create ( ) ; <nl> + default_button - > setName ( " Title Button " ) ; <nl> + default_button - > setTouchEnabled ( true ) ; <nl> + default_button - > loadTextures ( " cocosgui / backtotoppressed . png " , " cocosgui / backtotopnormal . png " , " " ) ; <nl> + <nl> + Layout * default_item = Layout : : create ( ) ; <nl> + default_item - > setTouchEnabled ( true ) ; <nl> + default_item - > setSize ( default_button - > getSize ( ) ) ; <nl> + default_button - > setPosition ( Point ( default_item - > getSize ( ) . width / 2 . 0f , default_item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + default_item - > addChild ( default_button ) ; <nl> + <nl> + / / set model <nl> + listView - > setItemModel ( default_item ) ; <nl> + <nl> + / / add default item <nl> + int count = _array - > count ( ) ; <nl> + for ( int i = 0 ; i < count / 4 ; + + i ) <nl> + { <nl> + listView - > pushBackDefaultItem ( ) ; <nl> + } <nl> + / / insert default item <nl> + for ( int i = 0 ; i < count / 4 ; + + i ) <nl> + { <nl> + listView - > insertDefaultItem ( 0 ) ; <nl> + } <nl> + <nl> + / / add custom item <nl> + for ( int i = 0 ; i < count / 4 ; + + i ) <nl> + { <nl> + Button * custom_button = Button : : create ( ) ; <nl> + custom_button - > setName ( " Title Button " ) ; <nl> + custom_button - > setTouchEnabled ( true ) ; <nl> + custom_button - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + custom_button - > setScale9Enabled ( true ) ; <nl> + custom_button - > setSize ( default_button - > getSize ( ) ) ; <nl> + <nl> + Layout * custom_item = Layout : : create ( ) ; <nl> + custom_item - > setSize ( custom_button - > getSize ( ) ) ; <nl> + custom_button - > setPosition ( Point ( custom_item - > getSize ( ) . width / 2 . 0f , custom_item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + custom_item - > addChild ( custom_button ) ; <nl> + <nl> + listView - > pushBackCustomItem ( custom_item ) ; <nl> + } <nl> + / / insert custom item <nl> + Vector < Widget * > & items = listView - > getItems ( ) ; <nl> + int items_count = items . size ( ) ; <nl> + for ( int i = 0 ; i < count / 4 ; + + i ) <nl> + { <nl> + Button * custom_button = Button : : create ( ) ; <nl> + custom_button - > setName ( " Title Button " ) ; <nl> + custom_button - > setTouchEnabled ( true ) ; <nl> + custom_button - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + custom_button - > setScale9Enabled ( true ) ; <nl> + custom_button - > setSize ( default_button - > getSize ( ) ) ; <nl> + <nl> + Layout * custom_item = Layout : : create ( ) ; <nl> + custom_item - > setSize ( custom_button - > getSize ( ) ) ; <nl> + custom_button - > setPosition ( Point ( custom_item - > getSize ( ) . width / 2 . 0f , custom_item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + custom_item - > addChild ( custom_button ) ; <nl> + <nl> + listView - > insertCustomItem ( custom_item , items_count ) ; <nl> + } <nl> + <nl> + / / set item data <nl> + items_count = items . size ( ) ; <nl> + for ( int i = 0 ; i < items_count ; + + i ) <nl> + { <nl> + Widget * item = listView - > getItem ( i ) ; <nl> + Button * button = static_cast < Button * > ( item - > getChildByName ( " Title Button " ) ) ; <nl> + int index = listView - > getIndex ( item ) ; <nl> + button - > setTitleText ( static_cast < String * > ( _array - > getObjectAtIndex ( index ) ) - > getCString ( ) ) ; <nl> + } <nl> + <nl> + / / remove last item <nl> + listView - > removeLastItem ( ) ; <nl> + <nl> + / / remove item by index <nl> + items_count = items . size ( ) ; <nl> + listView - > removeItem ( items_count - 1 ) ; <nl> + <nl> + / / set all items layout gravity <nl> + listView - > setGravity ( LISTVIEW_GRAVITY_CENTER_VERTICAL ) ; <nl> + <nl> + / / set items margin <nl> + listView - > setItemsMargin ( 2 . 0f ) ; <nl> <nl> return true ; <nl> } <nl> bool UIListViewTest_Vertical : : init ( ) <nl> return false ; <nl> } <nl> <nl> + void UIListViewTest_Vertical : : selectedItemEvent ( Object * pSender , ScrollviewEventType type ) <nl> + { <nl> + / * <nl> + switch ( type ) <nl> + { <nl> + case SCROLLVIEW_EVENT_SELECT_CHILD : <nl> + { <nl> + ListView * listView = static_cast < ListView * > ( pSender ) ; <nl> + CCLOG ( " select child index = % d " , listView - > getSelectedChildIndex ( ) ) ; <nl> + } <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + * / <nl> + } <nl> + <nl> / / UIListViewTest_Horizontal <nl> <nl> UIListViewTest_Horizontal : : UIListViewTest_Horizontal ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> - , m_nCount ( 0 ) <nl> - , m_array ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> + , _array ( nullptr ) <nl> { <nl> } <nl> <nl> UIListViewTest_Horizontal : : ~ UIListViewTest_Horizontal ( ) <nl> { <nl> + CC_SAFE_RELEASE ( _array ) ; <nl> } <nl> <nl> bool UIListViewTest_Horizontal : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add a label in which the button events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " Move by vertical direction " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIListViewTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> - <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " ListView " ) ; <nl> - alert - > setFontName ( font_UIListViewTest ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move by horizontal direction " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getContentSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " ListView horizontal " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> - <nl> - UIListView * lv = UIListView : : create ( ) ; <nl> - lv - > setDirection ( SCROLLVIEW_DIR_HORIZONTAL ) ; <nl> - UIButton * model = UIButton : : create ( ) ; <nl> - model - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - lv - > setItemModel ( model ) ; <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + <nl> + <nl> + / / create list view ex data <nl> + _array = Array : : create ( ) ; <nl> + CC_SAFE_RETAIN ( _array ) ; <nl> + for ( int i = 0 ; i < 20 ; + + i ) <nl> + { <nl> + String * ccstr = String : : createWithFormat ( " listview_item_ % d " , i ) ; <nl> + _array - > addObject ( ccstr ) ; <nl> + } <nl> + <nl> + <nl> + / / Create the list view ex <nl> + ListView * listView = ListView : : create ( ) ; <nl> + / / set list view ex direction <nl> + listView - > setDirection ( SCROLLVIEW_DIR_HORIZONTAL ) ; <nl> + listView - > setTouchEnabled ( true ) ; <nl> + listView - > setBounceEnabled ( true ) ; <nl> + listView - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> + listView - > setBackGroundImageScale9Enabled ( true ) ; <nl> + listView - > setSize ( Size ( 240 , 130 ) ) ; <nl> + listView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - listView - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - listView - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + listView - > addEventListenerScrollView ( this , scrollvieweventselector ( UIListViewTest_Horizontal : : selectedItemEvent ) ) ; <nl> + _uiLayer - > addChild ( listView ) ; <nl> + <nl> + <nl> + / / create model <nl> + Button * default_button = Button : : create ( ) ; <nl> + default_button - > setName ( " Title Button " ) ; <nl> + default_button - > setTouchEnabled ( true ) ; <nl> + default_button - > loadTextures ( " cocosgui / backtotoppressed . png " , " cocosgui / backtotopnormal . png " , " " ) ; <nl> + <nl> + Layout * default_item = Layout : : create ( ) ; <nl> + default_item - > setTouchEnabled ( true ) ; <nl> + default_item - > setSize ( default_button - > getSize ( ) ) ; <nl> + default_button - > setPosition ( Point ( default_item - > getSize ( ) . width / 2 . 0f , default_item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + default_item - > addChild ( default_button ) ; <nl> + <nl> + / / set model <nl> + listView - > setItemModel ( default_item ) ; <nl> + <nl> + / / add default item <nl> + int count = _array - > count ( ) ; <nl> + for ( int i = 0 ; i < count / 4 ; + + i ) <nl> + { <nl> + listView - > pushBackDefaultItem ( ) ; <nl> + } <nl> + / / insert default item <nl> + for ( int i = 0 ; i < count / 4 ; + + i ) <nl> + { <nl> + listView - > insertDefaultItem ( 0 ) ; <nl> + } <nl> <nl> - for ( int i = 0 ; i < 20 ; i + + ) <nl> + / / add custom item <nl> + for ( int i = 0 ; i < count / 4 ; + + i ) <nl> { <nl> - lv - > pushBackDefaultItem ( ) ; <nl> + Button * custom_button = Button : : create ( ) ; <nl> + custom_button - > setName ( " Title Button " ) ; <nl> + custom_button - > setTouchEnabled ( true ) ; <nl> + custom_button - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + custom_button - > setScale9Enabled ( true ) ; <nl> + custom_button - > setSize ( default_button - > getSize ( ) ) ; <nl> + <nl> + Layout * custom_item = Layout : : create ( ) ; <nl> + custom_item - > setSize ( custom_button - > getSize ( ) ) ; <nl> + custom_button - > setPosition ( Point ( custom_item - > getSize ( ) . width / 2 . 0f , custom_item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + custom_item - > addChild ( custom_button ) ; <nl> + <nl> + listView - > pushBackCustomItem ( custom_item ) ; <nl> } <nl> - lv - > setItemsMargin ( 10 ) ; <nl> - lv - > setGravity ( LISTVIEW_GRAVITY_CENTER_VERTICAL ) ; <nl> - lv - > setSize ( Size ( 100 , 100 ) ) ; <nl> - lv - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> - lv - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> - lv - > setPosition ( Point ( 100 , 100 ) ) ; <nl> - m_pUiLayer - > addWidget ( lv ) ; <nl> + / / insert custom item <nl> + Vector < Widget * > & items = listView - > getItems ( ) ; <nl> + int items_count = items . size ( ) ; <nl> + for ( int i = 0 ; i < count / 4 ; + + i ) <nl> + { <nl> + Button * custom_button = Button : : create ( ) ; <nl> + custom_button - > setName ( " Title Button " ) ; <nl> + custom_button - > setTouchEnabled ( true ) ; <nl> + custom_button - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> + custom_button - > setScale9Enabled ( true ) ; <nl> + custom_button - > setSize ( default_button - > getSize ( ) ) ; <nl> + <nl> + Layout * custom_item = Layout : : create ( ) ; <nl> + custom_item - > setSize ( custom_button - > getSize ( ) ) ; <nl> + custom_button - > setPosition ( Point ( custom_item - > getSize ( ) . width / 2 . 0f , custom_item - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + custom_item - > addChild ( custom_button ) ; <nl> + <nl> + listView - > insertCustomItem ( custom_item , items_count ) ; <nl> + } <nl> + <nl> + / / set item data <nl> + items_count = items . size ( ) ; <nl> + for ( int i = 0 ; i < items_count ; + + i ) <nl> + { <nl> + Widget * item = listView - > getItem ( i ) ; <nl> + Button * button = static_cast < Button * > ( item - > getChildByName ( " Title Button " ) ) ; <nl> + int index = listView - > getIndex ( item ) ; <nl> + button - > setTitleText ( static_cast < String * > ( _array - > getObjectAtIndex ( index ) ) - > getCString ( ) ) ; <nl> + } <nl> + <nl> + / / remove last item <nl> + listView - > removeLastItem ( ) ; <nl> + <nl> + / / remove item by index <nl> + items_count = items . size ( ) ; <nl> + listView - > removeItem ( items_count - 1 ) ; <nl> + <nl> + / / set all items layout gravity <nl> + listView - > setGravity ( LISTVIEW_GRAVITY_CENTER_VERTICAL ) ; <nl> + <nl> + / / set items margin <nl> + listView - > setItemsMargin ( 2 ) ; <nl> + <nl> return true ; <nl> } <nl> <nl> return false ; <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + void UIListViewTest_Horizontal : : selectedItemEvent ( Object * pSender , ScrollviewEventType type ) <nl> + { <nl> + / * <nl> + switch ( type ) <nl> + { <nl> + case SCROLLVIEW_EVENT_SELECT_CHILD : <nl> + { <nl> + ListView * listView = static_cast < ListView * > ( pSender ) ; <nl> + CCLOG ( " select child index = % d " , listView - > getSelectedChildIndex ( ) ) ; <nl> + } <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + * / <nl> + } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIListViewTest / UIListViewTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIListViewTest / UIListViewTest . h <nl> class UIListViewTest_Vertical : public UIScene <nl> UIListViewTest_Vertical ( ) ; <nl> ~ UIListViewTest_Vertical ( ) ; <nl> bool init ( ) ; <nl> + void selectedItemEvent ( Object * pSender , ScrollviewEventType type ) ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIListViewTest_Vertical ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> <nl> - int m_nCount ; <nl> - Array * m_array ; <nl> + __Array * _array ; <nl> } ; <nl> <nl> class UIListViewTest_Horizontal : public UIScene <nl> class UIListViewTest_Horizontal : public UIScene <nl> UIListViewTest_Horizontal ( ) ; <nl> ~ UIListViewTest_Horizontal ( ) ; <nl> bool init ( ) ; <nl> + void selectedItemEvent ( Object * pSender , ScrollviewEventType type ) ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIListViewTest_Horizontal ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> <nl> - int m_nCount ; <nl> - Array * m_array ; <nl> + __Array * _array ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UIListViewTest__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest . cpp <nl> <nl> <nl> # include " UILoadingBarTest . h " <nl> <nl> - const char * font_UILoadingBarTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UILoadingBarTest_Left <nl> <nl> UILoadingBarTest_Left : : UILoadingBarTest_Left ( ) <nl> - : m_nCount ( 0 ) <nl> + : _count ( 0 ) <nl> { <nl> <nl> } <nl> bool UILoadingBarTest_Left : : init ( ) <nl> { <nl> scheduleUpdate ( ) ; <nl> <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " LoadingBar " ) ; <nl> - alert - > setFontName ( font_UILoadingBarTest ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " LoadingBar left " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the loading bar <nl> - UILoadingBar * loadingBar = UILoadingBar : : create ( ) ; <nl> - loadingBar - > setName ( " LoadingBar " ) ; <nl> + LoadingBar * loadingBar = LoadingBar : : create ( ) ; <nl> + loadingBar - > setTag ( 0 ) ; <nl> loadingBar - > loadTexture ( " cocosgui / sliderProgress . png " ) ; <nl> loadingBar - > setPercent ( 0 ) ; <nl> <nl> loadingBar - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + loadingBar - > getSize ( ) . height / 4 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( loadingBar ) ; <nl> + _uiLayer - > addChild ( loadingBar ) ; <nl> <nl> return true ; <nl> } <nl> bool UILoadingBarTest_Left : : init ( ) <nl> <nl> void UILoadingBarTest_Left : : update ( float delta ) <nl> { <nl> - m_nCount + + ; <nl> - if ( m_nCount > 100 ) <nl> + _count + + ; <nl> + if ( _count > 100 ) <nl> { <nl> - m_nCount = 0 ; <nl> + _count = 0 ; <nl> } <nl> - <nl> - UILoadingBar * loadingBar = dynamic_cast < UILoadingBar * > ( m_pUiLayer - > getWidgetByName ( " LoadingBar " ) ) ; <nl> - loadingBar - > setPercent ( m_nCount ) ; <nl> + LoadingBar * loadingBar = static_cast < LoadingBar * > ( _uiLayer - > getChildByTag ( 0 ) ) ; <nl> + loadingBar - > setPercent ( _count ) ; <nl> } <nl> <nl> void UILoadingBarTest_Left : : previousCallback ( Object * sender , TouchEventType type ) <nl> void UILoadingBarTest_Left : : nextCallback ( Object * sender , TouchEventType type ) <nl> / / UILoadingBarTest_Right <nl> <nl> UILoadingBarTest_Right : : UILoadingBarTest_Right ( ) <nl> - : m_nCount ( 0 ) <nl> + : _count ( 0 ) <nl> { <nl> <nl> } <nl> bool UILoadingBarTest_Right : : init ( ) <nl> { <nl> scheduleUpdate ( ) ; <nl> <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " LoadingBar " ) ; <nl> - alert - > setFontName ( font_UILoadingBarTest ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " LoadingBar right " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the loading bar <nl> - UILoadingBar * loadingBar = UILoadingBar : : create ( ) ; <nl> - loadingBar - > setName ( " LoadingBar " ) ; <nl> + LoadingBar * loadingBar = LoadingBar : : create ( ) ; <nl> + loadingBar - > setTag ( 0 ) ; <nl> loadingBar - > loadTexture ( " cocosgui / sliderProgress . png " ) ; <nl> loadingBar - > setDirection ( LoadingBarTypeRight ) ; <nl> loadingBar - > setPercent ( 0 ) ; <nl> <nl> loadingBar - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + loadingBar - > getSize ( ) . height / 4 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( loadingBar ) ; <nl> + _uiLayer - > addChild ( loadingBar ) ; <nl> <nl> return true ; <nl> } <nl> bool UILoadingBarTest_Right : : init ( ) <nl> <nl> void UILoadingBarTest_Right : : update ( float delta ) <nl> { <nl> - m_nCount + + ; <nl> - if ( m_nCount > 100 ) <nl> + _count + + ; <nl> + if ( _count > 100 ) <nl> { <nl> - m_nCount = 0 ; <nl> + _count = 0 ; <nl> } <nl> - <nl> - UILoadingBar * loadingBar = dynamic_cast < UILoadingBar * > ( m_pUiLayer - > getWidgetByName ( " LoadingBar " ) ) ; <nl> - loadingBar - > setPercent ( m_nCount ) ; <nl> + LoadingBar * loadingBar = static_cast < LoadingBar * > ( _uiLayer - > getChildByTag ( 0 ) ) ; <nl> + loadingBar - > setPercent ( _count ) ; <nl> } <nl> <nl> void UILoadingBarTest_Right : : previousCallback ( Object * sender , TouchEventType type ) <nl> void UILoadingBarTest_Right : : nextCallback ( Object * sender , TouchEventType type ) <nl> / / UILoadingBarTest_Left_Scale9 <nl> <nl> UILoadingBarTest_Left_Scale9 : : UILoadingBarTest_Left_Scale9 ( ) <nl> - : m_nCount ( 0 ) <nl> + : _count ( 0 ) <nl> { <nl> <nl> } <nl> bool UILoadingBarTest_Left_Scale9 : : init ( ) <nl> { <nl> scheduleUpdate ( ) ; <nl> <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " LoadingBar Scale9 Render " ) ; <nl> - alert - > setFontName ( font_UILoadingBarTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " LoadingBar left scale9 render " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 7f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the loading bar <nl> - UILoadingBar * loadingBar = UILoadingBar : : create ( ) ; <nl> - loadingBar - > setName ( " LoadingBar " ) ; <nl> + LoadingBar * loadingBar = LoadingBar : : create ( ) ; <nl> + loadingBar - > setTag ( 0 ) ; <nl> loadingBar - > loadTexture ( " cocosgui / slider_bar_active_9patch . png " ) ; <nl> loadingBar - > setScale9Enabled ( true ) ; <nl> loadingBar - > setCapInsets ( Rect ( 0 , 0 , 0 , 0 ) ) ; <nl> - loadingBar - > setSize ( Size ( 300 , 30 ) ) ; <nl> + loadingBar - > setSize ( Size ( 300 , loadingBar - > getContentSize ( ) . height ) ) ; <nl> loadingBar - > setPercent ( 0 ) ; <nl> <nl> loadingBar - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + loadingBar - > getSize ( ) . height / 4 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( loadingBar ) ; <nl> + _uiLayer - > addChild ( loadingBar ) ; <nl> <nl> return true ; <nl> } <nl> bool UILoadingBarTest_Left_Scale9 : : init ( ) <nl> <nl> void UILoadingBarTest_Left_Scale9 : : update ( float delta ) <nl> { <nl> - m_nCount + + ; <nl> - if ( m_nCount > 100 ) <nl> + _count + + ; <nl> + if ( _count > 100 ) <nl> { <nl> - m_nCount = 0 ; <nl> + _count = 0 ; <nl> } <nl> - <nl> - UILoadingBar * loadingBar = dynamic_cast < UILoadingBar * > ( m_pUiLayer - > getWidgetByName ( " LoadingBar " ) ) ; <nl> - loadingBar - > setPercent ( m_nCount ) ; <nl> + LoadingBar * loadingBar = static_cast < LoadingBar * > ( _uiLayer - > getChildByTag ( 0 ) ) ; <nl> + loadingBar - > setPercent ( _count ) ; <nl> } <nl> <nl> void UILoadingBarTest_Left_Scale9 : : previousCallback ( Object * sender , TouchEventType type ) <nl> void UILoadingBarTest_Left_Scale9 : : nextCallback ( Object * sender , TouchEventType t <nl> / / UILoadingBarTest_Right_Scale9 <nl> <nl> UILoadingBarTest_Right_Scale9 : : UILoadingBarTest_Right_Scale9 ( ) <nl> - : m_nCount ( 0 ) <nl> + : _count ( 0 ) <nl> { <nl> <nl> } <nl> bool UILoadingBarTest_Right_Scale9 : : init ( ) <nl> { <nl> scheduleUpdate ( ) ; <nl> <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " LoadingBar Scale9 Render " ) ; <nl> - alert - > setFontName ( font_UILoadingBarTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " LoadingBar right scale9 render " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 7f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the loading bar <nl> - UILoadingBar * loadingBar = UILoadingBar : : create ( ) ; <nl> - loadingBar - > setName ( " LoadingBar " ) ; <nl> + LoadingBar * loadingBar = LoadingBar : : create ( ) ; <nl> + loadingBar - > setTag ( 0 ) ; <nl> loadingBar - > loadTexture ( " cocosgui / slider_bar_active_9patch . png " ) ; <nl> loadingBar - > setScale9Enabled ( true ) ; <nl> loadingBar - > setCapInsets ( Rect ( 0 , 0 , 0 , 0 ) ) ; <nl> - loadingBar - > setSize ( Size ( 300 , 30 ) ) ; <nl> + loadingBar - > setSize ( Size ( 300 , loadingBar - > getContentSize ( ) . height ) ) ; <nl> loadingBar - > setDirection ( LoadingBarTypeRight ) ; <nl> loadingBar - > setPercent ( 0 ) ; <nl> <nl> loadingBar - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + loadingBar - > getSize ( ) . height / 4 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( loadingBar ) ; <nl> + _uiLayer - > addChild ( loadingBar ) ; <nl> <nl> return true ; <nl> } <nl> bool UILoadingBarTest_Right_Scale9 : : init ( ) <nl> <nl> void UILoadingBarTest_Right_Scale9 : : update ( float delta ) <nl> { <nl> - m_nCount + + ; <nl> - if ( m_nCount > 100 ) <nl> + _count + + ; <nl> + if ( _count > 100 ) <nl> { <nl> - m_nCount = 0 ; <nl> + _count = 0 ; <nl> } <nl> - CCLOG ( " wocao " ) ; <nl> - UILoadingBar * loadingBar = dynamic_cast < UILoadingBar * > ( m_pUiLayer - > getWidgetByName ( " LoadingBar " ) ) ; <nl> - loadingBar - > setPercent ( m_nCount ) ; <nl> + LoadingBar * loadingBar = static_cast < LoadingBar * > ( _uiLayer - > getChildByTag ( 0 ) ) ; <nl> + loadingBar - > setPercent ( _count ) ; <nl> } <nl> <nl> void UILoadingBarTest_Right_Scale9 : : previousCallback ( Object * sender , TouchEventType type ) <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UILoadingBarTest / UILoadingBarTest . h <nl> class UILoadingBarTest_Left : public UIScene <nl> bool init ( ) ; <nl> void update ( float delta ) ; <nl> <nl> - virtual void previousCallback ( Object * sender , TouchEventType type ) ; <nl> - virtual void restartCallback ( Object * sender , TouchEventType type ) ; <nl> - virtual void nextCallback ( Object * sender , TouchEventType type ) ; <nl> + virtual void previousCallback ( Object * sender , TouchEventType type ) override ; <nl> + virtual void restartCallback ( Object * sender , TouchEventType type ) override ; <nl> + virtual void nextCallback ( Object * sender , TouchEventType type ) override ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UILoadingBarTest_Left ) <nl> - int m_nCount ; <nl> + int _count ; <nl> } ; <nl> <nl> class UILoadingBarTest_Right : public UIScene <nl> class UILoadingBarTest_Right : public UIScene <nl> bool init ( ) ; <nl> void update ( float delta ) ; <nl> <nl> - virtual void previousCallback ( Object * sender , TouchEventType type ) ; <nl> - virtual void restartCallback ( Object * sender , TouchEventType type ) ; <nl> - virtual void nextCallback ( Object * sender , TouchEventType type ) ; <nl> + virtual void previousCallback ( Object * sender , TouchEventType type ) override ; <nl> + virtual void restartCallback ( Object * sender , TouchEventType type ) override ; <nl> + virtual void nextCallback ( Object * sender , TouchEventType type ) override ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UILoadingBarTest_Right ) <nl> - int m_nCount ; <nl> + int _count ; <nl> } ; <nl> <nl> class UILoadingBarTest_Left_Scale9 : public UIScene <nl> class UILoadingBarTest_Left_Scale9 : public UIScene <nl> bool init ( ) ; <nl> void update ( float delta ) ; <nl> <nl> - virtual void previousCallback ( Object * sender , TouchEventType type ) ; <nl> - virtual void restartCallback ( Object * sender , TouchEventType type ) ; <nl> - virtual void nextCallback ( Object * sender , TouchEventType type ) ; <nl> + virtual void previousCallback ( Object * sender , TouchEventType type ) override ; <nl> + virtual void restartCallback ( Object * sender , TouchEventType type ) override ; <nl> + virtual void nextCallback ( Object * sender , TouchEventType type ) override ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UILoadingBarTest_Left_Scale9 ) <nl> - int m_nCount ; <nl> + int _count ; <nl> } ; <nl> <nl> class UILoadingBarTest_Right_Scale9 : public UIScene <nl> class UILoadingBarTest_Right_Scale9 : public UIScene <nl> bool init ( ) ; <nl> void update ( float delta ) ; <nl> <nl> - virtual void previousCallback ( Object * sender , TouchEventType type ) ; <nl> - virtual void restartCallback ( Object * sender , TouchEventType type ) ; <nl> - virtual void nextCallback ( Object * sender , TouchEventType type ) ; <nl> + virtual void previousCallback ( Object * sender , TouchEventType type ) override ; <nl> + virtual void restartCallback ( Object * sender , TouchEventType type ) override ; <nl> + virtual void nextCallback ( Object * sender , TouchEventType type ) override ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UILoadingBarTest_Right_Scale9 ) <nl> - int m_nCount ; <nl> + int _count ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UILoadingBarTest__ ) * / <nl> deleted file mode 100644 <nl> index 4ac36f958ddf . . 000000000000 <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UINodeContainerTest / UINodeContainerTest . cpp <nl> ppp / dev / null <nl> <nl> - <nl> - <nl> - # include " UINodeContainerTest . h " <nl> - # include " extensions / cocos - ext . h " <nl> - <nl> - const char * font_UINodeContainerTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> - <nl> - / / UINodeContainerTest <nl> - <nl> - UINodeContainerTest : : UINodeContainerTest ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UINodeContainerTest : : ~ UINodeContainerTest ( ) <nl> - { <nl> - } <nl> - <nl> - bool UINodeContainerTest : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add a label in which the UINodeContainer alert will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " NodeContainer Add CCNode " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UINodeContainerTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " NodeContainer " ) ; <nl> - alert - > setFontName ( font_UINodeContainerTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - / / Create the ui node container <nl> - UIWidget * nodeContainer = UIWidget : : create ( ) ; <nl> - nodeContainer - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( nodeContainer ) ; <nl> - <nl> - Sprite * sprite = Sprite : : create ( " cocosgui / ccicon . png " ) ; <nl> - sprite - > setPosition ( Point ( 0 , sprite - > getBoundingBox ( ) . size . height / 4 ) ) ; <nl> - nodeContainer - > addRenderer ( sprite , 0 ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> \ No newline at end of file <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . cpp <nl> <nl> <nl> # include " UIPageViewTest . h " <nl> <nl> - const char * font_UIPageViewTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UIPageViewTest <nl> UIPageViewTest : : UIPageViewTest ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( NULL ) <nl> { <nl> <nl> } <nl> bool UIPageViewTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the dragpanel events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " Move by horizontal direction " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIPageViewTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move by horizontal direction " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the black background <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " PageView " ) ; <nl> - alert - > setFontName ( font_UIPageViewTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the page view <nl> - UIPageView * pageView = UIPageView : : create ( ) ; <nl> + PageView * pageView = PageView : : create ( ) ; <nl> pageView - > setTouchEnabled ( true ) ; <nl> - pageView - > setSize ( Size ( 240 , 130 ) ) ; <nl> + pageView - > setSize ( Size ( 240 . 0f , 130 . 0f ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> - pageView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - pageView - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - pageView - > getSize ( ) . height ) / 2 ) ) ; <nl> + pageView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - pageView - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - pageView - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> <nl> for ( int i = 0 ; i < 3 ; + + i ) <nl> { <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setSize ( Size ( 240 , 130 ) ) ; <nl> + Layout * layout = Layout : : create ( ) ; <nl> + layout - > setSize ( Size ( 240 . 0f , 130 . 0f ) ) ; <nl> <nl> - UIImageView * imageView = UIImageView : : create ( ) ; <nl> + ImageView * imageView = ImageView : : create ( ) ; <nl> imageView - > setTouchEnabled ( true ) ; <nl> imageView - > setScale9Enabled ( true ) ; <nl> imageView - > loadTexture ( " cocosgui / scrollviewbg . png " ) ; <nl> imageView - > setSize ( Size ( 240 , 130 ) ) ; <nl> - imageView - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> + imageView - > setPosition ( Point ( layout - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( imageView ) ; <nl> <nl> - UILabel * label = UILabel : : create ( ) ; <nl> + gui : : Label * label = gui : : Label : : create ( ) ; <nl> label - > setText ( CCString : : createWithFormat ( " page % d " , ( i + 1 ) ) - > getCString ( ) ) ; <nl> - label - > setFontName ( font_UIPageViewTest ) ; <nl> + label - > setFontName ( " Marker Felt " ) ; <nl> label - > setFontSize ( 30 ) ; <nl> label - > setColor ( Color3B ( 192 , 192 , 192 ) ) ; <nl> - label - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> + label - > setPosition ( Point ( layout - > getSize ( ) . width / 2 . 0f , layout - > getSize ( ) . height / 2 . 0f ) ) ; <nl> layout - > addChild ( label ) ; <nl> <nl> pageView - > addPage ( layout ) ; <nl> } <nl> pageView - > addEventListenerPageView ( this , pagevieweventselector ( UIPageViewTest : : pageViewEvent ) ) ; <nl> <nl> - m_pUiLayer - > addWidget ( pageView ) ; <nl> + _uiLayer - > addChild ( pageView ) ; <nl> <nl> return true ; <nl> } <nl> void UIPageViewTest : : pageViewEvent ( Object * pSender , PageViewEventType type ) <nl> { <nl> case PAGEVIEW_EVENT_TURNING : <nl> { <nl> - UIPageView * pageView = dynamic_cast < UIPageView * > ( pSender ) ; <nl> + PageView * pageView = dynamic_cast < PageView * > ( pSender ) ; <nl> <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " page = % d " , pageView - > getCurPageIndex ( ) + 1 ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( CCString : : createWithFormat ( " page = % d " , pageView - > getCurPageIndex ( ) + 1 ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPageViewTest / UIPageViewTest . h <nl> class UIPageViewTest : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIPageViewTest ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UIPageViewTest__ ) * / <nl> deleted file mode 100644 <nl> index 94dbb0281945 . . 000000000000 <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPanelTest / UIPanelTest . cpp <nl> ppp / dev / null <nl> <nl> - <nl> - <nl> - # include " UIPanelTest . h " <nl> - <nl> - const char * font_UIPanelTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> - <nl> - / / UIPanelTest <nl> - <nl> - UIPanelTest : : UIPanelTest ( ) <nl> - { <nl> - } <nl> - <nl> - UIPanelTest : : ~ UIPanelTest ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIPanelTest : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " Panel " ) ; <nl> - alert - > setFontName ( font_UIPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the layout <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> - Size backgroundSize = background - > getSize ( ) ; <nl> - layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( layout ) ; <nl> - <nl> - UIButton * button = UIButton : : create ( ) ; <nl> - button - > setTouchEnabled ( true ) ; <nl> - button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - button - > setPosition ( Point ( button - > getSize ( ) . width / 2 , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button ) ; <nl> - <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - textButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> - button_scale9 - > setTouchEnabled ( true ) ; <nl> - button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setScale9Enabled ( true ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 , button_scale9 - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - / / UIPanelTest_Color <nl> - <nl> - UIPanelTest_Color : : UIPanelTest_Color ( ) <nl> - { <nl> - } <nl> - <nl> - UIPanelTest_Color : : ~ UIPanelTest_Color ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIPanelTest_Color : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " Panel color render " ) ; <nl> - alert - > setFontName ( font_UIPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the layout with color render <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> - layout - > setBackGroundColor ( Color3B ( 128 , 128 , 128 ) ) ; <nl> - layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> - Size backgroundSize = background - > getContentSize ( ) ; <nl> - layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( layout ) ; <nl> - <nl> - UIButton * button = UIButton : : create ( ) ; <nl> - button - > setTouchEnabled ( true ) ; <nl> - button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - button - > setPosition ( Point ( button - > getSize ( ) . width / 2 , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button ) ; <nl> - <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - textButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> - button_scale9 - > setTouchEnabled ( true ) ; <nl> - button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setScale9Enabled ( true ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 , button_scale9 - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - / / UIPanelTest_Gradient <nl> - <nl> - UIPanelTest_Gradient : : UIPanelTest_Gradient ( ) <nl> - { <nl> - } <nl> - <nl> - UIPanelTest_Gradient : : ~ UIPanelTest_Gradient ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIPanelTest_Gradient : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " Panel gradient render " ) ; <nl> - alert - > setFontName ( font_UIPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the layout with gradient render <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setBackGroundColorType ( LAYOUT_COLOR_GRADIENT ) ; <nl> - layout - > setBackGroundColor ( Color3B ( 64 , 64 , 64 ) , Color3B ( 192 , 192 , 192 ) ) ; <nl> - layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> - Size backgroundSize = background - > getContentSize ( ) ; <nl> - layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( layout ) ; <nl> - <nl> - UIButton * button = UIButton : : create ( ) ; <nl> - button - > setTouchEnabled ( true ) ; <nl> - button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - button - > setPosition ( Point ( button - > getSize ( ) . width / 2 , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button ) ; <nl> - <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - textButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> - button_scale9 - > setTouchEnabled ( true ) ; <nl> - button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setScale9Enabled ( true ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 , button_scale9 - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - / / UIPanelTest_BackGroundImage <nl> - <nl> - UIPanelTest_BackGroundImage : : UIPanelTest_BackGroundImage ( ) <nl> - { <nl> - } <nl> - <nl> - UIPanelTest_BackGroundImage : : ~ UIPanelTest_BackGroundImage ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIPanelTest_BackGroundImage : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " Panel background image " ) ; <nl> - alert - > setFontName ( font_UIPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the layout with background image <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setClippingEnabled ( true ) ; <nl> - layout - > setBackGroundImage ( " cocosgui / Hello . png " ) ; <nl> - layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> - Size backgroundSize = background - > getContentSize ( ) ; <nl> - layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( layout ) ; <nl> - <nl> - UIButton * button = UIButton : : create ( ) ; <nl> - button - > setTouchEnabled ( true ) ; <nl> - button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - button - > setPosition ( Point ( button - > getSize ( ) . width / 2 , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button ) ; <nl> - <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - textButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> - button_scale9 - > setTouchEnabled ( true ) ; <nl> - button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setScale9Enabled ( true ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 , button_scale9 - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - / / UIPanelTest_BackGroundImage_Scale9 <nl> - <nl> - UIPanelTest_BackGroundImage_Scale9 : : UIPanelTest_BackGroundImage_Scale9 ( ) <nl> - { <nl> - } <nl> - <nl> - UIPanelTest_BackGroundImage_Scale9 : : ~ UIPanelTest_BackGroundImage_Scale9 ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIPanelTest_BackGroundImage_Scale9 : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " Panel background image scale9 " ) ; <nl> - alert - > setFontName ( font_UIPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the layout with background image <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setBackGroundImageScale9Enabled ( true ) ; <nl> - layout - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> - layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> - Size backgroundSize = background - > getContentSize ( ) ; <nl> - layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( layout ) ; <nl> - <nl> - UIButton * button = UIButton : : create ( ) ; <nl> - button - > setTouchEnabled ( true ) ; <nl> - button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - button - > setPosition ( Point ( button - > getSize ( ) . width / 2 , layout - > getSize ( ) . height - button - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button ) ; <nl> - <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - textButton - > setPosition ( Point ( layout - > getSize ( ) . width / 2 , layout - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> - button_scale9 - > setTouchEnabled ( true ) ; <nl> - button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setScale9Enabled ( true ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Point ( layout - > getSize ( ) . width - button_scale9 - > getSize ( ) . width / 2 , button_scale9 - > getSize ( ) . height / 2 ) ) ; <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - / / UIPanelTest_Layout_Linear_Vertical <nl> - <nl> - UIPanelTest_Layout_Linear_Vertical : : UIPanelTest_Layout_Linear_Vertical ( ) <nl> - { <nl> - } <nl> - <nl> - UIPanelTest_Layout_Linear_Vertical : : ~ UIPanelTest_Layout_Linear_Vertical ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIPanelTest_Layout_Linear_Vertical : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " Panel Layout Linear Vertical " ) ; <nl> - alert - > setFontName ( font_UIPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the layout <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setLayoutType ( LAYOUT_LINEAR_VERTICAL ) ; <nl> - layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> - Size backgroundSize = background - > getSize ( ) ; <nl> - layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( layout ) ; <nl> - <nl> - <nl> - UIButton * button = UIButton : : create ( ) ; <nl> - button - > setTouchEnabled ( true ) ; <nl> - button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - layout - > addChild ( button ) ; <nl> - <nl> - UILinearLayoutParameter * lp1 = UILinearLayoutParameter : : create ( ) ; <nl> - button - > setLayoutParameter ( lp1 ) ; <nl> - lp1 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> - lp1 - > setMargin ( UIMargin ( 0 , 5 , 0 , 10 ) ) ; <nl> - <nl> - <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - UILinearLayoutParameter * lp2 = UILinearLayoutParameter : : create ( ) ; <nl> - textButton - > setLayoutParameter ( lp2 ) ; <nl> - lp2 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> - lp2 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> - <nl> - <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> - button_scale9 - > setTouchEnabled ( true ) ; <nl> - button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setScale9Enabled ( true ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> - UILinearLayoutParameter * lp3 = UILinearLayoutParameter : : create ( ) ; <nl> - button_scale9 - > setLayoutParameter ( lp3 ) ; <nl> - lp3 - > setGravity ( LINEAR_GRAVITY_CENTER_HORIZONTAL ) ; <nl> - lp3 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> - <nl> - <nl> - layout - > doLayout ( ) ; <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - / / UIPanelTest_Layout_Linear_Horizontal <nl> - <nl> - UIPanelTest_Layout_Linear_Horizontal : : UIPanelTest_Layout_Linear_Horizontal ( ) <nl> - { <nl> - } <nl> - <nl> - UIPanelTest_Layout_Linear_Horizontal : : ~ UIPanelTest_Layout_Linear_Horizontal ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIPanelTest_Layout_Linear_Horizontal : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " Panel Layout Linear Horizontal " ) ; <nl> - alert - > setFontName ( font_UIPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the layout <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setLayoutType ( LAYOUT_LINEAR_HORIZONTAL ) ; <nl> - layout - > setClippingEnabled ( true ) ; <nl> - layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> - Size backgroundSize = background - > getSize ( ) ; <nl> - layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( layout ) ; <nl> - <nl> - UIButton * button = UIButton : : create ( ) ; <nl> - button - > setTouchEnabled ( true ) ; <nl> - button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - layout - > addChild ( button ) ; <nl> - <nl> - UILinearLayoutParameter * lp1 = UILinearLayoutParameter : : create ( ) ; <nl> - button - > setLayoutParameter ( lp1 ) ; <nl> - lp1 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> - lp1 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> - <nl> - <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - UILinearLayoutParameter * lp2 = UILinearLayoutParameter : : create ( ) ; <nl> - textButton - > setLayoutParameter ( lp2 ) ; <nl> - lp2 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> - lp2 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> - <nl> - <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> - button_scale9 - > setTouchEnabled ( true ) ; <nl> - button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setScale9Enabled ( true ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> - UILinearLayoutParameter * lp3 = UILinearLayoutParameter : : create ( ) ; <nl> - button_scale9 - > setLayoutParameter ( lp3 ) ; <nl> - lp3 - > setGravity ( LINEAR_GRAVITY_CENTER_VERTICAL ) ; <nl> - lp3 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> - <nl> - <nl> - layout - > doLayout ( ) ; <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - / / UIPanelTest_Layout_Relative <nl> - <nl> - UIPanelTest_Layout_Relative : : UIPanelTest_Layout_Relative ( ) <nl> - { <nl> - } <nl> - <nl> - UIPanelTest_Layout_Relative : : ~ UIPanelTest_Layout_Relative ( ) <nl> - { <nl> - } <nl> - <nl> - bool UIPanelTest_Layout_Relative : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " Panel Layout Relative " ) ; <nl> - alert - > setFontName ( font_UIPanelTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> - <nl> - / / Create the layout <nl> - UILayout * layout = UILayout : : create ( ) ; <nl> - layout - > setLayoutType ( LAYOUT_RELATIVE ) ; <nl> - layout - > setSize ( Size ( 280 , 150 ) ) ; <nl> - layout - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> - layout - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> - Size backgroundSize = background - > getSize ( ) ; <nl> - layout - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - layout - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - layout - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( layout ) ; <nl> - <nl> - UIButton * button = UIButton : : create ( ) ; <nl> - button - > setTouchEnabled ( true ) ; <nl> - button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - layout - > addChild ( button ) ; <nl> - <nl> - UIRelativeLayoutParameter * rp1 = UIRelativeLayoutParameter : : create ( ) ; <nl> - button - > setLayoutParameter ( rp1 ) ; <nl> - rp1 - > setAlign ( RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL ) ; <nl> - / / rp1 - > setMargin ( UIMargin ( 0 , 10 , 0 , 10 ) ) ; <nl> - <nl> - <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - layout - > addChild ( textButton ) ; <nl> - <nl> - UIRelativeLayoutParameter * rp2 = UIRelativeLayoutParameter : : create ( ) ; <nl> - textButton - > setLayoutParameter ( rp2 ) ; <nl> - rp2 - > setAlign ( RELATIVE_ALIGN_PARENT_LEFT_BOTTOM ) ; <nl> - <nl> - <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> - button_scale9 - > setTouchEnabled ( true ) ; <nl> - button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setScale9Enabled ( true ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - layout - > addChild ( button_scale9 ) ; <nl> - <nl> - UIRelativeLayoutParameter * rp3 = UIRelativeLayoutParameter : : create ( ) ; <nl> - textButton - > setLayoutParameter ( rp3 ) ; <nl> - rp3 - > setAlign ( RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM ) ; <nl> - <nl> - <nl> - layout - > doLayout ( ) ; <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - return false ; <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 50b4780a4af0 . . 000000000000 <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPanelTest / UIPanelTest . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 cocos2d - x . org <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all 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 , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __TestCpp__UIPanelTest__ <nl> - # define __TestCpp__UIPanelTest__ <nl> - <nl> - # include " . . / UIScene . h " <nl> - <nl> - class UIPanelTest : public UIScene <nl> - { <nl> - public : <nl> - UIPanelTest ( ) ; <nl> - ~ UIPanelTest ( ) ; <nl> - bool init ( ) ; <nl> - <nl> - protected : <nl> - UI_SCENE_CREATE_FUNC ( UIPanelTest ) <nl> - } ; <nl> - <nl> - class UIPanelTest_Color : public UIScene <nl> - { <nl> - public : <nl> - UIPanelTest_Color ( ) ; <nl> - ~ UIPanelTest_Color ( ) ; <nl> - bool init ( ) ; <nl> - <nl> - protected : <nl> - UI_SCENE_CREATE_FUNC ( UIPanelTest_Color ) <nl> - } ; <nl> - <nl> - class UIPanelTest_Gradient : public UIScene <nl> - { <nl> - public : <nl> - UIPanelTest_Gradient ( ) ; <nl> - ~ UIPanelTest_Gradient ( ) ; <nl> - bool init ( ) ; <nl> - <nl> - protected : <nl> - UI_SCENE_CREATE_FUNC ( UIPanelTest_Gradient ) <nl> - } ; <nl> - <nl> - class UIPanelTest_BackGroundImage : public UIScene <nl> - { <nl> - public : <nl> - UIPanelTest_BackGroundImage ( ) ; <nl> - ~ UIPanelTest_BackGroundImage ( ) ; <nl> - bool init ( ) ; <nl> - <nl> - protected : <nl> - UI_SCENE_CREATE_FUNC ( UIPanelTest_BackGroundImage ) <nl> - } ; <nl> - <nl> - class UIPanelTest_BackGroundImage_Scale9 : public UIScene <nl> - { <nl> - public : <nl> - UIPanelTest_BackGroundImage_Scale9 ( ) ; <nl> - ~ UIPanelTest_BackGroundImage_Scale9 ( ) ; <nl> - bool init ( ) ; <nl> - <nl> - protected : <nl> - UI_SCENE_CREATE_FUNC ( UIPanelTest_BackGroundImage_Scale9 ) <nl> - } ; <nl> - <nl> - class UIPanelTest_Layout_Linear_Vertical : public UIScene <nl> - { <nl> - public : <nl> - UIPanelTest_Layout_Linear_Vertical ( ) ; <nl> - ~ UIPanelTest_Layout_Linear_Vertical ( ) ; <nl> - bool init ( ) ; <nl> - <nl> - protected : <nl> - UI_SCENE_CREATE_FUNC ( UIPanelTest_Layout_Linear_Vertical ) <nl> - } ; <nl> - <nl> - class UIPanelTest_Layout_Linear_Horizontal : public UIScene <nl> - { <nl> - public : <nl> - UIPanelTest_Layout_Linear_Horizontal ( ) ; <nl> - ~ UIPanelTest_Layout_Linear_Horizontal ( ) ; <nl> - bool init ( ) ; <nl> - <nl> - protected : <nl> - UI_SCENE_CREATE_FUNC ( UIPanelTest_Layout_Linear_Horizontal ) <nl> - } ; <nl> - <nl> - class UIPanelTest_Layout_Relative : public UIScene <nl> - { <nl> - public : <nl> - UIPanelTest_Layout_Relative ( ) ; <nl> - ~ UIPanelTest_Layout_Relative ( ) ; <nl> - bool init ( ) ; <nl> - <nl> - protected : <nl> - UI_SCENE_CREATE_FUNC ( UIPanelTest_Layout_Relative ) <nl> - } ; <nl> - <nl> - # endif / * defined ( __TestCpp__UIPanelTest__ ) * / <nl> new file mode 100644 <nl> index 000000000000 . . 53ec3758f22d <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPickerViewTest / UIPickerViewTest . cpp <nl> <nl> + <nl> + <nl> + # include " UIPickerViewTest . h " <nl> + <nl> + / / UIPickerViewTest_Vertical <nl> + <nl> + UIPickerViewTest_Vertical : : UIPickerViewTest_Vertical ( ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIPickerViewTest_Vertical : : ~ UIPickerViewTest_Vertical ( ) <nl> + { <nl> + CC_SAFE_RELEASE ( m_array ) ; <nl> + } <nl> + <nl> + bool UIPickerViewTest_Vertical : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + m_pDisplayValueLabel = gui : : Label : : create ( ) ; <nl> + m_pDisplayValueLabel - > setText ( " Move by vertical direction " ) ; <nl> + m_pDisplayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> + m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> + _uiLayer - > addChild ( m_pDisplayValueLabel ) ; <nl> + <nl> + <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " PickerView vertical " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + <nl> + <nl> + / / create picker view data <nl> + m_array = __Array : : create ( ) ; <nl> + CC_SAFE_RETAIN ( m_array ) ; <nl> + for ( int i = 0 ; i < 20 ; + + i ) <nl> + { <nl> + String * ccstr = String : : createWithFormat ( " pickerview_ % d " , i ) ; <nl> + m_array - > addObject ( ccstr ) ; <nl> + } <nl> + <nl> + <nl> + / / Create the picker view <nl> + PickerView * pickerView = PickerView : : create ( ) ; <nl> + / / set picker view direction <nl> + pickerView - > setDirection ( SCROLLVIEW_DIR_VERTICAL ) ; <nl> + pickerView - > setTouchEnabled ( true ) ; <nl> + pickerView - > setBounceEnabled ( true ) ; <nl> + pickerView - > setBackGroundImage ( " cocosgui / yellow_edit . png " ) ; <nl> + pickerView - > setBackGroundImageScale9Enabled ( true ) ; <nl> + pickerView - > setSize ( Size ( 240 , 150 ) ) ; <nl> + pickerView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> + ( backgroundSize . width - pickerView - > getSize ( ) . width ) / 2 , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 + <nl> + ( backgroundSize . height - pickerView - > getSize ( ) . height ) / 2 ) ) ; <nl> + pickerView - > addEventListenerScrollView ( this , scrollvieweventselector ( UIPickerViewTest_Vertical : : selectedItemEvent ) ) ; <nl> + pickerView - > addEventListenerPickerView ( this , pickervieweventselector ( UIPickerViewTest_Vertical : : pickItemEvent ) ) ; <nl> + _uiLayer - > addChild ( pickerView ) ; <nl> + <nl> + int count = m_array - > count ( ) ; <nl> + pickerView - > setItemCountInContainerWithOddNumber ( count / 5 ) ; <nl> + <nl> + for ( int i = 0 ; i < count ; + + i ) <nl> + { <nl> + Button * button = Button : : create ( ) ; <nl> + button - > loadTextures ( " cocosgui / orange_edit . png " , " cocosgui / orange_edit . png " , " " ) ; <nl> + button - > setScale9Enabled ( true ) ; <nl> + button - > setSize ( Size ( 100 , <nl> + pickerView - > getSize ( ) . height / pickerView - > getItemCountInContainerWithOddNumber ( ) ) ) ; <nl> + button - > setTitleText ( static_cast < String * > ( m_array - > getObjectAtIndex ( i ) ) - > getCString ( ) ) ; <nl> + <nl> + pickerView - > addChild ( button ) ; <nl> + } <nl> + <nl> + / / create picker render of picker view <nl> + Button * button_0 = static_cast < Button * > ( pickerView - > getChildren ( ) . at ( 0 ) ) ; <nl> + pickerView - > loadPickerTexture ( " cocosgui / green_edit . png " ) ; <nl> + Scale9Sprite * pickerRender = pickerView - > getPickerRender ( ) ; <nl> + pickerRender - > setOpacity ( pickerView - > getOpacity ( ) / 3 ) ; <nl> + pickerRender - > setPreferredSize ( Size ( pickerView - > getSize ( ) . width , button_0 - > getSize ( ) . height ) ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + void UIPickerViewTest_Vertical : : selectedItemEvent ( Object * pSender , ScrollviewEventType type ) <nl> + { <nl> + switch ( type ) <nl> + { <nl> + case SCROLLVIEW_EVENT_SELECT_CHILD : <nl> + { <nl> + PickerView * pickerView = static_cast < PickerView * > ( pSender ) ; <nl> + CCLOG ( " select child index = % d " , pickerView - > getSelectedChildIndex ( ) ) ; <nl> + } <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + void UIPickerViewTest_Vertical : : pickItemEvent ( Object * pSender , PickerViewEventType type ) <nl> + { <nl> + switch ( type ) <nl> + { <nl> + case PICKERVIEW_EVENT_PICK_ITEM : <nl> + { <nl> + PickerView * pickerView = static_cast < PickerView * > ( pSender ) ; <nl> + CCLOG ( " picker view pick index = % d " , pickerView - > getPickIndex ( ) ) ; <nl> + } <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + / / UIPickerViewTest_Horizontal <nl> + <nl> + UIPickerViewTest_Horizontal : : UIPickerViewTest_Horizontal ( ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIPickerViewTest_Horizontal : : ~ UIPickerViewTest_Horizontal ( ) <nl> + { <nl> + CC_SAFE_RELEASE ( m_array ) ; <nl> + } <nl> + <nl> + bool UIPickerViewTest_Horizontal : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + m_pDisplayValueLabel = gui : : Label : : create ( ) ; <nl> + m_pDisplayValueLabel - > setText ( " Move by horizontal direction " ) ; <nl> + m_pDisplayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> + m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> + _uiLayer - > addChild ( m_pDisplayValueLabel ) ; <nl> + <nl> + <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " PickerView horizontal " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + <nl> + <nl> + / / create picker view data <nl> + m_array = __Array : : create ( ) ; <nl> + CC_SAFE_RETAIN ( m_array ) ; <nl> + for ( int i = 0 ; i < 20 ; + + i ) <nl> + { <nl> + String * ccstr = String : : createWithFormat ( " PCKER % d " , i ) ; <nl> + m_array - > addObject ( ccstr ) ; <nl> + } <nl> + const char * title_0 = static_cast < String * > ( m_array - > getObjectAtIndex ( 0 ) ) - > getCString ( ) ; <nl> + <nl> + <nl> + / / Create the picker view <nl> + PickerView * pickerView = PickerView : : create ( ) ; <nl> + / / set picker view direction <nl> + pickerView - > setDirection ( SCROLLVIEW_DIR_HORIZONTAL ) ; <nl> + pickerView - > setTouchEnabled ( true ) ; <nl> + pickerView - > setBounceEnabled ( true ) ; <nl> + pickerView - > setBackGroundImage ( " cocosgui / yellow_edit . png " ) ; <nl> + pickerView - > setBackGroundImageScale9Enabled ( true ) ; <nl> + pickerView - > setSize ( Size ( 240 , 150 ) ) ; <nl> + pickerView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> + ( backgroundSize . width - pickerView - > getSize ( ) . width ) / 2 , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 + <nl> + ( backgroundSize . height - pickerView - > getSize ( ) . height ) / 2 ) ) ; <nl> + pickerView - > addEventListenerScrollView ( this , scrollvieweventselector ( UIPickerViewTest_Horizontal : : selectedItemEvent ) ) ; <nl> + pickerView - > addEventListenerPickerView ( this , pickervieweventselector ( UIPickerViewTest_Horizontal : : pickItemEvent ) ) ; <nl> + _uiLayer - > addChild ( pickerView ) ; <nl> + <nl> + int count = m_array - > count ( ) ; <nl> + pickerView - > setItemCountInContainerWithOddNumber ( count / 4 ) ; <nl> + <nl> + for ( int i = 0 ; i < count ; + + i ) <nl> + { <nl> + Button * button = Button : : create ( ) ; <nl> + button - > loadTextures ( " cocosgui / orange_edit . png " , " cocosgui / orange_edit . png " , " " ) ; <nl> + button - > setScale9Enabled ( true ) ; <nl> + button - > setSize ( Size ( pickerView - > getSize ( ) . width / pickerView - > getItemCountInContainerWithOddNumber ( ) , <nl> + 120 ) ) ; <nl> + button - > setTitleText ( static_cast < String * > ( m_array - > getObjectAtIndex ( i ) ) - > getCString ( ) ) ; <nl> + button - > setTitleDimension ( Size ( button - > getTitleFontSize ( ) , <nl> + button - > getTitleFontSize ( ) * ( strlen ( title_0 ) * 2 ) ) ) ; <nl> + button - > setTitleHorizontalAlignment ( TextHAlignment : : CENTER ) ; <nl> + button - > setTitleVerticalAlignment ( TextVAlignment : : CENTER ) ; <nl> + <nl> + pickerView - > addChild ( button ) ; <nl> + } <nl> + <nl> + / / create picker render of picker view <nl> + Button * button_0 = static_cast < Button * > ( pickerView - > getChildren ( ) . at ( 0 ) ) ; <nl> + pickerView - > loadPickerTexture ( " cocosgui / green_edit . png " ) ; <nl> + Scale9Sprite * pickerRender = pickerView - > getPickerRender ( ) ; <nl> + pickerRender - > setOpacity ( pickerView - > getOpacity ( ) / 3 ) ; <nl> + pickerRender - > setPreferredSize ( Size ( button_0 - > getSize ( ) . width , pickerView - > getSize ( ) . height ) ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + void UIPickerViewTest_Horizontal : : selectedItemEvent ( Object * pSender , ScrollviewEventType type ) <nl> + { <nl> + switch ( type ) <nl> + { <nl> + case SCROLLVIEW_EVENT_SELECT_CHILD : <nl> + { <nl> + PickerView * pickerView = static_cast < PickerView * > ( pSender ) ; <nl> + CCLOG ( " select child index = % d " , pickerView - > getSelectedChildIndex ( ) ) ; <nl> + } <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + void UIPickerViewTest_Horizontal : : pickItemEvent ( Object * pSender , PickerViewEventType type ) <nl> + { <nl> + switch ( type ) <nl> + { <nl> + case PICKERVIEW_EVENT_PICK_ITEM : <nl> + { <nl> + PickerView * pickerView = static_cast < PickerView * > ( pSender ) ; <nl> + CCLOG ( " picker view pick index = % d " , pickerView - > getPickIndex ( ) ) ; <nl> + } <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> similarity index 61 % <nl> rename from samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextButtonTest / UITextButtonTest . h <nl> rename to samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPickerViewTest / UIPickerViewTest . h <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextButtonTest / UITextButtonTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPickerViewTest / UIPickerViewTest . h <nl> <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # ifndef __TestCpp__UITextButtonTest__ <nl> - # define __TestCpp__UITextButtonTest__ <nl> + # ifndef __TestCpp__UIPickViewTest__ <nl> + # define __TestCpp__UIPickViewTest__ <nl> <nl> # include " . . / UIScene . h " <nl> <nl> - class UITextButtonTest : public UIScene <nl> + class UIPickerViewTest_Vertical : public UIScene <nl> { <nl> public : <nl> - UITextButtonTest ( ) ; <nl> - ~ UITextButtonTest ( ) ; <nl> + UIPickerViewTest_Vertical ( ) ; <nl> + ~ UIPickerViewTest_Vertical ( ) ; <nl> bool init ( ) ; <nl> - void touchEvent ( Object * pSender , TouchEventType type ) ; <nl> + void selectedItemEvent ( Object * pSender , ScrollviewEventType type ) ; <nl> + void pickItemEvent ( Object * pSender , PickerViewEventType type ) ; <nl> <nl> protected : <nl> - UI_SCENE_CREATE_FUNC ( UITextButtonTest ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + UI_SCENE_CREATE_FUNC ( UIPickerViewTest_Vertical ) <nl> + gui : : Label * m_pDisplayValueLabel ; <nl> + <nl> + __Array * m_array ; <nl> } ; <nl> <nl> - class UITextButtonTest_Scale9 : public UIScene <nl> + class UIPickerViewTest_Horizontal : public UIScene <nl> { <nl> public : <nl> - UITextButtonTest_Scale9 ( ) ; <nl> - ~ UITextButtonTest_Scale9 ( ) ; <nl> + UIPickerViewTest_Horizontal ( ) ; <nl> + ~ UIPickerViewTest_Horizontal ( ) ; <nl> bool init ( ) ; <nl> - void touchEvent ( Object * pSender , TouchEventType type ) ; <nl> + void selectedItemEvent ( Object * pSender , ScrollviewEventType type ) ; <nl> + void pickItemEvent ( Object * pSender , PickerViewEventType type ) ; <nl> <nl> protected : <nl> - UI_SCENE_CREATE_FUNC ( UITextButtonTest_Scale9 ) <nl> - / / CC_SYNTHESIZE_RETAIN ( CCLabelTTF * , m_pDisplayValueLabel , DisplayValueLabel ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + UI_SCENE_CREATE_FUNC ( UIPickerViewTest_Horizontal ) <nl> + gui : : Label * m_pDisplayValueLabel ; <nl> + <nl> + __Array * m_array ; <nl> } ; <nl> <nl> - # endif / * defined ( __TestCpp__UITextButtonTest__ ) * / <nl> + # endif / * defined ( __TestCpp__UIPickViewTest__ ) * / <nl> new file mode 100644 <nl> index 000000000000 . . b94b81e613b0 <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPotentiometerTest / UIPotentiometerTest . cpp <nl> <nl> + <nl> + <nl> + # include " UIPotentiometerTest . h " <nl> + <nl> + / / UIPotentiometerTest <nl> + UIPotentiometerTest : : UIPotentiometerTest ( ) <nl> + : _displayValueLabel ( NULL ) <nl> + { <nl> + } <nl> + <nl> + UIPotentiometerTest : : ~ UIPotentiometerTest ( ) <nl> + { <nl> + } <nl> + <nl> + bool UIPotentiometerTest : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the button events will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getSize ( ) . height / 3 ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Potentiometer " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the potentiometer <nl> + Potentiometer * potentiometer = Potentiometer : : create ( ) ; <nl> + potentiometer - > setTouchEnabled ( true ) ; <nl> + potentiometer - > loadTexture ( " cocosgui / potentiometerTrack . png " , " cocosgui / potentiometerProgress . png " , " cocosgui / potentiometerButton . png " ) ; <nl> + potentiometer - > setPosition ( Point ( widgetSize . width / 2 - potentiometer - > getSize ( ) . width , widgetSize . height / 2 ) ) ; <nl> + potentiometer - > addEventListenerPotentiometer ( this , potentiometervaluechangedselector ( UIPotentiometerTest : : valueChangedEvent ) ) ; <nl> + <nl> + _uiLayer - > addChild ( potentiometer ) ; <nl> + <nl> + <nl> + / / Create the potentiometer with allow min and max value <nl> + Potentiometer * potentiometerAllow = Potentiometer : : create ( ) ; <nl> + potentiometerAllow - > setTouchEnabled ( true ) ; <nl> + potentiometerAllow - > loadTexture ( " cocosgui / potentiometerTrack . png " , " cocosgui / potentiometerProgress . png " , " cocosgui / potentiometerButton . png " ) ; <nl> + potentiometerAllow - > setPosition ( Point ( widgetSize . width / 2 + potentiometerAllow - > getSize ( ) . width , widgetSize . height / 2 ) ) ; <nl> + potentiometerAllow - > addEventListenerPotentiometer ( this , potentiometervaluechangedselector ( UIPotentiometerTest : : valueChangedEvent ) ) ; <nl> + <nl> + potentiometerAllow - > setMinimumAllowValue ( 0 . 3 ) ; <nl> + potentiometerAllow - > setMaximumAllowValue ( 0 . 7 ) ; <nl> + potentiometerAllow - > setValue ( 0 . 3 ) ; <nl> + <nl> + _uiLayer - > addChild ( potentiometerAllow ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void UIPotentiometerTest : : valueChangedEvent ( Object * pSender , PotentiometerEventType type ) <nl> + { <nl> + Potentiometer * potentiometer = static_cast < Potentiometer * > ( pSender ) ; <nl> + <nl> + switch ( type ) <nl> + { <nl> + case POTENTIOMETER_EVENT_VALUECHANGED : <nl> + _displayValueLabel - > setText ( CCString : : createWithFormat ( " % . 02f " , potentiometer - > getValue ( ) ) - > getCString ( ) ) ; <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> similarity index 77 % <nl> rename from samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextAreaTest / UITextAreaTest . h <nl> rename to samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPotentiometerTest / UIPotentiometerTest . h <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextAreaTest / UITextAreaTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIPotentiometerTest / UIPotentiometerTest . h <nl> <nl> THE SOFTWARE . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # ifndef __TestCpp__UITextAreaTest__ <nl> - # define __TestCpp__UITextAreaTest__ <nl> + # ifndef __TestCpp__UIPotentiometerTest__ <nl> + # define __TestCpp__UIPotentiometerTest__ <nl> <nl> # include " . . / UIScene . h " <nl> <nl> - class UITextAreaTest : public UIScene <nl> + class UIPotentiometerTest : public UIScene <nl> { <nl> public : <nl> + UIPotentiometerTest ( ) ; <nl> + ~ UIPotentiometerTest ( ) ; <nl> bool init ( ) ; <nl> + void valueChangedEvent ( Object * pSender , PotentiometerEventType type ) ; <nl> + <nl> <nl> protected : <nl> - UI_SCENE_CREATE_FUNC ( UITextAreaTest ) <nl> + UI_SCENE_CREATE_FUNC ( UIPotentiometerTest ) <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> - # endif / * defined ( __TestCpp__UITextAreaTest__ ) * / <nl> + <nl> + # endif / * defined ( __TestCpp__UIPotentiometerTest__ ) * / <nl> new file mode 100644 <nl> index 000000000000 . . 9ec70b7f0b5f <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIProgressTimerTest / UIProgressTimerTest . cpp <nl> <nl> + <nl> + <nl> + # include " UIProgressTimerTest . h " <nl> + <nl> + / / UIProgressTimerTest_Radial <nl> + bool UIProgressTimerTest_Radial : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Progress Timer Radial " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the progress timer <nl> + ProgressTo * to1 = ProgressTo : : create ( 2 . 0f , 100 . 0f ) ; <nl> + ProgressTo * to2 = ProgressTo : : create ( 2 . 0f , 100 . 0f ) ; <nl> + <nl> + gui : : ProgressTimer * left = gui : : ProgressTimer : : create ( ) ; <nl> + left - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + left - > setPosition ( Point ( widgetSize . width / 2 . 0f - left - > getSize ( ) . width * 0 . 75f , widgetSize . height / 2 . 0f + left - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + left - > setType ( cocos2d : : ProgressTimer : : Type : : RADIAL ) ; <nl> + left - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( to1 ) ) ; <nl> + _uiLayer - > addChild ( left ) ; <nl> + <nl> + gui : : ProgressTimer * right = gui : : ProgressTimer : : create ( ) ; <nl> + right - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + right - > setPosition ( Point ( widgetSize . width / 2 . 0f + right - > getSize ( ) . width * 0 . 75f , widgetSize . height / 2 . 0f + right - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + right - > setType ( cocos2d : : ProgressTimer : : Type : : RADIAL ) ; <nl> + / / Makes the ridial CCW <nl> + right - > setReverseProgress ( true ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( to2 ) ) ; <nl> + _uiLayer - > addChild ( right ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UIProgressTimerTest_Horizontal <nl> + bool UIProgressTimerTest_Horizontal : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Progress Timer Horizontal " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 26 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 125f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the progress timer <nl> + ProgressTo * to1 = ProgressTo : : create ( 2 . 0f , 100 . 0f ) ; <nl> + ProgressTo * to2 = ProgressTo : : create ( 2 . 0f , 100 . 0f ) ; <nl> + <nl> + gui : : ProgressTimer * left = gui : : ProgressTimer : : create ( ) ; <nl> + left - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + left - > setPosition ( Point ( widgetSize . width / 2 . 0f - left - > getSize ( ) . width * 0 . 75f , widgetSize . height / 2 . 0f + left - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + left - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the left since the midpoint is 0 for the x <nl> + left - > setMidPoint ( Point ( 0 , 0 ) ) ; <nl> + / / Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change <nl> + left - > setBarChangeRate ( Point ( 1 , 0 ) ) ; <nl> + left - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( to1 ) ) ; <nl> + _uiLayer - > addChild ( left ) ; <nl> + <nl> + gui : : ProgressTimer * right = gui : : ProgressTimer : : create ( ) ; <nl> + right - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + right - > setPosition ( Point ( widgetSize . width / 2 . 0f + right - > getSize ( ) . width * 0 . 75f , widgetSize . height / 2 . 0f + right - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + right - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the left since the midpoint is 1 for the x <nl> + right - > setMidPoint ( Point ( 1 , 0 ) ) ; <nl> + / / Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change <nl> + right - > setBarChangeRate ( Point ( 1 , 0 ) ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( to2 ) ) ; <nl> + _uiLayer - > addChild ( right ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UIProgressTimerTest_Vertical <nl> + bool UIProgressTimerTest_Vertical : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Progress Timer Vertical " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 26 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 125f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the progress timer <nl> + ProgressTo * to1 = ProgressTo : : create ( 2 . 0f , 100 . 0f ) ; <nl> + ProgressTo * to2 = ProgressTo : : create ( 2 . 0f , 100 . 0f ) ; <nl> + <nl> + gui : : ProgressTimer * left = gui : : ProgressTimer : : create ( ) ; <nl> + left - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + left - > setPosition ( Point ( widgetSize . width / 2 . 0f - left - > getSize ( ) . width * 0 . 75f , widgetSize . height / 2 . 0f + left - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + left - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + left - > setMidPoint ( Point ( 0 , 0 ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + left - > setBarChangeRate ( Point ( 0 , 1 ) ) ; <nl> + left - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( to1 ) ) ; <nl> + _uiLayer - > addChild ( left ) ; <nl> + <nl> + gui : : ProgressTimer * right = gui : : ProgressTimer : : create ( ) ; <nl> + right - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + right - > setPosition ( Point ( widgetSize . width / 2 . 0f + right - > getSize ( ) . width * 0 . 75f , widgetSize . height / 2 . 0f + right - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + right - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + right - > setMidPoint ( Point ( 0 , 1 ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + right - > setBarChangeRate ( Point ( 0 , 1 ) ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( to2 ) ) ; <nl> + _uiLayer - > addChild ( right ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UIProgressTimerTest_RadialMidpointChanged <nl> + bool UIProgressTimerTest_RadialMidpointChanged : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Progress Timer Radial Midpoint Changed " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 17 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 325f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the progress timer <nl> + ProgressTo * action = ProgressTo : : create ( 2 . 0f , 100 . 0f ) ; <nl> + <nl> + gui : : ProgressTimer * left = gui : : ProgressTimer : : create ( ) ; <nl> + left - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + left - > setPosition ( Point ( widgetSize . width / 2 . 0f - left - > getSize ( ) . width * 0 . 75f , widgetSize . height / 2 . 0f + left - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + left - > setType ( cocos2d : : ProgressTimer : : Type : : RADIAL ) ; <nl> + left - > setMidPoint ( Point ( 0 . 25f , 0 . 75f ) ) ; <nl> + left - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) action - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( left ) ; <nl> + <nl> + gui : : ProgressTimer * right = gui : : ProgressTimer : : create ( ) ; <nl> + right - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + right - > setPosition ( Point ( widgetSize . width / 2 . 0f + right - > getSize ( ) . width * 0 . 75f , widgetSize . height / 2 . 0f + right - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + right - > setType ( cocos2d : : ProgressTimer : : Type : : RADIAL ) ; <nl> + right - > setMidPoint ( Point ( 0 . 75f , 0 . 25f ) ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) action - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( right ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UIProgressTimerTest_BarVarious <nl> + bool UIProgressTimerTest_BarVarious : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Progress Timer Bar Various " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 26 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 125f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the progress timer <nl> + ProgressTo * to = ProgressTo : : create ( 2 . 0f , 100 . 0f ) ; <nl> + <nl> + gui : : ProgressTimer * left = gui : : ProgressTimer : : create ( ) ; <nl> + left - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + left - > setPosition ( Point ( widgetSize . width / 2 . 0f - left - > getSize ( ) . width * 1 . 1 , widgetSize . height / 2 . 0f + left - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + left - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + left - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + left - > setBarChangeRate ( Point ( 1 , 0 ) ) ; <nl> + left - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( left ) ; <nl> + <nl> + gui : : ProgressTimer * middle = gui : : ProgressTimer : : create ( ) ; <nl> + middle - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + middle - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + middle - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + middle - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + middle - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + middle - > setBarChangeRate ( Point ( 1 , 1 ) ) ; <nl> + middle - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( middle ) ; <nl> + <nl> + gui : : ProgressTimer * right = gui : : ProgressTimer : : create ( ) ; <nl> + right - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + right - > setPosition ( Point ( widgetSize . width / 2 . 0f + right - > getSize ( ) . width * 1 . 1 , widgetSize . height / 2 . 0f + right - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + right - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + right - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + right - > setBarChangeRate ( Point ( 0 , 1 ) ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( right ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UIProgressTimerTest_BarTintAndFade <nl> + bool UIProgressTimerTest_BarTintAndFade : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Progress Timer Bar Tint and Fade " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 725f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the progress timer <nl> + ProgressTo * to = ProgressTo : : create ( 6 , 100 . 0f ) ; <nl> + Action * tint = Sequence : : create ( TintTo : : create ( 1 , 255 , 0 , 0 ) , <nl> + TintTo : : create ( 1 , 0 , 255 , 0 ) , <nl> + TintTo : : create ( 1 , 0 , 0 , 255 ) , <nl> + NULL ) ; <nl> + Action * fade = Sequence : : create ( FadeTo : : create ( 1 . 0f , 0 ) , <nl> + FadeTo : : create ( 1 . 0f , 255 ) , <nl> + NULL ) ; <nl> + <nl> + gui : : ProgressTimer * left = gui : : ProgressTimer : : create ( ) ; <nl> + left - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + left - > setPosition ( Point ( widgetSize . width / 2 . 0f - left - > getSize ( ) . width * 1 . 1 , widgetSize . height / 2 . 0f + left - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + left - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + left - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + left - > setBarChangeRate ( Point ( 1 , 0 ) ) ; <nl> + left - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + left - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) tint - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( left ) ; <nl> + <nl> + gui : : ProgressTimer * middle = gui : : ProgressTimer : : create ( ) ; <nl> + middle - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + middle - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + middle - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + middle - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + middle - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + middle - > setBarChangeRate ( Point ( 1 , 1 ) ) ; <nl> + middle - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + middle - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) fade - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( middle ) ; <nl> + <nl> + gui : : ProgressTimer * right = gui : : ProgressTimer : : create ( ) ; <nl> + right - > loadTexture ( " cocosgui / potentiometerProgress . png " ) ; <nl> + right - > setPosition ( Point ( widgetSize . width / 2 . 0f + right - > getSize ( ) . width * 1 . 1 , widgetSize . height / 2 . 0f + right - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + right - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + right - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + right - > setBarChangeRate ( Point ( 0 , 1 ) ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) tint - > clone ( ) ) ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) fade - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( right ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UIProgressTimerTest_WithSpriteFrame <nl> + bool UIProgressTimerTest_WithSpriteFrame : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Progress Timer with SpriteFrame " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 725f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the progress timer <nl> + ProgressTo * to = ProgressTo : : create ( 6 , 100 . 0f ) ; <nl> + <nl> + SpriteFrameCache : : getInstance ( ) - > addSpriteFramesWithFile ( " zwoptex / grossini . plist " ) ; <nl> + <nl> + gui : : ProgressTimer * left = gui : : ProgressTimer : : create ( ) ; <nl> + left - > loadTexture ( " grossini_dance_01 . png " , UI_TEX_TYPE_PLIST ) ; <nl> + left - > setPosition ( Point ( widgetSize . width / 2 . 0f - left - > getSize ( ) . width * 2 . 0f , widgetSize . height / 2 . 0f + left - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + left - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + left - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + left - > setBarChangeRate ( Point ( 1 , 0 ) ) ; <nl> + left - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( left ) ; <nl> + <nl> + gui : : ProgressTimer * middle = gui : : ProgressTimer : : create ( ) ; <nl> + middle - > loadTexture ( " grossini_dance_04 . png " , UI_TEX_TYPE_PLIST ) ; <nl> + middle - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + middle - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + middle - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + middle - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + middle - > setBarChangeRate ( Point ( 1 , 1 ) ) ; <nl> + middle - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( middle ) ; <nl> + <nl> + gui : : ProgressTimer * right = gui : : ProgressTimer : : create ( ) ; <nl> + right - > loadTexture ( " grossini_dance_03 . png " , UI_TEX_TYPE_PLIST ) ; <nl> + right - > setPosition ( Point ( widgetSize . width / 2 . 0f + right - > getSize ( ) . width * 2 . 0f , widgetSize . height / 2 . 0f + right - > getSize ( ) . height / 6 . 0f ) ) ; <nl> + right - > setType ( cocos2d : : ProgressTimer : : Type : : BAR ) ; <nl> + / / Setup for a bar starting from the bottom since the midpoint is 0 for the y <nl> + right - > setMidPoint ( Point ( 0 . 5f , 0 . 5f ) ) ; <nl> + / / Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change <nl> + right - > setBarChangeRate ( Point ( 0 , 1 ) ) ; <nl> + right - > getVirtualRenderer ( ) - > runAction ( RepeatForever : : create ( ( ActionInterval * ) to - > clone ( ) ) ) ; <nl> + _uiLayer - > addChild ( right ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . b13d9796b1a2 <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIProgressTimerTest / UIProgressTimerTest . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2013 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all 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 , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # ifndef __TestCpp__UIProgressTimerTest__ <nl> + # define __TestCpp__UIProgressTimerTest__ <nl> + <nl> + # include " . . / UIScene . h " <nl> + <nl> + class UIProgressTimerTest_Radial : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIProgressTimerTest_Radial ) <nl> + } ; <nl> + <nl> + class UIProgressTimerTest_Horizontal : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIProgressTimerTest_Horizontal ) <nl> + } ; <nl> + <nl> + class UIProgressTimerTest_Vertical : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIProgressTimerTest_Vertical ) <nl> + } ; <nl> + <nl> + class UIProgressTimerTest_RadialMidpointChanged : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIProgressTimerTest_RadialMidpointChanged ) <nl> + } ; <nl> + <nl> + class UIProgressTimerTest_BarVarious : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIProgressTimerTest_BarVarious ) <nl> + } ; <nl> + <nl> + class UIProgressTimerTest_BarTintAndFade : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIProgressTimerTest_BarTintAndFade ) <nl> + } ; <nl> + <nl> + class UIProgressTimerTest_WithSpriteFrame : public UIScene <nl> + { <nl> + public : <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIProgressTimerTest_WithSpriteFrame ) <nl> + } ; <nl> + <nl> + # endif / * defined ( __TestCpp__UIProgressTimerTest__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScene . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScene . cpp <nl> <nl> # include " UISceneManager . h " <nl> # include " . . / ExtensionsTest . h " <nl> # include " editor - support / cocostudio / CCSGUIReader . h " <nl> + # include " CocosGUIScene . h " <nl> <nl> using namespace gui ; <nl> <nl> UIScene : : UIScene ( ) <nl> - : m_pSceneTitle ( NULL ) <nl> - , m_pUiLayer ( NULL ) <nl> + : _sceneTitle ( nullptr ) <nl> + , _uiLayer ( nullptr ) <nl> { <nl> <nl> } <nl> bool UIScene : : init ( ) <nl> { <nl> if ( CCLayer : : init ( ) ) <nl> { <nl> - m_pUiLayer = UILayer : : create ( ) ; <nl> - addChild ( m_pUiLayer ) ; <nl> + _uiLayer = Layer : : create ( ) ; <nl> + addChild ( _uiLayer ) ; <nl> <nl> - m_pWidget = dynamic_cast < UILayout * > ( cocostudio : : GUIReader : : shareReader ( ) - > widgetFromJsonFile ( " cocosgui / UITest / UITest . json " ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pWidget ) ; <nl> + _widget = dynamic_cast < Layout * > ( cocostudio : : GUIReader : : shareReader ( ) - > widgetFromJsonFile ( " cocosgui / UITest / UITest . json " ) ) ; <nl> + _uiLayer - > addChild ( _widget ) ; <nl> <nl> - m_pSceneTitle = dynamic_cast < UILabel * > ( m_pUiLayer - > getWidgetByName ( " UItest " ) ) ; <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> <nl> - UILabel * back_label = dynamic_cast < UILabel * > ( m_pUiLayer - > getWidgetByName ( " back " ) ) ; <nl> - back_label - > setVisible ( false ) ; <nl> - / / back_label - > addReleaseEvent ( this , coco_releaseselector ( UIScene : : toExtensionsMainLayer ) ) ; <nl> + _sceneTitle = dynamic_cast < gui : : Label * > ( root - > getChildByName ( " UItest " ) ) ; <nl> <nl> - UIButton * left_button = dynamic_cast < UIButton * > ( m_pUiLayer - > getWidgetByName ( " left_Button " ) ) ; <nl> + gui : : Label * back_label = dynamic_cast < gui : : Label * > ( root - > getChildByName ( " back " ) ) ; <nl> + back_label - > addTouchEventListener ( this , toucheventselector ( UIScene : : toCocosGUITestScene ) ) ; <nl> + <nl> + Button * left_button = dynamic_cast < Button * > ( root - > getChildByName ( " left_Button " ) ) ; <nl> left_button - > addTouchEventListener ( this , toucheventselector ( UIScene : : previousCallback ) ) ; <nl> <nl> - UIButton * middle_button = dynamic_cast < UIButton * > ( m_pUiLayer - > getWidgetByName ( " middle_Button " ) ) ; <nl> + Button * middle_button = dynamic_cast < Button * > ( root - > getChildByName ( " middle_Button " ) ) ; <nl> middle_button - > addTouchEventListener ( this , toucheventselector ( UIScene : : restartCallback ) ) ; <nl> <nl> - UIButton * right_button = dynamic_cast < UIButton * > ( m_pUiLayer - > getWidgetByName ( " right_Button " ) ) ; <nl> + Button * right_button = dynamic_cast < Button * > ( root - > getChildByName ( " right_Button " ) ) ; <nl> right_button - > addTouchEventListener ( this , toucheventselector ( UIScene : : nextCallback ) ) ; <nl> <nl> - <nl> - UILabel * mainMenuLabel = UILabel : : create ( ) ; <nl> + / * <nl> + gui : : Label * mainMenuLabel = gui : : Label : : create ( ) ; <nl> mainMenuLabel - > setText ( " MainMenu " ) ; <nl> mainMenuLabel - > setFontSize ( 20 ) ; <nl> mainMenuLabel - > setTouchScaleChangeEnabled ( true ) ; <nl> mainMenuLabel - > setPosition ( Point ( 430 , 30 ) ) ; <nl> mainMenuLabel - > setTouchEnabled ( true ) ; <nl> mainMenuLabel - > addTouchEventListener ( this , toucheventselector ( UIScene : : menuCloseCallback ) ) ; <nl> - m_pUiLayer - > addWidget ( mainMenuLabel ) ; <nl> + _uiLayer - > addWidget ( mainMenuLabel ) ; <nl> + * / <nl> <nl> <nl> return true ; <nl> void UIScene : : menuCloseCallback ( Object * pSender , TouchEventType type ) <nl> { <nl> if ( type = = TOUCH_EVENT_ENDED ) <nl> { <nl> - m_pUiLayer - > removeFromParent ( ) ; <nl> + _uiLayer - > removeFromParent ( ) ; <nl> auto scene = new ExtensionsTestScene ( ) ; <nl> scene - > runThisTest ( ) ; <nl> scene - > release ( ) ; <nl> } <nl> } <nl> <nl> + void UIScene : : toCocosGUITestScene ( Object * sender , TouchEventType type ) <nl> + { <nl> + if ( type = = TOUCH_EVENT_ENDED ) <nl> + { <nl> + UISceneManager : : purgeUISceneManager ( ) ; <nl> + <nl> + CocosGUITestScene * pScene = new CocosGUITestScene ( ) ; <nl> + pScene - > runThisTest ( ) ; <nl> + pScene - > release ( ) ; <nl> + } <nl> + } <nl> + <nl> void UIScene : : previousCallback ( Object * sender , TouchEventType type ) <nl> { <nl> if ( type = = TOUCH_EVENT_ENDED ) <nl> { <nl> - m_pUiLayer - > removeFromParent ( ) ; <nl> CCDirector : : getInstance ( ) - > replaceScene ( UISceneManager : : sharedUISceneManager ( ) - > previousUIScene ( ) ) ; <nl> } <nl> } <nl> void UIScene : : restartCallback ( Object * sender , TouchEventType type ) <nl> { <nl> if ( type = = TOUCH_EVENT_ENDED ) <nl> { <nl> - m_pUiLayer - > removeFromParent ( ) ; <nl> CCDirector : : getInstance ( ) - > replaceScene ( UISceneManager : : sharedUISceneManager ( ) - > currentUIScene ( ) ) ; <nl> } <nl> } <nl> void UIScene : : nextCallback ( Object * sender , TouchEventType type ) <nl> { <nl> if ( type = = TOUCH_EVENT_ENDED ) <nl> { <nl> - m_pUiLayer - > removeFromParent ( ) ; <nl> CCDirector : : getInstance ( ) - > replaceScene ( UISceneManager : : sharedUISceneManager ( ) - > nextUIScene ( ) ) ; <nl> } <nl> } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScene . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScene . h <nl> static Scene * sceneWithTitle ( const char * title ) \ <nl> return pScene ; \ <nl> } <nl> <nl> - / / # define UI_SCENE_CREATE_FUNC ( UIScene ) \ <nl> - / / public : \ <nl> - / / static CCScene * sceneWithTitle ( const char * title ) \ <nl> - / / { \ <nl> - / / CCScene * pScene = CCScene : : create ( ) ; \ <nl> - / / UIScene * uiLayer = new UIScene ( ) ; \ <nl> - / / if ( uiLayer & & uiLayer - > init ( ) ) \ <nl> - / / { \ <nl> - / / uiLayer - > autorelease ( ) ; \ <nl> - / / uiLayer - > getSceneTitleLabel ( ) - > setString ( title ) ; \ <nl> - / / pScene - > addChild ( uiLayer ) ; \ <nl> - / / } \ <nl> - / / else \ <nl> - / / { \ <nl> - / / CC_SAFE_DELETE ( uiLayer ) ; \ <nl> - / / } \ <nl> - / / return pScene ; \ <nl> - / / } <nl> - <nl> class UIScene : public Layer <nl> { <nl> public : <nl> class UIScene : public Layer <nl> ~ UIScene ( ) ; <nl> bool init ( ) ; <nl> / / Menu Callbacks <nl> + void toCocosGUITestScene ( Object * sender , TouchEventType type ) ; <nl> virtual void previousCallback ( Object * sender , TouchEventType type ) ; <nl> virtual void restartCallback ( Object * sender , TouchEventType type ) ; <nl> virtual void nextCallback ( Object * sender , TouchEventType type ) ; <nl> <nl> - / * * Title label of the scene . * / <nl> - / / CC_SYNTHESIZE_RETAIN ( CCLabelTTF * , m_pSceneTitleLabel , SceneTitleLabel ) <nl> - <nl> - CC_SYNTHESIZE_READONLY ( UILabel * , m_pSceneTitle , SceneTitle ) <nl> + / * * Title label of the scene . * / <nl> + CC_SYNTHESIZE_READONLY ( gui : : Label * , _sceneTitle , SceneTitle ) <nl> <nl> UI_SCENE_CREATE_FUNC ( UIScene ) ; <nl> <nl> class UIScene : public Layer <nl> void menuCloseCallback ( Object * pSender , TouchEventType type ) ; <nl> <nl> protected : <nl> - UILayer * m_pUiLayer ; <nl> - UILayout * m_pWidget ; <nl> + Layer * _uiLayer ; <nl> + Layout * _widget ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UIScene__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISceneManager . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISceneManager . cpp <nl> <nl> # include " UISceneManager . h " <nl> # include " UIScene . h " <nl> # include " UIButtonTest / UIButtonTest . h " <nl> - # include " UITextButtonTest / UITextButtonTest . h " <nl> # include " UICheckBoxTest / UICheckBoxTest . h " <nl> # include " UISliderTest / UISliderTest . h " <nl> # include " UIImageViewTest / UIImageViewTest . h " <nl> # include " UILoadingBarTest / UILoadingBarTest . h " <nl> # include " UILabelAtlasTest / UILabelAtlasTest . h " <nl> # include " UILabelTest / UILabelTest . h " <nl> - # include " UITextAreaTest / UITextAreaTest . h " <nl> # include " UILabelBMFontTest / UILabelBMFontTest . h " <nl> # include " UITextFieldTest / UITextFieldTest . h " <nl> - # include " UIPanelTest / UIPanelTest . h " <nl> + # include " UILayoutTest / UILayoutTest . h " <nl> # include " UIScrollViewTest / UIScrollViewTest . h " <nl> # include " UIPageViewTest / UIPageViewTest . h " <nl> # include " UIListViewTest / UIListViewTest . h " <nl> - # include " UIDragPanelTest / UIDragPanelTest . h " <nl> - # include " UINodeContainerTest / UINodeContainerTest . h " <nl> + # include " UIWidgetAddNodeTest / UIWidgetAddNodeTest . h " <nl> + / * <nl> + # include " UIGridViewTest / UIGridViewTest . h " <nl> + # include " UIPickerViewTest / UIPickerViewTest . h " <nl> + # include " UISwitchTest / UISwitchTest . h " <nl> + # include " UIProgressTimerTest / UIProgressTimerTest . h " <nl> + # include " UIPotentiometerTest / UIPotentiometerTest . h " <nl> + * / <nl> <nl> USING_NS_CC ; <nl> <nl> - enum <nl> - { <nl> - kUIButtonTest = 0 , <nl> - kUIButtonTest_Scale9 , <nl> - kUIButtonTest_PressedAction , <nl> - kUITextButtonTest , <nl> - kUITextButtonTest_Scale9 , <nl> - kUICheckBoxTest , <nl> - kUISliderTest , <nl> - kUISliderTest_Scale9 , <nl> - kUIImageViewTest , <nl> - kUIImageViewTest_Scale9 , <nl> - kUILoadingBarTest_Left , <nl> - kUILoadingBarTest_Right , <nl> - kUILoadingBarTest_Left_Scale9 , <nl> - kUILoadingBarTest_Right_Scale9 , <nl> - kUILabelAtlasTest , <nl> - kUILabelTest , <nl> - kUITextAreaTest , <nl> - kUILabelBMFontTest , <nl> - kUITextFieldTest , <nl> - kUITextFieldTest_MaxLength , <nl> - kUITextFieldTest_Password , <nl> - kUIPanelTest , <nl> - kUIPanelTest_Color , <nl> - kUIPanelTest_Gradient , <nl> - kUIPanelTest_BackGroundImage , <nl> - kUIPanelTest_BackGroundImage_Scale9 , <nl> - kUIPanelTest_Layout_Linear_Vertical , <nl> - kUIPanelTest_Layout_Linear_Horizontal , <nl> - / / kUIPanelTest_Layout_Linear_Relative , <nl> - kUIScrollViewTest_Vertical , <nl> - kUIScrollViewTest_Horizontal , <nl> - kUIPageViewTest , <nl> - kUIListViewTest_Vertical , <nl> - kUIListViewTest_Horizontal , <nl> - kUIDragPanelTest , <nl> - kUIDragPanelTest_Bounce , <nl> - kUINodeContainerTest , <nl> - kUITestMax <nl> - } ; <nl> - <nl> static const char * s_testArray [ ] = <nl> { <nl> " UIButtonTest " , <nl> " UIButtonTest_Scale9 " , <nl> " UIButtonTest_PressedAction " , <nl> - " UITextButtonTest " , <nl> - " UITextButtonTest_Scale9 " , <nl> + " UIButtonTest_Title " , <nl> " UICheckBoxTest " , <nl> " UISliderTest " , <nl> " UISliderTest_Scale9 " , <nl> + / * <nl> + " UIPotentiometerTest " , <nl> + " UISwitchTest_Horizontal " , <nl> + " UISwitchTest_Vertical " , <nl> + " UISwitchTest_VerticalAndTitleVertical " , <nl> + * / <nl> " UIImageViewTest " , <nl> " UIImageViewTest_Scale9 " , <nl> " UILoadingBarTest_Left " , <nl> " UILoadingBarTest_Right " , <nl> " UILoadingBarTest_Left_Scale9 " , <nl> " UILoadingBarTest_Right_Scale9 " , <nl> + / * <nl> + " UIProgressTimerTest_Radial " , <nl> + " UIProgressTimerTest_Horizontal " , <nl> + " UIProgressTimerTest_Vertical " , <nl> + " UIProgressTimerTest_RadialMidpointChanged " , <nl> + " UIProgressTimerTest_BarVarious " , <nl> + " UIProgressTimerTest_BarTintAndFade " , <nl> + " UIProgressTimerTest_WithSpriteFrame " , <nl> + * / <nl> " UILabelAtlasTest " , <nl> " UILabelTest " , <nl> - " UITextAreaTest " , <nl> + " UILabelTest_LineWrap " , <nl> + / * <nl> + " UILabelTest_Effect " , <nl> + * / <nl> + " UILabelTest_TTF " , <nl> " UILabelBMFontTest " , <nl> " UITextFieldTest " , <nl> " UITextFieldTest_MaxLength " , <nl> " UITextFieldTest_Password " , <nl> - " UIPanelTest " , <nl> - " UIPanelTest_Color " , <nl> - " UIPanelTest_Gradient " , <nl> - " UIPanelTest_BackGroundImage " , <nl> - " UIPanelTest_BackGroundImage_Scale9 " , <nl> - " UIPanelTest_Layout_Linear_Vertical " , <nl> - " UIPanelTest_Layout_Linear_Horizontal " , <nl> - / / " UIPanelTest_Layout_Linear_Relative " , <nl> + " UILayoutTest " , <nl> + " UILayoutTest_Color " , <nl> + " UILayoutTest_Gradient " , <nl> + " UILayoutTest_BackGroundImage " , <nl> + " UILayoutTest_BackGroundImage_Scale9 " , <nl> + " UILayoutTest_Layout_Linear_Vertical " , <nl> + " UILayoutTest_Layout_Linear_Horizontal " , <nl> + " UILayoutTest_Layout_Relative_Align_Parent " , <nl> + " UILayoutTest_Layout_Relative_Location " , <nl> + / * <nl> + " UILayoutTest_Layout_Grid " , <nl> + * / <nl> " UIScrollViewTest_Vertical " , <nl> " UIScrollViewTest_Horizontal " , <nl> + " UIScrollViewTest_Both " , <nl> + " UIScrollViewTest_ScrollToPercentBothDirection " , <nl> + " UIScrollViewTest_ScrollToPercentBothDirection_Bounce " , <nl> " UIPageViewTest , " , <nl> " UIListViewTest_Vertical " , <nl> " UIListViewTest_Horizontal " , <nl> - " UIDragPanelTest " , <nl> - " UIDragPanelTest_Bounce " , <nl> - " UINodeContainerTest " , <nl> + / * <nl> + " UIGridViewTest_Mode_Column " , <nl> + " UIGridViewTest_Mode_Row " , <nl> + " UIPickerViewTest_Vertical " , <nl> + " UIPickerViewTest_Horizontal " , <nl> + * / <nl> + " UIWidgetAddNodeTest " , <nl> } ; <nl> <nl> static UISceneManager * sharedInstance = NULL ; <nl> static UISceneManager * sharedInstance = NULL ; <nl> <nl> UISceneManager : : UISceneManager ( ) <nl> { <nl> - m_nCurrentUISceneId = kUIButtonTest ; <nl> + _currentUISceneId = kUIButtonTest ; <nl> } <nl> <nl> UISceneManager : : ~ UISceneManager ( ) <nl> void UISceneManager : : purgeUISceneManager ( ) <nl> <nl> Scene * UISceneManager : : nextUIScene ( ) <nl> { <nl> - m_nCurrentUISceneId = ( m_nCurrentUISceneId + 1 ) % kUITestMax ; <nl> + _currentUISceneId = _currentUISceneId + 1 ; <nl> + if ( _currentUISceneId > _maxUISceneId ) <nl> + { <nl> + _currentUISceneId = _minUISceneId ; <nl> + } <nl> + / / _currentUISceneId = ( _currentUISceneId + 1 ) % kUITestMax ; <nl> <nl> return currentUIScene ( ) ; <nl> } <nl> <nl> Scene * UISceneManager : : previousUIScene ( ) <nl> { <nl> - m_nCurrentUISceneId = m_nCurrentUISceneId - 1 ; <nl> - if ( m_nCurrentUISceneId < 0 ) <nl> + _currentUISceneId = _currentUISceneId - 1 ; <nl> + if ( _currentUISceneId < _minUISceneId ) <nl> { <nl> - m_nCurrentUISceneId = kUITestMax - 1 ; <nl> + _currentUISceneId = _maxUISceneId ; <nl> } <nl> + / * <nl> + _currentUISceneId = _currentUISceneId - 1 ; <nl> + if ( _currentUISceneId < 0 ) <nl> + { <nl> + _currentUISceneId = kUITestMax - 1 ; <nl> + } <nl> + * / <nl> <nl> return currentUIScene ( ) ; <nl> } <nl> <nl> Scene * UISceneManager : : currentUIScene ( ) <nl> { <nl> - switch ( m_nCurrentUISceneId ) <nl> + switch ( _currentUISceneId ) <nl> { <nl> case kUIButtonTest : <nl> - return UIButtonTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIButtonTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUIButtonTest_Scale9 : <nl> - return UIButtonTest_Scale9 : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIButtonTest_Scale9 : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUIButtonTest_PressedAction : <nl> - return UIButtonTest_PressedAction : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIButtonTest_PressedAction : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUITextButtonTest : <nl> - return UITextButtonTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> - <nl> - case kUITextButtonTest_Scale9 : <nl> - return UITextButtonTest_Scale9 : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUIButtonTest_Title : <nl> + return UIButtonTest_Title : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUICheckBoxTest : <nl> - return UICheckBoxTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UICheckBoxTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUISliderTest : <nl> - return UISliderTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UISliderTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUISliderTest_Scale9 : <nl> - return UISliderTest_Scale9 : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UISliderTest_Scale9 : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + / * <nl> + case kUIPotentiometerTest : <nl> + return UIPotentiometerTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUISwitchTest_Horizontal : <nl> + return UISwitchTest_Horizontal : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUISwitchTest_Vertical : <nl> + return UISwitchTest_Vertical : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUISwitchTest_VerticalAndTitleVertical : <nl> + return UISwitchTest_VerticalAndTitleVertical : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + * / <nl> <nl> case kUIImageViewTest : <nl> - return UIImageViewTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIImageViewTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUIImageViewTest_Scale9 : <nl> - return UIImageViewTest_Scale9 : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIImageViewTest_Scale9 : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUILoadingBarTest_Left : <nl> - return UILoadingBarTest_Left : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UILoadingBarTest_Left : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUILoadingBarTest_Right : <nl> - return UILoadingBarTest_Right : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UILoadingBarTest_Right : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUILoadingBarTest_Left_Scale9 : <nl> - return UILoadingBarTest_Left_Scale9 : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UILoadingBarTest_Left_Scale9 : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUILoadingBarTest_Right_Scale9 : <nl> - return UILoadingBarTest_Right_Scale9 : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UILoadingBarTest_Right_Scale9 : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + / * <nl> + case kUIProgressTimerTest_Radial : <nl> + return UIProgressTimerTest_Radial : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIProgressTimerTest_Horizontal : <nl> + return UIProgressTimerTest_Horizontal : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIProgressTimerTest_Vertical : <nl> + return UIProgressTimerTest_Vertical : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIProgressTimerTest_RadialMidpointChanged : <nl> + return UIProgressTimerTest_RadialMidpointChanged : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIProgressTimerTest_BarVarious : <nl> + return UIProgressTimerTest_BarVarious : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIProgressTimerTest_BarTintAndFade : <nl> + return UIProgressTimerTest_BarTintAndFade : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIProgressTimerTest_WithSpriteFrame : <nl> + return UIProgressTimerTest_WithSpriteFrame : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + * / <nl> <nl> case kUILabelAtlasTest : <nl> - return UILabelAtlasTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UILabelAtlasTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUILabelBMFontTest : <nl> - return UILabelBMFontTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UILabelBMFontTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUILabelTest : <nl> - return UILabelTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UILabelTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUILabelTest_LineWrap : <nl> + return UILabelTest_LineWrap : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + / * <nl> + case kUILabelTest_Effect : <nl> + return UILabelTest_Effect : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + * / <nl> <nl> - case kUITextAreaTest : <nl> - return UITextAreaTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILabelTest_TTF : <nl> + return UILabelTest_TTF : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUITextFieldTest : <nl> - return UITextFieldTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UITextFieldTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUITextFieldTest_MaxLength : <nl> - return UITextFieldTest_MaxLength : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UITextFieldTest_MaxLength : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUITextFieldTest_Password : <nl> - return UITextFieldTest_Password : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UITextFieldTest_Password : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIPanelTest : <nl> - return UIPanelTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILayoutTest : <nl> + return UILayoutTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIPanelTest_Color : <nl> - return UIPanelTest_Color : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILayoutTest_Color : <nl> + return UILayoutTest_Color : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIPanelTest_Gradient : <nl> - return UIPanelTest_Gradient : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILayoutTest_Gradient : <nl> + return UILayoutTest_Gradient : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIPanelTest_BackGroundImage : <nl> - return UIPanelTest_BackGroundImage : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILayoutTest_BackGroundImage : <nl> + return UILayoutTest_BackGroundImage : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIPanelTest_BackGroundImage_Scale9 : <nl> - return UIPanelTest_BackGroundImage_Scale9 : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILayoutTest_BackGroundImage_Scale9 : <nl> + return UILayoutTest_BackGroundImage_Scale9 : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIPanelTest_Layout_Linear_Vertical : <nl> - return UIPanelTest_Layout_Linear_Vertical : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILayoutTest_Layout_Linear_Vertical : <nl> + return UILayoutTest_Layout_Linear_Vertical : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIPanelTest_Layout_Linear_Horizontal : <nl> - return UIPanelTest_Layout_Linear_Horizontal : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILayoutTest_Layout_Linear_Horizontal : <nl> + return UILayoutTest_Layout_Linear_Horizontal : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUILayoutTest_Layout_Relative_Align_Parent : <nl> + return UILayoutTest_Layout_Relative_Align_Parent : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUILayoutTest_Layout_Relative_Location : <nl> + return UILayoutTest_Layout_Relative_Location : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> / * <nl> - case kUIPanelTest_Layout_Linear_Relative : <nl> - return UIPanelTest_Layout_Relative : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUILayoutTest_Layout_Grid : <nl> + return UILayoutTest_Layout_Grid : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> * / <nl> <nl> case kUIScrollViewTest_Vertical : <nl> - return UIScrollViewTest_Vertical : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIScrollViewTest_Vertical : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUIScrollViewTest_Horizontal : <nl> - return UIScrollViewTest_Horizontal : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIScrollViewTest_Horizontal : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIScrollViewTest_Both : <nl> + return UIScrollViewTest_Both : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIScrollViewTest_ScrollToPercentBothDirection : <nl> + return UIScrollViewTest_ScrollToPercentBothDirection : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIScrollViewTest_ScrollToPercentBothDirection_Bounce : <nl> + return UIScrollViewTest_ScrollToPercentBothDirection_Bounce : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUIPageViewTest : <nl> - return UIPageViewTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIPageViewTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUIListViewTest_Vertical : <nl> - return UIListViewTest_Vertical : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIListViewTest_Vertical : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> case kUIListViewTest_Horizontal : <nl> - return UIListViewTest_Horizontal : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + return UIListViewTest_Horizontal : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIDragPanelTest : <nl> - return UIDragPanelTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + / * <nl> + case kUIGridViewTest_Mode_Column : <nl> + return UIGridViewTest_Mode_Column : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIGridViewTest_Mode_Row : <nl> + return UIGridViewTest_Mode_Row : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> <nl> - case kUIDragPanelTest_Bounce : <nl> - return UIDragPanelTest_Bounce : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUIPickerViewTest_Vertical : <nl> + return UIPickerViewTest_Vertical : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + <nl> + case kUIPickerViewTest_Horizontal : <nl> + return UIPickerViewTest_Horizontal : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> + * / <nl> <nl> - case kUINodeContainerTest : <nl> - return UINodeContainerTest : : sceneWithTitle ( s_testArray [ m_nCurrentUISceneId ] ) ; <nl> + case kUIWidgetAddNodeTest : <nl> + return UIWidgetAddNodeTest : : sceneWithTitle ( s_testArray [ _currentUISceneId ] ) ; <nl> } <nl> return NULL ; <nl> } <nl> \ No newline at end of file <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISceneManager . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISceneManager . h <nl> <nl> <nl> USING_NS_CC ; <nl> <nl> + enum <nl> + { <nl> + kUIButtonTest = 0 , <nl> + kUIButtonTest_Scale9 , <nl> + kUIButtonTest_PressedAction , <nl> + kUIButtonTest_Title , <nl> + kUICheckBoxTest , <nl> + kUISliderTest , <nl> + kUISliderTest_Scale9 , <nl> + / * <nl> + kUIPotentiometerTest , <nl> + kUISwitchTest_Horizontal , <nl> + kUISwitchTest_Vertical , <nl> + kUISwitchTest_VerticalAndTitleVertical , <nl> + * / <nl> + kUIImageViewTest , <nl> + kUIImageViewTest_Scale9 , <nl> + kUILoadingBarTest_Left , <nl> + kUILoadingBarTest_Right , <nl> + kUILoadingBarTest_Left_Scale9 , <nl> + kUILoadingBarTest_Right_Scale9 , <nl> + / * <nl> + kUIProgressTimerTest_Radial , <nl> + kUIProgressTimerTest_Horizontal , <nl> + kUIProgressTimerTest_Vertical , <nl> + kUIProgressTimerTest_RadialMidpointChanged , <nl> + kUIProgressTimerTest_BarVarious , <nl> + kUIProgressTimerTest_BarTintAndFade , <nl> + kUIProgressTimerTest_WithSpriteFrame , <nl> + * / <nl> + kUILabelAtlasTest , <nl> + kUILabelTest , <nl> + kUILabelTest_LineWrap , <nl> + / * <nl> + kUILabelTest_Effect , <nl> + * / <nl> + kUILabelTest_TTF , <nl> + kUILabelBMFontTest , <nl> + kUITextFieldTest , <nl> + kUITextFieldTest_MaxLength , <nl> + kUITextFieldTest_Password , <nl> + kUILayoutTest , <nl> + kUILayoutTest_Color , <nl> + kUILayoutTest_Gradient , <nl> + kUILayoutTest_BackGroundImage , <nl> + kUILayoutTest_BackGroundImage_Scale9 , <nl> + kUILayoutTest_Layout_Linear_Vertical , <nl> + kUILayoutTest_Layout_Linear_Horizontal , <nl> + kUILayoutTest_Layout_Relative_Align_Parent , <nl> + kUILayoutTest_Layout_Relative_Location , <nl> + / * <nl> + kUILayoutTest_Layout_Grid , <nl> + * / <nl> + kUIScrollViewTest_Vertical , <nl> + kUIScrollViewTest_Horizontal , <nl> + kUIScrollViewTest_Both , <nl> + kUIScrollViewTest_ScrollToPercentBothDirection , <nl> + kUIScrollViewTest_ScrollToPercentBothDirection_Bounce , <nl> + kUIPageViewTest , <nl> + kUIListViewTest_Vertical , <nl> + kUIListViewTest_Horizontal , <nl> + / * <nl> + kUIGridViewTest_Mode_Column , <nl> + kUIGridViewTest_Mode_Row , <nl> + kUIPickerViewTest_Vertical , <nl> + kUIPickerViewTest_Horizontal , <nl> + * / <nl> + kUIWidgetAddNodeTest , <nl> + kUITestMax <nl> + } ; <nl> + <nl> class UISceneManager : public Object <nl> { <nl> public : <nl> class UISceneManager : public Object <nl> cocos2d : : Scene * currentUIScene ( ) ; <nl> <nl> / * * UI scene id . * / <nl> - CC_SYNTHESIZE ( int , m_nCurrentUISceneId , CurrentUISceneId ) <nl> + CC_SYNTHESIZE ( int , _currentUISceneId , CurrentUISceneId ) <nl> + <nl> + CC_SYNTHESIZE ( int , _minUISceneId , MinUISceneId ) <nl> + CC_SYNTHESIZE ( int , _maxUISceneId , MaxUISceneId ) <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UISceneManager__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp <nl> <nl> <nl> # include " UIScrollViewTest . h " <nl> <nl> - const char * font_UIScrollViewTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UIScrollViewTest_Vertical <nl> <nl> UIScrollViewTest_Vertical : : UIScrollViewTest_Vertical ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> } <nl> <nl> bool UIScrollViewTest_Vertical : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the scrollview alert will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " Move by vertical direction " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIScrollViewTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move by vertical direction " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getContentSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " ScrollView " ) ; <nl> - alert - > setFontName ( font_UIScrollViewTest ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " ScrollView vertical " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the scrollview by vertical <nl> - UIScrollView * scrollView = UIScrollView : : create ( ) ; <nl> + gui : : ScrollView * scrollView = gui : : ScrollView : : create ( ) ; <nl> scrollView - > setTouchEnabled ( true ) ; <nl> - scrollView - > setSize ( Size ( 280 , 150 ) ) ; <nl> + scrollView - > setSize ( Size ( 280 . 0f , 150 . 0f ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> - scrollView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - scrollView - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - scrollView - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( scrollView ) ; <nl> + scrollView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - scrollView - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - scrollView - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( scrollView ) ; <nl> <nl> - UIImageView * imageView = UIImageView : : create ( ) ; <nl> + ImageView * imageView = ImageView : : create ( ) ; <nl> imageView - > loadTexture ( " cocosgui / ccicon . png " ) ; <nl> <nl> float innerWidth = scrollView - > getSize ( ) . width ; <nl> bool UIScrollViewTest_Vertical : : init ( ) <nl> <nl> scrollView - > setInnerContainerSize ( Size ( innerWidth , innerHeight ) ) ; <nl> <nl> - UIButton * button = UIButton : : create ( ) ; <nl> + Button * button = Button : : create ( ) ; <nl> button - > setTouchEnabled ( true ) ; <nl> button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - button - > setPosition ( Point ( innerWidth / 2 , scrollView - > getInnerContainerSize ( ) . height - button - > getSize ( ) . height / 2 ) ) ; <nl> + button - > setPosition ( Point ( innerWidth / 2 . 0f , scrollView - > getInnerContainerSize ( ) . height - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> scrollView - > addChild ( button ) ; <nl> <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - textButton - > setPosition ( Point ( innerWidth / 2 , button - > getBottomInParent ( ) - button - > getSize ( ) . height ) ) ; <nl> - scrollView - > addChild ( textButton ) ; <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + titleButton - > setPosition ( Point ( innerWidth / 2 . 0f , button - > getBottomInParent ( ) - button - > getSize ( ) . height ) ) ; <nl> + scrollView - > addChild ( titleButton ) ; <nl> <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> button_scale9 - > setTouchEnabled ( true ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Point ( innerWidth / 2 , textButton - > getBottomInParent ( ) - textButton - > getSize ( ) . height ) ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + button_scale9 - > setPosition ( Point ( innerWidth / 2 . 0f , titleButton - > getBottomInParent ( ) - titleButton - > getSize ( ) . height ) ) ; <nl> scrollView - > addChild ( button_scale9 ) ; <nl> <nl> - imageView - > setPosition ( Point ( innerWidth / 2 , imageView - > getSize ( ) . height / 2 ) ) ; <nl> - scrollView - > addChild ( imageView ) ; <nl> + imageView - > setPosition ( Point ( innerWidth / 2 . 0f , imageView - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + scrollView - > addChild ( imageView ) ; <nl> <nl> return true ; <nl> } <nl> bool UIScrollViewTest_Vertical : : init ( ) <nl> / / UIScrollViewTest_Horizontal <nl> <nl> UIScrollViewTest_Horizontal : : UIScrollViewTest_Horizontal ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> } <nl> <nl> bool UIScrollViewTest_Horizontal : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the scrollview alert will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " Move by horizontal direction " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UIScrollViewTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getContentSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> - <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " ScrollView " ) ; <nl> - alert - > setFontName ( font_UIScrollViewTest ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move by horizontal direction " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getContentSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " ScrollView horizontal " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> - UILayout * background = dynamic_cast < UILayout * > ( m_pUiLayer - > getWidgetByName ( " background_Panel " ) ) ; <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> <nl> / / Create the scrollview by horizontal <nl> - UIScrollView * scrollView = UIScrollView : : create ( ) ; <nl> + gui : : ScrollView * scrollView = gui : : ScrollView : : create ( ) ; <nl> scrollView - > setBounceEnabled ( true ) ; <nl> scrollView - > setDirection ( SCROLLVIEW_DIR_HORIZONTAL ) ; <nl> scrollView - > setTouchEnabled ( true ) ; <nl> - scrollView - > setSize ( Size ( 280 , 150 ) ) ; <nl> + scrollView - > setSize ( Size ( 280 . 0f , 150 . 0f ) ) ; <nl> scrollView - > setInnerContainerSize ( scrollView - > getSize ( ) ) ; <nl> Size backgroundSize = background - > getContentSize ( ) ; <nl> - scrollView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 + <nl> - ( backgroundSize . width - scrollView - > getSize ( ) . width ) / 2 , <nl> - ( widgetSize . height - backgroundSize . height ) / 2 + <nl> - ( backgroundSize . height - scrollView - > getSize ( ) . height ) / 2 ) ) ; <nl> - m_pUiLayer - > addWidget ( scrollView ) ; <nl> + scrollView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - scrollView - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - scrollView - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( scrollView ) ; <nl> <nl> - UIImageView * imageView = UIImageView : : create ( ) ; <nl> + ImageView * imageView = ImageView : : create ( ) ; <nl> imageView - > loadTexture ( " cocosgui / ccicon . png " ) ; <nl> <nl> float innerWidth = scrollView - > getSize ( ) . width + imageView - > getSize ( ) . width ; <nl> bool UIScrollViewTest_Horizontal : : init ( ) <nl> <nl> scrollView - > setInnerContainerSize ( Size ( innerWidth , innerHeight ) ) ; <nl> <nl> - UIButton * button = UIButton : : create ( ) ; <nl> + Button * button = Button : : create ( ) ; <nl> button - > setTouchEnabled ( true ) ; <nl> button - > loadTextures ( " cocosgui / animationbuttonnormal . png " , " cocosgui / animationbuttonpressed . png " , " " ) ; <nl> - button - > setPosition ( Point ( button - > getSize ( ) . width / 2 , <nl> - scrollView - > getInnerContainerSize ( ) . height - button - > getSize ( ) . height / 2 ) ) ; <nl> + button - > setPosition ( Point ( button - > getSize ( ) . width / 2 . 0f , <nl> + scrollView - > getInnerContainerSize ( ) . height - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> scrollView - > addChild ( button ) ; <nl> <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - textButton - > setPosition ( Point ( button - > getRightInParent ( ) + button - > getSize ( ) . width / 2 , <nl> - button - > getBottomInParent ( ) - button - > getSize ( ) . height / 2 ) ) ; <nl> - scrollView - > addChild ( textButton ) ; <nl> + Button * titleButton = Button : : create ( ) ; <nl> + titleButton - > setTouchEnabled ( true ) ; <nl> + titleButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> + titleButton - > setTitleText ( " Title Button " ) ; <nl> + titleButton - > setPosition ( Point ( button - > getRightInParent ( ) + button - > getSize ( ) . width / 2 . 0f , <nl> + button - > getBottomInParent ( ) - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + scrollView - > addChild ( titleButton ) ; <nl> <nl> - UIButton * button_scale9 = UIButton : : create ( ) ; <nl> + Button * button_scale9 = Button : : create ( ) ; <nl> button_scale9 - > setTouchEnabled ( true ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - button_scale9 - > setSize ( Size ( 100 , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Point ( textButton - > getRightInParent ( ) + textButton - > getSize ( ) . width / 2 , <nl> - textButton - > getBottomInParent ( ) - textButton - > getSize ( ) . height / 2 ) ) ; <nl> + button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getContentSize ( ) . height ) ) ; <nl> + button_scale9 - > setPosition ( Point ( titleButton - > getRightInParent ( ) + titleButton - > getSize ( ) . width / 2 . 0f , <nl> + titleButton - > getBottomInParent ( ) - titleButton - > getSize ( ) . height / 2 . 0f ) ) ; <nl> scrollView - > addChild ( button_scale9 ) ; <nl> <nl> - imageView - > setPosition ( Point ( innerWidth - imageView - > getSize ( ) . width / 2 , <nl> - button_scale9 - > getBottomInParent ( ) - button_scale9 - > getSize ( ) . height / 2 ) ) ; <nl> + imageView - > setPosition ( Point ( innerWidth - imageView - > getSize ( ) . width / 2 . 0f , <nl> + button_scale9 - > getBottomInParent ( ) - button_scale9 - > getSize ( ) . height / 2 . 0f ) ) ; <nl> scrollView - > addChild ( imageView ) ; <nl> <nl> return true ; <nl> } <nl> <nl> return false ; <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> + / / UIScrollViewTest_Both <nl> + UIScrollViewTest_Both : : UIScrollViewTest_Both ( ) <nl> + : _displayValueLabel ( nullptr ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIScrollViewTest_Both : : ~ UIScrollViewTest_Both ( ) <nl> + { <nl> + } <nl> + <nl> + bool UIScrollViewTest_Both : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; ; <nl> + <nl> + / / Add a label in which the dragpanel events will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move by any direction " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " ScrollView both " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + / / Create the dragpanel <nl> + gui : : ScrollView * scrollView = gui : : ScrollView : : create ( ) ; <nl> + scrollView - > setDirection ( SCROLLVIEW_DIR_BOTH ) ; <nl> + scrollView - > setTouchEnabled ( true ) ; <nl> + scrollView - > setBounceEnabled ( true ) ; <nl> + scrollView - > setBackGroundImageScale9Enabled ( true ) ; <nl> + scrollView - > setBackGroundImage ( " cocosgui / green_edit . png " ) ; <nl> + scrollView - > setSize ( Size ( 210 , 122 . 5 ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + scrollView - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - scrollView - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - scrollView - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + ImageView * imageView = ImageView : : create ( ) ; <nl> + imageView - > setTouchEnabled ( true ) ; <nl> + imageView - > loadTexture ( " Hello . png " ) ; <nl> + scrollView - > addChild ( imageView ) ; <nl> + <nl> + scrollView - > setInnerContainerSize ( imageView - > getContentSize ( ) ) ; <nl> + Size innerSize = scrollView - > getInnerContainerSize ( ) ; <nl> + imageView - > setPosition ( Point ( innerSize . width / 2 . 0f , innerSize . height / 2 . 0f ) ) ; <nl> + <nl> + _uiLayer - > addChild ( scrollView ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + / / UIScrollViewTest_ScrollToPercentBothDirection <nl> + UIScrollViewTest_ScrollToPercentBothDirection : : UIScrollViewTest_ScrollToPercentBothDirection ( ) <nl> + : _displayValueLabel ( nullptr ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIScrollViewTest_ScrollToPercentBothDirection : : ~ UIScrollViewTest_ScrollToPercentBothDirection ( ) <nl> + { <nl> + } <nl> + <nl> + bool UIScrollViewTest_ScrollToPercentBothDirection : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the dragpanel events will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + / / _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " ScrollView scroll to percent both directrion " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = static_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + gui : : ScrollView * sc = gui : : ScrollView : : create ( ) ; <nl> + sc - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> + sc - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> + sc - > setDirection ( SCROLLVIEW_DIR_BOTH ) ; <nl> + sc - > setInnerContainerSize ( Size ( 480 , 320 ) ) ; <nl> + sc - > setSize ( Size ( 100 , 100 ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + sc - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - sc - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - sc - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + sc - > scrollToPercentBothDirection ( Point ( 50 , 50 ) , 1 , true ) ; <nl> + ImageView * iv = ImageView : : create ( ) ; <nl> + iv - > loadTexture ( " cocosgui / Hello . png " ) ; <nl> + iv - > setPosition ( Point ( 240 , 160 ) ) ; <nl> + sc - > addChild ( iv ) ; <nl> + _uiLayer - > addChild ( sc ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + / / UIScrollViewTest_ScrollToPercentBothDirection_Bounce <nl> + UIScrollViewTest_ScrollToPercentBothDirection_Bounce : : UIScrollViewTest_ScrollToPercentBothDirection_Bounce ( ) <nl> + : _displayValueLabel ( nullptr ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIScrollViewTest_ScrollToPercentBothDirection_Bounce : : ~ UIScrollViewTest_ScrollToPercentBothDirection_Bounce ( ) <nl> + { <nl> + } <nl> + <nl> + bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the dragpanel events will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + / / _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " ScrollView scroll to percent both directrion bounce " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 4 . 5 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + Layout * root = static_cast < Layout * > ( _uiLayer - > getChildByTag ( 81 ) ) ; <nl> + <nl> + Layout * background = dynamic_cast < Layout * > ( root - > getChildByName ( " background_Panel " ) ) ; <nl> + <nl> + gui : : ScrollView * sc = gui : : ScrollView : : create ( ) ; <nl> + sc - > setBackGroundColor ( Color3B : : GREEN ) ; <nl> + sc - > setBackGroundColorType ( LAYOUT_COLOR_SOLID ) ; <nl> + sc - > setBounceEnabled ( true ) ; <nl> + sc - > setDirection ( SCROLLVIEW_DIR_BOTH ) ; <nl> + sc - > setInnerContainerSize ( Size ( 480 , 320 ) ) ; <nl> + sc - > setSize ( Size ( 100 , 100 ) ) ; <nl> + Size backgroundSize = background - > getContentSize ( ) ; <nl> + sc - > setPosition ( Point ( ( widgetSize . width - backgroundSize . width ) / 2 . 0f + <nl> + ( backgroundSize . width - sc - > getSize ( ) . width ) / 2 . 0f , <nl> + ( widgetSize . height - backgroundSize . height ) / 2 . 0f + <nl> + ( backgroundSize . height - sc - > getSize ( ) . height ) / 2 . 0f ) ) ; <nl> + sc - > scrollToPercentBothDirection ( Point ( 50 , 50 ) , 1 , true ) ; <nl> + ImageView * iv = ImageView : : create ( ) ; <nl> + iv - > loadTexture ( " cocosgui / Hello . png " ) ; <nl> + iv - > setPosition ( Point ( 240 , 160 ) ) ; <nl> + sc - > addChild ( iv ) ; <nl> + _uiLayer - > addChild ( sc ) ; <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . h <nl> class UIScrollViewTest_Vertical : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIScrollViewTest_Vertical ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> class UIScrollViewTest_Horizontal : public UIScene <nl> class UIScrollViewTest_Horizontal : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UIScrollViewTest_Horizontal ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> + } ; <nl> + <nl> + class UIScrollViewTest_Both : public UIScene <nl> + { <nl> + public : <nl> + UIScrollViewTest_Both ( ) ; <nl> + ~ UIScrollViewTest_Both ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIScrollViewTest_Both ) <nl> + gui : : Label * _displayValueLabel ; <nl> + } ; <nl> + <nl> + class UIScrollViewTest_ScrollToPercentBothDirection : public UIScene <nl> + { <nl> + public : <nl> + UIScrollViewTest_ScrollToPercentBothDirection ( ) ; <nl> + ~ UIScrollViewTest_ScrollToPercentBothDirection ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIScrollViewTest_ScrollToPercentBothDirection ) <nl> + gui : : Label * _displayValueLabel ; <nl> + } ; <nl> + <nl> + class UIScrollViewTest_ScrollToPercentBothDirection_Bounce : public UIScene <nl> + { <nl> + public : <nl> + UIScrollViewTest_ScrollToPercentBothDirection_Bounce ( ) ; <nl> + ~ UIScrollViewTest_ScrollToPercentBothDirection_Bounce ( ) ; <nl> + bool init ( ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UIScrollViewTest_ScrollToPercentBothDirection_Bounce ) <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UIScrollViewTest__ ) * / <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISliderTest / UISliderTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISliderTest / UISliderTest . cpp <nl> <nl> <nl> # include " UISliderTest . h " <nl> <nl> - const char * font_UISliderTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> <nl> / / UISliderTest <nl> <nl> UISliderTest : : UISliderTest ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> <nl> } <nl> bool UISliderTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the slider alert will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " Move the slider thumb " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UISliderTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move the slider thumb " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " Slider " ) ; <nl> - alert - > setFontName ( font_UISliderTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the slider <nl> - UISlider * slider = UISlider : : create ( ) ; <nl> + Slider * slider = Slider : : create ( ) ; <nl> slider - > setTouchEnabled ( true ) ; <nl> slider - > loadBarTexture ( " cocosgui / sliderTrack . png " ) ; <nl> slider - > loadSlidBallTextures ( " cocosgui / sliderThumb . png " , " cocosgui / sliderThumb . png " , " " ) ; <nl> slider - > loadProgressBarTexture ( " cocosgui / sliderProgress . png " ) ; <nl> - slider - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - slider - > addEventListenerSlider ( this , sliderpercentchangedselector ( UISliderTest : : percentChangedEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( slider ) ; <nl> + slider - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + slider - > getSize ( ) . height * 2 . 0f ) ) ; <nl> + slider - > addEventListenerSlider ( this , sliderpercentchangedselector ( UISliderTest : : sliderEvent ) ) ; <nl> + _uiLayer - > addChild ( slider ) ; <nl> + <nl> + / * <nl> + / / Create the slider that set allow min progress and allow max progress <nl> + Slider * sliderAllow = Slider : : create ( ) ; <nl> + sliderAllow - > setMinAllowPercent ( 20 ) ; <nl> + sliderAllow - > setMaxAllowPercent ( 80 ) ; <nl> + sliderAllow - > setTouchEnabled ( true ) ; <nl> + sliderAllow - > loadBarTexture ( " cocosgui / sliderTrack . png " ) ; <nl> + sliderAllow - > loadSlidBallTextures ( " cocosgui / sliderThumb . png " , " cocosgui / sliderThumb . png " , " " ) ; <nl> + sliderAllow - > loadProgressBarTexture ( " cocosgui / sliderProgress . png " ) ; <nl> + sliderAllow - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - sliderAllow - > getSize ( ) . height * 2 . 0f ) ) ; <nl> + sliderAllow - > addEventListenerSlider ( this , sliderpercentchangedselector ( UISliderTest : : sliderEvent ) ) ; <nl> + _uiLayer - > addChild ( sliderAllow ) ; <nl> + * / <nl> <nl> return true ; <nl> } <nl> return false ; <nl> } <nl> <nl> - void UISliderTest : : percentChangedEvent ( Object * pSender , SliderEventType type ) <nl> + void UISliderTest : : sliderEvent ( Object * pSender , SliderEventType type ) <nl> { <nl> if ( type = = SLIDER_PERCENTCHANGED ) <nl> { <nl> - UISlider * slider = dynamic_cast < UISlider * > ( pSender ) ; <nl> + Slider * slider = dynamic_cast < Slider * > ( pSender ) ; <nl> int percent = slider - > getPercent ( ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Percent % d " , percent ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Percent % d " , percent ) - > getCString ( ) ) ; <nl> } <nl> } <nl> <nl> / / UISliderTest_Scale9 <nl> <nl> UISliderTest_Scale9 : : UISliderTest_Scale9 ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> <nl> } <nl> bool UISliderTest_Scale9 : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the slider alert will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " Move the slider thumb " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UISliderTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " Move the slider thumb " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " Slider scale9 render " ) ; <nl> - alert - > setFontName ( font_UISliderTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the slider <nl> - UISlider * slider = UISlider : : create ( ) ; <nl> + Slider * slider = Slider : : create ( ) ; <nl> slider - > setTouchEnabled ( true ) ; <nl> slider - > loadBarTexture ( " cocosgui / sliderTrack2 . png " ) ; <nl> slider - > loadSlidBallTextures ( " cocosgui / sliderThumb . png " , " cocosgui / sliderThumb . png " , " " ) ; <nl> slider - > loadProgressBarTexture ( " cocosgui / slider_bar_active_9patch . png " ) ; <nl> slider - > setScale9Enabled ( true ) ; <nl> slider - > setCapInsets ( Rect ( 0 , 0 , 0 , 0 ) ) ; <nl> - slider - > setSize ( Size ( 250 , 10 ) ) ; <nl> - slider - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - slider - > addEventListenerSlider ( this , sliderpercentchangedselector ( UISliderTest_Scale9 : : percentChangedEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( slider ) ; <nl> + slider - > setSize ( Size ( 250 . 0f , 10 . 0f / Director : : getInstance ( ) - > getContentScaleFactor ( ) ) ) ; <nl> + slider - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + slider - > getSize ( ) . height * 3 . 0f ) ) ; <nl> + slider - > addEventListenerSlider ( this , sliderpercentchangedselector ( UISliderTest_Scale9 : : sliderEvent ) ) ; <nl> + _uiLayer - > addChild ( slider ) ; <nl> + <nl> + / * <nl> + / / Create the slider that set allow min progress and allow max progress <nl> + Slider * sliderAllow = Slider : : create ( ) ; <nl> + sliderAllow - > setMinAllowPercent ( 20 ) ; <nl> + sliderAllow - > setMaxAllowPercent ( 80 ) ; <nl> + sliderAllow - > setTouchEnabled ( true ) ; <nl> + sliderAllow - > loadBarTexture ( " cocosgui / sliderTrack2 . png " ) ; <nl> + sliderAllow - > loadSlidBallTextures ( " cocosgui / sliderThumb . png " , " cocosgui / sliderThumb . png " , " " ) ; <nl> + sliderAllow - > loadProgressBarTexture ( " cocosgui / slider_bar_active_9patch . png " ) ; <nl> + sliderAllow - > setScale9Enabled ( true ) ; <nl> + sliderAllow - > setCapInsets ( Rect ( 0 , 0 , 0 , 0 ) ) ; <nl> + sliderAllow - > setSize ( Size ( 250 . 0f , 10 . 0f / Director : : getInstance ( ) - > getContentScaleFactor ( ) ) ) ; <nl> + sliderAllow - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - slider - > getSize ( ) . height * 3 . 0f ) ) ; <nl> + sliderAllow - > addEventListenerSlider ( this , sliderpercentchangedselector ( UISliderTest_Scale9 : : sliderEvent ) ) ; <nl> + _uiLayer - > addChild ( sliderAllow ) ; <nl> + * / <nl> <nl> return true ; <nl> } <nl> return false ; <nl> } <nl> <nl> - void UISliderTest_Scale9 : : percentChangedEvent ( Object * pSender , SliderEventType type ) <nl> + void UISliderTest_Scale9 : : sliderEvent ( Object * pSender , SliderEventType type ) <nl> { <nl> if ( type = = SLIDER_PERCENTCHANGED ) <nl> { <nl> - UISlider * slider = dynamic_cast < UISlider * > ( pSender ) ; <nl> + Slider * slider = dynamic_cast < Slider * > ( pSender ) ; <nl> int percent = slider - > getPercent ( ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Percent % d " , percent ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " Percent % d " , percent ) - > getCString ( ) ) ; <nl> } <nl> } <nl> \ No newline at end of file <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISliderTest / UISliderTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISliderTest / UISliderTest . h <nl> class UISliderTest : public UIScene <nl> UISliderTest ( ) ; <nl> ~ UISliderTest ( ) ; <nl> bool init ( ) ; <nl> - void percentChangedEvent ( Object * pSender , SliderEventType type ) ; <nl> + void sliderEvent ( Object * pSender , SliderEventType type ) ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UISliderTest ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> class UISliderTest_Scale9 : public UIScene <nl> class UISliderTest_Scale9 : public UIScene <nl> UISliderTest_Scale9 ( ) ; <nl> ~ UISliderTest_Scale9 ( ) ; <nl> bool init ( ) ; <nl> - void percentChangedEvent ( Object * pSender , SliderEventType type ) ; <nl> + void sliderEvent ( Object * pSender , SliderEventType type ) ; <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UISliderTest_Scale9 ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UISliderTest__ ) * / <nl> new file mode 100644 <nl> index 000000000000 . . 6b5483486bbe <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISwitchTest / UISwitchTest . cpp <nl> <nl> + <nl> + <nl> + # include " UISwitchTest . h " <nl> + <nl> + / / UISwitchTest_Horizontal <nl> + UISwitchTest_Horizontal : : UISwitchTest_Horizontal ( ) <nl> + { <nl> + } <nl> + <nl> + UISwitchTest_Horizontal : : ~ UISwitchTest_Horizontal ( ) <nl> + { <nl> + } <nl> + <nl> + bool UISwitchTest_Horizontal : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the switch events will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Switch Horizontal " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the switch <nl> + Switch * pSwitch = Switch : : create ( ) ; <nl> + pSwitch - > setTouchEnabled ( true ) ; <nl> + pSwitch - > loadTextures ( " cocosgui / switch - mask . png " , " cocosgui / switch - on . png " , " cocosgui / switch - off . png " , " cocosgui / switch - thumb . png " ) ; <nl> + pSwitch - > setOnTitleText ( " On " ) ; <nl> + pSwitch - > setOffTitleText ( " Off " ) ; <nl> + pSwitch - > setOnTitleFontName ( " Arial - BoldMT " ) ; <nl> + pSwitch - > setOnTitleFontSize ( 16 ) ; <nl> + pSwitch - > setOffTitleFontName ( " Arial - BoldMT " ) ; <nl> + pSwitch - > setOffTitleFontSize ( 16 ) ; <nl> + Size switchSize = pSwitch - > getSize ( ) ; <nl> + pSwitch - > setPosition ( Point ( ( widgetSize . width - switchSize . width ) / 2 . 0f , ( widgetSize . height - switchSize . height ) / 2 . 0f ) ) ; <nl> + pSwitch - > addEventListenerSwitch ( this , switchselector ( UISwitchTest_Horizontal : : switchEvent ) ) ; <nl> + _uiLayer - > addChild ( pSwitch ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void UISwitchTest_Horizontal : : switchEvent ( Object * pSender , SwitchEventType type ) <nl> + { <nl> + Switch * pSwitch = static_cast < Switch * > ( pSender ) ; <nl> + <nl> + if ( pSwitch - > isOn ( ) ) <nl> + { <nl> + _displayValueLabel - > setText ( " On " ) ; <nl> + } <nl> + else <nl> + { <nl> + _displayValueLabel - > setText ( " Off " ) ; <nl> + } <nl> + <nl> + switch ( type ) <nl> + { <nl> + case SWITCH_EVENT_ON : <nl> + <nl> + break ; <nl> + <nl> + case SWITCH_EVENT_OFF : <nl> + <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + / / UISwitchTest_Vertical <nl> + UISwitchTest_Vertical : : UISwitchTest_Vertical ( ) <nl> + { <nl> + } <nl> + <nl> + UISwitchTest_Vertical : : ~ UISwitchTest_Vertical ( ) <nl> + { <nl> + } <nl> + <nl> + bool UISwitchTest_Vertical : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the switch events will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Switch Vertical " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the switch <nl> + Switch * pSwitch = Switch : : create ( ) ; <nl> + pSwitch - > setTouchEnabled ( true ) ; <nl> + pSwitch - > loadTextures ( " cocosgui / switch - mask_v . png " , " cocosgui / switch - on_v . png " , " cocosgui / switch - off_v . png " , " cocosgui / switch - thumb_v . png " ) ; <nl> + pSwitch - > setOnTitleText ( " On " ) ; <nl> + pSwitch - > setOffTitleText ( " Off " ) ; <nl> + pSwitch - > setOnTitleFontName ( " Arial - BoldMT " ) ; <nl> + pSwitch - > setOnTitleFontSize ( 16 ) ; <nl> + pSwitch - > setOffTitleFontName ( " Arial - BoldMT " ) ; <nl> + pSwitch - > setOffTitleFontSize ( 16 ) ; <nl> + Size switchSize = pSwitch - > getSize ( ) ; <nl> + pSwitch - > setPosition ( Point ( ( widgetSize . width - switchSize . width ) / 2 . 0f , ( widgetSize . height - switchSize . height ) / 2 . 0f ) ) ; <nl> + pSwitch - > addEventListenerSwitch ( this , switchselector ( UISwitchTest_Horizontal : : switchEvent ) ) ; <nl> + _uiLayer - > addChild ( pSwitch ) ; <nl> + <nl> + pSwitch - > setDirection ( SWITCH_DIRECTION_VERTICAL ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void UISwitchTest_Vertical : : switchEvent ( Object * pSender , SwitchEventType type ) <nl> + { <nl> + Switch * pSwitch = static_cast < Switch * > ( pSender ) ; <nl> + <nl> + if ( pSwitch - > isOn ( ) ) <nl> + { <nl> + _displayValueLabel - > setText ( " On " ) ; <nl> + } <nl> + else <nl> + { <nl> + _displayValueLabel - > setText ( " Off " ) ; <nl> + } <nl> + <nl> + switch ( type ) <nl> + { <nl> + case SWITCH_EVENT_ON : <nl> + <nl> + break ; <nl> + <nl> + case SWITCH_EVENT_OFF : <nl> + <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + / / UISwitchTest_VerticalAndTitleVertical <nl> + UISwitchTest_VerticalAndTitleVertical : : UISwitchTest_VerticalAndTitleVertical ( ) <nl> + { <nl> + } <nl> + <nl> + UISwitchTest_VerticalAndTitleVertical : : ~ UISwitchTest_VerticalAndTitleVertical ( ) <nl> + { <nl> + } <nl> + <nl> + bool UISwitchTest_VerticalAndTitleVertical : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add a label in which the switch events will be displayed <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Switch Vertical and Title Vertical " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 20 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 7 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the switch <nl> + Switch * pSwitch = Switch : : create ( ) ; <nl> + pSwitch - > setTouchEnabled ( true ) ; <nl> + pSwitch - > loadTextures ( " cocosgui / switch - mask_v . png " , " cocosgui / switch - on_v . png " , " cocosgui / switch - off_v . png " , " cocosgui / switch - thumb_v . png " ) ; <nl> + pSwitch - > setOnTitleText ( " On " ) ; <nl> + pSwitch - > setOffTitleText ( " Off " ) ; <nl> + pSwitch - > setOnTitleFontName ( " Arial - BoldMT " ) ; <nl> + pSwitch - > setOnTitleFontSize ( 16 ) ; <nl> + pSwitch - > setOffTitleFontName ( " Arial - BoldMT " ) ; <nl> + pSwitch - > setOffTitleFontSize ( 16 ) ; <nl> + Size switchSize = pSwitch - > getSize ( ) ; <nl> + pSwitch - > setPosition ( Point ( ( widgetSize . width - switchSize . width ) / 2 . 0f , ( widgetSize . height - switchSize . height ) / 2 . 0f ) ) ; <nl> + pSwitch - > addEventListenerSwitch ( this , switchselector ( UISwitchTest_Horizontal : : switchEvent ) ) ; <nl> + _uiLayer - > addChild ( pSwitch ) ; <nl> + <nl> + <nl> + pSwitch - > setDirection ( SWITCH_DIRECTION_VERTICAL ) ; <nl> + <nl> + / / set unicode text with title vertical direction <nl> + pSwitch - > setTitleDirection ( SWITCH_TITLE_DIRECTION_VERTICAL ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + void UISwitchTest_VerticalAndTitleVertical : : switchEvent ( Object * pSender , SwitchEventType type ) <nl> + { <nl> + Switch * pSwitch = static_cast < Switch * > ( pSender ) ; <nl> + <nl> + if ( pSwitch - > isOn ( ) ) <nl> + { <nl> + _displayValueLabel - > setText ( " On " ) ; <nl> + } <nl> + else <nl> + { <nl> + _displayValueLabel - > setText ( " Off " ) ; <nl> + } <nl> + <nl> + switch ( type ) <nl> + { <nl> + case SWITCH_EVENT_ON : <nl> + <nl> + break ; <nl> + <nl> + case SWITCH_EVENT_OFF : <nl> + <nl> + break ; <nl> + <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . ff5e40945efd <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UISwitchTest / UISwitchTest . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2013 cocos2d - x . org <nl> + <nl> + http : / / www . cocos2d - x . org <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in <nl> + all 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 , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> + THE SOFTWARE . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + # ifndef __TestCpp__UISwitchTest__ <nl> + # define __TestCpp__UISwitchTest__ <nl> + <nl> + # include " . . / UIScene . h " <nl> + <nl> + class UISwitchTest_Horizontal : public UIScene <nl> + { <nl> + public : <nl> + UISwitchTest_Horizontal ( ) ; <nl> + ~ UISwitchTest_Horizontal ( ) ; <nl> + bool init ( ) ; <nl> + void switchEvent ( Object * pSender , SwitchEventType type ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UISwitchTest_Horizontal ) <nl> + gui : : Label * _displayValueLabel ; <nl> + } ; <nl> + <nl> + class UISwitchTest_Vertical : public UIScene <nl> + { <nl> + public : <nl> + UISwitchTest_Vertical ( ) ; <nl> + ~ UISwitchTest_Vertical ( ) ; <nl> + bool init ( ) ; <nl> + void switchEvent ( Object * pSender , SwitchEventType type ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UISwitchTest_Vertical ) <nl> + gui : : Label * _displayValueLabel ; <nl> + } ; <nl> + <nl> + class UISwitchTest_VerticalAndTitleVertical : public UIScene <nl> + { <nl> + public : <nl> + UISwitchTest_VerticalAndTitleVertical ( ) ; <nl> + ~ UISwitchTest_VerticalAndTitleVertical ( ) ; <nl> + bool init ( ) ; <nl> + void switchEvent ( Object * pSender , SwitchEventType type ) ; <nl> + <nl> + protected : <nl> + UI_SCENE_CREATE_FUNC ( UISwitchTest_VerticalAndTitleVertical ) <nl> + gui : : Label * _displayValueLabel ; <nl> + } ; <nl> + <nl> + # endif / * defined ( __TestCpp__UISwitchTest__ ) * / <nl> deleted file mode 100644 <nl> index 71bda620f8d3 . . 000000000000 <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextAreaTest / UITextAreaTest . cpp <nl> ppp / dev / null <nl> <nl> - <nl> - <nl> - # include " UITextAreaTest . h " <nl> - <nl> - const char * font_UITextAreaTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> - <nl> - / / UITextAreaTest <nl> - <nl> - bool UITextAreaTest : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " TextArea " ) ; <nl> - alert - > setFontName ( font_UITextAreaTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - / / Create the text area <nl> - UILabel * textArea = UILabel : : create ( ) ; <nl> - textArea - > setTextAreaSize ( Size ( 280 , 150 ) ) ; <nl> - textArea - > setTextHorizontalAlignment ( TextHAlignment : : CENTER ) ; <nl> - textArea - > setText ( " TextArea widget can line wrap " ) ; <nl> - textArea - > setFontName ( " AmericanTypewriter " ) ; <nl> - textArea - > setFontSize ( 32 ) ; <nl> - textArea - > setPosition ( Point ( widgetSize . width / 2 , widgetSize . height / 2 - textArea - > getSize ( ) . height / 8 ) ) ; <nl> - m_pUiLayer - > addWidget ( textArea ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 440210eee6a6 . . 000000000000 <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextButtonTest / UITextButtonTest . cpp <nl> ppp / dev / null <nl> <nl> - <nl> - <nl> - # include " UITextButtonTest . h " <nl> - <nl> - const char * font_UITextButtonTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> - <nl> - / / UITextButtonTest <nl> - UITextButtonTest : : UITextButtonTest ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UITextButtonTest : : ~ UITextButtonTest ( ) <nl> - { <nl> - } <nl> - <nl> - bool UITextButtonTest : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add a label in which the text button events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UITextButtonTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " TextButton " ) ; <nl> - alert - > setFontName ( font_UITextButtonTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - / / Create the text button <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / backtotopnormal . png " , " cocosgui / backtotoppressed . png " , " " ) ; <nl> - textButton - > setTitleText ( " Text Button " ) ; <nl> - textButton - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - textButton - > addTouchEventListener ( this , toucheventselector ( UITextButtonTest : : touchEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( textButton ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - void UITextButtonTest : : touchEvent ( Object * pSender , TouchEventType type ) <nl> - { <nl> - switch ( type ) <nl> - { <nl> - case gui : : TOUCH_EVENT_BEGAN : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case gui : : TOUCH_EVENT_MOVED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case gui : : TOUCH_EVENT_ENDED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case gui : : TOUCH_EVENT_CANCELED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / / UITextButtonTest_Scale9 <nl> - UITextButtonTest_Scale9 : : UITextButtonTest_Scale9 ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> - { <nl> - <nl> - } <nl> - <nl> - UITextButtonTest_Scale9 : : ~ UITextButtonTest_Scale9 ( ) <nl> - { <nl> - <nl> - } <nl> - <nl> - bool UITextButtonTest_Scale9 : : init ( ) <nl> - { <nl> - if ( UIScene : : init ( ) ) <nl> - { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> - <nl> - / / Add a label in which the text button events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UITextButtonTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> - <nl> - / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> - alert - > setText ( " TextButton scale9 render " ) ; <nl> - alert - > setFontName ( font_UITextButtonTest ) ; <nl> - alert - > setFontSize ( 30 ) ; <nl> - alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> - <nl> - / / Create the text button <nl> - UIButton * textButton = UIButton : : create ( ) ; <nl> - textButton - > setTouchEnabled ( true ) ; <nl> - textButton - > setScale9Enabled ( true ) ; <nl> - textButton - > loadTextures ( " cocosgui / button . png " , " cocosgui / buttonHighlighted . png " , " " ) ; <nl> - textButton - > setSize ( Size ( 180 , textButton - > getContentSize ( ) . height * 1 . 5f ) ) ; <nl> - textButton - > setTitleText ( " Text Button scale9 render " ) ; <nl> - textButton - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> - textButton - > addTouchEventListener ( this , toucheventselector ( UITextButtonTest : : touchEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( textButton ) ; <nl> - <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - void UITextButtonTest_Scale9 : : touchEvent ( Object * pSender , TouchEventType type ) <nl> - { <nl> - switch ( type ) <nl> - { <nl> - case gui : : TOUCH_EVENT_BEGAN : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Down " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case gui : : TOUCH_EVENT_MOVED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Move " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case gui : : TOUCH_EVENT_ENDED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Up " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - case gui : : TOUCH_EVENT_CANCELED : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " Touch Cancelled " ) - > getCString ( ) ) ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> \ No newline at end of file <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . cpp <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . cpp <nl> <nl> <nl> # include " UITextFieldTest . h " <nl> <nl> - const char * font_UITextFieldTest = <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_IOS ) <nl> - " Marker Felt " ; <nl> - # else <nl> - " cocosgui / Marker Felt . ttf " ; <nl> - # endif <nl> - <nl> / / UITextFieldTest <nl> UITextFieldTest : : UITextFieldTest ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> <nl> } <nl> bool UITextFieldTest : : init ( ) <nl> { <nl> if ( UIScene : : init ( ) ) <nl> { <nl> - Size widgetSize = m_pWidget - > getSize ( ) ; <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> <nl> / / Add a label in which the textfield events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UITextFieldTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + m_pDisplayValueLabel - > getSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f + _displayValueLabel - > getSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " TextField " ) ; <nl> - alert - > setFontName ( font_UITextFieldTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the textfield <nl> - UITextField * textField = UITextField : : create ( ) ; <nl> + TextField * textField = TextField : : create ( ) ; <nl> textField - > setTouchEnabled ( true ) ; <nl> - textField - > setFontName ( font_UITextFieldTest ) ; <nl> + textField - > setFontName ( " Marker Felt " ) ; <nl> textField - > setFontSize ( 30 ) ; <nl> textField - > setPlaceHolder ( " input words here " ) ; <nl> textField - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> textField - > addEventListenerTextField ( this , textfieldeventselector ( UITextFieldTest : : textFieldEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( textField ) ; <nl> + _uiLayer - > addChild ( textField ) ; <nl> <nl> return true ; <nl> } <nl> void UITextFieldTest : : textFieldEvent ( Object * pSender , TextFiledEventType type ) <nl> { <nl> case TEXTFIELD_EVENT_ATTACH_WITH_IME : <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( pSender ) ; <nl> Size screenSize = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> textField - > runAction ( CCMoveTo : : create ( 0 . 225f , <nl> Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f + textField - > getContentSize ( ) . height / 2 . 0f ) ) ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " attach with IME " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " attach with IME " ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_DETACH_WITH_IME : <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( pSender ) ; <nl> Size screenSize = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> textField - > runAction ( CCMoveTo : : create ( 0 . 175f , Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f ) ) ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " detach with IME " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " detach with IME " ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_INSERT_TEXT : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " insert words " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " insert words " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_DELETE_BACKWARD : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " delete word " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " delete word " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> default : <nl> void UITextFieldTest : : textFieldEvent ( Object * pSender , TextFiledEventType type ) <nl> <nl> / / UITextFieldTest_MaxLength <nl> UITextFieldTest_MaxLength : : UITextFieldTest_MaxLength ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> <nl> } <nl> bool UITextFieldTest_MaxLength : : init ( ) <nl> Size screenSize = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> <nl> / / Add a label in which the textfield events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UITextFieldTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f + m_pDisplayValueLabel - > getSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f + _displayValueLabel - > getSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " TextField max length " ) ; <nl> - alert - > setFontName ( font_UITextFieldTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the textfield <nl> - UITextField * textField = UITextField : : create ( ) ; <nl> + TextField * textField = TextField : : create ( ) ; <nl> textField - > setMaxLengthEnabled ( true ) ; <nl> textField - > setMaxLength ( 3 ) ; <nl> textField - > setTouchEnabled ( true ) ; <nl> - textField - > setFontName ( font_UITextFieldTest ) ; <nl> + textField - > setFontName ( " Marker Felt " ) ; <nl> textField - > setFontSize ( 30 ) ; <nl> textField - > setPlaceHolder ( " input words here " ) ; <nl> textField - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f ) ) ; <nl> textField - > addEventListenerTextField ( this , textfieldeventselector ( UITextFieldTest_MaxLength : : textFieldEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( textField ) ; <nl> + _uiLayer - > addChild ( textField ) ; <nl> <nl> return true ; <nl> } <nl> void UITextFieldTest_MaxLength : : textFieldEvent ( Object * pSender , TextFiledEventTy <nl> { <nl> case TEXTFIELD_EVENT_ATTACH_WITH_IME : <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( pSender ) ; <nl> Size screenSize = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> textField - > runAction ( CCMoveTo : : create ( 0 . 225f , <nl> Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f + textField - > getContentSize ( ) . height / 2 . 0f ) ) ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " attach with IME max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " attach with IME max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_DETACH_WITH_IME : <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( pSender ) ; <nl> Size screenSize = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> textField - > runAction ( CCMoveTo : : create ( 0 . 175f , Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f ) ) ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " detach with IME max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " detach with IME max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_INSERT_TEXT : <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " insert words max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( pSender ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " insert words max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_DELETE_BACKWARD : <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " delete word max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( pSender ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " delete word max length % d " , textField - > getMaxLength ( ) ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> void UITextFieldTest_MaxLength : : textFieldEvent ( Object * pSender , TextFiledEventTy <nl> <nl> / / UITextFieldTest_Password <nl> UITextFieldTest_Password : : UITextFieldTest_Password ( ) <nl> - : m_pDisplayValueLabel ( NULL ) <nl> + : _displayValueLabel ( nullptr ) <nl> { <nl> <nl> } <nl> bool UITextFieldTest_Password : : init ( ) <nl> Size screenSize = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> <nl> / / Add a label in which the textfield events will be displayed <nl> - m_pDisplayValueLabel = UILabel : : create ( ) ; <nl> - m_pDisplayValueLabel - > setText ( " No Event " ) ; <nl> - m_pDisplayValueLabel - > setFontName ( font_UITextFieldTest ) ; <nl> - m_pDisplayValueLabel - > setFontSize ( 32 ) ; <nl> - m_pDisplayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 ) ) ; <nl> - m_pDisplayValueLabel - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f + m_pDisplayValueLabel - > getSize ( ) . height * 1 . 5 ) ) ; <nl> - m_pUiLayer - > addWidget ( m_pDisplayValueLabel ) ; <nl> + _displayValueLabel = gui : : Label : : create ( ) ; <nl> + _displayValueLabel - > setText ( " No Event " ) ; <nl> + _displayValueLabel - > setFontName ( " Marker Felt " ) ; <nl> + _displayValueLabel - > setFontSize ( 32 ) ; <nl> + _displayValueLabel - > setAnchorPoint ( Point ( 0 . 5f , - 1 . 0f ) ) ; <nl> + _displayValueLabel - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f + _displayValueLabel - > getSize ( ) . height * 1 . 5f ) ) ; <nl> + _uiLayer - > addChild ( _displayValueLabel ) ; <nl> <nl> / / Add the alert <nl> - UILabel * alert = UILabel : : create ( ) ; <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> alert - > setText ( " TextField password " ) ; <nl> - alert - > setFontName ( font_UITextFieldTest ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> alert - > setFontSize ( 30 ) ; <nl> alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> - alert - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f - alert - > getSize ( ) . height * 2 . 925 ) ) ; <nl> - m_pUiLayer - > addWidget ( alert ) ; <nl> + alert - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f - alert - > getSize ( ) . height * 3 . 075f ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> <nl> / / Create the textfield <nl> - UITextField * textField = UITextField : : create ( ) ; <nl> + TextField * textField = TextField : : create ( ) ; <nl> textField - > setPasswordEnabled ( true ) ; <nl> textField - > setPasswordStyleText ( " * " ) ; <nl> textField - > setTouchEnabled ( true ) ; <nl> - textField - > setFontName ( font_UITextFieldTest ) ; <nl> + textField - > setFontName ( " Marker Felt " ) ; <nl> textField - > setFontSize ( 30 ) ; <nl> textField - > setPlaceHolder ( " input password here " ) ; <nl> textField - > setPosition ( Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f ) ) ; <nl> textField - > addEventListenerTextField ( this , textfieldeventselector ( UITextFieldTest_Password : : textFieldEvent ) ) ; <nl> - m_pUiLayer - > addWidget ( textField ) ; <nl> + _uiLayer - > addChild ( textField ) ; <nl> <nl> return true ; <nl> } <nl> void UITextFieldTest_Password : : textFieldEvent ( Object * pSender , TextFiledEventTyp <nl> { <nl> case TEXTFIELD_EVENT_ATTACH_WITH_IME : <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( pSender ) ; <nl> Size screenSize = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> textField - > runAction ( CCMoveTo : : create ( 0 . 225f , <nl> Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f + textField - > getContentSize ( ) . height / 2 . 0f ) ) ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " attach with IME password " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " attach with IME password " ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_DETACH_WITH_IME : <nl> { <nl> - UITextField * textField = dynamic_cast < UITextField * > ( pSender ) ; <nl> + TextField * textField = dynamic_cast < TextField * > ( pSender ) ; <nl> Size screenSize = CCDirector : : getInstance ( ) - > getWinSize ( ) ; <nl> textField - > runAction ( CCMoveTo : : create ( 0 . 175f , Point ( screenSize . width / 2 . 0f , screenSize . height / 2 . 0f ) ) ) ; <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " detach with IME password " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " detach with IME password " ) - > getCString ( ) ) ; <nl> } <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_INSERT_TEXT : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " insert words password " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " insert words password " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> case TEXTFIELD_EVENT_DELETE_BACKWARD : <nl> - m_pDisplayValueLabel - > setText ( CCString : : createWithFormat ( " delete word password " ) - > getCString ( ) ) ; <nl> + _displayValueLabel - > setText ( String : : createWithFormat ( " delete word password " ) - > getCString ( ) ) ; <nl> break ; <nl> <nl> default : <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UITextFieldTest / UITextFieldTest . h <nl> class UITextFieldTest : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UITextFieldTest ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> class UITextFieldTest_MaxLength : public UIScene <nl> class UITextFieldTest_MaxLength : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UITextFieldTest_MaxLength ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> <nl> class UITextFieldTest_Password : public UIScene <nl> class UITextFieldTest_Password : public UIScene <nl> <nl> protected : <nl> UI_SCENE_CREATE_FUNC ( UITextFieldTest_Password ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + gui : : Label * _displayValueLabel ; <nl> } ; <nl> # endif / * defined ( __TestCpp__UITextFieldTest__ ) * / <nl> new file mode 100644 <nl> index 000000000000 . . 43ab1182c5ea <nl> mmm / dev / null <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest . cpp <nl> <nl> + <nl> + <nl> + # include " UIWidgetAddNodeTest . h " <nl> + <nl> + <nl> + / / UIWidgetAddNodeTest <nl> + <nl> + UIWidgetAddNodeTest : : UIWidgetAddNodeTest ( ) <nl> + { <nl> + <nl> + } <nl> + <nl> + UIWidgetAddNodeTest : : ~ UIWidgetAddNodeTest ( ) <nl> + { <nl> + } <nl> + <nl> + bool UIWidgetAddNodeTest : : init ( ) <nl> + { <nl> + if ( UIScene : : init ( ) ) <nl> + { <nl> + Size widgetSize = _widget - > getSize ( ) ; <nl> + <nl> + / / Add the alert <nl> + gui : : Label * alert = gui : : Label : : create ( ) ; <nl> + alert - > setText ( " Widget Add Node " ) ; <nl> + alert - > setFontName ( " Marker Felt " ) ; <nl> + alert - > setFontSize ( 30 ) ; <nl> + alert - > setColor ( Color3B ( 159 , 168 , 176 ) ) ; <nl> + alert - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f - alert - > getSize ( ) . height * 1 . 75 ) ) ; <nl> + _uiLayer - > addChild ( alert ) ; <nl> + <nl> + / / Create the ui node container <nl> + Widget * widget = Widget : : create ( ) ; <nl> + widget - > setPosition ( Point ( widgetSize . width / 2 . 0f , widgetSize . height / 2 . 0f ) ) ; <nl> + _uiLayer - > addChild ( widget ) ; <nl> + <nl> + Sprite * sprite = Sprite : : create ( " cocosgui / ccicon . png " ) ; <nl> + sprite - > setPosition ( Point ( 0 , sprite - > getBoundingBox ( ) . size . height / 4 ) ) ; <nl> + / / widget - > addRenderer ( sprite , 0 ) ; <nl> + <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> \ No newline at end of file <nl> similarity index 84 % <nl> rename from samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UINodeContainerTest / UINodeContainerTest . h <nl> rename to samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest . h <nl> mmm a / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UINodeContainerTest / UINodeContainerTest . h <nl> ppp b / samples / Cpp / TestCpp / Classes / ExtensionsTest / CocoStudioGUITest / UIWidgetAddNodeTest / UIWidgetAddNodeTest . h <nl> <nl> <nl> # include " . . / UIScene . h " <nl> <nl> - class UINodeContainerTest : public UIScene <nl> + class UIWidgetAddNodeTest : public UIScene <nl> { <nl> public : <nl> - UINodeContainerTest ( ) ; <nl> - ~ UINodeContainerTest ( ) ; <nl> + UIWidgetAddNodeTest ( ) ; <nl> + ~ UIWidgetAddNodeTest ( ) ; <nl> bool init ( ) ; <nl> <nl> protected : <nl> - UI_SCENE_CREATE_FUNC ( UINodeContainerTest ) <nl> - / / CC_SYNTHESIZE_RETAIN ( CCLabelTTF * , m_pDisplayValueLabel , DisplayValueLabel ) <nl> - UILabel * m_pDisplayValueLabel ; <nl> + UI_SCENE_CREATE_FUNC ( UIWidgetAddNodeTest ) <nl> } ; <nl> <nl> # endif / * defined ( __TestCpp__UINodeContainerTest__ ) * / <nl> | Merge pull request from dumganhar / gui - refactor | cocos2d/cocos2d-x | 7f459ef16be3cc6d4df232114337c45099a382f2 | 2013-12-26T02:46:04Z |
mmm a / tensorflow / contrib / tpu / ops / tpu_configuration_ops . cc <nl> ppp b / tensorflow / contrib / tpu / ops / tpu_configuration_ops . cc <nl> An op that shuts down a running distributed TPU system . The Op returns <nl> an error if no system is running . <nl> ) doc " ) ; <nl> <nl> - } / / namespace tensorflow <nl> + REGISTER_OP ( " SessionStatus " ) <nl> + . Input ( " fetch_start_timestamp : double " ) <nl> + . Output ( " status : string " ) <nl> + . SetShapeFn ( shape_inference : : ScalarShape ) <nl> + . Doc ( R " doc ( <nl> + Not for public usage . <nl> + <nl> + Returns messages from the current session as a serialized SessionStatusProto . <nl> + <nl> + This includes the current state of the compiler , along with any critical <nl> + logging or warning messages . <nl> + <nl> + fetch_start_timestamp : any messages earlier than this will be excluded from the <nl> + returned proto . <nl> + ) doc " ) ; <nl> + <nl> + } / / end namespace tensorflow <nl> mmm a / tensorflow / core / BUILD <nl> ppp b / tensorflow / core / BUILD <nl> CORE_PROTO_SRCS = [ <nl> " protobuf / rewriter_config . proto " , <nl> " protobuf / tensor_bundle . proto " , <nl> " protobuf / saver . proto " , <nl> + " util / event . proto " , <nl> " util / memmapped_file_system . proto " , <nl> " util / saved_tensor_slice . proto " , <nl> ] <nl> ADDITIONAL_CORE_PROTO_SRCS = [ <nl> " protobuf / named_tensor . proto " , <nl> " protobuf / saved_model . proto " , <nl> " protobuf / tensorflow_server . proto " , <nl> - " util / event . proto " , <nl> " util / test_log . proto " , <nl> ] <nl> <nl> cc_library ( <nl> hdrs = [ " platform / abi . h " ] , <nl> ) <nl> <nl> + cc_library ( <nl> + name = " session_message " , <nl> + srcs = [ " util / session_message . cc " ] , <nl> + hdrs = [ " util / session_message . h " ] , <nl> + deps = [ <nl> + " : framework " , <nl> + " : lib " , <nl> + " : protos_all_cc " , <nl> + ] , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " stacktrace_handler " , <nl> srcs = [ " platform / stacktrace_handler . cc " ] , <nl> FRAMEWORK_INTERNAL_PRIVATE_HEADERS = [ <nl> " framework / reader_base . * " , <nl> " util / memmapped_file_system . * " , <nl> " util / memmapped_file_system_writer . * " , <nl> + " util / session_message . * " , <nl> " util / version_info . cc " , <nl> ] , <nl> ) + select ( { <nl> tf_cuda_library ( <nl> " framework / resource_handle . cc " , <nl> " util / memmapped_file_system . * " , <nl> " util / memmapped_file_system_writer . * " , <nl> + " util / session_message . cc " , <nl> " util / version_info . cc " , <nl> ] , <nl> ) + select ( { <nl> mmm a / tensorflow / core / util / event . proto <nl> ppp b / tensorflow / core / util / event . proto <nl> message TaggedRunMetadata { <nl> / / deserialization . <nl> bytes run_metadata = 2 ; <nl> } <nl> + <nl> + / / For communicating live events back to a coordinator <nl> + message SessionStatus { <nl> + repeated Event event = 1 ; <nl> + } <nl> new file mode 100644 <nl> index 0000000000000 . . 28a6517a1a3c5 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / util / session_message . cc <nl> <nl> + / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / core / util / session_message . h " <nl> + # include " tensorflow / core / framework / op_kernel . h " <nl> + # include " tensorflow / core / framework / resource_mgr . h " <nl> + # include " tensorflow / core / lib / strings / stringprintf . h " <nl> + # include " tensorflow / core / util / event . pb . h " <nl> + <nl> + static const int kMaxLogEvents = 1000 ; <nl> + <nl> + namespace tensorflow { <nl> + <nl> + SessionLogger : : SessionLogger ( ) : status_ ( new SessionStatus ) { } <nl> + <nl> + SessionLogger : : ~ SessionLogger ( ) { } <nl> + <nl> + string SessionLogger : : DebugString ( ) { return " SessionLogger " ; } <nl> + <nl> + void SessionLogger : : Log ( StringPiece message ) { <nl> + mutex_lock lock ( mu_ ) ; <nl> + <nl> + Event * event = status_ - > add_event ( ) ; <nl> + event - > set_wall_time ( Env : : Default ( ) - > NowMicros ( ) ) ; <nl> + event - > set_step ( 0 ) ; <nl> + LogMessage * log = event - > mutable_log_message ( ) ; <nl> + log - > set_message ( message . ToString ( ) ) ; <nl> + log - > set_level ( LogMessage : : INFO ) ; <nl> + <nl> + / / Clip log events by 10 % if we overflow <nl> + if ( status_ - > event_size ( ) > kMaxLogEvents ) { <nl> + auto events = status_ - > mutable_event ( ) ; <nl> + events - > DeleteSubrange ( 0 , kMaxLogEvents / 10 ) ; <nl> + } <nl> + } <nl> + <nl> + SessionLogger * GetSessionLogger ( ResourceMgr * rm ) { <nl> + SessionLogger * logger ; <nl> + <nl> + std : : function < Status ( SessionLogger * * ) > status_creator = <nl> + [ ] ( SessionLogger * * result ) { <nl> + * result = new SessionLogger ( ) ; <nl> + return Status : : OK ( ) ; <nl> + } ; <nl> + <nl> + if ( ! rm - > LookupOrCreate < SessionLogger > ( " session " , " status " , & logger , <nl> + status_creator ) <nl> + . ok ( ) ) { <nl> + return nullptr ; <nl> + } <nl> + <nl> + return logger ; <nl> + } <nl> + <nl> + void LogSessionMessage ( ResourceMgr * rm , StringPiece message ) { <nl> + return GetSessionLogger ( rm ) - > Log ( message ) ; <nl> + } <nl> + <nl> + } / / namespace tensorflow <nl> new file mode 100644 <nl> index 0000000000000 . . c0f3d78b46a50 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / util / session_message . h <nl> <nl> + / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # ifndef TENSORFLOW_CORE_UTIL_SESSION_MESSAGE_H_ <nl> + # define TENSORFLOW_CORE_UTIL_SESSION_MESSAGE_H_ <nl> + <nl> + # include " tensorflow / core / framework / resource_mgr . h " <nl> + # include " tensorflow / core / lib / core / stringpiece . h " <nl> + # include " tensorflow / core / platform / mutex . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + class ResourceMgr ; <nl> + class SessionStatus ; <nl> + <nl> + class SessionLogger : public ResourceBase { <nl> + public : <nl> + SessionLogger ( ) ; <nl> + ~ SessionLogger ( ) ; <nl> + <nl> + void Log ( StringPiece message ) ; <nl> + string DebugString ( ) override ; <nl> + <nl> + const SessionStatus & status ( ) { return * status_ ; } <nl> + <nl> + private : <nl> + std : : unique_ptr < SessionStatus > status_ ; <nl> + mutex mu_ ; <nl> + } ; <nl> + <nl> + / / Return a SessionLogger instance for the current session . If the logger <nl> + / / will be used across multiple computations , you must explicitly acquire <nl> + / / and release references using Ref ( ) / Unref ( ) . <nl> + / / <nl> + / / Returns nullptr if a logger cannot be created . <nl> + SessionLogger * GetSessionLogger ( ResourceMgr * rm ) ; <nl> + <nl> + / / Attach ` message ` to the logger for the current session . <nl> + void LogSessionMessage ( ResourceMgr * rm , StringPiece message ) ; <nl> + <nl> + } / / namespace tensorflow <nl> + <nl> + # endif / / TENSORFLOW_CORE_UTIL_SESSION_MESSAGE_H <nl> | Add operation to forward log messages from remote workers to a local system . | tensorflow/tensorflow | 4cdfdaeae2540ac2eef13fc45928ff22cf8fd83e | 2018-02-08T01:16:12Z |
mmm a / xbmc / cores / dvdplayer / DVDPlayerVideo . cpp <nl> ppp b / xbmc / cores / dvdplayer / DVDPlayerVideo . cpp <nl> bool CDVDPlayerVideo : : OpenStream ( CDVDStreamInfo & hint ) <nl> / / if adjust refreshrate is used , or if sync playback to display is on , <nl> / / we try to calculate the framerate from the pts ' , because the codec fps <nl> / / is not always correct <nl> - m_bGuessFrameRate = g_guiSettings . GetBool ( " videoplayer . usedisplayasclock " ) | | <nl> + m_bCalcFrameRate = g_guiSettings . GetBool ( " videoplayer . usedisplayasclock " ) | | <nl> g_guiSettings . GetBool ( " videoplayer . adjustrefreshrate " ) ; <nl> <nl> m_fStableFrameRate = 0 . 0 ; <nl> m_iFrameRateCount = 0 ; <nl> - m_bAllowDrop = ! m_bGuessFrameRate ; / / we start with not allowing drops to calculate the framerate <nl> + m_bAllowDrop = ! m_bCalcFrameRate ; / / we start with not allowing drops to calculate the framerate <nl> m_iFrameRateLength = 1 ; <nl> <nl> if ( hint . vfr ) <nl> void CDVDPlayerVideo : : Process ( ) <nl> LeaveCriticalSection ( & m_critCodecSection ) ; <nl> <nl> m_pullupCorrection . Flush ( ) ; <nl> + / / we need to recalculate the framerate <nl> + / / TODO : this needs to be set on a streamchange instead <nl> m_iFrameRateLength = 1 ; <nl> + m_iFrameRateLength = ! m_bCalcFrameRate ; <nl> } <nl> else if ( pMsg - > IsType ( CDVDMsg : : VIDEO_NOSKIP ) ) <nl> { <nl> int CDVDPlayerVideo : : OutputPicture ( DVDVideoPicture * pPicture , double pts ) <nl> pts + = m_pullupCorrection . Correction ( ) ; <nl> <nl> / / try to calculate the framerate <nl> - if ( m_bGuessFrameRate ) <nl> + if ( m_bCalcFrameRate ) <nl> CalcFrameRate ( ) ; <nl> <nl> / / signal to clock what our framerate is , it may want to adjust it ' s <nl> mmm a / xbmc / cores / dvdplayer / DVDPlayerVideo . h <nl> ppp b / xbmc / cores / dvdplayer / DVDPlayerVideo . h <nl> class CDVDPlayerVideo : public CThread <nl> void CalcFrameRate ( ) ; <nl> <nl> float m_fFrameRate ; / / framerate of the video currently playing <nl> - bool m_bGuessFrameRate ; / / if we should guess the framerate from the timestamps <nl> + bool m_bCalcFrameRate ; / / if we should calculate the framerate from the timestamps <nl> double m_fStableFrameRate ; / / place to store calculated framerates <nl> int m_iFrameRateCount ; / / how many calculated framerates we stored in m_fStableFrameRate <nl> bool m_bAllowDrop ; / / we can ' t drop frames until we ' ve calculated the framerate <nl> | fixed : don ' t allow drops when resetting m_iFrameRateCount so the framerate can be properly recalculated | xbmc/xbmc | 3893d57bfc9bd3a41c2deaa591197056cc285454 | 2009-10-18T15:23:50Z |
mmm a / src / mongo / db / db . vcxproj <nl> ppp b / src / mongo / db / db . vcxproj <nl> <nl> < ClCompile Include = " . . \ util \ processinfo_win32 . cpp " / > <nl> < ClCompile Include = " . . \ util \ util . cpp " / > <nl> < ClCompile Include = " . . \ util \ net \ httpclient . cpp " / > <nl> - < ClCompile Include = " . . \ util \ md5 . cpppp " > <nl> + < ClCompile Include = " . . \ util \ md5 . cpp " > <nl> < PrecompiledHeader Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | Win32 ' " > <nl> < / PrecompiledHeader > <nl> < PrecompiledHeader Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusDebug | Win32 ' " > <nl> mmm a / src / mongo / dbtests / test . vcxproj <nl> ppp b / src / mongo / dbtests / test . vcxproj <nl> <nl> < ClCompile Include = " . . \ util \ assert_util . cpp " / > <nl> < ClCompile Include = " . . \ util \ background . cpp " / > <nl> < ClCompile Include = " . . \ util \ base64 . cpp " / > <nl> - < ClCompile Include = " . . \ util \ md5 . cpppp " > <nl> + < ClCompile Include = " . . \ util \ md5 . cpp " > <nl> < PrecompiledHeader Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | Win32 ' " > <nl> < / PrecompiledHeader > <nl> < PrecompiledHeader Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusDebug | Win32 ' " > <nl> mmm a / src / mongo / s / dbgrid . vcxproj <nl> ppp b / src / mongo / s / dbgrid . vcxproj <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> + < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> < Project DefaultTargets = " Build " ToolsVersion = " 4 . 0 " xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> < ItemGroup Label = " ProjectConfigurations " > <nl> < ProjectConfiguration Include = " Debug | Win32 " > <nl> <nl> < ClCompile Include = " . . \ db \ json . cpp " / > <nl> < ClCompile Include = " . . \ db \ lasterror . cpp " / > <nl> < ClCompile Include = " . . \ db \ matcher . cpp " / > <nl> - < ClCompile Include = " . . \ util \ md5 . cpppp " > <nl> + < ClCompile Include = " . . \ util \ md5 . cpp " > <nl> < PrecompiledHeader Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | Win32 ' " > <nl> < / PrecompiledHeader > <nl> < PrecompiledHeader Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Win2008PlusDebug | Win32 ' " > <nl> | SERVER - 4328 fix merge of vcxproj files | mongodb/mongo | d17c2e2f79ddfa79c5bcd01da597ae87b797d473 | 2012-01-24T23:23:10Z |
mmm a / bazel / README . md <nl> ppp b / bazel / README . md <nl> on the Bazel command line . <nl> <nl> # # Stats Tunables <nl> <nl> - The default maximum number of stats in shared memory , and the default maximum length of a stat name , <nl> - can be overriden at compile - time by defining ` ENVOY_DEFAULT_MAX_STATS ` and ` ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH ` , <nl> - respectively , to the desired value . For example : <nl> + The default maximum number of stats in shared memory , and the default <nl> + maximum length of a cluster / route config / listener name , can be <nl> + overriden at compile - time by defining ` ENVOY_DEFAULT_MAX_STATS ` and <nl> + ` ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH ` , respectively , to the desired <nl> + value . For example : <nl> + <nl> ` ` ` <nl> - bazel build - - copts = - DENVOY_DEFAULT_MAX_STATS = 32768 / / source / exe : envoy - static <nl> + bazel build - - copts = - DENVOY_DEFAULT_MAX_STATS = 32768 - - copts = - DENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH = 150 / / source / exe : envoy - static <nl> ` ` ` <nl> <nl> <nl> mmm a / docs / configuration / cluster_manager / cluster . rst <nl> ppp b / docs / configuration / cluster_manager / cluster . rst <nl> Cluster <nl> name <nl> * ( required , string ) * Supplies the name of the cluster which must be unique across all clusters . <nl> The cluster name is used when emitting : ref : ` statistics < config_cluster_manager_cluster_stats > ` . <nl> - The cluster name can be at most 60 characters long . <nl> + By default , the maximum length of a cluster name is limited to 60 characters . This limit can be <nl> + increased by setting the : option : ` - - max - obj - name - len ` command line argument to the desired value . <nl> <nl> . . _config_cluster_manager_type : <nl> <nl> mmm a / docs / configuration / http_conn_man / rds . rst <nl> ppp b / docs / configuration / http_conn_man / rds . rst <nl> route_config_name <nl> * ( required , string ) * The name of the route configuration . This name will be passed to the <nl> : ref : ` RDS HTTP API < config_http_conn_man_rds_api > ` . This allows an Envoy configuration with <nl> multiple HTTP listeners ( and associated HTTP connection manager filters ) to use different route <nl> - configurations . <nl> + configurations . By default , the maximum length of the name is limited to 60 characters . This <nl> + limit can be increased by setting the : option : ` - - max - obj - name - len ` command line argument to the <nl> + desired value . <nl> <nl> refresh_delay_ms <nl> * ( optional , integer ) * The delay , in milliseconds , between fetches to the RDS API . Envoy will add <nl> mmm a / docs / configuration / http_conn_man / route_config / vhost . rst <nl> ppp b / docs / configuration / http_conn_man / route_config / vhost . rst <nl> upstream cluster to route to or whether to perform a redirect . <nl> <nl> name <nl> * ( required , string ) * The logical name of the virtual host . This is used when emitting certain <nl> - statistics but is not relevant for forwarding . <nl> + statistics but is not relevant for forwarding . By default , the maximum length of the name is <nl> + limited to 60 characters . This limit can be increased by setting the <nl> + : option : ` - - max - obj - name - len ` command line argument to the desired value . <nl> <nl> domains <nl> * ( required , array ) * A list of domains ( host / authority header ) that will be matched to this <nl> mmm a / docs / configuration / listeners / listeners . rst <nl> ppp b / docs / configuration / listeners / listeners . rst <nl> name <nl> * ( optional , string ) * The unique name by which this listener is known . If no name is provided , <nl> Envoy will allocate an internal UUID for the listener . If the listener is to be dynamically <nl> updated or removed via : ref : ` LDS < config_listeners_lds > ` a unique name must be provided . <nl> + By default , the maximum length of a listener ' s name is limited to 60 characters . This limit can be <nl> + increased by setting the : option : ` - - max - obj - name - len ` command line argument to the desired value . <nl> <nl> address <nl> * ( required , string ) * The address that the listener should listen on . Currently only TCP <nl> mmm a / docs / operations / cli . rst <nl> ppp b / docs / operations / cli . rst <nl> following are the command line options that Envoy supports . <nl> during a hot restart . See the : ref : ` hot restart overview < arch_overview_hot_restart > ` for more <nl> information . Defaults to 900 seconds ( 15 minutes ) . <nl> <nl> - . . option : : - - max - stat - name - len < uint64_t > <nl> + . . option : : - - max - obj - name - len < uint64_t > <nl> <nl> - * ( optional ) * The maximum name length ( in bytes ) for a stat . This setting affects the output <nl> - of : option : ` - - hot - restart - version ` ; the same value must be used to hot restart . Defaults to 127 . <nl> + * ( optional ) * The maximum name length ( in bytes ) of the name field in a cluster / route_config / listener . <nl> + This setting is typically used in scenarios where the cluster names are auto generated , and often exceed <nl> + the built - in limit of 60 characters . Defaults to 60 . <nl> + <nl> + . . attention : : <nl> + <nl> + This setting affects the output of : option : ` - - hot - restart - version ` . If you started envoy with this <nl> + option set to a non default value , you should use the same option ( and same value ) for subsequent hot <nl> + restarts . <nl> <nl> . . option : : - - max - stats < uint64_t > <nl> <nl> mmm a / include / envoy / server / options . h <nl> ppp b / include / envoy / server / options . h <nl> class Options { <nl> virtual uint64_t maxStats ( ) PURE ; <nl> <nl> / * * <nl> - * @ return uint64_t the maximum name length of a stat . <nl> + * @ return uint64_t the maximum name length of the name field in <nl> + * router / cluster / listener . <nl> * / <nl> - virtual uint64_t maxStatNameLength ( ) PURE ; <nl> + virtual uint64_t maxObjNameLength ( ) PURE ; <nl> } ; <nl> <nl> } / / namespace Server <nl> mmm a / source / common / config / BUILD <nl> ppp b / source / common / config / BUILD <nl> envoy_cc_library ( <nl> " : address_json_lib " , <nl> " : json_utility_lib " , <nl> " : tls_context_json_lib " , <nl> + " : utility_lib " , <nl> " : well_known_names " , <nl> " / / include / envoy / json : json_object_interface " , <nl> " / / source / common / common : assert_lib " , <nl> envoy_cc_library ( <nl> " : well_known_names " , <nl> " / / include / envoy / json : json_object_interface " , <nl> " / / source / common / common : assert_lib " , <nl> + " / / source / common / config : utility_lib " , <nl> " / / source / common / json : config_schemas_lib " , <nl> ] , <nl> ) <nl> envoy_cc_library ( <nl> " / / source / common / json : config_schemas_lib " , <nl> " / / source / common / protobuf " , <nl> " / / source / common / protobuf : utility_lib " , <nl> + " / / source / common / stats : stats_lib " , <nl> ] , <nl> ) <nl> <nl> mmm a / source / common / config / cds_json . cc <nl> ppp b / source / common / config / cds_json . cc <nl> void CdsJson : : translateCluster ( const Json : : Object & json_cluster , <nl> const Optional < envoy : : api : : v2 : : ConfigSource > & eds_config , <nl> envoy : : api : : v2 : : Cluster & cluster ) { <nl> json_cluster . validateSchema ( Json : : Schema : : CLUSTER_SCHEMA ) ; <nl> - cluster . set_name ( json_cluster . getString ( " name " ) ) ; <nl> + <nl> + const std : : string name = json_cluster . getString ( " name " ) ; <nl> + Utility : : checkObjNameLength ( " Invalid cluster name " , name ) ; <nl> + cluster . set_name ( name ) ; <nl> + <nl> const std : : string string_type = json_cluster . getString ( " type " ) ; <nl> auto set_dns_hosts = [ & json_cluster , & cluster ] { <nl> const auto hosts = json_cluster . getObjectArray ( " hosts " ) ; <nl> mmm a / source / common / config / lds_json . cc <nl> ppp b / source / common / config / lds_json . cc <nl> <nl> # include " common / config / address_json . h " <nl> # include " common / config / json_utility . h " <nl> # include " common / config / tls_context_json . h " <nl> + # include " common / config / utility . h " <nl> # include " common / config / well_known_names . h " <nl> # include " common / json / config_schemas . h " <nl> # include " common / network / utility . h " <nl> void LdsJson : : translateListener ( const Json : : Object & json_listener , <nl> envoy : : api : : v2 : : Listener & listener ) { <nl> json_listener . validateSchema ( Json : : Schema : : LISTENER_SCHEMA ) ; <nl> <nl> + const std : : string name = json_listener . getString ( " name " , " " ) ; <nl> + Utility : : checkObjNameLength ( " Invalid listener name " , name ) ; <nl> + listener . set_name ( name ) ; <nl> + <nl> AddressJson : : translateAddress ( json_listener . getString ( " address " ) , true , true , <nl> * listener . mutable_address ( ) ) ; <nl> <nl> void LdsJson : : translateListener ( const Json : : Object & json_listener , <nl> } <nl> <nl> JSON_UTIL_SET_BOOL ( json_listener , * filter_chain , use_proxy_proto ) ; <nl> - <nl> JSON_UTIL_SET_BOOL ( json_listener , listener , use_original_dst ) ; <nl> - JSON_UTIL_SET_INTEGER ( json_listener , listener , per_connection_buffer_limit_bytes ) ; <nl> - JSON_UTIL_SET_STRING ( json_listener , listener , name ) ; <nl> - <nl> JSON_UTIL_SET_BOOL ( json_listener , * listener . mutable_deprecated_v1 ( ) , bind_to_port ) ; <nl> + JSON_UTIL_SET_INTEGER ( json_listener , listener , per_connection_buffer_limit_bytes ) ; <nl> } <nl> <nl> } / / namespace Config <nl> mmm a / source / common / config / rds_json . cc <nl> ppp b / source / common / config / rds_json . cc <nl> <nl> # include " common / config / base_json . h " <nl> # include " common / config / json_utility . h " <nl> # include " common / config / metadata . h " <nl> + # include " common / config / utility . h " <nl> # include " common / config / well_known_names . h " <nl> # include " common / json / config_schemas . h " <nl> <nl> void RdsJson : : translateRouteConfiguration ( const Json : : Object & json_route_config , <nl> void RdsJson : : translateVirtualHost ( const Json : : Object & json_virtual_host , <nl> envoy : : api : : v2 : : VirtualHost & virtual_host ) { <nl> json_virtual_host . validateSchema ( Json : : Schema : : VIRTUAL_HOST_CONFIGURATION_SCHEMA ) ; <nl> - JSON_UTIL_SET_STRING ( json_virtual_host , virtual_host , name ) ; <nl> + <nl> + const std : : string name = json_virtual_host . getString ( " name " , " " ) ; <nl> + Utility : : checkObjNameLength ( " Invalid virtual host name " , name ) ; <nl> + virtual_host . set_name ( name ) ; <nl> <nl> for ( const std : : string & domain : json_virtual_host . getStringArray ( " domains " , true ) ) { <nl> virtual_host . add_domains ( domain ) ; <nl> mmm a / source / common / config / utility . cc <nl> ppp b / source / common / config / utility . cc <nl> <nl> # include " common / json / config_schemas . h " <nl> # include " common / protobuf / protobuf . h " <nl> # include " common / protobuf / utility . h " <nl> + # include " common / stats / stats_impl . h " <nl> <nl> # include " fmt / format . h " <nl> <nl> void Utility : : translateCdsConfig ( const Json : : Object & json_config , <nl> <nl> void Utility : : translateRdsConfig ( const Json : : Object & json_rds , envoy : : api : : v2 : : filter : : Rds & rds ) { <nl> json_rds . validateSchema ( Json : : Schema : : RDS_CONFIGURATION_SCHEMA ) ; <nl> + <nl> + const std : : string name = json_rds . getString ( " route_config_name " , " " ) ; <nl> + checkObjNameLength ( " Invalid route_config name " , name ) ; <nl> + rds . set_route_config_name ( name ) ; <nl> + <nl> translateApiConfigSource ( json_rds . getString ( " cluster " ) , <nl> json_rds . getInteger ( " refresh_delay_ms " , 30000 ) , <nl> json_rds . getString ( " api_type " , ApiType : : get ( ) . RestLegacy ) , <nl> * rds . mutable_config_source ( ) - > mutable_api_config_source ( ) ) ; <nl> - JSON_UTIL_SET_STRING ( json_rds , rds , route_config_name ) ; <nl> } <nl> <nl> void Utility : : translateLdsConfig ( const Json : : Object & json_lds , <nl> std : : string Utility : : resourceName ( const ProtobufWkt : : Any & resource ) { <nl> fmt : : format ( " Unknown type URL { } in DiscoveryResponse " , resource . type_url ( ) ) ) ; <nl> } <nl> <nl> + void Utility : : checkObjNameLength ( const std : : string & error_prefix , const std : : string & name ) { <nl> + if ( name . length ( ) > Stats : : RawStatData : : maxObjNameLength ( ) ) { <nl> + throw EnvoyException ( fmt : : format ( " { } : Length of { } ( { } ) exceeds allowed maximum length ( { } ) " , <nl> + error_prefix , name , name . length ( ) , <nl> + Stats : : RawStatData : : maxObjNameLength ( ) ) ) ; <nl> + } <nl> + } <nl> + <nl> } / / namespace Config <nl> } / / namespace Envoy <nl> mmm a / source / common / config / utility . h <nl> ppp b / source / common / config / utility . h <nl> class Utility { <nl> * @ return std : : string resource name . <nl> * / <nl> static std : : string resourceName ( const ProtobufWkt : : Any & resource ) ; <nl> + <nl> + / * * <nl> + * Check user supplied name in RDS / CDS / LDS for sanity . <nl> + * It should be within the configured length limit . Throws on error . <nl> + * @ param error_prefix supplies the prefix to use in error messages . <nl> + * @ param name supplies the name to check for length limits . <nl> + * / <nl> + static void checkObjNameLength ( const std : : string & error_prefix , const std : : string & name ) ; <nl> } ; <nl> <nl> } / / namespace Config <nl> mmm a / source / common / json / config_schemas . cc <nl> ppp b / source / common / json / config_schemas . cc <nl> const std : : string Json : : Schema : : CLUSTER_SCHEMA ( R " EOF ( <nl> " properties " : { <nl> " name " : { <nl> " type " : " string " , <nl> - " minLength " : 1 , <nl> - " maxLength " : 60 <nl> + " minLength " : 1 <nl> } , <nl> " type " : { <nl> " type " : " string " , <nl> mmm a / source / common / stats / stats_impl . cc <nl> ppp b / source / common / stats / stats_impl . cc <nl> size_t RawStatData : : size ( ) { <nl> return roundUpMultipleNaturalAlignment ( sizeof ( RawStatData ) + nameSize ( ) ) ; <nl> } <nl> <nl> - size_t & RawStatData : : initializeAndGetMutableMaxNameLength ( size_t configured_size ) { <nl> + size_t & RawStatData : : initializeAndGetMutableMaxObjNameLength ( size_t configured_size ) { <nl> / / Like CONSTRUCT_ON_FIRST_USE , but non - const so that the value can be changed by tests <nl> static size_t size = configured_size ; <nl> return size ; <nl> } <nl> <nl> void RawStatData : : configure ( Server : : Options & options ) { <nl> - const size_t configured = options . maxStatNameLength ( ) ; <nl> + const size_t configured = options . maxObjNameLength ( ) ; <nl> RELEASE_ASSERT ( configured > 0 ) ; <nl> - size_t max_name_length = initializeAndGetMutableMaxNameLength ( configured ) ; <nl> + size_t max_obj_name_length = initializeAndGetMutableMaxObjNameLength ( configured ) ; <nl> <nl> / / If this fails , it means that this function was called too late during <nl> / / startup because things were already using this size before it was set . <nl> - RELEASE_ASSERT ( max_name_length = = configured ) ; <nl> + RELEASE_ASSERT ( max_obj_name_length = = configured ) ; <nl> } <nl> <nl> void RawStatData : : configureForTestsOnly ( Server : : Options & options ) { <nl> - const size_t configured = options . maxStatNameLength ( ) ; <nl> - initializeAndGetMutableMaxNameLength ( configured ) = configured ; <nl> + const size_t configured = options . maxObjNameLength ( ) ; <nl> + initializeAndGetMutableMaxObjNameLength ( configured ) = configured ; <nl> } <nl> <nl> std : : string Utility : : sanitizeStatsName ( const std : : string & name ) { <nl> mmm a / source / common / stats / stats_impl . h <nl> ppp b / source / common / stats / stats_impl . h <nl> struct RawStatData { <nl> * Returns the maximum length of the name of a stat . This length <nl> * does not include a trailing NULL - terminator . <nl> * / <nl> - static size_t maxNameLength ( ) { <nl> - return initializeAndGetMutableMaxNameLength ( DEFAULT_MAX_NAME_SIZE ) ; <nl> + static size_t maxNameLength ( ) { return maxObjNameLength ( ) + MAX_STAT_SUFFIX_LENGTH ; } <nl> + <nl> + / * * <nl> + * Returns the maximum length of a user supplied object ( route / cluster / listener ) <nl> + * name field in a stat . This length does not include a trailing NULL - terminator . <nl> + * / <nl> + static size_t maxObjNameLength ( ) { <nl> + return initializeAndGetMutableMaxObjNameLength ( DEFAULT_MAX_OBJ_NAME_LENGTH ) ; <nl> } <nl> <nl> + / * * <nl> + * Returns the maximum length of a stat suffix that Envoy generates ( over the user supplied name ) . <nl> + * This length does not include a trailing NULL - terminator . <nl> + * / <nl> + static size_t maxStatSuffixLength ( ) { return MAX_STAT_SUFFIX_LENGTH ; } <nl> + <nl> / * * <nl> * size in bytes of name_ <nl> * / <nl> struct RawStatData { <nl> char name_ [ ] ; <nl> <nl> private : <nl> - static const size_t DEFAULT_MAX_NAME_SIZE = 127 ; <nl> - <nl> - static size_t & initializeAndGetMutableMaxNameLength ( size_t configured_size ) ; <nl> + / / The max name length is based on current set of stats . <nl> + / / As of now , the longest stat is <nl> + / / cluster . < cluster_name > . outlier_detection . ejections_consecutive_5xx <nl> + / / which is 52 characters long without the cluster name . <nl> + / / The max stat name length is 127 ( default ) . So , in order to give room <nl> + / / for growth to both the envoy generated stat characters <nl> + / / ( e . g . , outlier_detection . . . ) and user supplied names ( e . g . , cluster name ) , <nl> + / / we set the max user supplied name length to 60 , and the max internally <nl> + / / generated stat suffixes to 67 ( 15 more characters to grow ) . <nl> + / / If you want to increase the max user supplied name length , use the compiler <nl> + / / option ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH or the CLI option <nl> + / / max - obj - name - len <nl> + static const size_t DEFAULT_MAX_OBJ_NAME_LENGTH = 60 ; <nl> + static const size_t MAX_STAT_SUFFIX_LENGTH = 67 ; <nl> + <nl> + static size_t & initializeAndGetMutableMaxObjNameLength ( size_t configured_size ) ; <nl> } ; <nl> <nl> / * * <nl> mmm a / source / server / BUILD <nl> ppp b / source / server / BUILD <nl> envoy_cc_library ( <nl> " / / include / envoy / server : options_interface " , <nl> " / / source / common / common : macros " , <nl> " / / source / common / common : version_lib " , <nl> + " / / source / common / stats : stats_lib " , <nl> ] , <nl> ) <nl> <nl> mmm a / source / server / options_impl . cc <nl> ppp b / source / server / options_impl . cc <nl> <nl> <nl> # include " common / common / macros . h " <nl> # include " common / common / version . h " <nl> + # include " common / stats / stats_impl . h " <nl> <nl> # include " fmt / format . h " <nl> # include " spdlog / spdlog . h " <nl> <nl> # endif <nl> <nl> / / Can be overridden at compile time <nl> - # ifndef ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH <nl> - # define ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH 127 <nl> + / / See comment in common / stat / stat_impl . h for rationale behind <nl> + / / this constant . <nl> + # ifndef ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH <nl> + # define ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH 60 <nl> # endif <nl> <nl> - # if ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH < 127 <nl> - # error " ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH must be > = 127 " <nl> + # if ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH < 60 <nl> + # error " ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH must be > = 60 " <nl> # endif <nl> <nl> namespace Envoy { <nl> OptionsImpl : : OptionsImpl ( int argc , char * * argv , const HotRestartVersionCb & hot_r <nl> " Maximum number of stats guages and counters " <nl> " that can be allocated in shared memory . " , <nl> false , ENVOY_DEFAULT_MAX_STATS , " uint64_t " , cmd ) ; <nl> - TCLAP : : ValueArg < uint64_t > max_stat_name_len ( " " , " max - stat - name - len " , <nl> - " Maximum name length for a stat " , false , <nl> - ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH , " uint64_t " , cmd ) ; <nl> + TCLAP : : ValueArg < uint64_t > max_obj_name_len ( " " , " max - obj - name - len " , <nl> + " Maximum name length for a field in the config " <nl> + " ( applies to listener name , route config name and " <nl> + " the cluster name ) " , <nl> + false , ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH , " uint64_t " , <nl> + cmd ) ; <nl> <nl> try { <nl> cmd . parse ( argc , argv ) ; <nl> OptionsImpl : : OptionsImpl ( int argc , char * * argv , const HotRestartVersionCb & hot_r <nl> exit ( 1 ) ; <nl> } <nl> <nl> - if ( max_stat_name_len . getValue ( ) < 127 ) { <nl> - std : : cerr < < " error : the ' max - stat - name - len ' value specified ( " < < max_stat_name_len . getValue ( ) <nl> - < < " ) is less than the minimum value of 127 " < < std : : endl ; <nl> + if ( max_obj_name_len . getValue ( ) < 60 ) { <nl> + std : : cerr < < " error : the ' max - obj - name - len ' value specified ( " < < max_obj_name_len . getValue ( ) <nl> + < < " ) is less than the minimum value of 60 " < < std : : endl ; <nl> exit ( 1 ) ; <nl> } <nl> <nl> if ( hot_restart_version_option . getValue ( ) ) { <nl> - std : : cerr < < hot_restart_version_cb ( max_stats . getValue ( ) , max_stat_name_len . getValue ( ) ) ; <nl> + std : : cerr < < hot_restart_version_cb ( max_stats . getValue ( ) , <nl> + max_obj_name_len . getValue ( ) + <nl> + Stats : : RawStatData : : maxStatSuffixLength ( ) ) ; <nl> exit ( 0 ) ; <nl> } <nl> <nl> OptionsImpl : : OptionsImpl ( int argc , char * * argv , const HotRestartVersionCb & hot_r <nl> drain_time_ = std : : chrono : : seconds ( drain_time_s . getValue ( ) ) ; <nl> parent_shutdown_time_ = std : : chrono : : seconds ( parent_shutdown_time_s . getValue ( ) ) ; <nl> max_stats_ = max_stats . getValue ( ) ; <nl> - max_stat_name_length_ = max_stat_name_len . getValue ( ) ; <nl> + max_obj_name_length_ = max_obj_name_len . getValue ( ) ; <nl> } <nl> } / / namespace Envoy <nl> mmm a / source / server / options_impl . h <nl> ppp b / source / server / options_impl . h <nl> class OptionsImpl : public Server : : Options { <nl> const std : : string & serviceNodeName ( ) override { return service_node_ ; } <nl> const std : : string & serviceZone ( ) override { return service_zone_ ; } <nl> uint64_t maxStats ( ) override { return max_stats_ ; } <nl> - uint64_t maxStatNameLength ( ) override { return max_stat_name_length_ ; } <nl> + uint64_t maxObjNameLength ( ) override { return max_obj_name_length_ ; } <nl> <nl> private : <nl> uint64_t base_id_ ; <nl> class OptionsImpl : public Server : : Options { <nl> std : : chrono : : seconds parent_shutdown_time_ ; <nl> Server : : Mode mode_ ; <nl> uint64_t max_stats_ ; <nl> - uint64_t max_stat_name_length_ ; <nl> + uint64_t max_obj_name_length_ ; <nl> } ; <nl> } / / namespace Envoy <nl> mmm a / test / common / config / BUILD <nl> ppp b / test / common / config / BUILD <nl> envoy_cc_test ( <nl> srcs = [ " utility_test . cc " ] , <nl> external_deps = [ " envoy_eds " ] , <nl> deps = [ <nl> + " / / source / common / config : cds_json_lib " , <nl> + " / / source / common / config : lds_json_lib " , <nl> + " / / source / common / config : rds_json_lib " , <nl> " / / source / common / config : utility_lib " , <nl> + " / / source / common / stats : stats_lib " , <nl> " / / test / mocks / local_info : local_info_mocks " , <nl> + " / / test / test_common : utility_lib " , <nl> ] , <nl> ) <nl> mmm a / test / common / config / utility_test . cc <nl> ppp b / test / common / config / utility_test . cc <nl> <nl> + # include " common / config / cds_json . h " <nl> + # include " common / config / lds_json . h " <nl> + # include " common / config / rds_json . h " <nl> # include " common / config / utility . h " <nl> # include " common / protobuf / protobuf . h " <nl> + # include " common / stats / stats_impl . h " <nl> <nl> # include " test / mocks / local_info / mocks . h " <nl> + # include " test / test_common / utility . h " <nl> <nl> # include " api / eds . pb . h " <nl> + # include " fmt / format . h " <nl> # include " gmock / gmock . h " <nl> # include " gtest / gtest . h " <nl> <nl> TEST ( UtilityTest , TranslateApiConfigSource ) { <nl> EXPECT_EQ ( " test_grpc_cluster " , api_config_source_grpc . cluster_name ( 0 ) ) ; <nl> } <nl> <nl> + TEST ( UtilityTest , ObjNameLength ) { <nl> + <nl> + std : : string name = " listenerwithareallyreallylongnamemorethanmaxcharsallowedbyschema " ; <nl> + std : : string err_prefix ; <nl> + std : : string err_suffix = fmt : : format ( " : Length of { } ( { } ) exceeds allowed maximum length ( { } ) " , <nl> + name , name . length ( ) , Stats : : RawStatData : : maxObjNameLength ( ) ) ; <nl> + { <nl> + err_prefix = " test " ; <nl> + EXPECT_THROW_WITH_MESSAGE ( Utility : : checkObjNameLength ( err_prefix , name ) , EnvoyException , <nl> + err_prefix + err_suffix ) ; <nl> + } <nl> + <nl> + { <nl> + err_prefix = " Invalid listener name " ; <nl> + std : : string json = <nl> + R " EOF ( { " name " : " ) EOF " + name + R " EOF ( " , " address " : " foo " , " filters " : [ ] } ) EOF " ; <nl> + auto json_object_ptr = Json : : Factory : : loadFromString ( json ) ; <nl> + <nl> + envoy : : api : : v2 : : Listener listener ; <nl> + EXPECT_THROW_WITH_MESSAGE ( Config : : LdsJson : : translateListener ( * json_object_ptr , listener ) , <nl> + EnvoyException , err_prefix + err_suffix ) ; <nl> + } <nl> + <nl> + { <nl> + err_prefix = " Invalid virtual host name " ; <nl> + std : : string json = R " EOF ( { " name " : " ) EOF " + name + R " EOF ( " , " domains " : [ ] , " routes " : [ ] } ) EOF " ; <nl> + auto json_object_ptr = Json : : Factory : : loadFromString ( json ) ; <nl> + envoy : : api : : v2 : : VirtualHost vhost ; <nl> + EXPECT_THROW_WITH_MESSAGE ( Config : : RdsJson : : translateVirtualHost ( * json_object_ptr , vhost ) , <nl> + EnvoyException , err_prefix + err_suffix ) ; <nl> + } <nl> + <nl> + { <nl> + err_prefix = " Invalid cluster name " ; <nl> + std : : string json = <nl> + R " EOF ( { " name " : " ) EOF " + name + <nl> + R " EOF ( " , " type " : " static " , " lb_type " : " random " , " connect_timeout_ms " : 1 } ) EOF " ; <nl> + auto json_object_ptr = Json : : Factory : : loadFromString ( json ) ; <nl> + envoy : : api : : v2 : : Cluster cluster ; <nl> + envoy : : api : : v2 : : ConfigSource eds_config ; <nl> + EXPECT_THROW_WITH_MESSAGE ( <nl> + Config : : CdsJson : : translateCluster ( * json_object_ptr , eds_config , cluster ) , EnvoyException , <nl> + err_prefix + err_suffix ) ; <nl> + } <nl> + <nl> + { <nl> + err_prefix = " Invalid route_config name " ; <nl> + std : : string json = R " EOF ( { " route_config_name " : " ) EOF " + name + R " EOF ( " , " cluster " : " foo " } ) EOF " ; <nl> + auto json_object_ptr = Json : : Factory : : loadFromString ( json ) ; <nl> + envoy : : api : : v2 : : filter : : Rds rds ; <nl> + EXPECT_THROW_WITH_MESSAGE ( Config : : Utility : : translateRdsConfig ( * json_object_ptr , rds ) , <nl> + EnvoyException , err_prefix + err_suffix ) ; <nl> + } <nl> + } <nl> + <nl> } / / namespace Config <nl> } / / namespace Envoy <nl> mmm a / test / common / upstream / cluster_manager_impl_test . cc <nl> ppp b / test / common / upstream / cluster_manager_impl_test . cc <nl> TEST_F ( ClusterManagerImplTest , UnknownHcType ) { <nl> EXPECT_THROW ( create ( parseBootstrapFromJson ( json ) ) , EnvoyException ) ; <nl> } <nl> <nl> - TEST_F ( ClusterManagerImplTest , MaxClusterName ) { <nl> - const std : : string json = R " EOF ( <nl> - { <nl> - " clusters " : [ <nl> - { <nl> - " name " : " clusterwithareallyreallylongnamemorethanmaxcharsallowedbyschema " <nl> - } ] <nl> - } <nl> - ) EOF " ; <nl> - <nl> - EXPECT_THROW_WITH_MESSAGE ( create ( parseBootstrapFromJson ( json ) ) , Json : : Exception , <nl> - " JSON at lines 4 - 6 does not conform to schema . \ n Invalid schema : " <nl> - " # / properties / name \ n Schema violation : maxLength \ n Offending " <nl> - " document key : # / name " ) ; <nl> - } <nl> - <nl> TEST_F ( ClusterManagerImplTest , ValidClusterName ) { <nl> const std : : string json = R " EOF ( <nl> { <nl> mmm a / test / integration / hotrestart_test . sh <nl> ppp b / test / integration / hotrestart_test . sh <nl> do <nl> exit 2 <nl> fi <nl> <nl> - echo " Checking max - stat - name - len " <nl> - CLI_HOT_RESTART_VERSION = $ ( " $ { ENVOY_BIN } " - - hot - restart - version - - max - stat - name - len 1234 2 > & 1 ) <nl> + echo " Checking max - obj - name - len " <nl> + CLI_HOT_RESTART_VERSION = $ ( " $ { ENVOY_BIN } " - - hot - restart - version - - max - obj - name - len 1234 2 > & 1 ) <nl> if [ [ " $ { ADMIN_HOT_RESTART_VERSION } " = " $ { CLI_HOT_RESTART_VERSION } " ] ] ; then <nl> echo " Hot restart version match when it should mismatch : $ { ADMIN_HOT_RESTART_VERSION } = = " \ <nl> " $ { CLI_HOT_RESTART_VERSION } " <nl> mmm a / test / integration / server . h <nl> ppp b / test / integration / server . h <nl> class TestOptionsImpl : public Options { <nl> const std : : string & serviceNodeName ( ) override { return service_node_name_ ; } <nl> const std : : string & serviceZone ( ) override { return service_zone_ ; } <nl> uint64_t maxStats ( ) override { return 16384 ; } <nl> - uint64_t maxStatNameLength ( ) override { return 127 ; } <nl> + uint64_t maxObjNameLength ( ) override { return 60 ; } <nl> <nl> private : <nl> const std : : string config_path_ ; <nl> mmm a / test / mocks / server / mocks . cc <nl> ppp b / test / mocks / server / mocks . cc <nl> MockOptions : : MockOptions ( const std : : string & config_path ) <nl> ON_CALL ( * this , serviceZone ( ) ) . WillByDefault ( ReturnRef ( service_zone_name_ ) ) ; <nl> ON_CALL ( * this , logPath ( ) ) . WillByDefault ( ReturnRef ( log_path_ ) ) ; <nl> ON_CALL ( * this , maxStats ( ) ) . WillByDefault ( Return ( 1000 ) ) ; <nl> - ON_CALL ( * this , maxStatNameLength ( ) ) . WillByDefault ( Return ( 150 ) ) ; <nl> + ON_CALL ( * this , maxObjNameLength ( ) ) . WillByDefault ( Return ( 150 ) ) ; <nl> } <nl> MockOptions : : ~ MockOptions ( ) { } <nl> <nl> mmm a / test / mocks / server / mocks . h <nl> ppp b / test / mocks / server / mocks . h <nl> class MockOptions : public Options { <nl> MOCK_METHOD0 ( serviceNodeName , const std : : string & ( ) ) ; <nl> MOCK_METHOD0 ( serviceZone , const std : : string & ( ) ) ; <nl> MOCK_METHOD0 ( maxStats , uint64_t ( ) ) ; <nl> - MOCK_METHOD0 ( maxStatNameLength , uint64_t ( ) ) ; <nl> + MOCK_METHOD0 ( maxObjNameLength , uint64_t ( ) ) ; <nl> <nl> std : : string config_path_ ; <nl> std : : string admin_address_path_ ; <nl> mmm a / test / server / BUILD <nl> ppp b / test / server / BUILD <nl> envoy_cc_test ( <nl> name = " hot_restart_impl_test " , <nl> srcs = envoy_select_hot_restart ( [ " hot_restart_impl_test . cc " ] ) , <nl> deps = [ <nl> + " / / source / common / stats : stats_lib " , <nl> " / / source / server : hot_restart_lib " , <nl> " / / test / mocks / server : server_mocks " , <nl> ] , <nl> mmm a / test / server / hot_restart_impl_test . cc <nl> ppp b / test / server / hot_restart_impl_test . cc <nl> <nl> + # include " common / stats / stats_impl . h " <nl> + <nl> # include " server / hot_restart_impl . h " <nl> <nl> # include " test / mocks / api / mocks . h " <nl> class HotRestartImplTest : public testing : : Test { <nl> <nl> TEST_F ( HotRestartImplTest , versionString ) { <nl> setup ( ) ; <nl> - EXPECT_EQ ( hot_restart_ - > version ( ) , Envoy : : Server : : SharedMemory : : version ( <nl> - options_ . maxStats ( ) , options_ . maxStatNameLength ( ) ) ) ; <nl> + EXPECT_EQ ( hot_restart_ - > version ( ) , <nl> + Envoy : : Server : : SharedMemory : : version ( options_ . maxStats ( ) , <nl> + options_ . maxObjNameLength ( ) + <nl> + Stats : : RawStatData : : maxStatSuffixLength ( ) ) ) ; <nl> } <nl> <nl> TEST_F ( HotRestartImplTest , crossAlloc ) { <nl> class HotRestartImplAlignmentTest : public HotRestartImplTest , <nl> public : <nl> HotRestartImplAlignmentTest ( ) : name_len_ ( 8 + GetParam ( ) ) { <nl> EXPECT_CALL ( options_ , maxStats ( ) ) . WillRepeatedly ( Return ( num_stats_ ) ) ; <nl> - EXPECT_CALL ( options_ , maxStatNameLength ( ) ) . WillRepeatedly ( Return ( name_len_ ) ) ; <nl> + EXPECT_CALL ( options_ , maxObjNameLength ( ) ) . WillRepeatedly ( Return ( name_len_ ) ) ; <nl> setup ( ) ; <nl> - EXPECT_EQ ( name_len_ , Stats : : RawStatData : : maxNameLength ( ) ) ; <nl> + EXPECT_EQ ( name_len_ , Stats : : RawStatData : : maxObjNameLength ( ) ) ; <nl> } <nl> <nl> static const uint64_t num_stats_ = 8 ; <nl> TEST_P ( HotRestartImplAlignmentTest , objectOverlap ) { <nl> } ; <nl> std : : vector < TestStat > stats ; <nl> for ( uint64_t i = 0 ; i < num_stats_ ; i + + ) { <nl> - std : : string name = fmt : : format ( " { } zzzzzzzzzzzzzzzzzzzzzzzzzzzz " , i ) <nl> + std : : string name = fmt : : format ( " { } zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " <nl> + " zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " <nl> + " zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " , <nl> + i ) <nl> . substr ( 0 , Stats : : RawStatData : : maxNameLength ( ) ) ; <nl> TestStat ts ; <nl> ts . stat_ = hot_restart_ - > alloc ( name ) ; <nl> mmm a / test / server / options_impl_test . cc <nl> ppp b / test / server / options_impl_test . cc <nl> TEST ( OptionsImplTest , BadCliOption ) { <nl> " error : unknown IP address version ' foo ' " ) ; <nl> } <nl> <nl> - TEST ( OptionsImplTest , BadStatNameLenOption ) { <nl> - EXPECT_DEATH ( createOptionsImpl ( " envoy - - max - stat - name - len 1 " ) , <nl> - " error : the ' max - stat - name - len ' value specified " ) ; <nl> + TEST ( OptionsImplTest , BadObjNameLenOption ) { <nl> + EXPECT_DEATH ( createOptionsImpl ( " envoy - - max - obj - name - len 1 " ) , <nl> + " error : the ' max - obj - name - len ' value specified " ) ; <nl> } <nl> } / / namespace Envoy <nl> | set cluster / route / listener / vhost name len based on CLI opt ( ) | envoyproxy/envoy | e366bcfd8dee9d4f2eb3956e77a77f17bd7a5244 | 2017-10-19T03:36:59Z |
mmm a / include / mlir / Analysis / AffineStructures . h <nl> ppp b / include / mlir / Analysis / AffineStructures . h <nl> class HyperRectangularSet ; <nl> / / / A mutable affine map . Its affine expressions are however unique . <nl> struct MutableAffineMap { <nl> public : <nl> - explicit MutableAffineMap ( AffineMap * map ) ; <nl> + MutableAffineMap ( AffineMap * map , MLIRContext * context ) ; <nl> <nl> AffineExpr * getResult ( unsigned idx ) const { return results [ idx ] ; } <nl> unsigned getNumResults ( ) const { return results . size ( ) ; } <nl> + unsigned getNumDims ( ) const { return numDims ; } <nl> + unsigned getNumSymbols ( ) const { return numSymbols ; } <nl> + / / / Returns true if the idx ' th result expression is a multiple of factor . <nl> + bool isMultipleOf ( unsigned idx , int64_t factor ) const ; <nl> + <nl> + / / / Simplify the ( result ) expressions in this map using analysis ( used by <nl> + / / - simplify - affine - expr pass ) . <nl> + void simplify ( ) ; <nl> + / / / Get the AffineMap corresponding to this MutableAffineMap . Note that an <nl> + / / / AffineMap * will be uniqued and stored in context , while a mutable one <nl> + / / / isn ' t . <nl> + AffineMap * getAffineMap ( ) ; <nl> <nl> private : <nl> + / / Same meaning as AffineMap ' s fields . <nl> SmallVector < AffineExpr * , 8 > results ; <nl> SmallVector < AffineExpr * , 8 > rangeSizes ; <nl> + unsigned numDims ; <nl> + unsigned numSymbols ; <nl> + / / / A pointer to the IR ' s context to store all newly created AffineExpr ' s . <nl> + MLIRContext * context ; <nl> } ; <nl> <nl> / / / A mutable integer set . Its affine expressions are however unique . <nl> struct MutableIntegerSet { <nl> public : <nl> - explicit MutableIntegerSet ( IntegerSet * set ) ; <nl> + MutableIntegerSet ( IntegerSet * set , MLIRContext * context ) ; <nl> <nl> / / / Create a universal set ( no constraints ) . <nl> - explicit MutableIntegerSet ( unsigned numDims , unsigned numSymbols ) ; <nl> + MutableIntegerSet ( unsigned numDims , unsigned numSymbols , <nl> + MLIRContext * context ) ; <nl> <nl> unsigned getNumDims ( ) const { return numDims ; } <nl> unsigned getNumSymbols ( ) const { return numSymbols ; } <nl> struct MutableIntegerSet { <nl> <nl> SmallVector < AffineExpr * , 8 > constraints ; <nl> SmallVector < bool , 8 > eqFlags ; <nl> + / / / A pointer to the IR ' s context to store all newly created AffineExpr ' s . <nl> + MLIRContext * context ; <nl> } ; <nl> <nl> / / / An AffineValueMap is an affine map plus its ML value operands and <nl> struct MutableIntegerSet { <nl> / / TODO ( bondhugula ) : Some of these classes could go into separate files . <nl> class AffineValueMap { <nl> public : <nl> - explicit AffineValueMap ( const AffineApplyOp & op ) ; <nl> - explicit AffineValueMap ( const AffineBound & bound ) ; <nl> - explicit AffineValueMap ( AffineMap * map ) ; <nl> + AffineValueMap ( const AffineApplyOp & op , MLIRContext * context ) ; <nl> + AffineValueMap ( const AffineBound & bound , MLIRContext * context ) ; <nl> + AffineValueMap ( AffineMap * map , MLIRContext * context ) ; <nl> <nl> ~ AffineValueMap ( ) ; <nl> <nl> class AffineValueMap { <nl> <nl> / / / Return true if the idx ^ th result can be proved to be a multiple of <nl> / / / ' factor ' , false otherwise . <nl> - bool isMultipleOf ( unsigned idx , int64_t factor ) const ; <nl> + inline bool isMultipleOf ( unsigned idx , int64_t factor ) const ; <nl> <nl> / / / Return true if the result at ' idx ' is a constant , false <nl> / / / otherwise . <nl> class AffineValueMap { <nl> SmallVector < MLValue * , 4 > operands ; <nl> / / / The SSA results binding to the results of ' map ' . <nl> SmallVector < MLValue * , 4 > results ; <nl> - / / / A pointer to the IR ' s context to store all newly created AffineExpr ' s . <nl> - MLIRContext * context ; <nl> } ; <nl> <nl> / / / An IntegerValueSet is an integer set plus its operands . <nl> class IntegerValueSet { <nl> MutableIntegerSet set ; <nl> / / / The SSA operands binding to the dim ' s and symbols of ' set ' . <nl> SmallVector < MLValue * , 4 > operands ; <nl> - / / / A pointer to the IR ' s context to store all newly created AffineExpr ' s . <nl> - MLIRContext * context ; <nl> } ; <nl> <nl> / / / A flat list of affine equalities and inequalities in the form . <nl> class FlatAffineConstraints { <nl> / / / constraints and identifiers . . <nl> FlatAffineConstraints ( unsigned numReservedInequalities , <nl> unsigned numReservedEqualities , unsigned numReservedIds ) <nl> - : numEqualities ( 0 ) , numInequalities ( 0 ) , <nl> - numReservedEqualities ( numReservedEqualities ) , <nl> + : numReservedEqualities ( numReservedEqualities ) , <nl> numReservedInequalities ( numReservedInequalities ) , <nl> numReservedIds ( numReservedIds ) { <nl> equalities . reserve ( numReservedIds * numReservedEqualities ) ; <nl> class FlatAffineConstraints { <nl> <nl> / / / Create an affine constraint system from an IntegerValueSet . <nl> / / TODO ( bondhugula ) <nl> - FlatAffineConstraints ( const IntegerValueSet & set ) ; <nl> + explicit FlatAffineConstraints ( const IntegerValueSet & set ) ; <nl> <nl> FlatAffineConstraints ( ArrayRef < const AffineValueMap * > avmRef , <nl> const IntegerSet & set ) ; <nl> <nl> + FlatAffineConstraints ( const MutableAffineMap & map ) ; <nl> + <nl> ~ FlatAffineConstraints ( ) { } <nl> <nl> - inline int64_t atEq ( unsigned i , unsigned j ) { <nl> - return equalities [ i * numIds + j ] ; <nl> + inline int64_t atEq ( unsigned i , unsigned j ) const { <nl> + return equalities [ i * ( numIds + 1 ) + j ] ; <nl> + } <nl> + <nl> + inline int64_t & atEq ( unsigned i , unsigned j ) { <nl> + return equalities [ i * ( numIds + 1 ) + j ] ; <nl> } <nl> <nl> - inline int64_t atIneq ( unsigned i , unsigned j ) { <nl> - return inequalities [ i * numIds + j ] ; <nl> + inline int64_t atIneq ( unsigned i , unsigned j ) const { <nl> + return inequalities [ i * ( numIds + 1 ) + j ] ; <nl> } <nl> <nl> - unsigned getNumEqualities ( ) const { return equalities . size ( ) ; } <nl> - unsigned getNumInequalities ( ) const { return inequalities . size ( ) ; } <nl> + inline int64_t & atIneq ( unsigned i , unsigned j ) { <nl> + return inequalities [ i * ( numIds + 1 ) + j ] ; <nl> + } <nl> + <nl> + inline unsigned getNumCols ( ) const { return numIds + 1 ; } <nl> + <nl> + inline unsigned getNumEqualities ( ) const { <nl> + return equalities . size ( ) / getNumCols ( ) ; <nl> + } <nl> + <nl> + inline unsigned getNumInequalities ( ) const { <nl> + return inequalities . size ( ) / getNumCols ( ) ; <nl> + } <nl> + <nl> + ArrayRef < int64_t > getEquality ( unsigned idx ) { <nl> + return ArrayRef < int64_t > ( & equalities [ idx * getNumCols ( ) ] , getNumCols ( ) ) ; <nl> + } <nl> + <nl> + ArrayRef < int64_t > getInequality ( unsigned idx ) { <nl> + return ArrayRef < int64_t > ( & inequalities [ idx * getNumCols ( ) ] , getNumCols ( ) ) ; <nl> + } <nl> + <nl> + AffineExpr * toAffineExpr ( unsigned idx , MLIRContext * context ) ; <nl> <nl> void addInequality ( ArrayRef < int64_t > inEq ) ; <nl> void addEquality ( ArrayRef < int64_t > eq ) ; <nl> class FlatAffineConstraints { <nl> void removeEquality ( unsigned pos ) ; <nl> void removeInequality ( unsigned pos ) ; <nl> <nl> - unsigned getNumConstraints ( ) const { return numEqualities + numInequalities ; } <nl> - unsigned getNumIds ( ) const { return numIds ; } <nl> - unsigned getNumDimIds ( ) const { return numDims ; } <nl> - unsigned getNumSymbolIds ( ) const { return numSymbols ; } <nl> - unsigned getNumLocalIds ( ) const { return numDims - numSymbols - numDims ; } <nl> + unsigned getNumConstraints ( ) const { <nl> + return equalities . size ( ) + inequalities . size ( ) ; <nl> + } <nl> + inline unsigned getNumIds ( ) const { return numIds ; } <nl> + inline unsigned getNumResultDimIds ( ) const { return numResultDims ; } <nl> + inline unsigned getNumDimIds ( ) const { return numDims ; } <nl> + inline unsigned getNumSymbolIds ( ) const { return numSymbols ; } <nl> + inline unsigned getNumLocalIds ( ) const { <nl> + return numIds - numResultDims - numDims - numSymbols ; <nl> + } <nl> + <nl> + void print ( raw_ostream & os ) const ; <nl> + void dump ( ) const ; <nl> <nl> private : <nl> / / / Coefficients of affine equalities ( in = = 0 form ) . <nl> class FlatAffineConstraints { <nl> / / / Coefficients of affine inequalities ( in > = 0 form ) . <nl> SmallVector < int64_t , 64 > inequalities ; <nl> <nl> - / / / Number of equalities in this system . <nl> - unsigned numEqualities ; <nl> - <nl> - / / / Number of inequalities in this system . <nl> - unsigned numInequalities ; <nl> - <nl> / / Pre - allocated space . <nl> unsigned numReservedEqualities ; <nl> unsigned numReservedInequalities ; <nl> class FlatAffineConstraints { <nl> / / / Total number of identifiers . <nl> unsigned numIds ; <nl> <nl> + / / / Number of identifiers corresponding to real dimensions . <nl> + unsigned numResultDims ; <nl> + <nl> / / / Number of identifiers corresponding to real dimensions . <nl> unsigned numDims ; <nl> <nl> mmm a / include / mlir / Analysis / HyperRectangularSet . h <nl> ppp b / include / mlir / Analysis / HyperRectangularSet . h <nl> class HyperRectangularSet <nl> HyperRectangularSet ( unsigned numDims , unsigned numSymbols , <nl> ArrayRef < ArrayRef < AffineExpr * > > lbs , <nl> ArrayRef < ArrayRef < AffineExpr * > > ubs , <nl> + MLIRContext * context , <nl> IntegerSet * symbolContext = nullptr ) ; <nl> <nl> unsigned getNumDims ( ) const { return numDims ; } <nl> mmm a / include / mlir / IR / AffineExpr . h <nl> ppp b / include / mlir / IR / AffineExpr . h <nl> class AffineExpr { <nl> / / / floordiv , ceildiv , and mod is only allowed w . r . t constants . <nl> bool isPureAffine ( ) const ; <nl> <nl> + / / / Returns the greatest known common divisor of this affine expression . <nl> + uint64_t getKnownGcd ( ) const ; <nl> + <nl> + / / / Return true if the affine expression is a multiple of ' factor ' . <nl> + bool isMultipleOf ( int64_t factor ) const ; <nl> + <nl> protected : <nl> explicit AffineExpr ( Kind kind ) : kind ( kind ) { } <nl> ~ AffineExpr ( ) { } <nl> mmm a / include / mlir / IR / AffineExprVisitor . h <nl> ppp b / include / mlir / IR / AffineExprVisitor . h <nl> <nl> <nl> namespace mlir { <nl> <nl> - / / / Base class for AffineExpr visitors . <nl> + / / / Base class for AffineExpr visitors / walkers . <nl> / / / <nl> / / / AffineExpr visitors are used when you want to perform different actions <nl> / / / for different kinds of AffineExprs without having to use lots of casts <nl> namespace mlir { <nl> / / / just as efficient as having your own switch statement over the statement <nl> / / / opcode . <nl> <nl> - template < typename SubClass > class AffineExprVisitor { <nl> + template < typename SubClass , typename RetTy = void > class AffineExprVisitor { <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> / / Interface code - This is the public interface of the AffineExprVisitor <nl> / / that you use to visit affine expressions . . . <nl> public : <nl> + / / Function to walk an AffineExpr ( in post order ) . <nl> + RetTy walkPostOrder ( AffineExpr * expr ) { <nl> + static_assert ( std : : is_base_of < AffineExprVisitor , SubClass > : : value , <nl> + " Must instantiate with a derived type of AffineExprVisitor " ) ; <nl> + switch ( expr - > getKind ( ) ) { <nl> + case AffineExpr : : Kind : : Add : { <nl> + auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> + walkOperandsPostOrder ( binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitAddExpr ( binOpExpr ) ; <nl> + } <nl> + case AffineExpr : : Kind : : Mul : { <nl> + auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> + walkOperandsPostOrder ( binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitMulExpr ( binOpExpr ) ; <nl> + } <nl> + case AffineExpr : : Kind : : Mod : { <nl> + auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> + walkOperandsPostOrder ( binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitModExpr ( binOpExpr ) ; <nl> + } <nl> + case AffineExpr : : Kind : : FloorDiv : { <nl> + auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> + walkOperandsPostOrder ( binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitFloorDivExpr ( binOpExpr ) ; <nl> + } <nl> + case AffineExpr : : Kind : : CeilDiv : { <nl> + auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> + walkOperandsPostOrder ( binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitCeilDivExpr ( binOpExpr ) ; <nl> + } <nl> + case AffineExpr : : Kind : : Constant : <nl> + return static_cast < SubClass * > ( this ) - > visitConstantExpr ( <nl> + cast < AffineConstantExpr > ( expr ) ) ; <nl> + case AffineExpr : : Kind : : DimId : <nl> + return static_cast < SubClass * > ( this ) - > visitDimExpr ( <nl> + cast < AffineDimExpr > ( expr ) ) ; <nl> + case AffineExpr : : Kind : : SymbolId : <nl> + return static_cast < SubClass * > ( this ) - > visitSymbolExpr ( <nl> + cast < AffineSymbolExpr > ( expr ) ) ; <nl> + } <nl> + } <nl> + <nl> / / Function to visit an AffineExpr . <nl> - void visit ( AffineExpr * expr ) { <nl> + RetTy visit ( AffineExpr * expr ) { <nl> static_assert ( std : : is_base_of < AffineExprVisitor , SubClass > : : value , <nl> " Must instantiate with a derived type of AffineExprVisitor " ) ; <nl> switch ( expr - > getKind ( ) ) { <nl> case AffineExpr : : Kind : : Add : { <nl> auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> - visitAffineBinaryOpOperands ( binOpExpr ) ; <nl> - return static_cast < SubClass * > ( this ) - > visitAffineBinaryAddOpExpr ( <nl> - binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitAddExpr ( binOpExpr ) ; <nl> } <nl> case AffineExpr : : Kind : : Mul : { <nl> auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> - visitAffineBinaryOpOperands ( binOpExpr ) ; <nl> - return static_cast < SubClass * > ( this ) - > visitAffineBinaryMulOpExpr ( <nl> - binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitMulExpr ( binOpExpr ) ; <nl> } <nl> case AffineExpr : : Kind : : Mod : { <nl> auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> - visitAffineBinaryOpOperands ( binOpExpr ) ; <nl> - return static_cast < SubClass * > ( this ) - > visitAffineBinaryModOpExpr ( <nl> - binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitModExpr ( binOpExpr ) ; <nl> } <nl> case AffineExpr : : Kind : : FloorDiv : { <nl> auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> - visitAffineBinaryOpOperands ( binOpExpr ) ; <nl> - return static_cast < SubClass * > ( this ) - > visitAffineBinaryFloorDivOpExpr ( <nl> - binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitFloorDivExpr ( binOpExpr ) ; <nl> } <nl> case AffineExpr : : Kind : : CeilDiv : { <nl> auto * binOpExpr = cast < AffineBinaryOpExpr > ( expr ) ; <nl> - visitAffineBinaryOpOperands ( binOpExpr ) ; <nl> - return static_cast < SubClass * > ( this ) - > visitAffineBinaryCeilDivOpExpr ( <nl> - binOpExpr ) ; <nl> + return static_cast < SubClass * > ( this ) - > visitCeilDivExpr ( binOpExpr ) ; <nl> } <nl> case AffineExpr : : Kind : : Constant : <nl> - return static_cast < SubClass * > ( this ) - > visitAffineConstantExpr ( <nl> + return static_cast < SubClass * > ( this ) - > visitConstantExpr ( <nl> cast < AffineConstantExpr > ( expr ) ) ; <nl> case AffineExpr : : Kind : : DimId : <nl> - return static_cast < SubClass * > ( this ) - > visitAffineDimExpr ( <nl> + return static_cast < SubClass * > ( this ) - > visitDimExpr ( <nl> cast < AffineDimExpr > ( expr ) ) ; <nl> case AffineExpr : : Kind : : SymbolId : <nl> - return static_cast < SubClass * > ( this ) - > visitAffineSymbolExpr ( <nl> + return static_cast < SubClass * > ( this ) - > visitSymbolExpr ( <nl> cast < AffineSymbolExpr > ( expr ) ) ; <nl> } <nl> } <nl> template < typename SubClass > class AffineExprVisitor { <nl> / / Default visit methods . Note that the default op - specific binary op visit <nl> / / methods call the general visitAffineBinaryOpExpr visit method . <nl> void visitAffineBinaryOpExpr ( AffineBinaryOpExpr * expr ) { } <nl> - void visitAffineBinaryAddOpExpr ( AffineBinaryOpExpr * expr ) { <nl> + void visitAddExpr ( AffineBinaryOpExpr * expr ) { <nl> static_cast < SubClass * > ( this ) - > visitAffineBinaryOpExpr ( expr ) ; <nl> } <nl> - void visitAffineBinaryMulOpExpr ( AffineBinaryOpExpr * expr ) { <nl> + void visitMulExpr ( AffineBinaryOpExpr * expr ) { <nl> static_cast < SubClass * > ( this ) - > visitAffineBinaryOpExpr ( expr ) ; <nl> } <nl> - void visitAffineBinaryModOpExpr ( AffineBinaryOpExpr * expr ) { <nl> + void visitModExpr ( AffineBinaryOpExpr * expr ) { <nl> static_cast < SubClass * > ( this ) - > visitAffineBinaryOpExpr ( expr ) ; <nl> } <nl> - void visitAffineBinaryFloorDivOpExpr ( AffineBinaryOpExpr * expr ) { <nl> + void visitFloorDivExpr ( AffineBinaryOpExpr * expr ) { <nl> static_cast < SubClass * > ( this ) - > visitAffineBinaryOpExpr ( expr ) ; <nl> } <nl> - void visitAffineBinaryCeilDivOpExpr ( AffineBinaryOpExpr * expr ) { <nl> + void visitCeilDivExpr ( AffineBinaryOpExpr * expr ) { <nl> static_cast < SubClass * > ( this ) - > visitAffineBinaryOpExpr ( expr ) ; <nl> } <nl> - void visitAffineConstantExpr ( AffineConstantExpr * expr ) { } <nl> + void visitConstantExpr ( AffineConstantExpr * expr ) { } <nl> void visitAffineDimExpr ( AffineDimExpr * expr ) { } <nl> void visitAffineSymbolExpr ( AffineSymbolExpr * expr ) { } <nl> <nl> private : <nl> - void visitAffineBinaryOpOperands ( AffineBinaryOpExpr * expr ) { <nl> - visit ( expr - > getLHS ( ) ) ; <nl> - visit ( expr - > getRHS ( ) ) ; <nl> + / / Walk the operands - each operand is itself walked in post order . <nl> + void walkOperandsPostOrder ( AffineBinaryOpExpr * expr ) { <nl> + walkPostOrder ( expr - > getLHS ( ) ) ; <nl> + walkPostOrder ( expr - > getRHS ( ) ) ; <nl> } <nl> } ; <nl> <nl> mmm a / include / mlir / Transforms / Passes . h <nl> ppp b / include / mlir / Transforms / Passes . h <nl> <nl> <nl> namespace mlir { <nl> <nl> + class FunctionPass ; <nl> class MLFunctionPass ; <nl> class ModulePass ; <nl> <nl> MLFunctionPass * createLoopUnrollPass ( int unrollFactor = - 1 , <nl> / / / line if provided . <nl> MLFunctionPass * createLoopUnrollAndJamPass ( int unrollJamFactor = - 1 ) ; <nl> <nl> + / / / Creates an affine expression simplification pass . <nl> + FunctionPass * createSimplifyAffineExprPass ( ) ; <nl> + <nl> / / / Replaces all ML functions in the module with equivalent CFG functions . <nl> / / / Function references are appropriately patched to refer to the newly <nl> / / / generated CFG functions . <nl> mmm a / lib / Analysis / AffineStructures . cpp <nl> ppp b / lib / Analysis / AffineStructures . cpp <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> # include " mlir / Analysis / AffineStructures . h " <nl> + <nl> # include " mlir / IR / AffineExpr . h " <nl> + # include " mlir / IR / AffineExprVisitor . h " <nl> # include " mlir / IR / AffineMap . h " <nl> # include " mlir / IR / IntegerSet . h " <nl> # include " mlir / IR / MLIRContext . h " <nl> # include " mlir / IR / StandardOps . h " <nl> + # include " llvm / ADT / ArrayRef . h " <nl> + # include " llvm / Support / raw_ostream . h " <nl> <nl> namespace mlir { <nl> <nl> - MutableAffineMap : : MutableAffineMap ( AffineMap * map ) { <nl> + MutableAffineMap : : MutableAffineMap ( AffineMap * map , MLIRContext * context ) <nl> + : numDims ( map - > getNumDims ( ) ) , numSymbols ( map - > getNumSymbols ( ) ) , <nl> + context ( context ) { <nl> for ( auto * result : map - > getResults ( ) ) <nl> results . push_back ( result ) ; <nl> for ( auto * rangeSize : map - > getRangeSizes ( ) ) <nl> results . push_back ( rangeSize ) ; <nl> } <nl> <nl> - MutableIntegerSet : : MutableIntegerSet ( IntegerSet * set ) <nl> - : numDims ( set - > getNumDims ( ) ) , numSymbols ( set - > getNumSymbols ( ) ) { <nl> + bool MutableAffineMap : : isMultipleOf ( unsigned idx , int64_t factor ) const { <nl> + if ( results [ idx ] - > isMultipleOf ( factor ) ) <nl> + return true ; <nl> + <nl> + / / TODO ( bondhugula ) : use FlatAffineConstraints to complete this ( for a more <nl> + / / powerful analysis ) . <nl> + assert ( 0 & & " isMultipleOf implementation incomplete " ) ; <nl> + return false ; <nl> + } <nl> + <nl> + MutableIntegerSet : : MutableIntegerSet ( IntegerSet * set , MLIRContext * context ) <nl> + : numDims ( set - > getNumDims ( ) ) , numSymbols ( set - > getNumSymbols ( ) ) , <nl> + context ( context ) { <nl> / / TODO ( bondhugula ) <nl> } <nl> <nl> / / Universal set . <nl> - MutableIntegerSet : : MutableIntegerSet ( unsigned numDims , unsigned numSymbols ) <nl> - : numDims ( numDims ) , numSymbols ( numSymbols ) { } <nl> + MutableIntegerSet : : MutableIntegerSet ( unsigned numDims , unsigned numSymbols , <nl> + MLIRContext * context ) <nl> + : numDims ( numDims ) , numSymbols ( numSymbols ) , context ( context ) { } <nl> <nl> - AffineValueMap : : AffineValueMap ( const AffineApplyOp & op ) <nl> - : map ( op . getAffineMap ( ) ) { <nl> + AffineValueMap : : AffineValueMap ( const AffineApplyOp & op , MLIRContext * context ) <nl> + : map ( op . getAffineMap ( ) , context ) { <nl> / / TODO : pull operands and results in . <nl> } <nl> <nl> - bool AffineValueMap : : isMultipleOf ( unsigned idx , int64_t factor ) const { <nl> - / / Check if the ( first result expr ) % factor becomes 0 . <nl> - if ( auto * expr = dyn_cast < AffineConstantExpr > ( AffineBinaryOpExpr : : get ( <nl> - AffineExpr : : Kind : : Mod , map . getResult ( idx ) , <nl> - AffineConstantExpr : : get ( factor , context ) , context ) ) ) <nl> - return expr - > getValue ( ) = = 0 ; <nl> - <nl> - / / TODO ( bondhugula ) : use FlatAffineConstraints to complete this . <nl> - assert ( 0 & & " isMultipleOf implementation incomplete " ) ; <nl> - return false ; <nl> + inline bool AffineValueMap : : isMultipleOf ( unsigned idx , int64_t factor ) const { <nl> + return map . isMultipleOf ( idx , factor ) ; <nl> } <nl> <nl> AffineValueMap : : ~ AffineValueMap ( ) { } <nl> <nl> + void FlatAffineConstraints : : addEquality ( ArrayRef < int64_t > eq ) { <nl> + assert ( eq . size ( ) = = getNumCols ( ) ) ; <nl> + unsigned offset = equalities . size ( ) ; <nl> + equalities . resize ( equalities . size ( ) + eq . size ( ) ) ; <nl> + for ( unsigned i = 0 , e = eq . size ( ) ; i < e ; i + + ) { <nl> + equalities [ offset + i ] = eq [ i ] ; <nl> + } <nl> + } <nl> + <nl> } / / end namespace mlir <nl> mmm a / lib / Analysis / HyperRectangularSet . cpp <nl> ppp b / lib / Analysis / HyperRectangularSet . cpp <nl> static void mergeBounds ( const HyperRectangularSet & set , <nl> HyperRectangularSet : : HyperRectangularSet ( unsigned numDims , unsigned numSymbols , <nl> ArrayRef < ArrayRef < AffineExpr * > > lbs , <nl> ArrayRef < ArrayRef < AffineExpr * > > ubs , <nl> + MLIRContext * context , <nl> IntegerSet * symbolContext ) <nl> - : context ( symbolContext ? MutableIntegerSet ( symbolContext ) <nl> - : MutableIntegerSet ( numDims , numSymbols ) ) { <nl> + : context ( symbolContext ? MutableIntegerSet ( symbolContext , context ) <nl> + : MutableIntegerSet ( numDims , numSymbols , context ) ) { <nl> unsigned d = 0 ; <nl> for ( auto boundList : lbs ) { <nl> AffineBoundExprList lb ; <nl> mmm a / lib / IR / AffineExpr . cpp <nl> ppp b / lib / IR / AffineExpr . cpp <nl> bool AffineExpr : : isPureAffine ( ) const { <nl> } <nl> } <nl> } <nl> + <nl> + uint64_t AffineExpr : : getKnownGcd ( ) const { <nl> + AffineBinaryOpExpr * binExpr = nullptr ; <nl> + switch ( kind ) { <nl> + case Kind : : SymbolId : <nl> + LLVM_FALLTHROUGH ; <nl> + case Kind : : DimId : <nl> + return 1 ; <nl> + case Kind : : Constant : <nl> + return std : : abs ( cast < AffineConstantExpr > ( this ) - > getValue ( ) ) ; <nl> + case Kind : : Mul : <nl> + binExpr = cast < AffineBinaryOpExpr > ( const_cast < AffineExpr * > ( this ) ) ; <nl> + return binExpr - > getLHS ( ) - > getKnownGcd ( ) * binExpr - > getRHS ( ) - > getKnownGcd ( ) ; <nl> + case Kind : : Add : <nl> + LLVM_FALLTHROUGH ; <nl> + case Kind : : FloorDiv : <nl> + case Kind : : CeilDiv : <nl> + case Kind : : Mod : <nl> + binExpr = cast < AffineBinaryOpExpr > ( const_cast < AffineExpr * > ( this ) ) ; <nl> + return llvm : : GreatestCommonDivisor64 ( binExpr - > getLHS ( ) - > getKnownGcd ( ) , <nl> + binExpr - > getRHS ( ) - > getKnownGcd ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + bool AffineExpr : : isMultipleOf ( int64_t factor ) const { <nl> + AffineBinaryOpExpr * binExpr = nullptr ; <nl> + uint64_t l , u ; <nl> + switch ( kind ) { <nl> + case Kind : : SymbolId : <nl> + LLVM_FALLTHROUGH ; <nl> + case Kind : : DimId : <nl> + return factor * factor = = 1 ; <nl> + case Kind : : Constant : <nl> + return cast < AffineConstantExpr > ( this ) - > getValue ( ) % factor = = 0 ; <nl> + case Kind : : Mul : <nl> + binExpr = cast < AffineBinaryOpExpr > ( const_cast < AffineExpr * > ( this ) ) ; <nl> + / / It ' s probably not worth optimizing this further ( to not traverse the <nl> + / / whole sub - tree under - it that would require a version of isMultipleOf <nl> + / / that on a ' false ' return also returns the known GCD ) . <nl> + return ( l = binExpr - > getLHS ( ) - > getKnownGcd ( ) ) % factor = = 0 | | <nl> + ( u = binExpr - > getRHS ( ) - > getKnownGcd ( ) ) % factor = = 0 | | <nl> + ( l * u ) % factor = = 0 ; <nl> + case Kind : : Add : <nl> + case Kind : : FloorDiv : <nl> + case Kind : : CeilDiv : <nl> + case Kind : : Mod : <nl> + binExpr = cast < AffineBinaryOpExpr > ( const_cast < AffineExpr * > ( this ) ) ; <nl> + return llvm : : GreatestCommonDivisor64 ( binExpr - > getLHS ( ) - > getKnownGcd ( ) , <nl> + binExpr - > getRHS ( ) - > getKnownGcd ( ) ) % <nl> + factor = = <nl> + 0 ; <nl> + } <nl> + } <nl> mmm a / lib / IR / AffineMap . cpp <nl> ppp b / lib / IR / AffineMap . cpp <nl> AffineExpr * AffineBinaryOpExpr : : simplifyMod ( AffineExpr * lhs , AffineExpr * rhs , <nl> return AffineConstantExpr : : get ( lhsConst - > getValue ( ) % rhsConst - > getValue ( ) , <nl> context ) ; <nl> <nl> - / / Fold modulo of a multiply with a constant that is a multiple of the <nl> - / / modulo factor to zero . Eg : ( i * 128 ) mod 64 = 0 . <nl> + / / Fold modulo of an expression that is known to be a multiple of a constant <nl> + / / to zero if that constant is a multiple of the modulo factor . Eg : ( i * 128 ) <nl> + / / mod 64 is folded to 0 , and less trivially , ( i * ( j * 4 * ( k * 32 ) ) ) mod 128 = 0 . <nl> if ( rhsConst ) { <nl> - auto * lBin = dyn_cast < AffineBinaryOpExpr > ( lhs ) ; <nl> - if ( lBin & & lBin - > getKind ( ) = = Kind : : Mul ) { <nl> - if ( auto * lrhs = dyn_cast < AffineConstantExpr > ( lBin - > getRHS ( ) ) ) { <nl> - / / rhsConst is known to be positive if a constant . <nl> - if ( lrhs - > getValue ( ) % rhsConst - > getValue ( ) = = 0 ) <nl> - return AffineConstantExpr : : get ( 0 , context ) ; <nl> - } <nl> - } <nl> + / / rhsConst is known to be positive if a constant . <nl> + if ( lhs - > getKnownGcd ( ) % rhsConst - > getValue ( ) = = 0 ) <nl> + return AffineConstantExpr : : get ( 0 , context ) ; <nl> } <nl> <nl> return nullptr ; <nl> new file mode 100644 <nl> index 0000000000000 . . 3c72887c30184 <nl> mmm / dev / null <nl> ppp b / lib / Transforms / SimplifyAffineExpr . cpp <nl> <nl> + / / = = = - SimplifyAffineExpr . cpp - MLIR Affine Structures Classmmm - - * - C + + - * - = = = / / <nl> + / / <nl> + / / Copyright 2019 The MLIR 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> + / / This file implements a pass to simplify affine expressions . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # include " mlir / Analysis / AffineStructures . h " <nl> + # include " mlir / IR / AffineExprVisitor . h " <nl> + # include " mlir / IR / AffineMap . h " <nl> + # include " mlir / IR / Attributes . h " <nl> + # include " mlir / IR / StmtVisitor . h " <nl> + <nl> + # include " mlir / Transforms / Pass . h " <nl> + # include " mlir / Transforms / Passes . h " <nl> + <nl> + using namespace mlir ; <nl> + using llvm : : report_fatal_error ; <nl> + <nl> + namespace { <nl> + <nl> + / / / Simplify all affine expressions appearing in the operation statements of the <nl> + / / / MLFunction . <nl> + / / TODO ( someone ) : Gradually , extend this to all affine map references found in <nl> + / / ML functions and CFG functions . <nl> + struct SimplifyAffineExpr : public FunctionPass { <nl> + explicit SimplifyAffineExpr ( ) { } <nl> + <nl> + void runOnMLFunction ( MLFunction * f ) ; <nl> + / / Does nothing on CFG functions for now . No reusable walkers / visitors exist <nl> + / / for this yet ? TODO ( someone ) . <nl> + void runOnCFGFunction ( CFGFunction * f ) { } <nl> + } ; <nl> + <nl> + / / This class is used to flatten a pure affine expression into a sum of products <nl> + / / ( w . r . t constants ) when possible , and in that process accumulating <nl> + / / contributions for each dimensional and symbolic identifier together . Note <nl> + / / that an affine expression may not always be expressible that way due to the <nl> + / / preesnce of modulo , floordiv , and ceildiv expressions . A simplification that <nl> + / / this flattening naturally performs is to fold a modulo expression to a zero , <nl> + / / if possible . Two examples are below : <nl> + / / <nl> + / / ( d0 + 3 * d1 ) + d0 ) - 2 * d1 ) - d0 simplified to d0 + d1 <nl> + / / ( d0 - d0 mod 4 + 4 ) mod 4 simplified to 0 . <nl> + / / <nl> + / / For modulo and floordiv expressions , an additional variable is introduced to <nl> + / / rewrite it as a sum of products ( w . r . t constants ) . For example , for the <nl> + / / second example above , d0 % 4 is replaced by d0 - 4 * q with q being introduced : <nl> + / / the expression simplifies to : <nl> + / / ( d0 - ( d0 - 4q ) + 4 ) = 4q + 4 , modulo of which w . r . t 4 simplifies to zero . <nl> + / / <nl> + / / This is a linear time post order walk for an affine expression that attempts <nl> + / / the above simplifications through visit methods , with partial results being <nl> + / / stored in ' operandExprStack ' . When a parent expr is visited , the flattened <nl> + / / expressions corresponding to its two operands would already be on the stack - <nl> + / / the parent expr looks at the two flattened expressions and combines the two . <nl> + / / It pops off the operand expressions and pushes the combined result ( although <nl> + / / this is done in - place on its LHS operand expr . When the walk is completed , <nl> + / / the flattened form of the top - level expression would be left on the stack . <nl> + / / <nl> + class AffineExprFlattener : public AffineExprVisitor < AffineExprFlattener > { <nl> + public : <nl> + std : : vector < SmallVector < int64_t , 32 > > operandExprStack ; <nl> + <nl> + / / The layout of the flattened expressions is dimensions , symbols , locals , <nl> + / / and constant term . <nl> + unsigned getNumCols ( ) const { return numDims + numSymbols + numLocals + 1 ; } <nl> + <nl> + AffineExprFlattener ( unsigned numDims , unsigned numSymbols ) <nl> + : numDims ( numDims ) , numSymbols ( numSymbols ) , numLocals ( 0 ) { } <nl> + <nl> + void visitMulExpr ( AffineBinaryOpExpr * expr ) { <nl> + assert ( expr - > isPureAffine ( ) ) ; <nl> + / / Get the RHS constant . <nl> + auto rhsConst = operandExprStack . back ( ) [ getNumCols ( ) - 1 ] ; <nl> + operandExprStack . pop_back ( ) ; <nl> + / / Update the LHS in place instead of pop and push . <nl> + auto & lhs = operandExprStack . back ( ) ; <nl> + for ( unsigned i = 0 , e = lhs . size ( ) ; i < e ; i + + ) { <nl> + lhs [ i ] * = rhsConst ; <nl> + } <nl> + } <nl> + void visitAddExpr ( AffineBinaryOpExpr * expr ) { <nl> + const auto & rhs = operandExprStack . back ( ) ; <nl> + auto & lhs = operandExprStack [ operandExprStack . size ( ) - 2 ] ; <nl> + assert ( lhs . size ( ) = = rhs . size ( ) ) ; <nl> + / / Update the LHS in place . <nl> + for ( unsigned i = 0 ; i < rhs . size ( ) ; i + + ) { <nl> + lhs [ i ] + = rhs [ i ] ; <nl> + } <nl> + / / Pop off the RHS . <nl> + operandExprStack . pop_back ( ) ; <nl> + } <nl> + void visitModExpr ( AffineBinaryOpExpr * expr ) { <nl> + assert ( expr - > isPureAffine ( ) ) ; <nl> + / / This is a pure affine expr ; the RHS is a constant . <nl> + auto rhsConst = operandExprStack . back ( ) [ getNumCols ( ) - 1 ] ; <nl> + operandExprStack . pop_back ( ) ; <nl> + auto & lhs = operandExprStack . back ( ) ; <nl> + assert ( rhsConst ! = 0 & & " RHS constant can ' t be zero " ) ; <nl> + unsigned i ; <nl> + for ( i = 0 ; i < lhs . size ( ) ; i + + ) <nl> + if ( lhs [ i ] % rhsConst ! = 0 ) <nl> + break ; <nl> + if ( i = = lhs . size ( ) ) { <nl> + / / The modulo expression here simplifies to zero . <nl> + lhs . assign ( lhs . size ( ) , 0 ) ; <nl> + return ; <nl> + } <nl> + / / Add an existential quantifier . expr1 % expr2 is replaced by ( expr1 - <nl> + / / q * expr2 ) where q is the existential quantifier introduced . <nl> + addExistentialQuantifier ( ) ; <nl> + lhs = operandExprStack . back ( ) ; <nl> + lhs [ numDims + numSymbols + numLocals - 1 ] = - rhsConst ; <nl> + } <nl> + void visitConstantExpr ( AffineConstantExpr * expr ) { <nl> + operandExprStack . emplace_back ( SmallVector < int64_t , 32 > ( getNumCols ( ) , 0 ) ) ; <nl> + auto & eq = operandExprStack . back ( ) ; <nl> + eq [ getNumCols ( ) - 1 ] = expr - > getValue ( ) ; <nl> + } <nl> + void visitDimExpr ( AffineDimExpr * expr ) { <nl> + SmallVector < int64_t , 32 > eq ( getNumCols ( ) , 0 ) ; <nl> + eq [ expr - > getPosition ( ) ] = 1 ; <nl> + operandExprStack . push_back ( eq ) ; <nl> + } <nl> + void visitSymbolExpr ( AffineSymbolExpr * expr ) { <nl> + SmallVector < int64_t , 32 > eq ( getNumCols ( ) , 0 ) ; <nl> + eq [ numDims + expr - > getPosition ( ) ] = 1 ; <nl> + operandExprStack . push_back ( eq ) ; <nl> + } <nl> + void visitCeilDivExpr ( AffineBinaryOpExpr * expr ) { <nl> + / / TODO ( bondhugula ) : handle ceildiv as well ; won ' t simplify further through <nl> + / / this analysis but will be handled ( rest of the expr will simplify ) . <nl> + report_fatal_error ( " ceildiv expr simplification not supported here " ) ; <nl> + } <nl> + void visitFloorDivExpr ( AffineBinaryOpExpr * expr ) { <nl> + / / TODO ( bondhugula ) : handle ceildiv as well ; won ' t simplify further through <nl> + / / this analysis but will be handled ( rest of the expr will simplify ) . <nl> + report_fatal_error ( " floordiv expr simplification unimplemented " ) ; <nl> + } <nl> + / / Add an existential quantifier ( used to flatten a mod or a floordiv expr ) . <nl> + void addExistentialQuantifier ( ) { <nl> + for ( auto & subExpr : operandExprStack ) { <nl> + subExpr . insert ( subExpr . begin ( ) + numDims + numSymbols + numLocals , 0 ) ; <nl> + } <nl> + numLocals + + ; <nl> + } <nl> + <nl> + unsigned numDims ; <nl> + unsigned numSymbols ; <nl> + unsigned numLocals ; <nl> + } ; <nl> + <nl> + } / / end anonymous namespace <nl> + <nl> + FunctionPass * mlir : : createSimplifyAffineExprPass ( ) { <nl> + return new SimplifyAffineExpr ( ) ; <nl> + } <nl> + <nl> + AffineMap * MutableAffineMap : : getAffineMap ( ) { <nl> + return AffineMap : : get ( numDims , numSymbols , results , rangeSizes , context ) ; <nl> + } <nl> + <nl> + void SimplifyAffineExpr : : runOnMLFunction ( MLFunction * f ) { <nl> + struct MapSimplifier : public StmtWalker < MapSimplifier > { <nl> + MLIRContext * context ; <nl> + MapSimplifier ( MLIRContext * context ) : context ( context ) { } <nl> + <nl> + void visitOperationStmt ( OperationStmt * opStmt ) { <nl> + for ( auto attr : opStmt - > getAttrs ( ) ) { <nl> + if ( auto * mapAttr = dyn_cast < AffineMapAttr > ( attr . second ) ) { <nl> + MutableAffineMap mMap ( mapAttr - > getValue ( ) , context ) ; <nl> + mMap . simplify ( ) ; <nl> + auto * map = mMap . getAffineMap ( ) ; <nl> + opStmt - > setAttr ( attr . first , AffineMapAttr : : get ( map , context ) ) ; <nl> + } <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + MapSimplifier v ( f - > getContext ( ) ) ; <nl> + v . walkPostOrder ( f ) ; <nl> + } <nl> + <nl> + / / / Get an affine expression from a flat ArrayRef . If there are local variables <nl> + / / / ( existential quantifiers introduced during the flattening ) that appear in <nl> + / / / the sum of products expression , we can ' t readily express it as an affine <nl> + / / / expression of dimension and symbol id ' s ; return nullptr in such cases . <nl> + static AffineExpr * toAffineExpr ( ArrayRef < int64_t > eq , unsigned numDims , <nl> + unsigned numSymbols , MLIRContext * context ) { <nl> + / / Check if any local variable has a non - zero coefficient . <nl> + for ( unsigned j = numDims + numSymbols ; j < eq . size ( ) - 1 ; j + + ) { <nl> + if ( eq [ j ] ! = 0 ) <nl> + return nullptr ; <nl> + } <nl> + <nl> + AffineExpr * expr = AffineConstantExpr : : get ( 0 , context ) ; <nl> + for ( unsigned j = 0 ; j < numDims + numSymbols ; j + + ) { <nl> + if ( eq [ j ] ! = 0 ) { <nl> + AffineExpr * id = <nl> + j < numDims <nl> + ? static_cast < AffineExpr * > ( AffineDimExpr : : get ( j , context ) ) <nl> + : AffineSymbolExpr : : get ( j - numDims , context ) ; <nl> + expr = AffineBinaryOpExpr : : get ( <nl> + AffineExpr : : Kind : : Add , expr , <nl> + AffineBinaryOpExpr : : get ( AffineExpr : : Kind : : Mul , <nl> + AffineConstantExpr : : get ( eq [ j ] , context ) , id , <nl> + context ) , <nl> + context ) ; <nl> + } <nl> + } <nl> + unsigned constTerm = eq [ eq . size ( ) - 1 ] ; <nl> + if ( constTerm ! = 0 ) <nl> + expr = AffineBinaryOpExpr : : get ( AffineExpr : : Kind : : Add , expr , <nl> + AffineConstantExpr : : get ( constTerm , context ) , <nl> + context ) ; <nl> + return expr ; <nl> + } <nl> + <nl> + / / Simplify the result affine expressions of this map . The expressions have to <nl> + / / be pure for the simplification implemented . <nl> + void MutableAffineMap : : simplify ( ) { <nl> + / / Simplify each of the results if possible . <nl> + for ( unsigned i = 0 , e = getNumResults ( ) ; i < e ; i + + ) { <nl> + AffineExpr * result = getResult ( i ) ; <nl> + if ( ! result - > isPureAffine ( ) ) <nl> + continue ; <nl> + <nl> + AffineExprFlattener flattener ( numDims , numSymbols ) ; <nl> + flattener . walkPostOrder ( result ) ; <nl> + const auto & flattenedExpr = flattener . operandExprStack . back ( ) ; <nl> + auto * expr = toAffineExpr ( flattenedExpr , numDims , numSymbols , context ) ; <nl> + if ( expr ) <nl> + results [ i ] = expr ; <nl> + flattener . operandExprStack . pop_back ( ) ; <nl> + assert ( flattener . operandExprStack . empty ( ) ) ; <nl> + } <nl> + } <nl> mmm a / test / IR / affine - map . mlir <nl> ppp b / test / IR / affine - map . mlir <nl> <nl> # map3j = ( i , j ) - > ( i + 1 , j * 1 * 4 + 2 ) <nl> # map3k = ( i , j ) - > ( i + 1 , j * 4 * 1 + 2 ) <nl> <nl> - / / The following reduction should be unique ' d out too but the expression <nl> - / / simplifier is not powerful enough . <nl> + / / The following reduction should be unique ' d out too but such expression <nl> + / / simplification is not performed for IR parsing , but only through analyses <nl> + / / and transforms . <nl> / / CHECK : # map { { [ 0 - 9 ] + } } = ( d0 , d1 ) - > ( d1 - d0 + ( d0 - d1 + 1 ) * 2 + d1 - 1 , d1 + d1 + d1 + d1 + 2 ) <nl> # map3l = ( i , j ) - > ( ( j - i ) + 2 * ( i - j + 1 ) + j - 1 + 0 , j + j + 1 + j + j + 1 ) <nl> <nl> <nl> / / CHECK : # map { { [ 0 - 9 ] + } } = ( d0 , d1 , d2 ) - > ( 0 , d1 , d0 * 2 , 0 ) <nl> # map46 = ( i , j , k ) - > ( i * 0 , 1 * j , i * 128 floordiv 64 , j * 0 floordiv 64 ) <nl> <nl> - / / CHECK : # map { { [ 0 - 9 ] + } } = ( d0 , d1 , d2 ) - > ( d0 , d0 * 4 , 0 , 0 ) <nl> - # map47 = ( i , j , k ) - > ( i * 64 ceildiv 64 , i * 512 ceildiv 128 , 4 * j mod 4 , 4 * j * 4 mod 8 ) <nl> + / / CHECK : # map { { [ 0 - 9 ] + } } = ( d0 , d1 , d2 ) - > ( d0 , d0 * 4 , 0 , 0 , 0 ) <nl> + # map47 = ( i , j , k ) - > ( i * 64 ceildiv 64 , i * 512 ceildiv 128 , 4 * j mod 4 , 4 * j * 4 mod 8 , k mod 1 ) <nl> <nl> - / / floordiv should resolve similarly to ceildiv and be unique ' d out <nl> + / / floordiv should resolve similarly to ceildiv and be unique ' d out . <nl> / / CHECK - NOT : # map48 { { [ a - z ] } } <nl> # map48 = ( i , j , k ) - > ( i * 64 floordiv 64 , i * 512 floordiv 128 , 4 * j mod 4 , 4 * j * 4 mod 8 ) <nl> <nl> + / / Simplifications for mod using known GCD ' s of the LHS expr . <nl> + / / CHECK : # map { { [ 0 - 9 ] + } } = ( d0 , d1 ) [ s0 ] - > ( 0 , 0 , 0 , ( d0 * 4 + 3 ) mod 2 ) <nl> + # map49 = ( i , j ) [ s0 ] - > ( ( i * 4 + 8 ) mod 4 , 32 * j * s0 * 8 mod 256 , ( 4 * i + ( j * ( s0 * 2 ) ) ) mod 2 , ( 4 * i + 3 ) mod 2 ) <nl> + <nl> / / CHECK : extfunc @ f0 ( memref < 2x4xi8 , # map { { [ 0 - 9 ] + } } , 1 > ) <nl> extfunc @ f0 ( memref < 2x4xi8 , # map0 , 1 > ) <nl> <nl> extfunc @ f47 ( memref < 100x100x100xi8 , # map47 > ) <nl> <nl> / / CHECK : extfunc @ f48 ( memref < 100x100x100xi8 , # map { { [ 0 - 9 ] + } } > ) <nl> extfunc @ f48 ( memref < 100x100x100xi8 , # map48 > ) <nl> + <nl> + / / CHECK : extfunc @ f49 ( memref < 100x100xi8 , # map { { [ 0 - 9 ] + } } > ) <nl> + extfunc @ f49 ( memref < 100x100xi8 , # map49 > ) <nl> new file mode 100644 <nl> index 0000000000000 . . 19d9cb1c352c9 <nl> mmm / dev / null <nl> ppp b / test / Transforms / simplify . mlir <nl> <nl> + / / RUN : mlir - opt % s - o - - simplify - affine - expr | FileCheck % s <nl> + <nl> + / / CHECK : # map { { [ 0 - 9 ] + } } = ( d0 , d1 ) - > ( 0 , 0 ) <nl> + # map0 = ( d0 , d1 ) - > ( ( d0 - d0 mod 4 ) mod 4 , ( d0 - d0 mod 128 - 64 ) mod 64 ) <nl> + / / CHECK : # map { { [ 0 - 9 ] + } } = ( d0 , d1 ) - > ( d0 + 1 , d1 * 5 + 3 ) <nl> + # map1 = ( d0 , d1 ) - > ( d1 - d0 + ( d0 - d1 + 1 ) * 2 + d1 - 1 , 1 + 2 * d1 + d1 + d1 + d1 + 2 ) <nl> + / / CHECK : # map { { [ 0 - 9 ] + } } = ( d0 , d1 ) - > ( 0 , 0 , 0 ) <nl> + # map2 = ( d0 , d1 ) - > ( ( ( d0 - d0 mod 2 ) * 2 ) mod 4 , ( 5 * d1 + 8 - ( 5 * d1 + 4 ) mod 4 ) mod 4 , 0 ) <nl> + <nl> + mlfunc @ test ( ) { <nl> + for % n0 = 0 to 127 { <nl> + for % n1 = 0 to 7 { <nl> + % x = affine_apply # map0 ( % n0 , % n1 ) <nl> + % y = affine_apply # map1 ( % n0 , % n1 ) <nl> + % z = affine_apply # map2 ( % n0 , % n1 ) <nl> + } <nl> + } <nl> + return <nl> + } <nl> + <nl> mmm a / tools / mlir - opt / mlir - opt . cpp <nl> ppp b / tools / mlir - opt / mlir - opt . cpp <nl> <nl> # include " llvm / Support / Regex . h " <nl> # include " llvm / Support / SourceMgr . h " <nl> # include " llvm / Support / ToolOutputFile . h " <nl> + <nl> using namespace mlir ; <nl> using namespace llvm ; <nl> <nl> enum Passes { <nl> ConvertToCFG , <nl> LoopUnroll , <nl> LoopUnrollAndJam , <nl> + SimplifyAffineExpr , <nl> TFRaiseControlFlow , <nl> } ; <nl> <nl> static cl : : list < Passes > passList ( <nl> clEnumValN ( LoopUnroll , " loop - unroll " , " Unroll loops " ) , <nl> clEnumValN ( LoopUnrollAndJam , " loop - unroll - jam " , <nl> " Unroll and jam loops " ) , <nl> + clEnumValN ( SimplifyAffineExpr , " simplify - affine - expr " , <nl> + " Simplify affine expressions " ) , <nl> clEnumValN ( TFRaiseControlFlow , " tf - raise - control - flow " , <nl> " Dynamic TensorFlow Switch / Match nodes to a CFG " ) ) ) ; <nl> <nl> OptResult parseAndPrintMemoryBuffer ( std : : unique_ptr < MemoryBuffer > buffer ) { <nl> case LoopUnrollAndJam : <nl> pass = createLoopUnrollAndJamPass ( ) ; <nl> break ; <nl> + case SimplifyAffineExpr : <nl> + pass = createSimplifyAffineExprPass ( ) ; <nl> + break ; <nl> case TFRaiseControlFlow : <nl> pass = createRaiseTFControlFlowPass ( ) ; <nl> break ; <nl> | Affine expression analysis and simplification . | tensorflow/tensorflow | 83a41c9c857504d77c07b96ed22375093e6d75f5 | 2019-03-29T20:07:44Z |
mmm a / tensorflow / compiler / xla / service / BUILD <nl> ppp b / tensorflow / compiler / xla / service / BUILD <nl> cc_test ( <nl> ] , <nl> ) <nl> <nl> + cc_library ( <nl> + name = " logical_buffer_analysis " , <nl> + srcs = [ " logical_buffer_analysis . cc " ] , <nl> + hdrs = [ " logical_buffer_analysis . h " ] , <nl> + deps = [ <nl> + " : hlo " , <nl> + " : logical_buffer " , <nl> + " / / tensorflow / compiler / xla : shape_util " , <nl> + " / / tensorflow / compiler / xla : statusor " , <nl> + " / / tensorflow / core : lib " , <nl> + " / / tensorflow / core : lib_internal " , <nl> + ] , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " tuple_points_to_analysis " , <nl> srcs = [ " tuple_points_to_analysis . cc " ] , <nl> cc_library ( <nl> deps = [ <nl> " : hlo " , <nl> " : logical_buffer " , <nl> + " : logical_buffer_analysis " , <nl> " / / tensorflow / compiler / xla : shape_tree " , <nl> " / / tensorflow / compiler / xla : shape_util " , <nl> " / / tensorflow / compiler / xla : statusor " , <nl> mmm a / tensorflow / compiler / xla / service / buffer_assignment . cc <nl> ppp b / tensorflow / compiler / xla / service / buffer_assignment . cc <nl> BufferAssignmentProto BufferAssignment : : ToProto ( ) const { <nl> for ( LogicalBuffer : : Id id = 0 ; id < points_to_analysis . num_logical_buffers ( ) ; <nl> id + + ) { <nl> auto & buffer = points_to_analysis . logical_buffer ( id ) ; <nl> - if ( HasAllocation ( * buffer ) ) { <nl> - LogicalBufferProto proto_buffer = buffer - > ToProto ( buffer_size_ ) ; <nl> + if ( HasAllocation ( buffer ) ) { <nl> + LogicalBufferProto proto_buffer = buffer . ToProto ( buffer_size_ ) ; <nl> proto . add_logical_buffers ( ) - > Swap ( & proto_buffer ) ; <nl> <nl> / / Fill buffer aliases . <nl> for ( const BufferAlias & alias : <nl> - points_to_analysis . GetBufferAliases ( * buffer ) ) { <nl> - if ( alias . instruction ( ) = = buffer - > instruction ( ) & & <nl> - alias . index ( ) = = buffer - > index ( ) ) { <nl> + points_to_analysis . GetBufferAliases ( buffer ) ) { <nl> + if ( alias . instruction ( ) = = buffer . instruction ( ) & & <nl> + alias . index ( ) = = buffer . index ( ) ) { <nl> continue ; / / skip self - aliases <nl> } <nl> BufferAssignmentProto : : BufferAlias * proto_alias = <nl> proto . add_buffer_aliases ( ) ; <nl> LogicalBufferProto : : Location proto_alias_location = <nl> LogicalBuffer : : ToLocationProto ( * alias . instruction ( ) , alias . index ( ) ) ; <nl> - proto_alias - > set_source_buffer_id ( buffer - > id ( ) ) ; <nl> + proto_alias - > set_source_buffer_id ( buffer . id ( ) ) ; <nl> proto_alias - > mutable_location ( ) - > Swap ( & proto_alias_location ) ; <nl> } <nl> } <nl> mmm a / tensorflow / compiler / xla / service / buffer_assignment_test . cc <nl> ppp b / tensorflow / compiler / xla / service / buffer_assignment_test . cc <nl> TEST_F ( BufferAssignmentTest , BasicUniquelyColored ) { <nl> id < buffer_liveness . points_to_analysis ( ) . num_logical_buffers ( ) ; <nl> id + + ) { <nl> auto & buffer = buffer_liveness . points_to_analysis ( ) . logical_buffer ( id ) ; <nl> - buffer - > set_color ( LogicalBuffer : : Color ( color + + ) ) ; <nl> + buffer . set_color ( LogicalBuffer : : Color ( color + + ) ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> } ; <nl> TEST_F ( BufferAssignmentTest , BasicPartiallyColored ) { <nl> id + + ) { <nl> auto & buffer = buffer_liveness . points_to_analysis ( ) . logical_buffer ( id ) ; <nl> const auto & aliases = <nl> - buffer_liveness . points_to_analysis ( ) . GetBufferAliases ( * buffer ) ; <nl> + buffer_liveness . points_to_analysis ( ) . GetBufferAliases ( buffer ) ; <nl> for ( const auto & alias : aliases ) { <nl> if ( alias . instruction ( ) - > opcode ( ) = = HloOpcode : : kAdd | | <nl> alias . instruction ( ) - > opcode ( ) = = HloOpcode : : kMultiply ) { <nl> - buffer - > set_color ( LogicalBuffer : : Color ( 1 ) ) ; <nl> + buffer . set_color ( LogicalBuffer : : Color ( 1 ) ) ; <nl> } <nl> } <nl> - if ( ! buffer - > has_color ( ) ) { <nl> - buffer - > set_color ( LogicalBuffer : : Color ( 0 ) ) ; <nl> + if ( ! buffer . has_color ( ) ) { <nl> + buffer . set_color ( LogicalBuffer : : Color ( 0 ) ) ; <nl> } <nl> } <nl> return Status : : OK ( ) ; <nl> mmm a / tensorflow / compiler / xla / service / buffer_liveness . h <nl> ppp b / tensorflow / compiler / xla / service / buffer_liveness . h <nl> class BufferLiveness { <nl> id < buffer_liveness . points_to_analysis ( ) . num_logical_buffers ( ) ; <nl> id + + ) { <nl> auto & buffer = buffer_liveness . points_to_analysis ( ) . logical_buffer ( id ) ; <nl> - buffer - > set_color ( LogicalBuffer : : Color ( 0 ) ) ; <nl> + buffer . set_color ( LogicalBuffer : : Color ( 0 ) ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> } ; <nl> mmm a / tensorflow / compiler / xla / service / layout_assignment . cc <nl> ppp b / tensorflow / compiler / xla / service / layout_assignment . cc <nl> LayoutConstraints : : LayoutConstraints ( <nl> auto & buffer = points_to_analysis_ . logical_buffer ( id ) ; <nl> / / The points to analysis is computed per module , restrict constraints to <nl> / / array buffers in this computation . <nl> - if ( buffer - > IsArray ( ) & & buffer - > instruction ( ) - > parent ( ) = = computation ) { <nl> - unconstrained_buffer_ids_ . insert ( buffer - > id ( ) ) ; <nl> + if ( buffer . IsArray ( ) & & buffer . instruction ( ) - > parent ( ) = = computation ) { <nl> + unconstrained_buffer_ids_ . insert ( buffer . id ( ) ) ; <nl> } <nl> } <nl> } <nl> new file mode 100644 <nl> index 0000000000000 . . 8041d74baa729 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / logical_buffer_analysis . cc <nl> <nl> + / * Copyright 2017 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / compiler / xla / service / logical_buffer_analysis . h " <nl> + <nl> + # include < utility > <nl> + <nl> + # include " tensorflow / compiler / xla / shape_util . h " <nl> + # include " tensorflow / core / lib / core / errors . h " <nl> + # include " tensorflow / core / platform / logging . h " <nl> + <nl> + namespace xla { <nl> + <nl> + / * static * / StatusOr < std : : unique_ptr < LogicalBufferAnalysis > > <nl> + LogicalBufferAnalysis : : Run ( const HloModule * module ) { <nl> + std : : unique_ptr < LogicalBufferAnalysis > analysis ( <nl> + new LogicalBufferAnalysis ( module ) ) ; <nl> + TF_RETURN_IF_ERROR ( analysis - > Analyze ( ) ) ; <nl> + return std : : move ( analysis ) ; <nl> + } <nl> + <nl> + Status LogicalBufferAnalysis : : Analyze ( ) { <nl> + / / Empirically we usually have a few more logical buffers than instructions , <nl> + / / so reserve 10 % more than the number of instructions to avoid frequent <nl> + / / resizes . <nl> + logical_buffers_ . clear ( ) ; <nl> + logical_buffers_ . reserve ( ( module_ - > NumUniqueInstructionIds ( ) * 11 ) / 10 ) ; <nl> + <nl> + / / We filter out fusion computations , and get to them through fusion <nl> + / / instructions . This is because it ' s possible to have orphaned ( unreachable ) <nl> + / / fusion computations , and we don ' t want to try to assign buffers to those . <nl> + for ( auto & computation : module_ - > computations ( ) ) { <nl> + if ( computation - > IsFusionComputation ( ) ) { <nl> + continue ; <nl> + } <nl> + TF_RETURN_IF_ERROR ( computation - > Accept ( this ) ) ; <nl> + for ( auto & instruction : computation - > instructions ( ) ) { <nl> + if ( instruction - > opcode ( ) ! = HloOpcode : : kFusion ) { <nl> + continue ; <nl> + } <nl> + TF_RETURN_IF_ERROR ( instruction - > fused_expression_root ( ) - > Accept ( this ) ) ; <nl> + } <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + LogicalBuffer & LogicalBufferAnalysis : : GetBuffer ( LogicalBuffer : : Id id ) const { <nl> + CHECK_GE ( id , 0 ) ; <nl> + CHECK_LT ( id , logical_buffers_ . size ( ) ) ; <nl> + return * logical_buffers_ [ id ] ; <nl> + } <nl> + <nl> + LogicalBuffer & LogicalBufferAnalysis : : GetBuffer ( HloInstruction * instruction , <nl> + const ShapeIndex & index ) const { <nl> + return * output_buffers_ . at ( std : : make_pair ( instruction , index ) ) ; <nl> + } <nl> + <nl> + void LogicalBufferAnalysis : : NewLogicalBuffer ( HloInstruction * instruction , <nl> + const ShapeIndex & index ) { <nl> + CHECK_EQ ( logical_buffers_ . size ( ) , next_buffer_id_ ) ; <nl> + logical_buffers_ . emplace_back ( <nl> + MakeUnique < LogicalBuffer > ( instruction , index , next_buffer_id_ ) ) ; <nl> + output_buffers_ [ std : : make_pair ( instruction , index ) ] = <nl> + logical_buffers_ . back ( ) . get ( ) ; <nl> + <nl> + + + next_buffer_id_ ; <nl> + } <nl> + <nl> + Status LogicalBufferAnalysis : : DefaultAction ( HloInstruction * hlo_instruction ) { <nl> + / / Create a logical buffer for each output of the instruction . <nl> + ShapeUtil : : ForEachSubshape ( <nl> + hlo_instruction - > shape ( ) , <nl> + [ this , hlo_instruction ] ( const Shape & shape , const ShapeIndex & index ) { <nl> + NewLogicalBuffer ( hlo_instruction , index ) ; <nl> + } ) ; <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status LogicalBufferAnalysis : : HandleGetTupleElement ( <nl> + HloInstruction * get_tuple_element , HloInstruction * operand ) { <nl> + / / GetTupleElement does not create buffers . <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status LogicalBufferAnalysis : : HandleCopy ( HloInstruction * copy ) { <nl> + / / The top - level buffer ( index = { } ) for kCopy is newly created , but all other <nl> + / / buffers ( in the case of a tuple shape ) come from the operand <nl> + NewLogicalBuffer ( copy , / * index = * / { } ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status LogicalBufferAnalysis : : HandleBitcast ( HloInstruction * bitcast ) { <nl> + / / A kBitcast instruction aliases its operand . That is , the buffer of its <nl> + / / result * is * the buffer of its operand . <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status LogicalBufferAnalysis : : HandleTuple ( <nl> + HloInstruction * tuple , <nl> + tensorflow : : gtl : : ArraySlice < HloInstruction * > operands ) { <nl> + / / A Tuple instruction only creates the top - level buffer . <nl> + NewLogicalBuffer ( tuple , / * index = * / { } ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status LogicalBufferAnalysis : : HandleSelect ( HloInstruction * select , <nl> + HloInstruction * / * pred * / , <nl> + HloInstruction * on_true , <nl> + HloInstruction * on_false ) { <nl> + / / Select allocates a new buffer and then shallow copies the on_true or <nl> + / / on_false buffer into this new buffer . <nl> + NewLogicalBuffer ( select , / * index = * / { } ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + } / / namespace xla <nl> new file mode 100644 <nl> index 0000000000000 . . de9fe1b0a4ed3 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / logical_buffer_analysis . h <nl> <nl> + / * Copyright 2017 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # ifndef THIRD_PARTY_TENSORFLOW_COMPILER_XLA_SERVICE_LOGICAL_BUFFER_ANALYSIS_H_ <nl> + # define THIRD_PARTY_TENSORFLOW_COMPILER_XLA_SERVICE_LOGICAL_BUFFER_ANALYSIS_H_ <nl> + <nl> + # include " tensorflow / compiler / xla / service / hlo_instruction . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_module . h " <nl> + # include " tensorflow / compiler / xla / service / logical_buffer . h " <nl> + # include " tensorflow / compiler / xla / statusor . h " <nl> + # include " tensorflow / core / lib / hash / hash . h " <nl> + <nl> + namespace xla { <nl> + / / A class to create all the logical buffers defined by the HLO ops in a module . <nl> + class LogicalBufferAnalysis : public DfsHloVisitorWithDefault { <nl> + public : <nl> + / / Runs points - to analysis on ' module ' . <nl> + static StatusOr < std : : unique_ptr < LogicalBufferAnalysis > > Run ( <nl> + const HloModule * module ) ; <nl> + <nl> + / / Returns the logical buffer with the given ID . <nl> + LogicalBuffer & GetBuffer ( LogicalBuffer : : Id id ) const ; <nl> + <nl> + / / Returns the logical buffer that represents the output of a given HLO <nl> + / / at a given index . <nl> + LogicalBuffer & GetBuffer ( HloInstruction * instruction , <nl> + const ShapeIndex & index ) const ; <nl> + <nl> + const std : : vector < std : : unique_ptr < LogicalBuffer > > & logical_buffers ( ) const { <nl> + return logical_buffers_ ; <nl> + } <nl> + LogicalBuffer : : Id num_logical_buffers ( ) const { return next_buffer_id_ ; } <nl> + <nl> + private : <nl> + explicit LogicalBufferAnalysis ( const HloModule * module ) : module_ ( module ) { } <nl> + Status Analyze ( ) ; <nl> + <nl> + / / The module this analysis is performed on . <nl> + const HloModule * module_ ; <nl> + <nl> + / / Create a new logical buffer and return a reference to it . The newly created <nl> + / / buffer is stored in an internal vector of LogicalBuffers and can be <nl> + / / accessed with GetBuffer . <nl> + void NewLogicalBuffer ( HloInstruction * instruction , const ShapeIndex & index ) ; <nl> + <nl> + Status DefaultAction ( HloInstruction * hlo_instruction ) override ; <nl> + Status HandleTuple ( <nl> + HloInstruction * tuple , <nl> + tensorflow : : gtl : : ArraySlice < HloInstruction * > operands ) override ; <nl> + Status HandleGetTupleElement ( HloInstruction * get_tuple_element , <nl> + HloInstruction * operand ) override ; <nl> + Status HandleBitcast ( HloInstruction * bitcast ) override ; <nl> + Status HandleCopy ( HloInstruction * copy ) override ; <nl> + Status HandleSelect ( HloInstruction * select , HloInstruction * pred , <nl> + HloInstruction * on_true , <nl> + HloInstruction * on_false ) override ; <nl> + <nl> + / / A map from the buffer ID to the logical buffer <nl> + std : : vector < std : : unique_ptr < LogicalBuffer > > logical_buffers_ ; <nl> + <nl> + struct Hasher { <nl> + size_t operator ( ) ( <nl> + std : : pair < const HloInstruction * , const ShapeIndex > p ) const { <nl> + size_t inst_hash = tensorflow : : hash < const HloInstruction * > ( ) ( p . first ) ; <nl> + for ( auto index = p . second . begin ( ) ; index ! = p . second . end ( ) ; + + index ) { <nl> + inst_hash = tensorflow : : Hash64Combine ( * index , inst_hash ) ; <nl> + } <nl> + return inst_hash ; <nl> + } <nl> + } ; <nl> + <nl> + / / A map from an hlo + shape index to the logical buffer representing <nl> + / / the appropriate output . <nl> + std : : unordered_map < std : : pair < const HloInstruction * , const ShapeIndex > , <nl> + LogicalBuffer * , Hasher > <nl> + output_buffers_ ; <nl> + <nl> + / / The ID of the next logical buffer created . <nl> + LogicalBuffer : : Id next_buffer_id_ = 0 ; <nl> + } ; <nl> + <nl> + } / / namespace xla <nl> + <nl> + # endif / / THIRD_PARTY_TENSORFLOW_COMPILER_XLA_SERVICE_LOGICAL_BUFFER_ANALYSIS_H_ <nl> mmm a / tensorflow / compiler / xla / service / tuple_points_to_analysis . cc <nl> ppp b / tensorflow / compiler / xla / service / tuple_points_to_analysis . cc <nl> void PointsToSet : : add_tuple_source ( const ShapeIndex & index , <nl> <nl> / * static * / StatusOr < std : : unique_ptr < TuplePointsToAnalysis > > <nl> TuplePointsToAnalysis : : Run ( const HloModule * module ) { <nl> - std : : unique_ptr < TuplePointsToAnalysis > analysis ( <nl> - new TuplePointsToAnalysis ( module ) ) ; <nl> + auto logical_buffer_analysis = LogicalBufferAnalysis : : Run ( module ) ; <nl> + std : : unique_ptr < TuplePointsToAnalysis > analysis ( new TuplePointsToAnalysis ( <nl> + module , logical_buffer_analysis . ConsumeValueOrDie ( ) ) ) ; <nl> TF_RETURN_IF_ERROR ( analysis - > Analyze ( ) ) ; <nl> return std : : move ( analysis ) ; <nl> } <nl> Status TuplePointsToAnalysis : : Analyze ( ) { <nl> per_instruction_ . clear ( ) ; <nl> per_instruction_ . resize ( module_ - > NumUniqueInstructionIds ( ) ) ; <nl> <nl> - / / Empirically we usually have a few more logical buffers than instructions , <nl> - / / so reserve 10 % more than the number of instructions to avoid frequent <nl> - / / resizes . <nl> - logical_buffers_ . clear ( ) ; <nl> - logical_buffers_ . reserve ( ( module_ - > NumUniqueInstructionIds ( ) * 11 ) / 10 ) ; <nl> + logical_buffer_aliases_ . clear ( ) ; <nl> + logical_buffer_aliases_ . resize ( <nl> + logical_buffer_analysis_ - > num_logical_buffers ( ) ) ; <nl> <nl> for ( auto & computation : module_ - > computations ( ) ) { <nl> if ( computation - > IsFusionComputation ( ) ) { <nl> Status TuplePointsToAnalysis : : PopulateDefinedBuffersAndAliases ( <nl> const ShapeIndex & index , <nl> const PointsToSet : : BufferList & pointed_to_buffers ) { <nl> for ( const LogicalBuffer * buffer : pointed_to_buffers ) { <nl> - PerBuffer ( buffer - > id ( ) ) <nl> - - > buffer_aliases . emplace_back ( instruction . get ( ) , index ) ; <nl> + logical_buffer_aliases_ [ buffer - > id ( ) ] . emplace_back ( <nl> + instruction . get ( ) , index ) ; <nl> } <nl> } ) ; <nl> } <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> - const LogicalBuffer & TuplePointsToAnalysis : : NewLogicalBuffer ( <nl> - HloInstruction * instruction , const ShapeIndex & index ) { <nl> - CHECK_EQ ( logical_buffers_ . size ( ) , next_buffer_id_ ) ; <nl> - logical_buffers_ . resize ( next_buffer_id_ + 1 ) ; <nl> - PerLogicalBuffer * b = & logical_buffers_ [ next_buffer_id_ ] ; <nl> - b - > logical_buffer = <nl> - MakeUnique < LogicalBuffer > ( instruction , index , next_buffer_id_ ) ; <nl> - + + next_buffer_id_ ; <nl> - return * b - > logical_buffer ; <nl> - } <nl> - <nl> Status TuplePointsToAnalysis : : DefaultAction ( HloInstruction * hlo_instruction ) { <nl> / / Create trivial points - to set for instruction . Each points - to set at index i <nl> / / contains a single element LogicalBuffer ( hlo_instruction , i ) . This indicates <nl> Status TuplePointsToAnalysis : : DefaultAction ( HloInstruction * hlo_instruction ) { <nl> points_to_set . ForEachMutableElement ( <nl> [ this , hlo_instruction ] ( const ShapeIndex & index , <nl> PointsToSet : : BufferList * buffers ) { <nl> - const LogicalBuffer & buffer = NewLogicalBuffer ( hlo_instruction , index ) ; <nl> - buffers - > push_back ( & buffer ) ; <nl> + buffers - > push_back ( <nl> + & logical_buffer_analysis_ - > GetBuffer ( hlo_instruction , index ) ) ; <nl> } ) ; <nl> <nl> if ( ShapeUtil : : IsTuple ( hlo_instruction - > shape ( ) ) ) { <nl> Status TuplePointsToAnalysis : : HandleCopy ( HloInstruction * copy ) { <nl> / / tuple shape ) come from the operand <nl> PointsToSet & points_to_set = CreateCopiedPointsToSet ( copy , copy - > operand ( 0 ) ) ; <nl> points_to_set . mutable_element ( / * index = * / { } ) - > clear ( ) ; <nl> - points_to_set . AddPointedToBuffer ( NewLogicalBuffer ( copy , / * index = * / { } ) , <nl> - / * index = * / { } ) ; <nl> + points_to_set . AddPointedToBuffer ( <nl> + logical_buffer_analysis_ - > GetBuffer ( copy , / * index = * / { } ) , <nl> + / * index = * / { } ) ; <nl> <nl> return Status : : OK ( ) ; <nl> } <nl> Status TuplePointsToAnalysis : : HandleTuple ( <nl> HloInstruction * tuple , <nl> tensorflow : : gtl : : ArraySlice < HloInstruction * > operands ) { <nl> PointsToSet & points_to_set = CreateEmptyPointsToSet ( tuple ) ; <nl> - points_to_set . AddPointedToBuffer ( NewLogicalBuffer ( tuple , / * index = * / { } ) , <nl> - / * index = * / { } ) ; <nl> + points_to_set . AddPointedToBuffer ( <nl> + logical_buffer_analysis_ - > GetBuffer ( tuple , / * index = * / { } ) , <nl> + / * index = * / { } ) ; <nl> <nl> / / A tuple contains references to all input operands and transitively any <nl> / / references in those operands . <nl> Status TuplePointsToAnalysis : : HandleSelect ( HloInstruction * select , <nl> / / Select creates a new ( top - level ) buffer to store its result , so its <nl> / / respective element in the points - to set should contain only itself . <nl> points_to_set . mutable_element ( { } ) - > clear ( ) ; <nl> - points_to_set . AddPointedToBuffer ( NewLogicalBuffer ( select , / * index = * / { } ) , <nl> - / * index = * / { } ) ; <nl> + points_to_set . AddPointedToBuffer ( <nl> + logical_buffer_analysis_ - > GetBuffer ( select , / * index = * / { } ) , <nl> + / * index = * / { } ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> Status TuplePointsToAnalysis : : VerifyBuffer ( const LogicalBuffer & buffer ) const { <nl> buffer . ToString ( ) . c_str ( ) , buffer . instruction ( ) - > name ( ) . c_str ( ) ) ; <nl> } <nl> <nl> - if ( buffer . id ( ) < 0 | | buffer . id ( ) > = next_buffer_id_ ) { <nl> + if ( buffer . id ( ) < 0 | | <nl> + buffer . id ( ) > = logical_buffer_analysis_ - > num_logical_buffers ( ) ) { <nl> return FailedPrecondition ( <nl> " LogicalBuffer % s is ill - defined : invalid id % lld " , <nl> buffer . ToString ( ) . c_str ( ) , buffer . id ( ) ) ; <nl> Status TuplePointsToAnalysis : : VerifyBuffer ( const LogicalBuffer & buffer ) const { <nl> const LogicalBuffer & TuplePointsToAnalysis : : GetBuffer ( <nl> LogicalBuffer : : Id id ) const { <nl> CHECK_GE ( id , 0 ) ; <nl> - CHECK_LT ( id , logical_buffers_ . size ( ) ) ; <nl> - return * logical_buffers_ [ id ] . logical_buffer ; <nl> + CHECK_LT ( id , logical_buffer_analysis_ - > num_logical_buffers ( ) ) ; <nl> + return logical_buffer_analysis_ - > GetBuffer ( id ) ; <nl> } <nl> <nl> StatusOr < const LogicalBuffer * > TuplePointsToAnalysis : : GetBufferDefinedAt ( <nl> StatusOr < const LogicalBuffer * > TuplePointsToAnalysis : : GetBufferDefinedAt ( <nl> <nl> const TuplePointsToAnalysis : : BufferAliasVector & <nl> TuplePointsToAnalysis : : GetBufferAliases ( const LogicalBuffer & buffer ) const { <nl> - return logical_buffers_ . at ( buffer . id ( ) ) . buffer_aliases ; <nl> + return logical_buffer_aliases_ . at ( buffer . id ( ) ) ; <nl> } <nl> <nl> const TuplePointsToAnalysis : : BufferDefinitionVector & <nl> string TuplePointsToAnalysis : : ToString ( ) const { <nl> } <nl> <nl> tensorflow : : strings : : StrAppend ( & output , " LogicalBuffers : \ n " ) ; <nl> - for ( auto & b : logical_buffers_ ) { <nl> - tensorflow : : strings : : StrAppend ( & output , " buffer " , <nl> - b . logical_buffer - > ToString ( ) , " : \ n " ) ; <nl> - for ( const BufferAlias & alias : b . buffer_aliases ) { <nl> + for ( const auto & b : logical_buffer_analysis_ - > logical_buffers ( ) ) { <nl> + tensorflow : : strings : : StrAppend ( & output , " buffer " , b - > ToString ( ) , " : \ n " ) ; <nl> + for ( const BufferAlias & alias : logical_buffer_aliases_ . at ( b - > id ( ) ) ) { <nl> tensorflow : : strings : : StrAppend ( & output , " alias " , alias . ToString ( ) , <nl> " \ n " ) ; <nl> } <nl> mmm a / tensorflow / compiler / xla / service / tuple_points_to_analysis . h <nl> ppp b / tensorflow / compiler / xla / service / tuple_points_to_analysis . h <nl> limitations under the License . <nl> # include " tensorflow / compiler / xla / service / hlo_instruction . h " <nl> # include " tensorflow / compiler / xla / service / hlo_module . h " <nl> # include " tensorflow / compiler / xla / service / logical_buffer . h " <nl> + # include " tensorflow / compiler / xla / service / logical_buffer_analysis . h " <nl> # include " tensorflow / compiler / xla / shape_tree . h " <nl> # include " tensorflow / compiler / xla / statusor . h " <nl> # include " tensorflow / compiler / xla / types . h " <nl> class TuplePointsToAnalysis : public DfsHloVisitorWithDefault { <nl> const BufferAliasVector & GetBufferAliases ( const LogicalBuffer & buffer ) const ; <nl> <nl> / / Returns the number of logical buffers in the module <nl> - LogicalBuffer : : Id num_logical_buffers ( ) const { return next_buffer_id_ ; } <nl> + LogicalBuffer : : Id num_logical_buffers ( ) const { <nl> + return logical_buffer_analysis_ - > num_logical_buffers ( ) ; <nl> + } <nl> <nl> / / Return a the logical buffer with id " id " in the module . Iteration <nl> / / over all logical buffers is usually done with something like : <nl> class TuplePointsToAnalysis : public DfsHloVisitorWithDefault { <nl> / / const auto & buffer = points_to . logical_buffer ( id ) ; <nl> / / . . . do something with buffer . . . <nl> / / } <nl> - const std : : unique_ptr < LogicalBuffer > & logical_buffer ( <nl> - LogicalBuffer : : Id id ) const { <nl> - return logical_buffers_ [ id ] . logical_buffer ; <nl> + LogicalBuffer & logical_buffer ( LogicalBuffer : : Id id ) const { <nl> + return logical_buffer_analysis_ - > GetBuffer ( id ) ; <nl> } <nl> <nl> / / Returns a vector of buffers that the instruction produces . Most <nl> class TuplePointsToAnalysis : public DfsHloVisitorWithDefault { <nl> string ToString ( ) const ; <nl> <nl> private : <nl> - explicit TuplePointsToAnalysis ( const HloModule * module ) : module_ ( module ) { } <nl> + explicit TuplePointsToAnalysis ( <nl> + const HloModule * module , <nl> + std : : unique_ptr < LogicalBufferAnalysis > logical_buffer_analysis ) <nl> + : module_ ( module ) , <nl> + logical_buffer_analysis_ ( std : : move ( logical_buffer_analysis ) ) { } <nl> <nl> / / Perform the analysis . Should be called immediately after constructing the <nl> / / object and before calling GetPointsToSet . <nl> class TuplePointsToAnalysis : public DfsHloVisitorWithDefault { <nl> Status PopulateDefinedBuffersAndAliases ( <nl> const std : : list < std : : unique_ptr < HloInstruction > > & instructions ) ; <nl> <nl> - / / Create a new logical buffer and return a reference to it . The newly created <nl> - / / buffer is stored in an internal vector of LogicalBuffers and can be <nl> - / / accessed with GetBuffer . <nl> - const LogicalBuffer & NewLogicalBuffer ( HloInstruction * instruction , <nl> - const ShapeIndex & index ) ; <nl> - <nl> / / Creates an empty PointsToSet in the points_to_ map for the given <nl> / / instruction . <nl> PointsToSet & CreateEmptyPointsToSet ( const HloInstruction * instruction ) ; <nl> class TuplePointsToAnalysis : public DfsHloVisitorWithDefault { <nl> BufferDefinitionVector instruction_defined_buffers ; <nl> } ; <nl> <nl> - / / Information kept per logical buffer <nl> - struct PerLogicalBuffer { <nl> - std : : unique_ptr < LogicalBuffer > logical_buffer ; <nl> - / / Empircally , ~ 85 % of buffers have 1 buffer_alias <nl> - BufferAliasVector buffer_aliases ; <nl> - } ; <nl> - <nl> const PerInstruction * PerInst ( const HloInstruction * inst ) const { <nl> int id = inst - > unique_id ( ) ; <nl> DCHECK_GE ( id , 0 ) ; <nl> class TuplePointsToAnalysis : public DfsHloVisitorWithDefault { <nl> return & per_instruction_ [ id ] ; <nl> } <nl> <nl> - PerLogicalBuffer * PerBuffer ( const LogicalBuffer : : Id id ) { <nl> - DCHECK_GE ( id , 0 ) ; <nl> - DCHECK_LT ( id , logical_buffers_ . size ( ) ) ; <nl> - return & logical_buffers_ [ id ] ; <nl> - } <nl> - <nl> / / The module this analysis is performed on . <nl> const HloModule * module_ ; <nl> <nl> + / / The logical buffers for this module . <nl> + const std : : unique_ptr < LogicalBufferAnalysis > logical_buffer_analysis_ ; <nl> + <nl> / / A map from instruction - > unique_id ( ) to <nl> std : : vector < PerInstruction > per_instruction_ ; <nl> <nl> - / / A map from LogicalBuffer - > id ( ) to information about that logical buffer <nl> - std : : vector < PerLogicalBuffer > logical_buffers_ ; <nl> - <nl> - / / The ID of the next logical buffer created . <nl> - LogicalBuffer : : Id next_buffer_id_ = 0 ; <nl> + / / A map from LogicalBuffer - > id ( ) to alias information about that logical <nl> + / / buffer <nl> + std : : vector < BufferAliasVector > logical_buffer_aliases_ ; <nl> <nl> TF_DISALLOW_COPY_AND_ASSIGN ( TuplePointsToAnalysis ) ; <nl> } ; <nl> | [ XLA ] Separate logical buffer creation and ownership out of tuple pointer analysis . | tensorflow/tensorflow | a6e811ff29406aa582b14e2e07d2881c81d3e4a8 | 2017-08-21T20:03:00Z |
mmm a / scripting / engine . cpp <nl> ppp b / scripting / engine . cpp <nl> namespace mongo { <nl> <nl> private : <nl> PoolToScopes _pools ; <nl> - mutex _mutex ; <nl> + boost : : mutex _mutex ; <nl> int _magic ; <nl> } ; <nl> <nl> | compilie solaris MINOR | mongodb/mongo | f579b721757347d0419878d3c1ef6d21101bd7e2 | 2009-09-29T20:58:48Z |
mmm a / src / strings / uri . cc <nl> ppp b / src / strings / uri . cc <nl> <nl> # include " src / strings / char - predicates - inl . h " <nl> # include " src / strings / string - search . h " <nl> # include " src / strings / unicode - inl . h " <nl> + # include " src / tracing / trace - event . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> bool IntoOneAndTwoByte ( Handle < String > uri , bool is_uri , <nl> <nl> MaybeHandle < String > Uri : : Decode ( Isolate * isolate , Handle < String > uri , <nl> bool is_uri ) { <nl> + TRACE_EVENT0 ( " v8 " , " V8 . DecodeUri " ) ; <nl> + <nl> uri = String : : Flatten ( isolate , uri ) ; <nl> std : : vector < uint8_t > one_byte_buffer ; <nl> std : : vector < uc16 > two_byte_buffer ; <nl> void EncodePair ( uc16 cc1 , uc16 cc2 , std : : vector < uint8_t > * buffer ) { <nl> <nl> MaybeHandle < String > Uri : : Encode ( Isolate * isolate , Handle < String > uri , <nl> bool is_uri ) { <nl> + TRACE_EVENT0 ( " v8 " , " V8 . EncodeUri " ) ; <nl> + <nl> uri = String : : Flatten ( isolate , uri ) ; <nl> int uri_length = uri - > length ( ) ; <nl> std : : vector < uint8_t > buffer ; <nl> | [ Jank ] : Add uri trace events | v8/v8 | d1aee56d1a6564fafbe995551e953ced95a26134 | 2020-06-12T16:27:03Z |
mmm a / modules / videoio / doc / videoio_overview . markdown <nl> ppp b / modules / videoio / doc / videoio_overview . markdown <nl> cap . open ( filename , cv : : CAP_DSHOW ) ; <nl> <nl> # # # # How to enable backends <nl> <nl> - There are two kinds of videoio backends : built - in backends and plugins which will be loaded at runtime ( since OpenCV 4 . 1 . 1 ) . Use functions cv : : videoio_registry : : getBackends , cv : : videoio_registry : : hasBackend and cv : : videoio_registry : : getBackendName to check actual presence of backend during runtime . <nl> + There are two kinds of videoio backends : built - in backends and plugins which will be loaded at runtime ( since OpenCV 4 . 1 . 0 ) . Use functions cv : : videoio_registry : : getBackends , cv : : videoio_registry : : hasBackend and cv : : videoio_registry : : getBackendName to check actual presence of backend during runtime . <nl> <nl> To enable built - in videoio backends : <nl> 1 . Enable corresponding CMake option , e . g . ` - DWITH_GSTREAMER = ON ` <nl> | videoio ( doc ) : fix ' since ' version | opencv/opencv | 6a439ae53ddd6d3ffb2a454837a02d41d3a53133 | 2019-08-20T10:15:56Z |
mmm a / Code / Sandbox / Plugins / EditorCommon / AssetSystem / AssetEditor . h <nl> ppp b / Code / Sandbox / Plugins / EditorCommon / AssetSystem / AssetEditor . h <nl> class EDITOR_COMMON_API CAssetEditor : public CDockableEditor <nl> CAsset * GetAssetBeingEdited ( ) { return m_assetBeingEdited ; } <nl> const CAsset * GetAssetBeingEdited ( ) const { return m_assetBeingEdited ; } <nl> <nl> - virtual bool OnSave ( ) override final ; <nl> + virtual bool OnSave ( ) override ; / / # TODO Make this method final . <nl> virtual bool OnSaveAs ( ) override ; / / # TODO Make this method final . <nl> <nl> bool SaveBackup ( const string & backupFolder ) ; <nl> mmm a / Code / Sandbox / Plugins / MeshImporter / MeshImporterEditor . cpp <nl> ppp b / Code / Sandbox / Plugins / MeshImporter / MeshImporterEditor . cpp <nl> bool CEditorAdapter : : OnOpenAsset ( CAsset * pAsset ) <nl> return bOpen ; <nl> } <nl> <nl> - bool CEditorAdapter : : OnSaveAsset ( CEditableAsset & ) <nl> + bool CEditorAdapter : : OnSaveAsset ( CEditableAsset & / * editAsset * / ) <nl> { <nl> - m_pDialog - > OnSave ( ) ; <nl> + CRY_ASSERT_MESSAGE ( false , " Not implemented " ) ; <nl> return false ; <nl> } <nl> <nl> + bool CEditorAdapter : : OnSave ( ) <nl> + { <nl> + m_pDialog - > OnSave ( ) ; <nl> + return true ; <nl> + } <nl> + <nl> bool CEditorAdapter : : OnSaveAs ( ) <nl> { <nl> m_pDialog - > OnSaveAs ( ) ; <nl> mmm a / Code / Sandbox / Plugins / MeshImporter / MeshImporterEditor . h <nl> ppp b / Code / Sandbox / Plugins / MeshImporter / MeshImporterEditor . h <nl> class CEditorAdapter : public CAssetEditor , public MeshImporter : : IDialogHost <nl> virtual void OnCloseAsset ( ) override ; <nl> <nl> / / CEditor implementation . <nl> + virtual bool OnSave ( ) override ; <nl> virtual bool OnSaveAs ( ) override ; <nl> <nl> virtual void customEvent ( QEvent * pEvent ) override ; <nl> | ! XB ( FBXImporter ) ( CE - 15666 ) Mesh Importer cannot save new files | CRYTEK/CRYENGINE | 3dc342d6dc4af0d810d386a3c45c6caf57259ad2 | 2018-03-22T09:56:06Z |
mmm a / modules / ml / src / svm . cpp <nl> ppp b / modules / ml / src / svm . cpp <nl> void CvSVM : : write ( CvFileStorage * fs , const char * name ) const <nl> params . svm_type = = CvSVM : : ONE_CLASS ? 1 : 0 ; <nl> const CvSVMDecisionFunc * df = decision_func ; <nl> if ( ! isSvmModelApplicable ( sv_total , var_all , var_count , class_count ) ) <nl> + { <nl> + cvReleaseFileStorage ( & fs ) ; <nl> + fs = NULL ; <nl> + <nl> CV_ERROR ( CV_StsParseError , " SVM model data is invalid , check sv_count , var_ * and class_count tags " ) ; <nl> + } <nl> <nl> cvStartWriteStruct ( fs , name , CV_NODE_MAP , CV_TYPE_NAME_ML_SVM ) ; <nl> <nl> | release filestorage before exception | opencv/opencv | 3c3bc123fc8508e1845d0a3e1ea85f66b1a36fc9 | 2015-09-17T10:40:36Z |
mmm a / test / ClangImporter / pch - bridging - header - module - map - diags . swift <nl> ppp b / test / ClangImporter / pch - bridging - header - module - map - diags . swift <nl> <nl> / / RUN : rm - f % t . * <nl> + / / REQUIRES : objc_interop <nl> <nl> / / Build a bridging PCH for involving a module map that contains a warning <nl> / / RUN : % target - swift - frontend - F % S / Inputs / ModuleMapWarning - emit - pch % S / Inputs / ModuleMapWarning / bridging - pch . h - pch - output - dir % t / pch 2 > % t . stderr <nl> | Test requires Objective - C | apple/swift | 34a883d90e91e892ab57c5475970213f264b05c7 | 2019-12-13T20:48:48Z |
mmm a / src / compiler / wasm - compiler . cc <nl> ppp b / src / compiler / wasm - compiler . cc <nl> Handle < Code > CompileWasmToJSWrapper ( <nl> origin = = wasm : : kAsmJsOrigin ? new ( & zone ) SourcePositionTable ( & graph ) <nl> : nullptr ; <nl> <nl> - ModuleEnv env = { nullptr , { } , { } , { } , Handle < Code > ( ) , use_trap_handler } ; <nl> + ModuleEnv env = { nullptr , <nl> + std : : vector < Address > ( ) , <nl> + std : : vector < Address > ( ) , <nl> + std : : vector < Handle < Code > > ( ) , <nl> + Handle < Code > ( ) , <nl> + use_trap_handler } ; <nl> WasmGraphBuilder builder ( & env , & zone , & jsgraph , <nl> CEntryStub ( isolate , 1 ) . GetCode ( ) , sig , <nl> source_position_table ) ; <nl> Handle < Code > CompileWasmToWasmWrapper ( Isolate * isolate , WasmCodeWrapper target , <nl> <nl> ModuleEnv env = { <nl> nullptr , <nl> - { } , <nl> - { } , <nl> - { } , <nl> + std : : vector < Address > ( ) , <nl> + std : : vector < Address > ( ) , <nl> + std : : vector < Handle < Code > > ( ) , <nl> Handle < Code > ( ) , <nl> ! target . IsCodeObject ( ) & & target . GetWasmCode ( ) - > HasTrapHandlerIndex ( ) } ; <nl> WasmGraphBuilder builder ( & env , & zone , & jsgraph , Handle < Code > ( ) , sig ) ; <nl> | MIPS [ 64 ] : Fix compilation problem | v8/v8 | 633144e6d7bad0be7cd2d9daabc0d0ee7e0688a2 | 2017-12-11T13:56:33Z |
mmm a / docs / FAQs / General_FAQs . md <nl> ppp b / docs / FAQs / General_FAQs . md <nl> Sending a pull request is simple . <nl> # # Do comments need to be made in Doxygen ? <nl> <nl> Yes , currently all comments need to be made in Doxygen . <nl> + <nl> + <nl> + * * More General FAQs to follow . * * <nl> | Update General_FAQs . md | ApolloAuto/apollo | d6b279a8838390e622578ac02466b81e41f1da09 | 2017-12-20T01:03:26Z |
mmm a / Code / CryEngine / RenderDll / XRenderD3D9 / GraphicsPipeline / ShadowMap . cpp <nl> ppp b / Code / CryEngine / RenderDll / XRenderD3D9 / GraphicsPipeline / ShadowMap . cpp <nl> void CShadowMapStage : : ReAllocateResources ( const SShadowConfig shadowConfig ) <nl> if ( ! pTx ) <nl> { <nl> char szName [ 64 ] ; <nl> - cry_sprintf ( szName , " % CachedShadowMap_ % d " , i ) ; <nl> + cry_sprintf ( szName , " $ ShadowMapCached_ % d " , i ) ; <nl> <nl> pTx = CTexture : : GetOrCreateDepthStencil ( szName , nResolutions [ i ] , nResolutions [ i ] , Clr_FarPlane , eTT_2D , FT_DONT_STREAM , texFormat ) ; <nl> } <nl> | ! B ( Renderer ) Fixed malformed texture - name | CRYTEK/CRYENGINE | 2fdb8d78ab2263e1573627b284abdf66be5ee6a2 | 2019-01-29T10:02:03Z |
mmm a / src / clientversion . h <nl> ppp b / src / clientversion . h <nl> <nl> <nl> / / Check that required client information is defined <nl> # if ! defined ( CLIENT_VERSION_MAJOR ) | | ! defined ( CLIENT_VERSION_MINOR ) | | ! defined ( CLIENT_VERSION_REVISION ) | | ! defined ( CLIENT_VERSION_BUILD ) | | ! defined ( CLIENT_VERSION_IS_RELEASE ) | | ! defined ( COPYRIGHT_YEAR ) <nl> - # error Client version information missing : wasn ' t defined by bitcoin - config . h nor defined any other way <nl> + # error Client version information missing : version is not defined by bitcoin - config . h or in any other way <nl> # endif <nl> <nl> / * * <nl> | Merge : Fix build warning from # error text | bitcoin/bitcoin | 703202180bde4e464039e00d796797ed9aa32f68 | 2017-04-10T06:38:55Z |
mmm a / tensorflow / core / lib / core / threadpool . h <nl> ppp b / tensorflow / core / lib / core / threadpool . h <nl> class ThreadPool { <nl> / / pointer points to , and should not attempt to delete . <nl> Eigen : : ThreadPoolInterface * AsEigenThreadPool ( ) ; <nl> <nl> + private : <nl> struct Impl ; <nl> <nl> - private : <nl> std : : unique_ptr < Impl > impl_ ; <nl> TF_DISALLOW_COPY_AND_ASSIGN ( ThreadPool ) ; <nl> } ; <nl> | Merge pull request from ccgrtwall : threadpool - impl | tensorflow/tensorflow | edd1bceca826e4af93c2ff05301a49baa3546f0c | 2019-06-12T23:55:32Z |
mmm a / drivers / gles3 / rasterizer_canvas_gles3 . cpp <nl> ppp b / drivers / gles3 / rasterizer_canvas_gles3 . cpp <nl> void RasterizerCanvasGLES3 : : canvas_end ( ) { <nl> state . using_ninepatch = false ; <nl> } <nl> <nl> - RasterizerStorageGLES3 : : Texture * RasterizerCanvasGLES3 : : _bind_canvas_texture ( const RID & p_texture , const RID & p_normal_map ) { <nl> + RasterizerStorageGLES3 : : Texture * RasterizerCanvasGLES3 : : _bind_canvas_texture ( const RID & p_texture , const RID & p_normal_map , bool p_force ) { <nl> <nl> RasterizerStorageGLES3 : : Texture * tex_return = NULL ; <nl> <nl> - if ( p_texture = = state . current_tex ) { <nl> + if ( p_texture = = state . current_tex & & ! p_force ) { <nl> tex_return = state . current_tex_ptr ; <nl> } else if ( p_texture . is_valid ( ) ) { <nl> <nl> RasterizerStorageGLES3 : : Texture * RasterizerCanvasGLES3 : : _bind_canvas_texture ( con <nl> state . current_tex_ptr = NULL ; <nl> } <nl> <nl> - if ( p_normal_map = = state . current_normal ) { <nl> + if ( p_normal_map = = state . current_normal & & ! p_force ) { <nl> / / do none <nl> state . canvas_shader . set_uniform ( CanvasShaderGLES3 : : USE_DEFAULT_NORMAL , state . current_normal . is_valid ( ) ) ; <nl> <nl> void RasterizerCanvasGLES3 : : _copy_texscreen ( const Rect2 & p_rect ) { <nl> state . using_texture_rect = true ; <nl> _set_texture_rect_mode ( false ) ; <nl> <nl> - _bind_canvas_texture ( state . current_tex , state . current_normal ) ; <nl> + _bind_canvas_texture ( state . current_tex , state . current_normal , true ) ; <nl> <nl> glEnable ( GL_BLEND ) ; <nl> } <nl> mmm a / drivers / gles3 / rasterizer_canvas_gles3 . h <nl> ppp b / drivers / gles3 / rasterizer_canvas_gles3 . h <nl> class RasterizerCanvasGLES3 : public RasterizerCanvas { <nl> virtual void canvas_end ( ) ; <nl> <nl> _FORCE_INLINE_ void _set_texture_rect_mode ( bool p_enable , bool p_ninepatch = false ) ; <nl> - _FORCE_INLINE_ RasterizerStorageGLES3 : : Texture * _bind_canvas_texture ( const RID & p_texture , const RID & p_normal_map ) ; <nl> + _FORCE_INLINE_ RasterizerStorageGLES3 : : Texture * _bind_canvas_texture ( const RID & p_texture , const RID & p_normal_map , bool p_force = false ) ; <nl> <nl> _FORCE_INLINE_ void _draw_gui_primitive ( int p_points , const Vector2 * p_vertices , const Color * p_colors , const Vector2 * p_uvs ) ; <nl> _FORCE_INLINE_ void _draw_polygon ( const int * p_indices , int p_index_count , int p_vertex_count , const Vector2 * p_vertices , const Vector2 * p_uvs , const Color * p_colors , bool p_singlecolor , const int * p_bones , const float * p_weights ) ; <nl> | Fix a corner - case bug in _copy_texscreen in the gles3 renderer | godotengine/godot | ee52d12921aefd51c74ff9d50833e19569b2fb31 | 2018-05-15T11:35:46Z |
mmm a / fdbclient / BlobStore . actor . cpp <nl> ppp b / fdbclient / BlobStore . actor . cpp <nl> ACTOR Future < Reference < HTTP : : Response > > doRequest_impl ( Reference < BlobStoreEndpoi <nl> Future < BlobStoreEndpoint : : ReusableConnection > frconn = bstore - > connect ( ) ; <nl> <nl> / / Make a shallow copy of the queue by calling addref ( ) on each buffer in the chain and then prepending that chain to contentCopy <nl> + contentCopy . discardAll ( ) ; <nl> if ( pContent ! = nullptr ) { <nl> - contentCopy . discardAll ( ) ; <nl> PacketBuffer * pFirst = pContent - > getUnsent ( ) ; <nl> PacketBuffer * pLast = nullptr ; <nl> for ( PacketBuffer * p = pFirst ; p ! = nullptr ; p = p - > nextPacketBuffer ( ) ) { <nl> mmm a / fdbclient / HTTP . actor . cpp <nl> ppp b / fdbclient / HTTP . actor . cpp <nl> namespace HTTP { <nl> / / and be destroyed by the caller <nl> / / TODO : pSent is very hackish , do something better . <nl> ACTOR Future < Reference < HTTP : : Response > > doRequest ( Reference < IConnection > conn , std : : string verb , std : : string resource , HTTP : : Headers headers , UnsentPacketQueue * pContent , int contentLen , Reference < IRateControl > sendRate , int64_t * pSent , Reference < IRateControl > recvRate ) { <nl> + state TraceEvent event ( SevDebug , " HTTPRequest " ) ; <nl> + <nl> state UnsentPacketQueue empty ; <nl> if ( pContent = = NULL ) <nl> pContent = & empty ; <nl> namespace HTTP { <nl> state bool earlyResponse = false ; <nl> state int total_sent = 0 ; <nl> <nl> + event . detail ( " DebugID " , conn - > getDebugID ( ) ) ; <nl> + event . detail ( " RemoteAddress " , conn - > getPeerAddress ( ) ) ; <nl> + event . detail ( " Verb " , verb ) ; <nl> + event . detail ( " Resource " , resource ) ; <nl> + event . detail ( " RequestContentLen " , contentLen ) ; <nl> + <nl> try { <nl> / / Write headers to a packet buffer chain <nl> PacketBuffer * pFirst = new PacketBuffer ( ) ; <nl> namespace HTTP { <nl> } <nl> <nl> Void _ = wait ( responseReading ) ; <nl> + event . detail ( " ResponseCode " , r - > code ) ; <nl> + event . detail ( " ResponseContentLen " , r - > contentLen ) ; <nl> <nl> double elapsed = timer ( ) - send_start ; <nl> + event . detail ( " Elapsed " , elapsed ) ; <nl> if ( CLIENT_KNOBS - > HTTP_VERBOSE_LEVEL > 0 ) <nl> printf ( " [ % s ] HTTP code = % d early = % d , time = % fs % s % s contentLen = % d [ % d out , response content len % d ] \ n " , <nl> conn - > getDebugID ( ) . toString ( ) . c_str ( ) , r - > code , earlyResponse , elapsed , verb . c_str ( ) , resource . c_str ( ) , contentLen , total_sent , ( int ) r - > contentLen ) ; <nl> | Bug fix in blobstore request loop where zero - content requests ( i . e . not uploads ) could cause mismatches between requests and responses . Added HTTPRequest debug event . | apple/foundationdb | 339e15563e4b9fd9573e06dd5a2269fee0f6a077 | 2019-01-05T02:34:16Z |
new file mode 100644 <nl> index 00000000000 . . 9a71eaf9890 <nl> mmm / dev / null <nl> ppp b / hphp / hack / src / client / clientAiQuery . ml <nl> <nl> + ( * * <nl> + * Copyright ( c ) 2015 , 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 " hack " 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> + let go result = <nl> + print_endline result <nl> mmm a / hphp / hack / src / client / clientArgs . ml <nl> ppp b / hphp / hack / src / client / clientArgs . ml <nl> let parse_check_args cmd = <nl> Arg . String ( fun x - > set_mode ( MODE_IDE_HIGHLIGHT_REFS x ) ( ) ) , <nl> ( * Similar to - - ide - find - refs , but returns references in current file only , <nl> * and is optimized to be faster in that case * ) " " ; <nl> + " - - ai - query " , Arg . String ( fun x - > set_mode ( MODE_AI_QUERY x ) ( ) ) , <nl> + ( * Send an AI query * ) " " ; <nl> ( * flags * ) <nl> " - - json " , Arg . Set output_json , <nl> " output json for machine consumption . ( default : false ) " ; <nl> mmm a / hphp / hack / src / client / clientCheck . ml <nl> ppp b / hphp / hack / src / client / clientCheck . ml <nl> let main args = <nl> let results = rpc args @ @ Rpc . TRACE_AI action in <nl> ClientTraceAi . go results args . output_json ; <nl> Exit_status . No_error <nl> + | MODE_AI_QUERY json - > <nl> + let results = rpc args @ @ Rpc . AI_QUERY json in <nl> + ClientAiQuery . go results ; <nl> + Exit_status . No_error <nl> in <nl> HackEventLogger . client_check_finish exit_status ; <nl> exit_status <nl> mmm a / hphp / hack / src / client / clientEnv . ml <nl> ppp b / hphp / hack / src / client / clientEnv . ml <nl> type client_mode = <nl> | MODE_REMOVE_DEAD_FIXMES of int list <nl> | MODE_IDE_FIND_REFS of string <nl> | MODE_IDE_HIGHLIGHT_REFS of string <nl> + | MODE_AI_QUERY of string <nl> <nl> type client_check_env = { <nl> mode : client_mode ; <nl> let mode_to_string = function <nl> | MODE_IDE_FIND_REFS _ - > " MODE_IDE_FIND_REFS " <nl> | MODE_GET_DEFINITION_BY_ID _ - > " MODE_GET_DEFINITION_BY_ID " <nl> | MODE_IDE_HIGHLIGHT_REFS _ - > " MODE_IDE_HIGHLIGHT_REFS " <nl> + | MODE_AI_QUERY _ - > " MODE_AI_QUERY " <nl> mmm a / hphp / hack / src / server / serverRpc . ml <nl> ppp b / hphp / hack / src / server / serverRpc . ml <nl> type _ t = <nl> | FIND_LVAR_REFS : string * int * int - > ServerFindLocals . result t <nl> | FORMAT : string * int * int - > string Format_hack . return t <nl> | TRACE_AI : Ai . TraceService . action - > string t <nl> + | AI_QUERY : string - > string t <nl> <nl> let handle : type a . genv - > env - > a t - > a = <nl> fun genv env - > function <nl> let handle : type a . genv - > env - > a t - > a = <nl> | TRACE_AI action - > <nl> Ai . TraceService . go action Typing_check_utils . check_defs <nl> ( ServerArgs . ai_mode genv . options ) env . tcopt <nl> + | AI_QUERY json - > <nl> + Ai . QueryService . go json <nl> <nl> let to_string : type a . a t - > _ = function <nl> | STATUS - > " STATUS " <nl> let to_string : type a . a t - > _ = function <nl> | IDE_FIND_REFS _ - > " IDE_FIND_REFS " <nl> | GET_DEFINITION_BY_ID _ - > " GET_DEFINITION_BY_ID " <nl> | IDE_HIGHLIGHT_REFS _ - > " IDE_HIGHLIGHT_REFS " <nl> + | AI_QUERY _ - > " AI_QUERY " <nl> mmm a / hphp / hack / src / stubs / ai . ml <nl> ppp b / hphp / hack / src / stubs / ai . ml <nl> module TraceService = struct <nl> <nl> let go _ _ _ _ = " " <nl> end <nl> + <nl> + module QueryService = struct <nl> + let go _ = " " <nl> + end <nl> | HH Client / Server new AI feature | facebook/hhvm | 2bdfb3ac8889b7e1b8372830834fe16a2e640911 | 2016-06-28T00:16:06Z |
mmm a / test / test_c10d . py <nl> ppp b / test / test_c10d . py <nl> def check_no_grads ( ) : <nl> @ skip_if_not_multigpu <nl> @ skip_if_not_nccl <nl> def test_accumulate_gradients ( self ) : <nl> - gpus = gpus_for_rank ( self . world_size ) [ self . rank ] [ 0 : 1 ] <nl> - self . assertEqual ( len ( gpus ) , 1 ) <nl> + int_devices = gpus_for_rank ( self . world_size ) [ self . rank ] [ : 1 ] <nl> + devices = list ( [ torch . device ( ' cuda : ' + str ( i ) ) for i in int_devices ] ) <nl> store = c10d . FileStore ( self . file . name , self . world_size ) <nl> process_group = c10d . ProcessGroupNCCL ( store , self . rank , self . world_size ) <nl> - local_batch_size = len ( gpus ) <nl> - global_batch_size = self . world_size * local_batch_size <nl> + global_batch_size = self . world_size <nl> <nl> model , ddp_model , input , target = \ <nl> self . _prepare_single_device_module ( <nl> - process_group , gpus , global_batch_size ) <nl> + process_group , devices , devices , global_batch_size ) <nl> <nl> def step_model ( model , input , target ) : <nl> model . train ( ) <nl> def step_model ( model , input , target ) : <nl> ddp_model . train ( ) <nl> ddp_model . module ( input ) <nl> <nl> - # check two model parameters over 2 iterations <nl> + # Check two model parameters over 4 iterations . <nl> + # Use 4 iterations because we alternate between reducing and <nl> + # not reducing and want to make sure we switch both ways . <nl> for iteration in range ( 4 ) : <nl> - # single cpu / gpu training <nl> step_model ( model , input , target ) <nl> <nl> if iteration % 2 = = 0 : <nl> # Skip gradients sync without calling prepare_for_backward <nl> - step_model ( ddp_model . module , <nl> - input [ self . rank * local_batch_size : ( self . rank + 1 ) * local_batch_size ] , <nl> - target [ self . rank * local_batch_size : ( self . rank + 1 ) * local_batch_size ] ) <nl> - <nl> + step_model ( <nl> + ddp_model . module , <nl> + input [ self . rank : ( self . rank + 1 ) ] , <nl> + target [ self . rank : ( self . rank + 1 ) ] ) <nl> for i , j in zip ( model . parameters ( ) , ddp_model . parameters ( ) ) : <nl> self . assertNotEqual ( i . grad , j . grad ) <nl> else : <nl> - # DDP training , DDP scatters subsets of input_cpu to nodes / GPUs <nl> - step_model ( ddp_model , <nl> - input [ self . rank * local_batch_size : ( self . rank + 1 ) * local_batch_size ] , <nl> - target [ self . rank * local_batch_size : ( self . rank + 1 ) * local_batch_size ] ) <nl> - <nl> + step_model ( <nl> + ddp_model , <nl> + input [ self . rank : ( self . rank + 1 ) ] , <nl> + target [ self . rank : ( self . rank + 1 ) ] ) <nl> for i , j in zip ( model . parameters ( ) , ddp_model . parameters ( ) ) : <nl> self . assertEqual ( i . grad , j . grad ) <nl> <nl> | Fix DistributedDataParallelTest . test_accumulate_gradients ( ) | pytorch/pytorch | a0e5240afc95b90fd9ff4deb898e22082af119e6 | 2019-05-10T06:27:18Z |
mmm a / src / mat_pixel . cpp <nl> ppp b / src / mat_pixel . cpp <nl> Mat Mat : : from_pixels_resize ( const unsigned char * pixels , int type , int w , int h , <nl> <nl> if ( type_from = = PIXEL_RGB | | type_from = = PIXEL_BGR ) <nl> { <nl> - unsigned char * dst = new unsigned char [ target_width * target_height * 3 ] ; <nl> + Mat dst ( target_width , target_height , ( size_t ) 3u , 3 ) ; <nl> <nl> resize_bilinear_c3 ( pixels , w , h , dst , target_width , target_height ) ; <nl> <nl> m = Mat : : from_pixels ( dst , type , target_width , target_height , allocator ) ; <nl> - <nl> - delete [ ] dst ; <nl> } <nl> else if ( type_from = = PIXEL_GRAY ) <nl> { <nl> - unsigned char * dst = new unsigned char [ target_width * target_height ] ; <nl> + Mat dst ( target_width , target_height , ( size_t ) 1u , 1 ) ; <nl> <nl> resize_bilinear_c1 ( pixels , w , h , dst , target_width , target_height ) ; <nl> <nl> m = Mat : : from_pixels ( dst , type , target_width , target_height , allocator ) ; <nl> - <nl> - delete [ ] dst ; <nl> } <nl> else if ( type_from = = PIXEL_RGBA ) <nl> { <nl> - unsigned char * dst = new unsigned char [ target_width * target_height * 4 ] ; <nl> + Mat dst ( target_width , target_height , ( size_t ) 4u , 4 ) ; <nl> <nl> resize_bilinear_c4 ( pixels , w , h , dst , target_width , target_height ) ; <nl> <nl> m = Mat : : from_pixels ( dst , type , target_width , target_height , allocator ) ; <nl> - <nl> - delete [ ] dst ; <nl> } <nl> <nl> return m ; <nl> void Mat : : to_pixels_resize ( unsigned char * pixels , int type , int target_width , in <nl> <nl> if ( type_to = = PIXEL_RGB | | type_to = = PIXEL_BGR ) <nl> { <nl> - unsigned char * src = new unsigned char [ w * h * 3 ] ; <nl> + Mat src ( target_width , target_height , ( size_t ) 3u , 3 ) ; <nl> <nl> to_pixels ( src , type ) ; <nl> <nl> resize_bilinear_c3 ( src , w , h , pixels , target_width , target_height ) ; <nl> - <nl> - delete [ ] src ; <nl> } <nl> else if ( type_to = = PIXEL_GRAY ) <nl> { <nl> - unsigned char * src = new unsigned char [ w * h ] ; <nl> + Mat src ( target_width , target_height , ( size_t ) 1u , 1 ) ; <nl> <nl> to_pixels ( src , type ) ; <nl> <nl> resize_bilinear_c1 ( src , w , h , pixels , target_width , target_height ) ; <nl> - <nl> - delete [ ] src ; <nl> } <nl> else if ( type_to = = PIXEL_RGBA ) <nl> { <nl> - unsigned char * src = new unsigned char [ w * h * 4 ] ; <nl> + Mat src ( target_width , target_height , ( size_t ) 4u , 4 ) ; <nl> <nl> to_pixels ( src , type ) ; <nl> <nl> resize_bilinear_c4 ( src , w , h , pixels , target_width , target_height ) ; <nl> - <nl> - delete [ ] src ; <nl> } <nl> } <nl> # endif / / NCNN_PIXEL <nl> | packed mat is handy | Tencent/ncnn | 721abe91a82ab773c2672d96bd6aee00ed3695c4 | 2019-06-06T14:16:00Z |
mmm a / atom / browser / api / atom_api_url_request . cc <nl> ppp b / atom / browser / api / atom_api_url_request . cc <nl> void URLRequest : : OnAuthenticationRequired ( <nl> } <nl> <nl> void URLRequest : : OnResponseStarted ( <nl> - scoped_refptr < const net : : HttpResponseHeaders > response_headers ) { <nl> + scoped_refptr < net : : HttpResponseHeaders > response_headers ) { <nl> if ( request_state_ . Canceled ( ) | | <nl> request_state_ . Failed ( ) | | <nl> request_state_ . Closed ( ) ) { <nl> std : : string URLRequest : : StatusMessage ( ) const { <nl> return result ; <nl> } <nl> <nl> - scoped_refptr < const net : : HttpResponseHeaders > <nl> + scoped_refptr < net : : HttpResponseHeaders > <nl> URLRequest : : RawResponseHeaders ( ) const { <nl> return response_headers_ ; <nl> } <nl> mmm a / atom / browser / api / atom_api_url_request . h <nl> ppp b / atom / browser / api / atom_api_url_request . h <nl> class URLRequest : public mate : : EventEmitter < URLRequest > { <nl> void OnAuthenticationRequired ( <nl> scoped_refptr < const net : : AuthChallengeInfo > auth_info ) ; <nl> void OnResponseStarted ( <nl> - scoped_refptr < const net : : HttpResponseHeaders > response_headers ) ; <nl> + scoped_refptr < net : : HttpResponseHeaders > response_headers ) ; <nl> void OnResponseData ( scoped_refptr < const net : : IOBufferWithSize > data ) ; <nl> void OnResponseCompleted ( ) ; <nl> void OnRequestError ( const std : : string & error ) ; <nl> class URLRequest : public mate : : EventEmitter < URLRequest > { <nl> bool CanReadHeaders ( ) const ; <nl> int StatusCode ( ) const ; <nl> std : : string StatusMessage ( ) const ; <nl> - scoped_refptr < const net : : HttpResponseHeaders > RawResponseHeaders ( ) const ; <nl> + scoped_refptr < net : : HttpResponseHeaders > RawResponseHeaders ( ) const ; <nl> uint32_t ResponseHttpVersionMajor ( ) const ; <nl> uint32_t ResponseHttpVersionMinor ( ) const ; <nl> <nl> class URLRequest : public mate : : EventEmitter < URLRequest > { <nl> <nl> / / Used to implement pin / unpin . <nl> v8 : : Global < v8 : : Object > wrapper_ ; <nl> - scoped_refptr < const net : : HttpResponseHeaders > response_headers_ ; <nl> + scoped_refptr < net : : HttpResponseHeaders > response_headers_ ; <nl> base : : WeakPtrFactory < URLRequest > weak_ptr_factory_ ; <nl> <nl> <nl> mmm a / atom / browser / net / atom_url_request . cc <nl> ppp b / atom / browser / net / atom_url_request . cc <nl> void AtomURLRequest : : OnResponseStarted ( net : : URLRequest * request ) { <nl> DCHECK_CURRENTLY_ON ( content : : BrowserThread : : IO ) ; <nl> DCHECK_EQ ( request , request_ . get ( ) ) ; <nl> <nl> - scoped_refptr < const net : : HttpResponseHeaders > response_headers = <nl> + scoped_refptr < net : : HttpResponseHeaders > response_headers = <nl> request - > response_headers ( ) ; <nl> const auto & status = request_ - > status ( ) ; <nl> if ( status . is_success ( ) ) { <nl> void AtomURLRequest : : InformDelegateAuthenticationRequired ( <nl> } <nl> <nl> void AtomURLRequest : : InformDelegateResponseStarted ( <nl> - scoped_refptr < const net : : HttpResponseHeaders > response_headers ) const { <nl> + scoped_refptr < net : : HttpResponseHeaders > response_headers ) const { <nl> DCHECK_CURRENTLY_ON ( content : : BrowserThread : : UI ) ; <nl> if ( delegate_ ) <nl> delegate_ - > OnResponseStarted ( response_headers ) ; <nl> mmm a / atom / browser / net / atom_url_request . h <nl> ppp b / atom / browser / net / atom_url_request . h <nl> class AtomURLRequest : public base : : RefCountedThreadSafe < AtomURLRequest > , <nl> void InformDelegateAuthenticationRequired ( <nl> scoped_refptr < net : : AuthChallengeInfo > auth_info ) const ; <nl> void InformDelegateResponseStarted ( <nl> - scoped_refptr < const net : : HttpResponseHeaders > ) const ; <nl> + scoped_refptr < net : : HttpResponseHeaders > ) const ; <nl> void InformDelegateResponseData ( <nl> scoped_refptr < net : : IOBufferWithSize > data ) const ; <nl> void InformDelegateResponseCompleted ( ) const ; <nl> mmm a / atom / common / native_mate_converters / net_converter . cc <nl> ppp b / atom / common / native_mate_converters / net_converter . cc <nl> v8 : : Local < v8 : : Value > Converter < scoped_refptr < net : : X509Certificate > > : : ToV8 ( <nl> <nl> / / static <nl> v8 : : Local < v8 : : Value > <nl> - Converter < scoped_refptr < const net : : HttpResponseHeaders > > : : ToV8 ( <nl> + Converter < scoped_refptr < net : : HttpResponseHeaders > > : : ToV8 ( <nl> v8 : : Isolate * isolate , <nl> - scoped_refptr < const net : : HttpResponseHeaders > headers ) { <nl> + scoped_refptr < net : : HttpResponseHeaders > headers ) { <nl> base : : DictionaryValue response_headers ; <nl> if ( headers ) { <nl> size_t iter = 0 ; <nl> mmm a / atom / common / native_mate_converters / net_converter . h <nl> ppp b / atom / common / native_mate_converters / net_converter . h <nl> struct Converter < scoped_refptr < net : : X509Certificate > > { <nl> } ; <nl> <nl> template < > <nl> - struct Converter < scoped_refptr < const net : : HttpResponseHeaders > > { <nl> + struct Converter < scoped_refptr < net : : HttpResponseHeaders > > { <nl> static v8 : : Local < v8 : : Value > ToV8 ( v8 : : Isolate * isolate , <nl> - scoped_refptr < const net : : HttpResponseHeaders > headers ) ; <nl> + scoped_refptr < net : : HttpResponseHeaders > headers ) ; <nl> } ; <nl> <nl> } / / namespace mate <nl> | Fixing build : removing constness on net : : HttpResponseHeaders as otherwise we would need a change in libchromiumcontent . | electron/electron | de29f2dde5ed6bfe75a13ee304beaf3cc1b8d763 | 2016-10-13T15:51:19Z |
mmm a / . circleci / config . yml <nl> ppp b / . circleci / config . yml <nl> <nl> build - steps : & build - steps <nl> steps : <nl> - checkout <nl> + - run : <nl> + name : Install Node . js 10 on MacOS <nl> + command : | <nl> + if [ " $ INSTALL_MACOS_NODE " = = " true " ] ; then <nl> + echo ' Installing Node . js 10 for MacOS ' <nl> + brew update <nl> + brew install node @ 10 <nl> + fi <nl> - run : <nl> name : Check for release <nl> command : | <nl> build - steps : & build - steps <nl> <nl> build - defaults : & build - defaults <nl> docker : <nl> - - image : electronbuilds / electron : 0 . 0 . 7 <nl> + - image : electronbuilds / electron : 0 . 0 . 8 <nl> < < : * build - steps <nl> <nl> version : 2 <nl> jobs : <nl> environment : <nl> TARGET_ARCH : x64 <nl> RUN_TESTS : true <nl> + INSTALL_MACOS_NODE : true <nl> macos : <nl> - xcode : " 9 . 0 " <nl> + xcode : " 8 . 3 . 3 " <nl> < < : * build - steps <nl> <nl> electron - osx - x64 - release - nightly : <nl> environment : <nl> TARGET_ARCH : x64 <nl> RUN_RELEASE_BUILD : true <nl> + INSTALL_MACOS_NODE : true <nl> macos : <nl> - xcode : " 9 . 0 " <nl> + xcode : " 8 . 3 . 3 " <nl> < < : * build - steps <nl> <nl> electron - mas - x64 : <nl> jobs : <nl> TARGET_ARCH : x64 <nl> MAS_BUILD : 1 <nl> RUN_TESTS : true <nl> + INSTALL_MACOS_NODE : true <nl> macos : <nl> - xcode : " 9 . 0 " <nl> + xcode : " 8 . 3 . 3 " <nl> < < : * build - steps <nl> <nl> electron - mas - x64 - release - nightly : <nl> jobs : <nl> TARGET_ARCH : x64 <nl> MAS_BUILD : 1 <nl> RUN_RELEASE_BUILD : true <nl> + INSTALL_MACOS_NODE : true <nl> macos : <nl> - xcode : " 9 . 0 " <nl> + xcode : " 8 . 3 . 3 " <nl> < < : * build - steps <nl> <nl> <nl> mmm a / Dockerfile <nl> ppp b / Dockerfile <nl> ENV HOME = / home <nl> RUN chmod a + rwx / home <nl> <nl> # Install node . js <nl> - RUN curl - sL https : / / deb . nodesource . com / setup_8 . x | bash - <nl> - RUN apt - get update & & apt - get install - y nodejs <nl> + RUN curl - sL https : / / deb . nodesource . com / setup_10 . x | bash - <nl> + RUN apt - get install - y nodejs <nl> <nl> # Install wget used by crash reporter <nl> RUN apt - get install - y wget <nl> mmm a / Dockerfile . circleci <nl> ppp b / Dockerfile . circleci <nl> FROM electronbuilds / libchromiumcontent : 0 . 0 . 4 <nl> USER root <nl> <nl> # Install node . js <nl> - RUN curl - sL https : / / deb . nodesource . com / setup_8 . x | bash - <nl> - RUN apt - get update & & apt - get install - y nodejs <nl> + RUN curl - sL https : / / deb . nodesource . com / setup_10 . x | bash - <nl> + RUN apt - get install - y nodejs <nl> <nl> # Install wget used by crash reporter <nl> RUN apt - get install - y wget <nl> new file mode 100644 <nl> index 000000000000 . . cb0c8a67db55 <nl> mmm / dev / null <nl> ppp b / appveyor . yml <nl> <nl> + version : 1 . 0 . { build } <nl> + build_cloud : electron - 16 <nl> + image : electron - 16 - vs2017 <nl> + environment : <nl> + DISABLE_CRASH_REPORTER_TESTS : true <nl> + matrix : <nl> + - TARGET_ARCH : ia32 <nl> + - TARGET_ARCH : x64 <nl> + build_script : <nl> + - ps : > - <nl> + if ( ( $ env : APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME - split " / " ) [ 0 ] - eq ( $ env : APPVEYOR_REPO_NAME - split " / " ) [ 0 ] ) { <nl> + Write - warning " Skipping PR build for branch " ; Exit - AppveyorBuild <nl> + <nl> + } else { <nl> + Add - Path " $ env : ProgramFiles ( x86 ) \ Windows Kits \ 10 \ Debuggers \ x64 " <nl> + <nl> + $ env : path = " $ env : ProgramFiles ( x86 ) \ Windows Kits \ 10 \ Debuggers \ x64 ; $ env : path " <nl> + <nl> + $ Message = ( git log - - format = % B - n 1 HEAD ) | Out - String <nl> + <nl> + if ( ( Test - Path Env : \ RUN_RELEASE_BUILD ) ) { <nl> + $ env : ELECTRON_RELEASE = ' 1 ' <nl> + Write - Output " release build triggered from api " <nl> + } <nl> + <nl> + if ( ( Test - Path Env : \ ELECTRON_RELEASE ) ) { <nl> + Write - Output " Running release build " <nl> + python script \ bootstrap . py - - target_arch = $ env : TARGET_ARCH <nl> + python script \ build . py - c R <nl> + python script \ create - dist . py <nl> + } else { <nl> + Write - Output " Running debug build " <nl> + python script \ bootstrap . py - - target_arch = $ env : TARGET_ARCH - - dev <nl> + python script \ build . py - c D <nl> + } <nl> + if ( $ ? - ne ' True ' ) { <nl> + throw " Build failed with exit code $ ? " <nl> + } else { <nl> + " Build succeeded . " <nl> + } <nl> + } <nl> + <nl> + test_script : <nl> + - ps : > - <nl> + if ( Test - Path Env : \ ELECTRON_RELEASE ) { <nl> + Write - Output " Skipping tests for release build " <nl> + } else { <nl> + Write - Output " Running tests for debug build " <nl> + python script \ test . py - - ci <nl> + if ( $ LASTEXITCODE - ne ' 0 ' ) { <nl> + throw " Tests failed with exit code $ LASTEXITCODE " <nl> + } else { <nl> + Write - Output " Tests succeeded . " <nl> + } <nl> + python script \ verify - ffmpeg . py <nl> + <nl> + if ( $ LASTEXITCODE - ne ' 0 ' ) { <nl> + throw " Verify ffmpeg failed with exit code $ LASTEXITCODE " <nl> + } else { <nl> + " Verify ffmpeg succeeded . " <nl> + } <nl> + } <nl> + artifacts : <nl> + - path : out <nl> + name : out <nl> mmm a / atom / app / atom_content_client . cc <nl> ppp b / atom / app / atom_content_client . cc <nl> <nl> # include " content / public / common / user_agent . h " <nl> # include " media / media_features . h " <nl> # include " ppapi / shared_impl / ppapi_permissions . h " <nl> - # include " third_party / widevine / cdm / stub / widevine_cdm_version . h " <nl> # include " ui / base / l10n / l10n_util . h " <nl> # include " url / url_constants . h " <nl> <nl> content : : PepperPluginInfo CreateWidevineCdmInfo ( const base : : FilePath & path , <nl> kWidevineCdmPluginMimeType , kWidevineCdmPluginExtension , <nl> kWidevineCdmPluginMimeTypeDescription ) ; <nl> <nl> - / / Add the supported codecs as if they came from the component manifest . <nl> - std : : vector < std : : string > codecs ; <nl> - codecs . push_back ( kCdmSupportedCodecVp8 ) ; <nl> - codecs . push_back ( kCdmSupportedCodecVp9 ) ; <nl> - # if BUILDFLAG ( USE_PROPRIETARY_CODECS ) <nl> - codecs . push_back ( kCdmSupportedCodecAvc1 ) ; <nl> - # endif / / BUILDFLAG ( USE_PROPRIETARY_CODECS ) <nl> - std : : string codec_string = base : : JoinString ( <nl> - codecs , std : : string ( 1 , kCdmSupportedCodecsValueDelimiter ) ) ; <nl> - widevine_cdm_mime_type . additional_param_names . push_back ( <nl> - base : : ASCIIToUTF16 ( kCdmSupportedCodecsParamName ) ) ; <nl> - widevine_cdm_mime_type . additional_param_values . push_back ( <nl> - base : : ASCIIToUTF16 ( codec_string ) ) ; <nl> - <nl> widevine_cdm . mime_types . push_back ( widevine_cdm_mime_type ) ; <nl> widevine_cdm . permissions = kWidevineCdmPluginPermissions ; <nl> <nl> void AtomContentClient : : AddPepperPlugins ( <nl> # endif / / defined ( ENABLE_PDF_VIEWER ) <nl> } <nl> <nl> + void AtomContentClient : : AddContentDecryptionModules ( <nl> + std : : vector < content : : CdmInfo > * cdms , <nl> + std : : vector < media : : CdmHostFilePath > * cdm_host_file_paths ) { <nl> + # if defined ( WIDEVINE_CDM_AVAILABLE ) & & BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> + auto command_line = base : : CommandLine : : ForCurrentProcess ( ) ; <nl> + base : : FilePath widevine_cdm_path = <nl> + command_line - > GetSwitchValuePath ( switches : : kWidevineCdmPath ) ; <nl> + if ( widevine_cdm_path . empty ( ) ) <nl> + return ; <nl> + <nl> + if ( ! base : : PathExists ( widevine_cdm_path ) ) <nl> + return ; <nl> + <nl> + auto widevine_cdm_version = <nl> + command_line - > GetSwitchValueASCII ( switches : : kWidevineCdmVersion ) ; <nl> + if ( widevine_cdm_version . empty ( ) ) <nl> + return ; <nl> + <nl> + std : : vector < media : : VideoCodec > supported_video_codecs ; <nl> + supported_video_codecs . push_back ( media : : VideoCodec : : kCodecVP8 ) ; <nl> + supported_video_codecs . push_back ( media : : VideoCodec : : kCodecVP9 ) ; <nl> + # if BUILDFLAG ( USE_PROPRIETARY_CODECS ) <nl> + supported_video_codecs . push_back ( media : : VideoCodec : : kCodecH264 ) ; <nl> + # endif / / BUILDFLAG ( USE_PROPRIETARY_CODECS ) <nl> + content : : CdmRegistry : : GetInstance ( ) - > RegisterCdm ( <nl> + content : : CdmInfo ( kWidevineCdmDisplayName , kWidevineCdmGuid , <nl> + base : : Version ( widevine_cdm_version ) , widevine_cdm_path , <nl> + kWidevineCdmFileSystemId , supported_video_codecs , false , <nl> + kWidevineKeySystem , false ) ) ; <nl> + # endif / / defined ( WIDEVINE_CDM_AVAILABLE ) & & BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> + } <nl> + <nl> } / / namespace atom <nl> mmm a / atom / app / atom_content_client . h <nl> ppp b / atom / app / atom_content_client . h <nl> class AtomContentClient : public brightray : : ContentClient { <nl> void AddAdditionalSchemes ( Schemes * schemes ) override ; <nl> void AddPepperPlugins ( <nl> std : : vector < content : : PepperPluginInfo > * plugins ) override ; <nl> + void AddContentDecryptionModules ( <nl> + std : : vector < content : : CdmInfo > * cdms , <nl> + std : : vector < media : : CdmHostFilePath > * cdm_host_file_paths ) override ; <nl> <nl> private : <nl> DISALLOW_COPY_AND_ASSIGN ( AtomContentClient ) ; <nl> mmm a / atom / app / atom_main_delegate . cc <nl> ppp b / atom / app / atom_main_delegate . cc <nl> <nl> # include " chrome / common / chrome_paths . h " <nl> # include " content / public / common / content_switches . h " <nl> # include " ipc / ipc_features . h " <nl> + # include " services / service_manager / sandbox / switches . h " <nl> # include " ui / base / l10n / l10n_util . h " <nl> # include " ui / base / resource / resource_bundle . h " <nl> <nl> void AtomMainDelegate : : PreSandboxStartup ( ) { <nl> if ( command_line - > HasSwitch ( switches : : kEnableSandbox ) ) { <nl> / / Disable setuid sandbox since it is not longer required on <nl> / / linux ( namespace sandbox is available on most distros ) . <nl> - command_line - > AppendSwitch ( : : switches : : kDisableSetuidSandbox ) ; <nl> + command_line - > AppendSwitch ( <nl> + service_manager : : switches : : kDisableSetuidSandbox ) ; <nl> } else { <nl> / / Disable renderer sandbox for most of node ' s functions . <nl> command_line - > AppendSwitch ( : : switches : : kNoSandbox ) ; <nl> mmm a / atom / app / node_main . cc <nl> ppp b / atom / app / node_main . cc <nl> int NodeMain ( int argc , char * argv [ ] ) { <nl> feature_list - > InitializeFromCommandLine ( " " , " " ) ; <nl> base : : FeatureList : : SetInstance ( std : : move ( feature_list ) ) ; <nl> <nl> - gin : : V8Initializer : : LoadV8Snapshot ( ) ; <nl> + gin : : V8Initializer : : LoadV8Snapshot ( <nl> + gin : : V8Initializer : : V8SnapshotFileType : : kWithAdditionalContext ) ; <nl> gin : : V8Initializer : : LoadV8Natives ( ) ; <nl> <nl> / / V8 requires a task scheduler apparently <nl> mmm a / atom / browser / api / atom_api_app . cc <nl> ppp b / atom / browser / api / atom_api_app . cc <nl> <nl> # include " atom / common / native_mate_converters / gurl_converter . h " <nl> # include " atom / common / native_mate_converters / image_converter . h " <nl> # include " atom / common / native_mate_converters / net_converter . h " <nl> + # include " atom / common / native_mate_converters / network_converter . h " <nl> # include " atom / common / native_mate_converters / value_converter . h " <nl> # include " atom / common / node_includes . h " <nl> # include " atom / common / options_switches . h " <nl> <nl> # include " native_mate / object_template_builder . h " <nl> # include " net / ssl / client_cert_identity . h " <nl> # include " net / ssl / ssl_cert_request_info . h " <nl> + # include " services / network / public / cpp / network_switches . h " <nl> # include " ui / base / l10n / l10n_util . h " <nl> # include " ui / gfx / image / image . h " <nl> <nl> bool App : : CanCreateWindow ( <nl> WindowOpenDisposition disposition , <nl> const blink : : mojom : : WindowFeatures & features , <nl> const std : : vector < std : : string > & additional_features , <nl> - const scoped_refptr < content : : ResourceRequestBody > & body , <nl> + const scoped_refptr < network : : ResourceRequestBody > & body , <nl> bool user_gesture , <nl> bool opener_suppressed , <nl> bool * no_javascript_access ) { <nl> void AppendSwitch ( const std : : string & switch_string , mate : : Arguments * args ) { <nl> <nl> if ( base : : EndsWith ( switch_string , " - path " , <nl> base : : CompareCase : : INSENSITIVE_ASCII ) | | <nl> - switch_string = = switches : : kLogNetLog ) { <nl> + switch_string = = network : : switches : : kLogNetLog ) { <nl> base : : FilePath path ; <nl> args - > GetNext ( & path ) ; <nl> command_line - > AppendSwitchPath ( switch_string , path ) ; <nl> mmm a / atom / browser / api / atom_api_app . h <nl> ppp b / atom / browser / api / atom_api_app . h <nl> class App : public AtomBrowserClient : : Delegate , <nl> WindowOpenDisposition disposition , <nl> const blink : : mojom : : WindowFeatures & features , <nl> const std : : vector < std : : string > & additional_features , <nl> - const scoped_refptr < content : : ResourceRequestBody > & body , <nl> + const scoped_refptr < network : : ResourceRequestBody > & body , <nl> bool user_gesture , <nl> bool opener_suppressed , <nl> bool * no_javascript_access ) override ; <nl> mmm a / atom / browser / api / atom_api_browser_window . cc <nl> ppp b / atom / browser / api / atom_api_browser_window . cc <nl> void BrowserWindow : : BeforeUnloadDialogCancelled ( ) { <nl> window_unresponsive_closure_ . Cancel ( ) ; <nl> } <nl> <nl> - void BrowserWindow : : OnRendererUnresponsive ( content : : RenderWidgetHost * ) { <nl> + void BrowserWindow : : OnRendererUnresponsive ( content : : RenderProcessHost * ) { <nl> / / Schedule the unresponsive shortly later , since we may receive the <nl> / / responsive event soon . This could happen after the whole application had <nl> / / blocked for a while . <nl> mmm a / atom / browser / api / atom_api_browser_window . h <nl> ppp b / atom / browser / api / atom_api_browser_window . h <nl> class BrowserWindow : public TopLevelWindow , <nl> void RenderViewCreated ( content : : RenderViewHost * render_view_host ) override ; <nl> void DidFirstVisuallyNonEmptyPaint ( ) override ; <nl> void BeforeUnloadDialogCancelled ( ) override ; <nl> - void OnRendererUnresponsive ( content : : RenderWidgetHost * ) override ; <nl> + void OnRendererUnresponsive ( content : : RenderProcessHost * ) override ; <nl> bool OnMessageReceived ( const IPC : : Message & message , <nl> content : : RenderFrameHost * rfh ) override ; <nl> <nl> mmm a / atom / browser / api / atom_api_cookies . cc <nl> ppp b / atom / browser / api / atom_api_cookies . cc <nl> <nl> # include " content / public / browser / browser_thread . h " <nl> # include " native_mate / dictionary . h " <nl> # include " native_mate / object_template_builder . h " <nl> - # include " net / cookies / cookie_monster . h " <nl> + # include " net / cookies / canonical_cookie . h " <nl> # include " net / cookies / cookie_store . h " <nl> # include " net / cookies / cookie_util . h " <nl> # include " net / url_request / url_request_context . h " <nl> struct Converter < net : : CanonicalCookie > { <nl> } ; <nl> <nl> template < > <nl> - struct Converter < net : : CookieStore : : ChangeCause > { <nl> + struct Converter < net : : CookieChangeCause > { <nl> static v8 : : Local < v8 : : Value > ToV8 ( v8 : : Isolate * isolate , <nl> - const net : : CookieStore : : ChangeCause & val ) { <nl> + const net : : CookieChangeCause & val ) { <nl> switch ( val ) { <nl> - case net : : CookieStore : : ChangeCause : : INSERTED : <nl> - case net : : CookieStore : : ChangeCause : : EXPLICIT : <nl> - case net : : CookieStore : : ChangeCause : : EXPLICIT_DELETE_BETWEEN : <nl> - case net : : CookieStore : : ChangeCause : : EXPLICIT_DELETE_PREDICATE : <nl> - case net : : CookieStore : : ChangeCause : : EXPLICIT_DELETE_SINGLE : <nl> - case net : : CookieStore : : ChangeCause : : EXPLICIT_DELETE_CANONICAL : <nl> + case net : : CookieChangeCause : : INSERTED : <nl> + case net : : CookieChangeCause : : EXPLICIT : <nl> return mate : : StringToV8 ( isolate , " explicit " ) ; <nl> - case net : : CookieStore : : ChangeCause : : OVERWRITE : <nl> + case net : : CookieChangeCause : : OVERWRITE : <nl> return mate : : StringToV8 ( isolate , " overwrite " ) ; <nl> - case net : : CookieStore : : ChangeCause : : EXPIRED : <nl> + case net : : CookieChangeCause : : EXPIRED : <nl> return mate : : StringToV8 ( isolate , " expired " ) ; <nl> - case net : : CookieStore : : ChangeCause : : EVICTED : <nl> + case net : : CookieChangeCause : : EVICTED : <nl> return mate : : StringToV8 ( isolate , " evicted " ) ; <nl> - case net : : CookieStore : : ChangeCause : : EXPIRED_OVERWRITE : <nl> + case net : : CookieChangeCause : : EXPIRED_OVERWRITE : <nl> return mate : : StringToV8 ( isolate , " expired - overwrite " ) ; <nl> default : <nl> return mate : : StringToV8 ( isolate , " unknown " ) ; <nl> void SetCookieOnIO ( scoped_refptr < net : : URLRequestContextGetter > getter , <nl> : base : : Time : : FromDoubleT ( last_access_date ) ; <nl> } <nl> <nl> - GetCookieStore ( getter ) - > SetCookieWithDetailsAsync ( <nl> - GURL ( url ) , name , value , domain , path , creation_time , expiration_time , <nl> - last_access_time , secure , http_only , net : : CookieSameSite : : DEFAULT_MODE , <nl> - net : : COOKIE_PRIORITY_DEFAULT , base : : BindOnce ( OnSetCookie , callback ) ) ; <nl> + std : : unique_ptr < net : : CanonicalCookie > canonical_cookie ( <nl> + net : : CanonicalCookie : : CreateSanitizedCookie ( <nl> + GURL ( url ) , name , value , domain , path , creation_time , expiration_time , <nl> + last_access_time , secure , http_only , <nl> + net : : CookieSameSite : : DEFAULT_MODE , net : : COOKIE_PRIORITY_DEFAULT ) ) ; <nl> + auto completion_callback = base : : BindOnce ( OnSetCookie , callback ) ; <nl> + if ( ! canonical_cookie | | ! canonical_cookie - > IsCanonical ( ) ) { <nl> + std : : move ( completion_callback ) . Run ( false ) ; <nl> + return ; <nl> + } <nl> + if ( url . empty ( ) ) { <nl> + std : : move ( completion_callback ) . Run ( false ) ; <nl> + return ; <nl> + } <nl> + if ( name . empty ( ) ) { <nl> + std : : move ( completion_callback ) . Run ( false ) ; <nl> + return ; <nl> + } <nl> + GetCookieStore ( getter ) - > SetCanonicalCookieAsync ( <nl> + std : : move ( canonical_cookie ) , secure , http_only , <nl> + std : : move ( completion_callback ) ) ; <nl> } <nl> <nl> } / / namespace <nl> mmm a / atom / browser / api / atom_api_debugger . cc <nl> ppp b / atom / browser / api / atom_api_debugger . cc <nl> Debugger : : Debugger ( v8 : : Isolate * isolate , content : : WebContents * web_contents ) <nl> <nl> Debugger : : ~ Debugger ( ) { } <nl> <nl> - void Debugger : : AgentHostClosed ( DevToolsAgentHost * agent_host , <nl> - bool replaced_with_another_client ) { <nl> + void Debugger : : AgentHostClosed ( DevToolsAgentHost * agent_host ) { <nl> std : : string detach_reason = " target closed " ; <nl> - if ( replaced_with_another_client ) <nl> - detach_reason = " replaced with devtools " ; <nl> Emit ( " detach " , detach_reason ) ; <nl> } <nl> <nl> void Debugger : : Detach ( ) { <nl> if ( ! agent_host_ . get ( ) ) <nl> return ; <nl> agent_host_ - > DetachClient ( this ) ; <nl> - AgentHostClosed ( agent_host_ . get ( ) , false ) ; <nl> + AgentHostClosed ( agent_host_ . get ( ) ) ; <nl> agent_host_ = nullptr ; <nl> } <nl> <nl> mmm a / atom / browser / api / atom_api_debugger . h <nl> ppp b / atom / browser / api / atom_api_debugger . h <nl> class Debugger : public mate : : TrackableObject < Debugger > , <nl> ~ Debugger ( ) override ; <nl> <nl> / / content : : DevToolsAgentHostClient : <nl> - void AgentHostClosed ( content : : DevToolsAgentHost * agent_host , <nl> - bool replaced_with_another_client ) override ; <nl> + void AgentHostClosed ( content : : DevToolsAgentHost * agent_host ) override ; <nl> void DispatchProtocolMessage ( content : : DevToolsAgentHost * agent_host , <nl> const std : : string & message ) override ; <nl> <nl> mmm a / atom / browser / api / atom_api_desktop_capturer . cc <nl> ppp b / atom / browser / api / atom_api_desktop_capturer . cc <nl> using base : : PlatformThreadRef ; <nl> # include " atom / common / native_mate_converters / gfx_converter . h " <nl> # include " base / strings / string_number_conversions . h " <nl> # include " base / strings / utf_string_conversions . h " <nl> + # include " base / task_scheduler / post_task . h " <nl> + # include " base / threading / thread_task_runner_handle . h " <nl> # include " chrome / browser / media / desktop_media_list . h " <nl> + # include " content / public / browser / browser_thread . h " <nl> # include " content / public / browser / desktop_capture . h " <nl> # include " native_mate / dictionary . h " <nl> # include " third_party / webrtc / modules / desktop_capture / desktop_capture_options . h " <nl> struct Converter < atom : : api : : DesktopCapturer : : Source > { <nl> <nl> } / / namespace mate <nl> <nl> - namespace atom { <nl> - <nl> - namespace api { <nl> + namespace { <nl> <nl> - DesktopCapturer : : DesktopCapturer ( v8 : : Isolate * isolate ) { <nl> - Init ( isolate ) ; <nl> + void EmitFinished ( <nl> + const std : : vector < atom : : api : : DesktopCapturer : : Source > & sources , <nl> + atom : : api : : DesktopCapturer * cap ) { <nl> + cap - > Emit ( " finished " , sources ) ; <nl> } <nl> <nl> - DesktopCapturer : : ~ DesktopCapturer ( ) { } <nl> - <nl> - void DesktopCapturer : : StartHandling ( bool capture_window , <nl> - bool capture_screen , <nl> - const gfx : : Size & thumbnail_size ) { <nl> - webrtc : : DesktopCaptureOptions options = <nl> - content : : CreateDesktopCaptureOptions ( ) ; <nl> + void StartHandlingTask ( bool capture_window , <nl> + bool capture_screen , <nl> + const gfx : : Size & thumbnail_size , <nl> + atom : : api : : DesktopCapturer * cap ) { <nl> # if defined ( OS_WIN ) <nl> - using_directx_capturer_ = options . allow_directx_capturer ( ) ; <nl> + cap - > using_directx_capturer_ = <nl> + content : : desktop_capture : : CreateDesktopCaptureOptions ( ) <nl> + . allow_directx_capturer ( ) ; <nl> # endif / / defined ( OS_WIN ) <nl> - <nl> std : : unique_ptr < webrtc : : DesktopCapturer > screen_capturer ( <nl> - capture_screen ? webrtc : : DesktopCapturer : : CreateScreenCapturer ( options ) <nl> + capture_screen ? content : : desktop_capture : : CreateScreenCapturer ( ) <nl> : nullptr ) ; <nl> std : : unique_ptr < webrtc : : DesktopCapturer > window_capturer ( <nl> - capture_window ? webrtc : : DesktopCapturer : : CreateWindowCapturer ( options ) <nl> + capture_window ? content : : desktop_capture : : CreateScreenCapturer ( ) <nl> : nullptr ) ; <nl> - media_list_ . reset ( new NativeDesktopMediaList ( std : : move ( screen_capturer ) , <nl> - std : : move ( window_capturer ) ) ) ; <nl> + cap - > media_list_ . reset ( new NativeDesktopMediaList ( <nl> + std : : move ( screen_capturer ) , std : : move ( window_capturer ) ) ) ; <nl> <nl> - media_list_ - > SetThumbnailSize ( thumbnail_size ) ; <nl> - media_list_ - > StartUpdating ( this ) ; <nl> + cap - > media_list_ - > SetThumbnailSize ( thumbnail_size ) ; <nl> + cap - > media_list_ - > StartUpdating ( cap ) ; <nl> } <nl> <nl> - void DesktopCapturer : : OnSourceAdded ( int index ) { } <nl> - <nl> - void DesktopCapturer : : OnSourceRemoved ( int index ) { } <nl> - <nl> - void DesktopCapturer : : OnSourceMoved ( int old_index , int new_index ) { } <nl> - <nl> - void DesktopCapturer : : OnSourceNameChanged ( int index ) { } <nl> - <nl> - void DesktopCapturer : : OnSourceThumbnailChanged ( int index ) { } <nl> - <nl> - bool DesktopCapturer : : OnRefreshFinished ( ) { <nl> - const auto media_list_sources = media_list_ - > GetSources ( ) ; <nl> - std : : vector < DesktopCapturer : : Source > sources ; <nl> + void OnRefreshFinishedTask ( atom : : api : : DesktopCapturer * cap ) { <nl> + const auto media_list_sources = cap - > media_list_ - > GetSources ( ) ; <nl> + std : : vector < atom : : api : : DesktopCapturer : : Source > sources ; <nl> for ( const auto & media_list_source : media_list_sources ) { <nl> sources . emplace_back ( <nl> - DesktopCapturer : : Source { media_list_source , std : : string ( ) } ) ; <nl> + atom : : api : : DesktopCapturer : : Source { media_list_source , std : : string ( ) } ) ; <nl> } <nl> <nl> # if defined ( OS_WIN ) <nl> bool DesktopCapturer : : OnRefreshFinished ( ) { <nl> / / to provide an association between it and desktopCapturer / getUserMedia . <nl> / / This is only required when using the DirectX capturer , otherwise the IDs <nl> / / across the APIs already match . <nl> - if ( using_directx_capturer_ ) { <nl> + if ( cap - > using_directx_capturer_ ) { <nl> std : : vector < std : : string > device_names ; <nl> / / Crucially , this list of device names will be in the same order as <nl> / / | media_list_sources | . <nl> bool DesktopCapturer : : OnRefreshFinished ( ) { <nl> / / supports capturing the entire desktop on Linux . Revisit this if individual <nl> / / screen support is added . <nl> <nl> - Emit ( " finished " , sources ) ; <nl> + content : : BrowserThread : : PostTask ( content : : BrowserThread : : UI , FROM_HERE , <nl> + base : : Bind ( EmitFinished , sources , cap ) ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + namespace atom { <nl> + <nl> + namespace api { <nl> + <nl> + DesktopCapturer : : DesktopCapturer ( v8 : : Isolate * isolate ) { <nl> + Init ( isolate ) ; <nl> + capture_thread_ = base : : CreateSequencedTaskRunnerWithTraits ( <nl> + { base : : WithBaseSyncPrimitives ( ) , base : : MayBlock ( ) , <nl> + base : : TaskPriority : : USER_VISIBLE } ) ; <nl> + } <nl> + <nl> + DesktopCapturer : : ~ DesktopCapturer ( ) { } <nl> + <nl> + void DesktopCapturer : : StartHandling ( bool capture_window , <nl> + bool capture_screen , <nl> + const gfx : : Size & thumbnail_size ) { <nl> + capture_thread_ - > PostTask ( <nl> + FROM_HERE , base : : BindOnce ( StartHandlingTask , capture_window , <nl> + capture_screen , thumbnail_size , this ) ) ; <nl> + } <nl> + <nl> + void DesktopCapturer : : OnSourceAdded ( int index ) { } <nl> + <nl> + void DesktopCapturer : : OnSourceRemoved ( int index ) { } <nl> + <nl> + void DesktopCapturer : : OnSourceMoved ( int old_index , int new_index ) { } <nl> + <nl> + void DesktopCapturer : : OnSourceNameChanged ( int index ) { } <nl> + <nl> + void DesktopCapturer : : OnSourceThumbnailChanged ( int index ) { } <nl> + <nl> + bool DesktopCapturer : : OnRefreshFinished ( ) { <nl> + capture_thread_ - > PostTask ( FROM_HERE , <nl> + base : : BindOnce ( OnRefreshFinishedTask , this ) ) ; <nl> return false ; <nl> } <nl> <nl> mmm a / atom / browser / api / atom_api_desktop_capturer . h <nl> ppp b / atom / browser / api / atom_api_desktop_capturer . h <nl> class DesktopCapturer : public mate : : EventEmitter < DesktopCapturer > , <nl> bool capture_screen , <nl> const gfx : : Size & thumbnail_size ) ; <nl> <nl> + std : : unique_ptr < DesktopMediaList > media_list_ ; <nl> + # if defined ( OS_WIN ) <nl> + bool using_directx_capturer_ ; <nl> + # endif / / defined ( OS_WIN ) <nl> + <nl> protected : <nl> explicit DesktopCapturer ( v8 : : Isolate * isolate ) ; <nl> ~ DesktopCapturer ( ) override ; <nl> class DesktopCapturer : public mate : : EventEmitter < DesktopCapturer > , <nl> bool OnRefreshFinished ( ) override ; <nl> <nl> private : <nl> - std : : unique_ptr < DesktopMediaList > media_list_ ; <nl> - # if defined ( OS_WIN ) <nl> - bool using_directx_capturer_ ; <nl> - # endif / / defined ( OS_WIN ) <nl> + scoped_refptr < base : : SequencedTaskRunner > capture_thread_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( DesktopCapturer ) ; <nl> } ; <nl> mmm a / atom / browser / api / atom_api_download_item . cc <nl> ppp b / atom / browser / api / atom_api_download_item . cc <nl> <nl> namespace mate { <nl> <nl> template < > <nl> - struct Converter < content : : DownloadItem : : DownloadState > { <nl> - static v8 : : Local < v8 : : Value > ToV8 ( v8 : : Isolate * isolate , <nl> - content : : DownloadItem : : DownloadState state ) { <nl> + struct Converter < download : : DownloadItem : : DownloadState > { <nl> + static v8 : : Local < v8 : : Value > ToV8 ( <nl> + v8 : : Isolate * isolate , <nl> + download : : DownloadItem : : DownloadState state ) { <nl> std : : string download_state ; <nl> switch ( state ) { <nl> - case content : : DownloadItem : : IN_PROGRESS : <nl> + case download : : DownloadItem : : IN_PROGRESS : <nl> download_state = " progressing " ; <nl> break ; <nl> - case content : : DownloadItem : : COMPLETE : <nl> + case download : : DownloadItem : : COMPLETE : <nl> download_state = " completed " ; <nl> break ; <nl> - case content : : DownloadItem : : CANCELLED : <nl> + case download : : DownloadItem : : CANCELLED : <nl> download_state = " cancelled " ; <nl> break ; <nl> - case content : : DownloadItem : : INTERRUPTED : <nl> + case download : : DownloadItem : : INTERRUPTED : <nl> download_state = " interrupted " ; <nl> break ; <nl> default : <nl> std : : map < uint32_t , v8 : : Global < v8 : : Object > > g_download_item_objects ; <nl> } / / namespace <nl> <nl> DownloadItem : : DownloadItem ( v8 : : Isolate * isolate , <nl> - content : : DownloadItem * download_item ) <nl> + download : : DownloadItem * download_item ) <nl> : download_item_ ( download_item ) { <nl> download_item_ - > AddObserver ( this ) ; <nl> Init ( isolate ) ; <nl> DownloadItem : : ~ DownloadItem ( ) { <nl> g_download_item_objects . erase ( weak_map_id ( ) ) ; <nl> } <nl> <nl> - void DownloadItem : : OnDownloadUpdated ( content : : DownloadItem * item ) { <nl> + void DownloadItem : : OnDownloadUpdated ( download : : DownloadItem * item ) { <nl> if ( download_item_ - > IsDone ( ) ) { <nl> Emit ( " done " , item - > GetState ( ) ) ; <nl> / / Destroy the item once item is downloaded . <nl> void DownloadItem : : OnDownloadUpdated ( content : : DownloadItem * item ) { <nl> } <nl> } <nl> <nl> - void DownloadItem : : OnDownloadDestroyed ( content : : DownloadItem * download_item ) { <nl> + void DownloadItem : : OnDownloadDestroyed ( download : : DownloadItem * download_item ) { <nl> download_item_ = nullptr ; <nl> / / Destroy the native class immediately when downloadItem is destroyed . <nl> delete this ; <nl> const std : : vector < GURL > & DownloadItem : : GetURLChain ( ) const { <nl> return download_item_ - > GetUrlChain ( ) ; <nl> } <nl> <nl> - content : : DownloadItem : : DownloadState DownloadItem : : GetState ( ) const { <nl> + download : : DownloadItem : : DownloadState DownloadItem : : GetState ( ) const { <nl> return download_item_ - > GetState ( ) ; <nl> } <nl> <nl> void DownloadItem : : BuildPrototype ( v8 : : Isolate * isolate , <nl> <nl> / / static <nl> mate : : Handle < DownloadItem > DownloadItem : : Create ( v8 : : Isolate * isolate , <nl> - content : : DownloadItem * item ) { <nl> + download : : DownloadItem * item ) { <nl> auto * existing = TrackableObject : : FromWrappedClass ( isolate , item ) ; <nl> if ( existing ) <nl> return mate : : CreateHandle ( isolate , static_cast < DownloadItem * > ( existing ) ) ; <nl> mmm a / atom / browser / api / atom_api_download_item . h <nl> ppp b / atom / browser / api / atom_api_download_item . h <nl> <nl> <nl> # include " atom / browser / api / trackable_object . h " <nl> # include " base / files / file_path . h " <nl> - # include " content / public / browser / download_item . h " <nl> + # include " components / download / public / common / download_item . h " <nl> # include " native_mate / handle . h " <nl> # include " url / gurl . h " <nl> <nl> namespace atom { <nl> namespace api { <nl> <nl> class DownloadItem : public mate : : TrackableObject < DownloadItem > , <nl> - public content : : DownloadItem : : Observer { <nl> + public download : : DownloadItem : : Observer { <nl> public : <nl> static mate : : Handle < DownloadItem > Create ( v8 : : Isolate * isolate , <nl> - content : : DownloadItem * item ) ; <nl> + download : : DownloadItem * item ) ; <nl> <nl> static void BuildPrototype ( v8 : : Isolate * isolate , <nl> v8 : : Local < v8 : : FunctionTemplate > prototype ) ; <nl> class DownloadItem : public mate : : TrackableObject < DownloadItem > , <nl> std : : string GetContentDisposition ( ) const ; <nl> const GURL & GetURL ( ) const ; <nl> const std : : vector < GURL > & GetURLChain ( ) const ; <nl> - content : : DownloadItem : : DownloadState GetState ( ) const ; <nl> + download : : DownloadItem : : DownloadState GetState ( ) const ; <nl> bool IsDone ( ) const ; <nl> void SetSavePath ( const base : : FilePath & path ) ; <nl> base : : FilePath GetSavePath ( ) const ; <nl> class DownloadItem : public mate : : TrackableObject < DownloadItem > , <nl> double GetStartTime ( ) const ; <nl> <nl> protected : <nl> - DownloadItem ( v8 : : Isolate * isolate , content : : DownloadItem * download_item ) ; <nl> + DownloadItem ( v8 : : Isolate * isolate , download : : DownloadItem * download_item ) ; <nl> ~ DownloadItem ( ) override ; <nl> <nl> - / / Override content : : DownloadItem : : Observer methods <nl> - void OnDownloadUpdated ( content : : DownloadItem * download ) override ; <nl> - void OnDownloadDestroyed ( content : : DownloadItem * download ) override ; <nl> + / / Override download : : DownloadItem : : Observer methods <nl> + void OnDownloadUpdated ( download : : DownloadItem * download ) override ; <nl> + void OnDownloadDestroyed ( download : : DownloadItem * download ) override ; <nl> <nl> private : <nl> base : : FilePath save_path_ ; <nl> - content : : DownloadItem * download_item_ ; <nl> + download : : DownloadItem * download_item_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( DownloadItem ) ; <nl> } ; <nl> mmm a / atom / browser / api / atom_api_notification . cc <nl> ppp b / atom / browser / api / atom_api_notification . cc <nl> <nl> # include " atom / common / native_mate_converters / gfx_converter . h " <nl> # include " atom / common / native_mate_converters / image_converter . h " <nl> # include " atom / common / native_mate_converters / string16_converter . h " <nl> + # include " base / guid . h " <nl> # include " base / strings / utf_string_conversions . h " <nl> # include " brightray / browser / browser_client . h " <nl> # include " native_mate / constructor . h " <nl> void Notification : : Close ( ) { <nl> void Notification : : Show ( ) { <nl> Close ( ) ; <nl> if ( presenter_ ) { <nl> - notification_ = presenter_ - > CreateNotification ( this ) ; <nl> + notification_ = presenter_ - > CreateNotification ( this , base : : GenerateGUID ( ) ) ; <nl> if ( notification_ ) { <nl> brightray : : NotificationOptions options ; <nl> options . title = title_ ; <nl> mmm a / atom / browser / api / atom_api_power_save_blocker . cc <nl> ppp b / atom / browser / api / atom_api_power_save_blocker . cc <nl> <nl> <nl> # include < string > <nl> <nl> - # include " content / public / browser / browser_thread . h " <nl> + # include " base / task_scheduler / post_task . h " <nl> + # include " base / threading / thread_task_runner_handle . h " <nl> # include " native_mate / dictionary . h " <nl> <nl> # include " atom / common / node_includes . h " <nl> <nl> - using content : : BrowserThread ; <nl> - <nl> namespace mate { <nl> <nl> template < > <nl> - struct Converter < device : : PowerSaveBlocker : : PowerSaveBlockerType > { <nl> + struct Converter < device : : mojom : : WakeLockType > { <nl> static bool FromV8 ( v8 : : Isolate * isolate , <nl> v8 : : Local < v8 : : Value > val , <nl> - device : : PowerSaveBlocker : : PowerSaveBlockerType * out ) { <nl> - using device : : PowerSaveBlocker ; <nl> + device : : mojom : : WakeLockType * out ) { <nl> std : : string type ; <nl> if ( ! ConvertFromV8 ( isolate , val , & type ) ) <nl> return false ; <nl> if ( type = = " prevent - app - suspension " ) <nl> - * out = PowerSaveBlocker : : kPowerSaveBlockPreventAppSuspension ; <nl> + * out = device : : mojom : : WakeLockType : : kPreventAppSuspension ; <nl> else if ( type = = " prevent - display - sleep " ) <nl> - * out = PowerSaveBlocker : : kPowerSaveBlockPreventDisplaySleep ; <nl> + * out = device : : mojom : : WakeLockType : : kPreventDisplaySleep ; <nl> else <nl> return false ; <nl> return true ; <nl> namespace api { <nl> <nl> PowerSaveBlocker : : PowerSaveBlocker ( v8 : : Isolate * isolate ) <nl> : current_blocker_type_ ( <nl> - device : : PowerSaveBlocker : : kPowerSaveBlockPreventAppSuspension ) { <nl> + device : : mojom : : WakeLockType : : kPreventAppSuspension ) { <nl> Init ( isolate ) ; <nl> } <nl> <nl> void PowerSaveBlocker : : UpdatePowerSaveBlocker ( ) { <nl> return ; <nl> } <nl> <nl> - / / | kPowerSaveBlockPreventAppSuspension | keeps system active , but allows <nl> + / / | WakeLockType : : kPreventAppSuspension | keeps system active , but allows <nl> / / screen to be turned off . <nl> - / / | kPowerSaveBlockPreventDisplaySleep | keeps system and screen active , has a <nl> - / / higher precedence level than | kPowerSaveBlockPreventAppSuspension | . <nl> + / / | WakeLockType : : kPreventDisplaySleep | keeps system and screen active , has a <nl> + / / higher precedence level than | WakeLockType : : kPreventAppSuspension | . <nl> / / <nl> / / Only the highest - precedence blocker type takes effect . <nl> - device : : PowerSaveBlocker : : PowerSaveBlockerType new_blocker_type = <nl> - device : : PowerSaveBlocker : : kPowerSaveBlockPreventAppSuspension ; <nl> + device : : mojom : : WakeLockType new_blocker_type = <nl> + device : : mojom : : WakeLockType : : kPreventAppSuspension ; <nl> for ( const auto & element : power_save_blocker_types_ ) { <nl> if ( element . second = = <nl> - device : : PowerSaveBlocker : : kPowerSaveBlockPreventDisplaySleep ) { <nl> + device : : mojom : : WakeLockType : : kPreventDisplaySleep ) { <nl> new_blocker_type = <nl> - device : : PowerSaveBlocker : : kPowerSaveBlockPreventDisplaySleep ; <nl> + device : : mojom : : WakeLockType : : kPreventDisplaySleep ; <nl> break ; <nl> } <nl> } <nl> <nl> if ( ! power_save_blocker_ | | new_blocker_type ! = current_blocker_type_ ) { <nl> auto new_blocker = std : : make_unique < device : : PowerSaveBlocker > ( <nl> - new_blocker_type , device : : PowerSaveBlocker : : kReasonOther , <nl> - ATOM_PRODUCT_NAME , <nl> - BrowserThread : : GetTaskRunnerForThread ( BrowserThread : : UI ) , <nl> - BrowserThread : : GetTaskRunnerForThread ( BrowserThread : : FILE ) ) ; <nl> + new_blocker_type , device : : mojom : : WakeLockReason : : kOther , <nl> + ATOM_PRODUCT_NAME , base : : ThreadTaskRunnerHandle : : Get ( ) , <nl> + / / This task runner may be used by some device service <nl> + / / implementation bits to interface with dbus client code , which in <nl> + / / turn imposes some subtle thread affinity on the clients . We <nl> + / / therefore require a single - thread runner . <nl> + base : : CreateSingleThreadTaskRunnerWithTraits ( <nl> + { base : : MayBlock ( ) , base : : TaskPriority : : BACKGROUND } ) ) ; <nl> power_save_blocker_ . swap ( new_blocker ) ; <nl> current_blocker_type_ = new_blocker_type ; <nl> } <nl> } <nl> <nl> - int PowerSaveBlocker : : Start ( <nl> - device : : PowerSaveBlocker : : PowerSaveBlockerType type ) { <nl> + int PowerSaveBlocker : : Start ( device : : mojom : : WakeLockType type ) { <nl> static int count = 0 ; <nl> power_save_blocker_types_ [ count ] = type ; <nl> UpdatePowerSaveBlocker ( ) ; <nl> mmm a / atom / browser / api / atom_api_power_save_blocker . h <nl> ppp b / atom / browser / api / atom_api_power_save_blocker . h <nl> class PowerSaveBlocker : public mate : : TrackableObject < PowerSaveBlocker > { <nl> <nl> private : <nl> void UpdatePowerSaveBlocker ( ) ; <nl> - int Start ( device : : PowerSaveBlocker : : PowerSaveBlockerType type ) ; <nl> + int Start ( device : : mojom : : WakeLockType type ) ; <nl> bool Stop ( int id ) ; <nl> bool IsStarted ( int id ) ; <nl> <nl> std : : unique_ptr < device : : PowerSaveBlocker > power_save_blocker_ ; <nl> <nl> - / / Currnet blocker type used by | power_save_blocker_ | <nl> - device : : PowerSaveBlocker : : PowerSaveBlockerType current_blocker_type_ ; <nl> + / / Current blocker type used by | power_save_blocker_ | <nl> + device : : mojom : : WakeLockType current_blocker_type_ ; <nl> <nl> / / Map from id to the corresponding blocker type for each request . <nl> - using PowerSaveBlockerTypeMap = <nl> - std : : map < int , device : : PowerSaveBlocker : : PowerSaveBlockerType > ; <nl> - PowerSaveBlockerTypeMap power_save_blocker_types_ ; <nl> + using WakeLockTypeMap = std : : map < int , device : : mojom : : WakeLockType > ; <nl> + WakeLockTypeMap power_save_blocker_types_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( PowerSaveBlocker ) ; <nl> } ; <nl> mmm a / atom / browser / api / atom_api_session . cc <nl> ppp b / atom / browser / api / atom_api_session . cc <nl> <nl> # include " brightray / browser / media / media_device_id_salt . h " <nl> # include " chrome / browser / browser_process . h " <nl> # include " chrome / common / pref_names . h " <nl> + # include " components / download / public / common / download_danger_type . h " <nl> # include " components / prefs / pref_service . h " <nl> - # include " content / common / devtools / devtools_network_conditions . h " <nl> - # include " content / common / devtools / devtools_network_controller . h " <nl> # include " content / public / browser / browser_thread . h " <nl> + # include " content / public / browser / download_item_utils . h " <nl> # include " content / public / browser / download_manager_delegate . h " <nl> # include " content / public / browser / storage_partition . h " <nl> # include " native_mate / dictionary . h " <nl> <nl> # include " net / dns / host_cache . h " <nl> # include " net / http / http_auth_handler_factory . h " <nl> # include " net / http / http_auth_preferences . h " <nl> - # include " net / proxy / proxy_config_service_fixed . h " <nl> - # include " net / proxy / proxy_service . h " <nl> + # include " net / proxy_resolution / proxy_config_service_fixed . h " <nl> + # include " net / proxy_resolution / proxy_service . h " <nl> # include " net / url_request / static_http_user_agent_settings . h " <nl> # include " net / url_request / url_request_context . h " <nl> # include " net / url_request / url_request_context_getter . h " <nl> + # include " services / network / throttling / network_conditions . h " <nl> + # include " services / network / throttling / throttling_controller . h " <nl> # include " ui / base / l10n / l10n_util . h " <nl> <nl> using atom : : api : : Cookies ; <nl> class ResolveProxyHelper { <nl> const GURL & url ) { <nl> DCHECK_CURRENTLY_ON ( content : : BrowserThread : : IO ) ; <nl> <nl> - net : : ProxyService * proxy_service = <nl> - context_getter - > GetURLRequestContext ( ) - > proxy_service ( ) ; <nl> + net : : ProxyResolutionService * proxy_service = <nl> + context_getter - > GetURLRequestContext ( ) - > proxy_resolution_service ( ) ; <nl> net : : CompletionCallback completion_callback = base : : Bind ( <nl> & ResolveProxyHelper : : OnResolveProxyCompleted , base : : Unretained ( this ) ) ; <nl> <nl> class ResolveProxyHelper { <nl> <nl> Session : : ResolveProxyCallback callback_ ; <nl> net : : ProxyInfo proxy_info_ ; <nl> - net : : ProxyService : : PacRequest * pac_req_ ; <nl> + net : : ProxyResolutionService : : Request * pac_req_ ; <nl> scoped_refptr < base : : SingleThreadTaskRunner > original_thread_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( ResolveProxyHelper ) ; <nl> void DoCacheActionInIO ( <nl> void SetProxyInIO ( scoped_refptr < net : : URLRequestContextGetter > getter , <nl> const net : : ProxyConfig & config , <nl> const base : : Closure & callback ) { <nl> - auto * proxy_service = getter - > GetURLRequestContext ( ) - > proxy_service ( ) ; <nl> + auto * proxy_service = <nl> + getter - > GetURLRequestContext ( ) - > proxy_resolution_service ( ) ; <nl> proxy_service - > ResetConfigService ( <nl> base : : WrapUnique ( new net : : ProxyConfigServiceFixed ( config ) ) ) ; <nl> / / Refetches and applies the new pac script if provided . <nl> void AllowNTLMCredentialsForDomainsInIO ( <nl> auto * auth_preferences = const_cast < net : : HttpAuthPreferences * > ( <nl> auth_handler - > http_auth_preferences ( ) ) ; <nl> if ( auth_preferences ) <nl> - auth_preferences - > set_server_whitelist ( domains ) ; <nl> + auth_preferences - > SetServerWhitelist ( domains ) ; <nl> } <nl> } <nl> <nl> void DownloadIdCallback ( content : : DownloadManager * download_manager , <nl> base : : GenerateGUID ( ) , id , path , path , url_chain , GURL ( ) , GURL ( ) , GURL ( ) , <nl> GURL ( ) , mime_type , mime_type , start_time , base : : Time ( ) , etag , <nl> last_modified , offset , length , std : : string ( ) , <nl> - content : : DownloadItem : : INTERRUPTED , <nl> - content : : DownloadDangerType : : DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS , <nl> - content : : DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT , false , base : : Time ( ) , <nl> - false , std : : vector < content : : DownloadItem : : ReceivedSlice > ( ) ) ; <nl> + download : : DownloadItem : : INTERRUPTED , <nl> + download : : DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS , <nl> + download : : DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT , false , base : : Time ( ) , <nl> + false , std : : vector < download : : DownloadItem : : ReceivedSlice > ( ) ) ; <nl> } <nl> <nl> void SetDevToolsNetworkEmulationClientIdInIO ( <nl> Session : : ~ Session ( ) { <nl> } <nl> <nl> void Session : : OnDownloadCreated ( content : : DownloadManager * manager , <nl> - content : : DownloadItem * item ) { <nl> + download : : DownloadItem * item ) { <nl> if ( item - > IsSavePackageDownload ( ) ) <nl> return ; <nl> <nl> v8 : : Locker locker ( isolate ( ) ) ; <nl> v8 : : HandleScope handle_scope ( isolate ( ) ) ; <nl> auto handle = DownloadItem : : Create ( isolate ( ) , item ) ; <nl> - if ( item - > GetState ( ) = = content : : DownloadItem : : INTERRUPTED ) <nl> + if ( item - > GetState ( ) = = download : : DownloadItem : : INTERRUPTED ) <nl> handle - > SetSavePath ( item - > GetTargetFilePath ( ) ) ; <nl> - bool prevent_default = Emit ( " will - download " , handle , item - > GetWebContents ( ) ) ; <nl> + content : : WebContents * web_contents = <nl> + content : : DownloadItemUtils : : GetWebContents ( item ) ; <nl> + bool prevent_default = Emit ( " will - download " , handle , web_contents ) ; <nl> if ( prevent_default ) { <nl> item - > Cancel ( true ) ; <nl> item - > Remove ( ) ; <nl> void Session : : SetDownloadPath ( const base : : FilePath & path ) { <nl> } <nl> <nl> void Session : : EnableNetworkEmulation ( const mate : : Dictionary & options ) { <nl> - std : : unique_ptr < content : : DevToolsNetworkConditions > conditions ; <nl> + std : : unique_ptr < network : : NetworkConditions > conditions ; <nl> bool offline = false ; <nl> double latency = 0 . 0 , download_throughput = 0 . 0 , upload_throughput = 0 . 0 ; <nl> if ( options . Get ( " offline " , & offline ) & & offline ) { <nl> - conditions . reset ( new content : : DevToolsNetworkConditions ( offline ) ) ; <nl> + conditions . reset ( new network : : NetworkConditions ( offline ) ) ; <nl> } else { <nl> options . Get ( " latency " , & latency ) ; <nl> options . Get ( " downloadThroughput " , & download_throughput ) ; <nl> options . Get ( " uploadThroughput " , & upload_throughput ) ; <nl> - conditions . reset ( new content : : DevToolsNetworkConditions ( <nl> + conditions . reset ( new network : : NetworkConditions ( <nl> false , latency , download_throughput , upload_throughput ) ) ; <nl> } <nl> <nl> - content : : DevToolsNetworkController : : SetNetworkState ( <nl> + network : : ThrottlingController : : SetConditions ( <nl> devtools_network_emulation_client_id_ , std : : move ( conditions ) ) ; <nl> BrowserThread : : PostTask ( <nl> BrowserThread : : IO , FROM_HERE , <nl> void Session : : EnableNetworkEmulation ( const mate : : Dictionary & options ) { <nl> } <nl> <nl> void Session : : DisableNetworkEmulation ( ) { <nl> - auto conditions = std : : make_unique < content : : DevToolsNetworkConditions > ( ) ; <nl> - content : : DevToolsNetworkController : : SetNetworkState ( <nl> + auto conditions = std : : make_unique < network : : NetworkConditions > ( ) ; <nl> + network : : ThrottlingController : : SetConditions ( <nl> devtools_network_emulation_client_id_ , std : : move ( conditions ) ) ; <nl> BrowserThread : : PostTask ( <nl> BrowserThread : : IO , FROM_HERE , <nl> mmm a / atom / browser / api / atom_api_session . h <nl> ppp b / atom / browser / api / atom_api_session . h <nl> class Session : public mate : : TrackableObject < Session > , <nl> <nl> / / content : : DownloadManager : : Observer : <nl> void OnDownloadCreated ( content : : DownloadManager * manager , <nl> - content : : DownloadItem * item ) override ; <nl> + download : : DownloadItem * item ) override ; <nl> <nl> private : <nl> / / Cached object . <nl> mmm a / atom / browser / api / atom_api_web_contents . cc <nl> ppp b / atom / browser / api / atom_api_web_contents . cc <nl> <nl> # include " atom / common / native_mate_converters / gurl_converter . h " <nl> # include " atom / common / native_mate_converters / image_converter . h " <nl> # include " atom / common / native_mate_converters / net_converter . h " <nl> + # include " atom / common / native_mate_converters / network_converter . h " <nl> # include " atom / common / native_mate_converters / string16_converter . h " <nl> # include " atom / common / native_mate_converters / value_converter . h " <nl> # include " atom / common / options_switches . h " <nl> <nl> # include " content / browser / renderer_host / render_widget_host_view_base . h " <nl> # include " content / common / view_messages . h " <nl> # include " content / public / browser / child_process_security_policy . h " <nl> + # include " content / public / browser / download_request_utils . h " <nl> # include " content / public / browser / favicon_status . h " <nl> # include " content / public / browser / native_web_keyboard_event . h " <nl> # include " content / public / browser / navigation_details . h " <nl> <nl> # include " content / public / browser / render_view_host . h " <nl> # include " content / public / browser / render_widget_host . h " <nl> # include " content / public / browser / render_widget_host_view . h " <nl> - # include " content / public / browser / resource_request_details . h " <nl> # include " content / public / browser / service_worker_context . h " <nl> # include " content / public / browser / site_instance . h " <nl> # include " content / public / browser / storage_partition . h " <nl> <nl> # include " third_party / WebKit / public / web / WebFindOptions . h " <nl> # include " ui / display / screen . h " <nl> # include " ui / events / base_event_utils . h " <nl> - # include " ui / latency / latency_info . h " <nl> <nl> # if ! defined ( OS_MACOSX ) <nl> # include " ui / aura / window . h " <nl> content : : ServiceWorkerContext * GetServiceWorkerContext ( <nl> <nl> / / Called when CapturePage is done . <nl> void OnCapturePageDone ( const base : : Callback < void ( const gfx : : Image & ) > & callback , <nl> - const SkBitmap & bitmap , <nl> - content : : ReadbackResponse response ) { <nl> + const SkBitmap & bitmap ) { <nl> / / Hack to enable transparency in captured image <nl> / / TODO ( nitsakh ) Remove hack once fixed in chromium <nl> const_cast < SkBitmap & > ( bitmap ) . setAlphaType ( kPremul_SkAlphaType ) ; <nl> void WebContents : : OnCreateWindow ( <nl> const std : : string & frame_name , <nl> WindowOpenDisposition disposition , <nl> const std : : vector < std : : string > & features , <nl> - const scoped_refptr < content : : ResourceRequestBody > & body ) { <nl> + const scoped_refptr < network : : ResourceRequestBody > & body ) { <nl> if ( type_ = = BROWSER_WINDOW | | type_ = = OFF_SCREEN ) <nl> Emit ( " - new - window " , target_url , frame_name , disposition , features , body , <nl> referrer ) ; <nl> void WebContents : : ExitFullscreenModeForTab ( content : : WebContents * source ) { <nl> <nl> void WebContents : : RendererUnresponsive ( <nl> content : : WebContents * source , <nl> - const content : : WebContentsUnresponsiveState & unresponsive_state ) { <nl> + content : : RenderWidgetHost * render_widget_host ) { <nl> Emit ( " unresponsive " ) ; <nl> } <nl> <nl> - void WebContents : : RendererResponsive ( content : : WebContents * source ) { <nl> + void WebContents : : RendererResponsive ( <nl> + content : : WebContents * source , <nl> + content : : RenderWidgetHost * render_widget_host ) { <nl> Emit ( " responsive " ) ; <nl> for ( ExtendedWebContentsObserver & observer : observers_ ) <nl> observer . OnRendererResponsive ( ) ; <nl> content : : JavaScriptDialogManager * WebContents : : GetJavaScriptDialogManager ( <nl> return dialog_manager_ . get ( ) ; <nl> } <nl> <nl> + void WebContents : : ResizeDueToAutoResize ( content : : WebContents * web_contents , <nl> + const gfx : : Size & new_size ) { <nl> + if ( IsGuest ( ) ) { <nl> + guest_delegate_ - > ResizeDueToAutoResize ( new_size ) ; <nl> + } <nl> + } <nl> + <nl> void WebContents : : BeforeUnloadFired ( const base : : TimeTicks & proceed_time ) { <nl> / / Do nothing , we override this method just to avoid compilation error since <nl> / / there are two virtual functions named BeforeUnloadFired . <nl> void WebContents : : MediaStartedPlaying ( const MediaPlayerInfo & video_type , <nl> Emit ( " media - started - playing " ) ; <nl> } <nl> <nl> - void WebContents : : MediaStoppedPlaying ( const MediaPlayerInfo & video_type , <nl> - const MediaPlayerId & id ) { <nl> + void WebContents : : MediaStoppedPlaying ( <nl> + const MediaPlayerInfo & video_type , <nl> + const MediaPlayerId & id , <nl> + content : : WebContentsObserver : : MediaStoppedReason reason ) { <nl> Emit ( " media - paused " ) ; <nl> } <nl> <nl> void WebContents : : DidStopLoading ( ) { <nl> Emit ( " did - stop - loading " ) ; <nl> } <nl> <nl> - void WebContents : : DidGetResourceResponseStart ( <nl> - const content : : ResourceRequestDetails & details ) { <nl> - / / Plznavigate is using blob URLs to deliver the body <nl> - / / of the main resource to the renderer process . This <nl> - / / gets better in the future with kNavigationMojoResponse <nl> - / / feature , which replaces this mechanism with Mojo Datapipe . <nl> - if ( details . url . SchemeIsBlob ( ) & & <nl> - ( details . resource_type = = content : : RESOURCE_TYPE_MAIN_FRAME | | <nl> - details . resource_type = = content : : RESOURCE_TYPE_SUB_FRAME ) ) <nl> - return ; <nl> - Emit ( " - did - get - response - details " , details . socket_address . IsEmpty ( ) , <nl> - details . url , details . original_url , details . http_response_code , <nl> - details . method , details . referrer , details . headers . get ( ) , <nl> - ResourceTypeToString ( details . resource_type ) ) ; <nl> - } <nl> - <nl> - void WebContents : : DidGetRedirectForResourceRequest ( <nl> - const content : : ResourceRedirectDetails & details ) { <nl> - Emit ( " - did - get - redirect - request " , details . url , details . new_url , <nl> - ( details . resource_type = = content : : RESOURCE_TYPE_MAIN_FRAME ) , <nl> - details . http_response_code , details . method , details . referrer , <nl> - details . headers . get ( ) ) ; <nl> - } <nl> - <nl> void WebContents : : DidStartNavigation ( <nl> content : : NavigationHandle * navigation_handle ) { <nl> bool is_main_frame = navigation_handle - > IsInMainFrame ( ) ; <nl> void WebContents : : LoadURL ( const GURL & url , const mate : : Dictionary & options ) { <nl> if ( options . Get ( " extraHeaders " , & extra_headers ) ) <nl> params . extra_headers = extra_headers ; <nl> <nl> - scoped_refptr < content : : ResourceRequestBody > body ; <nl> + scoped_refptr < network : : ResourceRequestBody > body ; <nl> if ( options . Get ( " postData " , & body ) ) { <nl> params . post_data = body ; <nl> params . load_type = content : : NavigationController : : LOAD_TYPE_HTTP_POST ; <nl> void WebContents : : DownloadURL ( const GURL & url ) { <nl> auto * browser_context = web_contents ( ) - > GetBrowserContext ( ) ; <nl> auto * download_manager = <nl> content : : BrowserContext : : GetDownloadManager ( browser_context ) ; <nl> - <nl> - download_manager - > DownloadUrl ( <nl> - content : : DownloadUrlParameters : : CreateForWebContentsMainFrame ( <nl> + std : : unique_ptr < download : : DownloadUrlParameters > download_params ( <nl> + content : : DownloadRequestUtils : : CreateDownloadForWebContentsMainFrame ( <nl> web_contents ( ) , url , NO_TRAFFIC_ANNOTATION_YET ) ) ; <nl> + download_manager - > DownloadUrl ( std : : move ( download_params ) ) ; <nl> } <nl> <nl> GURL WebContents : : GetURL ( ) const { <nl> bool WebContents : : SendIPCMessage ( bool all_frames , <nl> <nl> void WebContents : : SendInputEvent ( v8 : : Isolate * isolate , <nl> v8 : : Local < v8 : : Value > input_event ) { <nl> - auto * const view = static_cast < content : : RenderWidgetHostViewBase * > ( <nl> - web_contents ( ) - > GetRenderWidgetHostView ( ) ) ; <nl> + content : : RenderWidgetHostView * view = <nl> + web_contents ( ) - > GetRenderWidgetHostView ( ) ; <nl> if ( ! view ) <nl> return ; <nl> <nl> + content : : RenderWidgetHost * rwh = view - > GetRenderWidgetHost ( ) ; <nl> blink : : WebInputEvent : : Type type = <nl> mate : : GetWebInputEventType ( isolate , input_event ) ; <nl> if ( blink : : WebInputEvent : : IsMouseEventType ( type ) ) { <nl> blink : : WebMouseEvent mouse_event ; <nl> if ( mate : : ConvertFromV8 ( isolate , input_event , & mouse_event ) ) { <nl> - view - > ProcessMouseEvent ( mouse_event , ui : : LatencyInfo ( ) ) ; <nl> + if ( IsOffScreen ( ) ) { <nl> + # if defined ( ENABLE_OSR ) <nl> + GetOffScreenRenderWidgetHostView ( ) - > SendMouseEvent ( mouse_event ) ; <nl> + # endif <nl> + } else { <nl> + rwh - > ForwardMouseEvent ( mouse_event ) ; <nl> + } <nl> return ; <nl> } <nl> } else if ( blink : : WebInputEvent : : IsKeyboardEventType ( type ) ) { <nl> void WebContents : : SendInputEvent ( v8 : : Isolate * isolate , <nl> blink : : WebKeyboardEvent : : kRawKeyDown , <nl> blink : : WebInputEvent : : kNoModifiers , ui : : EventTimeForNow ( ) ) ; <nl> if ( mate : : ConvertFromV8 ( isolate , input_event , & keyboard_event ) ) { <nl> - view - > ProcessKeyboardEvent ( keyboard_event , ui : : LatencyInfo ( ) ) ; <nl> + rwh - > ForwardKeyboardEvent ( keyboard_event ) ; <nl> return ; <nl> } <nl> } else if ( type = = blink : : WebInputEvent : : kMouseWheel ) { <nl> blink : : WebMouseWheelEvent mouse_wheel_event ; <nl> if ( mate : : ConvertFromV8 ( isolate , input_event , & mouse_wheel_event ) ) { <nl> - view - > ProcessMouseWheelEvent ( mouse_wheel_event , ui : : LatencyInfo ( ) ) ; <nl> + if ( IsOffScreen ( ) ) { <nl> + # if defined ( ENABLE_OSR ) <nl> + GetOffScreenRenderWidgetHostView ( ) - > SendMouseWheelEvent ( <nl> + mouse_wheel_event ) ; <nl> + # endif <nl> + } else { <nl> + rwh - > ForwardWheelEvent ( mouse_wheel_event ) ; <nl> + } <nl> return ; <nl> } <nl> } <nl> void WebContents : : BeginFrameSubscription ( mate : : Arguments * args ) { <nl> return ; <nl> } <nl> <nl> - auto * const view = web_contents ( ) - > GetRenderWidgetHostView ( ) ; <nl> - if ( view ) { <nl> - std : : unique_ptr < FrameSubscriber > frame_subscriber ( <nl> - new FrameSubscriber ( isolate ( ) , view , callback , only_dirty ) ) ; <nl> - view - > BeginFrameSubscription ( std : : move ( frame_subscriber ) ) ; <nl> - } <nl> + frame_subscriber_ . reset ( <nl> + new FrameSubscriber ( isolate ( ) , web_contents ( ) , callback , only_dirty ) ) ; <nl> } <nl> <nl> void WebContents : : EndFrameSubscription ( ) { <nl> - auto * const view = web_contents ( ) - > GetRenderWidgetHostView ( ) ; <nl> - if ( view ) <nl> - view - > EndFrameSubscription ( ) ; <nl> + frame_subscriber_ . reset ( ) ; <nl> } <nl> <nl> void WebContents : : StartDrag ( const mate : : Dictionary & item , <nl> void WebContents : : CapturePage ( mate : : Arguments * args ) { <nl> bitmap_size = gfx : : ScaleToCeiledSize ( view_size , scale ) ; <nl> <nl> view - > CopyFromSurface ( gfx : : Rect ( rect . origin ( ) , view_size ) , bitmap_size , <nl> - base : : Bind ( & OnCapturePageDone , callback ) , <nl> - kBGRA_8888_SkColorType ) ; <nl> + base : : BindOnce ( & OnCapturePageDone , callback ) ) ; <nl> } <nl> <nl> void WebContents : : OnCursorChange ( const content : : WebCursor & cursor ) { <nl> int WebContents : : GetFrameRate ( ) const { <nl> void WebContents : : Invalidate ( ) { <nl> if ( IsOffScreen ( ) ) { <nl> # if defined ( ENABLE_OSR ) <nl> - auto * osr_rwhv = static_cast < OffScreenRenderWidgetHostView * > ( <nl> - web_contents ( ) - > GetRenderWidgetHostView ( ) ) ; <nl> + auto * osr_rwhv = GetOffScreenRenderWidgetHostView ( ) ; <nl> if ( osr_rwhv ) <nl> osr_rwhv - > Invalidate ( ) ; <nl> # endif <nl> v8 : : Local < v8 : : Value > WebContents : : Debugger ( v8 : : Isolate * isolate ) { <nl> <nl> void WebContents : : GrantOriginAccess ( const GURL & url ) { <nl> content : : ChildProcessSecurityPolicy : : GetInstance ( ) - > GrantOrigin ( <nl> - web_contents ( ) - > GetMainFrame ( ) - > GetProcess ( ) - > GetID ( ) , url : : Origin ( url ) ) ; <nl> + web_contents ( ) - > GetMainFrame ( ) - > GetProcess ( ) - > GetID ( ) , <nl> + url : : Origin : : Create ( url ) ) ; <nl> } <nl> <nl> / / static <nl> mmm a / atom / browser / api / atom_api_web_contents . h <nl> ppp b / atom / browser / api / atom_api_web_contents . h <nl> namespace brightray { <nl> class InspectableWebContents ; <nl> } <nl> <nl> - namespace content { <nl> - class ResourceRequestBody ; <nl> - } <nl> - <nl> namespace mate { <nl> class Arguments ; <nl> class Dictionary ; <nl> } / / namespace mate <nl> <nl> + namespace network { <nl> + class ResourceRequestBody ; <nl> + } <nl> + <nl> namespace atom { <nl> <nl> struct SetSizeParams ; <nl> class AtomBrowserContext ; <nl> class AtomJavaScriptDialogManager ; <nl> class WebContentsZoomController ; <nl> class WebViewGuestDelegate ; <nl> + class FrameSubscriber ; <nl> <nl> # if defined ( ENABLE_OSR ) <nl> class OffScreenWebContentsView ; <nl> + class OffScreenRenderWidgetHostView ; <nl> # endif <nl> <nl> namespace api { <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> const std : : string & frame_name , <nl> WindowOpenDisposition disposition , <nl> const std : : vector < std : : string > & features , <nl> - const scoped_refptr < content : : ResourceRequestBody > & body ) ; <nl> + const scoped_refptr < network : : ResourceRequestBody > & body ) ; <nl> <nl> / / Returns the web preferences of current WebContents . <nl> v8 : : Local < v8 : : Value > GetWebPreferences ( v8 : : Isolate * isolate ) ; <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> void ExitFullscreenModeForTab ( content : : WebContents * source ) override ; <nl> void RendererUnresponsive ( <nl> content : : WebContents * source , <nl> - const content : : WebContentsUnresponsiveState & unresponsive_state ) override ; <nl> - void RendererResponsive ( content : : WebContents * source ) override ; <nl> + content : : RenderWidgetHost * render_widget_host ) override ; <nl> + void RendererResponsive ( <nl> + content : : WebContents * source , <nl> + content : : RenderWidgetHost * render_widget_host ) override ; <nl> bool HandleContextMenu ( const content : : ContextMenuParams & params ) override ; <nl> bool OnGoToEntryOffset ( int offset ) override ; <nl> void FindReply ( content : : WebContents * web_contents , <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> const content : : BluetoothChooser : : EventHandler & handler ) override ; <nl> content : : JavaScriptDialogManager * GetJavaScriptDialogManager ( <nl> content : : WebContents * source ) override ; <nl> + void ResizeDueToAutoResize ( content : : WebContents * web_contents , <nl> + const gfx : : Size & new_size ) override ; <nl> <nl> / / content : : WebContentsObserver : <nl> void BeforeUnloadFired ( const base : : TimeTicks & proceed_time ) override ; <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> const base : : string16 & error_description ) override ; <nl> void DidStartLoading ( ) override ; <nl> void DidStopLoading ( ) override ; <nl> - void DidGetResourceResponseStart ( <nl> - const content : : ResourceRequestDetails & details ) override ; <nl> - void DidGetRedirectForResourceRequest ( <nl> - const content : : ResourceRedirectDetails & details ) override ; <nl> void DidStartNavigation ( <nl> content : : NavigationHandle * navigation_handle ) override ; <nl> void DidFinishNavigation ( <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> base : : ProcessId plugin_pid ) override ; <nl> void MediaStartedPlaying ( const MediaPlayerInfo & video_type , <nl> const MediaPlayerId & id ) override ; <nl> - void MediaStoppedPlaying ( const MediaPlayerInfo & video_type , <nl> - const MediaPlayerId & id ) override ; <nl> + void MediaStoppedPlaying ( <nl> + const MediaPlayerInfo & video_type , <nl> + const MediaPlayerId & id , <nl> + content : : WebContentsObserver : : MediaStoppedReason reason ) override ; <nl> void DidChangeThemeColor ( SkColor theme_color ) override ; <nl> <nl> / / brightray : : InspectableWebContentsDelegate : <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> <nl> # if defined ( ENABLE_OSR ) <nl> OffScreenWebContentsView * GetOffScreenWebContentsView ( ) const ; <nl> + OffScreenRenderWidgetHostView * GetOffScreenRenderWidgetHostView ( ) const ; <nl> # endif <nl> <nl> / / Called when we receive a CursorChange message from chromium . <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> std : : unique_ptr < AtomJavaScriptDialogManager > dialog_manager_ ; <nl> std : : unique_ptr < WebViewGuestDelegate > guest_delegate_ ; <nl> <nl> + std : : unique_ptr < FrameSubscriber > frame_subscriber_ ; <nl> + <nl> / / The host webcontents that may contain this webcontents . <nl> WebContents * embedder_ = nullptr ; <nl> <nl> mmm a / atom / browser / api / atom_api_web_contents_mac . mm <nl> ppp b / atom / browser / api / atom_api_web_contents_mac . mm <nl> <nl> / / found in the LICENSE file . <nl> <nl> # include " atom / browser / api / atom_api_web_contents . h " <nl> + # include " content / public / browser / render_widget_host_view . h " <nl> <nl> # import < Cocoa / Cocoa . h > <nl> <nl> mmm a / atom / browser / api / atom_api_web_contents_osr . cc <nl> ppp b / atom / browser / api / atom_api_web_contents_osr . cc <nl> <nl> <nl> # include " atom / browser / api / atom_api_web_contents . h " <nl> <nl> + # include " atom / browser / osr / osr_render_widget_host_view . h " <nl> # include " atom / browser / osr / osr_web_contents_view . h " <nl> # include " content / browser / web_contents / web_contents_impl . h " <nl> <nl> OffScreenWebContentsView * WebContents : : GetOffScreenWebContentsView ( ) const { <nl> return static_cast < OffScreenWebContentsView * > ( impl - > GetView ( ) ) ; <nl> } <nl> <nl> + OffScreenRenderWidgetHostView * WebContents : : GetOffScreenRenderWidgetHostView ( ) <nl> + const { <nl> + return static_cast < OffScreenRenderWidgetHostView * > ( <nl> + web_contents ( ) - > GetRenderWidgetHostView ( ) ) ; <nl> + } <nl> + <nl> } / / namespace api <nl> <nl> } / / namespace atom <nl> mmm a / atom / browser / api / event_emitter . cc <nl> ppp b / atom / browser / api / event_emitter . cc <nl> void PreventDefault ( mate : : Arguments * args ) { <nl> / / Create a pure JavaScript Event object . <nl> v8 : : Local < v8 : : Object > CreateEventObject ( v8 : : Isolate * isolate ) { <nl> if ( event_template . IsEmpty ( ) ) { <nl> - event_template . Reset ( isolate , <nl> - ObjectTemplateBuilder ( isolate ) <nl> - . SetMethod ( " preventDefault " , & PreventDefault ) <nl> - . Build ( ) ) ; <nl> + event_template . Reset ( <nl> + isolate , <nl> + ObjectTemplateBuilder ( isolate , v8 : : ObjectTemplate : : New ( isolate ) ) <nl> + . SetMethod ( " preventDefault " , & PreventDefault ) <nl> + . Build ( ) ) ; <nl> } <nl> <nl> return v8 : : Local < v8 : : ObjectTemplate > : : New ( isolate , event_template ) <nl> mmm a / atom / browser / api / frame_subscriber . cc <nl> ppp b / atom / browser / api / frame_subscriber . cc <nl> <nl> # include " atom / browser / api / frame_subscriber . h " <nl> <nl> # include " atom / common / native_mate_converters / gfx_converter . h " <nl> - # include " base / bind . h " <nl> - # include " content / public / browser / render_widget_host . h " <nl> - # include " ui / display / display . h " <nl> - # include " ui / display / screen . h " <nl> - <nl> - # include " atom / common / node_includes . h " <nl> + # include " components / viz / common / frame_sinks / copy_output_request . h " <nl> + # include " components / viz / service / frame_sinks / frame_sink_manager_impl . h " <nl> + # include " components / viz / service / surfaces / surface_manager . h " <nl> + # include " content / browser / compositor / surface_utils . h " <nl> + # include " content / browser / renderer_host / render_widget_host_view_base . h " <nl> + # include " ui / gfx / geometry / rect_conversions . h " <nl> + # include " ui / gfx / skbitmap_operations . h " <nl> <nl> namespace atom { <nl> <nl> namespace api { <nl> <nl> FrameSubscriber : : FrameSubscriber ( v8 : : Isolate * isolate , <nl> - content : : RenderWidgetHostView * view , <nl> + content : : WebContents * web_contents , <nl> const FrameCaptureCallback & callback , <nl> bool only_dirty ) <nl> - : isolate_ ( isolate ) , <nl> - view_ ( view ) , <nl> + : content : : WebContentsObserver ( web_contents ) , <nl> + isolate_ ( isolate ) , <nl> callback_ ( callback ) , <nl> - only_dirty_ ( only_dirty ) , <nl> - source_id_for_copy_request_ ( base : : UnguessableToken : : Create ( ) ) , <nl> - weak_factory_ ( this ) { } <nl> + only_dirty_ ( only_dirty ) { } <nl> <nl> FrameSubscriber : : ~ FrameSubscriber ( ) = default ; <nl> <nl> - bool FrameSubscriber : : ShouldCaptureFrame ( <nl> - const gfx : : Rect & dirty_rect , <nl> - base : : TimeTicks present_time , <nl> - scoped_refptr < media : : VideoFrame > * storage , <nl> - DeliverFrameCallback * callback ) { <nl> - if ( ! view_ ) <nl> - return false ; <nl> - <nl> - if ( dirty_rect . IsEmpty ( ) ) <nl> - return false ; <nl> - <nl> - gfx : : Rect rect = gfx : : Rect ( view_ - > GetVisibleViewportSize ( ) ) ; <nl> - if ( only_dirty_ ) <nl> - rect = dirty_rect ; <nl> - <nl> - gfx : : Size view_size = rect . size ( ) ; <nl> - gfx : : Size bitmap_size = view_size ; <nl> - gfx : : NativeView native_view = view_ - > GetNativeView ( ) ; <nl> - const float scale = display : : Screen : : GetScreen ( ) <nl> - - > GetDisplayNearestView ( native_view ) <nl> - . device_scale_factor ( ) ; <nl> - if ( scale > 1 . 0f ) <nl> - bitmap_size = gfx : : ScaleToCeiledSize ( view_size , scale ) ; <nl> - <nl> - rect = gfx : : Rect ( rect . origin ( ) , bitmap_size ) ; <nl> - <nl> - view_ - > CopyFromSurface ( <nl> - rect , rect . size ( ) , <nl> - base : : Bind ( & FrameSubscriber : : OnFrameDelivered , weak_factory_ . GetWeakPtr ( ) , <nl> - callback_ , rect ) , <nl> - kBGRA_8888_SkColorType ) ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - const base : : UnguessableToken & FrameSubscriber : : GetSourceIdForCopyRequest ( ) { <nl> - return source_id_for_copy_request_ ; <nl> + gfx : : Rect FrameSubscriber : : GetDamageRect ( ) { <nl> + auto * view = web_contents ( ) - > GetRenderWidgetHostView ( ) ; <nl> + if ( view = = nullptr ) <nl> + return gfx : : Rect ( ) ; <nl> + <nl> + auto * view_base = static_cast < content : : RenderWidgetHostViewBase * > ( view ) ; <nl> + viz : : SurfaceManager * surface_manager = <nl> + content : : GetFrameSinkManager ( ) - > surface_manager ( ) ; <nl> + viz : : Surface * surface = <nl> + surface_manager - > GetSurfaceForId ( view_base - > GetCurrentSurfaceId ( ) ) ; <nl> + if ( surface = = nullptr ) <nl> + return gfx : : Rect ( ) ; <nl> + <nl> + if ( surface - > HasActiveFrame ( ) ) { <nl> + const viz : : CompositorFrame & frame = surface - > GetActiveFrame ( ) ; <nl> + viz : : RenderPass * root_pass = frame . render_pass_list . back ( ) . get ( ) ; <nl> + gfx : : Size frame_size = root_pass - > output_rect . size ( ) ; <nl> + gfx : : Rect damage_rect = <nl> + gfx : : ToEnclosingRect ( gfx : : RectF ( root_pass - > damage_rect ) ) ; <nl> + damage_rect . Intersect ( gfx : : Rect ( frame_size ) ) ; <nl> + return gfx : : ScaleToEnclosedRect ( damage_rect , <nl> + 1 . 0f / frame . device_scale_factor ( ) ) ; <nl> + } else { <nl> + return gfx : : Rect ( ) ; <nl> + } <nl> } <nl> <nl> - void FrameSubscriber : : OnFrameDelivered ( const FrameCaptureCallback & callback , <nl> - const gfx : : Rect & damage_rect , <nl> - const SkBitmap & bitmap , <nl> - content : : ReadbackResponse response ) { <nl> - if ( response ! = content : : ReadbackResponse : : READBACK_SUCCESS ) <nl> + void FrameSubscriber : : DidReceiveCompositorFrame ( ) { <nl> + auto * view = web_contents ( ) - > GetRenderWidgetHostView ( ) ; <nl> + if ( view = = nullptr ) <nl> return ; <nl> <nl> - v8 : : Locker locker ( isolate_ ) ; <nl> - v8 : : HandleScope handle_scope ( isolate_ ) ; <nl> - <nl> - size_t rgb_row_size = bitmap . width ( ) * bitmap . bytesPerPixel ( ) ; <nl> - <nl> - v8 : : MaybeLocal < v8 : : Object > buffer = <nl> - node : : Buffer : : New ( isolate_ , rgb_row_size * bitmap . height ( ) ) ; <nl> + view - > CopyFromSurface ( <nl> + gfx : : Rect ( ) , view - > GetViewBounds ( ) . size ( ) , <nl> + base : : BindOnce ( & FrameSubscriber : : Done , base : : Unretained ( this ) , <nl> + GetDamageRect ( ) ) ) ; <nl> + } <nl> <nl> - if ( buffer . IsEmpty ( ) ) <nl> + void FrameSubscriber : : Done ( const gfx : : Rect & damage , const SkBitmap & frame ) { <nl> + if ( frame . drawsNothing ( ) ) <nl> return ; <nl> <nl> - auto local_buffer = buffer . ToLocalChecked ( ) ; <nl> - <nl> - { <nl> - auto * source = static_cast < const unsigned char * > ( bitmap . getPixels ( ) ) ; <nl> - auto * target = node : : Buffer : : Data ( local_buffer ) ; <nl> + const_cast < SkBitmap & > ( frame ) . setAlphaType ( kPremul_SkAlphaType ) ; <nl> + v8 : : Local < v8 : : Value > damage_rect = <nl> + mate : : Converter < gfx : : Rect > : : ToV8 ( isolate_ , damage ) ; <nl> <nl> - for ( int y = 0 ; y < bitmap . height ( ) ; + + y ) { <nl> - memcpy ( target , source , rgb_row_size ) ; <nl> - source + = bitmap . rowBytes ( ) ; <nl> - target + = rgb_row_size ; <nl> - } <nl> + if ( only_dirty_ ) { <nl> + const SkBitmap & damageFrame = SkBitmapOperations : : CreateTiledBitmap ( <nl> + frame , damage . x ( ) , damage . y ( ) , damage . width ( ) , damage . height ( ) ) ; <nl> + callback_ . Run ( gfx : : Image : : CreateFrom1xBitmap ( damageFrame ) , damage_rect ) ; <nl> + } else { <nl> + callback_ . Run ( gfx : : Image : : CreateFrom1xBitmap ( frame ) , damage_rect ) ; <nl> } <nl> - <nl> - v8 : : Local < v8 : : Value > damage = <nl> - mate : : Converter < gfx : : Rect > : : ToV8 ( isolate_ , damage_rect ) ; <nl> - <nl> - callback_ . Run ( local_buffer , damage ) ; <nl> } <nl> <nl> } / / namespace api <nl> mmm a / atom / browser / api / frame_subscriber . h <nl> ppp b / atom / browser / api / frame_subscriber . h <nl> <nl> # ifndef ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_ <nl> # define ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_ <nl> <nl> + # include " content / public / browser / web_contents . h " <nl> + <nl> # include " base / callback . h " <nl> - # include " base / memory / weak_ptr . h " <nl> - # include " content / browser / renderer_host / render_widget_host_view_frame_subscriber . h " <nl> - # include " content / public / browser / readback_types . h " <nl> - # include " content / public / browser / render_widget_host_view . h " <nl> - # include " third_party / skia / include / core / SkBitmap . h " <nl> - # include " ui / gfx / geometry / size . h " <nl> + # include " components / viz / common / frame_sinks / copy_output_result . h " <nl> + # include " content / public / browser / web_contents_observer . h " <nl> + # include " ui / gfx / image / image . h " <nl> # include " v8 / include / v8 . h " <nl> <nl> namespace atom { <nl> <nl> namespace api { <nl> <nl> - class FrameSubscriber : public content : : RenderWidgetHostViewFrameSubscriber { <nl> + class WebContents ; <nl> + <nl> + class FrameSubscriber : public content : : WebContentsObserver { <nl> public : <nl> using FrameCaptureCallback = <nl> - base : : Callback < void ( v8 : : Local < v8 : : Value > , v8 : : Local < v8 : : Value > ) > ; <nl> + base : : Callback < void ( const gfx : : Image & , v8 : : Local < v8 : : Value > ) > ; <nl> <nl> FrameSubscriber ( v8 : : Isolate * isolate , <nl> - content : : RenderWidgetHostView * view , <nl> + content : : WebContents * web_contents , <nl> const FrameCaptureCallback & callback , <nl> bool only_dirty ) ; <nl> - ~ FrameSubscriber ( ) override ; <nl> - <nl> - bool ShouldCaptureFrame ( const gfx : : Rect & damage_rect , <nl> - base : : TimeTicks present_time , <nl> - scoped_refptr < media : : VideoFrame > * storage , <nl> - DeliverFrameCallback * callback ) override ; <nl> - const base : : UnguessableToken & GetSourceIdForCopyRequest ( ) override ; <nl> + ~ FrameSubscriber ( ) ; <nl> <nl> private : <nl> - void OnFrameDelivered ( const FrameCaptureCallback & callback , <nl> - const gfx : : Rect & damage_rect , <nl> - const SkBitmap & bitmap , <nl> - content : : ReadbackResponse response ) ; <nl> + gfx : : Rect GetDamageRect ( ) ; <nl> + void DidReceiveCompositorFrame ( ) override ; <nl> + void Done ( const gfx : : Rect & damage , const SkBitmap & frame ) ; <nl> <nl> v8 : : Isolate * isolate_ ; <nl> - content : : RenderWidgetHostView * view_ ; <nl> FrameCaptureCallback callback_ ; <nl> bool only_dirty_ ; <nl> <nl> - base : : UnguessableToken source_id_for_copy_request_ ; <nl> - <nl> - base : : WeakPtrFactory < FrameSubscriber > weak_factory_ ; <nl> - <nl> DISALLOW_COPY_AND_ASSIGN ( FrameSubscriber ) ; <nl> } ; <nl> <nl> mmm a / atom / browser / api / save_page_handler . cc <nl> ppp b / atom / browser / api / save_page_handler . cc <nl> SavePageHandler : : SavePageHandler ( content : : WebContents * web_contents , <nl> SavePageHandler : : ~ SavePageHandler ( ) { } <nl> <nl> void SavePageHandler : : OnDownloadCreated ( content : : DownloadManager * manager , <nl> - content : : DownloadItem * item ) { <nl> + download : : DownloadItem * item ) { <nl> / / OnDownloadCreated is invoked during WebContents : : SavePage , so the | item | <nl> / / here is the one stated by WebContents : : SavePage . <nl> item - > AddObserver ( this ) ; <nl> bool SavePageHandler : : Handle ( const base : : FilePath & full_path , <nl> return result ; <nl> } <nl> <nl> - void SavePageHandler : : OnDownloadUpdated ( content : : DownloadItem * item ) { <nl> + void SavePageHandler : : OnDownloadUpdated ( download : : DownloadItem * item ) { <nl> if ( item - > IsDone ( ) ) { <nl> v8 : : Isolate * isolate = v8 : : Isolate : : GetCurrent ( ) ; <nl> v8 : : Locker locker ( isolate ) ; <nl> v8 : : HandleScope handle_scope ( isolate ) ; <nl> - if ( item - > GetState ( ) = = content : : DownloadItem : : COMPLETE ) { <nl> + if ( item - > GetState ( ) = = download : : DownloadItem : : COMPLETE ) { <nl> callback_ . Run ( v8 : : Null ( isolate ) ) ; <nl> } else { <nl> v8 : : Local < v8 : : String > error_message = <nl> void SavePageHandler : : OnDownloadUpdated ( content : : DownloadItem * item ) { <nl> } <nl> } <nl> <nl> - void SavePageHandler : : Destroy ( content : : DownloadItem * item ) { <nl> + void SavePageHandler : : Destroy ( download : : DownloadItem * item ) { <nl> item - > RemoveObserver ( this ) ; <nl> delete this ; <nl> } <nl> mmm a / atom / browser / api / save_page_handler . h <nl> ppp b / atom / browser / api / save_page_handler . h <nl> <nl> <nl> # include < string > <nl> <nl> - # include " content / public / browser / download_item . h " <nl> + # include " components / download / public / common / download_item . h " <nl> # include " content / public / browser / download_manager . h " <nl> # include " content / public / browser / save_page_type . h " <nl> # include " v8 / include / v8 . h " <nl> namespace api { <nl> <nl> / / A self - destroyed class for handling save page request . <nl> class SavePageHandler : public content : : DownloadManager : : Observer , <nl> - public content : : DownloadItem : : Observer { <nl> + public download : : DownloadItem : : Observer { <nl> public : <nl> using SavePageCallback = base : : Callback < void ( v8 : : Local < v8 : : Value > ) > ; <nl> <nl> class SavePageHandler : public content : : DownloadManager : : Observer , <nl> const content : : SavePageType & save_type ) ; <nl> <nl> private : <nl> - void Destroy ( content : : DownloadItem * item ) ; <nl> + void Destroy ( download : : DownloadItem * item ) ; <nl> <nl> / / content : : DownloadManager : : Observer : <nl> void OnDownloadCreated ( content : : DownloadManager * manager , <nl> - content : : DownloadItem * item ) override ; <nl> + download : : DownloadItem * item ) override ; <nl> <nl> - / / content : : DownloadItem : : Observer : <nl> - void OnDownloadUpdated ( content : : DownloadItem * item ) override ; <nl> + / / download : : DownloadItem : : Observer : <nl> + void OnDownloadUpdated ( download : : DownloadItem * item ) override ; <nl> <nl> content : : WebContents * web_contents_ ; / / weak <nl> SavePageCallback callback_ ; <nl> deleted file mode 100644 <nl> index 1107ad6a5b67 . . 000000000000 <nl> mmm a / atom / browser / atom_access_token_store . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2014 GitHub , Inc . <nl> - / / Use of this source code is governed by the MIT license that can be <nl> - / / found in the LICENSE file . <nl> - <nl> - # ifndef ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_ <nl> - # define ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_ <nl> - <nl> - # include " device / geolocation / access_token_store . h " <nl> - <nl> - namespace atom { <nl> - <nl> - class AtomAccessTokenStore : public device : : AccessTokenStore { <nl> - public : <nl> - AtomAccessTokenStore ( ) = default ; <nl> - <nl> - / / device : : AccessTokenStore : <nl> - void LoadAccessTokens ( const LoadAccessTokensCallback & callback ) override { } <nl> - void SaveAccessToken ( const GURL & server_url , <nl> - const base : : string16 & access_token ) override { } <nl> - <nl> - private : <nl> - ~ AtomAccessTokenStore ( ) override = default ; <nl> - DISALLOW_COPY_AND_ASSIGN ( AtomAccessTokenStore ) ; <nl> - } ; <nl> - <nl> - } / / namespace atom <nl> - <nl> - # endif / / ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_ <nl> mmm a / atom / browser / atom_blob_reader . cc <nl> ppp b / atom / browser / atom_blob_reader . cc <nl> <nl> # include " storage / browser / blob / blob_data_handle . h " <nl> # include " storage / browser / blob / blob_reader . h " <nl> # include " storage / browser / blob / blob_storage_context . h " <nl> - # include " storage / browser / fileapi / file_system_context . h " <nl> <nl> # include " atom / common / node_includes . h " <nl> <nl> void RunCallbackInUI ( const AtomBlobReader : : CompletionCallback & callback , <nl> <nl> } / / namespace <nl> <nl> - AtomBlobReader : : AtomBlobReader ( content : : ChromeBlobStorageContext * blob_context , <nl> - storage : : FileSystemContext * file_system_context ) <nl> - : blob_context_ ( blob_context ) , file_system_context_ ( file_system_context ) { } <nl> + AtomBlobReader : : AtomBlobReader ( content : : ChromeBlobStorageContext * blob_context ) <nl> + : blob_context_ ( blob_context ) { } <nl> <nl> AtomBlobReader : : ~ AtomBlobReader ( ) { } <nl> <nl> void AtomBlobReader : : StartReading ( <nl> return ; <nl> } <nl> <nl> - auto blob_reader = blob_data_handle - > CreateReader ( file_system_context_ . get ( ) ) ; <nl> + auto blob_reader = blob_data_handle - > CreateReader ( ) ; <nl> BlobReadHelper * blob_read_helper = <nl> new BlobReadHelper ( std : : move ( blob_reader ) , callback ) ; <nl> blob_read_helper - > Read ( ) ; <nl> mmm a / atom / browser / atom_blob_reader . h <nl> ppp b / atom / browser / atom_blob_reader . h <nl> class IOBuffer ; <nl> namespace storage { <nl> class BlobDataHandle ; <nl> class BlobReader ; <nl> - class FileSystemContext ; <nl> } / / namespace storage <nl> <nl> namespace v8 { <nl> class AtomBlobReader { <nl> public : <nl> using CompletionCallback = base : : Callback < void ( v8 : : Local < v8 : : Value > ) > ; <nl> <nl> - AtomBlobReader ( content : : ChromeBlobStorageContext * blob_context , <nl> - storage : : FileSystemContext * file_system_context ) ; <nl> + explicit AtomBlobReader ( content : : ChromeBlobStorageContext * blob_context ) ; <nl> ~ AtomBlobReader ( ) ; <nl> <nl> void StartReading ( const std : : string & uuid , <nl> class AtomBlobReader { <nl> } ; <nl> <nl> scoped_refptr < content : : ChromeBlobStorageContext > blob_context_ ; <nl> - scoped_refptr < storage : : FileSystemContext > file_system_context_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( AtomBlobReader ) ; <nl> } ; <nl> mmm a / atom / browser / atom_browser_client . cc <nl> ppp b / atom / browser / atom_browser_client . cc <nl> <nl> # include " atom / browser / atom_resource_dispatcher_host_delegate . h " <nl> # include " atom / browser / atom_speech_recognition_manager_delegate . h " <nl> # include " atom / browser / child_web_contents_tracker . h " <nl> + # include " atom / browser / login_handler . h " <nl> # include " atom / browser / native_window . h " <nl> # include " atom / browser / session_preferences . h " <nl> # include " atom / browser / web_contents_permission_helper . h " <nl> <nl> # include " base / strings / string_util . h " <nl> # include " chrome / browser / printing / printing_message_filter . h " <nl> # include " chrome / browser / renderer_host / pepper / chrome_browser_pepper_host_factory . h " <nl> - # include " chrome / browser / renderer_host / pepper / widevine_cdm_message_filter . h " <nl> # include " chrome / browser / speech / tts_message_filter . h " <nl> # include " content / public / browser / browser_ppapi_host . h " <nl> # include " content / public / browser / client_certificate_delegate . h " <nl> <nl> # include " content / public / browser / web_contents . h " <nl> # include " content / public / common / content_paths . h " <nl> # include " content / public / common / content_switches . h " <nl> - # include " content / public / common / resource_request_body . h " <nl> # include " content / public / common / url_constants . h " <nl> # include " content / public / common / web_preferences . h " <nl> # include " net / ssl / ssl_cert_request_info . h " <nl> # include " ppapi / host / ppapi_host . h " <nl> + # include " services / network / public / cpp / resource_request_body . h " <nl> # include " ui / base / l10n / l10n_util . h " <nl> # include " v8 / include / v8 . h " <nl> <nl> + # if defined ( USE_NSS_CERTS ) <nl> + # include " net / ssl / client_cert_store_nss . h " <nl> + # elif defined ( OS_WIN ) <nl> + # include " net / ssl / client_cert_store_win . h " <nl> + # elif defined ( OS_MACOSX ) <nl> + # include " net / ssl / client_cert_store_mac . h " <nl> + # elif defined ( USE_OPENSSL ) <nl> + # include " net / ssl / client_cert_store . h " <nl> + # endif <nl> + <nl> using content : : BrowserThread ; <nl> <nl> namespace atom { <nl> bool AtomBrowserClient : : RendererDisablesPopups ( int process_id ) { <nl> } <nl> <nl> void AtomBrowserClient : : RenderProcessWillLaunch ( <nl> - content : : RenderProcessHost * host ) { <nl> + content : : RenderProcessHost * host , <nl> + service_manager : : mojom : : ServiceRequest * service_request ) { <nl> / / When a render process is crashed , it might be reused . <nl> int process_id = host - > GetID ( ) ; <nl> if ( IsProcessObserved ( process_id ) ) <nl> void AtomBrowserClient : : RenderProcessWillLaunch ( <nl> <nl> host - > AddFilter ( new printing : : PrintingMessageFilter ( process_id ) ) ; <nl> host - > AddFilter ( new TtsMessageFilter ( process_id , host - > GetBrowserContext ( ) ) ) ; <nl> - host - > AddFilter ( <nl> - new WidevineCdmMessageFilter ( process_id , host - > GetBrowserContext ( ) ) ) ; <nl> <nl> ProcessPreferences prefs ; <nl> auto * web_preferences = <nl> bool AtomBrowserClient : : CanCreateWindow ( <nl> WindowOpenDisposition disposition , <nl> const blink : : mojom : : WindowFeatures & features , <nl> const std : : vector < std : : string > & additional_features , <nl> - const scoped_refptr < content : : ResourceRequestBody > & body , <nl> + const scoped_refptr < network : : ResourceRequestBody > & body , <nl> bool user_gesture , <nl> bool opener_suppressed , <nl> bool * no_javascript_access ) { <nl> void AtomBrowserClient : : SiteInstanceDeleting ( <nl> } <nl> } <nl> <nl> + std : : unique_ptr < net : : ClientCertStore > AtomBrowserClient : : CreateClientCertStore ( <nl> + content : : ResourceContext * resource_context ) { <nl> + # if defined ( USE_NSS_CERTS ) <nl> + return std : : make_unique < net : : ClientCertStoreNSS > ( <nl> + net : : ClientCertStoreNSS : : PasswordDelegateFactory ( ) ) ; <nl> + # elif defined ( OS_WIN ) <nl> + return std : : make_unique < net : : ClientCertStoreWin > ( ) ; <nl> + # elif defined ( OS_MACOSX ) <nl> + return std : : make_unique < net : : ClientCertStoreMac > ( ) ; <nl> + # elif defined ( USE_OPENSSL ) <nl> + return std : : unique_ptr < net : : ClientCertStore > ( ) ; <nl> + # endif <nl> + } <nl> + <nl> + content : : ResourceDispatcherHostLoginDelegate * <nl> + AtomBrowserClient : : CreateLoginDelegate ( <nl> + net : : AuthChallengeInfo * auth_info , <nl> + content : : ResourceRequestInfo : : WebContentsGetter web_contents_getter , <nl> + bool is_main_frame , <nl> + const GURL & url , <nl> + bool first_auth_attempt , <nl> + const base : : Callback < void ( const base : : Optional < net : : AuthCredentials > & ) > & <nl> + auth_required_callback ) { <nl> + return new LoginHandler ( auth_info , web_contents_getter , url , <nl> + auth_required_callback ) ; <nl> + } <nl> + <nl> brightray : : BrowserMainParts * AtomBrowserClient : : OverrideCreateBrowserMainParts ( <nl> const content : : MainFunctionParams & ) { <nl> v8 : : V8 : : Initialize ( ) ; / / Init V8 before creating main parts . <nl> mmm a / atom / browser / atom_browser_client . h <nl> ppp b / atom / browser / atom_browser_client . h <nl> class AtomBrowserClient : public brightray : : BrowserClient , <nl> <nl> protected : <nl> / / content : : ContentBrowserClient : <nl> - void RenderProcessWillLaunch ( content : : RenderProcessHost * host ) override ; <nl> + void RenderProcessWillLaunch ( <nl> + content : : RenderProcessHost * host , <nl> + service_manager : : mojom : : ServiceRequest * service_request ) override ; <nl> content : : SpeechRecognitionManagerDelegate * <nl> CreateSpeechRecognitionManagerDelegate ( ) override ; <nl> void OverrideWebkitPrefs ( content : : RenderViewHost * render_view_host , <nl> class AtomBrowserClient : public brightray : : BrowserClient , <nl> WindowOpenDisposition disposition , <nl> const blink : : mojom : : WindowFeatures & features , <nl> const std : : vector < std : : string > & additional_features , <nl> - const scoped_refptr < content : : ResourceRequestBody > & body , <nl> + const scoped_refptr < network : : ResourceRequestBody > & body , <nl> bool user_gesture , <nl> bool opener_suppressed , <nl> bool * no_javascript_access ) override ; <nl> void GetAdditionalAllowedSchemesForFileSystem ( <nl> std : : vector < std : : string > * schemes ) override ; <nl> void SiteInstanceDeleting ( content : : SiteInstance * site_instance ) override ; <nl> + std : : unique_ptr < net : : ClientCertStore > CreateClientCertStore ( <nl> + content : : ResourceContext * resource_context ) override ; <nl> + content : : ResourceDispatcherHostLoginDelegate * CreateLoginDelegate ( <nl> + net : : AuthChallengeInfo * auth_info , <nl> + content : : ResourceRequestInfo : : WebContentsGetter web_contents_getter , <nl> + bool is_main_frame , <nl> + const GURL & url , <nl> + bool first_auth_attempt , <nl> + const base : : Callback < void ( const base : : Optional < net : : AuthCredentials > & ) > & <nl> + auth_required_callback ) override ; <nl> <nl> / / brightray : : BrowserClient : <nl> brightray : : BrowserMainParts * OverrideCreateBrowserMainParts ( <nl> mmm a / atom / browser / atom_browser_context . cc <nl> ppp b / atom / browser / atom_browser_context . cc <nl> <nl> # include " base / strings / string_util . h " <nl> # include " base / strings / stringprintf . h " <nl> # include " base / task_scheduler / post_task . h " <nl> - # include " base / threading / sequenced_worker_pool . h " <nl> # include " chrome / common / chrome_paths . h " <nl> # include " chrome / common / pref_names . h " <nl> # include " components / prefs / pref_registry_simple . h " <nl> std : : vector < std : : string > AtomBrowserContext : : GetCookieableSchemes ( ) { <nl> return default_schemes ; <nl> } <nl> <nl> - void AtomBrowserContext : : NotifyCookieChange ( <nl> - const net : : CanonicalCookie & cookie , <nl> - bool removed , <nl> - net : : CookieStore : : ChangeCause cause ) { <nl> + void AtomBrowserContext : : NotifyCookieChange ( const net : : CanonicalCookie & cookie , <nl> + bool removed , <nl> + net : : CookieChangeCause cause ) { <nl> CookieDetails cookie_details ( & cookie , removed , cause ) ; <nl> cookie_change_sub_list_ . Notify ( & cookie_details ) ; <nl> } <nl> AtomBlobReader * AtomBrowserContext : : GetBlobReader ( ) { <nl> if ( ! blob_reader_ . get ( ) ) { <nl> content : : ChromeBlobStorageContext * blob_context = <nl> content : : ChromeBlobStorageContext : : GetFor ( this ) ; <nl> - storage : : FileSystemContext * file_system_context = <nl> - content : : BrowserContext : : GetStoragePartition ( this , nullptr ) <nl> - - > GetFileSystemContext ( ) ; <nl> - blob_reader_ . reset ( new AtomBlobReader ( blob_context , file_system_context ) ) ; <nl> + blob_reader_ . reset ( new AtomBlobReader ( blob_context ) ) ; <nl> } <nl> return blob_reader_ . get ( ) ; <nl> } <nl> mmm a / atom / browser / atom_browser_context . h <nl> ppp b / atom / browser / atom_browser_context . h <nl> class AtomBrowserContext : public brightray : : BrowserContext { <nl> std : : vector < std : : string > GetCookieableSchemes ( ) override ; <nl> void NotifyCookieChange ( const net : : CanonicalCookie & cookie , <nl> bool removed , <nl> - net : : CookieStore : : ChangeCause cause ) override ; <nl> + net : : CookieChangeCause cause ) override ; <nl> <nl> / / content : : BrowserContext : <nl> content : : DownloadManagerDelegate * GetDownloadManagerDelegate ( ) override ; <nl> mmm a / atom / browser / atom_browser_main_parts . cc <nl> ppp b / atom / browser / atom_browser_main_parts . cc <nl> <nl> <nl> # include " atom / browser / api / atom_api_app . h " <nl> # include " atom / browser / api / trackable_object . h " <nl> - # include " atom / browser / atom_access_token_store . h " <nl> # include " atom / browser / atom_browser_client . h " <nl> # include " atom / browser / atom_browser_context . h " <nl> # include " atom / browser / bridge_task_runner . h " <nl> <nl> # include " base / threading / thread_task_runner_handle . h " <nl> # include " chrome / browser / browser_process . h " <nl> # include " content / public / browser / child_process_security_policy . h " <nl> - # include " device / geolocation / geolocation_delegate . h " <nl> - # include " device / geolocation / geolocation_provider . h " <nl> + # include " content / public / common / result_codes . h " <nl> + # include " content / public / common / service_manager_connection . h " <nl> + # include " services / device / public / mojom / constants . mojom . h " <nl> + # include " services / service_manager / public / cpp / connector . h " <nl> # include " ui / base / idle / idle . h " <nl> # include " ui / base / l10n / l10n_util . h " <nl> - # include " v8 / include / v8 - debug . h " <nl> <nl> # if defined ( USE_X11 ) <nl> # include " chrome / browser / ui / libgtkui / gtk_util . h " <nl> namespace atom { <nl> <nl> namespace { <nl> <nl> - / / A provider of Geolocation services to override AccessTokenStore . <nl> - class AtomGeolocationDelegate : public device : : GeolocationDelegate { <nl> - public : <nl> - AtomGeolocationDelegate ( ) { <nl> - device : : GeolocationProvider : : GetInstance ( ) <nl> - - > UserDidOptIntoLocationServices ( ) ; <nl> - } <nl> - <nl> - scoped_refptr < device : : AccessTokenStore > CreateAccessTokenStore ( ) final { <nl> - return new AtomAccessTokenStore ( ) ; <nl> - } <nl> - <nl> - private : <nl> - DISALLOW_COPY_AND_ASSIGN ( AtomGeolocationDelegate ) ; <nl> - } ; <nl> - <nl> template < typename T > <nl> void Erase ( T * container , typename T : : iterator iter ) { <nl> container - > erase ( iter ) ; <nl> void AtomBrowserMainParts : : RegisterDestructionCallback ( <nl> destructors_ . insert ( destructors_ . begin ( ) , std : : move ( callback ) ) ; <nl> } <nl> <nl> - void AtomBrowserMainParts : : PreEarlyInitialization ( ) { <nl> - brightray : : BrowserMainParts : : PreEarlyInitialization ( ) ; <nl> + int AtomBrowserMainParts : : PreEarlyInitialization ( ) { <nl> + const int result = brightray : : BrowserMainParts : : PreEarlyInitialization ( ) ; <nl> + if ( result ! = content : : RESULT_CODE_NORMAL_EXIT ) <nl> + return result ; <nl> + <nl> # if defined ( OS_POSIX ) <nl> HandleSIGCHLD ( ) ; <nl> # endif <nl> + <nl> + return content : : RESULT_CODE_NORMAL_EXIT ; <nl> } <nl> <nl> void AtomBrowserMainParts : : PostEarlyInitialization ( ) { <nl> void AtomBrowserMainParts : : PostMainMessageLoopStart ( ) { <nl> # if defined ( OS_POSIX ) <nl> HandleShutdownSignals ( ) ; <nl> # endif <nl> - device : : GeolocationProvider : : SetGeolocationDelegate ( <nl> - new AtomGeolocationDelegate ( ) ) ; <nl> + / / TODO ( deepak1556 ) : Enable this optionally based on response <nl> + / / from AtomPermissionManager . <nl> + GetGeolocationControl ( ) - > UserDidOptIntoLocationServices ( ) ; <nl> } <nl> <nl> void AtomBrowserMainParts : : PostMainMessageLoopRun ( ) { <nl> void AtomBrowserMainParts : : PostMainMessageLoopRun ( ) { <nl> } <nl> } <nl> <nl> + device : : mojom : : GeolocationControl * <nl> + AtomBrowserMainParts : : GetGeolocationControl ( ) { <nl> + if ( geolocation_control_ ) <nl> + return geolocation_control_ . get ( ) ; <nl> + <nl> + auto request = mojo : : MakeRequest ( & geolocation_control_ ) ; <nl> + if ( ! content : : ServiceManagerConnection : : GetForProcess ( ) ) <nl> + return geolocation_control_ . get ( ) ; <nl> + <nl> + service_manager : : Connector * connector = <nl> + content : : ServiceManagerConnection : : GetForProcess ( ) - > GetConnector ( ) ; <nl> + connector - > BindInterface ( device : : mojom : : kServiceName , std : : move ( request ) ) ; <nl> + return geolocation_control_ . get ( ) ; <nl> + } <nl> + <nl> } / / namespace atom <nl> mmm a / atom / browser / atom_browser_main_parts . h <nl> ppp b / atom / browser / atom_browser_main_parts . h <nl> <nl> # include " base / timer / timer . h " <nl> # include " brightray / browser / browser_main_parts . h " <nl> # include " content / public / browser / browser_context . h " <nl> + # include " services / device / public / mojom / geolocation_control . mojom . h " <nl> <nl> class BrowserProcess ; <nl> <nl> class AtomBrowserMainParts : public brightray : : BrowserMainParts { <nl> <nl> protected : <nl> / / content : : BrowserMainParts : <nl> - void PreEarlyInitialization ( ) override ; <nl> + int PreEarlyInitialization ( ) override ; <nl> void PostEarlyInitialization ( ) override ; <nl> int PreCreateThreads ( ) override ; <nl> void ToolkitInitialized ( ) override ; <nl> class AtomBrowserMainParts : public brightray : : BrowserMainParts { <nl> std : : unique_ptr < brightray : : ViewsDelegate > views_delegate_ ; <nl> # endif <nl> <nl> + device : : mojom : : GeolocationControl * GetGeolocationControl ( ) ; <nl> + <nl> / / A fake BrowserProcess object that used to feed the source code from chrome . <nl> std : : unique_ptr < BrowserProcess > fake_browser_process_ ; <nl> <nl> class AtomBrowserMainParts : public brightray : : BrowserMainParts { <nl> / / List of callbacks should be executed before destroying JS env . <nl> std : : list < base : : OnceClosure > destructors_ ; <nl> <nl> + device : : mojom : : GeolocationControlPtr geolocation_control_ ; <nl> + <nl> static AtomBrowserMainParts * self_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( AtomBrowserMainParts ) ; <nl> mmm a / atom / browser / atom_download_manager_delegate . cc <nl> ppp b / atom / browser / atom_download_manager_delegate . cc <nl> <nl> # include " atom / common / options_switches . h " <nl> # include " base / bind . h " <nl> # include " base / files / file_util . h " <nl> + # include " base / task_scheduler / post_task . h " <nl> # include " chrome / common / pref_names . h " <nl> + # include " components / download / public / common / download_danger_type . h " <nl> # include " components / prefs / pref_service . h " <nl> # include " content / public / browser / browser_context . h " <nl> # include " content / public / browser / browser_thread . h " <nl> + # include " content / public / browser / download_item_utils . h " <nl> # include " content / public / browser / download_manager . h " <nl> # include " net / base / filename_util . h " <nl> <nl> namespace atom { <nl> namespace { <nl> <nl> / / Generate default file path to save the download . <nl> - void CreateDownloadPath ( <nl> - const GURL & url , <nl> - const std : : string & content_disposition , <nl> - const std : : string & suggested_filename , <nl> - const std : : string & mime_type , <nl> - const base : : FilePath & default_download_path , <nl> - const AtomDownloadManagerDelegate : : CreateDownloadPathCallback & callback ) { <nl> - DCHECK_CURRENTLY_ON ( content : : BrowserThread : : FILE ) ; <nl> - <nl> + base : : FilePath CreateDownloadPath ( const GURL & url , <nl> + const std : : string & content_disposition , <nl> + const std : : string & suggested_filename , <nl> + const std : : string & mime_type , <nl> + const base : : FilePath & default_download_path ) { <nl> auto generated_name = <nl> net : : GenerateFileName ( url , content_disposition , std : : string ( ) , <nl> suggested_filename , mime_type , " download " ) ; <nl> void CreateDownloadPath ( <nl> if ( ! base : : PathExists ( default_download_path ) ) <nl> base : : CreateDirectory ( default_download_path ) ; <nl> <nl> - base : : FilePath path ( default_download_path . Append ( generated_name ) ) ; <nl> - content : : BrowserThread : : PostTask ( content : : BrowserThread : : UI , FROM_HERE , <nl> - base : : BindOnce ( callback , path ) ) ; <nl> + return default_download_path . Append ( generated_name ) ; <nl> } <nl> <nl> } / / namespace <nl> AtomDownloadManagerDelegate : : ~ AtomDownloadManagerDelegate ( ) { <nl> } <nl> } <nl> <nl> - void AtomDownloadManagerDelegate : : GetItemSavePath ( content : : DownloadItem * item , <nl> + void AtomDownloadManagerDelegate : : GetItemSavePath ( download : : DownloadItem * item , <nl> base : : FilePath * path ) { <nl> v8 : : Isolate * isolate = v8 : : Isolate : : GetCurrent ( ) ; <nl> v8 : : Locker locker ( isolate ) ; <nl> void AtomDownloadManagerDelegate : : OnDownloadPathGenerated ( <nl> return ; <nl> <nl> NativeWindow * window = nullptr ; <nl> - content : : WebContents * web_contents = item - > GetWebContents ( ) ; <nl> + content : : WebContents * web_contents = <nl> + content : : DownloadItemUtils : : GetWebContents ( item ) ; <nl> auto * relay = <nl> web_contents ? NativeWindowRelay : : FromWebContents ( web_contents ) : nullptr ; <nl> if ( relay ) <nl> void AtomDownloadManagerDelegate : : OnDownloadPathGenerated ( <nl> / / Running the DownloadTargetCallback with an empty FilePath signals that the <nl> / / download should be cancelled . <nl> / / If user cancels the file save dialog , run the callback with empty FilePath . <nl> - callback . Run ( path , content : : DownloadItem : : TARGET_DISPOSITION_PROMPT , <nl> - content : : DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS , path , <nl> - path . empty ( ) ? content : : DOWNLOAD_INTERRUPT_REASON_USER_CANCELED <nl> - : content : : DOWNLOAD_INTERRUPT_REASON_NONE ) ; <nl> + callback . Run ( path , download : : DownloadItem : : TARGET_DISPOSITION_PROMPT , <nl> + download : : DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS , path , <nl> + path . empty ( ) ? download : : DOWNLOAD_INTERRUPT_REASON_USER_CANCELED <nl> + : download : : DOWNLOAD_INTERRUPT_REASON_NONE ) ; <nl> } <nl> <nl> void AtomDownloadManagerDelegate : : Shutdown ( ) { <nl> void AtomDownloadManagerDelegate : : Shutdown ( ) { <nl> } <nl> <nl> bool AtomDownloadManagerDelegate : : DetermineDownloadTarget ( <nl> - content : : DownloadItem * download , <nl> + download : : DownloadItem * download , <nl> const content : : DownloadTargetCallback & callback ) { <nl> DCHECK_CURRENTLY_ON ( content : : BrowserThread : : UI ) ; <nl> <nl> if ( ! download - > GetForcedFilePath ( ) . empty ( ) ) { <nl> callback . Run ( download - > GetForcedFilePath ( ) , <nl> - content : : DownloadItem : : TARGET_DISPOSITION_OVERWRITE , <nl> - content : : DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS , <nl> + download : : DownloadItem : : TARGET_DISPOSITION_OVERWRITE , <nl> + download : : DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS , <nl> download - > GetForcedFilePath ( ) , <nl> - content : : DOWNLOAD_INTERRUPT_REASON_NONE ) ; <nl> + download : : DOWNLOAD_INTERRUPT_REASON_NONE ) ; <nl> return true ; <nl> } <nl> <nl> bool AtomDownloadManagerDelegate : : DetermineDownloadTarget ( <nl> base : : FilePath save_path ; <nl> GetItemSavePath ( download , & save_path ) ; <nl> if ( ! save_path . empty ( ) ) { <nl> - callback . Run ( save_path , content : : DownloadItem : : TARGET_DISPOSITION_OVERWRITE , <nl> - content : : DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS , save_path , <nl> - content : : DOWNLOAD_INTERRUPT_REASON_NONE ) ; <nl> + callback . Run ( save_path , <nl> + download : : DownloadItem : : TARGET_DISPOSITION_OVERWRITE , <nl> + download : : DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS , <nl> + save_path , download : : DOWNLOAD_INTERRUPT_REASON_NONE ) ; <nl> return true ; <nl> } <nl> <nl> bool AtomDownloadManagerDelegate : : DetermineDownloadTarget ( <nl> base : : FilePath default_download_path = <nl> browser_context - > prefs ( ) - > GetFilePath ( prefs : : kDownloadDefaultDirectory ) ; <nl> <nl> - CreateDownloadPathCallback download_path_callback = <nl> - base : : Bind ( & AtomDownloadManagerDelegate : : OnDownloadPathGenerated , <nl> - weak_ptr_factory_ . GetWeakPtr ( ) , download - > GetId ( ) , callback ) ; <nl> - <nl> - content : : BrowserThread : : PostTask ( <nl> - content : : BrowserThread : : FILE , FROM_HERE , <nl> + base : : PostTaskWithTraitsAndReplyWithResult ( <nl> + FROM_HERE , <nl> + { base : : MayBlock ( ) , base : : TaskPriority : : BACKGROUND , <nl> + base : : TaskShutdownBehavior : : SKIP_ON_SHUTDOWN } , <nl> base : : BindOnce ( & CreateDownloadPath , download - > GetURL ( ) , <nl> download - > GetContentDisposition ( ) , <nl> download - > GetSuggestedFilename ( ) , download - > GetMimeType ( ) , <nl> - default_download_path , download_path_callback ) ) ; <nl> + default_download_path ) , <nl> + base : : BindOnce ( & AtomDownloadManagerDelegate : : OnDownloadPathGenerated , <nl> + weak_ptr_factory_ . GetWeakPtr ( ) , download - > GetId ( ) , <nl> + callback ) ) ; <nl> return true ; <nl> } <nl> <nl> bool AtomDownloadManagerDelegate : : ShouldOpenDownload ( <nl> - content : : DownloadItem * download , <nl> + download : : DownloadItem * download , <nl> const content : : DownloadOpenDelayedCallback & callback ) { <nl> return true ; <nl> } <nl> <nl> void AtomDownloadManagerDelegate : : GetNextId ( <nl> const content : : DownloadIdCallback & callback ) { <nl> - static uint32_t next_id = content : : DownloadItem : : kInvalidId + 1 ; <nl> + static uint32_t next_id = download : : DownloadItem : : kInvalidId + 1 ; <nl> callback . Run ( next_id + + ) ; <nl> } <nl> <nl> mmm a / atom / browser / atom_download_manager_delegate . h <nl> ppp b / atom / browser / atom_download_manager_delegate . h <nl> class AtomDownloadManagerDelegate : public content : : DownloadManagerDelegate { <nl> / / content : : DownloadManagerDelegate : <nl> void Shutdown ( ) override ; <nl> bool DetermineDownloadTarget ( <nl> - content : : DownloadItem * download , <nl> + download : : DownloadItem * download , <nl> const content : : DownloadTargetCallback & callback ) override ; <nl> bool ShouldOpenDownload ( <nl> - content : : DownloadItem * download , <nl> + download : : DownloadItem * download , <nl> const content : : DownloadOpenDelayedCallback & callback ) override ; <nl> void GetNextId ( const content : : DownloadIdCallback & callback ) override ; <nl> <nl> private : <nl> / / Get the save path set on the associated api : : DownloadItem object <nl> - void GetItemSavePath ( content : : DownloadItem * item , base : : FilePath * path ) ; <nl> + void GetItemSavePath ( download : : DownloadItem * item , base : : FilePath * path ) ; <nl> <nl> content : : DownloadManager * download_manager_ ; <nl> base : : WeakPtrFactory < AtomDownloadManagerDelegate > weak_ptr_factory_ ; <nl> mmm a / atom / browser / atom_javascript_dialog_manager . cc <nl> ppp b / atom / browser / atom_javascript_dialog_manager . cc <nl> AtomJavaScriptDialogManager : : ~ AtomJavaScriptDialogManager ( ) = default ; <nl> <nl> void AtomJavaScriptDialogManager : : RunJavaScriptDialog ( <nl> content : : WebContents * web_contents , <nl> - const GURL & origin_url , <nl> + content : : RenderFrameHost * rfh , <nl> JavaScriptDialogType dialog_type , <nl> const base : : string16 & message_text , <nl> const base : : string16 & default_prompt_text , <nl> DialogClosedCallback callback , <nl> bool * did_suppress_message ) { <nl> + auto origin_url = rfh - > GetLastCommittedURL ( ) ; <nl> const std : : string & origin = origin_url . GetOrigin ( ) . spec ( ) ; <nl> if ( origin_counts_ [ origin ] = = kUserWantsNoMoreDialogs ) { <nl> return std : : move ( callback ) . Run ( false , base : : string16 ( ) ) ; <nl> void AtomJavaScriptDialogManager : : RunJavaScriptDialog ( <nl> <nl> void AtomJavaScriptDialogManager : : RunBeforeUnloadDialog ( <nl> content : : WebContents * web_contents , <nl> + content : : RenderFrameHost * rfh , <nl> bool is_reload , <nl> DialogClosedCallback callback ) { <nl> bool default_prevented = api_web_contents_ - > Emit ( " will - prevent - unload " ) ; <nl> mmm a / atom / browser / atom_javascript_dialog_manager . h <nl> ppp b / atom / browser / atom_javascript_dialog_manager . h <nl> class AtomJavaScriptDialogManager : public content : : JavaScriptDialogManager { <nl> <nl> / / content : : JavaScriptDialogManager implementations . <nl> void RunJavaScriptDialog ( content : : WebContents * web_contents , <nl> - const GURL & origin_url , <nl> + content : : RenderFrameHost * rfh , <nl> content : : JavaScriptDialogType dialog_type , <nl> const base : : string16 & message_text , <nl> const base : : string16 & default_prompt_text , <nl> DialogClosedCallback callback , <nl> bool * did_suppress_message ) override ; <nl> void RunBeforeUnloadDialog ( content : : WebContents * web_contents , <nl> + content : : RenderFrameHost * rfh , <nl> bool is_reload , <nl> DialogClosedCallback callback ) override ; <nl> void CancelDialogs ( content : : WebContents * web_contents , <nl> mmm a / atom / browser / atom_permission_manager . cc <nl> ppp b / atom / browser / atom_permission_manager . cc <nl> void AtomPermissionManager : : OnPermissionResponse ( <nl> } <nl> } <nl> <nl> - void AtomPermissionManager : : CancelPermissionRequest ( int request_id ) { <nl> - auto * pending_request = pending_requests_ . Lookup ( request_id ) ; <nl> - if ( ! pending_request ) <nl> - return ; <nl> - <nl> - if ( ! WebContentsDestroyed ( pending_request - > render_process_id ( ) ) ) <nl> - pending_request - > RunCallback ( ) ; <nl> - pending_requests_ . Remove ( request_id ) ; <nl> - } <nl> <nl> void AtomPermissionManager : : ResetPermission ( content : : PermissionType permission , <nl> const GURL & requesting_origin , <nl> mmm a / atom / browser / atom_permission_manager . h <nl> ppp b / atom / browser / atom_permission_manager . h <nl> class AtomPermissionManager : public content : : PermissionManager { <nl> blink : : mojom : : PermissionStatus status ) ; <nl> <nl> / / content : : PermissionManager : <nl> - void CancelPermissionRequest ( int request_id ) override ; <nl> void ResetPermission ( content : : PermissionType permission , <nl> const GURL & requesting_origin , <nl> const GURL & embedding_origin ) override ; <nl> mmm a / atom / browser / atom_quota_permission_context . cc <nl> ppp b / atom / browser / atom_quota_permission_context . cc <nl> <nl> <nl> # include " atom / browser / atom_quota_permission_context . h " <nl> <nl> - # include " storage / common / quota / quota_types . h " <nl> - <nl> namespace atom { <nl> <nl> AtomQuotaPermissionContext : : AtomQuotaPermissionContext ( ) { } <nl> mmm a / atom / browser / atom_quota_permission_context . h <nl> ppp b / atom / browser / atom_quota_permission_context . h <nl> <nl> # define ATOM_BROWSER_ATOM_QUOTA_PERMISSION_CONTEXT_H_ <nl> <nl> # include " content / public / browser / quota_permission_context . h " <nl> + # include " content / public / common / storage_quota_params . h " <nl> <nl> namespace atom { <nl> <nl> mmm a / atom / browser / atom_resource_dispatcher_host_delegate . cc <nl> ppp b / atom / browser / atom_resource_dispatcher_host_delegate . cc <nl> <nl> # include " atom / browser / atom_resource_dispatcher_host_delegate . h " <nl> <nl> # include " atom / browser / atom_browser_context . h " <nl> - # include " atom / browser / login_handler . h " <nl> # include " atom / browser / web_contents_permission_helper . h " <nl> # include " atom / browser / web_contents_preferences . h " <nl> # include " atom / common / platform_util . h " <nl> <nl> # include " content / public / browser / download_manager . h " <nl> # include " content / public / browser / render_frame_host . h " <nl> # include " net / base / escape . h " <nl> - # include " net / ssl / client_cert_store . h " <nl> # include " url / gurl . h " <nl> <nl> - # if defined ( USE_NSS_CERTS ) <nl> - # include " net / ssl / client_cert_store_nss . h " <nl> - # elif defined ( OS_WIN ) <nl> - # include " net / ssl / client_cert_store_win . h " <nl> - # elif defined ( OS_MACOSX ) <nl> - # include " net / ssl / client_cert_store_mac . h " <nl> - # endif <nl> - <nl> # if defined ( ENABLE_PDF_VIEWER ) <nl> # include " atom / common / atom_constants . h " <nl> # include " base / strings / stringprintf . h " <nl> bool AtomResourceDispatcherHostDelegate : : HandleExternalProtocol ( <nl> return true ; <nl> } <nl> <nl> - content : : ResourceDispatcherHostLoginDelegate * <nl> - AtomResourceDispatcherHostDelegate : : CreateLoginDelegate ( <nl> - net : : AuthChallengeInfo * auth_info , <nl> - net : : URLRequest * request ) { <nl> - return new LoginHandler ( auth_info , request ) ; <nl> - } <nl> - <nl> - std : : unique_ptr < net : : ClientCertStore > <nl> - AtomResourceDispatcherHostDelegate : : CreateClientCertStore ( <nl> - content : : ResourceContext * resource_context ) { <nl> - # if defined ( USE_NSS_CERTS ) <nl> - return std : : make_unique < net : : ClientCertStoreNSS > ( <nl> - net : : ClientCertStoreNSS : : PasswordDelegateFactory ( ) ) ; <nl> - # elif defined ( OS_WIN ) <nl> - return std : : make_unique < net : : ClientCertStoreWin > ( ) ; <nl> - # elif defined ( OS_MACOSX ) <nl> - return std : : make_unique < net : : ClientCertStoreMac > ( ) ; <nl> - # elif defined ( USE_OPENSSL ) <nl> - return std : : unique_ptr < net : : ClientCertStore > ( ) ; <nl> - # endif <nl> - } <nl> - <nl> bool AtomResourceDispatcherHostDelegate : : ShouldInterceptResourceAsStream ( <nl> net : : URLRequest * request , <nl> - const base : : FilePath & plugin_path , <nl> const std : : string & mime_type , <nl> GURL * origin , <nl> std : : string * payload ) { <nl> mmm a / atom / browser / atom_resource_dispatcher_host_delegate . h <nl> ppp b / atom / browser / atom_resource_dispatcher_host_delegate . h <nl> class AtomResourceDispatcherHostDelegate <nl> / / content : : ResourceDispatcherHostDelegate : <nl> bool HandleExternalProtocol ( const GURL & url , <nl> content : : ResourceRequestInfo * info ) override ; <nl> - content : : ResourceDispatcherHostLoginDelegate * CreateLoginDelegate ( <nl> - net : : AuthChallengeInfo * auth_info , <nl> - net : : URLRequest * request ) override ; <nl> - std : : unique_ptr < net : : ClientCertStore > CreateClientCertStore ( <nl> - content : : ResourceContext * resource_context ) override ; <nl> bool ShouldInterceptResourceAsStream ( net : : URLRequest * request , <nl> - const base : : FilePath & plugin_path , <nl> const std : : string & mime_type , <nl> GURL * origin , <nl> std : : string * payload ) override ; <nl> mmm a / atom / browser / browser . h <nl> ppp b / atom / browser / browser . h <nl> <nl> # include " native_mate / arguments . h " <nl> <nl> # if defined ( OS_WIN ) <nl> + # include < windows . h > <nl> # include " base / files / file_path . h " <nl> # endif <nl> <nl> mmm a / atom / browser / common_web_contents_delegate . cc <nl> ppp b / atom / browser / common_web_contents_delegate . cc <nl> <nl> # include " atom / common / atom_constants . h " <nl> # include " atom / common / options_switches . h " <nl> # include " base / files / file_util . h " <nl> + # include " base / task_scheduler / post_task . h " <nl> + # include " base / threading / sequenced_task_runner_handle . h " <nl> # include " chrome / browser / printing / print_preview_message_handler . h " <nl> # include " chrome / browser / printing / print_view_manager_basic . h " <nl> # include " chrome / browser / ssl / security_state_tab_helper . h " <nl> std : : unique_ptr < base : : DictionaryValue > CreateFileSystemValue ( <nl> } <nl> <nl> void WriteToFile ( const base : : FilePath & path , const std : : string & content ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + base : : AssertBlockingAllowed ( ) ; <nl> DCHECK ( ! path . empty ( ) ) ; <nl> <nl> base : : WriteFile ( path , content . data ( ) , content . size ( ) ) ; <nl> } <nl> <nl> void AppendToFile ( const base : : FilePath & path , const std : : string & content ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + base : : AssertBlockingAllowed ( ) ; <nl> DCHECK ( ! path . empty ( ) ) ; <nl> <nl> base : : AppendToFile ( path , content . data ( ) , content . size ( ) ) ; <nl> bool IsDevToolsFileSystemAdded ( content : : WebContents * web_contents , <nl> } / / namespace <nl> <nl> CommonWebContentsDelegate : : CommonWebContentsDelegate ( ) <nl> - : devtools_file_system_indexer_ ( new DevToolsFileSystemIndexer ) { } <nl> + : devtools_file_system_indexer_ ( new DevToolsFileSystemIndexer ) , <nl> + file_task_runner_ ( <nl> + base : : CreateSequencedTaskRunnerWithTraits ( { base : : MayBlock ( ) } ) ) { } <nl> <nl> CommonWebContentsDelegate : : ~ CommonWebContentsDelegate ( ) { } <nl> <nl> bool CommonWebContentsDelegate : : CanOverscrollContent ( ) const { <nl> content : : ColorChooser * CommonWebContentsDelegate : : OpenColorChooser ( <nl> content : : WebContents * web_contents , <nl> SkColor color , <nl> - const std : : vector < content : : ColorSuggestion > & suggestions ) { <nl> + const std : : vector < blink : : mojom : : ColorSuggestionPtr > & suggestions ) { <nl> return chrome : : ShowColorChooser ( web_contents , color ) ; <nl> } <nl> <nl> void CommonWebContentsDelegate : : DevToolsSaveToFile ( const std : : string & url , <nl> } <nl> <nl> saved_files_ [ url ] = path ; <nl> - BrowserThread : : PostTaskAndReply ( <nl> - BrowserThread : : FILE , FROM_HERE , <nl> - base : : BindOnce ( & WriteToFile , path , content ) , <nl> - base : : BindOnce ( & CommonWebContentsDelegate : : OnDevToolsSaveToFile , <nl> - base : : Unretained ( this ) , url ) ) ; <nl> + / / Notify DevTools . <nl> + base : : Value url_value ( url ) ; <nl> + base : : Value file_system_path_value ( path . AsUTF8Unsafe ( ) ) ; <nl> + web_contents_ - > CallClientFunction ( " DevToolsAPI . savedURL " , & url_value , <nl> + & file_system_path_value , nullptr ) ; <nl> + file_task_runner_ - > PostTask ( FROM_HERE , <nl> + base : : BindOnce ( & WriteToFile , path , content ) ) ; <nl> } <nl> <nl> void CommonWebContentsDelegate : : DevToolsAppendToFile ( <nl> void CommonWebContentsDelegate : : DevToolsAppendToFile ( <nl> if ( it = = saved_files_ . end ( ) ) <nl> return ; <nl> <nl> - BrowserThread : : PostTaskAndReply ( <nl> - BrowserThread : : FILE , FROM_HERE , <nl> - base : : BindOnce ( & AppendToFile , it - > second , content ) , <nl> - base : : BindOnce ( & CommonWebContentsDelegate : : OnDevToolsAppendToFile , <nl> - base : : Unretained ( this ) , url ) ) ; <nl> + / / Notify DevTools . <nl> + base : : Value url_value ( url ) ; <nl> + web_contents_ - > CallClientFunction ( " DevToolsAPI . appendedToURL " , & url_value , <nl> + nullptr , nullptr ) ; <nl> + file_task_runner_ - > PostTask ( <nl> + FROM_HERE , base : : BindOnce ( & AppendToFile , it - > second , content ) ) ; <nl> } <nl> <nl> void CommonWebContentsDelegate : : DevToolsRequestFileSystems ( ) { <nl> void CommonWebContentsDelegate : : DevToolsSearchInPath ( <nl> base : : Unretained ( this ) , request_id , file_system_path ) ) ; <nl> } <nl> <nl> - void CommonWebContentsDelegate : : OnDevToolsSaveToFile ( const std : : string & url ) { <nl> - / / Notify DevTools . <nl> - base : : Value url_value ( url ) ; <nl> - web_contents_ - > CallClientFunction ( " DevToolsAPI . savedURL " , & url_value , nullptr , <nl> - nullptr ) ; <nl> - } <nl> - <nl> - void CommonWebContentsDelegate : : OnDevToolsAppendToFile ( const std : : string & url ) { <nl> - / / Notify DevTools . <nl> - base : : Value url_value ( url ) ; <nl> - web_contents_ - > CallClientFunction ( " DevToolsAPI . appendedToURL " , & url_value , <nl> - nullptr , nullptr ) ; <nl> - } <nl> - <nl> void CommonWebContentsDelegate : : OnDevToolsIndexingWorkCalculated ( <nl> int request_id , <nl> const std : : string & file_system_path , <nl> mmm a / atom / browser / common_web_contents_delegate . h <nl> ppp b / atom / browser / common_web_contents_delegate . h <nl> <nl> <nl> using brightray : : DevToolsFileSystemIndexer ; <nl> <nl> + namespace base { <nl> + class SequencedTaskRunner ; <nl> + } <nl> + <nl> namespace atom { <nl> <nl> class AtomBrowserContext ; <nl> class CommonWebContentsDelegate <nl> content : : ColorChooser * OpenColorChooser ( <nl> content : : WebContents * web_contents , <nl> SkColor color , <nl> - const std : : vector < content : : ColorSuggestion > & suggestions ) override ; <nl> + const std : : vector < blink : : mojom : : ColorSuggestionPtr > & suggestions ) <nl> + override ; <nl> void RunFileChooser ( content : : RenderFrameHost * render_frame_host , <nl> const content : : FileChooserParams & params ) override ; <nl> void EnumerateDirectory ( content : : WebContents * web_contents , <nl> class CommonWebContentsDelegate <nl> void ResetManagedWebContents ( bool async ) ; <nl> <nl> private : <nl> - / / Callback for when DevToolsSaveToFile has completed . <nl> - void OnDevToolsSaveToFile ( const std : : string & url ) ; <nl> - <nl> - / / Callback for when DevToolsAppendToFile has completed . <nl> - void OnDevToolsAppendToFile ( const std : : string & url ) ; <nl> - <nl> / / DevTools index event callbacks . <nl> void OnDevToolsIndexingWorkCalculated ( int request_id , <nl> const std : : string & file_system_path , <nl> class CommonWebContentsDelegate <nl> DevToolsIndexingJobsMap ; <nl> DevToolsIndexingJobsMap devtools_indexing_jobs_ ; <nl> <nl> + scoped_refptr < base : : SequencedTaskRunner > file_task_runner_ ; <nl> + <nl> DISALLOW_COPY_AND_ASSIGN ( CommonWebContentsDelegate ) ; <nl> } ; <nl> <nl> mmm a / atom / browser / javascript_environment . cc <nl> ppp b / atom / browser / javascript_environment . cc <nl> bool JavascriptEnvironment : : Initialize ( ) { <nl> new v8 : : TracingController ( ) ) ; <nl> gin : : IsolateHolder : : Initialize ( <nl> gin : : IsolateHolder : : kNonStrictMode , gin : : IsolateHolder : : kStableV8Extras , <nl> - gin : : ArrayBufferAllocator : : SharedInstance ( ) , false ) ; <nl> + gin : : ArrayBufferAllocator : : SharedInstance ( ) , <nl> + nullptr / * external_reference_table * / , false / * create_v8_platform * / ) ; <nl> return true ; <nl> } <nl> <nl> mmm a / atom / browser / loader / layered_resource_handler . cc <nl> ppp b / atom / browser / loader / layered_resource_handler . cc <nl> LayeredResourceHandler : : LayeredResourceHandler ( <nl> LayeredResourceHandler : : ~ LayeredResourceHandler ( ) { } <nl> <nl> void LayeredResourceHandler : : OnResponseStarted ( <nl> - content : : ResourceResponse * response , <nl> + network : : ResourceResponse * response , <nl> std : : unique_ptr < content : : ResourceController > controller ) { <nl> if ( delegate_ ) <nl> delegate_ - > OnResponseStarted ( response ) ; <nl> mmm a / atom / browser / loader / layered_resource_handler . h <nl> ppp b / atom / browser / loader / layered_resource_handler . h <nl> <nl> # define ATOM_BROWSER_LOADER_LAYERED_RESOURCE_HANDLER_H_ <nl> <nl> # include " content / browser / loader / layered_resource_handler . h " <nl> + # include " services / network / public / cpp / resource_response . h " <nl> <nl> namespace atom { <nl> <nl> class LayeredResourceHandler : public content : : LayeredResourceHandler { <nl> Delegate ( ) { } <nl> virtual ~ Delegate ( ) { } <nl> <nl> - virtual void OnResponseStarted ( content : : ResourceResponse * response ) = 0 ; <nl> + virtual void OnResponseStarted ( network : : ResourceResponse * response ) = 0 ; <nl> } ; <nl> <nl> LayeredResourceHandler ( net : : URLRequest * request , <nl> class LayeredResourceHandler : public content : : LayeredResourceHandler { <nl> <nl> / / content : : LayeredResourceHandler : <nl> void OnResponseStarted ( <nl> - content : : ResourceResponse * response , <nl> + network : : ResourceResponse * response , <nl> std : : unique_ptr < content : : ResourceController > controller ) override ; <nl> <nl> private : <nl> mmm a / atom / browser / login_handler . cc <nl> ppp b / atom / browser / login_handler . cc <nl> <nl> # include " atom / browser / login_handler . h " <nl> <nl> # include " atom / browser / browser . h " <nl> - # include " atom / common / native_mate_converters / net_converter . h " <nl> # include " base / values . h " <nl> # include " content / public / browser / browser_thread . h " <nl> - # include " content / public / browser / render_frame_host . h " <nl> - # include " content / public / browser / resource_dispatcher_host . h " <nl> - # include " content / public / browser / resource_request_info . h " <nl> # include " content / public / browser / web_contents . h " <nl> # include " net / base / auth . h " <nl> - # include " net / url_request / url_request . h " <nl> <nl> using content : : BrowserThread ; <nl> <nl> namespace atom { <nl> <nl> - namespace { <nl> - <nl> - / / Helper to remove the ref from an net : : URLRequest to the LoginHandler . <nl> - / / Should only be called from the IO thread , since it accesses an <nl> - / / net : : URLRequest . <nl> - void ResetLoginHandlerForRequest ( net : : URLRequest * request ) { <nl> - content : : ResourceDispatcherHost : : Get ( ) - > ClearLoginDelegateForRequest ( request ) ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - LoginHandler : : LoginHandler ( net : : AuthChallengeInfo * auth_info , <nl> - net : : URLRequest * request ) <nl> - : auth_info_ ( auth_info ) , request_ ( request ) { <nl> - content : : ResourceRequestInfo : : ForRequest ( request_ ) - > GetAssociatedRenderFrame ( <nl> - & render_process_host_id_ , & render_frame_id_ ) ; <nl> - <nl> + LoginHandler : : LoginHandler ( <nl> + net : : AuthChallengeInfo * auth_info , <nl> + content : : ResourceRequestInfo : : WebContentsGetter web_contents_getter , <nl> + const GURL & url , <nl> + const base : : Callback < void ( const base : : Optional < net : : AuthCredentials > & ) > & <nl> + auth_required_callback ) <nl> + : auth_info_ ( auth_info ) , <nl> + web_contents_getter_ ( web_contents_getter ) , <nl> + auth_required_callback_ ( auth_required_callback ) { <nl> / / Fill request details on IO thread . <nl> + / / TODO ( deepak1556 ) : Fill in method and referrer details to <nl> + / / avoid breaking the app login event . <nl> std : : unique_ptr < base : : DictionaryValue > request_details ( <nl> new base : : DictionaryValue ) ; <nl> - FillRequestDetails ( request_details . get ( ) , request_ ) ; <nl> + request_details - > SetKey ( " url " , base : : Value ( url . spec ( ) ) ) ; <nl> <nl> BrowserThread : : PostTask ( <nl> BrowserThread : : UI , FROM_HERE , <nl> LoginHandler : : ~ LoginHandler ( ) { } <nl> <nl> content : : WebContents * LoginHandler : : GetWebContents ( ) const { <nl> DCHECK_CURRENTLY_ON ( BrowserThread : : UI ) ; <nl> - <nl> - content : : RenderFrameHost * rfh = content : : RenderFrameHost : : FromID ( <nl> - render_process_host_id_ , render_frame_id_ ) ; <nl> - return content : : WebContents : : FromRenderFrameHost ( rfh ) ; <nl> + return web_contents_getter_ . Run ( ) ; <nl> } <nl> <nl> void LoginHandler : : Login ( const base : : string16 & username , <nl> void LoginHandler : : CancelAuth ( ) { <nl> <nl> void LoginHandler : : OnRequestCancelled ( ) { <nl> TestAndSetAuthHandled ( ) ; <nl> - request_ = nullptr ; <nl> + auth_required_callback_ . Reset ( ) ; <nl> } <nl> <nl> / / Marks authentication as handled and returns the previous handled state . <nl> bool LoginHandler : : TestAndSetAuthHandled ( ) { <nl> <nl> void LoginHandler : : DoCancelAuth ( ) { <nl> DCHECK_CURRENTLY_ON ( BrowserThread : : IO ) ; <nl> - <nl> - if ( request_ ) { <nl> - request_ - > CancelAuth ( ) ; <nl> - / / Verify that CancelAuth doesn ' t destroy the request via our delegate . <nl> - DCHECK ( request_ ! = nullptr ) ; <nl> - ResetLoginHandlerForRequest ( request_ ) ; <nl> - } <nl> + if ( ! auth_required_callback_ . is_null ( ) ) <nl> + std : : move ( auth_required_callback_ ) . Run ( base : : nullopt ) ; <nl> } <nl> <nl> void LoginHandler : : DoLogin ( const base : : string16 & username , <nl> const base : : string16 & password ) { <nl> DCHECK_CURRENTLY_ON ( BrowserThread : : IO ) ; <nl> - <nl> - if ( request_ ) { <nl> - request_ - > SetAuth ( net : : AuthCredentials ( username , password ) ) ; <nl> - ResetLoginHandlerForRequest ( request_ ) ; <nl> + if ( ! auth_required_callback_ . is_null ( ) ) { <nl> + std : : move ( auth_required_callback_ ) <nl> + . Run ( net : : AuthCredentials ( username , password ) ) ; <nl> } <nl> } <nl> <nl> mmm a / atom / browser / login_handler . h <nl> ppp b / atom / browser / login_handler . h <nl> <nl> # ifndef ATOM_BROWSER_LOGIN_HANDLER_H_ <nl> # define ATOM_BROWSER_LOGIN_HANDLER_H_ <nl> <nl> + # include " base / callback . h " <nl> + # include " base / optional . h " <nl> # include " base / strings / string16 . h " <nl> # include " base / synchronization / lock . h " <nl> # include " content / public / browser / resource_dispatcher_host_login_delegate . h " <nl> + # include " content / public / browser / resource_request_info . h " <nl> <nl> namespace content { <nl> class WebContents ; <nl> class WebContents ; <nl> <nl> namespace net { <nl> class AuthChallengeInfo ; <nl> - class URLRequest ; <nl> + class AuthCredentials ; <nl> } / / namespace net <nl> <nl> namespace atom { <nl> namespace atom { <nl> / / Handles the HTTP basic auth , must be created on IO thread . <nl> class LoginHandler : public content : : ResourceDispatcherHostLoginDelegate { <nl> public : <nl> - LoginHandler ( net : : AuthChallengeInfo * auth_info , net : : URLRequest * request ) ; <nl> + LoginHandler ( <nl> + net : : AuthChallengeInfo * auth_info , <nl> + content : : ResourceRequestInfo : : WebContentsGetter web_contents_getter , <nl> + const GURL & url , <nl> + const base : : Callback < void ( const base : : Optional < net : : AuthCredentials > & ) > & <nl> + auth_required_callback ) ; <nl> <nl> / / Returns the WebContents associated with the request , must be called on UI <nl> / / thread . <nl> class LoginHandler : public content : : ResourceDispatcherHostLoginDelegate { <nl> / / Who / where / what asked for the authentication . <nl> scoped_refptr < net : : AuthChallengeInfo > auth_info_ ; <nl> <nl> - / / The request that wants login data . <nl> - / / This should only be accessed on the IO loop . <nl> - net : : URLRequest * request_ = nullptr ; <nl> + / / WebContents associated with the login request . <nl> + content : : ResourceRequestInfo : : WebContentsGetter web_contents_getter_ ; <nl> <nl> - / / Cached from the net : : URLRequest , in case it goes NULL on us . <nl> - int render_process_host_id_ = 0 ; <nl> - int render_frame_id_ = 0 ; <nl> + base : : Callback < void ( const base : : Optional < net : : AuthCredentials > & ) > <nl> + auth_required_callback_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( LoginHandler ) ; <nl> } ; <nl> mmm a / atom / browser / mac / atom_application_delegate . mm <nl> ppp b / atom / browser / mac / atom_application_delegate . mm <nl> <nl> # import " atom / browser / mac / atom_application . h " <nl> # include " atom / browser / mac / dict_util . h " <nl> # include " base / allocator / allocator_shim . h " <nl> - # include " base / allocator / features . h " <nl> + # include " base / allocator / buildflags . h " <nl> # include " base / mac / mac_util . h " <nl> # include " base / mac / scoped_objc_class_swizzler . h " <nl> # include " base / strings / sys_string_conversions . h " <nl> mmm a / atom / browser / native_window_mac . mm <nl> ppp b / atom / browser / native_window_mac . mm <nl> void ViewDidMoveToSuperview ( NSView * self , SEL _cmd ) { <nl> } <nl> <nl> gfx : : AcceleratedWidget NativeWindowMac : : GetAcceleratedWidget ( ) const { <nl> - return [ window_ contentView ] ; <nl> + return gfx : : kNullAcceleratedWidget ; <nl> } <nl> <nl> void NativeWindowMac : : SetProgressBar ( double progress , <nl> mmm a / atom / browser / native_window_views . cc <nl> ppp b / atom / browser / native_window_views . cc <nl> <nl> <nl> # if defined ( OS_WIN ) <nl> # include < objbase . h > <nl> + # include < wrl / client . h > <nl> # endif <nl> <nl> # include < vector > <nl> NativeWindowViews : : NativeWindowViews ( const mate : : Dictionary & options , <nl> if ( options . Get ( options : : kDarkTheme , & use_dark_theme ) & & use_dark_theme ) { <nl> XDisplay * xdisplay = gfx : : GetXDisplay ( ) ; <nl> XChangeProperty ( xdisplay , GetAcceleratedWidget ( ) , <nl> - XInternAtom ( xdisplay , " _GTK_THEME_VARIANT " , False ) , <nl> - XInternAtom ( xdisplay , " UTF8_STRING " , False ) , 8 , <nl> + XInternAtom ( xdisplay , " _GTK_THEME_VARIANT " , x11 : : False ) , <nl> + XInternAtom ( xdisplay , " UTF8_STRING " , x11 : : False ) , 8 , <nl> PropModeReplace , <nl> reinterpret_cast < const unsigned char * > ( " dark " ) , 4 ) ; <nl> } <nl> void NativeWindowViews : : FlashFrame ( bool flash ) { <nl> <nl> void NativeWindowViews : : SetSkipTaskbar ( bool skip ) { <nl> # if defined ( OS_WIN ) <nl> - base : : win : : ScopedComPtr < ITaskbarList > taskbar ; <nl> + Microsoft : : WRL : : ComPtr < ITaskbarList > taskbar ; <nl> if ( FAILED ( : : CoCreateInstance ( CLSID_TaskbarList , nullptr , <nl> CLSCTX_INPROC_SERVER , <nl> IID_PPV_ARGS ( & taskbar ) ) ) | | <nl> void NativeWindowViews : : SetBackgroundColor ( SkColor background_color ) { <nl> } <nl> <nl> void NativeWindowViews : : SetHasShadow ( bool has_shadow ) { <nl> - wm : : SetShadowElevation ( GetNativeWindow ( ) , has_shadow <nl> - ? wm : : ShadowElevation : : MEDIUM <nl> - : wm : : ShadowElevation : : NONE ) ; <nl> + wm : : SetShadowElevation ( GetNativeWindow ( ) , <nl> + has_shadow ? wm : : kShadowElevationInactiveWindow <nl> + : wm : : kShadowElevationNone ) ; <nl> } <nl> <nl> bool NativeWindowViews : : HasShadow ( ) { <nl> return GetNativeWindow ( ) - > GetProperty ( wm : : kShadowElevationKey ) ! = <nl> - wm : : ShadowElevation : : NONE ; <nl> + wm : : kShadowElevationNone ; <nl> } <nl> <nl> void NativeWindowViews : : SetOpacity ( const double opacity ) { <nl> void NativeWindowViews : : SetIgnoreMouseEvents ( bool ignore , bool forward ) { <nl> ShapeInput , 0 , 0 , & r , 1 , ShapeSet , YXBanded ) ; <nl> } else { <nl> XShapeCombineMask ( gfx : : GetXDisplay ( ) , GetAcceleratedWidget ( ) , ShapeInput , 0 , <nl> - 0 , None , ShapeSet ) ; <nl> + 0 , x11 : : None , ShapeSet ) ; <nl> } <nl> # endif <nl> } <nl> base : : string16 NativeWindowViews : : GetWindowTitle ( ) const { <nl> return base : : UTF8ToUTF16 ( title_ ) ; <nl> } <nl> <nl> - bool NativeWindowViews : : ShouldHandleSystemCommands ( ) const { <nl> - return true ; <nl> - } <nl> - <nl> views : : View * NativeWindowViews : : GetContentsView ( ) { <nl> return root_view_ . get ( ) ; <nl> } <nl> mmm a / atom / browser / native_window_views . h <nl> ppp b / atom / browser / native_window_views . h <nl> class NativeWindowViews : public NativeWindow , <nl> bool CanMaximize ( ) const override ; <nl> bool CanMinimize ( ) const override ; <nl> base : : string16 GetWindowTitle ( ) const override ; <nl> - bool ShouldHandleSystemCommands ( ) const override ; <nl> views : : View * GetContentsView ( ) override ; <nl> bool ShouldDescendIntoChildForEventHandling ( <nl> gfx : : NativeView child , <nl> mmm a / atom / browser / net / atom_network_delegate . cc <nl> ppp b / atom / browser / net / atom_network_delegate . cc <nl> <nl> # include " atom / common / native_mate_converters / net_converter . h " <nl> # include " base / stl_util . h " <nl> # include " base / strings / string_util . h " <nl> - # include " content / common / devtools / devtools_network_transaction . h " <nl> # include " content / public / browser / browser_thread . h " <nl> # include " content / public / browser / render_frame_host . h " <nl> # include " net / url_request / url_request . h " <nl> + # include " services / network / throttling / throttling_network_transaction . h " <nl> <nl> using content : : BrowserThread ; <nl> - using content : : DevToolsNetworkTransaction ; <nl> + using network : : ThrottlingNetworkTransaction ; <nl> <nl> namespace atom { <nl> <nl> int AtomNetworkDelegate : : OnBeforeStartTransaction ( <nl> const net : : CompletionCallback & callback , <nl> net : : HttpRequestHeaders * headers ) { <nl> if ( ! client_id_ . empty ( ) ) <nl> - headers - > SetHeader ( content : : DevToolsNetworkTransaction : : <nl> + headers - > SetHeader ( network : : ThrottlingNetworkTransaction : : <nl> kDevToolsEmulateNetworkConditionsClientId , <nl> client_id_ ) ; <nl> if ( ! base : : ContainsKey ( response_listeners_ , kOnBeforeSendHeaders ) ) <nl> void AtomNetworkDelegate : : OnBeforeRedirect ( net : : URLRequest * request , <nl> request - > was_cached ( ) ) ; <nl> } <nl> <nl> - void AtomNetworkDelegate : : OnResponseStarted ( net : : URLRequest * request ) { <nl> + void AtomNetworkDelegate : : OnResponseStarted ( net : : URLRequest * request , <nl> + int net_error ) { <nl> if ( ! base : : ContainsKey ( simple_listeners_ , kOnResponseStarted ) ) { <nl> - brightray : : NetworkDelegate : : OnResponseStarted ( request ) ; <nl> + brightray : : NetworkDelegate : : OnResponseStarted ( request , net_error ) ; <nl> return ; <nl> } <nl> <nl> mmm a / atom / browser / net / atom_network_delegate . h <nl> ppp b / atom / browser / net / atom_network_delegate . h <nl> class AtomNetworkDelegate : public brightray : : NetworkDelegate { <nl> GURL * allowed_unsafe_redirect_url ) override ; <nl> void OnBeforeRedirect ( net : : URLRequest * request , <nl> const GURL & new_location ) override ; <nl> - void OnResponseStarted ( net : : URLRequest * request ) override ; <nl> + void OnResponseStarted ( net : : URLRequest * request , int net_error ) override ; <nl> void OnCompleted ( net : : URLRequest * request , bool started ) override ; <nl> void OnURLRequestDestroyed ( net : : URLRequest * request ) override ; <nl> <nl> mmm a / atom / browser / net / atom_url_request . cc <nl> ppp b / atom / browser / net / atom_url_request . cc <nl> void AtomURLRequest : : OnAuthRequired ( net : : URLRequest * request , <nl> this , scoped_refptr < net : : AuthChallengeInfo > ( auth_info ) ) ) ; <nl> } <nl> <nl> - void AtomURLRequest : : OnResponseStarted ( net : : URLRequest * request ) { <nl> + void AtomURLRequest : : OnResponseStarted ( net : : URLRequest * request , <nl> + int net_error ) { <nl> DCHECK_CURRENTLY_ON ( content : : BrowserThread : : IO ) ; <nl> if ( ! request_ ) { <nl> return ; <nl> void AtomURLRequest : : OnResponseStarted ( net : : URLRequest * request ) { <nl> ReadResponse ( ) ; <nl> } else if ( status . status ( ) = = net : : URLRequestStatus : : Status : : FAILED ) { <nl> / / Report error on Start . <nl> - DoCancelWithError ( net : : ErrorToString ( status . ToNetError ( ) ) , true ) ; <nl> + DoCancelWithError ( net : : ErrorToString ( net_error ) , true ) ; <nl> } <nl> / / We don ' t report an error is the request is canceled . <nl> } <nl> mmm a / atom / browser / net / atom_url_request . h <nl> ppp b / atom / browser / net / atom_url_request . h <nl> class AtomURLRequest : public base : : RefCountedThreadSafe < AtomURLRequest > , <nl> bool * defer_redirect ) override ; <nl> void OnAuthRequired ( net : : URLRequest * request , <nl> net : : AuthChallengeInfo * auth_info ) override ; <nl> - void OnResponseStarted ( net : : URLRequest * request ) override ; <nl> + void OnResponseStarted ( net : : URLRequest * request , int net_error ) override ; <nl> void OnReadCompleted ( net : : URLRequest * request , int bytes_read ) override ; <nl> <nl> / / Overrides of net : : URLRequestContextGetterObserver <nl> mmm a / atom / browser / net / cookie_details . h <nl> ppp b / atom / browser / net / cookie_details . h <nl> <nl> # define ATOM_BROWSER_NET_COOKIE_DETAILS_H_ <nl> <nl> # include " base / macros . h " <nl> - # include " net / cookies / cookie_store . h " <nl> + # include " net / cookies / cookie_change_dispatcher . h " <nl> <nl> namespace atom { <nl> <nl> struct CookieDetails { <nl> public : <nl> CookieDetails ( const net : : CanonicalCookie * cookie_copy , <nl> bool is_removed , <nl> - net : : CookieStore : : ChangeCause cause ) <nl> + net : : CookieChangeCause cause ) <nl> : cookie ( cookie_copy ) , removed ( is_removed ) , cause ( cause ) { } <nl> <nl> const net : : CanonicalCookie * cookie ; <nl> bool removed ; <nl> - net : : CookieStore : : ChangeCause cause ; <nl> + net : : CookieChangeCause cause ; <nl> } ; <nl> <nl> } / / namespace atom <nl> mmm a / atom / browser / net / js_asker . cc <nl> ppp b / atom / browser / net / js_asker . cc <nl> void AskForOptions ( v8 : : Isolate * isolate , <nl> } <nl> <nl> bool IsErrorOptions ( base : : Value * value , int * error ) { <nl> - if ( value - > IsType ( base : : Value : : Type : : DICTIONARY ) ) { <nl> + if ( value - > is_dict ( ) ) { <nl> base : : DictionaryValue * dict = static_cast < base : : DictionaryValue * > ( value ) ; <nl> if ( dict - > GetInteger ( " error " , error ) ) <nl> return true ; <nl> - } else if ( value - > IsType ( base : : Value : : Type : : INTEGER ) ) { <nl> + } else if ( value - > is_int ( ) ) { <nl> if ( value - > GetAsInteger ( error ) ) <nl> return true ; <nl> } <nl> mmm a / atom / browser / net / url_request_async_asar_job . cc <nl> ppp b / atom / browser / net / url_request_async_asar_job . cc <nl> URLRequestAsyncAsarJob : : URLRequestAsyncAsarJob ( <nl> <nl> void URLRequestAsyncAsarJob : : StartAsync ( std : : unique_ptr < base : : Value > options ) { <nl> base : : FilePath : : StringType file_path ; <nl> - if ( options - > IsType ( base : : Value : : Type : : DICTIONARY ) ) { <nl> + if ( options - > is_dict ( ) ) { <nl> static_cast < base : : DictionaryValue * > ( options . get ( ) ) <nl> - > GetString ( " path " , & file_path ) ; <nl> - } else if ( options - > IsType ( base : : Value : : Type : : STRING ) ) { <nl> + } else if ( options - > is_string ( ) ) { <nl> options - > GetAsString ( & file_path ) ; <nl> } <nl> <nl> mmm a / atom / browser / net / url_request_buffer_job . cc <nl> ppp b / atom / browser / net / url_request_buffer_job . cc <nl> URLRequestBufferJob : : ~ URLRequestBufferJob ( ) = default ; <nl> <nl> void URLRequestBufferJob : : StartAsync ( std : : unique_ptr < base : : Value > options ) { <nl> const base : : Value * binary = nullptr ; <nl> - if ( options - > IsType ( base : : Value : : Type : : DICTIONARY ) ) { <nl> + if ( options - > is_dict ( ) ) { <nl> base : : DictionaryValue * dict = <nl> static_cast < base : : DictionaryValue * > ( options . get ( ) ) ; <nl> dict - > GetString ( " mimeType " , & mime_type_ ) ; <nl> dict - > GetString ( " charset " , & charset_ ) ; <nl> dict - > GetBinary ( " data " , & binary ) ; <nl> - } else if ( options - > IsType ( base : : Value : : Type : : BINARY ) ) { <nl> + } else if ( options - > is_blob ( ) ) { <nl> binary = options . get ( ) ; <nl> } <nl> <nl> mmm a / atom / browser / net / url_request_fetch_job . cc <nl> ppp b / atom / browser / net / url_request_fetch_job . cc <nl> void URLRequestFetchJob : : BeforeStartInUI ( v8 : : Isolate * isolate , <nl> } <nl> <nl> void URLRequestFetchJob : : StartAsync ( std : : unique_ptr < base : : Value > options ) { <nl> - if ( ! options - > IsType ( base : : Value : : Type : : DICTIONARY ) ) { <nl> + if ( ! options - > is_dict ( ) ) { <nl> NotifyStartError ( net : : URLRequestStatus ( net : : URLRequestStatus : : FAILED , <nl> net : : ERR_NOT_IMPLEMENTED ) ) ; <nl> return ; <nl> mmm a / atom / browser / net / url_request_string_job . cc <nl> ppp b / atom / browser / net / url_request_string_job . cc <nl> URLRequestStringJob : : URLRequestStringJob ( net : : URLRequest * request , <nl> URLRequestStringJob : : ~ URLRequestStringJob ( ) = default ; <nl> <nl> void URLRequestStringJob : : StartAsync ( std : : unique_ptr < base : : Value > options ) { <nl> - if ( options - > IsType ( base : : Value : : Type : : DICTIONARY ) ) { <nl> + if ( options - > is_dict ( ) ) { <nl> base : : DictionaryValue * dict = <nl> static_cast < base : : DictionaryValue * > ( options . get ( ) ) ; <nl> dict - > GetString ( " mimeType " , & mime_type_ ) ; <nl> dict - > GetString ( " charset " , & charset_ ) ; <nl> dict - > GetString ( " data " , & data_ ) ; <nl> - } else if ( options - > IsType ( base : : Value : : Type : : STRING ) ) { <nl> + } else if ( options - > is_string ( ) ) { <nl> options - > GetAsString ( & data_ ) ; <nl> } <nl> net : : URLRequestSimpleJob : : Start ( ) ; <nl> mmm a / atom / browser / osr / osr_render_widget_host_view . cc <nl> ppp b / atom / browser / osr / osr_render_widget_host_view . cc <nl> <nl> # include " base / memory / ptr_util . h " <nl> # include " base / single_thread_task_runner . h " <nl> # include " base / time / time . h " <nl> + # include " components / viz / common / features . h " <nl> # include " components / viz / common / frame_sinks / copy_output_request . h " <nl> # include " components / viz / common / frame_sinks / delay_based_time_source . h " <nl> # include " components / viz / common / gl_helper . h " <nl> <nl> # include " content / browser / renderer_host / compositor_resize_lock . h " <nl> # include " content / browser / renderer_host / render_widget_host_delegate . h " <nl> # include " content / browser / renderer_host / render_widget_host_impl . h " <nl> - # include " content / browser / renderer_host / render_widget_host_view_frame_subscriber . h " <nl> # include " content / common / view_messages . h " <nl> # include " content / public / browser / browser_thread . h " <nl> # include " content / public / browser / context_factory . h " <nl> + # include " content / public / browser / render_process_host . h " <nl> # include " media / base / video_frame . h " <nl> # include " third_party / WebKit / public / platform / WebInputEvent . h " <nl> # include " ui / compositor / compositor . h " <nl> class AtomCopyFrameGenerator { <nl> & AtomCopyFrameGenerator : : CopyFromCompositingSurfaceHasResult , <nl> weak_ptr_factory_ . GetWeakPtr ( ) , damage_rect ) ) ; <nl> <nl> - request - > set_area ( gfx : : Rect ( view_ - > GetPhysicalBackingSize ( ) ) ) ; <nl> + request - > set_area ( gfx : : Rect ( view_ - > GetCompositorViewportPixelSize ( ) ) ) ; <nl> view_ - > GetRootLayer ( ) - > RequestCopyOfOutput ( std : : move ( request ) ) ; <nl> } <nl> <nl> OffScreenRenderWidgetHostView : : OffScreenRenderWidgetHostView ( <nl> # if ! defined ( OS_MACOSX ) <nl> delegated_frame_host_ = std : : make_unique < content : : DelegatedFrameHost > ( <nl> AllocateFrameSinkId ( is_guest_view_hack ) , this , <nl> - false / * enable_surface_synchronization * / ) ; <nl> + features : : IsSurfaceSynchronizationEnabled ( ) , <nl> + base : : FeatureList : : IsEnabled ( features : : kVizDisplayCompositor ) , <nl> + true / * should_register_frame_sink_id * / ) ; <nl> <nl> root_layer_ . reset ( new ui : : Layer ( ui : : LAYER_SOLID_COLOR ) ) ; <nl> # endif <nl> <nl> local_surface_id_ = local_surface_id_allocator_ . GenerateId ( ) ; <nl> <nl> + / / Surface synchronization is not supported with OSR . <nl> + DCHECK ( ! features : : IsSurfaceSynchronizationEnabled ( ) ) ; <nl> + <nl> # if defined ( OS_MACOSX ) <nl> CreatePlatformWidget ( is_guest_view_hack ) ; <nl> # else <nl> OffScreenRenderWidgetHostView : : OffScreenRenderWidgetHostView ( <nl> new ui : : Compositor ( context_factory_private - > AllocateFrameSinkId ( ) , <nl> content : : GetContextFactory ( ) , context_factory_private , <nl> base : : ThreadTaskRunnerHandle : : Get ( ) , <nl> - false / * enable_surface_synchronization * / , <nl> + features : : IsSurfaceSynchronizationEnabled ( ) , <nl> false / * enable_pixel_canvas * / ) ) ; <nl> compositor_ - > SetAcceleratedWidget ( gfx : : kNullAcceleratedWidget ) ; <nl> compositor_ - > SetRootLayer ( root_layer_ . get ( ) ) ; <nl> void OffScreenRenderWidgetHostView : : SendBeginFrame ( <nl> renderer_compositor_frame_sink_ - > OnBeginFrame ( begin_frame_args ) ; <nl> } <nl> <nl> - bool OffScreenRenderWidgetHostView : : OnMessageReceived ( <nl> - const IPC : : Message & message ) { <nl> - bool handled = true ; <nl> - IPC_BEGIN_MESSAGE_MAP ( OffScreenRenderWidgetHostView , message ) <nl> - IPC_MESSAGE_HANDLER ( ViewHostMsg_SetNeedsBeginFrames , SetNeedsBeginFrames ) <nl> - IPC_MESSAGE_UNHANDLED ( handled = false ) <nl> - IPC_END_MESSAGE_MAP ( ) <nl> - <nl> - if ( ! handled ) <nl> - return content : : RenderWidgetHostViewBase : : OnMessageReceived ( message ) ; <nl> - return handled ; <nl> - } <nl> - <nl> void OffScreenRenderWidgetHostView : : InitAsChild ( gfx : : NativeView ) { <nl> DCHECK ( parent_host_view_ ) ; <nl> <nl> void OffScreenRenderWidgetHostView : : InitAsChild ( gfx : : NativeView ) { <nl> Show ( ) ; <nl> } <nl> <nl> - content : : RenderWidgetHost * OffScreenRenderWidgetHostView : : GetRenderWidgetHost ( ) <nl> - const { <nl> - return render_widget_host_ ; <nl> - } <nl> - <nl> void OffScreenRenderWidgetHostView : : SetSize ( const gfx : : Size & size ) { <nl> size_ = size ; <nl> WasResized ( ) ; <nl> void OffScreenRenderWidgetHostView : : Show ( ) { <nl> browser_compositor_ - > SetRenderWidgetHostIsHidden ( false ) ; <nl> # else <nl> delegated_frame_host_ - > SetCompositor ( compositor_ . get ( ) ) ; <nl> - delegated_frame_host_ - > WasShown ( ui : : LatencyInfo ( ) ) ; <nl> + delegated_frame_host_ - > WasShown ( <nl> + GetLocalSurfaceId ( ) , GetRootLayer ( ) - > bounds ( ) . size ( ) , ui : : LatencyInfo ( ) ) ; <nl> # endif <nl> <nl> if ( render_widget_host_ ) <nl> void OffScreenRenderWidgetHostView : : DidCreateNewRendererCompositorFrameSink ( <nl> <nl> void OffScreenRenderWidgetHostView : : SubmitCompositorFrame ( <nl> const viz : : LocalSurfaceId & local_surface_id , <nl> - viz : : CompositorFrame frame ) { <nl> + viz : : CompositorFrame frame , <nl> + viz : : mojom : : HitTestRegionListPtr hit_test_region_list ) { <nl> TRACE_EVENT0 ( " electron " , <nl> " OffScreenRenderWidgetHostView : : SubmitCompositorFrame " ) ; <nl> <nl> void OffScreenRenderWidgetHostView : : SubmitCompositorFrame ( <nl> / / We would normally call BrowserCompositorMac : : SubmitCompositorFrame on <nl> / / macOS , however it contains compositor resize logic that we don ' t want . <nl> / / Consequently we instead call the SubmitCompositorFrame method directly . <nl> - GetDelegatedFrameHost ( ) - > SubmitCompositorFrame ( local_surface_id , <nl> - std : : move ( frame ) ) ; <nl> + GetDelegatedFrameHost ( ) - > SubmitCompositorFrame ( <nl> + local_surface_id , std : : move ( frame ) , std : : move ( hit_test_region_list ) ) ; <nl> } else { <nl> if ( ! copy_frame_generator_ . get ( ) ) { <nl> copy_frame_generator_ . reset ( <nl> void OffScreenRenderWidgetHostView : : SubmitCompositorFrame ( <nl> / / We would normally call BrowserCompositorMac : : SubmitCompositorFrame on <nl> / / macOS , however it contains compositor resize logic that we don ' t want . <nl> / / Consequently we instead call the SubmitCompositorFrame method directly . <nl> - GetDelegatedFrameHost ( ) - > SubmitCompositorFrame ( local_surface_id , <nl> - std : : move ( frame ) ) ; <nl> + GetDelegatedFrameHost ( ) - > SubmitCompositorFrame ( <nl> + local_surface_id , std : : move ( frame ) , std : : move ( hit_test_region_list ) ) ; <nl> <nl> / / Request a copy of the last compositor frame which will eventually call <nl> / / OnPaint asynchronously . <nl> void OffScreenRenderWidgetHostView : : SelectionBoundsChanged ( <nl> const ViewHostMsg_SelectionBounds_Params & ) { } <nl> <nl> void OffScreenRenderWidgetHostView : : CopyFromSurface ( <nl> - const gfx : : Rect & src_subrect , <nl> - const gfx : : Size & dst_size , <nl> - const content : : ReadbackRequestCallback & callback , <nl> - const SkColorType preferred_color_type ) { <nl> - GetDelegatedFrameHost ( ) - > CopyFromCompositingSurface ( <nl> - src_subrect , dst_size , callback , preferred_color_type ) ; <nl> - } <nl> - <nl> - void OffScreenRenderWidgetHostView : : CopyFromSurfaceToVideoFrame ( <nl> - const gfx : : Rect & src_subrect , <nl> - scoped_refptr < media : : VideoFrame > target , <nl> - const base : : Callback < void ( const gfx : : Rect & , bool ) > & callback ) { <nl> - GetDelegatedFrameHost ( ) - > CopyFromCompositingSurfaceToVideoFrame ( <nl> - src_subrect , target , callback ) ; <nl> - } <nl> - <nl> - void OffScreenRenderWidgetHostView : : BeginFrameSubscription ( <nl> - std : : unique_ptr < content : : RenderWidgetHostViewFrameSubscriber > subscriber ) { <nl> - GetDelegatedFrameHost ( ) - > BeginFrameSubscription ( std : : move ( subscriber ) ) ; <nl> + const gfx : : Rect & src_rect , <nl> + const gfx : : Size & output_size , <nl> + base : : OnceCallback < void ( const SkBitmap & ) > callback ) { <nl> + GetDelegatedFrameHost ( ) - > CopyFromCompositingSurface ( src_rect , output_size , <nl> + std : : move ( callback ) ) ; <nl> } <nl> <nl> - void OffScreenRenderWidgetHostView : : EndFrameSubscription ( ) { <nl> - GetDelegatedFrameHost ( ) - > EndFrameSubscription ( ) ; <nl> + void OffScreenRenderWidgetHostView : : GetScreenInfo ( <nl> + content : : ScreenInfo * screen_info ) const { <nl> + screen_info - > depth = 24 ; <nl> + screen_info - > depth_per_component = 8 ; <nl> + screen_info - > orientation_angle = 0 ; <nl> + screen_info - > device_scale_factor = 1 . 0 ; <nl> + screen_info - > orientation_type = <nl> + content : : SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY ; <nl> + screen_info - > rect = gfx : : Rect ( size_ ) ; <nl> + screen_info - > available_rect = gfx : : Rect ( size_ ) ; <nl> } <nl> <nl> void OffScreenRenderWidgetHostView : : InitAsGuest ( <nl> void OffScreenRenderWidgetHostView : : InitAsGuest ( <nl> parent_host_view_ - > RegisterGuestViewFrameSwappedCallback ( guest_view ) ; <nl> } <nl> <nl> - bool OffScreenRenderWidgetHostView : : HasAcceleratedSurface ( const gfx : : Size & ) { <nl> - return false ; <nl> + gfx : : Vector2d OffScreenRenderWidgetHostView : : GetOffsetFromRootSurface ( ) { <nl> + return gfx : : Vector2d ( ) ; <nl> } <nl> <nl> gfx : : Rect OffScreenRenderWidgetHostView : : GetBoundsInRootWindow ( ) { <nl> return gfx : : Rect ( size_ ) ; <nl> } <nl> <nl> + content : : RenderWidgetHostImpl * <nl> + OffScreenRenderWidgetHostView : : GetRenderWidgetHostImpl ( ) const { <nl> + return render_widget_host_ ; <nl> + } <nl> + <nl> + viz : : SurfaceId OffScreenRenderWidgetHostView : : GetCurrentSurfaceId ( ) const { <nl> + return GetDelegatedFrameHost ( ) <nl> + ? GetDelegatedFrameHost ( ) - > GetCurrentSurfaceId ( ) <nl> + : viz : : SurfaceId ( ) ; <nl> + } <nl> + <nl> void OffScreenRenderWidgetHostView : : ImeCompositionRangeChanged ( <nl> const gfx : : Range & , <nl> const std : : vector < gfx : : Rect > & ) { } <nl> <nl> - gfx : : Size OffScreenRenderWidgetHostView : : GetPhysicalBackingSize ( ) const { <nl> + gfx : : Size OffScreenRenderWidgetHostView : : GetCompositorViewportPixelSize ( ) <nl> + const { <nl> return gfx : : ScaleToCeiledSize ( GetRequestedRendererSize ( ) , scale_factor_ ) ; <nl> } <nl> <nl> bool OffScreenRenderWidgetHostView : : DelegatedFrameHostIsVisible ( ) const { <nl> return ! render_widget_host_ - > is_hidden ( ) ; <nl> } <nl> <nl> - SkColor OffScreenRenderWidgetHostView : : DelegatedFrameHostGetGutterColor ( <nl> - SkColor color ) const { <nl> + SkColor OffScreenRenderWidgetHostView : : DelegatedFrameHostGetGutterColor ( ) <nl> + const { <nl> if ( render_widget_host_ - > delegate ( ) & & <nl> render_widget_host_ - > delegate ( ) - > IsFullscreenForCurrentTab ( ) ) { <nl> return SK_ColorWHITE ; <nl> } <nl> - return color ; <nl> - } <nl> - <nl> - gfx : : Size OffScreenRenderWidgetHostView : : DelegatedFrameHostDesiredSizeInDIP ( ) <nl> - const { <nl> - return GetRootLayer ( ) - > bounds ( ) . size ( ) ; <nl> + return background_color_ ; <nl> } <nl> <nl> bool OffScreenRenderWidgetHostView : : DelegatedFrameCanCreateResizeLock ( ) const { <nl> viz : : LocalSurfaceId OffScreenRenderWidgetHostView : : GetLocalSurfaceId ( ) const { <nl> return local_surface_id_ ; <nl> } <nl> <nl> - void OffScreenRenderWidgetHostView : : OnBeginFrame ( ) { } <nl> + void OffScreenRenderWidgetHostView : : OnFirstSurfaceActivation ( <nl> + const viz : : SurfaceInfo & surface_info ) { } <nl> + <nl> + void OffScreenRenderWidgetHostView : : OnBeginFrame ( base : : TimeTicks frame_time ) { } <nl> + <nl> + void OffScreenRenderWidgetHostView : : OnFrameTokenChanged ( uint32_t frame_token ) { <nl> + render_widget_host_ - > DidProcessFrame ( frame_token ) ; <nl> + } <nl> + <nl> + void OffScreenRenderWidgetHostView : : DidReceiveFirstFrameAfterNavigation ( ) { <nl> + render_widget_host_ - > DidReceiveFirstFrameAfterNavigation ( ) ; <nl> + } <nl> <nl> std : : unique_ptr < ui : : CompositorLock > <nl> OffScreenRenderWidgetHostView : : GetCompositorLock ( <nl> bool OffScreenRenderWidgetHostView : : IsAutoResizeEnabled ( ) const { <nl> # endif / / ! defined ( OS_MACOSX ) <nl> <nl> bool OffScreenRenderWidgetHostView : : TransformPointToLocalCoordSpace ( <nl> - const gfx : : Point & point , <nl> + const gfx : : PointF & point , <nl> const viz : : SurfaceId & original_surface , <nl> - gfx : : Point * transformed_point ) { <nl> + gfx : : PointF * transformed_point ) { <nl> / / Transformations use physical pixels rather than DIP , so conversion <nl> / / is necessary . <nl> - gfx : : Point point_in_pixels = gfx : : ConvertPointToPixel ( scale_factor_ , point ) ; <nl> + gfx : : PointF point_in_pixels = gfx : : ConvertPointToPixel ( scale_factor_ , point ) ; <nl> if ( ! GetDelegatedFrameHost ( ) - > TransformPointToLocalCoordSpace ( <nl> point_in_pixels , original_surface , transformed_point ) ) { <nl> return false ; <nl> bool OffScreenRenderWidgetHostView : : TransformPointToLocalCoordSpace ( <nl> } <nl> <nl> bool OffScreenRenderWidgetHostView : : TransformPointToCoordSpaceForView ( <nl> - const gfx : : Point & point , <nl> + const gfx : : PointF & point , <nl> RenderWidgetHostViewBase * target_view , <nl> - gfx : : Point * transformed_point ) { <nl> + gfx : : PointF * transformed_point ) { <nl> if ( target_view = = this ) { <nl> * transformed_point = point ; <nl> return true ; <nl> void OffScreenRenderWidgetHostView : : ProxyViewDestroyed ( <nl> <nl> void OffScreenRenderWidgetHostView : : RegisterGuestViewFrameSwappedCallback ( <nl> content : : RenderWidgetHostViewGuest * guest_host_view ) { <nl> - guest_host_view - > RegisterFrameSwappedCallback ( <nl> - std : : make_unique < base : : Closure > ( base : : Bind ( <nl> - & OffScreenRenderWidgetHostView : : OnGuestViewFrameSwapped , <nl> - weak_ptr_factory_ . GetWeakPtr ( ) , base : : Unretained ( guest_host_view ) ) ) ) ; <nl> + guest_host_view - > RegisterFrameSwappedCallback ( base : : BindOnce ( <nl> + & OffScreenRenderWidgetHostView : : OnGuestViewFrameSwapped , <nl> + weak_ptr_factory_ . GetWeakPtr ( ) , base : : Unretained ( guest_host_view ) ) ) ; <nl> } <nl> <nl> void OffScreenRenderWidgetHostView : : OnGuestViewFrameSwapped ( <nl> void OffScreenRenderWidgetHostView : : SetNeedsBeginFrames ( <nl> } <nl> } <nl> <nl> + void OffScreenRenderWidgetHostView : : SetWantsAnimateOnlyBeginFrames ( ) { <nl> + if ( GetDelegatedFrameHost ( ) ) { <nl> + GetDelegatedFrameHost ( ) - > SetWantsAnimateOnlyBeginFrames ( ) ; <nl> + } <nl> + } <nl> + <nl> void CopyBitmapTo ( const SkBitmap & destination , <nl> const SkBitmap & source , <nl> const gfx : : Rect & pos ) { <nl> void OffScreenRenderWidgetHostView : : WasResized ( ) { <nl> ResizeRootLayer ( ) ; <nl> if ( render_widget_host_ ) <nl> render_widget_host_ - > WasResized ( ) ; <nl> - GetDelegatedFrameHost ( ) - > WasResized ( ) ; <nl> + GetDelegatedFrameHost ( ) - > WasResized ( local_surface_id_ , size_ , <nl> + cc : : DeadlinePolicy : : UseDefaultDeadline ( ) ) ; <nl> } <nl> <nl> - void OffScreenRenderWidgetHostView : : ProcessKeyboardEvent ( <nl> - const content : : NativeWebKeyboardEvent & event , <nl> - const ui : : LatencyInfo & latency ) { <nl> - if ( ! render_widget_host_ ) <nl> - return ; <nl> - render_widget_host_ - > ForwardKeyboardEventWithLatencyInfo ( event , latency ) ; <nl> - } <nl> - <nl> - void OffScreenRenderWidgetHostView : : ProcessMouseEvent ( <nl> - const blink : : WebMouseEvent & event , <nl> - const ui : : LatencyInfo & latency ) { <nl> + void OffScreenRenderWidgetHostView : : SendMouseEvent ( <nl> + const blink : : WebMouseEvent & event ) { <nl> for ( auto * proxy_view : proxy_views_ ) { <nl> gfx : : Rect bounds = proxy_view - > GetBounds ( ) ; <nl> if ( bounds . Contains ( event . PositionInWidget ( ) . x , <nl> void OffScreenRenderWidgetHostView : : ProcessMouseEvent ( <nl> popup_event . PositionInWidget ( ) . y - <nl> popup_host_view_ - > popup_position_ . y ( ) ) ; <nl> <nl> - popup_host_view_ - > ProcessMouseEvent ( popup_event , latency ) ; <nl> + popup_host_view_ - > ProcessMouseEvent ( popup_event , ui : : LatencyInfo ( ) ) ; <nl> return ; <nl> } <nl> } <nl> void OffScreenRenderWidgetHostView : : ProcessMouseEvent ( <nl> render_widget_host_ - > ForwardMouseEvent ( event ) ; <nl> } <nl> <nl> - void OffScreenRenderWidgetHostView : : ProcessMouseWheelEvent ( <nl> - const blink : : WebMouseWheelEvent & event , <nl> - const ui : : LatencyInfo & latency ) { <nl> + void OffScreenRenderWidgetHostView : : SendMouseWheelEvent ( <nl> + const blink : : WebMouseWheelEvent & event ) { <nl> for ( auto * proxy_view : proxy_views_ ) { <nl> gfx : : Rect bounds = proxy_view - > GetBounds ( ) ; <nl> if ( bounds . Contains ( event . PositionInWidget ( ) . x , <nl> void OffScreenRenderWidgetHostView : : ProcessMouseWheelEvent ( <nl> popup_host_view_ - > popup_position_ . x ( ) , <nl> popup_event . PositionInWidget ( ) . y - <nl> popup_host_view_ - > popup_position_ . y ( ) ) ; <nl> - popup_host_view_ - > ProcessMouseWheelEvent ( popup_event , latency ) ; <nl> + popup_host_view_ - > ProcessMouseWheelEvent ( popup_event , <nl> + ui : : LatencyInfo ( ) ) ; <nl> return ; <nl> } else { <nl> / / Scrolling outside of the popup widget so destroy it . <nl> void OffScreenRenderWidgetHostView : : ResizeRootLayer ( ) { <nl> local_surface_id_ = local_surface_id_allocator_ . GenerateId ( ) ; <nl> <nl> GetRootLayer ( ) - > SetBounds ( gfx : : Rect ( size ) ) ; <nl> - GetCompositor ( ) - > SetScaleAndSize ( scale_factor_ , size_in_pixels ) ; <nl> + GetCompositor ( ) - > SetScaleAndSize ( scale_factor_ , size_in_pixels , <nl> + local_surface_id_ ) ; <nl> + <nl> + # if defined ( OS_MACOSX ) <nl> + bool resized = browser_compositor_ - > UpdateNSViewAndDisplay ( ) ; <nl> + # else <nl> + bool resized = true ; <nl> + GetDelegatedFrameHost ( ) - > WasResized ( local_surface_id_ , size , <nl> + cc : : DeadlinePolicy : : UseDefaultDeadline ( ) ) ; <nl> + # endif <nl> + <nl> + / / Note that | render_widget_host_ | will retrieve resize parameters from the <nl> + / / DelegatedFrameHost , so it must have WasResized called after . <nl> + if ( resized & & render_widget_host_ ) <nl> + render_widget_host_ - > WasResized ( ) ; <nl> } <nl> <nl> viz : : FrameSinkId OffScreenRenderWidgetHostView : : AllocateFrameSinkId ( <nl> mmm a / atom / browser / osr / osr_render_widget_host_view . h <nl> ppp b / atom / browser / osr / osr_render_widget_host_view . h <nl> <nl> # include " components / viz / common / frame_sinks / begin_frame_args . h " <nl> # include " components / viz / common / frame_sinks / begin_frame_source . h " <nl> # include " components / viz / common / quads / compositor_frame . h " <nl> - # include " components / viz / common / surfaces / local_surface_id_allocator . h " <nl> + # include " components / viz / common / surfaces / parent_local_surface_id_allocator . h " <nl> # include " content / browser / frame_host / render_widget_host_view_guest . h " <nl> # include " content / browser / renderer_host / compositor_resize_lock . h " <nl> # include " content / browser / renderer_host / delegated_frame_host . h " <nl> class OffScreenRenderWidgetHostView <nl> ~ OffScreenRenderWidgetHostView ( ) override ; <nl> <nl> / / content : : RenderWidgetHostView : <nl> - bool OnMessageReceived ( const IPC : : Message & ) override ; <nl> void InitAsChild ( gfx : : NativeView ) override ; <nl> - content : : RenderWidgetHost * GetRenderWidgetHost ( void ) const override ; <nl> void SetSize ( const gfx : : Size & ) override ; <nl> void SetBounds ( const gfx : : Rect & ) override ; <nl> gfx : : Vector2dF GetLastScrollOffset ( void ) const override ; <nl> class OffScreenRenderWidgetHostView <nl> bool LockMouse ( void ) override ; <nl> void UnlockMouse ( void ) override ; <nl> void SetNeedsBeginFrames ( bool needs_begin_frames ) override ; <nl> + void SetWantsAnimateOnlyBeginFrames ( ) override ; <nl> # if defined ( OS_MACOSX ) <nl> ui : : AcceleratedWidgetMac * GetAcceleratedWidgetMac ( ) const override ; <nl> void SetActive ( bool active ) override ; <nl> class OffScreenRenderWidgetHostView <nl> void DidCreateNewRendererCompositorFrameSink ( <nl> viz : : mojom : : CompositorFrameSinkClient * renderer_compositor_frame_sink ) <nl> override ; <nl> - void SubmitCompositorFrame ( const viz : : LocalSurfaceId & local_surface_id , <nl> - viz : : CompositorFrame frame ) override ; <nl> + void SubmitCompositorFrame ( <nl> + const viz : : LocalSurfaceId & local_surface_id , <nl> + viz : : CompositorFrame frame , <nl> + viz : : mojom : : HitTestRegionListPtr hit_test_region_list ) override ; <nl> <nl> void ClearCompositorFrame ( void ) override ; <nl> void InitAsPopup ( content : : RenderWidgetHostView * rwhv , <nl> class OffScreenRenderWidgetHostView <nl> void RenderProcessGone ( base : : TerminationStatus , int ) override ; <nl> void Destroy ( void ) override ; <nl> void SetTooltipText ( const base : : string16 & ) override ; <nl> - # if defined ( OS_MACOSX ) <nl> - void SelectionChanged ( const base : : string16 & text , <nl> - size_t offset , <nl> - const gfx : : Range & range ) override ; <nl> - # endif <nl> void SelectionBoundsChanged ( <nl> const ViewHostMsg_SelectionBounds_Params & ) override ; <nl> - void CopyFromSurface ( const gfx : : Rect & src_subrect , <nl> - const gfx : : Size & dst_size , <nl> - const content : : ReadbackRequestCallback & callback , <nl> - const SkColorType color_type ) override ; <nl> - void CopyFromSurfaceToVideoFrame ( <nl> - const gfx : : Rect & src_subrect , <nl> - scoped_refptr < media : : VideoFrame > target , <nl> - const base : : Callback < void ( const gfx : : Rect & , bool ) > & callback ) override ; <nl> - void BeginFrameSubscription ( <nl> - std : : unique_ptr < content : : RenderWidgetHostViewFrameSubscriber > ) override ; <nl> - void EndFrameSubscription ( ) override ; <nl> + void CopyFromSurface ( <nl> + const gfx : : Rect & src_rect , <nl> + const gfx : : Size & output_size , <nl> + base : : OnceCallback < void ( const SkBitmap & ) > callback ) override ; <nl> + void GetScreenInfo ( content : : ScreenInfo * results ) const override ; <nl> void InitAsGuest ( content : : RenderWidgetHostView * , <nl> content : : RenderWidgetHostViewGuest * ) override ; <nl> - bool HasAcceleratedSurface ( const gfx : : Size & ) override ; <nl> + gfx : : Vector2d GetOffsetFromRootSurface ( ) override ; <nl> gfx : : Rect GetBoundsInRootWindow ( void ) override ; <nl> + content : : RenderWidgetHostImpl * GetRenderWidgetHostImpl ( ) const override ; <nl> + viz : : SurfaceId GetCurrentSurfaceId ( ) const override ; <nl> void ImeCompositionRangeChanged ( const gfx : : Range & , <nl> const std : : vector < gfx : : Rect > & ) override ; <nl> - gfx : : Size GetPhysicalBackingSize ( ) const override ; <nl> + gfx : : Size GetCompositorViewportPixelSize ( ) const override ; <nl> gfx : : Size GetRequestedRendererSize ( ) const override ; <nl> <nl> content : : RenderWidgetHostViewBase * CreateViewForWidget ( <nl> class OffScreenRenderWidgetHostView <nl> int DelegatedFrameHostGetGpuMemoryBufferClientId ( void ) const ; <nl> ui : : Layer * DelegatedFrameHostGetLayer ( void ) const override ; <nl> bool DelegatedFrameHostIsVisible ( void ) const override ; <nl> - SkColor DelegatedFrameHostGetGutterColor ( SkColor ) const override ; <nl> - gfx : : Size DelegatedFrameHostDesiredSizeInDIP ( void ) const override ; <nl> + SkColor DelegatedFrameHostGetGutterColor ( ) const override ; <nl> bool DelegatedFrameCanCreateResizeLock ( ) const override ; <nl> std : : unique_ptr < content : : CompositorResizeLock > <nl> DelegatedFrameHostCreateResizeLock ( ) override ; <nl> viz : : LocalSurfaceId GetLocalSurfaceId ( ) const override ; <nl> - void OnBeginFrame ( ) override ; <nl> + void OnFirstSurfaceActivation ( const viz : : SurfaceInfo & surface_info ) override ; <nl> + void OnBeginFrame ( base : : TimeTicks frame_time ) override ; <nl> + void OnFrameTokenChanged ( uint32_t frame_token ) override ; <nl> + void DidReceiveFirstFrameAfterNavigation ( ) override ; <nl> / / CompositorResizeLockClient implementation . <nl> std : : unique_ptr < ui : : CompositorLock > GetCompositorLock ( <nl> ui : : CompositorLockClient * client ) override ; <nl> class OffScreenRenderWidgetHostView <nl> bool IsAutoResizeEnabled ( ) const override ; <nl> # endif / / ! defined ( OS_MACOSX ) <nl> <nl> - bool TransformPointToLocalCoordSpace ( const gfx : : Point & point , <nl> + bool TransformPointToLocalCoordSpace ( const gfx : : PointF & point , <nl> const viz : : SurfaceId & original_surface , <nl> - gfx : : Point * transformed_point ) override ; <nl> + gfx : : PointF * transformed_point ) override ; <nl> bool TransformPointToCoordSpaceForView ( <nl> - const gfx : : Point & point , <nl> + const gfx : : PointF & point , <nl> RenderWidgetHostViewBase * target_view , <nl> - gfx : : Point * transformed_point ) override ; <nl> + gfx : : PointF * transformed_point ) override ; <nl> <nl> / / ui : : CompositorDelegate : <nl> std : : unique_ptr < viz : : SoftwareOutputDevice > CreateSoftwareOutputDevice ( <nl> class OffScreenRenderWidgetHostView <nl> void ReleaseResize ( ) ; <nl> void WasResized ( ) ; <nl> <nl> - void ProcessKeyboardEvent ( const content : : NativeWebKeyboardEvent & event , <nl> - const ui : : LatencyInfo & latency ) override ; <nl> - void ProcessMouseEvent ( const blink : : WebMouseEvent & event , <nl> - const ui : : LatencyInfo & latency ) override ; <nl> - void ProcessMouseWheelEvent ( const blink : : WebMouseWheelEvent & event , <nl> - const ui : : LatencyInfo & latency ) override ; <nl> + void SendMouseEvent ( const blink : : WebMouseEvent & event ) ; <nl> + void SendMouseWheelEvent ( const blink : : WebMouseWheelEvent & event ) ; <nl> <nl> void SetPainting ( bool painting ) ; <nl> bool IsPainting ( ) const ; <nl> class OffScreenRenderWidgetHostView <nl> bool paint_callback_running_ = false ; <nl> <nl> viz : : LocalSurfaceId local_surface_id_ ; <nl> - viz : : LocalSurfaceIdAllocator local_surface_id_allocator_ ; <nl> + viz : : ParentLocalSurfaceIdAllocator local_surface_id_allocator_ ; <nl> <nl> std : : unique_ptr < ui : : Layer > root_layer_ ; <nl> std : : unique_ptr < ui : : Compositor > compositor_ ; <nl> class OffScreenRenderWidgetHostView <nl> uint64_t begin_frame_number_ = viz : : BeginFrameArgs : : kStartingFrameNumber ; <nl> <nl> # if defined ( OS_MACOSX ) <nl> - CALayer * background_layer_ ; <nl> std : : unique_ptr < content : : BrowserCompositorMac > browser_compositor_ ; <nl> <nl> / / Can not be managed by smart pointer because its header can not be included <nl> mmm a / atom / browser / osr / osr_render_widget_host_view_mac . mm <nl> ppp b / atom / browser / osr / osr_render_widget_host_view_mac . mm <nl> explicit MacHelper ( OffScreenRenderWidgetHostView * view ) : view_ ( view ) { <nl> virtual ~ MacHelper ( ) { } <nl> <nl> / / content : : BrowserCompositorMacClient : <nl> - NSView * BrowserCompositorMacGetNSView ( ) const override { <nl> - / / Intentionally return nil so that <nl> - / / BrowserCompositorMac : : DelegatedFrameHostDesiredSizeInDIP uses the layer <nl> - / / size instead of the NSView size . <nl> - return nil ; <nl> - } <nl> - <nl> SkColor BrowserCompositorMacGetGutterColor ( SkColor color ) const override { <nl> / / When making an element on the page fullscreen the element ' s background <nl> / / may not match the page ' s , so use black as the gutter color to avoid <nl> SkColor BrowserCompositorMacGetGutterColor ( SkColor color ) const override { <nl> <nl> void BrowserCompositorMacOnBeginFrame ( ) override { } <nl> <nl> - viz : : LocalSurfaceId GetLocalSurfaceId ( ) const override { <nl> - return view_ - > local_surface_id ( ) ; <nl> + void OnFrameTokenChanged ( uint32_t frame_token ) override { <nl> + view_ - > render_widget_host ( ) - > DidProcessFrame ( frame_token ) ; <nl> } <nl> <nl> / / ui : : AcceleratedWidgetMacNSView : <nl> void AcceleratedWidgetGetVSyncParameters ( <nl> <nl> void AcceleratedWidgetSwapCompleted ( ) override { } <nl> <nl> + void DidReceiveFirstFrameAfterNavigation ( ) override { <nl> + view_ - > render_widget_host ( ) - > DidReceiveFirstFrameAfterNavigation ( ) ; <nl> + } <nl> + <nl> + void DestroyCompositorForShutdown ( ) override { } <nl> + <nl> private : <nl> OffScreenRenderWidgetHostView * view_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( MacHelper ) ; <nl> } ; <nl> <nl> - ui : : AcceleratedWidgetMac * <nl> - OffScreenRenderWidgetHostView : : GetAcceleratedWidgetMac ( ) const { <nl> - if ( browser_compositor_ ) <nl> - return browser_compositor_ - > GetAcceleratedWidgetMac ( ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> void OffScreenRenderWidgetHostView : : SetActive ( bool active ) { } <nl> <nl> void OffScreenRenderWidgetHostView : : ShowDefinitionForSelection ( ) { } <nl> void AcceleratedWidgetSwapCompleted ( ) override { } <nl> <nl> void OffScreenRenderWidgetHostView : : StopSpeaking ( ) { } <nl> <nl> - void OffScreenRenderWidgetHostView : : SelectionChanged ( const base : : string16 & text , <nl> - size_t offset , <nl> - const gfx : : Range & range ) { <nl> - if ( range . is_empty ( ) | | text . empty ( ) ) { <nl> - selected_text_ . clear ( ) ; <nl> - } else { <nl> - size_t pos = range . GetMin ( ) - offset ; <nl> - size_t n = range . length ( ) ; <nl> - <nl> - DCHECK ( pos + n < = text . length ( ) ) < < " The text can not fully cover range . " ; <nl> - if ( pos > = text . length ( ) ) { <nl> - DCHECK ( false ) < < " The text can not cover range . " ; <nl> - return ; <nl> - } <nl> - selected_text_ = base : : UTF16ToUTF8 ( text . substr ( pos , n ) ) ; <nl> - } <nl> - <nl> - RenderWidgetHostViewBase : : SelectionChanged ( text , offset , range ) ; <nl> + bool CefRenderWidgetHostViewOSR : : ShouldContinueToPauseForFrame ( ) { <nl> + return browser_compositor_ - > ShouldContinueToPauseForFrame ( ) ; <nl> } <nl> <nl> void OffScreenRenderWidgetHostView : : CreatePlatformWidget ( <nl> mmm a / atom / browser / osr / osr_web_contents_view . cc <nl> ppp b / atom / browser / osr / osr_web_contents_view . cc <nl> void OffScreenWebContentsView : : StoreFocus ( ) { } <nl> <nl> void OffScreenWebContentsView : : RestoreFocus ( ) { } <nl> <nl> + void OffScreenWebContentsView : : FocusThroughTabTraversal ( bool reverse ) { } <nl> + <nl> content : : DropData * OffScreenWebContentsView : : GetDropData ( ) const { <nl> return nullptr ; <nl> } <nl> void OffScreenWebContentsView : : RenderViewSwappedIn ( <nl> <nl> void OffScreenWebContentsView : : SetOverscrollControllerEnabled ( bool enabled ) { } <nl> <nl> - void OffScreenWebContentsView : : GetScreenInfo ( <nl> - content : : ScreenInfo * screen_info ) const { <nl> - screen_info - > depth = 24 ; <nl> - screen_info - > depth_per_component = 8 ; <nl> - screen_info - > orientation_angle = 0 ; <nl> - screen_info - > device_scale_factor = 1 . 0 ; <nl> - screen_info - > orientation_type = <nl> - content : : SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY ; <nl> - <nl> - if ( GetView ( ) ) { <nl> - screen_info - > rect = gfx : : Rect ( GetView ( ) - > size ( ) ) ; <nl> - screen_info - > available_rect = gfx : : Rect ( GetView ( ) - > size ( ) ) ; <nl> - } else { <nl> - const display : : Display display = <nl> - display : : Screen : : GetScreen ( ) - > GetPrimaryDisplay ( ) ; <nl> - screen_info - > rect = display . bounds ( ) ; <nl> - screen_info - > available_rect = display . work_area ( ) ; <nl> - } <nl> - } <nl> - <nl> # if defined ( OS_MACOSX ) <nl> void OffScreenWebContentsView : : SetAllowOtherViews ( bool allow ) { } <nl> <nl> mmm a / atom / browser / osr / osr_web_contents_view . h <nl> ppp b / atom / browser / osr / osr_web_contents_view . h <nl> class OffScreenWebContentsView : public content : : WebContentsView , <nl> void SetInitialFocus ( ) override ; <nl> void StoreFocus ( ) override ; <nl> void RestoreFocus ( ) override ; <nl> + void FocusThroughTabTraversal ( bool reverse ) override ; <nl> content : : DropData * GetDropData ( ) const override ; <nl> gfx : : Rect GetViewBounds ( ) const override ; <nl> void CreateView ( const gfx : : Size & initial_size , <nl> class OffScreenWebContentsView : public content : : WebContentsView , <nl> void RenderViewCreated ( content : : RenderViewHost * host ) override ; <nl> void RenderViewSwappedIn ( content : : RenderViewHost * host ) override ; <nl> void SetOverscrollControllerEnabled ( bool enabled ) override ; <nl> - void GetScreenInfo ( content : : ScreenInfo * screen_info ) const override ; <nl> <nl> # if defined ( OS_MACOSX ) <nl> void SetAllowOtherViews ( bool allow ) override ; <nl> mmm a / atom / browser / resources / mac / Info . plist <nl> ppp b / atom / browser / resources / mac / Info . plist <nl> <nl> < key > LSApplicationCategoryType < / key > <nl> < string > public . app - category . developer - tools < / string > <nl> < key > LSMinimumSystemVersion < / key > <nl> - < string > 10 . 9 . 0 < / string > <nl> + < string > 10 . 10 . 0 < / string > <nl> < key > NSMainNibFile < / key > <nl> < string > MainMenu < / string > <nl> < key > NSPrincipalClass < / key > <nl> mmm a / atom / browser / ui / autofill_popup . cc <nl> ppp b / atom / browser / ui / autofill_popup . cc <nl> void AutofillPopup : : CreateView ( content : : RenderFrameHost * frame_host , <nl> element_bounds_ = gfx : : ToEnclosedRect ( r ) ; <nl> <nl> gfx : : Vector2d height_offset ( 0 , element_bounds_ . height ( ) ) ; <nl> - popup_bounds_in_view_ = element_bounds_ + height_offset ; <nl> gfx : : Point menu_position ( element_bounds_ . origin ( ) + height_offset ) ; <nl> views : : View : : ConvertPointToScreen ( parent , & menu_position ) ; <nl> popup_bounds_ = gfx : : Rect ( menu_position , element_bounds_ . size ( ) ) ; <nl> void AutofillPopup : : UpdatePopupBounds ( ) { <nl> popup_bounds_ = <nl> gfx : : Rect ( popup_x_and_width . first , popup_y_and_height . first , <nl> popup_x_and_width . second , popup_y_and_height . second ) ; <nl> - popup_bounds_in_view_ = <nl> - gfx : : Rect ( popup_bounds_in_view_ . origin ( ) , <nl> - gfx : : Size ( popup_x_and_width . second , popup_y_and_height . second ) ) ; <nl> + } <nl> + <nl> + gfx : : Rect AutofillPopup : : popup_bounds_in_view ( ) { <nl> + gfx : : Point origin ( popup_bounds_ . origin ( ) ) ; <nl> + views : : View : : ConvertPointFromScreen ( parent_ , & origin ) ; <nl> + <nl> + return gfx : : Rect ( origin , popup_bounds_ . size ( ) ) ; <nl> } <nl> <nl> void AutofillPopup : : OnViewBoundsChanged ( views : : View * view ) { <nl> mmm a / atom / browser / ui / autofill_popup . h <nl> ppp b / atom / browser / ui / autofill_popup . h <nl> class AutofillPopup : public views : : ViewObserver { <nl> const std : : vector < base : : string16 > & labels ) ; <nl> void UpdatePopupBounds ( ) ; <nl> <nl> + gfx : : Rect popup_bounds_in_view ( ) ; <nl> + <nl> private : <nl> friend class AutofillPopupView ; <nl> <nl> class AutofillPopup : public views : : ViewObserver { <nl> <nl> / / Popup location <nl> gfx : : Rect popup_bounds_ ; <nl> - gfx : : Rect popup_bounds_in_view_ ; <nl> <nl> / / Bounds of the autofilled element <nl> gfx : : Rect element_bounds_ ; <nl> mmm a / atom / browser / ui / certificate_trust_win . cc <nl> ppp b / atom / browser / ui / certificate_trust_win . cc <nl> <nl> <nl> # include " atom / browser / ui / certificate_trust . h " <nl> <nl> + # include < windows . h > / / windows . h must be included first <nl> + <nl> # include < wincrypt . h > <nl> - # include < windows . h > <nl> <nl> # include " base / callback . h " <nl> # include " net / cert / cert_database . h " <nl> mmm a / atom / browser / ui / views / autofill_popup_view . cc <nl> ppp b / atom / browser / ui / views / autofill_popup_view . cc <nl> <nl> namespace atom { <nl> <nl> void AutofillPopupChildView : : GetAccessibleNodeData ( ui : : AXNodeData * node_data ) { <nl> - node_data - > role = ui : : AX_ROLE_MENU_ITEM ; <nl> + node_data - > role = ax : : mojom : : Role : : kMenuItem ; <nl> node_data - > SetName ( suggestion_ ) ; <nl> } <nl> <nl> void AutofillPopupView : : Show ( ) { <nl> auto * host = popup_ - > frame_host_ - > GetRenderViewHost ( ) - > GetWidget ( ) ; <nl> host - > AddKeyPressEventCallback ( keypress_callback_ ) ; <nl> <nl> - NotifyAccessibilityEvent ( ui : : AX_EVENT_MENU_START , true ) ; <nl> + NotifyAccessibilityEvent ( ax : : mojom : : Event : : kMenuStart , true ) ; <nl> } <nl> <nl> void AutofillPopupView : : Hide ( ) { <nl> void AutofillPopupView : : Hide ( ) { <nl> } <nl> <nl> RemoveObserver ( ) ; <nl> - NotifyAccessibilityEvent ( ui : : AX_EVENT_MENU_END , true ) ; <nl> + NotifyAccessibilityEvent ( ax : : mojom : : Event : : kMenuEnd , true ) ; <nl> <nl> if ( GetWidget ( ) ) { <nl> GetWidget ( ) - > Close ( ) ; <nl> void AutofillPopupView : : OnSelectedRowChanged ( <nl> int selected = current_row_selection . value_or ( - 1 ) ; <nl> if ( selected = = - 1 | | selected > = child_count ( ) ) <nl> return ; <nl> - child_at ( selected ) - > NotifyAccessibilityEvent ( ui : : AX_EVENT_SELECTION , true ) ; <nl> + child_at ( selected ) - > NotifyAccessibilityEvent ( ax : : mojom : : Event : : kSelection , <nl> + true ) ; <nl> } <nl> } <nl> <nl> void AutofillPopupView : : DoUpdateBoundsAndRedrawPopup ( ) { <nl> return ; <nl> <nl> GetWidget ( ) - > SetBounds ( popup_ - > popup_bounds_ ) ; <nl> + # if defined ( ENABLE_OSR ) <nl> + if ( view_proxy_ . get ( ) ) { <nl> + view_proxy_ - > SetBounds ( popup_ - > popup_bounds_in_view ( ) ) ; <nl> + } <nl> + # endif <nl> SchedulePaint ( ) ; <nl> } <nl> <nl> void AutofillPopupView : : OnPaint ( gfx : : Canvas * canvas ) { <nl> # if defined ( ENABLE_OSR ) <nl> std : : unique_ptr < cc : : SkiaPaintCanvas > paint_canvas ; <nl> if ( view_proxy_ . get ( ) ) { <nl> - bitmap . allocN32Pixels ( popup_ - > popup_bounds_in_view_ . width ( ) , <nl> - popup_ - > popup_bounds_in_view_ . height ( ) , true ) ; <nl> + bitmap . allocN32Pixels ( popup_ - > popup_bounds_in_view ( ) . width ( ) , <nl> + popup_ - > popup_bounds_in_view ( ) . height ( ) , true ) ; <nl> paint_canvas . reset ( new cc : : SkiaPaintCanvas ( bitmap ) ) ; <nl> draw_canvas = new gfx : : Canvas ( paint_canvas . get ( ) , 1 . 0 ) ; <nl> } <nl> void AutofillPopupView : : OnPaint ( gfx : : Canvas * canvas ) { <nl> <nl> # if defined ( ENABLE_OSR ) <nl> if ( view_proxy_ . get ( ) ) { <nl> - view_proxy_ - > SetBounds ( popup_ - > popup_bounds_in_view_ ) ; <nl> + view_proxy_ - > SetBounds ( popup_ - > popup_bounds_in_view ( ) ) ; <nl> view_proxy_ - > SetBitmap ( bitmap ) ; <nl> } <nl> # endif <nl> } <nl> <nl> void AutofillPopupView : : GetAccessibleNodeData ( ui : : AXNodeData * node_data ) { <nl> - node_data - > role = ui : : AX_ROLE_MENU ; <nl> + node_data - > role = ax : : mojom : : Role : : kMenu ; <nl> node_data - > SetName ( " Autofill Menu " ) ; <nl> } <nl> <nl> mmm a / atom / browser / ui / views / global_menu_bar_x11 . cc <nl> ppp b / atom / browser / ui / views / global_menu_bar_x11 . cc <nl> <nl> <nl> # include " atom / browser / ui / views / global_menu_bar_x11 . h " <nl> <nl> - # include < X11 / Xlib . h > <nl> - <nl> - / / This conflicts with mate : : Converter , <nl> - # undef True <nl> - # undef False <nl> - / / and V8 , <nl> - # undef None <nl> - / / and url_request_status . h , <nl> - # undef Status <nl> - <nl> # include < dlfcn . h > <nl> # include < glib - object . h > <nl> <nl> <nl> # include " ui / aura / window_tree_host . h " <nl> # include " ui / base / accelerators / menu_label_accelerator_util_linux . h " <nl> # include " ui / events / keycodes / keyboard_code_conversion_x . h " <nl> + # include " ui / gfx / x / x11 . h " <nl> <nl> / / libdbusmenu - glib types <nl> typedef struct _DbusmenuMenuitem DbusmenuMenuitem ; <nl> mmm a / atom / browser / ui / views / menu_bar . cc <nl> ppp b / atom / browser / ui / views / menu_bar . cc <nl> MenuBar : : MenuBar ( views : : View * window ) <nl> : background_color_ ( kDefaultColor ) , window_ ( window ) { <nl> RefreshColorCache ( ) ; <nl> UpdateViewColors ( ) ; <nl> - SetLayoutManager ( new views : : BoxLayout ( views : : BoxLayout : : kHorizontal ) ) ; <nl> + SetLayoutManager ( std : : make_unique < views : : BoxLayout > ( <nl> + views : : BoxLayout : : kHorizontal ) ) ; <nl> window_ - > GetFocusManager ( ) - > AddFocusChangeListener ( this ) ; <nl> } <nl> <nl> mmm a / atom / browser / ui / webui / pdf_viewer_ui . cc <nl> ppp b / atom / browser / ui / webui / pdf_viewer_ui . cc <nl> <nl> # include " net / base / mime_util . h " <nl> # include " net / url_request / url_request . h " <nl> # include " net / url_request / url_request_context . h " <nl> + # include " services / network / public / cpp / resource_response . h " <nl> # include " ui / base / resource / resource_bundle . h " <nl> <nl> using content : : BrowserThread ; <nl> class PdfViewerUI : : ResourceRequester <nl> <nl> protected : <nl> / / atom : : LayeredResourceHandler : : Delegate : <nl> - void OnResponseStarted ( content : : ResourceResponse * response ) override { <nl> + void OnResponseStarted ( network : : ResourceResponse * response ) override { <nl> DCHECK_CURRENTLY_ON ( BrowserThread : : IO ) ; <nl> <nl> auto resource_response_head = response - > head ; <nl> mmm a / atom / browser / ui / win / taskbar_host . h <nl> ppp b / atom / browser / ui / win / taskbar_host . h <nl> <nl> # define ATOM_BROWSER_UI_WIN_TASKBAR_HOST_H_ <nl> <nl> # include < shobjidl . h > <nl> + # include < wrl / client . h > <nl> <nl> # include < map > <nl> # include < string > <nl> <nl> <nl> # include " atom / browser / native_window . h " <nl> # include " base / callback . h " <nl> - # include " base / win / scoped_comptr . h " <nl> # include " ui / gfx / geometry / rect . h " <nl> # include " ui / gfx / image / image . h " <nl> <nl> class TaskbarHost { <nl> std : : vector < ThumbarButton > last_buttons_ ; <nl> <nl> / / The COM object of taskbar . <nl> - base : : win : : ScopedComPtr < ITaskbarList3 > taskbar_ ; <nl> + Microsoft : : WRL : : ComPtr < ITaskbarList3 > taskbar_ ; <nl> <nl> / / Whether we have already added the buttons to thumbar . <nl> bool thumbar_buttons_added_ = false ; <nl> mmm a / atom / browser / ui / x / window_state_watcher . cc <nl> ppp b / atom / browser / ui / x / window_state_watcher . cc <nl> <nl> <nl> # include " atom / browser / ui / x / window_state_watcher . h " <nl> <nl> - # include < X11 / Xlib . h > <nl> - <nl> # include " ui / events / platform / platform_event_source . h " <nl> + # include " ui / gfx / x / x11 . h " <nl> # include " ui / gfx / x / x11_atom_cache . h " <nl> <nl> namespace atom { <nl> mmm a / atom / browser / ui / x / x_window_utils . cc <nl> ppp b / atom / browser / ui / x / x_window_utils . cc <nl> void SetWMSpecState ( : : Window xwindow , bool enabled , : : Atom state ) { <nl> xclient . xclient . format = 32 ; <nl> xclient . xclient . data . l [ 0 ] = enabled ? 1 : 0 ; <nl> xclient . xclient . data . l [ 1 ] = state ; <nl> - xclient . xclient . data . l [ 2 ] = None ; <nl> + xclient . xclient . data . l [ 2 ] = x11 : : None ; <nl> xclient . xclient . data . l [ 3 ] = 1 ; <nl> xclient . xclient . data . l [ 4 ] = 0 ; <nl> <nl> XDisplay * xdisplay = gfx : : GetXDisplay ( ) ; <nl> - XSendEvent ( xdisplay , DefaultRootWindow ( xdisplay ) , False , <nl> + XSendEvent ( xdisplay , DefaultRootWindow ( xdisplay ) , x11 : : False , <nl> SubstructureRedirectMask | SubstructureNotifyMask , & xclient ) ; <nl> } <nl> <nl> void SetWindowType ( : : Window xwindow , const std : : string & type ) { <nl> XDisplay * xdisplay = gfx : : GetXDisplay ( ) ; <nl> std : : string type_prefix = " _NET_WM_WINDOW_TYPE_ " ; <nl> : : Atom window_type = XInternAtom ( <nl> - xdisplay , ( type_prefix + base : : ToUpperASCII ( type ) ) . c_str ( ) , False ) ; <nl> + xdisplay , ( type_prefix + base : : ToUpperASCII ( type ) ) . c_str ( ) , x11 : : False ) ; <nl> XChangeProperty ( xdisplay , xwindow , <nl> - XInternAtom ( xdisplay , " _NET_WM_WINDOW_TYPE " , False ) , XA_ATOM , <nl> - 32 , PropModeReplace , <nl> + XInternAtom ( xdisplay , " _NET_WM_WINDOW_TYPE " , x11 : : False ) , <nl> + XA_ATOM , 32 , PropModeReplace , <nl> reinterpret_cast < unsigned char * > ( & window_type ) , 1 ) ; <nl> } <nl> <nl> mmm a / atom / browser / ui / x / x_window_utils . h <nl> ppp b / atom / browser / ui / x / x_window_utils . h <nl> <nl> # ifndef ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_ <nl> # define ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_ <nl> <nl> - # include < X11 / Xlib . h > <nl> - # include < X11 / extensions / XInput2 . h > <nl> - # include < X11 / extensions / Xrandr . h > <nl> - <nl> # include < string > <nl> <nl> + # include " ui / gfx / x / x11 . h " <nl> + <nl> namespace atom { <nl> <nl> : : Atom GetAtom ( const char * name ) ; <nl> mmm a / atom / browser / web_view_guest_delegate . cc <nl> ppp b / atom / browser / web_view_guest_delegate . cc <nl> void WebViewGuestDelegate : : SetSize ( const SetSizeParams & params ) { <nl> new_size = GetDefaultSize ( ) ; <nl> } <nl> <nl> + bool changed_due_to_auto_resize = false ; <nl> if ( auto_size_enabled_ ) { <nl> / / Autosize was previously enabled . <nl> rvh - > DisableAutoResize ( new_size ) ; <nl> - GuestSizeChangedDueToAutoSize ( guest_size_ , new_size ) ; <nl> + changed_due_to_auto_resize = true ; <nl> } else { <nl> / / Autosize was already disabled . <nl> guest_host_ - > SizeContents ( new_size ) ; <nl> } <nl> <nl> - guest_size_ = new_size ; <nl> + UpdateGuestSize ( new_size , changed_due_to_auto_resize ) ; <nl> } <nl> <nl> auto_size_enabled_ = enable_auto_size ; <nl> } <nl> <nl> + void WebViewGuestDelegate : : ResizeDueToAutoResize ( const gfx : : Size & new_size ) { <nl> + UpdateGuestSize ( new_size , auto_size_enabled_ ) ; <nl> + } <nl> + <nl> void WebViewGuestDelegate : : DidFinishNavigation ( <nl> content : : NavigationHandle * navigation_handle ) { <nl> if ( navigation_handle - > HasCommitted ( ) & & ! navigation_handle - > IsErrorPage ( ) ) { <nl> content : : WebContents * WebViewGuestDelegate : : GetOwnerWebContents ( ) const { <nl> return embedder_web_contents_ ; <nl> } <nl> <nl> - void WebViewGuestDelegate : : GuestSizeChanged ( const gfx : : Size & new_size ) { <nl> - if ( ! auto_size_enabled_ ) <nl> - return ; <nl> - GuestSizeChangedDueToAutoSize ( guest_size_ , new_size ) ; <nl> - guest_size_ = new_size ; <nl> - } <nl> - <nl> void WebViewGuestDelegate : : SetGuestHost ( content : : GuestHost * guest_host ) { <nl> guest_host_ = guest_host ; <nl> } <nl> void WebViewGuestDelegate : : OnZoomLevelChanged ( <nl> } <nl> } <nl> <nl> - void WebViewGuestDelegate : : GuestSizeChangedDueToAutoSize ( <nl> - const gfx : : Size & old_size , <nl> - const gfx : : Size & new_size ) { <nl> - api_web_contents_ - > Emit ( " size - changed " , old_size . width ( ) , old_size . height ( ) , <nl> - new_size . width ( ) , new_size . height ( ) ) ; <nl> + void WebViewGuestDelegate : : UpdateGuestSize ( const gfx : : Size & new_size , <nl> + bool due_to_auto_resize ) { <nl> + if ( due_to_auto_resize ) <nl> + api_web_contents_ - > Emit ( " size - changed " , guest_size_ . width ( ) , <nl> + guest_size_ . height ( ) , new_size . width ( ) , <nl> + new_size . height ( ) ) ; <nl> + guest_size_ = new_size ; <nl> } <nl> <nl> gfx : : Size WebViewGuestDelegate : : GetDefaultSize ( ) const { <nl> mmm a / atom / browser / web_view_guest_delegate . h <nl> ppp b / atom / browser / web_view_guest_delegate . h <nl> class WebViewGuestDelegate : public content : : BrowserPluginGuestDelegate , <nl> / / and normal sizes . <nl> void SetSize ( const SetSizeParams & params ) ; <nl> <nl> + / / Invoked when the contents auto - resized and the container should match it . <nl> + void ResizeDueToAutoResize ( const gfx : : Size & new_size ) ; <nl> + <nl> / / Return true if attached . <nl> bool IsAttached ( ) const { return attached_ ; } <nl> <nl> class WebViewGuestDelegate : public content : : BrowserPluginGuestDelegate , <nl> void DidAttach ( int guest_proxy_routing_id ) final ; <nl> void DidDetach ( ) final ; <nl> content : : WebContents * GetOwnerWebContents ( ) const final ; <nl> - void GuestSizeChanged ( const gfx : : Size & new_size ) final ; <nl> void SetGuestHost ( content : : GuestHost * guest_host ) final ; <nl> void WillAttach ( content : : WebContents * embedder_web_contents , <nl> int element_instance_id , <nl> class WebViewGuestDelegate : public content : : BrowserPluginGuestDelegate , <nl> / / <nl> / / This gives the derived class an opportunity to inform its container element <nl> / / or perform other actions . <nl> - void GuestSizeChangedDueToAutoSize ( const gfx : : Size & old_size , <nl> - const gfx : : Size & new_size ) ; <nl> + void UpdateGuestSize ( const gfx : : Size & new_size , bool due_to_auto_resize ) ; <nl> <nl> / / Returns the default size of the guestview . <nl> gfx : : Size GetDefaultSize ( ) const ; <nl> mmm a / atom / common / api / atom_api_v8_util . cc <nl> ppp b / atom / common / api / atom_api_v8_util . cc <nl> void RequestGarbageCollectionForTesting ( v8 : : Isolate * isolate ) { <nl> } <nl> <nl> bool IsSameOrigin ( const GURL & l , const GURL & r ) { <nl> - return url : : Origin ( l ) . IsSameOriginWith ( url : : Origin ( r ) ) ; <nl> + return url : : Origin : : Create ( l ) . IsSameOriginWith ( url : : Origin : : Create ( r ) ) ; <nl> } <nl> <nl> void Initialize ( v8 : : Local < v8 : : Object > exports , <nl> mmm a / atom / common / api / atom_bindings . cc <nl> ppp b / atom / common / api / atom_bindings . cc <nl> <nl> # include " atom / common / native_mate_converters / string16_converter . h " <nl> # include " atom / common / node_includes . h " <nl> # include " base / logging . h " <nl> + # include " base / process / process_metrics_iocounters . h " <nl> # include " base / sys_info . h " <nl> # include " native_mate / dictionary . h " <nl> <nl> AtomBindings : : ~ AtomBindings ( ) { <nl> } <nl> <nl> void AtomBindings : : BindTo ( v8 : : Isolate * isolate , v8 : : Local < v8 : : Object > process ) { <nl> - v8 : : V8 : : SetFatalErrorHandler ( FatalErrorCallback ) ; <nl> + isolate - > SetFatalErrorHandler ( FatalErrorCallback ) ; <nl> <nl> mate : : Dictionary dict ( isolate , process ) ; <nl> dict . SetMethod ( " crash " , & AtomBindings : : Crash ) ; <nl> mmm a / atom / common / asar / archive . cc <nl> ppp b / atom / common / asar / archive . cc <nl> bool Archive : : Init ( ) { <nl> std : : string error ; <nl> base : : JSONReader reader ; <nl> std : : unique_ptr < base : : Value > value ( reader . ReadToValue ( header ) ) ; <nl> - if ( ! value | | ! value - > IsType ( base : : Value : : Type : : DICTIONARY ) ) { <nl> + if ( ! value | | ! value - > is_dict ( ) ) { <nl> LOG ( ERROR ) < < " Failed to parse header : " < < error ; <nl> return false ; <nl> } <nl> mmm a / atom / common / chrome_version . h <nl> ppp b / atom / common / chrome_version . h <nl> <nl> # ifndef ATOM_COMMON_CHROME_VERSION_H_ <nl> # define ATOM_COMMON_CHROME_VERSION_H_ <nl> <nl> - # define CHROME_VERSION_STRING " 63 . 0 . 3239 . 150 " <nl> + # define CHROME_VERSION_STRING " 66 . 0 . 3359 . 181 " <nl> # define CHROME_VERSION " v " CHROME_VERSION_STRING <nl> <nl> # endif / / ATOM_COMMON_CHROME_VERSION_H_ <nl> mmm a / atom / common / common_message_generator . h <nl> ppp b / atom / common / common_message_generator . h <nl> <nl> # include " chrome / common / chrome_utility_printing_messages . h " <nl> # include " chrome / common / print_messages . h " <nl> # include " chrome / common / tts_messages . h " <nl> - # include " chrome / common / widevine_cdm_messages . h " <nl> mmm a / atom / common / crash_reporter / win / crash_service . h <nl> ppp b / atom / common / crash_reporter / win / crash_service . h <nl> <nl> # include " base / macros . h " <nl> # include " base / synchronization / lock . h " <nl> <nl> + # if defined ( OS_WIN ) <nl> + # include < windows . h > <nl> + # endif / / defined ( OS_WIN ) <nl> + <nl> namespace google_breakpad { <nl> <nl> class CrashReportSender ; <nl> mmm a / atom / common / native_mate_converters / content_converter . cc <nl> ppp b / atom / common / native_mate_converters / content_converter . cc <nl> <nl> # include " atom / common / native_mate_converters / value_converter . h " <nl> # include " content / public / browser / web_contents . h " <nl> # include " content / public / common / context_menu_params . h " <nl> - # include " content / public / common / resource_request_body . h " <nl> # include " native_mate / dictionary . h " <nl> <nl> - using content : : ResourceRequestBody ; <nl> - <nl> namespace { <nl> <nl> void ExecuteCommand ( content : : WebContents * web_contents , <nl> v8 : : Local < v8 : : Value > Converter < content : : PermissionType > : : ToV8 ( <nl> switch ( val ) { <nl> case content : : PermissionType : : MIDI_SYSEX : <nl> return StringToV8 ( isolate , " midiSysex " ) ; <nl> - case content : : PermissionType : : PUSH_MESSAGING : <nl> - return StringToV8 ( isolate , " pushMessaging " ) ; <nl> case content : : PermissionType : : NOTIFICATIONS : <nl> return StringToV8 ( isolate , " notifications " ) ; <nl> case content : : PermissionType : : GEOLOCATION : <nl> bool Converter < content : : StopFindAction > : : FromV8 ( v8 : : Isolate * isolate , <nl> return true ; <nl> } <nl> <nl> - / / static <nl> - v8 : : Local < v8 : : Value > Converter < scoped_refptr < ResourceRequestBody > > : : ToV8 ( <nl> - v8 : : Isolate * isolate , <nl> - const scoped_refptr < ResourceRequestBody > & val ) { <nl> - if ( ! val ) <nl> - return v8 : : Null ( isolate ) ; <nl> - auto list = std : : make_unique < base : : ListValue > ( ) ; <nl> - for ( const auto & element : * ( val - > elements ( ) ) ) { <nl> - auto post_data_dict = std : : make_unique < base : : DictionaryValue > ( ) ; <nl> - auto type = element . type ( ) ; <nl> - if ( type = = ResourceRequestBody : : Element : : TYPE_BYTES ) { <nl> - std : : unique_ptr < base : : Value > bytes ( base : : Value : : CreateWithCopiedBuffer ( <nl> - element . bytes ( ) , static_cast < size_t > ( element . length ( ) ) ) ) ; <nl> - post_data_dict - > SetString ( " type " , " rawData " ) ; <nl> - post_data_dict - > Set ( " bytes " , std : : move ( bytes ) ) ; <nl> - } else if ( type = = ResourceRequestBody : : Element : : TYPE_FILE ) { <nl> - post_data_dict - > SetString ( " type " , " file " ) ; <nl> - post_data_dict - > SetKey ( " filePath " , <nl> - base : : Value ( element . path ( ) . AsUTF8Unsafe ( ) ) ) ; <nl> - post_data_dict - > SetInteger ( " offset " , static_cast < int > ( element . offset ( ) ) ) ; <nl> - post_data_dict - > SetInteger ( " length " , static_cast < int > ( element . length ( ) ) ) ; <nl> - post_data_dict - > SetDouble ( <nl> - " modificationTime " , element . expected_modification_time ( ) . ToDoubleT ( ) ) ; <nl> - } else if ( type = = ResourceRequestBody : : Element : : TYPE_FILE_FILESYSTEM ) { <nl> - post_data_dict - > SetString ( " type " , " fileSystem " ) ; <nl> - post_data_dict - > SetKey ( " fileSystemURL " , <nl> - base : : Value ( element . filesystem_url ( ) . spec ( ) ) ) ; <nl> - post_data_dict - > SetInteger ( " offset " , static_cast < int > ( element . offset ( ) ) ) ; <nl> - post_data_dict - > SetInteger ( " length " , static_cast < int > ( element . length ( ) ) ) ; <nl> - post_data_dict - > SetDouble ( <nl> - " modificationTime " , element . expected_modification_time ( ) . ToDoubleT ( ) ) ; <nl> - } else if ( type = = ResourceRequestBody : : Element : : TYPE_BLOB ) { <nl> - post_data_dict - > SetString ( " type " , " blob " ) ; <nl> - post_data_dict - > SetString ( " blobUUID " , element . blob_uuid ( ) ) ; <nl> - } <nl> - list - > Append ( std : : move ( post_data_dict ) ) ; <nl> - } <nl> - return ConvertToV8 ( isolate , * list ) ; <nl> - } <nl> - <nl> - / / static <nl> - bool Converter < scoped_refptr < ResourceRequestBody > > : : FromV8 ( <nl> - v8 : : Isolate * isolate , <nl> - v8 : : Local < v8 : : Value > val , <nl> - scoped_refptr < ResourceRequestBody > * out ) { <nl> - auto list = std : : make_unique < base : : ListValue > ( ) ; <nl> - if ( ! ConvertFromV8 ( isolate , val , list . get ( ) ) ) <nl> - return false ; <nl> - * out = new content : : ResourceRequestBody ( ) ; <nl> - for ( size_t i = 0 ; i < list - > GetSize ( ) ; + + i ) { <nl> - base : : DictionaryValue * dict = nullptr ; <nl> - std : : string type ; <nl> - if ( ! list - > GetDictionary ( i , & dict ) ) <nl> - return false ; <nl> - dict - > GetString ( " type " , & type ) ; <nl> - if ( type = = " rawData " ) { <nl> - base : : Value * bytes = nullptr ; <nl> - dict - > GetBinary ( " bytes " , & bytes ) ; <nl> - ( * out ) - > AppendBytes ( bytes - > GetBlob ( ) . data ( ) , bytes - > GetBlob ( ) . size ( ) ) ; <nl> - } else if ( type = = " file " ) { <nl> - std : : string file ; <nl> - int offset = 0 , length = - 1 ; <nl> - double modification_time = 0 . 0 ; <nl> - dict - > GetStringWithoutPathExpansion ( " filePath " , & file ) ; <nl> - dict - > GetInteger ( " offset " , & offset ) ; <nl> - dict - > GetInteger ( " file " , & length ) ; <nl> - dict - > GetDouble ( " modificationTime " , & modification_time ) ; <nl> - ( * out ) - > AppendFileRange ( base : : FilePath : : FromUTF8Unsafe ( file ) , <nl> - static_cast < uint64_t > ( offset ) , <nl> - static_cast < uint64_t > ( length ) , <nl> - base : : Time : : FromDoubleT ( modification_time ) ) ; <nl> - } else if ( type = = " fileSystem " ) { <nl> - std : : string file_system_url ; <nl> - int offset = 0 , length = - 1 ; <nl> - double modification_time = 0 . 0 ; <nl> - dict - > GetStringWithoutPathExpansion ( " fileSystemURL " , & file_system_url ) ; <nl> - dict - > GetInteger ( " offset " , & offset ) ; <nl> - dict - > GetInteger ( " file " , & length ) ; <nl> - dict - > GetDouble ( " modificationTime " , & modification_time ) ; <nl> - ( * out ) - > AppendFileSystemFileRange ( <nl> - GURL ( file_system_url ) , static_cast < uint64_t > ( offset ) , <nl> - static_cast < uint64_t > ( length ) , <nl> - base : : Time : : FromDoubleT ( modification_time ) ) ; <nl> - } else if ( type = = " blob " ) { <nl> - std : : string uuid ; <nl> - dict - > GetString ( " blobUUID " , & uuid ) ; <nl> - ( * out ) - > AppendBlob ( uuid ) ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> / / static <nl> v8 : : Local < v8 : : Value > Converter < content : : WebContents * > : : ToV8 ( <nl> v8 : : Isolate * isolate , <nl> mmm a / atom / common / native_mate_converters / content_converter . h <nl> ppp b / atom / common / native_mate_converters / content_converter . h <nl> <nl> <nl> namespace content { <nl> struct ContextMenuParams ; <nl> - class ResourceRequestBody ; <nl> class WebContents ; <nl> } / / namespace content <nl> <nl> struct Converter < content : : PermissionType > { <nl> const content : : PermissionType & val ) ; <nl> } ; <nl> <nl> - template < > <nl> - struct Converter < scoped_refptr < content : : ResourceRequestBody > > { <nl> - static v8 : : Local < v8 : : Value > ToV8 ( <nl> - v8 : : Isolate * isolate , <nl> - const scoped_refptr < content : : ResourceRequestBody > & val ) ; <nl> - static bool FromV8 ( v8 : : Isolate * isolate , <nl> - v8 : : Local < v8 : : Value > val , <nl> - scoped_refptr < content : : ResourceRequestBody > * out ) ; <nl> - } ; <nl> - <nl> template < > <nl> struct Converter < content : : StopFindAction > { <nl> static bool FromV8 ( v8 : : Isolate * isolate , <nl> mmm a / atom / common / native_mate_converters / gfx_converter . cc <nl> ppp b / atom / common / native_mate_converters / gfx_converter . cc <nl> bool Converter < gfx : : Point > : : FromV8 ( v8 : : Isolate * isolate , <nl> return true ; <nl> } <nl> <nl> + v8 : : Local < v8 : : Value > Converter < gfx : : PointF > : : ToV8 ( v8 : : Isolate * isolate , <nl> + const gfx : : PointF & val ) { <nl> + mate : : Dictionary dict = mate : : Dictionary : : CreateEmpty ( isolate ) ; <nl> + dict . SetHidden ( " simple " , true ) ; <nl> + dict . Set ( " x " , val . x ( ) ) ; <nl> + dict . Set ( " y " , val . y ( ) ) ; <nl> + return dict . GetHandle ( ) ; <nl> + } <nl> + <nl> + bool Converter < gfx : : PointF > : : FromV8 ( v8 : : Isolate * isolate , <nl> + v8 : : Local < v8 : : Value > val , <nl> + gfx : : PointF * out ) { <nl> + mate : : Dictionary dict ; <nl> + if ( ! ConvertFromV8 ( isolate , val , & dict ) ) <nl> + return false ; <nl> + float x , y ; <nl> + if ( ! dict . Get ( " x " , & x ) | | ! dict . Get ( " y " , & y ) ) <nl> + return false ; <nl> + * out = gfx : : PointF ( x , y ) ; <nl> + return true ; <nl> + } <nl> + <nl> v8 : : Local < v8 : : Value > Converter < gfx : : Size > : : ToV8 ( v8 : : Isolate * isolate , <nl> const gfx : : Size & val ) { <nl> mate : : Dictionary dict = mate : : Dictionary : : CreateEmpty ( isolate ) ; <nl> struct Converter < display : : Display : : TouchSupport > { <nl> static v8 : : Local < v8 : : Value > ToV8 ( v8 : : Isolate * isolate , <nl> const display : : Display : : TouchSupport & val ) { <nl> switch ( val ) { <nl> - case display : : Display : : TOUCH_SUPPORT_AVAILABLE : <nl> + case display : : Display : : TouchSupport : : AVAILABLE : <nl> return StringToV8 ( isolate , " available " ) ; <nl> - case display : : Display : : TOUCH_SUPPORT_UNAVAILABLE : <nl> + case display : : Display : : TouchSupport : : UNAVAILABLE : <nl> return StringToV8 ( isolate , " unavailable " ) ; <nl> default : <nl> return StringToV8 ( isolate , " unknown " ) ; <nl> mmm a / atom / common / native_mate_converters / gfx_converter . h <nl> ppp b / atom / common / native_mate_converters / gfx_converter . h <nl> <nl> # define ATOM_COMMON_NATIVE_MATE_CONVERTERS_GFX_CONVERTER_H_ <nl> <nl> # include " native_mate / converter . h " <nl> + # include " ui / gfx / geometry / point_f . h " <nl> <nl> namespace display { <nl> class Display ; <nl> struct Converter < gfx : : Point > { <nl> gfx : : Point * out ) ; <nl> } ; <nl> <nl> + template < > <nl> + struct Converter < gfx : : PointF > { <nl> + static v8 : : Local < v8 : : Value > ToV8 ( v8 : : Isolate * isolate , <nl> + const gfx : : PointF & val ) ; <nl> + static bool FromV8 ( v8 : : Isolate * isolate , <nl> + v8 : : Local < v8 : : Value > val , <nl> + gfx : : PointF * out ) ; <nl> + } ; <nl> + <nl> template < > <nl> struct Converter < gfx : : Size > { <nl> static v8 : : Local < v8 : : Value > ToV8 ( v8 : : Isolate * isolate , const gfx : : Size & val ) ; <nl> mmm a / atom / common / native_mate_converters / net_converter . cc <nl> ppp b / atom / common / native_mate_converters / net_converter . cc <nl> <nl> # include " net / base / upload_element_reader . h " <nl> # include " net / base / upload_file_element_reader . h " <nl> # include " net / cert / x509_certificate . h " <nl> + # include " net / cert / x509_util . h " <nl> # include " net / http / http_response_headers . h " <nl> # include " net / url_request / url_request . h " <nl> # include " storage / browser / blob / upload_blob_element_reader . h " <nl> v8 : : Local < v8 : : Value > Converter < scoped_refptr < net : : X509Certificate > > : : ToV8 ( <nl> const scoped_refptr < net : : X509Certificate > & val ) { <nl> mate : : Dictionary dict ( isolate , v8 : : Object : : New ( isolate ) ) ; <nl> std : : string encoded_data ; <nl> - net : : X509Certificate : : GetPEMEncoded ( val - > os_cert_handle ( ) , & encoded_data ) ; <nl> + net : : X509Certificate : : GetPEMEncoded ( val - > cert_buffer ( ) , & encoded_data ) ; <nl> <nl> dict . Set ( " data " , encoded_data ) ; <nl> dict . Set ( " issuer " , val - > issuer ( ) ) ; <nl> v8 : : Local < v8 : : Value > Converter < scoped_refptr < net : : X509Certificate > > : : ToV8 ( <nl> dict . Set ( " validStart " , val - > valid_start ( ) . ToDoubleT ( ) ) ; <nl> dict . Set ( " validExpiry " , val - > valid_expiry ( ) . ToDoubleT ( ) ) ; <nl> dict . Set ( " fingerprint " , <nl> - net : : HashValue ( val - > CalculateFingerprint256 ( val - > os_cert_handle ( ) ) ) <nl> + net : : HashValue ( val - > CalculateFingerprint256 ( val - > cert_buffer ( ) ) ) <nl> . ToString ( ) ) ; <nl> <nl> - if ( ! val - > GetIntermediateCertificates ( ) . empty ( ) ) { <nl> - net : : X509Certificate : : OSCertHandles issuer_intermediates ( <nl> - val - > GetIntermediateCertificates ( ) . begin ( ) + 1 , <nl> - val - > GetIntermediateCertificates ( ) . end ( ) ) ; <nl> + const auto & intermediate_buffers = val - > intermediate_buffers ( ) ; <nl> + if ( ! intermediate_buffers . empty ( ) ) { <nl> + std : : vector < bssl : : UniquePtr < CRYPTO_BUFFER > > issuer_intermediates ; <nl> + issuer_intermediates . reserve ( intermediate_buffers . size ( ) - 1 ) ; <nl> + for ( size_t i = 1 ; i < intermediate_buffers . size ( ) ; + + i ) { <nl> + issuer_intermediates . push_back ( <nl> + net : : x509_util : : DupCryptoBuffer ( intermediate_buffers [ i ] . get ( ) ) ) ; <nl> + } <nl> const scoped_refptr < net : : X509Certificate > & issuer_cert = <nl> - net : : X509Certificate : : CreateFromHandle ( <nl> - val - > GetIntermediateCertificates ( ) . front ( ) , issuer_intermediates ) ; <nl> + net : : X509Certificate : : CreateFromBuffer ( <nl> + net : : x509_util : : DupCryptoBuffer ( intermediate_buffers [ 0 ] . get ( ) ) , <nl> + std : : move ( issuer_intermediates ) ) ; <nl> dict . Set ( " issuerCert " , issuer_cert ) ; <nl> } <nl> <nl> bool Converter < scoped_refptr < net : : X509Certificate > > : : FromV8 ( <nl> if ( ! CertFromData ( data , & leaf_cert ) ) <nl> return false ; <nl> <nl> - scoped_refptr < net : : X509Certificate > parent ; <nl> - if ( dict . Get ( " issuerCert " , & parent ) ) { <nl> - auto parents = std : : vector < net : : X509Certificate : : OSCertHandle > ( <nl> - parent - > GetIntermediateCertificates ( ) ) ; <nl> - parents . insert ( parents . begin ( ) , parent - > os_cert_handle ( ) ) ; <nl> - auto cert = net : : X509Certificate : : CreateFromHandle ( <nl> - leaf_cert - > os_cert_handle ( ) , parents ) ; <nl> + scoped_refptr < net : : X509Certificate > issuer_cert ; <nl> + if ( dict . Get ( " issuerCert " , & issuer_cert ) ) { <nl> + std : : vector < bssl : : UniquePtr < CRYPTO_BUFFER > > intermediates ; <nl> + intermediates . push_back ( <nl> + net : : x509_util : : DupCryptoBuffer ( issuer_cert - > cert_buffer ( ) ) ) ; <nl> + auto cert = net : : X509Certificate : : CreateFromBuffer ( <nl> + net : : x509_util : : DupCryptoBuffer ( leaf_cert - > cert_buffer ( ) ) , <nl> + std : : move ( intermediates ) ) ; <nl> if ( ! cert ) <nl> return false ; <nl> <nl> new file mode 100644 <nl> index 000000000000 . . 1f98a5b8ebd5 <nl> mmm / dev / null <nl> ppp b / atom / common / native_mate_converters / network_converter . cc <nl> <nl> + / / Copyright ( c ) 2018 GitHub , Inc . <nl> + / / Use of this source code is governed by the MIT license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + # include " atom / common / native_mate_converters / network_converter . h " <nl> + <nl> + # include < string > <nl> + # include < utility > <nl> + <nl> + # include " atom / common / native_mate_converters / value_converter . h " <nl> + # include " native_mate / dictionary . h " <nl> + # include " services / network / public / cpp / resource_request_body . h " <nl> + <nl> + namespace mate { <nl> + <nl> + / / static <nl> + v8 : : Local < v8 : : Value > <nl> + Converter < scoped_refptr < network : : ResourceRequestBody > > : : ToV8 ( <nl> + v8 : : Isolate * isolate , <nl> + const scoped_refptr < network : : ResourceRequestBody > & val ) { <nl> + if ( ! val ) <nl> + return v8 : : Null ( isolate ) ; <nl> + auto list = std : : make_unique < base : : ListValue > ( ) ; <nl> + for ( const auto & element : * ( val - > elements ( ) ) ) { <nl> + auto post_data_dict = std : : make_unique < base : : DictionaryValue > ( ) ; <nl> + auto type = element . type ( ) ; <nl> + if ( type = = network : : DataElement : : TYPE_BYTES ) { <nl> + auto bytes = base : : Value : : CreateWithCopiedBuffer ( <nl> + element . bytes ( ) , static_cast < size_t > ( element . length ( ) ) ) ; <nl> + post_data_dict - > SetString ( " type " , " rawData " ) ; <nl> + post_data_dict - > Set ( " bytes " , std : : move ( bytes ) ) ; <nl> + } else if ( type = = network : : DataElement : : TYPE_FILE ) { <nl> + post_data_dict - > SetString ( " type " , " file " ) ; <nl> + post_data_dict - > SetKey ( " filePath " , <nl> + base : : Value ( element . path ( ) . AsUTF8Unsafe ( ) ) ) ; <nl> + post_data_dict - > SetInteger ( " offset " , static_cast < int > ( element . offset ( ) ) ) ; <nl> + post_data_dict - > SetInteger ( " length " , static_cast < int > ( element . length ( ) ) ) ; <nl> + post_data_dict - > SetDouble ( <nl> + " modificationTime " , element . expected_modification_time ( ) . ToDoubleT ( ) ) ; <nl> + } else if ( type = = network : : DataElement : : TYPE_BLOB ) { <nl> + post_data_dict - > SetString ( " type " , " blob " ) ; <nl> + post_data_dict - > SetString ( " blobUUID " , element . blob_uuid ( ) ) ; <nl> + } <nl> + list - > Append ( std : : move ( post_data_dict ) ) ; <nl> + } <nl> + return ConvertToV8 ( isolate , * list ) ; <nl> + } <nl> + <nl> + / / static <nl> + bool Converter < scoped_refptr < network : : ResourceRequestBody > > : : FromV8 ( <nl> + v8 : : Isolate * isolate , <nl> + v8 : : Local < v8 : : Value > val , <nl> + scoped_refptr < network : : ResourceRequestBody > * out ) { <nl> + auto list = std : : make_unique < base : : ListValue > ( ) ; <nl> + if ( ! ConvertFromV8 ( isolate , val , list . get ( ) ) ) <nl> + return false ; <nl> + * out = new network : : ResourceRequestBody ( ) ; <nl> + for ( size_t i = 0 ; i < list - > GetSize ( ) ; + + i ) { <nl> + base : : DictionaryValue * dict = nullptr ; <nl> + std : : string type ; <nl> + if ( ! list - > GetDictionary ( i , & dict ) ) <nl> + return false ; <nl> + dict - > GetString ( " type " , & type ) ; <nl> + if ( type = = " rawData " ) { <nl> + base : : Value * bytes = nullptr ; <nl> + dict - > GetBinary ( " bytes " , & bytes ) ; <nl> + ( * out ) - > AppendBytes ( bytes - > GetBlob ( ) . data ( ) , bytes - > GetBlob ( ) . size ( ) ) ; <nl> + } else if ( type = = " file " ) { <nl> + std : : string file ; <nl> + int offset = 0 , length = - 1 ; <nl> + double modification_time = 0 . 0 ; <nl> + dict - > GetStringWithoutPathExpansion ( " filePath " , & file ) ; <nl> + dict - > GetInteger ( " offset " , & offset ) ; <nl> + dict - > GetInteger ( " file " , & length ) ; <nl> + dict - > GetDouble ( " modificationTime " , & modification_time ) ; <nl> + ( * out ) - > AppendFileRange ( base : : FilePath : : FromUTF8Unsafe ( file ) , <nl> + static_cast < uint64_t > ( offset ) , <nl> + static_cast < uint64_t > ( length ) , <nl> + base : : Time : : FromDoubleT ( modification_time ) ) ; <nl> + } else if ( type = = " blob " ) { <nl> + std : : string uuid ; <nl> + dict - > GetString ( " blobUUID " , & uuid ) ; <nl> + ( * out ) - > AppendBlob ( uuid ) ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + } / / namespace mate <nl> new file mode 100644 <nl> index 000000000000 . . 439ba19ec165 <nl> mmm / dev / null <nl> ppp b / atom / common / native_mate_converters / network_converter . h <nl> <nl> + / / Copyright ( c ) 2018 GitHub , Inc . <nl> + / / Use of this source code is governed by the MIT license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + # ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_NETWORK_CONVERTER_H_ <nl> + # define ATOM_COMMON_NATIVE_MATE_CONVERTERS_NETWORK_CONVERTER_H_ <nl> + <nl> + # include " base / memory / scoped_refptr . h " <nl> + # include " native_mate / converter . h " <nl> + <nl> + namespace network { <nl> + class ResourceRequestBody ; <nl> + } <nl> + <nl> + namespace mate { <nl> + <nl> + template < > <nl> + struct Converter < scoped_refptr < network : : ResourceRequestBody > > { <nl> + static v8 : : Local < v8 : : Value > ToV8 ( <nl> + v8 : : Isolate * isolate , <nl> + const scoped_refptr < network : : ResourceRequestBody > & val ) ; <nl> + static bool FromV8 ( v8 : : Isolate * isolate , <nl> + v8 : : Local < v8 : : Value > val , <nl> + scoped_refptr < network : : ResourceRequestBody > * out ) ; <nl> + } ; <nl> + <nl> + } / / namespace mate <nl> + <nl> + # endif / / ATOM_COMMON_NATIVE_MATE_CONVERTERS_NETWORK_CONVERTER_H_ <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> base : : Value * V8ValueConverter : : FromV8Value ( <nl> v8 : : Local < v8 : : Value > V8ValueConverter : : ToV8ValueImpl ( <nl> v8 : : Isolate * isolate , <nl> const base : : Value * value ) const { <nl> - switch ( value - > GetType ( ) ) { <nl> + switch ( value - > type ( ) ) { <nl> case base : : Value : : Type : : NONE : <nl> return v8 : : Null ( isolate ) ; <nl> <nl> v8 : : Local < v8 : : Value > V8ValueConverter : : ToV8ValueImpl ( <nl> return ToArrayBuffer ( isolate , static_cast < const base : : Value * > ( value ) ) ; <nl> <nl> default : <nl> - LOG ( ERROR ) < < " Unexpected value type : " < < value - > GetType ( ) ; <nl> + LOG ( ERROR ) < < " Unexpected value type : " < < value - > type ( ) ; <nl> return v8 : : Null ( isolate ) ; <nl> } <nl> } <nl> v8 : : Local < v8 : : Value > V8ValueConverter : : ToV8Array ( <nl> <nl> v8 : : Local < v8 : : Value > child_v8 = ToV8ValueImpl ( isolate , child ) ; <nl> <nl> - v8 : : TryCatch try_catch ; <nl> + v8 : : TryCatch try_catch ( isolate ) ; <nl> result - > Set ( static_cast < uint32_t > ( i ) , child_v8 ) ; <nl> if ( try_catch . HasCaught ( ) ) <nl> LOG ( ERROR ) < < " Setter for index " < < i < < " threw an exception . " ; <nl> v8 : : Local < v8 : : Value > V8ValueConverter : : ToV8Object ( <nl> const std : : string & key = iter . key ( ) ; <nl> v8 : : Local < v8 : : Value > child_v8 = ToV8ValueImpl ( isolate , & iter . value ( ) ) ; <nl> <nl> - v8 : : TryCatch try_catch ; <nl> + v8 : : TryCatch try_catch ( isolate ) ; <nl> result . Set ( key , child_v8 ) ; <nl> if ( try_catch . HasCaught ( ) ) { <nl> LOG ( ERROR ) < < " Setter for property " < < key . c_str ( ) < < " threw an " <nl> v8 : : Local < v8 : : Value > V8ValueConverter : : ToArrayBuffer ( <nl> return v8 : : Uint8Array : : New ( array_buffer , 0 , length ) ; <nl> } <nl> <nl> - mate : : Dictionary buffer_class ( isolate , buffer_value - > ToObject ( ) ) ; <nl> + mate : : Dictionary buffer_class ( <nl> + isolate , <nl> + buffer_value - > ToObject ( isolate - > GetCurrentContext ( ) ) . ToLocalChecked ( ) ) ; <nl> v8 : : Local < v8 : : Value > from_value ; <nl> if ( ! buffer_class . Get ( " from " , & from_value ) | | ! from_value - > IsFunction ( ) ) { <nl> return v8 : : Uint8Array : : New ( array_buffer , 0 , length ) ; <nl> base : : Value * V8ValueConverter : : FromV8ValueImpl ( FromV8ValueState * state , <nl> if ( val - > IsNull ( ) ) <nl> return std : : make_unique < base : : Value > ( ) . release ( ) ; <nl> <nl> + auto context = isolate - > GetCurrentContext ( ) ; <nl> + <nl> if ( val - > IsBoolean ( ) ) <nl> - return new base : : Value ( val - > ToBoolean ( ) - > Value ( ) ) ; <nl> + return new base : : Value ( val - > ToBoolean ( context ) . ToLocalChecked ( ) - > Value ( ) ) ; <nl> <nl> if ( val - > IsInt32 ( ) ) <nl> - return new base : : Value ( val - > ToInt32 ( ) - > Value ( ) ) ; <nl> + return new base : : Value ( val - > ToInt32 ( context ) . ToLocalChecked ( ) - > Value ( ) ) ; <nl> <nl> if ( val - > IsNumber ( ) ) { <nl> - double val_as_double = val - > ToNumber ( ) - > Value ( ) ; <nl> + double val_as_double = val - > ToNumber ( context ) . ToLocalChecked ( ) - > Value ( ) ; <nl> if ( ! std : : isfinite ( val_as_double ) ) <nl> return nullptr ; <nl> return new base : : Value ( val_as_double ) ; <nl> } <nl> <nl> if ( val - > IsString ( ) ) { <nl> - v8 : : String : : Utf8Value utf8 ( val - > ToString ( ) ) ; <nl> + v8 : : String : : Utf8Value utf8 ( val - > ToString ( context ) . ToLocalChecked ( ) ) ; <nl> return new base : : Value ( std : : string ( * utf8 , utf8 . length ( ) ) ) ; <nl> } <nl> <nl> base : : Value * V8ValueConverter : : FromV8ValueImpl ( FromV8ValueState * state , <nl> v8 : : Local < v8 : : Value > result = <nl> toISOString . As < v8 : : Function > ( ) - > Call ( val , 0 , nullptr ) ; <nl> if ( ! result . IsEmpty ( ) ) { <nl> - v8 : : String : : Utf8Value utf8 ( result - > ToString ( ) ) ; <nl> + v8 : : String : : Utf8Value utf8 ( result - > ToString ( context ) . ToLocalChecked ( ) ) ; <nl> return new base : : Value ( std : : string ( * utf8 , utf8 . length ( ) ) ) ; <nl> } <nl> } <nl> base : : Value * V8ValueConverter : : FromV8ValueImpl ( FromV8ValueState * state , <nl> if ( val - > IsRegExp ( ) ) { <nl> if ( ! reg_exp_allowed_ ) <nl> / / JSON . stringify converts to an object . <nl> - return FromV8Object ( val - > ToObject ( ) , state , isolate ) ; <nl> - return new base : : Value ( * v8 : : String : : Utf8Value ( val - > ToString ( ) ) ) ; <nl> + return FromV8Object ( val - > ToObject ( context ) . ToLocalChecked ( ) , <nl> + state , isolate ) ; <nl> + return new base : : Value ( <nl> + * v8 : : String : : Utf8Value ( val - > ToString ( context ) . ToLocalChecked ( ) ) ) ; <nl> } <nl> <nl> / / v8 : : Value doesn ' t have a ToArray ( ) method for some reason . <nl> base : : Value * V8ValueConverter : : FromV8ValueImpl ( FromV8ValueState * state , <nl> if ( ! function_allowed_ ) <nl> / / JSON . stringify refuses to convert function ( ) { } . <nl> return nullptr ; <nl> - return FromV8Object ( val - > ToObject ( ) , state , isolate ) ; <nl> + return FromV8Object ( val - > ToObject ( context ) . ToLocalChecked ( ) , <nl> + state , isolate ) ; <nl> } <nl> <nl> if ( node : : Buffer : : HasInstance ( val ) ) { <nl> base : : Value * V8ValueConverter : : FromV8ValueImpl ( FromV8ValueState * state , <nl> } <nl> <nl> if ( val - > IsObject ( ) ) { <nl> - return FromV8Object ( val - > ToObject ( ) , state , isolate ) ; <nl> + return FromV8Object ( val - > ToObject ( context ) . ToLocalChecked ( ) , <nl> + state , isolate ) ; <nl> } <nl> <nl> LOG ( ERROR ) < < " Unexpected v8 value type encountered . " ; <nl> base : : Value * V8ValueConverter : : FromV8Array ( v8 : : Local < v8 : : Array > val , <nl> <nl> / / Only fields with integer keys are carried over to the ListValue . <nl> for ( uint32_t i = 0 ; i < val - > Length ( ) ; + + i ) { <nl> - v8 : : TryCatch try_catch ; <nl> + v8 : : TryCatch try_catch ( isolate ) ; <nl> v8 : : Local < v8 : : Value > child_v8 = val - > Get ( i ) ; <nl> if ( try_catch . HasCaught ( ) ) { <nl> LOG ( ERROR ) < < " Getter for index " < < i < < " threw an exception . " ; <nl> base : : Value * V8ValueConverter : : FromV8Object ( v8 : : Local < v8 : : Object > val , <nl> continue ; <nl> } <nl> <nl> - v8 : : String : : Utf8Value name_utf8 ( key - > ToString ( ) ) ; <nl> + v8 : : String : : Utf8Value name_utf8 ( <nl> + key - > ToString ( isolate - > GetCurrentContext ( ) ) . ToLocalChecked ( ) ) ; <nl> <nl> - v8 : : TryCatch try_catch ; <nl> + v8 : : TryCatch try_catch ( isolate ) ; <nl> v8 : : Local < v8 : : Value > child_v8 = val - > Get ( key ) ; <nl> <nl> if ( try_catch . HasCaught ( ) ) { <nl> base : : Value * V8ValueConverter : : FromV8Object ( v8 : : Local < v8 : : Object > val , <nl> / / there * is * a " windowId " property , but since it should be an int , code <nl> / / on the browser which doesn ' t additionally check for null will fail . <nl> / / We can avoid all bugs related to this by stripping null . <nl> - if ( strip_null_from_objects_ & & child - > IsType ( base : : Value : : Type : : NONE ) ) <nl> + if ( strip_null_from_objects_ & & child - > is_none ( ) ) <nl> continue ; <nl> <nl> result - > SetWithoutPathExpansion ( std : : string ( * name_utf8 , name_utf8 . length ( ) ) , <nl> mmm a / atom / common / native_mate_converters / value_converter . cc <nl> ppp b / atom / common / native_mate_converters / value_converter . cc <nl> bool Converter < base : : DictionaryValue > : : FromV8 ( v8 : : Isolate * isolate , <nl> atom : : V8ValueConverter converter ; <nl> std : : unique_ptr < base : : Value > value ( <nl> converter . FromV8Value ( val , isolate - > GetCurrentContext ( ) ) ) ; <nl> - if ( value & & value - > IsType ( base : : Value : : Type : : DICTIONARY ) ) { <nl> + if ( value & & value - > is_dict ( ) ) { <nl> out - > Swap ( static_cast < base : : DictionaryValue * > ( value . get ( ) ) ) ; <nl> return true ; <nl> } else { <nl> bool Converter < base : : ListValue > : : FromV8 ( v8 : : Isolate * isolate , <nl> atom : : V8ValueConverter converter ; <nl> std : : unique_ptr < base : : Value > value ( <nl> converter . FromV8Value ( val , isolate - > GetCurrentContext ( ) ) ) ; <nl> - if ( value - > IsType ( base : : Value : : Type : : LIST ) ) { <nl> + if ( value - > is_list ( ) ) { <nl> out - > Swap ( static_cast < base : : ListValue * > ( value . get ( ) ) ) ; <nl> return true ; <nl> } else { <nl> mmm a / atom / common / platform_util_win . cc <nl> ppp b / atom / common / platform_util_win . cc <nl> <nl> # include < objbase . h > <nl> # include < shellapi . h > <nl> # include < shlobj . h > <nl> + # include < wrl / client . h > <nl> <nl> # include " base / bind . h " <nl> # include " base / bind_helpers . h " <nl> <nl> # include " base / win / registry . h " <nl> # include " base / win / scoped_co_mem . h " <nl> # include " base / win / scoped_com_initializer . h " <nl> - # include " base / win / scoped_comptr . h " <nl> # include " base / win / windows_version . h " <nl> # include " ui / base / win / shell . h " <nl> # include " url / gurl . h " <nl> namespace platform_util { <nl> <nl> bool ShowItemInFolder ( const base : : FilePath & full_path ) { <nl> base : : win : : ScopedCOMInitializer com_initializer ; <nl> - if ( ! com_initializer . succeeded ( ) ) <nl> + if ( ! com_initializer . Succeeded ( ) ) <nl> return false ; <nl> <nl> base : : FilePath dir = full_path . DirName ( ) . AsEndingWithSeparator ( ) ; <nl> bool ShowItemInFolder ( const base : : FilePath & full_path ) { <nl> return ui : : win : : OpenFolderViaShell ( dir ) ; <nl> } <nl> <nl> - base : : win : : ScopedComPtr < IShellFolder > desktop ; <nl> + Microsoft : : WRL : : ComPtr < IShellFolder > desktop ; <nl> HRESULT hr = SHGetDesktopFolder ( desktop . GetAddressOf ( ) ) ; <nl> if ( FAILED ( hr ) ) <nl> return false ; <nl> void OpenExternal ( const base : : string16 & url , <nl> <nl> bool MoveItemToTrash ( const base : : FilePath & path ) { <nl> base : : win : : ScopedCOMInitializer com_initializer ; <nl> - if ( ! com_initializer . succeeded ( ) ) <nl> + if ( ! com_initializer . Succeeded ( ) ) <nl> return false ; <nl> <nl> - base : : win : : ScopedComPtr < IFileOperation > pfo ; <nl> + Microsoft : : WRL : : ComPtr < IFileOperation > pfo ; <nl> if ( FAILED ( : : CoCreateInstance ( CLSID_FileOperation , nullptr , CLSCTX_ALL , <nl> IID_PPV_ARGS ( & pfo ) ) ) ) <nl> return false ; <nl> bool MoveItemToTrash ( const base : : FilePath & path ) { <nl> } <nl> <nl> / / Create an IShellItem from the supplied source path . <nl> - base : : win : : ScopedComPtr < IShellItem > delete_item ; <nl> + Microsoft : : WRL : : ComPtr < IShellItem > delete_item ; <nl> if ( FAILED ( SHCreateItemFromParsingName ( <nl> path . value ( ) . c_str ( ) , NULL , <nl> IID_PPV_ARGS ( delete_item . GetAddressOf ( ) ) ) ) ) <nl> return false ; <nl> <nl> - base : : win : : ScopedComPtr < IFileOperationProgressSink > delete_sink ( <nl> + Microsoft : : WRL : : ComPtr < IFileOperationProgressSink > delete_sink ( <nl> new DeleteFileProgressSink ) ; <nl> if ( ! delete_sink ) <nl> return false ; <nl> mmm a / brightray / brightray . gyp <nl> ppp b / brightray / brightray . gyp <nl> <nl> { <nl> ' variables ' : { <nl> # The libraries brightray will be compiled to . <nl> - ' linux_system_libraries ' : ' gtk + - 3 . 0 dbus - 1 x11 x11 - xcb xcb xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf - 2 . 0 gmodule - 2 . 0 nss ' , <nl> + ' linux_system_libraries ' : ' gtk + - 3 . 0 atk - bridge - 2 . 0 dbus - 1 x11 x11 - xcb xcb xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf - 2 . 0 gmodule - 2 . 0 nss ' , <nl> ' conditions ' : [ <nl> [ ' target_arch = = " mips64el " ' , { <nl> ' linux_system_libraries ' : ' < ( linux_system_libraries ) libpulse ' , <nl> <nl> ' < ( libchromiumcontent_src_dir ) / third_party / mojo / src ' , <nl> ' < ( libchromiumcontent_src_dir ) / third_party / WebKit ' , <nl> ' < ( libchromiumcontent_src_dir ) / third_party / khronos ' , <nl> + ' < ( libchromiumcontent_src_dir ) / third_party / protobuf / src ' , <nl> ' < ( libchromiumcontent_dir ) / gen ' , <nl> ] , <nl> ' direct_dependent_settings ' : { <nl> <nl> ' < ( libchromiumcontent_dir ) / gen / third_party / WebKit ' , <nl> ] , <nl> } , <nl> + ' defines ' : [ <nl> + # See Chromium ' s " src / third_party / protobuf / BUILD . gn " . <nl> + ' GOOGLE_PROTOBUF_NO_RTTI ' , <nl> + ' GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER ' , <nl> + ] , <nl> ' sources ' : [ ' < @ ( brightray_sources ) ' ] , <nl> ' conditions ' : [ <nl> # Link with libraries of libchromiumcontent . <nl> <nl> # Following libraries are always linked statically . <nl> ' < ( libchromiumcontent_dir ) / libgtkui . a ' , <nl> ' < ( libchromiumcontent_dir ) / libhttp_server . a ' , <nl> - ' < ( libchromiumcontent_dir ) / libdesktop_capture . a ' , <nl> + ' < ( libchromiumcontent_dir ) / libdevice_service . a ' , <nl> ' < ( libchromiumcontent_dir ) / libdom_keycode_converter . a ' , <nl> ' < ( libchromiumcontent_dir ) / libsystem_wrappers . a ' , <nl> ' < ( libchromiumcontent_dir ) / librtc_base . a ' , <nl> <nl> ' < ( libchromiumcontent_dir ) / libyuv . a ' , <nl> ' < ( libchromiumcontent_dir ) / librenderer . a ' , <nl> ' < ( libchromiumcontent_dir ) / libsecurity_state . a ' , <nl> - # components / network_session_configurator / common / <nl> - ' < ( libchromiumcontent_dir ) / libcommon . a ' , <nl> + ' < ( libchromiumcontent_dir ) / libviz_service . a ' , <nl> # services / device / wake_lock / power_save_blocker / <nl> ' < ( libchromiumcontent_dir ) / libpower_save_blocker . a ' , <nl> # Friends of libpdf . a : <nl> <nl> ' < ( libchromiumcontent_dir ) / libppapi_cpp_objects . a ' , <nl> ' < ( libchromiumcontent_dir ) / libppapi_internal_module . a ' , <nl> ' < ( libchromiumcontent_dir ) / libpdfium . a ' , <nl> + ' < ( libchromiumcontent_dir ) / libpdfium_skia_shared . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfdrm . a ' , <nl> ' < ( libchromiumcontent_dir ) / libformfiller . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfpdfapi . a ' , <nl> <nl> ' < ( libchromiumcontent_dir ) / libfxcodec . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfxge . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfxjs . a ' , <nl> - ' < ( libchromiumcontent_dir ) / libjavascript . a ' , <nl> ' < ( libchromiumcontent_dir ) / libpwl . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfx_agg . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfx_lcms2 . a ' , <nl> <nl> ' libraries ' : [ <nl> # Following libraries are always linked statically . <nl> ' < ( libchromiumcontent_dir ) / libhttp_server . a ' , <nl> - ' < ( libchromiumcontent_dir ) / libdesktop_capture . a ' , <nl> + ' < ( libchromiumcontent_dir ) / libdevice_service . a ' , <nl> ' < ( libchromiumcontent_dir ) / libdom_keycode_converter . a ' , <nl> ' < ( libchromiumcontent_dir ) / librtc_base . a ' , <nl> ' < ( libchromiumcontent_dir ) / librtc_base_generic . a ' , <nl> <nl> ' < ( libchromiumcontent_dir ) / libwebrtc_common . a ' , <nl> ' < ( libchromiumcontent_dir ) / libinit_webrtc . a ' , <nl> ' < ( libchromiumcontent_dir ) / libyuv . a ' , <nl> + ' < ( libchromiumcontent_dir ) / libpdfium_skia_shared . a ' , <nl> ' < ( libchromiumcontent_dir ) / librenderer . a ' , <nl> ' < ( libchromiumcontent_dir ) / libsecurity_state . a ' , <nl> - # components / network_session_configurator / common / <nl> - ' < ( libchromiumcontent_dir ) / libcommon . a ' , <nl> + ' < ( libchromiumcontent_dir ) / libviz_service . a ' , <nl> # services / device / wake_lock / power_save_blocker / <nl> ' < ( libchromiumcontent_dir ) / libpower_save_blocker . a ' , <nl> # Friends of libpdf . a : <nl> <nl> ' < ( libchromiumcontent_dir ) / libfxcrt . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfxge . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfxjs . a ' , <nl> - ' < ( libchromiumcontent_dir ) / libjavascript . a ' , <nl> ' < ( libchromiumcontent_dir ) / libpwl . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfx_agg . a ' , <nl> ' < ( libchromiumcontent_dir ) / libfx_lcms2 . a ' , <nl> <nl> ' $ ( SDKROOT ) / System / Library / Frameworks / Carbon . framework ' , <nl> ' $ ( SDKROOT ) / System / Library / Frameworks / CoreFoundation . framework ' , <nl> # device / gamepad / BUILD . gn : <nl> + ' $ ( SDKROOT ) / System / Library / Frameworks / ForceFeedback . framework ' , <nl> ' $ ( SDKROOT ) / System / Library / Frameworks / GameController . framework ' , <nl> # content_browser . gypi : <nl> ' - lbsm ' , <nl> <nl> ' < ( libchromiumcontent_dir ) / sandbox . lib ' , <nl> ' < ( libchromiumcontent_dir ) / sandbox_helper_win . lib ' , <nl> ' < ( libchromiumcontent_dir ) / http_server . lib ' , <nl> - ' < ( libchromiumcontent_dir ) / desktop_capture . lib ' , <nl> + ' < ( libchromiumcontent_dir ) / device_service . lib ' , <nl> ' < ( libchromiumcontent_dir ) / dom_keycode_converter . lib ' , <nl> ' < ( libchromiumcontent_dir ) / rtc_base . lib ' , <nl> ' < ( libchromiumcontent_dir ) / rtc_base_generic . lib ' , <nl> <nl> ' < ( libchromiumcontent_dir ) / webrtc_common . lib ' , <nl> ' < ( libchromiumcontent_dir ) / init_webrtc . lib ' , <nl> ' < ( libchromiumcontent_dir ) / libyuv . lib ' , <nl> + ' < ( libchromiumcontent_dir ) / pdfium_skia_shared . lib ' , <nl> ' < ( libchromiumcontent_dir ) / renderer . lib ' , <nl> ' < ( libchromiumcontent_dir ) / security_state . lib ' , <nl> - # components / network_session_configurator / common / <nl> - ' < ( libchromiumcontent_dir ) / common . lib ' , <nl> + ' < ( libchromiumcontent_dir ) / viz_service . lib ' , <nl> # services / device / wake_lock / power_save_blocker / <nl> ' < ( libchromiumcontent_dir ) / power_save_blocker . lib ' , <nl> # Friends of pdf . lib : <nl> <nl> ' < ( libchromiumcontent_dir ) / fxcrt . lib ' , <nl> ' < ( libchromiumcontent_dir ) / fxge . lib ' , <nl> ' < ( libchromiumcontent_dir ) / fxjs . lib ' , <nl> - ' < ( libchromiumcontent_dir ) / javascript . lib ' , <nl> ' < ( libchromiumcontent_dir ) / pwl . lib ' , <nl> ' < ( libchromiumcontent_dir ) / fx_agg . lib ' , <nl> ' < ( libchromiumcontent_dir ) / fx_lcms2 . lib ' , <nl> ' < ( libchromiumcontent_dir ) / fx_libopenjpeg . lib ' , <nl> ' < ( libchromiumcontent_dir ) / fx_zlib . lib ' , <nl> + ' < ( libchromiumcontent_dir ) / desktop_capture_generic . lib ' , <nl> + ' < ( libchromiumcontent_dir ) / desktop_capture . lib ' , <nl> ] , <nl> } , <nl> } , { <nl> mmm a / brightray / brightray . gypi <nl> ppp b / brightray / brightray . gypi <nl> <nl> ' GCC_ENABLE_CPP_RTTI ' : ' NO ' , <nl> ' GCC_TREAT_WARNINGS_AS_ERRORS ' : ' YES ' , <nl> ' CLANG_CXX_LANGUAGE_STANDARD ' : ' c + + 14 ' , <nl> - ' MACOSX_DEPLOYMENT_TARGET ' : ' 10 . 9 ' , <nl> + ' MACOSX_DEPLOYMENT_TARGET ' : ' 10 . 10 ' , <nl> ' RUN_CLANG_STATIC_ANALYZER ' : ' YES ' , <nl> ' USE_HEADER_MAP ' : ' NO ' , <nl> } , <nl> <nl> ] , <nl> ' cflags_cc ' : [ <nl> ' - D__STRICT_ANSI__ ' , <nl> + ' - fno - exceptions ' , <nl> ' - fno - rtti ' , <nl> ] , <nl> ' ldflags ' : [ <nl> <nl> # perform FPO regardless , so we must explicitly disable . <nl> # We still want the false setting above to avoid having <nl> # " / Oy / Oy - " and warnings about overriding . <nl> - ' AdditionalOptions ' : [ ' / Oy - ' , ' / d2guard4 ' ] , <nl> + ' AdditionalOptions ' : [ ' / Oy - ' , ' / guard : cf ' ] , <nl> } , <nl> ' VCLibrarianTool ' : { <nl> ' LinkTimeCodeGeneration ' : ' true ' , # / LTCG <nl> mmm a / brightray / browser / browser_context . cc <nl> ppp b / brightray / browser / browser_context . cc <nl> content : : SSLHostStateDelegate * BrowserContext : : GetSSLHostStateDelegate ( ) { <nl> return nullptr ; <nl> } <nl> <nl> - content : : PermissionManager * BrowserContext : : GetPermissionManager ( ) { <nl> - if ( ! permission_manager_ . get ( ) ) <nl> - permission_manager_ . reset ( new PermissionManager ) ; <nl> - return permission_manager_ . get ( ) ; <nl> - } <nl> - <nl> content : : BackgroundFetchDelegate * BrowserContext : : GetBackgroundFetchDelegate ( ) { <nl> return nullptr ; <nl> } <nl> mmm a / brightray / browser / browser_context . h <nl> ppp b / brightray / browser / browser_context . h <nl> <nl> # include " base / memory / ref_counted . h " <nl> # include " base / memory / weak_ptr . h " <nl> # include " brightray / browser / media / media_device_id_salt . h " <nl> - # include " brightray / browser / permission_manager . h " <nl> # include " brightray / browser / url_request_context_getter . h " <nl> # include " content / public / browser / browser_context . h " <nl> <nl> class SpecialStoragePolicy ; <nl> <nl> namespace brightray { <nl> <nl> - class PermissionManager ; <nl> - <nl> class BrowserContext : public base : : RefCounted < BrowserContext > , <nl> public content : : BrowserContext , <nl> public brightray : : URLRequestContextGetter : : Delegate { <nl> class BrowserContext : public base : : RefCounted < BrowserContext > , <nl> storage : : SpecialStoragePolicy * GetSpecialStoragePolicy ( ) override ; <nl> content : : PushMessagingService * GetPushMessagingService ( ) override ; <nl> content : : SSLHostStateDelegate * GetSSLHostStateDelegate ( ) override ; <nl> - content : : PermissionManager * GetPermissionManager ( ) override ; <nl> content : : BackgroundFetchDelegate * GetBackgroundFetchDelegate ( ) override ; <nl> content : : BackgroundSyncController * GetBackgroundSyncController ( ) override ; <nl> content : : BrowsingDataRemoverDelegate * GetBrowsingDataRemoverDelegate ( ) <nl> class BrowserContext : public base : : RefCounted < BrowserContext > , <nl> scoped_refptr < URLRequestContextGetter > url_request_getter_ ; <nl> scoped_refptr < storage : : SpecialStoragePolicy > storage_policy_ ; <nl> std : : unique_ptr < PrefService > prefs_ ; <nl> - std : : unique_ptr < PermissionManager > permission_manager_ ; <nl> std : : unique_ptr < MediaDeviceIDSalt > media_device_id_salt_ ; <nl> <nl> base : : WeakPtrFactory < BrowserContext > weak_factory_ ; <nl> mmm a / brightray / browser / browser_main_parts . cc <nl> ppp b / brightray / browser / browser_main_parts . cc <nl> <nl> # include " brightray / common / main_delegate . h " <nl> # include " content / public / browser / browser_thread . h " <nl> # include " content / public / common / content_switches . h " <nl> + # include " content / public / common / result_codes . h " <nl> # include " media / base / localized_strings . h " <nl> - # include " net / proxy / proxy_resolver_v8 . h " <nl> + # include " net / proxy_resolution / proxy_resolver_v8 . h " <nl> # include " ui / base / l10n / l10n_util . h " <nl> # include " ui / base / material_design / material_design_controller . h " <nl> # include " ui / base / resource / resource_bundle . h " <nl> void OverrideAppLogsPath ( ) { <nl> } <nl> # endif <nl> <nl> - void BrowserMainParts : : PreEarlyInitialization ( ) { <nl> + int BrowserMainParts : : PreEarlyInitialization ( ) { <nl> std : : unique_ptr < base : : FeatureList > feature_list ( new base : : FeatureList ) ; <nl> / / TODO ( deepak1556 ) : Disable guest webcontents based on OOPIF feature . <nl> - feature_list - > InitializeFromCommandLine ( " " , " GuestViewCrossProcessFrames " ) ; <nl> + / / Disable surface synchronization and async wheel events to make OSR work . <nl> + feature_list - > InitializeFromCommandLine ( <nl> + " " , <nl> + " GuestViewCrossProcessFrames , SurfaceSynchronization , AsyncWheelEvents " ) ; <nl> base : : FeatureList : : SetInstance ( std : : move ( feature_list ) ) ; <nl> OverrideAppLogsPath ( ) ; <nl> # if defined ( USE_X11 ) <nl> void BrowserMainParts : : PreEarlyInitialization ( ) { <nl> / / we can ' t shutdown properly while creating and initializing services . <nl> ui : : SetX11ErrorHandlers ( nullptr , nullptr ) ; <nl> # endif <nl> + <nl> + return content : : RESULT_CODE_NORMAL_EXIT ; <nl> } <nl> <nl> void BrowserMainParts : : ToolkitInitialized ( ) { <nl> mmm a / brightray / browser / browser_main_parts . h <nl> ppp b / brightray / browser / browser_main_parts . h <nl> class BrowserMainParts : public content : : BrowserMainParts { <nl> <nl> protected : <nl> / / content : : BrowserMainParts : <nl> - void PreEarlyInitialization ( ) override ; <nl> + int PreEarlyInitialization ( ) override ; <nl> void ToolkitInitialized ( ) override ; <nl> void PreMainMessageLoopStart ( ) override ; <nl> void PreMainMessageLoopRun ( ) override ; <nl> mmm a / brightray / browser / devtools_file_system_indexer . cc <nl> ppp b / brightray / browser / devtools_file_system_indexer . cc <nl> <nl> # include " base / files / file_util_proxy . h " <nl> # include " base / lazy_instance . h " <nl> # include " base / logging . h " <nl> + # include " base / sequence_checker . h " <nl> # include " base / stl_util . h " <nl> # include " base / strings / string_util . h " <nl> # include " base / strings / utf_string_conversions . h " <nl> + # include " base / task_scheduler / lazy_task_runner . h " <nl> + # include " base / task_scheduler / post_task . h " <nl> # include " content / public / browser / browser_thread . h " <nl> <nl> using base : : Bind ; <nl> using base : : TimeDelta ; <nl> using base : : TimeTicks ; <nl> using content : : BrowserThread ; <nl> using std : : map ; <nl> - using std : : set ; <nl> using std : : string ; <nl> using std : : vector ; <nl> <nl> namespace brightray { <nl> <nl> namespace { <nl> <nl> + base : : SequencedTaskRunner * impl_task_runner ( ) { <nl> + constexpr base : : TaskTraits kBlockingTraits = { base : : MayBlock ( ) , <nl> + base : : TaskPriority : : BACKGROUND } ; <nl> + static base : : LazySequencedTaskRunner s_sequenced_task_task_runner = <nl> + LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER ( kBlockingTraits ) ; <nl> + return s_sequenced_task_task_runner . Get ( ) . get ( ) ; <nl> + } <nl> + <nl> typedef int32_t Trigram ; <nl> typedef char TrigramChar ; <nl> typedef uint16_t FileId ; <nl> const TrigramChar kUndefinedTrigramChar = - 1 ; <nl> const TrigramChar kBinaryTrigramChar = - 2 ; <nl> const Trigram kUndefinedTrigram = - 1 ; <nl> <nl> - template < typename Char > <nl> - bool IsAsciiUpper ( Char c ) { <nl> - return c > = ' A ' & & c < = ' Z ' ; <nl> - } <nl> - <nl> class Index { <nl> public : <nl> Index ( ) ; <nl> + / / Index is only instantiated as a leak LazyInstance , so the destructor is <nl> + / / never called . <nl> + ~ Index ( ) = delete ; <nl> + <nl> Time LastModifiedTimeForFile ( const FilePath & file_path ) ; <nl> void SetTrigramsForFile ( const FilePath & file_path , <nl> const vector < Trigram > & index , <nl> const Time & time ) ; <nl> - vector < FilePath > Search ( string query ) ; <nl> - void PrintStats ( ) ; <nl> + vector < FilePath > Search ( const string & query ) ; <nl> void NormalizeVectors ( ) ; <nl> + void Reset ( ) ; <nl> + void EnsureInitialized ( ) ; <nl> <nl> private : <nl> - ~ Index ( ) ; <nl> - <nl> FileId GetFileId ( const FilePath & file_path ) ; <nl> <nl> typedef map < FilePath , FileId > FileIdsMap ; <nl> class Index { <nl> typedef map < FilePath , Time > IndexedFilesMap ; <nl> IndexedFilesMap index_times_ ; <nl> vector < bool > is_normalized_ ; <nl> + SEQUENCE_CHECKER ( sequence_checker_ ) ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( Index ) ; <nl> } ; <nl> TrigramChar TrigramCharForChar ( char c ) { <nl> char ch = static_cast < char > ( i ) ; <nl> if ( ch = = ' \ t ' ) <nl> ch = ' ' ; <nl> - if ( IsAsciiUpper ( ch ) ) <nl> + if ( base : : IsAsciiUpper ( ch ) ) <nl> ch = ch - ' A ' + ' a ' ; <nl> <nl> bool is_binary_char = ch < 9 | | ( ch > = 14 & & ch < 32 ) | | ch = = 127 ; <nl> Trigram TrigramAtIndex ( const vector < TrigramChar > & trigram_chars , size_t index ) { <nl> } <nl> <nl> Index : : Index ( ) : last_file_id_ ( 0 ) { <nl> + Reset ( ) ; <nl> + } <nl> + <nl> + void Index : : Reset ( ) { <nl> + file_ids_ . clear ( ) ; <nl> + index_ . clear ( ) ; <nl> + index_times_ . clear ( ) ; <nl> + is_normalized_ . clear ( ) ; <nl> + last_file_id_ = 0 ; <nl> + } <nl> + <nl> + void Index : : EnsureInitialized ( ) { <nl> + if ( index_ . size ( ) ! = 0 ) <nl> + return ; <nl> index_ . resize ( kTrigramCount ) ; <nl> is_normalized_ . resize ( kTrigramCount ) ; <nl> std : : fill ( is_normalized_ . begin ( ) , is_normalized_ . end ( ) , true ) ; <nl> } <nl> <nl> - Index : : ~ Index ( ) { } <nl> - <nl> Time Index : : LastModifiedTimeForFile ( const FilePath & file_path ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + DCHECK_CALLED_ON_VALID_SEQUENCE ( sequence_checker_ ) ; <nl> + EnsureInitialized ( ) ; <nl> Time last_modified_time ; <nl> if ( index_times_ . find ( file_path ) ! = index_times_ . end ( ) ) <nl> last_modified_time = index_times_ [ file_path ] ; <nl> Time Index : : LastModifiedTimeForFile ( const FilePath & file_path ) { <nl> void Index : : SetTrigramsForFile ( const FilePath & file_path , <nl> const vector < Trigram > & index , <nl> const Time & time ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + DCHECK_CALLED_ON_VALID_SEQUENCE ( sequence_checker_ ) ; <nl> + EnsureInitialized ( ) ; <nl> FileId file_id = GetFileId ( file_path ) ; <nl> auto it = index . begin ( ) ; <nl> for ( ; it ! = index . end ( ) ; + + it ) { <nl> void Index : : SetTrigramsForFile ( const FilePath & file_path , <nl> index_times_ [ file_path ] = time ; <nl> } <nl> <nl> - vector < FilePath > Index : : Search ( string query ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + vector < FilePath > Index : : Search ( const string & query ) { <nl> + DCHECK_CALLED_ON_VALID_SEQUENCE ( sequence_checker_ ) ; <nl> + EnsureInitialized ( ) ; <nl> const char * data = query . c_str ( ) ; <nl> vector < TrigramChar > trigram_chars ; <nl> trigram_chars . reserve ( query . size ( ) ) ; <nl> vector < FilePath > Index : : Search ( string query ) { <nl> if ( trigram ! = kUndefinedTrigram ) <nl> trigrams . push_back ( trigram ) ; <nl> } <nl> - set < FileId > file_ids ; <nl> + std : : set < FileId > file_ids ; <nl> bool first = true ; <nl> vector < Trigram > : : const_iterator it = trigrams . begin ( ) ; <nl> for ( ; it ! = trigrams . end ( ) ; + + it ) { <nl> vector < FilePath > Index : : Search ( string query ) { <nl> first = false ; <nl> continue ; <nl> } <nl> - set < FileId > intersection = <nl> - base : : STLSetIntersection < set < FileId > > ( file_ids , index_ [ trigram ] ) ; <nl> + std : : set < FileId > intersection = <nl> + base : : STLSetIntersection < std : : set < FileId > > ( file_ids , index_ [ trigram ] ) ; <nl> file_ids . swap ( intersection ) ; <nl> } <nl> vector < FilePath > result ; <nl> vector < FilePath > Index : : Search ( string query ) { <nl> } <nl> <nl> FileId Index : : GetFileId ( const FilePath & file_path ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + DCHECK_CALLED_ON_VALID_SEQUENCE ( sequence_checker_ ) ; <nl> + EnsureInitialized ( ) ; <nl> string file_path_str = file_path . AsUTF8Unsafe ( ) ; <nl> if ( file_ids_ . find ( file_path ) ! = file_ids_ . end ( ) ) <nl> return file_ids_ [ file_path ] ; <nl> FileId Index : : GetFileId ( const FilePath & file_path ) { <nl> } <nl> <nl> void Index : : NormalizeVectors ( ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + DCHECK_CALLED_ON_VALID_SEQUENCE ( sequence_checker_ ) ; <nl> + EnsureInitialized ( ) ; <nl> for ( size_t i = 0 ; i < kTrigramCount ; + + i ) { <nl> if ( ! is_normalized_ [ i ] ) { <nl> std : : sort ( index_ [ i ] . begin ( ) , index_ [ i ] . end ( ) ) ; <nl> void Index : : NormalizeVectors ( ) { <nl> } <nl> } <nl> <nl> - void Index : : PrintStats ( ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> - LOG ( ERROR ) < < " Index stats : " ; <nl> - size_t size = 0 ; <nl> - size_t maxSize = 0 ; <nl> - size_t capacity = 0 ; <nl> - for ( size_t i = 0 ; i < kTrigramCount ; + + i ) { <nl> - if ( index_ [ i ] . size ( ) > maxSize ) <nl> - maxSize = index_ [ i ] . size ( ) ; <nl> - size + = index_ [ i ] . size ( ) ; <nl> - capacity + = index_ [ i ] . capacity ( ) ; <nl> - } <nl> - LOG ( ERROR ) < < " - total trigram count : " < < size ; <nl> - LOG ( ERROR ) < < " - max file count per trigram : " < < maxSize ; <nl> - LOG ( ERROR ) < < " - total vectors capacity " < < capacity ; <nl> - size_t total_index_size = <nl> - capacity * sizeof ( FileId ) + sizeof ( vector < FileId > ) * kTrigramCount ; <nl> - LOG ( ERROR ) < < " - estimated total index size " < < total_index_size ; <nl> - } <nl> - <nl> typedef Callback < void ( bool , const vector < bool > & ) > IndexerCallback ; <nl> <nl> } / / namespace <nl> DevToolsFileSystemIndexer : : FileSystemIndexingJob : : FileSystemIndexingJob ( <nl> total_work_callback_ ( total_work_callback ) , <nl> worked_callback_ ( worked_callback ) , <nl> done_callback_ ( done_callback ) , <nl> - current_file_ ( <nl> - BrowserThread : : GetTaskRunnerForThread ( BrowserThread : : FILE ) . get ( ) ) , <nl> files_indexed_ ( 0 ) , <nl> stopped_ ( false ) { <nl> current_trigrams_set_ . resize ( kTrigramCount ) ; <nl> DevToolsFileSystemIndexer : : FileSystemIndexingJob : : ~ FileSystemIndexingJob ( ) { } <nl> <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : Start ( ) { <nl> DCHECK_CURRENTLY_ON ( BrowserThread : : UI ) ; <nl> - BrowserThread : : PostTask ( <nl> - BrowserThread : : FILE , FROM_HERE , <nl> - BindOnce ( & FileSystemIndexingJob : : CollectFilesToIndex , this ) ) ; <nl> + impl_task_runner ( ) - > PostTask ( <nl> + FROM_HERE , BindOnce ( & FileSystemIndexingJob : : CollectFilesToIndex , this ) ) ; <nl> } <nl> <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : Stop ( ) { <nl> DCHECK_CURRENTLY_ON ( BrowserThread : : UI ) ; <nl> - BrowserThread : : PostTask ( <nl> - BrowserThread : : FILE , FROM_HERE , <nl> - BindOnce ( & FileSystemIndexingJob : : StopOnFileThread , this ) ) ; <nl> + impl_task_runner ( ) - > PostTask ( <nl> + FROM_HERE , BindOnce ( & FileSystemIndexingJob : : StopOnImplSequence , this ) ) ; <nl> } <nl> <nl> - void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : StopOnFileThread ( ) { <nl> + void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : StopOnImplSequence ( ) { <nl> stopped_ = true ; <nl> } <nl> <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : CollectFilesToIndex ( ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + DCHECK ( impl_task_runner ( ) - > RunsTasksInCurrentSequence ( ) ) ; <nl> if ( stopped_ ) <nl> return ; <nl> if ( ! file_enumerator_ ) { <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : CollectFilesToIndex ( ) { <nl> if ( current_last_modified_time > saved_last_modified_time ) { <nl> file_path_times_ [ file_path ] = current_last_modified_time ; <nl> } <nl> - BrowserThread : : PostTask ( <nl> - BrowserThread : : FILE , FROM_HERE , <nl> - BindOnce ( & FileSystemIndexingJob : : CollectFilesToIndex , this ) ) ; <nl> + impl_task_runner ( ) - > PostTask ( <nl> + FROM_HERE , BindOnce ( & FileSystemIndexingJob : : CollectFilesToIndex , this ) ) ; <nl> } <nl> <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : IndexFiles ( ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + DCHECK ( impl_task_runner ( ) - > RunsTasksInCurrentSequence ( ) ) ; <nl> if ( stopped_ ) <nl> return ; <nl> if ( indexing_it_ = = file_path_times_ . end ( ) ) { <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : IndexFiles ( ) { <nl> return ; <nl> } <nl> FilePath file_path = indexing_it_ - > first ; <nl> - current_file_ . CreateOrOpen ( <nl> - file_path , base : : File : : FLAG_OPEN | base : : File : : FLAG_READ , <nl> - Bind ( & FileSystemIndexingJob : : StartFileIndexing , this ) ) ; <nl> - } <nl> - <nl> - void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : StartFileIndexing ( <nl> - base : : File : : Error error ) { <nl> + current_file_ . Initialize ( file_path , <nl> + base : : File : : FLAG_OPEN | base : : File : : FLAG_READ ) ; <nl> if ( ! current_file_ . IsValid ( ) ) { <nl> FinishFileIndexing ( false ) ; <nl> return ; <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : ReadFromFile ( ) { <nl> CloseFile ( ) ; <nl> return ; <nl> } <nl> - current_file_ . Read ( current_file_offset_ , kMaxReadLength , <nl> - Bind ( & FileSystemIndexingJob : : OnRead , this ) ) ; <nl> - } <nl> - <nl> - void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : OnRead ( <nl> - base : : File : : Error error , <nl> - const char * data , <nl> - int bytes_read ) { <nl> - if ( error ! = base : : File : : FILE_OK ) { <nl> + std : : unique_ptr < char [ ] > data_ptr ( new char [ kMaxReadLength ] ) ; <nl> + const char * const data = data_ptr . get ( ) ; <nl> + int bytes_read = <nl> + current_file_ . Read ( current_file_offset_ , data_ptr . get ( ) , kMaxReadLength ) ; <nl> + if ( bytes_read < 0 ) { <nl> FinishFileIndexing ( false ) ; <nl> return ; <nl> } <nl> <nl> - if ( ! bytes_read | | bytes_read < 3 ) { <nl> + if ( bytes_read < 3 ) { <nl> FinishFileIndexing ( true ) ; <nl> return ; <nl> } <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : OnRead ( <nl> } <nl> } <nl> current_file_offset_ + = bytes_read - 2 ; <nl> - ReadFromFile ( ) ; <nl> + impl_task_runner ( ) - > PostTask ( <nl> + FROM_HERE , base : : BindOnce ( & FileSystemIndexingJob : : ReadFromFile , this ) ) ; <nl> } <nl> <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : FinishFileIndexing ( <nl> bool success ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + DCHECK ( impl_task_runner ( ) - > RunsTasksInCurrentSequence ( ) ) ; <nl> CloseFile ( ) ; <nl> if ( success ) { <nl> FilePath file_path = indexing_it_ - > first ; <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : FinishFileIndexing ( <nl> } <nl> ReportWorked ( ) ; <nl> + + indexing_it_ ; <nl> - IndexFiles ( ) ; <nl> + impl_task_runner ( ) - > PostTask ( <nl> + FROM_HERE , base : : BindOnce ( & FileSystemIndexingJob : : IndexFiles , this ) ) ; <nl> } <nl> <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : CloseFile ( ) { <nl> if ( current_file_ . IsValid ( ) ) <nl> - current_file_ . Close ( Bind ( & FileSystemIndexingJob : : CloseCallback , this ) ) ; <nl> + current_file_ . Close ( ) ; <nl> } <nl> <nl> - void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : CloseCallback ( <nl> - base : : File : : Error error ) { } <nl> - <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : ReportWorked ( ) { <nl> TimeTicks current_time = TimeTicks : : Now ( ) ; <nl> bool should_send_worked_nitification = true ; <nl> void DevToolsFileSystemIndexer : : FileSystemIndexingJob : : ReportWorked ( ) { <nl> } <nl> } <nl> <nl> - DevToolsFileSystemIndexer : : DevToolsFileSystemIndexer ( ) { } <nl> + static int g_instance_count = 0 ; <nl> <nl> - DevToolsFileSystemIndexer : : ~ DevToolsFileSystemIndexer ( ) { } <nl> + DevToolsFileSystemIndexer : : DevToolsFileSystemIndexer ( ) { <nl> + impl_task_runner ( ) - > PostTask ( FROM_HERE , <nl> + base : : BindOnce ( [ ] ( ) { + + g_instance_count ; } ) ) ; <nl> + } <nl> + <nl> + DevToolsFileSystemIndexer : : ~ DevToolsFileSystemIndexer ( ) { <nl> + impl_task_runner ( ) - > PostTask ( FROM_HERE , base : : BindOnce ( [ ] ( ) { <nl> + - - g_instance_count ; <nl> + if ( ! g_instance_count ) <nl> + g_trigram_index . Get ( ) . Reset ( ) ; <nl> + } ) ) ; <nl> + } <nl> <nl> scoped_refptr < DevToolsFileSystemIndexer : : FileSystemIndexingJob > <nl> DevToolsFileSystemIndexer : : IndexPath ( <nl> void DevToolsFileSystemIndexer : : SearchInPath ( const string & file_system_path , <nl> const string & query , <nl> const SearchCallback & callback ) { <nl> DCHECK_CURRENTLY_ON ( BrowserThread : : UI ) ; <nl> - BrowserThread : : PostTask ( <nl> - BrowserThread : : FILE , FROM_HERE , <nl> - BindOnce ( & DevToolsFileSystemIndexer : : SearchInPathOnFileThread , this , <nl> + impl_task_runner ( ) - > PostTask ( <nl> + FROM_HERE , <nl> + BindOnce ( & DevToolsFileSystemIndexer : : SearchInPathOnImplSequence , this , <nl> file_system_path , query , callback ) ) ; <nl> } <nl> <nl> - void DevToolsFileSystemIndexer : : SearchInPathOnFileThread ( <nl> + void DevToolsFileSystemIndexer : : SearchInPathOnImplSequence ( <nl> const string & file_system_path , <nl> const string & query , <nl> const SearchCallback & callback ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> + DCHECK ( impl_task_runner ( ) - > RunsTasksInCurrentSequence ( ) ) ; <nl> vector < FilePath > file_paths = g_trigram_index . Get ( ) . Search ( query ) ; <nl> vector < string > result ; <nl> FilePath path = FilePath : : FromUTF8Unsafe ( file_system_path ) ; <nl> void DevToolsFileSystemIndexer : : SearchInPathOnFileThread ( <nl> result . push_back ( it - > AsUTF8Unsafe ( ) ) ; <nl> } <nl> BrowserThread : : PostTask ( BrowserThread : : UI , FROM_HERE , <nl> - BindOnce ( callback , result ) ) ; <nl> + BindOnce ( callback , std : : move ( result ) ) ) ; <nl> } <nl> <nl> } / / namespace brightray <nl> mmm a / brightray / browser / devtools_file_system_indexer . h <nl> ppp b / brightray / browser / devtools_file_system_indexer . h <nl> <nl> # include < vector > <nl> <nl> # include " base / callback . h " <nl> - # include " base / files / file_proxy . h " <nl> + # include " base / files / file . h " <nl> # include " base / macros . h " <nl> # include " base / memory / ref_counted . h " <nl> <nl> class FileEnumerator ; <nl> class Time ; <nl> } / / namespace base <nl> <nl> - namespace content { <nl> - class WebContents ; <nl> - } <nl> - <nl> namespace brightray { <nl> <nl> class DevToolsFileSystemIndexer <nl> class DevToolsFileSystemIndexer <nl> typedef base : : Callback < void ( ) > DoneCallback ; <nl> typedef base : : Callback < void ( const std : : vector < std : : string > & ) > SearchCallback ; <nl> <nl> - class FileSystemIndexingJob : public base : : RefCounted < FileSystemIndexingJob > { <nl> + class FileSystemIndexingJob <nl> + : public base : : RefCountedThreadSafe < FileSystemIndexingJob > { <nl> public : <nl> void Stop ( ) ; <nl> <nl> private : <nl> - friend class base : : RefCounted < FileSystemIndexingJob > ; <nl> + friend class base : : RefCountedThreadSafe < FileSystemIndexingJob > ; <nl> friend class DevToolsFileSystemIndexer ; <nl> FileSystemIndexingJob ( const base : : FilePath & file_system_path , <nl> const TotalWorkCallback & total_work_callback , <nl> class DevToolsFileSystemIndexer <nl> virtual ~ FileSystemIndexingJob ( ) ; <nl> <nl> void Start ( ) ; <nl> - void StopOnFileThread ( ) ; <nl> + void StopOnImplSequence ( ) ; <nl> void CollectFilesToIndex ( ) ; <nl> void IndexFiles ( ) ; <nl> - void StartFileIndexing ( base : : File : : Error error ) ; <nl> void ReadFromFile ( ) ; <nl> void OnRead ( base : : File : : Error error , const char * data , int bytes_read ) ; <nl> void FinishFileIndexing ( bool success ) ; <nl> void CloseFile ( ) ; <nl> - void CloseCallback ( base : : File : : Error error ) ; <nl> void ReportWorked ( ) ; <nl> <nl> base : : FilePath file_system_path_ ; <nl> class DevToolsFileSystemIndexer <nl> typedef std : : map < base : : FilePath , base : : Time > FilePathTimesMap ; <nl> FilePathTimesMap file_path_times_ ; <nl> FilePathTimesMap : : const_iterator indexing_it_ ; <nl> - base : : FileProxy current_file_ ; <nl> + base : : File current_file_ ; <nl> int64_t current_file_offset_ ; <nl> typedef int32_t Trigram ; <nl> std : : vector < Trigram > current_trigrams_ ; <nl> class DevToolsFileSystemIndexer <nl> <nl> virtual ~ DevToolsFileSystemIndexer ( ) ; <nl> <nl> - void SearchInPathOnFileThread ( const std : : string & file_system_path , <nl> - const std : : string & query , <nl> - const SearchCallback & callback ) ; <nl> + void SearchInPathOnImplSequence ( const std : : string & file_system_path , <nl> + const std : : string & query , <nl> + const SearchCallback & callback ) ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( DevToolsFileSystemIndexer ) ; <nl> } ; <nl> mmm a / brightray / browser / devtools_manager_delegate . cc <nl> ppp b / brightray / browser / devtools_manager_delegate . cc <nl> std : : unique_ptr < content : : DevToolsSocketFactory > CreateSocketFactory ( ) { <nl> / / static <nl> void DevToolsManagerDelegate : : StartHttpHandler ( ) { <nl> content : : DevToolsAgentHost : : StartRemoteDebuggingServer ( <nl> - CreateSocketFactory ( ) , std : : string ( ) , base : : FilePath ( ) , base : : FilePath ( ) ) ; <nl> + CreateSocketFactory ( ) , base : : FilePath ( ) , base : : FilePath ( ) ) ; <nl> } <nl> <nl> DevToolsManagerDelegate : : DevToolsManagerDelegate ( ) { } <nl> void DevToolsManagerDelegate : : Inspect ( content : : DevToolsAgentHost * agent_host ) { } <nl> <nl> bool DevToolsManagerDelegate : : HandleCommand ( <nl> content : : DevToolsAgentHost * agent_host , <nl> - int session_id , <nl> + content : : DevToolsAgentHostClient * client , <nl> base : : DictionaryValue * command ) { <nl> return false ; <nl> } <nl> DevToolsManagerDelegate : : CreateNewTarget ( const GURL & url ) { <nl> } <nl> <nl> std : : string DevToolsManagerDelegate : : GetDiscoveryPageHTML ( ) { <nl> - return ResourceBundle : : GetSharedInstance ( ) <nl> + return ui : : ResourceBundle : : GetSharedInstance ( ) <nl> . GetRawDataResource ( IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE ) <nl> . as_string ( ) ; <nl> } <nl> <nl> - std : : string DevToolsManagerDelegate : : GetFrontendResource ( <nl> - const std : : string & path ) { <nl> - return content : : DevToolsFrontendHost : : GetFrontendResource ( path ) . as_string ( ) ; <nl> + bool DevToolsManagerDelegate : : HasBundledFrontendResources ( ) { <nl> + return true ; <nl> } <nl> <nl> } / / namespace brightray <nl> mmm a / brightray / browser / devtools_manager_delegate . h <nl> ppp b / brightray / browser / devtools_manager_delegate . h <nl> class DevToolsManagerDelegate : public content : : DevToolsManagerDelegate { <nl> / / DevToolsManagerDelegate implementation . <nl> void Inspect ( content : : DevToolsAgentHost * agent_host ) override ; <nl> bool HandleCommand ( content : : DevToolsAgentHost * agent_host , <nl> - int session_id , <nl> + content : : DevToolsAgentHostClient * client , <nl> base : : DictionaryValue * command ) override ; <nl> scoped_refptr < content : : DevToolsAgentHost > CreateNewTarget ( <nl> const GURL & url ) override ; <nl> std : : string GetDiscoveryPageHTML ( ) override ; <nl> - std : : string GetFrontendResource ( const std : : string & path ) override ; <nl> + bool HasBundledFrontendResources ( ) override ; <nl> <nl> private : <nl> DISALLOW_COPY_AND_ASSIGN ( DevToolsManagerDelegate ) ; <nl> mmm a / brightray / browser / inspectable_web_contents_impl . cc <nl> ppp b / brightray / browser / inspectable_web_contents_impl . cc <nl> content : : WebContents * InspectableWebContentsImpl : : GetDevToolsWebContents ( ) <nl> <nl> void InspectableWebContentsImpl : : InspectElement ( int x , int y ) { <nl> if ( agent_host_ . get ( ) ) <nl> - agent_host_ - > InspectElement ( this , x , y ) ; <nl> + agent_host_ - > InspectElement ( web_contents_ - > GetMainFrame ( ) , x , y ) ; <nl> } <nl> <nl> void InspectableWebContentsImpl : : SetDelegate ( <nl> void InspectableWebContentsImpl : : RegisterExtensionsAPI ( <nl> <nl> void InspectableWebContentsImpl : : HandleMessageFromDevToolsFrontend ( <nl> const std : : string & message ) { <nl> + / / TODO ( alexeykuzmin ) : Should we expect it to exist ? <nl> + if ( ! embedder_message_dispatcher_ ) { <nl> + return ; <nl> + } <nl> + <nl> std : : string method ; <nl> base : : ListValue empty_params ; <nl> base : : ListValue * params = & empty_params ; <nl> void InspectableWebContentsImpl : : DispatchProtocolMessage ( <nl> } <nl> <nl> void InspectableWebContentsImpl : : AgentHostClosed ( <nl> - content : : DevToolsAgentHost * agent_host , <nl> - bool replaced ) { } <nl> + content : : DevToolsAgentHost * agent_host ) { } <nl> <nl> void InspectableWebContentsImpl : : RenderFrameHostChanged ( <nl> content : : RenderFrameHost * old_host , <nl> void InspectableWebContentsImpl : : CloseContents ( content : : WebContents * source ) { <nl> content : : ColorChooser * InspectableWebContentsImpl : : OpenColorChooser ( <nl> content : : WebContents * source , <nl> SkColor color , <nl> - const std : : vector < content : : ColorSuggestion > & suggestions ) { <nl> + const std : : vector < blink : : mojom : : ColorSuggestionPtr > & suggestions ) { <nl> auto * delegate = web_contents_ - > GetDelegate ( ) ; <nl> if ( delegate ) <nl> return delegate - > OpenColorChooser ( source , color , suggestions ) ; <nl> mmm a / brightray / browser / inspectable_web_contents_impl . h <nl> ppp b / brightray / browser / inspectable_web_contents_impl . h <nl> class InspectableWebContentsImpl <nl> / / content : : DevToolsAgentHostClient : <nl> void DispatchProtocolMessage ( content : : DevToolsAgentHost * agent_host , <nl> const std : : string & message ) override ; <nl> - void AgentHostClosed ( content : : DevToolsAgentHost * agent_host , <nl> - bool replaced ) override ; <nl> + void AgentHostClosed ( content : : DevToolsAgentHost * agent_host ) override ; <nl> <nl> / / content : : WebContentsObserver : <nl> void RenderFrameHostChanged ( content : : RenderFrameHost * old_host , <nl> class InspectableWebContentsImpl <nl> content : : ColorChooser * OpenColorChooser ( <nl> content : : WebContents * source , <nl> SkColor color , <nl> - const std : : vector < content : : ColorSuggestion > & suggestions ) override ; <nl> + const std : : vector < blink : : mojom : : ColorSuggestionPtr > & suggestions ) <nl> + override ; <nl> void RunFileChooser ( content : : RenderFrameHost * render_frame_host , <nl> const content : : FileChooserParams & params ) override ; <nl> void EnumerateDirectory ( content : : WebContents * source , <nl> mmm a / brightray / browser / io_thread . cc <nl> ppp b / brightray / browser / io_thread . cc <nl> <nl> # include " brightray / browser / io_thread . h " <nl> <nl> # include " content / public / browser / browser_thread . h " <nl> - # include " net / proxy / proxy_service . h " <nl> + # include " net / proxy_resolution / proxy_service . h " <nl> # include " net / url_request / url_request_context . h " <nl> # include " net / url_request / url_request_context_builder . h " <nl> # include " net / url_request / url_request_context_getter . h " <nl> IOThread : : ~ IOThread ( ) { <nl> <nl> void IOThread : : Init ( ) { <nl> net : : URLRequestContextBuilder builder ; <nl> - builder . set_proxy_service ( net : : ProxyService : : CreateDirect ( ) ) ; <nl> + builder . set_proxy_resolution_service ( <nl> + net : : ProxyResolutionService : : CreateDirect ( ) ) ; <nl> url_request_context_ = builder . Build ( ) ; <nl> url_request_context_getter_ = new net : : TrivialURLRequestContextGetter ( <nl> url_request_context_ . get ( ) , base : : ThreadTaskRunnerHandle : : Get ( ) ) ; <nl> mmm a / brightray / browser / net_log . cc <nl> ppp b / brightray / browser / net_log . cc <nl> <nl> # include " base / command_line . h " <nl> # include " base / files / file_path . h " <nl> # include " base / values . h " <nl> - # include " content / public / common / content_switches . h " <nl> # include " net / log / file_net_log_observer . h " <nl> # include " net / log / net_log_util . h " <nl> + # include " services / network / public / cpp / network_switches . h " <nl> <nl> namespace brightray { <nl> <nl> NetLog : : ~ NetLog ( ) { <nl> <nl> void NetLog : : StartLogging ( ) { <nl> auto * command_line = base : : CommandLine : : ForCurrentProcess ( ) ; <nl> - if ( ! command_line - > HasSwitch ( switches : : kLogNetLog ) ) <nl> + if ( ! command_line - > HasSwitch ( network : : switches : : kLogNetLog ) ) <nl> return ; <nl> <nl> - base : : FilePath log_path ; <nl> - log_path = command_line - > GetSwitchValuePath ( switches : : kLogNetLog ) ; <nl> + base : : FilePath log_path = <nl> + command_line - > GetSwitchValuePath ( network : : switches : : kLogNetLog ) ; <nl> if ( log_path . empty ( ) ) <nl> return ; <nl> <nl> mmm a / brightray / browser / network_delegate . cc <nl> ppp b / brightray / browser / network_delegate . cc <nl> int NetworkDelegate : : OnHeadersReceived ( <nl> void NetworkDelegate : : OnBeforeRedirect ( net : : URLRequest * request , <nl> const GURL & new_location ) { } <nl> <nl> - void NetworkDelegate : : OnResponseStarted ( net : : URLRequest * request ) { } <nl> + void NetworkDelegate : : OnResponseStarted ( net : : URLRequest * request , <nl> + int net_error ) { } <nl> <nl> void NetworkDelegate : : OnNetworkBytesReceived ( net : : URLRequest * request , <nl> int64_t bytes_read ) { } <nl> bool NetworkDelegate : : OnCanGetCookies ( const net : : URLRequest & request , <nl> } <nl> <nl> bool NetworkDelegate : : OnCanSetCookie ( const net : : URLRequest & request , <nl> - const std : : string & cookie_line , <nl> + const net : : CanonicalCookie & cookie_line , <nl> net : : CookieOptions * options ) { <nl> return true ; <nl> } <nl> bool NetworkDelegate : : OnCanQueueReportingReport ( <nl> return false ; <nl> } <nl> <nl> - bool NetworkDelegate : : OnCanSendReportingReport ( <nl> - const url : : Origin & origin ) const { <nl> - return false ; <nl> - } <nl> + void NetworkDelegate : : OnCanSendReportingReports ( <nl> + std : : set < url : : Origin > origins , <nl> + base : : OnceCallback < void ( std : : set < url : : Origin > ) > result_callback ) const { } <nl> <nl> bool NetworkDelegate : : OnCanSetReportingClient ( const url : : Origin & origin , <nl> const GURL & endpoint ) const { <nl> mmm a / brightray / browser / network_delegate . h <nl> ppp b / brightray / browser / network_delegate . h <nl> <nl> # ifndef BRIGHTRAY_BROWSER_NETWORK_DELEGATE_H_ <nl> # define BRIGHTRAY_BROWSER_NETWORK_DELEGATE_H_ <nl> <nl> + # include < set > <nl> # include < string > <nl> # include < vector > <nl> <nl> class NetworkDelegate : public net : : NetworkDelegate { <nl> GURL * allowed_unsafe_redirect_url ) override ; <nl> void OnBeforeRedirect ( net : : URLRequest * request , <nl> const GURL & new_location ) override ; <nl> - void OnResponseStarted ( net : : URLRequest * request ) override ; <nl> + void OnResponseStarted ( net : : URLRequest * request , int net_error ) override ; <nl> void OnNetworkBytesReceived ( net : : URLRequest * request , <nl> int64_t bytes_read ) override ; <nl> void OnNetworkBytesSent ( net : : URLRequest * request , <nl> class NetworkDelegate : public net : : NetworkDelegate { <nl> bool OnCanGetCookies ( const net : : URLRequest & request , <nl> const net : : CookieList & cookie_list ) override ; <nl> bool OnCanSetCookie ( const net : : URLRequest & request , <nl> - const std : : string & cookie_line , <nl> + const net : : CanonicalCookie & cookie_line , <nl> net : : CookieOptions * options ) override ; <nl> bool OnCanAccessFile ( const net : : URLRequest & request , <nl> const base : : FilePath & original_path , <nl> class NetworkDelegate : public net : : NetworkDelegate { <nl> const GURL & target_url , <nl> const GURL & referrer_url ) const override ; <nl> bool OnCanQueueReportingReport ( const url : : Origin & origin ) const override ; <nl> - bool OnCanSendReportingReport ( const url : : Origin & origin ) const override ; <nl> + void OnCanSendReportingReports ( std : : set < url : : Origin > origins , <nl> + base : : OnceCallback < void ( std : : set < url : : Origin > ) > <nl> + result_callback ) const override ; <nl> bool OnCanSetReportingClient ( const url : : Origin & origin , <nl> const GURL & endpoint ) const override ; <nl> bool OnCanUseReportingClient ( const url : : Origin & origin , <nl> mmm a / brightray / browser / notification . h <nl> ppp b / brightray / browser / notification . h <nl> class Notification { <nl> } <nl> <nl> void set_delegate ( NotificationDelegate * delegate ) { delegate_ = delegate ; } <nl> + void set_notification_id ( const std : : string & id ) { notification_id_ = id ; } <nl> + <nl> NotificationDelegate * delegate ( ) const { return delegate_ ; } <nl> NotificationPresenter * presenter ( ) const { return presenter_ ; } <nl> + const std : : string & notification_id ( ) const { return notification_id_ ; } <nl> <nl> protected : <nl> Notification ( NotificationDelegate * delegate , <nl> class Notification { <nl> private : <nl> NotificationDelegate * delegate_ ; <nl> NotificationPresenter * presenter_ ; <nl> + std : : string notification_id_ ; <nl> <nl> base : : WeakPtrFactory < Notification > weak_factory_ ; <nl> <nl> mmm a / brightray / browser / notification_presenter . cc <nl> ppp b / brightray / browser / notification_presenter . cc <nl> NotificationPresenter : : ~ NotificationPresenter ( ) { <nl> } <nl> <nl> base : : WeakPtr < Notification > NotificationPresenter : : CreateNotification ( <nl> - NotificationDelegate * delegate ) { <nl> + NotificationDelegate * delegate , <nl> + const std : : string & notification_id ) { <nl> Notification * notification = CreateNotificationObject ( delegate ) ; <nl> + notification - > set_notification_id ( notification_id ) ; <nl> notifications_ . insert ( notification ) ; <nl> return notification - > GetWeakPtr ( ) ; <nl> } <nl> void NotificationPresenter : : RemoveNotification ( Notification * notification ) { <nl> delete notification ; <nl> } <nl> <nl> + void NotificationPresenter : : CloseNotificationWithId ( <nl> + const std : : string & notification_id ) { <nl> + auto it = std : : find_if ( notifications_ . begin ( ) , notifications_ . end ( ) , <nl> + [ & notification_id ] ( const Notification * n ) { <nl> + return n - > notification_id ( ) = = notification_id ; <nl> + } ) ; <nl> + if ( it ! = notifications_ . end ( ) ) <nl> + ( * it ) - > Dismiss ( ) ; <nl> + } <nl> + <nl> } / / namespace brightray <nl> mmm a / brightray / browser / notification_presenter . h <nl> ppp b / brightray / browser / notification_presenter . h <nl> <nl> # define BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_H_ <nl> <nl> # include < set > <nl> + # include < string > <nl> <nl> # include " base / memory / weak_ptr . h " <nl> <nl> class NotificationPresenter { <nl> virtual ~ NotificationPresenter ( ) ; <nl> <nl> base : : WeakPtr < Notification > CreateNotification ( <nl> - NotificationDelegate * delegate ) ; <nl> + NotificationDelegate * delegate , <nl> + const std : : string & notification_id ) ; <nl> + void CloseNotificationWithId ( const std : : string & notification_id ) ; <nl> <nl> std : : set < Notification * > notifications ( ) const { return notifications_ ; } <nl> <nl> deleted file mode 100644 <nl> index eb301f763c89 . . 000000000000 <nl> mmm a / brightray / browser / permission_manager . cc <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2015 The Chromium 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 - CHROMIUM file . <nl> - <nl> - # include " brightray / browser / permission_manager . h " <nl> - <nl> - # include " base / callback . h " <nl> - # include " content / public / browser / child_process_security_policy . h " <nl> - # include " content / public / browser / permission_type . h " <nl> - # include " content / public / browser / render_frame_host . h " <nl> - # include " content / public / browser / render_process_host . h " <nl> - <nl> - namespace brightray { <nl> - <nl> - PermissionManager : : PermissionManager ( ) { } <nl> - <nl> - PermissionManager : : ~ PermissionManager ( ) { } <nl> - <nl> - int PermissionManager : : RequestPermission ( <nl> - content : : PermissionType permission , <nl> - content : : RenderFrameHost * render_frame_host , <nl> - const GURL & requesting_origin , <nl> - bool user_gesture , <nl> - const base : : Callback < void ( blink : : mojom : : PermissionStatus ) > & callback ) { <nl> - if ( permission = = content : : PermissionType : : MIDI_SYSEX ) { <nl> - content : : ChildProcessSecurityPolicy : : GetInstance ( ) <nl> - - > GrantSendMidiSysExMessage ( render_frame_host - > GetProcess ( ) - > GetID ( ) ) ; <nl> - } <nl> - callback . Run ( blink : : mojom : : PermissionStatus : : GRANTED ) ; <nl> - return kNoPendingOperation ; <nl> - } <nl> - <nl> - int PermissionManager : : RequestPermissions ( <nl> - const std : : vector < content : : PermissionType > & permissions , <nl> - content : : RenderFrameHost * render_frame_host , <nl> - const GURL & requesting_origin , <nl> - bool user_gesture , <nl> - const base : : Callback < <nl> - void ( const std : : vector < blink : : mojom : : PermissionStatus > & ) > & callback ) { <nl> - std : : vector < blink : : mojom : : PermissionStatus > permissionStatuses ; <nl> - <nl> - for ( auto permission : permissions ) { <nl> - if ( permission = = content : : PermissionType : : MIDI_SYSEX ) { <nl> - content : : ChildProcessSecurityPolicy : : GetInstance ( ) <nl> - - > GrantSendMidiSysExMessage ( render_frame_host - > GetProcess ( ) - > GetID ( ) ) ; <nl> - } <nl> - <nl> - permissionStatuses . push_back ( blink : : mojom : : PermissionStatus : : GRANTED ) ; <nl> - } <nl> - <nl> - callback . Run ( permissionStatuses ) ; <nl> - return kNoPendingOperation ; <nl> - } <nl> - <nl> - void PermissionManager : : CancelPermissionRequest ( int request_id ) { } <nl> - <nl> - void PermissionManager : : ResetPermission ( content : : PermissionType permission , <nl> - const GURL & requesting_origin , <nl> - const GURL & embedding_origin ) { } <nl> - <nl> - blink : : mojom : : PermissionStatus PermissionManager : : GetPermissionStatus ( <nl> - content : : PermissionType permission , <nl> - const GURL & requesting_origin , <nl> - const GURL & embedding_origin ) { <nl> - return blink : : mojom : : PermissionStatus : : GRANTED ; <nl> - } <nl> - <nl> - int PermissionManager : : SubscribePermissionStatusChange ( <nl> - content : : PermissionType permission , <nl> - const GURL & requesting_origin , <nl> - const GURL & embedding_origin , <nl> - const base : : Callback < void ( blink : : mojom : : PermissionStatus ) > & callback ) { <nl> - return - 1 ; <nl> - } <nl> - <nl> - void PermissionManager : : UnsubscribePermissionStatusChange ( int subscription_id ) { <nl> - } <nl> - <nl> - } / / namespace brightray <nl> deleted file mode 100644 <nl> index da39fdd91bde . . 000000000000 <nl> mmm a / brightray / browser / permission_manager . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2015 The Chromium 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 - CHROMIUM file . <nl> - <nl> - # ifndef BRIGHTRAY_BROWSER_PERMISSION_MANAGER_H_ <nl> - # define BRIGHTRAY_BROWSER_PERMISSION_MANAGER_H_ <nl> - <nl> - # include < vector > <nl> - <nl> - # include " base / callback_forward . h " <nl> - # include " base / macros . h " <nl> - # include " content / public / browser / permission_manager . h " <nl> - <nl> - namespace brightray { <nl> - <nl> - class PermissionManager : public content : : PermissionManager { <nl> - public : <nl> - PermissionManager ( ) ; <nl> - ~ PermissionManager ( ) override ; <nl> - <nl> - / / content : : PermissionManager : <nl> - int RequestPermission ( <nl> - content : : PermissionType permission , <nl> - content : : RenderFrameHost * render_frame_host , <nl> - const GURL & requesting_origin , <nl> - bool user_gesture , <nl> - const base : : Callback < void ( blink : : mojom : : PermissionStatus ) > & callback ) <nl> - override ; <nl> - int RequestPermissions ( <nl> - const std : : vector < content : : PermissionType > & permissions , <nl> - content : : RenderFrameHost * render_frame_host , <nl> - const GURL & requesting_origin , <nl> - bool user_gesture , <nl> - const base : : Callback < <nl> - void ( const std : : vector < blink : : mojom : : PermissionStatus > & ) > & callback ) <nl> - override ; <nl> - void CancelPermissionRequest ( int request_id ) override ; <nl> - void ResetPermission ( content : : PermissionType permission , <nl> - const GURL & requesting_origin , <nl> - const GURL & embedding_origin ) override ; <nl> - blink : : mojom : : PermissionStatus GetPermissionStatus ( <nl> - content : : PermissionType permission , <nl> - const GURL & requesting_origin , <nl> - const GURL & embedding_origin ) override ; <nl> - int SubscribePermissionStatusChange ( <nl> - content : : PermissionType permission , <nl> - const GURL & requesting_origin , <nl> - const GURL & embedding_origin , <nl> - const base : : Callback < void ( blink : : mojom : : PermissionStatus ) > & callback ) <nl> - override ; <nl> - void UnsubscribePermissionStatusChange ( int subscription_id ) override ; <nl> - <nl> - private : <nl> - DISALLOW_COPY_AND_ASSIGN ( PermissionManager ) ; <nl> - } ; <nl> - <nl> - } / / namespace brightray <nl> - <nl> - # endif / / BRIGHTRAY_BROWSER_PERMISSION_MANAGER_H_ <nl> mmm a / brightray / browser / platform_notification_service . cc <nl> ppp b / brightray / browser / platform_notification_service . cc <nl> namespace brightray { <nl> <nl> namespace { <nl> <nl> - void RemoveNotification ( base : : WeakPtr < Notification > notification ) { <nl> - if ( notification ) <nl> - notification - > Dismiss ( ) ; <nl> - } <nl> - <nl> void OnWebNotificationAllowed ( base : : WeakPtr < Notification > notification , <nl> const SkBitmap & icon , <nl> const content : : PlatformNotificationData & data , <nl> void PlatformNotificationService : : DisplayNotification ( <nl> const std : : string & notification_id , <nl> const GURL & origin , <nl> const content : : PlatformNotificationData & notification_data , <nl> - const content : : NotificationResources & notification_resources , <nl> - base : : Closure * cancel_callback ) { <nl> + const content : : NotificationResources & notification_resources ) { <nl> auto * presenter = browser_client_ - > GetNotificationPresenter ( ) ; <nl> if ( ! presenter ) <nl> return ; <nl> NotificationDelegateImpl * delegate = <nl> new NotificationDelegateImpl ( notification_id ) ; <nl> - auto notification = presenter - > CreateNotification ( delegate ) ; <nl> + auto notification = presenter - > CreateNotification ( delegate , notification_id ) ; <nl> if ( notification ) { <nl> - * cancel_callback = base : : Bind ( & RemoveNotification , notification ) ; <nl> browser_client_ - > WebNotificationAllowed ( <nl> render_process_id_ , base : : Bind ( & OnWebNotificationAllowed , notification , <nl> notification_resources . notification_icon , <nl> void PlatformNotificationService : : ClosePersistentNotification ( <nl> content : : BrowserContext * browser_context , <nl> const std : : string & notification_id ) { } <nl> <nl> + void PlatformNotificationService : : CloseNotification ( <nl> + content : : BrowserContext * browser_context , <nl> + const std : : string & notification_id ) { <nl> + auto * presenter = browser_client_ - > GetNotificationPresenter ( ) ; <nl> + if ( ! presenter ) <nl> + return ; <nl> + presenter - > CloseNotificationWithId ( notification_id ) ; <nl> + } <nl> + <nl> void PlatformNotificationService : : GetDisplayedNotifications ( <nl> content : : BrowserContext * browser_context , <nl> const DisplayedNotificationsCallback & callback ) { } <nl> mmm a / brightray / browser / platform_notification_service . h <nl> ppp b / brightray / browser / platform_notification_service . h <nl> class PlatformNotificationService <nl> const std : : string & notification_id , <nl> const GURL & origin , <nl> const content : : PlatformNotificationData & notification_data , <nl> - const content : : NotificationResources & notification_resources , <nl> - base : : Closure * cancel_callback ) override ; <nl> + const content : : NotificationResources & notification_resources ) override ; <nl> void DisplayPersistentNotification ( <nl> content : : BrowserContext * browser_context , <nl> const std : : string & notification_id , <nl> class PlatformNotificationService <nl> const content : : NotificationResources & notification_resources ) override ; <nl> void ClosePersistentNotification ( content : : BrowserContext * browser_context , <nl> const std : : string & notification_id ) override ; <nl> + void CloseNotification ( content : : BrowserContext * browser_context , <nl> + const std : : string & notification_id ) override ; <nl> void GetDisplayedNotifications ( <nl> content : : BrowserContext * browser_context , <nl> const DisplayedNotificationsCallback & callback ) override ; <nl> mmm a / brightray / browser / special_storage_policy . cc <nl> ppp b / brightray / browser / special_storage_policy . cc <nl> bool SpecialStoragePolicy : : HasSessionOnlyOrigins ( ) { <nl> return false ; <nl> } <nl> <nl> + bool SpecialStoragePolicy : : ShouldDeleteCookieOnExit ( const GURL & origin ) { <nl> + return false ; <nl> + } <nl> + <nl> } / / namespace brightray <nl> mmm a / brightray / browser / special_storage_policy . h <nl> ppp b / brightray / browser / special_storage_policy . h <nl> class SpecialStoragePolicy : public storage : : SpecialStoragePolicy { <nl> bool HasIsolatedStorage ( const GURL & origin ) override ; <nl> bool IsStorageSessionOnly ( const GURL & origin ) override ; <nl> bool HasSessionOnlyOrigins ( ) override ; <nl> + bool ShouldDeleteCookieOnExit ( const GURL & origin ) override ; <nl> <nl> protected : <nl> ~ SpecialStoragePolicy ( ) override ; <nl> mmm a / brightray / browser / url_request_context_getter . cc <nl> ppp b / brightray / browser / url_request_context_getter . cc <nl> <nl> # include " content / public / browser / browser_thread . h " <nl> # include " content / public / browser / cookie_store_factory . h " <nl> # include " content / public / browser / devtools_network_transaction_factory . h " <nl> - # include " content / public / common / content_switches . h " <nl> # include " net / base / host_mapping_rules . h " <nl> # include " net / cert / cert_verifier . h " <nl> # include " net / cert / ct_known_logs . h " <nl> <nl> # include " net / cert / ct_policy_enforcer . h " <nl> # include " net / cert / multi_log_ct_verifier . h " <nl> # include " net / cookies / cookie_monster . h " <nl> + # include " net / cookies / cookie_store . h " <nl> # include " net / dns / mapped_host_resolver . h " <nl> # include " net / http / http_auth_filter . h " <nl> # include " net / http / http_auth_handler_factory . h " <nl> # include " net / http / http_auth_preferences . h " <nl> # include " net / http / http_server_properties_impl . h " <nl> # include " net / log / net_log . h " <nl> - # include " net / proxy / dhcp_proxy_script_fetcher_factory . h " <nl> - # include " net / proxy / proxy_config . h " <nl> - # include " net / proxy / proxy_config_service . h " <nl> - # include " net / proxy / proxy_script_fetcher_impl . h " <nl> - # include " net / proxy / proxy_service . h " <nl> + # include " net / proxy_resolution / dhcp_pac_file_fetcher_factory . h " <nl> + # include " net / proxy_resolution / pac_file_fetcher_impl . h " <nl> + # include " net / proxy_resolution / proxy_config . h " <nl> + # include " net / proxy_resolution / proxy_config_service . h " <nl> + # include " net / proxy_resolution / proxy_service . h " <nl> # include " net / ssl / channel_id_service . h " <nl> # include " net / ssl / default_channel_id_store . h " <nl> # include " net / ssl / ssl_config_service_defaults . h " <nl> <nl> # include " net / url_request / url_request_context_storage . h " <nl> # include " net / url_request / url_request_intercepting_job_factory . h " <nl> # include " net / url_request / url_request_job_factory_impl . h " <nl> + # include " services / network / public / cpp / network_switches . h " <nl> # include " storage / browser / quota / special_storage_policy . h " <nl> # include " url / url_constants . h " <nl> <nl> URLRequestContextGetter : : URLRequestContextGetter ( <nl> / / must synchronously run on the glib message loop . This will be passed to <nl> / / the URLRequestContextStorage on the IO thread in GetURLRequestContext ( ) . <nl> proxy_config_service_ = <nl> - net : : ProxyService : : CreateSystemProxyConfigService ( io_task_runner_ ) ; <nl> + net : : ProxyResolutionService : : CreateSystemProxyConfigService ( <nl> + io_task_runner_ ) ; <nl> } <nl> <nl> URLRequestContextGetter : : ~ URLRequestContextGetter ( ) { } <nl> void URLRequestContextGetter : : NotifyContextShutdownOnIO ( ) { <nl> <nl> void URLRequestContextGetter : : OnCookieChanged ( <nl> const net : : CanonicalCookie & cookie , <nl> - net : : CookieStore : : ChangeCause cause ) { <nl> + net : : CookieChangeCause cause ) { <nl> DCHECK_CURRENTLY_ON ( content : : BrowserThread : : IO ) ; <nl> <nl> if ( ! delegate_ | | context_shutting_down_ ) <nl> void URLRequestContextGetter : : OnCookieChanged ( <nl> <nl> content : : BrowserThread : : PostTask ( <nl> content : : BrowserThread : : UI , FROM_HERE , <nl> - base : : BindOnce ( <nl> - & Delegate : : NotifyCookieChange , base : : Unretained ( delegate_ ) , cookie , <nl> - ! ( cause = = net : : CookieStore : : ChangeCause : : INSERTED ) , cause ) ) ; <nl> + base : : BindOnce ( & Delegate : : NotifyCookieChange , base : : Unretained ( delegate_ ) , <nl> + cookie , ! ( cause = = net : : CookieChangeCause : : INSERTED ) , <nl> + cause ) ) ; <nl> } <nl> <nl> net : : HostResolver * URLRequestContextGetter : : host_resolver ( ) { <nl> net : : URLRequestContext * URLRequestContextGetter : : GetURLRequestContext ( ) { <nl> : base_path_ . Append ( FILE_PATH_LITERAL ( " Cookies " ) ) ; <nl> std : : unique_ptr < net : : CookieStore > cookie_store = <nl> content : : CreateCookieStore ( content : : CookieStoreConfig ( <nl> - cookie_path , content : : CookieStoreConfig : : EPHEMERAL_SESSION_COOKIES , <nl> - nullptr ) ) ; <nl> + cookie_path , false , false , nullptr ) ) ; <nl> storage_ - > set_cookie_store ( std : : move ( cookie_store ) ) ; <nl> <nl> / / Set custom schemes that can accept cookies . <nl> net : : URLRequestContext * URLRequestContextGetter : : GetURLRequestContext ( ) { <nl> / / Cookie store will outlive notifier by order of declaration <nl> / / in the header . <nl> cookie_change_sub_ = <nl> - url_request_context_ - > cookie_store ( ) - > AddCallbackForAllChanges ( <nl> - base : : Bind ( & URLRequestContextGetter : : OnCookieChanged , this ) ) ; <nl> + url_request_context_ - > cookie_store ( ) <nl> + - > GetChangeDispatcher ( ) <nl> + . AddCallbackForAllChanges ( <nl> + base : : Bind ( & URLRequestContextGetter : : OnCookieChanged , this ) ) ; <nl> <nl> storage_ - > set_channel_id_service ( std : : make_unique < net : : ChannelIDService > ( <nl> new net : : DefaultChannelIDStore ( nullptr ) ) ) ; <nl> net : : URLRequestContext * URLRequestContextGetter : : GetURLRequestContext ( ) { <nl> net : : HostResolver : : CreateDefaultResolver ( nullptr ) ) ; <nl> <nl> / / - - host - resolver - rules <nl> - if ( command_line . HasSwitch ( : : switches : : kHostResolverRules ) ) { <nl> + if ( command_line . HasSwitch ( network : : switches : : kHostResolverRules ) ) { <nl> std : : unique_ptr < net : : MappedHostResolver > remapped_resolver ( <nl> new net : : MappedHostResolver ( std : : move ( host_resolver ) ) ) ; <nl> - remapped_resolver - > SetRulesFromString ( <nl> - command_line . GetSwitchValueASCII ( : : switches : : kHostResolverRules ) ) ; <nl> + remapped_resolver - > SetRulesFromString ( command_line . GetSwitchValueASCII ( <nl> + network : : switches : : kHostResolverRules ) ) ; <nl> host_resolver = std : : move ( remapped_resolver ) ; <nl> } <nl> <nl> / / - - proxy - server <nl> if ( command_line . HasSwitch ( switches : : kNoProxyServer ) ) { <nl> - storage_ - > set_proxy_service ( net : : ProxyService : : CreateDirect ( ) ) ; <nl> + storage_ - > set_proxy_resolution_service ( <nl> + net : : ProxyResolutionService : : CreateDirect ( ) ) ; <nl> } else if ( command_line . HasSwitch ( switches : : kProxyServer ) ) { <nl> net : : ProxyConfig proxy_config ; <nl> proxy_config . proxy_rules ( ) . ParseFromString ( <nl> command_line . GetSwitchValueASCII ( switches : : kProxyServer ) ) ; <nl> proxy_config . proxy_rules ( ) . bypass_rules . ParseFromString ( <nl> command_line . GetSwitchValueASCII ( switches : : kProxyBypassList ) ) ; <nl> - storage_ - > set_proxy_service ( net : : ProxyService : : CreateFixed ( proxy_config ) ) ; <nl> + storage_ - > set_proxy_resolution_service ( <nl> + net : : ProxyResolutionService : : CreateFixed ( proxy_config ) ) ; <nl> } else if ( command_line . HasSwitch ( switches : : kProxyPacUrl ) ) { <nl> auto proxy_config = net : : ProxyConfig : : CreateFromCustomPacURL ( <nl> GURL ( command_line . GetSwitchValueASCII ( switches : : kProxyPacUrl ) ) ) ; <nl> proxy_config . set_pac_mandatory ( true ) ; <nl> - storage_ - > set_proxy_service ( net : : ProxyService : : CreateFixed ( proxy_config ) ) ; <nl> + storage_ - > set_proxy_resolution_service ( <nl> + net : : ProxyResolutionService : : CreateFixed ( proxy_config ) ) ; <nl> } else { <nl> - storage_ - > set_proxy_service ( <nl> - net : : ProxyService : : CreateUsingSystemProxyResolver ( <nl> + storage_ - > set_proxy_resolution_service ( <nl> + net : : ProxyResolutionService : : CreateUsingSystemProxyResolver ( <nl> std : : move ( proxy_config_service_ ) , net_log_ ) ) ; <nl> } <nl> <nl> net : : URLRequestContext * URLRequestContextGetter : : GetURLRequestContext ( ) { <nl> <nl> / / - - auth - server - whitelist <nl> if ( command_line . HasSwitch ( switches : : kAuthServerWhitelist ) ) { <nl> - http_auth_preferences_ - > set_server_whitelist ( <nl> + http_auth_preferences_ - > SetServerWhitelist ( <nl> command_line . GetSwitchValueASCII ( switches : : kAuthServerWhitelist ) ) ; <nl> } <nl> <nl> / / - - auth - negotiate - delegate - whitelist <nl> if ( command_line . HasSwitch ( switches : : kAuthNegotiateDelegateWhitelist ) ) { <nl> - http_auth_preferences_ - > set_delegate_whitelist ( <nl> + http_auth_preferences_ - > SetDelegateWhitelist ( <nl> command_line . GetSwitchValueASCII ( <nl> switches : : kAuthNegotiateDelegateWhitelist ) ) ; <nl> } <nl> mmm a / brightray / browser / url_request_context_getter . h <nl> ppp b / brightray / browser / url_request_context_getter . h <nl> <nl> # include " base / files / file_path . h " <nl> # include " content / public / browser / browser_context . h " <nl> # include " content / public / browser / content_browser_client . h " <nl> - # include " net / cookies / cookie_store . h " <nl> + # include " net / cookies / cookie_change_dispatcher . h " <nl> # include " net / http / http_cache . h " <nl> # include " net / http / transport_security_state . h " <nl> # include " net / http / url_security_manager . h " <nl> class URLRequestContextGetter : public net : : URLRequestContextGetter { <nl> virtual std : : vector < std : : string > GetCookieableSchemes ( ) ; <nl> virtual void NotifyCookieChange ( const net : : CanonicalCookie & cookie , <nl> bool removed , <nl> - net : : CookieStore : : ChangeCause cause ) { } <nl> + net : : CookieChangeCause cause ) { } <nl> } ; <nl> <nl> URLRequestContextGetter ( <nl> class URLRequestContextGetter : public net : : URLRequestContextGetter { <nl> content : : ProtocolHandlerMap * protocol_handlers , <nl> content : : URLRequestInterceptorScopedVector protocol_interceptors ) ; <nl> <nl> - / / net : : CookieStore : : CookieChangedCallback implementation . <nl> + / / net : : CookieChangeDispatcher : : CookieChangedCallback implementation . <nl> void OnCookieChanged ( const net : : CanonicalCookie & cookie , <nl> - net : : CookieStore : : ChangeCause cause ) ; <nl> + net : : CookieChangeCause cause ) ; <nl> <nl> / / net : : URLRequestContextGetter : <nl> net : : URLRequestContext * GetURLRequestContext ( ) override ; <nl> class URLRequestContextGetter : public net : : URLRequestContextGetter { <nl> std : : unique_ptr < net : : HostMappingRules > host_mapping_rules_ ; <nl> std : : unique_ptr < net : : HttpAuthPreferences > http_auth_preferences_ ; <nl> std : : unique_ptr < net : : HttpNetworkSession > http_network_session_ ; <nl> - std : : unique_ptr < net : : CookieStore : : CookieChangedSubscription > <nl> - cookie_change_sub_ ; <nl> + std : : unique_ptr < net : : CookieChangeSubscription > cookie_change_sub_ ; <nl> content : : ProtocolHandlerMap protocol_handlers_ ; <nl> content : : URLRequestInterceptorScopedVector protocol_interceptors_ ; <nl> <nl> mmm a / brightray / browser / views / views_delegate . cc <nl> ppp b / brightray / browser / views / views_delegate . cc <nl> bool ViewsDelegate : : GetSavedWindowPlacement ( <nl> } <nl> <nl> void ViewsDelegate : : NotifyAccessibilityEvent ( views : : View * view , <nl> - ui : : AXEvent event_type ) { } <nl> + ax : : mojom : : Event event_type ) { } <nl> <nl> void ViewsDelegate : : NotifyMenuItemFocused ( const base : : string16 & menu_name , <nl> const base : : string16 & menu_item_name , <nl> mmm a / brightray / browser / views / views_delegate . h <nl> ppp b / brightray / browser / views / views_delegate . h <nl> class ViewsDelegate : public views : : ViewsDelegate { <nl> gfx : : Rect * bounds , <nl> ui : : WindowShowState * show_state ) const override ; <nl> void NotifyAccessibilityEvent ( views : : View * view , <nl> - ui : : AXEvent event_type ) override ; <nl> + ax : : mojom : : Event event_type ) override ; <nl> void NotifyMenuItemFocused ( const base : : string16 & menu_name , <nl> const base : : string16 & menu_item_name , <nl> int item_index , <nl> mmm a / brightray / browser / zoom_level_delegate . cc <nl> ppp b / brightray / browser / zoom_level_delegate . cc <nl> <nl> # include " brightray / browser / zoom_level_delegate . h " <nl> <nl> # include < functional > <nl> + # include < memory > <nl> # include < vector > <nl> <nl> # include " base / bind . h " <nl> const char kPartitionPerHostZoomLevels [ ] = " partition . per_host_zoom_levels " ; <nl> <nl> std : : string GetHash ( const base : : FilePath & partition_path ) { <nl> size_t int_key = std : : hash < base : : FilePath > ( ) ( partition_path ) ; <nl> - return base : : SizeTToString ( int_key ) ; <nl> + return base : : NumberToString ( int_key ) ; <nl> } <nl> <nl> } / / namespace <nl> mmm a / brightray / common / content_client . cc <nl> ppp b / brightray / common / content_client . cc <nl> gfx : : Image & ContentClient : : GetNativeImageNamed ( int resource_id ) const { <nl> <nl> base : : RefCountedMemory * ContentClient : : GetDataResourceBytes ( <nl> int resource_id ) const { <nl> - return ResourceBundle : : GetSharedInstance ( ) . LoadDataResourceBytes ( resource_id ) ; <nl> + return ui : : ResourceBundle : : GetSharedInstance ( ) . LoadDataResourceBytes ( <nl> + resource_id ) ; <nl> } <nl> <nl> } / / namespace brightray <nl> mmm a / brightray / filenames . gypi <nl> ppp b / brightray / filenames . gypi <nl> <nl> ' browser / notification_presenter . h ' , <nl> ' browser / notification . cc ' , <nl> ' browser / notification . h ' , <nl> - ' browser / permission_manager . cc ' , <nl> - ' browser / permission_manager . h ' , <nl> ' browser / platform_notification_service . cc ' , <nl> ' browser / platform_notification_service . h ' , <nl> ' browser / linux / libnotify_loader . h ' , <nl> mmm a / chromium_src / chrome / browser / extensions / global_shortcut_listener_x11 . cc <nl> ppp b / chromium_src / chrome / browser / extensions / global_shortcut_listener_x11 . cc <nl> <nl> # include " ui / base / accelerators / accelerator . h " <nl> # include " ui / events / keycodes / keyboard_code_conversion_x . h " <nl> # include " ui / events / platform / platform_event_source . h " <nl> + # include " ui / gfx / x / x11 . h " <nl> # include " ui / gfx / x / x11_error_tracker . h " <nl> # include " ui / gfx / x / x11_types . h " <nl> <nl> bool GlobalShortcutListenerX11 : : RegisterAcceleratorImpl ( <nl> / / Caps lock , Scroll lock . See comment about | kModifiersMasks | . <nl> for ( size_t i = 0 ; i < arraysize ( kModifiersMasks ) ; + + i ) { <nl> XGrabKey ( x_display_ , keycode , modifiers | kModifiersMasks [ i ] , <nl> - x_root_window_ , False , GrabModeAsync , GrabModeAsync ) ; <nl> + x_root_window_ , x11 : : False , GrabModeAsync , GrabModeAsync ) ; <nl> } <nl> <nl> if ( err_tracker . FoundNewError ( ) ) { <nl> mmm a / chromium_src / chrome / browser / extensions / global_shortcut_listener_x11 . h <nl> ppp b / chromium_src / chrome / browser / extensions / global_shortcut_listener_x11 . h <nl> <nl> # ifndef CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_X11_H_ <nl> # define CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_X11_H_ <nl> <nl> - # include < X11 / Xlib . h > <nl> # include < stdint . h > <nl> <nl> # include < set > <nl> <nl> # include " base / macros . h " <nl> # include " chrome / browser / extensions / global_shortcut_listener . h " <nl> # include " ui / events / platform / platform_event_dispatcher . h " <nl> + # include " ui / gfx / x / x11 . h " <nl> <nl> namespace extensions { <nl> <nl> mmm a / chromium_src / chrome / browser / icon_loader_win . cc <nl> ppp b / chromium_src / chrome / browser / icon_loader_win . cc <nl> <nl> <nl> # include " chrome / browser / icon_loader . h " <nl> <nl> - # include < shellapi . h > <nl> # include < windows . h > <nl> + # include < shellapi . h > <nl> <nl> # include " base / bind . h " <nl> # include " base / message_loop / message_loop . h " <nl> mmm a / chromium_src / chrome / browser / media / native_desktop_media_list . cc <nl> ppp b / chromium_src / chrome / browser / media / native_desktop_media_list . cc <nl> NativeDesktopMediaList : : NativeDesktopMediaList ( <nl> observer_ ( NULL ) , <nl> weak_factory_ ( this ) { <nl> capture_task_runner_ = base : : CreateSequencedTaskRunnerWithTraits ( <nl> - { base : : MayBlock ( ) , base : : TaskPriority : : USER_VISIBLE } ) ; <nl> + { base : : WithBaseSyncPrimitives ( ) , base : : MayBlock ( ) , <nl> + base : : TaskPriority : : USER_VISIBLE } ) ; <nl> } <nl> <nl> NativeDesktopMediaList : : ~ NativeDesktopMediaList ( ) { <nl> mmm a / chromium_src / chrome / browser / printing / pdf_to_emf_converter . cc <nl> ppp b / chromium_src / chrome / browser / printing / pdf_to_emf_converter . cc <nl> <nl> # include " base / files / scoped_temp_dir . h " <nl> # include " base / logging . h " <nl> # include " base / macros . h " <nl> + # include " base / memory / ref_counted_delete_on_sequence . h " <nl> + # include " base / sequenced_task_runner . h " <nl> + # include " base / task_scheduler / post_task . h " <nl> + # include " base / threading / sequenced_task_runner_handle . h " <nl> + # include " base / threading / thread_restrictions . h " <nl> # include " base / threading / thread_task_runner_handle . h " <nl> # include " chrome / common / chrome_utility_printing_messages . h " <nl> # include " content / public / browser / browser_thread . h " <nl> namespace printing { <nl> <nl> namespace { <nl> <nl> + void CloseFileOnBlockingTaskRunner ( base : : File temp_file ) { <nl> + base : : AssertBlockingAllowed ( ) ; <nl> + temp_file . Close ( ) ; <nl> + } <nl> + <nl> class PdfConverterImpl ; <nl> <nl> / / Allows to delete temporary directory after all temporary files created inside <nl> class PdfConverterImpl ; <nl> / / used to store PDF and metafiles . PDF should be gone by the time utility <nl> / / process exits . Metafiles should be gone when all LazyEmf destroyed . <nl> class RefCountedTempDir <nl> - : public base : : RefCountedThreadSafe < RefCountedTempDir , <nl> - BrowserThread : : DeleteOnFileThread > { <nl> + : public base : : RefCountedDeleteOnSequence < RefCountedTempDir > { <nl> public : <nl> - RefCountedTempDir ( ) { ignore_result ( temp_dir_ . CreateUniqueTempDir ( ) ) ; } <nl> + RefCountedTempDir ( ) <nl> + : base : : RefCountedDeleteOnSequence < RefCountedTempDir > ( <nl> + base : : SequencedTaskRunnerHandle : : Get ( ) ) { <nl> + ignore_result ( temp_dir_ . CreateUniqueTempDir ( ) ) ; <nl> + } <nl> + <nl> bool IsValid ( ) const { return temp_dir_ . IsValid ( ) ; } <nl> const base : : FilePath & GetPath ( ) const { return temp_dir_ . GetPath ( ) ; } <nl> <nl> private : <nl> - friend struct BrowserThread : : DeleteOnThread < BrowserThread : : FILE > ; <nl> + friend class base : : RefCountedDeleteOnSequence < RefCountedTempDir > ; <nl> friend class base : : DeleteHelper < RefCountedTempDir > ; <nl> + <nl> ~ RefCountedTempDir ( ) { } <nl> <nl> base : : ScopedTempDir temp_dir_ ; <nl> DISALLOW_COPY_AND_ASSIGN ( RefCountedTempDir ) ; <nl> } ; <nl> <nl> - using ScopedTempFile = <nl> - std : : unique_ptr < base : : File , BrowserThread : : DeleteOnFileThread > ; <nl> + class TempFile { <nl> + public : <nl> + explicit TempFile ( base : : File file ) <nl> + : file_ ( std : : move ( file ) ) , <nl> + blocking_task_runner_ ( base : : SequencedTaskRunnerHandle : : Get ( ) ) { <nl> + base : : AssertBlockingAllowed ( ) ; <nl> + } <nl> + ~ TempFile ( ) { <nl> + blocking_task_runner_ - > PostTask ( <nl> + FROM_HERE , base : : BindOnce ( & CloseFileOnBlockingTaskRunner , <nl> + base : : Passed ( std : : move ( file_ ) ) ) ) ; <nl> + } <nl> + <nl> + base : : File & file ( ) { return file_ ; } <nl> + <nl> + private : <nl> + base : : File file_ ; <nl> + const scoped_refptr < base : : SequencedTaskRunner > blocking_task_runner_ ; <nl> + <nl> + DISALLOW_COPY_AND_ASSIGN ( TempFile ) ; <nl> + } ; <nl> + <nl> + using ScopedTempFile = std : : unique_ptr < TempFile > ; <nl> <nl> / / Wrapper for Emf to keep only file handle in memory , and load actual data only <nl> / / on playback . Emf : : InitFromFile ( ) can play metafile directly from disk , but it <nl> class PostScriptMetaFile : public LazyEmf { <nl> : LazyEmf ( temp_dir , std : : move ( file ) ) { } <nl> ~ PostScriptMetaFile ( ) override ; <nl> <nl> - protected : <nl> + private : <nl> / / MetafilePlayer : <nl> bool SafePlayback ( HDC hdc ) const override ; <nl> <nl> class PostScriptMetaFile : public LazyEmf { <nl> } ; <nl> <nl> / / Class for converting PDF to another format for printing ( Emf , Postscript ) . <nl> - / / Class uses 3 threads : UI , IO and FILE . <nl> + / / Class uses UI thread , IO thread and | blocking_task_runner_ | . <nl> / / Internal workflow is following : <nl> / / 1 . Create instance on the UI thread . ( files_ , settings_ , ) <nl> - / / 2 . Create pdf file on the FILE thread . <nl> + / / 2 . Create pdf file on | blocking_task_runner_ | . <nl> / / 3 . Start utility process and start conversion on the IO thread . <nl> / / 4 . Utility process returns page count . <nl> / / 5 . For each page : <nl> class PdfConverterUtilityProcessHostClient <nl> / / sync message replies . <nl> bool Send ( IPC : : Message * msg ) ; <nl> <nl> - protected : <nl> + private : <nl> class GetPageCallbackData { <nl> public : <nl> GetPageCallbackData ( int page_number , PdfConverter : : GetPageCallback callback ) <nl> class PdfConverterUtilityProcessHostClient <nl> <nl> / / Helper functions : must be overridden by subclasses <nl> / / Set the process name <nl> - virtual base : : string16 GetName ( ) const ; <nl> + base : : string16 GetName ( ) const ; <nl> / / Create a metafileplayer subclass file from a temporary file . <nl> - virtual std : : unique_ptr < MetafilePlayer > GetFileFromTemp ( <nl> - std : : unique_ptr < base : : File , content : : BrowserThread : : DeleteOnFileThread > <nl> - temp_file ) ; <nl> + std : : unique_ptr < MetafilePlayer > GetFileFromTemp ( ScopedTempFile temp_file ) ; <nl> / / Send the messages to Start , GetPage , and Stop . <nl> - virtual void SendStartMessage ( IPC : : PlatformFileForTransit transit ) ; <nl> - virtual void SendGetPageMessage ( int page_number , <nl> - IPC : : PlatformFileForTransit transit ) ; <nl> - virtual void SendStopMessage ( ) ; <nl> + void SendStartMessage ( IPC : : PlatformFileForTransit transit ) ; <nl> + void SendGetPageMessage ( int page_number , IPC : : PlatformFileForTransit transit ) ; <nl> + void SendStopMessage ( ) ; <nl> <nl> / / Message handlers : <nl> void OnPageCount ( int page_count ) ; <nl> class PdfConverterUtilityProcessHostClient <nl> using GetPageCallbacks = std : : queue < GetPageCallbackData > ; <nl> GetPageCallbacks get_page_callbacks_ ; <nl> <nl> + const scoped_refptr < base : : SequencedTaskRunner > blocking_task_runner_ ; <nl> + <nl> DISALLOW_COPY_AND_ASSIGN ( PdfConverterUtilityProcessHostClient ) ; <nl> } ; <nl> <nl> std : : unique_ptr < MetafilePlayer > <nl> PdfConverterUtilityProcessHostClient : : GetFileFromTemp ( <nl> - std : : unique_ptr < base : : File , content : : BrowserThread : : DeleteOnFileThread > <nl> - temp_file ) { <nl> + ScopedTempFile temp_file ) { <nl> if ( settings_ . mode = = PdfRenderSettings : : Mode : : POSTSCRIPT_LEVEL2 | | <nl> settings_ . mode = = PdfRenderSettings : : Mode : : POSTSCRIPT_LEVEL3 ) { <nl> return std : : make_unique < PostScriptMetaFile > ( temp_dir_ , <nl> class PdfConverterImpl : public PdfConverter { <nl> <nl> ScopedTempFile CreateTempFile ( scoped_refptr < RefCountedTempDir > * temp_dir ) { <nl> if ( ! temp_dir - > get ( ) ) <nl> - * temp_dir = new RefCountedTempDir ( ) ; <nl> + * temp_dir = base : : MakeRefCounted < RefCountedTempDir > ( ) ; <nl> ScopedTempFile file ; <nl> if ( ! ( * temp_dir ) - > IsValid ( ) ) <nl> return file ; <nl> ScopedTempFile CreateTempFile ( scoped_refptr < RefCountedTempDir > * temp_dir ) { <nl> < < ( * temp_dir ) - > GetPath ( ) . value ( ) ; <nl> return file ; <nl> } <nl> - file . reset ( new base : : File ( <nl> + file = std : : make_unique < TempFile > ( base : : File ( <nl> path , base : : File : : FLAG_CREATE_ALWAYS | base : : File : : FLAG_WRITE | <nl> base : : File : : FLAG_READ | base : : File : : FLAG_DELETE_ON_CLOSE | <nl> base : : File : : FLAG_TEMPORARY ) ) ; <nl> - if ( ! file - > IsValid ( ) ) { <nl> + if ( ! file - > file ( ) . IsValid ( ) ) { <nl> PLOG ( ERROR ) < < " Failed to create " < < path . value ( ) ; <nl> file . reset ( ) ; <nl> } <nl> ScopedTempFile CreateTempFile ( scoped_refptr < RefCountedTempDir > * temp_dir ) { <nl> ScopedTempFile CreateTempPdfFile ( <nl> const scoped_refptr < base : : RefCountedMemory > & data , <nl> scoped_refptr < RefCountedTempDir > * temp_dir ) { <nl> - DCHECK_CURRENTLY_ON ( BrowserThread : : FILE ) ; <nl> - <nl> ScopedTempFile pdf_file = CreateTempFile ( temp_dir ) ; <nl> - if ( ! pdf_file | | <nl> - static_cast < int > ( data - > size ( ) ) ! = <nl> - pdf_file - > WriteAtCurrentPos ( data - > front_as < char > ( ) , data - > size ( ) ) ) { <nl> + if ( ! pdf_file | | static_cast < int > ( data - > size ( ) ) ! = <nl> + pdf_file - > file ( ) . WriteAtCurrentPos ( <nl> + data - > front_as < char > ( ) , data - > size ( ) ) ) { <nl> pdf_file . reset ( ) ; <nl> return pdf_file ; <nl> } <nl> - pdf_file - > Seek ( base : : File : : FROM_BEGIN , 0 ) ; <nl> + pdf_file - > file ( ) . Seek ( base : : File : : FROM_BEGIN , 0 ) ; <nl> return pdf_file ; <nl> } <nl> <nl> void LazyEmf : : Close ( ) const { <nl> } <nl> <nl> bool LazyEmf : : LoadEmf ( Emf * emf ) const { <nl> - file_ - > Seek ( base : : File : : FROM_BEGIN , 0 ) ; <nl> - int64_t size = file_ - > GetLength ( ) ; <nl> + file_ - > file ( ) . Seek ( base : : File : : FROM_BEGIN , 0 ) ; <nl> + int64_t size = file_ - > file ( ) . GetLength ( ) ; <nl> if ( size < = 0 ) <nl> return false ; <nl> std : : vector < char > data ( size ) ; <nl> - if ( file_ - > ReadAtCurrentPos ( data . data ( ) , data . size ( ) ) ! = size ) <nl> + if ( file_ - > file ( ) . ReadAtCurrentPos ( data . data ( ) , data . size ( ) ) ! = size ) <nl> return false ; <nl> return emf - > InitFromData ( data . data ( ) , data . size ( ) ) ; <nl> } <nl> bool PostScriptMetaFile : : SafePlayback ( HDC hdc ) const { <nl> PdfConverterUtilityProcessHostClient : : PdfConverterUtilityProcessHostClient ( <nl> base : : WeakPtr < PdfConverterImpl > converter , <nl> const PdfRenderSettings & settings ) <nl> - : converter_ ( converter ) , settings_ ( settings ) { } <nl> + : converter_ ( converter ) , <nl> + settings_ ( settings ) , <nl> + blocking_task_runner_ ( base : : CreateSequencedTaskRunnerWithTraits ( <nl> + { base : : MayBlock ( ) , base : : TaskPriority : : USER_VISIBLE , <nl> + base : : TaskShutdownBehavior : : BLOCK_SHUTDOWN } ) ) { } <nl> <nl> PdfConverterUtilityProcessHostClient : : ~ PdfConverterUtilityProcessHostClient ( ) { } <nl> <nl> void PdfConverterUtilityProcessHostClient : : Start ( <nl> - > AsWeakPtr ( ) ; <nl> utility_process_host_ - > SetName ( GetName ( ) ) ; <nl> <nl> - BrowserThread : : PostTaskAndReplyWithResult ( <nl> - BrowserThread : : FILE , FROM_HERE , <nl> + base : : PostTaskAndReplyWithResult ( <nl> + blocking_task_runner_ . get ( ) , FROM_HERE , <nl> base : : Bind ( & CreateTempPdfFile , data , & temp_dir_ ) , <nl> base : : Bind ( & PdfConverterUtilityProcessHostClient : : OnTempPdfReady , this ) ) ; <nl> } <nl> void PdfConverterUtilityProcessHostClient : : OnTempPdfReady ( ScopedTempFile pdf ) { <nl> return OnFailed ( ) ; <nl> / / Should reply with OnPageCount ( ) . <nl> SendStartMessage ( <nl> - IPC : : GetPlatformFileForTransit ( pdf - > GetPlatformFile ( ) , false ) ) ; <nl> + IPC : : GetPlatformFileForTransit ( pdf - > file ( ) . GetPlatformFile ( ) , false ) ) ; <nl> } <nl> <nl> void PdfConverterUtilityProcessHostClient : : OnPageCount ( int page_count ) { <nl> void PdfConverterUtilityProcessHostClient : : GetPage ( <nl> if ( ! utility_process_host_ ) <nl> return OnFailed ( ) ; <nl> <nl> - BrowserThread : : PostTaskAndReplyWithResult ( <nl> - BrowserThread : : FILE , FROM_HERE , base : : Bind ( & CreateTempFile , & temp_dir_ ) , <nl> + base : : PostTaskAndReplyWithResult ( <nl> + blocking_task_runner_ . get ( ) , FROM_HERE , <nl> + base : : Bind ( & CreateTempFile , & temp_dir_ ) , <nl> base : : Bind ( & PdfConverterUtilityProcessHostClient : : OnTempFileReady , this , <nl> & get_page_callbacks_ . back ( ) ) ) ; <nl> } <nl> void PdfConverterUtilityProcessHostClient : : OnTempFileReady ( <nl> DCHECK_CURRENTLY_ON ( BrowserThread : : IO ) ; <nl> if ( ! utility_process_host_ | | ! temp_file ) <nl> return OnFailed ( ) ; <nl> - IPC : : PlatformFileForTransit transit = <nl> - IPC : : GetPlatformFileForTransit ( temp_file - > GetPlatformFile ( ) , false ) ; <nl> + IPC : : PlatformFileForTransit transit = IPC : : GetPlatformFileForTransit ( <nl> + temp_file - > file ( ) . GetPlatformFile ( ) , false ) ; <nl> callback_data - > set_file ( std : : move ( temp_file ) ) ; <nl> / / Should reply with OnPageDone ( ) . <nl> SendGetPageMessage ( callback_data - > page_number ( ) , transit ) ; <nl> mmm a / chromium_src / chrome / browser / printing / print_job . cc <nl> ppp b / chromium_src / chrome / browser / printing / print_job . cc <nl> <nl> # include " base / run_loop . h " <nl> # include " base / single_thread_task_runner . h " <nl> # include " base / task_scheduler / post_task . h " <nl> - # include " base / threading / sequenced_worker_pool . h " <nl> # include " base / threading / thread_restrictions . h " <nl> # include " base / threading / thread_task_runner_handle . h " <nl> # include " build / build_config . h " <nl> <nl> # include " chrome / browser / printing / print_job_worker . h " <nl> # include " content / public / browser / notification_service . h " <nl> # include " printing / printed_document . h " <nl> - # include " printing / printed_page . h " <nl> <nl> # if defined ( OS_WIN ) <nl> # include " chrome / browser / printing / pdf_to_emf_converter . h " <nl> # include " printing / pdf_render_settings . h " <nl> + # include " printing / metafile . h " <nl> # endif <nl> <nl> using base : : TimeDelta ; <nl> void PrintJob : : StartPrinting ( ) { <nl> <nl> / / Tell everyone ! <nl> scoped_refptr < JobEventDetails > details ( <nl> - new JobEventDetails ( JobEventDetails : : NEW_DOC , document_ . get ( ) , nullptr ) ) ; <nl> + new JobEventDetails ( JobEventDetails : : NEW_DOC , 0 , document_ . get ( ) ) ) ; <nl> content : : NotificationService : : current ( ) - > Notify ( <nl> chrome : : NOTIFICATION_PRINT_JOB_EVENT , content : : Source < PrintJob > ( this ) , <nl> content : : Details < JobEventDetails > ( details . get ( ) ) ) ; <nl> void PrintJob : : Cancel ( ) { <nl> } <nl> / / Make sure a Cancel ( ) is broadcast . <nl> scoped_refptr < JobEventDetails > details ( <nl> - new JobEventDetails ( JobEventDetails : : FAILED , nullptr , nullptr ) ) ; <nl> + new JobEventDetails ( JobEventDetails : : FAILED , 0 , nullptr ) ) ; <nl> content : : NotificationService : : current ( ) - > Notify ( <nl> chrome : : NOTIFICATION_PRINT_JOB_EVENT , content : : Source < PrintJob > ( this ) , <nl> content : : Details < JobEventDetails > ( details . get ( ) ) ) ; <nl> void PrintJob : : StartPdfToEmfConversion ( <nl> std : : make_unique < PdfConversionState > ( page_size , content_area ) ; <nl> const int kPrinterDpi = settings ( ) . dpi ( ) ; <nl> PdfRenderSettings settings ( <nl> - content_area , gfx : : Point ( 0 , 0 ) , kPrinterDpi , / * autorotate = * / true , <nl> + content_area , gfx : : Point ( 0 , 0 ) , gfx : : Size ( kPrinterDpi , kPrinterDpi ) , / * autorotate = * / true , <nl> print_text_with_gdi ? PdfRenderSettings : : Mode : : GDI_TEXT <nl> : PdfRenderSettings : : Mode : : NORMAL ) ; <nl> pdf_conversion_state_ - > Start ( <nl> void PrintJob : : StartPdfToPostScriptConversion ( <nl> std : : make_unique < PdfConversionState > ( gfx : : Size ( ) , gfx : : Rect ( ) ) ; <nl> const int kPrinterDpi = settings ( ) . dpi ( ) ; <nl> PdfRenderSettings settings ( <nl> - content_area , physical_offsets , kPrinterDpi , true / * autorotate ? * / , <nl> + content_area , physical_offsets , gfx : : Size ( kPrinterDpi , kPrinterDpi ) , true / * autorotate ? * / , <nl> ps_level2 ? PdfRenderSettings : : Mode : : POSTSCRIPT_LEVEL2 <nl> : PdfRenderSettings : : Mode : : POSTSCRIPT_LEVEL3 ) ; <nl> pdf_conversion_state_ - > Start ( <nl> void PrintJob : : OnDocumentDone ( ) { <nl> Stop ( ) ; <nl> <nl> scoped_refptr < JobEventDetails > details ( <nl> - new JobEventDetails ( JobEventDetails : : JOB_DONE , document_ . get ( ) , nullptr ) ) ; <nl> + new JobEventDetails ( JobEventDetails : : JOB_DONE , 0 , document_ . get ( ) ) ) ; <nl> content : : NotificationService : : current ( ) - > Notify ( <nl> chrome : : NOTIFICATION_PRINT_JOB_EVENT , content : : Source < PrintJob > ( this ) , <nl> content : : Details < JobEventDetails > ( details . get ( ) ) ) ; <nl> void PrintJob : : Quit ( ) { <nl> } <nl> <nl> / / Takes settings_ ownership and will be deleted in the receiving thread . <nl> + # if defined ( OS_WIN ) <nl> JobEventDetails : : JobEventDetails ( Type type , <nl> + int job_id , <nl> PrintedDocument * document , <nl> PrintedPage * page ) <nl> - : document_ ( document ) , page_ ( page ) , type_ ( type ) { } <nl> + : document_ ( document ) , page_ ( page ) , type_ ( type ) , job_id_ ( job_id ) { } <nl> + # endif <nl> + <nl> + JobEventDetails : : JobEventDetails ( Type type , <nl> + int job_id , <nl> + PrintedDocument * document ) <nl> + : document_ ( document ) , type_ ( type ) , job_id_ ( job_id ) { } <nl> <nl> JobEventDetails : : ~ JobEventDetails ( ) { } <nl> <nl> PrintedDocument * JobEventDetails : : document ( ) const { <nl> return document_ . get ( ) ; <nl> } <nl> <nl> - PrintedPage * JobEventDetails : : page ( ) const { <nl> - return page_ . get ( ) ; <nl> - } <nl> - <nl> + # if defined ( OS_WIN ) <nl> + PrintedPage * JobEventDetails : : page ( ) const { return page_ . get ( ) ; } <nl> + # endif <nl> } / / namespace printing <nl> mmm a / chromium_src / chrome / browser / printing / print_job . h <nl> ppp b / chromium_src / chrome / browser / printing / print_job . h <nl> <nl> # include " content / public / browser / notification_observer . h " <nl> # include " content / public / browser / notification_registrar . h " <nl> <nl> + # if defined ( OS_WIN ) <nl> + # include " printing / printed_page_win . h " <nl> + # endif <nl> + <nl> namespace base { <nl> class RefCountedMemory ; <nl> } <nl> class MetafilePlayer ; <nl> class PdfToEmfConverter ; <nl> class PrintJobWorker ; <nl> class PrintedDocument ; <nl> + # if defined ( OS_WIN ) <nl> class PrintedPage ; <nl> + # endif <nl> class PrinterQuery ; <nl> <nl> / / Manages the print work for a specific document . Talks to the printer through <nl> class JobEventDetails : public base : : RefCountedThreadSafe < JobEventDetails > { <nl> FAILED , <nl> } ; <nl> <nl> - JobEventDetails ( Type type , PrintedDocument * document , PrintedPage * page ) ; <nl> + # if defined ( OS_WIN ) <nl> + JobEventDetails ( Type type , <nl> + int job_id , <nl> + PrintedDocument * document , <nl> + PrintedPage * page ) ; <nl> + # endif <nl> + JobEventDetails ( Type type , int job_id , PrintedDocument * document ) ; <nl> <nl> / / Getters . <nl> PrintedDocument * document ( ) const ; <nl> + # if defined ( OS_WIN ) <nl> PrintedPage * page ( ) const ; <nl> + # endif <nl> Type type ( ) const { return type_ ; } <nl> + int job_id ( ) const { return job_id_ ; } <nl> <nl> private : <nl> friend class base : : RefCountedThreadSafe < JobEventDetails > ; <nl> class JobEventDetails : public base : : RefCountedThreadSafe < JobEventDetails > { <nl> ~ JobEventDetails ( ) ; <nl> <nl> scoped_refptr < PrintedDocument > document_ ; <nl> + # if defined ( OS_WIN ) <nl> scoped_refptr < PrintedPage > page_ ; <nl> + # endif <nl> const Type type_ ; <nl> + int job_id_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( JobEventDetails ) ; <nl> } ; <nl> mmm a / chromium_src / chrome / browser / printing / print_job_manager . cc <nl> ppp b / chromium_src / chrome / browser / printing / print_job_manager . cc <nl> <nl> # include " content / public / browser / browser_thread . h " <nl> # include " content / public / browser / notification_service . h " <nl> # include " printing / printed_document . h " <nl> - # include " printing / printed_page . h " <nl> <nl> namespace printing { <nl> <nl> mmm a / chromium_src / chrome / browser / printing / print_job_worker . cc <nl> ppp b / chromium_src / chrome / browser / printing / print_job_worker . cc <nl> <nl> # include " content / public / browser / web_contents . h " <nl> # include " printing / print_job_constants . h " <nl> # include " printing / printed_document . h " <nl> - # include " printing / printed_page . h " <nl> # include " printing / printing_utils . h " <nl> # include " ui / base / l10n / l10n_util . h " <nl> <nl> <nl> # include " printing / print_settings . h " <nl> # include " printing / units . h " <nl> <nl> + # if defined ( OS_WIN ) <nl> + # include " printing / printed_page_win . h " <nl> + # endif <nl> + <nl> using content : : BrowserThread ; <nl> <nl> namespace printing { <nl> namespace { <nl> <nl> / / Helper function to ensure | owner | is valid until at least | callback | returns . <nl> void HoldRefCallback ( const scoped_refptr < PrintJobWorkerOwner > & owner , <nl> - const base : : Closure & callback ) { <nl> - callback . Run ( ) ; <nl> + base : : OnceClosure callback ) { <nl> + std : : move ( callback ) . Run ( ) ; <nl> } <nl> <nl> void SetCustomMarginsToJobSettings ( const PageSizeMargins & page_size_margins , <nl> std : : string PrintingContextDelegate : : GetAppLocale ( ) { <nl> <nl> void NotificationCallback ( PrintJobWorkerOwner * print_job , <nl> JobEventDetails : : Type detail_type , <nl> - PrintedDocument * document , <nl> - PrintedPage * page ) { <nl> - JobEventDetails * details = new JobEventDetails ( detail_type , document , page ) ; <nl> + int job_id , <nl> + PrintedDocument * document ) { <nl> + JobEventDetails * details = new JobEventDetails ( detail_type , job_id , document ) ; <nl> content : : NotificationService : : current ( ) - > Notify ( <nl> chrome : : NOTIFICATION_PRINT_JOB_EVENT , <nl> / / We know that is is a PrintJob object in this circumstance . <nl> void NotificationCallback ( PrintJobWorkerOwner * print_job , <nl> } <nl> <nl> void PostOnOwnerThread ( const scoped_refptr < PrintJobWorkerOwner > & owner , <nl> - const PrintingContext : : PrintSettingsCallback & callback , <nl> + PrintingContext : : PrintSettingsCallback callback , <nl> PrintingContext : : Result result ) { <nl> - owner - > PostTask ( FROM_HERE , base : : Bind ( & HoldRefCallback , owner , <nl> - base : : Bind ( callback , result ) ) ) ; <nl> + owner - > PostTask ( FROM_HERE , <nl> + base : : BindOnce ( & HoldRefCallback , owner , <nl> + base : : BindOnce ( std : : move ( callback ) , result ) ) ) ; <nl> + } <nl> + <nl> + # if defined ( OS_WIN ) <nl> + void PageNotificationCallback ( PrintJobWorkerOwner * print_job , <nl> + JobEventDetails : : Type detail_type , <nl> + int job_id , <nl> + PrintedDocument * document , <nl> + PrintedPage * page ) { <nl> + JobEventDetails * details = <nl> + new JobEventDetails ( detail_type , job_id , document , page ) ; <nl> + content : : NotificationService : : current ( ) - > Notify ( <nl> + chrome : : NOTIFICATION_PRINT_JOB_EVENT , <nl> + / / We know that is is a PrintJob object in this circumstance . <nl> + content : : Source < PrintJob > ( static_cast < PrintJob * > ( print_job ) ) , <nl> + content : : Details < JobEventDetails > ( details ) ) ; <nl> } <nl> + # endif <nl> <nl> } / / namespace <nl> <nl> void PrintJobWorker : : GetSettings ( bool ask_user_for_settings , <nl> if ( ask_user_for_settings ) { <nl> BrowserThread : : PostTask ( <nl> BrowserThread : : UI , FROM_HERE , <nl> - base : : Bind ( & HoldRefCallback , WrapRefCounted ( owner_ ) , <nl> - base : : Bind ( & PrintJobWorker : : GetSettingsWithUI , <nl> - base : : Unretained ( this ) , document_page_count , <nl> - has_selection , is_scripted ) ) ) ; <nl> + base : : BindOnce ( <nl> + & HoldRefCallback , WrapRefCounted ( owner_ ) , <nl> + base : : BindOnce ( & PrintJobWorker : : GetSettingsWithUI , <nl> + base : : Unretained ( this ) , document_page_count , <nl> + has_selection , is_scripted ) ) ) ; <nl> } else if ( ! device_name . empty ( ) ) { <nl> BrowserThread : : PostTask ( <nl> BrowserThread : : UI , FROM_HERE , <nl> - base : : Bind ( & HoldRefCallback , WrapRefCounted ( owner_ ) , <nl> - base : : Bind ( & PrintJobWorker : : InitWithDeviceName , <nl> - base : : Unretained ( this ) , device_name ) ) ) ; <nl> + base : : BindOnce ( & HoldRefCallback , WrapRefCounted ( owner_ ) , <nl> + base : : BindOnce ( & PrintJobWorker : : InitWithDeviceName , <nl> + base : : Unretained ( this ) , device_name ) ) ) ; <nl> } else { <nl> BrowserThread : : PostTask ( <nl> BrowserThread : : UI , FROM_HERE , <nl> - base : : Bind ( & HoldRefCallback , WrapRefCounted ( owner_ ) , <nl> - base : : Bind ( & PrintJobWorker : : UseDefaultSettings , <nl> - base : : Unretained ( this ) ) ) ) ; <nl> + base : : BindOnce ( & HoldRefCallback , WrapRefCounted ( owner_ ) , <nl> + base : : BindOnce ( & PrintJobWorker : : UseDefaultSettings , <nl> + base : : Unretained ( this ) ) ) ) ; <nl> } <nl> } <nl> <nl> void PrintJobWorker : : SetSettings ( <nl> <nl> BrowserThread : : PostTask ( <nl> BrowserThread : : UI , FROM_HERE , <nl> - base : : Bind ( <nl> + base : : BindOnce ( <nl> & HoldRefCallback , WrapRefCounted ( owner_ ) , <nl> - base : : Bind ( & PrintJobWorker : : UpdatePrintSettings , <nl> - base : : Unretained ( this ) , base : : Passed ( & new_settings ) ) ) ) ; <nl> + base : : BindOnce ( & PrintJobWorker : : UpdatePrintSettings , <nl> + base : : Unretained ( this ) , base : : Passed ( & new_settings ) ) ) ) ; <nl> } <nl> <nl> void PrintJobWorker : : UpdatePrintSettings ( <nl> void PrintJobWorker : : GetSettingsWithUI ( int document_page_count , <nl> / / weak_factory_ creates pointers valid only on owner_ thread . <nl> printing_context_ - > AskUserForSettings ( <nl> document_page_count , has_selection , is_scripted , <nl> - base : : Bind ( & PostOnOwnerThread , WrapRefCounted ( owner_ ) , <nl> - base : : Bind ( & PrintJobWorker : : GetSettingsDone , <nl> - weak_factory_ . GetWeakPtr ( ) ) ) ) ; <nl> + base : : BindOnce ( & PostOnOwnerThread , WrapRefCounted ( owner_ ) , <nl> + base : : BindOnce ( & PrintJobWorker : : GetSettingsDone , <nl> + weak_factory_ . GetWeakPtr ( ) ) ) ) ; <nl> } <nl> <nl> void PrintJobWorker : : UseDefaultSettings ( ) { <nl> void PrintJobWorker : : OnDocumentChanged ( PrintedDocument * new_document ) { <nl> document_ = new_document ; <nl> } <nl> <nl> + void PrintJobWorker : : PostWaitForPage ( ) { <nl> + / / We need to wait for the page to be available . <nl> + base : : ThreadTaskRunnerHandle : : Get ( ) - > PostDelayedTask ( <nl> + FROM_HERE , <nl> + base : : BindOnce ( & PrintJobWorker : : OnNewPage , weak_factory_ . GetWeakPtr ( ) ) , <nl> + base : : TimeDelta : : FromMilliseconds ( 500 ) ) ; <nl> + } <nl> + <nl> + # if defined ( OS_WIN ) <nl> void PrintJobWorker : : OnNewPage ( ) { <nl> if ( ! document_ . get ( ) ) / / Spurious message . <nl> return ; <nl> void PrintJobWorker : : OnNewPage ( ) { <nl> / / We have enough information to initialize page_number_ . <nl> page_number_ . Init ( document_ - > settings ( ) , page_count ) ; <nl> } <nl> - DCHECK_NE ( page_number_ , PageNumber : : npos ( ) ) ; <nl> <nl> + DCHECK_NE ( page_number_ , PageNumber : : npos ( ) ) ; <nl> while ( true ) { <nl> / / Is the page available ? <nl> scoped_refptr < PrintedPage > page = document_ - > GetPage ( page_number_ . ToInt ( ) ) ; <nl> if ( ! page . get ( ) ) { <nl> - / / We need to wait for the page to be available . <nl> - base : : ThreadTaskRunnerHandle : : Get ( ) - > PostDelayedTask ( <nl> - FROM_HERE , <nl> - base : : Bind ( & PrintJobWorker : : OnNewPage , weak_factory_ . GetWeakPtr ( ) ) , <nl> - base : : TimeDelta : : FromMilliseconds ( 500 ) ) ; <nl> + PostWaitForPage ( ) ; <nl> break ; <nl> } <nl> / / The page is there , print it . <nl> void PrintJobWorker : : OnNewPage ( ) { <nl> } <nl> } <nl> } <nl> + # else <nl> + void PrintJobWorker : : OnNewPage ( ) { <nl> + if ( ! document_ . get ( ) ) / / Spurious message . <nl> + return ; <nl> + <nl> + / / message_loop ( ) could return NULL when the print job is cancelled . <nl> + DCHECK ( task_runner_ - > RunsTasksInCurrentSequence ( ) ) ; <nl> + <nl> + const MetafilePlayer * metafile = document_ - > GetMetafile ( ) ; <nl> + if ( ! metafile ) { <nl> + PostWaitForPage ( ) ; <nl> + return ; <nl> + } <nl> + SpoolJob ( ) ; <nl> + / / Don ' t touch this anymore since the instance could be destroyed . <nl> + OnDocumentDone ( ) ; <nl> + } <nl> + # endif / / defined ( OS_WIN ) <nl> <nl> void PrintJobWorker : : Cancel ( ) { <nl> / / This is the only function that can be called from any thread . <nl> void PrintJobWorker : : OnDocumentDone ( ) { <nl> DCHECK_EQ ( page_number_ , PageNumber : : npos ( ) ) ; <nl> DCHECK ( document_ . get ( ) ) ; <nl> <nl> + int job_id = printing_context_ - > job_id ( ) ; <nl> if ( printing_context_ - > DocumentDone ( ) ! = PrintingContext : : OK ) { <nl> OnFailure ( ) ; <nl> return ; <nl> void PrintJobWorker : : OnDocumentDone ( ) { <nl> <nl> owner_ - > PostTask ( FROM_HERE , <nl> base : : Bind ( & NotificationCallback , base : : RetainedRef ( owner_ ) , <nl> - JobEventDetails : : DOC_DONE , <nl> - base : : RetainedRef ( document_ ) , nullptr ) ) ; <nl> + JobEventDetails : : DOC_DONE , job_id , <nl> + base : : RetainedRef ( document_ ) ) ) ; <nl> <nl> / / Makes sure the variables are reinitialized . <nl> document_ = NULL ; <nl> } <nl> <nl> + # if defined ( OS_WIN ) <nl> void PrintJobWorker : : SpoolPage ( PrintedPage * page ) { <nl> DCHECK ( task_runner_ - > RunsTasksInCurrentSequence ( ) ) ; <nl> DCHECK_NE ( page_number_ , PageNumber : : npos ( ) ) ; <nl> <nl> - / / Signal everyone that the page is about to be printed . <nl> - owner_ - > PostTask ( <nl> - FROM_HERE , <nl> - base : : Bind ( & NotificationCallback , base : : RetainedRef ( owner_ ) , <nl> - JobEventDetails : : NEW_PAGE , base : : RetainedRef ( document_ ) , <nl> - base : : RetainedRef ( page ) ) ) ; <nl> - <nl> / / Preprocess . <nl> if ( printing_context_ - > NewPage ( ) ! = PrintingContext : : OK ) { <nl> OnFailure ( ) ; <nl> void PrintJobWorker : : SpoolPage ( PrintedPage * page ) { <nl> } <nl> <nl> / / Actual printing . <nl> - # if defined ( OS_WIN ) | | defined ( OS_MACOSX ) <nl> document_ - > RenderPrintedPage ( * page , printing_context_ - > context ( ) ) ; <nl> - # elif defined ( OS_POSIX ) <nl> - document_ - > RenderPrintedPage ( * page , printing_context_ . get ( ) ) ; <nl> - # endif <nl> <nl> / / Postprocess . <nl> if ( printing_context_ - > PageDone ( ) ! = PrintingContext : : OK ) { <nl> void PrintJobWorker : : SpoolPage ( PrintedPage * page ) { <nl> } <nl> <nl> / / Signal everyone that the page is printed . <nl> - owner_ - > PostTask ( <nl> - FROM_HERE , <nl> - base : : Bind ( & NotificationCallback , base : : RetainedRef ( owner_ ) , <nl> - JobEventDetails : : PAGE_DONE , base : : RetainedRef ( document_ ) , <nl> - base : : RetainedRef ( page ) ) ) ; <nl> + owner_ - > PostTask ( FROM_HERE , <nl> + base : : BindRepeating ( <nl> + & PageNotificationCallback , base : : RetainedRef ( owner_ ) , <nl> + JobEventDetails : : PAGE_DONE , printing_context_ - > job_id ( ) , <nl> + base : : RetainedRef ( document_ ) , base : : RetainedRef ( page ) ) ) ; <nl> + } <nl> + # else <nl> + void PrintJobWorker : : SpoolJob ( ) { <nl> + DCHECK ( task_runner_ - > RunsTasksInCurrentSequence ( ) ) ; <nl> + if ( ! document_ - > RenderPrintedDocument ( printing_context_ . get ( ) ) ) <nl> + OnFailure ( ) ; <nl> } <nl> + # endif <nl> <nl> void PrintJobWorker : : OnFailure ( ) { <nl> DCHECK ( task_runner_ - > RunsTasksInCurrentSequence ( ) ) ; <nl> void PrintJobWorker : : OnFailure ( ) { <nl> / / We may loose our last reference by broadcasting the FAILED event . <nl> scoped_refptr < PrintJobWorkerOwner > handle ( owner_ ) ; <nl> <nl> - owner_ - > PostTask ( FROM_HERE , <nl> - base : : Bind ( & NotificationCallback , base : : RetainedRef ( owner_ ) , <nl> - JobEventDetails : : FAILED , <nl> - base : : RetainedRef ( document_ ) , nullptr ) ) ; <nl> + owner_ - > PostTask ( <nl> + FROM_HERE , base : : BindRepeating ( <nl> + & NotificationCallback , base : : RetainedRef ( owner_ ) , <nl> + JobEventDetails : : FAILED , 0 , base : : RetainedRef ( document_ ) ) ) ; <nl> Cancel ( ) ; <nl> <nl> / / Makes sure the variables are reinitialized . <nl> mmm a / chromium_src / chrome / browser / printing / print_job_worker . h <nl> ppp b / chromium_src / chrome / browser / printing / print_job_worker . h <nl> <nl> # include " base / memory / ref_counted . h " <nl> # include " base / memory / weak_ptr . h " <nl> # include " base / threading / thread . h " <nl> + # include " build / build_config . h " <nl> # include " chrome / browser / printing / printer_query . h " <nl> # include " content / public / browser / browser_thread . h " <nl> # include " printing / page_number . h " <nl> class PrintJobWorker { <nl> / / and DEFAULT_INIT_DONE . These three are sent through PrintJob : : InitDone ( ) . <nl> class NotificationTask ; <nl> <nl> + / / Posts a task to call OnNewPage ( ) . Used to wait for pages / document to be <nl> + / / available . <nl> + void PostWaitForPage ( ) ; <nl> + <nl> + # if defined ( OS_WIN ) <nl> / / Renders a page in the printer . <nl> void SpoolPage ( PrintedPage * page ) ; <nl> + # else <nl> + / / Renders the document to the printer . <nl> + void SpoolJob ( ) ; <nl> + # endif <nl> <nl> / / Closes the job since spooling is done . <nl> void OnDocumentDone ( ) ; <nl> mmm a / chromium_src / chrome / browser / printing / print_job_worker_owner . cc <nl> ppp b / chromium_src / chrome / browser / printing / print_job_worker_owner . cc <nl> bool PrintJobWorkerOwner : : RunsTasksInCurrentSequence ( ) const { <nl> } <nl> <nl> bool PrintJobWorkerOwner : : PostTask ( const base : : Location & from_here , <nl> - const base : : Closure & task ) { <nl> - return task_runner_ - > PostTask ( from_here , task ) ; <nl> + base : : OnceClosure task ) { <nl> + return task_runner_ - > PostTask ( from_here , std : : move ( task ) ) ; <nl> } <nl> <nl> } / / namespace printing <nl> mmm a / chromium_src / chrome / browser / printing / print_job_worker_owner . h <nl> ppp b / chromium_src / chrome / browser / printing / print_job_worker_owner . h <nl> class PrintJobWorkerOwner <nl> bool RunsTasksInCurrentSequence ( ) const ; <nl> <nl> / / Posts the given task to be run . <nl> - bool PostTask ( const base : : Location & from_here , const base : : Closure & task ) ; <nl> + bool PostTask ( const base : : Location & from_here , base : : OnceClosure task ) ; <nl> <nl> protected : <nl> friend class base : : RefCountedThreadSafe < PrintJobWorkerOwner > ; <nl> mmm a / chromium_src / chrome / browser / printing / print_view_manager_base . cc <nl> ppp b / chromium_src / chrome / browser / printing / print_view_manager_base . cc <nl> PrintViewManagerBase : : PrintViewManagerBase ( content : : WebContents * web_contents ) <nl> cookie_ ( 0 ) , <nl> queue_ ( g_browser_process - > print_job_manager ( ) - > queue ( ) ) { <nl> DCHECK ( queue_ . get ( ) ) ; <nl> - # if ! defined ( OS_MACOSX ) <nl> expecting_first_page_ = true ; <nl> - # endif / / OS_MACOSX <nl> printing_enabled_ = true ; <nl> } <nl> <nl> void PrintViewManagerBase : : OnDidGetDocumentCookie ( int cookie ) { <nl> <nl> void PrintViewManagerBase : : OnDidPrintPage ( <nl> const PrintHostMsg_DidPrintPage_Params & params ) { <nl> + / / TODO ( rbpotter ) : Remove this check once there are no more spurious <nl> + / / DidPrintPage messages . <nl> + # if ! defined ( OS_WIN ) <nl> + if ( ! expecting_first_page_ ) <nl> + return ; <nl> + # endif <nl> + <nl> if ( ! OpportunisticallyCreatePrintJob ( params . document_cookie ) ) <nl> return ; <nl> <nl> void PrintViewManagerBase : : OnDidPrintPage ( <nl> return ; <nl> } <nl> <nl> - # if defined ( OS_MACOSX ) <nl> - const bool metafile_must_be_valid = true ; <nl> - # else <nl> const bool metafile_must_be_valid = expecting_first_page_ ; <nl> expecting_first_page_ = false ; <nl> - # endif / / OS_MACOSX <nl> <nl> base : : SharedMemory shared_buf ( params . metafile_data_handle , true ) ; <nl> if ( metafile_must_be_valid ) { <nl> void PrintViewManagerBase : : OnDidPrintPage ( <nl> } <nl> } <nl> <nl> - std : : unique_ptr < PdfMetafileSkia > metafile ( <nl> - new PdfMetafileSkia ( SkiaDocumentType : : PDF ) ) ; <nl> + auto metafile = std : : make_unique < PdfMetafileSkia > ( ) ; <nl> if ( metafile_must_be_valid ) { <nl> if ( ! metafile - > InitFromData ( shared_buf . memory ( ) , params . data_size ) ) { <nl> NOTREACHED ( ) < < " Invalid metafile header " ; <nl> void PrintViewManagerBase : : OnDidPrintPage ( <nl> <nl> # if ! defined ( OS_WIN ) <nl> / / Update the rendered document . It will send notifications to the listener . <nl> - document - > SetPage ( params . page_number , std : : move ( metafile ) , params . page_size , <nl> - params . content_area ) ; <nl> + document - > SetDocument ( std : : move ( metafile ) , params . page_size , <nl> + params . content_area ) ; <nl> <nl> ShouldQuitFromInnerMessageLoop ( ) ; <nl> # else <nl> void PrintViewManagerBase : : DisconnectFromCurrentPrintJob ( ) { <nl> / / DO NOT wait for the job to finish . <nl> ReleasePrintJob ( ) ; <nl> } <nl> - # if ! defined ( OS_MACOSX ) <nl> expecting_first_page_ = true ; <nl> - # endif / / OS_MACOSX <nl> } <nl> <nl> void PrintViewManagerBase : : PrintingDone ( bool success ) { <nl> mmm a / chromium_src / chrome / browser / printing / print_view_manager_base . h <nl> ppp b / chromium_src / chrome / browser / printing / print_view_manager_base . h <nl> class PrintViewManagerBase : public content : : NotificationObserver , <nl> / / print settings are being loaded . <nl> bool inside_inner_message_loop_ ; <nl> <nl> - # if ! defined ( OS_MACOSX ) <nl> / / Set to true when OnDidPrintPage ( ) should be expecting the first page . <nl> bool expecting_first_page_ ; <nl> - # endif / / OS_MACOSX <nl> <nl> / / The document cookie of the current PrinterQuery . <nl> int cookie_ ; <nl> mmm a / chromium_src / chrome / browser / printing / printing_message_filter . cc <nl> ppp b / chromium_src / chrome / browser / printing / printing_message_filter . cc <nl> void PrintingMessageFilter : : OnUpdatePrintSettings ( <nl> scoped_refptr < PrinterQuery > printer_query ; <nl> printer_query = queue_ - > PopPrinterQuery ( document_cookie ) ; <nl> if ( ! printer_query . get ( ) ) { <nl> - int host_id = render_process_id_ ; <nl> - int routing_id = reply_msg - > routing_id ( ) ; <nl> - if ( ! new_settings - > GetInteger ( printing : : kPreviewInitiatorHostId , <nl> - & host_id ) | | <nl> - ! new_settings - > GetInteger ( printing : : kPreviewInitiatorRoutingId , <nl> - & routing_id ) ) { <nl> - host_id = content : : ChildProcessHost : : kInvalidUniqueID ; <nl> - routing_id = content : : ChildProcessHost : : kInvalidUniqueID ; <nl> - } <nl> - printer_query = queue_ - > CreatePrinterQuery ( host_id , routing_id ) ; <nl> + printer_query = queue_ - > CreatePrinterQuery ( <nl> + content : : ChildProcessHost : : kInvalidUniqueID , MSG_ROUTING_NONE ) ; <nl> } <nl> printer_query - > SetSettings ( <nl> std : : move ( new_settings ) , <nl> mmm a / chromium_src / chrome / browser / process_singleton_posix . cc <nl> ppp b / chromium_src / chrome / browser / process_singleton_posix . cc <nl> class ScopedSocket { <nl> <nl> / / Returns a random string for uniquifying profile connections . <nl> std : : string GenerateCookie ( ) { <nl> - return base : : Uint64ToString ( base : : RandUint64 ( ) ) ; <nl> + return base : : NumberToString ( base : : RandUint64 ( ) ) ; <nl> } <nl> <nl> bool CheckCookie ( const base : : FilePath & path , const base : : FilePath & cookie ) { <nl> deleted file mode 100644 <nl> index 32bfc759c734 . . 000000000000 <nl> mmm a / chromium_src / chrome / browser / renderer_host / pepper / widevine_cdm_message_filter . cc <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2013 The Chromium 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> - # include " chrome / browser / renderer_host / pepper / widevine_cdm_message_filter . h " <nl> - <nl> - # include " base / bind . h " <nl> - # include " content / public / browser / browser_context . h " <nl> - # include " content / public / browser / plugin_service . h " <nl> - # include " content / public / browser / render_process_host . h " <nl> - # include " content / public / common / webplugininfo . h " <nl> - # include " media / media_features . h " <nl> - <nl> - using content : : BrowserThread ; <nl> - using content : : PluginService ; <nl> - using content : : WebPluginInfo ; <nl> - <nl> - WidevineCdmMessageFilter : : WidevineCdmMessageFilter ( <nl> - int render_process_id , <nl> - content : : BrowserContext * browser_context ) <nl> - : BrowserMessageFilter ( ChromeMsgStart ) , <nl> - render_process_id_ ( render_process_id ) , <nl> - browser_context_ ( browser_context ) { } <nl> - <nl> - bool WidevineCdmMessageFilter : : OnMessageReceived ( const IPC : : Message & message ) { <nl> - IPC_BEGIN_MESSAGE_MAP ( WidevineCdmMessageFilter , message ) <nl> - # if BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> - IPC_MESSAGE_HANDLER ( ChromeViewHostMsg_IsInternalPluginAvailableForMimeType , <nl> - OnIsInternalPluginAvailableForMimeType ) <nl> - # endif / / BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> - IPC_MESSAGE_UNHANDLED ( return false ) <nl> - IPC_END_MESSAGE_MAP ( ) <nl> - return true ; <nl> - } <nl> - <nl> - # if BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> - void WidevineCdmMessageFilter : : OnIsInternalPluginAvailableForMimeType ( <nl> - const std : : string & mime_type , <nl> - bool * is_available , <nl> - std : : vector < base : : string16 > * additional_param_names , <nl> - std : : vector < base : : string16 > * additional_param_values ) { <nl> - std : : vector < WebPluginInfo > plugins ; <nl> - PluginService : : GetInstance ( ) - > GetInternalPlugins ( & plugins ) ; <nl> - <nl> - for ( size_t i = 0 ; i < plugins . size ( ) ; + + i ) { <nl> - const WebPluginInfo & plugin = plugins [ i ] ; <nl> - const std : : vector < content : : WebPluginMimeType > & mime_types = <nl> - plugin . mime_types ; <nl> - for ( size_t j = 0 ; j < mime_types . size ( ) ; + + j ) { <nl> - if ( mime_types [ j ] . mime_type = = mime_type ) { <nl> - * is_available = true ; <nl> - * additional_param_names = mime_types [ j ] . additional_param_names ; <nl> - * additional_param_values = mime_types [ j ] . additional_param_values ; <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - * is_available = false ; <nl> - } <nl> - # endif / / BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> - <nl> - void WidevineCdmMessageFilter : : OnDestruct ( ) const { <nl> - BrowserThread : : DeleteOnUIThread : : Destruct ( this ) ; <nl> - } <nl> - <nl> - WidevineCdmMessageFilter : : ~ WidevineCdmMessageFilter ( ) { } <nl> deleted file mode 100644 <nl> index 58e966a0a630 . . 000000000000 <nl> mmm a / chromium_src / chrome / browser / renderer_host / pepper / widevine_cdm_message_filter . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2013 The Chromium 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> - # ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_WIDEVINE_CDM_MESSAGE_FILTER_H_ <nl> - # define CHROME_BROWSER_RENDERER_HOST_PEPPER_WIDEVINE_CDM_MESSAGE_FILTER_H_ <nl> - <nl> - # include " chrome / common / widevine_cdm_messages . h " <nl> - # include " content / public / browser / browser_message_filter . h " <nl> - # include " media / media_features . h " <nl> - <nl> - namespace content { <nl> - class BrowserContext ; <nl> - } <nl> - <nl> - class WidevineCdmMessageFilter : public content : : BrowserMessageFilter { <nl> - public : <nl> - explicit WidevineCdmMessageFilter ( int render_process_id , <nl> - content : : BrowserContext * browser_context ) ; <nl> - bool OnMessageReceived ( const IPC : : Message & message ) override ; <nl> - void OnDestruct ( ) const override ; <nl> - <nl> - private : <nl> - friend class content : : BrowserThread ; <nl> - friend class base : : DeleteHelper < WidevineCdmMessageFilter > ; <nl> - <nl> - ~ WidevineCdmMessageFilter ( ) override ; <nl> - <nl> - # if BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> - / / Returns whether any internal plugin supporting | mime_type | is registered <nl> - / / and enabled . Does not determine whether the plugin can actually be <nl> - / / instantiated ( e . g . whether it has all its dependencies ) . <nl> - / / When the returned * | is_available | is true , | additional_param_names | and <nl> - / / | additional_param_values | contain the name - value pairs , if any , specified <nl> - / / for the * first * non - disabled plugin found that is registered for <nl> - / / | mime_type | . <nl> - void OnIsInternalPluginAvailableForMimeType ( <nl> - const std : : string & mime_type , <nl> - bool * is_available , <nl> - std : : vector < base : : string16 > * additional_param_names , <nl> - std : : vector < base : : string16 > * additional_param_values ) ; <nl> - # endif / / BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> - <nl> - int render_process_id_ ; <nl> - content : : BrowserContext * browser_context_ ; <nl> - <nl> - DISALLOW_COPY_AND_ASSIGN ( WidevineCdmMessageFilter ) ; <nl> - } ; <nl> - <nl> - # endif / / CHROME_BROWSER_RENDERER_HOST_PEPPER_WIDEVINE_CDM_MESSAGE_FILTER_H_ <nl> mmm a / chromium_src / chrome / browser / speech / tts_linux . cc <nl> ppp b / chromium_src / chrome / browser / speech / tts_linux . cc <nl> <nl> # include " base / debug / leak_annotations . h " <nl> # include " base / memory / singleton . h " <nl> # include " base / synchronization / lock . h " <nl> + # include " base / task_scheduler / post_task . h " <nl> # include " chrome / browser / speech / tts_platform . h " <nl> # include " content / public / browser / browser_thread . h " <nl> # include " content / public / common / content_switches . h " <nl> TtsPlatformImplLinux : : TtsPlatformImplLinux ( ) : utterance_id_ ( 0 ) { <nl> if ( ! command_line . HasSwitch ( switches : : kEnableSpeechDispatcher ) ) <nl> return ; <nl> <nl> - BrowserThread : : PostTask ( <nl> - BrowserThread : : FILE , FROM_HERE , <nl> + base : : PostTaskWithTraits ( <nl> + FROM_HERE , { base : : MayBlock ( ) , base : : TaskPriority : : BACKGROUND } , <nl> base : : Bind ( & TtsPlatformImplLinux : : Initialize , base : : Unretained ( this ) ) ) ; <nl> } <nl> <nl> mmm a / chromium_src / chrome / browser / speech / tts_win . cc <nl> ppp b / chromium_src / chrome / browser / speech / tts_win . cc <nl> <nl> # include < math . h > <nl> # include < objbase . h > <nl> # include < sapi . h > <nl> + # include < wrl / client . h > <nl> <nl> # include " base / memory / singleton . h " <nl> # include " base / strings / string_number_conversions . h " <nl> # include " base / strings / utf_string_conversions . h " <nl> # include " base / values . h " <nl> - # include " base / win / scoped_comptr . h " <nl> # include " chrome / browser / speech / tts_controller . h " <nl> # include " chrome / browser / speech / tts_platform . h " <nl> <nl> class TtsPlatformImplWin : public TtsPlatformImpl { <nl> <nl> void OnSpeechEvent ( ) ; <nl> <nl> - base : : win : : ScopedComPtr < ISpVoice > speech_synthesizer_ ; <nl> + Microsoft : : WRL : : ComPtr < ISpVoice > speech_synthesizer_ ; <nl> <nl> / / These apply to the current utterance only . <nl> std : : wstring utterance_ ; <nl> mmm a / chromium_src / chrome / browser / ssl / security_state_tab_helper . cc <nl> ppp b / chromium_src / chrome / browser / ssl / security_state_tab_helper . cc <nl> void SecurityStateTabHelper : : VisibleSecurityStateChanged ( ) { <nl> <nl> security_state : : SecurityInfo security_info ; <nl> GetSecurityInfo ( & security_info ) ; <nl> - if ( ! security_info . displayed_password_field_on_http & & <nl> - ! security_info . displayed_credit_card_field_on_http ) { <nl> + if ( ! security_info . insecure_input_events . password_field_shown & & <nl> + ! security_info . insecure_input_events . credit_card_field_edited ) { <nl> return ; <nl> } <nl> <nl> void SecurityStateTabHelper : : VisibleSecurityStateChanged ( ) { <nl> web_contents ( ) - > GetMainFrame ( ) - > AddMessageToConsole ( <nl> content : : CONSOLE_MESSAGE_LEVEL_WARNING , warning ) ; <nl> <nl> - if ( security_info . displayed_credit_card_field_on_http ) { <nl> + if ( security_info . insecure_input_events . credit_card_field_edited ) { <nl> UMA_HISTOGRAM_BOOLEAN ( <nl> " Security . HTTPBad . UserWarnedAboutSensitiveInput . CreditCard " , <nl> warning_is_user_visible ) ; <nl> } <nl> - if ( security_info . displayed_password_field_on_http ) { <nl> + if ( security_info . insecure_input_events . password_field_shown ) { <nl> UMA_HISTOGRAM_BOOLEAN ( <nl> " Security . HTTPBad . UserWarnedAboutSensitiveInput . Password " , <nl> warning_is_user_visible ) ; <nl> mmm a / chromium_src / chrome / common / widevine_cdm_constants . h <nl> ppp b / chromium_src / chrome / common / widevine_cdm_constants . h <nl> <nl> <nl> # include " base / files / file_path . h " <nl> # include " base / macros . h " <nl> + # include " third_party / widevine / cdm / widevine_cdm_common . h " <nl> <nl> extern const char kWidevineCdmPluginExtension [ ] ; <nl> <nl> deleted file mode 100644 <nl> index cb732a47ded6 . . 000000000000 <nl> mmm a / chromium_src / chrome / common / widevine_cdm_messages . h <nl> ppp / dev / null <nl> <nl> - / / Copyright ( c ) 2013 The Chromium 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> - / / Multiply - included message file , hence no include guard . <nl> - <nl> - # include < vector > <nl> - <nl> - # include " ipc / ipc_message_macros . h " <nl> - # include " media / media_features . h " <nl> - <nl> - # define IPC_MESSAGE_START ChromeMsgStart <nl> - <nl> - / / Renderer - > Browser messages . <nl> - <nl> - # if BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> - / / Returns whether any internal plugin supporting | mime_type | is registered and <nl> - / / enabled . Does not determine whether the plugin can actually be instantiated <nl> - / / ( e . g . whether it has all its dependencies ) . <nl> - / / When the returned * | is_available | is true , | additional_param_names | and <nl> - / / | additional_param_values | contain the name - value pairs , if any , specified <nl> - / / for the * first * non - disabled plugin found that is registered for | mime_type | . <nl> - IPC_SYNC_MESSAGE_CONTROL1_3 ( <nl> - ChromeViewHostMsg_IsInternalPluginAvailableForMimeType , <nl> - std : : string / * mime_type * / , <nl> - bool / * is_available * / , <nl> - std : : vector < base : : string16 > / * additional_param_names * / , <nl> - std : : vector < base : : string16 > / * additional_param_values * / ) <nl> - # endif / / BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> - <nl> - / / Browser - > Renderer messages . <nl> mmm a / chromium_src / chrome / renderer / media / chrome_key_systems . cc <nl> ppp b / chromium_src / chrome / renderer / media / chrome_key_systems . cc <nl> <nl> # include " base / strings / string16 . h " <nl> # include " base / strings / string_split . h " <nl> # include " base / strings / utf_string_conversions . h " <nl> - # include " chrome / common / widevine_cdm_messages . h " <nl> # include " components / cdm / renderer / widevine_key_system_properties . h " <nl> # include " content / public / renderer / render_thread . h " <nl> # include " media / base / eme_constants . h " <nl> # include " media / base / key_system_properties . h " <nl> # include " media / media_features . h " <nl> <nl> + # if BUILDFLAG ( ENABLE_LIBRARY_CDMS ) <nl> + # include " content / public / renderer / key_system_support . h " <nl> + # include " media / base / video_codecs . h " <nl> + # endif <nl> + <nl> # include " widevine_cdm_version . h " / / In SHARED_INTERMEDIATE_DIR . <nl> <nl> / / The following must be after widevine_cdm_version . h . <nl> using media : : SupportedCodecs ; <nl> static const char kExternalClearKeyPepperType [ ] = <nl> " application / x - ppapi - clearkey - cdm " ; <nl> <nl> - static bool IsPepperCdmAvailable ( <nl> - const std : : string & pepper_type , <nl> - std : : vector < base : : string16 > * additional_param_names , <nl> - std : : vector < base : : string16 > * additional_param_values ) { <nl> - bool is_available = false ; <nl> - content : : RenderThread : : Get ( ) - > Send ( <nl> - new ChromeViewHostMsg_IsInternalPluginAvailableForMimeType ( <nl> - pepper_type , & is_available , additional_param_names , <nl> - additional_param_values ) ) ; <nl> - <nl> - return is_available ; <nl> - } <nl> - <nl> / / KeySystemProperties implementation for external Clear Key systems . <nl> class ExternalClearKeyProperties : public KeySystemProperties { <nl> public : <nl> static void AddExternalClearKey ( <nl> static const char kExternalClearKeyCrashKeySystem [ ] = <nl> " org . chromium . externalclearkey . crash " ; <nl> <nl> - std : : vector < base : : string16 > additional_param_names ; <nl> - std : : vector < base : : string16 > additional_param_values ; <nl> - if ( ! IsPepperCdmAvailable ( kExternalClearKeyPepperType , <nl> - & additional_param_names , <nl> - & additional_param_values ) ) { <nl> + std : : vector < media : : VideoCodec > supported_video_codecs ; <nl> + bool supports_persistent_license ; <nl> + if ( ! content : : IsKeySystemSupported ( kExternalClearKeyKeySystem , <nl> + & supported_video_codecs , <nl> + & supports_persistent_license ) ) { <nl> return ; <nl> } <nl> <nl> static void AddExternalClearKey ( <nl> } <nl> <nl> # if defined ( WIDEVINE_CDM_AVAILABLE ) <nl> - / / This function finds " codecs " and parses the value into the vector | codecs | . <nl> - / / Converts the codec strings to UTF - 8 since we only expect ASCII strings and <nl> - / / this simplifies the rest of the code in this file . <nl> - void GetSupportedCodecsForPepperCdm ( <nl> - const std : : vector < base : : string16 > & additional_param_names , <nl> - const std : : vector < base : : string16 > & additional_param_values , <nl> - std : : vector < std : : string > * codecs ) { <nl> - DCHECK ( codecs - > empty ( ) ) ; <nl> - DCHECK_EQ ( additional_param_names . size ( ) , additional_param_values . size ( ) ) ; <nl> - for ( size_t i = 0 ; i < additional_param_names . size ( ) ; + + i ) { <nl> - if ( additional_param_names [ i ] = = <nl> - base : : ASCIIToUTF16 ( kCdmSupportedCodecsParamName ) ) { <nl> - const base : : string16 & codecs_string16 = additional_param_values [ i ] ; <nl> - std : : string codecs_string ; <nl> - if ( ! base : : UTF16ToUTF8 ( codecs_string16 . c_str ( ) , codecs_string16 . length ( ) , <nl> - & codecs_string ) ) { <nl> - DLOG ( WARNING ) < < " Non - UTF - 8 codecs string . " ; <nl> - / / Continue using the best effort conversion . <nl> - } <nl> - * codecs = base : : SplitString ( <nl> - codecs_string , std : : string ( 1 , kCdmSupportedCodecsValueDelimiter ) , <nl> - base : : TRIM_WHITESPACE , base : : SPLIT_WANT_ALL ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> static void AddPepperBasedWidevine ( <nl> std : : vector < std : : unique_ptr < KeySystemProperties > > * concrete_key_systems ) { <nl> # if defined ( WIDEVINE_CDM_MIN_GLIBC_VERSION ) <nl> static void AddPepperBasedWidevine ( <nl> return ; <nl> # endif / / defined ( WIDEVINE_CDM_MIN_GLIBC_VERSION ) <nl> <nl> - std : : vector < base : : string16 > additional_param_names ; <nl> - std : : vector < base : : string16 > additional_param_values ; <nl> - if ( ! IsPepperCdmAvailable ( kWidevineCdmPluginMimeType , & additional_param_names , <nl> - & additional_param_values ) ) { <nl> + std : : vector < media : : VideoCodec > supported_video_codecs ; <nl> + bool supports_persistent_license = false ; <nl> + if ( ! content : : IsKeySystemSupported ( kWidevineKeySystem , <nl> + & supported_video_codecs , <nl> + & supports_persistent_license ) ) { <nl> DVLOG ( 1 ) < < " Widevine CDM is not currently available . " ; <nl> return ; <nl> } <nl> <nl> - std : : vector < std : : string > codecs ; <nl> - GetSupportedCodecsForPepperCdm ( additional_param_names , <nl> - additional_param_values , & codecs ) ; <nl> - <nl> SupportedCodecs supported_codecs = media : : EME_CODEC_NONE ; <nl> <nl> / / Audio codecs are always supported . <nl> static void AddPepperBasedWidevine ( <nl> supported_codecs | = media : : EME_CODEC_MP4_AAC ; <nl> # endif / / BUILDFLAG ( USE_PROPRIETARY_CODECS ) <nl> <nl> - for ( size_t i = 0 ; i < codecs . size ( ) ; + + i ) { <nl> - if ( codecs [ i ] = = kCdmSupportedCodecVp8 ) <nl> - supported_codecs | = media : : EME_CODEC_WEBM_VP8 ; <nl> - if ( codecs [ i ] = = kCdmSupportedCodecVp9 ) { <nl> - supported_codecs | = media : : EME_CODEC_WEBM_VP9 ; <nl> - supported_codecs | = media : : EME_CODEC_COMMON_VP9 ; <nl> - } <nl> + / / Video codecs are determined by what was registered for the CDM . <nl> + for ( const auto & codec : supported_video_codecs ) { <nl> + switch ( codec ) { <nl> + case media : : VideoCodec : : kCodecVP8 : <nl> + supported_codecs | = media : : EME_CODEC_WEBM_VP8 ; <nl> + break ; <nl> + case media : : VideoCodec : : kCodecVP9 : <nl> + supported_codecs | = media : : EME_CODEC_WEBM_VP9 ; <nl> + supported_codecs | = media : : EME_CODEC_COMMON_VP9 ; <nl> + break ; <nl> # if BUILDFLAG ( USE_PROPRIETARY_CODECS ) <nl> - if ( codecs [ i ] = = kCdmSupportedCodecAvc1 ) <nl> - supported_codecs | = media : : EME_CODEC_MP4_AVC1 ; <nl> + case media : : VideoCodec : : kCodecH264 : <nl> + supported_codecs | = media : : EME_CODEC_MP4_AVC1 ; <nl> + break ; <nl> # endif / / BUILDFLAG ( USE_PROPRIETARY_CODECS ) <nl> + default : <nl> + DVLOG ( 1 ) < < " Unexpected supported codec : " < < GetCodecName ( codec ) ; <nl> + break ; <nl> + } <nl> } <nl> <nl> using Robustness = cdm : : WidevineKeySystemProperties : : Robustness ; <nl> mmm a / chromium_src / chrome / renderer / pepper / pepper_flash_renderer_host . cc <nl> ppp b / chromium_src / chrome / renderer / pepper / pepper_flash_renderer_host . cc <nl> <nl> # include " ppapi / thunk / ppb_image_data_api . h " <nl> # include " skia / ext / platform_canvas . h " <nl> # include " third_party / skia / include / core / SkCanvas . h " <nl> + # include " third_party / skia / include / core / SkFontStyle . h " <nl> # include " third_party / skia / include / core / SkMatrix . h " <nl> # include " third_party / skia / include / core / SkPaint . h " <nl> # include " third_party / skia / include / core / SkPoint . h " <nl> int32_t PepperFlashRendererHost : : OnSetInstanceAlwaysOnTop ( <nl> int32_t PepperFlashRendererHost : : OnDrawGlyphs ( <nl> ppapi : : host : : HostMessageContext * host_context , <nl> ppapi : : proxy : : PPBFlash_DrawGlyphs_Params params ) { <nl> - if ( params . glyph_indices . size ( ) ! = params . glyph_advances . size ( ) | | <nl> - params . glyph_indices . empty ( ) ) <nl> - return PP_ERROR_FAILED ; <nl> - <nl> - / / Set up the typeface . <nl> - int style = SkTypeface : : kNormal ; <nl> - if ( static_cast < PP_BrowserFont_Trusted_Weight > ( params . font_desc . weight ) > = <nl> - PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD ) <nl> - style | = SkTypeface : : kBold ; <nl> - if ( params . font_desc . italic ) <nl> - style | = SkTypeface : : kItalic ; <nl> - sk_sp < SkTypeface > typeface ( SkTypeface : : MakeFromName ( <nl> - params . font_desc . face . c_str ( ) , SkFontStyle : : FromOldStyle ( style ) ) ) ; <nl> - if ( ! typeface ) <nl> - return PP_ERROR_FAILED ; <nl> - <nl> - EnterResourceNoLock < PPB_ImageData_API > enter ( <nl> - params . image_data . host_resource ( ) , true ) ; <nl> - if ( enter . failed ( ) ) <nl> - return PP_ERROR_FAILED ; <nl> - <nl> - / / Set up the canvas . <nl> - PPB_ImageData_API * image = static_cast < PPB_ImageData_API * > ( enter . object ( ) ) ; <nl> - SkCanvas * canvas = image - > GetCanvas ( ) ; <nl> - bool needs_unmapping = false ; <nl> - if ( ! canvas ) { <nl> - needs_unmapping = true ; <nl> - image - > Map ( ) ; <nl> - canvas = image - > GetCanvas ( ) ; <nl> - if ( ! canvas ) <nl> - return PP_ERROR_FAILED ; / / Failure mapping . <nl> - } <nl> - <nl> - SkAutoCanvasRestore acr ( canvas , true ) ; <nl> - <nl> - / / Clip is applied in pixels before the transform . <nl> - SkRect clip_rect = { <nl> - SkIntToScalar ( params . clip . point . x ) , SkIntToScalar ( params . clip . point . y ) , <nl> - SkIntToScalar ( params . clip . point . x + params . clip . size . width ) , <nl> - SkIntToScalar ( params . clip . point . y + params . clip . size . height ) } ; <nl> - canvas - > clipRect ( clip_rect ) ; <nl> - <nl> - / / Convert & set the matrix . <nl> - SkMatrix matrix ; <nl> - matrix . set ( SkMatrix : : kMScaleX , SkFloatToScalar ( params . transformation [ 0 ] [ 0 ] ) ) ; <nl> - matrix . set ( SkMatrix : : kMSkewX , SkFloatToScalar ( params . transformation [ 0 ] [ 1 ] ) ) ; <nl> - matrix . set ( SkMatrix : : kMTransX , SkFloatToScalar ( params . transformation [ 0 ] [ 2 ] ) ) ; <nl> - matrix . set ( SkMatrix : : kMSkewY , SkFloatToScalar ( params . transformation [ 1 ] [ 0 ] ) ) ; <nl> - matrix . set ( SkMatrix : : kMScaleY , SkFloatToScalar ( params . transformation [ 1 ] [ 1 ] ) ) ; <nl> - matrix . set ( SkMatrix : : kMTransY , SkFloatToScalar ( params . transformation [ 1 ] [ 2 ] ) ) ; <nl> - matrix . set ( SkMatrix : : kMPersp0 , SkFloatToScalar ( params . transformation [ 2 ] [ 0 ] ) ) ; <nl> - matrix . set ( SkMatrix : : kMPersp1 , SkFloatToScalar ( params . transformation [ 2 ] [ 1 ] ) ) ; <nl> - matrix . set ( SkMatrix : : kMPersp2 , SkFloatToScalar ( params . transformation [ 2 ] [ 2 ] ) ) ; <nl> - canvas - > concat ( matrix ) ; <nl> - <nl> - SkPaint paint ; <nl> - paint . setColor ( params . color ) ; <nl> - paint . setTextEncoding ( SkPaint : : kGlyphID_TextEncoding ) ; <nl> - paint . setAntiAlias ( true ) ; <nl> - paint . setHinting ( SkPaint : : kFull_Hinting ) ; <nl> - paint . setTextSize ( SkIntToScalar ( params . font_desc . size ) ) ; <nl> - paint . setTypeface ( std : : move ( typeface ) ) ; <nl> - if ( params . allow_subpixel_aa ) { <nl> - paint . setSubpixelText ( true ) ; <nl> - paint . setLCDRenderText ( true ) ; <nl> - } <nl> - <nl> - SkScalar x = SkIntToScalar ( params . position . x ) ; <nl> - SkScalar y = SkIntToScalar ( params . position . y ) ; <nl> - <nl> - / / Build up the skia advances . <nl> - size_t glyph_count = params . glyph_indices . size ( ) ; <nl> - if ( glyph_count ) { <nl> - std : : vector < SkPoint > storage ; <nl> - storage . resize ( glyph_count ) ; <nl> - SkPoint * sk_positions = & storage [ 0 ] ; <nl> - for ( uint32_t i = 0 ; i < glyph_count ; i + + ) { <nl> - sk_positions [ i ] . set ( x , y ) ; <nl> - x + = SkFloatToScalar ( params . glyph_advances [ i ] . x ) ; <nl> - y + = SkFloatToScalar ( params . glyph_advances [ i ] . y ) ; <nl> - } <nl> - <nl> - canvas - > drawPosText ( & params . glyph_indices [ 0 ] , glyph_count * 2 , sk_positions , <nl> - paint ) ; <nl> - } <nl> - <nl> - if ( needs_unmapping ) <nl> - image - > Unmap ( ) ; <nl> - <nl> - return PP_OK ; <nl> + return PP_ERROR_FAILED ; <nl> + / / if ( params . glyph_indices . size ( ) ! = params . glyph_advances . size ( ) | | <nl> + / / params . glyph_indices . empty ( ) ) <nl> + / / return PP_ERROR_FAILED ; <nl> + / / <nl> + / / / / Set up the typeface . <nl> + / / int weight = ( params . font_desc . weight + 1 ) * 100 ; <nl> + / / SkFontStyle : : Slant slant = SkFontStyle : : kUpright_Slant ; <nl> + / / if ( params . font_desc . italic ) <nl> + / / slant = SkFontStyle : : kItalic_Slant ; <nl> + / / SkFontStyle style ( weight , SkFontStyle : : kNormal_Width , slant ) ; <nl> + / / sk_sp < SkTypeface > typeface ( <nl> + / / SkTypeface : : MakeFromName ( params . font_desc . face . c_str ( ) , style ) ) ; <nl> + / / if ( ! typeface ) <nl> + / / return PP_ERROR_FAILED ; <nl> + / / <nl> + / / EnterResourceNoLock < PPB_ImageData_API > enter ( <nl> + / / params . image_data . host_resource ( ) , true ) ; <nl> + / / if ( enter . failed ( ) ) <nl> + / / return PP_ERROR_FAILED ; <nl> + / / <nl> + / / / / Set up the canvas . <nl> + / / PPB_ImageData_API * image = static_cast < PPB_ImageData_API * > ( enter . object ( ) ) ; <nl> + / / SkCanvas * canvas = image - > GetCanvas ( ) ; <nl> + / / bool needs_unmapping = false ; <nl> + / / if ( ! canvas ) { <nl> + / / needs_unmapping = true ; <nl> + / / image - > Map ( ) ; <nl> + / / canvas = image - > GetCanvas ( ) ; <nl> + / / if ( ! canvas ) <nl> + / / return PP_ERROR_FAILED ; / / Failure mapping . <nl> + / / } <nl> + / / <nl> + / / SkAutoCanvasRestore acr ( canvas , true ) ; <nl> + / / <nl> + / / / / Clip is applied in pixels before the transform . <nl> + / / SkRect clip_rect = { <nl> + / / SkIntToScalar ( params . clip . point . x ) , SkIntToScalar ( params . clip . point . y ) , <nl> + / / SkIntToScalar ( params . clip . point . x + params . clip . size . width ) , <nl> + / / SkIntToScalar ( params . clip . point . y + params . clip . size . height ) } ; <nl> + / / canvas - > clipRect ( clip_rect ) ; <nl> + / / <nl> + / / / / Convert & set the matrix . <nl> + / / SkMatrix matrix ; <nl> + / / matrix . set ( SkMatrix : : kMScaleX , SkFloatToScalar ( params . transformation [ 0 ] [ 0 ] ) ) ; <nl> + / / matrix . set ( SkMatrix : : kMSkewX , SkFloatToScalar ( params . transformation [ 0 ] [ 1 ] ) ) ; <nl> + / / matrix . set ( SkMatrix : : kMTransX , SkFloatToScalar ( params . transformation [ 0 ] [ 2 ] ) ) ; <nl> + / / matrix . set ( SkMatrix : : kMSkewY , SkFloatToScalar ( params . transformation [ 1 ] [ 0 ] ) ) ; <nl> + / / matrix . set ( SkMatrix : : kMScaleY , SkFloatToScalar ( params . transformation [ 1 ] [ 1 ] ) ) ; <nl> + / / matrix . set ( SkMatrix : : kMTransY , SkFloatToScalar ( params . transformation [ 1 ] [ 2 ] ) ) ; <nl> + / / matrix . set ( SkMatrix : : kMPersp0 , SkFloatToScalar ( params . transformation [ 2 ] [ 0 ] ) ) ; <nl> + / / matrix . set ( SkMatrix : : kMPersp1 , SkFloatToScalar ( params . transformation [ 2 ] [ 1 ] ) ) ; <nl> + / / matrix . set ( SkMatrix : : kMPersp2 , SkFloatToScalar ( params . transformation [ 2 ] [ 2 ] ) ) ; <nl> + / / canvas - > concat ( matrix ) ; <nl> + / / <nl> + / / SkPaint paint ; <nl> + / / paint . setColor ( params . color ) ; <nl> + / / paint . setTextEncoding ( SkPaint : : kGlyphID_TextEncoding ) ; <nl> + / / paint . setAntiAlias ( true ) ; <nl> + / / paint . setHinting ( SkPaint : : kFull_Hinting ) ; <nl> + / / paint . setTextSize ( SkIntToScalar ( params . font_desc . size ) ) ; <nl> + / / paint . setTypeface ( std : : move ( typeface ) ) ; <nl> + / / if ( params . allow_subpixel_aa ) { <nl> + / / paint . setSubpixelText ( true ) ; <nl> + / / paint . setLCDRenderText ( true ) ; <nl> + / / } <nl> + / / <nl> + / / SkScalar x = SkIntToScalar ( params . position . x ) ; <nl> + / / SkScalar y = SkIntToScalar ( params . position . y ) ; <nl> + / / <nl> + / / / / Build up the skia advances . <nl> + / / size_t glyph_count = params . glyph_indices . size ( ) ; <nl> + / / if ( glyph_count ) { <nl> + / / std : : vector < SkPoint > storage ; <nl> + / / storage . resize ( glyph_count ) ; <nl> + / / SkPoint * sk_positions = & storage [ 0 ] ; <nl> + / / for ( uint32_t i = 0 ; i < glyph_count ; i + + ) { <nl> + / / sk_positions [ i ] . set ( x , y ) ; <nl> + / / x + = SkFloatToScalar ( params . glyph_advances [ i ] . x ) ; <nl> + / / y + = SkFloatToScalar ( params . glyph_advances [ i ] . y ) ; <nl> + / / } <nl> + / / <nl> + / / canvas - > drawPosText ( & params . glyph_indices [ 0 ] , glyph_count * 2 , sk_positions , <nl> + / / paint ) ; <nl> + / / } <nl> + / / <nl> + / / if ( needs_unmapping ) <nl> + / / image - > Unmap ( ) ; <nl> + / / <nl> + / / return PP_OK ; <nl> } <nl> <nl> / / CAUTION : This code is subtle because Navigate is a sync call which may <nl> mmm a / chromium_src / chrome / renderer / printing / print_web_view_helper . cc <nl> ppp b / chromium_src / chrome / renderer / printing / print_web_view_helper . cc <nl> <nl> # include " net / base / escape . h " <nl> # include " printing / pdf_metafile_skia . h " <nl> # include " printing / units . h " <nl> + # include " third_party / WebKit / public / mojom / page / page_visibility_state . mojom . h " <nl> # include " third_party / WebKit / public / platform / WebDoubleSize . h " <nl> # include " third_party / WebKit / public / platform / WebSize . h " <nl> # include " third_party / WebKit / public / platform / WebURLRequest . h " <nl> class PrepareFrameAndViewForPrint : public blink : : WebViewClient , <nl> const blink : : WebString & name , <nl> const blink : : WebString & unique_name , <nl> blink : : WebSandboxFlags sandbox_flags , <nl> - const blink : : WebParsedFeaturePolicy & container_policy , <nl> + const blink : : ParsedFeaturePolicy & container_policy , <nl> const blink : : WebFrameOwnerProperties & frame_owner_properties ) override ; <nl> <nl> private : <nl> void PrepareFrameAndViewForPrint : : CopySelection ( <nl> WebPreferences prefs = preferences ; <nl> prefs . javascript_enabled = false ; <nl> <nl> - blink : : WebView * web_view = <nl> - blink : : WebView : : Create ( this , blink : : kWebPageVisibilityStateVisible ) ; <nl> + blink : : WebView * web_view = blink : : WebView : : Create ( <nl> + this , blink : : mojom : : PageVisibilityState : : kVisible , nullptr ) ; <nl> owns_web_view_ = true ; <nl> content : : RenderView : : ApplyWebPreferences ( prefs , web_view ) ; <nl> blink : : WebLocalFrame * main_frame = <nl> blink : : WebLocalFrame * PrepareFrameAndViewForPrint : : CreateChildFrame ( <nl> const blink : : WebString & name , <nl> const blink : : WebString & unique_name , <nl> blink : : WebSandboxFlags sandbox_flags , <nl> - const blink : : WebParsedFeaturePolicy & container_policy , <nl> + const blink : : ParsedFeaturePolicy & container_policy , <nl> const blink : : WebFrameOwnerProperties & frame_owner_properties ) { <nl> blink : : WebLocalFrame * frame = parent - > CreateLocalChild ( scope , this , nullptr ) ; <nl> return frame ; <nl> bool PrintWebViewHelper : : PrintPreviewContext : : CreatePreviewDocument ( <nl> return false ; <nl> } <nl> <nl> - metafile_ . reset ( new PdfMetafileSkia ( SkiaDocumentType : : PDF ) ) ; <nl> + metafile_ . reset ( new PdfMetafileSkia ( ) ) ; <nl> CHECK ( metafile_ - > Init ( ) ) ; <nl> <nl> current_page_index_ = 0 ; <nl> mmm a / chromium_src / chrome / renderer / printing / print_web_view_helper . h <nl> ppp b / chromium_src / chrome / renderer / printing / print_web_view_helper . h <nl> class PrintWebViewHelper <nl> void RenderPage ( const PrintMsg_Print_Params & params , <nl> int page_number , <nl> blink : : WebLocalFrame * frame , <nl> - bool is_preview , <nl> PdfMetafileSkia * metafile , <nl> gfx : : Size * page_size , <nl> gfx : : Rect * content_rect ) ; <nl> mmm a / chromium_src / chrome / renderer / printing / print_web_view_helper_linux . cc <nl> ppp b / chromium_src / chrome / renderer / printing / print_web_view_helper_linux . cc <nl> bool PrintWebViewHelper : : RenderPreviewPage ( <nl> std : : unique_ptr < PdfMetafileSkia > draft_metafile ; <nl> PdfMetafileSkia * initial_render_metafile = print_preview_context_ . metafile ( ) ; <nl> if ( print_preview_context_ . IsModifiable ( ) & & is_print_ready_metafile_sent_ ) { <nl> - draft_metafile . reset ( new PdfMetafileSkia ( SkiaDocumentType : : PDF ) ) ; <nl> + draft_metafile . reset ( new PdfMetafileSkia ( ) ) ; <nl> initial_render_metafile = draft_metafile . get ( ) ; <nl> } <nl> <nl> bool PrintWebViewHelper : : RenderPreviewPage ( <nl> <nl> bool PrintWebViewHelper : : PrintPagesNative ( blink : : WebLocalFrame * frame , <nl> int page_count ) { <nl> - PdfMetafileSkia metafile ( SkiaDocumentType : : PDF ) ; <nl> + PdfMetafileSkia metafile ; <nl> if ( ! metafile . Init ( ) ) <nl> return false ; <nl> <nl> mmm a / chromium_src / chrome / renderer / printing / print_web_view_helper_mac . mm <nl> ppp b / chromium_src / chrome / renderer / printing / print_web_view_helper_mac . mm <nl> <nl> void PrintWebViewHelper : : PrintPageInternal ( <nl> const PrintMsg_PrintPage_Params & params , <nl> WebLocalFrame * frame ) { <nl> - PdfMetafileSkia metafile ( SkiaDocumentType : : PDF ) ; <nl> + PdfMetafileSkia metafile ; <nl> CHECK ( metafile . Init ( ) ) ; <nl> <nl> int page_number = params . page_number ; <nl> gfx : : Size page_size_in_dpi ; <nl> gfx : : Rect content_area_in_dpi ; <nl> - RenderPage ( print_pages_params_ - > params , page_number , frame , false , & metafile , <nl> + RenderPage ( print_pages_params_ - > params , page_number , frame , & metafile , <nl> & page_size_in_dpi , & content_area_in_dpi ) ; <nl> metafile . FinishDocument ( ) ; <nl> <nl> <nl> print_preview_context_ . IsModifiable ( ) & & is_print_ready_metafile_sent_ ; <nl> <nl> if ( render_to_draft ) { <nl> - draft_metafile . reset ( new PdfMetafileSkia ( SkiaDocumentType : : PDF ) ) ; <nl> + draft_metafile . reset ( new PdfMetafileSkia ( ) ) ; <nl> CHECK ( draft_metafile - > Init ( ) ) ; <nl> initial_render_metafile = draft_metafile . get ( ) ; <nl> } <nl> <nl> base : : TimeTicks begin_time = base : : TimeTicks : : Now ( ) ; <nl> gfx : : Size page_size ; <nl> RenderPage ( printParams , page_number , print_preview_context_ . prepared_frame ( ) , <nl> - true , initial_render_metafile , & page_size , NULL ) ; <nl> + initial_render_metafile , & page_size , nullptr ) ; <nl> print_preview_context_ . RenderedPreviewPage ( base : : TimeTicks : : Now ( ) - <nl> begin_time ) ; <nl> <nl> <nl> void PrintWebViewHelper : : RenderPage ( const PrintMsg_Print_Params & params , <nl> int page_number , <nl> WebLocalFrame * frame , <nl> - bool is_preview , <nl> PdfMetafileSkia * metafile , <nl> gfx : : Size * page_size , <nl> gfx : : Rect * content_rect ) { <nl> <nl> return ; <nl> <nl> MetafileSkiaWrapper : : SetMetafileOnCanvas ( canvas , metafile ) ; <nl> - cc : : SetIsPreviewMetafile ( canvas , is_preview ) ; <nl> RenderPageContent ( frame , page_number , canvas_area , content_area , <nl> scale_factor , static_cast < blink : : WebCanvas * > ( canvas ) ) ; <nl> } <nl> mmm a / chromium_src / chrome / renderer / printing / print_web_view_helper_pdf_win . cc <nl> ppp b / chromium_src / chrome / renderer / printing / print_web_view_helper_pdf_win . cc <nl> bool PrintWebViewHelper : : RenderPreviewPage ( <nl> std : : unique_ptr < PdfMetafileSkia > draft_metafile ; <nl> PdfMetafileSkia * initial_render_metafile = print_preview_context_ . metafile ( ) ; <nl> if ( print_preview_context_ . IsModifiable ( ) & & is_print_ready_metafile_sent_ ) { <nl> - draft_metafile . reset ( new PdfMetafileSkia ( SkiaDocumentType : : PDF ) ) ; <nl> + draft_metafile . reset ( new PdfMetafileSkia ( ) ) ; <nl> initial_render_metafile = draft_metafile . get ( ) ; <nl> } <nl> <nl> bool PrintWebViewHelper : : RenderPreviewPage ( <nl> <nl> bool PrintWebViewHelper : : PrintPagesNative ( blink : : WebLocalFrame * frame , <nl> int page_count ) { <nl> - PdfMetafileSkia metafile ( SkiaDocumentType : : PDF ) ; <nl> + PdfMetafileSkia metafile ; <nl> if ( ! metafile . Init ( ) ) <nl> return false ; <nl> <nl> mmm a / chromium_src / chrome / utility / printing_handler_win . cc <nl> ppp b / chromium_src / chrome / utility / printing_handler_win . cc <nl> bool PrintingHandlerWin : : RenderPdfPageToMetafile ( int page_number , <nl> <nl> if ( ! chrome_pdf : : RenderPDFPageToDC ( <nl> & pdf_data_ . front ( ) , pdf_data_ . size ( ) , page_number , metafile . context ( ) , <nl> - pdf_rendering_settings_ . dpi , <nl> + pdf_rendering_settings_ . dpi . width ( ) , pdf_rendering_settings_ . dpi . height ( ) , <nl> pdf_rendering_settings_ . area . x ( ) - offset_x , <nl> pdf_rendering_settings_ . area . y ( ) - offset_y , <nl> pdf_rendering_settings_ . area . width ( ) , <nl> mmm a / common . gypi <nl> ppp b / common . gypi <nl> <nl> ' debug_http2 ' : ' false ' , <nl> ' debug_nghttp2 ' : ' false ' , <nl> # XXX ( alexeykuzmin ) : Must match the clang version we use . See ` clang - v ` . <nl> - ' llvm_version ' : ' 6 . 0 ' , <nl> + ' llvm_version ' : ' 7 . 0 ' , <nl> ' python ' : ' python ' , <nl> ' openssl_fips ' : ' ' , <nl> ' openssl_no_asm ' : 1 , <nl> ' use_openssl_def ' : 0 , <nl> ' openssl_product ' : ' libopenssl . a ' , <nl> + ' node_debug_lib ' : ' false ' , <nl> ' node_release_urlbase ' : ' https : / / atom . io / download / electron ' , <nl> ' node_byteorder ' : ' < ! ( node < ( DEPTH ) / tools / get - endianness . js ) ' , <nl> ' node_target_type ' : ' shared_library ' , <nl> mmm a / docs / api / browser - window . md <nl> ppp b / docs / api / browser - window . md <nl> Same as ` webContents . capturePage ( [ rect , ] callback ) ` . <nl> * ` httpReferrer ` ( String | [ Referrer ] ( structures / referrer . md ) ) ( optional ) - An HTTP Referrer url . <nl> * ` userAgent ` String ( optional ) - A user agent originating the request . <nl> * ` extraHeaders ` String ( optional ) - Extra headers separated by " \ n " <nl> - * ` postData ` ( [ UploadRawData [ ] ] ( structures / upload - raw - data . md ) | [ UploadFile [ ] ] ( structures / upload - file . md ) | [ UploadFileSystem [ ] ] ( structures / upload - file - system . md ) | [ UploadBlob [ ] ] ( structures / upload - blob . md ) ) ( optional ) <nl> + * ` postData ` ( [ UploadRawData [ ] ] ( structures / upload - raw - data . md ) | [ UploadFile [ ] ] ( structures / upload - file . md ) | [ UploadBlob [ ] ] ( structures / upload - blob . md ) ) ( optional ) <nl> * ` baseURLForDataURL ` String ( optional ) - Base url ( with trailing path separator ) for files to be loaded by the data url . This is needed only if the specified ` url ` is a data url and needs to load other files . <nl> <nl> Same as ` webContents . loadURL ( url [ , options ] ) ` . <nl> deleted file mode 100644 <nl> index d7a1b28a03a9 . . 000000000000 <nl> mmm a / docs / api / structures / upload - file - system . md <nl> ppp / dev / null <nl> <nl> - # UploadFileSystem Object <nl> - <nl> - * ( Deprecated ) * <nl> - <nl> - * ` type ` String - ` fileSystem ` . <nl> - * ` filsSystemURL ` String - FileSystem url to read data for upload . <nl> - * ` offset ` Integer - Defaults to ` 0 ` . <nl> - * ` length ` Integer - Number of bytes to read from ` offset ` . <nl> - Defaults to ` 0 ` . <nl> - * ` modificationTime ` Double - Last Modification time in <nl> - number of seconds since the UNIX epoch . <nl> mmm a / docs / api / web - contents . md <nl> ppp b / docs / api / web - contents . md <nl> Corresponds to the points in time when the spinner of the tab started spinning . <nl> <nl> Corresponds to the points in time when the spinner of the tab stopped spinning . <nl> <nl> - # # # # Event : ' did - get - response - details ' * ( Deprecated ) * <nl> - <nl> - Returns : <nl> - <nl> - * ` event ` Event <nl> - * ` status ` Boolean <nl> - * ` newURL ` String <nl> - * ` originalURL ` String <nl> - * ` httpResponseCode ` Integer <nl> - * ` requestMethod ` String <nl> - * ` referrer ` String <nl> - * ` headers ` Object <nl> - * ` resourceType ` String <nl> - <nl> - Emitted when details regarding a requested resource are available . <nl> - ` status ` indicates the socket connection to download the resource . <nl> - <nl> - * * Deprecated * * : This event has been deprecated . Use the [ ` webRequest ` ] ( web - request . md ) module which provides similar navigation details on a subscription basis . <nl> - # # # # Event : ' did - get - redirect - request ' * ( Deprecated ) * <nl> - <nl> - Returns : <nl> - <nl> - * ` event ` Event <nl> - * ` oldURL ` String <nl> - * ` newURL ` String <nl> - * ` isMainFrame ` Boolean <nl> - * ` httpResponseCode ` Integer <nl> - * ` requestMethod ` String <nl> - * ` referrer ` String <nl> - * ` headers ` Object <nl> - <nl> - Emitted when a redirect is received while requesting a resource . <nl> - * * Deprecated * * : This event has been deprecated . Use the [ ` webRequest ` ] ( web - request . md ) module which provides similar navigation details on a subscription basis . <nl> # # # # Event : ' dom - ready ' <nl> <nl> Returns : <nl> for windows with * offscreen rendering * enabled . <nl> * ` httpReferrer ` ( String | [ Referrer ] ( structures / referrer . md ) ) ( optional ) - An HTTP Referrer url . <nl> * ` userAgent ` String ( optional ) - A user agent originating the request . <nl> * ` extraHeaders ` String ( optional ) - Extra headers separated by " \ n " . <nl> - * ` postData ` ( [ UploadRawData [ ] ] ( structures / upload - raw - data . md ) | [ UploadFile [ ] ] ( structures / upload - file . md ) | [ UploadFileSystem [ ] ] ( structures / upload - file - system . md ) | [ UploadBlob [ ] ] ( structures / upload - blob . md ) ) ( optional ) <nl> + * ` postData ` ( [ UploadRawData [ ] ] ( structures / upload - raw - data . md ) | [ UploadFile [ ] ] ( structures / upload - file . md ) | [ UploadBlob [ ] ] ( structures / upload - blob . md ) ) ( optional ) <nl> * ` baseURLForDataURL ` String ( optional ) - Base url ( with trailing path separator ) for files to be loaded by the data url . This is needed only if the specified ` url ` is a data url and needs to load other files . <nl> <nl> Loads the ` url ` in the window . The ` url ` must contain the protocol prefix , <nl> For the ` mouseWheel ` event , the ` event ` object also have following properties : <nl> <nl> * ` onlyDirty ` Boolean ( optional ) - Defaults to ` false ` . <nl> * ` callback ` Function <nl> - * ` frameBuffer ` Buffer <nl> + * ` image ` [ NativeImage ] ( native - image . md ) <nl> * ` dirtyRect ` [ Rectangle ] ( structures / rectangle . md ) <nl> <nl> Begin subscribing for presentation events and captured frames , the ` callback ` <nl> - will be called with ` callback ( frameBuffer , dirtyRect ) ` when there is a <nl> - presentation event . <nl> + will be called with ` callback ( image , dirtyRect ) ` when there is a presentation <nl> + event . <nl> <nl> - The ` frameBuffer ` is a ` Buffer ` that contains raw pixel data . On most machines , <nl> - the pixel data is effectively stored in 32bit BGRA format , but the actual <nl> - representation depends on the endianness of the processor ( most modern <nl> - processors are little - endian , on machines with big - endian processors the data <nl> - is in 32bit ARGB format ) . <nl> + The ` image ` is an instance of [ NativeImage ] ( native - image . md ) that stores the <nl> + captured frame . <nl> <nl> The ` dirtyRect ` is an object with ` x , y , width , height ` properties that <nl> describes which part of the page was repainted . If ` onlyDirty ` is set to <nl> - ` true ` , ` frameBuffer ` will only contain the repainted area . ` onlyDirty ` <nl> - defaults to ` false ` . <nl> + ` true ` , ` image ` will only contain the repainted area . ` onlyDirty ` defaults to <nl> + ` false ` . <nl> <nl> # # # # ` contents . endFrameSubscription ( ) ` <nl> <nl> mmm a / docs / api / webview - tag . md <nl> ppp b / docs / api / webview - tag . md <nl> webview . addEventListener ( ' dom - ready ' , ( ) = > { <nl> * ` httpReferrer ` ( String | [ Referrer ] ( structures / referrer . md ) ) ( optional ) - An HTTP Referrer url . <nl> * ` userAgent ` String ( optional ) - A user agent originating the request . <nl> * ` extraHeaders ` String ( optional ) - Extra headers separated by " \ n " <nl> - * ` postData ` ( [ UploadRawData [ ] ] ( structures / upload - raw - data . md ) | [ UploadFile [ ] ] ( structures / upload - file . md ) | [ UploadFileSystem [ ] ] ( structures / upload - file - system . md ) | [ UploadBlob [ ] ] ( structures / upload - blob . md ) ) ( optional ) <nl> + * ` postData ` ( [ UploadRawData [ ] ] ( structures / upload - raw - data . md ) | [ UploadFile [ ] ] ( structures / upload - file . md ) | [ UploadBlob [ ] ] ( structures / upload - blob . md ) ) ( optional ) <nl> * ` baseURLForDataURL ` String ( optional ) - Base url ( with trailing path separator ) for files to be loaded by the data url . This is needed only if the specified ` url ` is a data url and needs to load other files . <nl> <nl> Loads the ` url ` in the webview , the ` url ` must contain the protocol prefix , <nl> Corresponds to the points in time when the spinner of the tab starts spinning . <nl> <nl> Corresponds to the points in time when the spinner of the tab stops spinning . <nl> <nl> - # # # Event : ' did - get - response - details ' * ( Deprecated ) * <nl> - <nl> - Returns : <nl> - <nl> - * ` status ` Boolean <nl> - * ` newURL ` String <nl> - * ` originalURL ` String <nl> - * ` httpResponseCode ` Integer <nl> - * ` requestMethod ` String <nl> - * ` referrer ` String <nl> - * ` headers ` Object <nl> - * ` resourceType ` String <nl> - <nl> - Fired when details regarding a requested resource is available . <nl> - ` status ` indicates socket connection to download the resource . <nl> - <nl> - * * Deprecated * * : This event has been deprecated . Use the [ ` webRequest ` ] ( web - request . md ) module which provides similar navigation details on a subscription basis . <nl> - # # # Event : ' did - get - redirect - request ' * ( Deprecated ) * <nl> - <nl> - Returns : <nl> - <nl> - * ` oldURL ` String <nl> - * ` newURL ` String <nl> - * ` isMainFrame ` Boolean <nl> - <nl> - Fired when a redirect was received while requesting a resource . <nl> - * * Deprecated * * : This event has been deprecated . Use the [ ` webRequest ` ] ( web - request . md ) module which provides similar navigation details on a subscription basis . <nl> # # # Event : ' dom - ready ' <nl> <nl> Fired when document in the given frame is loaded . <nl> mmm a / docs / tutorial / snapcraft . md <nl> ppp b / docs / tutorial / snapcraft . md <nl> The output should look roughly like this : <nl> ├ ─ ─ locales <nl> ├ ─ ─ natives_blob . bin <nl> ├ ─ ─ resources <nl> - ├ ─ ─ snapshot_blob . bin <nl> + ├ ─ ─ v8_context_snapshot . bin <nl> └ ─ ─ version <nl> ` ` ` <nl> <nl> mmm a / docs / tutorial / windows - store - guide . md <nl> ppp b / docs / tutorial / windows - store - guide . md <nl> The output should look roughly like this : <nl> ├ ─ ─ resources <nl> │ ├ ─ ─ app <nl> │ └ ─ ─ atom . asar <nl> - ├ ─ ─ snapshot_blob . bin <nl> + ├ ─ ─ v8_context_snapshot . bin <nl> ├ ─ ─ squirrel . exe <nl> └ ─ ─ ui_resources_200_percent . pak <nl> ` ` ` <nl> mmm a / electron . gyp <nl> ppp b / electron . gyp <nl> <nl> ' < ( libchromiumcontent_dir ) / ui_resources_200_percent . pak ' , <nl> ' < ( libchromiumcontent_dir ) / views_resources_200_percent . pak ' , <nl> ' < ( libchromiumcontent_dir ) / natives_blob . bin ' , <nl> - ' < ( libchromiumcontent_dir ) / snapshot_blob . bin ' , <nl> + ' < ( libchromiumcontent_dir ) / v8_context_snapshot . bin ' , <nl> ' external_binaries / d3dcompiler_47 . dll ' , <nl> ] , <nl> } , <nl> <nl> ' < ( libchromiumcontent_dir ) / ui_resources_200_percent . pak ' , <nl> ' < ( libchromiumcontent_dir ) / views_resources_200_percent . pak ' , <nl> ' < ( libchromiumcontent_dir ) / natives_blob . bin ' , <nl> - ' < ( libchromiumcontent_dir ) / snapshot_blob . bin ' , <nl> + ' < ( libchromiumcontent_dir ) / v8_context_snapshot . bin ' , <nl> ] , <nl> } , <nl> ] , <nl> <nl> ' - lwinmm . lib ' , <nl> ' - lcrypt32 . lib ' , <nl> ' - luiautomationcore . lib ' , <nl> + ' - lPropsys . lib ' <nl> ] , <nl> } , <nl> ' dependencies ' : [ <nl> <nl> ' < ( libchromiumcontent_dir ) / ui_resources_200_percent . pak ' , <nl> ' < ( libchromiumcontent_dir ) / views_resources_200_percent . pak ' , <nl> ' < ( libchromiumcontent_dir ) / natives_blob . bin ' , <nl> - ' < ( libchromiumcontent_dir ) / snapshot_blob . bin ' , <nl> + ' < ( libchromiumcontent_dir ) / v8_context_snapshot . bin ' , <nl> ] , <nl> ' xcode_settings ' : { <nl> ' ATOM_BUNDLE_ID ' : ' com . < ( company_abbr ) . < ( project_name ) . framework ' , <nl> mmm a / features . gypi <nl> ppp b / features . gypi <nl> <nl> ' variables ' : { <nl> ' variables ' : { <nl> ' enable_desktop_capturer % ' : 1 , <nl> - ' enable_osr % ' : 1 , # FIXME ( alexeykuzmin ) <nl> + ' enable_osr % ' : 0 , # FIXME ( alexeykuzmin ) <nl> ' enable_pdf_viewer % ' : 0 , # FIXME ( deepak1556 ) <nl> ' enable_run_as_node % ' : 1 , <nl> ' enable_view_api % ' : 0 , <nl> mmm a / filenames . gypi <nl> ppp b / filenames . gypi <nl> <nl> ' atom / browser / auto_updater . cc ' , <nl> ' atom / browser / auto_updater . h ' , <nl> ' atom / browser / auto_updater_mac . mm ' , <nl> - ' atom / browser / atom_access_token_store . h ' , <nl> ' atom / browser / atom_blob_reader . cc ' , <nl> ' atom / browser / atom_blob_reader . h ' , <nl> ' atom / browser / atom_browser_client . cc ' , <nl> <nl> ' atom / common / native_mate_converters / image_converter . h ' , <nl> ' atom / common / native_mate_converters / net_converter . cc ' , <nl> ' atom / common / native_mate_converters / net_converter . h ' , <nl> + ' atom / common / native_mate_converters / network_converter . cc ' , <nl> + ' atom / common / native_mate_converters / network_converter . h ' , <nl> ' atom / common / native_mate_converters / string16_converter . h ' , <nl> ' atom / common / native_mate_converters / ui_base_types_converter . h ' , <nl> ' atom / common / native_mate_converters / v8_value_converter . cc ' , <nl> <nl> ' chromium_src / chrome / browser / renderer_host / pepper / pepper_flash_drm_host . h ' , <nl> ' chromium_src / chrome / browser / renderer_host / pepper / pepper_isolated_file_system_message_filter . cc ' , <nl> ' chromium_src / chrome / browser / renderer_host / pepper / pepper_isolated_file_system_message_filter . h ' , <nl> - ' chromium_src / chrome / browser / renderer_host / pepper / widevine_cdm_message_filter . cc ' , <nl> - ' chromium_src / chrome / browser / renderer_host / pepper / widevine_cdm_message_filter . h ' , <nl> ' chromium_src / chrome / browser / speech / tts_controller . h ' , <nl> ' chromium_src / chrome / browser / speech / tts_controller_impl . cc ' , <nl> ' chromium_src / chrome / browser / speech / tts_controller_impl . h ' , <nl> <nl> ' chromium_src / chrome / common / tts_messages . h ' , <nl> ' chromium_src / chrome / common / tts_utterance_request . cc ' , <nl> ' chromium_src / chrome / common / tts_utterance_request . h ' , <nl> - ' chromium_src / chrome / common / widevine_cdm_messages . h ' , <nl> ' chromium_src / chrome / common / widevine_cdm_constants . cc ' , <nl> ' chromium_src / chrome / common / widevine_cdm_constants . h ' , <nl> ' chromium_src / chrome / renderer / media / chrome_key_systems . cc ' , <nl> mmm a / lib / browser / guest - view - manager . js <nl> ppp b / lib / browser / guest - view - manager . js <nl> const supportedWebViewEvents = [ <nl> ' did - frame - finish - load ' , <nl> ' did - start - loading ' , <nl> ' did - stop - loading ' , <nl> - ' - did - get - response - details ' , <nl> - ' - did - get - redirect - request ' , <nl> ' dom - ready ' , <nl> ' console - message ' , <nl> ' context - menu ' , <nl> mmm a / lib / renderer / web - view / guest - view - internal . js <nl> ppp b / lib / renderer / web - view / guest - view - internal . js <nl> const WEB_VIEW_EVENTS = { <nl> ' did - frame - finish - load ' : [ ' isMainFrame ' , ' frameProcessId ' , ' frameRoutingId ' ] , <nl> ' did - start - loading ' : [ ] , <nl> ' did - stop - loading ' : [ ] , <nl> - ' - did - get - response - details ' : [ ' status ' , ' newURL ' , ' originalURL ' , ' httpResponseCode ' , ' requestMethod ' , ' referrer ' , ' headers ' , ' resourceType ' ] , <nl> - ' - did - get - redirect - request ' : [ ' oldURL ' , ' newURL ' , ' isMainFrame ' ] , <nl> ' dom - ready ' : [ ] , <nl> ' console - message ' : [ ' level ' , ' message ' , ' line ' , ' sourceId ' ] , <nl> ' context - menu ' : [ ' params ' ] , <nl> mmm a / script / create - dist . py <nl> ppp b / script / create - dist . py <nl> <nl> ' ui_resources_200_percent . pak ' , <nl> ' views_resources_200_percent . pak ' , <nl> ' natives_blob . bin ' , <nl> - ' snapshot_blob . bin ' , <nl> + ' v8_context_snapshot . bin ' , <nl> ] , <nl> ' linux ' : [ <nl> PROJECT_NAME , # ' electron ' <nl> <nl> ' ui_resources_200_percent . pak ' , <nl> ' views_resources_200_percent . pak ' , <nl> ' natives_blob . bin ' , <nl> - ' snapshot_blob . bin ' , <nl> + ' v8_context_snapshot . bin ' , <nl> ] , <nl> } <nl> TARGET_BINARIES_EXT = [ ] <nl> mmm a / script / update - clang . sh <nl> ppp b / script / update - clang . sh <nl> <nl> # Do NOT CHANGE this if you don ' t know what you ' re doing - - see <nl> # https : / / code . google . com / p / chromium / wiki / UpdatingClang <nl> # Reverting problematic clang rolls is safe , though . <nl> - CLANG_REVISION = 313786 <nl> + CLANG_REVISION = 325667 <nl> <nl> # This is incremented when pushing a new build of Clang at the same revision . <nl> CLANG_SUB_REVISION = 1 <nl> mmm a / spec / api - app - spec . js <nl> ppp b / spec / api - app - spec . js <nl> describe ( ' app module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' getAppMetrics ( ) API ' , ( ) = > { <nl> + / / TODO ( marshallofsound ) : [ Ch66 ] Failed on Windows x64 + ia32 on CI , passes locally <nl> + xdescribe ( ' getAppMetrics ( ) API ' , ( ) = > { <nl> it ( ' returns memory and cpu stats of all running electron processes ' , ( ) = > { <nl> const appMetrics = app . getAppMetrics ( ) <nl> expect ( appMetrics ) . to . be . an ( ' array ' ) . and . have . lengthOf . at . least ( 1 , ' App memory info object is not > 0 ' ) <nl> mmm a / spec / api - browser - window - spec . js <nl> ppp b / spec / api - browser - window - spec . js <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> it ( ' should not crash when invoked synchronously inside navigation observer ' , ( done ) = > { <nl> const events = [ <nl> { name : ' did - start - loading ' , url : ` $ { server . url } / 200 ` } , <nl> - { name : ' - did - get - redirect - request ' , url : ` $ { server . url } / 301 ` } , <nl> - { name : ' - did - get - response - details ' , url : ` $ { server . url } / 200 ` } , <nl> { name : ' dom - ready ' , url : ` $ { server . url } / 200 ` } , <nl> { name : ' page - title - updated ' , url : ` $ { server . url } / title ` } , <nl> { name : ' did - stop - loading ' , url : ` $ { server . url } / 200 ` } , <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> w . on ( ' ready - to - show ' , ( ) = > { done ( ) } ) <nl> w . loadURL ( ' about : blank ' ) <nl> } ) <nl> - / / TODO ( nitsakh ) : Deprecated <nl> - it ( ' should emit did - get - response - details ( deprecated ) event ' , ( done ) = > { <nl> - / / expected { fileName : resourceType } pairs <nl> - const expectedResources = { <nl> - ' did - get - response - details . html ' : ' mainFrame ' , <nl> - ' logo . png ' : ' image ' <nl> - } <nl> - let responses = 0 <nl> - w . webContents . on ( ' - did - get - response - details ' , ( event , status , newUrl , oldUrl , responseCode , method , referrer , headers , resourceType ) = > { <nl> - responses + = 1 <nl> - const fileName = newUrl . slice ( newUrl . lastIndexOf ( ' / ' ) + 1 ) <nl> - const expectedType = expectedResources [ fileName ] <nl> - assert ( ! ! expectedType , ` Unexpected response details for $ { newUrl } ` ) <nl> - assert ( typeof status = = = ' boolean ' , ' status should be boolean ' ) <nl> - assert . equal ( responseCode , 200 ) <nl> - assert . equal ( method , ' GET ' ) <nl> - assert ( typeof referrer = = = ' string ' , ' referrer should be string ' ) <nl> - assert ( ! ! headers , ' headers should be present ' ) <nl> - assert ( typeof headers = = = ' object ' , ' headers should be object ' ) <nl> - assert . equal ( resourceType , expectedType , ' Incorrect resourceType ' ) <nl> - if ( responses = = = Object . keys ( expectedResources ) . length ) done ( ) <nl> - } ) <nl> - w . loadURL ( ` file : / / $ { path . join ( fixtures , ' pages ' , ' did - get - response - details . html ' ) } ` ) <nl> - } ) <nl> it ( ' should emit did - fail - load event for files that do not exist ' , ( done ) = > { <nl> w . webContents . on ( ' did - fail - load ' , ( event , code , desc , url , isMainFrame ) = > { <nl> assert . equal ( code , - 6 ) <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' BrowserWindow . getFocusedWindow ( ) ' , ( done ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the test . Passes locally . <nl> + xdescribe ( ' BrowserWindow . getFocusedWindow ( ) ' , ( done ) = > { <nl> it ( ' returns the opener window when dev tools window is focused ' , ( done ) = > { <nl> w . show ( ) <nl> w . webContents . once ( ' devtools - focused ' , ( ) = > { <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' BrowserWindow . alwaysOnTop ( ) resets level on minimize ' , ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the test . Passes locally . <nl> + xdescribe ( ' BrowserWindow . alwaysOnTop ( ) resets level on minimize ' , ( ) = > { <nl> before ( function ( ) { <nl> if ( process . platform ! = = ' darwin ' ) { <nl> this . skip ( ) <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' document . visibilityState / hidden ' , ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the tests . They pass locally . <nl> + xdescribe ( ' document . visibilityState / hidden ' , ( ) = > { <nl> beforeEach ( ( ) = > { w . destroy ( ) } ) <nl> <nl> function onVisibilityChange ( callback ) { <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' beginFrameSubscription method ' , ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Crashes the app . <nl> + / / Fix and enable the test . <nl> + xdescribe ( ' beginFrameSubscription method ' , ( ) = > { <nl> before ( function ( ) { <nl> / / This test is too slow , only test it on CI . <nl> if ( ! isCI ) { <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the test . It passes locally . <nl> describe ( ' kiosk state ' , ( ) = > { <nl> before ( function ( ) { <nl> / / Only implemented on macOS . <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' fullscreen state ' , ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the tests . They pass locally . <nl> + xdescribe ( ' fullscreen state ' , ( ) = > { <nl> before ( function ( ) { <nl> / / Only implemented on macOS . <nl> if ( process . platform ! = = ' darwin ' ) { <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } <nl> } ) <nl> <nl> - it ( ' exits HTML fullscreen when window leaves fullscreen ' , ( done ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the test . Fails on CI bots , passes locally . <nl> + xit ( ' exits HTML fullscreen when window leaves fullscreen ' , ( done ) = > { <nl> w . destroy ( ) <nl> w = new BrowserWindow ( ) <nl> w . webContents . once ( ' did - finish - load ' , ( ) = > { <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' for a valid extension ' , ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the tests . <nl> + xdescribe ( ' for a valid extension ' , ( ) = > { <nl> const extensionName = ' foo ' <nl> <nl> const removeExtension = ( ) = > { <nl> describe ( ' BrowserWindow module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - it ( ' works when used with partitions ' , ( done ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Times out . Fix it and enable . <nl> + xit ( ' works when used with partitions ' , ( done ) = > { <nl> if ( w ! = null ) { <nl> w . destroy ( ) <nl> } <nl> mmm a / spec / api - crash - reporter - spec . js <nl> ppp b / spec / api - crash - reporter - spec . js <nl> const { app , BrowserWindow , crashReporter } = remote . require ( ' electron ' ) <nl> describe ( ' crashReporter module ' , ( ) = > { <nl> if ( process . mas | | process . env . DISABLE_CRASH_REPORTER_TESTS ) return <nl> <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Fails . Fix it and enable back . <nl> + if ( process . platform = = = ' linux ' ) return <nl> + <nl> let originalTempDirectory = null <nl> let tempDirectory = null <nl> <nl> mmm a / spec / api - debugger - spec . js <nl> ppp b / spec / api - debugger - spec . js <nl> describe ( ' debugger module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - it ( ' handles valid unicode characters in message ' , ( done ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Times out . Fix it and enable back . <nl> + xit ( ' handles valid unicode characters in message ' , ( done ) = > { <nl> try { <nl> w . webContents . debugger . attach ( ) <nl> } catch ( err ) { <nl> describe ( ' debugger module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - it ( ' does not crash for invalid unicode characters in message ' , ( done ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Times out . Fix it and enable back . <nl> + xit ( ' does not crash for invalid unicode characters in message ' , ( done ) = > { <nl> try { <nl> w . webContents . debugger . attach ( ) <nl> } catch ( err ) { <nl> mmm a / spec / api - power - monitor - spec . js <nl> ppp b / spec / api - power - monitor - spec . js <nl> const Promise = require ( ' bluebird ' ) <nl> <nl> const skip = process . platform ! = = ' linux ' | | ! process . env . DBUS_SYSTEM_BUS_ADDRESS <nl> <nl> - describe ( ' powerMonitor ' , ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Crashes on Linux ia32 . Fix it and enable back . <nl> + xdescribe ( ' powerMonitor ' , ( ) = > { <nl> let logindMock , dbusMockPowerMonitor , getCalls , emitSignal , reset <nl> <nl> if ( ! skip ) { <nl> mmm a / spec / api - session - spec . js <nl> ppp b / spec / api - session - spec . js <nl> describe ( ' session module ' , ( ) = > { <nl> name : ' 1 ' , <nl> value : ' 1 ' <nl> } , ( error ) = > { <nl> + assert ( error , ' Should have an error ' ) <nl> assert . equal ( error . message , ' Setting cookie failed ' ) <nl> done ( ) <nl> } ) <nl> mmm a / spec / api - web - contents - spec . js <nl> ppp b / spec / api - web - contents - spec . js <nl> describe ( ' webContents module ' , ( ) = > { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' focus ( ) ' , ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the test . Passes locally . <nl> + xdescribe ( ' focus ( ) ' , ( ) = > { <nl> describe ( ' when the web contents is hidden ' , ( ) = > { <nl> it ( ' does not blur the focused window ' , ( done ) = > { <nl> ipcMain . once ( ' answer ' , ( event , parentFocused , childFocused ) = > { <nl> describe ( ' webContents module ' , ( ) = > { <nl> it ( ' should not crash when invoked synchronously inside navigation observer ' , ( done ) = > { <nl> const events = [ <nl> { name : ' did - start - loading ' , url : ` $ { server . url } / 200 ` } , <nl> - { name : ' - did - get - redirect - request ' , url : ` $ { server . url } / 301 ` } , <nl> - { name : ' - did - get - response - details ' , url : ` $ { server . url } / 200 ` } , <nl> { name : ' dom - ready ' , url : ` $ { server . url } / 200 ` } , <nl> { name : ' did - stop - loading ' , url : ` $ { server . url } / 200 ` } , <nl> { name : ' did - finish - load ' , url : ` $ { server . url } / 200 ` } , <nl> mmm a / spec / chromium - spec . js <nl> ppp b / spec / chromium - spec . js <nl> describe ( ' chromium feature ' , ( ) = > { <nl> b = window . open ( windowUrl , ' ' , ' nodeIntegration = no , show = no ' ) <nl> } ) <nl> <nl> - it ( ' disables node integration when it is disabled on the parent window for chrome devtools URLs ' , ( done ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Fix the test . <nl> + xit ( ' disables node integration when it is disabled on the parent window for chrome devtools URLs ' , ( done ) = > { <nl> let b <nl> app . once ( ' web - contents - created ' , ( event , contents ) = > { <nl> contents . once ( ' did - finish - load ' , ( ) = > { <nl> mmm a / spec / fixtures / pages / audio . html <nl> ppp b / spec / fixtures / pages / audio . html <nl> @ @ - 1 + 1 @ @ <nl> - < audio autoplay muted src = " . . / assets / tone . wav " > < / audio > <nl> + < audio muted src = " . . / assets / tone . wav " > < / audio > <nl> mmm a / spec / node - spec . js <nl> ppp b / spec / node - spec . js <nl> describe ( ' node feature ' , ( ) = > { <nl> child . on ( ' message ' , ( { cmd , debuggerEnabled , secondSessionOpened , success } ) = > { <nl> if ( cmd = = = ' assert ' ) { <nl> assert . equal ( debuggerEnabled , true ) <nl> - assert . equal ( secondSessionOpened , false ) <nl> + assert . equal ( secondSessionOpened , true ) <nl> assert . equal ( success , true ) <nl> done ( ) <nl> } <nl> new file mode 100644 <nl> index 000000000000 . . f286018282ea <nl> mmm / dev / null <nl> ppp b / spec / package - lock . json <nl> <nl> + { <nl> + " name " : " electron - test " , <nl> + " version " : " 0 . 1 . 0 " , <nl> + " lockfileVersion " : 1 , <nl> + " requires " : true , <nl> + " dependencies " : { <nl> + " abstract - socket " : { <nl> + " version " : " 2 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / abstract - socket / - / abstract - socket - 2 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - 2DyT598w0n4j8 + gqdj5 / XnjZFvk = " , <nl> + " dev " : true , <nl> + " optional " : true , <nl> + " requires " : { <nl> + " bindings " : " 1 . 3 . 0 " , <nl> + " nan " : " 2 . 10 . 0 " <nl> + } <nl> + } , <nl> + " ansi - regex " : { <nl> + " version " : " 3 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / ansi - regex / - / ansi - regex - 3 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - 7QMXwyIGT3lGbAKWa922Bas32Zg = " , <nl> + " dev " : true <nl> + } , <nl> + " assertion - error " : { <nl> + " version " : " 1 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / assertion - error / - / assertion - error - 1 . 1 . 0 . tgz " , <nl> + " integrity " : " sha512 - jgsaNduz + ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw = = " , <nl> + " dev " : true <nl> + } , <nl> + " balanced - match " : { <nl> + " version " : " 1 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / balanced - match / - / balanced - match - 1 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - ibTRmasr7kneFk6gK4nORi1xt2c = " , <nl> + " dev " : true <nl> + } , <nl> + " basic - auth " : { <nl> + " version " : " 1 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / basic - auth / - / basic - auth - 1 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - RSIe5Cn37h5QNb4 / UVM / HN / SmIQ = " , <nl> + " dev " : true <nl> + } , <nl> + " bindings " : { <nl> + " version " : " 1 . 3 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / bindings / - / bindings - 1 . 3 . 0 . tgz " , <nl> + " integrity " : " sha512 - DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE + YvXyfd6mtCeRnrUfOLYiTMlNSw = = " , <nl> + " dev " : true , <nl> + " optional " : true <nl> + } , <nl> + " bluebird " : { <nl> + " version " : " 3 . 5 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / bluebird / - / bluebird - 3 . 5 . 1 . tgz " , <nl> + " integrity " : " sha512 - MKiLiV + I1AA596t9w1sQJ8jkiSr5 + ZKi0WKrYGUn6d1Fx + Ij4tIj + m2WMQSGczs5jZVxV339chE8iwk6F64wjA = = " , <nl> + " dev " : true <nl> + } , <nl> + " brace - expansion " : { <nl> + " version " : " 1 . 1 . 11 " , <nl> + " resolved " : " https : / / registry . npmjs . org / brace - expansion / - / brace - expansion - 1 . 1 . 11 . tgz " , <nl> + " integrity " : " sha512 - iCuPHDFgrHX7H2vEI / 5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " balanced - match " : " 1 . 0 . 0 " , <nl> + " concat - map " : " 0 . 0 . 1 " <nl> + } <nl> + } , <nl> + " browser - stdout " : { <nl> + " version " : " 1 . 3 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / browser - stdout / - / browser - stdout - 1 . 3 . 0 . tgz " , <nl> + " integrity " : " sha1 - 81HTKWnTL6XXpVZxVCY9korjvR8 = " , <nl> + " dev " : true <nl> + } , <nl> + " builtin - modules " : { <nl> + " version " : " 1 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / builtin - modules / - / builtin - modules - 1 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - Jw8HbFpywC9bZaR9 + Uxf46J4iS8 = " , <nl> + " dev " : true <nl> + } , <nl> + " camelcase " : { <nl> + " version " : " 3 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / camelcase / - / camelcase - 3 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - MvxLn82vhF / N9 + c7uXysImHwqwo = " , <nl> + " dev " : true <nl> + } , <nl> + " chai " : { <nl> + " version " : " 4 . 1 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / chai / - / chai - 4 . 1 . 2 . tgz " , <nl> + " integrity " : " sha1 - D2RYS6ZC8PKs4oBiefTwbKI61zw = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " assertion - error " : " 1 . 1 . 0 " , <nl> + " check - error " : " 1 . 0 . 2 " , <nl> + " deep - eql " : " 3 . 0 . 1 " , <nl> + " get - func - name " : " 2 . 0 . 0 " , <nl> + " pathval " : " 1 . 1 . 0 " , <nl> + " type - detect " : " 4 . 0 . 8 " <nl> + } <nl> + } , <nl> + " chai - as - promised " : { <nl> + " version " : " 7 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / chai - as - promised / - / chai - as - promised - 7 . 1 . 1 . tgz " , <nl> + " integrity " : " sha512 - azL6xMoi + uxu6z4rhWQ1jbdUhOMhis2PvscD / xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv / g57RXbiaA = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " check - error " : " 1 . 0 . 2 " <nl> + } <nl> + } , <nl> + " charenc " : { <nl> + " version " : " 0 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / charenc / - / charenc - 0 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - wKHS86cJLgN3S / qD8UwPxXkKhmc = " , <nl> + " dev " : true <nl> + } , <nl> + " check - error " : { <nl> + " version " : " 1 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / check - error / - / check - error - 1 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - V00xLt2Iu13YkS6Sht1sCu1KrII = " , <nl> + " dev " : true <nl> + } , <nl> + " cliui " : { <nl> + " version " : " 3 . 2 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / cliui / - / cliui - 3 . 2 . 0 . tgz " , <nl> + " integrity " : " sha1 - EgYBU3qRbSmUD5NNo7SNWFo5IT0 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " string - width " : " 1 . 0 . 2 " , <nl> + " strip - ansi " : " 3 . 0 . 1 " , <nl> + " wrap - ansi " : " 2 . 1 . 0 " <nl> + } , <nl> + " dependencies " : { <nl> + " ansi - regex " : { <nl> + " version " : " 2 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / ansi - regex / - / ansi - regex - 2 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - w7M6te42DYbg5ijwRorn7yfWVN8 = " , <nl> + " dev " : true <nl> + } , <nl> + " strip - ansi " : { <nl> + " version " : " 3 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / strip - ansi / - / strip - ansi - 3 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - ajhfuIU9lS1f8F0Oiq + UJ43GPc8 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " ansi - regex " : " 2 . 1 . 1 " <nl> + } <nl> + } <nl> + } <nl> + } , <nl> + " code - point - at " : { <nl> + " version " : " 1 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / code - point - at / - / code - point - at - 1 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - DQcLTQQ6W + ozovGkDi7bPZpMz3c = " , <nl> + " dev " : true <nl> + } , <nl> + " coffee - script " : { <nl> + " version " : " 1 . 12 . 7 " , <nl> + " resolved " : " https : / / registry . npmjs . org / coffee - script / - / coffee - script - 1 . 12 . 7 . tgz " , <nl> + " integrity " : " sha512 - fLeEhqwymYat / MpTPUjSKHVYYl0ec2mOyALEMLmzr5i1isuG + 6jfI2j2d5oBO3VIzgUXgBVIcOT9uH1TFxBckw = = " , <nl> + " dev " : true <nl> + } , <nl> + " commander " : { <nl> + " version " : " 2 . 9 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / commander / - / commander - 2 . 9 . 0 . tgz " , <nl> + " integrity " : " sha1 - nJkJQXbhIkDLItbFFGCYQA / g99Q = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " graceful - readlink " : " 1 . 0 . 1 " <nl> + } <nl> + } , <nl> + " concat - map " : { <nl> + " version " : " 0 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / concat - map / - / concat - map - 0 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - 2Klr13 / Wjfd5OnMDajug1UBdR3s = " , <nl> + " dev " : true <nl> + } , <nl> + " crypt " : { <nl> + " version " : " 0 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / crypt / - / crypt - 0 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - iNf / fsDfuG9xPch7u0LQRNPmxBs = " , <nl> + " dev " : true <nl> + } , <nl> + " dbus - native " : { <nl> + " version " : " 0 . 2 . 5 " , <nl> + " resolved " : " https : / / registry . npmjs . org / dbus - native / - / dbus - native - 0 . 2 . 5 . tgz " , <nl> + " integrity " : " sha512 - ocxMKCV7QdiNhzhFSeEMhj258OGtvpANSb3oWGiotmI5h1ZIse0TMPcSLiXSpqvbYvQz2Y5RsYPMNYLWhg9eBw = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " abstract - socket " : " 2 . 0 . 0 " , <nl> + " event - stream " : " 3 . 3 . 4 " , <nl> + " hexy " : " 0 . 2 . 11 " , <nl> + " long " : " 3 . 2 . 0 " , <nl> + " optimist " : " 0 . 6 . 1 " , <nl> + " put " : " 0 . 0 . 6 " , <nl> + " safe - buffer " : " 5 . 1 . 2 " , <nl> + " xml2js " : " 0 . 1 . 14 " <nl> + } <nl> + } , <nl> + " debug " : { <nl> + " version " : " 2 . 6 . 8 " , <nl> + " resolved " : " https : / / registry . npmjs . org / debug / - / debug - 2 . 6 . 8 . tgz " , <nl> + " integrity " : " sha1 - 5zFTHKLt4n0YgiJCfaF4IdaP9Pw = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " ms " : " 2 . 0 . 0 " <nl> + } <nl> + } , <nl> + " decamelize " : { <nl> + " version " : " 1 . 2 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / decamelize / - / decamelize - 1 . 2 . 0 . tgz " , <nl> + " integrity " : " sha1 - 9lNNFRSCabIDUue + 4m9QH5oZEpA = " , <nl> + " dev " : true <nl> + } , <nl> + " deep - eql " : { <nl> + " version " : " 3 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / deep - eql / - / deep - eql - 3 . 0 . 1 . tgz " , <nl> + " integrity " : " sha512 - + QeIQyN5ZuO + 3Uk5DYh6 / 1eKO0m0YmJFGNmFHGACpf1ClL1nmlV / p4gNgbl2pJGxgXb4faqo6UE + M5ACEMyVcw = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " type - detect " : " 4 . 0 . 8 " <nl> + } <nl> + } , <nl> + " depd " : { <nl> + " version " : " 1 . 1 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / depd / - / depd - 1 . 1 . 2 . tgz " , <nl> + " integrity " : " sha1 - m81S4UwJd2PnSbJ0xDRu0uVgtak = " , <nl> + " dev " : true <nl> + } , <nl> + " destroy " : { <nl> + " version " : " 1 . 0 . 4 " , <nl> + " resolved " : " https : / / registry . npmjs . org / destroy / - / destroy - 1 . 0 . 4 . tgz " , <nl> + " integrity " : " sha1 - l4hXRCxEdJ5CBmE + N5RiBYJqvYA = " , <nl> + " dev " : true <nl> + } , <nl> + " diff " : { <nl> + " version " : " 3 . 2 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / diff / - / diff - 3 . 2 . 0 . tgz " , <nl> + " integrity " : " sha1 - yc45Okt8vQsFinJck98pkCeGj / k = " , <nl> + " dev " : true <nl> + } , <nl> + " duplexer " : { <nl> + " version " : " 0 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / duplexer / - / duplexer - 0 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - rOb / gIwc5mtX0ev5eXessCM0z8E = " , <nl> + " dev " : true <nl> + } , <nl> + " ee - first " : { <nl> + " version " : " 1 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / ee - first / - / ee - first - 1 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - WQxhFWsK4vTwJVcyoViyZrxWsh0 = " , <nl> + " dev " : true <nl> + } , <nl> + " encodeurl " : { <nl> + " version " : " 1 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / encodeurl / - / encodeurl - 1 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - rT / 0yG7C0CkyL1oCw6mmBslbP1k = " , <nl> + " dev " : true <nl> + } , <nl> + " error - ex " : { <nl> + " version " : " 1 . 3 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / error - ex / - / error - ex - 1 . 3 . 1 . tgz " , <nl> + " integrity " : " sha1 - + FWobOYa3E6GIcPNoh56dhLDqNw = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " is - arrayish " : " 0 . 2 . 1 " <nl> + } <nl> + } , <nl> + " escape - html " : { <nl> + " version " : " 1 . 0 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / escape - html / - / escape - html - 1 . 0 . 3 . tgz " , <nl> + " integrity " : " sha1 - Aljq5NPQwJdN4cFpGI7wBR0dGYg = " , <nl> + " dev " : true <nl> + } , <nl> + " escape - string - regexp " : { <nl> + " version " : " 1 . 0 . 5 " , <nl> + " resolved " : " https : / / registry . npmjs . org / escape - string - regexp / - / escape - string - regexp - 1 . 0 . 5 . tgz " , <nl> + " integrity " : " sha1 - G2HAViGQqN / 2rjuyzwIAyhMLhtQ = " , <nl> + " dev " : true <nl> + } , <nl> + " etag " : { <nl> + " version " : " 1 . 8 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / etag / - / etag - 1 . 8 . 1 . tgz " , <nl> + " integrity " : " sha1 - Qa4u62XvpiJorr / qg6x9eSmbCIc = " , <nl> + " dev " : true <nl> + } , <nl> + " event - stream " : { <nl> + " version " : " 3 . 3 . 4 " , <nl> + " resolved " : " http : / / registry . npmjs . org / event - stream / - / event - stream - 3 . 3 . 4 . tgz " , <nl> + " integrity " : " sha1 - SrTJoPWlTbkzi0w02Gv86PSzVXE = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " duplexer " : " 0 . 1 . 1 " , <nl> + " from " : " 0 . 1 . 7 " , <nl> + " map - stream " : " 0 . 1 . 0 " , <nl> + " pause - stream " : " 0 . 0 . 11 " , <nl> + " split " : " 0 . 3 . 3 " , <nl> + " stream - combiner " : " 0 . 0 . 4 " , <nl> + " through " : " 2 . 3 . 8 " <nl> + } <nl> + } , <nl> + " fd - slicer " : { <nl> + " version " : " 1 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / fd - slicer / - / fd - slicer - 1 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - i1vL2ewyfFBBv5qwI / 1nUPEXfmU = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " pend " : " 1 . 2 . 0 " <nl> + } <nl> + } , <nl> + " find - up " : { <nl> + " version " : " 1 . 1 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / find - up / - / find - up - 1 . 1 . 2 . tgz " , <nl> + " integrity " : " sha1 - ay6YIrGizgpgq2TWEOzK1TyyTQ8 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " path - exists " : " 2 . 1 . 0 " , <nl> + " pinkie - promise " : " 2 . 0 . 1 " <nl> + } <nl> + } , <nl> + " fresh " : { <nl> + " version " : " 0 . 5 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / fresh / - / fresh - 0 . 5 . 2 . tgz " , <nl> + " integrity " : " sha1 - PYyt2Q2XZWn6g1qx + OSyOhBWBac = " , <nl> + " dev " : true <nl> + } , <nl> + " from " : { <nl> + " version " : " 0 . 1 . 7 " , <nl> + " resolved " : " https : / / registry . npmjs . org / from / - / from - 0 . 1 . 7 . tgz " , <nl> + " integrity " : " sha1 - g8YK / Fi5xWmXAH7Rp2izqzA6RP4 = " , <nl> + " dev " : true <nl> + } , <nl> + " fs . realpath " : { <nl> + " version " : " 1 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / fs . realpath / - / fs . realpath - 1 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - FQStJSMVjKpA20onh8sBQRmU6k8 = " , <nl> + " dev " : true <nl> + } , <nl> + " get - caller - file " : { <nl> + " version " : " 1 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / get - caller - file / - / get - caller - file - 1 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - 9wLmMSfn4jHBYKgMFVSstw1QR + U = " , <nl> + " dev " : true <nl> + } , <nl> + " get - func - name " : { <nl> + " version " : " 2 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / get - func - name / - / get - func - name - 2 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - 6td0q + 5y4gQJQzoGY2YCPdaIekE = " , <nl> + " dev " : true <nl> + } , <nl> + " glob " : { <nl> + " version " : " 7 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / glob / - / glob - 7 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - gFIR3wT6rxxjo2ADBs31reULLsg = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " fs . realpath " : " 1 . 0 . 0 " , <nl> + " inflight " : " 1 . 0 . 6 " , <nl> + " inherits " : " 2 . 0 . 3 " , <nl> + " minimatch " : " 3 . 0 . 4 " , <nl> + " once " : " 1 . 4 . 0 " , <nl> + " path - is - absolute " : " 1 . 0 . 1 " <nl> + } <nl> + } , <nl> + " graceful - fs " : { <nl> + " version " : " 4 . 1 . 11 " , <nl> + " resolved " : " https : / / registry . npmjs . org / graceful - fs / - / graceful - fs - 4 . 1 . 11 . tgz " , <nl> + " integrity " : " sha1 - Dovf5NHduIVNZOBOp8AOKgJuVlg = " , <nl> + " dev " : true <nl> + } , <nl> + " graceful - readlink " : { <nl> + " version " : " 1 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / graceful - readlink / - / graceful - readlink - 1 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - TK + tdrxi8C + gObL5Tpo906ORpyU = " , <nl> + " dev " : true <nl> + } , <nl> + " growl " : { <nl> + " version " : " 1 . 9 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / growl / - / growl - 1 . 9 . 2 . tgz " , <nl> + " integrity " : " sha1 - Dqd0NxXbjY3ixe3hd14bRayFwC8 = " , <nl> + " dev " : true <nl> + } , <nl> + " has - flag " : { <nl> + " version " : " 1 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / has - flag / - / has - flag - 1 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - nZ55MWXOAXoA8AQYxD + UKnsdEfo = " , <nl> + " dev " : true <nl> + } , <nl> + " he " : { <nl> + " version " : " 1 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / he / - / he - 1 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - k0EP0hsAlzUVH4howvJx80J + I / 0 = " , <nl> + " dev " : true <nl> + } , <nl> + " hexy " : { <nl> + " version " : " 0 . 2 . 11 " , <nl> + " resolved " : " https : / / registry . npmjs . org / hexy / - / hexy - 0 . 2 . 11 . tgz " , <nl> + " integrity " : " sha512 - ciq6hFsSG / Bpt2DmrZJtv + 56zpPdnq + NQ4ijEFrveKN0ZG1mhl / LdT1NQZ9se6ty1fACcI4d4vYqC9v8EYpH2A = = " , <nl> + " dev " : true <nl> + } , <nl> + " hosted - git - info " : { <nl> + " version " : " 2 . 6 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / hosted - git - info / - / hosted - git - info - 2 . 6 . 0 . tgz " , <nl> + " integrity " : " sha512 - lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB + FgA + C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw = = " , <nl> + " dev " : true <nl> + } , <nl> + " http - errors " : { <nl> + " version " : " 1 . 6 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / http - errors / - / http - errors - 1 . 6 . 3 . tgz " , <nl> + " integrity " : " sha1 - i1VoC7S + KDoLW / TqLjhYC + HZMg0 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " depd " : " 1 . 1 . 2 " , <nl> + " inherits " : " 2 . 0 . 3 " , <nl> + " setprototypeof " : " 1 . 1 . 0 " , <nl> + " statuses " : " 1 . 4 . 0 " <nl> + } <nl> + } , <nl> + " inflight " : { <nl> + " version " : " 1 . 0 . 6 " , <nl> + " resolved " : " https : / / registry . npmjs . org / inflight / - / inflight - 1 . 0 . 6 . tgz " , <nl> + " integrity " : " sha1 - Sb1jMdfQLQwJvJEKEHW6gWW1bfk = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " once " : " 1 . 4 . 0 " , <nl> + " wrappy " : " 1 . 0 . 2 " <nl> + } <nl> + } , <nl> + " inherits " : { <nl> + " version " : " 2 . 0 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / inherits / - / inherits - 2 . 0 . 3 . tgz " , <nl> + " integrity " : " sha1 - Yzwsg + PaQqUC9SRmAiSA9CCCYd4 = " , <nl> + " dev " : true <nl> + } , <nl> + " invert - kv " : { <nl> + " version " : " 1 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / invert - kv / - / invert - kv - 1 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - EEqOSqym09jNFXqO + L + rLXo / / bY = " , <nl> + " dev " : true <nl> + } , <nl> + " is - arrayish " : { <nl> + " version " : " 0 . 2 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / is - arrayish / - / is - arrayish - 0 . 2 . 1 . tgz " , <nl> + " integrity " : " sha1 - d8mYQFJ6qOyxqLppe4BkWnqSap0 = " , <nl> + " dev " : true <nl> + } , <nl> + " is - buffer " : { <nl> + " version " : " 1 . 1 . 6 " , <nl> + " resolved " : " https : / / registry . npmjs . org / is - buffer / - / is - buffer - 1 . 1 . 6 . tgz " , <nl> + " integrity " : " sha512 - NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5 / ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ + 9F3USqfHqTaU5w = = " , <nl> + " dev " : true <nl> + } , <nl> + " is - builtin - module " : { <nl> + " version " : " 1 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / is - builtin - module / - / is - builtin - module - 1 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - VAVy0096wxGfj3bDDLwbHgN6 / 74 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " builtin - modules " : " 1 . 1 . 1 " <nl> + } <nl> + } , <nl> + " is - fullwidth - code - point " : { <nl> + " version " : " 1 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / is - fullwidth - code - point / - / is - fullwidth - code - point - 1 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - 754xOG8DGn8NZDr4L95QxFfvAMs = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " number - is - nan " : " 1 . 0 . 1 " <nl> + } <nl> + } , <nl> + " is - utf8 " : { <nl> + " version " : " 0 . 2 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / is - utf8 / - / is - utf8 - 0 . 2 . 1 . tgz " , <nl> + " integrity " : " sha1 - Sw2hRCEE0bM2NA6AeX6GXPOffXI = " , <nl> + " dev " : true <nl> + } , <nl> + " json3 " : { <nl> + " version " : " 3 . 3 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / json3 / - / json3 - 3 . 3 . 2 . tgz " , <nl> + " integrity " : " sha1 - PAQ0dD35Pi9cQq7nsZvLSDV19OE = " , <nl> + " dev " : true <nl> + } , <nl> + " lcid " : { <nl> + " version " : " 1 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lcid / - / lcid - 1 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - MIrMr6C8SDo4Z7S28rlQYlHRuDU = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " invert - kv " : " 1 . 0 . 0 " <nl> + } <nl> + } , <nl> + " load - json - file " : { <nl> + " version " : " 1 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / load - json - file / - / load - json - file - 1 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - lWkFcI1YtLq0wiYbBPWfMcmTdMA = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " graceful - fs " : " 4 . 1 . 11 " , <nl> + " parse - json " : " 2 . 2 . 0 " , <nl> + " pify " : " 2 . 3 . 0 " , <nl> + " pinkie - promise " : " 2 . 0 . 1 " , <nl> + " strip - bom " : " 2 . 0 . 0 " <nl> + } <nl> + } , <nl> + " lodash . _baseassign " : { <nl> + " version " : " 3 . 2 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . _baseassign / - / lodash . _baseassign - 3 . 2 . 0 . tgz " , <nl> + " integrity " : " sha1 - jDigmVAPIVrQnlnxci / QxSv + Ck4 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " lodash . _basecopy " : " 3 . 0 . 1 " , <nl> + " lodash . keys " : " 3 . 1 . 2 " <nl> + } <nl> + } , <nl> + " lodash . _basecopy " : { <nl> + " version " : " 3 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . _basecopy / - / lodash . _basecopy - 3 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - jaDmqHbPNEwK2KVIghEd08XHyjY = " , <nl> + " dev " : true <nl> + } , <nl> + " lodash . _basecreate " : { <nl> + " version " : " 3 . 0 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . _basecreate / - / lodash . _basecreate - 3 . 0 . 3 . tgz " , <nl> + " integrity " : " sha1 - G8ZhYU2qf8MRt9A78WgGoCE8 + CE = " , <nl> + " dev " : true <nl> + } , <nl> + " lodash . _getnative " : { <nl> + " version " : " 3 . 9 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . _getnative / - / lodash . _getnative - 3 . 9 . 1 . tgz " , <nl> + " integrity " : " sha1 - VwvH3t5G1hzc3mh9ZdPuy6o6r / U = " , <nl> + " dev " : true <nl> + } , <nl> + " lodash . _isiterateecall " : { <nl> + " version " : " 3 . 0 . 9 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . _isiterateecall / - / lodash . _isiterateecall - 3 . 0 . 9 . tgz " , <nl> + " integrity " : " sha1 - UgOte6Ql + uhCRg5pbbnPPmqsBXw = " , <nl> + " dev " : true <nl> + } , <nl> + " lodash . create " : { <nl> + " version " : " 3 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . create / - / lodash . create - 3 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - 1 / KEnw29p + BGgruM1yqwIkYd6 + c = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " lodash . _baseassign " : " 3 . 2 . 0 " , <nl> + " lodash . _basecreate " : " 3 . 0 . 3 " , <nl> + " lodash . _isiterateecall " : " 3 . 0 . 9 " <nl> + } <nl> + } , <nl> + " lodash . isarguments " : { <nl> + " version " : " 3 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . isarguments / - / lodash . isarguments - 3 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - L1c9hcaiQon / AGY7SRwdM4 / zRYo = " , <nl> + " dev " : true <nl> + } , <nl> + " lodash . isarray " : { <nl> + " version " : " 3 . 0 . 4 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . isarray / - / lodash . isarray - 3 . 0 . 4 . tgz " , <nl> + " integrity " : " sha1 - eeTriMNqgSKvhvhEqpvNhRtfu1U = " , <nl> + " dev " : true <nl> + } , <nl> + " lodash . keys " : { <nl> + " version " : " 3 . 1 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / lodash . keys / - / lodash . keys - 3 . 1 . 2 . tgz " , <nl> + " integrity " : " sha1 - TbwEcrFWvlCgsoaFXRvQsMZWCYo = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " lodash . _getnative " : " 3 . 9 . 1 " , <nl> + " lodash . isarguments " : " 3 . 1 . 0 " , <nl> + " lodash . isarray " : " 3 . 0 . 4 " <nl> + } <nl> + } , <nl> + " long " : { <nl> + " version " : " 3 . 2 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / long / - / long - 3 . 2 . 0 . tgz " , <nl> + " integrity " : " sha1 - 2CG3E4yhy1gcFymQ7xTbIAtcR0s = " , <nl> + " dev " : true <nl> + } , <nl> + " map - stream " : { <nl> + " version " : " 0 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / map - stream / - / map - stream - 0 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - 5WqpTEyAVaFkBKBnS3jyFffI4ZQ = " , <nl> + " dev " : true <nl> + } , <nl> + " md5 " : { <nl> + " version " : " 2 . 2 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / md5 / - / md5 - 2 . 2 . 1 . tgz " , <nl> + " integrity " : " sha1 - U6s41f48iJG6RlMp6iP6wFQBJvk = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " charenc " : " 0 . 0 . 2 " , <nl> + " crypt " : " 0 . 0 . 2 " , <nl> + " is - buffer " : " 1 . 1 . 6 " <nl> + } <nl> + } , <nl> + " mime " : { <nl> + " version " : " 1 . 4 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / mime / - / mime - 1 . 4 . 1 . tgz " , <nl> + " integrity " : " sha512 - KI1 + qOZu5DcW6wayYHSzR / tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc + 9FiKmWUgeNLg7W3uIQvxtQ = = " , <nl> + " dev " : true <nl> + } , <nl> + " minimatch " : { <nl> + " version " : " 3 . 0 . 4 " , <nl> + " resolved " : " https : / / registry . npmjs . org / minimatch / - / minimatch - 3 . 0 . 4 . tgz " , <nl> + " integrity " : " sha512 - yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ + yDrR0HRot + yOCdCO7u4hX3pWft6kWBBcqh0UA = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " brace - expansion " : " 1 . 1 . 11 " <nl> + } <nl> + } , <nl> + " minimist " : { <nl> + " version " : " 0 . 0 . 10 " , <nl> + " resolved " : " https : / / registry . npmjs . org / minimist / - / minimist - 0 . 0 . 10 . tgz " , <nl> + " integrity " : " sha1 - 3j + YVD2 / lggr5IrRoMfNqDYwHc8 = " , <nl> + " dev " : true <nl> + } , <nl> + " mkdirp " : { <nl> + " version " : " 0 . 5 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / mkdirp / - / mkdirp - 0 . 5 . 1 . tgz " , <nl> + " integrity " : " sha1 - MAV0OOrGz3 + MR2fzhkjWaX11yQM = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " minimist " : " 0 . 0 . 8 " <nl> + } , <nl> + " dependencies " : { <nl> + " minimist " : { <nl> + " version " : " 0 . 0 . 8 " , <nl> + " resolved " : " https : / / registry . npmjs . org / minimist / - / minimist - 0 . 0 . 8 . tgz " , <nl> + " integrity " : " sha1 - hX / Kv8M5fSYluCKCYuhqp6ARsF0 = " , <nl> + " dev " : true <nl> + } <nl> + } <nl> + } , <nl> + " mocha " : { <nl> + " version " : " 3 . 5 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / mocha / - / mocha - 3 . 5 . 3 . tgz " , <nl> + " integrity " : " sha512 - / 6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb + fk2qmQ3iqsi258l / Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " browser - stdout " : " 1 . 3 . 0 " , <nl> + " commander " : " 2 . 9 . 0 " , <nl> + " debug " : " 2 . 6 . 8 " , <nl> + " diff " : " 3 . 2 . 0 " , <nl> + " escape - string - regexp " : " 1 . 0 . 5 " , <nl> + " glob " : " 7 . 1 . 1 " , <nl> + " growl " : " 1 . 9 . 2 " , <nl> + " he " : " 1 . 1 . 1 " , <nl> + " json3 " : " 3 . 3 . 2 " , <nl> + " lodash . create " : " 3 . 1 . 1 " , <nl> + " mkdirp " : " 0 . 5 . 1 " , <nl> + " supports - color " : " 3 . 1 . 2 " <nl> + } <nl> + } , <nl> + " mocha - junit - reporter " : { <nl> + " version " : " 1 . 17 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / mocha - junit - reporter / - / mocha - junit - reporter - 1 . 17 . 0 . tgz " , <nl> + " integrity " : " sha1 - LlFJ7UD8XS48px5C21qx / snG2Fw = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " debug " : " 2 . 6 . 8 " , <nl> + " md5 " : " 2 . 2 . 1 " , <nl> + " mkdirp " : " 0 . 5 . 1 " , <nl> + " strip - ansi " : " 4 . 0 . 0 " , <nl> + " xml " : " 1 . 0 . 1 " <nl> + } <nl> + } , <nl> + " ms " : { <nl> + " version " : " 2 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / ms / - / ms - 2 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - VgiurfwAvmwpAd9fmGF4jeDVl8g = " , <nl> + " dev " : true <nl> + } , <nl> + " multiparty " : { <nl> + " version " : " 4 . 1 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / multiparty / - / multiparty - 4 . 1 . 3 . tgz " , <nl> + " integrity " : " sha1 - PEPH / LGJbhdGBDap3Qtu8WaOT5Q = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " fd - slicer " : " 1 . 0 . 1 " <nl> + } <nl> + } , <nl> + " nan " : { <nl> + " version " : " 2 . 10 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / nan / - / nan - 2 . 10 . 0 . tgz " , <nl> + " integrity " : " sha512 - bAdJv7fBLhWC + / Bls0Oza + mvTaNQtP + 1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD / eScyA = = " , <nl> + " optional " : true <nl> + } , <nl> + " normalize - package - data " : { <nl> + " version " : " 2 . 4 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / normalize - package - data / - / normalize - package - data - 2 . 4 . 0 . tgz " , <nl> + " integrity " : " sha512 - 9jjUFbTPfEy3R / ad / 2oNbKtW9Hgovl5O1FvFWKkKblNXoN / Oou6 + 9 + KKohPK13Yc3 / TyunyWhJp6gvRNR / PPAw = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " hosted - git - info " : " 2 . 6 . 0 " , <nl> + " is - builtin - module " : " 1 . 0 . 0 " , <nl> + " semver " : " 5 . 5 . 0 " , <nl> + " validate - npm - package - license " : " 3 . 0 . 3 " <nl> + } <nl> + } , <nl> + " number - is - nan " : { <nl> + " version " : " 1 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / number - is - nan / - / number - is - nan - 1 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - CXtgK1NCKlIsGvuHkDGDNpQaAR0 = " , <nl> + " dev " : true <nl> + } , <nl> + " on - finished " : { <nl> + " version " : " 2 . 3 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / on - finished / - / on - finished - 2 . 3 . 0 . tgz " , <nl> + " integrity " : " sha1 - IPEzZIGwg811M3mSoWlxqi2QaUc = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " ee - first " : " 1 . 1 . 1 " <nl> + } <nl> + } , <nl> + " once " : { <nl> + " version " : " 1 . 4 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / once / - / once - 1 . 4 . 0 . tgz " , <nl> + " integrity " : " sha1 - WDsap3WWHUsROsF9nFC6753Xa9E = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " wrappy " : " 1 . 0 . 2 " <nl> + } <nl> + } , <nl> + " optimist " : { <nl> + " version " : " 0 . 6 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / optimist / - / optimist - 0 . 6 . 1 . tgz " , <nl> + " integrity " : " sha1 - 2j6nRob6IaGaERwybpDrFaAZZoY = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " minimist " : " 0 . 0 . 10 " , <nl> + " wordwrap " : " 0 . 0 . 3 " <nl> + } <nl> + } , <nl> + " options " : { <nl> + " version " : " 0 . 0 . 6 " , <nl> + " resolved " : " https : / / registry . npmjs . org / options / - / options - 0 . 0 . 6 . tgz " , <nl> + " integrity " : " sha1 - 7CLTEoBrtT5zF3Pnza788cZDEo8 = " , <nl> + " dev " : true <nl> + } , <nl> + " os - locale " : { <nl> + " version " : " 1 . 4 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / os - locale / - / os - locale - 1 . 4 . 0 . tgz " , <nl> + " integrity " : " sha1 - IPnxeuKe00XoveWDsT0gCYA8FNk = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " lcid " : " 1 . 0 . 0 " <nl> + } <nl> + } , <nl> + " os - tmpdir " : { <nl> + " version " : " 1 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / os - tmpdir / - / os - tmpdir - 1 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - u + Z0BseaqFxc / sdm / lc0VV36EnQ = " , <nl> + " dev " : true <nl> + } , <nl> + " parse - json " : { <nl> + " version " : " 2 . 2 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / parse - json / - / parse - json - 2 . 2 . 0 . tgz " , <nl> + " integrity " : " sha1 - 9ID0BDTvgHQfhGkJn43qGPVaTck = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " error - ex " : " 1 . 3 . 1 " <nl> + } <nl> + } , <nl> + " path - exists " : { <nl> + " version " : " 2 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / path - exists / - / path - exists - 2 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - D + tsZPD8UY2adU3V77YscCJ2H0s = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " pinkie - promise " : " 2 . 0 . 1 " <nl> + } <nl> + } , <nl> + " path - is - absolute " : { <nl> + " version " : " 1 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / path - is - absolute / - / path - is - absolute - 1 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - F0uSaHNVNP + 8es5r9TpanhtcX18 = " , <nl> + " dev " : true <nl> + } , <nl> + " path - type " : { <nl> + " version " : " 1 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / path - type / - / path - type - 1 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - WcRPfuSR2nBNpBXaWkBwuk + P5EE = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " graceful - fs " : " 4 . 1 . 11 " , <nl> + " pify " : " 2 . 3 . 0 " , <nl> + " pinkie - promise " : " 2 . 0 . 1 " <nl> + } <nl> + } , <nl> + " pathval " : { <nl> + " version " : " 1 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / pathval / - / pathval - 1 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - uULm1L3mUwBe9rcTYd74cn0GReA = " , <nl> + " dev " : true <nl> + } , <nl> + " pause - stream " : { <nl> + " version " : " 0 . 0 . 11 " , <nl> + " resolved " : " https : / / registry . npmjs . org / pause - stream / - / pause - stream - 0 . 0 . 11 . tgz " , <nl> + " integrity " : " sha1 - / lo0sMvOErWqaitAPuLnO2AvFEU = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " through " : " 2 . 3 . 8 " <nl> + } <nl> + } , <nl> + " pend " : { <nl> + " version " : " 1 . 2 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / pend / - / pend - 1 . 2 . 0 . tgz " , <nl> + " integrity " : " sha1 - elfrVQpng / kRUzH89GY9XI4AelA = " , <nl> + " dev " : true <nl> + } , <nl> + " pify " : { <nl> + " version " : " 2 . 3 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / pify / - / pify - 2 . 3 . 0 . tgz " , <nl> + " integrity " : " sha1 - 7RQaasBDqEnqWISY59yosVMw6Qw = " , <nl> + " dev " : true <nl> + } , <nl> + " pinkie " : { <nl> + " version " : " 2 . 0 . 4 " , <nl> + " resolved " : " https : / / registry . npmjs . org / pinkie / - / pinkie - 2 . 0 . 4 . tgz " , <nl> + " integrity " : " sha1 - clVrgM + g1IqXToDnckjoDtT3 + HA = " , <nl> + " dev " : true <nl> + } , <nl> + " pinkie - promise " : { <nl> + " version " : " 2 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / pinkie - promise / - / pinkie - promise - 2 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - ITXW36ejWMBprJsXh3YogihFD / o = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " pinkie " : " 2 . 0 . 4 " <nl> + } <nl> + } , <nl> + " put " : { <nl> + " version " : " 0 . 0 . 6 " , <nl> + " resolved " : " https : / / registry . npmjs . org / put / - / put - 0 . 0 . 6 . tgz " , <nl> + " integrity " : " sha1 - MPX2C9bkOJvTKeFqJThsuy5KAKM = " , <nl> + " dev " : true <nl> + } , <nl> + " q " : { <nl> + " version " : " 1 . 5 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / q / - / q - 1 . 5 . 1 . tgz " , <nl> + " integrity " : " sha1 - fjL3W0E4EpHQRhHxvxQQmsAGUdc = " , <nl> + " dev " : true <nl> + } , <nl> + " range - parser " : { <nl> + " version " : " 1 . 2 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / range - parser / - / range - parser - 1 . 2 . 0 . tgz " , <nl> + " integrity " : " sha1 - 9JvmtIeJTdxA3MlKMi9hEJLgDV4 = " , <nl> + " dev " : true <nl> + } , <nl> + " read - pkg " : { <nl> + " version " : " 1 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / read - pkg / - / read - pkg - 1 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - 9f + qXs0pyzHAR0vKfXVra7KePyg = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " load - json - file " : " 1 . 1 . 0 " , <nl> + " normalize - package - data " : " 2 . 4 . 0 " , <nl> + " path - type " : " 1 . 1 . 0 " <nl> + } <nl> + } , <nl> + " read - pkg - up " : { <nl> + " version " : " 1 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / read - pkg - up / - / read - pkg - up - 1 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - nWPBMnbAZZGNV / ACpX9AobZD + wI = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " find - up " : " 1 . 1 . 2 " , <nl> + " read - pkg " : " 1 . 1 . 0 " <nl> + } <nl> + } , <nl> + " require - directory " : { <nl> + " version " : " 2 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / require - directory / - / require - directory - 2 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - jGStX9MNqxyXbiNE / + f3kqam30I = " , <nl> + " dev " : true <nl> + } , <nl> + " require - main - filename " : { <nl> + " version " : " 1 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / require - main - filename / - / require - main - filename - 1 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - l / cXtp1IeE9fUmpsWqj / 3aBVpNE = " , <nl> + " dev " : true <nl> + } , <nl> + " rimraf " : { <nl> + " version " : " 2 . 2 . 8 " , <nl> + " resolved " : " https : / / registry . npmjs . org / rimraf / - / rimraf - 2 . 2 . 8 . tgz " , <nl> + " integrity " : " sha1 - 5Dm + Kq7jJzIZUnMPmaiSnk / FBYI = " , <nl> + " dev " : true <nl> + } , <nl> + " runas " : { <nl> + " version " : " 3 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / runas / - / runas - 3 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - Ut1TjbDkF0U5lTWjRwkbpFzA6rA = " , <nl> + " optional " : true , <nl> + " requires " : { <nl> + " nan " : " 2 . 10 . 0 " <nl> + } <nl> + } , <nl> + " safe - buffer " : { <nl> + " version " : " 5 . 1 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / safe - buffer / - / safe - buffer - 5 . 1 . 2 . tgz " , <nl> + " integrity " : " sha512 - Gd2UZBJDkXlY7GbJxfsE8 / nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud / wPtojys4G6 + g = = " , <nl> + " dev " : true <nl> + } , <nl> + " sax " : { <nl> + " version " : " 1 . 2 . 4 " , <nl> + " resolved " : " https : / / registry . npmjs . org / sax / - / sax - 1 . 2 . 4 . tgz " , <nl> + " integrity " : " sha512 - NqVDv9TpANUjFm0N8uM5GxL36UgKi9 / atZw + x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw = = " , <nl> + " dev " : true <nl> + } , <nl> + " semver " : { <nl> + " version " : " 5 . 5 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / semver / - / semver - 5 . 5 . 0 . tgz " , <nl> + " integrity " : " sha512 - 4SJ3dm0WAwWy / NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr + ZinwZAH4xIA = = " , <nl> + " dev " : true <nl> + } , <nl> + " send " : { <nl> + " version " : " 0 . 16 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / send / - / send - 0 . 16 . 2 . tgz " , <nl> + " integrity " : " sha512 - E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " debug " : " 2 . 6 . 9 " , <nl> + " depd " : " 1 . 1 . 2 " , <nl> + " destroy " : " 1 . 0 . 4 " , <nl> + " encodeurl " : " 1 . 0 . 2 " , <nl> + " escape - html " : " 1 . 0 . 3 " , <nl> + " etag " : " 1 . 8 . 1 " , <nl> + " fresh " : " 0 . 5 . 2 " , <nl> + " http - errors " : " 1 . 6 . 3 " , <nl> + " mime " : " 1 . 4 . 1 " , <nl> + " ms " : " 2 . 0 . 0 " , <nl> + " on - finished " : " 2 . 3 . 0 " , <nl> + " range - parser " : " 1 . 2 . 0 " , <nl> + " statuses " : " 1 . 4 . 0 " <nl> + } , <nl> + " dependencies " : { <nl> + " debug " : { <nl> + " version " : " 2 . 6 . 9 " , <nl> + " resolved " : " https : / / registry . npmjs . org / debug / - / debug - 2 . 6 . 9 . tgz " , <nl> + " integrity " : " sha512 - bC7ElrdJaJnPbAP + 1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm / E7AdgFBVeAPVMNcKGsHMA = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " ms " : " 2 . 0 . 0 " <nl> + } <nl> + } <nl> + } <nl> + } , <nl> + " set - blocking " : { <nl> + " version " : " 2 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / set - blocking / - / set - blocking - 2 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - BF + XgtARrppoA93TgrJDkrPYkPc = " , <nl> + " dev " : true <nl> + } , <nl> + " setprototypeof " : { <nl> + " version " : " 1 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / setprototypeof / - / setprototypeof - 1 . 1 . 0 . tgz " , <nl> + " integrity " : " sha512 - BvE / TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS / cBBzwBcNDWoFxt2XEFIpQ = = " , <nl> + " dev " : true <nl> + } , <nl> + " spdx - correct " : { <nl> + " version " : " 3 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / spdx - correct / - / spdx - correct - 3 . 0 . 0 . tgz " , <nl> + " integrity " : " sha512 - N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL / fxS2pBo2jbfcFRVuFZ / oFC + vZz0MNNk0h80iMn5 / S6qGZOL5 + g = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " spdx - expression - parse " : " 3 . 0 . 0 " , <nl> + " spdx - license - ids " : " 3 . 0 . 0 " <nl> + } <nl> + } , <nl> + " spdx - exceptions " : { <nl> + " version " : " 2 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / spdx - exceptions / - / spdx - exceptions - 2 . 1 . 0 . tgz " , <nl> + " integrity " : " sha512 - 4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs / gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg = = " , <nl> + " dev " : true <nl> + } , <nl> + " spdx - expression - parse " : { <nl> + " version " : " 3 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / spdx - expression - parse / - / spdx - expression - parse - 3 . 0 . 0 . tgz " , <nl> + " integrity " : " sha512 - Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h / 0sO6neh2jqRDVHOQ4o / LMea0tgCkbMgea5ip / e + MkWyg = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " spdx - exceptions " : " 2 . 1 . 0 " , <nl> + " spdx - license - ids " : " 3 . 0 . 0 " <nl> + } <nl> + } , <nl> + " spdx - license - ids " : { <nl> + " version " : " 3 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / spdx - license - ids / - / spdx - license - ids - 3 . 0 . 0 . tgz " , <nl> + " integrity " : " sha512 - 2 + EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn + M / ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA = = " , <nl> + " dev " : true <nl> + } , <nl> + " split " : { <nl> + " version " : " 0 . 3 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / split / - / split - 0 . 3 . 3 . tgz " , <nl> + " integrity " : " sha1 - zQ7qXmOiEd / / frDwkcQTPi0N0o8 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " through " : " 2 . 3 . 8 " <nl> + } <nl> + } , <nl> + " statuses " : { <nl> + " version " : " 1 . 4 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / statuses / - / statuses - 1 . 4 . 0 . tgz " , <nl> + " integrity " : " sha512 - zhSCtt8v2NDrRlPQpCNtw / heZLtfUDqxBM1udqikb / Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew = = " , <nl> + " dev " : true <nl> + } , <nl> + " stream - combiner " : { <nl> + " version " : " 0 . 0 . 4 " , <nl> + " resolved " : " https : / / registry . npmjs . org / stream - combiner / - / stream - combiner - 0 . 0 . 4 . tgz " , <nl> + " integrity " : " sha1 - TV5DPBhSYd3mI8o / RMWGvPXErRQ = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " duplexer " : " 0 . 1 . 1 " <nl> + } <nl> + } , <nl> + " string - width " : { <nl> + " version " : " 1 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / string - width / - / string - width - 1 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - EYvfW4zcUaKn5w0hHgfisLmxB9M = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " code - point - at " : " 1 . 1 . 0 " , <nl> + " is - fullwidth - code - point " : " 1 . 0 . 0 " , <nl> + " strip - ansi " : " 3 . 0 . 1 " <nl> + } , <nl> + " dependencies " : { <nl> + " ansi - regex " : { <nl> + " version " : " 2 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / ansi - regex / - / ansi - regex - 2 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - w7M6te42DYbg5ijwRorn7yfWVN8 = " , <nl> + " dev " : true <nl> + } , <nl> + " strip - ansi " : { <nl> + " version " : " 3 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / strip - ansi / - / strip - ansi - 3 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - ajhfuIU9lS1f8F0Oiq + UJ43GPc8 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " ansi - regex " : " 2 . 1 . 1 " <nl> + } <nl> + } <nl> + } <nl> + } , <nl> + " strip - ansi " : { <nl> + " version " : " 4 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / strip - ansi / - / strip - ansi - 4 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - qEeQIusaw2iocTibY1JixQXuNo8 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " ansi - regex " : " 3 . 0 . 0 " <nl> + } <nl> + } , <nl> + " strip - bom " : { <nl> + " version " : " 2 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / strip - bom / - / strip - bom - 2 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - YhmoVhZSBJHzV4i9vxRHqZx + aw4 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " is - utf8 " : " 0 . 2 . 1 " <nl> + } <nl> + } , <nl> + " supports - color " : { <nl> + " version " : " 3 . 1 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / supports - color / - / supports - color - 3 . 1 . 2 . tgz " , <nl> + " integrity " : " sha1 - cqJiiU2dQIuVbKBf83su2KbiotU = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " has - flag " : " 1 . 0 . 0 " <nl> + } <nl> + } , <nl> + " temp " : { <nl> + " version " : " 0 . 8 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / temp / - / temp - 0 . 8 . 3 . tgz " , <nl> + " integrity " : " sha1 - 4Ma8TSa5AxJEEOT + 2BEDAU38H1k = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " os - tmpdir " : " 1 . 0 . 2 " , <nl> + " rimraf " : " 2 . 2 . 8 " <nl> + } <nl> + } , <nl> + " through " : { <nl> + " version " : " 2 . 3 . 8 " , <nl> + " resolved " : " https : / / registry . npmjs . org / through / - / through - 2 . 3 . 8 . tgz " , <nl> + " integrity " : " sha1 - DdTJ / 6q8NXlgsbckEV1 + Doai4fU = " , <nl> + " dev " : true <nl> + } , <nl> + " type - detect " : { <nl> + " version " : " 4 . 0 . 8 " , <nl> + " resolved " : " https : / / registry . npmjs . org / type - detect / - / type - detect - 4 . 0 . 8 . tgz " , <nl> + " integrity " : " sha512 - 0fr / mIH1dlO + x7TlcMy + bIDqKPsw / 70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5 / g = = " , <nl> + " dev " : true <nl> + } , <nl> + " ultron " : { <nl> + " version " : " 1 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / ultron / - / ultron - 1 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - rOEWq1V80Zc4ak6I9GhTeMiy5Po = " , <nl> + " dev " : true <nl> + } , <nl> + " validate - npm - package - license " : { <nl> + " version " : " 3 . 0 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / validate - npm - package - license / - / validate - npm - package - license - 3 . 0 . 3 . tgz " , <nl> + " integrity " : " sha512 - 63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm + 60qPs / KsZGzPNg6Smnc / oY16QTjF0g = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " spdx - correct " : " 3 . 0 . 0 " , <nl> + " spdx - expression - parse " : " 3 . 0 . 0 " <nl> + } <nl> + } , <nl> + " walkdir " : { <nl> + " version " : " 0 . 0 . 11 " , <nl> + " resolved " : " https : / / registry . npmjs . org / walkdir / - / walkdir - 0 . 0 . 11 . tgz " , <nl> + " integrity " : " sha1 - oW0CXrkxvQO1LzCMrtD0D86 + lTI = " , <nl> + " dev " : true <nl> + } , <nl> + " which - module " : { <nl> + " version " : " 1 . 0 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / which - module / - / which - module - 1 . 0 . 0 . tgz " , <nl> + " integrity " : " sha1 - u6Y8qGGUiZT / MHc2CJ47lgJsKk8 = " , <nl> + " dev " : true <nl> + } , <nl> + " winreg " : { <nl> + " version " : " 1 . 2 . 4 " , <nl> + " resolved " : " https : / / registry . npmjs . org / winreg / - / winreg - 1 . 2 . 4 . tgz " , <nl> + " integrity " : " sha1 - ugZWKbepJRMOFXeRCM9UCZDpjRs = " , <nl> + " dev " : true <nl> + } , <nl> + " wordwrap " : { <nl> + " version " : " 0 . 0 . 3 " , <nl> + " resolved " : " https : / / registry . npmjs . org / wordwrap / - / wordwrap - 0 . 0 . 3 . tgz " , <nl> + " integrity " : " sha1 - o9XabNXAvAAI03I0u68b7WMFkQc = " , <nl> + " dev " : true <nl> + } , <nl> + " wrap - ansi " : { <nl> + " version " : " 2 . 1 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / wrap - ansi / - / wrap - ansi - 2 . 1 . 0 . tgz " , <nl> + " integrity " : " sha1 - 2Pw9KE3QV5T + hJc8rs3Rz4JP3YU = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " string - width " : " 1 . 0 . 2 " , <nl> + " strip - ansi " : " 3 . 0 . 1 " <nl> + } , <nl> + " dependencies " : { <nl> + " ansi - regex " : { <nl> + " version " : " 2 . 1 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / ansi - regex / - / ansi - regex - 2 . 1 . 1 . tgz " , <nl> + " integrity " : " sha1 - w7M6te42DYbg5ijwRorn7yfWVN8 = " , <nl> + " dev " : true <nl> + } , <nl> + " strip - ansi " : { <nl> + " version " : " 3 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / strip - ansi / - / strip - ansi - 3 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - ajhfuIU9lS1f8F0Oiq + UJ43GPc8 = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " ansi - regex " : " 2 . 1 . 1 " <nl> + } <nl> + } <nl> + } <nl> + } , <nl> + " wrappy " : { <nl> + " version " : " 1 . 0 . 2 " , <nl> + " resolved " : " https : / / registry . npmjs . org / wrappy / - / wrappy - 1 . 0 . 2 . tgz " , <nl> + " integrity " : " sha1 - tSQ9jz7BqjXxNkYFvA0QNuMKtp8 = " , <nl> + " dev " : true <nl> + } , <nl> + " ws " : { <nl> + " version " : " 1 . 1 . 5 " , <nl> + " resolved " : " https : / / registry . npmjs . org / ws / - / ws - 1 . 1 . 5 . tgz " , <nl> + " integrity " : " sha512 - o3KqipXNUdS7wpQzBHSe180lBGO60SoK0yVo3CYJgb2MkobuWuBX6dhkYP5ORCLd55y + SaflMOV5fqAB53ux4w = = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " options " : " 0 . 0 . 6 " , <nl> + " ultron " : " 1 . 0 . 2 " <nl> + } <nl> + } , <nl> + " xml " : { <nl> + " version " : " 1 . 0 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / xml / - / xml - 1 . 0 . 1 . tgz " , <nl> + " integrity " : " sha1 - eLpyAgApxbyHuKgaPPzXS0ovweU = " , <nl> + " dev " : true <nl> + } , <nl> + " xml2js " : { <nl> + " version " : " 0 . 1 . 14 " , <nl> + " resolved " : " https : / / registry . npmjs . org / xml2js / - / xml2js - 0 . 1 . 14 . tgz " , <nl> + " integrity " : " sha1 - UnTmf1pkxfkpdM2FE54DMq3GuQw = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " sax " : " 1 . 2 . 4 " <nl> + } <nl> + } , <nl> + " y18n " : { <nl> + " version " : " 3 . 2 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / y18n / - / y18n - 3 . 2 . 1 . tgz " , <nl> + " integrity " : " sha1 - bRX7qITAhnnA136I53WegR4H + kE = " , <nl> + " dev " : true <nl> + } , <nl> + " yargs " : { <nl> + " version " : " 6 . 6 . 0 " , <nl> + " resolved " : " https : / / registry . npmjs . org / yargs / - / yargs - 6 . 6 . 0 . tgz " , <nl> + " integrity " : " sha1 - eC7CHvQDNF + DCoCMo9UTr1YGUgg = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " camelcase " : " 3 . 0 . 0 " , <nl> + " cliui " : " 3 . 2 . 0 " , <nl> + " decamelize " : " 1 . 2 . 0 " , <nl> + " get - caller - file " : " 1 . 0 . 2 " , <nl> + " os - locale " : " 1 . 4 . 0 " , <nl> + " read - pkg - up " : " 1 . 0 . 1 " , <nl> + " require - directory " : " 2 . 1 . 1 " , <nl> + " require - main - filename " : " 1 . 0 . 1 " , <nl> + " set - blocking " : " 2 . 0 . 0 " , <nl> + " string - width " : " 1 . 0 . 2 " , <nl> + " which - module " : " 1 . 0 . 0 " , <nl> + " y18n " : " 3 . 2 . 1 " , <nl> + " yargs - parser " : " 4 . 2 . 1 " <nl> + } <nl> + } , <nl> + " yargs - parser " : { <nl> + " version " : " 4 . 2 . 1 " , <nl> + " resolved " : " https : / / registry . npmjs . org / yargs - parser / - / yargs - parser - 4 . 2 . 1 . tgz " , <nl> + " integrity " : " sha1 - KczqwNxPA8bIe0qfIX3RjJ90hxw = " , <nl> + " dev " : true , <nl> + " requires " : { <nl> + " camelcase " : " 3 . 0 . 0 " <nl> + } <nl> + } <nl> + } <nl> + } <nl> mmm a / spec / webview - spec . js <nl> ppp b / spec / webview - spec . js <nl> describe ( ' < webview > tag ' , function ( ) { <nl> <nl> describe ( ' media - started - playing media - paused events ' , ( ) = > { <nl> it ( ' emits when audio starts and stops playing ' , async ( ) = > { <nl> - loadWebView ( webview , { src : ` file : / / $ { fixtures } / pages / audio . html ` } ) <nl> + await loadWebView ( webview , { src : ` file : / / $ { fixtures } / pages / audio . html ` } ) <nl> + <nl> + / / XXX ( alexeykuzmin ) : Starting from Ch66 playing an audio requires <nl> + / / a user interaction . See https : / / goo . gl / xX8pDD . <nl> + <nl> + webview . executeJavaScript ( ' document . querySelector ( " audio " ) . play ( ) ' , true ) <nl> await waitForEvent ( webview , ' media - started - playing ' ) <nl> + <nl> + webview . executeJavaScript ( ' document . querySelector ( " audio " ) . pause ( ) ' , true ) <nl> await waitForEvent ( webview , ' media - paused ' ) <nl> } ) <nl> } ) <nl> describe ( ' < webview > tag ' , function ( ) { <nl> } ) <nl> } ) <nl> <nl> - describe ( ' did - get - response - details event ( deprecated ) ' , ( ) = > { <nl> - it ( ' emits for the page and its resources ' , ( done ) = > { <nl> - / / expected { fileName : resourceType } pairs <nl> - const expectedResources = { <nl> - ' did - get - response - details . html ' : ' mainFrame ' , <nl> - ' logo . png ' : ' image ' <nl> - } <nl> - let responses = 0 <nl> - webview . addEventListener ( ' - did - get - response - details ' , ( event ) = > { <nl> - responses + = 1 <nl> - const fileName = event . newURL . slice ( event . newURL . lastIndexOf ( ' / ' ) + 1 ) <nl> - const expectedType = expectedResources [ fileName ] <nl> - assert ( ! ! expectedType , ` Unexpected response details for $ { event . newURL } ` ) <nl> - assert ( typeof event . status = = = ' boolean ' , ' status should be boolean ' ) <nl> - assert . equal ( event . httpResponseCode , 200 ) <nl> - assert . equal ( event . requestMethod , ' GET ' ) <nl> - assert ( typeof event . referrer = = = ' string ' , ' referrer should be string ' ) <nl> - assert ( ! ! event . headers , ' headers should be present ' ) <nl> - assert ( typeof event . headers = = = ' object ' , ' headers should be object ' ) <nl> - assert . equal ( event . resourceType , expectedType , ' Incorrect resourceType ' ) <nl> - if ( responses = = = Object . keys ( expectedResources ) . length ) done ( ) <nl> - } ) <nl> - webview . src = ` file : / / $ { path . join ( fixtures , ' pages ' , ' did - get - response - details . html ' ) } ` <nl> - document . body . appendChild ( webview ) <nl> - } ) <nl> - } ) <nl> - <nl> describe ( ' document . visibilityState / hidden ' , ( ) = > { <nl> afterEach ( ( ) = > { <nl> ipcMain . removeAllListeners ( ' pong ' ) <nl> describe ( ' < webview > tag ' , function ( ) { <nl> expect ( tabId ) . to . be . not . equal ( w . webContents . id ) <nl> } ) <nl> <nl> - describe ( ' guestinstance attribute ' , ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : Some tests rashe a renderer process . <nl> + / / Fix them and enable the tests . <nl> + xdescribe ( ' guestinstance attribute ' , ( ) = > { <nl> it ( ' before loading there is no attribute ' , ( ) = > { <nl> loadWebView ( webview ) / / Don ' t wait for loading to finish . <nl> assert ( ! webview . hasAttribute ( ' guestinstance ' ) ) <nl> describe ( ' < webview > tag ' , function ( ) { <nl> if ( div ! = null ) div . remove ( ) <nl> } ) <nl> <nl> - it ( ' emits resize events ' , ( done ) = > { <nl> - webview . addEventListener ( ' dom - ready ' , ( ) = > { <nl> - div . style . width = ' 1234px ' <nl> - div . style . height = ' 789px ' <nl> - } ) <nl> - <nl> - webview . addEventListener ( ' resize ' , function onResize ( event ) { <nl> - webview . removeEventListener ( ' resize ' , onResize ) <nl> - assert . equal ( event . newWidth , 100 ) <nl> - assert . equal ( event . newHeight , 10 ) <nl> - assert . equal ( event . target , webview ) <nl> - webview . addEventListener ( ' resize ' , function onResizeAgain ( event ) { <nl> - / / This will be triggered after setting the new div width and height . <nl> - webview . removeEventListener ( ' resize ' , onResizeAgain ) <nl> - assert . equal ( event . newWidth , 1234 ) <nl> - assert . equal ( event . newHeight , 789 ) <nl> - assert . equal ( event . target , webview ) <nl> - done ( ) <nl> - } ) <nl> - } ) <nl> - <nl> + it ( ' emits resize events ' , async ( ) = > { <nl> webview . src = ` file : / / $ { fixtures } / pages / a . html ` <nl> div . appendChild ( webview ) <nl> document . body . appendChild ( div ) <nl> + <nl> + const firstResizeEvent = await waitForEvent ( webview , ' resize ' ) <nl> + expect ( firstResizeEvent . target ) . to . equal ( webview ) <nl> + expect ( firstResizeEvent . newWidth ) . to . equal ( 100 ) <nl> + expect ( firstResizeEvent . newHeight ) . to . equal ( 10 ) <nl> + <nl> + await waitForEvent ( webview , ' dom - ready ' ) <nl> + <nl> + const newWidth = 1234 <nl> + const newHeight = 789 <nl> + div . style . width = ` $ { newWidth } px ` <nl> + div . style . height = ` $ { newHeight } px ` <nl> + <nl> + const secondResizeEvent = await waitForEvent ( webview , ' resize ' ) <nl> + expect ( secondResizeEvent . target ) . to . equal ( webview ) <nl> + expect ( secondResizeEvent . newWidth ) . to . equal ( newWidth ) <nl> + expect ( secondResizeEvent . newHeight ) . to . equal ( newHeight ) <nl> } ) <nl> } ) <nl> <nl> describe ( ' < webview > tag ' , function ( ) { <nl> return Promise . all ( [ elementResize , guestResize ] ) <nl> } ) <nl> <nl> - it ( ' does not resize guest when attribute is present ' , async ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the test . <nl> + xit ( ' does not resize guest when attribute is present ' , async ( ) = > { <nl> const INITIAL_SIZE = 200 <nl> const w = await openTheWindow ( <nl> { show : false , width : INITIAL_SIZE , height : INITIAL_SIZE } ) <nl> describe ( ' < webview > tag ' , function ( ) { <nl> return noGuestResizePromise <nl> } ) <nl> <nl> - it ( ' dispatches element resize event even when attribute is present ' , async ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the test . <nl> + xit ( ' dispatches element resize event even when attribute is present ' , async ( ) = > { <nl> const INITIAL_SIZE = 200 <nl> const w = await openTheWindow ( <nl> { show : false , width : INITIAL_SIZE , height : INITIAL_SIZE } ) <nl> describe ( ' < webview > tag ' , function ( ) { <nl> return elementResizePromise <nl> } ) <nl> <nl> - it ( ' can be manually resized with setSize even when attribute is present ' , async ( ) = > { <nl> + / / TODO ( alexeykuzmin ) : [ Ch66 ] Enable the test . <nl> + xit ( ' can be manually resized with setSize even when attribute is present ' , async ( ) = > { <nl> const INITIAL_SIZE = 200 <nl> const w = await openTheWindow ( <nl> { show : false , width : INITIAL_SIZE , height : INITIAL_SIZE } ) <nl> mmm a / toolchain . gypi <nl> ppp b / toolchain . gypi <nl> <nl> " - add - plugin " , <nl> " - Xclang " , <nl> " find - bad - constructs " , <nl> - " - Xclang " , <nl> - " - plugin - arg - find - bad - constructs " , <nl> - " - Xclang " , <nl> - " check - auto - raw - pointer " , <nl> ] , <nl> } , <nl> } , { # OS = = " mac " <nl> <nl> " - add - plugin " , <nl> " - Xclang " , <nl> " find - bad - constructs " , <nl> - " - Xclang " , <nl> - " - plugin - arg - find - bad - constructs " , <nl> - " - Xclang " , <nl> - " check - auto - raw - pointer " , <nl> ] , <nl> } ] , <nl> ] , <nl> mmm a / vendor / crashpad <nl> ppp b / vendor / crashpad <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 1875fddc7e671b14d8b54068301d9648d12e9dc2 <nl> + Subproject commit f72fa99d3e3d65e3bb9bed9d83429459d6f80c0d <nl> mmm a / vendor / libchromiumcontent <nl> ppp b / vendor / libchromiumcontent <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 03bdc78da46b87ad6acf74b2fe5b7c09e352ec24 <nl> + Subproject commit 3611defa3fcf3e61fbd754a28d21a5a92dbdb1ab <nl> mmm a / vendor / native_mate <nl> ppp b / vendor / native_mate <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit ddec87224c7619ebd751b78e3214bf70a7a04a99 <nl> + Subproject commit 875706f66008e03a0c7a699de16d7e2bde0efb90 <nl> mmm a / vendor / node <nl> ppp b / vendor / node <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 538a5023af0a92ba19de2420a0eada6ad4cd18f6 <nl> + Subproject commit ce2efb3516b064df284c258e9a30825eb6f924b1 <nl> | Merge pull request from electron / upgrade - to - chromium - 66 | electron/electron | bcbcb4c6436e84e7f1f2387c2d7581bbdadb5732 | 2018-06-19T09:10:37Z |
mmm a / xbmc / lib / libPython / XBPythonDll . cpp <nl> ppp b / xbmc / lib / libPython / XBPythonDll . cpp <nl> <nl> * <nl> * / <nl> <nl> + # if ( defined HAVE_CONFIG_H ) & & ( ! defined WIN32 ) <nl> + # include " config . h " <nl> + # endif <nl> + # if ( defined USE_EXTERNAL_PYTHON ) <nl> + # if ( defined HAVE_LIBPYTHON2_6 ) <nl> + # include < python2 . 6 / pyconfig . h > <nl> + # elif ( defined HAVE_LIBPYTHON2_5 ) <nl> + # include < python2 . 5 / pyconfig . h > <nl> + # elif ( defined HAVE_LIBPYTHON2_4 ) <nl> + # include < python2 . 4 / pyconfig . h > <nl> + # else <nl> + # error " Could not determine version of Python to use . " <nl> + # endif <nl> + # else <nl> + # include " Python / Include / pyconfig . h " <nl> + # endif <nl> + <nl> # include " XBPythonDll . h " <nl> # include " cores / DllLoader / DllLoader . h " <nl> <nl> extern " C " <nl> FUNCTION ( PyLong_AsLong ) <nl> FUNCTION ( PyLong_AsLongLong ) <nl> FUNCTION ( PyErr_Format ) <nl> - # if ! defined ( _LINUX ) <nl> + # if Py_UNICODE_SIZE = = 2 <nl> FUNCTION ( PyUnicodeUCS2_AsUnicode ) <nl> # else <nl> FUNCTION ( PyUnicodeUCS4_AsUnicode ) <nl> extern " C " <nl> dll . ResolveExport ( DLL_FUNCTION ( PyLong_AsLong ) ) & & <nl> dll . ResolveExport ( DLL_FUNCTION ( PyLong_AsLongLong ) ) & & <nl> dll . ResolveExport ( DLL_FUNCTION ( PyErr_Format ) ) & & <nl> - # if ! defined ( _LINUX ) <nl> + # if Py_UNICODE_SIZE = = 2 <nl> dll . ResolveExport ( DLL_FUNCTION ( PyUnicodeUCS2_AsUnicode ) ) & & <nl> # else <nl> dll . ResolveExport ( DLL_FUNCTION ( PyUnicodeUCS4_AsUnicode ) ) & & <nl> mmm a / xbmc / lib / libPython / XBPythonDllFuncs . S <nl> ppp b / xbmc / lib / libPython / XBPythonDllFuncs . S <nl> <nl> # if ( defined HAVE_CONFIG_H ) & & ( ! defined WIN32 ) <nl> # include " config . h " <nl> # endif <nl> + # if ( defined USE_EXTERNAL_PYTHON ) <nl> + # if ( defined HAVE_LIBPYTHON2_6 ) <nl> + # include < python2 . 6 / pyconfig . h > <nl> + # elif ( defined HAVE_LIBPYTHON2_5 ) <nl> + # include < python2 . 5 / pyconfig . h > <nl> + # elif ( defined HAVE_LIBPYTHON2_4 ) <nl> + # include < python2 . 4 / pyconfig . h > <nl> + # else <nl> + # error " Could not determine version of Python to use . " <nl> + # endif <nl> + # else <nl> + # include " Python / Include / pyconfig . h " <nl> + # endif <nl> # ifndef __arm__ <nl> # ifndef __APPLE__ <nl> # if defined ( __PPC__ ) <nl> <nl> FUNCTION ( PyLong_AsLong ) <nl> FUNCTION ( PyLong_AsLongLong ) <nl> FUNCTION ( PyErr_Format ) <nl> - # if ! defined ( _LINUX ) <nl> + # if Py_UNICODE_SIZE = = 2 <nl> FUNCTION ( PyUnicodeUCS2_AsUnicode ) <nl> # else <nl> FUNCTION ( PyUnicodeUCS4_AsUnicode ) <nl> | fixed : build with external python with default UCS2 unicode | xbmc/xbmc | ac562a19bba20a8443aa8d69dca3fd5b4b2aad5f | 2010-06-08T16:19:33Z |
mmm a / modules / features2d / include / opencv2 / features2d / features2d . hpp <nl> ppp b / modules / features2d / include / opencv2 / features2d / features2d . hpp <nl> class CV_EXPORTS_W BRISK : public Feature2D <nl> void computeImpl ( const Mat & image , vector < KeyPoint > & keypoints , Mat & descriptors ) const ; <nl> void detectImpl ( const Mat & image , vector < KeyPoint > & keypoints , const Mat & mask = Mat ( ) ) const ; <nl> <nl> + void computeKeypointsNoOrientation ( InputArray image , InputArray mask , vector < KeyPoint > & keypoints ) const ; <nl> + void computeDescriptorsAndOrOrientation ( InputArray image , InputArray mask , vector < KeyPoint > & keypoints , <nl> + OutputArray descriptors , bool doDescriptors , bool doOrientation , <nl> + bool useProvidedKeypoints ) const ; <nl> + <nl> / / Feature parameters <nl> CV_PROP_RW int threshold ; <nl> CV_PROP_RW int octaves ; <nl> mmm a / modules / features2d / src / brisk . cpp <nl> ppp b / modules / features2d / src / brisk . cpp <nl> RoiPredicate ( const float minX , const float minY , const float maxX , const float m <nl> void <nl> BRISK : : operator ( ) ( InputArray _image , InputArray _mask , vector < KeyPoint > & keypoints , <nl> OutputArray _descriptors , bool useProvidedKeypoints ) const <nl> + { <nl> + bool doOrientation ; <nl> + if ( useProvidedKeypoints ) <nl> + doOrientation = false ; <nl> + computeDescriptorsAndOrOrientation ( _image , _mask , keypoints , _descriptors , true , doOrientation , <nl> + useProvidedKeypoints ) ; <nl> + } <nl> + <nl> + void <nl> + BRISK : : computeDescriptorsAndOrOrientation ( InputArray _image , InputArray _mask , vector < KeyPoint > & keypoints , <nl> + OutputArray _descriptors , bool doDescriptors , bool doOrientation , <nl> + bool useProvidedKeypoints ) const <nl> { <nl> Mat image = _image . getMat ( ) , mask = _mask . getMat ( ) ; <nl> if ( image . type ( ) ! = CV_8UC1 ) <nl> cvtColor ( image , image , CV_BGR2GRAY ) ; <nl> <nl> if ( ! useProvidedKeypoints ) <nl> - detectImpl ( image , keypoints , mask ) ; <nl> + { <nl> + doOrientation = true ; <nl> + computeKeypointsNoOrientation ( _image , _mask , keypoints ) ; <nl> + } <nl> <nl> / / Remove keypoints very close to the border <nl> size_t ksize = keypoints . size ( ) ; <nl> BRISK : : operator ( ) ( InputArray _image , InputArray _mask , vector < KeyPoint > & keypoi <nl> int * _values = new int [ points_ ] ; / / for temporary use <nl> <nl> / / resize the descriptors : <nl> - _descriptors . create ( ksize , strings_ , CV_8U ) ; <nl> - cv : : Mat descriptors = _descriptors . getMat ( ) ; <nl> - descriptors . setTo ( 0 ) ; <nl> + cv : : Mat descriptors ; <nl> + if ( doDescriptors ) <nl> + { <nl> + _descriptors . create ( ksize , strings_ , CV_8U ) ; <nl> + descriptors = _descriptors . getMat ( ) ; <nl> + descriptors . setTo ( 0 ) ; <nl> + } <nl> <nl> / / now do the extraction for all keypoints : <nl> <nl> BRISK : : operator ( ) ( InputArray _image , InputArray _mask , vector < KeyPoint > & keypoi <nl> uchar * ptr = descriptors . data ; <nl> for ( size_t k = 0 ; k < ksize ; k + + ) <nl> { <nl> - int theta ; <nl> cv : : KeyPoint & kp = keypoints [ k ] ; <nl> const int & scale = kscales [ k ] ; <nl> - int shifter = 0 ; <nl> int * pvalues = _values ; <nl> const float & x = kp . pt . x ; <nl> const float & y = kp . pt . y ; <nl> + <nl> + if ( doOrientation ) <nl> + { <nl> + / / get the gray values in the unrotated pattern <nl> + for ( unsigned int i = 0 ; i < points_ ; i + + ) <nl> + { <nl> + * ( pvalues + + ) = smoothedIntensity ( image , _integral , x , y , scale , 0 , i ) ; <nl> + } <nl> + <nl> + int direction0 = 0 ; <nl> + int direction1 = 0 ; <nl> + / / now iterate through the long pairings <nl> + const BriskLongPair * max = longPairs_ + noLongPairs_ ; <nl> + for ( BriskLongPair * iter = longPairs_ ; iter < max ; + + iter ) <nl> + { <nl> + t1 = * ( _values + iter - > i ) ; <nl> + t2 = * ( _values + iter - > j ) ; <nl> + const int delta_t = ( t1 - t2 ) ; <nl> + / / update the direction : <nl> + const int tmp0 = delta_t * ( iter - > weighted_dx ) / 1024 ; <nl> + const int tmp1 = delta_t * ( iter - > weighted_dy ) / 1024 ; <nl> + direction0 + = tmp0 ; <nl> + direction1 + = tmp1 ; <nl> + } <nl> + kp . angle = atan2 ( ( float ) direction1 , ( float ) direction0 ) / M_PI * 180 . 0 ; <nl> + if ( kp . angle < 0 ) <nl> + kp . angle + = 360 ; <nl> + } <nl> + <nl> + if ( ! doDescriptors ) <nl> + continue ; <nl> + <nl> + int theta ; <nl> if ( kp . angle = = - 1 ) <nl> { <nl> / / don ' t compute the gradient direction , just assign a rotation of 0 ° <nl> BRISK : : operator ( ) ( InputArray _image , InputArray _mask , vector < KeyPoint > & keypoi <nl> <nl> / / now also extract the stuff for the actual direction : <nl> / / let us compute the smoothed values <nl> - shifter = 0 ; <nl> + int shifter = 0 ; <nl> <nl> / / unsigned int mean = 0 ; <nl> pvalues = _values ; <nl> BRISK : : ~ BRISK ( ) <nl> } <nl> <nl> void <nl> - BRISK : : operator ( ) ( InputArray _image , InputArray _mask , vector < KeyPoint > & keypoints ) const <nl> + BRISK : : operator ( ) ( InputArray image , InputArray mask , vector < KeyPoint > & keypoints ) const <nl> + { <nl> + computeKeypointsNoOrientation ( image , mask , keypoints ) ; <nl> + computeDescriptorsAndOrOrientation ( image , mask , keypoints , cv : : noArray ( ) , false , true , true ) ; <nl> + } <nl> + <nl> + void <nl> + BRISK : : computeKeypointsNoOrientation ( InputArray _image , InputArray _mask , vector < KeyPoint > & keypoints ) const <nl> { <nl> Mat image = _image . getMat ( ) , mask = _mask . getMat ( ) ; <nl> if ( image . type ( ) ! = CV_8UC1 ) <nl> BRISK : : operator ( ) ( InputArray _image , InputArray _mask , vector < KeyPoint > & keypoin <nl> <nl> / / remove invalid points <nl> removeInvalidPoints ( mask , keypoints ) ; <nl> - <nl> - / / Compute the orientations of the keypoints <nl> - / / Remove keypoints very close to the border <nl> - size_t ksize = keypoints . size ( ) ; <nl> - std : : vector < int > kscales ; / / remember the scale per keypoint <nl> - kscales . resize ( ksize ) ; <nl> - static const float log2 = 0 . 693147180559945 ; <nl> - static const float lb_scalerange = log ( scalerange_ ) / ( log2 ) ; <nl> - std : : vector < cv : : KeyPoint > : : iterator beginning = keypoints . begin ( ) ; <nl> - std : : vector < int > : : iterator beginningkscales = kscales . begin ( ) ; <nl> - static const float basicSize06 = basicSize_ * 0 . 6 ; <nl> - for ( size_t k = 0 ; k < ksize ; k + + ) <nl> - { <nl> - unsigned int scale ; <nl> - scale = std : : max ( ( int ) ( scales_ / lb_scalerange * ( log ( keypoints [ k ] . size / ( basicSize06 ) ) / log2 ) + 0 . 5 ) , 0 ) ; <nl> - / / saturate <nl> - if ( scale > = scales_ ) <nl> - scale = scales_ - 1 ; <nl> - kscales [ k ] = scale ; <nl> - const int border = sizeList_ [ scale ] ; <nl> - const int border_x = image . cols - border ; <nl> - const int border_y = image . rows - border ; <nl> - if ( RoiPredicate ( border , border , border_x , border_y , keypoints [ k ] ) ) <nl> - { <nl> - keypoints . erase ( beginning + k ) ; <nl> - kscales . erase ( beginningkscales + k ) ; <nl> - if ( k = = 0 ) <nl> - { <nl> - beginning = keypoints . begin ( ) ; <nl> - beginningkscales = kscales . begin ( ) ; <nl> - } <nl> - ksize - - ; <nl> - k - - ; <nl> - } <nl> - } <nl> - <nl> - / / first , calculate the integral image over the whole image : <nl> - / / current integral image <nl> - cv : : Mat _integral ; / / the integral image <nl> - cv : : integral ( image , _integral ) ; <nl> - <nl> - int * _values = new int [ points_ ] ; / / for temporary use <nl> - <nl> - / / now do the extraction for all keypoints : <nl> - <nl> - / / temporary variables containing gray values at sample points : <nl> - int t1 ; <nl> - int t2 ; <nl> - <nl> - / / the feature orientation <nl> - int direction0 ; <nl> - int direction1 ; <nl> - <nl> - for ( size_t k = 0 ; k < ksize ; k + + ) <nl> - { <nl> - cv : : KeyPoint & kp = keypoints [ k ] ; <nl> - const int & scale = kscales [ k ] ; <nl> - int * pvalues = _values ; <nl> - const float & x = kp . pt . x ; <nl> - const float & y = kp . pt . y ; <nl> - / / get the gray values in the unrotated pattern <nl> - for ( unsigned int i = 0 ; i < points_ ; i + + ) <nl> - { <nl> - * ( pvalues + + ) = smoothedIntensity ( image , _integral , x , y , scale , 0 , i ) ; <nl> - } <nl> - <nl> - direction0 = 0 ; <nl> - direction1 = 0 ; <nl> - / / now iterate through the long pairings <nl> - const BriskLongPair * max = longPairs_ + noLongPairs_ ; <nl> - for ( BriskLongPair * iter = longPairs_ ; iter < max ; + + iter ) <nl> - { <nl> - t1 = * ( _values + iter - > i ) ; <nl> - t2 = * ( _values + iter - > j ) ; <nl> - const int delta_t = ( t1 - t2 ) ; <nl> - / / update the direction : <nl> - const int tmp0 = delta_t * ( iter - > weighted_dx ) / 1024 ; <nl> - const int tmp1 = delta_t * ( iter - > weighted_dy ) / 1024 ; <nl> - direction0 + = tmp0 ; <nl> - direction1 + = tmp1 ; <nl> - } <nl> - kp . angle = atan2 ( ( float ) direction1 , ( float ) direction0 ) / M_PI * 180 . 0 ; <nl> - if ( kp . angle < 0 ) <nl> - kp . angle + = 360 ; <nl> - } <nl> } <nl> <nl> <nl> | revert orientation computation in jeypoint detection for efficiency ( like done originally ) | opencv/opencv | 84c4797030e981f46257b34a1260892cceabb0a1 | 2012-08-30T12:28:39Z |
mmm a / lib / SILOptimizer / SILCombiner / SILCombinerMiscVisitors . cpp <nl> ppp b / lib / SILOptimizer / SILCombiner / SILCombinerMiscVisitors . cpp <nl> SILInstruction * SILCombiner : : visitReleaseValueInst ( ReleaseValueInst * RVI ) { <nl> } <nl> } <nl> <nl> - / / ReleaseValueInst of an unowned type is an unowned_release . <nl> - if ( OperandTy . is < UnownedStorageType > ( ) ) <nl> - return Builder . createUnownedRelease ( RVI - > getLoc ( ) , Operand , <nl> + / / ReleaseValueInst of a loadable reference storage type needs the <nl> + / / corresponding release instruction . <nl> + # define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE ( Name , . . . ) \ <nl> + if ( OperandTy . is < Name # # StorageType > ( ) ) \ <nl> + return Builder . create # # Name # # Release ( RVI - > getLoc ( ) , Operand , \ <nl> RVI - > getAtomicity ( ) ) ; <nl> + # include " swift / AST / ReferenceStorage . def " <nl> <nl> / / ReleaseValueInst of a reference type is a strong_release . <nl> if ( OperandTy . isReferenceCounted ( RVI - > getModule ( ) ) ) <nl> SILInstruction * SILCombiner : : visitRetainValueInst ( RetainValueInst * RVI ) { <nl> } <nl> } <nl> <nl> - / / RetainValueInst of an unowned type is an unowned_retain . <nl> - if ( OperandTy . is < UnownedStorageType > ( ) ) <nl> - return Builder . createUnownedRetain ( RVI - > getLoc ( ) , Operand , <nl> + / / RetainValueInst of a loadable reference storage type needs the <nl> + / / corresponding retain instruction . <nl> + # define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE ( Name , . . . ) \ <nl> + if ( OperandTy . is < Name # # StorageType > ( ) ) \ <nl> + return Builder . create # # Name # # Retain ( RVI - > getLoc ( ) , Operand , \ <nl> RVI - > getAtomicity ( ) ) ; <nl> + # include " swift / AST / ReferenceStorage . def " <nl> <nl> / / RetainValueInst of a reference type is a strong_release . <nl> if ( OperandTy . isReferenceCounted ( RVI - > getModule ( ) ) ) { <nl> mmm a / lib / SILOptimizer / Utils / InstOptUtils . cpp <nl> ppp b / lib / SILOptimizer / Utils / InstOptUtils . cpp <nl> swift : : createIncrementBefore ( SILValue ptr , SILInstruction * insertPt ) { <nl> / / If Ptr is refcounted itself , create the strong_retain and <nl> / / return . <nl> if ( ptr - > getType ( ) . isReferenceCounted ( builder . getModule ( ) ) ) { <nl> - if ( ptr - > getType ( ) . is < UnownedStorageType > ( ) ) <nl> - return builder . createUnownedRetain ( loc , ptr , <nl> - builder . getDefaultAtomicity ( ) ) ; <nl> - else <nl> - return builder . createStrongRetain ( loc , ptr , <nl> - builder . getDefaultAtomicity ( ) ) ; <nl> + # define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE ( Name , . . . ) \ <nl> + if ( ptr - > getType ( ) . is < Name # # StorageType > ( ) ) \ <nl> + return builder . create # # Name # # Retain ( loc , ptr , \ <nl> + builder . getDefaultAtomicity ( ) ) ; <nl> + # include " swift / AST / ReferenceStorage . def " <nl> + <nl> + return builder . createStrongRetain ( loc , ptr , <nl> + builder . getDefaultAtomicity ( ) ) ; <nl> } <nl> <nl> / / Otherwise , create the retain_value . <nl> swift : : createDecrementBefore ( SILValue ptr , SILInstruction * insertPt ) { <nl> <nl> / / If ptr has reference semantics itself , create a strong_release . <nl> if ( ptr - > getType ( ) . isReferenceCounted ( builder . getModule ( ) ) ) { <nl> - if ( ptr - > getType ( ) . is < UnownedStorageType > ( ) ) <nl> - return builder . createUnownedRelease ( loc , ptr , <nl> + # define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE ( Name , . . . ) \ <nl> + if ( ptr - > getType ( ) . is < Name # # StorageType > ( ) ) \ <nl> + return builder . create # # Name # # Release ( loc , ptr , \ <nl> builder . getDefaultAtomicity ( ) ) ; <nl> - else <nl> - return builder . createStrongRelease ( loc , ptr , <nl> - builder . getDefaultAtomicity ( ) ) ; <nl> + # include " swift / AST / ReferenceStorage . def " <nl> + <nl> + return builder . createStrongRelease ( loc , ptr , <nl> + builder . getDefaultAtomicity ( ) ) ; <nl> } <nl> <nl> / / Otherwise create a release value . <nl> | Merge remote - tracking branch ' origin / master ' into master - next | apple/swift | 44ee74800fac3fd30a01720640b7f3697ed469c0 | 2020-04-21T10:58:10Z |
mmm a / xbmc / windows / GUIWindowDebugInfo . cpp <nl> ppp b / xbmc / windows / GUIWindowDebugInfo . cpp <nl> bool CGUIWindowDebugInfo : : OnMessage ( CGUIMessage & message ) <nl> delete m_layout ; <nl> m_layout = nullptr ; <nl> } <nl> + else if ( message . GetMessage ( ) = = GUI_MSG_REFRESH_TIMER ) <nl> + MarkDirtyRegion ( ) ; <nl> + <nl> return CGUIDialog : : OnMessage ( message ) ; <nl> } <nl> <nl> | Merge pull request from peak3d / guiinfo | xbmc/xbmc | 54939ed1e8015bef54297f8f0580788b82cad2cf | 2019-01-22T21:47:26Z |
mmm a / include / swift / SIL / TypeLowering . h <nl> ppp b / include / swift / SIL / TypeLowering . h <nl> class TypeConverter { <nl> CanGenericSignature getEffectiveGenericSignature ( AnyFunctionRef fn , <nl> CaptureInfo captureInfo ) ; <nl> <nl> + / / / Retrieve the set of generic parameters closed over by the context . <nl> + CanGenericSignature getEffectiveGenericSignature ( DeclContext * dc ) ; <nl> + <nl> / / / Push a generic function context . See GenericContextScope for an RAII <nl> / / / interface to this function . <nl> / / / <nl> mmm a / lib / SIL / TypeLowering . cpp <nl> ppp b / lib / SIL / TypeLowering . cpp <nl> static CanAnyFunctionType getGlobalGetterType ( CanType varType ) { <nl> static CanAnyFunctionType getDefaultArgGeneratorInterfaceType ( <nl> TypeConverter & TC , <nl> AbstractFunctionDecl * AFD , <nl> - unsigned DefaultArgIndex , <nl> - ASTContext & context ) { <nl> + unsigned DefaultArgIndex ) { <nl> auto resultTy = AFD - > getDefaultArg ( DefaultArgIndex ) . second ; <nl> assert ( resultTy & & " Didn ' t find default argument ? " ) ; <nl> <nl> static CanAnyFunctionType getDefaultArgGeneratorInterfaceType ( <nl> / / Get the generic signature from the surrounding context . <nl> auto funcInfo = TC . getConstantInfo ( SILDeclRef ( AFD ) ) ; <nl> CanGenericSignature sig ; <nl> - if ( auto genTy = funcInfo . FormalInterfaceType - > getAs < GenericFunctionType > ( ) ) <nl> - sig = genTy - > getGenericSignature ( ) - > getCanonicalSignature ( ) ; <nl> + if ( auto genTy = dyn_cast < GenericFunctionType > ( funcInfo . FormalInterfaceType ) ) <nl> + sig = genTy . getGenericSignature ( ) ; <nl> <nl> if ( sig ) { <nl> - return cast < GenericFunctionType > ( <nl> - GenericFunctionType : : get ( sig , <nl> - TupleType : : getEmpty ( context ) , <nl> - canResultTy , <nl> - AnyFunctionType : : ExtInfo ( ) ) <nl> - - > getCanonicalType ( ) ) ; <nl> + return CanGenericFunctionType : : get ( sig , <nl> + TupleType : : getEmpty ( TC . Context ) , <nl> + canResultTy , <nl> + AnyFunctionType : : ExtInfo ( ) ) ; <nl> } <nl> <nl> - return CanFunctionType : : get ( TupleType : : getEmpty ( context ) , canResultTy ) ; <nl> + return CanFunctionType : : get ( TupleType : : getEmpty ( TC . Context ) , canResultTy ) ; <nl> } <nl> <nl> / / / Get the type of a stored property initializer , ( ) - > T . <nl> static CanAnyFunctionType getStoredPropertyInitializerInterfaceType ( <nl> TypeConverter & TC , <nl> - VarDecl * VD , <nl> - ASTContext & context ) { <nl> + VarDecl * VD ) { <nl> auto * DC = VD - > getDeclContext ( ) ; <nl> CanType resultTy = <nl> DC - > mapTypeOutOfContext ( VD - > getParentPattern ( ) - > getType ( ) ) <nl> - > getCanonicalType ( ) ; <nl> - GenericSignature * sig = DC - > getGenericSignatureOfContext ( ) ; <nl> + auto sig = TC . getEffectiveGenericSignature ( DC ) ; <nl> <nl> if ( sig ) <nl> - return CanGenericFunctionType : : get ( sig - > getCanonicalSignature ( ) , <nl> - TupleType : : getEmpty ( context ) , <nl> + return CanGenericFunctionType : : get ( sig , <nl> + TupleType : : getEmpty ( TC . Context ) , <nl> resultTy , <nl> GenericFunctionType : : ExtInfo ( ) ) ; <nl> <nl> - return CanFunctionType : : get ( TupleType : : getEmpty ( context ) , resultTy ) ; <nl> + return CanFunctionType : : get ( TupleType : : getEmpty ( TC . Context ) , resultTy ) ; <nl> } <nl> <nl> / / / Get the type of a destructor function . <nl> - static CanAnyFunctionType getDestructorInterfaceType ( DestructorDecl * dd , <nl> + static CanAnyFunctionType getDestructorInterfaceType ( TypeConverter & TC , <nl> + DestructorDecl * dd , <nl> bool isDeallocating , <nl> - ASTContext & C , <nl> bool isForeign ) { <nl> auto classType = dd - > getDeclContext ( ) - > getDeclaredInterfaceType ( ) <nl> - - > getCanonicalType ( ) ; <nl> + - > getCanonicalType ( dd - > getGenericSignatureOfContext ( ) , <nl> + * TC . M . getSwiftModule ( ) ) ; <nl> <nl> assert ( ( ! isForeign | | isDeallocating ) <nl> & & " There are no foreign destroying destructors " ) ; <nl> - AnyFunctionType : : ExtInfo extInfo = <nl> + auto extInfo = <nl> AnyFunctionType : : ExtInfo ( FunctionType : : Representation : : Thin , <nl> / * throws * / false ) ; <nl> if ( isForeign ) <nl> static CanAnyFunctionType getDestructorInterfaceType ( DestructorDecl * dd , <nl> extInfo = extInfo <nl> . withSILRepresentation ( SILFunctionTypeRepresentation : : Method ) ; <nl> <nl> - CanType resultTy = isDeallocating ? TupleType : : getEmpty ( C ) - > getCanonicalType ( ) <nl> - : C . TheNativeObjectType ; <nl> + auto & C = TC . Context ; <nl> + CanType resultTy = ( isDeallocating <nl> + ? TupleType : : getEmpty ( C ) <nl> + : C . TheNativeObjectType ) ; <nl> <nl> - auto sig = dd - > getDeclContext ( ) - > getGenericSignatureOfContext ( ) ; <nl> + auto sig = TC . getEffectiveGenericSignature ( dd ) ; <nl> if ( sig ) <nl> - return cast < GenericFunctionType > ( <nl> - GenericFunctionType : : get ( sig , classType , resultTy , extInfo ) <nl> - - > getCanonicalType ( ) ) ; <nl> + return CanGenericFunctionType : : get ( sig , classType , resultTy , extInfo ) ; <nl> return CanFunctionType : : get ( classType , resultTy , extInfo ) ; <nl> } <nl> <nl> / / / Retrieve the type of the ivar initializer or destroyer method for <nl> / / / a class . <nl> - static CanAnyFunctionType getIVarInitDestroyerInterfaceType ( ClassDecl * cd , <nl> + static CanAnyFunctionType getIVarInitDestroyerInterfaceType ( TypeConverter & TC , <nl> + ClassDecl * cd , <nl> bool isObjC , <nl> - ASTContext & ctx , <nl> bool isDestroyer ) { <nl> - auto classType = cd - > getDeclaredInterfaceType ( ) - > getCanonicalType ( ) ; <nl> + auto classType = cd - > getDeclaredInterfaceType ( ) <nl> + - > getCanonicalType ( cd - > getGenericSignatureOfContext ( ) , <nl> + * TC . M . getSwiftModule ( ) ) ; <nl> <nl> - auto emptyTupleTy = TupleType : : getEmpty ( ctx ) - > getCanonicalType ( ) ; <nl> - CanType resultType = isDestroyer ? emptyTupleTy : classType ; <nl> + CanType emptyTupleTy = TupleType : : getEmpty ( TC . Context ) ; <nl> + auto resultType = ( isDestroyer ? emptyTupleTy : classType ) ; <nl> auto extInfo = AnyFunctionType : : ExtInfo ( FunctionType : : Representation : : Thin , <nl> / * throws * / false ) ; <nl> extInfo = extInfo <nl> static CanAnyFunctionType getIVarInitDestroyerInterfaceType ( ClassDecl * cd , <nl> : SILFunctionTypeRepresentation : : Method ) ; <nl> <nl> resultType = CanFunctionType : : get ( emptyTupleTy , resultType , extInfo ) ; <nl> - auto sig = cd - > getGenericSignatureOfContext ( ) ; <nl> + auto sig = TC . getEffectiveGenericSignature ( cd ) ; <nl> if ( sig ) <nl> - return CanGenericFunctionType : : get ( sig - > getCanonicalSignature ( ) , <nl> + return CanGenericFunctionType : : get ( sig , <nl> classType , resultType , <nl> extInfo ) ; <nl> return CanFunctionType : : get ( classType , resultType , extInfo ) ; <nl> TypeConverter : : getEffectiveGenericEnvironment ( AnyFunctionRef fn , <nl> return nullptr ; <nl> } <nl> <nl> + CanGenericSignature <nl> + TypeConverter : : getEffectiveGenericSignature ( DeclContext * dc ) { <nl> + if ( auto sig = dc - > getGenericSignatureOfContext ( ) ) { <nl> + if ( sig - > areAllParamsConcrete ( ) ) <nl> + return nullptr ; <nl> + return sig - > getCanonicalSignature ( ) ; <nl> + } <nl> + <nl> + return nullptr ; <nl> + } <nl> + <nl> CanGenericSignature <nl> TypeConverter : : getEffectiveGenericSignature ( AnyFunctionRef fn , <nl> CaptureInfo captureInfo ) { <nl> TypeConverter : : getEffectiveGenericSignature ( AnyFunctionRef fn , <nl> ! captureInfo . hasGenericParamCaptures ( ) ) <nl> return nullptr ; <nl> <nl> - if ( auto sig = dc - > getGenericSignatureOfContext ( ) ) { <nl> - if ( sig - > areAllParamsConcrete ( ) ) <nl> - return nullptr ; <nl> - return sig - > getCanonicalSignature ( ) ; <nl> - } <nl> - <nl> - return nullptr ; <nl> + return getEffectiveGenericSignature ( dc ) ; <nl> } <nl> <nl> CanAnyFunctionType <nl> CanAnyFunctionType TypeConverter : : makeConstantInterfaceType ( SILDeclRef c ) { <nl> <nl> case SILDeclRef : : Kind : : Destroyer : <nl> case SILDeclRef : : Kind : : Deallocator : <nl> - return getDestructorInterfaceType ( cast < DestructorDecl > ( vd ) , <nl> - c . kind = = SILDeclRef : : Kind : : Deallocator , <nl> - Context , <nl> - c . isForeign ) ; <nl> + return getDestructorInterfaceType ( * this , <nl> + cast < DestructorDecl > ( vd ) , <nl> + c . kind = = SILDeclRef : : Kind : : Deallocator , <nl> + c . isForeign ) ; <nl> <nl> case SILDeclRef : : Kind : : GlobalAccessor : { <nl> VarDecl * var = cast < VarDecl > ( vd ) ; <nl> CanAnyFunctionType TypeConverter : : makeConstantInterfaceType ( SILDeclRef c ) { <nl> case SILDeclRef : : Kind : : DefaultArgGenerator : <nl> return getDefaultArgGeneratorInterfaceType ( * this , <nl> cast < AbstractFunctionDecl > ( vd ) , <nl> - c . defaultArgIndex , Context ) ; <nl> + c . defaultArgIndex ) ; <nl> case SILDeclRef : : Kind : : StoredPropertyInitializer : <nl> return getStoredPropertyInitializerInterfaceType ( * this , <nl> - cast < VarDecl > ( vd ) , <nl> - Context ) ; <nl> + cast < VarDecl > ( vd ) ) ; <nl> case SILDeclRef : : Kind : : IVarInitializer : <nl> - return getIVarInitDestroyerInterfaceType ( cast < ClassDecl > ( vd ) , <nl> - c . isForeign , Context , false ) ; <nl> + return getIVarInitDestroyerInterfaceType ( * this , <nl> + cast < ClassDecl > ( vd ) , <nl> + c . isForeign , false ) ; <nl> case SILDeclRef : : Kind : : IVarDestroyer : <nl> - return getIVarInitDestroyerInterfaceType ( cast < ClassDecl > ( vd ) , <nl> - c . isForeign , Context , true ) ; <nl> + return getIVarInitDestroyerInterfaceType ( * this , <nl> + cast < ClassDecl > ( vd ) , <nl> + c . isForeign , true ) ; <nl> } <nl> <nl> llvm_unreachable ( " Unhandled SILDeclRefKind in switch . " ) ; <nl> TypeConverter : : getInterfaceBoxTypeForCapture ( ValueDecl * captured , <nl> CanType loweredInterfaceType , <nl> bool isMutable ) { <nl> auto & C = M . getASTContext ( ) ; <nl> - CanGenericSignature signature ; <nl> - if ( auto sig = captured - > getDeclContext ( ) - > getGenericSignatureOfContext ( ) ) <nl> - signature = sig - > getCanonicalSignature ( ) ; <nl> + auto signature = getEffectiveGenericSignature ( captured - > getDeclContext ( ) ) ; <nl> <nl> / / If the type is not dependent at all , we can form a concrete box layout . <nl> / / We don ' t need to capture the generic environment . <nl> mmm a / test / SILGen / constrained_extensions . swift <nl> ppp b / test / SILGen / constrained_extensions . swift <nl> extension AnythingGoes where T : VeryConstrained { <nl> / / CHECK : return <nl> init ( fromExtension : ( ) ) { } <nl> } <nl> + <nl> + extension Array where Element = = Int { <nl> + struct Nested { <nl> + / / CHECK - LABEL : sil hidden [ transparent ] @ _T0Sa22constrained_extensionsSiRszlE6NestedV1eSiSgvfi : $ @ convention ( thin ) ( ) - > Optional < Int > <nl> + var e : Element ? = nil <nl> + <nl> + / / CHECK - LABEL : sil hidden @ _T0Sa22constrained_extensionsSiRszlE6NestedV10hasDefaultySiSg1e_tFfA_ : $ @ convention ( thin ) ( ) - > Optional < Int > <nl> + / / CHECK - LABEL : sil hidden @ _T0Sa22constrained_extensionsSiRszlE6NestedV10hasDefaultySiSg1e_tF : $ @ convention ( method ) ( Optional < Int > , @ inout Array < Int > . Nested ) - > ( ) <nl> + mutating func hasDefault ( e : Element ? = nil ) { <nl> + self . e = e <nl> + } <nl> + } <nl> + } <nl> + <nl> + extension Array where Element = = AnyObject { <nl> + class NestedClass { <nl> + / / CHECK - LABEL : sil hidden @ _T0Sa22constrained_extensionsyXlRszlE11NestedClassCfd : $ @ convention ( method ) ( @ guaranteed Array < AnyObject > . NestedClass ) - > @ owned Builtin . NativeObject <nl> + / / CHECK - LABEL : sil hidden @ _T0Sa22constrained_extensionsyXlRszlE11NestedClassCfD : $ @ convention ( method ) ( @ owned Array < AnyObject > . NestedClass ) - > ( ) <nl> + deinit { } <nl> + <nl> + / / CHECK - LABEL : sil hidden @ _T0Sa22constrained_extensionsyXlRszlE11NestedClassCACyyXl_GycfC : $ @ convention ( method ) ( @ thick Array < AnyObject > . NestedClass . Type ) - > @ owned Array < AnyObject > . NestedClass <nl> + / / CHECK - LABEL : sil hidden @ _T0Sa22constrained_extensionsyXlRszlE11NestedClassCACyyXl_Gycfc : $ @ convention ( method ) ( @ owned Array < AnyObject > . NestedClass ) - > @ owned Array < AnyObject > . NestedClass <nl> + } <nl> + <nl> + class DerivedClass : NestedClass { <nl> + / / CHECK - LABEL : sil hidden [ transparent ] @ _T0Sa22constrained_extensionsyXlRszlE12DerivedClassC1eyXlSgvfi : $ @ convention ( thin ) ( ) - > @ owned Optional < AnyObject > <nl> + / / CHECK - LABEL : sil hidden @ _T0Sa22constrained_extensionsyXlRszlE12DerivedClassCfE : $ @ convention ( method ) ( @ guaranteed Array < AnyObject > . DerivedClass ) - > ( ) <nl> + var e : Element ? = nil <nl> + } <nl> + } <nl> + <nl> + func referenceNestedTypes ( ) { <nl> + _ = Array < AnyObject > . NestedClass ( ) <nl> + _ = Array < AnyObject > . DerivedClass ( ) <nl> + } <nl> | SILGen : Fix issues with types nested inside fully - concrete extensions | apple/swift | 9c7afa7bdd0018d4940a16effa2d7a997f9a0952 | 2017-05-23T02:49:53Z |
mmm a / xbmc / ApplicationPlayer . cpp <nl> ppp b / xbmc / ApplicationPlayer . cpp <nl> void CApplicationPlayer : : SetTempo ( float tempo ) <nl> player - > SetTempo ( tempo ) ; <nl> } <nl> <nl> + void CApplicationPlayer : : FrameAdvance ( int frames ) <nl> + { <nl> + std : : shared_ptr < IPlayer > player = GetInternal ( ) ; <nl> + if ( player ) <nl> + player - > FrameAdvance ( frames ) ; <nl> + } <nl> + <nl> void CApplicationPlayer : : DoAudioWork ( ) <nl> { <nl> std : : shared_ptr < IPlayer > player = GetInternal ( ) ; <nl> mmm a / xbmc / ApplicationPlayer . h <nl> ppp b / xbmc / ApplicationPlayer . h <nl> class CApplicationPlayer <nl> PlayBackRet OpenFile ( const CFileItem & item , const CPlayerOptions & options ) ; <nl> void SetPlaySpeed ( float speed ) ; <nl> void SetTempo ( float tempo ) ; <nl> + void FrameAdvance ( int frames ) ; <nl> <nl> void FrameMove ( ) ; <nl> void Render ( bool clear , uint32_t alpha = 255 , bool gui = true ) ; <nl> mmm a / xbmc / cores / IPlayer . h <nl> ppp b / xbmc / cores / IPlayer . h <nl> class IPlayer <nl> virtual void SetSpeed ( float speed ) = 0 ; <nl> virtual void SetTempo ( float tempo ) { } ; <nl> virtual bool SupportsTempo ( ) { return false ; } <nl> + virtual void FrameAdvance ( int frames ) { } ; <nl> <nl> / / Returns true if not playback ( paused or stopped being filled ) <nl> virtual bool IsCaching ( ) const { return false ; } ; <nl> mmm a / xbmc / cores / VideoPlayer / DVDClock . cpp <nl> ppp b / xbmc / cores / VideoPlayer / DVDClock . cpp <nl> void CDVDClock : : Pause ( bool pause ) <nl> } <nl> } <nl> <nl> + void CDVDClock : : Advance ( double time ) <nl> + { <nl> + CSingleLock lock ( m_critSection ) ; <nl> + <nl> + if ( m_pauseClock ) <nl> + { <nl> + m_pauseClock + = time / DVD_TIME_BASE * m_systemFrequency ; <nl> + } <nl> + } <nl> + <nl> void CDVDClock : : SetSpeed ( int iSpeed ) <nl> { <nl> / / this will sometimes be a little bit of due to rounding errors , ie clock might jump a bit when changing speed <nl> mmm a / xbmc / cores / VideoPlayer / DVDClock . h <nl> ppp b / xbmc / cores / VideoPlayer / DVDClock . h <nl> class CDVDClock <nl> double GetVsyncAdjust ( ) ; <nl> <nl> void Pause ( bool pause ) ; <nl> + void Advance ( double time ) ; <nl> <nl> protected : <nl> double SystemToAbsolute ( int64_t system ) ; <nl> mmm a / xbmc / cores / VideoPlayer / DVDMessage . h <nl> ppp b / xbmc / cores / VideoPlayer / DVDMessage . h <nl> class CDVDMsg : public IDVDResourceCounted < CDVDMsg > <nl> PLAYER_AVCHANGE , / / signal a change in audio or video parameters <nl> PLAYER_ABORT , <nl> PLAYER_REPORT_STATE , <nl> + PLAYER_FRAME_ADVANCE , <nl> <nl> / / demuxer related messages <nl> DEMUXER_PACKET , / / data packet <nl> mmm a / xbmc / cores / VideoPlayer / VideoPlayer . cpp <nl> ppp b / xbmc / cores / VideoPlayer / VideoPlayer . cpp <nl> void CVideoPlayer : : HandleMessages ( ) <nl> if ( m_pDemuxer ) <nl> m_pDemuxer - > SetSpeed ( speed ) ; <nl> } <nl> + else if ( pMsg - > IsType ( CDVDMsg : : PLAYER_FRAME_ADVANCE ) ) <nl> + { <nl> + int frames = static_cast < CDVDMsgInt * > ( pMsg ) - > m_value ; <nl> + double time = DVD_TIME_BASE / m_processInfo - > GetVideoFps ( ) * frames ; <nl> + m_clock . Advance ( time ) ; <nl> + } <nl> else if ( pMsg - > IsType ( CDVDMsg : : GENERAL_GUI_ACTION ) ) <nl> OnAction ( static_cast < CDVDMsgType < CAction > * > ( pMsg ) - > m_value ) ; <nl> else if ( pMsg - > IsType ( CDVDMsg : : PLAYER_STARTED ) ) <nl> void CVideoPlayer : : SetTempo ( float tempo ) <nl> } <nl> } <nl> <nl> + void CVideoPlayer : : FrameAdvance ( int frames ) <nl> + { <nl> + float currentSpeed = m_processInfo - > GetNewSpeed ( ) ; <nl> + if ( currentSpeed ! = DVD_PLAYSPEED_PAUSE ) <nl> + return ; <nl> + <nl> + m_messenger . Put ( new CDVDMsgInt ( CDVDMsg : : PLAYER_FRAME_ADVANCE , frames ) ) ; <nl> + } <nl> + <nl> bool CVideoPlayer : : SupportsTempo ( ) <nl> { <nl> return m_canTempo ; <nl> mmm a / xbmc / cores / VideoPlayer / VideoPlayer . h <nl> ppp b / xbmc / cores / VideoPlayer / VideoPlayer . h <nl> class CVideoPlayer : public IPlayer , public CThread , public IVideoPlayer , public <nl> void SetSpeed ( float speed ) override ; <nl> void SetTempo ( float tempo ) override ; <nl> bool SupportsTempo ( ) override ; <nl> + void FrameAdvance ( int frames ) override ; <nl> bool OnAction ( const CAction & action ) override ; <nl> <nl> int GetSourceBitrate ( ) override ; <nl> mmm a / xbmc / cores / VideoPlayer / VideoPlayerVideo . cpp <nl> ppp b / xbmc / cores / VideoPlayer / VideoPlayerVideo . cpp <nl> void CVideoPlayerVideo : : Process ( ) <nl> while ( ! m_bStop ) <nl> { <nl> int iQueueTimeOut = ( int ) ( m_stalled ? frametime : frametime * 10 ) / 1000 ; <nl> - int iPriority = ( m_speed = = DVD_PLAYSPEED_PAUSE & & m_syncState = = IDVDStreamPlayer : : SYNC_INSYNC ) ? 1 : 0 ; <nl> + int iPriority = 0 ; <nl> <nl> if ( m_syncState = = IDVDStreamPlayer : : SYNC_WAITSYNC ) <nl> iPriority = 1 ; <nl> mmm a / xbmc / interfaces / builtins / PlayerBuiltins . cpp <nl> ppp b / xbmc / interfaces / builtins / PlayerBuiltins . cpp <nl> static int PlayerControl ( const std : : vector < std : : string > & params ) <nl> { <nl> g_application . StopPlaying ( ) ; <nl> } <nl> + else if ( StringUtils : : StartsWithNoCase ( params [ 0 ] , " frameadvance " ) ) <nl> + { <nl> + std : : string strFrames ; <nl> + if ( params [ 0 ] . size ( ) = = 12 ) <nl> + CLog : : Log ( LOGERROR , " PlayerControl ( frameadvance ( n ) ) called with no argument " ) ; <nl> + else if ( params [ 0 ] . size ( ) < 15 ) / / arg must be at least " ( N ) " <nl> + CLog : : Log ( LOGERROR , " PlayerControl ( frameadvance ( n ) ) called with invalid argument : \ " % s \ " " , params [ 0 ] . substr ( 13 ) . c_str ( ) ) ; <nl> + else <nl> + <nl> + strFrames = params [ 0 ] . substr ( 13 ) ; <nl> + StringUtils : : TrimRight ( strFrames , " ) " ) ; <nl> + float frames = ( float ) atof ( strFrames . c_str ( ) ) ; <nl> + g_application . m_pPlayer - > FrameAdvance ( frames ) ; <nl> + } <nl> else if ( paramlow = = " rewind " | | paramlow = = " forward " ) <nl> { <nl> if ( g_application . m_pPlayer - > IsPlaying ( ) & & ! g_application . m_pPlayer - > IsPaused ( ) ) <nl> | Merge pull request from FernetMenta / advance | xbmc/xbmc | 5dd414ee8813e4b802c3ba52b5b6c32d428e8b34 | 2017-09-19T05:50:57Z |
mmm a / src / she / win / window . cpp <nl> ppp b / src / she / win / window . cpp <nl> <nl> <nl> namespace she { <nl> <nl> + static PointerType wt_packet_pkcursor_to_pointer_type ( int pkCursor ) <nl> + { <nl> + switch ( pkCursor ) { <nl> + case 0 : <nl> + case 3 : <nl> + return PointerType : : Cursor ; <nl> + case 1 : <nl> + case 4 : <nl> + return PointerType : : Pen ; <nl> + case 2 : <nl> + case 5 : <nl> + case 6 : / / Undocumented : Inverted stylus when EnableMouseInPointer ( ) is on <nl> + return PointerType : : Eraser ; <nl> + } <nl> + return PointerType : : Unknown ; <nl> + } <nl> + <nl> WinWindow : : WinWindow ( int width , int height , int scale ) <nl> : m_hwnd ( nullptr ) <nl> , m_hcursor ( nullptr ) <nl> WinWindow : : WinWindow ( int width , int height , int scale ) <nl> , m_captureMouse ( false ) <nl> , m_customHcursor ( false ) <nl> , m_usePointerApi ( false ) <nl> - , m_ignoreMouseMessages ( false ) <nl> , m_lastPointerId ( 0 ) <nl> , m_ictx ( nullptr ) <nl> , m_emulateDoubleClick ( false ) <nl> WinWindow : : WinWindow ( int width , int height , int scale ) <nl> winApi . IsMouseInPointerEnabled & & <nl> winApi . GetPointerInfo & & <nl> winApi . GetPointerPenInfo ) { <nl> + / / Do not enable pointer API for mouse events because : <nl> + / / - Wacom driver doesn ' t inform their messages in a correct <nl> + / / pointer API format ( events from pen are reported as mouse <nl> + / / events and without eraser tip information ) . <nl> + / / - We have to emulate the double - click for the regular mouse <nl> + / / ( search for m_emulateDoubleClick ) . <nl> + / / - Double click with Wacom stylus doesn ' t work . <nl> + # if 0 <nl> if ( ! winApi . IsMouseInPointerEnabled ( ) ) { <nl> / / Prefer pointer messages ( WM_POINTER * ) since Windows 8 instead <nl> / / of mouse messages ( WM_MOUSE * ) <nl> winApi . EnableMouseInPointer ( TRUE ) ; <nl> - m_ignoreMouseMessages = <nl> m_emulateDoubleClick = <nl> ( winApi . IsMouseInPointerEnabled ( ) ? true : false ) ; <nl> } <nl> + # endif <nl> <nl> / / Initialize a Interaction Context to convert WM_POINTER messages <nl> / / into gestures processed by handleInteractionContextOutput ( ) . <nl> LRESULT WinWindow : : wndProc ( UINT msg , WPARAM wparam , LPARAM lparam ) <nl> / / Mouse and Trackpad Messages <nl> <nl> case WM_MOUSEMOVE : { <nl> - / / If the pointer API is enable , we use WM_POINTERUPDATE instead <nl> - / / of WM_MOUSEMOVE . <nl> - if ( m_ignoreMouseMessages ) <nl> - break ; <nl> - <nl> Event ev ; <nl> mouseEvent ( lparam , ev ) ; <nl> <nl> LRESULT WinWindow : : wndProc ( UINT msg , WPARAM wparam , LPARAM lparam ) <nl> / / Wintab API Messages <nl> <nl> case WT_PROXIMITY : { <nl> + MOUSE_TRACE ( " WT_PROXIMITY \ n " ) ; <nl> + <nl> bool entering_ctx = ( LOWORD ( lparam ) ? true : false ) ; <nl> if ( ! entering_ctx ) <nl> m_pointerType = PointerType : : Unknown ; <nl> LRESULT WinWindow : : wndProc ( UINT msg , WPARAM wparam , LPARAM lparam ) <nl> HCTX ctx = ( HCTX ) lparam ; <nl> PACKET packet ; <nl> <nl> - if ( api . packet ( ctx , serial , & packet ) ) { <nl> - switch ( packet . pkCursor ) { <nl> - case 0 : <nl> - case 3 : <nl> - m_pointerType = PointerType : : Cursor ; <nl> - break ; <nl> - case 1 : <nl> - case 4 : <nl> - m_pointerType = PointerType : : Pen ; <nl> - break ; <nl> - case 2 : <nl> - case 5 : <nl> - m_pointerType = PointerType : : Eraser ; <nl> - break ; <nl> - default : <nl> - m_pointerType = PointerType : : Unknown ; <nl> - break ; <nl> - } <nl> - } <nl> + if ( api . packet ( ctx , serial , & packet ) ) <nl> + m_pointerType = wt_packet_pkcursor_to_pointer_type ( packet . pkCursor ) ; <nl> else <nl> m_pointerType = PointerType : : Unknown ; <nl> + <nl> + MOUSE_TRACE ( " WT_CSRCHANGE pointer = % d \ n " , m_pointerType ) ; <nl> + break ; <nl> } <nl> <nl> case WT_PACKET : { <nl> LRESULT WinWindow : : wndProc ( UINT msg , WPARAM wparam , LPARAM lparam ) <nl> <nl> if ( api . packet ( ctx , serial , & packet ) ) { <nl> m_pressure = packet . pkNormalPressure / 1000 . 0 ; / / TODO get the maximum value <nl> - <nl> - if ( packet . pkCursor = = 2 | | packet . pkCursor = = 5 ) <nl> - m_pointerType = PointerType : : Eraser ; <nl> - else <nl> - m_pointerType = PointerType : : Pen ; <nl> + m_pointerType = wt_packet_pkcursor_to_pointer_type ( packet . pkCursor ) ; <nl> } <nl> else <nl> m_pointerType = PointerType : : Unknown ; <nl> + <nl> + MOUSE_TRACE ( " WT_PACKET pointer = % d m_pressure = % . 16g \ n " , <nl> + m_pointerType , m_pressure ) ; <nl> break ; <nl> } <nl> <nl> bool WinWindow : : pointerEvent ( WPARAM wparam , Event & ev , POINTER_INFO & pi ) <nl> <nl> switch ( pi . pointerType ) { <nl> case PT_MOUSE : { <nl> + MOUSE_TRACE ( " pi . pointerType PT_MOUSE \ n " ) ; <nl> ev . setPointerType ( PointerType : : Mouse ) ; <nl> + <nl> + / / If we use EnableMouseInPointer ( true ) , events from Wacom <nl> + / / stylus came as PT_MOUSE instead of PT_PEN with eraser <nl> + / / flag . This is just insane , EnableMouseInPointer ( true ) is not <nl> + / / an option at the moment if we want proper support for Wacom <nl> + / / events . <nl> break ; <nl> } <nl> case PT_TOUCH : { <nl> + MOUSE_TRACE ( " pi . pointerType PT_TOUCH \ n " ) ; <nl> ev . setPointerType ( PointerType : : Touch ) ; <nl> break ; <nl> } <nl> case PT_TOUCHPAD : { <nl> + MOUSE_TRACE ( " pi . pointerType PT_TOUCHPAD \ n " ) ; <nl> ev . setPointerType ( PointerType : : Touchpad ) ; <nl> break ; <nl> } <nl> case PT_PEN : { <nl> + MOUSE_TRACE ( " pi . pointerType PT_PEN \ n " ) ; <nl> ev . setPointerType ( PointerType : : Pen ) ; <nl> <nl> POINTER_PEN_INFO ppi ; <nl> if ( winApi . GetPointerPenInfo ( pi . pointerId , & ppi ) ) { <nl> + MOUSE_TRACE ( " - ppi . penFlags = % d \ n " , ppi . penFlags ) ; <nl> if ( ppi . penFlags & PEN_FLAG_ERASER ) <nl> ev . setPointerType ( PointerType : : Eraser ) ; <nl> } <nl> mmm a / src / she / win / window . h <nl> ppp b / src / she / win / window . h <nl> namespace she { <nl> <nl> / / Windows 8 pointer API <nl> bool m_usePointerApi ; <nl> - bool m_ignoreMouseMessages ; <nl> UINT32 m_lastPointerId ; <nl> UINT32 m_capturePointerId ; <nl> HINTERACTIONCONTEXT m_ictx ; <nl> | Revert Windows pointer API , doesn ' t go well with Wacom drivers | aseprite/aseprite | 4ce5e0b64dc04dcae6a4ddfb48ec4f9d296d0a60 | 2018-03-19T13:47:29Z |
mmm a / src / Core / SettingsCollection . cpp <nl> ppp b / src / Core / SettingsCollection . cpp <nl> namespace ErrorCodes <nl> <nl> <nl> template < typename Type > <nl> - String SettingNumber < Type > : : toString ( ) const <nl> + String SettingFieldNumber < Type > : : toString ( ) const <nl> { <nl> return DB : : toString ( value ) ; <nl> } <nl> <nl> template < typename Type > <nl> - Field SettingNumber < Type > : : toField ( ) const <nl> + Field SettingFieldNumber < Type > : : toField ( ) const <nl> { <nl> return value ; <nl> } <nl> <nl> template < typename Type > <nl> - void SettingNumber < Type > : : set ( Type x ) <nl> + void SettingFieldNumber < Type > : : set ( Type x ) <nl> { <nl> value = x ; <nl> changed = true ; <nl> } <nl> <nl> template < typename Type > <nl> - void SettingNumber < Type > : : set ( const Field & x ) <nl> + void SettingFieldNumber < Type > : : set ( const Field & x ) <nl> { <nl> if ( x . getType ( ) = = Field : : Types : : String ) <nl> set ( get < const String & > ( x ) ) ; <nl> void SettingNumber < Type > : : set ( const Field & x ) <nl> } <nl> <nl> template < typename Type > <nl> - void SettingNumber < Type > : : set ( const String & x ) <nl> + void SettingFieldNumber < Type > : : set ( const String & x ) <nl> { <nl> set ( parseWithSizeSuffix < Type > ( x ) ) ; <nl> } <nl> <nl> template < > <nl> - void SettingNumber < bool > : : set ( const String & x ) <nl> + void SettingFieldNumber < bool > : : set ( const String & x ) <nl> { <nl> if ( x . size ( ) = = 1 ) <nl> { <nl> void SettingNumber < bool > : : set ( const String & x ) <nl> } <nl> <nl> template < typename Type > <nl> - void SettingNumber < Type > : : serialize ( WriteBuffer & buf , SettingsBinaryFormat format ) const <nl> + void SettingFieldNumber < Type > : : serialize ( WriteBuffer & buf , SettingsBinaryFormat format ) const <nl> { <nl> if ( format > = SettingsBinaryFormat : : STRINGS ) <nl> { <nl> void SettingNumber < Type > : : serialize ( WriteBuffer & buf , SettingsBinaryFormat form <nl> } <nl> <nl> template < typename Type > <nl> - void SettingNumber < Type > : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) <nl> + void SettingFieldNumber < Type > : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) <nl> { <nl> if ( format > = SettingsBinaryFormat : : STRINGS ) <nl> { <nl> void SettingNumber < Type > : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat for <nl> } <nl> } <nl> <nl> - template struct SettingNumber < UInt64 > ; <nl> - template struct SettingNumber < Int64 > ; <nl> - template struct SettingNumber < float > ; <nl> - template struct SettingNumber < bool > ; <nl> + template struct SettingFieldNumber < UInt64 > ; <nl> + template struct SettingFieldNumber < Int64 > ; <nl> + template struct SettingFieldNumber < float > ; <nl> + template struct SettingFieldNumber < bool > ; <nl> <nl> <nl> - String SettingMaxThreads : : toString ( ) const <nl> + String SettingFieldMaxThreads : : toString ( ) const <nl> { <nl> / / / Instead of the ` auto ` value , we output the actual value to make it easier to see . <nl> return is_auto ? ( " auto ( " + DB : : toString ( value ) + " ) " ) : DB : : toString ( value ) ; <nl> } <nl> <nl> - Field SettingMaxThreads : : toField ( ) const <nl> + Field SettingFieldMaxThreads : : toField ( ) const <nl> { <nl> return is_auto ? 0 : value ; <nl> } <nl> <nl> - void SettingMaxThreads : : set ( UInt64 x ) <nl> + void SettingFieldMaxThreads : : set ( UInt64 x ) <nl> { <nl> value = x ? x : getAutoValue ( ) ; <nl> is_auto = x = = 0 ; <nl> changed = true ; <nl> } <nl> <nl> - void SettingMaxThreads : : set ( const Field & x ) <nl> + void SettingFieldMaxThreads : : set ( const Field & x ) <nl> { <nl> if ( x . getType ( ) = = Field : : Types : : String ) <nl> set ( get < const String & > ( x ) ) ; <nl> void SettingMaxThreads : : set ( const Field & x ) <nl> set ( applyVisitor ( FieldVisitorConvertToNumber < UInt64 > ( ) , x ) ) ; <nl> } <nl> <nl> - void SettingMaxThreads : : set ( const String & x ) <nl> + void SettingFieldMaxThreads : : set ( const String & x ) <nl> { <nl> if ( startsWith ( x , " auto " ) ) <nl> setAuto ( ) ; <nl> void SettingMaxThreads : : set ( const String & x ) <nl> set ( parse < UInt64 > ( x ) ) ; <nl> } <nl> <nl> - void SettingMaxThreads : : serialize ( WriteBuffer & buf , SettingsBinaryFormat format ) const <nl> + void SettingFieldMaxThreads : : serialize ( WriteBuffer & buf , SettingsBinaryFormat format ) const <nl> { <nl> if ( format > = SettingsBinaryFormat : : STRINGS ) <nl> { <nl> void SettingMaxThreads : : serialize ( WriteBuffer & buf , SettingsBinaryFormat format <nl> writeVarUInt ( is_auto ? 0 : value , buf ) ; <nl> } <nl> <nl> - void SettingMaxThreads : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) <nl> + void SettingFieldMaxThreads : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) <nl> { <nl> if ( format > = SettingsBinaryFormat : : STRINGS ) <nl> { <nl> void SettingMaxThreads : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat forma <nl> set ( x ) ; <nl> } <nl> <nl> - void SettingMaxThreads : : setAuto ( ) <nl> + void SettingFieldMaxThreads : : setAuto ( ) <nl> { <nl> value = getAutoValue ( ) ; <nl> is_auto = true ; <nl> } <nl> <nl> - UInt64 SettingMaxThreads : : getAutoValue ( ) <nl> + UInt64 SettingFieldMaxThreads : : getAutoValue ( ) <nl> { <nl> return getNumberOfPhysicalCPUCores ( ) ; <nl> } <nl> <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - String SettingTimespan < io_unit > : : toString ( ) const <nl> + template < SettingFieldTimespanIO io_unit > <nl> + String SettingFieldTimespan < io_unit > : : toString ( ) const <nl> { <nl> return DB : : toString ( value . totalMicroseconds ( ) / microseconds_per_io_unit ) ; <nl> } <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - Field SettingTimespan < io_unit > : : toField ( ) const <nl> + template < SettingFieldTimespanIO io_unit > <nl> + Field SettingFieldTimespan < io_unit > : : toField ( ) const <nl> { <nl> return value . totalMicroseconds ( ) / microseconds_per_io_unit ; <nl> } <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - void SettingTimespan < io_unit > : : set ( const Poco : : Timespan & x ) <nl> + template < SettingFieldTimespanIO io_unit > <nl> + void SettingFieldTimespan < io_unit > : : set ( const Poco : : Timespan & x ) <nl> { <nl> value = x ; <nl> changed = true ; <nl> } <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - void SettingTimespan < io_unit > : : set ( UInt64 x ) <nl> + template < SettingFieldTimespanIO io_unit > <nl> + void SettingFieldTimespan < io_unit > : : set ( UInt64 x ) <nl> { <nl> set ( Poco : : Timespan ( x * microseconds_per_io_unit ) ) ; <nl> } <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - void SettingTimespan < io_unit > : : set ( const Field & x ) <nl> + template < SettingFieldTimespanIO io_unit > <nl> + void SettingFieldTimespan < io_unit > : : set ( const Field & x ) <nl> { <nl> if ( x . getType ( ) = = Field : : Types : : String ) <nl> set ( get < const String & > ( x ) ) ; <nl> void SettingTimespan < io_unit > : : set ( const Field & x ) <nl> set ( applyVisitor ( FieldVisitorConvertToNumber < UInt64 > ( ) , x ) ) ; <nl> } <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - void SettingTimespan < io_unit > : : set ( const String & x ) <nl> + template < SettingFieldTimespanIO io_unit > <nl> + void SettingFieldTimespan < io_unit > : : set ( const String & x ) <nl> { <nl> set ( parse < UInt64 > ( x ) ) ; <nl> } <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - void SettingTimespan < io_unit > : : serialize ( WriteBuffer & buf , SettingsBinaryFormat format ) const <nl> + template < SettingFieldTimespanIO io_unit > <nl> + void SettingFieldTimespan < io_unit > : : serialize ( WriteBuffer & buf , SettingsBinaryFormat format ) const <nl> { <nl> if ( format > = SettingsBinaryFormat : : STRINGS ) <nl> { <nl> void SettingTimespan < io_unit > : : serialize ( WriteBuffer & buf , SettingsBinaryFormat <nl> writeVarUInt ( value . totalMicroseconds ( ) / microseconds_per_io_unit , buf ) ; <nl> } <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - void SettingTimespan < io_unit > : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) <nl> + template < SettingFieldTimespanIO io_unit > <nl> + void SettingFieldTimespan < io_unit > : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) <nl> { <nl> if ( format > = SettingsBinaryFormat : : STRINGS ) <nl> { <nl> void SettingTimespan < io_unit > : : deserialize ( ReadBuffer & buf , SettingsBinaryForma <nl> set ( x ) ; <nl> } <nl> <nl> - template struct SettingTimespan < SettingTimespanIO : : SECOND > ; <nl> - template struct SettingTimespan < SettingTimespanIO : : MILLISECOND > ; <nl> + template struct SettingFieldTimespan < SettingFieldTimespanIO : : SECOND > ; <nl> + template struct SettingFieldTimespan < SettingFieldTimespanIO : : MILLISECOND > ; <nl> <nl> <nl> - String SettingString : : toString ( ) const <nl> + String SettingFieldString : : toString ( ) const <nl> { <nl> return value ; <nl> } <nl> <nl> - Field SettingString : : toField ( ) const <nl> + Field SettingFieldString : : toField ( ) const <nl> { <nl> return value ; <nl> } <nl> <nl> - void SettingString : : set ( const String & x ) <nl> + void SettingFieldString : : set ( const String & x ) <nl> { <nl> value = x ; <nl> changed = true ; <nl> } <nl> <nl> - void SettingString : : set ( const Field & x ) <nl> + void SettingFieldString : : set ( const Field & x ) <nl> { <nl> set ( safeGet < const String & > ( x ) ) ; <nl> } <nl> <nl> - void SettingString : : serialize ( WriteBuffer & buf , SettingsBinaryFormat ) const <nl> + void SettingFieldString : : serialize ( WriteBuffer & buf , SettingsBinaryFormat ) const <nl> { <nl> writeStringBinary ( value , buf ) ; <nl> } <nl> <nl> - void SettingString : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> + void SettingFieldString : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> { <nl> String s ; <nl> readStringBinary ( s , buf ) ; <nl> void SettingString : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> } <nl> <nl> <nl> - String SettingChar : : toString ( ) const <nl> + String SettingFieldChar : : toString ( ) const <nl> { <nl> return String ( 1 , value ) ; <nl> } <nl> <nl> - Field SettingChar : : toField ( ) const <nl> + Field SettingFieldChar : : toField ( ) const <nl> { <nl> return toString ( ) ; <nl> } <nl> <nl> - void SettingChar : : set ( char x ) <nl> + void SettingFieldChar : : set ( char x ) <nl> { <nl> value = x ; <nl> changed = true ; <nl> } <nl> <nl> - void SettingChar : : set ( const String & x ) <nl> + void SettingFieldChar : : set ( const String & x ) <nl> { <nl> if ( x . size ( ) > 1 ) <nl> throw Exception ( " A setting ' s value string has to be an exactly one character long " , ErrorCodes : : SIZE_OF_FIXED_STRING_DOESNT_MATCH ) ; <nl> void SettingChar : : set ( const String & x ) <nl> set ( c ) ; <nl> } <nl> <nl> - void SettingChar : : set ( const Field & x ) <nl> + void SettingFieldChar : : set ( const Field & x ) <nl> { <nl> const String & s = safeGet < const String & > ( x ) ; <nl> set ( s ) ; <nl> } <nl> <nl> - void SettingChar : : serialize ( WriteBuffer & buf , SettingsBinaryFormat ) const <nl> + void SettingFieldChar : : serialize ( WriteBuffer & buf , SettingsBinaryFormat ) const <nl> { <nl> writeStringBinary ( toString ( ) , buf ) ; <nl> } <nl> <nl> - void SettingChar : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> + void SettingFieldChar : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> { <nl> String s ; <nl> readStringBinary ( s , buf ) ; <nl> void SettingChar : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> <nl> <nl> template < typename EnumType , typename Tag > <nl> - void SettingEnum < EnumType , Tag > : : serialize ( WriteBuffer & buf , SettingsBinaryFormat ) const <nl> + void SettingFieldEnum < EnumType , Tag > : : serialize ( WriteBuffer & buf , SettingsBinaryFormat ) const <nl> { <nl> writeStringBinary ( toString ( ) , buf ) ; <nl> } <nl> <nl> template < typename EnumType , typename Tag > <nl> - void SettingEnum < EnumType , Tag > : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> + void SettingFieldEnum < EnumType , Tag > : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> { <nl> String s ; <nl> readStringBinary ( s , buf ) ; <nl> void SettingEnum < EnumType , Tag > : : deserialize ( ReadBuffer & buf , SettingsBinaryFor <nl> } <nl> <nl> template < typename EnumType , typename Tag > <nl> - Field SettingEnum < EnumType , Tag > : : toField ( ) const <nl> + Field SettingFieldEnum < EnumType , Tag > : : toField ( ) const <nl> { <nl> return toString ( ) ; <nl> } <nl> <nl> template < typename EnumType , typename Tag > <nl> - void SettingEnum < EnumType , Tag > : : set ( const Field & x ) <nl> + void SettingFieldEnum < EnumType , Tag > : : set ( const Field & x ) <nl> { <nl> set ( safeGet < const String & > ( x ) ) ; <nl> } <nl> <nl> <nl> - String SettingURI : : toString ( ) const <nl> + String SettingFieldURI : : toString ( ) const <nl> { <nl> return value . toString ( ) ; <nl> } <nl> <nl> - Field SettingURI : : toField ( ) const <nl> + Field SettingFieldURI : : toField ( ) const <nl> { <nl> return value . toString ( ) ; <nl> } <nl> <nl> - void SettingURI : : set ( const Poco : : URI & x ) <nl> + void SettingFieldURI : : set ( const Poco : : URI & x ) <nl> { <nl> value = x ; <nl> changed = true ; <nl> } <nl> <nl> - void SettingURI : : set ( const Field & x ) <nl> + void SettingFieldURI : : set ( const Field & x ) <nl> { <nl> const String & s = safeGet < const String & > ( x ) ; <nl> set ( s ) ; <nl> } <nl> <nl> - void SettingURI : : set ( const String & x ) <nl> + void SettingFieldURI : : set ( const String & x ) <nl> { <nl> set ( Poco : : URI ( x ) ) ; <nl> } <nl> <nl> - void SettingURI : : serialize ( WriteBuffer & buf , SettingsBinaryFormat ) const <nl> + void SettingFieldURI : : serialize ( WriteBuffer & buf , SettingsBinaryFormat ) const <nl> { <nl> writeStringBinary ( toString ( ) , buf ) ; <nl> } <nl> <nl> - void SettingURI : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> + void SettingFieldURI : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> { <nl> String s ; <nl> readStringBinary ( s , buf ) ; <nl> void SettingURI : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> <nl> # define IMPLEMENT_SETTING_ENUM_WITH_TAG ( ENUM_NAME , TAG , LIST_OF_NAMES_MACRO , ERROR_CODE_FOR_UNEXPECTED_NAME ) \ <nl> template < > \ <nl> - String SettingEnum < ENUM_NAME , TAG > : : toString ( ) const \ <nl> + String SettingFieldEnum < ENUM_NAME , TAG > : : toString ( ) const \ <nl> { \ <nl> using EnumType = ENUM_NAME ; \ <nl> using UnderlyingType = std : : underlying_type < EnumType > : : type ; \ <nl> void SettingURI : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> } \ <nl> \ <nl> template < > \ <nl> - void SettingEnum < ENUM_NAME , TAG > : : set ( const String & s ) \ <nl> + void SettingFieldEnum < ENUM_NAME , TAG > : : set ( const String & s ) \ <nl> { \ <nl> using EnumType = ENUM_NAME ; \ <nl> LIST_OF_NAMES_MACRO ( IMPLEMENT_SETTING_ENUM_FROM_STRING_HELPER_ ) \ <nl> void SettingURI : : deserialize ( ReadBuffer & buf , SettingsBinaryFormat ) <nl> ERROR_CODE_FOR_UNEXPECTED_NAME ) ; \ <nl> } \ <nl> \ <nl> - template struct SettingEnum < ENUM_NAME , TAG > ; <nl> + template struct SettingFieldEnum < ENUM_NAME , TAG > ; <nl> <nl> # define IMPLEMENT_SETTING_ENUM_TO_STRING_HELPER_ ( NAME , IO_NAME ) \ <nl> case static_cast < UnderlyingType > ( EnumType : : NAME ) : return IO_NAME ; <nl> IMPLEMENT_SETTING_ENUM ( OverflowMode , OVERFLOW_MODE_LIST_OF_NAMES , ErrorCodes : : UN <nl> M ( THROW , " throw " ) \ <nl> M ( BREAK , " break " ) \ <nl> M ( ANY , " any " ) <nl> - IMPLEMENT_SETTING_ENUM_WITH_TAG ( OverflowMode , SettingOverflowModeGroupByTag , OVERFLOW_MODE_LIST_OF_NAMES_WITH_ANY , ErrorCodes : : UNKNOWN_OVERFLOW_MODE ) <nl> + IMPLEMENT_SETTING_ENUM_WITH_TAG ( OverflowMode , SettingFieldOverflowModeGroupByTag , OVERFLOW_MODE_LIST_OF_NAMES_WITH_ANY , ErrorCodes : : UNKNOWN_OVERFLOW_MODE ) <nl> <nl> <nl> # define DISTRIBUTED_PRODUCT_MODE_LIST_OF_NAMES ( M ) \ <nl> mmm a / src / Core / SettingsCollection . h <nl> ppp b / src / Core / SettingsCollection . h <nl> enum class SettingsBinaryFormat ; <nl> * / <nl> <nl> template < typename Type > <nl> - struct SettingNumber <nl> + struct SettingFieldNumber <nl> { <nl> Type value ; <nl> bool changed = false ; <nl> <nl> - SettingNumber ( Type x = 0 ) : value ( x ) { } <nl> + SettingFieldNumber ( Type x = 0 ) : value ( x ) { } <nl> <nl> operator Type ( ) const { return value ; } <nl> - SettingNumber & operator = ( Type x ) { set ( x ) ; return * this ; } <nl> + SettingFieldNumber & operator = ( Type x ) { set ( x ) ; return * this ; } <nl> <nl> / / / Serialize to a test string . <nl> String toString ( ) const ; <nl> struct SettingNumber <nl> void deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) ; <nl> } ; <nl> <nl> - using SettingUInt64 = SettingNumber < UInt64 > ; <nl> - using SettingInt64 = SettingNumber < Int64 > ; <nl> - using SettingFloat = SettingNumber < float > ; <nl> - using SettingBool = SettingNumber < bool > ; <nl> + using SettingFieldUInt64 = SettingFieldNumber < UInt64 > ; <nl> + using SettingFieldInt64 = SettingFieldNumber < Int64 > ; <nl> + using SettingFieldFloat = SettingFieldNumber < float > ; <nl> + using SettingFieldBool = SettingFieldNumber < bool > ; <nl> <nl> <nl> / * * Unlike SettingUInt64 , supports the value of ' auto ' - the number of processor cores without taking into account SMT . <nl> * A value of 0 is also treated as auto . <nl> * When serializing , ` auto ` is written in the same way as 0 . <nl> * / <nl> - struct SettingMaxThreads <nl> + struct SettingFieldMaxThreads <nl> { <nl> UInt64 value ; <nl> bool is_auto ; <nl> bool changed = false ; <nl> <nl> - SettingMaxThreads ( UInt64 x = 0 ) : value ( x ? x : getAutoValue ( ) ) , is_auto ( x = = 0 ) { } <nl> + SettingFieldMaxThreads ( UInt64 x = 0 ) : value ( x ? x : getAutoValue ( ) ) , is_auto ( x = = 0 ) { } <nl> <nl> operator UInt64 ( ) const { return value ; } <nl> - SettingMaxThreads & operator = ( UInt64 x ) { set ( x ) ; return * this ; } <nl> + SettingFieldMaxThreads & operator = ( UInt64 x ) { set ( x ) ; return * this ; } <nl> <nl> String toString ( ) const ; <nl> Field toField ( ) const ; <nl> struct SettingMaxThreads <nl> } ; <nl> <nl> <nl> - enum class SettingTimespanIO { MILLISECOND , SECOND } ; <nl> + enum class SettingFieldTimespanIO { MILLISECOND , SECOND } ; <nl> <nl> - template < SettingTimespanIO io_unit > <nl> - struct SettingTimespan <nl> + template < SettingFieldTimespanIO io_unit > <nl> + struct SettingFieldTimespan <nl> { <nl> Poco : : Timespan value ; <nl> bool changed = false ; <nl> <nl> - SettingTimespan ( UInt64 x = 0 ) : value ( x * microseconds_per_io_unit ) { } <nl> + SettingFieldTimespan ( UInt64 x = 0 ) : value ( x * microseconds_per_io_unit ) { } <nl> <nl> operator Poco : : Timespan ( ) const { return value ; } <nl> - SettingTimespan & operator = ( const Poco : : Timespan & x ) { set ( x ) ; return * this ; } <nl> + SettingFieldTimespan & operator = ( const Poco : : Timespan & x ) { set ( x ) ; return * this ; } <nl> <nl> template < class Rep , class Period = std : : ratio < 1 > > <nl> operator std : : chrono : : duration < Rep , Period > ( ) const { return std : : chrono : : duration_cast < std : : chrono : : duration < Rep , Period > > ( std : : chrono : : microseconds ( value . totalMicroseconds ( ) ) ) ; } <nl> <nl> template < class Rep , class Period = std : : ratio < 1 > > <nl> - SettingTimespan & operator = ( const std : : chrono : : duration < Rep , Period > & x ) { set ( x ) ; return * this ; } <nl> + SettingFieldTimespan & operator = ( const std : : chrono : : duration < Rep , Period > & x ) { set ( x ) ; return * this ; } <nl> <nl> Poco : : Timespan : : TimeDiff totalSeconds ( ) const { return value . totalSeconds ( ) ; } <nl> Poco : : Timespan : : TimeDiff totalMilliseconds ( ) const { return value . totalMilliseconds ( ) ; } <nl> struct SettingTimespan <nl> void serialize ( WriteBuffer & buf , SettingsBinaryFormat format ) const ; <nl> void deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) ; <nl> <nl> - static constexpr UInt64 microseconds_per_io_unit = ( io_unit = = SettingTimespanIO : : MILLISECOND ) ? 1000 : 1000000 ; <nl> + static constexpr UInt64 microseconds_per_io_unit = ( io_unit = = SettingFieldTimespanIO : : MILLISECOND ) ? 1000 : 1000000 ; <nl> } ; <nl> <nl> - using SettingSeconds = SettingTimespan < SettingTimespanIO : : SECOND > ; <nl> - using SettingMilliseconds = SettingTimespan < SettingTimespanIO : : MILLISECOND > ; <nl> + using SettingFieldSeconds = SettingFieldTimespan < SettingFieldTimespanIO : : SECOND > ; <nl> + using SettingFieldMilliseconds = SettingFieldTimespan < SettingFieldTimespanIO : : MILLISECOND > ; <nl> <nl> <nl> - struct SettingString <nl> + struct SettingFieldString <nl> { <nl> String value ; <nl> bool changed = false ; <nl> <nl> - SettingString ( const String & x = String { } ) : value ( x ) { } <nl> + SettingFieldString ( const String & x = String { } ) : value ( x ) { } <nl> <nl> operator String ( ) const { return value ; } <nl> - SettingString & operator = ( const String & x ) { set ( x ) ; return * this ; } <nl> + SettingFieldString & operator = ( const String & x ) { set ( x ) ; return * this ; } <nl> <nl> String toString ( ) const ; <nl> Field toField ( ) const ; <nl> struct SettingString <nl> } ; <nl> <nl> <nl> - struct SettingChar <nl> + struct SettingFieldChar <nl> { <nl> public : <nl> char value ; <nl> bool changed = false ; <nl> <nl> - SettingChar ( char x = ' \ 0 ' ) : value ( x ) { } <nl> + SettingFieldChar ( char x = ' \ 0 ' ) : value ( x ) { } <nl> <nl> operator char ( ) const { return value ; } <nl> - SettingChar & operator = ( char x ) { set ( x ) ; return * this ; } <nl> + SettingFieldChar & operator = ( char x ) { set ( x ) ; return * this ; } <nl> <nl> String toString ( ) const ; <nl> Field toField ( ) const ; <nl> struct SettingChar <nl> <nl> / / / Template class to define enum - based settings . <nl> template < typename EnumType , typename Tag = void > <nl> - struct SettingEnum <nl> + struct SettingFieldEnum <nl> { <nl> EnumType value ; <nl> bool changed = false ; <nl> <nl> - SettingEnum ( EnumType x ) : value ( x ) { } <nl> + SettingFieldEnum ( EnumType x ) : value ( x ) { } <nl> <nl> operator EnumType ( ) const { return value ; } <nl> - SettingEnum & operator = ( EnumType x ) { set ( x ) ; return * this ; } <nl> + SettingFieldEnum & operator = ( EnumType x ) { set ( x ) ; return * this ; } <nl> <nl> String toString ( ) const ; <nl> Field toField ( ) const ; <nl> struct SettingEnum <nl> void deserialize ( ReadBuffer & buf , SettingsBinaryFormat format ) ; <nl> } ; <nl> <nl> - struct SettingURI <nl> + struct SettingFieldURI <nl> { <nl> Poco : : URI value ; <nl> bool changed = false ; <nl> <nl> - SettingURI ( const Poco : : URI & x = Poco : : URI { } ) : value ( x ) { } <nl> + SettingFieldURI ( const Poco : : URI & x = Poco : : URI { } ) : value ( x ) { } <nl> <nl> operator Poco : : URI ( ) const { return value ; } <nl> - SettingURI & operator = ( const Poco : : URI & x ) { set ( x ) ; return * this ; } <nl> + SettingFieldURI & operator = ( const Poco : : URI & x ) { set ( x ) ; return * this ; } <nl> <nl> String toString ( ) const ; <nl> Field toField ( ) const ; <nl> enum class LoadBalancing <nl> / / round robin across replicas with the same number of errors . <nl> ROUND_ROBIN , <nl> } ; <nl> - using SettingLoadBalancing = SettingEnum < LoadBalancing > ; <nl> + using SettingFieldLoadBalancing = SettingFieldEnum < LoadBalancing > ; <nl> <nl> <nl> enum class JoinStrictness <nl> enum class JoinStrictness <nl> ALL , / / / Query JOIN without strictness - > ALL JOIN . . . <nl> ANY , / / / Query JOIN without strictness - > ANY JOIN . . . <nl> } ; <nl> - using SettingJoinStrictness = SettingEnum < JoinStrictness > ; <nl> + using SettingFieldJoinStrictness = SettingFieldEnum < JoinStrictness > ; <nl> <nl> enum class JoinAlgorithm <nl> { <nl> enum class JoinAlgorithm <nl> PARTIAL_MERGE , <nl> PREFER_PARTIAL_MERGE , <nl> } ; <nl> - using SettingJoinAlgorithm = SettingEnum < JoinAlgorithm > ; <nl> + using SettingFieldJoinAlgorithm = SettingFieldEnum < JoinAlgorithm > ; <nl> <nl> <nl> enum class SpecialSort <nl> enum class SpecialSort <nl> NOT_SPECIFIED = 0 , <nl> OPENCL_BITONIC , <nl> } ; <nl> - using SettingSpecialSort = SettingEnum < SpecialSort > ; <nl> + using SettingFieldSpecialSort = SettingFieldEnum < SpecialSort > ; <nl> <nl> <nl> / / / Which rows should be included in TOTALS . <nl> enum class TotalsMode <nl> AFTER_HAVING_EXCLUSIVE = 2 , / / / Include only the rows that passed and max_rows_to_group_by , and HAVING . <nl> AFTER_HAVING_AUTO = 3 , / / / Automatically select between INCLUSIVE and EXCLUSIVE , <nl> } ; <nl> - using SettingTotalsMode = SettingEnum < TotalsMode > ; <nl> + using SettingFieldTotalsMode = SettingFieldEnum < TotalsMode > ; <nl> <nl> <nl> / / / The settings keeps OverflowMode which cannot be OverflowMode : : ANY . <nl> - using SettingOverflowMode = SettingEnum < OverflowMode > ; <nl> - struct SettingOverflowModeGroupByTag ; <nl> + using SettingFieldOverflowMode = SettingFieldEnum < OverflowMode > ; <nl> + struct SettingFieldOverflowModeGroupByTag ; <nl> <nl> / / / The settings keeps OverflowMode which can be OverflowMode : : ANY . <nl> - using SettingOverflowModeGroupBy = SettingEnum < OverflowMode , SettingOverflowModeGroupByTag > ; <nl> + using SettingFieldOverflowModeGroupBy = SettingFieldEnum < OverflowMode , SettingFieldOverflowModeGroupByTag > ; <nl> <nl> <nl> / / / The setting for executing distributed subqueries inside IN or JOIN sections . <nl> enum class DistributedProductMode <nl> GLOBAL , / / / Convert to global query <nl> ALLOW / / / Enable <nl> } ; <nl> - using SettingDistributedProductMode = SettingEnum < DistributedProductMode > ; <nl> + using SettingFieldDistributedProductMode = SettingFieldEnum < DistributedProductMode > ; <nl> <nl> <nl> - using SettingDateTimeInputFormat = SettingEnum < FormatSettings : : DateTimeInputFormat > ; <nl> + using SettingFieldDateTimeInputFormat = SettingFieldEnum < FormatSettings : : DateTimeInputFormat > ; <nl> <nl> <nl> enum class LogsLevel <nl> enum class LogsLevel <nl> debug , <nl> trace , <nl> } ; <nl> - using SettingLogsLevel = SettingEnum < LogsLevel > ; <nl> + using SettingFieldLogsLevel = SettingFieldEnum < LogsLevel > ; <nl> <nl> enum class DefaultDatabaseEngine <nl> { <nl> Ordinary , <nl> Atomic , <nl> } ; <nl> - using SettingDefaultDatabaseEngine = SettingEnum < DefaultDatabaseEngine > ; <nl> + using SettingFieldDefaultDatabaseEngine = SettingFieldEnum < DefaultDatabaseEngine > ; <nl> <nl> / / Make it signed for compatibility with DataTypeEnum8 <nl> enum QueryLogElementType : int8_t <nl> enum QueryLogElementType : int8_t <nl> EXCEPTION_BEFORE_START = 3 , <nl> EXCEPTION_WHILE_PROCESSING = 4 , <nl> } ; <nl> - using SettingLogQueriesType = SettingEnum < QueryLogElementType > ; <nl> + using SettingFieldLogQueriesType = SettingFieldEnum < QueryLogElementType > ; <nl> <nl> <nl> enum class SettingsBinaryFormat <nl> class SettingsCollection <nl> LIST_OF_SETTINGS_MACRO ( DECLARE_SETTINGS_COLLECTION_DECLARE_VARIABLES_HELPER_ ) <nl> <nl> # define DECLARE_SETTINGS_COLLECTION_DECLARE_VARIABLES_HELPER_ ( TYPE , NAME , DEFAULT , DESCRIPTION , FLAGS ) \ <nl> - Setting # # TYPE NAME { DEFAULT } ; <nl> + SettingField # # TYPE NAME { DEFAULT } ; <nl> } <nl> mmm a / src / Core / SettingsCollectionImpl . h <nl> ppp b / src / Core / SettingsCollectionImpl . h <nl> void SettingsCollection < Derived > : : deserialize ( ReadBuffer & buf , SettingsBinaryFo <nl> static void NAME # # _setField ( Derived & collection , const Field & value ) { collection . NAME . set ( value ) ; } \ <nl> static void NAME # # _serialize ( const Derived & collection , WriteBuffer & buf , SettingsBinaryFormat format ) { collection . NAME . serialize ( buf , format ) ; } \ <nl> static void NAME # # _deserialize ( Derived & collection , ReadBuffer & buf , SettingsBinaryFormat format ) { collection . NAME . deserialize ( buf , format ) ; } \ <nl> - static String NAME # # _valueToString ( const Field & value ) { Setting # # TYPE temp { DEFAULT } ; temp . set ( value ) ; return temp . toString ( ) ; } \ <nl> - static Field NAME # # _valueToCorrespondingType ( const Field & value ) { Setting # # TYPE temp { DEFAULT } ; temp . set ( value ) ; return temp . toField ( ) ; } \ <nl> + static String NAME # # _valueToString ( const Field & value ) { SettingField # # TYPE temp { DEFAULT } ; temp . set ( value ) ; return temp . toString ( ) ; } \ <nl> + static Field NAME # # _valueToCorrespondingType ( const Field & value ) { SettingField # # TYPE temp { DEFAULT } ; temp . set ( value ) ; return temp . toField ( ) ; } \ <nl> <nl> <nl> # define IMPLEMENT_SETTINGS_COLLECTION_ADD_MEMBER_INFO_HELPER_ ( TYPE , NAME , DEFAULT , DESCRIPTION , FLAGS ) \ <nl> | Rename Setting * = > SettingField * . | ClickHouse/ClickHouse | d152e84a2ea947ae94dc53e31f52302fdf22bf12 | 2020-07-31T16:11:27Z |
mmm a / php_swoole . h <nl> ppp b / php_swoole . h <nl> static sw_inline void swoole_set_object ( zval * object , void * ptr ) <nl> } <nl> assert ( handle < SW_MAX_SOCKET_ID ) ; <nl> swoole_objects . array = erealloc ( swoole_objects . array , sizeof ( void * ) * swoole_objects . size ) ; <nl> - bzero ( swoole_objects . array + ( old_size * sizeof ( void * ) ) , ( swoole_objects . size - old_size ) * sizeof ( void * ) ) ; <nl> + bzero ( ( ( void * ) swoole_objects . array ) + ( old_size * sizeof ( void * ) ) , ( swoole_objects . size - old_size ) * sizeof ( void * ) ) ; <nl> } <nl> swoole_objects . array [ handle ] = ptr ; <nl> } <nl> mmm a / swoole . c <nl> ppp b / swoole . c <nl> PHP_RINIT_FUNCTION ( swoole ) <nl> } <nl> <nl> swoole_objects . size = 65536 ; <nl> - swoole_objects . array = emalloc ( sizeof ( void * ) * swoole_objects . size ) ; <nl> + swoole_objects . array = ecalloc ( swoole_objects . size , sizeof ( void * ) ) ; <nl> <nl> # ifdef SW_DEBUG_REMOTE_OPEN <nl> swoole_open_remote_debug ( ) ; <nl> | fixed bzero out of the memory . | swoole/swoole-src | 3bfc3626f351df9d5bc42f999d798df5fa03ef15 | 2015-06-23T07:15:19Z |
mmm a / DEPS <nl> ppp b / DEPS <nl> vars = { <nl> <nl> deps = { <nl> ' build ' : <nl> - Var ( ' chromium_url ' ) + ' / chromium / src / build . git ' + ' @ ' + ' 4fd0dec37b78efe519e20bb4bdbf0e503339579d ' , <nl> + Var ( ' chromium_url ' ) + ' / chromium / src / build . git ' + ' @ ' + ' b031112684a2a4ee47da9dd91d9aa50e17ab14d4 ' , <nl> ' third_party / depot_tools ' : <nl> Var ( ' chromium_url ' ) + ' / chromium / tools / depot_tools . git ' + ' @ ' + ' 6d2a0fef93155cb26724fbc0430f7a6f1d1aaed1 ' , <nl> ' third_party / icu ' : <nl> | Update V8 DEPS . | v8/v8 | a90fdd2c1033ea5c3328593978f00656e35b2b0b | 2020-12-01T19:10:52Z |
mmm a / xbmc / GUIInfoManager . cpp <nl> ppp b / xbmc / GUIInfoManager . cpp <nl> const infomap container_bools [ ] = { { " onnext " , CONTAINER_MOVE_NEXT } , <nl> { " hasprevious " , CONTAINER_HAS_PREVIOUS } , <nl> { " canfilter " , CONTAINER_CAN_FILTER } , <nl> { " canfilteradvanced " , CONTAINER_CAN_FILTERADVANCED } , <nl> - { " filtered " , CONTAINER_FILTERED } } ; <nl> + { " filtered " , CONTAINER_FILTERED } , <nl> + { " isupdating " , CONTAINER_ISUPDATING } } ; <nl> <nl> const infomap container_ints [ ] = { { " row " , CONTAINER_ROW } , <nl> { " column " , CONTAINER_COLUMN } , <nl> bool CGUIInfoManager : : GetBool ( int condition1 , int contextWindow , const CGUIListI <nl> if ( pWindow ) <nl> bReturn = ( ( CGUIMediaWindow * ) pWindow ) - > CurrentDirectory ( ) . HasArt ( " thumb " ) ; <nl> } <nl> - else if ( condition = = CONTAINER_HAS_NEXT | | condition = = CONTAINER_HAS_PREVIOUS | | condition = = CONTAINER_SCROLLING ) <nl> + else if ( condition = = CONTAINER_HAS_NEXT | | condition = = CONTAINER_HAS_PREVIOUS <nl> + | | condition = = CONTAINER_SCROLLING | | condition = = CONTAINER_ISUPDATING ) <nl> { <nl> CGUIWindow * window = GetWindowWithCondition ( contextWindow , WINDOW_CONDITION_IS_MEDIA_WINDOW ) ; <nl> if ( window ) <nl> bool CGUIInfoManager : : GetMultiInfoBool ( const GUIInfo & info , int contextWindow , c <nl> case CONTAINER_HAS_PREVIOUS : <nl> case CONTAINER_SCROLLING : <nl> case CONTAINER_SUBITEM : <nl> + case CONTAINER_ISUPDATING : <nl> { <nl> const CGUIControl * control = NULL ; <nl> if ( info . GetData1 ( ) ) <nl> mmm a / xbmc / GUIInfoManager . h <nl> ppp b / xbmc / GUIInfoManager . h <nl> namespace INFO <nl> # define CONTAINER_STATIC 347 <nl> # define CONTAINER_MOVE_NEXT 348 <nl> # define CONTAINER_SCROLL_NEXT 349 <nl> - <nl> + # define CONTAINER_ISUPDATING 350 <nl> # define CONTAINER_HASFILES 351 <nl> # define CONTAINER_HASFOLDERS 352 <nl> # define CONTAINER_STACKED 353 <nl> mmm a / xbmc / guilib / GUIBaseContainer . cpp <nl> ppp b / xbmc / guilib / GUIBaseContainer . cpp <nl> bool CGUIBaseContainer : : GetCondition ( int condition , int data ) const <nl> } <nl> case CONTAINER_SCROLLING : <nl> return ( m_scrollTimer . GetElapsedMilliseconds ( ) > std : : max ( m_scroller . GetDuration ( ) , SCROLLING_THRESHOLD ) | | m_pageChangeTimer . IsRunning ( ) ) ; <nl> + case CONTAINER_ISUPDATING : <nl> + return ( m_listProvider ) ? m_listProvider - > IsUpdating ( ) : false ; <nl> default : <nl> return false ; <nl> } <nl> | Merge pull request from Black09 / container - isupdating | xbmc/xbmc | 44040c976aa59f3f89982e99ee0e2a31bbe4caac | 2014-04-28T09:47:07Z |
mmm a / dbms / programs / main . cpp <nl> ppp b / dbms / programs / main . cpp <nl> <nl> # include < signal . h > <nl> # include < setjmp . h > <nl> + # include < unistd . h > <nl> <nl> # include < new > <nl> # include < iostream > <nl> enum class InstructionFail <nl> AVX512 = 7 <nl> } ; <nl> <nl> - std : : string instructionFailToString ( InstructionFail fail ) <nl> + const char * instructionFailToString ( InstructionFail fail ) <nl> { <nl> switch ( fail ) <nl> { <nl> void checkRequiredInstructionsImpl ( volatile InstructionFail & fail ) <nl> fail = InstructionFail : : NONE ; <nl> } <nl> <nl> - / / / Check SSE and others instructions availability <nl> - / / / Calls exit on fail <nl> - / / / This function must be called as early inside main as possible . <nl> + / / / This function is safe to use in static initializers . <nl> + void writeError ( const char * data , size_t size ) <nl> + { <nl> + while ( size ! = 0 ) <nl> + { <nl> + ssize_t res = : : write ( STDERR_FILENO , data , size ) ; <nl> + <nl> + if ( ( - 1 = = res | | 0 = = res ) & & errno ! = EINTR ) <nl> + _Exit ( 1 ) ; <nl> + <nl> + if ( res > 0 ) <nl> + { <nl> + data + = res ; <nl> + size - = res ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / / Check SSE and others instructions availability . Calls exit on fail . <nl> + / / / This function must be called as early as possible , even before main , because static initializers may use unavailable instructions . <nl> void checkRequiredInstructions ( ) <nl> { <nl> struct sigaction sa { } ; <nl> void checkRequiredInstructions ( ) <nl> | | sigaddset ( & sa . sa_mask , signal ) ! = 0 <nl> | | sigaction ( signal , & sa , & sa_old ) ! = 0 ) <nl> { <nl> - std : : cerr < < " Can not set signal handler \ n " ; <nl> - exit ( 1 ) ; <nl> + / / / You may wonder about strlen . <nl> + / / / Typical implementation of strlen is using SSE4 . 2 or AVX2 . <nl> + / / / But this is not the case because it ' s compiler builtin and is executed at compile time . <nl> + <nl> + const char * msg = " Can not set signal handler \ n " ; <nl> + writeError ( msg , strlen ( msg ) ) ; <nl> + _Exit ( 1 ) ; <nl> } <nl> <nl> volatile InstructionFail fail = InstructionFail : : NONE ; <nl> <nl> if ( sigsetjmp ( jmpbuf , 1 ) ) <nl> { <nl> - std : : cerr < < " Instruction check fail . There is no " < < instructionFailToString ( fail ) < < " instruction set \ n " ; <nl> - exit ( 1 ) ; <nl> + const char * msg1 = " Instruction check fail . The CPU does not support " ; <nl> + writeError ( msg1 , strlen ( msg1 ) ) ; <nl> + const char * msg2 = instructionFailToString ( fail ) ; <nl> + writeError ( msg2 , strlen ( msg2 ) ) ; <nl> + const char * msg3 = " instruction set . \ n " ; <nl> + writeError ( msg3 , strlen ( msg3 ) ) ; <nl> + _Exit ( 1 ) ; <nl> } <nl> <nl> checkRequiredInstructionsImpl ( fail ) ; <nl> <nl> if ( sigaction ( signal , & sa_old , nullptr ) ) <nl> { <nl> - std : : cerr < < " Can not set signal handler \ n " ; <nl> - exit ( 1 ) ; <nl> + const char * msg = " Can not set signal handler \ n " ; <nl> + writeError ( msg , strlen ( msg ) ) ; <nl> + _Exit ( 1 ) ; <nl> } <nl> } <nl> <nl> + struct Checker { Checker ( ) { checkRequiredInstructions ( ) ; } } checker ; <nl> + <nl> } <nl> <nl> <nl> bool inside_main = false ; <nl> <nl> int main ( int argc_ , char * * argv_ ) <nl> { <nl> - checkRequiredInstructions ( ) ; <nl> - <nl> inside_main = true ; <nl> SCOPE_EXIT ( { inside_main = false ; } ) ; <nl> <nl> | Proper check | ClickHouse/ClickHouse | 6eb98d8c77b78320c75a8450ef625ca0d84ebcad | 2020-03-26T17:53:57Z |
mmm a / src / bootstrapper . cc <nl> ppp b / src / bootstrapper . cc <nl> void Genesis : : TransferNamedProperties ( Handle < JSObject > from , <nl> / / Copy all keys and values in enumeration order . <nl> Handle < GlobalDictionary > properties = <nl> Handle < GlobalDictionary > ( from - > global_dictionary ( ) ) ; <nl> - Handle < FixedArray > key_indices = <nl> - GlobalDictionary : : IterationIndices ( properties ) ; <nl> - for ( int i = 0 ; i < key_indices - > length ( ) ; i + + ) { <nl> - int key_index = Smi : : cast ( key_indices - > get ( i ) ) - > value ( ) ; <nl> - Object * raw_key = properties - > KeyAt ( key_index ) ; <nl> - DCHECK ( properties - > IsKey ( isolate ( ) , raw_key ) ) ; <nl> - DCHECK ( raw_key - > IsName ( ) ) ; <nl> + Handle < FixedArray > indices = GlobalDictionary : : IterationIndices ( properties ) ; <nl> + for ( int i = 0 ; i < indices - > length ( ) ; i + + ) { <nl> + int index = Smi : : cast ( indices - > get ( i ) ) - > value ( ) ; <nl> / / If the property is already there we skip it . <nl> - Handle < Name > key ( Name : : cast ( raw_key ) , isolate ( ) ) ; <nl> + Handle < PropertyCell > cell ( properties - > CellAt ( index ) ) ; <nl> + Handle < Name > key ( cell - > name ( ) , isolate ( ) ) ; <nl> LookupIterator it ( to , key , LookupIterator : : OWN_SKIP_INTERCEPTOR ) ; <nl> CHECK_NE ( LookupIterator : : ACCESS_CHECK , it . state ( ) ) ; <nl> if ( it . IsFound ( ) ) continue ; <nl> / / Set the property . <nl> - DCHECK ( properties - > ValueAt ( key_index ) - > IsPropertyCell ( ) ) ; <nl> - Handle < PropertyCell > cell ( <nl> - PropertyCell : : cast ( properties - > ValueAt ( key_index ) ) , isolate ( ) ) ; <nl> Handle < Object > value ( cell - > value ( ) , isolate ( ) ) ; <nl> if ( value - > IsTheHole ( isolate ( ) ) ) continue ; <nl> PropertyDetails details = cell - > property_details ( ) ; <nl> mmm a / src / code - stub - assembler . cc <nl> ppp b / src / code - stub - assembler . cc <nl> void CodeStubAssembler : : SetNextEnumerationIndex ( Node * dictionary , <nl> next_enum_index_smi , SKIP_WRITE_BARRIER ) ; <nl> } <nl> <nl> + template < > <nl> + Node * CodeStubAssembler : : LoadName < NameDictionary > ( Node * key ) { <nl> + CSA_ASSERT ( this , Word32Or ( IsTheHole ( key ) , IsName ( key ) ) ) ; <nl> + return key ; <nl> + } <nl> + <nl> + template < > <nl> + Node * CodeStubAssembler : : LoadName < GlobalDictionary > ( Node * key ) { <nl> + CSA_ASSERT ( this , IsPropertyCell ( key ) ) ; <nl> + CSA_ASSERT ( this , IsNotTheHole ( key ) ) ; <nl> + return LoadObjectField ( key , PropertyCell : : kNameOffset ) ; <nl> + } <nl> + <nl> template < typename Dictionary > <nl> void CodeStubAssembler : : NameDictionaryLookup ( Node * dictionary , <nl> Node * unique_name , Label * if_found , <nl> void CodeStubAssembler : : NameDictionaryLookup ( Node * dictionary , <nl> / / See Dictionary : : FirstProbe ( ) . <nl> Node * count = IntPtrConstant ( 0 ) ; <nl> Node * entry = WordAnd ( hash , mask ) ; <nl> + Node * undefined = UndefinedConstant ( ) ; <nl> <nl> for ( int i = 0 ; i < inlined_probes ; i + + ) { <nl> Node * index = EntryToIndex < Dictionary > ( entry ) ; <nl> var_name_index - > Bind ( index ) ; <nl> <nl> Node * current = LoadFixedArrayElement ( dictionary , index ) ; <nl> + GotoIf ( WordEqual ( current , undefined ) , if_not_found ) ; <nl> + current = LoadName < Dictionary > ( current ) ; <nl> GotoIf ( WordEqual ( current , unique_name ) , if_found ) ; <nl> <nl> / / See Dictionary : : NextProbe ( ) . <nl> void CodeStubAssembler : : NameDictionaryLookup ( Node * dictionary , <nl> var_name_index - > Bind ( IntPtrConstant ( 0 ) ) ; <nl> } <nl> <nl> - Node * undefined = UndefinedConstant ( ) ; <nl> Node * the_hole = mode = = kFindExisting ? nullptr : TheHoleConstant ( ) ; <nl> <nl> VARIABLE ( var_count , MachineType : : PointerRepresentation ( ) , count ) ; <nl> void CodeStubAssembler : : NameDictionaryLookup ( Node * dictionary , <nl> Node * current = LoadFixedArrayElement ( dictionary , index ) ; <nl> GotoIf ( WordEqual ( current , undefined ) , if_not_found ) ; <nl> if ( mode = = kFindExisting ) { <nl> + current = LoadName < Dictionary > ( current ) ; <nl> GotoIf ( WordEqual ( current , unique_name ) , if_found ) ; <nl> } else { <nl> DCHECK_EQ ( kFindInsertionIndex , mode ) ; <nl> void CodeStubAssembler : : LoadPropertyFromGlobalDictionary ( Node * dictionary , <nl> Comment ( " [ LoadPropertyFromGlobalDictionary " ) ; <nl> CSA_ASSERT ( this , IsDictionary ( dictionary ) ) ; <nl> <nl> - Node * property_cell = <nl> - LoadValueByKeyIndex < GlobalDictionary > ( dictionary , name_index ) ; <nl> + Node * property_cell = LoadFixedArrayElement ( dictionary , name_index ) ; <nl> + CSA_ASSERT ( this , IsPropertyCell ( property_cell ) ) ; <nl> <nl> Node * value = LoadObjectField ( property_cell , PropertyCell : : kValueOffset ) ; <nl> GotoIf ( WordEqual ( value , TheHoleConstant ( ) ) , if_deleted ) ; <nl> mmm a / src / code - stub - assembler . h <nl> ppp b / src / code - stub - assembler . h <nl> class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler : : CodeAssembler { <nl> / / { if_not_found } . <nl> static const int kInlinedDictionaryProbes = 4 ; <nl> enum LookupMode { kFindExisting , kFindInsertionIndex } ; <nl> + <nl> + template < typename Dictionary > <nl> + Node * LoadName ( Node * key ) ; <nl> + <nl> template < typename Dictionary > <nl> void NameDictionaryLookup ( Node * dictionary , Node * unique_name , <nl> Label * if_found , Variable * var_name_index , <nl> mmm a / src / elements . cc <nl> ppp b / src / elements . cc <nl> class DictionaryElementsAccessor <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> Object * key = dict - > KeyAt ( i ) ; <nl> if ( ! dict - > IsKey ( isolate , key ) ) continue ; <nl> - DCHECK ( ! dict - > IsDeleted ( i ) ) ; <nl> PropertyDetails details = dict - > DetailsAt ( i ) ; <nl> if ( details . kind ( ) = = kAccessor ) return true ; <nl> } <nl> class DictionaryElementsAccessor <nl> <nl> static uint32_t FilterKey ( Handle < SeededNumberDictionary > dictionary , <nl> int entry , Object * raw_key , PropertyFilter filter ) { <nl> - DCHECK ( ! dictionary - > IsDeleted ( entry ) ) ; <nl> DCHECK ( raw_key - > IsNumber ( ) ) ; <nl> DCHECK_LE ( raw_key - > Number ( ) , kMaxUInt32 ) ; <nl> PropertyDetails details = dictionary - > DetailsAt ( entry ) ; <nl> class DictionaryElementsAccessor <nl> KeyAccumulator * accumulator , <nl> AddKeyConversion convert ) { <nl> Isolate * isolate = accumulator - > isolate ( ) ; <nl> - Handle < Object > undefined = isolate - > factory ( ) - > undefined_value ( ) ; <nl> - Handle < Object > the_hole = isolate - > factory ( ) - > the_hole_value ( ) ; <nl> Handle < SeededNumberDictionary > dictionary ( <nl> SeededNumberDictionary : : cast ( receiver - > elements ( ) ) , isolate ) ; <nl> int capacity = dictionary - > Capacity ( ) ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> Object * k = dictionary - > KeyAt ( i ) ; <nl> - if ( k = = * undefined ) continue ; <nl> - if ( k = = * the_hole ) continue ; <nl> - if ( dictionary - > IsDeleted ( i ) ) continue ; <nl> + if ( ! dictionary - > IsKey ( isolate , k ) ) continue ; <nl> Object * value = dictionary - > ValueAt ( i ) ; <nl> DCHECK ( ! value - > IsTheHole ( isolate ) ) ; <nl> DCHECK ( ! value - > IsAccessorPair ( ) ) ; <nl> mmm a / src / factory . cc <nl> ppp b / src / factory . cc <nl> Handle < Cell > Factory : : NewManyClosuresCell ( Handle < Object > value ) { <nl> return cell ; <nl> } <nl> <nl> - Handle < PropertyCell > Factory : : NewPropertyCell ( ) { <nl> - CALL_HEAP_FUNCTION ( <nl> - isolate ( ) , <nl> - isolate ( ) - > heap ( ) - > AllocatePropertyCell ( ) , <nl> - PropertyCell ) ; <nl> + Handle < PropertyCell > Factory : : NewPropertyCell ( Handle < Name > name ) { <nl> + CALL_HEAP_FUNCTION ( isolate ( ) , isolate ( ) - > heap ( ) - > AllocatePropertyCell ( * name ) , <nl> + PropertyCell ) ; <nl> } <nl> <nl> <nl> Handle < JSGlobalObject > Factory : : NewJSGlobalObject ( <nl> PropertyDetails d ( kAccessor , details . attributes ( ) , <nl> PropertyCellType : : kMutable ) ; <nl> Handle < Name > name ( descs - > GetKey ( i ) ) ; <nl> - Handle < PropertyCell > cell = NewPropertyCell ( ) ; <nl> + Handle < PropertyCell > cell = NewPropertyCell ( name ) ; <nl> cell - > set_value ( descs - > GetValue ( i ) ) ; <nl> / / | dictionary | already contains enough space for all properties . <nl> USE ( GlobalDictionary : : Add ( dictionary , name , cell , d ) ) ; <nl> mmm a / src / factory . h <nl> ppp b / src / factory . h <nl> class V8_EXPORT_PRIVATE Factory final { <nl> <nl> Handle < Cell > NewCell ( Handle < Object > value ) ; <nl> <nl> - Handle < PropertyCell > NewPropertyCell ( ) ; <nl> + Handle < PropertyCell > NewPropertyCell ( Handle < Name > name ) ; <nl> <nl> Handle < WeakCell > NewWeakCell ( Handle < HeapObject > value ) ; <nl> <nl> mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> AllocationResult Heap : : AllocateCell ( Object * value ) { <nl> return result ; <nl> } <nl> <nl> - AllocationResult Heap : : AllocatePropertyCell ( ) { <nl> + AllocationResult Heap : : AllocatePropertyCell ( Name * name ) { <nl> + DCHECK ( name - > IsUniqueName ( ) ) ; <nl> int size = PropertyCell : : kSize ; <nl> STATIC_ASSERT ( PropertyCell : : kSize < = kMaxRegularHeapObjectSize ) ; <nl> <nl> AllocationResult Heap : : AllocatePropertyCell ( ) { <nl> cell - > set_dependent_code ( DependentCode : : cast ( empty_fixed_array ( ) ) , <nl> SKIP_WRITE_BARRIER ) ; <nl> cell - > set_property_details ( PropertyDetails ( Smi : : kZero ) ) ; <nl> + cell - > set_name ( name ) ; <nl> cell - > set_value ( the_hole_value ( ) ) ; <nl> return result ; <nl> } <nl> void Heap : : CreateInitialObjects ( ) { <nl> script - > set_type ( Script : : TYPE_NATIVE ) ; <nl> set_empty_script ( * script ) ; <nl> <nl> - Handle < PropertyCell > cell = factory - > NewPropertyCell ( ) ; <nl> + Handle < PropertyCell > cell = factory - > NewPropertyCell ( factory - > empty_string ( ) ) ; <nl> cell - > set_value ( Smi : : FromInt ( Isolate : : kProtectorValid ) ) ; <nl> set_array_protector ( * cell ) ; <nl> <nl> - cell = factory - > NewPropertyCell ( ) ; <nl> + cell = factory - > NewPropertyCell ( factory - > empty_string ( ) ) ; <nl> cell - > set_value ( the_hole_value ( ) ) ; <nl> set_empty_property_cell ( * cell ) ; <nl> <nl> - cell = factory - > NewPropertyCell ( ) ; <nl> + cell = factory - > NewPropertyCell ( factory - > empty_string ( ) ) ; <nl> cell - > set_value ( Smi : : FromInt ( Isolate : : kProtectorValid ) ) ; <nl> set_array_iterator_protector ( * cell ) ; <nl> <nl> void Heap : : CreateInitialObjects ( ) { <nl> handle ( Smi : : FromInt ( Isolate : : kProtectorValid ) , isolate ( ) ) ) ; <nl> set_species_protector ( * species_cell ) ; <nl> <nl> - cell = factory - > NewPropertyCell ( ) ; <nl> + cell = factory - > NewPropertyCell ( factory - > empty_string ( ) ) ; <nl> cell - > set_value ( Smi : : FromInt ( Isolate : : kProtectorValid ) ) ; <nl> set_string_length_protector ( * cell ) ; <nl> <nl> void Heap : : CreateInitialObjects ( ) { <nl> handle ( Smi : : FromInt ( Isolate : : kProtectorValid ) , isolate ( ) ) ) ; <nl> set_fast_array_iteration_protector ( * fast_array_iteration_cell ) ; <nl> <nl> - cell = factory - > NewPropertyCell ( ) ; <nl> + cell = factory - > NewPropertyCell ( factory - > empty_string ( ) ) ; <nl> cell - > set_value ( Smi : : FromInt ( Isolate : : kProtectorValid ) ) ; <nl> set_array_buffer_neutering_protector ( * cell ) ; <nl> <nl> mmm a / src / heap / heap . h <nl> ppp b / src / heap / heap . h <nl> class Heap { <nl> MUST_USE_RESULT AllocationResult AllocateCell ( Object * value ) ; <nl> <nl> / / Allocate a tenured JS global property cell initialized with the hole . <nl> - MUST_USE_RESULT AllocationResult AllocatePropertyCell ( ) ; <nl> + MUST_USE_RESULT AllocationResult AllocatePropertyCell ( Name * name ) ; <nl> <nl> MUST_USE_RESULT AllocationResult AllocateWeakCell ( HeapObject * value ) ; <nl> <nl> mmm a / src / ic / ic . cc <nl> ppp b / src / ic / ic . cc <nl> Handle < WeakCell > HolderCell ( Isolate * isolate , Handle < JSObject > holder , <nl> GlobalDictionary * dict = global - > global_dictionary ( ) ; <nl> int number = dict - > FindEntry ( name ) ; <nl> DCHECK_NE ( NameDictionary : : kNotFound , number ) ; <nl> - Handle < PropertyCell > cell ( PropertyCell : : cast ( dict - > ValueAt ( number ) ) , <nl> - isolate ) ; <nl> + Handle < PropertyCell > cell ( dict - > CellAt ( number ) , isolate ) ; <nl> return isolate - > factory ( ) - > NewWeakCell ( cell ) ; <nl> } <nl> return Map : : GetOrCreatePrototypeWeakCell ( holder , isolate ) ; <nl> mmm a / src / lookup . cc <nl> ppp b / src / lookup . cc <nl> void LookupIterator : : PrepareForDataProperty ( Handle < Object > value ) { <nl> <nl> if ( holder - > IsJSGlobalObject ( ) ) { <nl> Handle < GlobalDictionary > dictionary ( holder - > global_dictionary ( ) ) ; <nl> - Handle < PropertyCell > cell ( <nl> - PropertyCell : : cast ( dictionary - > ValueAt ( dictionary_entry ( ) ) ) ) ; <nl> - DCHECK ( ! cell - > IsTheHole ( isolate_ ) ) ; <nl> + Handle < PropertyCell > cell ( dictionary - > CellAt ( dictionary_entry ( ) ) ) ; <nl> property_details_ = cell - > property_details ( ) ; <nl> PropertyCell : : PrepareForValue ( dictionary , dictionary_entry ( ) , value , <nl> property_details_ ) ; <nl> Handle < Object > LookupIterator : : FetchValue ( ) const { <nl> } else if ( holder_ - > IsJSGlobalObject ( ) ) { <nl> Handle < JSObject > holder = GetHolder < JSObject > ( ) ; <nl> result = holder - > global_dictionary ( ) - > ValueAt ( number_ ) ; <nl> - DCHECK ( result - > IsPropertyCell ( ) ) ; <nl> - result = PropertyCell : : cast ( result ) - > value ( ) ; <nl> } else if ( ! holder_ - > HasFastProperties ( ) ) { <nl> result = holder_ - > property_dictionary ( ) - > ValueAt ( number_ ) ; <nl> } else if ( property_details_ . location ( ) = = kField ) { <nl> Handle < FieldType > LookupIterator : : GetFieldType ( ) const { <nl> Handle < PropertyCell > LookupIterator : : GetPropertyCell ( ) const { <nl> DCHECK ( ! IsElement ( ) ) ; <nl> Handle < JSGlobalObject > holder = GetHolder < JSGlobalObject > ( ) ; <nl> - Object * value = holder - > global_dictionary ( ) - > ValueAt ( dictionary_entry ( ) ) ; <nl> - DCHECK ( value - > IsPropertyCell ( ) ) ; <nl> - return handle ( PropertyCell : : cast ( value ) , isolate_ ) ; <nl> + return handle ( holder - > global_dictionary ( ) - > CellAt ( dictionary_entry ( ) ) , <nl> + isolate_ ) ; <nl> } <nl> <nl> <nl> void LookupIterator : : WriteDataValue ( Handle < Object > value , <nl> } <nl> } else if ( holder - > IsJSGlobalObject ( ) ) { <nl> GlobalDictionary * dictionary = JSObject : : cast ( * holder ) - > global_dictionary ( ) ; <nl> - Object * cell = dictionary - > ValueAt ( dictionary_entry ( ) ) ; <nl> - DCHECK ( cell - > IsPropertyCell ( ) ) ; <nl> - PropertyCell : : cast ( cell ) - > set_value ( * value ) ; <nl> + dictionary - > CellAt ( dictionary_entry ( ) ) - > set_value ( * value ) ; <nl> } else { <nl> NameDictionary * dictionary = holder - > property_dictionary ( ) ; <nl> dictionary - > ValueAtPut ( dictionary_entry ( ) , * value ) ; <nl> LookupIterator : : State LookupIterator : : LookupInSpecialHolder ( <nl> int number = dict - > FindEntry ( name_ ) ; <nl> if ( number = = GlobalDictionary : : kNotFound ) return NOT_FOUND ; <nl> number_ = static_cast < uint32_t > ( number ) ; <nl> - DCHECK ( dict - > ValueAt ( number_ ) - > IsPropertyCell ( ) ) ; <nl> - PropertyCell * cell = PropertyCell : : cast ( dict - > ValueAt ( number_ ) ) ; <nl> + PropertyCell * cell = dict - > CellAt ( number_ ) ; <nl> if ( cell - > value ( ) - > IsTheHole ( isolate_ ) ) return NOT_FOUND ; <nl> property_details_ = cell - > property_details ( ) ; <nl> has_property_ = true ; <nl> mmm a / src / objects - inl . h <nl> ppp b / src / objects - inl . h <nl> bool Object : : KeyEquals ( Object * second ) { <nl> } <nl> <nl> bool Object : : FilterKey ( PropertyFilter filter ) { <nl> + DCHECK ( ! IsPropertyCell ( ) ) ; <nl> if ( IsSymbol ( ) ) { <nl> if ( filter & SKIP_SYMBOLS ) return true ; <nl> if ( Symbol : : cast ( this ) - > is_private ( ) ) return true ; <nl> Handle < Object > Oddball : : ToNumber ( Handle < Oddball > input ) { <nl> <nl> ACCESSORS ( Cell , value , Object , kValueOffset ) <nl> ACCESSORS ( PropertyCell , dependent_code , DependentCode , kDependentCodeOffset ) <nl> - ACCESSORS ( PropertyCell , property_details_raw , Object , kDetailsOffset ) <nl> + ACCESSORS ( PropertyCell , name , Name , kNameOffset ) <nl> ACCESSORS ( PropertyCell , value , Object , kValueOffset ) <nl> - <nl> + ACCESSORS ( PropertyCell , property_details_raw , Object , kDetailsOffset ) <nl> <nl> PropertyDetails PropertyCell : : property_details ( ) { <nl> return PropertyDetails ( Smi : : cast ( property_details_raw ( ) ) ) ; <nl> int HashTableBase : : ComputeCapacity ( int at_least_space_for ) { <nl> return Max ( capacity , kMinCapacity ) ; <nl> } <nl> <nl> - bool HashTableBase : : IsKey ( Isolate * isolate , Object * k ) { <nl> - Heap * heap = isolate - > heap ( ) ; <nl> - return k ! = heap - > the_hole_value ( ) & & k ! = heap - > undefined_value ( ) ; <nl> - } <nl> - <nl> void HashTableBase : : SetNumberOfElements ( int nof ) { <nl> set ( kNumberOfElementsIndex , Smi : : FromInt ( nof ) ) ; <nl> } <nl> bool AccessorPair : : IsJSAccessor ( Object * obj ) { <nl> template < typename Derived , typename Shape > <nl> void Dictionary < Derived , Shape > : : ClearEntry ( int entry ) { <nl> Object * the_hole = this - > GetHeap ( ) - > the_hole_value ( ) ; <nl> - SetEntry ( entry , the_hole , the_hole , PropertyDetails : : Empty ( ) ) ; <nl> + PropertyDetails details = PropertyDetails : : Empty ( ) ; <nl> + Derived : : cast ( this ) - > SetEntry ( entry , the_hole , the_hole , details ) ; <nl> } <nl> <nl> template < typename Derived , typename Shape > <nl> void Dictionary < Derived , Shape > : : SetEntry ( int entry , Object * key , Object * value , <nl> PropertyDetails details ) { <nl> - STATIC_ASSERT ( Dictionary : : kEntrySize = = 2 | | Dictionary : : kEntrySize = = 3 ) ; <nl> + DCHECK ( Dictionary : : kEntrySize = = 2 | | Dictionary : : kEntrySize = = 3 ) ; <nl> DCHECK ( ! key - > IsName ( ) | | details . dictionary_index ( ) > 0 ) ; <nl> int index = DerivedHashTable : : EntryToIndex ( entry ) ; <nl> DisallowHeapAllocation no_gc ; <nl> void Dictionary < Derived , Shape > : : SetEntry ( int entry , Object * key , Object * value , <nl> if ( Shape : : kHasDetails ) DetailsAtPut ( entry , details ) ; <nl> } <nl> <nl> + Object * GlobalDictionaryShape : : Unwrap ( Object * object ) { <nl> + return PropertyCell : : cast ( object ) - > name ( ) ; <nl> + } <nl> + <nl> + Name * NameDictionary : : NameAt ( int entry ) { return Name : : cast ( KeyAt ( entry ) ) ; } <nl> + <nl> + PropertyCell * GlobalDictionary : : CellAt ( int entry ) { <nl> + DCHECK ( KeyAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> + return PropertyCell : : cast ( KeyAt ( entry ) ) ; <nl> + } <nl> + <nl> + bool GlobalDictionaryShape : : IsLive ( Isolate * isolate , Object * k ) { <nl> + Heap * heap = isolate - > heap ( ) ; <nl> + DCHECK_NE ( heap - > the_hole_value ( ) , k ) ; <nl> + return k ! = heap - > undefined_value ( ) ; <nl> + } <nl> + <nl> + bool GlobalDictionaryShape : : IsKey ( Isolate * isolate , Object * k ) { <nl> + return IsLive ( isolate , k ) & & <nl> + ! PropertyCell : : cast ( k ) - > value ( ) - > IsTheHole ( isolate ) ; <nl> + } <nl> + <nl> + Name * GlobalDictionary : : NameAt ( int entry ) { return CellAt ( entry ) - > name ( ) ; } <nl> + Object * GlobalDictionary : : ValueAt ( int entry ) { return CellAt ( entry ) - > value ( ) ; } <nl> + <nl> + void GlobalDictionary : : SetEntry ( int entry , Object * key , Object * value , <nl> + PropertyDetails details ) { <nl> + DCHECK_EQ ( key , PropertyCell : : cast ( value ) - > name ( ) ) ; <nl> + set ( EntryToIndex ( entry ) + kEntryKeyIndex , value ) ; <nl> + DetailsAtPut ( entry , details ) ; <nl> + } <nl> <nl> bool NumberDictionaryShape : : IsMatch ( uint32_t key , Object * other ) { <nl> DCHECK ( other - > IsNumber ( ) ) ; <nl> uint32_t NameDictionaryShape : : HashForObject ( Isolate * isolate , Object * other ) { <nl> return Name : : cast ( other ) - > Hash ( ) ; <nl> } <nl> <nl> + bool GlobalDictionaryShape : : IsMatch ( Handle < Name > key , Object * other ) { <nl> + DCHECK ( PropertyCell : : cast ( other ) - > name ( ) - > IsUniqueName ( ) ) ; <nl> + return * key = = PropertyCell : : cast ( other ) - > name ( ) ; <nl> + } <nl> + <nl> + uint32_t GlobalDictionaryShape : : HashForObject ( Isolate * isolate , Object * other ) { <nl> + return PropertyCell : : cast ( other ) - > name ( ) - > Hash ( ) ; <nl> + } <nl> <nl> Handle < Object > NameDictionaryShape : : AsHandle ( Isolate * isolate , <nl> Handle < Name > key ) { <nl> Handle < Object > NameDictionaryShape : : AsHandle ( Isolate * isolate , <nl> template < typename Dictionary > <nl> PropertyDetails GlobalDictionaryShape : : DetailsAt ( Dictionary * dict , int entry ) { <nl> DCHECK_LE ( 0 , entry ) ; / / Not found is - 1 , which is not caught by get ( ) . <nl> - Object * raw_value = dict - > ValueAt ( entry ) ; <nl> - DCHECK ( raw_value - > IsPropertyCell ( ) ) ; <nl> - PropertyCell * cell = PropertyCell : : cast ( raw_value ) ; <nl> - return cell - > property_details ( ) ; <nl> + return dict - > CellAt ( entry ) - > property_details ( ) ; <nl> } <nl> <nl> <nl> template < typename Dictionary > <nl> void GlobalDictionaryShape : : DetailsAtPut ( Dictionary * dict , int entry , <nl> PropertyDetails value ) { <nl> DCHECK_LE ( 0 , entry ) ; / / Not found is - 1 , which is not caught by get ( ) . <nl> - PropertyCell * cell = PropertyCell : : cast ( dict - > ValueAt ( entry ) ) ; <nl> + PropertyCell * cell = dict - > CellAt ( entry ) ; <nl> if ( cell - > property_details ( ) . IsReadOnly ( ) ! = value . IsReadOnly ( ) ) { <nl> cell - > dependent_code ( ) - > DeoptimizeDependentCodeGroup ( <nl> cell - > GetIsolate ( ) , DependentCode : : kPropertyCellChangedGroup ) ; <nl> void GlobalDictionaryShape : : DetailsAtPut ( Dictionary * dict , int entry , <nl> cell - > set_property_details ( value ) ; <nl> } <nl> <nl> - template < typename Dictionary > <nl> - bool GlobalDictionaryShape : : IsDeleted ( Dictionary * dict , int entry ) { <nl> - DCHECK ( dict - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> - Isolate * isolate = dict - > GetIsolate ( ) ; <nl> - return PropertyCell : : cast ( dict - > ValueAt ( entry ) ) - > value ( ) - > IsTheHole ( isolate ) ; <nl> - } <nl> - <nl> - <nl> bool ObjectHashTableShape : : IsMatch ( Handle < Object > key , Object * other ) { <nl> return key - > SameValue ( other ) ; <nl> } <nl> mmm a / src / objects - printer . cc <nl> ppp b / src / objects - printer . cc <nl> void Cell : : CellPrint ( std : : ostream & os ) { / / NOLINT <nl> <nl> void PropertyCell : : PropertyCellPrint ( std : : ostream & os ) { / / NOLINT <nl> HeapObject : : PrintHeader ( os , " PropertyCell " ) ; <nl> + os < < " \ n - name : " ; <nl> + name ( ) - > NamePrint ( os ) ; <nl> os < < " \ n - value : " < < Brief ( value ( ) ) ; <nl> os < < " \ n - details : " ; <nl> property_details ( ) . PrintAsSlowTo ( os ) ; <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> void JSObject : : SetNormalizedProperty ( Handle < JSObject > object , <nl> int entry = dictionary - > FindEntry ( isolate , name , hash ) ; <nl> <nl> if ( entry = = GlobalDictionary : : kNotFound ) { <nl> - auto cell = isolate - > factory ( ) - > NewPropertyCell ( ) ; <nl> + auto cell = isolate - > factory ( ) - > NewPropertyCell ( name ) ; <nl> cell - > set_value ( * value ) ; <nl> auto cell_type = value - > IsUndefined ( isolate ) <nl> ? PropertyCellType : : kUndefined <nl> void HeapObject : : HeapObjectShortPrint ( std : : ostream & os ) { / / NOLINT <nl> break ; <nl> } <nl> case PROPERTY_CELL_TYPE : { <nl> - os < < " < PropertyCell value = " ; <nl> + PropertyCell * cell = PropertyCell : : cast ( this ) ; <nl> + os < < " < PropertyCell name = " ; <nl> + cell - > name ( ) - > ShortPrint ( os ) ; <nl> + os < < " value = " ; <nl> HeapStringAllocator allocator ; <nl> StringStream accumulator ( & allocator ) ; <nl> - PropertyCell * cell = PropertyCell : : cast ( this ) ; <nl> cell - > value ( ) - > ShortPrint ( & accumulator ) ; <nl> os < < accumulator . ToCString ( ) . get ( ) ; <nl> os < < ' > ' ; <nl> void JSObject : : MigrateSlowToFast ( Handle < JSObject > object , <nl> int current_offset = 0 ; <nl> for ( int i = 0 ; i < instance_descriptor_length ; i + + ) { <nl> int index = Smi : : cast ( iteration_order - > get ( i ) ) - > value ( ) ; <nl> - Object * k = dictionary - > KeyAt ( index ) ; <nl> - DCHECK ( dictionary - > IsKey ( isolate , k ) ) ; <nl> + Name * k = dictionary - > NameAt ( index ) ; <nl> / / Dictionary keys are internalized upon insertion . <nl> / / TODO ( jkummerow ) : Turn this into a DCHECK if it ' s not hit in the wild . <nl> CHECK ( k - > IsUniqueName ( ) ) ; <nl> - Handle < Name > key ( Name : : cast ( k ) , isolate ) ; <nl> + Handle < Name > key ( k , isolate ) ; <nl> <nl> Object * value = dictionary - > ValueAt ( index ) ; <nl> <nl> Maybe < bool > JSReceiver : : SetIntegrityLevel ( Handle < JSReceiver > receiver , <nl> namespace { <nl> <nl> template < typename Dictionary > <nl> - bool TestDictionaryPropertiesIntegrityLevel ( Dictionary dict , Isolate * isolate , <nl> + bool TestDictionaryPropertiesIntegrityLevel ( Dictionary * dict , Isolate * isolate , <nl> PropertyAttributes level ) { <nl> DCHECK ( level = = SEALED | | level = = FROZEN ) ; <nl> <nl> uint32_t capacity = dict - > Capacity ( ) ; <nl> for ( uint32_t i = 0 ; i < capacity ; i + + ) { <nl> - Object * key = dict - > KeyAt ( i ) ; <nl> - if ( ! dict - > IsKey ( isolate , key ) | | key - > FilterKey ( ALL_PROPERTIES ) | | <nl> - dict - > IsDeleted ( i ) ) <nl> - continue ; <nl> + Object * key ; <nl> + if ( ! dict - > ToKey ( isolate , i , & key ) ) continue ; <nl> + if ( key - > FilterKey ( ALL_PROPERTIES ) ) continue ; <nl> PropertyDetails details = dict - > DetailsAt ( i ) ; <nl> if ( details . IsConfigurable ( ) ) return false ; <nl> if ( level = = FROZEN & & details . kind ( ) = = kData & & ! details . IsReadOnly ( ) ) { <nl> void ApplyAttributesToDictionary ( Isolate * isolate , <nl> const PropertyAttributes attributes ) { <nl> int capacity = dictionary - > Capacity ( ) ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * k = dictionary - > KeyAt ( i ) ; <nl> - if ( dictionary - > IsKey ( isolate , k ) & & <nl> - ! ( k - > IsSymbol ( ) & & Symbol : : cast ( k ) - > is_private ( ) ) ) { <nl> - PropertyDetails details = dictionary - > DetailsAt ( i ) ; <nl> - int attrs = attributes ; <nl> - / / READ_ONLY is an invalid attribute for JS setters / getters . <nl> - if ( ( attributes & READ_ONLY ) & & details . kind ( ) = = kAccessor ) { <nl> - Object * v = dictionary - > ValueAt ( i ) ; <nl> - if ( v - > IsPropertyCell ( ) ) v = PropertyCell : : cast ( v ) - > value ( ) ; <nl> - if ( v - > IsAccessorPair ( ) ) attrs & = ~ READ_ONLY ; <nl> - } <nl> - details = details . CopyAddAttributes ( <nl> - static_cast < PropertyAttributes > ( attrs ) ) ; <nl> - dictionary - > DetailsAtPut ( i , details ) ; <nl> + Object * k ; <nl> + if ( ! dictionary - > ToKey ( isolate , i , & k ) ) continue ; <nl> + if ( k - > FilterKey ( ALL_PROPERTIES ) ) continue ; <nl> + PropertyDetails details = dictionary - > DetailsAt ( i ) ; <nl> + int attrs = attributes ; <nl> + / / READ_ONLY is an invalid attribute for JS setters / getters . <nl> + if ( ( attributes & READ_ONLY ) & & details . kind ( ) = = kAccessor ) { <nl> + Object * v = dictionary - > ValueAt ( i ) ; <nl> + if ( v - > IsAccessorPair ( ) ) attrs & = ~ READ_ONLY ; <nl> } <nl> + details = details . CopyAddAttributes ( static_cast < PropertyAttributes > ( attrs ) ) ; <nl> + dictionary - > DetailsAtPut ( i , details ) ; <nl> } <nl> } <nl> <nl> void Dictionary < Derived , Shape > : : Print ( std : : ostream & os ) { / / NOLINT <nl> int capacity = this - > Capacity ( ) ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> Object * k = this - > KeyAt ( i ) ; <nl> - if ( this - > IsKey ( isolate , k ) ) { <nl> + if ( Shape : : IsLive ( isolate , k ) ) { <nl> os < < " \ n " ; <nl> if ( k - > IsString ( ) ) { <nl> String : : cast ( k ) - > StringPrint ( os ) ; <nl> void HashTable < Derived , Shape > : : Rehash ( Derived * new_table ) { <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> uint32_t from_index = EntryToIndex ( i ) ; <nl> Object * k = this - > get ( from_index ) ; <nl> - if ( IsKey ( isolate , k ) ) { <nl> + if ( Shape : : IsLive ( isolate , k ) ) { <nl> uint32_t hash = Shape : : HashForObject ( isolate , k ) ; <nl> uint32_t insertion_index = <nl> EntryToIndex ( new_table - > FindInsertionEntry ( hash ) ) ; <nl> void HashTable < Derived , Shape > : : Rehash ( ) { <nl> done = true ; <nl> for ( uint32_t current = 0 ; current < capacity ; current + + ) { <nl> Object * current_key = KeyAt ( current ) ; <nl> - if ( IsKey ( isolate , current_key ) ) { <nl> + if ( Shape : : IsLive ( isolate , current_key ) ) { <nl> uint32_t target = EntryForProbe ( current_key , probe , current ) ; <nl> if ( current = = target ) continue ; <nl> Object * target_key = KeyAt ( target ) ; <nl> - if ( ! IsKey ( isolate , target_key ) | | <nl> + if ( ! Shape : : IsLive ( isolate , target_key ) | | <nl> EntryForProbe ( target_key , probe , target ) ! = target ) { <nl> / / Put the current element into the correct position . <nl> Swap ( current , target , mode ) ; <nl> uint32_t HashTable < Derived , Shape > : : FindInsertionEntry ( uint32_t hash ) { <nl> / / EnsureCapacity will guarantee the hash table is never full . <nl> Isolate * isolate = GetIsolate ( ) ; <nl> while ( true ) { <nl> - Object * element = KeyAt ( entry ) ; <nl> - if ( ! IsKey ( isolate , element ) ) break ; <nl> + if ( ! Shape : : IsLive ( isolate , KeyAt ( entry ) ) ) break ; <nl> entry = NextProbe ( entry , count + + , capacity ) ; <nl> } <nl> return entry ; <nl> Handle < Object > JSObject : : PrepareSlowElementsForSort ( <nl> / / allocated one that is large enough for all entries . <nl> DisallowHeapAllocation no_gc ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * k = dict - > KeyAt ( i ) ; <nl> - if ( ! dict - > IsKey ( isolate , k ) ) continue ; <nl> + Object * k ; <nl> + if ( ! dict - > ToKey ( isolate , i , & k ) ) continue ; <nl> <nl> DCHECK ( k - > IsNumber ( ) ) ; <nl> DCHECK ( ! k - > IsSmi ( ) | | Smi : : cast ( k ) - > value ( ) > = 0 ) ; <nl> Handle < PropertyCell > JSGlobalObject : : EnsureEmptyPropertyCell ( <nl> Handle < PropertyCell > cell ; <nl> if ( entry ! = GlobalDictionary : : kNotFound ) { <nl> if ( entry_out ) * entry_out = entry ; <nl> - / / This call should be idempotent . <nl> - DCHECK ( dictionary - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> - cell = handle ( PropertyCell : : cast ( dictionary - > ValueAt ( entry ) ) ) ; <nl> + cell = handle ( dictionary - > CellAt ( entry ) ) ; <nl> PropertyCellType original_cell_type = cell - > property_details ( ) . cell_type ( ) ; <nl> DCHECK ( original_cell_type = = PropertyCellType : : kInvalidated | | <nl> original_cell_type = = PropertyCellType : : kUninitialized ) ; <nl> Handle < PropertyCell > JSGlobalObject : : EnsureEmptyPropertyCell ( <nl> cell - > set_property_details ( details ) ; <nl> return cell ; <nl> } <nl> - cell = isolate - > factory ( ) - > NewPropertyCell ( ) ; <nl> + cell = isolate - > factory ( ) - > NewPropertyCell ( name ) ; <nl> PropertyDetails details ( kData , NONE , cell_type ) ; <nl> dictionary = <nl> GlobalDictionary : : Add ( dictionary , name , cell , details , entry_out ) ; <nl> Handle < Derived > Dictionary < Derived , Shape > : : Add ( Handle < Derived > dictionary , <nl> uint32_t entry = dictionary - > FindInsertionEntry ( hash ) ; <nl> dictionary - > SetEntry ( entry , * k , * value , details ) ; <nl> DCHECK ( dictionary - > KeyAt ( entry ) - > IsNumber ( ) | | <nl> - dictionary - > KeyAt ( entry ) - > IsUniqueName ( ) ) ; <nl> + Shape : : Unwrap ( dictionary - > KeyAt ( entry ) ) - > IsUniqueName ( ) ) ; <nl> dictionary - > ElementAdded ( ) ; <nl> if ( entry_out ) * entry_out = entry ; <nl> return dictionary ; <nl> bool SeededNumberDictionary : : HasComplexElements ( ) { <nl> Isolate * isolate = this - > GetIsolate ( ) ; <nl> int capacity = this - > Capacity ( ) ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * k = this - > KeyAt ( i ) ; <nl> - if ( ! this - > IsKey ( isolate , k ) ) continue ; <nl> - DCHECK ( ! IsDeleted ( i ) ) ; <nl> + Object * k ; <nl> + if ( ! this - > ToKey ( isolate , i , & k ) ) continue ; <nl> PropertyDetails details = this - > DetailsAt ( i ) ; <nl> if ( details . kind ( ) = = kAccessor ) return true ; <nl> PropertyAttributes attr = details . attributes ( ) ; <nl> void SeededNumberDictionary : : CopyValuesTo ( FixedArray * elements ) { <nl> DisallowHeapAllocation no_gc ; <nl> WriteBarrierMode mode = elements - > GetWriteBarrierMode ( no_gc ) ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * k = this - > KeyAt ( i ) ; <nl> - if ( this - > IsKey ( isolate , k ) ) { <nl> + Object * k ; <nl> + if ( this - > ToKey ( isolate , i , & k ) ) { <nl> elements - > set ( pos + + , this - > ValueAt ( i ) , mode ) ; <nl> } <nl> } <nl> int Dictionary < Derived , Shape > : : NumberOfEnumerableProperties ( ) { <nl> int capacity = this - > Capacity ( ) ; <nl> int result = 0 ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * k = this - > KeyAt ( i ) ; <nl> - if ( this - > IsKey ( isolate , k ) & & ! k - > FilterKey ( ENUMERABLE_STRINGS ) ) { <nl> - if ( this - > IsDeleted ( i ) ) continue ; <nl> - PropertyDetails details = this - > DetailsAt ( i ) ; <nl> - PropertyAttributes attr = details . attributes ( ) ; <nl> - if ( ( attr & ONLY_ENUMERABLE ) = = 0 ) result + + ; <nl> - } <nl> + Object * k ; <nl> + if ( ! this - > ToKey ( isolate , i , & k ) ) continue ; <nl> + if ( k - > FilterKey ( ENUMERABLE_STRINGS ) ) continue ; <nl> + PropertyDetails details = this - > DetailsAt ( i ) ; <nl> + PropertyAttributes attr = details . attributes ( ) ; <nl> + if ( ( attr & ONLY_ENUMERABLE ) = = 0 ) result + + ; <nl> } <nl> return result ; <nl> } <nl> void BaseNameDictionary < Derived , Shape > : : CopyEnumKeysTo ( <nl> int capacity = dictionary - > Capacity ( ) ; <nl> int properties = 0 ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * key = dictionary - > KeyAt ( i ) ; <nl> + Object * key ; <nl> + if ( ! dictionary - > ToKey ( isolate , i , & key ) ) continue ; <nl> bool is_shadowing_key = false ; <nl> - if ( ! dictionary - > IsKey ( isolate , key ) ) continue ; <nl> if ( key - > IsSymbol ( ) ) continue ; <nl> PropertyDetails details = dictionary - > DetailsAt ( i ) ; <nl> if ( details . IsDontEnum ( ) ) { <nl> void BaseNameDictionary < Derived , Shape > : : CopyEnumKeysTo ( <nl> continue ; <nl> } <nl> } <nl> - if ( dictionary - > IsDeleted ( i ) ) continue ; <nl> if ( is_shadowing_key ) { <nl> accumulator - > AddShadowingKey ( key ) ; <nl> continue ; <nl> void BaseNameDictionary < Derived , Shape > : : CopyEnumKeysTo ( <nl> std : : sort ( start , start + length , cmp ) ; <nl> for ( int i = 0 ; i < length ; i + + ) { <nl> int index = Smi : : cast ( raw_storage - > get ( i ) ) - > value ( ) ; <nl> - raw_storage - > set ( i , raw_dictionary - > KeyAt ( index ) ) ; <nl> + raw_storage - > set ( i , raw_dictionary - > NameAt ( index ) ) ; <nl> } <nl> } <nl> <nl> Handle < FixedArray > BaseNameDictionary < Derived , Shape > : : IterationIndices ( <nl> DisallowHeapAllocation no_gc ; <nl> Derived * raw_dictionary = * dictionary ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * k = raw_dictionary - > KeyAt ( i ) ; <nl> - if ( ! raw_dictionary - > IsKey ( isolate , k ) ) continue ; <nl> - if ( raw_dictionary - > IsDeleted ( i ) ) continue ; <nl> + Object * k ; <nl> + if ( ! raw_dictionary - > ToKey ( isolate , i , & k ) ) continue ; <nl> array - > set ( array_size + + , Smi : : FromInt ( i ) ) ; <nl> } <nl> <nl> void BaseNameDictionary < Derived , Shape > : : CollectKeysTo ( <nl> DisallowHeapAllocation no_gc ; <nl> Derived * raw_dictionary = * dictionary ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * k = raw_dictionary - > KeyAt ( i ) ; <nl> - if ( ! raw_dictionary - > IsKey ( isolate , k ) | | k - > FilterKey ( filter ) ) continue ; <nl> - if ( raw_dictionary - > IsDeleted ( i ) ) continue ; <nl> + Object * k ; <nl> + if ( ! raw_dictionary - > ToKey ( isolate , i , & k ) ) continue ; <nl> + if ( k - > FilterKey ( filter ) ) continue ; <nl> PropertyDetails details = raw_dictionary - > DetailsAt ( i ) ; <nl> if ( ( details . attributes ( ) & filter ) ! = 0 ) { <nl> keys - > AddShadowingKey ( k ) ; <nl> void BaseNameDictionary < Derived , Shape > : : CollectKeysTo ( <nl> if ( filter & ONLY_ALL_CAN_READ ) { <nl> if ( details . kind ( ) ! = kAccessor ) continue ; <nl> Object * accessors = raw_dictionary - > ValueAt ( i ) ; <nl> - if ( accessors - > IsPropertyCell ( ) ) { <nl> - accessors = PropertyCell : : cast ( accessors ) - > value ( ) ; <nl> - } <nl> if ( ! accessors - > IsAccessorInfo ( ) ) continue ; <nl> if ( ! AccessorInfo : : cast ( accessors ) - > all_can_read ( ) ) continue ; <nl> } <nl> void BaseNameDictionary < Derived , Shape > : : CollectKeysTo ( <nl> bool has_seen_symbol = false ; <nl> for ( int i = 0 ; i < array_size ; i + + ) { <nl> int index = Smi : : cast ( array - > get ( i ) ) - > value ( ) ; <nl> - Object * key = dictionary - > KeyAt ( index ) ; <nl> + Object * key = dictionary - > NameAt ( index ) ; <nl> if ( key - > IsSymbol ( ) ) { <nl> has_seen_symbol = true ; <nl> continue ; <nl> void BaseNameDictionary < Derived , Shape > : : CollectKeysTo ( <nl> if ( has_seen_symbol ) { <nl> for ( int i = 0 ; i < array_size ; i + + ) { <nl> int index = Smi : : cast ( array - > get ( i ) ) - > value ( ) ; <nl> - Object * key = dictionary - > KeyAt ( index ) ; <nl> + Object * key = dictionary - > NameAt ( index ) ; <nl> if ( ! key - > IsSymbol ( ) ) continue ; <nl> keys - > AddKey ( key , DO_NOT_CONVERT ) ; <nl> } <nl> } <nl> } <nl> <nl> - <nl> / / Backwards lookup ( slow ) . <nl> template < typename Derived , typename Shape > <nl> Object * Dictionary < Derived , Shape > : : SlowReverseLookup ( Object * value ) { <nl> - Isolate * isolate = this - > GetIsolate ( ) ; <nl> - int capacity = this - > Capacity ( ) ; <nl> + Derived * dictionary = Derived : : cast ( this ) ; <nl> + Isolate * isolate = dictionary - > GetIsolate ( ) ; <nl> + int capacity = dictionary - > Capacity ( ) ; <nl> for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Object * k = this - > KeyAt ( i ) ; <nl> - if ( ! this - > IsKey ( isolate , k ) ) continue ; <nl> - Object * e = this - > ValueAt ( i ) ; <nl> - / / TODO ( dcarney ) : this should be templatized . <nl> - if ( e - > IsPropertyCell ( ) ) { <nl> - e = PropertyCell : : cast ( e ) - > value ( ) ; <nl> - } <nl> + Object * k ; <nl> + if ( ! dictionary - > ToKey ( isolate , i , & k ) ) continue ; <nl> + Object * e = dictionary - > ValueAt ( i ) ; <nl> if ( e = = value ) return k ; <nl> } <nl> return isolate - > heap ( ) - > undefined_value ( ) ; <nl> Handle < JSArray > JSWeakCollection : : GetEntries ( Handle < JSWeakCollection > holder , <nl> int count = 0 ; <nl> for ( int i = 0 ; <nl> count / values_per_entry < max_entries & & i < table - > Capacity ( ) ; i + + ) { <nl> - Handle < Object > key ( table - > KeyAt ( i ) , isolate ) ; <nl> - if ( table - > IsKey ( isolate , * key ) ) { <nl> - entries - > set ( count + + , * key ) ; <nl> + Object * key ; <nl> + if ( table - > ToKey ( isolate , i , & key ) ) { <nl> + entries - > set ( count + + , key ) ; <nl> if ( values_per_entry > 1 ) { <nl> - Object * value = table - > Lookup ( key ) ; <nl> + Object * value = table - > Lookup ( handle ( key , isolate ) ) ; <nl> entries - > set ( count + + , value ) ; <nl> } <nl> } <nl> Handle < PropertyCell > PropertyCell : : InvalidateEntry ( <nl> Handle < GlobalDictionary > dictionary , int entry ) { <nl> Isolate * isolate = dictionary - > GetIsolate ( ) ; <nl> / / Swap with a copy . <nl> - DCHECK ( dictionary - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> - Handle < PropertyCell > cell ( PropertyCell : : cast ( dictionary - > ValueAt ( entry ) ) ) ; <nl> - Handle < PropertyCell > new_cell = isolate - > factory ( ) - > NewPropertyCell ( ) ; <nl> + Handle < PropertyCell > cell ( dictionary - > CellAt ( entry ) ) ; <nl> + Handle < Name > name ( cell - > name ( ) , isolate ) ; <nl> + Handle < PropertyCell > new_cell = isolate - > factory ( ) - > NewPropertyCell ( name ) ; <nl> new_cell - > set_value ( cell - > value ( ) ) ; <nl> dictionary - > ValueAtPut ( entry , * new_cell ) ; <nl> bool is_the_hole = cell - > value ( ) - > IsTheHole ( isolate ) ; <nl> Handle < PropertyCell > PropertyCell : : PrepareForValue ( <nl> PropertyDetails details ) { <nl> Isolate * isolate = dictionary - > GetIsolate ( ) ; <nl> DCHECK ( ! value - > IsTheHole ( isolate ) ) ; <nl> - DCHECK ( dictionary - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> - Handle < PropertyCell > cell ( PropertyCell : : cast ( dictionary - > ValueAt ( entry ) ) ) ; <nl> + Handle < PropertyCell > cell ( dictionary - > CellAt ( entry ) ) ; <nl> const PropertyDetails original_details = cell - > property_details ( ) ; <nl> / / Data accesses could be cached in ics or optimized code . <nl> bool invalidate = <nl> original_details . kind ( ) = = kData & & details . kind ( ) = = kAccessor ; <nl> - int index = original_details . dictionary_index ( ) ; <nl> + int index ; <nl> PropertyCellType old_type = original_details . cell_type ( ) ; <nl> / / Preserve the enumeration index unless the property was deleted or never <nl> / / initialized . <nl> if ( cell - > value ( ) - > IsTheHole ( isolate ) ) { <nl> index = dictionary - > NextEnumerationIndex ( ) ; <nl> dictionary - > SetNextEnumerationIndex ( index + 1 ) ; <nl> + } else { <nl> + index = original_details . dictionary_index ( ) ; <nl> } <nl> DCHECK_LT ( 0 , index ) ; <nl> details = details . set_index ( index ) ; <nl> void FetchStarExports ( Handle < Module > module , Zone * zone , <nl> Handle < ObjectHashTable > requested_exports ( requested_module - > exports ( ) , <nl> isolate ) ; <nl> for ( int i = 0 , n = requested_exports - > Capacity ( ) ; i < n ; + + i ) { <nl> - Handle < Object > key ( requested_exports - > KeyAt ( i ) , isolate ) ; <nl> - if ( ! requested_exports - > IsKey ( isolate , * key ) ) continue ; <nl> - Handle < String > name = Handle < String > : : cast ( key ) ; <nl> + Object * key ; <nl> + if ( ! requested_exports - > ToKey ( isolate , i , & key ) ) continue ; <nl> + Handle < String > name ( String : : cast ( key ) , isolate ) ; <nl> <nl> if ( name - > Equals ( isolate - > heap ( ) - > default_string ( ) ) ) continue ; <nl> if ( ! exports - > Lookup ( name ) - > IsTheHole ( isolate ) ) continue ; <nl> Handle < JSModuleNamespace > Module : : GetModuleNamespace ( Handle < Module > module ) { <nl> ZoneVector < Handle < String > > names ( & zone ) ; <nl> names . reserve ( exports - > NumberOfElements ( ) ) ; <nl> for ( int i = 0 , n = exports - > Capacity ( ) ; i < n ; + + i ) { <nl> - Handle < Object > key ( exports - > KeyAt ( i ) , isolate ) ; <nl> - if ( ! exports - > IsKey ( isolate , * key ) ) continue ; <nl> - DCHECK ( exports - > ValueAt ( i ) - > IsCell ( ) ) ; <nl> - names . push_back ( Handle < String > : : cast ( key ) ) ; <nl> + Object * key ; <nl> + if ( ! exports - > ToKey ( isolate , i , & key ) ) continue ; <nl> + names . push_back ( handle ( String : : cast ( key ) , isolate ) ) ; <nl> } <nl> DCHECK_EQ ( static_cast < int > ( names . size ( ) ) , exports - > NumberOfElements ( ) ) ; <nl> <nl> mmm a / src / objects . h <nl> ppp b / src / objects . h <nl> class Cell : public HeapObject { <nl> <nl> class PropertyCell : public HeapObject { <nl> public : <nl> + / / [ name ] : the name of the global property . <nl> + DECL_ACCESSORS ( name , Name ) <nl> / / [ property_details ] : details of the global property . <nl> DECL_ACCESSORS ( property_details_raw , Object ) <nl> / / [ value ] : value of the global property . <nl> class PropertyCell : public HeapObject { <nl> <nl> / / Layout description . <nl> static const int kDetailsOffset = HeapObject : : kHeaderSize ; <nl> - static const int kValueOffset = kDetailsOffset + kPointerSize ; <nl> + static const int kNameOffset = kDetailsOffset + kPointerSize ; <nl> + static const int kValueOffset = kNameOffset + kPointerSize ; <nl> static const int kDependentCodeOffset = kValueOffset + kPointerSize ; <nl> static const int kSize = kDependentCodeOffset + kPointerSize ; <nl> <nl> - typedef FixedBodyDescriptor < kValueOffset , <nl> - kSize , <nl> - kSize > BodyDescriptor ; <nl> + typedef FixedBodyDescriptor < kNameOffset , kSize , kSize > BodyDescriptor ; <nl> / / No weak fields . <nl> typedef BodyDescriptor BodyDescriptorWeak ; <nl> <nl> mmm a / src / objects / dictionary . h <nl> ppp b / src / objects / dictionary . h <nl> class Dictionary : public HashTable < Derived , Shape > { <nl> Shape : : DetailsAtPut ( static_cast < Derived * > ( this ) , entry , value ) ; <nl> } <nl> <nl> - / / Returns true if property at given entry is deleted . <nl> - bool IsDeleted ( int entry ) { <nl> - return Shape : : IsDeleted ( static_cast < Derived * > ( this ) , entry ) ; <nl> - } <nl> - <nl> / / Delete a property from the dictionary . <nl> MUST_USE_RESULT static Handle < Derived > DeleteEntry ( Handle < Derived > dictionary , <nl> int entry ) ; <nl> class BaseDictionaryShape : public BaseShape < Key > { <nl> dict - > set ( Dictionary : : EntryToIndex ( entry ) + Dictionary : : kEntryDetailsIndex , <nl> value . AsSmi ( ) ) ; <nl> } <nl> - <nl> - template < typename Dictionary > <nl> - static bool IsDeleted ( Dictionary * dict , int entry ) { <nl> - return false ; <nl> - } <nl> } ; <nl> <nl> class NameDictionaryShape : public BaseDictionaryShape < Handle < Name > > { <nl> class NameDictionary <nl> <nl> static const int kEntryDetailsIndex = 2 ; <nl> static const int kInitialCapacity = 2 ; <nl> + inline Name * NameAt ( int entry ) ; <nl> } ; <nl> <nl> class GlobalDictionaryShape : public NameDictionaryShape { <nl> public : <nl> - static const int kEntrySize = 2 ; / / Overrides NameDictionaryShape : : kEntrySize <nl> + static inline bool IsMatch ( Handle < Name > key , Object * other ) ; <nl> + static inline uint32_t HashForObject ( Isolate * isolate , Object * object ) ; <nl> + <nl> + static const int kEntrySize = 1 ; / / Overrides NameDictionaryShape : : kEntrySize <nl> <nl> template < typename Dictionary > <nl> static inline PropertyDetails DetailsAt ( Dictionary * dict , int entry ) ; <nl> class GlobalDictionaryShape : public NameDictionaryShape { <nl> static inline void DetailsAtPut ( Dictionary * dict , int entry , <nl> PropertyDetails value ) ; <nl> <nl> - template < typename Dictionary > <nl> - static bool IsDeleted ( Dictionary * dict , int entry ) ; <nl> + static inline Object * Unwrap ( Object * key ) ; <nl> + static inline bool IsKey ( Isolate * isolate , Object * k ) ; <nl> + static inline bool IsLive ( Isolate * isolate , Object * key ) ; <nl> } ; <nl> <nl> class GlobalDictionary <nl> : public BaseNameDictionary < GlobalDictionary , GlobalDictionaryShape > { <nl> public : <nl> DECLARE_CAST ( GlobalDictionary ) <nl> + <nl> + inline Object * ValueAt ( int entry ) ; <nl> + inline PropertyCell * CellAt ( int entry ) ; <nl> + inline void SetEntry ( int entry , Object * key , Object * value , <nl> + PropertyDetails details ) ; <nl> + inline Name * NameAt ( int entry ) ; <nl> + void ValueAtPut ( int entry , Object * value ) { set ( EntryToIndex ( entry ) , value ) ; } <nl> } ; <nl> <nl> class NumberDictionaryShape : public BaseDictionaryShape < uint32_t > { <nl> mmm a / src / objects / hash - table - inl . h <nl> ppp b / src / objects / hash - table - inl . h <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + template < typename KeyT > <nl> + bool BaseShape < KeyT > : : IsLive ( Isolate * isolate , Object * k ) { <nl> + Heap * heap = isolate - > heap ( ) ; <nl> + return k ! = heap - > the_hole_value ( ) & & k ! = heap - > undefined_value ( ) ; <nl> + } <nl> + <nl> } / / namespace internal <nl> } / / namespace v8 <nl> <nl> mmm a / src / objects / hash - table . h <nl> ppp b / src / objects / hash - table . h <nl> class BaseShape { <nl> typedef KeyT Key ; <nl> static inline Map * GetMap ( Isolate * isolate ) ; <nl> static const bool kNeedsHoleCheck = true ; <nl> + static Object * Unwrap ( Object * key ) { return key ; } <nl> + static bool IsKey ( Isolate * isolate , Object * key ) { <nl> + return IsLive ( isolate , key ) ; <nl> + } <nl> + static inline bool IsLive ( Isolate * isolate , Object * key ) ; <nl> } ; <nl> <nl> class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE ( FixedArray ) { <nl> class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE ( FixedArray ) { <nl> / / number of elements . May be more than HashTable : : kMaxCapacity . <nl> static inline int ComputeCapacity ( int at_least_space_for ) ; <nl> <nl> - / / Tells whether k is a real key . The hole and undefined are not allowed <nl> - / / as keys and can be used to indicate missing or deleted elements . <nl> - static inline bool IsKey ( Isolate * isolate , Object * k ) ; <nl> - <nl> / / Compute the probe offset ( quadratic probing ) . <nl> INLINE ( static uint32_t GetProbeOffset ( uint32_t n ) ) { <nl> return ( n + n * n ) > > 1 ; <nl> class HashTable : public HashTableBase { <nl> / / Rehashes the table in - place . <nl> void Rehash ( ) ; <nl> <nl> + / / Tells whether k is a real key . The hole and undefined are not allowed <nl> + / / as keys and can be used to indicate missing or deleted elements . <nl> + static bool IsKey ( Isolate * isolate , Object * k ) { <nl> + return Shape : : IsKey ( isolate , k ) ; <nl> + } <nl> + <nl> + inline bool ToKey ( Isolate * isolate , int entry , Object * * out_k ) { <nl> + Object * k = KeyAt ( entry ) ; <nl> + if ( ! IsKey ( isolate , k ) ) return false ; <nl> + * out_k = Shape : : Unwrap ( k ) ; <nl> + return true ; <nl> + } <nl> + <nl> / / Returns the key at entry . <nl> Object * KeyAt ( int entry ) { return get ( EntryToIndex ( entry ) + kEntryKeyIndex ) ; } <nl> <nl> mmm a / src / profiler / heap - snapshot - generator . cc <nl> ppp b / src / profiler / heap - snapshot - generator . cc <nl> void V8HeapExplorer : : ExtractPropertyReferences ( JSObject * js_obj , int entry ) { <nl> GlobalDictionary * dictionary = js_obj - > global_dictionary ( ) ; <nl> int length = dictionary - > Capacity ( ) ; <nl> for ( int i = 0 ; i < length ; + + i ) { <nl> - Object * k = dictionary - > KeyAt ( i ) ; <nl> - if ( dictionary - > IsKey ( isolate , k ) ) { <nl> - DCHECK ( dictionary - > ValueAt ( i ) - > IsPropertyCell ( ) ) ; <nl> - PropertyCell * cell = PropertyCell : : cast ( dictionary - > ValueAt ( i ) ) ; <nl> + if ( dictionary - > IsKey ( isolate , dictionary - > KeyAt ( i ) ) ) { <nl> + PropertyCell * cell = dictionary - > CellAt ( i ) ; <nl> + Name * name = cell - > name ( ) ; <nl> Object * value = cell - > value ( ) ; <nl> PropertyDetails details = cell - > property_details ( ) ; <nl> - SetDataOrAccessorPropertyReference ( details . kind ( ) , js_obj , entry , <nl> - Name : : cast ( k ) , value ) ; <nl> + SetDataOrAccessorPropertyReference ( details . kind ( ) , js_obj , entry , name , <nl> + value ) ; <nl> } <nl> } <nl> } else { <nl> mmm a / src / runtime / runtime - object . cc <nl> ppp b / src / runtime / runtime - object . cc <nl> static MaybeHandle < Object > KeyedGetObjectProperty ( Isolate * isolate , <nl> GlobalDictionary * dictionary = receiver - > global_dictionary ( ) ; <nl> int entry = dictionary - > FindEntry ( key ) ; <nl> if ( entry ! = GlobalDictionary : : kNotFound ) { <nl> - DCHECK ( dictionary - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> - PropertyCell * cell = PropertyCell : : cast ( dictionary - > ValueAt ( entry ) ) ; <nl> + PropertyCell * cell = dictionary - > CellAt ( entry ) ; <nl> if ( cell - > property_details ( ) . kind ( ) = = kData ) { <nl> Object * value = cell - > value ( ) ; <nl> if ( ! value - > IsTheHole ( isolate ) ) { <nl> mmm a / test / cctest / test - code - stub - assembler . cc <nl> ppp b / test / cctest / test - code - stub - assembler . cc <nl> void TestNameDictionaryLookup ( ) { <nl> } ; <nl> <nl> for ( size_t i = 0 ; i < arraysize ( keys ) ; i + + ) { <nl> - Handle < Object > value = factory - > NewPropertyCell ( ) ; <nl> + Handle < Object > value = factory - > NewPropertyCell ( keys [ i ] ) ; <nl> dictionary = Dictionary : : Add ( dictionary , keys [ i ] , value , fake_details ) ; <nl> } <nl> <nl> mmm a / tools / v8heapconst . py <nl> ppp b / tools / v8heapconst . py <nl> <nl> ( " OLD_SPACE " , 0x02821 ) : " EmptySloppyArgumentsElements " , <nl> ( " OLD_SPACE " , 0x02841 ) : " EmptySlowElementDictionary " , <nl> ( " OLD_SPACE " , 0x02889 ) : " EmptyPropertyCell " , <nl> - ( " OLD_SPACE " , 0x028a9 ) : " EmptyWeakCell " , <nl> - ( " OLD_SPACE " , 0x028c1 ) : " ArrayProtector " , <nl> - ( " OLD_SPACE " , 0x028e1 ) : " IsConcatSpreadableProtector " , <nl> - ( " OLD_SPACE " , 0x028f1 ) : " SpeciesProtector " , <nl> - ( " OLD_SPACE " , 0x02901 ) : " StringLengthProtector " , <nl> - ( " OLD_SPACE " , 0x02921 ) : " FastArrayIterationProtector " , <nl> - ( " OLD_SPACE " , 0x02931 ) : " ArrayIteratorProtector " , <nl> - ( " OLD_SPACE " , 0x02951 ) : " ArrayBufferNeuteringProtector " , <nl> - ( " OLD_SPACE " , 0x02971 ) : " InfinityValue " , <nl> - ( " OLD_SPACE " , 0x02981 ) : " MinusZeroValue " , <nl> - ( " OLD_SPACE " , 0x02991 ) : " MinusInfinityValue " , <nl> + ( " OLD_SPACE " , 0x028b1 ) : " EmptyWeakCell " , <nl> + ( " OLD_SPACE " , 0x028c9 ) : " ArrayProtector " , <nl> + ( " OLD_SPACE " , 0x028f1 ) : " IsConcatSpreadableProtector " , <nl> + ( " OLD_SPACE " , 0x02901 ) : " SpeciesProtector " , <nl> + ( " OLD_SPACE " , 0x02911 ) : " StringLengthProtector " , <nl> + ( " OLD_SPACE " , 0x02939 ) : " FastArrayIterationProtector " , <nl> + ( " OLD_SPACE " , 0x02949 ) : " ArrayIteratorProtector " , <nl> + ( " OLD_SPACE " , 0x02971 ) : " ArrayBufferNeuteringProtector " , <nl> + ( " OLD_SPACE " , 0x02999 ) : " InfinityValue " , <nl> + ( " OLD_SPACE " , 0x029a9 ) : " MinusZeroValue " , <nl> + ( " OLD_SPACE " , 0x029b9 ) : " MinusInfinityValue " , <nl> } <nl> <nl> # List of known V8 Frame Markers . <nl> | [ dictionary ] Move Name into PropertyCell to save space in overallocated hashtable | v8/v8 | e91c6dc7a9d3cdd37fc572f69625123b6564c0e0 | 2017-06-27T12:25:22Z |
mmm a / tensorflow / core / platform / cloud / BUILD <nl> ppp b / tensorflow / core / platform / cloud / BUILD <nl> cc_library ( <nl> " : google_auth_provider " , <nl> " : http_request " , <nl> " : retrying_file_system " , <nl> + " : retrying_utils " , <nl> " : time_util " , <nl> " / / tensorflow / core : framework_headers_lib " , <nl> " / / tensorflow / core : lib_internal " , <nl> tf_cc_test ( <nl> " / / tensorflow / core : test_main " , <nl> ] , <nl> ) <nl> + <nl> + tf_cc_test ( <nl> + name = " retrying_utils_test " , <nl> + size = " small " , <nl> + srcs = [ " retrying_utils_test . cc " ] , <nl> + deps = [ <nl> + " : retrying_utils " , <nl> + " / / tensorflow / core : lib " , <nl> + " / / tensorflow / core : lib_internal " , <nl> + " / / tensorflow / core : test " , <nl> + " / / tensorflow / core : test_main " , <nl> + ] , <nl> + ) <nl> mmm a / tensorflow / core / platform / cloud / gcs_file_system . cc <nl> ppp b / tensorflow / core / platform / cloud / gcs_file_system . cc <nl> limitations under the License . <nl> # include " tensorflow / core / lib / strings / numbers . h " <nl> # include " tensorflow / core / lib / strings / str_util . h " <nl> # include " tensorflow / core / platform / cloud / google_auth_provider . h " <nl> + # include " tensorflow / core / platform / cloud / retrying_utils . h " <nl> # include " tensorflow / core / platform / cloud / time_util . h " <nl> # include " tensorflow / core / platform / env . h " <nl> # include " tensorflow / core / platform / mutex . h " <nl> class GcsRandomAccessFile : public RandomAccessFile { <nl> buffer_ . reserve ( desired_buffer_size ) ; <nl> } <nl> <nl> + / / Shift the offset and clear the buffer so that the state stays <nl> + / / consistent if loading from GCS fails . <nl> buffer_start_offset_ = offset ; <nl> + buffer_ . clear ( ) ; <nl> + <nl> TF_RETURN_IF_ERROR ( LoadBufferFromGCS ( ) ) ; <nl> <nl> / / Set the results . <nl> class GcsWritableFile : public WritableFile { <nl> GcsWritableFile ( const string & bucket , const string & object , <nl> AuthProvider * auth_provider , <nl> HttpRequest : : Factory * http_request_factory , <nl> - int32 max_upload_attempts ) <nl> + int64 initial_retry_delay_usec ) <nl> : bucket_ ( bucket ) , <nl> object_ ( object ) , <nl> auth_provider_ ( auth_provider ) , <nl> http_request_factory_ ( http_request_factory ) , <nl> sync_needed_ ( true ) , <nl> - max_upload_attempts_ ( max_upload_attempts ) { <nl> + initial_retry_delay_usec_ ( initial_retry_delay_usec ) { <nl> if ( GetTmpFilename ( & tmp_content_filename_ ) . ok ( ) ) { <nl> outfile_ . open ( tmp_content_filename_ , <nl> std : : ofstream : : binary | std : : ofstream : : app ) ; <nl> class GcsWritableFile : public WritableFile { <nl> AuthProvider * auth_provider , <nl> const string & tmp_content_filename , <nl> HttpRequest : : Factory * http_request_factory , <nl> - int32 max_upload_attempts ) <nl> + int64 initial_retry_delay_usec ) <nl> : bucket_ ( bucket ) , <nl> object_ ( object ) , <nl> auth_provider_ ( auth_provider ) , <nl> http_request_factory_ ( http_request_factory ) , <nl> sync_needed_ ( true ) , <nl> - max_upload_attempts_ ( max_upload_attempts ) { <nl> + initial_retry_delay_usec_ ( initial_retry_delay_usec ) { <nl> tmp_content_filename_ = tmp_content_filename ; <nl> outfile_ . open ( tmp_content_filename_ , <nl> std : : ofstream : : binary | std : : ofstream : : app ) ; <nl> class GcsWritableFile : public WritableFile { <nl> string session_uri ; <nl> TF_RETURN_IF_ERROR ( CreateNewUploadSession ( & session_uri ) ) ; <nl> uint64 already_uploaded = 0 ; <nl> - for ( int attempt = 0 ; attempt < max_upload_attempts_ ; attempt + + ) { <nl> - if ( attempt > 0 ) { <nl> - bool completed ; <nl> - TF_RETURN_IF_ERROR ( RequestUploadSessionStatus ( session_uri , & completed , <nl> - & already_uploaded ) ) ; <nl> - if ( completed ) { <nl> - / / It ' s unclear why UploadToSession didn ' t return OK in the previous <nl> - / / attempt , but GCS reports that the file is fully uploaded , <nl> - / / so succeed . <nl> - return Status : : OK ( ) ; <nl> - } <nl> - } <nl> - const Status upload_status = <nl> - UploadToSession ( session_uri , already_uploaded ) ; <nl> - if ( upload_status . ok ( ) ) { <nl> + bool first_attempt = true ; <nl> + const Status upload_status = RetryingUtils : : CallWithRetries ( <nl> + [ & first_attempt , & already_uploaded , & session_uri , this ] ( ) { <nl> + if ( ! first_attempt ) { <nl> + bool completed ; <nl> + TF_RETURN_IF_ERROR ( RequestUploadSessionStatus ( <nl> + session_uri , & completed , & already_uploaded ) ) ; <nl> + if ( completed ) { <nl> + / / It ' s unclear why UploadToSession didn ' t return OK in the <nl> + / / previous attempt , but GCS reports that the file is fully <nl> + / / uploaded , so succeed . <nl> + return Status : : OK ( ) ; <nl> + } <nl> + } <nl> + first_attempt = false ; <nl> + return UploadToSession ( session_uri , already_uploaded ) ; <nl> + } , <nl> + initial_retry_delay_usec_ ) ; <nl> + switch ( upload_status . code ( ) ) { <nl> + case errors : : Code : : OK : <nl> return Status : : OK ( ) ; <nl> - } <nl> - switch ( upload_status . code ( ) ) { <nl> - case errors : : Code : : NOT_FOUND : <nl> - / / GCS docs recommend retrying the whole upload . We ' re relying on the <nl> - / / RetryingFileSystem to retry the Sync ( ) call . <nl> - return errors : : Unavailable ( " Could not upload gs : / / " , bucket_ , " / " , <nl> - object_ ) ; <nl> - case errors : : Code : : UNAVAILABLE : <nl> - / / The upload can be resumed , but GCS docs recommend an exponential <nl> - / / back - off . <nl> - Env : : Default ( ) - > SleepForMicroseconds ( kUploadRetryDelayMicros <nl> - < < attempt ) ; <nl> - break ; <nl> - default : <nl> - / / Something unexpected happen , fail . <nl> - return upload_status ; <nl> - } <nl> + case errors : : Code : : NOT_FOUND : <nl> + / / GCS docs recommend retrying the whole upload . We ' re relying on the <nl> + / / RetryingFileSystem to retry the Sync ( ) call . <nl> + return errors : : Unavailable ( " Could not upload gs : / / " , bucket_ , " / " , <nl> + object_ ) ; <nl> + case errors : : Code : : UNAVAILABLE : <nl> + / / Return ABORTED so that RetryingFileSystem doesn ' t retry again . <nl> + return errors : : Aborted ( " Upload gs : / / " , bucket_ , " / " , object_ , <nl> + " failed . " ) ; <nl> + default : <nl> + / / Something unexpected happen , fail . <nl> + return upload_status ; <nl> } <nl> - return errors : : Aborted ( " Upload gs : / / " , bucket_ , " / " , object_ , " failed . " ) ; <nl> } <nl> <nl> Status CheckWritable ( ) const { <nl> class GcsWritableFile : public WritableFile { <nl> std : : ofstream outfile_ ; <nl> HttpRequest : : Factory * http_request_factory_ ; <nl> bool sync_needed_ ; / / whether there is buffered data that needs to be synced <nl> - int32 max_upload_attempts_ ; <nl> + int64 initial_retry_delay_usec_ ; <nl> } ; <nl> <nl> class GcsReadOnlyMemoryRegion : public ReadOnlyMemoryRegion { <nl> GcsFileSystem : : GcsFileSystem ( ) <nl> GcsFileSystem : : GcsFileSystem ( <nl> std : : unique_ptr < AuthProvider > auth_provider , <nl> std : : unique_ptr < HttpRequest : : Factory > http_request_factory , <nl> - size_t read_ahead_bytes , int32 max_upload_attempts ) <nl> + size_t read_ahead_bytes , int64 initial_retry_delay_usec ) <nl> : auth_provider_ ( std : : move ( auth_provider ) ) , <nl> http_request_factory_ ( std : : move ( http_request_factory ) ) , <nl> read_ahead_bytes_ ( read_ahead_bytes ) , <nl> - max_upload_attempts_ ( max_upload_attempts ) { } <nl> + initial_retry_delay_usec_ ( initial_retry_delay_usec ) { } <nl> <nl> Status GcsFileSystem : : NewRandomAccessFile ( <nl> const string & fname , std : : unique_ptr < RandomAccessFile > * result ) { <nl> Status GcsFileSystem : : NewWritableFile ( const string & fname , <nl> TF_RETURN_IF_ERROR ( ParseGcsPath ( fname , false , & bucket , & object ) ) ; <nl> result - > reset ( new GcsWritableFile ( bucket , object , auth_provider_ . get ( ) , <nl> http_request_factory_ . get ( ) , <nl> - max_upload_attempts_ ) ) ; <nl> + initial_retry_delay_usec_ ) ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> Status GcsFileSystem : : NewAppendableFile ( const string & fname , <nl> TF_RETURN_IF_ERROR ( ParseGcsPath ( fname , false , & bucket , & object ) ) ; <nl> result - > reset ( new GcsWritableFile ( <nl> bucket , object , auth_provider_ . get ( ) , old_content_filename , <nl> - http_request_factory_ . get ( ) , max_upload_attempts_ ) ) ; <nl> + http_request_factory_ . get ( ) , initial_retry_delay_usec_ ) ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> mmm a / tensorflow / core / platform / cloud / gcs_file_system . h <nl> ppp b / tensorflow / core / platform / cloud / gcs_file_system . h <nl> class GcsFileSystem : public FileSystem { <nl> GcsFileSystem ( ) ; <nl> GcsFileSystem ( std : : unique_ptr < AuthProvider > auth_provider , <nl> std : : unique_ptr < HttpRequest : : Factory > http_request_factory , <nl> - size_t read_ahead_bytes , int32 max_upload_attempts ) ; <nl> + size_t read_ahead_bytes , int64 initial_retry_delay_usec ) ; <nl> <nl> Status NewRandomAccessFile ( <nl> const string & filename , <nl> class GcsFileSystem : public FileSystem { <nl> / / RandomAccessFile implementation . Defaults to 256Mb . <nl> const size_t read_ahead_bytes_ = 256 * 1024 * 1024 ; <nl> <nl> - / / The max number of attempts to upload a file to GCS using the resumable <nl> - / / upload API . <nl> - const int32 max_upload_attempts_ = 5 ; <nl> + / / The initial delay for exponential backoffs when retrying failed calls . <nl> + const int64 initial_retry_delay_usec_ = 1000000L ; <nl> <nl> TF_DISALLOW_COPY_AND_ASSIGN ( GcsFileSystem ) ; <nl> } ; <nl> mmm a / tensorflow / core / platform / cloud / gcs_file_system_test . cc <nl> ppp b / tensorflow / core / platform / cloud / gcs_file_system_test . cc <nl> TEST ( GcsFileSystemTest , NewRandomAccessFile_NoReadAhead ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < RandomAccessFile > file ; <nl> TF_EXPECT_OK ( fs . NewRandomAccessFile ( " gs : / / bucket / random_access . txt " , & file ) ) ; <nl> TEST ( GcsFileSystemTest , NewRandomAccessFile_NoReadAhead_differentN ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < RandomAccessFile > file ; <nl> TF_EXPECT_OK ( fs . NewRandomAccessFile ( " gs : / / bucket / random_access . txt " , & file ) ) ; <nl> TEST ( GcsFileSystemTest , NewRandomAccessFile_WithReadAhead ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 5 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 5 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> char scratch [ 100 ] ; <nl> StringPiece result ; <nl> TEST ( GcsFileSystemTest , NewRandomAccessFile_NoObjectName ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 5 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 5 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < RandomAccessFile > file ; <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> TEST ( GcsFileSystemTest , NewWritableFile ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < WritableFile > file ; <nl> TF_EXPECT_OK ( fs . NewWritableFile ( " gs : / / bucket / path / writeable . txt " , & file ) ) ; <nl> TEST ( GcsFileSystemTest , NewWritableFile_ResumeUploadSucceeds ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < WritableFile > file ; <nl> TF_EXPECT_OK ( fs . NewWritableFile ( " gs : / / bucket / path / writeable . txt " , & file ) ) ; <nl> TEST ( GcsFileSystemTest , NewWritableFile_ResumeUploadSucceedsOnGetStatus ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < WritableFile > file ; <nl> TF_EXPECT_OK ( fs . NewWritableFile ( " gs : / / bucket / path / writeable . txt " , & file ) ) ; <nl> TEST ( GcsFileSystemTest , NewWritableFile_ResumeUploadAllAttemptsFail ) { <nl> " Auth Token : fake_token \ n " <nl> " Header Content - Range : bytes 0 - 16 / 17 \ n " <nl> " Put body : content1 , content2 \ n " , <nl> - " " , errors : : Unavailable ( " 503 " ) , 503 ) , <nl> - new FakeHttpRequest ( " Uri : https : / / custom / upload / location \ n " <nl> - " Auth Token : fake_token \ n " <nl> - " Header Content - Range : bytes * / 17 \ n " <nl> - " Put : yes \ n " , <nl> - " " , errors : : Unavailable ( " 308 " ) , nullptr , <nl> - { { " Range " , " 0 - 10 " } } , 308 ) , <nl> - new FakeHttpRequest ( " Uri : https : / / custom / upload / location \ n " <nl> - " Auth Token : fake_token \ n " <nl> - " Header Content - Range : bytes 11 - 16 / 17 \ n " <nl> - " Put body : ntent2 \ n " , <nl> - " " , errors : : Unavailable ( " 503 " ) , 503 ) , <nl> - / / These calls will be made in the Close ( ) attempt from the destructor . <nl> - / / Letting the destructor succeed . <nl> - new FakeHttpRequest ( <nl> - " Uri : https : / / www . googleapis . com / upload / storage / v1 / b / bucket / o ? " <nl> - " uploadType = resumable & name = path % 2Fwriteable . txt \ n " <nl> - " Auth Token : fake_token \ n " <nl> - " Header X - Upload - Content - Length : 17 \ n " <nl> - " Post : yes \ n " , <nl> - " " , { { " Location " , " https : / / custom / upload / location " } } ) , <nl> - new FakeHttpRequest ( " Uri : https : / / custom / upload / location \ n " <nl> - " Auth Token : fake_token \ n " <nl> - " Header Content - Range : bytes 0 - 16 / 17 \ n " <nl> - " Put body : content1 , content2 \ n " , <nl> - " " ) } ) ; <nl> + " " , errors : : Unavailable ( " 503 " ) , 503 ) } ) ; <nl> + for ( int i = 0 ; i < 10 ; i + + ) { <nl> + requests . emplace_back ( new FakeHttpRequest ( <nl> + " Uri : https : / / custom / upload / location \ n " <nl> + " Auth Token : fake_token \ n " <nl> + " Header Content - Range : bytes * / 17 \ n " <nl> + " Put : yes \ n " , <nl> + " " , errors : : Unavailable ( " 308 " ) , nullptr , { { " Range " , " 0 - 10 " } } , 308 ) ) ; <nl> + requests . emplace_back ( <nl> + new FakeHttpRequest ( " Uri : https : / / custom / upload / location \ n " <nl> + " Auth Token : fake_token \ n " <nl> + " Header Content - Range : bytes 11 - 16 / 17 \ n " <nl> + " Put body : ntent2 \ n " , <nl> + " " , errors : : Unavailable ( " 503 " ) , 503 ) ) ; <nl> + } <nl> + / / These calls will be made in the Close ( ) attempt from the destructor . <nl> + / / Letting the destructor succeed . <nl> + requests . emplace_back ( new FakeHttpRequest ( <nl> + " Uri : https : / / www . googleapis . com / upload / storage / v1 / b / bucket / o ? " <nl> + " uploadType = resumable & name = path % 2Fwriteable . txt \ n " <nl> + " Auth Token : fake_token \ n " <nl> + " Header X - Upload - Content - Length : 17 \ n " <nl> + " Post : yes \ n " , <nl> + " " , { { " Location " , " https : / / custom / upload / location " } } ) ) ; <nl> + requests . emplace_back ( <nl> + new FakeHttpRequest ( " Uri : https : / / custom / upload / location \ n " <nl> + " Auth Token : fake_token \ n " <nl> + " Header Content - Range : bytes 0 - 16 / 17 \ n " <nl> + " Put body : content1 , content2 \ n " , <nl> + " " ) ) ; <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> TEST ( GcsFileSystemTest , NewWritableFile_UploadReturns404 ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < WritableFile > file ; <nl> TF_EXPECT_OK ( fs . NewWritableFile ( " gs : / / bucket / path / writeable . txt " , & file ) ) ; <nl> TEST ( GcsFileSystemTest , NewWritableFile_NoObjectName ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 5 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 5 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < WritableFile > file ; <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> TEST ( GcsFileSystemTest , NewAppendableFile ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < WritableFile > file ; <nl> TF_EXPECT_OK ( fs . NewAppendableFile ( " gs : / / bucket / path / appendable . txt " , & file ) ) ; <nl> TEST ( GcsFileSystemTest , NewAppendableFile_NoObjectName ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 5 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 5 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < WritableFile > file ; <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> TEST ( GcsFileSystemTest , NewReadOnlyMemoryRegionFromFile ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < ReadOnlyMemoryRegion > region ; <nl> TF_EXPECT_OK ( fs . NewReadOnlyMemoryRegionFromFile ( <nl> TEST ( GcsFileSystemTest , NewReadOnlyMemoryRegionFromFile_NoObjectName ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 5 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 5 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : unique_ptr < ReadOnlyMemoryRegion > region ; <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> TEST ( GcsFileSystemTest , FileExists_YesAsObject ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . FileExists ( " gs : / / bucket / path / file1 . txt " ) ) ; <nl> } <nl> TEST ( GcsFileSystemTest , FileExists_YesAsFolder ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . FileExists ( " gs : / / bucket / path / subfolder " ) ) ; <nl> } <nl> TEST ( GcsFileSystemTest , FileExists_YesAsBucket ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . FileExists ( " gs : / / bucket1 " ) ) ; <nl> TF_EXPECT_OK ( fs . FileExists ( " gs : / / bucket1 / " ) ) ; <nl> TEST ( GcsFileSystemTest , FileExists_NotAsObjectOrFolder ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> EXPECT_EQ ( errors : : Code : : NOT_FOUND , <nl> fs . FileExists ( " gs : / / bucket / path / file1 . txt " ) . code ( ) ) ; <nl> TEST ( GcsFileSystemTest , FileExists_NotAsBucket ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> fs . FileExists ( " gs : / / bucket2 / " ) . code ( ) ) ; <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> TEST ( GcsFileSystemTest , GetChildren_NoItems ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > children ; <nl> TF_EXPECT_OK ( fs . GetChildren ( " gs : / / bucket / path / " , & children ) ) ; <nl> TEST ( GcsFileSystemTest , GetChildren_ThreeFiles ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > children ; <nl> TF_EXPECT_OK ( fs . GetChildren ( " gs : / / bucket / path / " , & children ) ) ; <nl> TEST ( GcsFileSystemTest , GetChildren_SelfDirectoryMarker ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > children ; <nl> TF_EXPECT_OK ( fs . GetChildren ( " gs : / / bucket / path / " , & children ) ) ; <nl> TEST ( GcsFileSystemTest , GetChildren_ThreeFiles_NoSlash ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > children ; <nl> TF_EXPECT_OK ( fs . GetChildren ( " gs : / / bucket / path " , & children ) ) ; <nl> TEST ( GcsFileSystemTest , GetChildren_Root ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > children ; <nl> TF_EXPECT_OK ( fs . GetChildren ( " gs : / / bucket - a - b - c " , & children ) ) ; <nl> TEST ( GcsFileSystemTest , GetChildren_Empty ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > children ; <nl> TF_EXPECT_OK ( fs . GetChildren ( " gs : / / bucket / path / " , & children ) ) ; <nl> TEST ( GcsFileSystemTest , GetChildren_Pagination ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > children ; <nl> TF_EXPECT_OK ( fs . GetChildren ( " gs : / / bucket / path " , & children ) ) ; <nl> TEST ( GcsFileSystemTest , GetMatchingPaths_NoWildcard ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > result ; <nl> TF_EXPECT_OK ( <nl> TEST ( GcsFileSystemTest , GetMatchingPaths_BucketAndWildcard ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > result ; <nl> TF_EXPECT_OK ( fs . GetMatchingPaths ( " gs : / / bucket / * / * " , & result ) ) ; <nl> TEST ( GcsFileSystemTest , GetMatchingPaths_FolderAndWildcard_Matches ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > result ; <nl> TF_EXPECT_OK ( fs . GetMatchingPaths ( " gs : / / bucket / path / * / file2 . txt " , & result ) ) ; <nl> TEST ( GcsFileSystemTest , GetMatchingPaths_SelfDirectoryMarker ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > result ; <nl> TF_EXPECT_OK ( fs . GetMatchingPaths ( " gs : / / bucket / path / * " , & result ) ) ; <nl> TEST ( GcsFileSystemTest , GetMatchingPaths_FolderAndWildcard_NoMatches ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > result ; <nl> TF_EXPECT_OK ( fs . GetMatchingPaths ( " gs : / / bucket / path / * / file3 . txt " , & result ) ) ; <nl> TEST ( GcsFileSystemTest , GetMatchingPaths_OnlyWildcard ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> std : : vector < string > result ; <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> TEST ( GcsFileSystemTest , DeleteFile ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . DeleteFile ( " gs : / / bucket / path / file1 . txt " ) ) ; <nl> } <nl> TEST ( GcsFileSystemTest , DeleteFile_NoObjectName ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 5 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 5 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> fs . DeleteFile ( " gs : / / bucket / " ) . code ( ) ) ; <nl> TEST ( GcsFileSystemTest , DeleteDir_Empty ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . DeleteDir ( " gs : / / bucket / path / " ) ) ; <nl> } <nl> TEST ( GcsFileSystemTest , DeleteDir_OnlyDirMarkerLeft ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . DeleteDir ( " gs : / / bucket / path / " ) ) ; <nl> } <nl> TEST ( GcsFileSystemTest , DeleteDir_BucketOnly ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . DeleteDir ( " gs : / / bucket " ) ) ; <nl> } <nl> TEST ( GcsFileSystemTest , DeleteDir_NonEmpty ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> EXPECT_EQ ( error : : Code : : FAILED_PRECONDITION , <nl> fs . DeleteDir ( " gs : / / bucket / path / " ) . code ( ) ) ; <nl> TEST ( GcsFileSystemTest , GetFileSize ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> uint64 size ; <nl> TF_EXPECT_OK ( fs . GetFileSize ( " gs : / / bucket / file . txt " , & size ) ) ; <nl> TEST ( GcsFileSystemTest , GetFileSize_NoObjectName ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 5 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 5 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> uint64 size ; <nl> EXPECT_EQ ( errors : : Code : : INVALID_ARGUMENT , <nl> TEST ( GcsFileSystemTest , RenameFile_Folder ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . RenameFile ( " gs : / / bucket / path1 " , " gs : / / bucket / path2 / " ) ) ; <nl> } <nl> TEST ( GcsFileSystemTest , RenameFile_Object ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( <nl> fs . RenameFile ( " gs : / / bucket / path / src . txt " , " gs : / / bucket / path / dst . txt " ) ) ; <nl> TEST ( GcsFileSystemTest , RenameFile_Object_Incomplete ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> EXPECT_EQ ( <nl> errors : : Code : : UNIMPLEMENTED , <nl> TEST ( GcsFileSystemTest , Stat_Object ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> FileStatistics stat ; <nl> TF_EXPECT_OK ( fs . Stat ( " gs : / / bucket / file . txt " , & stat ) ) ; <nl> TEST ( GcsFileSystemTest , Stat_Folder ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> FileStatistics stat ; <nl> TF_EXPECT_OK ( fs . Stat ( " gs : / / bucket / subfolder " , & stat ) ) ; <nl> TEST ( GcsFileSystemTest , Stat_ObjectOrFolderNotFound ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> FileStatistics stat ; <nl> EXPECT_EQ ( error : : Code : : NOT_FOUND , fs . Stat ( " gs : / / bucket / path " , & stat ) . code ( ) ) ; <nl> TEST ( GcsFileSystemTest , Stat_Bucket ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> FileStatistics stat ; <nl> TF_EXPECT_OK ( fs . Stat ( " gs : / / bucket / " , & stat ) ) ; <nl> TEST ( GcsFileSystemTest , Stat_BucketNotFound ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> FileStatistics stat ; <nl> EXPECT_EQ ( error : : Code : : NOT_FOUND , fs . Stat ( " gs : / / bucket / " , & stat ) . code ( ) ) ; <nl> TEST ( GcsFileSystemTest , IsDirectory_NotFound ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> EXPECT_EQ ( error : : Code : : NOT_FOUND , <nl> fs . IsDirectory ( " gs : / / bucket / file . txt " ) . code ( ) ) ; <nl> TEST ( GcsFileSystemTest , IsDirectory_NotDirectoryButObject ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> EXPECT_EQ ( error : : Code : : FAILED_PRECONDITION , <nl> fs . IsDirectory ( " gs : / / bucket / file . txt " ) . code ( ) ) ; <nl> TEST ( GcsFileSystemTest , IsDirectory_Yes ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . IsDirectory ( " gs : / / bucket / subfolder " ) ) ; <nl> TF_EXPECT_OK ( fs . IsDirectory ( " gs : / / bucket / subfolder / " ) ) ; <nl> TEST ( GcsFileSystemTest , IsDirectory_Bucket ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . IsDirectory ( " gs : / / bucket " ) ) ; <nl> TF_EXPECT_OK ( fs . IsDirectory ( " gs : / / bucket / " ) ) ; <nl> TEST ( GcsFileSystemTest , IsDirectory_BucketNotFound ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> EXPECT_EQ ( error : : Code : : NOT_FOUND , fs . IsDirectory ( " gs : / / bucket / " ) . code ( ) ) ; <nl> } <nl> TEST ( GcsFileSystemTest , CreateDir_Folder ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . CreateDir ( " gs : / / bucket / subpath " ) ) ; <nl> TF_EXPECT_OK ( fs . CreateDir ( " gs : / / bucket / subpath / " ) ) ; <nl> TEST ( GcsFileSystemTest , CreateDir_Bucket ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> TF_EXPECT_OK ( fs . CreateDir ( " gs : / / bucket / " ) ) ; <nl> TF_EXPECT_OK ( fs . CreateDir ( " gs : / / bucket " ) ) ; <nl> TEST ( GcsFileSystemTest , DeleteRecursively_Ok ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> int64 undeleted_files , undeleted_dirs ; <nl> TF_EXPECT_OK ( fs . DeleteRecursively ( " gs : / / bucket / path " , & undeleted_files , <nl> TEST ( GcsFileSystemTest , DeleteRecursively_DeletionErrors ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> int64 undeleted_files , undeleted_dirs ; <nl> TF_EXPECT_OK ( fs . DeleteRecursively ( " gs : / / bucket / path " , & undeleted_files , <nl> TEST ( GcsFileSystemTest , DeleteRecursively_NotAFolder ) { <nl> GcsFileSystem fs ( std : : unique_ptr < AuthProvider > ( new FakeAuthProvider ) , <nl> std : : unique_ptr < HttpRequest : : Factory > ( <nl> new FakeHttpRequestFactory ( & requests ) ) , <nl> - 0 / * read ahead bytes * / , 5 / * max upload attempts * / ) ; <nl> + 0 / * read ahead bytes * / , 0 / * initial retry delay * / ) ; <nl> <nl> int64 undeleted_files , undeleted_dirs ; <nl> EXPECT_EQ ( error : : Code : : NOT_FOUND , <nl> mmm a / tensorflow / core / platform / cloud / retrying_file_system_test . cc <nl> ppp b / tensorflow / core / platform / cloud / retrying_file_system_test . cc <nl> TEST ( RetryingFileSystemTest , NewRandomAccessFile_SuccessWith3rdTry ) { <nl> <nl> TEST ( RetryingFileSystemTest , NewRandomAccessFile_AllRetriesFailed ) { <nl> / / Configure the mock base random access file . <nl> - ExpectedCalls expected_file_calls = CreateRetriableErrors ( " Read " , 6 ) ; <nl> + ExpectedCalls expected_file_calls = CreateRetriableErrors ( " Read " , 11 ) ; <nl> std : : unique_ptr < RandomAccessFile > base_file ( <nl> new MockRandomAccessFile ( expected_file_calls ) ) ; <nl> <nl> TEST ( RetryingFileSystemTest , NewRandomAccessFile_AllRetriesFailed ) { <nl> / / Use it and check the results . <nl> StringPiece result ; <nl> char scratch [ 10 ] ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> random_access_file - > Read ( 0 , 10 , & result , scratch ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , NewAppendableFile_SuccessWith3rdTry ) { <nl> <nl> TEST ( RetryingFileSystemTest , NewWritableFile_AllRetriesFailed ) { <nl> / / Configure the mock base random access file . <nl> - ExpectedCalls expected_file_calls = CreateRetriableErrors ( " Sync " , 6 ) ; <nl> + ExpectedCalls expected_file_calls = CreateRetriableErrors ( " Sync " , 11 ) ; <nl> expected_file_calls . emplace_back ( std : : make_tuple ( " Close " , Status : : OK ( ) ) ) ; <nl> std : : unique_ptr < WritableFile > base_file ( <nl> new MockWritableFile ( expected_file_calls ) ) ; <nl> TEST ( RetryingFileSystemTest , NewWritableFile_AllRetriesFailed ) { <nl> TF_EXPECT_OK ( fs . NewWritableFile ( " filename . txt " , & writable_file ) ) ; <nl> <nl> / / Use it and check the results . <nl> - EXPECT_EQ ( " Retriable error # 5 " , writable_file - > Sync ( ) . error_message ( ) ) ; <nl> + EXPECT_EQ ( " Retriable error # 10 " , writable_file - > Sync ( ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , <nl> TEST ( RetryingFileSystemTest , <nl> <nl> TEST ( RetryingFileSystemTest , NewReadOnlyMemoryRegionFromFile_AllRetriesFailed ) { <nl> ExpectedCalls expected_fs_calls = <nl> - CreateRetriableErrors ( " NewReadOnlyMemoryRegionFromFile " , 6 ) ; <nl> + CreateRetriableErrors ( " NewReadOnlyMemoryRegionFromFile " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> std : : unique_ptr < ReadOnlyMemoryRegion > result ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . NewReadOnlyMemoryRegionFromFile ( " filename . txt " , & result ) <nl> . error_message ( ) ) ; <nl> } <nl> TEST ( RetryingFileSystemTest , GetChildren_SuccessWith2ndTry ) { <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , GetChildren_AllRetriesFailed ) { <nl> - ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " GetChildren " , 6 ) ; <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " GetChildren " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> std : : vector < string > result ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . GetChildren ( " gs : / / path " , & result ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , GetMatchingPaths_SuccessWith2ndTry ) { <nl> <nl> TEST ( RetryingFileSystemTest , GetMatchingPaths_AllRetriesFailed ) { <nl> ExpectedCalls expected_fs_calls = <nl> - CreateRetriableErrors ( " GetMatchingPaths " , 6 ) ; <nl> + CreateRetriableErrors ( " GetMatchingPaths " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> std : : vector < string > result ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . GetMatchingPaths ( " gs : / / path / dir " , & result ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , DeleteFile_SuccessWith2ndTry ) { <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , DeleteFile_AllRetriesFailed ) { <nl> - ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " DeleteFile " , 6 ) ; <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " DeleteFile " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> std : : vector < string > result ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . DeleteFile ( " gs : / / path / file . txt " ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , CreateDir_SuccessWith2ndTry ) { <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , CreateDir_AllRetriesFailed ) { <nl> - ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " CreateDir " , 6 ) ; <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " CreateDir " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> std : : vector < string > result ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . CreateDir ( " gs : / / path / newdir " ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , DeleteDir_SuccessWith2ndTry ) { <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , DeleteDir_AllRetriesFailed ) { <nl> - ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " DeleteDir " , 6 ) ; <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " DeleteDir " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> std : : vector < string > result ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . DeleteDir ( " gs : / / path / dir " ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , GetFileSize_SuccessWith2ndTry ) { <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , GetFileSize_AllRetriesFailed ) { <nl> - ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " GetFileSize " , 6 ) ; <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " GetFileSize " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> uint64 size ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . GetFileSize ( " gs : / / path / file . txt " , & size ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , RenameFile_SuccessWith2ndTry ) { <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , RenameFile_AllRetriesFailed ) { <nl> - ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " RenameFile " , 6 ) ; <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " RenameFile " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . RenameFile ( " old_name " , " new_name " ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , Stat_SuccessWith2ndTry ) { <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , Stat_AllRetriesFailed ) { <nl> - ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " Stat " , 6 ) ; <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " Stat " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> FileStatistics stat ; <nl> - EXPECT_EQ ( " Retriable error # 5 " , fs . Stat ( " file_name " , & stat ) . error_message ( ) ) ; <nl> + EXPECT_EQ ( " Retriable error # 10 " , fs . Stat ( " file_name " , & stat ) . error_message ( ) ) ; <nl> + } <nl> + <nl> + TEST ( RetryingFileSystemTest , FileExists_AllRetriesFailed ) { <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " FileExists " , 11 ) ; <nl> + std : : unique_ptr < MockFileSystem > base_fs ( <nl> + new MockFileSystem ( expected_fs_calls ) ) ; <nl> + RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> + <nl> + EXPECT_EQ ( " Retriable error # 10 " , fs . FileExists ( " file_name " ) . error_message ( ) ) ; <nl> + } <nl> + <nl> + TEST ( RetryingFileSystemTest , FileExists_SuccessWith2ndTry ) { <nl> + ExpectedCalls expected_fs_calls ( <nl> + { std : : make_tuple ( " FileExists " , errors : : Unavailable ( " Something is wrong " ) ) , <nl> + std : : make_tuple ( " FileExists " , Status : : OK ( ) ) } ) ; <nl> + std : : unique_ptr < MockFileSystem > base_fs ( <nl> + new MockFileSystem ( expected_fs_calls ) ) ; <nl> + RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> + <nl> + TF_EXPECT_OK ( fs . FileExists ( " gs : / / path / dir " ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , IsDirectory_SuccessWith2ndTry ) { <nl> TEST ( RetryingFileSystemTest , IsDirectory_SuccessWith2ndTry ) { <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , IsDirectory_AllRetriesFailed ) { <nl> - ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " IsDirectory " , 6 ) ; <nl> + ExpectedCalls expected_fs_calls = CreateRetriableErrors ( " IsDirectory " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> <nl> - EXPECT_EQ ( " Retriable error # 5 " , <nl> + EXPECT_EQ ( " Retriable error # 10 " , <nl> fs . IsDirectory ( " gs : / / path / dir " ) . error_message ( ) ) ; <nl> } <nl> <nl> TEST ( RetryingFileSystemTest , DeleteRecursively_SuccessWith2ndTry ) { <nl> <nl> TEST ( RetryingFileSystemTest , DeleteRecursively_AllRetriesFailed ) { <nl> ExpectedCalls expected_fs_calls = <nl> - CreateRetriableErrors ( " DeleteRecursively " , 6 ) ; <nl> + CreateRetriableErrors ( " DeleteRecursively " , 11 ) ; <nl> std : : unique_ptr < MockFileSystem > base_fs ( <nl> new MockFileSystem ( expected_fs_calls ) ) ; <nl> RetryingFileSystem fs ( std : : move ( base_fs ) , 0 ) ; <nl> int64 undeleted_files , undeleted_dirs ; <nl> <nl> EXPECT_EQ ( <nl> - " Retriable error # 5 " , <nl> + " Retriable error # 10 " , <nl> fs . DeleteRecursively ( " gs : / / path / dir " , & undeleted_files , & undeleted_dirs ) <nl> . error_message ( ) ) ; <nl> } <nl> mmm a / tensorflow / core / platform / cloud / retrying_utils . cc <nl> ppp b / tensorflow / core / platform / cloud / retrying_utils . cc <nl> namespace tensorflow { <nl> namespace { <nl> <nl> / / In case of failure , every call will be retried kMaxRetries times . <nl> - constexpr int kMaxRetries = 5 ; <nl> + constexpr int kMaxRetries = 10 ; <nl> / / Maximum backoff time in microseconds . <nl> constexpr int64 kMaximumBackoffMicroseconds = 32000000 ; / / 32 seconds . <nl> <nl> bool IsRetriable ( Status status ) { <nl> } <nl> } <nl> <nl> - void WaitBeforeRetry ( const int64 delay_micros ) { <nl> + void WaitBeforeRetry ( const int64 delay_micros , <nl> + const std : : function < void ( int64 ) > & sleep_usec ) { <nl> const int64 random_micros = random : : New64 ( ) % 1000000 ; <nl> - Env : : Default ( ) - > SleepForMicroseconds ( std : : min ( delay_micros + random_micros , <nl> - kMaximumBackoffMicroseconds ) ) ; <nl> + sleep_usec ( std : : min ( delay_micros , kMaximumBackoffMicroseconds ) + <nl> + random_micros ) ; <nl> } <nl> <nl> } / / namespace <nl> <nl> Status RetryingUtils : : CallWithRetries ( const std : : function < Status ( ) > & f , <nl> const int64 initial_delay_microseconds ) { <nl> + return CallWithRetries ( f , initial_delay_microseconds , <nl> + std : : bind ( & Env : : SleepForMicroseconds , Env : : Default ( ) , <nl> + std : : placeholders : : _1 ) ) ; <nl> + } <nl> + <nl> + Status RetryingUtils : : CallWithRetries ( <nl> + const std : : function < Status ( ) > & f , const int64 initial_delay_microseconds , <nl> + const std : : function < void ( int64 ) > & sleep_usec ) { <nl> int retries = 0 ; <nl> while ( true ) { <nl> auto status = f ( ) ; <nl> Status RetryingUtils : : CallWithRetries ( const std : : function < Status ( ) > & f , <nl> } <nl> const int64 delay_micros = initial_delay_microseconds < < retries ; <nl> if ( delay_micros > 0 ) { <nl> - WaitBeforeRetry ( delay_micros ) ; <nl> + WaitBeforeRetry ( delay_micros , sleep_usec ) ; <nl> } <nl> retries + + ; <nl> } <nl> } <nl> - <nl> } / / namespace tensorflow <nl> mmm a / tensorflow / core / platform / cloud / retrying_utils . h <nl> ppp b / tensorflow / core / platform / cloud / retrying_utils . h <nl> class RetryingUtils { <nl> / / / If all retries failed , returns the last error status . <nl> static Status CallWithRetries ( const std : : function < Status ( ) > & f , <nl> const int64 initial_delay_microseconds ) ; <nl> + / / / sleep_usec is a function that sleeps for the given number of microseconds . <nl> + static Status CallWithRetries ( const std : : function < Status ( ) > & f , <nl> + const int64 initial_delay_microseconds , <nl> + const std : : function < void ( int64 ) > & sleep_usec ) ; <nl> } ; <nl> <nl> } / / namespace tensorflow <nl> new file mode 100644 <nl> index 0000000000000 . . 59af77a7a24e5 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / platform / cloud / retrying_utils_test . cc <nl> <nl> + / * Copyright 2017 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / core / platform / cloud / retrying_utils . h " <nl> + # include < fstream > <nl> + # include " tensorflow / core / lib / core / status_test_util . h " <nl> + # include " tensorflow / core / platform / env . h " <nl> + # include " tensorflow / core / platform / test . h " <nl> + <nl> + namespace tensorflow { <nl> + namespace { <nl> + <nl> + TEST ( RetryingUtilsTest , RetryDelays ) { <nl> + std : : vector < double > requested_delays ; / / requested delays in seconds <nl> + std : : function < void ( int64 ) > sleep = [ & requested_delays ] ( int64 delay ) { <nl> + requested_delays . emplace_back ( delay / 1000000 . 0 ) ; <nl> + } ; <nl> + std : : function < Status ( ) > f = [ ] ( ) { return errors : : Unavailable ( " " ) ; } ; <nl> + <nl> + EXPECT_EQ ( errors : : Code : : UNAVAILABLE , <nl> + RetryingUtils : : CallWithRetries ( f , 500000L , sleep ) . code ( ) ) ; <nl> + <nl> + EXPECT_EQ ( 10 , requested_delays . size ( ) ) ; <nl> + EXPECT_NEAR ( 0 . 5 , requested_delays [ 0 ] , 1 . 0 ) ; <nl> + EXPECT_NEAR ( 1 . 0 , requested_delays [ 1 ] , 1 . 0 ) ; <nl> + EXPECT_NEAR ( 2 . 0 , requested_delays [ 2 ] , 1 . 0 ) ; <nl> + EXPECT_NEAR ( 4 . 0 , requested_delays [ 3 ] , 1 . 0 ) ; <nl> + EXPECT_NEAR ( 8 . 0 , requested_delays [ 4 ] , 1 . 0 ) ; <nl> + EXPECT_NEAR ( 16 . 0 , requested_delays [ 5 ] , 1 . 0 ) ; <nl> + <nl> + / / All subsequent delays are capped at 32 seconds ( plus jitter ) . <nl> + EXPECT_NEAR ( 32 . 0 , requested_delays [ 6 ] , 1 . 0 ) ; <nl> + EXPECT_NEAR ( 32 . 0 , requested_delays [ 7 ] , 1 . 0 ) ; <nl> + EXPECT_NEAR ( 32 . 0 , requested_delays [ 8 ] , 1 . 0 ) ; <nl> + EXPECT_NEAR ( 32 . 0 , requested_delays [ 9 ] , 1 . 0 ) ; <nl> + } <nl> + <nl> + TEST ( RetryingUtilsTest , NotFoundIsNotRetried ) { <nl> + std : : vector < Status > results ( { errors : : Unavailable ( " " ) , errors : : NotFound ( " " ) } ) ; <nl> + std : : function < Status ( ) > f = [ & results ] ( ) { <nl> + auto result = results [ 0 ] ; <nl> + results . erase ( results . begin ( ) ) ; <nl> + return result ; <nl> + } ; <nl> + EXPECT_EQ ( errors : : Code : : NOT_FOUND , <nl> + RetryingUtils : : CallWithRetries ( f , 0 ) . code ( ) ) ; <nl> + } <nl> + <nl> + TEST ( RetryingUtilsTest , EventualSuccess ) { <nl> + std : : vector < Status > results ( <nl> + { errors : : Unavailable ( " " ) , errors : : Unavailable ( " " ) , Status : : OK ( ) } ) ; <nl> + std : : function < Status ( ) > f = [ & results ] ( ) { <nl> + auto result = results [ 0 ] ; <nl> + results . erase ( results . begin ( ) ) ; <nl> + return result ; <nl> + } ; <nl> + TF_EXPECT_OK ( RetryingUtils : : CallWithRetries ( f , 0 ) ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + } / / namespace tensorflow <nl> | Merge | tensorflow/tensorflow | d4fd3b106c62787206ac2780d202abe2af3ebdb7 | 2017-03-03T21:23:00Z |
mmm a / x64_dbg_dbg / threading . h <nl> ppp b / x64_dbg_dbg / threading . h <nl> enum SectionLock <nl> LockPluginCallbackList , <nl> LockPluginCommandList , <nl> LockPluginMenuList , <nl> - <nl> - / / This is defined because of a bug in the Windows 8 . 1 kernel ; <nl> - / / Calling VirtualQuery / VirtualProtect / ReadProcessMemory can and will cause <nl> - / / a deadlock . <nl> - / / <nl> - / / There ' s also no real way to fix this with a lock . Any external program <nl> - / / calling memory functions creates a deadlock too . ( See : ETW Tracing ) <nl> - / / <nl> - / / https : / / github . com / x64dbg / x64dbg / issues / 247 <nl> - LockWin8Workaround , <nl> - <nl> LockLast , <nl> } ; <nl> <nl> | DBG : Win8 . 1 kernel bug appears to be fixed | x64dbg/x64dbg | 9d5860d1e112129e03fc79407640779b0fb62538 | 2015-07-17T05:22:20Z |
mmm a / src / core / frontend / applets / controller . cpp <nl> ppp b / src / core / frontend / applets / controller . cpp <nl> <nl> <nl> # include " common / assert . h " <nl> # include " common / logging / log . h " <nl> - # include " core / core . h " <nl> # include " core / frontend / applets / controller . h " <nl> # include " core / hle / service / hid / controllers / npad . h " <nl> # include " core / hle / service / hid / hid . h " <nl> namespace Core : : Frontend { <nl> <nl> ControllerApplet : : ~ ControllerApplet ( ) = default ; <nl> <nl> + DefaultControllerApplet : : DefaultControllerApplet ( Service : : SM : : ServiceManager & service_manager_ ) <nl> + : service_manager { service_manager_ } { } <nl> + <nl> DefaultControllerApplet : : ~ DefaultControllerApplet ( ) = default ; <nl> <nl> void DefaultControllerApplet : : ReconfigureControllers ( std : : function < void ( ) > callback , <nl> void DefaultControllerApplet : : ReconfigureControllers ( std : : function < void ( ) > callb <nl> LOG_INFO ( Service_HID , " called , deducing the best configuration based on the given parameters ! " ) ; <nl> <nl> auto & npad = <nl> - Core : : System : : GetInstance ( ) <nl> - . ServiceManager ( ) <nl> - . GetService < Service : : HID : : Hid > ( " hid " ) <nl> + service_manager . GetService < Service : : HID : : Hid > ( " hid " ) <nl> - > GetAppletResource ( ) <nl> - > GetController < Service : : HID : : Controller_NPad > ( Service : : HID : : HidController : : NPad ) ; <nl> <nl> mmm a / src / core / frontend / applets / controller . h <nl> ppp b / src / core / frontend / applets / controller . h <nl> <nl> <nl> # include " common / common_types . h " <nl> <nl> + namespace Service : : SM { <nl> + class ServiceManager ; <nl> + } <nl> + <nl> namespace Core : : Frontend { <nl> <nl> using BorderColor = std : : array < u8 , 4 > ; <nl> class ControllerApplet { <nl> <nl> class DefaultControllerApplet final : public ControllerApplet { <nl> public : <nl> + explicit DefaultControllerApplet ( Service : : SM : : ServiceManager & service_manager_ ) ; <nl> ~ DefaultControllerApplet ( ) override ; <nl> <nl> void ReconfigureControllers ( std : : function < void ( ) > callback , <nl> ControllerParameters parameters ) const override ; <nl> + <nl> + private : <nl> + Service : : SM : : ServiceManager & service_manager ; <nl> } ; <nl> <nl> } / / namespace Core : : Frontend <nl> mmm a / src / core / hle / service / am / applets / applets . cpp <nl> ppp b / src / core / hle / service / am / applets / applets . cpp <nl> void AppletManager : : SetDefaultAppletFrontendSet ( ) { <nl> <nl> void AppletManager : : SetDefaultAppletsIfMissing ( ) { <nl> if ( frontend . controller = = nullptr ) { <nl> - frontend . controller = std : : make_unique < Core : : Frontend : : DefaultControllerApplet > ( ) ; <nl> + frontend . controller = <nl> + std : : make_unique < Core : : Frontend : : DefaultControllerApplet > ( system . ServiceManager ( ) ) ; <nl> } <nl> <nl> if ( frontend . e_commerce = = nullptr ) { <nl> | frontend / controller : Eliminate dependency on the global system instance | yuzu-emu/yuzu | 3e4a0a13cb2f2e02bdb623d763a63a71c2c5da7a | 2020-09-25T23:23:20Z |
mmm a / src / core / arm / dynarmic / arm_dynarmic . cpp <nl> ppp b / src / core / arm / dynarmic / arm_dynarmic . cpp <nl> MICROPROFILE_DEFINE ( ARM_Jit , " ARM JIT " , " ARM JIT " , MP_RGB ( 255 , 64 , 64 ) ) ; <nl> void ARM_Dynarmic : : ExecuteInstructions ( int num_instructions ) { <nl> MICROPROFILE_SCOPE ( ARM_Jit ) ; <nl> <nl> - jit - > Run ( static_cast < unsigned > ( num_instructions ) ) ; <nl> + unsigned ticks_executed = jit - > Run ( static_cast < unsigned > ( num_instructions ) ) ; <nl> <nl> - AddTicks ( num_instructions ) ; <nl> + AddTicks ( ticks_executed ) ; <nl> } <nl> <nl> void ARM_Dynarmic : : SaveContext ( Core : : ThreadContext & ctx ) { <nl> | Merge pull request from MerryMage / ticks_executed | yuzu-emu/yuzu | b230913c2bd52aae69c536b7e8e9868132468d69 | 2016-11-26T21:51:11Z |
mmm a / tensorflow / core / kernels / cuda_sparse . cc <nl> ppp b / tensorflow / core / kernels / cuda_sparse . cc <nl> static inline Status GtsvStridedBatchImpl ( SparseFn op , <nl> <nl> TF_CALL_LAPACK_TYPES ( GTSV_STRIDED_BATCH_INSTANCE ) ; <nl> <nl> + template < typename Scalar , typename SparseFn > <nl> + static inline Status Gtsv2Impl ( SparseFn op , cusparseHandle_t cusparse_handle , <nl> + int m , int n , const Scalar * dl , const Scalar * d , <nl> + const Scalar * du , Scalar * B , int ldb , <nl> + void * pBuffer ) { <nl> + TF_RETURN_IF_CUSPARSE_ERROR ( op ( cusparse_handle , m , n , AsCudaComplex ( dl ) , <nl> + AsCudaComplex ( d ) , AsCudaComplex ( du ) , <nl> + AsCudaComplex ( B ) , ldb , pBuffer ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define GTSV2_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status CudaSparse : : Gtsv2 < Scalar > ( int m , int n , const Scalar * dl , \ <nl> + const Scalar * d , const Scalar * du , \ <nl> + Scalar * B , int ldb , void * pBuffer ) const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return Gtsv2Impl ( SPARSE_FN ( gtsv2 , sparse_prefix ) , * cusparse_handle_ , m , n , \ <nl> + dl , d , du , B , ldb , pBuffer ) ; \ <nl> + } <nl> + <nl> + TF_CALL_LAPACK_TYPES ( GTSV2_INSTANCE ) ; <nl> + <nl> + # define GTSV2_NO_PIVOT_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status CudaSparse : : Gtsv2NoPivot < Scalar > ( \ <nl> + int m , int n , const Scalar * dl , const Scalar * d , const Scalar * du , \ <nl> + Scalar * B , int ldb , void * pBuffer ) const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return Gtsv2Impl ( SPARSE_FN ( gtsv2_nopivot , sparse_prefix ) , \ <nl> + * cusparse_handle_ , m , n , dl , d , du , B , ldb , pBuffer ) ; \ <nl> + } <nl> + <nl> + TF_CALL_LAPACK_TYPES ( GTSV2_NO_PIVOT_INSTANCE ) ; <nl> + <nl> + template < typename Scalar , typename SparseFn > <nl> + static inline Status Gtsv2BufferSizeExtImpl ( SparseFn op , <nl> + cusparseHandle_t cusparse_handle , <nl> + int m , int n , const Scalar * dl , <nl> + const Scalar * d , const Scalar * du , <nl> + const Scalar * B , int ldb , <nl> + size_t * bufferSizeInBytes ) { <nl> + TF_RETURN_IF_CUSPARSE_ERROR ( op ( cusparse_handle , m , n , AsCudaComplex ( dl ) , <nl> + AsCudaComplex ( d ) , AsCudaComplex ( du ) , <nl> + AsCudaComplex ( B ) , ldb , bufferSizeInBytes ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define GTSV2_BUFFER_SIZE_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status CudaSparse : : Gtsv2BufferSizeExt < Scalar > ( \ <nl> + int m , int n , const Scalar * dl , const Scalar * d , const Scalar * du , \ <nl> + const Scalar * B , int ldb , size_t * bufferSizeInBytes ) const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return Gtsv2BufferSizeExtImpl ( \ <nl> + SPARSE_FN ( gtsv2_bufferSizeExt , sparse_prefix ) , * cusparse_handle_ , m , \ <nl> + n , dl , d , du , B , ldb , bufferSizeInBytes ) ; \ <nl> + } <nl> + <nl> + TF_CALL_LAPACK_TYPES ( GTSV2_BUFFER_SIZE_INSTANCE ) ; <nl> + <nl> + # define GTSV2_NO_PIVOT_BUFFER_SIZE_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status CudaSparse : : Gtsv2NoPivotBufferSizeExt < Scalar > ( \ <nl> + int m , int n , const Scalar * dl , const Scalar * d , const Scalar * du , \ <nl> + const Scalar * B , int ldb , size_t * bufferSizeInBytes ) const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return Gtsv2BufferSizeExtImpl ( \ <nl> + SPARSE_FN ( gtsv2_nopivot_bufferSizeExt , sparse_prefix ) , \ <nl> + * cusparse_handle_ , m , n , dl , d , du , B , ldb , bufferSizeInBytes ) ; \ <nl> + } <nl> + <nl> + TF_CALL_LAPACK_TYPES ( GTSV2_NO_PIVOT_BUFFER_SIZE_INSTANCE ) ; <nl> + <nl> + template < typename Scalar , typename SparseFn > <nl> + static inline Status Gtsv2StridedBatchImpl ( SparseFn op , <nl> + cusparseHandle_t cusparse_handle , <nl> + int m , const Scalar * dl , <nl> + const Scalar * d , const Scalar * du , <nl> + Scalar * x , int batchCount , <nl> + int batchStride , void * pBuffer ) { <nl> + TF_RETURN_IF_CUSPARSE_ERROR ( op ( <nl> + cusparse_handle , m , AsCudaComplex ( dl ) , AsCudaComplex ( d ) , <nl> + AsCudaComplex ( du ) , AsCudaComplex ( x ) , batchCount , batchStride , pBuffer ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define GTSV2_STRIDED_BATCH_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status CudaSparse : : Gtsv2StridedBatch < Scalar > ( \ <nl> + int m , const Scalar * dl , const Scalar * d , const Scalar * du , Scalar * x , \ <nl> + int batchCount , int batchStride , void * pBuffer ) const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return Gtsv2StridedBatchImpl ( SPARSE_FN ( gtsv2StridedBatch , sparse_prefix ) , \ <nl> + * cusparse_handle_ , m , dl , d , du , x , \ <nl> + batchCount , batchStride , pBuffer ) ; \ <nl> + } <nl> + <nl> + TF_CALL_LAPACK_TYPES ( GTSV2_STRIDED_BATCH_INSTANCE ) ; <nl> + <nl> + template < typename Scalar , typename SparseFn > <nl> + static inline Status Gtsv2StridedBatchBufferSizeImpl ( <nl> + SparseFn op , cusparseHandle_t cusparse_handle , int m , const Scalar * dl , <nl> + const Scalar * d , const Scalar * du , const Scalar * x , int batchCount , <nl> + int batchStride , size_t * bufferSizeInBytes ) { <nl> + TF_RETURN_IF_CUSPARSE_ERROR ( op ( cusparse_handle , m , AsCudaComplex ( dl ) , <nl> + AsCudaComplex ( d ) , AsCudaComplex ( du ) , <nl> + AsCudaComplex ( x ) , batchCount , batchStride , <nl> + bufferSizeInBytes ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define GTSV2_STRIDED_BATCH_BUFFER_SIZE_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status CudaSparse : : Gtsv2StridedBatchBufferSizeExt < Scalar > ( \ <nl> + int m , const Scalar * dl , const Scalar * d , const Scalar * du , \ <nl> + const Scalar * x , int batchCount , int batchStride , \ <nl> + size_t * bufferSizeInBytes ) const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return Gtsv2StridedBatchBufferSizeImpl ( \ <nl> + SPARSE_FN ( gtsv2StridedBatch_bufferSizeExt , sparse_prefix ) , \ <nl> + * cusparse_handle_ , m , dl , d , du , x , batchCount , batchStride , \ <nl> + bufferSizeInBytes ) ; \ <nl> + } <nl> + <nl> + TF_CALL_LAPACK_TYPES ( GTSV2_STRIDED_BATCH_BUFFER_SIZE_INSTANCE ) ; <nl> + <nl> } / / namespace tensorflow <nl> <nl> # endif / / GOOGLE_CUDA <nl> mmm a / tensorflow / core / kernels / cuda_sparse . h <nl> ppp b / tensorflow / core / kernels / cuda_sparse . h <nl> class CudaSparse { <nl> / / <nl> <nl> / / Solves tridiagonal system of equations . <nl> + / / Note : Cuda Toolkit 9 . 0 + has better - performing gtsv2 routine . gtsv will be <nl> + / / removed in Cuda Toolkit 11 . 0 . <nl> / / See : https : / / docs . nvidia . com / cuda / cusparse / index . html # cusparse - lt - t - gt - gtsv <nl> / / Returns Status : : OK ( ) if the kernel was launched successfully . <nl> template < typename Scalar > <nl> class CudaSparse { <nl> Scalar * B , int ldb ) const ; <nl> <nl> / / Solves tridiagonal system of equations without pivoting . <nl> + / / Note : Cuda Toolkit 9 . 0 + has better - performing gtsv2_nopivot routine . <nl> + / / gtsv_nopivot will be removed in Cuda Toolkit 11 . 0 . <nl> / / See : <nl> / / https : / / docs . nvidia . com / cuda / cusparse / index . html # cusparse - lt - t - gt - gtsv_nopivot <nl> / / Returns Status : : OK ( ) if the kernel was launched successfully . <nl> class CudaSparse { <nl> <nl> / / Solves a batch of tridiagonal systems of equations . Doesn ' t support <nl> / / multiple right - hand sides per each system . Doesn ' t do pivoting . <nl> + / / Note : Cuda Toolkit 9 . 0 + has better - performing gtsv2StridedBatch routine . <nl> + / / gtsvStridedBatch will be removed in Cuda Toolkit 11 . 0 . <nl> / / See : <nl> / / https : / / docs . nvidia . com / cuda / cusparse / index . html # cusparse - lt - t - gt - gtsvstridedbatch <nl> / / Returns Status : : OK ( ) if the kernel was launched successfully . <nl> class CudaSparse { <nl> const Scalar * du , Scalar * x , int batchCount , <nl> int batchStride ) const ; <nl> <nl> + / / Solves tridiagonal system of equations . <nl> + / / See : https : / / docs . nvidia . com / cuda / cusparse / index . html # gtsv2 <nl> + template < typename Scalar > <nl> + Status Gtsv2 ( int m , int n , const Scalar * dl , const Scalar * d , <nl> + const Scalar * du , Scalar * B , int ldb , void * pBuffer ) const ; <nl> + <nl> + / / Computes the size of a temporary buffer used by Gtsv2 . <nl> + / / See : https : / / docs . nvidia . com / cuda / cusparse / index . html # gtsv2_bufferSize <nl> + template < typename Scalar > <nl> + Status Gtsv2BufferSizeExt ( int m , int n , const Scalar * dl , const Scalar * d , <nl> + const Scalar * du , const Scalar * B , int ldb , <nl> + size_t * bufferSizeInBytes ) const ; <nl> + <nl> + / / Solves tridiagonal system of equations without partial pivoting . <nl> + / / See : https : / / docs . nvidia . com / cuda / cusparse / index . html # gtsv2_nopivot <nl> + template < typename Scalar > <nl> + Status Gtsv2NoPivot ( int m , int n , const Scalar * dl , const Scalar * d , <nl> + const Scalar * du , Scalar * B , int ldb , <nl> + void * pBuffer ) const ; <nl> + <nl> + / / Computes the size of a temporary buffer used by Gtsv2NoPivot . <nl> + / / See : <nl> + / / https : / / docs . nvidia . com / cuda / cusparse / index . html # gtsv2_nopivot_bufferSize <nl> + template < typename Scalar > <nl> + Status Gtsv2NoPivotBufferSizeExt ( int m , int n , const Scalar * dl , <nl> + const Scalar * d , const Scalar * du , <nl> + const Scalar * B , int ldb , <nl> + size_t * bufferSizeInBytes ) const ; <nl> + <nl> + / / Solves a batch of tridiagonal systems of equations . Doesn ' t support <nl> + / / multiple right - hand sides per each system . Doesn ' t do pivoting . <nl> + / / See : https : / / docs . nvidia . com / cuda / cusparse / index . html # gtsv2stridedbatch <nl> + template < typename Scalar > <nl> + Status Gtsv2StridedBatch ( int m , const Scalar * dl , const Scalar * d , <nl> + const Scalar * du , Scalar * x , int batchCount , <nl> + int batchStride , void * pBuffer ) const ; <nl> + <nl> + / / Computes the size of a temporary buffer used by Gtsv2StridedBatch . <nl> + / / See : <nl> + / / https : / / docs . nvidia . com / cuda / cusparse / index . html # gtsv2stridedbatch_bufferSize <nl> + template < typename Scalar > <nl> + Status Gtsv2StridedBatchBufferSizeExt ( int m , const Scalar * dl , <nl> + const Scalar * d , const Scalar * du , <nl> + const Scalar * x , int batchCount , <nl> + int batchStride , <nl> + size_t * bufferSizeInBytes ) const ; <nl> + <nl> private : <nl> bool initialized_ ; <nl> OpKernelContext * context_ ; / / not owned . <nl> mmm a / tensorflow / core / kernels / tridiagonal_solve_op_gpu . cu . cc <nl> ppp b / tensorflow / core / kernels / tridiagonal_solve_op_gpu . cu . cc <nl> limitations under the License . <nl> # include " tensorflow / core / framework / op_kernel . h " <nl> # include " tensorflow / core / framework / register_types . h " <nl> # include " tensorflow / core / framework / tensor_shape . h " <nl> + # include " tensorflow / core / framework / types . h " <nl> # include " tensorflow / core / kernels / cuda_solvers . h " <nl> # include " tensorflow / core / kernels / cuda_sparse . h " <nl> # include " tensorflow / core / kernels / linalg_ops_common . h " <nl> class TridiagonalSolveOpGpuLinalg : public LinearAlgebraOp < Scalar > { <nl> const Scalar * superdiag , const Scalar * diag , <nl> const Scalar * subdiag , Scalar * rhs , const int num_eqs , <nl> const int num_rhs ) const { <nl> + # if CUDA_VERSION < 9000 <nl> auto function = pivoting_ ? & CudaSparse : : Gtsv < Scalar > <nl> : & CudaSparse : : GtsvNoPivot < Scalar > ; <nl> OP_REQUIRES_OK ( <nl> context , ( cusparse_solver . get ( ) - > * function ) ( <nl> num_eqs , num_rhs , subdiag , diag , superdiag , rhs , num_eqs ) ) ; <nl> + # else <nl> + auto buffer_function = pivoting_ <nl> + ? & CudaSparse : : Gtsv2BufferSizeExt < Scalar > <nl> + : & CudaSparse : : Gtsv2NoPivotBufferSizeExt < Scalar > ; <nl> + size_t buffer_size ; <nl> + OP_REQUIRES_OK ( context , ( cusparse_solver . get ( ) - > * buffer_function ) ( <nl> + num_eqs , num_rhs , subdiag , diag , superdiag , rhs , <nl> + num_eqs , & buffer_size ) ) ; <nl> + Tensor temp_tensor ; <nl> + TensorShape temp_shape ( { static_cast < int64 > ( buffer_size ) } ) ; <nl> + OP_REQUIRES_OK ( context , <nl> + context - > allocate_temp ( DT_UINT8 , temp_shape , & temp_tensor ) ) ; <nl> + void * buffer = temp_tensor . flat < std : : uint8_t > ( ) . data ( ) ; <nl> + <nl> + auto solver_function = pivoting_ ? & CudaSparse : : Gtsv2 < Scalar > <nl> + : & CudaSparse : : Gtsv2NoPivot < Scalar > ; <nl> + OP_REQUIRES_OK ( context , ( cusparse_solver . get ( ) - > * solver_function ) ( <nl> + num_eqs , num_rhs , subdiag , diag , superdiag , rhs , <nl> + num_eqs , buffer ) ) ; <nl> + # endif / / CUDA_VERSION < 9000 <nl> } <nl> <nl> void SolveForSizeOneOrTwo ( OpKernelContext * context , const Scalar * diagonals , <nl> class TridiagonalSolveOpGpu : public OpKernel { <nl> std : : unique_ptr < CudaSparse > cusparse_solver ( new CudaSparse ( context ) ) ; <nl> <nl> OP_REQUIRES_OK ( context , cusparse_solver - > Initialize ( ) ) ; <nl> + # if CUDA_VERSION < 9000 <nl> OP_REQUIRES_OK ( context , cusparse_solver - > GtsvStridedBatch ( <nl> matrix_size , subdiag , diag , superdiag , x , <nl> batch_size , matrix_size ) ) ; <nl> + # else <nl> + size_t buffer_size ; <nl> + OP_REQUIRES_OK ( context , cusparse_solver - > Gtsv2StridedBatchBufferSizeExt ( <nl> + matrix_size , subdiag , diag , superdiag , x , <nl> + batch_size , matrix_size , & buffer_size ) ) ; <nl> + Tensor temp_tensor ; <nl> + TensorShape temp_shape ( { static_cast < int64 > ( buffer_size ) } ) ; <nl> + OP_REQUIRES_OK ( context , <nl> + context - > allocate_temp ( DT_UINT8 , temp_shape , & temp_tensor ) ) ; <nl> + void * buffer = temp_tensor . flat < std : : uint8_t > ( ) . data ( ) ; <nl> + OP_REQUIRES_OK ( context , cusparse_solver - > Gtsv2StridedBatch ( <nl> + matrix_size , subdiag , diag , superdiag , x , <nl> + batch_size , matrix_size , buffer ) ) ; <nl> + # endif / / CUDA_VERSION < 9000 <nl> } <nl> <nl> void TransposeLhsForGtsvBatched ( OpKernelContext * context , const Tensor & lhs , <nl> | Replace deprecated gtsv routines with gtsv2 | tensorflow/tensorflow | bfad469d236f923f9e40f3c76dbb718d24984292 | 2019-07-02T11:43:05Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.